#! /bin/sh
# Make a new directory for the rn sources, cd to it, and run kits 1 thru 11 
# through sh.  When all 11 kits have been run, read README.

echo "This is rn kit 9 (of 11).  If kit 9 is complete, the line"
echo '"'"End of kit 9 (of 11)"'" will echo at the end.'
echo ""
export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
echo Extracting config.h.SH
cat >config.h.SH <<'!STUFFY!FUNK!'
: create config.h file
case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting config.h (with variable substitutions)"
case "$activetimes" in
'none')	acttimes='undef';;
*)	acttimes='define';;
esac
case "$hostfile" in
'')	usehostfile='undef';;
*)	usehostfile='define';;
esac

$sed 's,^#undef,/*#undef,' >config.h <<EOT
/* config.h
 * This file was produced by running the config.h.SH script, which
 * gets its values from config.sh, which is generally produced by
 * running Configure.
 *
 * Feel free to modify any of this as the need arises.  Note, however,
 * that running config.h.SH again will wipe out any changes you've made.
 * For a more permanent change edit config.sh and rerun config.h.SH.
 * $Id: config.h.SH,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: config.h.SH,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 *Release 4.4 Patchlevel 3
 *
 * Revision 4.4.2.1  1991/12/01  18:05:42  sob
 * Fixed problems with CTRLA flag.
 *
 * Revision 4.4  1991/09/09  20:18:23  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

/* name of the site.  May be overridden by HOSTFILE, gethostname, uname, etc. */
#define SITENAME "$sitename"
#$usehostfile HOSTFILE "$hostfile"	/* defined if we read the hostname from a file */

/* domain name for the site */
#define OURDOMAIN "$domain"

/* name of the organization, may be a file name */
#define ORGNAME "$orgname"

/* ignore the ORGANIZATION environment variable */
#$ignoreorg IGNOREORG		/**/

/* login name of news administrator, if any. */
#$isadmin NEWSADMIN "$newsadmin"	/**/

/* news library, may use only ~ and %l expansion */
#define LIB "$lib"

/* rn private library, may use ~ expansion, %x and %l */
#define RNLIB "$rnlib"

/* location of the news spool directory, may use ~ expansion, %x and %l */
#define SPOOL "$spool"

/* location of the active file, may use ~ expansion, %x and %l */
#define ACTIVE "$active"

/* define where the active.times file is kept if we're using it */
#$acttimes ACTIVE_TIMES "$activetimes"	/* including name */

/* location of spooled mail */
#define MAILFILE "$maildir"

/* default shell--ok to be a slow shell like csh */
#define PREFSHELL "$pref"

/* default editor */
#define DEFEDITOR "$defeditor"

/* root uid */
#define ROOTID $rootid

/* what is the first character of a mailbox? */
#define MBOXCHAR '$mboxchar'

/* how to cancel an article */
#define CANCEL "$inews -h <%h"

/* distribution groups */
#define LOCDIST   "$locpref"
#define ORGDIST   "$orgpref"
#define CITYDIST  "$citypref"
#define STATEDIST "$statepref"
#define CNTRYDIST "$cntrypref"
#define CONTDIST  "$contpref"

#$strchr index  strchr		/* cultural */
#$strchr rindex strrchr		/*  differences? */
#$memcpy bcopy(s,d,n) memcpy((char*)d,(char*)s,(int)n)	/* Different */
#$memcpy bzero(d,n)   memset((char*)d,0,(int)n)		/*  flavors. */
#$rename RENAME		/* is rename() a system call? */
#$truncate TRUNCATE	/* is truncate() available? */
#$chsize CHSIZE		/* is chsize() available? */
#$tzset TZSET		/* modern timezone functions? */
#$novoid void int	/* is void to be avoided? */
#$novfork vfork fork	/* is vfork too virtual? */
#$sunos4 SUNOS4		/* running SunOS 4.X? */
#$eunice EUNICE		/* no linking? */
#$eunice VMS		/* not currently used, here just in case */
#$getcwd GETCWD		/* do we have getcwd()? */
#$getwd GETWD		/* do we have getwd()? */
#$usendir USENDIR 	/* include ndir.c? */
#$libndir LIBNDIR 	/* include /usr/include/ndir.h? */
#define DIRTYPE $dirtype
#ifndef USENDIR
#define DIRINC $dirinc
#endif
#$mininact MININACT	/* include 2.10.2 optimization? */
#$portable PORTABLE	/* do we do extra lookups to start up? */
#$passnam PASSNAMES	/* do names come from the passwd file? */
			/*  (undef to take name from ~/.fullname) */
#$berknam BERKNAMES	/* if so, are they Berkeley format? */
			/* (that is, ":name,stuff:") */
#$usgnam USGNAMES	/* or are they USG format? */
			/* (that is, ":stuff-name(stuff):") */
#$whoami WHOAMI		/* should we include whoami.h? */
#$rdchk RDCHK		/* do we have rdchk()? */
#$termio TERMIO		/* is this a termio system? */
#$termios TERMIOS 	/* is this a termios system? */
#$fcntl FCNTL		/* should we include fcntl.h? */
#$ioctl IOCTL		/* are ioctl args all defined in one place? */
#$ptem PTEM		/* has the ptem.h include file ? */
#$normsig NORMSIG 	/* use signal rather than sigset? */
#$sigblock SIGBLOCK	/* use sigblock and sigsetmask */
#$sighold HAVESIGHOLD	/* use sighold and sigrelse */
#define SIGRET $sigret	/* what does signal() return? */
#$havetlib HAVETERMLIB	/* do we have termlib-style routines? */
#$getuidgid GETUIDGID	/* allow setuid (if possible) */
#$getpwent GETPWENT	/* should we include getpwent? */
#$internet INTERNET	/* does our mailer do INTERNET addressing? */
#$gethostname GETHOSTNAME	/* do we have a gethostname function? */
#$douname DOUNAME 	/* do we have a uname function? */
#$phostname PHOSTNAME "$hostcmd"	/* how to get host name with popen */
#$norelay NORELAY 	/* 2.10.3 doesn't have Relay-Version line */
#$isrrn SERVER		/* rrn server code */
#$isrrn SERVER_FILE "$serverfile"	/* news server file */
EOT
!STUFFY!FUNK!
echo Extracting final.c
cat >final.c <<'!STUFFY!FUNK!'
/* $Id: final.c,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: final.c,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 * Release 4.4 Patchlevel 3
 *
 * Revision 4.4.2.1  1991/12/01  18:05:42  sob
 * Patchlevel 2 changes
 *
 * Revision 4.4  1991/09/09  20:18:23  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

#include "EXTERN.h"
#include "common.h"
#include "util.h"
#include "term.h"
#include "ng.h"
#include "init.h"
#include "bits.h"
#include "last.h"
#include "rcstuff.h"
#include "ngdata.h"
#include "artio.h"
#ifdef SERVER
#include "server.h"
#endif
#include "INTERN.h"
#include "final.h"

#ifndef sigmask
#define sigmask(m)	(1 << ((m)-1))
#endif

void
final_init()
{
#ifdef SIGTSTP
    sigset(SIGTSTP, stop_catcher);	/* job control signals */
    sigset(SIGTTOU, stop_catcher);	/* job control signals */
    sigset(SIGTTIN, stop_catcher);	/* job control signals */
#endif

    sigset(SIGINT, int_catcher);	/* always catch interrupts */
#ifdef SIGHUP
    sigset(SIGHUP, sig_catcher);	/* and hangups */
#endif
    sigset(SIGILL, sig_catcher);
#ifdef SIGTRAP
    sigset(SIGTRAP, sig_catcher);
#endif
    sigset(SIGFPE, sig_catcher);
#ifdef SIGBUS
    sigset(SIGBUS, sig_catcher);
#endif
    sigset(SIGSEGV, sig_catcher);
#ifdef SIGSYS
    sigset(SIGSYS, sig_catcher);
#endif
    sigset(SIGTERM, sig_catcher);
#ifdef SIGXCPU
    sigset(SIGXCPU, sig_catcher);
#endif
#ifdef SIGXFSZ
    sigset(SIGXFSZ, sig_catcher);
#endif
#ifdef SIGWINCH
    sigset(SIGWINCH, winch_catcher);
#endif

#ifndef lint
#ifdef SIGEMT
    sigignore(SIGEMT);
#endif
#endif /* lint */
}

void					/* very much void */
finalize(status)
int status;
{
    termlib_reset();
    if (bizarre)
	resetty();
    if (lockname && *lockname)
 	UNLINK(lockname);
#ifdef SERVER
    if (*active_name)
	UNLINK(active_name);
    if (openart) {
 	char artname[MAXFILENAME];
	char intrpwork[MAXFILENAME];
	interp(intrpwork,MAXFILENAME,"%P");
 	sprintf(artname, "%s/rrn%ld.%d", intrpwork, (long)openart, getpid());
 	UNLINK(artname);
    }
    close_server();
#endif /* SERVER */
    if (status < 0) {
	chdir("/usr/tmp");
	sigset(SIGILL,SIG_DFL);
#ifdef SIGBLOCK
	sigsetmask(sigblock(0) & ~(sigmask(SIGILL) | sigmask(SIGIOT)));
#endif
	abort();
    }
    exit(status);
}

/* come here on interrupt */

SIGRET
int_catcher(dummy)
int dummy;
{
    sigset(SIGINT,int_catcher);
#ifdef DEBUGGING
    if (debug)
	write(2,"int_catcher\n",12);
#endif
    if (!waiting) {
	if (int_count) {		/* was there already an interrupt? */
	    write(2,"\nBye-bye.\n",10);
	    sig_catcher(0);		/* emulate the other signals */
	}
	int_count++;
    }
}

/* come here on signal other than interrupt, stop, or cont */

SIGRET
sig_catcher(signo)
int signo;
{
#ifdef VERBOSE
    static char *signame[] = {
	"",
	"HUP",
	"INT",
	"QUIT",
	"ILL",
	"TRAP",
	"IOT",
	"EMT",
	"FPE",
	"KILL",
	"BUS",
	"SEGV",
	"SYS",
	"PIPE",
	"ALRM",
	"TERM",
	"???"
#ifdef SIGTSTP
	,"STOP",
	"TSTP",
	"CONT",
	"CHLD",
	"TTIN",
	"TTOU",
	"TINT",
	"XCPU",
	"XFSZ"
#ifdef SIGPROF
	,"VTALARM",
	"PROF"
#endif
#endif
	};
#endif

#ifdef DEBUGGING
    if (debug) {
	printf("\nSIG%s--.newsrc not restored in debug\n",signame[signo]);
	finalize(-1);
    }
#endif
    if (panic) {
#ifdef SIGBLOCK
      sigsetmask(sigblock(0) & ~(sigmask(SIGILL) | sigmask(SIGIOT)));
#endif
	abort();
      }
    (void) sigset(SIGILL,SIG_DFL);
    panic = TRUE;			/* disable terminal I/O */
    if (doing_ng) {			/* need we reconstitute rc line? */
#ifdef DELAYMARK
	yankback();
#endif
	restore_ng();			/* then do so (hope this works) */
    }
    doing_ng = FALSE;
    if (rc_changed)			/* need we write .newsrc out? */
	write_rc();			/* then do so */
    rc_changed = FALSE;
#ifdef SIGHUP
    if (signo != SIGHUP)
#endif
#ifdef VERBOSE
	IF(verbose)
	    printf("\nCaught %s%s--.newsrc restored\n",
		signo ? "a SIG" : "an internal error", signame[signo]);
	ELSE
#endif
#ifdef TERSE
	    printf("\nSignal %d--bye bye\n",signo);
#endif
    switch (signo) {
#ifdef SIGBUS
    case SIGBUS:
#endif
    case SIGILL:
    case SIGSEGV:
	finalize(-signo);
    }
    finalize(1);				/* and blow up */
}

#ifdef SIGTSTP
/* come here on stop signal */

SIGRET
stop_catcher(signo)
int signo;
{
    if (!waiting) {
	checkpoint_rc();	/* good chance of crash while stopped */
	if (clear_on_stop) {
	    clear();
	    putchar('\n') FLUSH;
	}
	termlib_reset();
	resetty();		/* this is the point of all this */
#ifdef DEBUGGING
	if (debug)
	    write(2,"stop_catcher\n",13);
#endif
	sigset(signo,SIG_DFL);	/* enable stop */
#ifdef SIGBLOCK
	sigsetmask(sigblock(0) & ~(1 << (signo-1)));
#endif
	kill(0,signo);		/* and do the stop */
    	savetty();
#ifdef MAILCALL
    	mailcount = 0;			/* force recheck */
#endif
    	if (!panic) {
	    if (!waiting) {
		termlib_init();
	    	noecho();			/* set no echo */
	    	crmode();			/* set cbreak mode */
	    	forceme("\f");		/* cause a refresh */
					/* (defined only if TIOCSTI defined) */
		errno = 0;			/* needed for getcmd */
	    }
    	}
    }
    sigset(signo,stop_catcher);	/* unenable the stop */
}
#endif
!STUFFY!FUNK!
echo Extracting MANIFEST
cat >MANIFEST <<'!STUFFY!FUNK!'
After all the rn kits are run you should have the following files:

Filename	Kit Description
--------	--- -----------
Configure        2  A shell script that installs everything system dependent.
EXTERN.h        11  When included, makes other includes not belong to me.
HACKERSGUIDE     9  A brief guide to the contorted innards of rn.
INIT             2  Sample system-wide switch file.
INTERN.h        11  When included, makes other includes belong to me.
MANIFEST         9  This list of files.
Makefile.SH      9  The makefile.
NEW              7  List of new features with 4.4 rn.
Pnews.1          9  Manual page for Pnews.
Pnews.SH         6  A news posting shell script that knows about -h.
README           9  Installation instructions.
Rnmail.1         9  Manual page for Rnmail.
Rnmail.SH        8  A mailer that knows about -h.
Wishlist        11  What the next version wants in it.
addng.c          8  Routines for scanning the active file for new newsgroups.
addng.h         11  Public info regarding addng.c.
art.c            5  Routines to display an article.
art.h           11  Public info regarding art.c.
artio.c          9  Reserved for the article abstract type, someday.
artio.h          7  Public info regarding artio.c.
artsrch.c        8  Routines for searching among articles.
artsrch.h       10  Public info regarding artsrch.c.
artstate.h      10  Info on the current state of the article.
autosub.c       10  Routines to allow automatic subscription management
autosub.h       11  Public info regarding autosub.c
backpage.c      10  Routines for paging backwards in articles.
backpage.h       4  Public info regarding backpage.c.
bits.c           6  Bitmap management functions.
bits.h          10  Public info regarding bits.c.
cheat.c          9  Routines to do lookahead of several types.
cheat.h         11  Public info regarding cheat.c.
common.h         4  Global info.
config.h.SH      9  Shell script to create config.h
final.c          9  Finalization (exit) routines.
final.h         10  Public info regarding final.c.
getactive.c     10  Program used by shell scripts to the active file (RRN only)
head.c           8  Header parsing routines.
head.h           9  Public info regarding head.c.
help.c           4  Help routines.
help.h          11  Public info regarding help.c.
init.c           8  Initialization (startup) routines.
init.h          11  Public info regarding init.c.
intrp.c          3  Filename expansion and % interpretation routines.
intrp.h         10  Public info regarding intrp.c.
kfile.c          8  KILL file routines.
kfile.h         10  Public info regarding kfile.c.
kitleader       10  Shell script to produce front of kit.
kitlists.c      10  Knapsack packer.
kittrailer      10  Shell script to produce end of kit.
last.c          10  Routines for handling the .rnlast file.
last.h          10  Public info regarding last.c.
makedepend.SH   10  Shell script to generate make dependencies.
makedir.SH      10  Shell script to make nested subdirectories.
makedist         9  Shell script to make a distribution kit.
makekit         11  Shell script to make a kit file.
manifake        11  Shell script to make MANIFEST.new file.
manimake        11  Shell script to make MANIFEST file.
mbox.saver.SH    2  Shell script to save an article to a mailbox.
ndir.c          10  4.2 directory routine emulation.
ndir.h.SH       10  Shell script to make ndir.h file
newsetup.1      10  Manual page for newsetup.
newsetup.SH      9  Shell script to create a .newsrc file.
newsgroups.1    10  Manual page for newsgroups.
newsgroups.SH    9  Shell script to list unsubscribed newsgroups.
newsnews.SH     10  A motd-like file that rn may print at startup.
ng.c             4  Routines to display a newsgroup.
ng.h            10  Public info regarding ng.c.
ngdata.c         8  General data fetching routines for a newsgroup.
ngdata.h        10  Public info regarding ngdata.c.
ngsrch.c         9  Routines to search among newsgroups.
ngsrch.h        10  Public info regarding ngsrch.c.
ngstuff.c        8  Support routines for ng.c.
ngstuff.h       11  Public info regarding ng.c.
norm.saver.SH   10  Shell script to save an article to a normal file.
only.c          10  Routines to perform newsgroup restriction.
only.h           5  Public info regarding only.c.
patchlevel       1  Indicates current patch level.
range.c          8  Used when rebuilding the rn kit.
rcln.c           7  Routines to mung a .newsrc line.
rcln.h          10  Public info regarding rcln.c.
rcstuff.c        3  Routines to mung the .newsrc file.
rcstuff.h       10  Public info regarding rcstuff.c.
respond.c        6  Various routines for doing things with articles.
respond.h       10  Public info regarding respond.c.
rn.1             1  Manual pages for rn. PLEASE READ.
rn.c             7  Main program.
rn.h            10  Public info regarding rn.c.
search.c         5  Regular expression processing ala emacs.
search.h        10  Public info regarding search.c.
server.h.SH     10  Public info regarding the NNTP clientlib.
sw.c             7  Switch processing routines.
sw.h            11  Public info regarding switch.c.
term.c           5  Terminal interface routines.
term.h           7  Public info regarding term.c.
util.c           3  Utility routines.
util.h          10  Public info regarding util.c.
uudecode.c       6  Decodes uuencoded files.
uudecode.h      11  Public info regarding uudecode.c
!STUFFY!FUNK!
echo Extracting Makefile.SH
cat >Makefile.SH <<'!STUFFY!FUNK!'
case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting Makefile (with variable substitutions)"
$cat >Makefile <<!GROK!THIS!
# $Id: Makefile.SH,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
#
# This software is Copyright 1991 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction of this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 
#
# $Log: Makefile.SH,v $
# Revision 4.4.3.1  1992/02/01  03:09:32  sob
# Release 4.4 Patchlevel 3
#
# Revision 4.4.2.1  1991/12/01  18:05:42  sob
# Changed clientlib to be built in the rn tree instead of the nntp tree.
#
# Revision 4.4.1.1  1991/09/25  19:38:08  sob
# Changed some install directives
#
# Revision 4.4  1991/09/09  20:18:23  sob
# release 4.4
#
#
# 

CC = $cc 
rnbin = $rnbin
rnlib = $rnlib
mansrc = $mansrc
manext = $manext
#NNTPNNTPDIR = $NNTPSRC
#NNTPNNTPINC = $rrninclude
CFLAGS = $posix $iandd $addcflags -O $include
LDFLAGS = $posix $iandd
NDIRC = $ndirc
NDIRO = $ndiro

libs = $ndirlib $termlib $jobslib $socketlib -lm
mlibs = $jobslib
!GROK!THIS!
$cat >>Makefile <<'!NO!SUBS!'
#NNTPnntp=getactive
public = rn newsetup newsgroups Pnews Rnmail
private = norm.saver mbox.saver makedir	filexp Pnews.header $(nntp)
manpages = rn.1 Pnews.1 Rnmail.1 newsetup.1 newsgroups.1
util = Makefile makedepend newsnews


h1 = addng.h art.h artio.h artsrch.h autosub.h backpage.h bits.h cheat.h 
h2 = common.h final.h head.h help.h init.h intrp.h kfile.h last.h 
h3 = ng.h ngdata.h ngsrch.h ngstuff.h only.h rcln.h rcstuff.h
h4 = respond.h rn.h search.h sw.h term.h util.h uudecode.h

h = $(h1) $(h2) $(h3) $(h4)

c1 = addng.c art.c artio.c artsrch.c autosub.c backpage.c bits.c cheat.c
c2 = final.c head.c help.c init.c intrp.c kfile.c last.c $(NDIRC) ng.c
c3 = ngdata.c ngsrch.c ngstuff.c only.c rcln.c rcstuff.c respond.c rn.c
c4 = search.c sw.c term.c util.c uudecode.c
#NNTPc5 = $(NNTPDIR)/common/clientlib.c

c = $(c1) $(c2) $(c3) $(c4) $(c5) 

obj1 = addng.o art.o artio.o artsrch.o autosub.o backpage.o bits.o cheat.o
obj2 = final.o head.o help.o init.o intrp.o kfile.o last.o $(NDIRO) ng.o
obj3 = ngdata.o ngsrch.o ngstuff.o only.o rcln.o rcstuff.o respond.o rn.o
obj4 = search.o sw.o term.o util.o uudecode.o
#NNTPobj5 =  clientlib.o

obj = $(obj1) $(obj2) $(obj3) $(obj4) $(obj5)

lintflags = -phbvxac

add1 = Makefile.old Pnews Rnmail
add2 = bsd config.h config.sh eunice filexp 
add3 = loc makedepend makedir mbox.saver ndir.h newsetup
add4 = newsgroups newsnews norm.saver
add5 = pdp11 usg v7 ultrix sun hp-ux sgi xenix next server.h mips uts DGUX
add6 = all pyr grimble .falseactive Pnews.header s5uniq sigtest stardent

addedbyconf = $(add1) $(add2) $(add3) $(add4) $(add5) $(add6)

# grrr
SHELL = /bin/sh


.c.o:
	$(CC) -c $(CFLAGS) $*.c

all: $(public) $(private) $(util)
	touch all

rn: $(obj)
	$(CC) $(LDFLAGS) $(obj) $(libs) -o rn


#NNTPgetactive: getactive.o clientlib.o
#NNTP	$(CC) $(LDFLAGS) getactive.o clientlib.o -o getactive $(libs)

#NNTPclientlib.o:
#NNTP	$(CC) -c $(CFLAGS) $(NNTPINC) $(NNTPDIR)/common/clientlib.c

# if a .h file depends on another .h file...
$(h):
	touch $@

install: $(public) $(private) $(manpages)
# won't work with csh
	export PATH || exit 1
	- mv $(rnbin)/rn $(rnbin)/rn.old
#NNTP	- ln -s rn $(rnbin)/rrn
	- if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
	- if test `pwd` != $(rnbin); then cd $(rnbin); chmod 755 $(public); strip rn ; fi
	- ./makedir `./filexp $(rnlib)`
	- chmod 755 `./filexp $(rnlib)`
	- if test `pwd` != `./filexp $(rnlib)`; then cp INIT $(private) `./filexp $(rnlib)`; fi
#NNTP	- if test `pwd` != `./filexp $(rnlib)`; then strip `./filexp $(rnlib)`/getactive ; fi
	- if test ! -f `./filexp $(rnlib)/newsnews`; then cp newsnews `./filexp $(rnlib)`; fi
	cd `./filexp $(rnlib)`; chmod 755 $(private); chmod 644 INIT newsnews
	- if test `pwd` != $(mansrc); then \
for page in $(manpages); do \
cp $$page $(mansrc)/`basename $$page .1`.$(manext); \
chmod 444 $(mansrc)/`basename $$page .1`.$(manext); \
done; \
#NNTPecho ".so man$(manext)/rn.$(manext)" > $(mansrc)/rrn.$(manext) ; \
fi

clean:
	rm -f *.o

realclean:
	rm -f rn *.o core $(addedbyconf) 
#NNTP	rm -f clientlib.o getactive

# The following lint has practically everything turned on.  Unfortunately,
# you have to wade through a lot of mumbo jumbo that can't be suppressed.
# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
# for that spot.

lint: lint_rn

lint_rn:
	lint $(lintflags) $(defs) $(c) > rn.fuzz

depend: config.h Makefile
	./makedepend

# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
config.h: config.h.SH config.sh ; sh config.h.SH
Makefile: Makefile.SH config.sh ; sh Makefile.SH
$(obj):
	@ echo "You haven't done a "'"make depend" yet!'; exit 1
!NO!SUBS!
case "$isrrn" in
define)  sed < Makefile -e '/^#NNTP/s/^#NNTP//' > Makefile.new ;;
*) sed < Makefile -e '/^#NNTP/d' > Makefile.new ;;
esac
mv Makefile.new Makefile
$eunicefix Makefile
!STUFFY!FUNK!
echo Extracting artio.c
cat >artio.c <<'!STUFFY!FUNK!'
/* $Id: artio.c,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: artio.c,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 * Release 4.4 Patchlevel 3
 *
 * Revision 4.4  1991/09/09  20:18:23  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

#include "EXTERN.h"
#include "common.h"
#ifdef SERVER
#include "server.h"
#endif
#include "INTERN.h"
#include "artio.h"

void
artio_init()
{
    ;
}

/* open an article, unless it's already open */

FILE *
artopen(artnum)
ART_NUM artnum;
{
#ifdef SERVER
    return nntpopen(artnum,GET_ARTICLE);
#else
    char artname[MAXFILENAME];		/* filename of current article */

    if (artnum < 1)
	return Nullfp;
    if (openart == artnum) {		/* this article is already open? */
	fseek(artfp,0L,0);		/* just get to the beginning */
	return artfp;			/* and say we succeeded */
    }
    if (artfp != Nullfp) {		/* it was somebody else? */
	fclose(artfp);			/* put them out of their misery */
	openart = 0;			/* and remember them no more */
    }
    sprintf(artname,"%ld",(long)artnum);
					/* produce the name of the article */
    if (artfp = fopen(artname,"r"))	/* if we can open it */
	openart = artnum;		/* remember what we did here */
#ifdef LINKART
    {
	char tmpbuf[256];
	char *s;

	if (fstat(fileno(artfp),&filestat))
	    return artfp;
	if (filestat.st_size < (sizeof tmpbuf)) {
	    fgets(tmpbuf,(sizeof tmpbuf),artfp);
	    if (*tmpbuf == '/') {	/* is a "link" to another article */
		fclose(artfp);
		if (s=index(tmpbuf,'\n'))
		    *s = '\0';
		if (!(artfp = fopen(tmpbuf,"r")))
		    openart = 0;
		else {
		    if (*linkartname)
			free(linkartname);
		    linkartname = savestr(tmpbuf);
		}
	    }
	    else
		fseek(artfp,0L,0);		/* get back to the beginning */
	}
    }
#endif
    return artfp;			/* and return either fp or NULL */
#endif /* SERVER */
}

#ifdef SERVER
static long our_pid=0;

FILE *
nntpopen(artnum,function)
ART_NUM artnum;
ART_PART function;
{
    char artname[MAXFILENAME];		/* filename of current article */
    char intrpwork[MAXFILENAME];	/* filename of current article */
    if (our_pid == 0)
	our_pid = getpid();
    if (artnum < 1)
	return Nullfp;
    if ((openart == artnum) && (openpart >= function))
    {					/* this article is already open? */
	fseek(artfp,0L,0);		/* just get to the beginning */
	return artfp;			/* and say we succeeded */
    }
    if (artfp != Nullfp) {		/* it was somebody else? */
	fclose(artfp);			/* put them out of their misery */
	nntpclose();
	openart = 0;			/* and remember them no more */
    }
    interp(intrpwork,MAXFILENAME-1,"%P");
    sprintf(artname,"%s/rrn%ld.%ld", intrpwork,(long) artnum, our_pid);
    artfp = fopen(artname, "w+");	/* create the temporary article */
    if (artfp == Nullfp) {
	UNLINK(artname);
	return Nullfp;
    }
    switch (function){
	    case GET_STATUS:
		function = GET_HEADER;	/* fall through */
	    case GET_HEADER:
		sprintf(ser_line, "HEAD %ld", (long)artnum);
		break;
	    case GET_ARTICLE:
		sprintf(ser_line, "ARTICLE %ld", (long)artnum);
		break;
    }	    
#ifdef DEBUGGING
    if (debug & DEB_NNTP)
	printf(">%s\n", ser_line) FLUSH;
#endif
    put_server(ser_line);		/* ask the server for the article */
    if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
	fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
	finalize(1);
    }
#ifdef DEBUGGING
    if (debug & DEB_NNTP)
	printf("<%s\n", ser_line) FLUSH;
#endif
    if (*ser_line == CHAR_FATAL) {	/* Fatal error */
		fprintf(stderr,"\nrrn: %s\n",ser_line);
		finalize(1);
	}
    if (*ser_line != CHAR_OK) {		/* and get it's reaction */
	fclose(artfp);
	artfp = Nullfp;
	UNLINK(artname);
 	errno = ENOENT;		/* Simulate file-not-found */
        return Nullfp;
    }

    for (;;) {
        if (nntp_get(ser_line, sizeof(ser_line)) < 0) {
	    fprintf(stderr, "\nrrn: Unexpected close of server socket.\n");
	    finalize(1);
	}
	if (ser_line[0] == '.' && ser_line[1] == '\0')
		break;
	fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp);
	putc('\n', artfp);
    }
    openpart = function;
    if (function == GET_HEADER)
	 putc('\n', artfp); /* req'd blank line after header */
    fseek(artfp, 0L, 0);		/* Then get back to the start */
    openart = artnum;
    return artfp;			/* and return either fp or NULL */
}

void
nntpclose()
{
    char artname[MAXFILENAME];		/* filename of current article */
    char intrpwork[MAXFILENAME];	/* filename of current article */
    if (our_pid == 0)
	our_pid = getpid();
    interp(intrpwork,MAXFILENAME-1,"%P");
    sprintf(artname, "%s/rrn%ld.%ld", intrpwork,(long) openart, our_pid);
    UNLINK(artname);
}
#endif
!STUFFY!FUNK!
echo Extracting head.h
cat >head.h <<'!STUFFY!FUNK!'
/* $Id: head.h,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: head.h,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 * Release 4.4 Patchlevel 3
 *
 * Revision 4.4  1991/09/09  20:18:23  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

#define HEAD_FIRST 1

/* types of header lines (if only C really believed in enums)
 * (These must stay in alphabetic order at least in the first letter.
 * Within each letter it helps to arrange in increasing likelihood.)
 */

#define PAST_HEADER	0	/* body */
#define SOME_LINE	1	/* unrecognized */
#define ARTID_LINE	2	/* article-i.d. */
#define APPR_LINE	3	/* approved */
#define ACAT_LINE	4	/* ACategory (ClariNet) */
#define ANPA_LINE	5	/* ANPA (ClariNet) */
#define CODES_LINE	6	/* Codes (ClariNet) */
#define DIST_LINE	7	/* distribution */
#define DATE_LINE	8	/* date */
#define RECEIVED_LINE	9	/* date-received */
#define EXPIR_LINE	10	/* expires */
#define FOLLOW_LINE	11	/* followup-to */
#define FROM_LINE	12	/* from */
#define FORM_LINE	13	/* Format (ClariNet) */
#define KEYW_LINE	14	/* keywords */
#define LINES_LINE	15	/* lines */
#define MESSID_LINE	16	/* message-id */
#define NFFR_LINE	17	/* nf-from */
#define NFID_LINE	18	/* nf-id */
#define NGS_LINE	19	/* newsgroups */
#define NOTE_LINE	20	/* Note (ClariNet) */
#define ORG_LINE	21	/* organization */
#define PATH_LINE	22	/* path */
#define POSTED_LINE	23	/* posted */
#define PVER_LINE	24	/* posting-version */
#define PRI_LINE	25	/* Priority (ClariNet) */
#define REPLY_LINE	26	/* reply-to */
#define REFS_LINE	27	/* references */
#define RVER_LINE	28	/* relay-version */
#define SENDER_LINE	29	/* sender */
#define SUMRY_LINE	30	/* summary */
#define SUBJ_LINE	31	/* subject */
#define SLUG_LINE	32	/* Slugword (ClariNet) */
#define XREF_LINE	33	/* xref */
#define XSUP_LINE	34	/* X-Supersedes (ClariNet) */
#define HEAD_LAST	35	/* one more than the last one above */

struct headtype {
    char *ht_name;		/* header line identifier */
#ifdef pdp11
    short ht_minpos;
    short ht_maxpos;
#else
    ART_POS ht_minpos;		/* pointer to beginning of line in article */
    ART_POS ht_maxpos;		/* pointer to end of line in article */
#endif
    char ht_length;		/* could make these into nybbles but */
    char ht_flags;		/* it wouldn't save space normally */
};				/* due to alignment considerations */

#define HT_HIDE 1	/* -h on this line */
#define HT_MAGIC 2	/* do any special processing on this line */

/* This array must stay in the same order as the list above */

#ifndef DOINIT
EXT struct headtype htype[HEAD_LAST];
#else
struct headtype htype[HEAD_LAST] = {
 /* name             minpos   maxpos  length   flag */
    {"BODY",		0,	0,	4,	0		},
    {"unrecognized",	0,	0,	12,	0		},
    {"article-i.d.",	0,	0,	12,	HT_HIDE		},
    {"approved",	0,	0,	8,	HT_HIDE		},
    {"acategory",	0,	0,	9,	HT_HIDE		},
    {"anpa",		0,	0,	4,	HT_HIDE		},
    {"codes",		0,	0,	5,	HT_HIDE		},
    {"distribution",	0,	0,	12,	0		},
    {"date",		0,	0,	4,	0		},
    {"date-received",	0,	0,	13,	0		},
    {"expires",		0,	0,	7,	HT_HIDE|HT_MAGIC},
    {"followup-to",	0,	0,	11,	0		},
    {"from",		0,	0,	4,	HT_MAGIC	},
    {"format",		0,	0,	6,	HT_HIDE		},
    {"keywords",	0,	0,	8,	0		},
    {"lines",		0,	0,	5,	0		},
    {"message-id",	0,	0,	10,	HT_HIDE		},
    {"nf-from",		0,	0,	7,	HT_HIDE		},
    {"nf-id",		0,	0,	5,	HT_HIDE		},
    {"newsgroups",	0,	0,	10,	HT_MAGIC|HT_HIDE},
    {"note",		0,	0,	4,	0,		},
    {"organization",	0,	0,	12,	0		},
    {"path",		0,	0,	4,	HT_HIDE		},
    {"posted",		0,	0,	6,	HT_HIDE		},
    {"posting-version",	0,	0,	15,	HT_HIDE		},
    {"priority",	0,	0,	8,	HT_HIDE		},
    {"reply-to",	0,	0,	8,	HT_HIDE		},
    {"references",	0,	0,	10,	HT_HIDE		},
    {"relay-version",	0,	0,	13,	HT_HIDE		},
    {"sender",		0,	0,	6,	HT_HIDE		},
    {"summary",		0,	0,	7,	0		},
    {"subject",		0,	0,	7,	HT_MAGIC	},
    {"slugword",	0,	0,	8,	HT_HIDE		},
    {"xref",		0,	0,	4,	HT_HIDE		},
    {"x-supersedes",	0,	0,	12,	HT_HIDE		}
};
#endif

#ifdef ASYNC_PARSE
EXT ART_NUM parsed_art INIT(0);
#endif

EXT char in_header INIT(0);		/* are we decoding the header? */

#ifdef CACHESUBJ
    EXT char **subj_list INIT(Null(char **));
#endif

void	head_init ANSI((void));
int	set_line_type ANSI((char *,char *));
void	start_header ANSI((ART_NUM));
bool    parseline ANSI((char *,int,int));
#ifdef ASYNC_PARSE
    int		parse_maybe ANSI((ART_NUM));
#endif
char	*fetchsubj ANSI((ART_NUM,bool_int,bool_int));
char	*fetchlines ANSI((ART_NUM,int));

#ifdef DEBUGGING
void	dumpheader ANSI((char *));
#endif
!STUFFY!FUNK!
echo Extracting HACKERSGUIDE
cat >HACKERSGUIDE <<'!STUFFY!FUNK!'
Hacking Notes

If you aren't interested in mucking with the innards of rn, don't read this.

In the interests of both space and time optimization, things are done inside
rn that don't always conform to the highest ideals of programming.  To the
extent I felt it was practical, I've tried to conform to good programming
practice, but you must realize that my goal was to make a better mousetrap,
so certain conscious tradeoffs were made in the design of rn right from the
start.  In particular, if you want to hack on rn (and I wouldn't blame you,
it's fun), beware of the following:
  
  * buf and cmd_buf are reused all over the place.  11-squishing is a good
    term for it.  No, I'm on a Vax now, but I've been there.

  * The article header is parsed on the fly, while it is being displayed.
    In fact, practically everything is done on the fly within the article
    display loop, and there are plenty of state variables.  The header
    is never explicitly stored in memory; rather, pointers are kept into
    the file.  The information required to backup pages is not stored in
    memory, except for 1 buffer's worth.  The information required to do
    the delayed mark as unread (M) is not stored in memory either.

  * Lots of contortions are gone through to avoid using static memory, or
    allocating unnecessary memory, or losing track of allocated memory,
    while at the same time allowing .newsrc lines and header lines to be
    ANY length up to the amount of memory you have.  Rn spends a great deal
    of effort being lazy.  Do not use a static buffer when you can use
    growstr(). 

  * Lots of contortions are gone through to try to do things when people
    aren't waiting, or have only been waiting a very short time.  Guessing
    the next article to be opened and opening it, searching ahead for the
    next article with the same subject, delaying the look up of the number
    of articles in a newsgroup, writing the rest of the page while the
    reader is examining the header, cacheing up subjects while the user
    is reading, checkpointing the .newsrc only while the reader is in the
    middle of an interesting article, are some of the strategies employed.
  
  * There are plenty of goto's.  Most of them involve going back to reprompt,
    to reask for input, or to just plain do the unstructured things people
    want to do when they are glaring at a terminal.  If they bother you
    too much, just think of rn as a big state machine.  If they don't bother
    you at all, I don't want you hacking on rn.

  * Put all includes at the front of the file, before the first function,
    or makedepend will not work right.  I could relax this, but makedepend
    would take about 5 times longer to run.

In general then, feel free to hack on rn.  Just don't broadcast untested
patches to the net.  Remember that there are people with limited address
spaces and limited cpu cycles.  If you add a wonderful new feature and
want to publish a patch, put #ifdef's around it so that people who don't
want it or can't afford it can work around it.  THIS MEANS YOU.  We don't
need 57 varieties of mutually incompatible and incomprehensible rn floating
about the net.  Consider telling me about your patch so that I can consider
including it in the standard version.  A COMPLETE PATCH TAKES INTO ACCOUNT
SYSTEM DEPENDENCIES AS DETERMINED BY THE CONFIGURE SCRIPT.

* Don't use ints where rn uses typedefs, in particular, for article numbers.
* Don't use %d anywhere that someone might need a %ld.  (Just because YOU
    typedefed it as an int doesn't mean someone else won't need a long.)
* Don't use %D, that's archaic.
* Put FLUSHes after printf()s, fputs()es and putchar('\n')s for our poor
    brethern and sistern without line buffering.
* Declare the type of every function.  Use void, even if your C compiler
    doesn't.
* Follow the style that rn already uses!  This is my pet peeve.  Well, one of
    them, anyway.  I follow other people's strange styles when modifying
    their programs, so I'd be much obliged if you did likewise.
* Use lint.
* Use RCS.  Start a new branch, like 4.4.[2-9].  (I will use 4.4.1 myself.)
* Be structured wherever it doesn't interfere with practicality.
* Long live paranoid programming.  The rest of the program is out to get you.
    The world is out to destroy the program, not to mention the .newsrc.
    And then there's always bitrot...
* Stop reading this lugubrious trash and start thinking for yourself.
* Thank you and good night.
!STUFFY!FUNK!
echo Extracting Pnews.1
sed >Pnews.1 <<'!STUFFY!FUNK!' -e 's/X//'
X.\" $Id: Pnews.1,v 4.4.3.1 1992/02/01 03:17:20 sob PATCH_3 sob $
X.\" 
X.\" $Log: Pnews.1,v $
X.\" Revision 4.4.3.1  1992/02/01  03:17:20  sob
X.\" Version 4.4 Patchlevel 3
X.\"
X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
X.\" Changed quote macro to "standard" one
X.\"
X.\" Revision 4.4  1991/09/09  20:18:23  sob
X.\" release 4.4
X.\"
X.\" 
X.\" This software is Copyright 1991 by Stan Barber. 
X.\"
X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
X.\" use this software as long as: there is no monetary profit gained
X.\" specifically from the use or reproduction of this software, it is not
X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
X.\" included prominently in any copy made. 
X.\"
X.\" The author make no claims as to the fitness or correctness of this software
X.\" for any use whatsoever, and it is provided as is. Any use of this software
X.\" is at the user's own risk. 
X.\"
X.de Sh
X.br
X.ne 5
X.PP
X\fB\\$1\fR
X.PP
X..
X.de Sp
X.if t .sp .5v
X.if n .sp
X..
X.\"
X.\"     Set up \*(-- to give an unbreakable dash;
X.\"     string Tr holds user defined translation string.
X.\"     Bell System Logo is used as a dummy character.
X.\"
X.ie n \{\
X.tr \(bs-\*(Tr
X.ds -- \(bs-
X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
X.ds L" ""
X.ds R" ""
X.ds L' '
X.ds R' '
X'br\}
X.el\{\
X.ds -- \(em\|
X.tr \*(Tr
X.ds L" ``
X.ds R" ''
X.ds L' `
X.ds R' '
X'br\}
X.TH PNEWS 1 LOCAL
X.SH NAME
XPnews - a program for posting news articles
X.SH SYNOPSIS
X.B Pnews newsgroup title
X.br
X  or
X.br
X.B Pnews -h headerfile [oldarticle]
X.br
X  or
X.br
X.B Pnews
X.SH DESCRIPTION
XPnews is a friendly interface for posting news articles.
XIt will ask several questions, then allow you to enter your article,
Xand then post it using the inews(1) program.
XIf you type h and a carriage return at any point,
X.I Pnews
Xwill tell you what it wants to know.
X.PP
XThe -h form is used when invoked from
X.IR rn .
XIf your editor can edit multiple files, and you want the article to which
Xyou are replying to show up as an alternate file, define the environment
Xvariable NEWSPOSTER as \*(L"Pnews -h %h %A\*(R".
XYou can also modify the the NEWSHEADER environment variable to change the
Xheader file that
X.I rn
Xpasses to Pnews.
X.SH ENVIRONMENT
X.IP AUTHORCOPY 8
XIf defined, contains the name of a file to which the finished article will
Xbe appended.
X.Sp
XDefault: article not saved
X.IP DOTDIR 8
XWhere to find your dot files, if they aren't in your home directory.
XThis is primarily for accounts which are shared by more than one person.
X.Sp
XDefault: $HOME
X.IP EDITOR 8
XThe editor you want to use, if VISUAL is undefined.
X.Sp
XDefault: whatever your news administrator installed, usually vi.
X.IP HOME 8
XYour home directory.
X.Sp
XDefault: $LOGDIR
X.IP LOGDIR 8
XYour home directory if HOME is undefined.
X.IP LOGNAME 8
XYour login name, if USER is undefined.
X.Sp
XDefault: value of \*(L"whoami\*(R".
X.IP NAME 8
XYour full name.
X.Sp
XDefault: name from /etc/passwd, or ~/.fullname.
X.IP NEWSORG 8
XEither the name of your organization, or the name of a file containing the
Xname of your organization. (For use at organizations where the ORGANIZATION
Xenvironmental variable is in use for other purposes). If both NEWSORG and
XORGANIZATION are set, NEWSORG will override ORGANIZATION.
X.IP ORGANIZATION 8
XEither the name of your organization, or the name of a file containing the
Xname of your organization.
X.Sp
XDefault: whatever your news administrator chose.
X.IP REPLYTO 8
XThe contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
X.Sp
XDefault: header line not inserted.
X.IP USER 8
XYour login name.
X.Sp
XDefault: $LOGNAME
X.IP VISUAL 8
XThe editor you want to use.
X.Sp
XDefault: $EDITOR
X.SH FILES
X$DOTDIR/.article
X.br
X~/dead.article
X.SH SEE ALSO
Xrn(1), Rnmail(1), inews(1)
X.SH DIAGNOSTICS
X.SH BUGS
XNot the speediest program in the world, but maybe that's a blessing to the
Xnet.
!STUFFY!FUNK!
echo Extracting Rnmail.1
sed >Rnmail.1 <<'!STUFFY!FUNK!' -e 's/X//'
X.\" $Id: Rnmail.1,v 4.4.3.1 1992/02/01 03:17:20 sob PATCH_3 sob $
X.\" 
X.\" $Log: Rnmail.1,v $
X.\" Revision 4.4.3.1  1992/02/01  03:17:20  sob
X.\" Version 4.4 Patchlevel 3
X.\"
X.\" Revision 4.4.1.1  1991/09/25  19:36:48  sob
X.\" Changed quote macro to "standard" one
X.\"
X.\" Revision 4.4  1991/09/09  20:18:23  sob
X.\" release 4.4
X.\"
X.\" 
X.\" This software is Copyright 1991 by Stan Barber. 
X.\"
X.\" Permission is hereby granted to copy, reproduce, redistribute or otherwise
X.\" use this software as long as: there is no monetary profit gained
X.\" specifically from the use or reproduction of this software, it is not
X.\" sold, rented, traded or otherwise marketed, and this copyright notice is
X.\" included prominently in any copy made. 
X.\"
X.\" The author make no claims as to the fitness or correctness of this software
X.\" for any use whatsoever, and it is provided as is. Any use of this software
X.\" is at the user's own risk. 
X.\"
X.de Sh
X.br
X.ne 5
X.PP
X\fB\\$1\fR
X.PP
X..
X.de Sp
X.if t .sp .5v
X.if n .sp
X..
X.\"
X.\"     Set up \*(-- to give an unbreakable dash;
X.\"     string Tr holds user defined translation string.
X.\"     Bell System Logo is used as a dummy character.
X.\"
X.ie n \{\
X.tr \(bs-\*(Tr
X.ds -- \(bs-
X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
X.ds L" ""
X.ds R" ""
X.ds L' '
X.ds R' '
X'br\}
X.el\{\
X.ds -- \(em\|
X.tr \*(Tr
X.ds L" ``
X.ds R" ''
X.ds L' `
X.ds R' '
X'br\}
X.TH RNMAIL 1 LOCAL
X.SH NAME
XRnmail - a program for replying via mail
X.SH SYNOPSIS
X.B Rnmail destination_list
X.br
X  or
X.br
X.B Rnmail -h headerfile [oldarticle]
X.br
X  or
X.br
X.B Rnmail
X.SH DESCRIPTION
XRnmail is a friendly interface for mailing replies to news articles.
XIt will ask several questions, then allow you to enter your letter,
Xand then mail it off.
XIf you type h and a carriage return at any point,
X.I Rnmail
Xwill tell you what it wants to know.
X.PP
XThe -h form is used when invoked from
X.IR rn .
XIf your editor can edit multiple files, and you want the article to which
Xyou are replying to show up as an alternate file, define the environment
Xvariable MAILPOSTER as \*(L"Rnmail -h %h %A\*(R".
XYou can also modify the the MAILHEADER environment variable to change the
Xheader file that
X.I rn
Xpasses to Rnmail.
X.SH ENVIRONMENT
X.IP DOTDIR 8
XIf defined, specifies a place other than your home directory where 'dot' files
Xmay be stored.
XThis is primarily for accounts which are shared by more than one person.
X.Sp
XDefault: $HOME
X.IP EDITOR 8
XThe editor you want to use, if VISUAL is undefined.
X.Sp
XDefault: whatever your news administrator installed, usually vi.
X.IP HOME 8
XYour home directory.
X.Sp
XDefault: $LOGDIR
X.IP LOGDIR 8
XYour home directory if HOME is undefined.
X.IP LOGNAME 8
XYour login name, if USER is undefined.
X.Sp
XDefault: value of \*(L"whoami\*(R".
X.IP MAILRECORD 8
XIf defined, contains the name of a file to which the finished message will
Xbe appended.
X.Sp
XDefault: message not saved
X.IP NEWSORG 8
XEither the name of your organization, or the name of a file containing the
Xname of your organization. (For use at organizations where the ORGANIZATION
Xenvironmental variable is in use for other purposes). If both NEWSORG and 
XORGANIZATION are set, NEWSORG will override ORGANIZATION.
X.Sp
XDefault: whatever your news administrator chose.
X.IP ORGANIZATION 8
XEither the name of your organization, or the name of a file containing the
Xname of your organization.
X.Sp
XDefault: whatever your news administrator chose.
X.IP REPLYTO 8
XThe contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
X.Sp
XDefault: header line not inserted.
X.IP USER 8
XYour login name.
X.Sp
XDefault: $LOGNAME
X.IP VISUAL 8
XThe editor you want to use.
X.Sp
XDefault: $EDITOR
X.SH FILES
X$DOTDIR/.letter
X.br
X~/dead.letter
X.SH SEE ALSO
Xrn(1), Pnews(1), mail(1)
X.SH DIAGNOSTICS
X.SH BUGS
XUses /bin/mail in the absence of sendmail.
!STUFFY!FUNK!
echo Extracting README
cat >README <<'!STUFFY!FUNK!'
			Rn Kit, Version 4.4

		    Copyright (c) 1985, Larry Wall
                    Copyright (c) 1991, Stan Barber

You may copy the rn kit in whole or in part as long as you don't try to
make money off it, or pretend that you wrote it.
--------------------------------------------------------------------------

Please read all the directions below before you proceed any further, and
then follow them carefully.  Failure to do so may void your warranty. :-)

After you have unpacked your kit, you should have all the files listed
in MANIFEST.

Installation

1)  If you are trying to make it work with NNTP, be sure you have 
    installed the NNTP inews and the file that contains the name of the
    NNTP server. RRN expects that the NNTP is at least version 1.5. You 
    will need the source to nntp, at least the stuff in the common directory.
    Configure will ask for the location of the root of the nntp source tree.


2)  Run Configure.  This will figure out various things about your system.
    Some things Configure will figure out for itself, other things it will
    ask you about.  It will then proceed to make config.h, config.sh, Makefile,
    and a bunch of shell scripts.  It will also do a make depend for you.
    You might possibly have to trim # comments from the front of Configure
    if your sh doesn't handle them, but all other # comments will be taken
    care of. 

3)  Glance through config.h and common.h to make sure system dependencies
    are correct.  Most of them should have been taken care of by running
    the Configure script.

    If you have any additional changes to make to the C definitions, they
    can be done in the Makefile, in config.h, or in common.h.  If you have
    strange mailboxes on your system you should modify mbox.saver to correctly
    append an article to a mailbox or folder.

    If you are on a machine with limited address space, you may have to
    remove some of the special functions of rn to make it fit.  This is
    easily done by undefining symbols in the System Dependencies section
    of common.h.  You should run "make depend" again to be safe.

4)  make

    This will attempt to make rn in the current directory.

5)  make install

    This will put rn, newsetup, newsgroups, Pnews, and Rnmail into a public
    directory (normally /usr/local/bin), and put a number of files into the
    private rn library (normally /usr/lib/news/rn).  It will also try to put
    the man pages in a reasonable place.

6)  Read the manual entry before running rn.  It's quite different from
    readnews.

7)  Try rn, and play with some of the switches.  You may want to make -/
    default on your system.  This is done in common.h.  You may want to modify
    which header lines are displayed by default--this is done in head.h.

    To change default values of enviroment variables on a system-wide basis
    without recompiling rn, put switches into file INIT in the rn library.

8)  IMPORTANT!  Help save the world!  Communicate any problems and
    suggested patches to my faithful servant, rrn@lib.tmc.edu, so we can
    keep the world in sync.  If you have a problem, there's someone else
    out there who either has had or will have the same problem.

    If possible, send in patches such that the patch program will apply them.
    Context diffs are the best, then normal diffs.  Don't send ed scripts--
    I've probably changed my copy since the version you have.

    Watch for rn patches in news.software.readers.  Patches will generally be
    applyable (is that a word?) by the patch program.  If you are just
    now bringing up news and aren't sure how many patches there are, write
    to rrn@lib.tmc.edu and he'll tell you how to get them.

9)  If you are going to hack on rn, please read the HACKERSGUIDE first.
!STUFFY!FUNK!
echo Extracting cheat.c
cat >cheat.c <<'!STUFFY!FUNK!'
/* $Id: cheat.c,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: cheat.c,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 * Release 4.4 Patchlevel 3
 *
 * Revision 4.4.2.1  1991/12/01  18:05:42  sob
 * Patchlevel 2 changes
 *
 * Revision 4.4  1991/09/09  20:18:23  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

#include "EXTERN.h"
#include "common.h"
#include "intrp.h"
#include "search.h"
#include "ng.h"
#include "bits.h"
#include "artio.h"
#include "term.h"
#include "artsrch.h"
#include "head.h"
#include "INTERN.h"
#include "cheat.h"

/* see what we can do while they are reading */

#ifdef PENDING
#   ifdef ARTSEARCH
	COMPEX srchcompex;		/* compiled regex for searchahead */
#   endif
#endif

void
cheat_init()
{
    ;
}

#ifdef PENDING
void
look_ahead()
{
#ifdef ARTSEARCH
    register char *h, *s;

#ifdef DEBUGGING
    if (debug && srchahead) {
	printf("(%ld)",(long)srchahead);
	fflush(stdout);
    }
#endif
    if (srchahead && srchahead < art) {	/* in ^N mode? */
	char *pattern;

	pattern = buf+1;
	strcpy(pattern,": *");
	h = pattern + strlen(pattern);
	interp(h,(sizeof buf) - (h-buf),"%\\s");
	{			/* compensate for notesfiles */
	    register int i;
	    for (i = 24; *h && i--; h++)
		if (*h == '\\')
		    h++;
	    *h = '\0';
	}
#ifdef DEBUGGING
	if (debug & DEB_SEARCH_AHEAD) {
	    fputs("(hit CR)",stdout);
	    fflush(stdout);
	    gets(buf+128);
	    printf("\npattern = %s\n",pattern);
	}
#endif
	if ((s = compile(&srchcompex,pattern,TRUE,TRUE)) != Nullch) {
				    /* compile regular expression */
	    printf("\n%s\n",s);
	    srchahead = 0;
	}
	if (srchahead) {
	    srchahead = art;
	    for (;;) {
		srchahead++;	/* go forward one article */
		if (srchahead > lastart) { /* out of articles? */
#ifdef DEBUGGING
		    if (debug)
			fputs("(not found)",stdout);
#endif
		    break;
		}
		if (!was_read(srchahead) &&
		    wanted(&srchcompex,srchahead,0)) {
				    /* does the shoe fit? */
#ifdef DEBUGGING
		    if (debug)
			printf("(%ld)",(long)srchahead);
#endif
#ifdef SERVER
		    nntpopen(srchahead,GET_HEADER);
#else
		    artopen(srchahead);
#endif
		    break;
		}
		if (input_pending())
		    break;
	    }
	    fflush(stdout);
	}
    }
    else
#endif
    {
	if (art+1 <= lastart)/* how about a pre-fetch? */
#ifdef SERVER
	    nntpopen(art+1,GET_HEADER);	/* look for the next article */
#else
	    artopen(art+1);	/* look for the next article */
#endif
    }
}
#endif

/* see what else we can do while they are reading */

void
collect_subjects()
{
#ifdef PENDING
# ifdef CACHESUBJ
    ART_NUM oldart = openart;
    ART_POS oldartpos;

    if (!in_ng || !srchahead)
	return;
    if (oldart)			/* remember where we were in art */
	oldartpos = ftell(artfp);
    if (srchahead >= subj_to_get)
	subj_to_get = srchahead+1;
    while (!input_pending() && subj_to_get <= lastart)
	fetchsubj(subj_to_get++,FALSE,FALSE);
    if (oldart) {
	artopen(oldart);
	fseek(artfp,oldartpos,0);	/* do not screw the pager */
    }
# endif
#endif
}

!STUFFY!FUNK!
echo Extracting ngsrch.c
cat >ngsrch.c <<'!STUFFY!FUNK!'
/* $Id: ngsrch.c,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
 *
 * $Log: ngsrch.c,v $
 * Revision 4.4.3.1  1992/02/01  03:09:32  sob
 * Release 4.4 Patchlevel 3
 *
 * Revision 4.4  1991/09/09  20:23:31  sob
 * release 4.4
 *
 *
 * 
 */
/* This software is Copyright 1991 by Stan Barber. 
 *
 * Permission is hereby granted to copy, reproduce, redistribute or otherwise
 * use this software as long as: there is no monetary profit gained
 * specifically from the use or reproduction of this software, it is not
 * sold, rented, traded or otherwise marketed, and this copyright notice is
 * included prominently in any copy made. 
 *
 * The author make no claims as to the fitness or correctness of this software
 * for any use whatsoever, and it is provided as is. Any use of this software
 * is at the user's own risk. 
 */

#include "EXTERN.h"
#include "common.h"
#include "rcstuff.h"
#include "final.h"
#include "search.h"
#include "rn.h"
#include "util.h"
#include "term.h"
#include "rcln.h"
#include "INTERN.h"
#include "ngsrch.h"

#ifdef NGSORONLY
    COMPEX ngcompex;
#endif

void
ngsrch_init()
{
#ifdef ZEROGLOB
    init_compex(&ngcompex);
#endif	/* ZEROGLOB */
    ;
}

#ifdef NGSEARCH
int
ng_search(patbuf,get_cmd)
char *patbuf;				/* if patbuf != buf, get_cmd must */
int get_cmd;				/*   be set to FALSE!!! */
{
    char *pattern;			/* unparsed pattern */
    register char cmdchr = *patbuf;	/* what kind of search? */
    register char *s;
    bool backward = cmdchr == '?';	/* direction of search */

    int_count = 0;
    if (get_cmd && buf == patbuf)
	if (!finish_command(FALSE))		/* get rest of command */
	    return NGS_ABORT;
    for (pattern = patbuf+1; *pattern == ' '; pattern++) ;
    if (*pattern) {
	ng_doread = FALSE;
    }
    s = rindex(pattern,cmdchr);
    if (s != Nullch && *(s-1) != '\\') {
	*s++ = '\0';
	if (index(s,'r') != Nullch)
	    ng_doread = TRUE;
    }
    if ((s = ng_comp(&ngcompex,pattern,TRUE,TRUE)) != Nullch) {
					/* compile regular expression */
	printf("\n%s\n",s) FLUSH;
	return NGS_ERROR;
    }
    fputs("\nSearching...",stdout) FLUSH;	/* give them something to read */
    fflush(stdout);
    for (;;) {
	if (int_count) {
	    int_count = 0;
	    return NGS_INTR;
	}
	if (backward) {
	    if (ng > 0)
		--ng;
	    else
		ng = nextrcline;
	}
	else {
	    if (ng >= nextrcline)
		ng = 0;
	    else
		++ng;
	}
	if (ng == current_ng)
	    return NGS_NOTFOUND;
	if (ng == nextrcline || toread[ng] < TR_NONE || !ng_wanted())
	    continue;
	if (toread[ng] == TR_NONE)
	    set_toread(ng);
	
	if (toread[ng] > TR_NONE)
	    return NGS_FOUND;
	else if (toread[ng] == TR_NONE)
	    if (ng_doread)
		return NGS_FOUND;
	    else
		printf("\n[0 unread in %s--skipping]",rcline[ng]) FLUSH;
    }
}

bool
ng_wanted()
{
    return execute(&ngcompex,rcline[ng]) != Nullch;
}
#endif

#ifdef NGSORONLY
char *
ng_comp(compex,pattern,RE,fold)
COMPEX *compex;
char *pattern;
bool_int RE;
bool_int fold;
{
    char ng_pattern[128];
    register char *s = pattern, *d = ng_pattern;

    if (!*s) {
	if(compex->expbuf)
	    return Nullch;			/* reuse old pattern */
	else
	    return "No previous search pattern";
    }
    for (; *s; s++) {
	if (*s == '.') {
	    *d++ = '\\';
	    *d++ = *s;
	}
	else if (*s == '?') {
	    *d++ = '.';
	}
	else if (*s == '*') {
	    *d++ = '.';
	    *d++ = *s;
	}
	else if (strnEQ(s,"all",3)) {
	    *d++ = '.';
	    *d++ = '*';
	    s += 2;
	}
	else
	    *d++ = *s;
    }
    *d = '\0';
    return compile(compex,ng_pattern,RE,fold);
}
#endif

!STUFFY!FUNK!
echo Extracting newsetup.SH
cat >newsetup.SH <<'!STUFFY!FUNK!'
case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting newsetup (with variable substitutions)"
$spitshell >newsetup <<!GROK!THIS!
$startsh
#
# $Id: newsetup.SH,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
# 
# $Log: newsetup.SH,v $
# Revision 4.4.3.1  1992/02/01  03:09:32  sob
# Release 4.4 Patchlevel 3
#
# Revision 4.4.2.1  1991/12/01  18:05:42  sob
# Fixed problems with CTRLA flag.
#
# Revision 4.4.1.2  1991/11/09  20:54:14  sob
# Changes from eggert@twinsun.com to get rid of old code.
#
# Revision 4.4.1.1  1991/09/25  19:38:08  sob
# various fixed
#
# Revision 4.4  1991/09/09  20:23:31  sob
# release 4.4
#
#
# 
# This software is Copyright 1991 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction of this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)

: syntax: newsetup

: System dependencies
: You will want to change the definitions below to reflect the distribution
: areas around you.  If you have more areas than this you will need to modify
: the sed below.

locorg="$locpref"
organization="$orgpref"
city="$citypref"
state="$statepref"
cntry="$cntrypref"
cont="$contpref"
#NORMALactive="${active-/usr/lib/news/active}"
#NNTPactive="/tmp/active.\$\$"

dotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
newsrc="\${NEWSRC-\$dotdir/.newsrc}"
$rm -f \$newsrc-old
$echo "Creating \$newsrc to be used by news programs."
#NNTPrnlib=$rnlib
#NNTPcase \$rnlib in
#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
#NNTPesac
#NNTPif \$rnlib/getactive ACTIVE \$active; then
#NNTP    true;
#NNTPelse
#NNTP    exit 1;
#NNTPfi
#NORMALcase \$active in
#NORMAL~*) active=\`$filexp \$active\` ;;
#NORMALesac

if $test -s \$newsrc ; then
    $echo "Saving your current \$newsrc as \$newsrc-old..."
    $mv -f \$newsrc \$newsrc-old
fi

: newsrc order determined here

$sed <\$active '
	/^to\./d
	/ [^mny][^ ]*$/d
	s/ .*//
	s/^/ /
	s/^ '\$locorg'\./01&/
	s/^ '\$organization'\./02&/
	s/^ '\$city'\./03&/
	s/^ '\$state'\./04&/
	s/^ '\$cntry'\./05&/
	s/^ '\$cont'\./06&/
	s/^ news\./07&/
	s/^ comp\./08&/
	s/^ sci\./09&/
	s/^ rec\./10&/
	s/^ soc\./11&/
	s/^ talk\./13&/
	s/^ control\$/14&/
	s/^ junk\$/14&/
	s/^ test\$/14&/
	/\.test\$/s/^[0-9]*/14/
	s/^ .*\./12&/
	s/^ /00&/
' |
$sort -u |
$sed '
	/^14 /!s/\$/:/
	/^14 /s/\$/!/
	s/^[0-9][0-9] //
' >\$newsrc

#NNTP$rm -f \$active

$cat <<'EOH'
Done.

If you have never used the news system before, you may find the articles
in news.announce.newusers to be helpful.  There is also a manual entry for rn.

To get rid of newsgroups you aren't interested in, use the 'u' command.
Type h for help at any time while running rn.
EOH
!GROK!THIS!
case "$isrrn" in
define)  sed < newsetup -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsetup.new ;;
*) sed < newsetup -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsetup.new ;;
esac
mv newsetup.new newsetup
$eunicefix newsetup
chmod 755 newsetup
!STUFFY!FUNK!
echo Extracting newsgroups.SH
cat >newsgroups.SH <<'!STUFFY!FUNK!'
case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting newsgroups (with variable substitutions)"
$spitshell >newsgroups <<!GROK!THIS!
$startsh
# $Id: newsgroups.SH,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
# 
# $Log: newsgroups.SH,v $
# Revision 4.4.3.1  1992/02/01  03:09:32  sob
# Release 4.4 Patchlevel 3
#
# Revision 4.4.2.1  1991/12/01  18:05:42  sob
# Patchlevel 2 changes
#
# Revision 4.4.1.1  1991/09/25  19:38:08  sob
# various fixed
#
# Revision 4.4  1991/09/09  20:23:31  sob
# release 4.4
#
# 
# This software is Copyright 1991 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction of this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 

export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)

: syntax: newsgroups [pattern] [pipeflag]

: System Dependencies

: You might want to change pager to a "make column" program if you have one.
: On the other hand, if your kernel does paging, cat would probably do.
pager="${pager-/usr/ucb/more}"
#NORMALactive="${active-/usr/lib/news/active}"

#NORMALcase \$active in
#NORMAL~*) active=\`$filexp \$active\` ;;
#NORMALesac

#NNTPactive="/tmp/active.\$\$"

#NNTPcase \$rnlib in
#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
#NNTPesac

: End of system dependencies, hopefully

#NNTPif $rnlib/getactive ACTIVE \$active; then
#NNTP    true;
#NNTPelse
#NNTP    exit 1;
#NNTPfi

if $test \$# -ge 2 ; then
    pager=$cat
else
    $echo "Completely unsubscribed newsgroups:"
fi

dotdir=\${DOTDIR-\${HOME-\$LOGDIR}}
newsrc=\${NEWSRC-\$dotdir/.newsrc}

: Throwing .newsrc into the pot twice is a lovely hack to prevent
: bogus newsgroups from showing up as unsubscribed.

$cat \$newsrc \$newsrc \$active | \\
$sed -n	-e '/^options/d' \\
	-e '/^[	 ]/d' \\
	-e '/^control/d' \\
	-e '/^to\./d' \\
 	-e '/ x\$/d' \\
	-e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
	-e "/.*\$1/p" | \\
$sort | $uniq -u | \$pager
#NNTP$rm -f \$active
if $test \$# -ge 2 ; then
    exit
fi
$echo $n "[Type return to continue] $c"
read tmp
$echo ""
$echo "Unsubscribed but mentioned in \$newsrc:"
$sed -n < \$newsrc \\
	-e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
$sort | \$pager
!GROK!THIS!
case "$isrrn" in
define)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
*) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
esac
mv newsgroups.new newsgroups
$eunicefix newsgroups
chmod 755 newsgroups
!STUFFY!FUNK!
echo Extracting makedist
cat >makedist <<'!STUFFY!FUNK!'
#!/bin/sh
# $Id: makedist,v 4.4 1991/09/09 20:23:31 sob Exp sob $
#
# $Log: makedist,v $
# Revision 4.4  1991/09/09  20:23:31  sob
# release 4.4
#
#
# 

rm -f kit*.list
manifake
kitlists
manimake
makekit kit*.list
!STUFFY!FUNK!
echo ""
echo "End of kit 9 (of 11)"
cat /dev/null >kit9isdone
config=true
for iskit in 1 2 3 4 5 6 7 8 9 10 11 ; do
    if test -f kit${iskit}isdone; then
	echo "You have run kit ${iskit}."
    else
	echo "You still need to run kit ${iskit}."
	config=false
    fi
done
case $config in
    true)
	echo "You have run all your kits.  Please read README and then type Configure."
	chmod 755 Configure
	;;
esac
: I do not append .signature, but someone might mail this.
exit
