(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."
: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.
;; 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"
(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)