Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!munnari.oz.au!basser!ultima!nick From: nick@ultima.cs.uts.oz (Nick Andrew) Newsgroups: comp.os.minix Subject: News for Minix (part 10 of 12) Keywords: news Message-ID: <16752@ultima.cs.uts.oz> Date: 7 Dec 89 11:55:14 GMT Organization: Comp Sci, NSWIT, Australia Lines: 1387 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'defs.h' <<'END_OF_FILE' X/* X * This software is Copyright (c) 1986 by Rick Adams. X * X * Permission is hereby granted to copy, reproduce, redistribute or X * otherwise use this software as long as: there is no monetary X * profit gained specifically from the use or reproduction or this X * software, it is not sold, rented, traded or otherwise marketed, and X * this copyright notice is included prominently in any copy X * made. X * X * The author make no claims as to the fitness or correctness of X * this software for any use whatsoever, and it is provided as is. X * Any use of this software is at the user's own risk. X * X */ X X/* @(#)defs.dist 2.58 4/10/87 */ X X/* X * defs.h - defines for news-related programs. X * X * If you remove any lines here or in your Makefile, make the change X * to localize.sh so you won't have to redo it for each news release. X * X * If TMAIL is undefined, the -M option will be disabled. X * X * By convention, the version of the software you are running is taken X * to be news_version below. X */ X X#define DAYS (60L*60L*24L) X#define WEEKS (7*DAYS) X/* Things that very well may require local configuration */ X#ifndef HOME X#define ROOTID 10 /* uid of person allowed to cancel anything */ X#endif X#define N_UMASK 002 /* mask for umask call, 022 for secure system */ X#define DFLTEXP 2*WEEKS /* default no. of seconds to expire in */ X#define HISTEXP 4*WEEKS /* default no. of seconds to forget in */ X#define DFLTSUB "general,all.announce" /* default subscription list */ X#define TMAIL "/usr/bin/Mail" /* Mail program that understands -T */ X#define ADMSUB "general,all.announce" /* Mandatory subscription list */ X#define PAGE "/usr/bin/more" /* Default pager */ X#define NOTIFY "usenet" /* Tell him about certain ctl messages */ X /* Default xmit command - remove -z if */ X#define DFTXMIT "uux - -r -z -gd %s!rnews < %s" /* your uux can't do it */ X#define UXMIT "uux -r -z -gd -c %s!rnews '<' %s" /* If uux -c is ok */ X#define DFTEDITOR "mined" /* Default editor, see also postnews. */ X/* #define UUPROG "euuname" /* omit for uuname, put in LIBDIR */ X#define MANUALLY /* Don't execute rmgroups, just notify. */ X/* #define NONEWGROUPS /* Don't create new groups, just notify.*/ X/* #define SPOOLNEWS /* Spool incoming rnews, don't process */ X/* #define SPOOLINEWS /* Spool local inews, don't process */ X/* #define LOCALNAME /* There is no full name database. */ X#define INTERNET /* Internet mail works locally */ X#define MYDOMAIN ".OZ" /* Local domain */ X/* #define CHEAP /* don't chown files to news */ X/* #define OLD /* Add extra headers for old neighbors */ X/* #define UNAME /* If uname call returns your nodename */ X/* #define GHNAME /* If gethostname call is available. */ X#define UUNAME "/etc/uucpname" /* If your nodename is stored in a file */ X#define V7MAIL /* Local mail format is V7 ("From ") */ X#define SORTACTIVE /* if you want news presented in the order of the .newsrc */ X#define ZAPNOTES /* if you want old style notes headers moved into the headers */ X#define DIGPAGE /* allow digestifying in vnews */ X/* #define DOXREFS /* Generate xref line for rn to use */ X#define MULTICAST /* If you want to be able to multicast news */ X/* #define BSD4_2 /* If you are running 4.2 or 4.3 BSD */ X/* #define BSD4_1C /* If you are running 4.1C BSD */ X/* #define LOCKF /* If you have the lockf() sys call */ X/* #define ALWAYSALIAS /* temporary kludge for conversion */ X/* #define SENDMAIL "/usr/bin/sendmail" /* command line to run "sendmail" if you have it */ X/* #define MMDF "/usr/mmdf/submit" /* command line to run mmdf if you have it */ X#define MYORG "Minix support BBS, NSW, Australia" /* My organization. Please */ X /* include your city (and state, and */ X /* country, if not obvious) in MYORG, */ X /* and please keep it short. */ X/* #define HIDDENNET "frooz" /* if you have a local network and want */ X /* The mail address to look like it came */ X /* from one machine */ X/* NOTE: The following two macros replace the use of HIDDENNET */ X/* #define GENERICPATH "frooz" /* If you are using a shared USENET/UUCP node */ X/* #define GENERICFROM "Frobozz.COM" /* If you want generic From:-addresses */ X/* #define NICENESS 4 /* does a nice(NICENESS) in rnews */ X/* #define FASCIST "all,!all.all" /* only permit posting to certain groups */ X /* see installation guide for details */ X#define SMALL_ADDRESS_SPACE /* If your machine can't address > 32767 */ X/* #define ORGDISTRIB "froozum" /* For organization wide control message handling */ X X/* Things you might want to change */ X#define NEWSRC ".newsrc" /* name of .newsrc file (in home dir) */ X#define LINES 512 /* maximum no. of lines in .newsrc */ X#define NEGCHAR '!' /* newsgroup negation character */ X#define DEADTIME 45 /* no. of seconds to wait on deadlock */ X#define FMETA '%' /* file meta-character for c option */ X#if defined(pdp11) || defined(SMALL_ADDRESS_SPACE) X# define BUFLEN 128 /* standard buffer size */ X#else X# define BUFLEN 256 /* standard buffer size */ X#endif X#define LBUFLEN 1024 /* big buffer size */ X#define SBUFLEN 32 /* small buffer size (for system names, etc) */ X#define LNCNT 14 /* Articles with > LNCNT lines go through pager */ X X/* Things you probably won't want to change */ X#define PATHLEN 512 /* length of longest source string */ X#define DATELEN 64 /* length of longest allowed date string */ X#define NAMELEN 128 /* length of longest possible message ID */ X#define SNLN 8 /* max significant characters in sysname */ X#define PROTO 'A' /* old protocol name */ X#define NETCHRS "!:@^%,"/* Punct. chars used for various networks */ X#define TRUE 1 /* boolean true */ X#define FALSE 0 /* boolean false */ X#define PERHAPS 2 /* indeterminate boolean value */ X#define NGDELIM ',' /* delimit character in news group line */ X END_OF_FILE if test 5776 -ne `wc -c <'defs.h'`; then echo shar: \"'defs.h'\" unpacked with wrong size! fi # end of 'defs.h' fi if test -f 'defs.dist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'defs.dist'\" else echo shar: Extracting \"'defs.dist'\" \(5768 characters\) sed "s/^X//" >'defs.dist' <<'END_OF_FILE' X/* X * This software is Copyright (c) 1986 by Rick Adams. X * X * Permission is hereby granted to copy, reproduce, redistribute or X * otherwise use this software as long as: there is no monetary X * profit gained specifically from the use or reproduction or this X * software, it is not sold, rented, traded or otherwise marketed, and X * this copyright notice is included prominently in any copy X * made. X * X * The author make no claims as to the fitness or correctness of X * this software for any use whatsoever, and it is provided as is. X * Any use of this software is at the user's own risk. X * X */ X X/* @(#)defs.dist 2.58 4/10/87 */ X X/* X * defs.h - defines for news-related programs. X * X * If you remove any lines here or in your Makefile, make the change X * to localize.sh so you won't have to redo it for each news release. X * X * If TMAIL is undefined, the -M option will be disabled. X * X * By convention, the version of the software you are running is taken X * to be news_version below. X */ X X#define DAYS (60L*60L*24L) X#define WEEKS (7*DAYS) X/* Things that very well may require local configuration */ X#ifndef HOME X#define ROOTID 10 /* uid of person allowed to cancel anything */ X#endif X#define N_UMASK 000 /* mask for umask call, 022 for secure system */ X#define DFLTEXP 2*WEEKS /* default no. of seconds to expire in */ X#define HISTEXP 4*WEEKS /* default no. of seconds to forget in */ X#define DFLTSUB "general,all.announce" /* default subscription list */ X#define TMAIL "/usr/ucb/Mail" /* Mail program that understands -T */ X#define ADMSUB "general,all.announce" /* Mandatory subscription list */ X#define PAGE "/usr/ucb/more" /* Default pager */ X#define NOTIFY "usenet" /* Tell him about certain ctl messages */ X /* Default xmit command - remove -z if */ X#define DFTXMIT "uux - -r -z %s!rnews < %s" /* your uux can't do it */ X#define UXMIT "uux -r -z -c %s!rnews '<' %s" /* If uux -c is ok */ X#define DFTEDITOR "vi" /* Default editor, see also postnews. */ X/* #define UUPROG "euuname" /* omit for uuname, put in LIBDIR */ X#define MANUALLY /* Don't execute rmgroups, just notify. */ X/* #define NONEWGROUPS /* Don't create new groups, just notify.*/ X/* #define SPOOLNEWS /* Spool incoming rnews, don't process */ X/* #define SPOOLINEWS /* Spool local inews, don't process */ X/* #define LOCALNAME /* There is no full name database. */ X/* #define INTERNET /* Internet mail works locally */ X#define MYDOMAIN ".UUCP" /* Local domain */ X/* #define CHEAP /* don't chown files to news */ X/* #define OLD /* Add extra headers for old neighbors */ X/* #define UNAME /* If uname call returns your nodename */ X/* #define GHNAME /* If gethostname call is available. */ X/* #define UUNAME "/etc/uucpname" /* If your nodename is stored in a file */ X#define V7MAIL /* Local mail format is V7 ("From ") */ X#define SORTACTIVE /* if you want news presented in the order of the .newsrc */ X#define ZAPNOTES /* if you want old style notes headers moved into the headers */ X#define DIGPAGE /* allow digestifying in vnews */ X/* #define DOXREFS /* Generate xref line for rn to use */ X/* #define MULTICAST /* If you want to be able to multicast news */ X/* #define BSD4_2 /* If you are running 4.2 or 4.3 BSD */ X/* #define BSD4_1C /* If you are running 4.1C BSD */ X/* #define LOCKF /* If you have the lockf() sys call */ X/* #define ALWAYSALIAS /* temporary kludge for conversion */ X/* #define SENDMAIL "/usr/lib/sendmail" /* command line to run "sendmail" if you have it */ X/* #define MMDF "/usr/mmdf/submit" /* command line to run mmdf if you have it */ X#define MYORG "Frobozz Inc., St. Louis" /* My organization. Please */ X /* include your city (and state, and */ X /* country, if not obvious) in MYORG, */ X /* and please keep it short. */ X/* #define HIDDENNET "frooz" /* if you have a local network and want */ X /* The mail address to look like it came */ X /* from one machine */ X/* NOTE: The following two macros replace the use of HIDDENNET */ X/* #define GENERICPATH "frooz" /* If you are using a shared USENET/UUCP node */ X/* #define GENERICFROM "Frobozz.COM" /* If you want generic From:-addresses */ X/* #define NICENESS 4 /* does a nice(NICENESS) in rnews */ X/* #define FASCIST "all,!all.all" /* only permit posting to certain groups */ X /* see installation guide for details */ X/* #define SMALL_ADDRESS_SPACE /* If your machine can't address > 32767 */ X/* #define ORGDISTRIB "froozum" /* For organization wide control message handling */ X X/* Things you might want to change */ X#define NEWSRC ".newsrc" /* name of .newsrc file (in home dir) */ X#define LINES 512 /* maximum no. of lines in .newsrc */ X#define NEGCHAR '!' /* newsgroup negation character */ X#define DEADTIME 45 /* no. of seconds to wait on deadlock */ X#define FMETA '%' /* file meta-character for c option */ X#if defined(pdp11) || defined(SMALL_ADDRESS_SPACE) X# define BUFLEN 128 /* standard buffer size */ X#else X# define BUFLEN 256 /* standard buffer size */ X#endif X#define LBUFLEN 1024 /* big buffer size */ X#define SBUFLEN 32 /* small buffer size (for system names, etc) */ X#define LNCNT 14 /* Articles with > LNCNT lines go through pager */ X X/* Things you probably won't want to change */ X#define PATHLEN 512 /* length of longest source string */ X#define DATELEN 64 /* length of longest allowed date string */ X#define NAMELEN 128 /* length of longest possible message ID */ X#define SNLN 8 /* max significant characters in sysname */ X#define PROTO 'A' /* old protocol name */ X#define NETCHRS "!:@^%,"/* Punct. chars used for various networks */ X#define TRUE 1 /* boolean true */ X#define FALSE 0 /* boolean false */ X#define PERHAPS 2 /* indeterminate boolean value */ X#define NGDELIM ',' /* delimit character in news group line */ END_OF_FILE if test 5768 -ne `wc -c <'defs.dist'`; then echo shar: \"'defs.dist'\" unpacked with wrong size! fi # end of 'defs.dist' fi if test -f 'batch.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'batch.c'\" else echo shar: Extracting \"'batch.c'\" \(5484 characters\) sed "s/^X//" >'batch.c' <<'END_OF_FILE' X X/* X * This software is Copyright (c) 1985 by Rick Adams. X * X * Permission is hereby granted to copy, reproduce, redistribute or X * otherwise use this software as long as: there is no monetary X * profit gained specifically from the use or reproduction or this X * software, it is not sold, rented, traded or otherwise marketed, and X * this copyright notice is included prominently in any copy X * made. X * X * The author make no claims as to the fitness or correctness of X * this software for any use whatsoever, and it is provided as is. X * Any use of this software is at the user's own risk. X * X * Batch: program to batch a list of news articles into an unbatch script. X * Usage: /usr/lib/news/batch listfile [bytecount] X * where listfile is a file containing a list, one per line, of full X * path names of files containing articles, e.g. as produced by the F X * transmission option in the sys file. X * bytecount is the maximum number of bytes to output before exiting X * Output is placed on standard output. X * X * Intended usage: X * X * With the shellfile "sendbatch", with machine names as arguments: X * e.g X * sendbatch rlgvax seismo X * X * This would be invoked every hour or two from crontab. X * X */ X X#ifdef SCCSID Xstatic char *SccsId = "@(#)batch.c 1.18 12/16/86"; X#endif /* SCCSID */ X X#include X#include X#include X#include X#include "defs.h" X X#if defined(USG) || defined(BSD4_2) || defined(BSD4_1C) X#include X#endif X Xstruct stat sbuf; X Xextern int errno; Xextern char *sys_errlist[]; X Xmain(argc,argv) Xchar **argv; X{ X register FILE *fd, *nfd; X register int c; X register long n; X register char *cp; X char *fdstatus; X long maxbytes, nbytes; X long atol(); X char fname[512]; X char workfile[512]; X char *index(), *fgets(); X X if (argc < 2) { X fprintf(stderr, "Usage: batch listfile [bytecount]\n"); X exit(1); X } X X /* X * Rename real file to a work name to avoid race conditions. X * If workfile exists skip the rename in order X * to recover from a crash w/o losing anything. X */ X (void) strcpy(workfile, argv[1]); X (void) strcat(workfile, ".work"); X if (access(workfile, 0) < 0) { X if (access(argv[1], 0) < 0 && errno == ENOENT) X exit(0); /* no news */ X if (rename(argv[1], workfile) < 0) { X logerror("rename(%s,%s) %s", argv[1], workfile, X sys_errlist[errno]); X exit(1); X } X } X fd = fopen(workfile, "r"); X if (fd == NULL) { X logerror("fopen(%s,r) %s", workfile, sys_errlist[errno]); X exit(1); X } X X if (argc > 2) X maxbytes = atol(argv[2]); X else X maxbytes = 100000000L; /* backwards compatible */ X nbytes = 0; X while ((fdstatus = fgets(fname, sizeof fname, fd)) != NULL) { X cp = index(fname, '\n'); X if (cp) X *cp = '\0'; X nfd = fopen(fname, "r"); X if (nfd == NULL) { X perror(fname); X continue; X } X (void) fstat(fileno(nfd), &sbuf); X if (cp) X *cp = '\n'; X nbytes += sbuf.st_size; X if (nbytes > maxbytes && nbytes != sbuf.st_size) X break; X printf("#! rnews %ld\n", (long)sbuf.st_size); X /* guess length of #! rnews string */ X nbytes += 13; X n = 0; X while ((c = getc(nfd)) != EOF) { X putchar(c); X n++; X } X (void) fclose(nfd); X if (ferror(stdout)){ X logerror("stdout write %s", sys_errlist[errno]); X exit(1); X } X if (n != sbuf.st_size) { /* paranoia */ X logerror("%s, expected %ld bytes, got %ld", fname, X n, sbuf.st_size); X /* breaking out of this early will end up resyncing X the batch files (isn't serendipity wonderful?) */ X break; X } X } X if (fdstatus != NULL) { /* exceeded maxbytes */ X char tmpfile[512]; X X (void) umask(2); X (void) strcpy(tmpfile, argv[1]); X (void) strcat(tmpfile, ".tmp"); X nfd = fopen(tmpfile, "w"); X if (nfd == NULL) { X logerror("fopen(%s,w) %s", tmpfile, sys_errlist[errno]); X exit(1); X } X do { X fputs(fname, nfd); X } while (fgets(fname, sizeof fname, fd) != NULL); X if (ferror(nfd)) { X logerror("write(%s) %s", tmpfile, sys_errlist[errno]); X exit(1); X } X (void) fclose(nfd); X (void) fclose(fd); X /* will pick it up next time thru */ X if (rename(tmpfile, workfile) < 0) { X logerror("rename(%s,%s) %s", tmpfile, workfile, X sys_errlist[errno]); X exit(1); X } X } X else X (void) unlink(workfile); X exit(0); X} X X/* X * Log the given message, with printf strings and parameters allowed, X * on the log file, if it can be written. X */ X/* VARARGS1 */ Xlogerror(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) Xchar *fmt; Xlong a1, a2, a3, a4, a5, a6, a7, a8, a9; X{ X FILE *logfile; X char lfname[BUFLEN]; /* the log file */ X char bfr[BUFLEN]; X char *logtime, *ctime(); X time_t t; X X (void) time(&t); X logtime = ctime(&t); X logtime[16] = 0; X logtime += 4; X X#if defined(IHCC) || defined(HOME) X (void) sprintf(lfname, "%s/%s/errlog", logdir(HOME), LIBDIR); X#else X (void) sprintf(lfname, "%s/errlog", LIBDIR); X#endif X X (void) sprintf(bfr, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9); X fprintf(stderr, bfr); X if (access(lfname, 0) == 0 && (logfile = fopen(lfname, "a")) != NULL) { X#if defined(USG) || defined(BSD4_2) || defined(BSD4_1C) X int flags; X flags = fcntl(fileno(logfile), F_GETFL, 0); X (void) fcntl(fileno(logfile), F_SETFL, flags|O_APPEND); X#else /* v7 */ X (void) lseek(fileno(logfile), 0L, 2); X#endif /* v7 */ X fprintf(logfile, "%s\tbatch\t%s\n", logtime, bfr); X (void) fclose(logfile); X } X} X X#if !defined(BSD4_2) && !defined(BSD4_1C) Xrename(from, to) Xregister char *from, *to; X{ X (void) unlink(to); X if (link(from, to) < 0) X return -1; X X (void) unlink(from); X return 0; X} X#endif /* !BSD4_2 && !BSD4_1C */ END_OF_FILE if test 5484 -ne `wc -c <'batch.c'`; then echo shar: \"'batch.c'\" unpacked with wrong size! fi # end of 'batch.c' fi if test -f 'uurec.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'uurec.c'\" else echo shar: Extracting \"'uurec.c'\" \(3247 characters\) sed "s/^X//" >'uurec.c' <<'END_OF_FILE' X/* X * uurec - receive articles via /bin/mail. X */ X X#ifdef SCCSID Xstatic char *SccsId = "@(#)uurec.c 2.11 3/21/87"; X#endif /* SCCSID */ X X#include "defs.h" X X#include X#include X X/* X * Process a news article which has been shipped via /bin/mail. X */ X X#define FROM 01 X#define NLIN 02 X#define BLANK 03 X#define OTHER 04 X X#define SKIPPING 010 X#define READING 020 X X#define BFSZ 250 X X#define EOT '\004' X X#define A 01 X#define B 02 X X#ifdef debug X# define RNEWS "cat" X#endif Xextern char *strcat(), *strcpy(); Xextern char *frombreak(); Xextern FILE *popen(); X X/* ARGSUSED */ Xmain(argc, argv) Xint argc; Xchar **argv; X{ X char buf[BFSZ], fbuf[BFSZ]; X char bfr[BFSZ], *pbfr = bfr; X register char *p = NULL; X register FILE *pipe = stdout; X register int mode, frmflg, pathcnt, format; X char *index(); X X mode = SKIPPING; X frmflg = FALSE; X while (fgets(buf, BFSZ, stdin) != NULL) { X#ifdef debug X printf("%o\t%s", mode|type(buf), buf); X#endif X switch (mode | type(buf)) { X X case FROM | SKIPPING: X if (frmflg) X p = frombreak(p, buf); X else X p = fbuf; X frmflg = TRUE; X break; X X case FROM | READING: X if (!frmflg) { X frmflg = TRUE; X p = fbuf; X pclose(pipe); X } X p = frombreak(p, buf); X break; X X case NLIN | SKIPPING: X if ((isupper(buf[1]) && index(buf, ':')) || !strncmp(buf, "From ", 5)) X format = B; X else X format = A; X#ifdef debug X printf("format = %d\n", format); X#endif X mode = READING; X X case NLIN | READING: X if (frmflg) { X frmflg = FALSE; X --p; X while (p >= fbuf && *--p != '!') X ; X *++p = '\0'; X pathcnt = 0; X#ifdef IHCC X sprintf(pbfr, "%s/%s", logdir(HOME), RNEWS); X#else X pbfr = RNEWS; X#endif X if ((pipe = popen(pbfr, "w")) == NULL) { X perror("uurec: popen failed"); X exit(1); X } X } X if (format == A) { X if (++pathcnt == 3) X fputs(fbuf, pipe); X fputs(buf+1, pipe); X } else { X if (!pathcnt && (!strncmp(buf+1, "From: ", 6) || !strncmp(buf+1, "From ", 5))) { X pathcnt++; X fprintf(pipe, "From: %s", fbuf); X sscanf(buf, "%s %[^\n]", fbuf, fbuf); X fprintf(pipe, "%s\n", fbuf); X } else X fputs(buf+1, pipe); X } X break; X X case OTHER | SKIPPING: X break; X X case OTHER | READING: X pclose(pipe); X mode = SKIPPING; X } X } X if (pipe && pipe != stdout) X pclose(pipe); X exit(0); X} X Xtype(p) Xregister char *p; X{ X while (*p == ' ' || *p == '?') X ++p; X X if (*p == 'N') X return (NLIN); X X if (strncmp(p, ">From ", 6) == 0) X return (FROM); X X if (strncmp(p, "From ", 5) == 0) X return (FROM); X X return(OTHER); X} X X/* X * Get the system name out of a from line. X */ Xchar * Xfrombreak(buf, fbuf) Xregister char *buf, *fbuf; X{ X register char *p; X X /* break the line into tokens. */ X p = fbuf; X while (*++p != '\0') X switch (*p) { X case '\n': X case '\t': X case ' ': X *p = '\0'; X break; X case EOT: X goto garbled; X default:; X } X *++p = EOT; X *++p = '\0'; X X for (p=fbuf; *p != EOT || p[1] != '\0'; p += strlen(p)+1) { X if (strcmp(p, "forwarded") == 0) X return(buf); X if (strcmp(p, "remote") == 0) { X p += strlen(p)+1; X if (strcmp(p, "from") == 0) { X p += strlen(p)+1; X strcpy(buf, p); X strcat(buf, "!"); X return(buf+strlen(buf)); X } X } X } X garbled: X strcat(buf, "???!"); X return(buf+4); X} END_OF_FILE if test 3247 -ne `wc -c <'uurec.c'`; then echo shar: \"'uurec.c'\" unpacked with wrong size! fi # end of 'uurec.c' fi if test -f 'process.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'process.c'\" else echo shar: Extracting \"'process.c'\" \(3638 characters\) sed "s/^X//" >'process.c' <<'END_OF_FILE' X/* X * This software is Copyright (c) 1986 by Rick Adams. X * X * Permission is hereby granted to copy, reproduce, redistribute or X * otherwise use this software as long as: there is no monetary X * profit gained specifically from the use or reproduction or this X * software, it is not sold, rented, traded or otherwise marketed, and X * this copyright notice is included prominently in any copy X * made. X * X * The author make no claims as to the fitness or correctness of X * this software for any use whatsoever, and it is provided as is. X * Any use of this software is at the user's own risk. X * X * process - process options for readnews/vnews X */ X X#ifdef SCCSID Xstatic char *SccsId = "@(#)process.c 2.17 12/16/86"; X#endif /* SCCSID */ X X#include "rparams.h" X Xchar coptbuf[LBUFLEN], datebuf[LBUFLEN]; X X#define OPTION 0 /* pick up an option string */ X#define STRING 1 /* pick up a string of arguments */ X Xstruct optable *optpt, options[] = { /* Xoptlet filchar flag newstate oldmode newmode buf */ X'p', '\0', FALSE, OPTION, UNKNOWN, UNKNOWN,(char *)NULL, X't', '\0', FALSE, STRING, ANY, UNKNOWN,header.title, X'a', ' ', FALSE, STRING, ANY, UNKNOWN,datebuf, X'n', NGDELIM, FALSE, STRING, ANY, UNKNOWN,header.nbuf, X'c', ' ', FALSE, STRING, UNKNOWN, UNKNOWN,coptbuf, X'l', ' ', FALSE, OPTION, UNKNOWN, UNKNOWN,(char *)NULL, X'r', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X's', NGDELIM, FALSE, STRING, ANY, UNKNOWN,header.nbuf, X'x', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X'h', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X#ifdef TMAIL X'M', '\0', FALSE, OPTION, UNKNOWN, MAIL, (char *)NULL, X#else /* !TMAIL */ X'\377', '\0', FALSE, OPTION, UNKNOWN, UNKNOWN,(char *)NULL, X#endif /* !TMAIL */ X'f', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X'u', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X'e', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X'K', '\0', FALSE, OPTION, ANY, UNKNOWN,(char *)NULL, X'\0', '\0', 0, 0, 0, 0, (char *)NULL X}; X Xprocess(argc,argv) Xregister int argc; Xregister char **argv; X{ X register int state = STRING; X register char *ptr = header.nbuf; X char filchar = NGDELIM; X int len = LBUFLEN, tlen; X X /* loop once per arg. */ X X if (argc > 1 && **argv != '-') X nflag = TRUE; X X while (--argc) { X if (state == OPTION) { X if (**argv != '-') { X xerror("Bad option string \"%s\"", *argv); X } X while (*++*argv != '\0') { X for (optpt = options; optpt->optlet != '\0'; ++optpt) { X if (optpt->optlet == **argv) X goto found; X } X /* unknown option letter */ X#ifdef TMAIL X fprintf(stderr, "Usage: %s [ -a [ date ]] [ -n newsgroups ] [ -t titles ] [ -lprxhfuMK ]\n", Progname); X#else /* !TMAIL */ X fprintf(stderr, "Usage: %s [ -a [ date ]] [ -n newsgroups ] [ -t titles ] [ -lprxhfuK ]\n", Progname); X#endif /* !TMAIL */ X fprintf(stderr, "\t[ -c [ ``mailer'' ]]\n\n"); X fprintf(stderr, " %s -s\n", Progname); X exit(1); X X found:; X if (mode != UNKNOWN && (mode&optpt->oldmode) == 0) { X xerror("Bad %c option", **argv); X } X if (mode == UNKNOWN) X mode = optpt->newmode; X filchar = optpt->filchar; X optpt->flag = TRUE; X state = optpt->newstate; X ptr = optpt->buf; X len = LBUFLEN; X } X X argv++; /* done with this option arg. */ X X } else { X X /* X * Pick up a piece of a string and put it into X * the appropriate buffer. X */ X if (**argv == '-') { X state = OPTION; X argc++; /* uncount this arg. */ X continue; X } X X if ((tlen = strlen(*argv)) >= len) X xerror("Argument string too long"); X strcpy(ptr, *argv++); X ptr += tlen; X if (*(ptr-1) != filchar) X *ptr++ = filchar; X len -= tlen + 1; X *ptr = '\0'; X } X } X return; X} END_OF_FILE if test 3638 -ne `wc -c <'process.c'`; then echo shar: \"'process.c'\" unpacked with wrong size! fi # end of 'process.c' fi if test -f 'decode.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'decode.c'\" else echo shar: Extracting \"'decode.c'\" \(3365 characters\) sed "s/^X//" >'decode.c' <<'END_OF_FILE' X#include X X#ifdef SCCSID Xstatic char *SccsId = "@(#)decode.c 1.3 5/15/85"; X#endif /* SCCSID */ X X/* X * This program is the inverse of encode X * X * It collects runs of 12 characters, combines pairs of those X * to form 6 13 bit numbers, extracts the top bit of each of X * those to make a 13th 6 bit character, and splits each of X * the remaining 6 12 bit numbers to form 12 6 bit ones. X * X * The strings of 6 bit numbers are collected into groups of X * 4 and converted into 3 8 bit characters. X * X * Now all that would be trivial, if we didn't need to worry X * about ending all this correctly. About 1/2 of the following X * program wouldn't be here if the ending didn't matter.... X */ X X/* X * the following pair of characters can never occur as a pair X * in legal input (since (90 * 91 + 90) > 2^13) - they are X * noticed at the beginning of a 12 char block, and serve to X * indicate that this block is the terminator. The character X * immediately following is the (expanded) terminator length. X */ X#define ENDMARK1 ((90*91 + 90) / 91) X#define ENDMARK2 ((90*91 + 90) % 91) X Xmain() X{ X register c; X register char *p; X register i; X register first = 1; X register cnt = 0; X int errcnt = 0; X char b12[12]; X char c12[12]; X X p = b12; X i = 12; X X while ((c = getchar()) != EOF) { X if (c < ' ' || c >= (' ' + 91)) { X if (errcnt++ == 0) X fprintf(stderr, "decode: Bad data\n"); X continue; X } X if (i == 10 && p[-1] == ENDMARK1 && p[-2] == ENDMARK2) { X cnt = c - ' '; X i = 12; X p -= 2; X continue; X } X *p++ = c - ' '; X if (--i == 0) { X if (p == &b12[12]) { X if (!first) X pack12(c12, 12, 0); X else X first = 0; X p = c12; X } else { X pack12(b12, 12, 0); X p = b12; X } X i = 12; X } X } X X if (p >= &b12[0] && p < &b12[12]) { X if (!first) X pack12(c12, 12, i == 12 ? cnt : 0); X } else X pack12(b12, 12, i == 12 ? cnt : 0); X X if (i != 12) { X if (p >= &b12[0] && p < &b12[12]) X pack12(b12, 12-i, cnt); X else X pack12(c12, 12-i, cnt); X } X X exit(0); X} X Xstatic char b4[4]; Xstatic int cnt = 0; X Xpack12(p, n, last) X register char *p; X register n; X int last; X{ X register i; X register char *q; X char b13[13]; X X { X register c; X register c13; X X q = b13; X c13 = 0; X X for (i = 0; i < n; i += 2) { X c = *p++ * 91; X c += *p++; X c13 <<= 1; X if (c & (1 << 12)) X c13 |= 1; X *q++ = (c >> 6) & 0x3f; X *q++ = c & 0x3f; X } X *q++ = c13; X if (last) X q = &b13[last]; X } X X p = b13; X n = q - p; X i = cnt; X q = &b4[cnt]; X X while (--n > 0) { X *q++ = *p++; X if (++i == 4) { X char b3[3]; X register char *b = b4; X X /* inline expansion of pack6bit, to save calls ... */ X X q = b3; X *q++ = (b[0] << 2) | ((b[1] >> 4) & 0x3); X *q++ = (b[1] << 4) | ((b[2] >> 2) & 0xf); X *q = (b[2] << 6) | (b[3] & 0x3f); X X q = b3; X while (--i > 0) X putchar(*q++); X X q = b4; X } X } X X *q++ = *p++; /* the last octet */ X ++i; X X if (last || i == 4) { X pack6bit(b4, i, last); X i = 0; X } X X cnt = i; X} X Xpack6bit(p, n, last) X register char *p; X register int n; X int last; X{ X register char *q; X register i = 3; X char b3[3]; X X if (last) { X i = p[n-1]; X if (i >= 3) { X fprintf(stderr, "Badly encoded file\n"); X i = 3; /* do the best we can */ X } X } X X q = b3; X *q++ = (p[0] << 2) | ((p[1] >> 4) & 0x3); X *q++ = (p[1] << 4) | ((p[2] >> 2) & 0xf); X *q = (p[2] << 6) | (p[3] & 0x3f); X X q = b3; X X while (--i >= 0) X putchar(*q++); X} END_OF_FILE if test 3365 -ne `wc -c <'decode.c'`; then echo shar: \"'decode.c'\" unpacked with wrong size! fi # end of 'decode.c' fi if test -f 'checkgroups.sh' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'checkgroups.sh'\" else echo shar: Extracting \"'checkgroups.sh'\" \(3677 characters\) sed "s/^X//" >'checkgroups.sh' <<'END_OF_FILE' X: check active file for missing or extra newsgroups X: '@(#)checkgroups 1.22 3/20/87' X Xif test ! -s LIBDIR/newsgroups Xthen X cp /dev/null LIBDIR/newsgroups Xfi X# Read first line of stdin. If of the form "-n group", then only check X# for the specified group. Otherwise, assume doing standard groups Xsed -e '/^[a-zA-Z-]*: /d' -e '/^$/d' -e '/^[#:]/d' | ( Xread line Xcase "${line}" in X-n*) X # Doing specific group. extract group name and preserve X # all of current newsgroups file except for that group. X # Then append entries for this group. X group=`echo "${line}" | sed -e 's/-n /^/' -e 's/$/\\\\./'` X egrep -v "${group}" LIBDIR/newsgroups > /tmp/$$a X cat /tmp/$$a - > LIBDIR/newsgroups X ;; X*) X # Get the distributions from the checkgroups message itself X # This allows sites to append their local groups to the distributed X # checkgroups message and prevents stray checkgroups from other sites X # from showing all the local groups as being bad groups. X # X echo "${line}" > /tmp/$$msg X cat >> /tmp/$$msg X cp /dev/null /tmp/$$b X sed -e "s;[ ].*;;" -e "s;\..*;;" -e "s;^!;;" /tmp/$$msg | sort -u | X while read dist X do X group=`cat /tmp/$$b` X group="${group}|^$dist\\." X echo "${group}" > /tmp/$$b X done X group=`cat /tmp/$$b` X egrep -v "${group}" LIBDIR/newsgroups > /tmp/$$a X cat /tmp/$$a > LIBDIR/newsgroups X sed -e "/^!/d" /tmp/$$msg >> LIBDIR/newsgroups X rm -f /tmp/$$b /tmp/$$msg X ;; Xesac X Xegrep "${group}" LIBDIR/active | sed 's/ .*//' | sort >/tmp/$$active Xegrep "${group}" LIBDIR/newsgroups | sed 's/ .*//' | sort >/tmp/$$newsgrps X Xcomm -13 /tmp/$$active /tmp/$$newsgrps >/tmp/$$missing Xcomm -23 /tmp/$$active /tmp/$$newsgrps >/tmp/$$remove X Xegrep "${group}" LIBDIR/active | sed -n "/m\$/s/ .*//p" | X sort > /tmp/$$amod.all Xegrep "${group}" LIBDIR/newsgroups | Xsed -n "/Moderated/s/[ ][ ]*.*//p" | sort > /tmp/$$ng.mod X Xcomm -12 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.mod Xcomm -23 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.unmod Xcat /tmp/$$add.mod /tmp/$$add.unmod >>/tmp/$$add X Xcomm -23 /tmp/$$amod.all /tmp/$$remove >/tmp/$$amod Xcomm -13 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$ismod Xcomm -23 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$nm.all Xcomm -23 /tmp/$$nm.all /tmp/$$add >/tmp/$$notmod X Xif test -s /tmp/$$remove Xthen X ( X echo "The following newsgroups are not valid and should be removed." X sed "s/^/ /" /tmp/$$remove X echo "" X echo "You can do this by executing the command:" X echo \ LIBDIR/rmgroup `cat /tmp/$$remove` X echo "" X ) 2>&1 >/tmp/$$out Xfi X Xif test -s /tmp/$$add Xthen X ( X echo "The following newsgroups were missing and should be added." X sed "s/^/ /" /tmp/$$add X echo "" X echo "You can do this by executing the command(s):" X for i in `cat /tmp/$$add.unmod` X do X echo 'LIBDIR/inews -C '$i' &1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$ismod Xthen X ( X echo "The following newsgroups are not moderated and are marked moderated." X sed "s/^/ /" /tmp/$$ismod X echo "" X echo "You can correct this by executing the command(s):" X for i in `cat /tmp/$$ismod` X do X echo 'LIBDIR/inews -C '$i' &1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$notmod Xthen X ( X echo "The following newsgroups are moderated and not marked so." X sed "s/^/ /" /tmp/$$notmod X echo "" X echo "You can correct this by executing the command(s):" X for i in `cat /tmp/$$notmod` X do X echo 'LIBDIR/inews -C '$i' moderated &1 >>/tmp/$$out Xfi X Xif test -s /tmp/$$out Xthen X (echo "Subject: Problems with your active file" X echo "" X cat /tmp/$$out X ) | if test $# -gt 0 X then X mail $1 X else X cat X fi Xfi X) X Xrm -f /tmp/$$* X END_OF_FILE if test 3677 -ne `wc -c <'checkgroups.sh'`; then echo shar: \"'checkgroups.sh'\" unpacked with wrong size! fi # end of 'checkgroups.sh' fi if test -f 'uname.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'uname.c'\" else echo shar: Extracting \"'uname.c'\" \(2333 characters\) sed "s/^X//" >'uname.c' <<'END_OF_FILE' X/* X * This software is Copyright (c) 1986 by Rick Adams. X * X * Permission is hereby granted to copy, reproduce, redistribute or X * otherwise use this software as long as: there is no monetary X * profit gained specifically from the use or reproduction or this X * software, it is not sold, rented, traded or otherwise marketed, and X * this copyright notice is included prominently in any copy X * made. X * X * The author make no claims as to the fitness or correctness of X * this software for any use whatsoever, and it is provided as is. X * Any use of this software is at the user's own risk. X * X * This routine is compatible with the Unix T/S system call uname, X * which figures out the name of the local system. X * However, we do it by reading the file /usr/include/whoami.h. X * This avoids having to recompile uucp for each site and hence X * avoids having to distribute the source to uucp to people who X * have only binary licenses. X */ X X#ifdef SCCSID Xstatic char *SccsId = "@(#)uname.c 2.15 3/21/87"; X#endif /* SCCSID */ X X#include "params.h" X X#ifdef UNAME X# define DONE X#endif /* UNAME */ X X#ifdef GHNAME Xuname(uptr) Xstruct utsname *uptr; X{ X char *cp; X extern char *mydomain(); X gethostname(uptr->nodename, sizeof (uptr->nodename)); X cp = mydomain(); X if (*cp == '\0') /* get domain name from hostname */ X return; X cp = index(uptr->nodename, '.'); X if (cp) X *cp = '\0'; X} X# define DONE X#endif X X#ifdef UUNAME Xuname(uptr) Xstruct utsname *uptr; X{ X FILE *uucpf; X register char *p; X /* uucp name is stored UUNAME */ X X if (((uucpf = fopen(UUNAME, "r")) == NULL) || X fgets(uptr->nodename, sizeof (uptr->nodename), uucpf) == NULL) { X fprintf(stderr, "no sysname in %s\n", UUNAME); X return; X } X p = index(uptr->nodename, '\n'); X if (p) X *p = '\0'; X if (uucpf != NULL) X fclose(uucpf); X} X#define DONE X#endif /* UUNAME */ X X#ifndef DONE X#define HDRFILE "/usr/include/whoami.h" X Xuname(uptr) Xstruct utsname *uptr; X{ X char buf[BUFSIZ]; X FILE *fd; X X fd = fopen(HDRFILE, "r"); X if (fd == NULL) { X fprintf(stderr, "Cannot open %s\n", HDRFILE); X exit(1); X } X X for (;;) { /* each line in the file */ X if (fgets(buf, sizeof buf, fd) == NULL) { X fprintf(stderr, "no sysname in %s\n", HDRFILE); X fclose(fd); X exit(2); X } X if (sscanf(buf, "#define sysname \"%[^\"]\"", uptr->nodename) == 1) { X fclose(fd); X return; X } X } X} X#endif END_OF_FILE if test 2333 -ne `wc -c <'uname.c'`; then echo shar: \"'uname.c'\" unpacked with wrong size! fi # end of 'uname.c' fi if test -f 'rparams.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rparams.h'\" else echo shar: Extracting \"'rparams.h'\" \(2146 characters\) sed "s/^X//" >'rparams.h' <<'END_OF_FILE' X/* X * rparams.h - parameters for readnews, rfuncs, and readr. X */ X X/* @(#)rparams.h 2.23 10/23/86 */ X X#include "params.h" X X/* flags for readnews */ X#define pflag options[0].flag X#define tflag options[1].flag X#define aflag options[2].flag X#define nflag options[3].flag X#define cflag options[4].flag X#define lflag options[5].flag X#define rflag options[6].flag X#define sflag options[7].flag X#define xflag options[8].flag X#define hflag options[9].flag X#define Mflag options[10].flag X#define fflag options[11].flag X#define uflag options[12].flag X#define eflag options[13].flag X#define Kflag options[14].flag X X#define NEXT 0 X#define SPEC 1 X X#define FORWARD 0 X#define BACKWARD 1 X X#define UNKNOWN 0001 /* possible modes for news program */ X#define MAIL 0004 X#define ANY 0007 X Xstruct optable { /* options table. */ X char optlet; /* option character. */ X char filchar; /* if to pickup string, fill character. */ X int flag; /* TRUE if have seen this opt. */ X int newstate; /* STRING if takes arg, else OPTION */ X int oldmode; /* OR of legal input modes. */ X int newmode; /* output mode. */ X char *buf; /* string buffer */ X}; X X/* external declarations specific to readnews */ Xextern char *infile, *outfile, *PAGER, *ALIASES; Xextern char *bitmap, *MAILER, *MAILPARSER; X X#ifndef ROOTID Xextern int ROOTID; X#endif X X#ifdef NOTIFY Xextern char *TELLME; X#endif X Xextern char filename[],coptbuf[],datebuf[],afline[]; Xextern char newsrc[],groupdir[],rcbuf[],*rcline[],*argvrc[]; Xextern int mode, ngrp, line, newrc(), readmode, news; Xextern long bit, obit, last, ngsize, minartno; Xextern FILE *rcfp,*actfp; Xextern time_t atime; Xextern struct optable *optpt, options[]; Xextern int actdirect, rcreadok, zapng; X X#ifndef lint X/* lint gets very mad about i-minartno, this is one way of shutting it up */ X/* macros */ X#define get(i) ((i> 3] & (1 << (i-minartno) % 8))) X#define set(i) if (i>=minartno) bitmap[(i-minartno) >> 3] |= (1 << (i-minartno) % 8);else X#define clear(i) if (i>=minartno) bitmap[(i-minartno) >> 3] &= ~(1 << (i-minartno) % 8);else X#endif /* !lint */ X X#define FCLOSE(fp) {if (fp != NULL) {fclose(fp);fp = NULL;}} END_OF_FILE if test 2146 -ne `wc -c <'rparams.h'`; then echo shar: \"'rparams.h'\" unpacked with wrong size! fi # end of 'rparams.h' fi echo shar: End of shell archive. exit 0 -- "Zeta Microcomputer Software" ACSnet: nick@ultima.cs.uts.oz UUCP: ...!uunet!munnari!ultima.cs.uts.oz!nick Fidonet: Nick Andrew on 3:713/602 (Zeta)