Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
[emacs.git] / lisp / gnus / nntp.el
blobca63fa597efd2eb70c7b4eeabcbb0d9a5af79341
1 ;;; nntp.el --- nntp access for Gnus
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993,
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
5 ;; 2003, 2004, 2005 Free Software Foundation, Inc.
7 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published
14 ;; by the Free Software Foundation; either version 2, or (at your
15 ;; option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
25 ;; MA 02110-1301, USA.
27 ;;; Commentary:
29 ;;; Code:
31 (require 'nnheader)
32 (require 'nnoo)
33 (require 'gnus-util)
35 (nnoo-declare nntp)
37 (eval-when-compile (require 'cl))
39 (defgroup nntp nil
40 "NNTP access for Gnus."
41 :group 'gnus)
43 (defvoo nntp-address nil
44 "Address of the physical nntp server.")
46 (defvoo nntp-port-number "nntp"
47 "Port number on the physical nntp server.")
49 (defvoo nntp-server-opened-hook '(nntp-send-mode-reader)
50 "*Hook used for sending commands to the server at startup.
51 The default value is `nntp-send-mode-reader', which makes an innd
52 server spawn an nnrpd server.")
54 (defvoo nntp-authinfo-function 'nntp-send-authinfo
55 "Function used to send AUTHINFO to the server.
56 It is called with no parameters.")
58 (defvoo nntp-server-action-alist
59 '(("nntpd 1\\.5\\.11t"
60 (remove-hook 'nntp-server-opened-hook 'nntp-send-mode-reader))
61 ("NNRP server Netscape"
62 (setq nntp-server-list-active-group nil)))
63 "Alist of regexps to match on server types and actions to be taken.
64 For instance, if you want Gnus to beep every time you connect
65 to innd, you could say something like:
67 \(setq nntp-server-action-alist
68 '((\"innd\" (ding))))
70 You probably don't want to do that, though.")
72 (defvoo nntp-open-connection-function 'nntp-open-network-stream
73 "*Function used for connecting to a remote system.
74 It will be called with the buffer to output in as argument.
76 Currently, five such functions are provided (please refer to their
77 respective doc string for more information), three of them establishing
78 direct connections to the nntp server, and two of them using an indirect
79 host.
81 Direct connections:
82 - `nntp-open-network-stream' (the default),
83 - `nntp-open-ssl-stream',
84 - `nntp-open-tls-stream',
85 - `nntp-open-telnet-stream'.
87 Indirect connections:
88 - `nntp-open-via-rlogin-and-telnet',
89 - `nntp-open-via-telnet-and-telnet'.")
91 (defvoo nntp-pre-command nil
92 "*Pre-command to use with the various nntp-open-via-* methods.
93 This is where you would put \"runsocks\" or stuff like that.")
95 (defvoo nntp-telnet-command "telnet"
96 "*Telnet command used to connect to the nntp server.
97 This command is used by the various nntp-open-via-* methods.")
99 (defvoo nntp-telnet-switches '("-8")
100 "*Switches given to the telnet command `nntp-telnet-command'.")
102 (defvoo nntp-end-of-line "\r\n"
103 "*String to use on the end of lines when talking to the NNTP server.
104 This is \"\\r\\n\" by default, but should be \"\\n\" when
105 using an indirect connection method (nntp-open-via-*).")
107 (defvoo nntp-via-rlogin-command "rsh"
108 "*Rlogin command used to connect to an intermediate host.
109 This command is used by the `nntp-open-via-rlogin-and-telnet' method.
110 The default is \"rsh\", but \"ssh\" is a popular alternative.")
112 (defvoo nntp-via-rlogin-command-switches nil
113 "*Switches given to the rlogin command `nntp-via-rlogin-command'.
114 If you use \"ssh\" for `nntp-via-rlogin-command', you may set this to
115 \(\"-C\") in order to compress all data connections, otherwise set this
116 to \(\"-t\" \"-e\" \"none\") or (\"-C\" \"-t\" \"-e\" \"none\") if the telnet
117 command requires a pseudo-tty allocation on an intermediate host.")
119 (defvoo nntp-via-telnet-command "telnet"
120 "*Telnet command used to connect to an intermediate host.
121 This command is used by the `nntp-open-via-telnet-and-telnet' method.")
123 (defvoo nntp-via-telnet-switches '("-8")
124 "*Switches given to the telnet command `nntp-via-telnet-command'.")
126 (defvoo nntp-via-user-name nil
127 "*User name to log in on an intermediate host with.
128 This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
130 (defvoo nntp-via-user-password nil
131 "*Password to use to log in on an intermediate host with.
132 This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
134 (defvoo nntp-via-address nil
135 "*Address of an intermediate host to connect to.
136 This variable is used by the `nntp-open-via-rlogin-and-telnet' and
137 `nntp-open-via-telnet-and-telnet' methods.")
139 (defvoo nntp-via-envuser nil
140 "*Whether both telnet client and server support the ENVIRON option.
141 If non-nil, there will be no prompt for a login name.")
143 (defvoo nntp-via-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
144 "*Regular expression to match the shell prompt on an intermediate host.
145 This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
147 (defvoo nntp-large-newsgroup 50
148 "*The number of articles which indicates a large newsgroup.
149 If the number of articles is greater than the value, verbose
150 messages will be shown to indicate the current status.")
152 (defvoo nntp-maximum-request 400
153 "*The maximum number of the requests sent to the NNTP server at one time.
154 If Emacs hangs up while retrieving headers, set the variable to a
155 lower value.")
157 (defvoo nntp-nov-is-evil nil
158 "*If non-nil, nntp will never attempt to use XOVER when talking to the server.")
160 (defvoo nntp-xover-commands '("XOVER" "XOVERVIEW")
161 "*List of strings that are used as commands to fetch NOV lines from a server.
162 The strings are tried in turn until a positive response is gotten. If
163 none of the commands are successful, nntp will just grab headers one
164 by one.")
166 (defvoo nntp-nov-gap 5
167 "*Maximum allowed gap between two articles.
168 If the gap between two consecutive articles is bigger than this
169 variable, split the XOVER request into two requests.")
171 (defvoo nntp-prepare-server-hook nil
172 "*Hook run before a server is opened.
173 If can be used to set up a server remotely, for instance. Say you
174 have an account at the machine \"other.machine\". This machine has
175 access to an NNTP server that you can't access locally. You could
176 then use this hook to rsh to the remote machine and start a proxy NNTP
177 server there that you can connect to. See also
178 `nntp-open-connection-function'")
180 (defvoo nntp-coding-system-for-read 'binary
181 "*Coding system to read from NNTP.")
183 (defvoo nntp-coding-system-for-write 'binary
184 "*Coding system to write to NNTP.")
186 (defcustom nntp-authinfo-file "~/.authinfo"
187 ".netrc-like file that holds nntp authinfo passwords."
188 :group 'nntp
189 :type
190 '(choice file
191 (repeat :tag "Entries"
192 :menu-tag "Inline"
193 (list :format "%v"
194 :value ("" ("login" . "") ("password" . ""))
195 (string :tag "Host")
196 (checklist :inline t
197 (cons :format "%v"
198 (const :format "" "login")
199 (string :format "Login: %v"))
200 (cons :format "%v"
201 (const :format "" "password")
202 (string :format "Password: %v")))))))
206 (defvoo nntp-connection-timeout nil
207 "*Number of seconds to wait before an nntp connection times out.
208 If this variable is nil, which is the default, no timers are set.
209 NOTE: This variable is never seen to work in Emacs 20 and XEmacs 21.")
211 (defvoo nntp-prepare-post-hook nil
212 "*Hook run just before posting an article. It is supposed to be used
213 to insert Cancel-Lock headers.")
215 ;;; Internal variables.
217 (defvar nntp-record-commands nil
218 "*If non-nil, nntp will record all commands in the \"*nntp-log*\" buffer.")
220 (defvar nntp-have-messaged nil)
222 (defvar nntp-process-wait-for nil)
223 (defvar nntp-process-to-buffer nil)
224 (defvar nntp-process-callback nil)
225 (defvar nntp-process-decode nil)
226 (defvar nntp-process-start-point nil)
227 (defvar nntp-inside-change-function nil)
228 (defvoo nntp-last-command-time nil)
229 (defvoo nntp-last-command nil)
230 (defvoo nntp-authinfo-password nil)
231 (defvoo nntp-authinfo-user nil)
233 (defvar nntp-connection-list nil)
235 (defvoo nntp-server-type nil)
236 (defvoo nntp-connection-alist nil)
237 (defvoo nntp-status-string "")
238 (defconst nntp-version "nntp 5.0")
239 (defvoo nntp-inhibit-erase nil)
240 (defvoo nntp-inhibit-output nil)
242 (defvoo nntp-server-xover 'try)
243 (defvoo nntp-server-list-active-group 'try)
245 (defvar nntp-async-needs-kluge
246 (string-match "^GNU Emacs 20\\.3\\." (emacs-version))
247 "*When non-nil, nntp will poll asynchronous connections
248 once a second. By default, this is turned on only for Emacs
249 20.3, which has a bug that breaks nntp's normal method of
250 noticing asynchronous data.")
252 (defvar nntp-async-timer nil)
253 (defvar nntp-async-process-list nil)
255 (defvar nntp-ssl-program
256 "openssl s_client -quiet -ssl3 -connect %s:%p"
257 "A string containing commands for SSL connections.
258 Within a string, %s is replaced with the server address and %p with
259 port number on server. The program should accept IMAP commands on
260 stdin and return responses to stdout.")
262 (defvar nntp-authinfo-rejected nil
263 "A custom error condition used to report 'Authentication Rejected' errors.
264 Condition handlers that match just this condition ensure that the nntp
265 backend doesn't catch this error.")
266 (put 'nntp-authinfo-rejected 'error-conditions '(error nntp-authinfo-rejected))
267 (put 'nntp-authinfo-rejected 'error-message "Authorization Rejected")
271 ;;; Internal functions.
273 (defsubst nntp-send-string (process string)
274 "Send STRING to PROCESS."
275 ;; We need to store the time to provide timeouts, and
276 ;; to store the command so the we can replay the command
277 ;; if the server gives us an AUTHINFO challenge.
278 (setq nntp-last-command-time (current-time)
279 nntp-last-command string)
280 (when nntp-record-commands
281 (nntp-record-command string))
282 (process-send-string process (concat string nntp-end-of-line))
283 (or (memq (process-status process) '(open run))
284 (nntp-report "Server closed connection")))
286 (defun nntp-record-command (string)
287 "Record the command STRING."
288 (save-excursion
289 (set-buffer (get-buffer-create "*nntp-log*"))
290 (goto-char (point-max))
291 (let ((time (current-time)))
292 (insert (format-time-string "%Y%m%dT%H%M%S" time)
293 "." (format "%03d" (/ (nth 2 time) 1000))
294 " " nntp-address " " string "\n"))))
296 (defun nntp-report (&rest args)
297 "Report an error from the nntp backend. The first string in ARGS
298 can be a format string. For some commands, the failed command may be
299 retried once before actually displaying the error report."
301 (when nntp-record-commands
302 (nntp-record-command "*** CALLED nntp-report ***"))
304 (nnheader-report 'nntp args)
306 (apply 'error args))
308 (defun nntp-report-1 (&rest args)
309 "Throws out to nntp-with-open-group-error so that the connection may
310 be restored and the command retried."
312 (when nntp-record-commands
313 (nntp-record-command "*** CONNECTION LOST ***"))
315 (throw 'nntp-with-open-group-error t))
317 (defsubst nntp-wait-for (process wait-for buffer &optional decode discard)
318 "Wait for WAIT-FOR to arrive from PROCESS."
319 (save-excursion
320 (set-buffer (process-buffer process))
321 (goto-char (point-min))
322 (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5)))
323 (looking-at "48[02]"))
324 (memq (process-status process) '(open run)))
325 (cond ((looking-at "480")
326 (nntp-handle-authinfo process))
327 ((looking-at "482")
328 (nnheader-report 'nntp (get 'nntp-authinfo-rejected 'error-message))
329 (signal 'nntp-authinfo-rejected nil))
330 ((looking-at "^.*\n")
331 (delete-region (point) (progn (forward-line 1) (point)))))
332 (nntp-accept-process-output process)
333 (goto-char (point-min)))
334 (prog1
335 (cond
336 ((looking-at "[45]")
337 (progn
338 (nntp-snarf-error-message)
339 nil))
340 ((not (memq (process-status process) '(open run)))
341 (nntp-report "Server closed connection"))
343 (goto-char (point-max))
344 (let ((limit (point-min))
345 response)
346 (while (not (re-search-backward wait-for limit t))
347 (nntp-accept-process-output process)
348 ;; We assume that whatever we wait for is less than 1000
349 ;; characters long.
350 (setq limit (max (- (point-max) 1000) (point-min)))
351 (goto-char (point-max)))
352 (setq response (match-string 0))
353 (with-current-buffer nntp-server-buffer
354 (setq nntp-process-response response)))
355 (nntp-decode-text (not decode))
356 (unless discard
357 (save-excursion
358 (set-buffer buffer)
359 (goto-char (point-max))
360 (insert-buffer-substring (process-buffer process))
361 ;; Nix out "nntp reading...." message.
362 (when nntp-have-messaged
363 (setq nntp-have-messaged nil)
364 (nnheader-message 5 ""))))
366 (unless discard
367 (erase-buffer)))))
369 (defun nntp-kill-buffer (buffer)
370 (when (buffer-name buffer)
371 (kill-buffer buffer)
372 (nnheader-init-server-buffer)))
374 (defsubst nntp-find-connection (buffer)
375 "Find the connection delivering to BUFFER."
376 (let ((alist nntp-connection-alist)
377 (buffer (if (stringp buffer) (get-buffer buffer) buffer))
378 process entry)
379 (while (and alist (setq entry (pop alist)))
380 (when (eq buffer (cadr entry))
381 (setq process (car entry)
382 alist nil)))
383 (when process
384 (if (memq (process-status process) '(open run))
385 process
386 (nntp-kill-buffer (process-buffer process))
387 (setq nntp-connection-alist (delq entry nntp-connection-alist))
388 nil))))
390 (defsubst nntp-find-connection-entry (buffer)
391 "Return the entry for the connection to BUFFER."
392 (assq (nntp-find-connection buffer) nntp-connection-alist))
394 (defun nntp-find-connection-buffer (buffer)
395 "Return the process connection buffer tied to BUFFER."
396 (let ((process (nntp-find-connection buffer)))
397 (when process
398 (process-buffer process))))
400 (defsubst nntp-retrieve-data (command address port buffer
401 &optional wait-for callback decode)
402 "Use COMMAND to retrieve data into BUFFER from PORT on ADDRESS."
403 (let ((process (or (nntp-find-connection buffer)
404 (nntp-open-connection buffer))))
405 (if process
406 (progn
407 (unless (or nntp-inhibit-erase nnheader-callback-function)
408 (save-excursion
409 (set-buffer (process-buffer process))
410 (erase-buffer)))
411 (condition-case err
412 (progn
413 (when command
414 (nntp-send-string process command))
415 (cond
416 ((eq callback 'ignore)
418 ((and callback wait-for)
419 (nntp-async-wait process wait-for buffer decode callback)
421 (wait-for
422 (nntp-wait-for process wait-for buffer decode))
423 (t t)))
424 (nntp-authinfo-rejected
425 (signal 'nntp-authinfo-rejected (cdr err)))
426 (error
427 (nnheader-report 'nntp "Couldn't open connection to %s: %s"
428 address err))
429 (quit
430 (message "Quit retrieving data from nntp")
431 (signal 'quit nil)
432 nil)))
433 (nnheader-report 'nntp "Couldn't open connection to %s" address))))
435 (defsubst nntp-send-command (wait-for &rest strings)
436 "Send STRINGS to server and wait until WAIT-FOR returns."
437 (when (and (not nnheader-callback-function)
438 (not nntp-inhibit-output))
439 (save-excursion
440 (set-buffer nntp-server-buffer)
441 (erase-buffer)))
442 (let* ((command (mapconcat 'identity strings " "))
443 (process (nntp-find-connection nntp-server-buffer))
444 (buffer (and process (process-buffer process)))
445 (pos (and buffer (with-current-buffer buffer (point)))))
446 (if process
447 (prog1
448 (nntp-retrieve-data command
449 nntp-address nntp-port-number
450 nntp-server-buffer
451 wait-for nnheader-callback-function)
452 ;; If nothing to wait for, still remove possibly echo'ed commands.
453 ;; We don't have echos if nntp-open-connection-function
454 ;; is `nntp-open-network-stream', so we skip this in that case.
455 (unless (or wait-for
456 (equal nntp-open-connection-function
457 'nntp-open-network-stream))
458 (nntp-accept-response)
459 (save-excursion
460 (set-buffer buffer)
461 (goto-char pos)
462 (if (looking-at (regexp-quote command))
463 (delete-region pos (progn (forward-line 1)
464 (gnus-point-at-bol))))
466 (nnheader-report 'nntp "Couldn't open connection to %s."
467 nntp-address))))
469 (defun nntp-send-command-nodelete (wait-for &rest strings)
470 "Send STRINGS to server and wait until WAIT-FOR returns."
471 (let* ((command (mapconcat 'identity strings " "))
472 (process (nntp-find-connection nntp-server-buffer))
473 (buffer (and process (process-buffer process)))
474 (pos (and buffer (with-current-buffer buffer (point)))))
475 (if process
476 (prog1
477 (nntp-retrieve-data command
478 nntp-address nntp-port-number
479 nntp-server-buffer
480 wait-for nnheader-callback-function)
481 ;; If nothing to wait for, still remove possibly echo'ed commands
482 (unless wait-for
483 (nntp-accept-response)
484 (save-excursion
485 (set-buffer buffer)
486 (goto-char pos)
487 (if (looking-at (regexp-quote command))
488 (delete-region pos (progn (forward-line 1)
489 (gnus-point-at-bol)))))))
490 (nnheader-report 'nntp "Couldn't open connection to %s."
491 nntp-address))))
493 (defun nntp-send-command-and-decode (wait-for &rest strings)
494 "Send STRINGS to server and wait until WAIT-FOR returns."
495 (when (and (not nnheader-callback-function)
496 (not nntp-inhibit-output))
497 (save-excursion
498 (set-buffer nntp-server-buffer)
499 (erase-buffer)))
500 (let* ((command (mapconcat 'identity strings " "))
501 (process (nntp-find-connection nntp-server-buffer))
502 (buffer (and process (process-buffer process)))
503 (pos (and buffer (with-current-buffer buffer (point)))))
504 (if process
505 (prog1
506 (nntp-retrieve-data command
507 nntp-address nntp-port-number
508 nntp-server-buffer
509 wait-for nnheader-callback-function t)
510 ;; If nothing to wait for, still remove possibly echo'ed commands
511 (unless wait-for
512 (nntp-accept-response)
513 (save-excursion
514 (set-buffer buffer)
515 (goto-char pos)
516 (if (looking-at (regexp-quote command))
517 (delete-region pos (progn (forward-line 1) (gnus-point-at-bol))))
519 (nnheader-report 'nntp "Couldn't open connection to %s."
520 nntp-address))))
523 (defun nntp-send-buffer (wait-for)
524 "Send the current buffer to server and wait until WAIT-FOR returns."
525 (when (and (not nnheader-callback-function)
526 (not nntp-inhibit-output))
527 (save-excursion
528 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
529 (erase-buffer)))
530 (nntp-encode-text)
531 (mm-with-unibyte-current-buffer
532 ;; Some encoded unicode text contains character 0x80-0x9f e.g. Euro.
533 (process-send-region (nntp-find-connection nntp-server-buffer)
534 (point-min) (point-max)))
535 (nntp-retrieve-data
536 nil nntp-address nntp-port-number nntp-server-buffer
537 wait-for nnheader-callback-function))
541 ;;; Interface functions.
543 (nnoo-define-basics nntp)
545 (defsubst nntp-next-result-arrived-p ()
546 (cond
547 ;; A result that starts with a 2xx code is terminated by
548 ;; a line with only a "." on it.
549 ((eq (char-after) ?2)
550 (if (re-search-forward "\n\\.\r?\n" nil t)
552 nil))
553 ;; A result that starts with a 3xx or 4xx code is terminated
554 ;; by a newline.
555 ((looking-at "[34]")
556 (if (search-forward "\n" nil t)
558 nil))
559 ;; No result here.
561 nil)))
563 (eval-when-compile
564 (defvar nntp-with-open-group-internal nil)
565 (defvar nntp-report-n nil))
567 (defmacro nntp-with-open-group (group server &optional connectionless &rest forms)
568 "Protect against servers that don't like clients that keep idle connections opens.
569 The problem being that these servers may either close a connection or
570 simply ignore any further requests on a connection. Closed
571 connections are not detected until accept-process-output has updated
572 the process-status. Dropped connections are not detected until the
573 connection timeouts (which may be several minutes) or
574 nntp-connection-timeout has expired. When these occur
575 nntp-with-open-group, opens a new connection then re-issues the NNTP
576 command whose response triggered the error."
577 (when (and (listp connectionless)
578 (not (eq connectionless nil)))
579 (setq forms (cons connectionless forms)
580 connectionless nil))
581 `(letf ((nntp-report-n (symbol-function 'nntp-report))
582 ((symbol-function 'nntp-report) (symbol-function 'nntp-report-1))
583 (nntp-with-open-group-internal nil))
584 (while (catch 'nntp-with-open-group-error
585 ;; Open the connection to the server
586 ;; NOTE: Existing connections are NOT tested.
587 (nntp-possibly-change-group ,group ,server ,connectionless)
589 (let ((timer
590 (and nntp-connection-timeout
591 (nnheader-run-at-time
592 nntp-connection-timeout nil
593 '(lambda ()
594 (let ((process (nntp-find-connection
595 nntp-server-buffer))
596 (buffer (and process
597 (process-buffer process))))
598 ;; When I an able to identify the
599 ;; connection to the server AND I've
600 ;; received NO reponse for
601 ;; nntp-connection-timeout seconds.
602 (when (and buffer (eq 0 (buffer-size buffer)))
603 ;; Close the connection. Take no
604 ;; other action as the accept input
605 ;; code will handle the closed
606 ;; connection.
607 (nntp-kill-buffer buffer))))))))
608 (unwind-protect
609 (setq nntp-with-open-group-internal
610 (condition-case nil
611 (progn ,@forms)
612 (quit
613 (nntp-close-server)
614 (signal 'quit nil))))
615 (when timer
616 (nnheader-cancel-timer timer)))
617 nil))
618 (setf (symbol-function 'nntp-report) nntp-report-n))
619 nntp-with-open-group-internal))
621 (deffoo nntp-retrieve-headers (articles &optional group server fetch-old)
622 "Retrieve the headers of ARTICLES."
623 (nntp-with-open-group
624 group server
625 (save-excursion
626 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
627 (erase-buffer)
628 (if (and (not gnus-nov-is-evil)
629 (not nntp-nov-is-evil)
630 (nntp-retrieve-headers-with-xover articles fetch-old))
631 ;; We successfully retrieved the headers via XOVER.
632 'nov
633 ;; XOVER didn't work, so we do it the hard, slow and inefficient
634 ;; way.
635 (let ((number (length articles))
636 (articles articles)
637 (count 0)
638 (received 0)
639 (last-point (point-min))
640 (buf (nntp-find-connection-buffer nntp-server-buffer))
641 (nntp-inhibit-erase t)
642 article)
643 ;; Send HEAD commands.
644 (while (setq article (pop articles))
645 (nntp-send-command
647 "HEAD" (if (numberp article)
648 (int-to-string article)
649 ;; `articles' is either a list of article numbers
650 ;; or a list of article IDs.
651 article))
652 (incf count)
653 ;; Every 400 requests we have to read the stream in
654 ;; order to avoid deadlocks.
655 (when (or (null articles) ;All requests have been sent.
656 (zerop (% count nntp-maximum-request)))
657 (nntp-accept-response)
658 (while (progn
659 (set-buffer buf)
660 (goto-char last-point)
661 ;; Count replies.
662 (while (nntp-next-result-arrived-p)
663 (setq last-point (point))
664 (incf received))
665 (< received count))
666 ;; If number of headers is greater than 100, give
667 ;; informative messages.
668 (and (numberp nntp-large-newsgroup)
669 (> number nntp-large-newsgroup)
670 (zerop (% received 20))
671 (nnheader-message 6 "NNTP: Receiving headers... %d%%"
672 (/ (* received 100) number)))
673 (nntp-accept-response))))
674 (and (numberp nntp-large-newsgroup)
675 (> number nntp-large-newsgroup)
676 (nnheader-message 6 "NNTP: Receiving headers...done"))
678 ;; Now all of replies are received. Fold continuation lines.
679 (nnheader-fold-continuation-lines)
680 ;; Remove all "\r"'s.
681 (nnheader-strip-cr)
682 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
683 'headers)))))
685 (deffoo nntp-retrieve-groups (groups &optional server)
686 "Retrieve group info on GROUPS."
687 (nntp-with-open-group
688 nil server
689 (when (nntp-find-connection-buffer nntp-server-buffer)
690 (catch 'done
691 (save-excursion
692 ;; Erase nntp-server-buffer before nntp-inhibit-erase.
693 (set-buffer nntp-server-buffer)
694 (erase-buffer)
695 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
696 ;; The first time this is run, this variable is `try'. So we
697 ;; try.
698 (when (eq nntp-server-list-active-group 'try)
699 (nntp-try-list-active (car groups)))
700 (erase-buffer)
701 (let ((count 0)
702 (groups groups)
703 (received 0)
704 (last-point (point-min))
705 (nntp-inhibit-erase t)
706 (buf (nntp-find-connection-buffer nntp-server-buffer))
707 (command (if nntp-server-list-active-group
708 "LIST ACTIVE" "GROUP")))
709 (while groups
710 ;; Timeout may have killed the buffer.
711 (unless (gnus-buffer-live-p buf)
712 (nnheader-report 'nntp "Connection to %s is closed." server)
713 (throw 'done nil))
714 ;; Send the command to the server.
715 (nntp-send-command nil command (pop groups))
716 (incf count)
717 ;; Every 400 requests we have to read the stream in
718 ;; order to avoid deadlocks.
719 (when (or (null groups) ;All requests have been sent.
720 (zerop (% count nntp-maximum-request)))
721 (nntp-accept-response)
722 (while (and (gnus-buffer-live-p buf)
723 (progn
724 ;; Search `blue moon' in this file for the
725 ;; reason why set-buffer here.
726 (set-buffer buf)
727 (goto-char last-point)
728 ;; Count replies.
729 (while (re-search-forward "^[0-9]" nil t)
730 (incf received))
731 (setq last-point (point))
732 (< received count)))
733 (nntp-accept-response))))
735 ;; Wait for the reply from the final command.
736 (unless (gnus-buffer-live-p buf)
737 (nnheader-report 'nntp "Connection to %s is closed." server)
738 (throw 'done nil))
739 (set-buffer buf)
740 (goto-char (point-max))
741 (re-search-backward "^[0-9]" nil t)
742 (when (looking-at "^[23]")
743 (while (and (gnus-buffer-live-p buf)
744 (progn
745 (set-buffer buf)
746 (goto-char (point-max))
747 (if (not nntp-server-list-active-group)
748 (not (re-search-backward "\r?\n"
749 (- (point) 3) t))
750 (not (re-search-backward "^\\.\r?\n"
751 (- (point) 4) t)))))
752 (nntp-accept-response)))
754 ;; Now all replies are received. We remove CRs.
755 (unless (gnus-buffer-live-p buf)
756 (nnheader-report 'nntp "Connection to %s is closed." server)
757 (throw 'done nil))
758 (set-buffer buf)
759 (goto-char (point-min))
760 (while (search-forward "\r" nil t)
761 (replace-match "" t t))
763 (if (not nntp-server-list-active-group)
764 (progn
765 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
766 'group)
767 ;; We have read active entries, so we just delete the
768 ;; superfluous gunk.
769 (goto-char (point-min))
770 (while (re-search-forward "^[.2-5]" nil t)
771 (delete-region (match-beginning 0)
772 (progn (forward-line 1) (point))))
773 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
774 'active)))))))
776 (deffoo nntp-retrieve-articles (articles &optional group server)
777 (nntp-with-open-group
778 group server
779 (save-excursion
780 (let ((number (length articles))
781 (articles articles)
782 (count 0)
783 (received 0)
784 (last-point (point-min))
785 (buf (nntp-find-connection-buffer nntp-server-buffer))
786 (nntp-inhibit-erase t)
787 (map (apply 'vector articles))
788 (point 1)
789 article)
790 (set-buffer buf)
791 (erase-buffer)
792 ;; Send ARTICLE command.
793 (while (setq article (pop articles))
794 (nntp-send-command
796 "ARTICLE" (if (numberp article)
797 (int-to-string article)
798 ;; `articles' is either a list of article numbers
799 ;; or a list of article IDs.
800 article))
801 (incf count)
802 ;; Every 400 requests we have to read the stream in
803 ;; order to avoid deadlocks.
804 (when (or (null articles) ;All requests have been sent.
805 (zerop (% count nntp-maximum-request)))
806 (nntp-accept-response)
807 (while (progn
808 (set-buffer buf)
809 (goto-char last-point)
810 ;; Count replies.
811 (while (nntp-next-result-arrived-p)
812 (aset map received (cons (aref map received) (point)))
813 (setq last-point (point))
814 (incf received))
815 (< received count))
816 ;; If number of headers is greater than 100, give
817 ;; informative messages.
818 (and (numberp nntp-large-newsgroup)
819 (> number nntp-large-newsgroup)
820 (zerop (% received 20))
821 (nnheader-message 6 "NNTP: Receiving articles... %d%%"
822 (/ (* received 100) number)))
823 (nntp-accept-response))))
824 (and (numberp nntp-large-newsgroup)
825 (> number nntp-large-newsgroup)
826 (nnheader-message 6 "NNTP: Receiving articles...done"))
828 ;; Now we have all the responses. We go through the results,
829 ;; wash it and copy it over to the server buffer.
830 (set-buffer nntp-server-buffer)
831 (erase-buffer)
832 (setq last-point (point-min))
833 (mapcar
834 (lambda (entry)
835 (narrow-to-region
836 (setq point (goto-char (point-max)))
837 (progn
838 (insert-buffer-substring buf last-point (cdr entry))
839 (point-max)))
840 (setq last-point (cdr entry))
841 (nntp-decode-text)
842 (widen)
843 (cons (car entry) point))
844 map)))))
846 (defun nntp-try-list-active (group)
847 (nntp-list-active-group group)
848 (save-excursion
849 (set-buffer nntp-server-buffer)
850 (goto-char (point-min))
851 (cond ((or (eobp)
852 (looking-at "5[0-9]+"))
853 (setq nntp-server-list-active-group nil))
855 (setq nntp-server-list-active-group t)))))
857 (deffoo nntp-list-active-group (group &optional server)
858 "Return the active info on GROUP (which can be a regexp)."
859 (nntp-with-open-group
860 nil server
861 (nntp-send-command "^\\.*\r?\n" "LIST ACTIVE" group)))
863 (deffoo nntp-request-group-articles (group &optional server)
864 "Return the list of existing articles in GROUP."
865 (nntp-with-open-group
866 nil server
867 (nntp-send-command "^\\.*\r?\n" "LISTGROUP" group)))
869 (deffoo nntp-request-article (article &optional group server buffer command)
870 (nntp-with-open-group
871 group server
872 (when (nntp-send-command-and-decode
873 "\r?\n\\.\r?\n" "ARTICLE"
874 (if (numberp article) (int-to-string article) article))
875 (if (and buffer
876 (not (equal buffer nntp-server-buffer)))
877 (save-excursion
878 (set-buffer nntp-server-buffer)
879 (copy-to-buffer buffer (point-min) (point-max))
880 (nntp-find-group-and-number group))
881 (nntp-find-group-and-number group)))))
883 (deffoo nntp-request-head (article &optional group server)
884 (nntp-with-open-group
885 group server
886 (when (nntp-send-command
887 "\r?\n\\.\r?\n" "HEAD"
888 (if (numberp article) (int-to-string article) article))
889 (prog1
890 (nntp-find-group-and-number group)
891 (nntp-decode-text)))))
893 (deffoo nntp-request-body (article &optional group server)
894 (nntp-with-open-group
895 group server
896 (nntp-send-command-and-decode
897 "\r?\n\\.\r?\n" "BODY"
898 (if (numberp article) (int-to-string article) article))))
900 (deffoo nntp-request-group (group &optional server dont-check)
901 (nntp-with-open-group
902 nil server
903 (when (nntp-send-command "^[245].*\n" "GROUP" group)
904 (let ((entry (nntp-find-connection-entry nntp-server-buffer)))
905 (setcar (cddr entry) group)))))
907 (deffoo nntp-close-group (group &optional server)
910 (deffoo nntp-server-opened (&optional server)
911 "Say whether a connection to SERVER has been opened."
912 (and (nnoo-current-server-p 'nntp server)
913 nntp-server-buffer
914 (gnus-buffer-live-p nntp-server-buffer)
915 (nntp-find-connection nntp-server-buffer)))
917 (deffoo nntp-open-server (server &optional defs connectionless)
918 (nnheader-init-server-buffer)
919 (if (nntp-server-opened server)
921 (when (or (stringp (car defs))
922 (numberp (car defs)))
923 (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs))))
924 (unless (assq 'nntp-address defs)
925 (setq defs (append defs (list (list 'nntp-address server)))))
926 (nnoo-change-server 'nntp server defs)
927 (unless connectionless
928 (or (nntp-find-connection nntp-server-buffer)
929 (nntp-open-connection nntp-server-buffer)))))
931 (deffoo nntp-close-server (&optional server)
932 (nntp-possibly-change-group nil server t)
933 (let ((process (nntp-find-connection nntp-server-buffer)))
934 (while process
935 (when (memq (process-status process) '(open run))
936 (ignore-errors
937 (nntp-send-string process "QUIT")
938 (unless (eq nntp-open-connection-function 'nntp-open-network-stream)
939 ;; Ok, this is evil, but when using telnet and stuff
940 ;; as the connection method, it's important that the
941 ;; QUIT command actually is sent out before we kill
942 ;; the process.
943 (sleep-for 1))))
944 (nntp-kill-buffer (process-buffer process))
945 (setq process (car (pop nntp-connection-alist))))
946 (nnoo-close-server 'nntp)))
948 (deffoo nntp-request-close ()
949 (let (process)
950 (while (setq process (pop nntp-connection-list))
951 (when (memq (process-status process) '(open run))
952 (ignore-errors
953 (nntp-send-string process "QUIT")
954 (unless (eq nntp-open-connection-function 'nntp-open-network-stream)
955 ;; Ok, this is evil, but when using telnet and stuff
956 ;; as the connection method, it's important that the
957 ;; QUIT command actually is sent out before we kill
958 ;; the process.
959 (sleep-for 1))))
960 (nntp-kill-buffer (process-buffer process)))))
962 (deffoo nntp-request-list (&optional server)
963 (nntp-with-open-group
964 nil server
965 (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST")))
967 (deffoo nntp-request-list-newsgroups (&optional server)
968 (nntp-with-open-group
969 nil server
970 (nntp-send-command "\r?\n\\.\r?\n" "LIST NEWSGROUPS")))
972 (deffoo nntp-request-newgroups (date &optional server)
973 (nntp-with-open-group
974 nil server
975 (save-excursion
976 (set-buffer nntp-server-buffer)
977 (let* ((time (date-to-time date))
978 (ls (- (cadr time) (nth 8 (decode-time time)))))
979 (cond ((< ls 0)
980 (setcar time (1- (car time)))
981 (setcar (cdr time) (+ ls 65536)))
982 ((>= ls 65536)
983 (setcar time (1+ (car time)))
984 (setcar (cdr time) (- ls 65536)))
986 (setcar (cdr time) ls)))
987 (prog1
988 (nntp-send-command
989 "^\\.\r?\n" "NEWGROUPS"
990 (format-time-string "%y%m%d %H%M%S" time)
991 "GMT")
992 (nntp-decode-text))))))
994 (deffoo nntp-request-post (&optional server)
995 (nntp-with-open-group
996 nil server
997 (when (nntp-send-command "^[23].*\r?\n" "POST")
998 (let ((response (with-current-buffer nntp-server-buffer
999 nntp-process-response))
1000 server-id)
1001 (when (and response
1002 (string-match "^[23].*\\(<[^\t\n @<>]+@[^\t\n @<>]+>\\)"
1003 response))
1004 (setq server-id (match-string 1 response))
1005 (narrow-to-region (goto-char (point-min))
1006 (if (search-forward "\n\n" nil t)
1007 (1- (point))
1008 (point-max)))
1009 (unless (mail-fetch-field "Message-ID")
1010 (goto-char (point-min))
1011 (insert "Message-ID: " server-id "\n"))
1012 (widen))
1013 (run-hooks 'nntp-prepare-post-hook)
1014 (nntp-send-buffer "^[23].*\n")))))
1016 (deffoo nntp-request-type (group article)
1017 'news)
1019 (deffoo nntp-asynchronous-p ()
1022 ;;; Hooky functions.
1024 (defun nntp-send-mode-reader ()
1025 "Send the MODE READER command to the nntp server.
1026 This function is supposed to be called from `nntp-server-opened-hook'.
1027 It will make innd servers spawn an nnrpd process to allow actual article
1028 reading."
1029 (nntp-send-command "^.*\n" "MODE READER"))
1031 (defun nntp-send-authinfo (&optional send-if-force)
1032 "Send the AUTHINFO to the nntp server.
1033 It will look in the \"~/.authinfo\" file for matching entries. If
1034 nothing suitable is found there, it will prompt for a user name
1035 and a password.
1037 If SEND-IF-FORCE, only send authinfo to the server if the
1038 .authinfo file has the FORCE token."
1039 (let* ((list (gnus-parse-netrc nntp-authinfo-file))
1040 (alist (gnus-netrc-machine list nntp-address "nntp"))
1041 (force (gnus-netrc-get alist "force"))
1042 (user (or (gnus-netrc-get alist "login") nntp-authinfo-user))
1043 (passwd (gnus-netrc-get alist "password")))
1044 (when (or (not send-if-force)
1045 force)
1046 (unless user
1047 (setq user (read-string (format "NNTP (%s) user name: " nntp-address))
1048 nntp-authinfo-user user))
1049 (unless (member user '(nil ""))
1050 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user)
1051 (when t ;???Should check if AUTHINFO succeeded
1052 (nntp-send-command
1053 "^2.*\r?\n" "AUTHINFO PASS"
1054 (or passwd
1055 nntp-authinfo-password
1056 (setq nntp-authinfo-password
1057 (read-passwd (format "NNTP (%s@%s) password: "
1058 user nntp-address))))))))))
1060 (defun nntp-send-nosy-authinfo ()
1061 "Send the AUTHINFO to the nntp server."
1062 (let ((user (read-string (format "NNTP (%s) user name: " nntp-address))))
1063 (unless (member user '(nil ""))
1064 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user)
1065 (when t ;???Should check if AUTHINFO succeeded
1066 (nntp-send-command "^2.*\r?\n" "AUTHINFO PASS"
1067 (read-passwd (format "NNTP (%s@%s) password: "
1068 user nntp-address)))))))
1070 (defun nntp-send-authinfo-from-file ()
1071 "Send the AUTHINFO to the nntp server.
1073 The authinfo login name is taken from the user's login name and the
1074 password contained in '~/.nntp-authinfo'."
1075 (when (file-exists-p "~/.nntp-authinfo")
1076 (with-temp-buffer
1077 (insert-file-contents "~/.nntp-authinfo")
1078 (goto-char (point-min))
1079 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" (user-login-name))
1080 (nntp-send-command
1081 "^2.*\r?\n" "AUTHINFO PASS"
1082 (buffer-substring (point) (gnus-point-at-eol))))))
1084 ;;; Internal functions.
1086 (defun nntp-handle-authinfo (process)
1087 "Take care of an authinfo response from the server."
1088 (let ((last nntp-last-command))
1089 (funcall nntp-authinfo-function)
1090 ;; We have to re-send the function that was interrupted by
1091 ;; the authinfo request.
1092 (save-excursion
1093 (set-buffer nntp-server-buffer)
1094 (erase-buffer))
1095 (nntp-send-string process last)))
1097 (defun nntp-make-process-buffer (buffer)
1098 "Create a new, fresh buffer usable for nntp process connections."
1099 (save-excursion
1100 (set-buffer
1101 (generate-new-buffer
1102 (format " *server %s %s %s*"
1103 nntp-address nntp-port-number
1104 (gnus-buffer-exists-p buffer))))
1105 (mm-enable-multibyte)
1106 (set (make-local-variable 'after-change-functions) nil)
1107 (set (make-local-variable 'nntp-process-wait-for) nil)
1108 (set (make-local-variable 'nntp-process-callback) nil)
1109 (set (make-local-variable 'nntp-process-to-buffer) nil)
1110 (set (make-local-variable 'nntp-process-start-point) nil)
1111 (set (make-local-variable 'nntp-process-decode) nil)
1112 (current-buffer)))
1114 (defun nntp-open-connection (buffer)
1115 "Open a connection to PORT on ADDRESS delivering output to BUFFER."
1116 (run-hooks 'nntp-prepare-server-hook)
1117 (let* ((pbuffer (nntp-make-process-buffer buffer))
1118 (timer
1119 (and nntp-connection-timeout
1120 (nnheader-run-at-time
1121 nntp-connection-timeout nil
1122 `(lambda ()
1123 (nntp-kill-buffer ,pbuffer)))))
1124 (process
1125 (condition-case ()
1126 (let ((coding-system-for-read nntp-coding-system-for-read)
1127 (coding-system-for-write nntp-coding-system-for-write))
1128 (funcall nntp-open-connection-function pbuffer))
1129 (error nil)
1130 (quit
1131 (message "Quit opening connection")
1132 (nntp-kill-buffer pbuffer)
1133 (signal 'quit nil)
1134 nil))))
1135 (when timer
1136 (nnheader-cancel-timer timer))
1137 (unless process
1138 (nntp-kill-buffer pbuffer))
1139 (when (and (buffer-name pbuffer)
1140 process)
1141 (gnus-set-process-query-on-exit-flag process nil)
1142 (if (and (nntp-wait-for process "^2.*\n" buffer nil t)
1143 (memq (process-status process) '(open run)))
1144 (prog1
1145 (caar (push (list process buffer nil) nntp-connection-alist))
1146 (push process nntp-connection-list)
1147 (save-excursion
1148 (set-buffer pbuffer)
1149 (nntp-read-server-type)
1150 (erase-buffer)
1151 (set-buffer nntp-server-buffer)
1152 (let ((nnheader-callback-function nil))
1153 (run-hooks 'nntp-server-opened-hook)
1154 (nntp-send-authinfo t))))
1155 (nntp-kill-buffer (process-buffer process))
1156 nil))))
1158 (defun nntp-open-network-stream (buffer)
1159 (open-network-stream "nntpd" buffer nntp-address nntp-port-number))
1161 (eval-and-compile
1162 (autoload 'format-spec "format-spec")
1163 (autoload 'format-spec-make "format-spec")
1164 (autoload 'open-tls-stream "tls"))
1166 (defun nntp-open-ssl-stream (buffer)
1167 (let* ((process-connection-type nil)
1168 (proc (start-process "nntpd" buffer
1169 shell-file-name
1170 shell-command-switch
1171 (format-spec nntp-ssl-program
1172 (format-spec-make
1173 ?s nntp-address
1174 ?p nntp-port-number)))))
1175 (gnus-set-process-query-on-exit-flag proc nil)
1176 (save-excursion
1177 (set-buffer buffer)
1178 (let ((nntp-connection-alist (list proc buffer nil)))
1179 (nntp-wait-for-string "^\r*20[01]"))
1180 (beginning-of-line)
1181 (delete-region (point-min) (point))
1182 proc)))
1184 (defun nntp-open-tls-stream (buffer)
1185 (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number)))
1186 (gnus-set-process-query-on-exit-flag proc nil)
1187 (save-excursion
1188 (set-buffer buffer)
1189 (let ((nntp-connection-alist (list proc buffer nil)))
1190 (nntp-wait-for-string "^\r*20[01]"))
1191 (beginning-of-line)
1192 (delete-region (point-min) (point))
1193 proc)))
1195 (defun nntp-read-server-type ()
1196 "Find out what the name of the server we have connected to is."
1197 ;; Wait for the status string to arrive.
1198 (setq nntp-server-type (buffer-string))
1199 (let ((alist nntp-server-action-alist)
1200 (case-fold-search t)
1201 entry)
1202 ;; Run server-specific commands.
1203 (while alist
1204 (setq entry (pop alist))
1205 (when (string-match (car entry) nntp-server-type)
1206 (if (and (listp (cadr entry))
1207 (not (eq 'lambda (caadr entry))))
1208 (eval (cadr entry))
1209 (funcall (cadr entry)))))))
1211 (defun nntp-async-wait (process wait-for buffer decode callback)
1212 (save-excursion
1213 (set-buffer (process-buffer process))
1214 (unless nntp-inside-change-function
1215 (erase-buffer))
1216 (setq nntp-process-wait-for wait-for
1217 nntp-process-to-buffer buffer
1218 nntp-process-decode decode
1219 nntp-process-callback callback
1220 nntp-process-start-point (point-max))
1221 (setq after-change-functions '(nntp-after-change-function))
1222 (if nntp-async-needs-kluge
1223 (nntp-async-kluge process))))
1225 (defun nntp-async-kluge (process)
1226 ;; emacs 20.3 bug: process output with encoding 'binary
1227 ;; doesn't trigger after-change-functions.
1228 (unless nntp-async-timer
1229 (setq nntp-async-timer
1230 (nnheader-run-at-time 1 1 'nntp-async-timer-handler)))
1231 (add-to-list 'nntp-async-process-list process))
1233 (defun nntp-async-timer-handler ()
1234 (mapcar
1235 (lambda (proc)
1236 (if (memq (process-status proc) '(open run))
1237 (nntp-async-trigger proc)
1238 (nntp-async-stop proc)))
1239 nntp-async-process-list))
1241 (defun nntp-async-stop (proc)
1242 (setq nntp-async-process-list (delq proc nntp-async-process-list))
1243 (when (and nntp-async-timer (not nntp-async-process-list))
1244 (nnheader-cancel-timer nntp-async-timer)
1245 (setq nntp-async-timer nil)))
1247 (defun nntp-after-change-function (beg end len)
1248 (unwind-protect
1249 ;; we only care about insertions at eob
1250 (when (and (eq 0 len) (eq (point-max) end))
1251 (save-match-data
1252 (let ((proc (get-buffer-process (current-buffer))))
1253 (when proc
1254 (nntp-async-trigger proc)))))
1255 ;; any throw from after-change-functions will leave it
1256 ;; set to nil. so we reset it here, if necessary.
1257 (when quit-flag
1258 (setq after-change-functions '(nntp-after-change-function)))))
1260 (defun nntp-async-trigger (process)
1261 (save-excursion
1262 (set-buffer (process-buffer process))
1263 (when nntp-process-callback
1264 ;; do we have an error message?
1265 (goto-char nntp-process-start-point)
1266 (if (memq (following-char) '(?4 ?5))
1267 ;; wants credentials?
1268 (if (looking-at "480")
1269 (nntp-handle-authinfo process)
1270 ;; report error message.
1271 (nntp-snarf-error-message)
1272 (nntp-do-callback nil))
1274 ;; got what we expect?
1275 (goto-char (point-max))
1276 (when (re-search-backward
1277 nntp-process-wait-for nntp-process-start-point t)
1278 (let ((response (match-string 0)))
1279 (with-current-buffer nntp-server-buffer
1280 (setq nntp-process-response response)))
1281 (nntp-async-stop process)
1282 ;; convert it.
1283 (when (gnus-buffer-exists-p nntp-process-to-buffer)
1284 (let ((buf (current-buffer))
1285 (start nntp-process-start-point)
1286 (decode nntp-process-decode))
1287 (save-excursion
1288 (set-buffer nntp-process-to-buffer)
1289 (goto-char (point-max))
1290 (save-restriction
1291 (narrow-to-region (point) (point))
1292 (insert-buffer-substring buf start)
1293 (when decode
1294 (nntp-decode-text))))))
1295 ;; report it.
1296 (goto-char (point-max))
1297 (nntp-do-callback
1298 (buffer-name (get-buffer nntp-process-to-buffer))))))))
1300 (defun nntp-do-callback (arg)
1301 (let ((callback nntp-process-callback)
1302 (nntp-inside-change-function t))
1303 (setq nntp-process-callback nil)
1304 (funcall callback arg)))
1306 (defun nntp-snarf-error-message ()
1307 "Save the error message in the current buffer."
1308 (let ((message (buffer-string)))
1309 (while (string-match "[\r\n]+" message)
1310 (setq message (replace-match " " t t message)))
1311 (nnheader-report 'nntp message)
1312 message))
1314 (defun nntp-accept-process-output (process)
1315 "Wait for output from PROCESS and message some dots."
1316 (save-excursion
1317 (set-buffer (or (nntp-find-connection-buffer nntp-server-buffer)
1318 nntp-server-buffer))
1319 (let ((len (/ (buffer-size) 1024))
1320 message-log-max)
1321 (unless (< len 10)
1322 (setq nntp-have-messaged t)
1323 (nnheader-message 7 "nntp read: %dk" len)))
1324 (nnheader-accept-process-output process)
1325 ;; accept-process-output may update status of process to indicate
1326 ;; that the server has closed the connection. This MUST be
1327 ;; handled here as the buffer restored by the save-excursion may
1328 ;; be the process's former output buffer (i.e. now killed)
1329 (or (and process
1330 (memq (process-status process) '(open run)))
1331 (nntp-report "Server closed connection"))))
1333 (defun nntp-accept-response ()
1334 "Wait for output from the process that outputs to BUFFER."
1335 (nntp-accept-process-output (nntp-find-connection nntp-server-buffer)))
1337 (defun nntp-possibly-change-group (group server &optional connectionless)
1338 (let ((nnheader-callback-function nil))
1339 (when server
1340 (or (nntp-server-opened server)
1341 (nntp-open-server server nil connectionless)))
1343 (unless connectionless
1344 (or (nntp-find-connection nntp-server-buffer)
1345 (nntp-open-connection nntp-server-buffer))))
1347 (when group
1348 (let ((entry (nntp-find-connection-entry nntp-server-buffer)))
1349 (cond ((not entry)
1350 (nntp-report "Server closed connection"))
1351 ((not (equal group (caddr entry)))
1352 (save-excursion
1353 (set-buffer (process-buffer (car entry)))
1354 (erase-buffer)
1355 (nntp-send-command "^[245].*\n" "GROUP" group)
1356 (setcar (cddr entry) group)
1357 (erase-buffer)
1358 (save-excursion
1359 (set-buffer nntp-server-buffer)
1360 (erase-buffer))))))))
1362 (defun nntp-decode-text (&optional cr-only)
1363 "Decode the text in the current buffer."
1364 (goto-char (point-min))
1365 (while (search-forward "\r" nil t)
1366 (delete-char -1))
1367 (unless cr-only
1368 ;; Remove trailing ".\n" end-of-transfer marker.
1369 (goto-char (point-max))
1370 (forward-line -1)
1371 (when (looking-at ".\n")
1372 (delete-char 2))
1373 ;; Delete status line.
1374 (goto-char (point-min))
1375 (while (looking-at "[1-5][0-9][0-9] .*\n")
1376 ;; For some unknown reason, there is more than one status line.
1377 (delete-region (point) (progn (forward-line 1) (point))))
1378 ;; Remove "." -> ".." encoding.
1379 (while (search-forward "\n.." nil t)
1380 (delete-char -1))))
1382 (defun nntp-encode-text ()
1383 "Encode the text in the current buffer."
1384 (save-excursion
1385 ;; Replace "." at beginning of line with "..".
1386 (goto-char (point-min))
1387 (while (re-search-forward "^\\." nil t)
1388 (insert "."))
1389 (goto-char (point-max))
1390 ;; Insert newline at the end of the buffer.
1391 (unless (bolp)
1392 (insert "\n"))
1393 ;; Insert `.' at end of buffer (end of text mark).
1394 (goto-char (point-max))
1395 (insert ".\n")
1396 (goto-char (point-min))
1397 (while (not (eobp))
1398 (end-of-line)
1399 (delete-char 1)
1400 (insert nntp-end-of-line))))
1402 (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old)
1403 (set-buffer nntp-server-buffer)
1404 (erase-buffer)
1405 (cond
1407 ;; This server does not talk NOV.
1408 ((not nntp-server-xover)
1409 nil)
1411 ;; We don't care about gaps.
1412 ((or (not nntp-nov-gap)
1413 fetch-old)
1414 (nntp-send-xover-command
1415 (if fetch-old
1416 (if (numberp fetch-old)
1417 (max 1 (- (car articles) fetch-old))
1419 (car articles))
1420 (car (last articles)) 'wait)
1422 (goto-char (point-min))
1423 (when (looking-at "[1-5][0-9][0-9] .*\n")
1424 (delete-region (point) (progn (forward-line 1) (point))))
1425 (while (search-forward "\r" nil t)
1426 (replace-match "" t t))
1427 (goto-char (point-max))
1428 (forward-line -1)
1429 (when (looking-at "\\.")
1430 (delete-region (point) (progn (forward-line 1) (point)))))
1432 ;; We do it the hard way. For each gap, an XOVER command is sent
1433 ;; to the server. We do not wait for a reply from the server, we
1434 ;; just send them off as fast as we can. That means that we have
1435 ;; to count the number of responses we get back to find out when we
1436 ;; have gotten all we asked for.
1437 ((numberp nntp-nov-gap)
1438 (let ((count 0)
1439 (received 0)
1440 last-point
1441 in-process-buffer-p
1442 (buf nntp-server-buffer)
1443 (process-buffer (nntp-find-connection-buffer nntp-server-buffer))
1444 first last status)
1445 ;; We have to check `nntp-server-xover'. If it gets set to nil,
1446 ;; that means that the server does not understand XOVER, but we
1447 ;; won't know that until we try.
1448 (while (and nntp-server-xover articles)
1449 (setq first (car articles))
1450 ;; Search forward until we find a gap, or until we run out of
1451 ;; articles.
1452 (while (and (cdr articles)
1453 (< (- (nth 1 articles) (car articles)) nntp-nov-gap))
1454 (setq articles (cdr articles)))
1456 (setq in-process-buffer-p (stringp nntp-server-xover))
1457 (nntp-send-xover-command first (setq last (car articles)))
1458 (setq articles (cdr articles))
1460 (when (and nntp-server-xover in-process-buffer-p)
1461 ;; Don't count tried request.
1462 (setq count (1+ count))
1464 ;; Every 400 requests we have to read the stream in
1465 ;; order to avoid deadlocks.
1466 (when (or (null articles) ;All requests have been sent.
1467 (= 1 (% count nntp-maximum-request)))
1469 (nntp-accept-response)
1470 ;; On some Emacs versions the preceding function has a
1471 ;; tendency to change the buffer. Perhaps. It's quite
1472 ;; difficult to reproduce, because it only seems to happen
1473 ;; once in a blue moon.
1474 (set-buffer process-buffer)
1475 (while (progn
1476 (goto-char (or last-point (point-min)))
1477 ;; Count replies.
1478 (while (re-search-forward "^\\([0-9][0-9][0-9]\\) .*\n"
1479 nil t)
1480 (incf received)
1481 (setq status (match-string 1))
1482 (if (string-match "^[45]" status)
1483 (setq status 'error)
1484 (setq status 'ok)))
1485 (setq last-point (point))
1486 (or (< received count)
1487 (if (eq status 'error)
1489 ;; I haven't started reading the final response
1490 (progn
1491 (goto-char (point-max))
1492 (forward-line -1)
1493 (not (looking-at "^\\.\r?\n"))))))
1494 ;; I haven't read the end of the final response
1495 (nntp-accept-response)
1496 (set-buffer process-buffer))))
1498 ;; Some nntp servers seem to have an extension to the XOVER
1499 ;; extension. On these servers, requesting an article range
1500 ;; preceeding the active range does not return an error as
1501 ;; specified in the RFC. What we instead get is the NOV entry
1502 ;; for the first available article. Obviously, a client can
1503 ;; use that entry to avoid making unnecessary requests. The
1504 ;; only problem is for a client that assumes that the response
1505 ;; will always be within the requested ranage. For such a
1506 ;; client, we can get N copies of the same entry (one for each
1507 ;; XOVER command sent to the server).
1509 (when (<= count 1)
1510 (goto-char (point-min))
1511 (when (re-search-forward "^[0-9][0-9][0-9] .*\n\\([0-9]+\\)" nil t)
1512 (let ((low-limit (string-to-number
1513 (buffer-substring (match-beginning 1)
1514 (match-end 1)))))
1515 (while (and articles (<= (car articles) low-limit))
1516 (setq articles (cdr articles))))))
1517 (set-buffer buf))
1519 (when nntp-server-xover
1520 (when in-process-buffer-p
1521 (set-buffer buf)
1522 (goto-char (point-max))
1523 (insert-buffer-substring process-buffer)
1524 (set-buffer process-buffer)
1525 (erase-buffer)
1526 (set-buffer buf))
1528 ;; We remove any "." lines and status lines.
1529 (goto-char (point-min))
1530 (while (search-forward "\r" nil t)
1531 (delete-char -1))
1532 (goto-char (point-min))
1533 (delete-matching-lines "^\\.$\\|^[1-5][0-9][0-9] ")
1534 t))))
1536 nntp-server-xover)
1538 (defun nntp-send-xover-command (beg end &optional wait-for-reply)
1539 "Send the XOVER command to the server."
1540 (let ((range (format "%d-%d" beg end))
1541 (nntp-inhibit-erase t))
1542 (if (stringp nntp-server-xover)
1543 ;; If `nntp-server-xover' is a string, then we just send this
1544 ;; command.
1545 (if wait-for-reply
1546 (nntp-send-command-nodelete
1547 "\r?\n\\.\r?\n" nntp-server-xover range)
1548 ;; We do not wait for the reply.
1549 (nntp-send-command-nodelete nil nntp-server-xover range))
1550 (let ((commands nntp-xover-commands))
1551 ;; `nntp-xover-commands' is a list of possible XOVER commands.
1552 ;; We try them all until we get at positive response.
1553 (while (and commands (eq nntp-server-xover 'try))
1554 (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range)
1555 (save-excursion
1556 (set-buffer nntp-server-buffer)
1557 (goto-char (point-min))
1558 (and (looking-at "[23]") ; No error message.
1559 ;; We also have to look at the lines. Some buggy
1560 ;; servers give back simple lines with just the
1561 ;; article number. How... helpful.
1562 (progn
1563 (forward-line 1)
1564 (looking-at "[0-9]+\t...")) ; More text after number.
1565 (setq nntp-server-xover (car commands))))
1566 (setq commands (cdr commands)))
1567 ;; If none of the commands worked, we disable XOVER.
1568 (when (eq nntp-server-xover 'try)
1569 (save-excursion
1570 (set-buffer nntp-server-buffer)
1571 (erase-buffer)
1572 (setq nntp-server-xover nil)))
1573 nntp-server-xover))))
1575 (defun nntp-find-group-and-number (&optional group)
1576 (save-excursion
1577 (save-restriction
1578 (set-buffer nntp-server-buffer)
1579 (narrow-to-region (goto-char (point-min))
1580 (or (search-forward "\n\n" nil t) (point-max)))
1581 (goto-char (point-min))
1582 ;; We first find the number by looking at the status line.
1583 (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
1584 (string-to-number
1585 (buffer-substring (match-beginning 1)
1586 (match-end 1)))))
1587 newsgroups xref)
1588 (and number (zerop number) (setq number nil))
1589 (if number
1590 ;; Then we find the group name.
1591 (setq group
1592 (cond
1593 ;; If there is only one group in the Newsgroups
1594 ;; header, then it seems quite likely that this
1595 ;; article comes from that group, I'd say.
1596 ((and (setq newsgroups
1597 (mail-fetch-field "newsgroups"))
1598 (not (string-match "," newsgroups)))
1599 newsgroups)
1600 ;; If there is more than one group in the
1601 ;; Newsgroups header, then the Xref header should
1602 ;; be filled out. We hazard a guess that the group
1603 ;; that has this article number in the Xref header
1604 ;; is the one we are looking for. This might very
1605 ;; well be wrong if this article happens to have
1606 ;; the same number in several groups, but that's
1607 ;; life.
1608 ((and (setq xref (mail-fetch-field "xref"))
1609 number
1610 (string-match
1611 (format "\\([^ :]+\\):%d" number) xref))
1612 (match-string 1 xref))
1613 (t "")))
1614 (cond
1615 ((and (setq xref (mail-fetch-field "xref"))
1616 (string-match
1617 (if group
1618 (concat "\\(" (regexp-quote group) "\\):\\([0-9]+\\)")
1619 "\\([^ :]+\\):\\([0-9]+\\)")
1620 xref))
1621 (setq group (match-string 1 xref)
1622 number (string-to-number (match-string 2 xref))))
1623 ((and (setq newsgroups
1624 (mail-fetch-field "newsgroups"))
1625 (not (string-match "," newsgroups)))
1626 (setq group newsgroups))
1627 (group)
1628 (t (setq group ""))))
1629 (when (string-match "\r" group)
1630 (setq group (substring group 0 (match-beginning 0))))
1631 (cons group number)))))
1633 (defun nntp-wait-for-string (regexp)
1634 "Wait until string arrives in the buffer."
1635 (let ((buf (current-buffer))
1636 proc)
1637 (goto-char (point-min))
1638 (while (and (setq proc (get-buffer-process buf))
1639 (memq (process-status proc) '(open run))
1640 (not (re-search-forward regexp nil t)))
1641 (accept-process-output proc)
1642 (set-buffer buf)
1643 (goto-char (point-min)))))
1646 ;; ==========================================================================
1647 ;; Obsolete nntp-open-* connection methods -- drv
1648 ;; ==========================================================================
1650 (defvoo nntp-open-telnet-envuser nil
1651 "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.")
1653 (defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
1654 "*Regular expression to match the shell prompt on the remote machine.")
1656 (defvoo nntp-rlogin-program "rsh"
1657 "*Program used to log in on remote machines.
1658 The default is \"rsh\", but \"ssh\" is a popular alternative.")
1660 (defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
1661 "*Parameters to `nntp-open-rlogin'.
1662 That function may be used as `nntp-open-connection-function'. In that
1663 case, this list will be used as the parameter list given to rsh.")
1665 (defvoo nntp-rlogin-user-name nil
1666 "*User name on remote system when using the rlogin connect method.")
1668 (defvoo nntp-telnet-parameters
1669 '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
1670 "*Parameters to `nntp-open-telnet'.
1671 That function may be used as `nntp-open-connection-function'. In that
1672 case, this list will be executed as a command after logging in
1673 via telnet.")
1675 (defvoo nntp-telnet-user-name nil
1676 "User name to log in via telnet with.")
1678 (defvoo nntp-telnet-passwd nil
1679 "Password to use to log in via telnet with.")
1681 (defun nntp-open-telnet (buffer)
1682 (save-excursion
1683 (set-buffer buffer)
1684 (erase-buffer)
1685 (let ((proc (apply
1686 'start-process
1687 "nntpd" buffer nntp-telnet-command nntp-telnet-switches))
1688 (case-fold-search t))
1689 (when (memq (process-status proc) '(open run))
1690 (nntp-wait-for-string "^r?telnet")
1691 (process-send-string proc "set escape \^X\n")
1692 (cond
1693 ((and nntp-open-telnet-envuser nntp-telnet-user-name)
1694 (process-send-string proc (concat "open " "-l" nntp-telnet-user-name
1695 nntp-address "\n")))
1697 (process-send-string proc (concat "open " nntp-address "\n"))))
1698 (cond
1699 ((not nntp-open-telnet-envuser)
1700 (nntp-wait-for-string "^\r*.?login:")
1701 (process-send-string
1702 proc (concat
1703 (or nntp-telnet-user-name
1704 (setq nntp-telnet-user-name (read-string "login: ")))
1705 "\n"))))
1706 (nntp-wait-for-string "^\r*.?password:")
1707 (process-send-string
1708 proc (concat
1709 (or nntp-telnet-passwd
1710 (setq nntp-telnet-passwd
1711 (read-passwd "Password: ")))
1712 "\n"))
1713 (nntp-wait-for-string nntp-telnet-shell-prompt)
1714 (process-send-string
1715 proc (concat (mapconcat 'identity nntp-telnet-parameters " ") "\n"))
1716 (nntp-wait-for-string "^\r*20[01]")
1717 (beginning-of-line)
1718 (delete-region (point-min) (point))
1719 (process-send-string proc "\^]")
1720 (nntp-wait-for-string "^r?telnet")
1721 (process-send-string proc "mode character\n")
1722 (accept-process-output proc 1)
1723 (sit-for 1)
1724 (goto-char (point-min))
1725 (forward-line 1)
1726 (delete-region (point) (point-max)))
1727 proc)))
1729 (defun nntp-open-rlogin (buffer)
1730 "Open a connection to SERVER using rsh."
1731 (let ((proc (if nntp-rlogin-user-name
1732 (apply 'start-process
1733 "nntpd" buffer nntp-rlogin-program
1734 nntp-address "-l" nntp-rlogin-user-name
1735 nntp-rlogin-parameters)
1736 (apply 'start-process
1737 "nntpd" buffer nntp-rlogin-program nntp-address
1738 nntp-rlogin-parameters))))
1739 (save-excursion
1740 (set-buffer buffer)
1741 (nntp-wait-for-string "^\r*20[01]")
1742 (beginning-of-line)
1743 (delete-region (point-min) (point))
1744 proc)))
1747 ;; ==========================================================================
1748 ;; Replacements for the nntp-open-* functions -- drv
1749 ;; ==========================================================================
1751 (defun nntp-open-telnet-stream (buffer)
1752 "Open a nntp connection by telnet'ing the news server.
1754 Please refer to the following variables to customize the connection:
1755 - `nntp-pre-command',
1756 - `nntp-telnet-command',
1757 - `nntp-telnet-switches',
1758 - `nntp-address',
1759 - `nntp-port-number',
1760 - `nntp-end-of-line'."
1761 (let ((command `(,nntp-telnet-command
1762 ,@nntp-telnet-switches
1763 ,nntp-address ,nntp-port-number))
1764 proc)
1765 (and nntp-pre-command
1766 (push nntp-pre-command command))
1767 (setq proc (apply 'start-process "nntpd" buffer command))
1768 (save-excursion
1769 (set-buffer buffer)
1770 (nntp-wait-for-string "^\r*20[01]")
1771 (beginning-of-line)
1772 (delete-region (point-min) (point))
1773 proc)))
1775 (defun nntp-open-via-rlogin-and-telnet (buffer)
1776 "Open a connection to an nntp server through an intermediate host.
1777 First rlogin to the remote host, and then telnet the real news server
1778 from there.
1780 Please refer to the following variables to customize the connection:
1781 - `nntp-pre-command',
1782 - `nntp-via-rlogin-command',
1783 - `nntp-via-rlogin-command-switches',
1784 - `nntp-via-user-name',
1785 - `nntp-via-address',
1786 - `nntp-telnet-command',
1787 - `nntp-telnet-switches',
1788 - `nntp-address',
1789 - `nntp-port-number',
1790 - `nntp-end-of-line'."
1791 (let ((command `(,nntp-via-address
1792 ,nntp-telnet-command
1793 ,@nntp-telnet-switches))
1794 proc)
1795 (when nntp-via-user-name
1796 (setq command `("-l" ,nntp-via-user-name ,@command)))
1797 (when nntp-via-rlogin-command-switches
1798 (setq command (append nntp-via-rlogin-command-switches command)))
1799 (push nntp-via-rlogin-command command)
1800 (and nntp-pre-command
1801 (push nntp-pre-command command))
1802 (setq proc (apply 'start-process "nntpd" buffer command))
1803 (save-excursion
1804 (set-buffer buffer)
1805 (nntp-wait-for-string "^r?telnet")
1806 (process-send-string proc (concat "open " nntp-address
1807 " " nntp-port-number "\n"))
1808 (nntp-wait-for-string "^\r*20[01]")
1809 (beginning-of-line)
1810 (delete-region (point-min) (point))
1811 (process-send-string proc "\^]")
1812 (nntp-wait-for-string "^r?telnet")
1813 (process-send-string proc "mode character\n")
1814 (accept-process-output proc 1)
1815 (sit-for 1)
1816 (goto-char (point-min))
1817 (forward-line 1)
1818 (delete-region (point) (point-max)))
1819 proc))
1821 (defun nntp-open-via-telnet-and-telnet (buffer)
1822 "Open a connection to an nntp server through an intermediate host.
1823 First telnet the remote host, and then telnet the real news server
1824 from there.
1826 Please refer to the following variables to customize the connection:
1827 - `nntp-pre-command',
1828 - `nntp-via-telnet-command',
1829 - `nntp-via-telnet-switches',
1830 - `nntp-via-address',
1831 - `nntp-via-envuser',
1832 - `nntp-via-user-name',
1833 - `nntp-via-user-password',
1834 - `nntp-via-shell-prompt',
1835 - `nntp-telnet-command',
1836 - `nntp-telnet-switches',
1837 - `nntp-address',
1838 - `nntp-port-number',
1839 - `nntp-end-of-line'."
1840 (save-excursion
1841 (set-buffer buffer)
1842 (erase-buffer)
1843 (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches))
1844 (case-fold-search t)
1845 proc)
1846 (and nntp-pre-command (push nntp-pre-command command))
1847 (setq proc (apply 'start-process "nntpd" buffer command))
1848 (when (memq (process-status proc) '(open run))
1849 (nntp-wait-for-string "^r?telnet")
1850 (process-send-string proc "set escape \^X\n")
1851 (cond
1852 ((and nntp-via-envuser nntp-via-user-name)
1853 (process-send-string proc (concat "open " "-l" nntp-via-user-name
1854 nntp-via-address "\n")))
1856 (process-send-string proc (concat "open " nntp-via-address
1857 "\n"))))
1858 (when (not nntp-via-envuser)
1859 (nntp-wait-for-string "^\r*.?login:")
1860 (process-send-string proc
1861 (concat
1862 (or nntp-via-user-name
1863 (setq nntp-via-user-name
1864 (read-string "login: ")))
1865 "\n")))
1866 (nntp-wait-for-string "^\r*.?password:")
1867 (process-send-string proc
1868 (concat
1869 (or nntp-via-user-password
1870 (setq nntp-via-user-password
1871 (read-passwd "Password: ")))
1872 "\n"))
1873 (nntp-wait-for-string nntp-via-shell-prompt)
1874 (let ((real-telnet-command `("exec"
1875 ,nntp-telnet-command
1876 ,@nntp-telnet-switches
1877 ,nntp-address
1878 ,nntp-port-number)))
1879 (process-send-string proc
1880 (concat (mapconcat 'identity
1881 real-telnet-command " ")
1882 "\n")))
1883 (nntp-wait-for-string "^\r*20[01]")
1884 (beginning-of-line)
1885 (delete-region (point-min) (point))
1886 (process-send-string proc "\^]")
1887 (nntp-wait-for-string "^r?telnet")
1888 (process-send-string proc "mode character\n")
1889 (accept-process-output proc 1)
1890 (sit-for 1)
1891 (goto-char (point-min))
1892 (forward-line 1)
1893 (delete-region (point) (point-max)))
1894 proc)))
1896 (provide 'nntp)
1898 ;;; arch-tag: 8655466a-b1b5-4929-9c45-7b1b2e767271
1899 ;;; nntp.el ends here