Subject:  News/mail gateway package, Part04/04
Newsgroups: alt.sources

Archive-name: newsgate2beta/part04

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents:  Makefile mail-interface misc.c mkmailpost.1 mkmailpost.sh
#   news2mail.sh patchlevel.h signoff.c test-addr test-gag uucp-2-inet
# Wrapped by rsalz@litchi.bbn.com on Fri Feb 28 11:14:03 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive 4 (of 4)."'
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
  echo shar: Extracting \"'Makefile'\" \(3734 characters\)
  sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X##
X##  Makefile for mail/news gateway programs.
X##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/Makefile,v 1.18 91/07/22 10:26:34 rsalz Exp Locker: rsalz $
X##
XSHELL	= /bin/sh
X
X##  The header-reader in rfc822 needs a date parser.  If you want to use
X##  the getdate.y routine (which has problems with numeric timezones,
X##  among others), NEWSSRC to point to the directory where you have a copy
X##  of it.  If you want to use the C News getabsdate routine, comment out
X##  the NEWSSRC and GETDATE lines and edit DATELIB to point to your C News
X##  library.  (Make sure your linker knows the difference between Split
X##  and split, however!)  If you want to use the INN getdate routine,
X##  comment out NEWSSRC and GETDATE and edit DATELIB to point to your libinn.a
X#NEWSSRC		= ../news2.11/src
X#GETDATE		= getdate.o
XDATELIB		= ../inn/libinn.a
X#DATEDEF		= -DUSE_GETABSDATE
X
X##  Edit appropriately.  See gate.h before you touch UUCP_INET.
XUUCP_INET	= /usr/lib/news/.admin/uucp-2-inet
XDESTDIR		= /usr/uucp/bin
XOPT		= -g
X#OPT		= -O
XDEFS		= $(DATEDEF)
XCFLAGS		= $(OPT) $(DEFS)
XLINKFLAGS	=
X#LINKFLAGS	= -s -Bstatic
X
X##  Get just filenames from a standard manifest.
XSEDCOMMANDS = -e 1,2d -e '/(Directory)/d' -e 's/ .*//'
X
X##  Gag, the gateway alias generator.
XG_SRCS	= gag.c lex.c misc.c
XG_OBJS	= gag.o lex.o misc.o
X
X##  Mail2News, the mail into news part of the gateway.
XM_SRCS	= misc.c regex.c hdr.c mail2news.c rfc822.c
XM_OBJS	= misc.o regex.o hdr.o mail2news.o rfc822.o $(GETDATE)
X
X##  News2Mail, the news into mail part of the gateway.
XN_SRCS	= misc.c news2mail.c
XN_OBJS	= misc.o news2mail.o
X
X##  Manpages for the programs.
XDOCS	= gag.1 mail2news.1 mkmailpost.1 news2mail.1 signoff.1
X
Xall:			mail2news news2mail gag mkmailpost tags lint
X
Xinstall:		all
X	@echo "Install as directed in the README file."
X#	@rm -f $(DESTDIR)/gag $(DESTDIR)/mail2news $(DESTDIR)/news2mail
X#	cp gag mail2news news2mail $(DESTDIR)/.
X#	cp uucp-2-inet $(UUCP_INET)
X
Xclean clobber:
X	rm -f mail2news news2mail gag mkmailpost hdrtest *.o
X	rm -f tags lint.? core gag.c gag.h lex.c
X	rm -f Part0? newsgate.tar.Z
X
X
Xtags:			$(N_SRCS) $(M_SRCS)
X	ctags -tw $(N_SRCS) $(M_SRCS) $(G_SRCS) gate.h
X
Xlint:			lint.d lint.g lint.m lint.n
X
X
X##
Xmail2news:		$(M_OBJS)
X	@rm -f mail2news
X	$(CC) $(CFLAGS) $(LINKFLAGS) -o mail2news $(M_OBJS) $(DATELIB)
X
Xnews2mail:		$(N_OBJS)
X	@rm -f news2mail
X	$(CC) $(CFLAGS) $(LINKFLAGS) -o news2mail $(N_OBJS)
X
Xgag:			$(G_OBJS)
X	@rm -f gag
X	$(CC) $(CFLAGS) $(LINKFLAGS) -o gag $(G_OBJS)
X
Xmkmailpost:		mkmailpost.sh
X	@rm -f mkmailpost
X	cp mkmailpost.sh mkmailpost
X	chmod 755 mkmailpost
X
X##
X$(G_OBJS) $(M_OBJS) $(N_OBJS):	gate.h
X
X
X##
Xlint.d:			$(DOCS)
X	checknr -c.IR.BI.RI $(DOCS) regex.3 >lint.d
Xlint.g:			gag
X	lint -a    -h $(DEFS) $(G_SRCS) |grep -v yaccpar >lint.g
Xlint.m:			mail2news
X	lint -a -b -h $(DEFS) $(M_SRCS) >lint.m
Xlint.n:			news2mail
X	lint -a -b -h $(DEFS) $(N_SRCS) >lint.n
X
X##
XTESTFILES	= hdr.c rfc822.o $(GETDATE)
Xhdrtest:		$(TESTFILES)
X	@rm -f hdr.o hdrtest
X	$(CC) -DTEST $(CFLAGS) $(LINKFLAGS) -o hdrtest $(TESTFILES) $(DATELIB)
X	@rm -f hdr.o
X	./hdrtest <test-addr
X
X##  Keep intermediate files around.
Xlex.o:			lex.c
Xgag.o:			gag.c
Xgag.c:			gag.y
X	@rm -f gag.c gag.h
X	yacc -d gag.y
X	@mv y.tab.c gag.c
X	@mv y.tab.h gag.h
X
X
X##  Distribution kits.
Xshar:
X	@rm -f Part0?
X	makekit -m
X	@rm -f MANIFEST.BAK
X	@-chmod 444 Part0?
Xtar:
X	@rm -f newsgate.tar.Z
X	tar cf newsgate.tar `sed $(SEDCOMMANDS) <MANIFEST`
X	compress newsgate.tar
X
X
X##  Get the date parser from 2.11 news.
Xgetdate.o:
X	@rm -f getdate.o
X	cd $(NEWSSRC) ; make getdate.o
X	cp $(NEWSSRC)/getdate.o .
X
X##  Saber stuff
X.SUFFIXES: .c .o .src .obj
X.c.src:
X	#load $(CFLAGS) $<
X.c.obj:
X	#load $(CFLAGS) $<
Xsaber:		$(SABER_SRC)
X	#load $(CFLAGS) $(SABER_SRC) $(ROOTDIR)/clib/cronus.a
END_OF_FILE
  if test 3734 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
  fi
  # end of 'Makefile'
fi
if test -f 'mail-interface' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mail-interface'\"
else
  echo shar: Extracting \"'mail-interface'\" \(2823 characters\)
  sed "s/^X//" >'mail-interface' <<'END_OF_FILE'
X#! /bin/sh
X##  A portable mail interface program.  Original by Piete Brooks,
X##  modified by Rich $alz <rsalz@bbn.com>
X
Xmailer="${mailer-/usr/lib/sendmail}"
Xheaders=false
X
X##  Decode the arguments.
Xwhile test $# -gt 0 ; do
X    arg="$1"
X    shift
X    case "$arg" in
X    -A|-ASIS)
X	asis=true
X	;;
X    -b|-body)
X	body="$body
X$1"
X	shift
X	;;
X    -c|-cc)
X	cc="$cc, $1"
X	shift
X	headers=true
X	;;
X    -f|-from)
X	from="$1"
X	shift
X	headers=true
X	;;
X    -h|-help)
X	cat <<EOF
XUsage: $0 [flags] [recipients...]
X	-A -ASIS	Send text ASIS, i.e. headers are present in the input
X	-b -body	String which is to be the body of the message
X	-c -cc		Carbon Copy recipients
X	-f -from	From field
X	-h -help	This message
X	-r -recip	Recipient (passed on command line)
X	-s -subject	Set the subject field
X	-t -to		Main recipients
X	-*		ERROR
X	*		treat as recipients
XEOF
X	exit 1
X	;;
X    -r|-recip)
X	recip="$recip $1"
X	shift
X	;;
X    -s|-subject)
X	subject="$subject, $1"
X	shift
X	headers=true
X	;;
X    -t|-to)
X	to="$to, $1"
X	shift
X	headers=true
X	;;
X    -*)
X	echo $0: invalid argument \""$arg"\"
X	exit 1
X	;;
X    *)
X	to="$to, $arg"
X	;;
X    esac
Xdone
X
X##  If no recipients, send to postmaster.
Xcase "$to$cc$recip" in
X'')
X    recip=postmaster
X    ;;
Xesac
X
X##  If we got no headers on the command line, read them from the message.
Xcase $headers in
Xfalse)
X    asis=true
X    ;;
Xesac
X
X##  Strip off the spurious leading ", " in repeatable items
Xcase "$to" in
X', '*)
X    to=`expr "$to" : ", \(.*\)`
X    ;;
Xesac
Xcase "$cc"  in
X', '*)
X    cc=`expr "$cc" : ", \(.*\)`
X    ;;
Xesac
Xcase "$subject"	in ', '*)
X    subject=`expr "$subject" : ", \(.*\)`
X    ;;
Xesac
X
X##  Now do the business.
Xcase "$mailer" in
X*/sendmail|sendmail|*/sendmail' '*|sendmail' '*)
X    args="-oi"
X    if [ -z "$recip" ] ; then
X	args="$args -t"
X    fi
X    (
X	if [ ! -z "$subject" ] ; then
X	    echo "Subject: $subject"
X	fi
X	if [ ! -z "$from" ] ; then
X	    echo "From: $from"
X	fi
X	if [ ! -z "$to" ] ; then
X	    echo "To: $to"
X	fi
X	if [ ! -z "$cc" ] ; then
X	    echo "Cc: $cc"
X	fi
X	if [ -z "$asis" ] ; then
X	    echo ""
X	fi
X	if [ -z "$body" ] ; then
X	    cat
X	else
X	    echo "$body" | sed 1d
X	fi
X    ) | $debug $mailer $args $recip
X    ;;
X
X*/submit|submit|*/submit' '*|submit' '*)
X    args="-tsz"
X    case "$recip" in
X    if [ -z "$recip" ] ; then
X	if [ ! -z "$to" ] ; then
X	    args="${args}gto*"
X	fi
X	if [ ! -z "$cc" ] ; then
X	    args="${args}gcc*"
X	fi
X    fi
X    (
X	if [ ! -z "$subject" ] ; then
X	    echo "Subject: $subject"
X	fi
X	if [ ! -z "$from" ] ; then
X	    echo "From: $from"
X	fi
X	if [ ! -z "$to" ] ; then
X	    echo "To: $to"
X	fi
X	if [ ! -z "$cc" ] ; then
X	    echo "Cc: $cc"
X	fi
X	if [ -z "$asis" ] ; then
X	    echo ""
X	fi
X	if [ -z "$body" ] ; then
X	    cat
X	else
X	    echo "$body" | sed 1d
X	fi
X    ) | $debug $mailer $args $recip
X    ;;
X
X*)
X    echo Unknown mailer 1>&2
X    exit 1
X    ;;
X
Xesac
END_OF_FILE
  if test 2823 -ne `wc -c <'mail-interface'`; then
    echo shar: \"'mail-interface'\" unpacked with wrong size!
  fi
  # end of 'mail-interface'
fi
if test -f 'misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.c'\"
else
  echo shar: Extracting \"'misc.c'\" \(3068 characters\)
  sed "s/^X//" >'misc.c' <<'END_OF_FILE'
X/*
X**  Miscellaneous routines.
X*/
X#include "gate.h"
X#if	defined(RCSID)
Xstatic char RCS[] =
X	"$Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/misc.c,v 1.9 91/07/18 11:04:27 rsalz Exp $";
X#endif	/* defined(RCSID) */
X
X
X/*
X**  Allocate memory.
X*/
Xalign_t
XMyAlloc(i)
X    int			i;
X{
X    align_t		p;
X
X    if ((p = (align_t)malloc((unsigned int)i)) == NULL) {
X	Fprintf(stderr, "%s:  Could not allocate %d bytes: %s\n",
X		Pname, i, strerror(errno));
X	exit(EX_OSERR);
X    }
X    return p;
X}
X
X
X#if	!defined(HAVE_STRERROR)
X/*
X**  Return a printable representation of errno.
X*/
Xchar *
Xstrerror(x)
X    int			x;
X{
X    static char		buff[20];
X
X    if (x >= 0 && x < sys_nerr)
X	return sys_errlist[x];
X    Sprintf(buff, "Error code %d", x);
X    return buff;
X}
X#endif	/* !defined(HAVE_STRERROR) */
X
X
X/*
X**  Free up something that Split() made.
X*/
Xvoid
XSplitFree(p)
X    char	***p;
X{
X    if (p && *p) {
X	free((*p)[0]);
X	free((char *)*p);
X	*p = NULL;
X    }
X}
X
X
X/*
X**  This is an AWK-style split routine.  If the split character is NULL,
X**  we split on space or tab and eat long stretches of same (that is, no
X**  null fields will result).  Returns number of fields made.
X*/
Xint
XSplit(s, p, c)
X    register char	*s;
X    char		***p;
X    register char	c;
X{
X    register char	*cp;
X    register int	blank;
X    register int	n;
X    register int	i;
X
X    if (s == NULL || *s == '\0') {
X	Fprintf(stderr, "%s:  Someone was a pinhead!\n", Pname);
X	abort();
X    }
X
X    i = strlen(s) + 1;
X    cp = NEW(char, i);
X    /* This is too much -- we'll realloc what we really need later. */
X    *p = NEW(char*, i);
X
X    if (c == '\0') {
X	/* Eat multiple whitespace characters. */
X	for (blank = TRUE, n = 0; *s; s++)
X	    if (WHITE(*s)) {
X		if (!blank)
X		    *cp++ = '\0';
X		blank = TRUE;
X	    }
X	    else {
X		if (blank)
X		    (*p)[n++] = cp;
X		*cp++ = *s;
X		blank = FALSE;
X	    }
X
X	if (n == 0) {
X	    (*p)[0] = cp;
X	    SplitFree(p);
X	    return 0;
X	}
X    }
X    else
X	/* Normal case: find all occurrences of "c" and null them as field
X	 * terminators; add new string starts to the array of pointers to
X	 * strings. */
X	for ((*p)[0] = cp, n = 1; *s; s++)
X	    if (*s == c) {
X		*cp++ = '\0';
X		(*p)[n++] = cp;
X	    }
X	    else
X		*cp++ = *s;
X
X    /* Make sure the last string is terminated. */
X    *cp = '\0';
X
X    /* Free up the excess space. */
X    *p = (char **)REALLOC(*p, (n + 1) * sizeof (char *));
X    (*p)[n] = NULL;
X    return n;
X}
X
X
X
X/*
X**  Read in a file of lines, dump it into an array of strings.
X*/
Xchar **
XReadFile(Name)
X    char		*Name;
X{
X    register FILE	*F;
X    register char	**v;
X    register char	*p;
X    register int	i;
X    char		**value;
X    char		buff[SM_SIZE];
X
X    /* Open file, count number of lines therein. */
X    if ((F = fopen(Name, "r")) == NULL) {
X	perror(Name);
X	exit(EX_OSFILE);
X    }
X    for (i = 1; fgets(buff, sizeof buff, F); i++)
X	continue;
X
X    rewind(F);
X    for (v = value = NEW(char*, i); fgets(buff, sizeof buff, F); ) {
X	if ((p = IDX(buff, '\n')) != NULL)
X	    *p = '\0';
X	if (buff[0] && buff[0] != '#')
X	    *v++ = COPY(buff);
X    }
X
X    *v = NULL;
X    return value;
X}
END_OF_FILE
  if test 3068 -ne `wc -c <'misc.c'`; then
    echo shar: \"'misc.c'\" unpacked with wrong size!
  fi
  # end of 'misc.c'
fi
if test -f 'mkmailpost.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mkmailpost.1'\"
else
  echo shar: Extracting \"'mkmailpost.1'\" \(1832 characters\)
  sed "s/^X//" >'mkmailpost.1' <<'END_OF_FILE'
X.\" $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/mkmailpost.1,v 1.6 91/07/18 20:13:26 rsalz Exp Locker: rsalz $
X.TH MKMAILPOST 1 LOCAL
X.SH NAME
Xmkmailpost \- make a set of mailpost commands for a gag file
X.SH SYNOPSIS
X.B mkmailpost
X[
X.B activefile
X[
X.B mail2news_path
X] ]
X.SH DESCRIPTION
X.I mkmailpost
Xreads the news active file and generates a a set of ``mailpost'' commands
Xfor feeding into
X.IR gag (1L).
XOutput is sent to the standard output.
X.PP
XThe first argument is the path to the news active file; the default is
X.IR /usr/lib/news .
XThe second argument is the path to the
X.I mail2news
Xprogram; if specified, then a ``default mail2news
X.IR path ''
Xis output.
X.PP
X.I Mkmailpost
Xignores moderated groups, as well as ``junk,'' ``general,'' and those
Xof the form
X.RI ``to. site .''
XIt also ignores groups with the word ``test'' in them; such groups usually
Xhave mail reflectors attached to them, so that the poster gets a copy of
Xtheir message.
XIt is assumed that this is not appropriate if someone is mailing into a site.
X.I Mkmailpost
Xalso ignores groups with with the words ``announce'' in them under the
Xassumption that they are moderated groups and mail should be sent to
Xthe moderator, instead.
X(It is agreed that finding the moderator for non-Usenet sites can be
Xproblematic.)
X.PP
XAssume the main
X.I gag
Xinput is named
X.IR main.gag .
XThe following command line can be useful:
X.RS
X.nf
X( echo '#include "main.gag"' ; mkmailpost ) \e
X    | /lib/cpp | gag
X.fi
X.RE
X(On some systems you may have to use ``cc \-E'' or ``cc \-P'' instead
Xof ``/lib/cpp.'')
X.SH BUGS
XSince the name and number of Usenet groups changes very frequently,
Xa better method is to define a more general way of feeding mail into
Xnewsgroups.
X.SH "SEE ALSO"
Xgag(1L).
X.SH AUTHOR
XRich $alz <rsalz@bbn.com>, after an idea by
X.br
XErik E. Fair <fair@apple.com>.
END_OF_FILE
  if test 1832 -ne `wc -c <'mkmailpost.1'`; then
    echo shar: \"'mkmailpost.1'\" unpacked with wrong size!
  fi
  # end of 'mkmailpost.1'
fi
if test -f 'mkmailpost.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mkmailpost.sh'\"
else
  echo shar: Extracting \"'mkmailpost.sh'\" \(1202 characters\)
  sed "s/^X//" >'mkmailpost.sh' <<'END_OF_FILE'
X#! /bin/sh
X##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/mkmailpost.sh,v 1.4 91/02/12 14:49:26 rsalz Exp $
X##  Script to make a set of "mailpost" commands for all groups in
X##  the news active file.
X##  Usage:
X##	makemailpost [news active file [mail2newspath] ]
X
Xcase $# in
X[012])
X    ;;
X*)
X    echo "Usage: `basename $0` [activefile [mail2newspath] ]" 1>&2
X    exit 1
X    ;;
Xesac
X
XACTIVE=${1-/usr/lib/news/active}
Xif [ ! -f ${ACTIVE} ] ; then
X    echo "`basename $0`:  Can't read input ${ACTIVE}." 1>&2
X    exit 1
Xfi
X
X##  Write the prolog.
Xecho "/*"
Xecho "**  Generated from ${ACTIVE}"
Xecho "**  by `whoami` on `date`"
Xecho "*/"
Xif [ "$2" != "" ] ; then
X    echo 'default mail2news "'$2'";'
Xfi
X
Xtrap "rm -f /tmp/mmp$$ ; exit 1" 1 2 3 15
X
X##  Create the sed temporary file and run it
Xcat >/tmp/mmp$$ <<\EOF
X# Delete moderated groups
X/m$/d
X# Trim anything after the first field
Xs/ .*$//
X# Delete control, junk, site-specific
X/^control$/d
X/^junk$/d
X/^to\./d
X# Delete test groups and announce, assuming the latter is moderated
X/\<test\>/d
X/\<announce\>/d
X# Turn the line "foo" into "mailpost foo;"
Xs/^.*$/mailpost &;/
XEOF
X
X##  Run sed, clean up.
Xsed -f /tmp/mmp$$ <${ACTIVE} | sort
X
Xrm -f /tmp/mmp$$
END_OF_FILE
  if test 1202 -ne `wc -c <'mkmailpost.sh'`; then
    echo shar: \"'mkmailpost.sh'\" unpacked with wrong size!
  fi
  # end of 'mkmailpost.sh'
fi
if test -f 'news2mail.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'news2mail.sh'\"
else
  echo shar: Extracting \"'news2mail.sh'\" \(2028 characters\)
  sed "s/^X//" >'news2mail.sh' <<'END_OF_FILE'
X#! /bin/sh
X##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/news2mail.sh,v 1.3 91/02/12 14:50:28 rsalz Exp $
X##  A short, mostly-awk, script to send news on stdin out as mail.
X##  Usage:  news2mail <address>
X##  Written by John S. Quarterman <jsq@longway.tic.com>.
X##  Light editing by Rich $alz <rsalz@bbn.com>.
XPATH=/usr/local:/usr/ucb:/bin:/usr/bin ; export PATH
X
Xcase $1 in
X"")
X    echo "Usage:  `basename $0` address"
X    exit 1
X    ;;
X"-")
X    TO="cat -u"
X    ;;
X*)
X    TO="/bin/mail $1"
X    ;;
Xesac
X
Xawk '
XBEGIN {
X    header = 1;
X    date = "";
X}
Xheader == 1 && /^$/ {
X    # End of headers; print dates.
X    header = 0;
X    if (pdate != "" && date ~ /GMT/ && pdate !~ /GMT/) {
X	print "Date: "pdate;
X	print "Posted-Date: "date;
X    } else {
X	if (date != "")
X	    print "Date: "date;
X	if (pdate != "")
X	    print "Posted-Date: "pdate;
X    }
X}
Xheader == 0 {
X    print $0;
X    next;
X}
X$1 == "Relay-Version:"		{ next; }
X$1 == "Posting-Version:"	{ next; }
X$1 == "Path:"			{ next; }
X$1 == "From"			{ next; }
X$1 == "Date-Received:"		{ next; }
X$1 == "Received-Date:"		{ next; }
X#$1 == "Newsgroups:"		{ next; }
X#$1 == "Organization:"		{ next; }
X$1 == "Approved:"		{ next; }
X$1 == "Lines:"			{ next; }
X$1 == "Date:" {
X    date = $2;
X    for (i = 3; i <= NF; i++)
X	date = date " " $i;
X    next;
X}
X$1 == "Posted-Date:" {
X    pdate = $2;
X    for (i = 3; i <= NF; i++)
X	pdate = pdate " " $i;
X    next;
X}
X$1 == "From:" {
X    address=$2;
X    name = "";
X    surround = 0;
X    for (f = 3; f <= NF; f++) {
X	if ($f ~ /,/)
X	    surround=1;
X	if (split ($f, parts, "(") > 1)
X	    it = parts[2];
X	else
X	    it = $f;
X	if (split ($f, parts, ")") > 1)
X	    it = parts[1];
X	if (name == "")
X	    name = it;
X	else
X	    name = name " " it;
X    }
X    if (address ~ /.UUCP$/) {
X	split(address, parts, "@");
X	address = sprintf ("%s%%%s@%s", parts[1], parts[2], "'`hostname`'");
X    }
X    if (surround != 0)
X	    printf ("From: %s (%s)\n", address, name);
X    else
X	    printf ("From: %s <%s>\n", name, address);
X    next;
X}
X{
X    print $0;
X}' | eval $TO
END_OF_FILE
  if test 2028 -ne `wc -c <'news2mail.sh'`; then
    echo shar: \"'news2mail.sh'\" unpacked with wrong size!
  fi
  chmod +x 'news2mail.sh'
  # end of 'news2mail.sh'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
  echo shar: Extracting \"'patchlevel.h'\" \(2878 characters\)
  sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X/*
X**  HEADER FILE FOR NEWS/MAIL GATEWAY CODE.
X**  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/patchlevel.h,v 1.6 91/07/22 10:26:54 rsalz Exp $
X**
X**  $Log:	patchlevel.h,v $
X**  Revision 1.6  91/07/22  10:26:54  rsalz
X**  Add comments and #ifdef to use C News getabsdate routines.
X**  
X**  Revision 1.5  91/07/18  14:05:34  rsalz
X**  Add REQUIRE_UNIX_FROM #define.
X**  Have mail2news turn "From " into "Sender:" (Rickert).
X**  Add -a and -d flags to mail2news, document them, and reword description
X**  of the flags. (Rickert).
X**  Remove . from NETCHR list (Rickert).
X**  Update WHOAMI comment in gate.h
X**  Ran through static Saber-C analysis.
X**  Replace "I'm burnt out comment" with different words.
X**  Put X-Unparseable-Date if we can't parse date in mail2news.
X**  
X**  Revision 1.4  91/04/08  10:14:31  rsalz
X**  patch02:  TrimEnvironment was not quite right.
X**  patch02:	Neil Rickert <rickert@cs.niu.edu>
X**  patch02:  Invalid dates weren't caught in the RFC822-parser.
X**  patch02:	Neil Rickert <rickert@cs.niu.edu>
X**  patch02:  Change Makefile to be more clear about how to get getdate.o
X**  patch02:	Rich $alz <rsalz@bbn.com>
X**  
X**  Revision 1.3  91/04/01  09:43:10  rsalz
X**  patch01:  README had wrong RFC number.
X**  patch01:	Mark Moraes <moraes@cs.toronto.edu>
X**  patch01:  Not all systems have <netdb.h>.
X**  patch01:  Have TrimEnvironment set environ to empty array, not a null pointer.
X**  patch01:  	Gordon L. Burditt <gordon@sneaky.lonestar.org>
X**  patch01:  Closefile in gag.y was closing the wrong file.
X**  patch01:	Mike Pelletier <stealth@engin.umich.edu>
X**  patch01:  There is a multi-word typo in news2mail.1
X**  patch01:  	Brian Kanton <brian@ucsd.edu>
X**  patch01:  Was getting coredumps if UUNAME and L_SYS are #undef'd.
X**  patch01:	Kannan Varadhan <kannan@oar.net>
X**  patch01:  News2mail was putting out an extra space between the header name
X**  patch01:  and the colon.
X**  patch01:	Michael Gengenbach <gengenba@forwiss.uni-passau.de>
X**  patch01:  Fixed GATEWAY/GATEWAY_NAME confusion; added more explanatory
X**  patch01:  comments about what it (and FIXED_PATH) do.
X**  patch01:  Added C News and InterNetNews support to gag.  (-i is currently
X**  patch01:  about as useful to the outside world as -b, but I need it.)
X**  patch01:  Added warning that gag overwrites files and doesn't edit them,
X**  patch01:  and some other verbiage.
X**  patch01:  Described how to prevent loops and a simple-minded way that uses
X**  patch01:  one sys file entry when gatewaying many newsgroups into mail.
X**  patch01:  	Rich $alz <rsalz@bbn.com>
X**  
X**  Revision 1.2  91/02/12  15:02:40  rsalz
X**  Incorporate all known major code fixes.
X**  For release to NNTP-MANAGERS, prior to posting.
X**  I hope next release will be 2.0, reasonable patches.
X**  
X**  Revision 1.1  89/07/10  13:04:23  rsalz
X**  Initial revision
X**  
X*/
X#define PATCHLEVEL	1
END_OF_FILE
  if test 2878 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  fi
  # end of 'patchlevel.h'
fi
if test -f 'signoff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'signoff.c'\"
else
  echo shar: Extracting \"'signoff.c'\" \(3368 characters\)
  sed "s/^X//" >'signoff.c' <<'END_OF_FILE'
X/*
X**  SIGNOFF
X**  Quickie hack to see of a mail message is a "please drop me" request.
X**  Exit's with status 0 if it is a regular message, or 1 if it appears to
X**  be a one of this administrative requests that annoy everyone when
X**  they're sent to the whole list.  Optional first argument is the name
X**  of the input file, or stdin is read if none is given.
X**
X**  Original program written by Russ Nelson, <nelson@clutx.clarkson.edu>.
X**  Severely hacked on by Rich $alz, <rsalz@bbn.com>.  This program is
X**  basically incorporated into mail2news; it's pulled out here for
X**  demonstration.
X**
X**  For example, here is a script that could be used as a wrapper around
X**  the mail2news program:
X**	#! /bin/sh
X**	cat >/tmp/signoff$$
X**	if /usr/lib/news/signoff </tmp/signoff$$ ; then
X**	    /usr/ucb/Mail -s "Sign on/off request" usenet </tmp/signoff$$
X**	else
X**	    /usr/lib/news/mail2news.real </tmp/signoff$$
X**	fi
X**	exec rm /tmp/signoff$$
X**
X**  Russ ran the following test for a month and got only one real message
X**  (a gnu.gcc bug report) treated as a subscription request.  He doesn't
X**  know how many subs made it out to the net, tho:  that would entail
X**  reading ALL netnews articles -- yuck!
X**
X**  Put the following line in your news sys file:
X**	allmail:all::/usr/lib/news/ts
X**  here is the "ts" script:
X**	#! /bin/sh
X**	cat >/tmp/ts.$$
X**	/usr/lib/news/signoff </tmp/ts.$$ || mail usenet </tmp/ts.$$
X**	exec rm /tmp/ts.$$
X**
X**  Perhaps a better way to test is to make the test less conservative,
X**  and see what "real" articles get caught, and make adjustments then?
X**  Comments solicited.
X*/
X#include <stdio.h>
X#include <ctype.h>
X
X#define EQ(a, b)		(strcmp((a), (b)) == 0)
X
X
Xint
Xmain(ac, av)
X    int			ac;
X    char		*av[];
X{
X    register FILE	*F;
X    register char	*p;
X    register int	c;
X    register int	drop_or_add;
X    register int	from_or_to;
X    register int	mail_word;
X    register int	count;
X    char		word[128];
X
X    /* Get input. */
X    if (ac < 2)
X	F = stdin;
X    else if ((F = fopen(av[1], "r")) == NULL) {
X	(void)fprintf(stderr, "%s: cannot open %s\n", av[0], av[1]);
X	exit(1);
X    }
X
X    /* Skip headers by waiting for the first blank line. */
X    while (fgets(word, sizeof word, F) && *word != '\n')
X	    ;
X
X    /* Clear counts. */
X    drop_or_add = 0;
X    from_or_to = 0;
X    mail_word = 0;
X    count = 0;
X
X    /* Read input a word at a time. */
X    for (p = word; (c = getc(F)) != EOF; ) {
X	if (!isalpha(c)) {
X	    *p = '\0';
X	    if (p > word)
X		count++;
X	    p = word;
X
X	    if (EQ(word, "remove") || EQ(word, "drop") || EQ(word, "off")
X	     || EQ(word, "subscribe") || EQ(word, "get") || EQ(word, "add"))
X		drop_or_add++;
X	    else if (EQ(word, "from") || EQ(word, "to"))
X		from_or_to++;
X	    else if (EQ(word, "mail") || EQ(word, "mailing")
X		  || EQ(word, "list") || EQ(word, "dl"))
X		mail_word++;
X	}
X	else if (p < &word[sizeof word - 1])
X	    *p++ = isupper(c) ? tolower(c) : c;
X    }
X
X    (void)fclose(F);
X
X    /* Use fancy-shmancy AI techniques to determine what the message is. */
X    c = count < 25 && drop_or_add && from_or_to && mail_word;
X
X#if	defined(DEBUG)
X    printf("%s: %d words, %d drop, %d mail --> %s\n",
X	   av[1] ? av[1] : "<stdin>",
X	   count, drop_or_add, mail_word,
X	   c ? "yes" : "no");
X#endif	/* defined(DEBUG) */
X
X    /* Exit appropriately. */
X    exit(c ? 0 : 1);
X    return c ? 0 : 1;
X}
END_OF_FILE
  if test 3368 -ne `wc -c <'signoff.c'`; then
    echo shar: \"'signoff.c'\" unpacked with wrong size!
  fi
  # end of 'signoff.c'
fi
if test -f 'test-addr' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'test-addr'\"
else
  echo shar: Extracting \"'test-addr'\" \(1341 characters\)
  sed "s/^X//" >'test-addr' <<'END_OF_FILE'
X##
X##  Test re-write rules in hdr.c with hdrtest.
X##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/test-addr,v 1.3 91/07/18 19:40:52 rsalz Exp $
X
X## Various simple tests.
Xuucp-site!user
Xcronus.bbn.com!user
Xlitchi.bbn.com!user@corp.sun.com
Xuser@site.arpa
Xuser%site.edu@relay.cs.net
Xuser%site@relay.cs.net
Xuusite1!uusite2!uucp-site!user
Xuusite1!uusite2!bbn.com!user
Xuusite1!uucp-site.bogus!user
Xseismo!site.oz!user
Xuser%site.bitnet@cunyvm.cuny.edu
Xuser%gate1%gate.edu@bitgate
X@router:user@site.com
Xuser%site1.edu%site2.com@gateway
X
X##  First, a normal address.
Xrickert@math.niu.edu (Nice day today)
X
X##  Same thing with <> format.
XNice day today <rickert@math.niu.edu>
X
X##  Now a quoted comment with special characters.
X"<- save space for me ->" <rickert@math.niu.edu>
X
X##  A purely local address.
Xrickert (Neil Rickert)
X
X##  A local address with dots.
X<Neil.Rickert>
X
X##  The next address should be treated as local, since '@' is escaped.
Xrickert\@math.niu.edu
X
X##  A quoted address.
X"XYZVAX::rickert"@dnet.gw.niu.edu
X
X##  A more complex quoted address.
X"XYZVAX::uunet!postmaster"@dnet.gw.niu.edu
X
X##  An unbalanced quote in comments.
Xrickert@math.niu.edu (Nice day " today)
X
X##  And now something really cryptic.
X(Hi " there) rickert@(how are " you)math.niu.edu (" today)
X"The right paren ) is ok in phrase, bad in comment" <Neil.Rickert>
END_OF_FILE
  if test 1341 -ne `wc -c <'test-addr'`; then
    echo shar: \"'test-addr'\" unpacked with wrong size!
  fi
  # end of 'test-addr'
fi
if test -f 'test-gag' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'test-gag'\"
else
  echo shar: Extracting \"'test-gag'\" \(2745 characters\)
  sed "s/^X//" >'test-gag' <<'END_OF_FILE'
X/*
X**  Test suite for gag, Gateway Alias Generator.
X**
X**  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/test-gag,v 1.3 89/11/01 17:36:56 rsalz Exp $
X*/
X
X
X/*
X**  BBN MAILING LISTS
X*/
X/* default inews flags = ""; */
Xdefault distributions = "world usa na ne bbn ddn gnu inet";
Xdefault directory = "/usr/lib/news/.admin";	/* Where MMDF scripts are */
Xdefault mail2news = "/usr/uucp/bin/mail2news";	/* Paths to gateway	*/
Xdefault news2mail = "/usr/uucp/bin/news2mail";	/*   programs		*/
Xdefault mailcontact = "usenet";			/* Put in mail headers	*/
Xdefault mailhost = "mailer.bbn.com";		/* MMDF list processor	*/
Xdefault mailinglist = true;			/* Going both ways	*/
Xdefault organization = "BBN news/mail gateway";
Xdefault owner = "usenet";			/* Sendmail alias owner	*/
Xdefault site = "gateway";			/* Psuedo news site	*/
Xdefault user = "news";				/* MMDF script owner	*/
X
X/*	newsgroup		mailing list */
Xgateway bbn.bboard		bboard;
Xgateway bbn.test		usenet;
X
X/* Mail rec.equestrian articles to the list moderator, unless he's seen
X * them already. */
Xgateway rec.equestrian		horse
X	news2mail =
X	    "v6mail -to kenr@ccp.bbn.com -subj 'Forwarded Horse Article'"
X	site = "ccp.bbn.com";
X
X/* Set up post-comp-foo as an alias that posts articles. */
Xmailpost comp.foo;
X
X
X/*
X**  GNU MAILING LISTS (OSU)
X*/
Xdefault site = "internet";			/* Psuedo news site	*/
Xdefault inews flags = "-x internet -d gnu";	/* Flags for mail2news	*/
Xdefault mail2news = "/usr/lib/news/nrecnews";	/* Path to mail2news	*/
Xdefault mailhost = "prep.ai.mit.edu";		/* Home of mailing list	*/
Xdefault mailinglist = true;			/* Going both ways	*/
Xdefault organization = dotify("GNUs Not Usenet");
Xdefault owner = "usenet";			/* Sendmail alias owner	*/
X
Xgateway gnu.announce			info-gnu
X    moderator = "info-gnu@prep.ai.mit.edu"
X    inews flags = "-d gnu";
Xgateway gnu.emacs			info-gnu-emacs;
Xgateway gnu.emacs.bug			bug-gnu-emacs;
Xgateway gnu.gdb.bug			bug-gdb;
Xgateway gnu.gcc				info-gcc;
Xgateway gnu.gcc.bug			bug-gcc;
Xgateway gnu.g++				info-g++;
Xgateway gnu.g++.bug			bug-g++;
Xgateway gnu.chess			info-chess;
Xgateway gnu.ghostscript.bug		bug-ghostscript;
Xgateway gnu.utils.bug			bug-gnu-utils;
Xgateway gnu.emacs.gnus			info-gnus-english
X    mailhost = "cis.ohio-state.edu";
Xgateway gnu.emacs.vms		vms-gnu-emacs
X    mailhost = "harvard.havard.edu";
Xgateway gnu.emacs.lisp.manual		gnu-manual
X    mailhost = "a.cs.uiuc.edu";
X
X
X/*
X**  OSU LOCAL MAILING LISTS
X*/
Xgateway alt.sca				sca
X    inews flags = "-d alt -x internet"
X    mailhost = "mc.lcs.mit.edu"
X    mailinglist = false
X    organization = dotify("Society for Creative Anachronism");
X
Xgateway cis.big-lan			big-lan
X    inews flags = "-d cis -x internet"
X    mailhost = "suvm.acs.syr.edu"
X    organization = dotify("The Internet");
END_OF_FILE
  if test 2745 -ne `wc -c <'test-gag'`; then
    echo shar: \"'test-gag'\" unpacked with wrong size!
  fi
  # end of 'test-gag'
fi
if test -f 'uucp-2-inet' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uucp-2-inet'\"
else
  echo shar: Extracting \"'uucp-2-inet'\" \(3297 characters\)
  sed "s/^X//" >'uucp-2-inet' <<'END_OF_FILE'
X##  This file maps UUCP names to Internet names.
X##  Blank lines, and lines starting with # are ignored.
X##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/uucp-2-inet,v 1.2 87/10/01 14:06:50 rsalz Release1 $
X##  (I added uunet and bbn.)
Xames			ames.arpa
Xaurora			ames-aurora.arpa
Xkestrel			kestrel.arpa
Xlll-crg			lll-crg.arpa
Xlll-lcc			lll-lcc.arpa
Xstyx			lll-tis-b.arpa
Xcmcl2			nyu.arpa
Xyale			yale.arpa
Xrandvax			rand-unix.arpa
Xosu-eddie		ohio-state.arpa
Xuunet			uunet.uu.net
X
Xcunyvm.bitnet		cunyvm.bitnet
Xpsuvm.bitnet		psuvm.bitnet
X
Xmcnc			mcnc.org
X
Xbrl-smoke		smoke.brl.mil
Xbrl-sem			sem.brl.mil
Xbrl-adm			adm.brl.mil
Xcod			cod.nosc.mil
Xmarlin			marlin.nosc.mil
Xmplvax			mplvax.nosc.mil
Xnoscvax			bass.nosc.mil
X
Xelroy			elroy.jpl.nasa.gov
Xseismo			seismo.css.gov
Xlanl			lanl.gov
Xmordor			mordor.s1.gov
Xhc			hc.dspo.gov
X
Xbbn			bbn.com
Xhplabs			hplabs.hp.com
Xdecwrl			decwrl.dec.com
Xbellcore		bellcore.bellcore.com
Xpetrus			petrus.bellcore.com
XDiamond			diamond.bbn.com
Xsun			sun.com
Xsri-spam		spam.istc.sri.com
Xsri-unix		unix.sri.com
Xthink			think.com
Xburdvax			burdvax.prc.unisys.com
Xbigburd			bigburd.prc.unisys.com
Xparcvax			parcvax.xerox.com
X
Xarizona			arizona.edu
XShasta			shasta.stanford.edu
Xacf2			acf2.nyu.edu
Xacf3			acf3.nyu.edu
Xacf4			acf4.nyu.edu
Xcsd2			csd2.nyu.edu
Xmit-athena		athena.mit.edu
Xathena.mit.edu		athena.mit.edu
Xbatcomputer		tcgould.tn.cornell.edu
Xbu-cs			bu-cs.bu.edu
Xbucsb.bu.edu		bucsb.bu.edu
Xcaip			caip.rutgers.edu
Xcit-vax			csvax.caltech.edu
Xcit-vlsi		vlsi.caltech.edu
Xcornell			cu-arpa.cs.cornell.edu
Xcvl			cvl.umd.edu
Xendor			endor.harvard.edu
Xeneevax			eneevax.umd.edu
Xernie.Berkeley.EDU	ernie.berkeley.edu
Xglacier			glacier.stanford.edu
Xgvax			gvax.cs.cornell.edu
Xgymble			gymble.umd.edu
Xh.cc.purdue.edu		h.cc.purdue.edu
Xprinceton		princeton.edu
Xharvard			harvard.harvard.edu
Xhusc4			husc4.harvard.edu
Xhusc6			husc6.harvard.edu
Xoddjob			oddjob.uchicago.edu
Xgargoyle		gargoyle.uchicago.edu
Xsphinx			sphinx.uchicago.edu
Xim4u			im4u.utexas.edu
Xius2.cs.cmu.edu		ius2.cs.cmu.edu
Xsei.cmu.edu		sei.cmu.edu
Xj.cc.purdue.edu		j.cc.purdue.edu
Xll-xn			xn.ll.mit.edu
Xmimsy			mimsy.umd.edu
Xmit-amt			media-lab.media.mit.edu
Xmit-athena		athena.mit.edu
Xmit-eddie		eddie.mit.edu
Xmit-hermes		hermes.ai.mit.edu
Xmit-prep		prep.ai.mit.edu
Xmit-trillian		trillian.mit.edu
Xprep.ai.mit.edu		prep.ai.mit.edu
Xpt.cs.cmu.edu		pt.cs.cmu.edu
Xpur-ee			ee.ecn.purdue.edu
Xpurdue			purdue.edu
Xriacs			icarus.riacs.edu
Xrice			rice.edu
Xrochester		cs.rochester.edu
Xrover.ri.cmu.edu	rover.ri.cmu.edu
Xrutgers			rutgers.rutgers.edu
Xsdcsvax			sdcsvax.ucsd.edu
Xspice.cs.cmu.edu	spice.cs.cmu.edu
Xsvax			svax.cs.cornell.edu
Xtalcott			talcott.harvard.edu
Xtopaz			topaz.rutgers.edu
Xucbcad			cad.berkeley.edu
Xucbvax			ucbvax.berkeley.edu
Xucla-cs			locus.ucla.edu
Xuiucdcs			a.cs.uiuc.edu
Xuiucdcsb		b.cs.uiuc.edu
Xuiucdcsc		c.cs.uiuc.edu
Xuiucdcsm		m.cs.uiuc.edu
Xuiucdcsp		p.cs.uiuc.edu
Xuiucuxc			uxc.cso.uiuc.edu
Xumcp-cs			mimsy.umd.edu
Xumd5			umd5.umd.edu
Xoberon			usc-oberon.usc.edu
Xut-ngp			ngp.utexas.edu
Xut-sally		sally.utexas.edu
Xutah-cs			cs.utah.edu
Xutah-gr			gr.utah.edu
Xutastro			astro.as.utexas.edu
Xuw-beaver		beaver.cs.washington.edu
Xuw-june			june.cs.washington.edu
Xuwmacc			unix.macc.wisc.edu
Xuwvax			rsch.wisc.edu
Xwjh12			wjh12.harvard.edu
X
XCS.UCL.AC.UK		cs.ucl.ac.uk
Xcs.ucl.ac.uk		cs.ucl.ac.uk
END_OF_FILE
  if test 3297 -ne `wc -c <'uucp-2-inet'`; then
    echo shar: \"'uucp-2-inet'\" unpacked with wrong size!
  fi
  # end of 'uucp-2-inet'
fi
echo shar: End of archive 4 \(of 4\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still must unpack the following archives:
    echo "        " ${MISSING}
fi
exit 0
exit 0 # Just in case...
