Xref: utzoo gnu.emacs.gnus:260 comp.emacs:6348 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bob From: bob@tut.cis.ohio-state.edu (Bob Sutterfield) Newsgroups: gnu.emacs.gnus,comp.emacs Subject: GNUS 3.12 (07 of 10) Message-ID: Date: 26 Jun 89 13:26:25 GMT Sender: bob@tut.cis.ohio-state.edu Reply-To: Bob Sutterfield Followup-To: gnu.emacs.gnus Organization: The Ohio State University Dept of Computer & Information Science Lines: 1430 #!/bin/sh # this is part 7 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file nntp.el continued # CurArch=7 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 sed 's/^X//' << 'SHAR_EOF' >> nntp.el X "Set article author of HEADER to FROM." X (` (aset (, header) 2 (, from)))) X X(defmacro nntp-header-xref (header) X "Return xref string in HEADER." X (` (aref (, header) 3))) X X(defmacro nntp-set-header-xref (header xref) X "Set article xref of HEADER to xref." X (` (aset (, header) 3 (, xref)))) X X(defmacro nntp-header-lines (header) X "Return lines in HEADER." X (` (aref (, header) 4))) X X(defmacro nntp-set-header-lines (header lines) X "Set article lines of HEADER to LINES." X (` (aset (, header) 4 (, lines)))) X X(defmacro nntp-header-date (header) X "Return date in HEADER." X (` (aref (, header) 5))) X X(defmacro nntp-set-header-date (header date) X "Set article date of HEADER to DATE." X (` (aset (, header) 5 (, date)))) X X(defmacro nntp-header-id (header) X "Return date in HEADER." X (` (aref (, header) 6))) X X(defmacro nntp-set-header-id (header id) X "Set article ID of HEADER to ID." X (` (aset (, header) 6 (, id)))) X X(defun nntp-retrieve-headers (sequence) X "Return list of article headers specified by SEQUENCE of article id. XThe format of list is `([NUMBER SUBJECT FROM XREF LINES DATE MESSAGE-ID] ...)'. XReader macros for the vector are defined as `nntp-header-FIELD'. XWriter macros for the vector are defined as `nntp-set-header-FIELD'. XNews group must be selected before calling me." X (save-excursion X (set-buffer nntp-server-buffer) X (erase-buffer) X (let ((number (length sequence)) X (last-point (point-min)) X (received 0) X (count 0) X (headers nil) ;Result list. X (article 0) X (subject nil) X (message-id) X (from nil) X (xref nil) X (lines 0) X (date nil)) X ;; Send HEAD command. X (while sequence X (nntp-send-strings-to-server "HEAD" (car sequence)) X (setq sequence (cdr sequence)) X (setq count (1+ count)) X ;; Every 400 header requests we have to read stream in order X ;; to avoid deadlock. X (if (or (null sequence) ;All requests have been sent. X (zerop (% count nntp-maximum-request))) X (progn X (accept-process-output) X (while (progn X (goto-char last-point) X ;; Count replies. X (while (re-search-forward "^[0-9]" nil t) X (setq received (1+ received))) X (setq last-point (point)) X (< received count)) X ;; If number of headers is greater than 100, give X ;; informative messages. X (and (> number nntp-large-newsgroup) X (zerop (% received 20)) X (message "NNTP: %d%% of headers received." X (/ (* received 100) number))) X (nntp-accept-response)) X )) X ) X ;; Wait for text of last command. X (goto-char (point-max)) X (re-search-backward "^[0-9]" nil t) X (if (looking-at "^[23]") X (while (progn X (goto-char (- (point-max) 3)) X (not (looking-at "^\\.\r$"))) X (nntp-accept-response) X )) X (if (> number nntp-large-newsgroup) X (message "NNTP: 100%% of headers received.")) X ;; Now all of replies are received. X ;; First, delete unnecessary lines. X (goto-char (point-min)) X (delete-non-matching-lines X "^Subject:\\|^Xref:\\|^From:\\|^Lines:\\|^Date:\\|^[23]") X (if (> number nntp-large-newsgroup) X (message "NNTP: Parsing headers...")) X (setq received number) X ;; Then examines replies. X (while (not (eobp)) X (cond ((looking-at "^[23].*[ \t]+\\([0-9]+\\)[ \t]+\\(<.+>\\)") X (setq article X (string-to-int X (buffer-substring (match-beginning 1) (match-end 1)))) X (setq message-id X (buffer-substring (match-beginning 2) (match-end 2))) X (forward-line 1) X ;; Set default value. X (setq subject nil) X (setq xref nil) X (setq from nil) X (setq lines 0) X (setq date nil) X ;; It is better to extract From:, Subject:, Date:, X ;; Lines: and Xref: field values in *THIS* order. X ;; Forward-line each time after getting expected value X ;; in order to reduce count of string matching. X (while (looking-at "^[^23]") X (if (looking-at "^From:[ \t]\\(.*\\)\r$") X (progn X (setq from (buffer-substring (match-beginning 1) X (match-end 1))) X (forward-line 1))) X (if (looking-at "^Subject:[ \t]\\(.*\\)\r$") X (progn X (setq subject (buffer-substring (match-beginning 1) X (match-end 1))) X (forward-line 1))) X (if (looking-at "^Date:[ \t]\\(.*\\)\r$") X (progn X (setq date (buffer-substring (match-beginning 1) X (match-end 1))) X (forward-line 1))) X (if (looking-at "^Lines:[ \t]\\(.*\\)\r$") X (progn X (setq lines (string-to-int X (buffer-substring (match-beginning 1) X (match-end 1)))) X (forward-line 1))) X (if (looking-at "^Xref:[ \t]\\(.*\\)\r$") X (progn X (setq xref (buffer-substring (match-beginning 1) X (match-end 1))) X (forward-line 1))) X ;; Skip invalid field (ex. Subject:abc) X (if (looking-at "^[^:]*:[^ \t]") X (forward-line 1)) X ) X (if (null subject) X (setq subject "(None)")) X (if (null from) X (setq from "Unknown User")) X (setq headers X (cons (vector article subject from X xref lines date message-id) X headers)) X ) X (t (forward-line 1)) ;Skip invalid field (ex. Subject:abc) X ) X (setq received (1- received)) X (and (> number nntp-large-newsgroup) X (zerop (% received 20)) X (message "NNTP: Parsing headers... %d%%" X (/ (* received 100) number))) X ) X (if (> number nntp-large-newsgroup) X (message "NNTP: Parsing headers... done")) X (nreverse headers) X ))) X X X;;; X;;; Raw Interface to Network News Transfer Protocol (RFC977). X;;; X X(defun nntp-open-server (host &optional service) X "Open news server on HOST. XIf HOST is nil, use value of environment variable `NNTPSERVER'. XIf optional argument SERVICE is non-nil, open by the service name." X (let ((host (or host (getenv "NNTPSERVER"))) X (status nil)) X (setq nntp-status-message-string "") X (cond ((and host (nntp-open-server-internal host service)) X (setq status (nntp-wait-for-response "^[23].*\r$")) X ;; Do check unexpected close of connection. X ;; Suggested by feldmark@hanako.stars.flab.fujitsu.junet. X (if status X (set-process-sentinel nntp-server-process X 'nntp-default-sentinel) X ;; We have to close connection here, since function X ;; `nntp-server-opened' may return incorrect status. X (nntp-close-server-internal) X )) X ((null host) X (setq nntp-status-message-string "NNTP server is not specified.")) X ) X status X )) X X(defun nntp-close-server () X "Close news server." X (unwind-protect X (progn X ;; Un-set default sentinel function before closing connection. X (and nntp-server-process X (eq 'nntp-default-sentinel X (process-sentinel nntp-server-process)) X (set-process-sentinel nntp-server-process nil)) X ;; We cannot send QUIT command unless the process is running. X (if (nntp-server-opened) X (nntp-send-command nil "QUIT")) X ) X (nntp-close-server-internal) X )) X X(fset 'nntp-request-quit (symbol-function 'nntp-close-server)) X X(defun nntp-server-opened () X "Return server process status, T or NIL. XIf the stream is opened, return T, otherwise return NIL." X (and nntp-server-process X (memq (process-status nntp-server-process) '(open run)))) X X(defun nntp-status-message () X "Return server status response as string." X (if (and nntp-status-message-string X ;; NNN MESSAGE X (string-match "[0-9][0-9][0-9][ \t]+\\([^\r]*\\).*$" X nntp-status-message-string)) X (substring nntp-status-message-string (match-beginning 1) (match-end 1)) X ;; Empty message if nothing. X "" X )) X X(defun nntp-request-article (id) X "Select article by message ID (or number)." X (prog1 X ;; If NEmacs, end of message may look like: "\256\215" (".^M") X (nntp-send-command "^\\.\r$" "ARTICLE" id) X (nntp-decode-text) X )) X X(defun nntp-request-body (id) X "Select article body by message ID (or number)." X (prog1 X ;; If NEmacs, end of message may look like: "\256\215" (".^M") X (nntp-send-command "^\\.\r$" "BODY" id) X (nntp-decode-text) X )) X X(defun nntp-request-head (id) X "Select article head by message ID (or number)." X (prog1 X (nntp-send-command "^\\.\r$" "HEAD" id) X (nntp-decode-text) X )) X X(defun nntp-request-stat (id) X "Select article by message ID (or number)." X (nntp-send-command "^[23].*\r$" "STAT" id)) X X(defun nntp-request-group (group) X "Select news GROUP." X ;; 1.2a NNTP's group command is buggy. "^M" (\r) is not appended to X ;; end of the status message. X (nntp-send-command "^[23].*$" "GROUP" group)) X X(defun nntp-request-list () X "List valid newsgoups." X (prog1 X (nntp-send-command "^\\.\r$" "LIST") X (nntp-decode-text) X )) X X(defun nntp-request-last () X "Set current article pointer to the previous article Xin the current news group." X (nntp-send-command "^[23].*\r$" "LAST")) X X(defun nntp-request-next () X "Advance current article pointer." X (nntp-send-command "^[23].*\r$" "NEXT")) X X(defun nntp-request-post () X "Post a new news in current buffer." X (if (nntp-send-command "^[23].*\r$" "POST") X (progn X (nntp-encode-text) X (nntp-send-region-to-server (point-min) (point-max)) X ;; 1.2a NNTP's post command is buggy. "^M" (\r) is not X ;; appended to end of the status message. X (nntp-wait-for-response "^[23].*$") X ))) X X(defun nntp-default-sentinel (proc status) X "Default sentinel function for NNTP server process." X (if (and nntp-server-process X (not (nntp-server-opened))) X (error "NNTP: Connection closed.") X )) X X;; Encoding and decoding of NNTP text. X X(defun nntp-decode-text () X "Decode text transmitted by NNTP. X0. Delete status line. X1. Delete `^M' at end of line. X2. Delete `.' at end of buffer (end of text mark). X3. Delete `.' at beginning of line." X (save-excursion X (set-buffer nntp-server-buffer) X ;; Insert newline at end of buffer. X (goto-char (point-max)) X (if (not (bolp)) X (insert "\n")) X ;; Delete status line. X (goto-char (point-min)) X (delete-region (point) (progn (forward-line 1) (point))) X ;; Delete `^M' at end of line. X ;; (replace-regexp "\r$" "") X (while (not (eobp)) X (end-of-line) X (if (= (preceding-char) ?\r) X (delete-char -1)) X (forward-line 1) X ) X ;; Delete `.' at end of buffer (end of text mark). X (goto-char (point-max)) X (forward-line -1) ;(beginning-of-line) X (if (looking-at "^\\.$") X (delete-region (point) (progn (forward-line 1) (point)))) X ;; Replace `..' at beginning of line with `.'. X (goto-char (point-min)) X ;; (replace-regexp "^\\.\\." ".") X (while (search-forward "\n.." nil t) X (delete-char -1)) X )) X X(defun nntp-encode-text () X "Encode text in current buffer for NNTP transmission. X1. Insert `.' at beginning of line. X2. Insert `.' at end of buffer (end of text mark)." X (save-excursion X ;; Insert newline at end of buffer. X (goto-char (point-max)) X (if (not (bolp)) X (insert "\n")) X ;; Replace `.' at beginning of line with `..'. X (goto-char (point-min)) X ;; (replace-regexp "^\\." "..") X (while (search-forward "\n." nil t) X (insert ".")) X ;; Insert `.' at end of buffer (end of text mark). X (goto-char (point-max)) X (insert ".\n") X )) X X X;;; X;;; Synchronous Communication with NNTP Server. X;;; X X(defun nntp-send-command (response cmd &rest args) X "Wait for server RESPONSE after sending CMD and optional ARGS to server." X (save-excursion X ;; Clear communication buffer. X (set-buffer nntp-server-buffer) X (erase-buffer) X (apply 'nntp-send-strings-to-server cmd args) X (if response X (nntp-wait-for-response response) X t) X )) X X(defun nntp-wait-for-response (regexp) X "Wait for server response which matches REGEXP." X (save-excursion X (let ((status t) X (wait t)) X (set-buffer nntp-server-buffer) X ;; Wait for status response (RFC977). X ;; 1xx - Informative message. X ;; 2xx - Command ok. X ;; 3xx - Command ok so far, send the rest of it. X ;; 4xx - Command was correct, but couldn't be performed for some X ;; reason. X ;; 5xx - Command unimplemented, or incorrect, or a serious X ;; program error occurred. X (nntp-accept-response) X (while wait X (goto-char (point-min)) X (cond ((looking-at "[23]") X (setq wait nil)) X ((looking-at "[45]") X (setq status nil) X (setq wait nil)) X (t (nntp-accept-response)) X )) X ;; Save status message. X (end-of-line) X (setq nntp-status-message-string X (buffer-substring (point-min) (point))) X (if status X (progn X (setq wait t) X (while wait X (goto-char (point-max)) X (forward-line -1) ;(beginning-of-line) X ;;(message (buffer-substring X ;; (point) X ;; (save-excursion (end-of-line) (point)))) X (if (looking-at regexp) X (setq wait nil) X (message "NNTP: Reading...") X (nntp-accept-response) X (message "") X )) X ;; Successfully received server response. X t X )) X ))) X X X;;; X;;; Low-Level Interface to NNTP Server. X;;; X X(defun nntp-send-strings-to-server (&rest strings) X "Send list of STRINGS to news server as command and its arguments." X (let ((cmd (car strings)) X (strings (cdr strings))) X ;; Command and each argument must be separeted by one or more spaces. X (while strings X (setq cmd (concat cmd " " (car strings))) X (setq strings (cdr strings))) X ;; Command line must be terminated by a CR-LF. X (process-send-string nntp-server-process (concat cmd "\n")) X )) X X(defun nntp-send-region-to-server (begin end) X "Send current buffer region (from BEGIN to END) to news server." X (save-excursion X ;; We have to work in the buffer associated with NNTP server X ;; process because of NEmacs hack. X (copy-to-buffer nntp-server-buffer begin end) X (set-buffer nntp-server-buffer) X (setq begin (point-min)) X (setq end (point-max)) X ;; `process-send-region' does not work if text to be sent is very X ;; large. I don't know maximum size of text sent correctly. X (let ((last nil) X (size 100)) ;Size of text sent at once. X (save-restriction X (narrow-to-region begin end) X (goto-char begin) X (while (not (eobp)) X ;;(setq last (min end (+ (point) size))) X ;; NEmacs gets confused if character at `last' is Kanji. X (setq last (save-excursion X (goto-char (min end (+ (point) size))) X (or (eobp) (forward-char 1)) ;Adjust point X (point))) X (process-send-region nntp-server-process (point) last) X ;; I don't know whether the next codes solve the known X ;; problem of communication error of GNU Emacs. X (accept-process-output) X ;;(sit-for 0) X (goto-char last) X ))) X ;; We cannot erase buffer, because reply may be received. X (delete-region begin end) X )) X X(defun nntp-open-server-internal (host &optional service) X "Open connection to news server on HOST by SERVICE (default is nntp)." X (save-excursion X ;; Use TCP/IP stream emulation package if needed. X (or (fboundp 'open-network-stream) X (require 'tcp)) X ;; Initialize communication buffer. X (setq nntp-server-buffer (get-buffer-create " *nntpd*")) X (set-buffer nntp-server-buffer) X (buffer-flush-undo (current-buffer)) X (erase-buffer) X (kill-all-local-variables) X (setq case-fold-search t) ;Should ignore case. X (setq nntp-server-process X (open-network-stream "nntpd" (current-buffer) X host (or service "nntp"))) X (setq nntp-server-name host) X ;; It is possible to change kanji-fileio-code in this hook. X (run-hooks 'nntp-server-hook) X ;; Return the server process. X nntp-server-process X )) X X(defun nntp-close-server-internal () X "Close connection to news server." X (if nntp-server-process X (delete-process nntp-server-process)) X (if nntp-server-buffer X (kill-buffer nntp-server-buffer)) X (setq nntp-server-buffer nil) X (setq nntp-server-process nil)) X X(defun nntp-accept-response () X "Read response of server. XIt is well-known that the communication speed will be much improved by Xdefining this function as macro." X ;; To deal with server process exiting before X ;; accept-process-output is called. X ;; Suggested by Jason Venner . X ;; This is a copy of `nntp-default-sentinel'. X (or (memq (process-status nntp-server-process) '(open run)) X (error "NNTP: Connection closed.")) X (if nntp-buggy-select X (progn X ;; We cannot use `accept-process-output'. X ;; Fujitsu UTS requires messages during sleep-for. I don't know why. X (message "NNTP: Reading...") X (sleep-for 1) X (message "")) X (condition-case errorcode X (accept-process-output nntp-server-process) X (error X (cond ((string-equal "select error: Invalid argument" (nth 1 errorcode)) X ;; Ignore select error. X nil X ) X (t X (signal (car errorcode) (cdr errorcode)))) X )) X )) SHAR_EOF chmod 0644 nntp.el || echo "restore of nntp.el fails" set `wc -c nntp.el`;Sum=$1 if test "$Sum" != "21708" then echo original size 21708, current size $Sum;fi sed 's/^X//' << 'SHAR_EOF' > tcp.el && X;;; TCP/IP stream emulation for GNU Emacs X;; Copyright (C) 1988, 1989 Fujitsu Laboratories LTD. X;; Copyright (C) 1988, 1989 Masanobu UMEDA X;; $Header: tcp.el,v 1.4 89/06/19 13:38:59 umerin Exp $ X X;; This file is part of GNU Emacs. X X;; GNU Emacs is distributed in the hope that it will be useful, X;; but WITHOUT ANY WARRANTY. No author or distributor X;; accepts responsibility to anyone for the consequences of using it X;; or for whether it serves any particular purpose or works at all, X;; unless he says so in writing. Refer to the GNU Emacs General Public X;; License for full details. X X;; Everyone is granted permission to copy, modify and redistribute X;; GNU Emacs, but only under the conditions described in the X;; GNU Emacs General Public License. A copy of this license is X;; supposed to have been given to you along with GNU Emacs so you X;; can know your rights and responsibilities. It should be in a X;; file named COPYING. Among other things, the copyright notice X;; and this notice must be preserved on all copies. X X;; Notes on TCP package: X;; X;; This package provides a TCP/IP stream emulation on GNU Emacs. If X;; the function `open-network-stream' is not defined in Emacs, but X;; your operating system has a capability of network stream X;; connection, this tcp package can be used for communicating with X;; NNTP server. X;; X;; The tcp package runs inferior process named `tcp' which actually X;; does the role of `open-network-stream'. Before loading the package, X;; compile `tcp.c' and install it as `tcp' in a direcotry in the emacs X;; search path. If you modify `tcp.c', please send diffs to the author X;; of GNUS. I'll include some of them in the next releases. X X(provide 'tcp) X X(defvar tcp-program-name "tcp" X "A name of the program emulating open-network-stream function.") X X(defun open-network-stream (name buffer host service) X "Open a TCP connection for a service to a host. XReturns a subprocess-object to represent the connection. XInput and output work as for subprocesses; `delete-process' closes it. XArgs are NAME BUFFER HOST SERVICE. XNAME is name for process. It is modified if necessary to make it unique. XBUFFER is the buffer (or buffer-name) to associate with the process. X Process output goes at end of that buffer, unless you specify X an output stream or filter function to handle the output. X BUFFER may be also nil, meaning that this process is not associated X with any buffer XThird arg is name of the host to connect to. XFourth arg SERVICE is name of the service desired, or an integer X specifying a port number to connect to." X (let ((proc X (start-process name buffer X tcp-program-name X "-h" host X "-s" (if (stringp service) X service X (int-to-string service)) X ))) X (process-kill-without-query proc) X ;; Return process X proc X )) SHAR_EOF chmod 0644 tcp.el || echo "restore of tcp.el fails" set `wc -c tcp.el`;Sum=$1 if test "$Sum" != "2808" then echo original size 2808, current size $Sum;fi sed 's/^X//' << 'SHAR_EOF' > tcp.c && X/* X * TCP/IP stream emulation for GNU Emacs. X * Copyright (C) 1988, 1989 Fujitsu Laboratories LTD. X * Copyright (C) 1988, 1989 Masanobu UMEDA X * $Header: tcp.c,v 1.3 89/06/19 13:39:12 umerin Exp $ X X * This file is part of GNU Emacs. X X * GNU Emacs is distributed in the hope that it will be useful, X * but WITHOUT ANY WARRANTY. No author or distributor X * accepts responsibility to anyone for the consequences of using it X * or for whether it serves any particular purpose or works at all, X * unless he says so in writing. Refer to the GNU Emacs General Public X * License for full details. X X * Everyone is granted permission to copy, modify and redistribute X * GNU Emacs, but only under the conditions described in the X * GNU Emacs General Public License. A copy of this license is X * supposed to have been given to you along with GNU Emacs so you X * can know your rights and responsibilities. It should be in a X * file named COPYING. Among other things, the copyright notice X * and this notice must be preserved on all copies. X X * If you modify the source for your system, please send me the diffs. X * I'll includes some of them in the future releases. X * X * Yasunari,Itoh at PFU limited contributed for Fujitsu UTS and SX/A. X * X * Thu Apr 6 13:47:37 JST 1989 X * USG fixes by Sakaeda X * X * For Fujitsu UTS compile with: X * cc -O -o tcp tcp.c -DFUJITSU_UTS -lu -lsocket X */ X X#ifndef lint Xstatic char *rcsId = "$Header: tcp.c,v 1.3 89/06/19 13:39:12 umerin Exp $"; X#endif X X#include X#include X#include X#include X X#ifdef FUJITSU_UTS X#define USG X#include X#include X#include X#include X#else X#include X#include X#include X#endif X X#ifdef USG X#include X#include X#endif X X#ifdef FUJITSU_UTS X#define bcopy(f,t,n) memcpy(t,f,n) X#define bcmp(b1,b2,n) (memcmp(b1,b2,n)!=0) X#define bzero(b,n) memset(b,0,n) X#endif X X#ifdef USG Xint selectable = 1; X Xsigout() X{ X fcntl(fileno(stdin),F_SETFL,0); X exit(-1); X} X#endif X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X struct hostent *host; X struct sockaddr_in sockin, sockme; X struct servent *serv; X char *hostname; X char *service = "nntp"; X int port; X int readfds; X int writefds; X int server; /* NNTP Server */ X int emacsIn = fileno(stdin); /* Emacs intput */ X int emacsOut = fileno(stdout); /* Emacs output */ X char buffer[1024]; X int nbuffer; /* Number of bytes in buffer */ X int wret; X char *retry; /* retry bufferp */ X X while(--argc > 0){ X switch(**(++argv)){ X case '-': X { X char *p = &argv[0][1]; X if(strcmp(p,"s")==0){ /* Service name */ X service = *(++argv); X --argc; X } else if(strcmp(p,"h")==0){ /* Host name */ X hostname = *(++argv); X --argc; X } else { X fprintf(stderr, "Usage: tcp -h HOST -s SERVICE\n"); X exit(1); X } X } X break; X default: X fprintf(stderr, "Usage: tcp -h HOST [-s SERVICE]\n"); X exit(1); X break; X } X } X X if((host = gethostbyname(hostname)) == NULL){ X perror("gethostbyname"); X exit(1); X } X if(isdigit(service[0])) X port = atoi(service); X else { X serv = getservbyname(service, "tcp"); X if(serv == NULL){ X perror("getservbyname"); X exit(1); X } X port = serv->s_port; X } X X bzero(&sockin, sizeof(sockin)); X sockin.sin_family = host->h_addrtype; X bcopy(host->h_addr, &sockin.sin_addr, host->h_length); X sockin.sin_port = htons(port); X if((server = socket(AF_INET, SOCK_STREAM, 0)) < 0) { X perror("socket"); X exit(1); X } X if(setsockopt(server, SOL_SOCKET, SO_REUSEADDR, 0, 0)) { X perror("setsockopt"); X exit(1); X } X bzero(&sockme, sizeof(sockme)); X sockme.sin_family = sockin.sin_family; X sockme.sin_addr.s_addr = INADDR_ANY; X if(bind(server, &sockme, sizeof(sockme)) < 0){ X perror("bind"); X exit(1); X } X if(connect(server, &sockin, sizeof (sockin)) < 0){ X perror("connect"); X close(server); X exit(1); X } X X#ifdef O_NDELAY X fcntl(server, F_SETFL, O_NDELAY); X X#ifdef USG X /* USG pipe cannot not select emacsIn */ X { X struct stat statbuf; X fstat (emacsIn,&statbuf); X if (statbuf.st_mode & 010000) X selectable = 0; X if (!selectable){ X signal(SIGINT,sigout); X fcntl(emacsIn, F_SETFL, O_NDELAY); X } X } X#endif X#endif X X /* Connection established. */ X while(1){ X readfds = (1 << server) | (1 << emacsIn); X if(select(32, &readfds, NULL, NULL, (struct timeval *)NULL) == -1){ X perror("select"); X exit(1); X } X if(readfds & (1 << emacsIn)){ X /* From Emacs */ X nbuffer = read(emacsIn, buffer, sizeof buffer -1); X X#ifdef USG X if (selectable && nbuffer == 0){ X goto finish; X } else if (!(readfds & (1 << server)) && nbuffer == 0){ X sleep (1); X } else X#else X if(nbuffer == 0) X goto finish; X#endif X for(retry = buffer; nbuffer > 0; nbuffer -= wret, retry += wret){ X writefds = 1 << server; X if(select(server+1,NULL,&writefds,NULL,(struct timeval*)NULL) == -1){ X perror("select"); X exit(1); X } X wret = write(server, retry, nbuffer); X if(wret < 0) goto finish; X } X } X if(readfds & (1 << server)){ X /* From NNTP server */ X nbuffer = read(server, buffer, sizeof buffer -1); X if(nbuffer == 0) X goto finish; X for(retry = buffer; nbuffer > 0; nbuffer -= wret, retry += wret){ X writefds = 1 << emacsOut; X#ifdef USG X if(selectable) X#endif X if(select(emacsOut+1,NULL,&writefds,NULL,(struct timeval*)NULL) == -1){ X perror("select"); X exit(1); X } X wret = write(emacsOut, retry, nbuffer); X if(wret < 0) goto finish; X } X } X } X X /* End of communication. */ X finish: X close(server); X#ifdef USG X if (!selectable) fcntl(emacsIn, F_SETFL,0); X#endif X close(emacsIn); X close(emacsOut); X exit(0); X} SHAR_EOF chmod 0644 tcp.c || echo "restore of tcp.c fails" set `wc -c tcp.c`;Sum=$1 if test "$Sum" != "5851" then echo original size 5851, current size $Sum;fi sed 's/^X//' << 'SHAR_EOF' > gnus.texinfo && X\input texinfo @c -*-texinfo-*- X@comment %**start of header (This is for running Texinfo on a region.) X@setfilename ../info/gnus X@settitle GNUS 3.12 Manual X@iftex X@finalout X@end iftex X@setchapternewpage odd X@c @smallbook X@comment %**end of header (This is for running Texinfo on a region.) X X@tex X\overfullrule=0pt X%\global\baselineskip 30pt % For printing in double spaces X@end tex X X@ifinfo XThis file documents GNUS, the GNU Emacs newsreader. X XCopyright (C) 1989 Fujitsu Laboratories LTD. XCopyright (C) 1989 Masanobu UMEDA. X XPermission is granted to make and distribute verbatim copies of this Xmanual provided the copyright notice and this permission notice are Xpreserved on all copies. X X@ignore XPermission is granted to process this file through TeX and print the Xresults, provided the printed document carries copying permission notice Xidentical to this one except for the removal of this paragraph (this Xparagraph not being relevant to the printed manual). X X@end ignore XPermission is granted to copy and distribute modified versions of this Xmanual under the conditions for verbatim copying, provided also that the Xsections entitled ``Distribution'' and ``GNUS General Public License'' Xare included exactly as in the original, and provided that the entire Xresulting derived work is distributed under the terms of a permission Xnotice identical to this one. X XPermission is granted to copy and distribute translations of this manual Xinto another language, under the above conditions for modified versions, Xexcept that the sections entitled ``Distribution'' and ``GNUS General XPublic License'' may be included in a translation approved by the author Xinstead of in the original English. X@end ifinfo X X@titlepage X@sp 6 X@center @titlefont{GNUS Manual} X@sp 4 X@center Second Edition, GNUS Version 3.12 X@sp 1 X@center June 1989 X@sp 5 X@center Masanobu UMEDA X@page X X@vskip 0pt plus 1filll XCopyright @copyright{} 1989 Fujitsu Laboratories LTD. X XPermission is granted to make and distribute verbatim copies of Xthis manual provided the copyright notice and this permission notice Xare preserved on all copies. X XPermission is granted to copy and distribute modified versions of this Xmanual under the conditions for verbatim copying, provided also that the Xsections entitled ``Distribution'' and ``GNUS General Public License'' Xare included exactly as in the original, and provided that the entire Xresulting derived work is distributed under the terms of a permission Xnotice identical to this one. X XPermission is granted to copy and distribute translations of this manual Xinto another language, under the above conditions for modified versions, Xexcept that the sections entitled ``Distribution'' and ``GNUS General XPublic License'' may be included in a translation approved by the author Xinstead of in the original English. X@end titlepage X@page X X@ifinfo X@node Top, Introduction,, (DIR) X XThe GNUS Newsreader X******************* X X GNUS is a network newsreader for GNU Emacs. This Info file describes Xhow to read and write USENET articles using GNUS and how to customize GNUS. X X@end ifinfo X@menu X* Distribution:: How to get the latest GNUS distribution. X* License:: Permission to redistribute GNUS on certain terms. X* Acknowledgments:: I would like to thank many people who have helped me. X X* Introduction:: An introduction to GNUS. X* Installation:: How to install GNUS. X* Starting up:: How to get started with GNUS. X* Buffers of GNUS:: Buffers used by GNUS. X* Newsgroup Commands:: Browsing through newsgroups. X* Subject Commands:: Browsing through headers and messages. X* Article Commands:: Commands for an article. X* KILL File:: How to use KILL files. X X* Customization:: How to customize GNUS. X* Problems:: How to solve problems with GNUS. X* Reporting Bugs:: Mailing lists and USENET newsgroups for GNUS lovers. X How to report bugs. X X* Key Index:: An item for each standard GNUS key sequence. X* Command Index:: An item for each command name. X* Variable Index:: An item for each documented variable. X* Program Index:: An item for each program. X* Concept Index:: An item for each concept. X@end menu X X@node Distribution, License, Top, Top X@unnumbered Distribution X XGNUS is @dfn{free}; this means that everyone is free to use it and free Xto redistribute it on a free basis. GNUS is not in the public domain; Xit is copyrighted and there are restrictions on its distribution, but Xthese restrictions are designed to permit everything that a good Xcooperating citizen would want to do. What is not allowed is to try to Xprevent others from further sharing any version of GNUS that they might Xget from you. The precise conditions appears following this section. X XThe easiest way to get a copy of GNUS is from someone else who has it. XYou need not ask for permission to do so, or tell any one else; just Xcopy it. X XIf you have access to the Internet, you can get the latest version of XGNUS from tut.cis.ohio-state.edu [128.146.8.60] using anonymous ftp. XYou can also get it from osu-cis using anonymous uucp. X XYou may also receive GNUS when you buy a computer. Computer Xmanufacturers are free to distribute copies on the same terms that apply Xto everyone else. These terms require them to give you the full Xsources, including whatever changes they may have made, and to permit Xyou to redistribute the GNUS received from them under the usual terms of Xthe General Public License. In other words, the program must be free Xfor you when you get it, not just free for the manufacturer. X XIf you cannot get a copy in any of those ways, you can order one from Xthe author using electronic mail. For further information, write to: X X@display Xumerin@@flab.Fujitsu.CO.JP, or Xumerin%flab.Fujitsu.JUNET@@uunet.uu.NET X@end display X XIf you cannot reach the author using these addresses, try the following Xmailing list: X X@cindex info-gnus-english X@display Xinfo-gnus-english@@tut.cis.ohio-state.edu X@end display X X@noindent XThe list is intended to exchange useful information about GNUS, such as Xbug reports, useful hooks, and extensions. Feel free to ask about the Xnearest machine that has GNUS installed. Subscription requests for this Xlist should be sent to: X X@display Xinfo-gnus-english-request@@tut.cis.ohio-state.edu X@end display X X@noindent X@xref{Reporting Bugs}, for more information on the mailing list.@refill X X@node License, Acknowledgments, Distribution, Top X@unnumbered GNUS General Public License X@center (Clarified 13 Jan 1989) X X The license agreements of most software companies keep you at the Xmercy of those companies. By contrast, our general public license is Xintended to give everyone the right to share GNUS. To make sure that Xyou get the rights we want you to have, we need to make restrictions Xthat forbid anyone to deny you these rights or to ask you to surrender Xthe rights. Hence this license agreement. X X Specifically, we want to make sure that you have the right to give Xaway copies of GNUS, that you receive source code or else can get it if Xyou want it, that you can change GNUS or use pieces of it in new free Xprograms, and that you know you can do these things. X X To make sure that everyone has such rights, we have to forbid you to Xdeprive anyone else of these rights. For example, if you distribute Xcopies of GNUS, you must give the recipients all the rights that you Xhave. You must make sure that they, too, receive or can get the source Xcode. And you must tell them their rights. X X Also, for our own protection, we must make certain that everyone finds Xout that there is no warranty for GNUS. If GNUS is modified by someone Xelse and passed on, we want its recipients to know that what they have Xis not what we distributed, so that any problems introduced by others Xwill not reflect on our reputation. X X Therefore I (Masanobu Umeda)@: use the following terms, which are Xwritten for GNU Emacs by Richard Stallman and the Free Software XFoundation, Inc. They say what you must do to be allowed to distribute Xor change GNU Emacs. You can know your right to distribute or change XGNUS by replacing any occurrences of GNU Emacs with GNUS. Please apply Xthe same policies to GNUS as GNU Emacs.@refill X X@unnumberedsec Copying Policies X X@enumerate X@item XYou may copy and distribute verbatim copies of GNU Emacs source code as Xyou receive it, in any medium, provided that you conspicuously and Xappropriately publish on each file a valid copyright notice ``Copyright X@copyright{} 1988 Free Software Foundation, Inc.'' (or with whatever Xyear is appropriate); keep intact the notices on all files that refer to Xthis License Agreement and to the absence of any warranty; and give any Xother recipients of the GNU Emacs program a copy of this License XAgreement along with the program. You may charge a distribution fee for Xthe physical act of transferring a copy. X X@item XYou may modify your copy or copies of GNU Emacs source code or Xany portion of it, and copy and distribute such modifications under Xthe terms of Paragraph 1 above, provided that you also do the following: X X@itemize @bullet X@item Xcause the modified files to carry prominent notices stating Xwho last changed such files and the date of any change; and X X@item Xcause the whole of any work that you distribute or publish, that Xin whole or in part contains or is a derivative of GNU Emacs or any Xpart thereof, to be licensed at no charge to all third parties on Xterms identical to those contained in this License Agreement X(except that you may choose to grant more extensive warranty Xprotection to some or all third parties, at your option). X X@item Xif the modified program serves as a text editor, cause it, when Xstarted running in the simplest and usual way, to print an Xannouncement including a valid copyright notice ``Copyright X@copyright{} 1988 Free Software Foundation, Inc.'' (or with the Xyear that is appropriate), saying that there is no warranty (or Xelse, saying that you provide a warranty) and that users may Xredistribute the program under these conditions, and telling the Xuser how to view a copy of this License Agreement. X X@item XYou may charge a distribution fee for the physical act of Xtransferring a copy, and you may at your option offer warranty Xprotection in exchange for a fee. X@end itemize X XMere aggregation of another unrelated program with this program (or its Xderivative) on a volume of a storage or distribution medium does not bring Xthe other program under the scope of these terms. X X@item XYou may copy and distribute GNU Emacs (or a portion or derivative of it, Xunder Paragraph 2) in object code or executable form under the terms Xof Paragraphs 1 and 2 above provided that you also do one of the Xfollowing: X X@itemize @bullet X@item Xaccompany it with the complete corresponding machine-readable Xsource code, which must be distributed under the terms of XParagraphs 1 and 2 above; or, X X@item Xaccompany it with a written offer, valid for at least three Xyears, to give any third party free (except for a nominal Xshipping charge) a complete machine-readable copy of the Xcorresponding source code, to be distributed under the terms of XParagraphs 1 and 2 above; or, X X@item Xaccompany it with the information you received as to where the Xcorresponding source code may be obtained. (This alternative is Xallowed only for noncommercial distribution and only if you Xreceived the program in object code or executable form alone.) X@end itemize X XFor an executable file, complete source code means all the source code Xfor all modules it contains; but, as a special exception, it need not Xinclude source code for modules which are standard libraries that Xaccompany the operating system on which the executable file runs. X X@item XYou may not copy, sublicense, distribute or transfer GNU Emacs except Xas expressly provided under this License Agreement. Any attempt Xotherwise to copy, sublicense, distribute or transfer GNU Emacs is Xvoid and your rights to use GNU Emacs under this License agreement Xshall be automatically terminated. However, parties who have received Xcomputer software programs from you with this License Agreement will Xnot have their licenses terminated so long as such parties remain in Xfull compliance. X X@item XIf you wish to incorporate parts of GNU Emacs into other free programs Xwhose distribution conditions are different, write to the Free Software XFoundation. We have not yet worked out a simple rule that can be stated Xhere, but we will often permit this. We will be guided by the two goals of Xpreserving the free status of all derivatives of our free software and of Xpromoting the sharing and reuse of software. X@end enumerate X XYour comments and suggestions about our licensing policies and our Xsoftware are welcome! Please contact the Free Software Foundation, Inc., X675 Mass Ave, Cambridge, MA 02139. X X@iftex X@vfil X@eject X@end iftex X@unnumberedsec NO WARRANTY X X BECAUSE GNUS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO XWARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN XOTHERWISE STATED IN WRITING, FUJITSU LABORATORIES LTD., MASANOBU UMEDA XAND/OR OTHER PARTIES PROVIDE GNUS ``AS IS'' WITHOUT WARRANTY OF ANY XKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR XPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE XPROGRAM IS WITH YOU. SHOULD THE GNUS PROGRAM PROVE DEFECTIVE, YOU XASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. X X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FUJITSU LABORATORIES XLTD., MASANOBU UMEDA, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND XREDISTRIBUTE GNUS AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, XINCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR XCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE X(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED XINACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE XPROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY MASANOBU UMEDA) THE XPROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH XDAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. X X@node Acknowledgments, Introduction, License, Top X@unnumbered Acknowledgments X X The author would like to thank all those who have helped design and Xdevelop GNUS, and who tested non stable code at their own risk. X X Haruo Yokota, Hiroyuki Yoshida, and Kohji Akiyama contributed many Xvaluable suggestions in the early stages of the development of GNUS. XNobuyuki Hiraoka, Tsuneo Nakata, and Mark Feldman patiently tested non Xstable code and contributed valuable comments. Mark Feldman also helped Xwith proofreading. Mike Khaw, Kouich Kumon, and Mitsuhiro Kishimoto Xhelped contribute the name GNUS. Itaru Ichikawa helped implement the Xcaesar rotations for Japanese characters. Yasunari Itoh, Akio Shibata, Xand Ken-ichi Sakaeda made this software available on SX/A Emacs and some Xold versions of GNU Emacs. Leonard H. Tower Jr., Bob Sutterfield, and XKarl Kleinpaste helped create mailing lists for GNUS users. Bob XSutterfield has also been managing the info-gnus-english mailing list. XJordan K. Hubbard helped with proofreading of this Texinfo manual. X X The author would also like to thank many other GNUS users who have Xsent comments, suggestions, and bug fixes. Thanks also go to Richard XStallman and the Free Software Foundation for their good work. X X@node Introduction, Installation, Top, Top X@unnumbered Introduction X X GNUS is a program for reading and writing USENET news using GNU Emacs. XThis manual documents the use and simple customization of GNUS. X X@pindex rn X Unlike other conventional newsreaders such as rn which was (:-) the Xmost popular newsreader in the world, GNUS runs inside the GNU Emacs Xeditor as a subsystem. This means that there is no need to invoke an Xeditor when composing articles or mail. The reading and writing of Xarticles can be done in the same Emacs environment you usually work in. X X@pindex rrn X@cindex NNTP X Like rrn, a remote version of rn, GNUS can use computer networks for Xretrieving articles. This means that there is no need to have a local Xcopy of the news spool, to mount a remote file system over the network, Xor to run Emacs on a remote machine. Its great advantage is to balance Xloads and exploit resources of the entire computer system in a Xdistributed environment. The protocol used by GNUS is @dfn{NNTP}, the XNetwork News Transfer Protocol, defined by RFC977.@refill X X Unlike rrn, GNUS can talk to many NNTP servers easily. The only thing Xyou have to do is to create startup files for each NNTP server. X X Like other libraries of GNU Emacs, GNUS is completely written in Emacs Xlisp. This means that GNUS is highly extensible and customizable just Xlike GNU Emacs. It is possible to change the behavior of GNUS and Xextend its functions by using variables and hooks. X X GNUS is pronounced @strong{``NUZ''}. Never call it X@strong{``ghu-NUZ''} nor @strong{``ghu-NAS''}.@refill X X This manual is currently in progress and thus is incomplete. Your Xsuggestions, bug fixes, and contributions are welcome. X X@node Installation, Starting up, Introduction, Top X@chapter Installing GNUS X@cindex install GNUS X@cindex how to install GNUS X X Installation of GNUS and some initialization of your computing Xenvironment are described in this chapter. Please read the following Xsections carefully before getting started with GNUS. X X@menu X* Files of GNUS:: How many files of GNUS are there? X* Compilation:: How to byte-compile lisp sources. X* Autoloading:: How to define autoload entries. X* Environment:: How to define your environment. X* Texinfo Manual:: How to install an Info file and print the manual. X@end menu X X@node Files of GNUS, Compilation, Installation, Installation X@section Files of GNUS X@cindex GNUS files X@cindex files of GNUS X X Unpacking the shar files will produce the following files. They are Xthe Emacs lisp sources, a C source, a Texinfo manual of GNUS, and a XMakefile. X X@table @file X@pindex gnus.el X@item gnus.el XMain part of GNUS newsreader. X X@pindex gnuspost.el X@item gnuspost.el XPost news commands. X X@pindex gnusmisc.el X@item gnusmisc.el XMiscellaneous commands. X X@pindex nntp.el X@item nntp.el XNNTP package. X X@pindex nnspool.el X@item nnspool.el XA package accessing local news spool like NNTP. X X@pindex mhspool.el X@item mhspool.el XA package accessing private directory like NNTP. X X@pindex tcp.el X@findex open-network-stream X@item tcp.el XPatches to some versions of GNU Emacs which do not have the function X@code{open-network-stream}.@refill X X@pindex tcp.c X@item tcp.c XC program for external TCP/IP implementation. This is used with X@file{tcp.el}.@refill X X@pindex gnus.texinfo X@item gnus.texinfo XTexinfo manual of GNUS. X X@pindex Makefile X@pindex make X@item Makefile XMakefile to byte-compile the lisp files using the @file{make} command. X@end table X X@node Compilation, Autoloading, Files of GNUS, Installation X@section Byte-Compilation X@cindex byte-compilation X@cindex compilation of lisp files X X@pindex make X@vindex load-path X Move the lisp files, the C file, and @file{Makefile} to the Xappropriate directory in the search path defined by the variable X@code{load-path}. Before actually byte-compiling the lisp files, make Xsure there are no byte-compiled files of older versions of GNUS in that Xdirectory. Remove or rename such files as the byte-compiler may be Xconfused by old macro definitions. If you can use the @file{make} Xcommand, you don't have to take care of the dependencies.@refill X X@vindex exec-path X@pindex tcp.c X The C file @file{tcp.c} should be compiled with a C compiler and Xinstalled in a directory in the search path defined by the variable X@code{exec-path}, if this is required.@refill X X If you can use the @file{make} command, just type @code{make} in a XUnix shell. All the lisp files will be byte-compiled. Otherwise, Xbyte-compile lisp files in the following order according to your Xcomputing environment by yourself:@refill X X@enumerate X@item X@pindex nntp.el X@pindex gnus.el X@pindex gnuspost.el X@pindex gnusmisc.el XByte-compile @file{nntp.el}, @file{gnus.el}, @file{gnuspost.el}, and X@file{gnusmisc.el} in this order.@refill X X@item X@pindex nnspool.el XByte-compile @file{nnspool.el} if you want to use the local news spool Xof your machine instead of NNTP (@pxref{Local News Spool}).@refill X X@item X@pindex mhspool.el XByte-compile @file{mhspool.el} if you want to read articles or mail in Xyour private directory using GNUS (@pxref{Private Directory}).@refill X X@item X@cindex TCP/IP X@pindex tcp.el X@pindex tcp.c XCompile and install @file{tcp.el} and @file{tcp.c} if TCP/IP is not Xsupported by Emacs but is supported by your operating system.@refill X@end enumerate X X@findex open-network-stream X @file{tcp.el} defines the function @code{open-network-stream}, and X@file{tcp.c} is an emulation program for the stream used by the Xfunction. If you modified @file{tcp.c} for your system, please send the Xauthor the diffs. Some of them will be included in the future releases Xof GNUS.@refill X X@node Autoloading, Environment, Compilation, Installation X@section Autoloading X@cindex autoload X X It is useful to define autoload entries in @file{.emacs}, X@file{site-init.el} or @file{default.el} as follows:@refill X X@example X(autoload 'gnus "gnus" "Read network news." t) X(autoload 'gnus-post-news "gnuspost" "Post a new news." t) X@end example X X@node Environment, Texinfo Manual, Autoloading, Installation X@section Environment X X The NNTP server and its service name, your domain and organization, SHAR_EOF echo "End of part 7, continue with part 8" echo "8" > s2_seq_.tmp exit 0