* liece.el (liece-open-server-internal): Use
authorueno <ueno>
Wed, 16 Aug 2000 02:17:01 +0000 (02:17 +0000)
committerueno <ueno>
Wed, 16 Aug 2000 02:17:01 +0000 (02:17 +0000)
`liece-open-network-stream'; bind liece-tcp-connection-type.

* liece-tcp.el (liece-tcp-open-program-stream-as-binary): Abolish.
(liece-tcp-open-ssl-stream-as-binary): Abolish.
(liece-tcp-open-rlogin-stream-as-binary): Abolish.
(liece-tcp-wait-for-string): Abolish.
(liece-tcp-stream-alist): New variable.
(liece-open-network-stream): Abolish 5th argument `type'.

lisp/ChangeLog
lisp/liece-tcp.el
lisp/liece.el

index 406c01c..c5d6ae5 100644 (file)
@@ -1,3 +1,15 @@
+2000-08-16   Daiki Ueno  <ueno@unixuser.org>
+
+       * liece.el (liece-open-server-internal): Use
+       `liece-open-network-stream'; bind liece-tcp-connection-type.
+
+       * liece-tcp.el (liece-tcp-open-program-stream-as-binary): Abolish.
+       (liece-tcp-open-ssl-stream-as-binary): Abolish.
+       (liece-tcp-open-rlogin-stream-as-binary): Abolish.
+       (liece-tcp-wait-for-string): Abolish.
+       (liece-tcp-stream-alist): New variable.
+       (liece-open-network-stream): Abolish 5th argument `type'.
+
 2000-08-01  Yoshiki Hayashi  <yoshiki@xemacs.org>
 
        * liece-xemacs.el (liece-toolbar-position): Use
index 208814d..837c903 100644 (file)
          (const :tag "rlogin" rlogin))
   :group 'liece-tcp)
 
-(autoload 'open-ssl-stream "ssl")
-(defvar ssl-program-arguments)
+(defvar liece-tcp-connection-type liece-tcp-default-connection-type)
+
+(eval-and-compile
+  (autoload 'open-ssl-stream "ssl")
+  (defvar ssl-program-arguments))
 
 (defcustom liece-tcp-ssl-protocol-version "3"
   "SSL protocol version."
@@ -103,42 +106,22 @@ The default is \"rsh\", but \"ssh\" is a popular alternative."
   :type 'string
   :group 'liece-tcp)
 
-\f
-;;;###liece-autoload
-(defun liece-open-network-stream-as-binary
-  (name buffer host service &optional type)
-  (let* ((type (or type liece-tcp-default-connection-type))
-        (method
-         (cond ((eq type 'network)
-                'open-network-stream-as-binary)
-               ((eq type 'program)
-                'liece-tcp-open-program-stream-as-binary)
-               ((eq type 'ssl)
-                'liece-tcp-open-ssl-stream-as-binary)
-               ((eq type 'rlogin)
-                'liece-tcp-open-rlogin-stream-as-binary))))
-    (funcall method name buffer host service)))
+(defvar liece-tcp-stream-alist
+  '((network open-network-stream)
+    (program liece-tcp-open-program-stream)
+    (ssl liece-tcp-open-ssl-stream)
+    (rlogin liece-tcp-open-rlogin-stream)))
 
+\f
 ;;;###liece-autoload
-(defun liece-open-network-stream
-  (name buffer host service &optional type)
-  (let* ((type (or type liece-tcp-default-connection-type))
-        (method
-         (cond ((eq type 'network)
-                'open-network-stream)
-               ((eq type 'program)
-                'liece-tcp-open-program-stream)
-               ((eq type 'ssl)
-                'liece-tcp-open-ssl-stream)
-               ((eq type 'rlogin)
-                'liece-tcp-open-rlogin-stream-as-binary))))
+(defun liece-open-network-stream (name buffer host service)
+  (let ((method
+        (nth 1 (assq liece-tcp-connection-type
+                     liece-tcp-stream-alist))))
+    (or method
+       (error "Invalid stream"))
     (funcall method name buffer host service)))
 
-(defun liece-tcp-open-program-stream-as-binary (name buffer host service)
-  (as-binary-process
-   (liece-tcp-open-program-stream
-    name buffer host service)))
-
 (defun liece-tcp-open-program-stream (name buffer host service)
   "Open a TCP connection for a service to a host.
 Returns a subprocess-object to represent the connection.
@@ -163,11 +146,6 @@ Fourth arg SERVICE is name of the service desired, or an integer
     ;; Return process
     proc))
 
-(defun liece-tcp-open-ssl-stream-as-binary (name buffer server service)
-  (as-binary-process
-   (liece-tcp-open-ssl-stream
-    name buffer server service)))
-
 (defun liece-tcp-open-ssl-stream-1 (name buffer server service extra-arg)
   (let* ((service (or service liece-tcp-ssl-default-service))
          (ssl-program-arguments (list extra-arg "-connect"
@@ -185,34 +163,18 @@ Fourth arg SERVICE is name of the service desired, or an integer
        (liece-tcp-open-ssl-stream-1
         name buffer server service "-ssl2"))))
 
-(defun liece-tcp-wait-for-string (proc regexp)
-  "Wait until string arrives in the buffer."
-  (let ((buffer (current-buffer)))
-    (goto-char (point-min))
-    (while (not (re-search-forward regexp nil t))
-      (accept-process-output proc)
-      (set-buffer buffer)
-      (goto-char (point-min)))))
-
 (defun liece-tcp-open-rlogin-stream (name buffer server service)
   "Open a connection to SERVER using rsh."
   (let* ((service (if (stringp service)
                      service
                    (int-to-string service)))
-        (args `(,name
-                ,buffer
-                ,liece-tcp-rlogin-program
+        (args `(,liece-tcp-rlogin-program
                 ,@(if liece-tcp-rlogin-user-name
                       (list "-l" liece-tcp-rlogin-user-name))
                 ,liece-tcp-relay-host
                 ,@liece-tcp-rlogin-parameters ,server ,service))
         (process-connection-type nil))
-    (apply #'start-process-shell-command args)))
-
-(defun liece-tcp-open-rlogin-stream-as-binary (name buffer server service)
-  "Open a connection to SERVER using rsh."
-  (as-binary-process
-   (liece-tcp-open-rlogin-stream name buffer server service)))
+    (apply #'start-process-shell-command name buffer args)))
 
 (provide 'liece-tcp)
 
index c530797..8b7b2a7 100644 (file)
@@ -529,9 +529,11 @@ Optional argument TYPE specifies connection types such as `program'."
        (erase-buffer)
        (cond
         ((string-match "^[^\\[]" host)
-         (setq liece-server-process
-               (liece-open-network-stream-as-binary
-                "IRC" (current-buffer) host (or service "irc") type)))
+         (let ((liece-tcp-connection-type type))
+           (as-binary-process
+            (setq liece-server-process
+                  (liece-open-network-stream
+                   "IRC" (current-buffer) host (or service "irc"))))))
         ((not
           (or
            (string-match