home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / nntp1.5 / part02 < prev    next >
Encoding:
Internet Message Format  |  1988-04-18  |  59.1 KB

  1. Subject:  v14i048:  Network News Transfer Protocol, version 1.5, Part02/09
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Phil Lapsley <phil@ucbvax.berkeley.edu>
  7. Posting-number: Volume 14, Issue 48
  8. Archive-name: nntp1.5/part02
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 2 (of 9)."
  17. # Wrapped by rsalz@fig.bbn.com on Tue Apr 19 18:16:37 1988
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f './common/nntp.h' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'./common/nntp.h'\"
  21. else
  22. echo shar: Extracting \"'./common/nntp.h'\" \(2530 characters\)
  23. sed "s/^X//" >'./common/nntp.h' <<'END_OF_FILE'
  24. X/*
  25. X * Response codes for NNTP server
  26. X *
  27. X * @(#)nntp.h    1.7    (Berkeley) 1/11/88
  28. X *
  29. X * First digit:
  30. X *
  31. X *    1xx    Informative message
  32. X *    2xx    Command ok
  33. X *    3xx    Command ok so far, continue
  34. X *    4xx    Command was correct, but couldn't be performed
  35. X *        for some specified reason.
  36. X *    5xx    Command unimplemented, incorrect, or a
  37. X *        program error has occured.
  38. X *
  39. X * Second digit:
  40. X *
  41. X *    x0x    Connection, setup, miscellaneous
  42. X *    x1x    Newsgroup selection
  43. X *    x2x    Article selection
  44. X *    x3x    Distribution
  45. X *    x4x    Posting
  46. X */
  47. X
  48. X#define    CHAR_INF    '1'
  49. X#define    CHAR_OK        '2'
  50. X#define    CHAR_CONT    '3'
  51. X#define    CHAR_ERR    '4'
  52. X#define    CHAR_FATAL    '5'
  53. X
  54. X#define    INF_HELP    100    /* Help text on way */
  55. X#define    INF_DEBUG    199    /* Debug output */
  56. X
  57. X#define    OK_CANPOST    200    /* Hello; you can post */
  58. X#define    OK_NOPOST    201    /* Hello; you can't post */
  59. X#define    OK_SLAVE    202    /* Slave status noted */
  60. X#define    OK_GOODBYE    205    /* Closing connection */
  61. X#define    OK_GROUP    211    /* Group selected */
  62. X#define    OK_GROUPS    215    /* Newsgroups follow */
  63. X#define    OK_ARTICLE    220    /* Article (head & body) follows */
  64. X#define    OK_HEAD        221    /* Head follows */
  65. X#define    OK_BODY        222    /* Body follows */
  66. X#define    OK_NOTEXT    223    /* No text sent -- stat, next, last */
  67. X#define    OK_NEWNEWS    230    /* New articles by message-id follow */
  68. X#define    OK_NEWGROUPS    231    /* New newsgroups follow */
  69. X#define    OK_XFERED    235    /* Article transferred successfully */
  70. X#define    OK_POSTED    240    /* Article posted successfully */
  71. X
  72. X#define CONT_XFER    335    /* Continue to send article */
  73. X#define    CONT_POST    340    /* Continue to post article */
  74. X
  75. X#define    ERR_GOODBYE    400    /* Have to hang up for some reason */
  76. X#define    ERR_NOGROUP    411    /* No such newsgroup */
  77. X#define    ERR_NCING    412    /* Not currently in newsgroup */
  78. X#define    ERR_NOCRNT    420    /* No current article selected */
  79. X#define    ERR_NONEXT    421    /* No next article in this group */
  80. X#define    ERR_NOPREV    422    /* No previous article in this group */
  81. X#define    ERR_NOARTIG    423    /* No such article in this group */
  82. X#define ERR_NOART    430    /* No such article at all */
  83. X#define ERR_GOTIT    435    /* Already got that article, don't send */
  84. X#define ERR_XFERFAIL    436    /* Transfer failed */
  85. X#define    ERR_XFERRJCT    437    /* Article rejected, don't resend */
  86. X#define    ERR_NOPOST    440    /* Posting not allowed */
  87. X#define    ERR_POSTFAIL    441    /* Posting failed */
  88. X
  89. X#define    ERR_COMMAND    500    /* Command not recognized */
  90. X#define    ERR_CMDSYN    501    /* Command syntax error */
  91. X#define    ERR_ACCESS    502    /* Access to server denied */
  92. X#define ERR_FAULT    503    /* Program fault, command not performed */
  93. X
  94. X/* RFC 977 defines this; don't change it. */
  95. X
  96. X#define    NNTP_STRLEN    512
  97. END_OF_FILE
  98. if test 2530 -ne `wc -c <'./common/nntp.h'`; then
  99.     echo shar: \"'./common/nntp.h'\" unpacked with wrong size!
  100. fi
  101. # end of './common/nntp.h'
  102. fi
  103. if test -f './doc/config.sh' -a "${1}" != "-c" ; then 
  104.   echo shar: Will not clobber existing file \"'./doc/config.sh'\"
  105. else
  106. echo shar: Extracting \"'./doc/config.sh'\" \(1847 characters\)
  107. sed "s/^X//" >'./doc/config.sh' <<'END_OF_FILE'
  108. X#!/bin/sh
  109. X#
  110. X# Shell script for making manual pages
  111. X#
  112. X# Created by Stan Barber; Mon Apr  6 13:25:27 CDT 1987
  113. X# Modified by Phil Lapsley; Thu Oct 15 17:43:40 PDT 1987
  114. X#
  115. X
  116. X#
  117. X# ------------- SITE DEPENDENT STUFF ---------------------------
  118. X# (modify these lines to suit your system)
  119. X#
  120. X# the location of inetd on your system (usually /etc/inetd)
  121. MINETD=/etc/inetd
  122. X# the location of the inetd configuration file (usually /etc/inetd.conf)
  123. MINETDCONFIG=/etc/inetd.conf
  124. X# the location of nntpd following installation (usually /etc/nntpd)
  125. MNNTPD=/etc/nntpd
  126. X# the location of the hosts file (usually /etc/hosts)
  127. MHOSTFILE=/etc/hosts
  128. X# the location of the services file (usually /etc/services)
  129. MSERVICES=/etc/services
  130. X# the location of the networks file (usually /etc/networks)
  131. MNETWORKFILE=/etc/networks
  132. X# The location of the news spool directory (usually /usr/spool/news)
  133. MNEWSSPOOL=/usr/spool/news
  134. X# The location of the news library directory (usually /usr/lib/news)
  135. MNEWSLIB=/usr/lib/news
  136. X# The location of the file containing the name of the nntp server machine
  137. X# (usually /usr/local/lib/rn/server)
  138. MSERVERFILE=/usr/local/lib/rn/server
  139. X# The location of rn's local library (usually /usr/local/lib/rn)
  140. MRNLIB=/usr/local/lib/rn
  141. X#
  142. X# ------------ END OF SITE DEPENDENT STUFF ---------------------
  143. X# (you should not have to touch anything below).
  144. X
  145. echo "Extracting $2 from $1 ..."
  146. X
  147. X( 
  148. echo g%NEWSLIB%s%NEWSLIB%$MNEWSLIB%
  149. echo g%NEWSSPOOL%s%NEWSSPOOL%$MNEWSSPOOL%
  150. echo g%INETDCONFIG%s%INETDCONFIG%$MINETDCONFIG%
  151. echo g%LNNTPD%s%LNNTPD%$MNNTPD%
  152. echo g%INETD%s%INETD%$MINETD%
  153. echo g%HOSTFILE%s%HOSTFILE%$MHOSTFILE%
  154. echo g%SERVICES%s%SERVICES%$MSERVICES%
  155. echo g%NETWORKFILE%s%NETWORKFILE%$MNETWORKFILE%
  156. echo g%RNLIB%s%RNLIB%$MRNLIB%
  157. echo w
  158. echo q
  159. X) > /tmp/ed.$$
  160. X
  161. rm -f $2
  162. cp $1 $2
  163. chmod 644 $2
  164. X(ed $2 < /tmp/ed.$$) 2>&1 > /dev/null
  165. rm /tmp/ed.$$
  166. X
  167. echo "Finished."
  168. END_OF_FILE
  169. if test 1847 -ne `wc -c <'./doc/config.sh'`; then
  170.     echo shar: \"'./doc/config.sh'\" unpacked with wrong size!
  171. fi
  172. chmod +x './doc/config.sh'
  173. # end of './doc/config.sh'
  174. fi
  175. if test -f './doc/mkgrdates.dst' -a "${1}" != "-c" ; then 
  176.   echo shar: Will not clobber existing file \"'./doc/mkgrdates.dst'\"
  177. else
  178. echo shar: Extracting \"'./doc/mkgrdates.dst'\" \(1911 characters\)
  179. sed "s/^X//" >'./doc/mkgrdates.dst' <<'END_OF_FILE'
  180. X.\"
  181. X.\" @(#)mkgrdates.dst    1.3    (Berkeley) 10/15/87
  182. X.\"
  183. X.TH MKGRDATES 8C "26 October 1985"
  184. X.UC 4
  185. X.SH NAME
  186. mkgrdates \- Make the newsgroup creation date file
  187. for the NNTP server
  188. X.SH SYNOPSIS
  189. X.B NEWSLIB/mkgrdates
  190. X.SH NOTICE
  191. X.I Mkgrdates
  192. is no longer used, and does not need to be run
  193. from crontab.
  194. It is included only for completeness and backward compatibility.
  195. For more information, see the manual page for
  196. X.I nntpd.
  197. X.SH DESCRIPTION
  198. X.I Mkgrdates
  199. maintains the newsgroup creation date file for the
  200. Network News Transfer Protocol server,
  201. which uses it for the NEWGROUPS command.
  202. When executed,
  203. X.I mkgrdates
  204. goes through the active file,
  205. X.IR NEWSLIB/active ,
  206. and creates the file
  207. X.I NEWSLIB/groupdates
  208. containing the creation dates and times of the
  209. newsgroups in the active file.  The
  210. X.I groupdates
  211. file has one line for each newsgroup, in the form
  212. X``date newsgroup'' where ``date'' is the newsgroup's
  213. creation time, in seconds since midnight, Jan. 1,
  214. X1970, GMT,
  215. and ``newsgroup'' is the name of the newsgroup in question.
  216. X.PP
  217. Since generating the
  218. X.I groupdates
  219. file is expensive, when
  220. X.I mkgrdates
  221. is run it creates the file
  222. X.I NEWSLIB/mkgdstats
  223. containing the length, in bytes, of the active file.
  224. The next time
  225. X.I mkgrdates
  226. is invoked, it compares the contents of the
  227. X.I mkgdstats
  228. file against the length of the active file, and
  229. exits if these lengths are the same.  If the
  230. lengths are not the same, it rebuilds the
  231. X.I groupdates
  232. file, and sets the
  233. X.I mkgdstats
  234. file to the appropriate value.
  235. This scheme avoids a fair amount of what would
  236. be wasted computing.
  237. X.PP
  238. X.I Mkgrdates
  239. should be run once or twice a day by an entry in
  240. X.I /usr/lib/crontab
  241. X.SH BUGS
  242. It's a crock;
  243. X.I mkgrdates'
  244. function needs to be done by the news system.
  245. NNTP version 1.4 does not use this program at all,
  246. and decides whether a group is ``new'' or not by
  247. a (rather poor) heuristic.
  248. X.SH AUTHOR
  249. Phil Lapsley
  250. X.SH SEE ALSO
  251. cron(1),
  252. nntpd(8C)
  253. END_OF_FILE
  254. if test 1911 -ne `wc -c <'./doc/mkgrdates.dst'`; then
  255.     echo shar: \"'./doc/mkgrdates.dst'\" unpacked with wrong size!
  256. fi
  257. # end of './doc/mkgrdates.dst'
  258. fi
  259. if test -f './inews/README' -a "${1}" != "-c" ; then 
  260.   echo shar: Will not clobber existing file \"'./inews/README'\"
  261. else
  262. echo shar: Extracting \"'./inews/README'\" \(2253 characters\)
  263. sed "s/^X//" >'./inews/README' <<'END_OF_FILE'
  264. X
  265. X     This is a "pseudo" inews which allows remote posting using
  266. the NNTP server.  Essentially it takes a bunch of arguments and ignores
  267. ones starting with "-", expecting to find at least one which is
  268. a file name.  If no files are specified, it uses standard input
  269. as the input file.
  270. X
  271. X     It then opens a connection to the NNTP server on the remote
  272. machine and blasts the article across.  It then closes the connection.
  273. If it doesn't find a From: or Path: line, it inserts them, in the
  274. default format
  275. X
  276. X    From: login@hostname.DOMAIN (Full_name)
  277. X    Path: hostname!login
  278. X
  279. where DOMAIN is a #define in ../common/conf.h, and should be changed
  280. to reflect your system.  A good choice is .UUCP if you are not a
  281. member of the Internet.  "Full_name" understands the & hack in
  282. password files.
  283. X
  284. X     "hostname" is figured out by what you've #defined in ../common/conf.h.
  285. If you have defined GHNAME, it uses the gethostname() call.
  286. If you've defined UUNAME, it figured it out from the file
  287. X/etc/uucpname.  Finally, if neither is defined it gets it from
  288. X/usr/include/whoami.h.  If you have GHNAME defined and your
  289. gethostname() returns your fully-qualified Internet name,
  290. undefine DOMAIN.
  291. X
  292. X     The point here is that the thing looks like inews to any program
  293. which would care to post something (e.g., Pnews, postnews, what have
  294. you).  The difference is that the article will look like it was posted
  295. on the remote end, not on the local end.  Please note that "postnews"
  296. X(nor any of the other standard news programs) is not required for
  297. rrn/nntp on client machines.
  298. X
  299. X     The "test*" files in this directory provide some good test
  300. material for inews; you can just redirect inews to take input from
  301. them or whatever.
  302. X
  303. X     Thanks to Steven Grady <grady@postgres.berkeley.edu> for
  304. writing this, and for wasting a lot of his valuable time dealing
  305. with the can-o'-worms that is the real inews.
  306. X
  307. BUGS:
  308. X
  309. X     This version of inews doesn't handle real inews options.  As
  310. a result, some posting programs (notably the Gnumacs front end) will
  311. fail if they use this program.  In the interests of simplicity, I
  312. have no plans for modifying mini-inews to handle real-inews options.
  313. However, if you'd like to send me diffs I'll be more than happy to
  314. install them for the next release.
  315. END_OF_FILE
  316. if test 2253 -ne `wc -c <'./inews/README'`; then
  317.     echo shar: \"'./inews/README'\" unpacked with wrong size!
  318. fi
  319. # end of './inews/README'
  320. fi
  321. if test -f './inews/uname.c' -a "${1}" != "-c" ; then 
  322.   echo shar: Will not clobber existing file \"'./inews/uname.c'\"
  323. else
  324. echo shar: Extracting \"'./inews/uname.c'\" \(2177 characters\)
  325. sed "s/^X//" >'./inews/uname.c' <<'END_OF_FILE'
  326. X/*
  327. X * This software is Copyright (c) 1986 by Rick Adams.
  328. X *
  329. X * Permission is hereby granted to copy, reproduce, redistribute or
  330. X * otherwise use this software as long as: there is no monetary
  331. X * profit gained specifically from the use or reproduction or this
  332. X * software, it is not sold, rented, traded or otherwise marketed, and
  333. X * this copyright notice is included prominently in any copy
  334. X * made.
  335. X *
  336. X * The author make no claims as to the fitness or correctness of
  337. X * this software for any use whatsoever, and it is provided as is. 
  338. X * Any use of this software is at the user's own risk.
  339. X *
  340. X * This routine is compatible with the Unix T/S system call uname,
  341. X * which figures out the name of the local system.
  342. X * However, we do it by reading the file /usr/include/whoami.h.
  343. X * This avoids having to recompile uucp for each site and hence
  344. X * avoids having to distribute the source to uucp to people who
  345. X * have only binary licenses.
  346. X */
  347. X
  348. X#ifdef SCCSID
  349. static char    *SccsId = "@(#)uname.c    2.9    1/20/86";
  350. X#endif /* SCCSID */
  351. X
  352. X#include <stdio.h>
  353. X#include "../common/conf.h"
  354. X
  355. X#ifdef UNAME
  356. X# define DONE
  357. X#endif /* UNAME */
  358. X
  359. X#ifdef GHNAME
  360. uname(uptr)
  361. char    *uptr;
  362. X{
  363. X    gethostname(uptr, 256);
  364. X}
  365. X# define DONE
  366. X#endif
  367. X
  368. X#ifdef    UUNAME
  369. uname(uptr)
  370. char *uptr;
  371. X{
  372. X    FILE *uucpf;
  373. X    register char *p;
  374. X    /* uucp name is stored in /etc/uucpname or /local/uucpname */
  375. X
  376. X    if (((uucpf = fopen("/etc/uucpname", "r")) == NULL &&
  377. X         (uucpf = fopen("/local/uucpname", "r")) == NULL) ||
  378. X        fgets(uptr, 256, uucpf) == NULL) {
  379. X            fprintf(stderr, "no sysname in %s\n", "/etc/uucpname");
  380. X            return;
  381. X    }
  382. X    p = index(uptr, '\n');
  383. X    if (p)
  384. X        *p = '\0';
  385. X    if (uucpf != NULL)
  386. X        fclose(uucpf);
  387. X}
  388. X#define DONE
  389. X#endif /* UUNAME */
  390. X
  391. X#ifndef DONE
  392. X#define    HDRFILE "/usr/include/whoami.h"
  393. X
  394. uname(uptr)
  395. char *uptr;
  396. X{
  397. X    char buf[BUFSIZ];
  398. X    FILE *fd;
  399. X    
  400. X    fd = fopen(HDRFILE, "r");
  401. X    if (fd == NULL) {
  402. X        fprintf(stderr, "Cannot open %s\n", HDRFILE);
  403. X        exit(1);
  404. X    }
  405. X    
  406. X    for (;;) {    /* each line in the file */
  407. X        if (fgets(buf, sizeof buf, fd) == NULL) {
  408. X            fprintf(stderr, "no sysname in %s\n", HDRFILE);
  409. X            fclose(fd);
  410. X            exit(2);
  411. X        }
  412. X        if (sscanf(buf, "#define sysname \"%[^\"]\"", uptr) == 1) {
  413. X            fclose(fd);
  414. X            return;
  415. X        }
  416. X    }
  417. X}
  418. X#endif
  419. END_OF_FILE
  420. if test 2177 -ne `wc -c <'./inews/uname.c'`; then
  421.     echo shar: \"'./inews/uname.c'\" unpacked with wrong size!
  422. fi
  423. # end of './inews/uname.c'
  424. fi
  425. if test -f './rrnpatches/getactive.c' -a "${1}" != "-c" ; then 
  426.   echo shar: Will not clobber existing file \"'./rrnpatches/getactive.c'\"
  427. else
  428. echo shar: Extracting \"'./rrnpatches/getactive.c'\" \(1518 characters\)
  429. sed "s/^X//" >'./rrnpatches/getactive.c' <<'END_OF_FILE'
  430. X#include <stdio.h>
  431. X#include "config.h"
  432. X#include "EXTERN.h"
  433. X#include "server.h"
  434. X
  435. main(argc, argv)
  436. X    int        argc;
  437. X    char         *argv[];
  438. X{
  439. X    char        ser_line[256];
  440. X    int        response;
  441. X    register char    *server;
  442. X    register FILE    *actfp;
  443. X
  444. X    if (argc != 2) {
  445. X        fprintf(stderr, "Usage: getactive filename\n");
  446. X        exit(1);
  447. X    }
  448. X
  449. X    server = getserverbyfile(SERVER_FILE);
  450. X    if (server == NULL) {
  451. X        fprintf(stderr, "Couldn't get name of news server from %s\n",
  452. X            SERVER_FILE);
  453. X        fprintf(stderr,
  454. X      "Either fix this file, or put NNTPSERVER in your environment.\n");
  455. X        exit(1);
  456. X    }
  457. X
  458. X    response = server_init(server);
  459. X    if (response < 0) {
  460. X        fprintf(stderr,
  461. X            "getactive: Can't get active file from server %s.\n",
  462. X                server);
  463. X        exit(1);
  464. X    }
  465. X
  466. X    if (handle_server_response(response, server) < 0)
  467. X        exit(1);
  468. X
  469. X    put_server("LIST");    /* tell server we want the active file */
  470. X    (void) get_server(ser_line, sizeof(ser_line));
  471. X    if (*ser_line != CHAR_OK) {        /* and then see if that's ok */
  472. X        fprintf(stderr,
  473. X            "getactive: Can't get active file from server.\n");
  474. X        fprintf(stderr, "Server said: %s\n", ser_line);
  475. X        exit(1);
  476. X    }
  477. X
  478. X    actfp = fopen(argv[1], "w");        /* and get ready */
  479. X    if (actfp == NULL) {
  480. X        close_server();
  481. X        perror(argv[1]);
  482. X        exit(1);
  483. X    }
  484. X
  485. X    while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
  486. X        if (ser_line[0] == '.')        /* there's another line */
  487. X            break;            /* get it and write it to */
  488. X        if (actfp != NULL) {        /* the temporary active file */
  489. X            fputs(ser_line, actfp);
  490. X            putc('\n', actfp);
  491. X        }
  492. X    }
  493. X
  494. X    (void) fclose(actfp);
  495. X    close_server();
  496. X}
  497. END_OF_FILE
  498. if test 1518 -ne `wc -c <'./rrnpatches/getactive.c'`; then
  499.     echo shar: \"'./rrnpatches/getactive.c'\" unpacked with wrong size!
  500. fi
  501. # end of './rrnpatches/getactive.c'
  502. fi
  503. if test -f './rrnpatches/init.c.pat' -a "${1}" != "-c" ; then 
  504.   echo shar: Will not clobber existing file \"'./rrnpatches/init.c.pat'\"
  505. else
  506. echo shar: Extracting \"'./rrnpatches/init.c.pat'\" \(1708 characters\)
  507. sed "s/^X//" >'./rrnpatches/init.c.pat' <<'END_OF_FILE'
  508. X*** rn/init.c    Sun Mar 15 19:54:18 1987
  509. X--- rrn/init.c    Mon May 25 23:31:56 1987
  510. X***************
  511. X*** 44,49
  512. X  #include "ngstuff.h"
  513. X  #include "rcln.h"
  514. X  #include "respond.h"
  515. X  #include "ng.h"
  516. X  #include "INTERN.h"
  517. X  #include "init.h"
  518. X
  519. X--- 44,50 -----
  520. X  #include "ngstuff.h"
  521. X  #include "rcln.h"
  522. X  #include "respond.h"
  523. X+ #include "server.h"
  524. X  #include "ng.h"
  525. X  #include "INTERN.h"
  526. X  #include "init.h"
  527. X***************
  528. X*** 56,61
  529. X      char *tcbuf;
  530. X      register bool foundany = FALSE;
  531. X      long time();
  532. X  #ifdef NOLINEBUF
  533. X      static char std_out_buf[BUFSIZ];    /* must be static or malloced */
  534. X  
  535. X
  536. X--- 57,66 -----
  537. X      char *tcbuf;
  538. X      register bool foundany = FALSE;
  539. X      long time();
  540. X+ #ifdef SERVER
  541. X+     char *server;
  542. X+     int response;
  543. X+ #endif SERVER
  544. X  #ifdef NOLINEBUF
  545. X      static char std_out_buf[BUFSIZ];    /* must be static or malloced */
  546. X  
  547. X***************
  548. X*** 123,128
  549. X  
  550. X      if (!checkflag)
  551. X      newsnews_check();
  552. X  
  553. X      /* open active file, etc. */
  554. X  
  555. X
  556. X--- 128,159 -----
  557. X  
  558. X      if (!checkflag)
  559. X      newsnews_check();
  560. X+ 
  561. X+ #ifdef SERVER
  562. X+ 
  563. X+     /* open connection to server if appropriate */
  564. X+ 
  565. X+     server = getserverbyfile(SERVER_FILE);
  566. X+     if (server == NULL) {
  567. X+     fprintf(stderr, "Can't get the name of the news server from %s\n",
  568. X+         SERVER_FILE);
  569. X+     fprintf(stderr,
  570. X+       "Either fix this file, or put NNTPSERVER in your environment.\n");
  571. X+     finalize(1);
  572. X+     }
  573. X+ 
  574. X+     response = server_init(server);
  575. X+     if (response < 0) {
  576. X+     fprintf(stderr,
  577. X+         "Couldn't connect to %s news server, try again later.\n",
  578. X+         server);
  579. X+     finalize(1);
  580. X+     }
  581. X+ 
  582. X+     if (handle_server_response(response, server) < 0)
  583. X+     finalize(1);
  584. X+ 
  585. X+ #endif SERVER
  586. X  
  587. X      /* open active file, etc. */
  588. X  
  589. END_OF_FILE
  590. if test 1708 -ne `wc -c <'./rrnpatches/init.c.pat'`; then
  591.     echo shar: \"'./rrnpatches/init.c.pat'\" unpacked with wrong size!
  592. fi
  593. # end of './rrnpatches/init.c.pat'
  594. fi
  595. if test -f './rrnpatches/ngdata.c.pat' -a "${1}" != "-c" ; then 
  596.   echo shar: Will not clobber existing file \"'./rrnpatches/ngdata.c.pat'\"
  597. else
  598. echo shar: Extracting \"'./rrnpatches/ngdata.c.pat'\" \(2563 characters\)
  599. sed "s/^X//" >'./rrnpatches/ngdata.c.pat' <<'END_OF_FILE'
  600. X*** rn/ngdata.c    Sun Mar 15 19:54:39 1987
  601. X--- rrn/ngdata.c    Sun Mar 15 22:26:37 1987
  602. X***************
  603. X*** 14,19
  604. X  #include "intrp.h"
  605. X  #include "final.h"
  606. X  #include "rcln.h"
  607. X  #include "INTERN.h"
  608. X  #include "ngdata.h"
  609. X  
  610. X
  611. X--- 14,20 -----
  612. X  #include "intrp.h"
  613. X  #include "final.h"
  614. X  #include "rcln.h"
  615. X+ #include "server.h"
  616. X  #include "INTERN.h"
  617. X  #include "ngdata.h"
  618. X  
  619. X***************
  620. X*** 17,22
  621. X  #include "INTERN.h"
  622. X  #include "ngdata.h"
  623. X  
  624. X  void
  625. X  ngdata_init()
  626. X  {
  627. X
  628. X--- 18,27 -----
  629. X  #include "INTERN.h"
  630. X  #include "ngdata.h"
  631. X  
  632. X+ #ifdef SERVER
  633. X+ char    active_name[256];
  634. X+ #endif SERVER
  635. X+ 
  636. X  void
  637. X  ngdata_init()
  638. X  {
  639. X***************
  640. X*** 20,25
  641. X  void
  642. X  ngdata_init()
  643. X  {
  644. X  /* The following is only for systems that do not zero globals properly */
  645. X  #ifdef ZEROGLOB
  646. X  # ifdef CACHEFIRST
  647. X
  648. X--- 25,34 -----
  649. X  void
  650. X  ngdata_init()
  651. X  {
  652. X+ #ifdef SERVER
  653. X+     char ser_line[256];
  654. X+     char *cp;
  655. X+ #endif
  656. X  /* The following is only for systems that do not zero globals properly */
  657. X  #ifdef ZEROGLOB
  658. X  # ifdef CACHEFIRST
  659. X***************
  660. X*** 30,35
  661. X  
  662. X      /* open the active file */
  663. X  
  664. X      actfp = fopen(filexp(ACTIVE),"r");
  665. X      if (actfp == Nullfp) {
  666. X      printf(cantopen,filexp(ACTIVE)) FLUSH;
  667. X
  668. X--- 39,72 -----
  669. X  
  670. X      /* open the active file */
  671. X  
  672. X+ #ifdef SERVER
  673. X+ 
  674. X+     put_server("LIST");        /* tell server we want the active file */
  675. X+     (void) get_server(ser_line, sizeof(ser_line));
  676. X+     if (*ser_line != CHAR_OK) {        /* and then see if that's ok */
  677. X+     fprintf(stdout, "Can't get active file from server: \n%s\n", ser_line);
  678. X+     finalize(1);
  679. X+     }
  680. X+ 
  681. X+     cp = filexp("/tmp/rrnact.%$");    /* make a temporary name */
  682. X+     strcpy(active_name, cp);
  683. X+     actfp = fopen(active_name, "w+");    /* and get ready */
  684. X+     if (actfp == Nullfp) {
  685. X+     printf(cantopen,filexp(ACTIVE)) FLUSH;
  686. X+     finalize(1);
  687. X+     }
  688. X+ 
  689. X+     while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
  690. X+     if (ser_line[0] == '.')        /* there's another line */
  691. X+         break;            /* get it and write it to */
  692. X+     fputs(ser_line, actfp);
  693. X+     putc('\n', actfp);
  694. X+     }
  695. X+ 
  696. X+     fseek(actfp,0L,0);        /* just get to the beginning */
  697. X+ 
  698. X+ #else not SERVER
  699. X+ 
  700. X      actfp = fopen(filexp(ACTIVE),"r");
  701. X  
  702. X  #endif SERVER
  703. X***************
  704. X*** 31,36
  705. X      /* open the active file */
  706. X  
  707. X      actfp = fopen(filexp(ACTIVE),"r");
  708. X      if (actfp == Nullfp) {
  709. X      printf(cantopen,filexp(ACTIVE)) FLUSH;
  710. X      finalize(1);
  711. X
  712. X--- 68,76 -----
  713. X  #else not SERVER
  714. X  
  715. X      actfp = fopen(filexp(ACTIVE),"r");
  716. X+ 
  717. X+ #endif SERVER
  718. X+ 
  719. X      if (actfp == Nullfp) {
  720. X      printf(cantopen,filexp(ACTIVE)) FLUSH;
  721. X      finalize(1);
  722. END_OF_FILE
  723. if test 2563 -ne `wc -c <'./rrnpatches/ngdata.c.pat'`; then
  724.     echo shar: \"'./rrnpatches/ngdata.c.pat'\" unpacked with wrong size!
  725. fi
  726. # end of './rrnpatches/ngdata.c.pat'
  727. fi
  728. if test -f './rrnpatches/respond.c.pat' -a "${1}" != "-c" ; then 
  729.   echo shar: Will not clobber existing file \"'./rrnpatches/respond.c.pat'\"
  730. else
  731. echo shar: Extracting \"'./rrnpatches/respond.c.pat'\" \(1520 characters\)
  732. sed "s/^X//" >'./rrnpatches/respond.c.pat' <<'END_OF_FILE'
  733. X*** rn/respond.c    Sun Mar 15 19:54:33 1987
  734. X--- rrn/respond.c    Sun Mar 15 20:48:49 1987
  735. X***************
  736. X*** 237,242
  737. X      crmode();
  738. X      }
  739. X  s_bomb:
  740. X      if (chdir(spool) || chdir(ngdir)) {
  741. X      printf(nocd,ngdir) FLUSH;
  742. X      sig_catcher(0);
  743. X
  744. X--- 237,245 -----
  745. X      crmode();
  746. X      }
  747. X  s_bomb:
  748. X+ #ifdef SERVER
  749. X+     if (chdir(spool)) {
  750. X+ #else not SERVER
  751. X      if (chdir(spool) || chdir(ngdir)) {
  752. X  #endif SERVER
  753. X      printf(nocd,ngdir) FLUSH;
  754. X***************
  755. X*** 238,243
  756. X      }
  757. X  s_bomb:
  758. X      if (chdir(spool) || chdir(ngdir)) {
  759. X      printf(nocd,ngdir) FLUSH;
  760. X      sig_catcher(0);
  761. X      }
  762. X
  763. X--- 241,247 -----
  764. X      if (chdir(spool)) {
  765. X  #else not SERVER
  766. X      if (chdir(spool) || chdir(ngdir)) {
  767. X+ #endif SERVER
  768. X      printf(nocd,ngdir) FLUSH;
  769. X      sig_catcher(0);
  770. X      }
  771. X***************
  772. X*** 417,422
  773. X  #ifdef TERSE
  774. X      fputs("\n(+cbreak)\n",stdout) FLUSH;
  775. X  #endif
  776. X      if (chdir(spool) || chdir(ngdir)) {
  777. X      printf(nocd,ngdir) FLUSH;
  778. X      sig_catcher(0);
  779. X
  780. X--- 421,429 -----
  781. X  #ifdef TERSE
  782. X      fputs("\n(+cbreak)\n",stdout) FLUSH;
  783. X  #endif
  784. X+ #ifdef SERVER
  785. X+     if (chdir(spool)) {
  786. X+ #else not SERVER
  787. X      if (chdir(spool) || chdir(ngdir)) {
  788. X  #endif SERVER
  789. X      printf(nocd,ngdir) FLUSH;
  790. X***************
  791. X*** 418,423
  792. X      fputs("\n(+cbreak)\n",stdout) FLUSH;
  793. X  #endif
  794. X      if (chdir(spool) || chdir(ngdir)) {
  795. X      printf(nocd,ngdir) FLUSH;
  796. X      sig_catcher(0);
  797. X      }
  798. X
  799. X--- 425,431 -----
  800. X      if (chdir(spool)) {
  801. X  #else not SERVER
  802. X      if (chdir(spool) || chdir(ngdir)) {
  803. X+ #endif SERVER
  804. X      printf(nocd,ngdir) FLUSH;
  805. X      sig_catcher(0);
  806. X      }
  807. END_OF_FILE
  808. if test 1520 -ne `wc -c <'./rrnpatches/respond.c.pat'`; then
  809.     echo shar: \"'./rrnpatches/respond.c.pat'\" unpacked with wrong size!
  810. fi
  811. # end of './rrnpatches/respond.c.pat'
  812. fi
  813. if test -f './server/SYSLOG' -a "${1}" != "-c" ; then 
  814.   echo shar: Will not clobber existing file \"'./server/SYSLOG'\"
  815. else
  816. echo shar: Extracting \"'./server/SYSLOG'\" \(2107 characters\)
  817. sed "s/^X//" >'./server/SYSLOG' <<'END_OF_FILE'
  818. SYSLOG INFO
  819. X
  820. If LOG is defined, the following informational messages are
  821. logged at LOG_INFO.  All messages are preceded by
  822. the host name executing the command.
  823. X
  824. host connect            "host" connected to the server.
  825. host refused connection        "host" tried to connect, but was denied.
  826. host unrecognized %s        "host" gave an unknown command, %s.
  827. host group newsgroup        "host" isssued GROUP to "newsgroup".
  828. host post rejected        "host" tried to POST, but was denied.
  829. host post succeeded        "host" tried to POST, inews worked.
  830. host post failed        "host" tried to POST, inews failed.
  831. host timeout            "host" didn't issue a command for TIMEOUT
  832. X                seconds (#defined in common/conf.h), so
  833. X                nntpd closed the connection.
  834. host transfer_timeout        "host" hasn't sent any lines of data
  835. X                during article transmission for XFER_TIMEOUT
  836. X                seconds, so nntpd closed the connection.
  837. host ihave_stats accepted %d rejected %d failed %d
  838. X                "host" quit, having offered news articles
  839. X                to us for transfer.  We accepted %d,
  840. X                rejected %d (having already seem them),
  841. X                and %d failed (inews exited non-zero).
  842. host newnews %s %s %s GMT|local %s
  843. X                "host" issued NEWNEWS in group %s,
  844. X                from date %s time %s.  Timezone was
  845. X                either GMT or local.  <%s> distributions.
  846. host newnews_stats told %d took %d
  847. X                "host" asked for new news (see above).
  848. X                We told it about %d articles, and it
  849. X                subsequently issued %d ARTICLE commands,
  850. X                presumably to retrieve the asked about msgs.
  851. host exit %d aritcles %d groups    "host" quit, having read a total of %d
  852. X                articles and %d groups.
  853. host times user %f system %f elapsed %f
  854. X                "host" quit, having used %f user seconds,
  855. X                %f system seconds, and %f real-time elapsed
  856. X                seconds.
  857. X
  858. The following messages are logged at priority LOG_DEBUG
  859. if IHAVE_DEBUG is #defined in common/conf.h:
  860. X
  861. host ihave artid rejected    "host" offered "artid", we already had it.
  862. host ihave artid accepted failed    "host" offered "artid", we didn't
  863. host ihave artid accepted succeeded    have it, and the rnews worked or not.
  864. X
  865. The following error message is logged at LOG_ERR:
  866. X
  867. host spawn: EOF before period on a line by itself
  868. END_OF_FILE
  869. if test 2107 -ne `wc -c <'./server/SYSLOG'`; then
  870.     echo shar: \"'./server/SYSLOG'\" unpacked with wrong size!
  871. fi
  872. # end of './server/SYSLOG'
  873. fi
  874. if test -f './server/ahbs.c' -a "${1}" != "-c" ; then 
  875.   echo shar: Will not clobber existing file \"'./server/ahbs.c'\"
  876. else
  877. echo shar: Extracting \"'./server/ahbs.c'\" \(2721 characters\)
  878. sed "s/^X//" >'./server/ahbs.c' <<'END_OF_FILE'
  879. X#ifndef lint
  880. static char    *sccsid = "@(#)ahbs.c    1.8    (Berkeley) 1/11/88";
  881. X#endif
  882. X
  883. X#include "common.h"
  884. X
  885. static char    *verbage[] = {
  886. X    "head and body follow",
  887. X    "head follows",
  888. X    "body follows",
  889. X    "request text separately"
  890. X};
  891. X
  892. X/*
  893. X * {ARTICLE,HEAD,BODY,STAT} <messageid>|articlenum
  894. X *
  895. X * Retrieve article, head, body, or stat, depending on the
  896. X * command we were invoked with.
  897. X */
  898. X
  899. ahbs(argc, argv)
  900. X    int        argc;
  901. X    char        *argv[];
  902. X{
  903. X    char        artbuf[MAXPATHLEN], art_id[MAXBUFLEN];
  904. X    register char    c;
  905. X    int        method;
  906. X    register FILE    *fp;        /* For Message-ID retrieval only */
  907. X
  908. X    if (argc > 2) {
  909. X        printf("%d Usage: %s <message-id>|article_number.\r\n", argv[0],
  910. X            ERR_CMDSYN);
  911. X        (void) fflush(stdout);
  912. X        return;
  913. X    }
  914. X
  915. X    if ((c = *argv[0]) == 'a' || c == 'A')
  916. X        method = ARTICLE;
  917. X    else if ((c == 's' || c == 'S'))
  918. X        method = STAT;
  919. X    else
  920. X        method = ((c == 'h' || c == 'H') ? HEAD : BODY);
  921. X
  922. X    if (argc == 2 && *argv[1] == '<') {    /* Message ID */
  923. X        fp = openartbyid(argv[1]);
  924. X        if (fp == NULL) {
  925. X            printf("%d No article by message-id %s, sorry.\r\n",
  926. X                ERR_NOART, argv[1]);
  927. X            (void) fflush(stdout);
  928. X            return;
  929. X        }
  930. X        if (check_ngperm(fp) == 0) {
  931. X            printf("%d Can't give that to you, sorry.\r\n",
  932. X                ERR_ACCESS);
  933. X            (void) fflush(stdout);
  934. X            (void) fclose(fp);
  935. X            return;
  936. X        }
  937. X        printf("%d 0 %s Article retrieved, %s.\r\n",
  938. X            OK_ARTICLE + method, argv[1], verbage[method]);
  939. X        spew(fp, method);
  940. X        (void) fclose(fp);
  941. X#ifdef LOG
  942. X        if (nn_told)
  943. X            nn_took++;
  944. X#endif
  945. X        return;
  946. X    }
  947. X
  948. X    /* Else we're trying to read */
  949. X
  950. X    if (!canread) {
  951. X        printf("%d You only have permission to transfer, sorry.\r\n",
  952. X            ERR_ACCESS);
  953. X        (void) fflush(stdout);
  954. X        return;
  955. X    }
  956. X
  957. X    if (!ingroup) {
  958. X        printf("%d You are not currently in a newsgroup.\r\n",
  959. X            ERR_NCING);
  960. X        (void) fflush(stdout);
  961. X        return;
  962. X    }
  963. X
  964. X    if (argc == 1) {
  965. X        if (art_ptr < 0 || art_ptr >= num_arts) {
  966. X            printf("%d No article is currently selected.\r\n",
  967. X                ERR_NOCRNT);
  968. X            (void) fflush(stdout);
  969. X            return;
  970. X        }
  971. X        (void) sprintf(artbuf, "%d", art_array[art_ptr]);
  972. X    } else
  973. X        (void) strcpy(artbuf, argv[1]);
  974. X
  975. X    if (!valid_art(artbuf)) {
  976. X        printf("%d Invalid article number: %s.\r\n",
  977. X            ERR_NOARTIG, artbuf);
  978. X        (void) fflush(stdout);
  979. X        return;
  980. X    }
  981. X
  982. X    while (open_valid_art(artbuf, art_id) == NULL) {
  983. X        if (argc > 1) {
  984. X            printf("%d Invalid article number: %s.\r\n",
  985. X                ERR_NOARTIG, artbuf);
  986. X            (void) fflush(stdout);
  987. X            return;
  988. X        } else {
  989. X            if (++art_ptr >= num_arts) {
  990. X                printf("%d Invalid article number.\r\n",
  991. X                    ERR_NOARTIG);
  992. X                (void) fflush(stdout);
  993. X                return;
  994. X            }
  995. X            (void) sprintf(artbuf, "%d", art_array[art_ptr]);
  996. X        }
  997. X    }
  998. X
  999. X    printf("%d %s %s Article retrieved; %s.\r\n",
  1000. X        OK_ARTICLE + method, artbuf, art_id, verbage[method]);
  1001. X
  1002. X    spew(art_fp, method);
  1003. X
  1004. X    if (argc > 1)
  1005. X        art_ptr = findart(artbuf);
  1006. X}
  1007. END_OF_FILE
  1008. if test 2721 -ne `wc -c <'./server/ahbs.c'`; then
  1009.     echo shar: \"'./server/ahbs.c'\" unpacked with wrong size!
  1010. fi
  1011. # end of './server/ahbs.c'
  1012. fi
  1013. if test -f './server/common.h' -a "${1}" != "-c" ; then 
  1014.   echo shar: Will not clobber existing file \"'./server/common.h'\"
  1015. else
  1016. echo shar: Extracting \"'./server/common.h'\" \(2383 characters\)
  1017. sed "s/^X//" >'./server/common.h' <<'END_OF_FILE'
  1018. X/*
  1019. X * Common declarations, includes, and other goodies.
  1020. X *
  1021. X * @(#)common.h    1.26    (Berkeley) 2/10/88
  1022. X */
  1023. X
  1024. X
  1025. X#include <stdio.h>
  1026. X#include <sys/types.h>
  1027. X#include <sys/stat.h>
  1028. X#include <errno.h>
  1029. X#include <ctype.h>
  1030. X#include <pwd.h>
  1031. X#include <sys/file.h>
  1032. X#include <sys/param.h>
  1033. X#ifdef BSD2_10
  1034. X#include <short_names.h>
  1035. X#endif BSD2_10
  1036. X
  1037. X#include "../common/nntp.h"
  1038. X#include "../common/conf.h"
  1039. X
  1040. X#ifdef SYSLOG
  1041. X# ifdef FAKESYSLOG
  1042. X#  include "fakesyslog.h"
  1043. X# else
  1044. X#  include <syslog.h>
  1045. X# endif
  1046. X#endif
  1047. X
  1048. X#ifdef USG
  1049. extern struct passwd *getpwent(), *getpwuid(), *getpwnam();
  1050. X# include <string.h>
  1051. X#else not USG
  1052. X# include <strings.h>
  1053. X# include <sys/wait.h>
  1054. X#endif not USG
  1055. X
  1056. X#ifdef NDIR
  1057. X# include <ndir.h>
  1058. X#else not NDIR
  1059. X# include <sys/dir.h>
  1060. X#endif not NDIR
  1061. X
  1062. X#ifdef FCNTL
  1063. X# include <fcntl.h>
  1064. X#endif FCNTL
  1065. X
  1066. X/*
  1067. X * <dbm.h> stupidly defines NULL, which is why the following
  1068. X * brain death is necessary.
  1069. X */
  1070. X
  1071. X#ifdef DBM
  1072. X# undef NULL
  1073. X# include <dbm.h>
  1074. X# undef NULL
  1075. X# define NULL    0
  1076. X#endif DBM
  1077. X
  1078. X#ifdef NDBM
  1079. X# include <ndbm.h>
  1080. X#endif
  1081. X
  1082. X/*
  1083. X * Some generic maximums.
  1084. X */
  1085. X
  1086. X#ifndef MAXPATHLEN
  1087. X#define    MAXPATHLEN    1024
  1088. X#endif not MAXPATHLEN
  1089. X
  1090. X#ifndef MAXHOSTNAMELEN
  1091. X#define    MAXHOSTNAMELEN    256
  1092. X#endif not MAXHOSTNAMELEN
  1093. X
  1094. X#define    MAXBUFLEN    1024
  1095. X
  1096. X/*
  1097. X * For "spew()"
  1098. X */
  1099. X
  1100. X#define    ARTICLE    0
  1101. X#define    HEAD    1
  1102. X#define    BODY    2
  1103. X#define    STAT    3
  1104. X
  1105. X/*
  1106. X * For "ngmatch()"
  1107. X */
  1108. X
  1109. X#define    ALLBUT    1
  1110. X
  1111. X#define    valid_art(s)    (atoi(s) != 0)
  1112. X
  1113. X#define    putline(s)    fputs((s), stdout); putchar('\r'); putchar('\n');
  1114. X
  1115. extern    int    errno;
  1116. X
  1117. extern    char    *gets(), *fgets();
  1118. extern    char    *mktemp();
  1119. extern    FILE    *open_valid_art();
  1120. extern    FILE    *openartbyid();
  1121. extern    char    *gethistent();
  1122. extern    int    restreql();
  1123. extern    int    s1strneql();    /* for ngmatch */
  1124. X
  1125. extern    char    spooldir[];
  1126. extern    char    activefile[];
  1127. extern    char    accessfile[];
  1128. extern    char    historyfile[];
  1129. extern    char    ngdatefile[];
  1130. extern    char    inews[];
  1131. extern    char    rnews[];
  1132. X
  1133. extern    char    **group_array;
  1134. extern    int    num_groups;
  1135. extern    char    *homedir;
  1136. extern    int    ingroup;
  1137. extern    int    maxgroups;
  1138. extern    int    art_array[];
  1139. extern    int    art_ptr;
  1140. extern    FILE    *art_fp;
  1141. extern    int    num_arts;
  1142. extern    int    uid_poster, gid_poster;
  1143. extern    int    canread, canpost, canxfer;
  1144. extern    char    **ngpermlist;
  1145. extern    int    ngpermcount;
  1146. X
  1147. extern    char    nntp_version[];
  1148. X
  1149. X#ifdef LOG
  1150. extern    int    grps_acsd, arts_acsd;
  1151. extern    char    hostname[];
  1152. X
  1153. extern    int    ih_accepted;
  1154. extern    int    ih_rejected;
  1155. extern    int    ih_failed;
  1156. X
  1157. extern    int    nn_told;
  1158. extern    int    nn_took;
  1159. X#endif
  1160. END_OF_FILE
  1161. if test 2383 -ne `wc -c <'./server/common.h'`; then
  1162.     echo shar: \"'./server/common.h'\" unpacked with wrong size!
  1163. fi
  1164. # end of './server/common.h'
  1165. fi
  1166. if test -f './server/group.c' -a "${1}" != "-c" ; then 
  1167.   echo shar: Will not clobber existing file \"'./server/group.c'\"
  1168. else
  1169. echo shar: Extracting \"'./server/group.c'\" \(2127 characters\)
  1170. sed "s/^X//" >'./server/group.c' <<'END_OF_FILE'
  1171. X#ifndef lint
  1172. static char    *sccsid = "@(#)group.c    1.11    (Berkeley) 2/6/88";
  1173. X#endif
  1174. X
  1175. X#include "common.h"
  1176. X
  1177. X/*
  1178. X * GROUP newsgroup
  1179. X *
  1180. X * Change the current group to the specified newsgroup.
  1181. X * We also change our current directory to that newsgroup if
  1182. X * a spool directory for it exists.
  1183. X * If the newsgroup specified is invalid, the old newsgroup
  1184. X * remains selected.
  1185. X */
  1186. X
  1187. group(argc, argv)
  1188. X    int    argc;
  1189. X    char    *argv[];
  1190. X{
  1191. X    char    temp_dir[256];
  1192. X    int    high_msg, low_msg;
  1193. X    char    *cp;
  1194. X    char    *reqlist[2];
  1195. X
  1196. X    if (argc != 2) {
  1197. X        printf("%d Usage: GROUP newsgroup.\r\n", ERR_CMDSYN);
  1198. X        (void) fflush(stdout);
  1199. X        return;
  1200. X    }
  1201. X
  1202. X    if (!canread) {
  1203. X        printf("%d You only have permission to transfer, sorry.\r\n",
  1204. X            ERR_ACCESS);
  1205. X        (void) fflush(stdout);
  1206. X        return;
  1207. X    }
  1208. X
  1209. X    if (index(argv[1], '/') != (char *) NULL) {
  1210. X        printf("%d Invalid group name.\r\n", ERR_NOGROUP);
  1211. X        (void) fflush(stdout);
  1212. X        return;
  1213. X    }
  1214. X
  1215. X    if (find_group(argv[1], num_groups, &low_msg, &high_msg) < 0) {
  1216. X        printf("%d Invalid group name.\r\n", ERR_NOGROUP);
  1217. X        (void) fflush(stdout);
  1218. X        return;
  1219. X    }
  1220. X
  1221. X    reqlist[0] = argv[1];
  1222. X    reqlist[1] = NULL;
  1223. X
  1224. X    if (ngpermcount) {
  1225. X        if (ngmatch(s1strneql, ALLBUT,
  1226. X            ngpermlist, ngpermcount, reqlist, 1) == 0) {
  1227. X            printf("%d You're not allowed to read %s, sorry.\r\n",
  1228. X                ERR_ACCESS, argv[1]);
  1229. X            (void) fflush(stdout);
  1230. X            return;
  1231. X        }
  1232. X    }
  1233. X
  1234. X    close_crnt();
  1235. X    (void) chdir(spooldir);
  1236. X
  1237. X#ifdef LOG
  1238. X    syslog(LOG_INFO, "%s group %s", hostname, argv[1]);
  1239. X#endif
  1240. X
  1241. X    while ((cp = index(argv[1], '.')) != (char *) NULL)
  1242. X        *cp = '/';
  1243. X
  1244. X    (void) strcpy(temp_dir, spooldir);
  1245. X    (void) strcat(temp_dir, "/");
  1246. X    (void) strcat(temp_dir, argv[1]);
  1247. X
  1248. X    /*
  1249. X     * (void) because a group can be in the active file
  1250. X     * but not have a spool directory.  Just leave us
  1251. X     * chdired to base spool directory if this fails.
  1252. X     */
  1253. X    (void) chdir(temp_dir);
  1254. X
  1255. X#ifdef LOG
  1256. X    ++grps_acsd;
  1257. X#endif
  1258. X
  1259. X    num_arts = scan_dir(low_msg, high_msg);
  1260. X    art_ptr = 0;
  1261. X
  1262. X    ingroup = 1;
  1263. X
  1264. X    while ((cp = index(argv[1], '/')) != (char *) NULL)
  1265. X        *cp = '.';
  1266. X
  1267. X    printf("%d %d %d %d %s\r\n",
  1268. X        OK_GROUP,
  1269. X        num_arts,
  1270. X        (num_arts > 0 ? art_array[0] : 0),
  1271. X        (num_arts > 0 ? art_array[num_arts-1] : 0),
  1272. X        argv[1]);
  1273. X    (void) fflush(stdout);
  1274. X}
  1275. END_OF_FILE
  1276. if test 2127 -ne `wc -c <'./server/group.c'`; then
  1277.     echo shar: \"'./server/group.c'\" unpacked with wrong size!
  1278. fi
  1279. # end of './server/group.c'
  1280. fi
  1281. if test -f './server/main.c' -a "${1}" != "-c" ; then 
  1282.   echo shar: Will not clobber existing file \"'./server/main.c'\"
  1283. else
  1284. echo shar: Extracting \"'./server/main.c'\" \(2151 characters\)
  1285. sed "s/^X//" >'./server/main.c' <<'END_OF_FILE'
  1286. X#ifdef EXCELAN
  1287. struct sockaddr_in current_peer = { AF_INET, IPPORT_NNTP };
  1288. X#endif
  1289. X#ifndef lint
  1290. static char    *sccsid = "@(#)main.c    1.10    (Berkeley) 2/6/88";
  1291. X#endif
  1292. X
  1293. X/*
  1294. X *    Network News Transfer Protocol server
  1295. X *
  1296. X *    Phil Lapsley
  1297. X *    University of California, Berkeley
  1298. X *    (Internet: phil@berkeley.edu; UUCP: ...!ucbvax!phil)
  1299. X */
  1300. X
  1301. X#include "common.h"
  1302. X#include <sys/socket.h>
  1303. X#include <netinet/in.h>
  1304. X#ifndef EXCELAN
  1305. X#include <netdb.h>
  1306. X#endif
  1307. X#include <signal.h>
  1308. X
  1309. main()
  1310. X{
  1311. X
  1312. X#ifdef ALONE    /* If no inetd */
  1313. X
  1314. X    int            sockt, client, length;
  1315. X    struct sockaddr_in    from;
  1316. X    extern int         reaper();
  1317. X
  1318. X    disassoc();
  1319. X
  1320. X    /* fd 0-2 should be open and point to / now. */
  1321. X
  1322. X#ifdef SYSLOG
  1323. X#ifdef BSD_42
  1324. X    openlog("nntpd", LOG_PID);            /* fd 3 */
  1325. X#else
  1326. X    openlog("nntpd", LOG_PID, SYSLOG);        /* fd 3 */
  1327. X#endif
  1328. X#endif
  1329. X
  1330. X#ifdef FASTFORK
  1331. X    num_groups = read_groups();    /* Read active file now (fd 4) */
  1332. X                    /* and then do it every */
  1333. X    set_timer();            /* so often later */
  1334. X#endif
  1335. X
  1336. X#ifndef EXCELAN
  1337. X    sockt = get_socket();        /* should be fd 4 or 5 */
  1338. X#endif
  1339. X
  1340. X#ifndef USG
  1341. X    (void) signal(SIGCHLD, reaper);
  1342. X#endif
  1343. X
  1344. X#ifndef EXCELAN
  1345. X    if (listen(sockt, SOMAXCONN) < 0) {
  1346. X#ifdef SYSLOG
  1347. X        syslog(LOG_ERR, "main: listen: %m");
  1348. X#endif
  1349. X        exit(1);
  1350. X    }
  1351. X#endif
  1352. X
  1353. X    for (;;) {
  1354. X#ifdef EXCELAN
  1355. X        int status;
  1356. X        sockt = get_socket();
  1357. X        if (sockt < 0)
  1358. X            continue;
  1359. X        client = accept(sockt, &from);
  1360. X#else
  1361. X        length = sizeof (from);
  1362. X        client = accept(sockt, &from, &length);
  1363. X#endif EXCELAN
  1364. X        if (client < 0) {
  1365. X#ifdef SYSLOG
  1366. X            if (errno != EINTR)
  1367. X                syslog(LOG_ERR, "accept: %m\n");
  1368. X#endif
  1369. X#ifdef EXCELAN
  1370. X            close(sockt);
  1371. X            sleep(1);
  1372. X#endif
  1373. X            continue;
  1374. X        }
  1375. X
  1376. X        switch (fork()) {
  1377. X        case    -1:
  1378. X#ifdef SYSLOG
  1379. X                syslog(LOG_ERR, "fork: %m\n");
  1380. X#endif
  1381. X#ifdef EXCELAN
  1382. X                (void) close(sockt);
  1383. X#endif
  1384. X                (void) close(client);
  1385. X                break;
  1386. X
  1387. X        case    0:
  1388. X#ifdef EXCELAN
  1389. X                if (fork())
  1390. X                    exit(0);
  1391. X                bcopy(&from,¤t_peer,sizeof(from));
  1392. X                make_stdio(sockt);
  1393. X#else
  1394. X                (void) close(sockt);
  1395. X                make_stdio(client);
  1396. X#endif
  1397. X                serve();
  1398. X                break;
  1399. X
  1400. X        default:
  1401. X#ifdef EXCELAN
  1402. X                (void) close(sockt);
  1403. X                (void) wait(&status);
  1404. X#else
  1405. X                (void) close(client);
  1406. X#endif
  1407. X                break;
  1408. X        }
  1409. X    }
  1410. X
  1411. X#else        /* We have inetd */
  1412. X
  1413. X    serve();
  1414. X
  1415. X#endif
  1416. X}
  1417. END_OF_FILE
  1418. if test 2151 -ne `wc -c <'./server/main.c'`; then
  1419.     echo shar: \"'./server/main.c'\" unpacked with wrong size!
  1420. fi
  1421. # end of './server/main.c'
  1422. fi
  1423. if test -f './server/newgroups.c' -a "${1}" != "-c" ; then 
  1424.   echo shar: Will not clobber existing file \"'./server/newgroups.c'\"
  1425. else
  1426. echo shar: Extracting \"'./server/newgroups.c'\" \(2497 characters\)
  1427. sed "s/^X//" >'./server/newgroups.c' <<'END_OF_FILE'
  1428. X#ifndef lint
  1429. static char    *sccsid = "@(#)newgroups.c    1.13    (Berkeley) 2/6/88";
  1430. X#endif
  1431. X
  1432. X#include "common.h"
  1433. X#include "time.h"
  1434. X
  1435. X/*
  1436. X * NEWGROUPS date time ["GMT"] [<distributions>]
  1437. X *
  1438. X * Display new newsgroups since a given date and time, but only
  1439. X * for those in <distributions>.
  1440. X */
  1441. X
  1442. newgroups(argc, argv)
  1443. X    int        argc;
  1444. X    char        *argv[];
  1445. X{
  1446. X    char        line[NNTP_STRLEN];
  1447. X    register char    *cp, *temp;
  1448. X    static char    **dist_list = (char **) NULL;
  1449. X    int        distcount = 0;
  1450. X    int        i;
  1451. X    long        date;
  1452. X    register FILE    *date_fp;
  1453. X
  1454. X    if (argc < 3) {
  1455. printf("%d Usage: NEWGROUPS yymmdd hhmmss [\"GMT\"] [<distributions>].\r\n",
  1456. X            ERR_CMDSYN);
  1457. X        (void) fflush(stdout);
  1458. X        return;
  1459. X    }
  1460. X
  1461. X    date_fp = fopen(ngdatefile, "r");
  1462. X    if (date_fp == NULL) {
  1463. X#ifdef SYSLOG
  1464. X        syslog(LOG_ERR, "newgroups: fopen %s: %m", ngdatefile);
  1465. X#endif
  1466. X        printf("%d Cannot open newsgroup date file.\r\n", ERR_FAULT);
  1467. X        (void) fflush(stdout);
  1468. X        return;
  1469. X    }
  1470. X
  1471. X    /*        YYMMDD            HHMMSS    */
  1472. X    if (strlen(argv[1]) != 6 || strlen(argv[2]) != 6) {
  1473. X        printf("%d Date/time must be in form YYMMDD HHMMSS.\r\n",
  1474. X            ERR_CMDSYN);
  1475. X        (void) fflush(stdout);
  1476. X        (void) fclose(date_fp);
  1477. X        return;
  1478. X    }
  1479. X
  1480. X    (void) strcpy(line, argv[1]);            /* yymmdd */
  1481. X    (void) strcat(line, argv[2]);            /* hhmmss */
  1482. X
  1483. X    date = dtol(line);
  1484. X    if (date < 0) {
  1485. X        printf("%d Invalid date specification.\r\n", ERR_CMDSYN);
  1486. X        (void) fflush(stdout);
  1487. X        (void) fclose(date_fp);
  1488. X        return;
  1489. X    }
  1490. X
  1491. X    argc -= 3;
  1492. X    argv += 3;
  1493. X
  1494. X    if (argc > 0 && !strcasecmp(*argv, "GMT")) { /* We store stuff in GMT */
  1495. X            ++argv;            /* anyway, so this is */
  1496. X            --argc;            /* a "noop" */
  1497. X    } else                     /* But that means not GMT */
  1498. X        date = local_to_gmt(date);    /* is a definite "op" */
  1499. X
  1500. X    if (argc > 0) {
  1501. X        distcount = get_distlist(&dist_list, *argv);
  1502. X        if (distcount < 0) {
  1503. X            printf("%d Bad distribution list %s:\r\n", *argv);
  1504. X            (void) fflush(stdout);
  1505. X            (void) fclose(date_fp);
  1506. X            return;
  1507. X        }
  1508. X    }
  1509. X
  1510. X    printf("%d New newsgroups since %s follow.\r\n", OK_NEWGROUPS, line);
  1511. X
  1512. X    while (fgets(line, sizeof(line), date_fp) != NULL) {
  1513. X        if ((cp = index(line, '\n')) != NULL)
  1514. X            *cp = '\0';
  1515. X        if ((cp = index(line, ' ')) != NULL)
  1516. X            *cp = '\0';
  1517. X        if (atoi(line) < date)
  1518. X            break;
  1519. X
  1520. X        if (distcount == 0) {
  1521. X            putline(cp + 1);
  1522. X        } else {
  1523. X            temp = cp + 1;
  1524. X            cp = index(temp, '.');
  1525. X            if (cp == NULL)
  1526. X                continue;
  1527. X            *cp = '\0';
  1528. X            for (i = 0; i < distcount; ++i)
  1529. X                if (strcmp(temp, dist_list[i]) == 0) {
  1530. X                    *cp = '.';
  1531. X                    putline(temp);
  1532. X                    break;
  1533. X                }
  1534. X        }
  1535. X    }
  1536. X    putchar('.');
  1537. X    putchar('\r');
  1538. X    putchar('\n');
  1539. X    (void) fflush(stdout);
  1540. X    (void) fclose(date_fp);
  1541. X}
  1542. END_OF_FILE
  1543. if test 2497 -ne `wc -c <'./server/newgroups.c'`; then
  1544.     echo shar: \"'./server/newgroups.c'\" unpacked with wrong size!
  1545. fi
  1546. # end of './server/newgroups.c'
  1547. fi
  1548. if test -f './server/nextlast.c' -a "${1}" != "-c" ; then 
  1549.   echo shar: Will not clobber existing file \"'./server/nextlast.c'\"
  1550. else
  1551. echo shar: Extracting \"'./server/nextlast.c'\" \(1876 characters\)
  1552. sed "s/^X//" >'./server/nextlast.c' <<'END_OF_FILE'
  1553. X#ifndef lint
  1554. static char    *sccsid = "@(#)nextlast.c    1.4    (Berkeley) 1/11/88";
  1555. X#endif
  1556. X
  1557. X#include "common.h"
  1558. X
  1559. X/*
  1560. X * NEXT
  1561. X * LAST
  1562. X *
  1563. X * Retrieve the message-id of the next or last article in the
  1564. X * newsgroup.  Position the current article pointer to this
  1565. X * article.
  1566. X */
  1567. X
  1568. nextlast(argc, argv)
  1569. X    int    argc;
  1570. X    char    *argv[];
  1571. X{
  1572. X    char    artbuf[MAXPATHLEN], art_id[MAXBUFLEN];
  1573. X    int    oldptr;
  1574. X    int    next;
  1575. X
  1576. X    if (!canread) {
  1577. X        printf("%d You only have permission to transfer, sorry.\r\n",
  1578. X            ERR_ACCESS);
  1579. X        (void) fflush(stdout);
  1580. X        return;
  1581. X    }
  1582. X
  1583. X    if (!ingroup) {
  1584. X        printf("%d You are not currently in a newsgroup.\r\n",
  1585. X            ERR_NCING);
  1586. X        (void) fflush(stdout);
  1587. X        return;
  1588. X    }
  1589. X
  1590. X    if (argc != 1) {
  1591. X        printf("%d NEXT/LAST need no arguments.\r\n", ERR_CMDSYN);
  1592. X        (void) fflush(stdout);
  1593. X        return;
  1594. X    }
  1595. X
  1596. X    next = (argv[0][0] == 'n' || argv[0][0] == 'N');
  1597. X
  1598. X    if (art_ptr < 0 || art_ptr >= num_arts) {
  1599. X        printf("%d No current article selected.\r\n",
  1600. X            ERR_NOCRNT);
  1601. X        (void) fflush(stdout);
  1602. X        return;
  1603. X    }
  1604. X
  1605. X    if (next ? (art_ptr + 1 >= num_arts) : (art_ptr - 1 < 0)) {
  1606. X        printf("%d No %s article to retrieve.\r\n",
  1607. X            ERR_NONEXT,  next ? "next" : "previous");
  1608. X        (void) fflush(stdout);
  1609. X        return;
  1610. X    }
  1611. X
  1612. X    oldptr = art_ptr;
  1613. X    (void) sprintf(artbuf, "%d", art_array[next ? ++art_ptr : --art_ptr]);
  1614. X
  1615. X    if (!valid_art(artbuf)) {
  1616. X        printf("%d Invalid article number: %s.\r\n", ERR_NOARTIG,
  1617. X            artbuf);
  1618. X        (void) fflush(stdout);
  1619. X        return;
  1620. X    }
  1621. X
  1622. X    while (open_valid_art(artbuf, art_id) == NULL) {
  1623. X        if (((next) ? (++art_ptr >= num_arts) : (--art_ptr < 0))) {
  1624. X            printf("%d No %s article to retrieve.\r\n",
  1625. X                ERR_NONEXT, next ? "next" : "previous");
  1626. X            art_ptr = oldptr;
  1627. X            (void) fflush(stdout);
  1628. X            return;
  1629. X        }
  1630. X        (void) sprintf(artbuf, "%d", art_array[art_ptr]);
  1631. X    }
  1632. X
  1633. X    printf("%d %s %s Article retrieved; request text separately.\r\n",
  1634. X        OK_NOTEXT, artbuf, art_id);
  1635. X
  1636. X    if (argc > 1)
  1637. X        art_ptr = findart(artbuf);
  1638. X    (void) fflush(stdout);
  1639. X}
  1640. END_OF_FILE
  1641. if test 1876 -ne `wc -c <'./server/nextlast.c'`; then
  1642.     echo shar: \"'./server/nextlast.c'\" unpacked with wrong size!
  1643. fi
  1644. # end of './server/nextlast.c'
  1645. fi
  1646. if test -f './server/ngmatch.c' -a "${1}" != "-c" ; then 
  1647.   echo shar: Will not clobber existing file \"'./server/ngmatch.c'\"
  1648. else
  1649. echo shar: Extracting \"'./server/ngmatch.c'\" \(2373 characters\)
  1650. sed "s/^X//" >'./server/ngmatch.c' <<'END_OF_FILE'
  1651. X#ifndef lint
  1652. static    char    *sccsid = "@(#)ngmatch.c    1.3    (Berkeley) 2/6/88";
  1653. X#endif
  1654. X
  1655. X#include "common.h"
  1656. X
  1657. X/*
  1658. X * nntpngmatch -- match a list of newsgroup specifiers with a list of
  1659. X * given newsgroups.  A pointer to the routine which determines a match is
  1660. X * also given.  This allows us to do regular expression handling for RFC
  1661. X * 977's NEWNEWS, and more efficient "strncmps" for the access file, which
  1662. X * must be checked often.
  1663. X * 
  1664. X * This is NOT the same routine as ngmatch in the news software.  Pity.
  1665. X * 
  1666. X *    Parameters:    "nglist" is the list of group specifiers (limited
  1667. X *            regexp) to match against.
  1668. X *            "ngcount" is the number of groups in nglist.
  1669. X *            "matchlist" is the list of newsgroups to match against.
  1670. X *            "matchcount" is number of groups in matchlist.
  1671. X *
  1672. X *    Returns:    1 if the named newsgroup is in the list.
  1673. X *            0 otherwise.
  1674. X */
  1675. X
  1676. ngmatch(func, dflt, ngspec, ngspeccount, matchlist, matchcount)
  1677. X    int        (*func)();
  1678. X    int        dflt;
  1679. X    char        **ngspec;
  1680. X    int        ngspeccount;
  1681. X    char        **matchlist;
  1682. X    int        matchcount;
  1683. X{
  1684. X    register int    i, j;
  1685. X    register int    match;
  1686. X    register char    *cp;
  1687. X
  1688. X    if (ngspeccount == 0)
  1689. X        return (1);
  1690. X
  1691. X    match = dflt;
  1692. X
  1693. X    for (i = 0; i < matchcount; ++i) {
  1694. X        if (cp = index(matchlist[i], '/'))
  1695. X            *cp = '\0';
  1696. X        for (j = 0; j < ngspeccount; ++j) {
  1697. X            if (ngspec[j][0] == '!') {    /* Handle negation */
  1698. X                if ((*func)(ngspec[j]+1, matchlist[i])) {
  1699. X                    match = 0;
  1700. X                }
  1701. X            } else {
  1702. X                if ((*func)(ngspec[j], matchlist[i])) {
  1703. X                    match = 1;
  1704. X                }
  1705. X            }
  1706. X        }
  1707. X    }
  1708. X
  1709. X    return (match);
  1710. X}
  1711. X
  1712. X
  1713. X/*
  1714. X * restreql -- A small regular expression string equivalnce routine.
  1715. X * Thanks and a tip of the hat to Nick Lai, <lai@shadow.berkeley.edu>
  1716. X * for this time saving device.
  1717. X *
  1718. X *    Parameters:    "w" is an asterisk-broadened regexp,
  1719. X *            "s" is a non-regexp string.
  1720. X *    Returns:    1 if match, 0 otherwise.
  1721. X *
  1722. X *    Side effects:    None.
  1723. X */
  1724. X
  1725. restreql(w, s)
  1726. X    register char *w;
  1727. X    register char *s;
  1728. X{
  1729. X
  1730. X    while (*s && *w) {
  1731. X        switch (*w) {
  1732. X            case '*':
  1733. X                for (w++; *s; s++)
  1734. X                    if (restreql(w, s))
  1735. X                        return 1;
  1736. X                break;
  1737. X            default:
  1738. X                if (*w != *s)
  1739. X                    return 0;
  1740. X                w++, s++;
  1741. X                break;
  1742. X        }
  1743. X    }
  1744. X    if (*s)
  1745. X        return 0;
  1746. X    while (*w)
  1747. X        if (*w++ != '*')
  1748. X            return 0;
  1749. X
  1750. X    return 1;
  1751. X}
  1752. X
  1753. X
  1754. X/*
  1755. X * s1strneql -- see if s1 is equivalent to s2 up to the length of s1.
  1756. X * Return non-zero if so, 0 otherwise.
  1757. X */
  1758. X
  1759. s1strneql(s1, s2)
  1760. X    register char    *s1;
  1761. X    register char    *s2;
  1762. X{
  1763. X    return (!strncmp(s1, s2, strlen(s1)));
  1764. X}
  1765. END_OF_FILE
  1766. if test 2373 -ne `wc -c <'./server/ngmatch.c'`; then
  1767.     echo shar: \"'./server/ngmatch.c'\" unpacked with wrong size!
  1768. fi
  1769. # end of './server/ngmatch.c'
  1770. fi
  1771. if test -f './server/parsit.c' -a "${1}" != "-c" ; then 
  1772.   echo shar: Will not clobber existing file \"'./server/parsit.c'\"
  1773. else
  1774. echo shar: Extracting \"'./server/parsit.c'\" \(2471 characters\)
  1775. sed "s/^X//" >'./server/parsit.c' <<'END_OF_FILE'
  1776. X#ifndef lint
  1777. static char *osccsid = "@(#)parsit.c    1.1    (Berkeley) 12/5/84";
  1778. static char *sccsid = "@(#)parsit.c    1.2    (Berkeley) 10/15/87";
  1779. X#endif
  1780. X
  1781. X/*
  1782. X * Parse a string of words separated by spaces into an
  1783. X * array of pointers to characters, just like good ol' argv[]
  1784. X * and argc.
  1785. X *
  1786. X * Usage:
  1787. X *
  1788. X * char line[132];
  1789. X * char **argv;
  1790. X * int argc;
  1791. X *
  1792. X *    argv = (char **) NULL;
  1793. X *    argc = parsit(line, &argv);
  1794. X *
  1795. X * returns the number of words parsed in argc.  argv[argc] will
  1796. X * be (char *) NULL to indicate end of list, if you're not
  1797. X * happy with just knowing how many words you have.
  1798. X *
  1799. X * Note that setting argv = (char **) NULL is only done the first
  1800. X * time the routine is called with a new "argv" -- it tells
  1801. X * parsit that "argv" is a new array, and parsit shouldn't free
  1802. X * up the elements (as it would do if it were an old array).
  1803. X *
  1804. X *    Phil Lapsley
  1805. X *    College of Engineering
  1806. X *    University of California, Berkeley
  1807. X *    (ARPA: phil@Berkeley.ARPA; UUCP: ...!ucbvax!phil)
  1808. X */
  1809. X
  1810. X#include <stdio.h>
  1811. X
  1812. extern    char    *malloc(), *strcpy();
  1813. X
  1814. parsit(line, array)
  1815. char *line;
  1816. char ***array;
  1817. X{
  1818. X    char    **argv;
  1819. X    char    word[132];
  1820. X    char    *linecp;
  1821. X    int    i, j, num_words;
  1822. X
  1823. X    argv = *array;
  1824. X    if (argv != (char **) NULL) {  /* Check to see if we should */
  1825. X        for (i = 0; argv[i] != (char *) NULL; i++)    /* free */
  1826. X            free(argv[i]);    /* the old array */
  1827. X        free((char *) argv);    /* and then free the ptr itself */
  1828. X    }
  1829. X
  1830. X    linecp = line;
  1831. X    num_words = 0;
  1832. X    while (1) {    /* count words in input */
  1833. X        for (; *linecp == ' ' || *linecp == '\t'; ++linecp)
  1834. X            ;
  1835. X        if (*linecp == '\0')
  1836. X            break;
  1837. X
  1838. X        for (; *linecp != ' ' && *linecp != '\t' && *linecp != '\0'; ++linecp)
  1839. X            ;
  1840. X        ++num_words;
  1841. X        if (*linecp == '\0')
  1842. X            break;
  1843. X    }
  1844. X
  1845. X    /* Then malloc enough for that many words plus 1 (for null) */
  1846. X
  1847. X    if ((argv = (char **) malloc((num_words + 1) * sizeof(char *))) ==
  1848. X        (char **) NULL) {
  1849. X        fprintf(stderr, "parsit: malloc out of space!\n");
  1850. X        return(0);
  1851. X    }
  1852. X
  1853. X    j = i = 0;
  1854. X    while (1) {    /* Now build the list of words */
  1855. X        for (; *line == ' ' || *line == '\t'; ++line)
  1856. X            ;
  1857. X        if (*line == '\0')
  1858. X            break;
  1859. X
  1860. X        i = 0;
  1861. X        for (; *line != ' ' && *line != '\t' && *line != '\0'; ++line)
  1862. X            word[i++] =  *line;
  1863. X        word[i] = '\0';
  1864. X        argv[j] = malloc(strlen(word) + 1);
  1865. X        if (argv[j] == (char *) NULL) {
  1866. X            fprintf(stderr, "parsit: malloc out of space!\n");
  1867. X            return(0);
  1868. X        }
  1869. X
  1870. X        (void) strcpy(argv[j], word);
  1871. X        ++j;
  1872. X        if (*line == '\0')
  1873. X            break;
  1874. X    }
  1875. X    argv[j] = (char *) NULL;  /* remember null at end of list */
  1876. X    *array = argv;
  1877. X    return(j);
  1878. X}
  1879. END_OF_FILE
  1880. if test 2471 -ne `wc -c <'./server/parsit.c'`; then
  1881.     echo shar: \"'./server/parsit.c'\" unpacked with wrong size!
  1882. fi
  1883. # end of './server/parsit.c'
  1884. fi
  1885. if test -f './support/README' -a "${1}" != "-c" ; then 
  1886.   echo shar: Will not clobber existing file \"'./support/README'\"
  1887. else
  1888. echo shar: Extracting \"'./support/README'\" \(1902 characters\)
  1889. sed "s/^X//" >'./support/README' <<'END_OF_FILE'
  1890. X>>>>>>>>>>>>>>>>>>>>>>>>> No software in the NNTP 1.4 package
  1891. X>> NOTE NOTE NOTE NOTE >> uses the NEWGROUPS command.  As a result,
  1892. X>> NOTE NOTE NOTE NOTE >> mkgrdates is no longer supported, but is
  1893. X>>>>>>>>>>>>>>>>>>>>>>>>> included for completeness.
  1894. X
  1895. X     Mkgrdates is run by cron periodically (say, every 6 or 12 hours --
  1896. it's up to you).  All it does is produce a cronologically ordered list
  1897. of newsgroups in the active file, along with their dates of creation.
  1898. It tries to be intelligent, and if the active file hasn't changed since
  1899. it was last run, it simply exits.
  1900. X
  1901. X     So, you'll need to put "mkgrdates" in /usr/lib/crontab to
  1902. be run periodically.  Every day is probably good enough.
  1903. X
  1904. X     Some things you might want to be aware of are that it creates
  1905. and updates the files STAT_FILE and NGDATE_FILE, defined in
  1906. X../common/conf.h.  It's up to you to define these constants to suit
  1907. your system.
  1908. X
  1909. X     The file "access_file" is the file which tells the news server
  1910. which hosts can read, which can post, and which can transfer.
  1911. This file wants to be installed wherever ACCESS_FILE in ../common/conf.h
  1912. says it should be (you can configure this to suit you).  Remember
  1913. that this should be readable by whatever uid the news server runs
  1914. as.  Further, remember that the entry "default" must be first in
  1915. the table.
  1916. X
  1917. X     >>> The access file will support subnets iff you have <<<
  1918. X     >>> defined SUBNET when you made the server.       <<<
  1919. X
  1920. X     Finally, edit Makefile to reflect DESTDIR -- where you want
  1921. the binary to be installed for mkgrdates.
  1922. X
  1923. X     If you're having the nntp server log copious info, you will
  1924. probably want to run the stat package developed by Erik Fair.
  1925. Once a week you should have crontab do
  1926. X
  1927. X    awk -f nntp_awk nntplog.old >& nntp_report
  1928. X
  1929. where "nntplog.old" is the last week's nntp log file produced
  1930. by syslog.  Any errors which it cannot resolve are placed
  1931. in the front of the report.
  1932. END_OF_FILE
  1933. if test 1902 -ne `wc -c <'./support/README'`; then
  1934.     echo shar: \"'./support/README'\" unpacked with wrong size!
  1935. fi
  1936. # end of './support/README'
  1937. fi
  1938. if test -f './xmit/Makefile' -a "${1}" != "-c" ; then 
  1939.   echo shar: Will not clobber existing file \"'./xmit/Makefile'\"
  1940. else
  1941. echo shar: Extracting \"'./xmit/Makefile'\" \(1833 characters\)
  1942. sed "s/^X//" >'./xmit/Makefile' <<'END_OF_FILE'
  1943. X# Compile time flags:
  1944. X#    BSD4_2        - We're a 4.2 BSD UNIX (or later, includes Ultrix)
  1945. X#                4.2BSD accounting
  1946. X#    USG        - We're a USG (System III/V) UNIX
  1947. X#                unreliable signals, strchr, missing bcopy,
  1948. X#                might have lockf(2)
  1949. X#    USELOG="file"    - Log transmission stats to this file
  1950. X#    DECNET        - We're an Ultrix system with DECNET
  1951. X#                (this implies BSD4_2)
  1952. X#    EXCELAN        - We're a USG system with an EXCELAN ethernet board
  1953. X#                to fake real networking with.
  1954. X#
  1955. X# these two are implied by EXCELAN:
  1956. X#    NONETDB        - We don't have gethostbyname(3) and getservbyname(3)
  1957. X#                and inet_ntoa(3) and inet_addr(3)
  1958. X#    OLDSOCKET    - We use the old (pre 4.2 BSD) socket(2) args
  1959. X#
  1960. X# these are implied by BSD4_2:
  1961. X#    SYSLOG        - We have syslog(3)
  1962. X#    FTRUNCATE    - We have ftruncate(2)
  1963. X#    RELSIG        - We have 4BSD's reliable signals
  1964. X#                (although I use the signal(2) interface)
  1965. X
  1966. DEFS= -DBSD4_2
  1967. X# -lresolv needed below for pyramids
  1968. LIBS=
  1969. CFLAGS= -O ${DEFS}
  1970. DESTDIR=/usr/lib/news
  1971. HFILES=nntpxmit.h get_tcp_conn.h llist.h sysexits.h nntp.h
  1972. SRC=nntpxmit.c remote.c llist.c get_tcp_conn.c
  1973. OBJ=nntpxmit.o remote.o llist.o get_tcp_conn.o
  1974. FILES=Makefile nntpxmit.1 ${SRC} ${HFILES} shlock.c nntpsend.csh nntpsend.sh nntp_awk
  1975. X
  1976. all: nntpxmit shlock
  1977. X
  1978. nntpxmit: ${OBJ}
  1979. X    cc -o $@ ${OBJ} ${LIBS}
  1980. X    @ls -las $@ ; size $@
  1981. X
  1982. nntpxmit.o: nntpxmit.c nntpxmit.h llist.h
  1983. X
  1984. get_tcp_conn.o: get_tcp_conn.c get_tcp_conn.h
  1985. X
  1986. remote.o: remote.c nntpxmit.h get_tcp_conn.h
  1987. X
  1988. llist.o: llist.c llist.h
  1989. X
  1990. shlock: shlock.c
  1991. X    cc ${CFLAGS} -o shlock shlock.c
  1992. X
  1993. install: nntpxmit shlock
  1994. X    cp nntpxmit shlock ${DESTDIR}
  1995. X    cd ${DESTDIR}; chmod 755 nntpxmit shlock
  1996. X    @echo "You'll have to edit nntpsend for local config."
  1997. X
  1998. lint:
  1999. X    lint -hbx ${DEFS} ${SRC} ${LIBS}
  2000. X
  2001. clean:
  2002. X    rm -f nntpxmit shlock ${OBJ}
  2003. X
  2004. dist: nntpxmit.tar
  2005. X
  2006. nntpxmit.tar: ${FILES}
  2007. X    tar cvhf nntpxmit.tar ${FILES}
  2008. X
  2009. X# two for Phil Lapsley
  2010. distrib: clean
  2011. X
  2012. check:;
  2013. X
  2014. END_OF_FILE
  2015. if test 1833 -ne `wc -c <'./xmit/Makefile'`; then
  2016.     echo shar: \"'./xmit/Makefile'\" unpacked with wrong size!
  2017. fi
  2018. # end of './xmit/Makefile'
  2019. fi
  2020. if test -f './xmit/nntp.h' -a "${1}" != "-c" ; then 
  2021.   echo shar: Will not clobber existing file \"'./xmit/nntp.h'\"
  2022. else
  2023. echo shar: Extracting \"'./xmit/nntp.h'\" \(2468 characters\)
  2024. sed "s/^X//" >'./xmit/nntp.h' <<'END_OF_FILE'
  2025. X/*
  2026. X * Response codes for NNTP server
  2027. X *
  2028. X * @(#)response_codes.h    1.6    (Berkeley) 2/6/86
  2029. X *
  2030. X * First digit:
  2031. X *
  2032. X *    1xx    Informative message
  2033. X *    2xx    Command ok
  2034. X *    3xx    Command ok so far, continue
  2035. X *    4xx    Command was correct, but couldn't be performed
  2036. X *        for some specified reason.
  2037. X *    5xx    Command unimplemented, incorrect, or a
  2038. X *        program error has occured.
  2039. X *
  2040. X * Second digit:
  2041. X *
  2042. X *    x0x    Connection, setup, miscellaneous
  2043. X *    x1x    Newsgroup selection
  2044. X *    x2x    Article selection
  2045. X *    x3x    Distribution
  2046. X *    x4x    Posting
  2047. X */
  2048. X
  2049. X#define    CHAR_INF    '1'
  2050. X#define    CHAR_OK        '2'
  2051. X#define    CHAR_CONT    '3'
  2052. X#define    CHAR_ERR    '4'
  2053. X#define    CHAR_FATAL    '5'
  2054. X
  2055. X#define    INF_HELP    100    /* Help text on way */
  2056. X#define    INF_DEBUG    199    /* Debug output */
  2057. X
  2058. X#define    OK_CANPOST    200    /* Hello; you can post */
  2059. X#define    OK_NOPOST    201    /* Hello; you can't post */
  2060. X#define    OK_SLAVE    202    /* Slave status noted */
  2061. X#define    OK_GOODBYE    205    /* Closing connection */
  2062. X#define    OK_GROUP    211    /* Group selected */
  2063. X#define    OK_GROUPS    215    /* Newsgroups follow */
  2064. X#define    OK_ARTICLE    220    /* Article (head & body) follows */
  2065. X#define    OK_HEAD        221    /* Head follows */
  2066. X#define    OK_BODY        222    /* Body follows */
  2067. X#define    OK_NOTEXT    223    /* No text sent -- stat, next, last */
  2068. X#define    OK_NEWNEWS    230    /* New articles by message-id follow */
  2069. X#define    OK_NEWGROUPS    231    /* New newsgroups follow */
  2070. X#define    OK_XFERED    235    /* Article transferred successfully */
  2071. X#define    OK_POSTED    240    /* Article posted successfully */
  2072. X
  2073. X#define CONT_XFER    335    /* Continue to send article */
  2074. X#define    CONT_POST    340    /* Continue to post article */
  2075. X
  2076. X#define    ERR_GOODBYE    400    /* Have to hang up for some reason */
  2077. X#define    ERR_NOGROUP    411    /* No such newsgroup */
  2078. X#define    ERR_NCING    412    /* Not currently in newsgroup */
  2079. X#define    ERR_NOCRNT    420    /* No current article selected */
  2080. X#define    ERR_NONEXT    421    /* No next article in this group */
  2081. X#define    ERR_NOPREV    422    /* No previous article in this group */
  2082. X#define    ERR_NOARTIG    423    /* No such article in this group */
  2083. X#define ERR_NOART    430    /* No such article at all */
  2084. X#define ERR_GOTIT    435    /* Already got that article, don't send */
  2085. X#define ERR_XFERFAIL    436    /* Transfer failed */
  2086. X#define    ERR_XFERRJCT    437    /* Article rejected, don't resend */
  2087. X#define    ERR_NOPOST    440    /* Posting not allowed */
  2088. X#define    ERR_POSTFAIL    441    /* Posting failed */
  2089. X
  2090. X#define    ERR_COMMAND    500    /* Command not recognized */
  2091. X#define    ERR_CMDSYN    501    /* Command syntax error */
  2092. X#define    ERR_ACCESS    502    /* Access to server denied */
  2093. X#define ERR_FAULT    503    /* Program fault, command not performed */
  2094. END_OF_FILE
  2095. if test 2468 -ne `wc -c <'./xmit/nntp.h'`; then
  2096.     echo shar: \"'./xmit/nntp.h'\" unpacked with wrong size!
  2097. fi
  2098. # end of './xmit/nntp.h'
  2099. fi
  2100. if test -f './xmit/nntpsend.csh' -a "${1}" != "-c" ; then 
  2101.   echo shar: Will not clobber existing file \"'./xmit/nntpsend.csh'\"
  2102. else
  2103. echo shar: Extracting \"'./xmit/nntpsend.csh'\" \(1550 characters\)
  2104. sed "s/^X//" >'./xmit/nntpsend.csh' <<'END_OF_FILE'
  2105. X#!/bin/csh -f
  2106. X#
  2107. X# What we have here is a csh script for sending netnews to NNTP sites.
  2108. X#
  2109. set batchdir=/usr/spool/news/batch libdir=/usr/spool/news/lib
  2110. set path=( $libdir /usr/ucb /usr/bin /bin $path )
  2111. set pname=$0
  2112. set pname=$pname:t
  2113. echo ${pname}: "[$$]" begin `date`
  2114. X#
  2115. X# Go to where the action is
  2116. X#
  2117. cd $batchdir
  2118. umask 022
  2119. X#
  2120. X#    For NNTP
  2121. X#
  2122. X#    Here "foo", "bar", and "zot" are the Internet names of
  2123. X#    the machines to which to send.  We make the supposition
  2124. X#    that the batch files will be a host's internet name.
  2125. X#    So, for example "nike"'s internet name is "ames-titan.arpa".
  2126. X#    Because of this, your sys file must have "ames-titan.arpa"
  2127. X#    as the batch file output for the machine "nike".
  2128. X#
  2129. foreach host ( {cad,zen,jade,cartan}.berkeley.edu decvax.dec.com cgl.ucsf.edu ucdavis.edu 128.54.0.1 )
  2130. X    set lock=NNTP_LOCK.${host} tmp=${host}.tmp send=${host}.nntp
  2131. X    shlock -p $$ -f ${lock}
  2132. X    if ($status == 0) then
  2133. X        if ( -e ${tmp} ) then
  2134. X            cat ${tmp} >> ${send}
  2135. X            rm ${tmp}
  2136. X        endif
  2137. X        if ( -e ${host} ) then
  2138. X# if there's already other work to do, let the tmp file cool off.
  2139. X# we'll pick it up again during the next iteration to make sure that
  2140. X# we don't miss anything that inews is adding to it now.
  2141. X            if ( -e ${send} ) then
  2142. X                mv ${host} ${tmp}
  2143. X            else
  2144. X                mv ${host} ${send}
  2145. X            endif
  2146. X        endif
  2147. X        if ( -e ${send} ) then
  2148. X            echo ${pname}: "[$$]" begin ${host}
  2149. X            time nntpxmit ${host}:${send}
  2150. X            echo ${pname}: "[$$]" end ${host}
  2151. X        endif
  2152. X        rm -f ${lock}
  2153. X    else
  2154. X        echo ${pname}: "[$$]" ${host} locked by "[`cat ${lock}`]"
  2155. X    endif
  2156. end
  2157. echo ${pname}: "[$$]" end `date`
  2158. END_OF_FILE
  2159. if test 1550 -ne `wc -c <'./xmit/nntpsend.csh'`; then
  2160.     echo shar: \"'./xmit/nntpsend.csh'\" unpacked with wrong size!
  2161. fi
  2162. chmod +x './xmit/nntpsend.csh'
  2163. # end of './xmit/nntpsend.csh'
  2164. fi
  2165. if test -f './xmit/nntpxmit.h' -a "${1}" != "-c" ; then 
  2166.   echo shar: Will not clobber existing file \"'./xmit/nntpxmit.h'\"
  2167. else
  2168. echo shar: Extracting \"'./xmit/nntpxmit.h'\" \(1545 characters\)
  2169. sed "s/^X//" >'./xmit/nntpxmit.h' <<'END_OF_FILE'
  2170. X/*
  2171. X** Random stuff needed for nntpxmit
  2172. X**
  2173. X** This file also contains a lot of assumptions about what features
  2174. X** are available on the local system - if something is not working
  2175. X** to your liking, look them over carefully.
  2176. X*/
  2177. X
  2178. typedef    int    (*ifunp)();    /* pointer to function that returns int */
  2179. X
  2180. X#define    dprintf    if (Debug) fprintf
  2181. X
  2182. X#define    TIMEOUT    3600        /* seconds to read timeout in sfgets */
  2183. X
  2184. X#ifndef    TRUE
  2185. X#define    TRUE    1
  2186. X#define    FALSE    0
  2187. X#endif
  2188. X
  2189. X/* in goodbye() wait (or not) for QUIT response */
  2190. X#define    WAIT        TRUE
  2191. X#define    DONT_WAIT    FALSE
  2192. X
  2193. X/* in lockfd(), blocking, or non_blocking */
  2194. X#define    BLOCK        FALSE
  2195. X#define    DONT_BLOCK    TRUE
  2196. X
  2197. X#ifndef FAIL
  2198. X#define    FAIL        (-1)
  2199. X#endif
  2200. X
  2201. X
  2202. X/* DECNET support is only there if the DECNET compile-time option defined */
  2203. X#define    T_IP_TCP    1    /* transport is IP/TCP */
  2204. X#define    T_DECNET    2    /* transport is DECNET */
  2205. X#define    T_FD        3    /* transport is a descriptor */
  2206. X
  2207. X/* for syslog, if we compile it in */
  2208. X#define    L_DEBUG        1
  2209. X#define    L_INFO        2
  2210. X#define    L_NOTICE    3
  2211. X#define    L_WARNING    4
  2212. X
  2213. X#if    (DECNET && !BSD4_2)    /* if we have DECNET, we're an Ultrix */
  2214. X#define    BSD4_2
  2215. X#undef    USG
  2216. X#endif
  2217. X
  2218. X#if    (EXCELAN && !USG)    /* if we have EXCELAN, we're an Uglix */
  2219. X#define    USG
  2220. X#undef    BSD4_2
  2221. X#endif
  2222. X
  2223. X#ifdef    USG            /* USG pinheadedness */
  2224. X#define    index    strchr
  2225. X#define    rindex    strrchr
  2226. X#define    u_long    unsigned long
  2227. X#define    u_short    unsigned short
  2228. X#endif
  2229. X
  2230. X#ifdef    BSD4_2            /* look at all these goodies we get! */
  2231. X#define    FTRUNCATE
  2232. X#define    SYSLOG
  2233. X#define    RELSIG
  2234. X#endif    BSD4_2
  2235. X
  2236. X#ifdef apollo
  2237. X#undef SYSLOG            /* Apollos don't have this by default */
  2238. X#endif
  2239. END_OF_FILE
  2240. if test 1545 -ne `wc -c <'./xmit/nntpxmit.h'`; then
  2241.     echo shar: \"'./xmit/nntpxmit.h'\" unpacked with wrong size!
  2242. fi
  2243. # end of './xmit/nntpxmit.h'
  2244. fi
  2245. echo shar: End of archive 2 \(of 9\).
  2246. cp /dev/null ark2isdone
  2247. MISSING=""
  2248. for I in 1 2 3 4 5 6 7 8 9 ; do
  2249.     if test ! -f ark${I}isdone ; then
  2250.     MISSING="${MISSING} ${I}"
  2251.     fi
  2252. done
  2253. if test "${MISSING}" = "" ; then
  2254.     echo You have unpacked all 9 archives.
  2255.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2256. else
  2257.     echo You still need to unpack the following archives:
  2258.     echo "        " ${MISSING}
  2259. fi
  2260. ##  End of shell archive.
  2261. exit 0
  2262.