v16i018: Bootstrap News v1.3, Part01/01

Ronald Florence ron at mlfarm.com
Sat Jan 5 15:20:46 AEST 1991


Submitted-by: ron at mlfarm.com (Ronald Florence)
Posting-number: Volume 16, Issue 18
Archive-name: bsnews1.3/part01

   bsnews - Bootstrap News
   copyright 1989, 1990 Ronald Florence
   version 1.3 (27 Dec 90)

   Bootstrap News is a collection of programs which enable a leaf node to
   take a limited news feed without installing a full news package.  News
   articles are spooled in a Unix-mail-format file, where they can be
   read, printed, forwarded, replied-to or saved with a mail reader such
   as Mail or elm.  In a single-user configuration, articles can be
   deleted by the reader; in the multi-user configuration, news articles
   are expired by a command run from cron.  Portions of bsnews can be
   compiled for ms-dos systems running uucp work-alikes.

   This version (1.3) of bsnews includes an expire command for multi-user
   systems, RFC 822 compliant headers on the news articles, expanded
   functionality in the news poster, and an improved Makefile.  The
   original version of bsnews and a subsequent patch were posted on 
   comp.sources.misc, and from the volume of mail I've gotten, have been 
   popular with users.
--
Ronald Florence			ron at mlfarm.com

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	Readme
#	Makefile
#	bsnews.man
#	checknews.c
#	expire.proto
#	mail.ed
#	myname.c
#	readnews.proto
#	rnews.c
#	pn.proto
#	uurec.proto
# This archive created: Fri Dec 28 11:20:58 1990
# By:	Ronald Florence (Maple Lawn Farm, Stonington, CT)
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Readme'" '(3768 characters)'
if test -f 'Readme'
then
	echo shar: "will not over-write existing file 'Readme'"
else
sed 's/^X//' << \SHAR_EOF > 'Readme'
Xbsnews - Bootstrap News
Xcopyright 1989, 1990 Ronald Florence
Xversion 1.3 (27 Dec 90)
X
XBootstrap News is a collection of programs which enable a leaf node to
Xtake a limited news feed without installing a full news package.  News
Xarticles are spooled in a Unix-mail-format file, where they can be
Xread, printed, forwarded, replied-to or saved with a mail reader such
Xas Mail or elm.  In a single-user configuration, articles can be
Xdeleted by the reader; in the multi-user configuration, news articles
Xare expired by a command run from cron.  Portions of bsnews can be
Xcompiled for ms-dos systems running uucp work-alikes.
X
XThis version (1.3) of bsnews includes an expire command for multi-user
Xsystems, RFC 822 compliant headers on the news articles, and expanded
Xfunctionality in the news poster.
X
XTo build bsnews for a Unix system:
X
X   1. Change the Makefile defines for READER, HOST, CC, ECHO,
X      CFLAGS, SPOOLPERM, and MANDIR to suit your system.  You 
X      may need to be a privileged user to install bsnews.
X
X   2. For a uux feed, do `make'.  Add `rnews' to the appropriate 
X      uucp permissions file in /usr/lib/uucp.  If you have 
X      /usr/bin/compress, tell your news feed to send you a 
X      compressed, batched feed.  Rnews will also detect and 
X      unpack uncompressed batches or single articles.
X
X   3. For a mail feed (if your host is using sendnews to send 
X      you news articles via mail), do `make mail-bsnews'.  Create
X      a sendmail or execmail alias (`rnews: |/usr/bin/uurec'), or 
X      use cron to run `uurec' with /usr/spool/mail/rnews as input.  
X      
X   4. Use `readnews' to read your news, and `pn' to post news.
X      To receive notification of new news when you log in, add 
X      `checknews' to your .login or .profile file.  You can use
X      environment variables EDITOR and PAGER to override the 
X      defaults of `vi' and `more' in the news poster.  
X
X      To test `pn', use a newsgroup with limited distribution, 
X      which the administrator of your news feed can suggest.  Before
X      you post to Usenet, you should read the file "Standard for 
X      Interchange of USENET Messages," available in newsgroup 
X      news.announce.newusers or from your news feed
X
X   5. For a multi-user site, create a cron entry for `expire n', 
X      where n is the expiration period for news in days.  The expire
X      script requires nawk or gawk.  If you have the old awk, you
X      can modify the script, or write me for a special version of
X      expire. 
X
XTo use Bootstrap News with ms-dos:
X
X   1. Add -DIAM='"yournodename"' to the CFLAGS in the Makefile, 
X      change CC and NEWSDIR to suit your C compiler and system, 
X      and do `make rnews.exe'.  Rnews.exe will unpack compressed 
X      or uncompressed batches or single articles.  You will need 
X      compress.exe for a compressed feed.
X
X   2. If your uucp-clone cannot execute rnews.exe with the incoming
X      news batches as input, have your host install a sendbatch 
X      command file in their /usr/spool/batch directory, with the 
X      nodename of your system in place of `yoursys':
X
X	  :
X          #! /bin/sh
X          # yoursys.cmd
X	  News=/tmp/`date '+%d%H%M%S'`.nws
X	  cat > $News
X	  uucp -rC $News yoursys!~/
X	  rm $News
X
X      After each poll of your host, run rnews.exe with the *.nws 
X      files in your public directory as input.  
X
X   3. To read your news, do `mail -f Newsspool', where
X      `Newsspool' is the spool path compiled into rnews.exe.
X
XPermission is hereby granted for unlimited non-commercial use of
Xthese programs, on condition that the copyright notices are left
Xintact and any modifications to the source code are noted as such.
XNo warranty of any kind is implied or granted for this material.
X
XRonald Florence			
Xron at mlfarm.com
X
SHAR_EOF
if test 3768 -ne "`wc -c < 'Readme'`"
then
	echo shar: "error transmitting 'Readme'" '(should have been 3768 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(2602 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X# Makefile for Bootstrap News
X# copyright 1989, 1990 Ronald Florence  
X# version 1.3 (ron at mlfarm.com, 23 Dec 90)
X
X# ----- Change the following defines, as needed. -----
X
X# Mail reader, with the option used to name the spool file
XREADER = elm -f
X
X# Your news feed
XHOST = BigNode
X
X# C compiler
XCC = gcc
X
X# If your echo uses `-n' to suppress newlines, use ECHO = -n
XECHO =
X
X# Add -DUNAME to CFLAGS for System V with uname()
X# Add -DGETHOSTNAME to CFLAGS for BSD with gethostname()
X# Add -DIAM='"yournodename"' to CFLAGS to hardcode your node name
XCFLAGS = -O -DNewsspool='"$(NEWSSPOOL)"'
X
X# For a single-user site, SPOOLPERM = 666;  multi-user, SPOOLPERM = 644
XSPOOLPERM = 644
X
X# Directory for man pages
XMANDIR = /usr/man/man.LOCAL
X
X# ----- You may want to change these. -----
X
XNEWSDIR = /usr/spool/news
XLIBDIR = /usr/lib/news
XBIN = bin
XBINDIR = /usr/bin
X
X# ----- You shouldn't need to make changes below here. -----
X
XNEWSSPOOL = $(NEWSDIR)/bsnews
XSEQFILE = $(LIBDIR)/seq
XPGMS = rnews uurec pn checknews readnews expire
XFILES = spoolfile seqfile
XSRCS = Readme Makefile bsnews.man checknews.c expire.proto mail.ed\
X       myname.c readnews.proto rnews.c pn.proto uurec.proto
XSHELL = /bin/sh
X
Xbsnews:	install 
X
Xmail-bsnews: fix-pn install
X
Xinstall: $(PGMS) $(FILES) bsnews.1
X	chgrp $(BIN) $(PGMS) $(NEWSSPOOL) $(SEQFILE)
X	chown $(BIN) $(PGMS) $(NEWSSPOOL) $(SEQFILE)
X	chmod 544 expire
X	chmod 555 readnews pn checknews
X	chmod 6555 rnews uurec
X	mv $(PGMS) $(BINDIR)
X	cp bsnews.1 $(MANDIR)
X
Xfix-pn: pn
X	ed - pn < mail.ed
X
Xbsnews.1: Makefile bsnews.man
X	sed "s|NEWSSPOOL|$(NEWSSPOOL)|" bsnews.man |\
X	sed "s|SEQ|$(SEQFILE)|" > bsnews.1
X
Xexpire: Makefile expire.proto
X	sed "s|NEWSSPOOL|$(NEWSSPOOL)|" expire.proto > expire
X
Xspoolfile:
X	[ -d $(NEWSDIR) ] || mkdir $(NEWSDIR)
X	[ -f $(NEWSSPOOL) ] || > $(NEWSSPOOL)
X	chmod $(SPOOLPERM) $(NEWSSPOOL)
X
Xseqfile:
X	[ -d $(LIBDIR) ] || mkdir $(LIBDIR)
X	[ -f $(SEQFILE) ] || echo "1" > $(SEQFILE)
X	chmod 666 $(SEQFILE)
X
Xuurec:	Makefile uurec.proto
X	sed "s|NEWSSPOOL|$(NEWSSPOOL)|" uurec.proto > uurec
X
Xcheckname: myname.c Makefile
X	$(CC) $(CFLAGS) -DCHECKNAME myname.c -o checkname
X	@./checkname
X
Xrnews:  checkname rnews.o myname.o 
X	$(CC) $(CFLAGS) rnews.o myname.o -o rnews
X
Xpn:	Makefile pn.proto
X	sed "s/BigNode/$(HOST)/" pn.proto |\
X	sed "s/^\(n=\)/\1$(ECHO)/" > pn
X
Xreadnews: Makefile readnews.proto
X	sed "s|READER|$(READER) $(NEWSSPOOL)|" readnews.proto > readnews
X
Xrnews.exe: rnews.c myname.c
X	$(CC) -DDOS $(CFLAGS) rnews.c myname.c -o rnews.exe
X
Xshar:	bsnews.shar 
X
Xbsnews.shar: $(SRCS)
X	shar -a $(SRCS) > bsnews.shar
X
Xclean:
X	rm -f $(PGMS) *.o checkname bsnews.1
SHAR_EOF
if test 2602 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 2602 characters)'
fi
fi
echo shar: "extracting 'bsnews.man'" '(2665 characters)'
if test -f 'bsnews.man'
then
	echo shar: "will not over-write existing file 'bsnews.man'"
else
sed 's/^X//' << \SHAR_EOF > 'bsnews.man'
X.\" bsnews.1
X.\" man page for bsnews (Bootstrap News)
X.\" Copyright 1990 Ronald Florence (ron at mlfarm.com, 23 Dec 90)
X.\"
X.TH BSNEWS LOCAL
X.SH NAME
Xrnews \- processes news articles received via uux
X.br
Xuurec \- processes news articles received via mail
X.br
Xchecknews \- a daemon to monitor the arrival of new news
X.br
Xexpire \- expires articles from the news spool
X.br
Xpn \- a simple news poster
X.br
Xreadnews \- a shell wrapper for the news reader
X.SH SYNOPSIS
X.B rnews 
X< 
X.I news-batch 
Xor
X.I article
X.br
X.B rnews 
X.I article(s)
Xor 
X.I news-batch(es)
X.br
X.B uurec 
X< 
X.I article
X.br
X.B checknews
X.br
X.B expire 
X.I n
X.br
X.B pn
X.br
X.B readnews
X.SH DESCRIPTION
X.PP
X.I Bsnews 
X(Bootstrap News) is a collection of programs which enable a leaf node
Xto take a limited news feed without installing a full news package.
X.PP
X.I Rnews 
Xprocesses individual news articles, batched, or batched and compressed
Xnews sent from a remote system via uux.  The articles are spooled in a
XUnix-mail-format news spool, with RFC 822 compliant headers.  An
Xinitial
X.I From
Xheader includes the email address of the poster and the date of
Xarrival at the system.  /usr/bin/compress is required for a compressed
Xfeed.
X.PP
X.I Uurec
Xspools news articles sent from a remote system in sendnews format
X(each line prefixed with an
X.IR N ).
X.PP
X.IR Checknews ,
Xnormally used in the
X.I .login
Xor 
X.I .profile
Xfile, notifies the user at login time whether there is new news on the
Xspool.
X.PP
X.I Expire
Xis normally run by cron on a multi-user system to expire news from the
Xnews spool after
X.I n
Xdays.  The expire script uses features of nawk (gawk).  An old-awk
Xversion is available from the author.
X.PP
X.I Pn 
Xis a simple news poster, configured by the bsnews Makefile to post
Xarticles via uux or mail.  
X.I Pn 
Xqueries interactively for the newsgroup(s) and subject, puts the user
Xin an editor (default
X.IR vi ),
Xto compose the article, and a pager (default
X.IR more )
Xto proof the article before posting.  The
X.SM EDITOR
Xand
X.SM PAGER 
Xenvironmental variables can be used to change the defaults.
X.PP
X.I Readnews 
Xis a simple shell-wrapper which adapts a Unix mail reader
X.RI ( elm , 
X.IR Mail ,
Xetc.) for reading news.  News articles can be read, printed,
Xforwarded, saved, replied-to, and (on a single-user system) deleted,
Xusing mailer commands.
X.SH FILES
X.if t .ta 2i
X.if n .ta 3i
XNEWSSPOOL	news spool
X.br
XSEQ	latest article ID
X.br
X$HOME/.lastnews	sentinel file for checknews
X.SH BUGS
X.I Bsnews 
Xis designed for a 
X.I limited 
Xnews feed.  Unless the news spool is expired frequently, a
Xsubscription of more than a few news groups is unwieldy.
X.SH AUTHOR
XRonald Florence (ron\s-2@\s0mlfarm.com).
X
SHAR_EOF
if test 2665 -ne "`wc -c < 'bsnews.man'`"
then
	echo shar: "error transmitting 'bsnews.man'" '(should have been 2665 characters)'
fi
fi
echo shar: "extracting 'checknews.c'" '(728 characters)'
if test -f 'checknews.c'
then
	echo shar: "will not over-write existing file 'checknews.c'"
else
sed 's/^X//' << \SHAR_EOF > 'checknews.c'
X/*
X * checknews.c - checks for bootstrap news
X * copyright 1989, 1990 Ronald Florence 
X * version 1.3 (ron at mlfarm.com, 15 Dec 90)
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#ifndef Newsspool
X#define Newsspool	"/usr/spool/news/bsnews"
X#endif
X
X#define bye(s)	   puts(s), exit(1)
X
Xmain()
X{
X  struct stat nt, lt;
X  char newsmarker[80], *getenv();
X
X  if (!strcpy(newsmarker, getenv("HOME")))
X    bye("checknews: cannot find $HOME.");
X  strcat(newsmarker, "/.lastnews");
X  if (stat(newsmarker, &lt) == -1)
X    lt.st_mtime = 0;
X  if (stat(Newsspool, &nt) == -1)
X    bye("checknews: cannot find Newsspool.");
X  puts(nt.st_mtime < lt.st_mtime ? "No news is good news." : "New news has arrived.");
X  exit(0);
X}
SHAR_EOF
if test 728 -ne "`wc -c < 'checknews.c'`"
then
	echo shar: "error transmitting 'checknews.c'" '(should have been 728 characters)'
fi
fi
echo shar: "extracting 'expire.proto'" '(1447 characters)'
if test -f 'expire.proto'
then
	echo shar: "will not over-write existing file 'expire.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'expire.proto'
X:
X#! /bin/sh
X# expire - expires bsnews spool
X# copyright 1990 Ronald Florence 
X# version 1.3 (ron at mlfarm.com, 22 Dec 90)
X# 
X# This awk script relies on features of nawk/gawk. 
X# Write me if you need an old-awk version.
X
Xwhile [ $# -gt 0 ]
X  do
X    case $1 in
X      -e|-E) shift;;
X          *) exp=`expr $1 : "-*[eE]*\([0-9]*\)"`; break;;
X    esac
X  done
X[ -z "$exp" ] &&  { echo "usage: $0 days"; exit; }
X
XNewsspool=NEWSSPOOL
X[ -f $Newsspool ] || { echo "$0: cannot find $Newsspool"; exit; }
XTmpspool=/tmp/expire.$$
Xtrap 'rm -f $Tmpspool' 1 2 3 15
X
XTimestamp=`awk 'expdays='$exp'
XBEGIN {
X  month["Jan"] = 1
X  month["Feb"] = 2
X  month["Mar"] = 3
X  month["Apr"] = 4
X  month["May"] = 5
X  month["Jun"] = 6
X  month["Jul"] = 7
X  month["Aug"] = 8
X  month["Sep"] = 9
X  month["Oct"] = 10
X  month["Nov"] = 11
X  month["Dec"] = 12
X  expired = 0
X  "ls -l '$Newsspool'" | getline
X  split($8, time, ":")
X  printf "%02d%02d%02d%02d", month[$6], $7, time[1], time[2]
X  "date" | getline
X  now = daynum($6, month[$2], $3)
X}  
X
X/^From / && expired == 0 { 
X  if (daynum($7, month[$4], $5) > now - expdays)
X      expired = 1
X}
Xexpired == 1 { print $0 > "'$Tmpspool'" }
X
Xfunction daynum(y, m, d, days, i, n) {
X  split("31 28 31 30 31 30 31 31 30 31 30 31", days)
X  n = (y - 1901) * 365 + int((y - 1901) / 4)
X  if (y % 4 == 0)
X    days[2]++
X  for (i = 1; i < m; i++)
X    n += days[i]
X  return (n + d)
X}' < $Newsspool`
X
Xtouch $Timestamp $Tmpspool
Xmv $Tmpspool $Newsspool
X
SHAR_EOF
if test 1447 -ne "`wc -c < 'expire.proto'`"
then
	echo shar: "error transmitting 'expire.proto'" '(should have been 1447 characters)'
fi
fi
echo shar: "extracting 'mail.ed'" '(74 characters)'
if test -f 'mail.ed'
then
	echo shar: "will not over-write existing file 'mail.ed'"
else
sed 's/^X//' << \SHAR_EOF > 'mail.ed'
X/uux/s/uux - -r \($H.*ws\) \(< $T.*t\)/sed 's\/\^\/N\/' \2 | mail \1/
Xw
Xq
SHAR_EOF
if test 74 -ne "`wc -c < 'mail.ed'`"
then
	echo shar: "error transmitting 'mail.ed'" '(should have been 74 characters)'
fi
fi
echo shar: "extracting 'myname.c'" '(1576 characters)'
if test -f 'myname.c'
then
	echo shar: "will not over-write existing file 'myname.c'"
else
sed 's/^X//' << \SHAR_EOF > 'myname.c'
X/*
X * myname.c
X * copyright 1989 Ronald Florence 
X * version 1.3 (ron at mlfarm, 15 Dec 90)
X */
X
X#include <stdio.h>
X
X#ifdef CHECKNAME
Xmain()
X{
X  char *myname();
X
X  fprintf(stderr, "\nIf your node name is not `%s' ", myname());
X  fprintf(stderr, "check the CFLAGS in your Makefile.\n\n");
X  exit(0);
X}
X#endif
X
X
Xchar *myname()
X{
X#ifdef IAM
X  return (IAM);
X}
X#else
X#ifdef UNAME
X#include <sys/utsname.h>
X
X  static struct utsname utn;
X
X  (void) uname(&utn);
X  return(utn.nodename);
X}
X#else  /* not UNAME */
X  static char nodename[64];
X
X#ifdef GETHOSTNAME
X  extern int gethostname();
X
X  (void) gethostname(nodename, (int) sizeof(nodename));
X  nodename[sizeof(nodename)] = 0;
X  return(nodename);
X}
X#else   /* not GETHOSTNAME */
X
X  FILE *whoami;
X
X  char *cp, *strchr(), *strpbrk();
X
X  if ((whoami = fopen("/etc/whoami", "r")) || 
X      (whoami = fopen("/etc/systemid", "r"))) 
X    {
X      fgets(nodename, sizeof(nodename), whoami);
X      fclose(whoami);
X      if (cp = strchr(nodename, '\n'))
X	*cp = '\0';
X      return(nodename);
X    }
X  if ((whoami = fopen("/usr/include/whoami.h", "r")) != 0) 
X    {
X      while (!feof(whoami)) 
X	{
X	  char	buf[100];
X	  
X	  if (fgets(buf, 100, whoami) == 0)
X	    break;
X	  if (sscanf(buf, "#define sysname \"%[^\"]\"", nodename))
X	    break;
X	}
X      fclose(whoami);
X      return (nodename);
X    }
X  if ((whoami = popen("uuname -l", "r")) != 0) 
X    {
X      fgets(nodename, sizeof(nodename), whoami);
X      pclose(whoami);
X      if (cp = strpbrk(nodename, " \n"))
X	*cp = '\0';
X      return (nodename);
X    }
X  return("nowhere");
X}
X#endif
X#endif
X#endif
SHAR_EOF
if test 1576 -ne "`wc -c < 'myname.c'`"
then
	echo shar: "error transmitting 'myname.c'" '(should have been 1576 characters)'
fi
fi
echo shar: "extracting 'readnews.proto'" '(169 characters)'
if test -f 'readnews.proto'
then
	echo shar: "will not over-write existing file 'readnews.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'readnews.proto'
X:
X#! /bin/sh
X# readnews - news reader for bootstrap news
X# copyright 1989, 1990 Ronald Florence 
X# version 1.3 (ron at mlfarm.com, 15 Dec 90)
X
XREADER
Xtouch $HOME/.lastnews
SHAR_EOF
if test 169 -ne "`wc -c < 'readnews.proto'`"
then
	echo shar: "error transmitting 'readnews.proto'" '(should have been 169 characters)'
fi
fi
echo shar: "extracting 'rnews.c'" '(2960 characters)'
if test -f 'rnews.c'
then
	echo shar: "will not over-write existing file 'rnews.c'"
else
sed 's/^X//' << \SHAR_EOF > 'rnews.c'
X/*
X * rnews.c 
X * copyright 1989, 1990 Ronald Florence
X * version 1.3  (ron at mlfarm.com, 15 Dec 90)
X */
X
X#include <stdio.h>
X#include <time.h>
X
X#ifndef DOS
X#define Readmode	"r"
X#define Compress	"/usr/bin/compress -dc > %s"
X#define Tmpstr		mktemp("/tmp/newsart.XXXXXX")
Xchar	*mktemp();
X#else
X#include <fcntl.h>
X#define Readmode	"rb"
X#define Compress	"compress -d %s"
X#define Tmpstr		"%08.8lX.Z", time()
X#define pclose		fclose
X#endif
X
X#ifndef Newsspool
X#define Newsspool	"/usr/spool/news/bsnews"
X#endif
X
X#define bye(s)		perror(s), exit(1)
X
Xchar  *iam, tmpnews[80], dcomp[80];
Xlong  time();
XFILE  *nf, *cf;
X
Xmain(argc, argv)
X     int  argc;
X     char **argv;
X{
X  extern char   *myname();
X
X  iam = myname();
X  if (!(nf = fopen(Newsspool, "a")))
X    bye(Newsspool);
X  sprintf(tmpnews, Tmpstr);
X  sprintf(dcomp, Compress, tmpnews);
X
X  if (--argc)
X    while (*++argv)
X      {
X	if ((cf = freopen(*argv, Readmode, stdin)) == NULL)
X	  bye(*argv);
X	parse();
X      }
X  else
X    {
X#ifdef DOS
X      setmode(fileno(stdin), O_BINARY);
X#endif
X      parse();
X    }
X  exit(0);
X}
X
X
Xparse()
X{
X  register  c;
X  int	new = 0, n;
X  char  buf[BUFSIZ];
X
X  while (fgets(buf, BUFSIZ, stdin) != NULL)
X    {
X      if (!strncmp(buf, "#! ", 3))
X	{
X	  if (!strncmp(buf+3, "cunbatch", 8))
X	    {
X#ifndef DOS
X	      if (!(cf = popen(dcomp, "w")))
X		bye(dcomp);
X#else
X	      if (!(cf = fopen(tmpnews, "wb")))
X		bye(tmpnews);
X#endif
X	      while ((c = getchar()) != EOF)
X		putc(c, cf);
X	      pclose(cf);
X#ifdef DOS
X	      tmpnews[8] = '\0';
X	      if (system(dcomp))
X		bye(dcomp);
X#endif
X	      if ((cf = freopen(tmpnews, Readmode, stdin)) == NULL)
X		bye(tmpnews);
X	      continue;
X	    }
X	  else if (sscanf(buf+3, "rnews %d", &n) == 1)
X	    {
X	      for (c = 0, new = 0; c < n; new++)
X		{
X		  if (fgets(buf, BUFSIZ, stdin) == NULL)
X		    break;
X		  c += strlen(buf);
X		  parse_line(buf, new);
X		}
X	      continue;
X	    }
X	}
X      else			/* unbatched news */
X	parse_line(buf, new++);
X    }
X  unlink(tmpnews);
X}
X
X
Xparse_line(buf, cont)
X     char *buf;
X     int  cont;
X{
X  static int h;
X  int    i, eoh = 0;
X  static char *hold[20];
X  char   *sp, *ep, *ctime(), *malloc(), *strchr();
X  long   clock;
X
X  if (!cont)
X    h = 0;
X  if (h >= 0)
X    {
X      hold[h] = malloc(strlen(buf) + 1);
X      strcpy(hold[h++], buf);
X      if (!strncmp(buf, "From: ", 6))
X	{
X	  time(&clock);
X	  if (sp = strchr(buf, '<'))
X	    {
X	      sp++;
X	      ep = strchr(buf, '>');
X	    }
X	  else
X	    {
X	      sp = &buf[6];
X	      ep = strchr(buf, '(');
X	    }
X	  if (ep == NULL)
X	    ep = strchr(buf, '\n');
X	  *ep = '\0';
X	  fprintf(nf, "\nFrom %s %s", sp, ctime(&clock));
X	  eoh = 1;
X	}
X      if (eoh || *buf == '\n')
X	{
X	  for (i = 0; i < h; i++)
X	    {
X	      if (!strncmp(hold[i], "Path: ", 6))
X		fprintf(nf, "Path: %s!%s", iam, &hold[i][6]);
X	      else
X		fputs(hold[i], nf);
X	      free(hold[i]);
X	    }
X	  h = -1;
X	}
X    }
X  else
X    {
X      if (!strncmp(buf, "From ", 5))
X	putc('>', nf);
X      fputs(buf, nf);
X    }
X}
SHAR_EOF
if test 2960 -ne "`wc -c < 'rnews.c'`"
then
	echo shar: "error transmitting 'rnews.c'" '(should have been 2960 characters)'
fi
fi
echo shar: "extracting 'pn.proto'" '(1144 characters)'
if test -f 'pn.proto'
then
	echo shar: "will not over-write existing file 'pn.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'pn.proto'
X:
X#! /bin/sh
X# pn - news poster for bootstrap news 
X# Copyright 1989, 1990 Ronald Florence 
X# version 1.3 (ron at mlfarm.com, 15 Dec 90)
X
Xc='\c'
Xn=
X[ "$n" = "-n" ] && c=''
XHostname=BigNode
Xeditor=${EDITOR:-vi}
Xpager=${PAGER:-more}
XSeqfile=/usr/lib/news/seq
Xset `date`
XDatestr="$3 $2 `expr $6 % 100` $4 $5"
XID=`cat $Seqfile`
XSys=`uuname -l | tr -d "\012\040"`
XUser=`logname`
XName=`sed -n "s/^$User:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
XSig=$HOME/.signature
X
Xecho $n "Newsgroups: $c"
Xread Groups
Xecho $n "Subject: $c"
Xread Subject
X
XTmpart=/tmp/newsart.$$
Xtrap 'rm -f $Tmpart' 1 2 3 15
X
Xcat > $Tmpart <<EOH
XPath: $Sys!$User
XFrom: $User@$Sys.UUCP ($Name)
XNewsgroups: $Groups
XSubject: $Subject
XMessage-ID: <$ID@$Sys.UUCP>
XDate: $Datestr
X
X
XEOH
X
X$editor +8 $Tmpart
Xcls
X[ -r $Sig ] && (echo "\n--" ; cat $Sig) >> $Tmpart
X$pager $Tmpart
Xecho $n "\n\nPost this article to all of usenet? $c"
Xwhile read yn
X  do case $yn in
X    y*|Y*) uux - -r $Hostname!rnews < $Tmpart
X	   echo `expr $ID + 1` > $Seqfile
X	   echo "Posted!"
X	   break ;;
X    n*|N*) echo "Article cancelled!"
X	   break ;;
X        *) echo $n "Yes or no? $c" ;;
X    esac
X  done
Xrm -f $Tmpart
SHAR_EOF
if test 1144 -ne "`wc -c < 'pn.proto'`"
then
	echo shar: "error transmitting 'pn.proto'" '(should have been 1144 characters)'
fi
fi
echo shar: "extracting 'uurec.proto'" '(332 characters)'
if test -f 'uurec.proto'
then
	echo shar: "will not over-write existing file 'uurec.proto'"
else
sed 's/^X//' << \SHAR_EOF > 'uurec.proto'
X:
X#! /bin/sh
X# uurec - bootstrap news by mail 
X# copyright 1989, 1990 Ronald Florence  
X# version 1.3 (ron at mlfarm.com, 15 Dec 90)
X
XNewsspool=NEWSSPOOL
X
Xsed	'/^Received: .*/d
X	/^	id .*/d
X	/^Subject: .*/d
X	/^To: .*/d
X	/^Message-Id: .*/d
X	/^Date: .*/d
X	/^From: .*/d
X	s/^NFrom />From /
X	s/^N//'  >> $Newsspool
Xecho "\n" >> $Newsspool
X
X
SHAR_EOF
if test 332 -ne "`wc -c < 'uurec.proto'`"
then
	echo shar: "error transmitting 'uurec.proto'" '(should have been 332 characters)'
fi
fi
exit 0
#	End of shell archive

--

Ronald Florence			ron at mlfarm.com



exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.



More information about the Comp.sources.misc mailing list