v23i072: Complete reposting of TRN at patchlevel 1, Part13/14

Rich Salz rsalz at bbn.com
Sat Jan 5 08:06:06 AEST 1991


Submitted-by: Wayne Davison <0004475895 at mcimail.com>
Posting-number: Volume 23, Issue 72
Archive-name: trn/part13

#! /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 at uunet.uu.net if you want that tool.
# Contents:  HACKERSGUIDE NEW Pnews.1 Rnmail.1 Wishlist addng.c
#   backpage.c bits.h getactive.c head.h makedepend.SH mt-lint.h
#   ndir.c ndir.h newsetup.1 newsgroups.1 newsgroups.SH ngsrch.c
#   only.c only.h threads.c unipatch.c
# Wrapped by rsalz at litchi.bbn.com on Thu Dec 27 11:34:13 1990
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 13 (of 14)."'
if test -f 'HACKERSGUIDE' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'HACKERSGUIDE'\"
else
  echo shar: Extracting \"'HACKERSGUIDE'\" \(4518 characters\)
  sed "s/^X//" >'HACKERSGUIDE' <<'END_OF_FILE'
XHacking Notes
X
XIf you aren't interested in mucking with the innards of rn, don't read this.
X
XIn the interests of both space and time optimization, things are done inside
Xrn that don't always conform to the highest ideals of programming.  To the
Xextent I felt it was practical, I've tried to conform to good programming
Xpractice, but you must realize that my goal was to make a better mousetrap,
Xso certain conscious tradeoffs were made in the design of rn right from the
Xstart.  In particular, if you want to hack on rn (and I wouldn't blame you,
Xit's fun), beware of the following:
X  
X  * buf and cmd_buf are reused all over the place.  11-squishing is a good
X    term for it.  No, I'm on a Vax now, but I've been there.
X
X  * The article header is parsed on the fly, while it is being displayed.
X    In fact, practically everything is done on the fly within the article
X    display loop, and there are plenty of state variables.  The header
X    is never explicitly stored in memory; rather, pointers are kept into
X    the file.  The information required to backup pages is not stored in
X    memory, except for 1 buffer's worth.  The information required to do
X    the delayed mark as unread (M) is not stored in memory either.
X
X  * Lots of contortions are gone through to avoid using static memory, or
X    allocating unnecessary memory, or losing track of allocated memory,
X    while at the same time allowing .newsrc lines and header lines to be
X    ANY length up to the amount of memory you have.  Rn spends a great deal
X    of effort being lazy.  Do not use a static buffer when you can use
X    growstr().
X
X  * Lots of contortions are gone through to try to do things when people
X    aren't waiting, or have only been waiting a very short time.  Guessing
X    the next article to be opened and opening it, searching ahead for the
X    next article with the same subject, delaying the look up of the number
X    of articles in a newsgroup, writing the rest of the page while the
X    reader is examining the header, cacheing up subjects while the user
X    is reading, checkpointing the .newsrc only while the reader is in the
X    middle of an interesting article, are some of the strategies employed.
X  
X  * There are plenty of goto's.  Most of them involve going back to reprompt,
X    to reask for input, or to just plain do the unstructured things people
X    want to do when they are glaring at a terminal.  If they bother you
X    too much, just think of rn as a big state machine.  If they don't bother
X    you at all, I don't want you hacking on rn.
X
X  * Put all includes at the front of the file, before the first function,
X    or makedepend will not work right.  I could relax this, but makedepend
X    would take about 5 times longer to run.
X
XIn general then, feel free to hack on rn.  Just don't broadcast untested
Xpatches to the net.  Remember that there are people with limited address
Xspaces and limited cpu cycles.  If you add a wonderful new feature and
Xwant to publish a patch, put #ifdef's around it so that people who don't
Xwant it or can't afford it can work around it.  THIS MEANS YOU.  We don't
Xneed 57 varieties of mutually incompatible and incomprehensible rn floating
Xabout the net.  Consider telling me about your patch so that I can consider
Xincluding it in the standard version.  A COMPLETE PATCH TAKES INTO ACCOUNT
XSYSTEM DEPENDENCIES AS DETERMINED BY THE CONFIGURE SCRIPT.
X
X* Don't use ints where rn uses typedefs, in particular, for article numbers.
X* Don't use %d anywhere that someone might need a %ld.  (Just because YOU
X    typedefed it as an int doesn't mean someone else won't need a long.)
X* Don't use %D, that's archaic.
X* Put FLUSHes after printf()s, fputs()es and putchar('\n')s for our poor
X    brethern and sistern without line buffering.
X* Declare the type of every function.  Use void, even if your C compiler
X    doesn't.
X* Follow the style that rn already uses!  This is my pet peeve.  Well, one of
X    them, anyway.  I follow other people's strange styles when modifying
X    their programs, so I'd be much obliged if you did likewise.
X* Use lint.
X* Use RCS.  Start a new branch, like 4.3.[2-9].  (I will use 4.3.1 myself.)
X* Be structured wherever it doesn't interfere with practicality.
X* Long live paranoid programming.  The rest of the program is out to get you.
X    The world is out to destroy the program, not to mention the .newsrc.
X    And then there's always bitrot...
X* Stop reading this lugubrious trash and start thinking for yourself.
X* Thank you and good night.
END_OF_FILE
  if test 4518 -ne `wc -c <'HACKERSGUIDE'`; then
    echo shar: \"'HACKERSGUIDE'\" unpacked with wrong size!
  fi
  # end of 'HACKERSGUIDE'
fi
if test -f 'NEW' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'NEW'\"
else
  echo shar: Extracting \"'NEW'\" \(2877 characters\)
  sed "s/^X//" >'NEW' <<'END_OF_FILE'
X		    NEW FEATURES OF TRN 1.0 vs RN 4.3
X
XNew commands (article level)
X	t		display a map of the thread's article tree.
X	[, ], {, }	move around in the article tree
X	J		junk an entire thread of disucussion regardless of
X			subject changes.
X	T		put the entire thread of discussion in the KILL file
X			(as opposed to the current subject).
X	<, >		move between threads of discussion
X	U		mark some articles as unread again (choose from
X			the current thread, subthread, selected threads, or
X			all articles).
X	e		extract a shar or uuencoded file.
X	:		execute a command on all the selected threads/articles
X
XNew commands (newsgroup level)
X	+		enter a newsgroup through the thread selector.
X	U		enter a newsgroup through the "set unread" prompt.
X
XNew commands (thread selector)
X	[...lots...]	use the thread selector to quickly browse the subjects
X			and/or authors of articles and select only the ones
X			that you want to read.  You can read each one as
X			soon as you select it, or select them all at once.
X			Use the 'h' command to see a command summary, or read
X			the man page for more details.
X
XNew header display:	we display a subset of the thread's article tree in
X			each header.
X
XNew display ordering:	the articles appear in their reply order.
X
XNew switches (default may be on, use +x/+X to turn them off)
X	-x		turn on threaded extensions.
X	-X		use thread selector to enter a group.
X
XNew magic (use +H to turn them off)
X	-Hfrom		displays only the commented portion of the user name.
X	-Hdate		displays the date in local time.
X
XNew environment variables
X	EXSAVER		shell command that starts an extraction.
X	SELECTCHARS	the character set to use to select threads
X			(default:  abcdefgijlorstuvwxz1234567890).
X	UNSHAR		the unshar program to use (default /bin/sh).
X	REPLYTO		the value to use for the "Reply-To:" header, if
X			needed.
X
XNew mode
X	%m=t		when in the thread selector
X
XNew % interpolations
X	%#		keeps an incremental count during a multi-file save,
X			extract, etc.  ":s part.%#"
X	%e		the last command executed to extract an article.
X	%E		The number of extra (unselected) articles, not
X			counting the current article (if selected).
X	%U		same as before (number of unread articles, not counting
X			the current one) but if selections are on, only counts
X			selected articles.
X	%Z		The number of selected threads.
X
XMacros and Keymaps
X	When defining macros, make sure you don't define something that
X	will conflict with the selection characters in the thread selector.
X	An easy way is to exclude the thread selector with a mode test:
X
X		f	%(%m=t?f:|mail smith\n)
X
X	Also, if you want to use one of the selection characters as a
X	command in the thread selector, be sure to exclude it from the
X	list of selection characters in SELECTCHARS (you can define this
X	with -ESELECTCHARS=abc123 in your .rninit file).
X
XMiscellaneous
X	...and much, much more! (including various bug fixes!)
END_OF_FILE
  if test 2877 -ne `wc -c <'NEW'`; then
    echo shar: \"'NEW'\" unpacked with wrong size!
  fi
  # end of 'NEW'
fi
if test -f 'Pnews.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Pnews.1'\"
else
  echo shar: Extracting \"'Pnews.1'\" \(3130 characters\)
  sed "s/^X//" >'Pnews.1' <<'END_OF_FILE'
X''' $Header: Pnews.1,v 4.3.3.1 90/07/21 19:57:23 davison Trn $
X''' 
X''' $Log:	Pnews.1,v $
X''' Revision 4.3.3.1  90/07/21  19:57:23  davison
X''' Initial Trn Release
X''' 
X''' Revision 4.3.1.2  85/08/01  14:22:48  lwall
X''' Added AUTHORCOPY.
X''' 
X''' Revision 4.3.1.1  85/05/10  11:30:30  lwall
X''' Branch for patches.
X''' 
X''' Revision 4.3  85/05/01  11:33:50  lwall
X''' Baseline for release with 4.3bsd.
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 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.
END_OF_FILE
  if test 3130 -ne `wc -c <'Pnews.1'`; then
    echo shar: \"'Pnews.1'\" unpacked with wrong size!
  fi
  # end of 'Pnews.1'
fi
if test -f 'Rnmail.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Rnmail.1'\"
else
  echo shar: Extracting \"'Rnmail.1'\" \(3038 characters\)
  sed "s/^X//" >'Rnmail.1' <<'END_OF_FILE'
X''' $Header: Rnmail.1,v 4.3.3.1 90/07/21 19:57:27 davison Trn $
X''' 
X''' $Log:	Rnmail.1,v $
X''' Revision 4.3.3.1  90/07/21  19:57:27  davison
X''' Initial Trn Release
X''' 
X''' Revision 4.3.1.2  85/08/01  14:22:08  lwall
X''' Added MAILRECORD, DOTDIR.
X''' 
X''' Revision 4.3.1.1  85/05/10  11:30:44  lwall
X''' Branch for patches.
X''' 
X''' Revision 4.3  85/05/01  11:34:28  lwall
X''' Baseline for release with 4.3bsd.
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 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.
END_OF_FILE
  if test 3038 -ne `wc -c <'Rnmail.1'`; then
    echo shar: \"'Rnmail.1'\" unpacked with wrong size!
  fi
  # end of 'Rnmail.1'
fi
if test -f 'Wishlist' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Wishlist'\"
else
  echo shar: Extracting \"'Wishlist'\" \(1595 characters\)
  sed "s/^X//" >'Wishlist' <<'END_OF_FILE'
XGeneralized article set manipulation
X	Interface to subject listing.
X	Recursive newsgroup visitation.
XVirtual article abstract type to allow the following:
X	Personalized header munging via % subs.
X	Undigestification.
X	Personal archive perusal.
X	Mail handling.
XParent command (waiting for ARTFILE interface and recursive newsgroups).
XMerge Pnews and postnews.
XVnews duplicate suppression algorithm for sites that can't do Xref patch.
XDynamic allocation of stuff currently restricted by MAXRCLINE.
X	(And pull parallel arrays into array of structs).
XSeparation of .newsrc functions and newsgroup functions to separate processes
X	communicating via pipes (to make fit on non-separate-I-and-D pdp11,
X	or unreasonable facsimiles thereof).
XFaster!!!
XSmaller!!!
XMore general!!!
XPerfect?
X----------
X			Better NNTP Support
X
XThe current NNTP support requires a duplicate database be maintained on each
Xclient machine.  Currently, this requires each client to run the NNTP version
Xof mthreads to access all the articles headers to create the local copy of the
Xthread database.  There are a number of ways this could be improved:
X
X   o	Create the database on the server host and distribute the finished
X	thread files to all the client hosts at regular intervals using ftp,
X	mail, uucp, etc.
X
X   o	Write an adjunct to NNTP that would serve to distribute thread data.
X
X   o	Cajole the NNTP people to include a command to distribe an authorized
X	list of files other than news articles (e.g. thread files).
X
X   o	Eliminate the need for a thread database.
X
XAll these options are left as an exercise for the reader.
END_OF_FILE
  if test 1595 -ne `wc -c <'Wishlist'`; then
    echo shar: \"'Wishlist'\" unpacked with wrong size!
  fi
  # end of 'Wishlist'
fi
if test -f 'addng.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'addng.c'\"
else
  echo shar: Extracting \"'addng.c'\" \(4510 characters\)
  sed "s/^X//" >'addng.c' <<'END_OF_FILE'
X/* $Header: addng.c,v 4.3.3.2 90/08/20 16:27:06 davison Trn $
X *
X * $Log:	addng.c,v $
X * Revision 4.3.3.2  90/08/20  16:27:06  davison
X * Allow breaking out of ng adding.  Don't add 'X'ed groups.
X * 
X * Revision 4.3.3.1  90/06/20  22:35:43  davison
X * Initial Trn Release
X * 
X * Revision 4.3.2.4  90/03/17  17:11:36  sob
X * Added support for CNEWS active file flags.
X * 
X * Revision 4.3.2.4  89/12/20  00:30:00  tale
X * Added support for C News active file flags.
X *
X * Revision 4.3.2.3  89/11/08  02:33:28  sob
X * Added include for server.h
X * 
X * Revision 4.3.2.2  89/11/08  01:23:49  sob
X * Added GROUP check when SERVER defined.
X * 
X * Revision 4.3.2.1  89/11/06  00:34:11  sob
X * Added RRN support from NNTP 1.5
X * 
X * Revision 4.3.1.2  85/05/29  09:06:24  lwall
X * New newsgroups without spool directories incorrectly classified as "ancient".
X * 
X * Revision 4.3.1.1  85/05/10  11:30:50  lwall
X * Branch for patches.
X * 
X * Revision 4.3  85/05/01  11:34:41  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#include "EXTERN.h"
X#include "common.h"
X#include "rn.h"
X#include "ngdata.h"
X#include "last.h"
X#include "util.h"
X#include "intrp.h"
X#include "only.h"
X#include "rcstuff.h"
X#ifdef SERVER
X#include "server.h"
X#endif
X#include "final.h"
X#include "INTERN.h"
X#include "addng.h"
X
Xvoid
Xaddng_init()
X{
X    ;
X}
X
X#ifdef FINDNEWNG
X/* generate a list of new newsgroups from active file */
X
Xbool
Xnewlist(munged,checkinlist)
Xbool munged;				/* are we scanning the whole file? */
Xbool checkinlist;
X{
X    char *tmpname;
X    register char *s, *status;
X    long birthof();
X
X    tmpname = savestr(filexp("/tmp/rnew.%$"));
X    tmpfp = fopen(tmpname,"w");
X    if (tmpfp == Nullfp) {
X	printf(cantcreate,tmpname) FLUSH;
X	return FALSE;
X    }
X    while (fgets(buf,LBUFLEN,actfp) != Nullch) {
X	/* Check if they want to break out of the new newsgroups search */
X	if (int_count) {
X	    int_count = 0;
X	    return FALSE;
X	}
X	if (s = index(buf,' ')) {
X	    status=s;
X	    while (isdigit(*status) || isspace(*status)) status++;
X	    *s++ = '\0';
X#ifdef USETHREADS
X	    if (strnEQ(buf,"to.",3) || *status == 'x' || *status == 'X'
X				    || *status == '=')
X#else
X	    if (strnEQ(buf,"to.",3) || *status == 'x' || *status == '=')
X#endif
X	        /* since = groups are refiling to another group, just
X		   ignore their existence */
X		continue;
X	    if (find_ng(buf) == nextrcline &&
X		    (checkinlist ?
X			(inlist(buf)) :
X			(birthof(buf,(ART_NUM)atol(s)) > lasttime)
X		    )
X		) {
X					/* if not in .newsrc and younger */
X					/* than the last time we checked */
X		fprintf(tmpfp,"%s\n",buf);
X					/* then remember said newsgroup */
X	    }
X#ifdef FASTNEW
X	    else {			/* not really a new group */
X		if (!munged) {		/* did we assume not munged? */
X		    fclose(tmpfp);	/* then go back, knowing that */
X		    UNLINK(tmpname);
X		    free(tmpname);
X		    return TRUE;	/* active file was indeed munged */
X		}
X	    }
X#endif
X	}
X#ifdef DEBUGGING
X	else
X	    printf("Bad active record: %s\n",buf) FLUSH;
X#endif
X    }
X
X    /* we have successfully generated the list */
X
X    fclose(tmpfp);
X    tmpfp = fopen(tmpname,"r");
X    UNLINK(tmpname);			/* be nice to the world */
X    if (tmpfp == Nullfp) {
X	printf(cantopen,tmpname) FLUSH;
X	return FALSE;
X    }
X    while (fgets(buf,LBUFLEN,tmpfp) != Nullch) {
X	buf[strlen(buf)-1] = '\0';
X	get_ng(buf,TRUE);		/* add newsgroup, maybe */
X    }
X    fclose(tmpfp);			/* be nice to ourselves */
X    free(tmpname);
X    return FALSE;			/* do not call us again */
X}
X
X/* return creation time of newsgroup */
X
Xlong
Xbirthof(ngnam,ngsize)
Xchar *ngnam;
XART_NUM ngsize;
X{
X    char tst[128];
X    long time();
X 
X#ifdef SERVER
X    int x,tot,min,max;
X    if (ngsize < 2) {
X          sprintf(tst,"GROUP %s",ngnam);
X          put_server(tst);
X          (void) get_server(tst, sizeof(tst));
X          if (*tst != CHAR_OK) return(0); /* not a real group */
X          (void) sscanf(tst,"%d%d%d%d",&x,&tot,&min,&max);
X          if (tot == 1 && min == 1 && max == 1) return(time(Null(long *)));
X     } else return(0);
X#else /* not SERVER */
X
X    sprintf(tst, ngsize ? "%s/%s/1" : "%s/%s" ,spool,getngdir(ngnam));
X    if (stat(tst,&filestat) < 0)
X	return (ngsize ? 0L : time(Null(long *)));
X	/* not there, assume something good */
X    else
X	return filestat.st_mtime;
X
X#endif
X}
X
Xbool
Xscanactive()
X{
X    NG_NUM oldnext = nextrcline;	/* remember # lines in newsrc */
X
X    fseek(actfp,0L,0);
X    newlist(TRUE,TRUE);
X    if (nextrcline != oldnext) {	/* did we add any new groups? */
X	return TRUE;
X    }
X    return FALSE;
X}
X
X#endif
X
END_OF_FILE
  if test 4510 -ne `wc -c <'addng.c'`; then
    echo shar: \"'addng.c'\" unpacked with wrong size!
  fi
  # end of 'addng.c'
fi
if test -f 'backpage.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'backpage.c'\"
else
  echo shar: Extracting \"'backpage.c'\" \(2168 characters\)
  sed "s/^X//" >'backpage.c' <<'END_OF_FILE'
X/* $Header: backpage.c,v 4.3.3.1 90/06/20 22:36:17 davison Trn $
X *
X * $Log:	backpage.c,v $
X * Revision 4.3.3.1  90/06/20  22:36:17  davison
X * Initial Trn Release
X * 
X * Revision 4.3  85/05/01  11:36:03  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#include "EXTERN.h"
X#include "common.h"
X#include "intrp.h"
X#include "final.h"
X#include "INTERN.h"
X#include "backpage.h"
X
XART_LINE maxindx = -1;
Xlong lseek();
X
Xvoid
Xbackpage_init()
X{
X    char *varyname;
X    
X    varyname = filexp(VARYNAME);
X    close(creat(varyname,0600));
X    varyfd = open(varyname,2);
X    UNLINK(varyname);
X    if (varyfd < 0) {
X	printf(cantopen,varyname) FLUSH;
X	sig_catcher(0);
X    }
X    
X}
X
X/* virtual array read */
X
XART_POS
Xvrdary(indx)
XART_LINE indx;
X{
X    int subindx;
X    long offset;
X
X#ifdef DEBUGGING
X    if (indx > maxindx) {
X	printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx) FLUSH;
X	return 0;
X    }
X#endif
X    if (indx < 0)
X	return 0;
X    subindx = indx % VARYSIZE;
X    offset = (indx - subindx) * sizeof(varybuf[0]);
X    if (offset != oldoffset) {
X	if (oldoffset >= 0) {
X#ifndef lint
X	    (void)lseek(varyfd,oldoffset,0);
X	    write(varyfd, (char *)varybuf,sizeof(varybuf));
X#endif /* lint */
X	}
X#ifndef lint
X	(void)lseek(varyfd,offset,0);
X	read(varyfd,(char *)varybuf,sizeof(varybuf));
X#endif /* lint */
X	oldoffset = offset;
X    }
X    return varybuf[subindx];
X}
X
X/* write to virtual array */
X
Xvoid
Xvwtary(indx,newvalue)
XART_LINE indx;
XART_POS newvalue;
X{
X    int subindx;
X    long offset;
X
X#ifdef DEBUGGING
X    if (indx < 0)
X	printf("vwtary(%ld)\n",(long)indx) FLUSH;
X    if (!indx)
X	maxindx = 0;
X    if (indx > maxindx) {
X	if (indx != maxindx + 1)
X	    printf("indx skipped %d-%d\n",maxindx+1,indx-1) FLUSH;
X	maxindx = indx;
X    }
X#endif
X    subindx = indx % VARYSIZE;
X    offset = (indx - subindx) * sizeof(varybuf[0]);
X    if (offset != oldoffset) {
X	if (oldoffset >= 0) {
X#ifndef lint
X	    (void)lseek(varyfd,oldoffset,0);
X	    write(varyfd,(char *)varybuf,sizeof(varybuf));
X#endif /* lint */
X	}
X#ifndef lint
X	(void)lseek(varyfd,offset,0);
X	read(varyfd,(char *)varybuf,sizeof(varybuf));
X#endif /* lint */
X	oldoffset = offset;
X    }
X    varybuf[subindx] = newvalue;
X}
X
END_OF_FILE
  if test 2168 -ne `wc -c <'backpage.c'`; then
    echo shar: \"'backpage.c'\" unpacked with wrong size!
  fi
  # end of 'backpage.c'
fi
if test -f 'bits.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bits.h'\"
else
  echo shar: Extracting \"'bits.h'\" \(2052 characters\)
  sed "s/^X//" >'bits.h' <<'END_OF_FILE'
X/* $Header: bits.h,v 4.3.3.1 90/06/20 22:36:35 davison Trn $
X *
X * $Log:	bits.h,v $
X * Revision 4.3.3.1  90/06/20  22:36:35  davison
X * Initial Trn Release
X * 
X * Revision 4.3.1.2  86/11/03  09:49:58  lwall
X * Added firstbit variable.
X * 
X * Revision 4.3.1.1  85/05/10  11:31:52  lwall
X * Branch for patches.
X * 
X * Revision 4.3  85/05/01  11:36:39  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
XEXT char *ctlarea INIT(Nullch);	/* one bit for each article in current newsgroup */
X			/* with the following interpretation: */
X			/*	0 => unread  */
X			/*	1 => read    */
X
X/* if subscripting is faster than shifting on your machine, define this */
X#undef USESUBSCRIPT
X#ifdef USESUBSCRIPT
XEXT char powerof2[] INIT({1,2,4,8,16,32,64,128});
X#define pow2(x) powerof2[x]
X#else
X#define pow2(x) (1 << (x))
X#endif
X
X#ifdef lint
XEXT bool nonesuch INIT(FALSE);
X#define ctl_set(a)
X#define ctl_clear(a)
X#define ctl_read(a) nonesuch
X#define was_read(a) nonesuch
X#else
X#define ctl_set(a) (ctlarea[(OFFSET(a)) / BITSPERBYTE] |= pow2((OFFSET(a)) % BITSPERBYTE))
X#define ctl_clear(a) (ctlarea[(OFFSET(a)) / BITSPERBYTE] &= ~pow2((OFFSET(a)) % BITSPERBYTE))
X#define ctl_read(a) ((ctlarea[(OFFSET(a)) / BITSPERBYTE] & pow2((OFFSET(a)) % BITSPERBYTE)) != 0)
X
X#define was_read(a) ((a)<firstbit || ctl_read(a))
X#endif /* lint */
X
XEXT ART_NUM absfirst INIT(0);	/* 1st real article in current newsgroup */
XEXT ART_NUM firstart INIT(0);	/* minimum unread article number in newsgroup */
XEXT ART_NUM firstbit INIT(0);	/* minimum valid bit, usually == firstart */
XEXT ART_NUM lastart INIT(0);	/* maximum article number in newsgroup */
X
X#ifdef DELAYMARK
XEXT FILE *dmfp INIT(Nullfp);
XEXT char *dmname INIT(Nullch);
XEXT int dmcount INIT(0);
X#endif
X
Xvoid	bits_init();
Xvoid	checkpoint_rc();
Xvoid	restore_ng();
Xvoid	onemore();
Xvoid	oneless();
Xvoid	unmark_as_read();
X#ifdef USETHREADS
Xvoid	set_read();
Xvoid	set_unread();
X#endif
Xvoid	delay_unmark();
Xvoid	mark_as_read();
Xvoid	check_first();
X#ifdef DELAYMARK
X    void	yankback();
X#endif
Xint	chase_xrefs();
Xint	initctl();
Xvoid	grow_ctl();
END_OF_FILE
  if test 2052 -ne `wc -c <'bits.h'`; then
    echo shar: \"'bits.h'\" unpacked with wrong size!
  fi
  # end of 'bits.h'
fi
if test -f 'getactive.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getactive.c'\"
else
  echo shar: Extracting \"'getactive.c'\" \(1826 characters\)
  sed "s/^X//" >'getactive.c' <<'END_OF_FILE'
X/* $Header: getactive.c,v 1.2 89/11/28 01:50:22 sob Locked $
X *
X * $Log:	getactive.c,v $
X * Revision 1.2  89/11/28  01:50:22  sob
X * Changed so that it won't give makedepend problems with SERVER is not defined.
X * 
X * Revision 1.1  89/11/06  00:50:14  sob
X * Initial revision
X * 
X *
X */
X#include <stdio.h>
X#include "config.h"
X#include "EXTERN.h"
X#ifdef SERVER
X#include "server.h"
X#endif
X
Xmain(argc, argv)
X	int		argc;
X	char	 	*argv[];
X{
X	char		ser_line[256];
X	int		response;
X	register char	*server;
X	register FILE	*actfp;
X
X	if (argc != 2) {
X		fprintf(stderr, "Usage: getactive filename\n");
X		exit(1);
X	}
X
X	server = getserverbyfile(SERVER_FILE);
X	if (server == NULL) {
X		fprintf(stderr, "Couldn't get name of news server from %s\n",
X			SERVER_FILE);
X		fprintf(stderr,
X	  "Either fix this file, or put NNTPSERVER in your environment.\n");
X		exit(1);
X	}
X
X	response = server_init(server);
X	if (response < 0) {
X		fprintf(stderr,
X			"getactive: Can't get active file from server %s.\n",
X				server);
X		exit(1);
X	}
X
X	if (handle_server_response(response, server) < 0)
X		exit(1);
X
X	put_server("LIST");	/* tell server we want the active file */
X	(void) get_server(ser_line, sizeof(ser_line));
X	if (*ser_line != CHAR_OK) {		/* and then see if that's ok */
X		fprintf(stderr,
X			"getactive: Can't get active file from server.\n");
X		fprintf(stderr, "Server said: %s\n", ser_line);
X		exit(1);
X	}
X
X	actfp = fopen(argv[1], "w");		/* and get ready */
X	if (actfp == NULL) {
X		close_server();
X		perror(argv[1]);
X		exit(1);
X	}
X
X	while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
X		if (ser_line[0] == '.')		/* there's another line */
X			break;			/* get it and write it to */
X		if (actfp != NULL) {		/* the temporary active file */
X			fputs(ser_line, actfp);
X			putc('\n', actfp);
X		}
X	}
X
X	(void) fclose(actfp);
X	close_server();
X}
END_OF_FILE
  if test 1826 -ne `wc -c <'getactive.c'`; then
    echo shar: \"'getactive.c'\" unpacked with wrong size!
  fi
  # end of 'getactive.c'
fi
if test -f 'head.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'head.h'\"
else
  echo shar: Extracting \"'head.h'\" \(3731 characters\)
  sed "s/^X//" >'head.h' <<'END_OF_FILE'
X/* $Header: head.h,v 4.3.3.1 90/06/20 22:37:18 davison Trn $
X *
X * $Log:	head.h,v $
X * Revision 4.3.3.1  90/06/20  22:37:18  davison
X * Initial Trn Release
X * 
X * Revision 4.3  85/05/01  11:38:31  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#define HEAD_FIRST 1
X
X/* types of header lines (if only C really believed in enums)
X * (These must stay in alphabetic order at least in the first letter.
X * Within each letter it helps to arrange in increasing likelihood.)
X */
X
X#define PAST_HEADER	0	/* body */
X#define SOME_LINE	1	/* unrecognized */
X#define ARTID_LINE	2	/* article-i.d. */
X#define APPR_LINE	3	/* approved */
X#define DIST_LINE	4	/* distribution */
X#define DATE_LINE	5	/* date */
X#define RECEIVED_LINE	6	/* date-received */
X#define EXPIR_LINE	7	/* expires */
X#define FOLLOW_LINE	8	/* followup-to */
X#define FROM_LINE	9	/* from */
X#define KEYW_LINE	10	/* keywords */
X#define LINES_LINE	11	/* lines */
X#define MESSID_LINE	12	/* message-id */
X#define NFFR_LINE	13	/* nf-from */
X#define NFID_LINE	14	/* nf-id */
X#define NGS_LINE	15	/* newsgroups */
X#define ORG_LINE	16	/* organization */
X#define PATH_LINE	17	/* path */
X#define POSTED_LINE	18	/* posted */
X#define PVER_LINE	19	/* posting-version */
X#define REPLY_LINE	20	/* reply-to */
X#define REFS_LINE	21	/* references */
X#define RVER_LINE	22	/* relay-version */
X#define SENDER_LINE	23	/* sender */
X#define SUMRY_LINE	24	/* summary */
X#define SUBJ_LINE	25	/* subject */
X#define XREF_LINE	26	/* xref */
X
X#define HEAD_LAST	27	/* one more than the last one above */
X
Xstruct headtype {
X    char *ht_name;		/* header line identifier */
X#ifdef pdp11
X    short ht_minpos;
X    short ht_maxpos;
X#else
X    ART_POS ht_minpos;		/* pointer to beginning of line in article */
X    ART_POS ht_maxpos;		/* pointer to end of line in article */
X#endif
X    char ht_length;		/* could make these into nybbles but */
X    char ht_flags;		/* it wouldn't save space normally */
X};				/* due to alignment considerations */
X
X#define HT_HIDE 1	/* -h on this line */
X#define HT_MAGIC 2	/* do any special processing on this line */
X
X/* This array must stay in the same order as the list above */
X
X#ifndef DOINIT
XEXT struct headtype htype[HEAD_LAST];
X#else
Xstruct headtype htype[HEAD_LAST] = {
X /* name             minpos   maxpos  length   flag */
X    {"BODY",		0,	0,	4,	0		},
X    {"unrecognized",	0,	0,	12,	0		},
X    {"article-i.d.",	0,	0,	12,	HT_HIDE		},
X    {"approved",	0,	0,	8,	HT_HIDE		},
X    {"distribution",	0,	0,	12,	0		},
X#ifdef USETHREADS
X    {"date",		0,	0,	4,	HT_MAGIC	},
X#else
X    {"date",		0,	0,	4,	0		},
X#endif
X    {"date-received",	0,	0,	13,	0		},
X    {"expires",		0,	0,	7,	HT_HIDE|HT_MAGIC},
X    {"followup-to",	0,	0,	11,	0		},
X    {"from",		0,	0,	4,	HT_MAGIC	},
X    {"keywords",	0,	0,	8,	0		},
X    {"lines",		0,	0,	5,	0		},
X    {"message-id",	0,	0,	10,	HT_HIDE		},
X    {"nf-from",		0,	0,	7,	HT_HIDE		},
X    {"nf-id",		0,	0,	5,	HT_HIDE		},
X    {"newsgroups",	0,	0,	10,	HT_MAGIC|HT_HIDE},
X    {"organization",	0,	0,	12,	0		},
X    {"path",		0,	0,	4,	HT_HIDE		},
X    {"posted",		0,	0,	6,	HT_HIDE		},
X    {"posting-version",	0,	0,	15,	HT_HIDE		},
X    {"reply-to",	0,	0,	8,	HT_HIDE		},
X    {"references",	0,	0,	10,	HT_HIDE		},
X    {"relay-version",	0,	0,	13,	HT_HIDE		},
X    {"sender",		0,	0,	6,	HT_HIDE		},
X    {"summary",		0,	0,	7,	0		},
X    {"subject",		0,	0,	7,	HT_MAGIC	},
X    {"xref",		0,	0,	4,	HT_HIDE		}
X};
X#endif
X
X#ifdef ASYNC_PARSE
XEXT ART_NUM parsed_art INIT(0);
X#endif
X
XEXT char in_header INIT(0);		/* are we decoding the header? */
X
X#ifdef CACHESUBJ
X    EXT char **subj_list INIT(Null(char **));
X#endif
X
Xvoid	head_init();
Xint	set_line_type();
Xvoid	start_header();
Xbool    parseline();
X#ifdef ASYNC_PARSE
X    int		parse_maybe();
X#endif
Xchar	*fetchsubj();
Xchar	*fetchlines();
END_OF_FILE
  if test 3731 -ne `wc -c <'head.h'`; then
    echo shar: \"'head.h'\" unpacked with wrong size!
  fi
  # end of 'head.h'
fi
if test -f 'makedepend.SH' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makedepend.SH'\"
else
  echo shar: Extracting \"'makedepend.SH'\" \(2437 characters\)
  sed "s/^X//" >'makedepend.SH' <<'END_OF_FILE'
Xcase $CONFIG in
X    '') . ./config.sh ;;
Xesac
Xecho "Extracting makedepend (with variable substitutions)"
X$spitshell >makedepend <<!GROK!THIS!
X$startsh
X# $Header: makedepend.SH,v 4.3.3.1 90/06/20 22:38:14 davison Trn $
X#
X# $Log:	makedepend.SH,v $
X# Revision 4.3.3.1  90/06/20  22:38:14  davison
X# Initial Trn Release
X# 
X# Revision 4.3.2.2  90/04/21  14:24:58  sob
X# Added a fix to deal with XENIX cc -E output.
X# 
X# Revision 4.3.2.1  89/12/17  02:52:46  sob
X# Will only read config.sh from local directory.
X# 
X# Revision 4.3.1.2  85/05/13  15:53:42  lwall
X# Made cpp look in /usr/local/include too.
X# 
X# Revision 4.3.1.1  85/05/10  11:35:10  lwall
X# Branch for patches.
X# 
X# Revision 4.3  85/05/01  11:42:26  lwall
X# Baseline for release with 4.3bsd.
X# 
X
Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
X
X$cat /dev/null >.deptmp
X$echo "(Note: this is going to take a while.)"
X$rm -f X*.c
Xfor file in *.c; do
X    filebase=\`basename \$file .c\`
X    $echo "Finding dependencies for \$filebase.o."
X    $sed -n <\$file >X\$file \\
X	-e "/^\${filebase}_init(/q" \\
X	-e '/^#/{' \\
X	-e 's|/\*.*$||' \\
X	-e p \\
X	-e '}'
X    $cpp -I/usr/local/include X\$file | $sed  \\
X	-e '/^# *line/s/line//' \
X	-e '/^# *[0-9]/!d' \\
X	-e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
X	-e 's|: \./|: |' \\
X	-e 's|: X|: |' | \\
X	$uniq | $sort | $uniq >> .deptmp
Xdone
X
Xfor file in *.SH; do
X    $echo \`basename \$file .SH\`: \$file config.sh \; /bin/sh \$file >> .deptmp
Xdone
X
X$sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
X
Xif $test -s .deptmp; then
X    echo "Updating Makefile..."
X    echo "# If this runs make out of memory, delete /usr/include lines." >>Makefile.new
X    $cat .deptmp >>Makefile.new
Xelse
X    $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
X    $egrep '^#include ' *.c *.h >.deptmp
X    echo "Updating Makefile..."
X    <.deptmp $sed -n 's|c:#include "\(.*\)".*\$\$|o: \1|p' >> Makefile.new
X    <.deptmp $sed -n 's|c:#include <\(.*\)>.*\$\$|o: /usr/include/\1|p' >> Makefile.new
X    <.deptmp $sed -n 's|h:#include "\(.*\)".*\$\$|h: \1|p' >> Makefile.new
X    <.deptmp $sed -n 's|h:#include <\(.*\)>.*\$\$|h: /usr/include/\1|p' >> Makefile.new
Xfi
X$mv Makefile Makefile.old
X$mv Makefile.new Makefile
X$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
Xrm .deptmp X*.c
X
X!GROK!THIS!
X$eunicefix makedepend
Xchmod 755 makedepend
END_OF_FILE
  if test 2437 -ne `wc -c <'makedepend.SH'`; then
    echo shar: \"'makedepend.SH'\" unpacked with wrong size!
  fi
  chmod +x 'makedepend.SH'
  # end of 'makedepend.SH'
fi
if test -f 'mt-lint.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mt-lint.h'\"
else
  echo shar: Extracting \"'mt-lint.h'\" \(1453 characters\)
  sed "s/^X//" >'mt-lint.h' <<'END_OF_FILE'
X/* $Header: mt-lint.h,v 4.3.3.1 90/06/20 22:55:11 davison Trn $
X**
X** $Log:	mt-lint.h,v $
X** Revision 4.3.3.1  90/06/20  22:55:11  davison
X** Initial Trn Release
X** 
X** Handle brain-dead lints that only have 6 significant-character names.
X*/
X
X#define subject_cnts		sucnts
X#define subject_array		suarra
X#define subject_strings		sustri
X#define subject_str		sustr
X#define author_cnts		aucnts
X#define author_array		auarra
X#define author_root		auroot
X#define author_str		austr
X#define valid_subject		vsubje
X#define valid_author		vautho
X#define valid_message_id	vmsgid
X#define read_authors		rautho
X#define read_articles		rartic
X#define read_ids		rids
X#define read_item		ritem
X#define processed_groups	pgroup
X#define process_articles	partic
X#define expired_articles	eartic
X#define unlink_child		uchild
X#define unlink_root		uroot
X#define free_article		fartic
X#define free_author		fautho
X#define enumerate_articles	enarti
X#define enumerate_thread	enthrd
X#define string_offset		soffst
X#define write_authors		wautho
X#define write_subjects		wsubje
X#define write_roots		wroots
X#define write_articles		wartic
X#define write_thread		wthred
X#define write_ids		wids
X#define write_item		witem
X#define processed_groups	pgroup
X#define timer_off		timoff
X#define timer_first		tim1st
X#define timer_next		timnxt
X#define truncate_len		trulen
X#define article_array		artarr
X
X#define safemalloc(x)	(NULL)
X#define free(x)		(x = NULL)
X#define Free(x)		(*x = NULL)
X#define signal(x,y)
END_OF_FILE
  if test 1453 -ne `wc -c <'mt-lint.h'`; then
    echo shar: \"'mt-lint.h'\" unpacked with wrong size!
  fi
  # end of 'mt-lint.h'
fi
if test -f 'ndir.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ndir.c'\"
else
  echo shar: Extracting \"'ndir.c'\" \(2251 characters\)
  sed "s/^X//" >'ndir.c' <<'END_OF_FILE'
X/* $Header: ndir.c,v 4.3.3.1 90/06/20 22:38:20 davison Trn $
X *
X * $Log:	ndir.c,v $
X * Revision 4.3.3.1  90/06/20  22:38:20  davison
X * Initial Trn Release
X * 
X * Revision 4.3.1.3  85/05/23  11:19:24  lwall
X * Oops, shouldn't have included sys/types.h again.
X * 
X * Revision 4.3.1.2  85/05/15  14:46:00  lwall
X * Changed short to ino_t, which may be ushort on some systems.
X * 
X * Revision 4.3.1.1  85/05/10  11:35:34  lwall
X * Branch for patches.
X * 
X * Revision 4.3  85/05/01  11:42:55  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#include "EXTERN.h"
X#include "common.h"
X#include "INTERN.h"
X#include "ndir.h"
X
X#ifdef USENDIR
X/*
X * support for Berkeley directory reading routine on a V7 file system
X */
X
X/*
X * open a directory.
X */
XDIR *
Xopendir(name)
Xchar *name;
X{
X	register DIR *dirp;
X	register int fd;
X	char *malloc();
X
X	if ((fd = open(name, 0)) == -1)
X		return NULL;
X	if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
X		close (fd);
X		return NULL;
X	}
X	dirp->dd_fd = fd;
X	dirp->dd_loc = 0;
X	return dirp;
X}
X
X/*
X * read an old style directory entry and present it as a new one
X */
X#ifndef pyr
X#define	ODIRSIZ	14
X
Xstruct	olddirect {
X	ino_t	od_ino;
X	char	od_name[ODIRSIZ];
X};
X#else	an Pyramid in the ATT universe
X#define	ODIRSIZ	248
X
Xstruct	olddirect {
X	long	od_ino;
X	short	od_fill1, od_fill2;
X	char	od_name[ODIRSIZ];
X};
X#endif
X
X/*
X * get next entry in a directory.
X */
Xstruct direct *
Xreaddir(dirp)
Xregister DIR *dirp;
X{
X	register struct olddirect *dp;
X	static struct direct dir;
X
X	for (;;) {
X		if (dirp->dd_loc == 0) {
X			dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
X			    DIRBLKSIZ);
X			if (dirp->dd_size <= 0)
X				return NULL;
X		}
X		if (dirp->dd_loc >= dirp->dd_size) {
X			dirp->dd_loc = 0;
X			continue;
X		}
X		dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
X		dirp->dd_loc += sizeof(struct olddirect);
X		if (dp->od_ino == 0)
X			continue;
X		dir.d_ino = dp->od_ino;
X		strncpy(dir.d_name, dp->od_name, ODIRSIZ);
X		dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
X		dir.d_namlen = strlen(dir.d_name);
X		dir.d_reclen = DIRSIZ(&dir);
X		return (&dir);
X	}
X}
X
X/*
X * close a directory.
X */
Xvoid
Xclosedir(dirp)
Xregister DIR *dirp;
X{
X	close(dirp->dd_fd);
X	dirp->dd_fd = -1;
X	dirp->dd_loc = 0;
X	free(dirp);
X}
X
X#endif /* USENDIR */
END_OF_FILE
  if test 2251 -ne `wc -c <'ndir.c'`; then
    echo shar: \"'ndir.c'\" unpacked with wrong size!
  fi
  # end of 'ndir.c'
fi
if test -f 'ndir.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ndir.h'\"
else
  echo shar: Extracting \"'ndir.h'\" \(1491 characters\)
  sed "s/^X//" >'ndir.h' <<'END_OF_FILE'
X/* $Header: ndir.h,v 4.3.2.1 90/04/17 15:28:13 sob Exp $
X *
X * $Log:	ndir.h,v $
X * Revision 4.3.2.1  90/04/17  15:28:13  sob
X * Altered to include correct directory include file.
X * 
X * Revision 4.3  85/05/01  11:43:00  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#ifdef LIBNDIR
X#   include <ndir.h>
X#else
X#   ifndef USENDIR
X#	include DIRINC
X#   else
X
X#ifndef DEV_BSIZE
X#define	DEV_BSIZE	512
X#endif
X#define DIRBLKSIZ	DEV_BSIZE
X#define	MAXNAMLEN	255
X
Xstruct	direct {
X	long	d_ino;			/* inode number of entry */
X	short	d_reclen;		/* length of this record */
X	short	d_namlen;		/* length of string in d_name */
X	char	d_name[MAXNAMLEN + 1];	/* name must be no longer than this */
X};
X
X/*
X * The DIRSIZ macro gives the minimum record length which will hold
X * the directory entry.  This requires the amount of space in struct direct
X * without the d_name field, plus enough space for the name with a terminating
X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
X */
X#undef DIRSIZ
X#define DIRSIZ(dp) \
X    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
X
X/*
X * Definitions for library routines operating on directories.
X */
Xtypedef struct _dirdesc {
X	int	dd_fd;
X	long	dd_loc;
X	long	dd_size;
X	char	dd_buf[DIRBLKSIZ];
X} DIR;
X#ifndef NULL
X#define NULL 0
X#endif
Xextern	DIR *opendir();
Xextern	struct direct *readdir();
Xextern	long telldir();
Xextern	void seekdir();
X#define rewinddir(dirp)	seekdir((dirp), (long)0)
Xextern	void closedir();
X
X#   endif
X#endif
END_OF_FILE
  if test 1491 -ne `wc -c <'ndir.h'`; then
    echo shar: \"'ndir.h'\" unpacked with wrong size!
  fi
  # end of 'ndir.h'
fi
if test -f 'newsetup.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newsetup.1'\"
else
  echo shar: Extracting \"'newsetup.1'\" \(1599 characters\)
  sed "s/^X//" >'newsetup.1' <<'END_OF_FILE'
X''' $Header: newsetup.1,v 4.3 85/05/01 11:43:22 lwall Exp $
X''' 
X''' $Log:	newsetup.1,v $
X''' Revision 4.3  85/05/01  11:43:22  lwall
X''' Baseline for release with 4.3bsd.
X''' 
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 NEWSETUP 1 LOCAL
X.SH NAME
Xnewsetup - a program to set up a .newsrc file
X.SH SYNOPSIS
X.B newsetup
X.SH DESCRIPTION
XThe
X.I newsetup
Xprogram creates a new .newsrc file containing all of the currently active
Xnewsgroups.
XIt tries to put them in a reasonable order, i.e. local newsgroups earlier,
Xbut you'll probably want to change the ordering anyway (if you use
X.IR rn )
Xin order to put interesting newsgroups first.
XIf you already have a .newsrc, it will be backed up with the name
X\*(L".oldnewsrc\*(R".
X.SH ENVIRONMENT
X.IP DOTDIR 8
XWhere to put your .newsrc, if not in your home directory.
X.Sp
XDefault: $HOME
X.IP HOME 8
XYour home directory.
X.Sp
XDefault: $LOGDIR
X.IP LOGDIR 8
XYour home directory if HOME is undefined.
X.SH FILES
X/usr/lib/news/active or a reasonable facsimile
X.br
X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
X.SH SEE ALSO
Xrn(1), newsrc(5)
X.SH DIAGNOSTICS
X.SH BUGS
END_OF_FILE
  if test 1599 -ne `wc -c <'newsetup.1'`; then
    echo shar: \"'newsetup.1'\" unpacked with wrong size!
  fi
  # end of 'newsetup.1'
fi
if test -f 'newsgroups.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newsgroups.1'\"
else
  echo shar: Extracting \"'newsgroups.1'\" \(1706 characters\)
  sed "s/^X//" >'newsgroups.1' <<'END_OF_FILE'
X''' $Header: newsgroups.1,v 4.3 85/05/01 11:43:32 lwall Exp $
X''' 
X''' $Log:	newsgroups.1,v $
X''' Revision 4.3  85/05/01  11:43:32  lwall
X''' Baseline for release with 4.3bsd.
X''' 
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 NEWSGROUPS 1 LOCAL
X.SH NAME
Xnewsgroups - a program to list unsubscribed newsgroups.
X.SH SYNOPSIS
X.B newsgroups pattern flag
X.SH DESCRIPTION
XThe
X.I newsgroups
Xprogram compares your .newsrc file with the file of active newsgroups,
Xand prints a list of unsubscribed newsgroups matching pattern.
XIf the second argument \*(L"flag\*(R" is present, only newsgroups not
Xfound in your .newsrc are listed, and the display is not paged.
XIf the second argument is missing, the display is paged, and an additional
Xlist of unsubscribed newsgroups occurring in your .newsrc is printed.
X.SH ENVIRONMENT
X.IP DOTDIR 8
XWhere to find your .newsrc, if not in your home directory.
X.Sp
XDefault: $HOME
X.IP HOME 8
XYour home directory.
X.Sp
XDefault: $LOGDIR
X.IP LOGDIR 8
XYour home directory if HOME is undefined.
X.SH FILES
X/usr/lib/news/active or a reasonable facsimile
X.br
X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
X.SH SEE ALSO
Xrn(1), newsrc(5)
X.SH DIAGNOSTICS
X.SH BUGS
XThe flag argument is a kludge.
END_OF_FILE
  if test 1706 -ne `wc -c <'newsgroups.1'`; then
    echo shar: \"'newsgroups.1'\" unpacked with wrong size!
  fi
  # end of 'newsgroups.1'
fi
if test -f 'newsgroups.SH' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newsgroups.SH'\"
else
  echo shar: Extracting \"'newsgroups.SH'\" \(2710 characters\)
  sed "s/^X//" >'newsgroups.SH' <<'END_OF_FILE'
Xcase $CONFIG in
X    '') . ./config.sh ;;
Xesac
Xecho "Extracting newsgroups (with variable substitutions)"
X$spitshell >newsgroups <<!GROK!THIS!
X$startsh
X# $Header: newsgroups.SH,v 4.3.2.7 90/04/23 19:30:41 sob Exp $
X# 
X# $Log:	newsgroups.SH,v $
X# Revision 4.3.2.7  90/04/23  19:30:41  sob
X# Extra space removed to make second part of newsgroups work.
X# Sigh.
X# 
X# Revision 4.3.2.6  90/04/06  20:35:37  sob
X# Added fixes for SCO Xenix sent by ronald at robobar.co.uk.
X# 
X# Revision 4.3.2.5  90/03/17  17:27:00  sob
X# System V sed and BSD sed don't work quite alike. This change uses a
X# syntax that is common between them.
X# 
X# Revision 4.3.2.4  89/11/08  01:13:35  sob
X# Finished modifications to make work with RN and RRN
X# 
X# Revision 4.3.2.3  89/11/07  22:58:04  sob
X# Added final changes to allow rn and rrn to be built from same sources.
X# 
X# Revision 4.3.2.2  89/11/07  22:52:22  sob
X# Added prelimiary support to allow both rrn and rn to be built from same
X# sources.
X# 
X# Revision 4.3.2.1  89/11/06  01:04:39  sob
X# Added RRN support from NNTP 1.5
X# 
X# Revision 4.3  85/05/01  11:43:27  lwall
X# Baseline for release with 4.3bsd.
X# 
X
Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
X
X: syntax: newsgroups [pattern] [pipeflag]
X
X: System Dependencies
X
X: You might want to change pager to a "make column" program if you have one.
X: On the other hand, if your kernel does paging, cat would probably do.
Xpager="${pager-/usr/ucb/more}"
X#NORMALactive="${active-/usr/lib/news/active}"
X
X#NORMALcase \$active in
X#NORMAL~*) active=\`$filexp \$active\` ;;
X#NORMALesac
X
X#NNTPactive="/tmp/active.\$\$"
X
X: End of system dependencies, hopefully
X
X#NNTP$rnlib/getactive \$active
X
Xif $test \$# -ge 2 ; then
X    pager=$cat
Xelse
X    $echo "Completely unsubscribed newsgroups:"
Xfi
X
Xdotdir=\${DOTDIR-\${HOME-\$LOGDIR}}
X
X: Throwing .newsrc into the pot twice is a lovely hack to prevent
X: bogus newsgroups from showing up as unsubscribed.
X
X$cat \$dotdir/.newsrc \$dotdir/.newsrc \$active | \\
X$sed -n	-e '/^options/d' \\
X	-e '/^[	 ]/d' \\
X	-e '/^control/d' \\
X	-e '/^to\./d' \\
X	-e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
X	-e "/.*\$1/p" | \\
X$sort | $uniq -u | \$pager
Xif $test \$# -ge 2 ; then
X    exit
Xfi
X$echo $n "[Type return to continue] $c"
Xread tmp
X$echo ""
X$echo "Unsubscribed but mentioned in .newsrc:"
X$sed -n < \$dotdir/.newsrc \\
X	-e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
X$sort | \$pager
X!GROK!THIS!
Xcase "$isrrn" in
Xdefine)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
X*) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
Xesac
Xmv newsgroups.new newsgroups
X$eunicefix newsgroups
Xchmod 755 newsgroups
END_OF_FILE
  if test 2710 -ne `wc -c <'newsgroups.SH'`; then
    echo shar: \"'newsgroups.SH'\" unpacked with wrong size!
  fi
  chmod +x 'newsgroups.SH'
  # end of 'newsgroups.SH'
fi
if test -f 'ngsrch.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ngsrch.c'\"
else
  echo shar: Extracting \"'ngsrch.c'\" \(2770 characters\)
  sed "s/^X//" >'ngsrch.c' <<'END_OF_FILE'
X/* $Header: ngsrch.c,v 4.3 85/05/01 11:44:51 lwall Exp $
X *
X * $Log:	ngsrch.c,v $
X * Revision 4.3  85/05/01  11:44:51  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#include "EXTERN.h"
X#include "common.h"
X#include "rcstuff.h"
X#include "final.h"
X#include "search.h"
X#include "rn.h"
X#include "util.h"
X#include "term.h"
X#include "rcln.h"
X#include "INTERN.h"
X#include "ngsrch.h"
X
X#ifdef NGSORONLY
X    COMPEX ngcompex;
X#endif
X
Xvoid
Xngsrch_init()
X{
X#ifdef ZEROGLOB
X    init_compex(&ngcompex);
X#endif	/* ZEROGLOB */
X    ;
X}
X
X#ifdef NGSEARCH
Xint
Xng_search(patbuf,get_cmd)
Xchar *patbuf;				/* if patbuf != buf, get_cmd must */
Xint get_cmd;				/*   be set to FALSE!!! */
X{
X    char *pattern;			/* unparsed pattern */
X    register char cmdchr = *patbuf;	/* what kind of search? */
X    register char *s;
X    bool backward = cmdchr == '?';	/* direction of search */
X
X    int_count = 0;
X    if (get_cmd && buf == patbuf)
X	if (!finish_command(FALSE))		/* get rest of command */
X	    return NGS_ABORT;
X    for (pattern = patbuf+1; *pattern == ' '; pattern++) ;
X    if (*pattern) {
X	ng_doread = FALSE;
X    }
X    s = rindex(pattern,cmdchr);
X    if (s != Nullch && *(s-1) != '\\') {
X	*s++ = '\0';
X	if (index(s,'r') != Nullch)
X	    ng_doread = TRUE;
X    }
X    if ((s = ng_comp(&ngcompex,pattern,TRUE,TRUE)) != Nullch) {
X					/* compile regular expression */
X	printf("\n%s\n",s) FLUSH;
X	return NGS_ABORT;
X    }
X    fputs("\nSearching...",stdout) FLUSH;	/* give them something to read */
X    fflush(stdout);
X    for (;;) {
X	if (int_count) {
X	    int_count = 0;
X	    return NGS_INTR;
X	}
X	if (backward) {
X	    if (ng > 0)
X		--ng;
X	    else
X		ng = nextrcline;
X	}
X	else {
X	    if (ng >= nextrcline)
X		ng = 0;
X	    else
X		++ng;
X	}
X	if (ng == current_ng)
X	    return NGS_NOTFOUND;
X	if (ng == nextrcline || toread[ng] < TR_NONE || !ng_wanted())
X	    continue;
X	if (toread[ng] == TR_NONE)
X	    set_toread(ng);
X	
X	if (toread[ng] > TR_NONE)
X	    return NGS_FOUND;
X	else if (toread[ng] == TR_NONE)
X	    if (ng_doread)
X		return NGS_FOUND;
X	    else
X		printf("\n[0 unread in %s--skipping]",rcline[ng]) FLUSH;
X    }
X}
X
Xbool
Xng_wanted()
X{
X    return execute(&ngcompex,rcline[ng]) != Nullch;
X}
X#endif
X
X#ifdef NGSORONLY
Xchar *
Xng_comp(compex,pattern,RE,fold)
XCOMPEX *compex;
Xchar *pattern;
Xbool RE;
Xbool fold;
X{
X    char ng_pattern[128];
X    register char *s = pattern, *d = ng_pattern;
X
X    if (!*s)
X	return Nullch;			/* reuse old pattern */
X    for (; *s; s++) {
X	if (*s == '.') {
X	    *d++ = '\\';
X	    *d++ = *s;
X	}
X	else if (*s == '?') {
X	    *d++ = '.';
X	}
X	else if (*s == '*') {
X	    *d++ = '.';
X	    *d++ = *s;
X	}
X	else if (strnEQ(s,"all",3)) {
X	    *d++ = '.';
X	    *d++ = '*';
X	    s += 2;
X	}
X	else
X	    *d++ = *s;
X    }
X    *d = '\0';
X    return compile(compex,ng_pattern,RE,fold);
X}
X#endif
X
END_OF_FILE
  if test 2770 -ne `wc -c <'ngsrch.c'`; then
    echo shar: \"'ngsrch.c'\" unpacked with wrong size!
  fi
  # end of 'ngsrch.c'
fi
if test -f 'only.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'only.c'\"
else
  echo shar: Extracting \"'only.c'\" \(2362 characters\)
  sed "s/^X//" >'only.c' <<'END_OF_FILE'
X/* $Header: only.c,v 4.3.3.1 90/06/20 22:39:13 davison Trn $
X *
X * $Log:	only.c,v $
X * Revision 4.3.3.1  90/06/20  22:39:13  davison
X * Initial Trn Release
X * 
X * Revision 4.3  85/05/01  11:45:21  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#include "EXTERN.h"
X#include "common.h"
X#include "search.h"
X#include "util.h"
X#include "final.h"
X#include "ngsrch.h"
X#include "INTERN.h"
X#include "only.h"
X
Xvoid
Xonly_init()
X{
X    ;
X}
X
Xvoid
Xsetngtodo(pat)
Xchar *pat;
X{
X    char *s;
X
X#ifdef ONLY
X    if (!*pat)
X	return;
X    if (maxngtodo < NGMAX) {
X	ngtodo[maxngtodo] = savestr(pat);
X#ifdef SPEEDOVERMEM
X#ifndef lint
X	compextodo[maxngtodo] = (COMPEX*)safemalloc(sizeof(COMPEX));
X#endif /* lint */
X	init_compex(compextodo[maxngtodo]);
X	compile(compextodo[maxngtodo],pat,TRUE,TRUE);
X	if ((s = ng_comp(compextodo[maxngtodo],pat,TRUE,TRUE)) != Nullch) {
X					    /* compile regular expression */
X	    printf("\n%s\n",s) FLUSH;
X	    finalize(1);
X	}
X#endif
X	maxngtodo++;
X    }
X#else
X    notincl("o");
X#endif
X}
X
X/* if command line list is non-null, is this newsgroup wanted? */
X
Xbool
Xinlist(ngnam)
Xchar *ngnam;
X{
X#ifdef ONLY
X    register int i;
X#ifdef SPEEDOVERMEM
X
X    if (maxngtodo == 0)
X	return TRUE;
X    for (i=0; i<maxngtodo; i++) {
X	if (execute(compextodo[i],ngnam))
X	    return TRUE;
X    }
X    return FALSE;
X#else
X    COMPEX ilcompex;
X    char *s;
X
X    if (maxngtodo == 0)
X	return TRUE;
X    init_compex(&ilcompex);
X    for (i=0; i<maxngtodo; i++) {
X	if ((s = ng_comp(&ilcompex,ngtodo[i],TRUE,TRUE)) != Nullch) {
X					    /* compile regular expression */
X	    printf("\n%s\n",s) FLUSH;
X	    finalize(1);
X	}
X	
X	if (execute(&ilcompex,ngnam) != Nullch) {
X	    free_compex(&ilcompex);
X	    return TRUE;
X	}
X    }
X    free_compex(&ilcompex);
X    return FALSE;
X#endif
X#else
X    return TRUE;
X#endif
X}
X
X#ifdef ONLY
Xvoid
Xend_only()
X{
X    if (maxngtodo) {			/* did they specify newsgroup(s) */
X	int whicharg;
X
X#ifdef VERBOSE
X	IF(verbose)
X	    printf("\nRestriction %s%s removed.\n",ngtodo[0],
X		maxngtodo > 1 ? ", etc." : nullstr) FLUSH;
X	ELSE
X#endif
X#ifdef TERSE
X	    fputs("\nExiting \"only\".\n",stdout) FLUSH;
X#endif
X	for (whicharg = 0; whicharg < maxngtodo; whicharg++) {
X	    free(ngtodo[whicharg]);
X#ifdef SPEEDOVERMEM
X	    free_compex(compextodo[whicharg]);
X#ifndef lint
X	    free((char*)compextodo[whicharg]);
X#endif /* lint */
X#endif
X	}
X	maxngtodo = 0;
X    }
X}
X#endif
END_OF_FILE
  if test 2362 -ne `wc -c <'only.c'`; then
    echo shar: \"'only.c'\" unpacked with wrong size!
  fi
  # end of 'only.c'
fi
if test -f 'only.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'only.h'\"
else
  echo shar: Extracting \"'only.h'\" \(662 characters\)
  sed "s/^X//" >'only.h' <<'END_OF_FILE'
X/* $Header: only.h,v 4.3 85/05/01 11:45:27 lwall Exp $
X *
X * $Log:	only.h,v $
X * Revision 4.3  85/05/01  11:45:27  lwall
X * Baseline for release with 4.3bsd.
X * 
X */
X
X#ifndef NBRA
X#include "search.h"
X#endif
X
X#ifdef ONLY
X    EXT char *ngtodo[NGMAX];		/* restrictions in effect */
X#   ifdef SPEEDOVERMEM
X	EXT COMPEX *compextodo[NGMAX];	/* restrictions in compiled form */
X#   endif
X#endif
X
XEXT int maxngtodo INIT(0);			/*  0 => no restrictions */
X					/* >0 => # of entries in ngtodo */
X
Xvoid	only_init();
Xbool	inlist();	/* return TRUE if ngname is in command line list */
X			/* or if there was no list */
Xvoid	setngtodo();
X#ifdef ONLY
X    void	end_only();
X#endif
END_OF_FILE
  if test 662 -ne `wc -c <'only.h'`; then
    echo shar: \"'only.h'\" unpacked with wrong size!
  fi
  # end of 'only.h'
fi
if test -f 'threads.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'threads.c'\"
else
  echo shar: Extracting \"'threads.c'\" \(2230 characters\)
  sed "s/^X//" >'threads.c' <<'END_OF_FILE'
X/* $Header: threads.c,v 4.3.3.2 90/08/20 16:49:38 davison Trn $
X**
X** $Log:	threads.c,v $
X** Revision 4.3.3.2  90/08/20  16:49:38  davison
X** Enlarged path buffers to be more consistent.
X** 
X** Revision 4.3.3.1  90/07/21  20:33:23  davison
X** Initial Trn Release
X** 
X*/
X
X#include "EXTERN.h"
X#include "common.h"
X#include "threads.h"
X
X#ifdef USETHREADS
X
X/* Change a newsgroup name into the name of the thread data file.  We
X** subsitute any '.'s in the group name into '/'s (unless LONG_THREAD_NAMES
X** is defined), prepend the path, and append the '/.thread' (or '.th') on to
X** the end.
X*/
Xchar *
Xthread_name( group )
Xchar *group;
X{
X    register char *ptr;
X    static char name_buff[512];
X#ifndef LONG_THREAD_NAMES
X    char group_buff[512];
X
X    strcpy( group_buff, group);
X    ptr = group = group_buff;
X    while( (ptr = index( ptr, '.' )) ) {
X	*ptr = '/';
X    }
X#endif
X#ifdef SUFFIX
X    sprintf( name_buff, "%s/%s%s", THREAD_DIR, group, SUFFIX );
X#else
X    sprintf( name_buff, "%s/%s", THREAD_DIR, group );
X#endif
X
X    return name_buff;
X}
X
X/* Determine this machine's byte map for WORDs and LONGs.  A byte map is an
X** array of BYTEs (sizeof (WORD) or sizeof (LONG) of them) with the 0th BYTE
X** being the byte number of the high-order byte in my <type>, and so forth.
X*/
Xvoid
Xmybytemap( map )
XBMAP *map;
X{
X    union {
X	BYTE b[sizeof (LONG)];
X	WORD w;
X	LONG l;
X    } u;
X    register BYTE *mp;
X    register int i, j;
X
X    mp = &map->w[sizeof (WORD)];
X    u.w = 1;
X    for( i = sizeof (WORD); i > 0; i-- ) {
X	for( j = 0; j < sizeof (WORD); j++ ) {
X	    if( u.b[j] != 0 ) {
X		break;
X	    }
X	}
X	if( j == sizeof (WORD) ) {
X	    goto bad_news;
X	}
X	*--mp = j;
X	while( u.b[j] != 0 && u.w ) {
X	    u.w <<= 1;
X	}
X    }
X
X    mp = &map->l[sizeof (LONG)];
X    u.l = 1;
X    for( i = sizeof (LONG); i > 0; i-- ) {
X	for( j = 0; j < sizeof (LONG); j++ ) {
X	    if( u.b[j] != 0 ) {
X		break;
X	    }
X	}
X	if( j == sizeof (LONG) ) {
X	  bad_news:
X	    /* trouble -- set both to *something* consistent */
X	    for( j = 0; j < sizeof (WORD); j++ ) {
X		map->w[j] = j;
X	    }
X	    for( j = 0; j < sizeof (LONG); j++ ) {
X		map->l[j] = j;
X	    }
X	    return;
X	}
X	*--mp = j;
X	while( u.b[j] != 0 && u.l ) {
X	    u.l <<= 1;
X	}
X    }
X}
X
X#endif /* USETHREADS */
END_OF_FILE
  if test 2230 -ne `wc -c <'threads.c'`; then
    echo shar: \"'threads.c'\" unpacked with wrong size!
  fi
  # end of 'threads.c'
fi
if test -f 'unipatch.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'unipatch.c'\"
else
  echo shar: Extracting \"'unipatch.c'\" \(1358 characters\)
  sed "s/^X//" >'unipatch.c' <<'END_OF_FILE'
X/*
XA filter to turn a unidiff into a degenerate context diff (no '!'s)
Xfor patch. Author: davison at dri.com (uunet!drivax!davison).
X*/
X#include <stdio.h>
X#define ERR(a) {fputs(a,stderr);exit(1);}
Xstruct Ln {
X	struct Ln *lk;
X	char t;
X	char s[1];
X} r,*h,*ln;
Xchar *malloc();
Xmain()
X{
Xchar bf[2048],*cp,ch;
Xlong os,ol,ns,nl,ne,lncnt=0;
Xfor(;;){
X for(;;){
X	if(!fgets(bf,sizeof bf,stdin)) exit(0);
X	lncnt++;
X	if(!strncmp(bf,"@@ -",4)) break;
X	fputs(bf,stdout);
X }
X if(sscanf(bf+4,"%ld,%ld +%ld,%ld %c",&os,&ol,&ns,&nl,&ch)!=5||ch!='@')
X	goto bad;
X r.lk=0, h= &r, ne=ns+nl-1;
X printf("***************\n*** %ld,%ld ****\n",os,os+ol-(os>0));
X while(ol||nl){
X	if(!fgets(bf,sizeof bf,stdin)){
X		if(nl>2) ERR("Unexpected end of file.\n");
X		strcpy(bf," \n");
X	}
X	lncnt++;
X	if(*bf=='\t'||*bf=='\n')
X		ch=' ', cp=bf;
X	else
X		ch= *bf, cp=bf+1;
X	switch(ch){
X	case'-':if(!ol--) goto bad;
X		printf("- %s",cp);
X		break;
X	case'=':ch=' ';
X	case' ':if(!ol--) goto bad;
X		printf("  %s",cp);
X	case'+':if(!nl--) goto bad;
X		ln = (struct Ln*)malloc(sizeof(*ln)+strlen(cp));
X		if(!ln) ERR("Out of memory!\n");
X		ln->lk=0, ln->t=ch, strcpy(ln->s,cp);
X		h->lk=ln, h=ln;
X		break;
X	default:
X	bad:	fprintf(stderr,"Malformed unidiff at line %ld: ",lncnt);
X		ERR(bf);
X	}
X }
X printf("--- %ld,%ld ----\n",ns,ne);
X for(ln=r.lk;ln;ln=h){
X	printf("%c %s",ln->t,ln->s);
X	h=ln->lk;
X	free(ln);
X }
X}
X}
END_OF_FILE
  if test 1358 -ne `wc -c <'unipatch.c'`; then
    echo shar: \"'unipatch.c'\" unpacked with wrong size!
  fi
  # end of 'unipatch.c'
fi
echo shar: End of archive 13 \(of 14\).
cp /dev/null ark13isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still must unpack the following archives:
    echo "        " ${MISSING}
fi
exit 0
exit 0 # Just in case...
-- 
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.



More information about the Comp.sources.unix mailing list