Function: nntp-open-via-telnet-and-telnet

nntp-open-via-telnet-and-telnet is a byte-compiled function defined in nntp.el.gz.

Signature

(nntp-open-via-telnet-and-telnet BUFFER)

Documentation

Open a connection to an nntp server through an intermediate host.

First telnet the remote host, and then telnet the real news server from there.

Please refer to the following variables to customize the connection:
- nntp-pre-command,
- nntp-via-telnet-command,
- nntp-via-telnet-switches,
- nntp-via-address,
- nntp-via-envuser,
- nntp-via-user-name,
- nntp-via-user-password,
- nntp-via-shell-prompt,
- nntp-telnet-command,
- nntp-telnet-switches,
- nntp-address,
- nntp-port-number,
- nntp-end-of-line.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nntp.el.gz
(defun nntp-open-via-telnet-and-telnet (buffer)
  "Open a connection to an nntp server through an intermediate host.
First telnet the remote host, and then telnet the real news server
from there.

Please refer to the following variables to customize the connection:
- `nntp-pre-command',
- `nntp-via-telnet-command',
- `nntp-via-telnet-switches',
- `nntp-via-address',
- `nntp-via-envuser',
- `nntp-via-user-name',
- `nntp-via-user-password',
- `nntp-via-shell-prompt',
- `nntp-telnet-command',
- `nntp-telnet-switches',
- `nntp-address',
- `nntp-port-number',
- `nntp-end-of-line'."
  (with-current-buffer buffer
    (erase-buffer)
    (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches))
	  (case-fold-search t)
	  proc)
      (and nntp-pre-command (push nntp-pre-command command))
      (setq proc (apply #'start-process "nntpd" buffer command))
      (when (memq (process-status proc) '(open run))
	(nntp-wait-for-string "^r?telnet")
	(process-send-string proc "set escape \^X\n")
	(cond
	 ((and nntp-via-envuser nntp-via-user-name)
	  (process-send-string proc (concat "open " "-l" nntp-via-user-name
					    nntp-via-address "\n")))
	 (t
	  (process-send-string proc (concat "open " nntp-via-address
					    "\n"))))
	(when (not nntp-via-envuser)
	  (nntp-wait-for-string "^\r*.?login:")
	  (process-send-string proc
			       (concat
				(or nntp-via-user-name
				    (setq nntp-via-user-name
					  (read-string "login: ")))
				"\n")))
	(nntp-wait-for-string "^\r*.?password:")
	(process-send-string proc
			     (concat
			      (or nntp-via-user-password
				  (setq nntp-via-user-password
					(read-passwd "Password: ")))
			      "\n"))
	(nntp-wait-for-string nntp-via-shell-prompt)
	(let ((real-telnet-command `("exec"
				     ,nntp-telnet-command
				     ,@nntp-telnet-switches
				     ,nntp-address
				     ,(nntp-service-to-port nntp-port-number))))
	  (process-send-string proc
			       (concat (mapconcat #'identity
						  real-telnet-command " ")
				       "\n")))
	(nntp-wait-for-string "^\r*20[01]")
	(beginning-of-line)
	(delete-region (point-min) (point))
	(process-send-string proc "\^]")
	(nntp-wait-for-string "^r?telnet")
	(process-send-string proc "mode character\n")
	(accept-process-output proc 1)
	(sit-for 1)
	(goto-char (point-min))
	(forward-line 1)
	(delete-region (point) (point-max)))
      proc)))