[alt.sources] Rich $alz's cshar package, new alpha release, Part01/05

rsalz@bbn.com (Rich Salz) (02/21/89)

This is what I use to create shell archives of small-to-humongous source
distributions.  Hope you find it useful.  Hope you find bugs, and send
them to me.  This will appear in comp.sources.unix after the bug reports
die down.  It runs on all sort of Unix machines, and a raft of other OS's,
too.

For more details, see the README file in the first shar.

Please don't pass this version around, wait for the "REAL" one.
	/rich $alz

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 5)."
# Contents:  MANIFEST README dirami.c dirami.h dirmsd.h dodoc.sh
#   findsrc.man glue.c lcwd.c lexec.c lhost.c lmem.c luser.c
#   manipull.man parser.h patchlog.h shar.man shell.c shell.man
#   unshar.man uudecode.man uuencode.c uuencode.man
# Wrapped by rsalz@fig.bbn.com on Mon Feb 20 18:15:28 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(2828 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   3	Control file for Unix make program
X README                     1	Acknowledgements, installation notes
X config.3b1                 3	Configuration for 3B1 machine
X config.5r3                 2	Configuration for System V rel 3.1 and 3.2
X config.bsd                 3	Configuration for BSD/Ultrix/Sun
X config.dos                 3	Configuration for MS-DOS (Microsoft C5.1)
X config.hpx                 3	Configuration for HP-UX 9000/300 9000/500
X config.vms                 2	Configuration for VMS
X config.x38                 3	configuration for Xenix on a 386
X dirami.c                   1	A partial Amiga readdir package
X dirami.h                   1	An <ndir.h> file for the Amiga
X dirmsd.c                   2	An MS-DOS readdir package
X dirmsd.h                   1	An <ndir.h> file for MS-DOS
X dodoc.sh                   1	Create formatted manpages
X findsrc.c                  3	Find source files, based on filename
X findsrc.man                1	Manual page for findsrc
X glue.c                     1	Glue that so unshar uses my /bin/sh parser
X lcwd.c                     1	Routines to find current directory
X lexec.c                    1	Fork, exec, system, signal, etc., routines
X lfiles.c                   2	File size and type routines
X lhost.c                    1	Find our machine name
X llib.c                     2	Stuff that should be in your C library
X lmem.c                     1	Memory allocator, uses calloc
X luser.c                    1	Get user's name
X makekit.c                  4	Partition files into reasonable-sized kits
X makekit.man                2	Manual page for makekit
X manipull.c                 2	Pull entries from a manifest
X manipull.man               1	Manual page for manipull
X maniscan.c                 4	Scan manifests for big or binary files
X maniscan.man               2	Manual page for maniscan
X parser.c                   5	Interpreter for shell archives
X parser.h                   1	Header file for archive interpreter
X patchlog.h                 1	Mistake recorder
X shar.c                     4	Create script to create files
X shar.h                     2	Header file, used by everyone
X shar.man                   1	Manual page for makekit
X shell.c                    1	Main routine for my shell interpreter
X shell.man                  1	Manual page for shell
X unshar.c                   4	Strip news, notes, mail headers from shar's
X unshar.man                 1	Manual page for unshar
X uudecode.c                 2	Printable->binary converter
X uudecode.man               1	Manual page for uudecode
X uuencode.c                 1	Binary->printable converter
X uuencode.man               1	Manual page for uuencode
END_OF_FILE
if test 2828 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(8473 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X ******************************************************************************
X * THIS IS AN ALPHA-TEST RELEASE.                                             *
X * If you are not going to port this to new systems, or try to fix bugs, then *
X * please wait a month or two until the real "bug-free" release happens in    *
X * comp.sources.unix; it'd be a shame to go to all sorts of trouble to        *
X * install buggy software.                                                    *
X *                                                                            *
X * PLEASE DO NOT RE-DISTRIBUTE THIS PACKAGE.                                  *
X * This code is in the public domain, and you can do what you want with it,   *
X * but I guarantee that the real release will have bugs fixed.  I would hate  *
X * for this to end up on fifty-skadillion BBS systems when the "real" version *
X * will be better, and available soon.                                        *
X ******************************************************************************
X
XIntroduction
X------------
XThis set of tools is designed to make it easier to ship sources around.  I
Xwrote them because I do a lot of that as moderator of comp.sources.unix,
Xand nothing else did the job for me.  This set isn't perfect, but its
Xclose.
X
XPrograms are included for the following tasks:
X    Find source files
X    Split large files and convert binaries to ASCII.
X    Partition them into reasonably-sized archives via a shipping list
X    Pull entries out of the shipping lists
X    Make shell archives out of them
X    Strip mail/news/notes headers from archives before feeding them to a shell
X    An interpreter of enough /bin/sh syntax to unpack them "sort of" safely
X
XThe sources in this distribution are being released into the public
Xdomain; do what you want, but let your conscience be your guide.  If you
Xsomehow enhance this package, please send it on to me so that others can
Xbenefit.
X
XOn a philosophical note, I've tried to make this all as general as
Xpossible for shipping sources around.  I'm not interested in binaries, so
Xthings like automatically running uuencode don't interest me.  Maniscan
Xis a begruding concession to reality.
X
XInstallation
X------------
XPick a configuration file that comes close to matching your system, edit
Xit as necessary, and copy it to "config.h".  Don't be scared by your first
Xlook at all the parameters in the config.XXX files.  I agree that there
Xare WAY too many, but it's really not that bad -- trust me.  If you find
Xthat you have to edit any other file, please let me know.   You might have
Xto tweak with some of the lXXX.c files for bizarre systems, but if you
Xhave to edit anything else then I goofed and would like to hear about it.
X
XIt would be nice if I could use a Larry Wall-style Configure, but that
Xonly works on Unix (and Eunice).  Send me your config.h file so that
Xothers can benefit.
X
XYou might have to edit the Makefile, or perhaps even write one from scratch.
XIf you end up making significant changes, please let me know.  Apparently
X"make" and compilers in the micro world don't have the de-facto standards
Xthe way Unix and VMS do, so unless your changes are very general and
Xapplicable to a wide variety of machines, you needn't send them to me.
X
XCredits
X-------
XI freely stole ideas from a number of people who have been good enough to
Xput their stuff out on Usenet.  Particular thanks to Gary Perlman and
XLarry Wall for giving me something nice to reverse-engineer, Michael
XMauldin for unshar, and Phil Budne for what I turned into manipull.
X
XThe following people sent in comments, bug reports, config files, etc.
XThanks to them all.
X
XEelco van Asperen
XTom Beattie
XPhil Budne
XJohn Chmielewski
XSteve Creps
XBob Desinger
XVital Dobroey
XJean-Pierre H. Dumas
XDavid Eckelkamp
XSteve Feldman
XArch-Mage Ged
XScott Garfinkle
XMike Haertel
XMarion Hakanson
XMatt Landau
XGreg Lee
XMarty Leisner
XDon Libes
XDavid MacKenzie
XShane McCarron
XJohn Meaders
XBob Mitchell
XChuck Musciano
XDarryl Ohahato
XTim Pointing
XBill Randle
XGeoff Scully
XJoel Shprentz
XLarry Virden
XPaul Vixie
XJamie Watson
XKen Yap
X
X
XEnjoy!
X	Rich $alz
X	BBN Systems and Technology, Inc.
X	10 Moulton Street
X	Cambridge, MA  02238
X	rsalz@bbn.com
X	rsalz@uunet.uu.net
X
X
X
XChanges since the last comp.sources.unix release include these new programs:
X	uuencode
X	uudecode
X	dodoc.sh (please use this before downloading to a PC BBS)
X	manipull
X	maniscann
X
XNew features:
X	Everyone uses getopt and has nice usage messages.
X	Safe unpacking for the parser.
X	MS-DOS probably works now.
X	A bunch of new config options.
X
X----------------------------------------------
XDate: Fri, 10 Jun 88 05:58:22-1000
XFrom: Greg Lee <lee@uhccux.uhcc.hawaii.edu>
X    Problems if it's a blank line that consists of space-character
X    & \n, and I don't really know whether it only happens when the blank
X    line is at the end of a file, or whether it always happens.
X
X    (create a file by "echo -n ' '>/tmp/f" and try to shar this file.)
X
X----------------------------------------------FIXED
XDate:  Tue, 29 Nov 88 17:51:53 PST
XFrom: Mike Wexler <mikew@wyse.com>
X    Check for execution of setuid programs?  [no --r$]
X    Check for access to files outside of the current directory?
X
X----------------------------------------------FIXED
XDate: 16 Feb 89 19:03:47 EST (Thursday)
XFrom: Marty Leisner <Leisner.Henr@Xerox.COM>
X    Shell.c has bad argv parsing now that it uses getopt.
X    Should use/provide ctermid.
X    Findsrc needs to prompt if #undef CAN_POPEN
X    Unshar should not use "foo.hdr" on MSDOS or VMS.
X
X----------------------------------------------FIXED
XDate: 27 Dec 88 13:16:38 EST (Tue)
XFrom: Karl Freburger <freb@goldfnch.mv.com>
X    Allow for shars to not end with \n, just EOF.
X    Make sure not to overrun input buffer.
X    Treat : as a comment command, not a "diy"
X    Bug in quotes and {} in variable expansion.
X
X----------------------------------------------FIXED
XDate: Mon, 19 Dec 88 11:25:39 PST
XFrom: Greg Yachuk <infmx!greggy>
X    Two bug fixes (sizeP, etc.) Dos changes (free in Execute, etc.).
X    MakeTempPath concept.
X
X----------------------------------------------FIXED
XDate: Wed, 15 Jun 88 05:27:53 EDT
XFrom: Phil Budne <budd@bu-it.bu.edu>
X    Doing "makekit -i MANIFESTO foo bar baz" silently ignores MANIFEST.
X    ^C handling is bad news, kills current kid and keeps going.
X
X----------------------------------------------FIXED
XDate: Fri, 10 Jun 88 10:15:18 cdt
XFrom: John L. Chmielewski <attmail!jlc>
X    Changes for System V Releases 3.1 and 3.2.
X    Rename config.h to config.bsd, let folks pick one.
X
X----------------------------------------------FIXED
XDate: Fri, 8 Jul 88 05:22:12 EDT
XFrom: David MacKenzie, Environmental Defense Fund  <edf@rocky2.rockefeller.edu>
X    I had to make a few other changes to get it to compile under UNOS.
X
X----------------------------------------------FIXED
XDate: Sat, 22 Oct 88 17:03:42 EDT
XFrom: Victor Duchovni <vic@fine.Princeton.EDU>
X    Add a \n to end of shar's if necessary.
X
X----------------------------------------------FIXED
XDate: 29 Nov 88 02:51:55 PST (Tue)
XFrom: Dave Arnold <ccicpg!arnold!dave>
X    GetStat() is used to check if file exists, but if it doesn't
X    Fsize() would be confused and report a zero size after the
X    file was created.
X
X----------------------------------------------FIXED
XDate: 9 Jun 88 13:31:00 GMT (Thu)
XFrom: John B. Meaders, Jr. <bigtex!jclyde!john>
X    Got it running on a 286 xenix.
X
X----------------------------------------------FIXED
XDate: Mon, 4 Jul 88 06:25:36 est
XFrom: Mike Haertel <mike@wheaties.ai.mit.edu>
X    Manpage problems with ".l" suffix in makefile.
X
X----------------------------------------------FIXED
XDate: Tue, 7 Jun 88 14:07:17 PDT
XFrom: Robbin W Johnson <Robbin.W.Johnson@resrch.molienergy.bc.ca>
X    Config file for HP-UX.
X    Add HAS_VFORK for hybrids.
X
X----------------------------------------------FIXED
XDate: Tue, 12 Jul 88 17:05:05 PDT
XFrom: Bill Randle <billr@saab.cna.tek.com>
X    Fix sorting bug so README preceeds MANIFEST.
X    Add IsProbablySource for sizing;
X    Add proper test of MANIFEST size.
X
X----------------------------------------------FIXED
XDate: ?
XFrom: A cast of thousands.
X    patch04:  Rename TEMP->File in glue.c
X    patch04:  Remove extra declarations if ANSI_HDRS.
X    patch04:  Add HOST_ENV, HOSTFILE, and DEF_HOST.
X    patch04:  Have msd_dir.h include <sys/types.h>
X    patch04:  Tweak #includes and fix declarations for ANSI_HDRS.
X    patch04:  Make makefile a little more configurable.
END_OF_FILE
if test 8473 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'dirami.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dirami.c'\"
else
echo shar: Extracting \"'dirami.c'\" \(3465 characters\)
sed "s/^X//" >'dirami.c' <<'END_OF_FILE'
X/*
X**  Readdir package for the Amiga.
X**
X**  [  I have not tried this at all, except to reformat it.  --r$  ]
X**  
X**  To: Richard Salz <rsalz@pineapple.bbn.com>
X**  Subject: Re: Amiga version of the dir library...
X**  Date: Mon, 13 Jul 87 21:54:25 PDT
X**  From: Mike (My watch has windows) Meyer <mwm@violet.Berkeley.EDU>
X**  
X**  Here is what I did. This is built to reflect the 4BSD manual pages, not
X**  the SysV/dpANS manual pages.
X**  
X**  I now know how to get the telldir/seekdir pair to work correctly with
X**  multiple tell()s, but do not have much motivation to do so. If someone
X**  out there does it, or is interested in doing it, I wouldd be interested in
X**  the results or willing to help.
X**  
X**  Final note: as with many micros, there is more than one C compiler.
X**  This was written for the Lattice compiler, and uses features known
X**  not to exist in other Amiga compilers. Fixing it should be trivial.
X**  
X**  	<mike
X**
X**  $Header$
X*/
X#include <dir.h>
X
X
XDIR		*AllocMem(int, int);
Xstruct FileLock	*Lock(char *, int);
Xstruct FileLock	*CurrentDir(struct FileLock *);
X
X
XDIR *
Xopendir(dirname)
X    char		*dirname;
X{
X    register DIR	*my_dir;
X
X    if ((my_dir = AllocMem(sizeof *my_dir, 0)) == NULL)
X	return NULL;
X
X    /* If we can't examine it, or it's not a directory, that's not good. */
X    if ((my_dir->d_lock = Lock(dirname, ACCESS_READ)) == NULL
X     || !Examine(my_dir->d_lock, &(my_dir->d_info))
X     || (my_dir->d_info.fib_DirEntryType < 0)) {
X	FreeMem(my_dir, sizeof *my_dir);
X	return NULL;
X    }
X    return my_dir;
X}
X
X
Xstruct direct *
Xreaddir(my_dir)
X    DIR				*my_dir;
X{
X    static struct direct	 result;
X
X    if (!ExNext(my_dir->d_lock, &(my_dir->d_info)))
X	return NULL;
X
X    result.d_reclen = result.d_ino = 1;	/* Not NULL! */
X    (void)strcpy(result.d_name, my_dir->d_info.fib_FileName);
X    result.d_namlen = strlen(result.d_name);
X    return &result;
X}
X
X
Xvoid
Xclosedir(my_dir)
X    DIR *my_dir;
X{
X    UnLock(my_dir->d_lock);
X    FreeMem(my_dir, sizeof *my_dir);
X}
X
X
X/*
X**  telldir and seekdir don't work quite right. The problem is that you have
X**  to save more than a long's worth of stuff to indicate position, and it's
X**  socially unacceptable to alloc stuff that you don't free later under
X**  AmigaDOS. So we fake it - you get one level of seek, and dat's all.
X**  As of now, these things are untested.
X*/
X#define DIR_SEEK_RETURN		((long)1)	/* Not 0! */
X
X
Xlong
Xtelldir(my_dir)
X    DIR *my_dir;
X{
X    my_dir->d_seek = my_dir->d_info;
X    return DIR_SEEK_RETURN;
X}
X
X
Xvoid
Xseekdir(my_dir, where)
X    DIR	*my_dir;
X    long	 where;
X{
X    if (where == DIR_SEEK_RETURN)
X	my_dir->d_info = my_dir->d_seek;
X    else
X	/* Makes the next readdir fail */
X	setmem((char *)my_dir, sizeof *my_dir, 0);
X}
X
X
Xvoid
Xrewinddir(my_dir)
X    DIR *my_dir;
X{
X    if (!Examine(my_dir->d_lock, &(my_dir->d_info)))
X	setmem((char *)my_dir, sizeof *my_dir, 0);
X}
X
X
X#ifdef	TEST
X/*
X * Simple code to list the files in the argument directory,
X *	lifted straight from the man page.
X */
X#include <stdio.h>
Xvoid
Xmain(ac, av)
X    int				 ac;
X    char			**av;
X{
X    register DIR		*dirp;
X    register struct direct	*dp;
X    register char		 *name;
X
X    name = ac < 2 ? "" : av[1];
X    if ((dirp = opendir(name)) == NULL) {
X	fprintf(stderr, "Bogus! Can't opendir %s\n", name);
X	exit(1);
X	/* NOTREACHED */
X    }
X
X    while (dp = readdir(dirp))
X	printf("%s ", dp->d_name);
X    closedir(dirp);
X    putchar('\n');
X    exit(0);
X    /* NOTREACHED */
X}
X#endif	/* TEST */
END_OF_FILE
if test 3465 -ne `wc -c <'dirami.c'`; then
    echo shar: \"'dirami.c'\" unpacked with wrong size!
fi
# end of 'dirami.c'
fi
if test -f 'dirami.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dirami.h'\"
else
echo shar: Extracting \"'dirami.h'\" \(2761 characters\)
sed "s/^X//" >'dirami.h' <<'END_OF_FILE'
X/*
X**  Readdir package for the Amiga.
X**
X**  [  I have not tried this at all except to reformat it.  --r$  ]
X**  
X**  To: Richard Salz <rsalz@pineapple.bbn.com>
X**  Subject: Re: Amiga version of the dir library... 
X**  Date: Mon, 13 Jul 87 21:54:25 PDT
X**  From: Mike (My watch has windows) Meyer <mwm@violet.Berkeley.EDU>
X**  
X**  Here's what I did. This is built to reflect the 4BSD manual pages, not
X**  the SysV/dpANS manual pages.
X**  
X**  I now know how to get the telldir/seekdir pair to work correctly with
X**  multiple tell()s, but don't have much motivation to do so. If someone
X**  out there does it, or is interested in doing it, I'd be interested in
X**  the results or willing to help.
X**  
X**  Final note: as with many micros, there's more than one C compiler.
X**  This was written for the Lattice compiler, and uses features known
X**  not to exist in other Amiga compilers. Fixing it should be trivial.
X**  
X**  	<mike
X**
X**  $Header$
X*/
X#ifndef	DIR_H
X#define DIR_H
X
X#ifndef	EXEC_TYPES_H
X#include "exec/types.h"
X#endif	/* EXEC_TYPES_H */
X
X#ifndef	LIBRARIES_DOS_H
X#include "libraries/dos.h"
X#endif /* LIBRARIES_DOS_H */
X
X#ifndef	LIBRARIES_DOSEXTENS_H
X#include "libraries/dosextens.h"
X#endif /* LIBRARIES_DOSEXTENS_H */
X
X
X/*
X**  MAXNAMELEN is the maximum length a file name can be. The direct structure
X**  is lifted from 4BSD, and has not been changed so that code which uses
X**  it will be compatable with 4BSD code. d_ino and d_reclen are unused,
X**  and will probably be set to some non-zero value.
X*/
X#define	MAXNAMLEN	31		/* AmigaDOS file max length */
X
Xstruct direct {
X	ULONG	d_ino;			/* unused - there for compatability */
X	USHORT	d_reclen;		/* ditto */
X	USHORT	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/*
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/*
X**  The DIR structure holds the things that AmigaDOS needs to know about
X**  a file to keep track of where it is and what it's doing.
X*/
Xtypedef struct {
X	struct FileInfoBlock	d_info;	/* Default info block */
X	struct FileInfoBlock	d_seek;	/* Info block for seeks */
X	struct FileLock		*d_lock; /* Lock on directory */
X} DIR;
X	
Xextern DIR		*opendir(char *);
Xextern struct direct	*readdir(DIR *);
Xextern long		 telldir(DIR *);
Xextern void		 seekdir(DIR *, long);
Xextern void		 rewinddir(DIR *);
Xextern void		 closedir(DIR *);
X
X#endif	/* DIR_H */
END_OF_FILE
if test 2761 -ne `wc -c <'dirami.h'`; then
    echo shar: \"'dirami.h'\" unpacked with wrong size!
fi
# end of 'dirami.h'
fi
if test -f 'dirmsd.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dirmsd.h'\"
else
echo shar: Extracting \"'dirmsd.h'\" \(978 characters\)
sed "s/^X//" >'dirmsd.h' <<'END_OF_FILE'
X/*
X**  Readdir package for MS-DOS.
X**  
X**  [  I have not tried this at all except to reformat it.  --r$  ]
X**
X**  Public domain implementation Michael Rendell <garfield!michael>
X**  August 1897.
X**
X**  $Header$
X*/
X#include <sys/types.h>
X
X#define MAXNAMLEN	12
X
Xtypedef struct _dircontents {
X	char			*_d_entry;
X	struct _dircontents	*_d_next;
X} _DIRCONTENTS;
X
Xstruct direct {
X	ino_t	d_ino;			/* a bit of a farce */
X	int	d_reclen;		/* more farce */
X	int	d_namlen;		/* length of d_name */
X	char	d_name[MAXNAMLEN + 1];	/* garentee null termination */
X};
X
Xtypedef struct _dir {
X	int		 dd_id;		/* identify each open directory */
X	long		 dd_loc;	/* where we are in directory entry */
X	_DIRCONTENTS	*dd_contents;	/* pointer to contents of dir */
X	_DIRCONTENTS	*dd_cp;		/* pointer to current position */
X} DIR;
X
X#define rewinddir(dirp)		seekdir(dirp, 0L)
Xextern DIR		*opendir();
Xextern struct direct	*readdir();
Xextern void		 seekdir();
Xextern long		 telldir();
Xextern void		 closedir();
END_OF_FILE
if test 978 -ne `wc -c <'dirmsd.h'`; then
    echo shar: \"'dirmsd.h'\" unpacked with wrong size!
fi
# end of 'dirmsd.h'
fi
if test -f 'dodoc.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dodoc.sh'\"
else
echo shar: Extracting \"'dodoc.sh'\" \(830 characters\)
sed "s/^X//" >'dodoc.sh' <<'END_OF_FILE'
X#! /bin/sh
X##  Script to generate simple formatted documentation for distribution
X##  to BBS's and other non-Unix systems.  It's basically a de-paginator
X##  for not-very-long manual pages (five pages or so).
X##
X##  This runs on SunOS 3.4, and might need tweaking if you go to a system
X##  where the -man macros have been munged differently.
X##
X##  $Header$
X##
X
Xcase $# in
X0)
X    echo "Usage: `basename $0` files..." >&2
X    exit 1
X    ;;
Xesac
X
Xfor I in "$@" ; do
X    echo ".pl 40i" \
X	| nroff -man - ${I}.man \
X	| col -b \
X	| awk '
X	  /SEE ALSO/ { F = 1 }
X	  {
X	    if (F == 1 && length == 0) { F = 2 }
X	    if (F != 2) { print }
X	  }' \
X	| sed \
X	  -e 's/^\([A-Z]*\)(1L)/\1    /' \
X	  -e 's/\([A-Z]*\)(1L)$/    \1/' \
X	  -e 's/^/     /' \
X	  -e 's/UNKNOWN SECTION OF THE MANUAL/                             /' \
X	>${I}.doc
Xdone
END_OF_FILE
if test 830 -ne `wc -c <'dodoc.sh'`; then
    echo shar: \"'dodoc.sh'\" unpacked with wrong size!
fi
chmod +x 'dodoc.sh'
# end of 'dodoc.sh'
fi
if test -f 'findsrc.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'findsrc.man'\"
else
echo shar: Extracting \"'findsrc.man'\" \(1884 characters\)
sed "s/^X//" >'findsrc.man' <<'END_OF_FILE'
X.TH FINDSRC 1L
X.\" $Header: findsrc.man,v 2.0 88/05/27 13:28:20 rsalz Exp $
X.SH NAME
Xfindsrc \- walk directories, trying to find source files
X.SH SYNOPSIS
X.RS
X.na
X.ti -.5i
X.B findsrc
X[
X.BI \-d\| y_or_n
X] [
X.B \-h
X] [
X.BI \-o\| name
X] [
X.B \-r
X] [
X.B \-s
X] [
X.B \-v
X] [ file... ]
X.ad
X.RE
X.SH DESCRIPTION
X.I Findsrc
Xrecursively examines all directories and files specified on the command
Xline, and determines, based on the file name, whether the file contains
Xsource code or not.
XAll directories are listed first, followed by all regular files,
Xwith one item per line.
X.PP
XIf
X.I findsrc
Xis unable to make a decision, it invokes the
X.IR file (1)
Xcommand, and prompts the user for a decision.
XIn reply to the prompt, type the letter ``y'' or ``n'' (either case);
XRETURN means yes.
XIf the reply starts with an exclamation point, the rest of the line
Xis passed off to a sub-shell and the question is repeated.
XThe ``\-d'' option may be used with an argument of ``y'' or ``n''
Xto by-pass the interaction, and provide a default answer.
X.PP
XThe ``\-o'' option may be used to specify an output filename.
XThis is designed to prevent confusion if a command like the following
Xis executed:
X.RS
Xfindsrc . * >LIST
X.RE
X.PP
XBy default,
X.I findsrc
Xignores files whose names begin with a period, like ``.newsrc'' or
X``.tags''; such hidden files may be included by using the ``\-h'' option.
X.I Findsrc
Xalso normally ignores
XRCS and SCCS files and directories; using either the ``\-r'' or ``\-s''
Xoption causes both to be included.
X.PP
X.I Findsrc
Xnormally lists only the names of those files that have been selected.
XIf the ``\-v'' option is used, rejected files are also listed preceeded
Xby the word ``PUNTED.''
X.PP
XIf no files are specified on the command line, the program operates as
Xa filter, reading a list of files and directories from the standard
Xinput, one per line.
X.SH "SEE ALSO"
Xmakekit(1L).
END_OF_FILE
if test 1884 -ne `wc -c <'findsrc.man'`; then
    echo shar: \"'findsrc.man'\" unpacked with wrong size!
fi
# end of 'findsrc.man'
fi
if test -f 'glue.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'glue.c'\"
else
echo shar: Extracting \"'glue.c'\" \(1403 characters\)
sed "s/^X//" >'glue.c' <<'END_OF_FILE'
X/*
X**  Subroutine to call the shell archive parser.  This is "glue" that holds
X**  unshar and parser together.
X*/
X#include "parser.h"
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: glue.c,v 2.0 88/05/27 13:26:14 rsalz Locked $";
X#endif	/* RCSID */
X
X
X#ifdef	USE_MY_SHELL
X/*
X**  Cleanup routine after BinSh is done
X*/
Xvoid
XBSclean()
X{
X    (void)fclose(Input);
X    if (File[0])
X	(void)unlink(File);
X}
X
X
X/*
X**  Copy the input to a temporary file, then call the shell parser.
X*/
XBinSh(Name, Stream, Pushback)
X    char		*Name;
X    REGISTER FILE	*Stream;
X    char		*Pushback;
X{
X    REGISTER FILE	*F;
X    char		 buff[BUFSIZ];
X    char		*vec[MAX_WORDS];
X
X    Interactive = Name == NULL;
X
X#ifdef	MSDOS
X    onexit(BSclean);
X#endif	/* MSDOS */
X
X    MakeTempName(File, TEMP_NAME1);
X    if ((F = fopen(File, "w")) == NULL) {
X	Fprintf(stderr," Can't create \"%s\" as temp file, %s.\n",
X		File, Ermsg(errno));
X	exit(1);
X	/* NOTREACHED */
X    }
X
X    (void)fputs(Pushback, F);
X    while (fgets(buff, sizeof buff, Stream))
X	(void)fputs(buff, F);
X    (void)fclose(Stream);
X    (void)fclose(F);
X
X    if ((Input = fopen(File, "r")) == NULL)
X	Fprintf(stderr, "Can't open %s, %s!?\n", File, Ermsg(errno));
X    else {
X	while (GetLine(TRUE)) {
X#ifdef	USE_JMPBUF
X	    if (setjmp(jEnv))
X		break;
X#endif	/* USE_JMPBUF */
X	    if (Argify(vec) && Exec(vec) == OOB_FALSE)
X		    break;
X	}
X    }
X
X    BSclean();
X}
X#endif	/* USE_MY_SHELL */
END_OF_FILE
if test 1403 -ne `wc -c <'glue.c'`; then
    echo shar: \"'glue.c'\" unpacked with wrong size!
fi
# end of 'glue.c'
fi
if test -f 'lcwd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lcwd.c'\"
else
echo shar: Extracting \"'lcwd.c'\" \(1117 characters\)
sed "s/^X//" >'lcwd.c' <<'END_OF_FILE'
X/*
X**  Return current working directory.  Something for everyone.
X*/
X/* LINTLIBRARY */
X#include "shar.h"
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: lcwd.c,v 2.0 88/05/27 13:26:24 rsalz Exp $";
X#endif	/* RCSID */
X
X
X#ifdef	PWDGETENV
X/* ARGSUSED */
Xchar *
XGetDir(p, i)
X    char	*p;
X    int		 i;
X{
X    char	*q;
X
X    return (q = getenv(PWDGETENV)) ? strcpy(p, q) : NULL;
X}
X#endif	/* PWDGETENV */
X
X
X#ifdef	GETWD
X/* ARGSUSED1 */
Xchar *
XGetDir(p, size)
X    char	*p;
X    int		 size;
X{
X    extern char	*getwd();
X
X    return getwd(p) ? p : NULL;
X}
X#endif	/* GETWD */
X
X
X#ifdef	GETCWD
Xchar *
XGetDir(p, size)
X    char	*p;
X    int		 size;
X{
X    extern char	*getcwd();
X
X    return getcwd(p, size) ? p : NULL;
X}
X#endif	/* GETCWD */
X
X
X#ifdef	PWDPOPEN
Xchar *
XGetDir(p, size)
X    char	*p;
X    int		 size;
X{
X    extern FILE	*popen();
X    FILE	*F;
X    int		 i;
X
X    /* This string could be "exec /bin/pwd" if you want... */
X    if (F = popen("pwd", "r")) {
X	if (fgets(p, size, F) && p[i = strlen(p) - 1] == '\n') {
X	    p[i] = '\0';
X	    (void)fclose(F);
X	    return p;
X	}
X	(void)fclose(F);
X    }
X    return NULL;
X}
X#endif	/* PWDPOPEN */
END_OF_FILE
if test 1117 -ne `wc -c <'lcwd.c'`; then
    echo shar: \"'lcwd.c'\" unpacked with wrong size!
fi
# end of 'lcwd.c'
fi
if test -f 'lexec.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lexec.c'\"
else
echo shar: Extracting \"'lexec.c'\" \(2645 characters\)
sed "s/^X//" >'lexec.c' <<'END_OF_FILE'
X/*
X**  Process stuff, like fork exec and wait.  Also signals.
X*/
X/* LINTLIBRARY */
X#include "shar.h"
X#include <signal.h>
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: lexec.c,v 2.0 88/05/27 13:26:35 rsalz Exp $";
X#endif	/* RCSID */
X
X
X/* How to fork(), what to wait with. */
X#ifdef	SYS_WAIT
X
X#include <sys/wait.h>
X#define FORK()		 vfork()
X#define W_VAL(w)	 ((w).w_retcode)
Xtypedef union wait	 WAITER;
X
X#else
X
X#ifdef	HAS_VFORK
X#define FORK()		 vfork()
X#else
X#define FORK()		 fork()
X#endif	/* HAS_VFORK */
X
X#define W_VAL(w)	 ((w) >> 8)
Xtypedef int		 WAITER;
X
X#endif	/* SYS_WAIT */
X
X
X
X/*
X**  Set up a signal handler.
X*/
XSetSigs(Func)
X    sigret_t	(*Func)();
X{
X    if (Func == NULL)
X	Func = SIG_DFL;
X#ifdef	SIGINT
X    if (signal(SIGINT, SIG_IGN) != SIG_IGN)
X	(void)signal(SIGINT, Func);
X#endif	/* SIGINT */
X#ifdef	SIGQUIT
X    if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
X	(void)signal(SIGQUIT, Func);
X#endif	/* SIGQUIT */
X#ifdef	SIGTERM
X    if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
X	(void)signal(SIGTERM, Func);
X#endif	/* SIGTERM */
X}
X
X
X/*
X**  Return the process ID.
X*/
Xint
XPid()
X{
X#ifdef	UNIX
X    static int	 X;
X
X    if (X == 0)
X	X = getpid();
X    return X;
X#endif	/* UNIX */
X#ifdef	MSDOS
X    return 1;
X#endif	/* MSDOS */
X#ifdef	VMS
X    return 1;
X#endif	/* VMS */
X}
X
X
X#ifndef	USE_SYSTEM
X/*
X**  Fork off a command.
X*/
Xint
XExecute(av)
X    char		*av[];
X{
X    REGISTER int	 i;
X    REGISTER int	 j;
X    WAITER		 W;
X
X    if ((i = FORK()) == 0) {
X	SetSigs((sigret_t (*)())NULL);
X	(void)execvp(av[0], av);
X	perror(av[0]);
X	_exit(1);
X	/* NOTREACHED */
X    }
X
X    /* We used to ignore signals around this wait, but that caused
X     * surprising behaviour when someone tried to kill makekit, e.g. */
X    while ((j = wait(&W)) < 0 && j != i)
X	;
X    return W_VAL(W);
X}
X
X#else
X
X/*
X**  Protect text from wildcard expansion, etc.
X*/
Xstatic char *
XProtect(p)
X    REGISTER char	*p;
X{
X    char		*save;
X
X    for (save = p; *p; p++)
X	if (CTYPE(*p) && !isalpha(*p))
X	    *p = '_';
X    return save;
X}
X
X
X/*
X**  Cons all the arguments together into a single command line and hand
X**  it off to the shell to execute.  Gotta quote each argument after
X**  the first one.
X*/
Xint
XExecute(av)
X    REGISTER char	*av[];
X{
X    REGISTER char	**v;
X    REGISTER char	 *p;
X    REGISTER char	 *q;
X    REGISTER int	  i;
X
X    /* Get length of command line. */
X    for (i = 2, v = av; *v; v++)
X	i += strlen(*v) + 3;
X
X    /* Create command line and execute it. */
X    p = NEW(char, i);
X    q = p + strlen(strcpy(p, *v));
X    for (v = &av[1]; *v; v++) {
X	*q++ = ' ';
X	q += strlen(strcpy(q, Protect(*v)));
X    }
X    *q = '\0';
X
X    i = system(p);
X    free(p);
X    return i;
X}
X#endif	/* USE_SYSTEM */
END_OF_FILE
if test 2645 -ne `wc -c <'lexec.c'`; then
    echo shar: \"'lexec.c'\" unpacked with wrong size!
fi
# end of 'lexec.c'
fi
if test -f 'lhost.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lhost.c'\"
else
echo shar: Extracting \"'lhost.c'\" \(1852 characters\)
sed "s/^X//" >'lhost.c' <<'END_OF_FILE'
X/*
X**  Return the name of this host.  Something for everyone.
X*/
X/* LINTLIBRARY */
X#include "shar.h"
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: lhost.c,v 2.0 88/05/27 13:27:01 rsalz Locked $";
X#endif	/* RCSID */
X
X
X#ifdef	HOSTENV
Xchar *
XHost()
X{
X    char		*p;
X
X    return (p = getenv(HOSTENV)) ? p : DEF_HOST;
X}
X#endif	/* HOSTENV */
X
X
X#ifdef	HOST_STRING
Xchar *
XHost()
X{
X    return DEF_HOST;
X}
X#endif	/* HOST_STRING */
X
X
X#ifdef	GETHOSTNAME
Xchar *
XHost()
X{
X    static char		 buff[64];
X
X    (void)gethostname(buff, sizeof buff);
X    return buff;
X}
X#endif	/* GETHOSTNAME */
X
X
X#ifdef	UNAME
X#include <sys/utsname.h>
Xchar *
XHost()
X{
X    static struct utsname	 U;
X
X    return uname(&U) < 0 ? DEF_HOST : U.nodename;
X}
X#endif	/* UNAME */
X
X
X#ifdef	UUNAME
Xchar *
XHost()
X{
X    static char		 buff[50];
X    extern FILE		*popen();
X    FILE		*F;
X    char		*p;
X
X    if (F = popen("exec uuname -l", "r")) {
X	if (fgets(buff, sizeof buff, F) == buff && (p = IDX(buff, '\n'))) {
X	    (void)pclose(F);
X	    *p = '\0';
X	    return buff;
X	}
X	(void)pclose(F);
X    }
X    return DEF_HOST;
X}
X#endif	/* UUNAME */
X
X
X#ifdef	WHOAMI
Xchar *
XHost()
X{
X    static char		 name[64];
X    REGISTER FILE	*F;
X    REGISTER char	*p;
X    char		 buff[100];
X
X    /* Try /etc/whoami; look for a single well-formed line. */
X    if (F = fopen(WHOAMI, "r")) {
X	if (fgets(name, sizeof name, F) && (p = IDX(name, '\n'))) {
X	    (void)fclose(F);
X	    *p = '\0';
X	    return name;
X	}
X	(void)fclose(F);
X    }
X
X    /* Try /usr/include/whoami.h; look for #define sysname "foo" somewhere. */
X    if (F = fopen("/usr/include/whoami.h", "r")) {
X	while (fgets(buff, sizeof buff, F))
X	    /* I don't like sscanf, nor do I trust it.  Sigh. */
X	    if (sscanf(buff, "#define sysname \"%[^\"]\"", name) == 1) {
X		(void)fclose(F);
X		return name;
X	    }
X	(void)fclose(F);
X    }
X
X    return DEF_HOST;
X}
X#endif /* WHOAMI */
END_OF_FILE
if test 1852 -ne `wc -c <'lhost.c'`; then
    echo shar: \"'lhost.c'\" unpacked with wrong size!
fi
# end of 'lhost.c'
fi
if test -f 'lmem.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lmem.c'\"
else
echo shar: Extracting \"'lmem.c'\" \(641 characters\)
sed "s/^X//" >'lmem.c' <<'END_OF_FILE'
X/*
X**  Get some memory or die trying.
X*/
X/* LINTLIBRARY */
X#include "shar.h"
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: lmem.c,v 2.0 88/05/27 13:27:16 rsalz Locked $";
X#endif	/* RCSID */
X
X
Xalign_t
Xgetmem(i, j)
X    unsigned int	 i;
X    unsigned int	 j;
X{
X#ifndef	ANSI_HDRS
X    extern char		*malloc();
X#endif	/* ANSI_HDRS */
X    align_t		 p;
X
X    /* Lint fluff:  "possible pointer alignment problem." */
X    if ((p = (align_t)malloc(i * j)) == NULL) {
X	/* Print the unsigned values as int's so ridiculous values show up. */
X	Fprintf(stderr, "Can't Calloc(%d,%d), %s.\n", i, j, Ermsg(errno));
X	exit(1);
X	/* NOTREACHED */
X    }
X    return p;
X}
END_OF_FILE
if test 641 -ne `wc -c <'lmem.c'`; then
    echo shar: \"'lmem.c'\" unpacked with wrong size!
fi
# end of 'lmem.c'
fi
if test -f 'luser.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'luser.c'\"
else
echo shar: Extracting \"'luser.c'\" \(722 characters\)
sed "s/^X//" >'luser.c' <<'END_OF_FILE'
X/*
X**  Get user name.  Something for everyone.
X*/
X/* LINTLIBRARY */
X#include "shar.h"
X#ifdef	USE_GETPWUID
X#include <pwd.h>
X#endif	/* USE_GETPWUID */
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: luser.c,v 2.0 88/05/27 13:27:23 rsalz Exp $";
X#endif	/* RCSID */
X
X
X/*
X**  Get user name.  Not secure, but who sends nastygrams as shell archives?
X*/
Xchar *
XUser()
X{
X#ifdef	USE_GETPWUID
X    extern struct passwd	*getpwuid();
X    struct passwd		*p;
X#endif	/* USE_GETPWUID */
X    char			*g;
X
X    if (g = getenv("USER"))
X	return g;
X    if (g = getenv("LOGNAME"))
X	return g;
X    if (g = getenv("NAME"))
X	return g;
X#ifdef	USE_GETPWUID
X    if (p = getpwuid(getuid()))
X	return p->pw_name;
X#endif	/* USE_GETPWUID */
X    return USERNAME;
X}
END_OF_FILE
if test 722 -ne `wc -c <'luser.c'`; then
    echo shar: \"'luser.c'\" unpacked with wrong size!
fi
# end of 'luser.c'
fi
if test -f 'manipull.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'manipull.man'\"
else
echo shar: Extracting \"'manipull.man'\" \(2032 characters\)
sed "s/^X//" >'manipull.man' <<'END_OF_FILE'
X.TH MANIPULL 1L
X.\" $Header$
X.SH NAME
Xmanipull \- extract entries out of an existing manifest
X.SH SYNOPSIS
X.RS
X.na
X.ti -.5i
X.B manipull
X[
X.BI \-f\| #
X] [
X.BI \-h\| #
X] [
X.BI \-i\| name
X] [
X.B \-m
X] [
X.BI \-o\| name
X] [
X.B \-s
X] file...
X.ad
X.RE
X.SH DESCRIPTION
X.I Manipull
Xreads an existing ``manifest'' (usually created and maintained by
X.IR makekit (1L))
Xand pulls the indicated entries out of it, making a new manifest.
X.PP
XA manifest consist of some header lines, followed by a series of lines
Xthat describe the files contained in the shell archives.
XEach line looks like this;
X.RS
Xfilename\ \ \ spaces\ \ \ optional-digits\ \ \ spaces\ \ \ text
X.RE
XFor more information on the interpretation of the file, see the
X.I makekit
Xdocumentation.
X.PP
XThe original manifest is read from the standard input.
XAn alternate input file may be given by using the ``\-i'' option.
XThe generated manifest will be sent to the standard output.
XAn alternate output file may be given by using the ``\-o'' option.
XThe ``\-m'' option is the same as giving the options
X\&``-iMANIFEST -oMANIFEST.NEW -h2'' and is commonly used when
Xreading existing manifests.
X.PP
XThe ``\-f'' option may be necessary if the original manifest
Xhas more than a couple of hundred lines.
XThe existance of this option can be taken as evidence that the program's
Xauthor is lazy.
XThe ``\-h'' option may be given to have the program skip the
Xindicated number of lines in the input before beginning parsing.
X.PP
XAfter all the options have been read, any remaining arguments are
Xtaken to be a list of files to extract from the manifest.
XIf a file named on the command line does not appear in the existing
Xmanifest, it is added to the new one, with a placeholder for both
Xthe archive number and the description.
X.PP
XAs it is processing,
X.I manipull
Xnormally prints a message to standard error when it adds a file that
Xisn't in the initial manifest, or when a file in that manifest is
Xomitted.
XThese messages may be suppressed by using the ``\-s'' option.
X.SH "SEE ALSO"
Xmakekit(1L).
END_OF_FILE
if test 2032 -ne `wc -c <'manipull.man'`; then
    echo shar: \"'manipull.man'\" unpacked with wrong size!
fi
# end of 'manipull.man'
fi
if test -f 'parser.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'parser.h'\"
else
echo shar: Extracting \"'parser.h'\" \(1843 characters\)
sed "s/^X//" >'parser.h' <<'END_OF_FILE'
X/*
X**  Header file for the shell/shar parser.
X**
X**  $Header$
X*/
X#include "shar.h"
X
X
X/*
X**  Manifest constants, handy shorthands.
X*/
X
X/* Character classes used in the syntax table. */
X#define C_LETR		1		/* A letter within a word	*/
X#define C_WHIT		2		/* Whitespace to separate words	*/
X#define C_WORD		3		/* A single-character word	*/
X#define C_DUBL		4		/* Something like <<, e.g.	*/
X#define C_QUOT		5		/* Quotes to group a word	*/
X#define C_META		6		/* Heavy magic character	*/
X#define C_TERM		7		/* Line terminator		*/
X
X/* Macros used to query character class. */
X#define ISletr(c)	(SynTable[(c)] == C_LETR)
X#define ISwhit(c)	(SynTable[(c)] == C_WHIT)
X#define ISword(c)	(SynTable[(c)] == C_WORD)
X#define ISdubl(c)	(SynTable[(c)] == C_DUBL)
X#define ISquot(c)	(SynTable[(c)] == C_QUOT)
X#define ISmeta(c)	(SynTable[(c)] == C_META)
X#define ISterm(c)	(SynTable[(c)] == C_TERM)
X
X
X/* Safety-checking. */
X#ifdef	MAX_FOPENS
X#ifndef	OPEN_OVERHEAD
X#define OPEN_OVERHEAD
X#endif	/* OPEN_OVERHEAD */
X#endif	/* MAX_FOPENS */
X
X#ifdef	PATH_CHECK
X#ifndef	OPEN_OVERHEAD
X#define OPEN_OVERHEAD
X#endif	/* OPEN_OVERHEAD */
X#endif	/* PATH_CHECK */
X
X
X/*
X**  Data types
X*/
X
X/* Command dispatch table. */
Xtypedef struct _comtab {
X    char	  Name[10];		/* Text of command name		*/
X    int		(*Func)();		/* Function that implements it	*/
X} COMTAB;
X
X/* A shell variable.  We only have a few of these. */
Xtypedef struct _var {
X    char	 *Name;
X    char	 *Value;
X} VAR;
X
X
X/*
X**  Parser variables and declarations.
X*/
X#ifdef	USE_JMPBUF
Xextern jmp_buf	 jEnv;			/* Pop out of main loop		*/
X#endif	/* USE_JMPBUF */
Xextern FILE	*Input;			/* Current input stream		*/
Xextern char	 File[TEMPSIZE];	/* Input filename		*/
Xextern int	 Interactive;		/* isatty(fileno(stdin))?	*/
X
Xextern void	 SetVar();		/* Shell variable assignment	*/
Xextern void	 SynErr();		/* Fatal syntax error		*/
END_OF_FILE
if test 1843 -ne `wc -c <'parser.h'`; then
    echo shar: \"'parser.h'\" unpacked with wrong size!
fi
# end of 'parser.h'
fi
if test -f 'patchlog.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlog.h'\"
else
echo shar: Extracting \"'patchlog.h'\" \(1261 characters\)
sed "s/^X//" >'patchlog.h' <<'END_OF_FILE'
X/*
X**  This file records official patches.
X**
X**  $Header: patchlog.h,v 2.3 88/06/06 22:04:33 rsalz Exp $
X**
X**  $Log:	patchlog.h,v $
X**  Revision 2.3  88/06/06  22:04:33  rsalz
X**  patch03:  Fix typo in makekit manpage, and getopt call in the program.
X**  patch03:  Add NEED_RENAME and BACKUP_PREFIX to config.*; edit llib.c
X**  patch03:  and makekit.c to use them.
X**  
X**  Revision 2.2  88/06/03  16:08:37  rsalz
X**  patch02:  Fix order of chdir/mkdir commands for unshar.
X**  
X**  Revision 2.1  88/06/03  12:16:40  rsalz
X**  patch01:  Add config.x386 & config.sVr3; change "dirent.h" to <dirent.h>
X**  patch01:  In Makefile, use $(DIRLIB) only in actions, not dependencies;
X**  patch01:  add /usr/man/local option for MANDIR.
X**  patch01:  Put isascii() before every use of a <ctype.h> macro. 
X**  patch01:  Initialize Flist in shar.c/main().
X**  patch01:  Add -x to synopsis in makekit.man; improve the usage message &
X**  patch01:  put comments around note after an #endif (ANSI strikes again).
X**  patch01:  Remove extraneous declaration of Dispatch[] in parser.c
X**  patch01:  Add missing argument in fprintf call in findsrc.
X**  
X**  Revision 2.0  88/05/27  13:32:13  rsalz
X**  First comp.sources.unix release
X*/
X#define VERSION 3
X#define PATCHLEVEL 0
END_OF_FILE
if test 1261 -ne `wc -c <'patchlog.h'`; then
    echo shar: \"'patchlog.h'\" unpacked with wrong size!
fi
# end of 'patchlog.h'
fi
if test -f 'shar.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shar.man'\"
else
echo shar: Extracting \"'shar.man'\" \(3035 characters\)
sed "s/^X//" >'shar.man' <<'END_OF_FILE'
X.TH SHAR 1L
X.\" $Header: shar.man,v 2.0 88/05/27 13:28:49 rsalz Exp $
X.SH NAME
Xshar \- create shell archive file for extraction by /bin/sh
X.SH SYNOPSIS
X.RS
X.na
X.ti -.5i
X.B shar
X[
X.B \-b
X] [
X.BI \-i\| name
X] [
X.BI \-n\| #
X] [
X.BI \-e\| #
X] [
X.BI \-o\| name
X] [
X.BI \-t\| text
X] [file...]
X.ad
X.RE
X.SH DESCRIPTION
X.I Shar
Xtakes a list of files, and generates a
X.IR /bin/sh
Xscript that, when executed, will re-create those files in a different
Xdirectory or on a different machine.
XThe resultant script will use
X.IR wc (1)
Xto do a mild error-check, and will warn about possibly-omitted
Xcontrol characters.
X.PP
X.I Shar
Xgenerates scripts that will make directories and plain files.
XIt will not try to generate intermediate filenames, however, so
X.RS
Xshar foo/bar/file
X.RE
Xwill not work.  Do
X.RS
Xshar foo foo/bar foo/bar/file
X.RE
Xinstead.
X.PP
XThe script is normally sent to standard output; the ``\-o'' option may be
Xused to specify an output filename.
XThis is designed to prevent filling up the disk if
X.RS
Xshar * >SHAR
X.RE
Xcommand is done; do
X.RS
Xshar -o SHAR *
X.RE
Xinstead.
X.PP
XThe list of files is normally specified on the command line; the ''\-i''
Xoption may be used instead, to specify a file that contains the list
Xof files to pack up, one per line.
XIf the file name is ``-'' the standard input is read.
X.PP
XThe ``\-b'' option says that all leading directory names should be stripped
Xfrom the file when they are packed into the archive.
XFor example,
X.RS
Xshar -b /etc/termcap
X.RE
Xcreates an archive that, when executed, creates a file named
X``termcap'' in the current directory, rather than overwrite the
Xhost system file.
XNote, however, that the scripts generated by
X.I shar
Xnormally refuse to overwrite pre-existing files.
X.SS "Multi\-part Archives"
XMost larger software packages are usually sent out in two or more shell
Xarchives.
XThe ``\-n,'' ``\-e,'' and ``\-t'' options are used to make an archive
Xthat is part of a series.
XThe individual archives are often called ``kits'' when this is done.
XThe ``\-n'' option specifies the archive number; the ``\-e'' option species
Xthe highest number in the series.
XWhen executed, the generated archives will then echo messages like
X.RS
Xshar: End of archive 3 of 9.
X.RE
Xat their end.
X.PP
XIn addition, each shar will generate a file named
X.IR ark X isdone .
XEach script will contain a loop to check for the presence of these
Xfiles, and indicate to the recipient which archives still need to be
Xexecuted.
XThe ``\-t'' option may be used to give starting instructions to the recipient.
XWhen the scripts determine that all the archives have been unpacked,
Xthe text specified with this flag is displayed.
XFor example,
X.RS
Xshar -n1 -k9 -t "Now do 'sh ./Configure'" *.c >SHAR
X.RE
XAdds commands to output the following when all the archives have been unpacked:
X.RS
X.nf
XYou have run all 9 archives.
XNow do 'sh ./Configure'
X.PP
XThe
X.IR makekit (1L)
Xprogram is designed to create such multi-part kits.
X.fi
X.RE
X.SH "SEE ALSO"
Xecho(1), findsrc(1L), makekit(1L), mkdir(1), sh(1), test(1), unshar(1L), wc(1).
END_OF_FILE
if test 3035 -ne `wc -c <'shar.man'`; then
    echo shar: \"'shar.man'\" unpacked with wrong size!
fi
# end of 'shar.man'
fi
if test -f 'shell.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shell.c'\"
else
echo shar: Extracting \"'shell.c'\" \(1217 characters\)
sed "s/^X//" >'shell.c' <<'END_OF_FILE'
X/*
X**  SHELL
X**
X**  Stand-alone driver for shell/shar interpreter.
X*/
X#include "parser.h"
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header: shell.c,v 2.0 88/05/27 13:28:06 rsalz Locked $";
X#endif	/* RCSID */
X
X
Xmain(ac, av)
X    REGISTER int	 ac;
X    REGISTER char	*av[];
X{
X    char		*vec[MAX_WORDS];
X    char		 buff[VAR_VALUE_SIZE];
X    int			 Oops;
X    int			 i;
X
X    for (Oops = FALSE; (i = getopt(ac, av, "")) != EOF; )
X	switch (i) {
X	default:
X	    Oops = TRUE;
X	    break;
X	}
X    ac -= optind;
X    av += optind;
X
X    if (Oops) {
X	Fprintf(stderr, "Usage:\n  shell [file] [parameters]\n");
X	exit(1);
X	/* NOTREACHED */
X    }
X
X    if (Interactive = (ac == 0)) {
X	Fprintf(stderr, "Testing shell interpreter...\n");
X	Input = stdin;
X	(void)strcpy(File, "stdin");
X    }
X    else {
X	(void)strcpy(File, av[0]);
X	if ((Input = fopen(av[0], "r")) == NULL)
X	    SynErr("UNREADABLE INPUT");
X	/* Build the positional parameters. */
X	for (ac = 0; av[ac]; ac++) {
X	    (void)sprintf(buff, "%d", ac);
X	    SetVar(buff, av[ac]);
X	}
X    }
X
X    /* Read, parse, and execute. */
X    while (GetLine(TRUE))
X	if (Argify(vec) && Exec(vec) == OOB_FALSE)
X	    break;
X
X    /* That's it. */
X    (void)fclose(Input);
X    exit(0);
X    /* NOTREACHED */
X}
END_OF_FILE
if test 1217 -ne `wc -c <'shell.c'`; then
    echo shar: \"'shell.c'\" unpacked with wrong size!
fi
# end of 'shell.c'
fi
if test -f 'shell.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shell.man'\"
else
echo shar: Extracting \"'shell.man'\" \(1084 characters\)
sed "s/^X//" >'shell.man' <<'END_OF_FILE'
X.TH SHELL 1L
X.\" $Header: shell.man,v 2.0 88/05/27 13:28:55 rsalz Locked $
X.SH NAME
Xshell \- Interpreter for shell archives
X.SH SYNOPSIS
X.RS
X.na
X.ti -.5i
X.B shell
X[ file... ]
X.ad
X.RE
X.SH DESCRIPTION
XThis program interprets enough
X.IR /bin/sh (1)
Xsyntax, and common command usage, to enable it to unpack many different
Xtypes of
X.SM UNIX
Xshell archives,
Xor ``shar's.''
XIt is primarily intended to be used on non-UNIX systems that need to
Xunpack such archives.
X.PP
X.I Shell
Xdoes
X.B some
Xsecurity checking, but to believe that it will protect against all
Xtrojan horses is probably naive.
X.PP
XThe program's parser is line-based, where lines are then split into
Xtokens; it is not a true token-based parser.
XIn general, it is best if all
X.I /bin/sh
Xkeywords that can appear alone on a line do so, and that compound
Xcommands (i.e., using a semi-colon) be avoided.
XFor more details on the syntax, see the source (sorry...).
X.SH BUGS
XIt is probably easier to write a true portable replacement for /bin/sh
Xthan it is to write something which understands all shar formats.
X.SH SEE ALSO
Xshar(1L).
END_OF_FILE
if test 1084 -ne `wc -c <'shell.man'`; then
    echo shar: \"'shell.man'\" unpacked with wrong size!
fi
# end of 'shell.man'
fi
if test -f 'unshar.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'unshar.man'\"
else
echo shar: Extracting \"'unshar.man'\" \(2337 characters\)
sed "s/^X//" >'unshar.man' <<'END_OF_FILE'
X.TH UNSHAR 1L
X.\" $Header: unshar.man,v 2.0 88/05/27 13:29:02 rsalz Exp $
X.SH NAME
Xunshar \- unpack shell archives from news, mail, notes, etc.
X.SH SYNOPSIS
X.RS
X.na
X.ti -.5i
X.B unshar
X[
X.BI \-c\| path
X] [
X.BI \-d\| path
X] [
X.BI \-h\| file
X] [
X.B \-f
X] [
X.B \-n
X] [
X.B \-s
X] [ file... ]
X.ad
X.RE
X.SH DESCRIPTION
X.I Unshar
Xremoves mail and news header lines from its input, and feeds the remainder
Xto
X.IR /bin/sh (1)
Xso that a shell archive can be properly unpacked.
XIf no files are specified,
X.I unshar
Xreads from standard input.
XThe program is designed to be useful when unpacking archives directly
Xfrom the news or mail systems (e.g., s | unshar).
X.PP
X.I Unshar
Xnormally unpacks its files in the current directory.
XUse the ``\-c'' option to have the program change to a new directory
Xbefore invoking the shell.
XIf the directory does not exist,
X.I unshar
Xwill try to create it.
XIf the directory name starts with a question mark, then
X.I unshar
Xwill ask for the directory name before doing anything; this is most useful
Xwith the environment variable UNSHAREDIR.
XIf the directory name starts with a tilde, then the value of the HOME
Xenvironment variable is inserted in place of that character.
XFor convenience, the ``\-d'' option is a synonym for the ``\-c'' option.
X.PP
X.I Unshar
Xnormally complains if the input looks like something other than a shar file.
X(Among other things, it checks for files that resemble C, and Pascal code).
XIt can be fooled, however, by nonstandard versions of news, notes, etc.
XThe ``\-f'' option forces
X.I unshar
Xto try unpacking files, even if they look like something else.
X.PP
XDepending on how the program is installed,
X.I unshar
Xmay or may not try to preserve the header part of file ``foo''
Xinto the name ``foo.hdr'' (if the file is standard input, the name
Xwill be ``UNSHAR.HDR'').
XUsing the ``\-s'' option forces the program to save the headers, while
Xusing the ``\-n'' option forces it to discard the headers.
XThe file is appended to, if it already exists, so all headers can be easily
Xsaved in one file.
XThe name of the file may be given by using the ``\-h'' option; this is
Xparticularly useful when processing more than one file at a time.
X.SH ENVIRONMENT
X.ta \w'UNSHAREDIR  'u
XHOME	Used if directory name starts with a tilde.
X.br
XUNSHAREDIR	Default value for ``\-c'' option.
X.SH "SEE ALSO"
Xshar(1L).
END_OF_FILE
if test 2337 -ne `wc -c <'unshar.man'`; then
    echo shar: \"'unshar.man'\" unpacked with wrong size!
fi
# end of 'unshar.man'
fi
if test -f 'uudecode.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uudecode.man'\"
else
echo shar: Extracting \"'uudecode.man'\" \(1357 characters\)
sed "s/^X//" >'uudecode.man' <<'END_OF_FILE'
X.\" $Header$
X.TH UUDECODE 1L
X.SH NAME
Xuudecode \- reconstruct a binary file from printable encoding
X.SH SYNOPSIS
X.B uudecode
X[ 
X.I input
X]
X.SH DESCRIPTION
X.I Uudecode
Xtranslates a text file created by
X.IR uuencode (1L)
Xinto a replica of the original (binary) file.
XIt reads the named file (or standard input if none is given), and skips
Xany headers or trailers that might surround the data, and parses
Xthe data to create the file named in the message.
XNo attempt is made to verify the file to be created, or the permission
Xmodes to be assigned to it, so it is wise to manually inspect the
Xinput before feeding it into
X.IR uudecode .
XOn
X.SM UNIX ,
Xthis can be done by the following command:
X.RS
Xprompt% grep '^begin'
X.I input
X.RE
X.PP
XSeveral versions of the original
X.I uuencode
Xand
X.I uudecode
Xprograms are available and have been widely distributed; luckily, all
Xthe changes seem to have been made in a compatible manner.
XThis distribution does not provide all the features of other versions,
Xjust the basic format and the ``translation table.''
XFor more detailed information, see the
X.I uuencode
Xmanual page.
X.PP
XIf more than one data file appears in the input, all others but the
Xfirst one are ignored.
X.PP
XNote that the encoded file is about 35% bigger (three bytes become four,
Xplus control information) than the original.
X.SH "SEE ALSO"
Xuuencode(1L).
END_OF_FILE
if test 1357 -ne `wc -c <'uudecode.man'`; then
    echo shar: \"'uudecode.man'\" unpacked with wrong size!
fi
# end of 'uudecode.man'
fi
if test -f 'uuencode.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uuencode.c'\"
else
echo shar: Extracting \"'uuencode.c'\" \(2666 characters\)
sed "s/^X//" >'uuencode.c' <<'END_OF_FILE'
X/*
X**  UUENCODE
X**
X**  Uuencode a file.  This is based on the public-domain implementation that
X**  Mark Horton released to mod.sources with the translation table written
X**  by Jean-Pierre H. Dumas.
X*/
X#include "shar.h"
X#ifndef	VMS
X#include <sys/stat.h>
X#else
X#include <stat.h>
X#endif	/* VMS */
X#ifdef	RCSID
Xstatic char RCS[] =
X	"$Header$";
X#endif	/* RCSID */
X
X/* Encode one character into printable. */
X#define ENC(C)		((C) ? ((C) & 077) + ' ': '`')
X
X
X/*
X**
X*/
Xuuencode(Name, Newname)
X    char		*Name;
X    char		*Newname;
X{
X    register char	*p;
X    register FILE	*Out;
X    register FILE	*In;
X    register int	 i;
X    register int	 c;
X    register int	 n;
X    struct stat		 Sb;
X    char		 Outbuffer[BUFSIZ];
X    char		 buff[UULINE_SIZE + 3];
X
X    /* Open input. */
X    if ((In = fopen(Name, "r")) == NULL) {
X	Fprintf(stderr, "Can't open \"%s\" for input, %s.\n",
X		Name, Ermsg(errno));
X	exit(1);
X	/* NOTREACHED */
X    }
X
X    /* Open the buffered output. */
X    if ((Out = fopen(Newname, "w")) == NULL) {
X	Fprintf(stderr, "Can't open \"%s\" for output, %s.\n",
X		buff, Ermsg(errno));
X	exit(1);
X	/* NOTREACHED */
X    }
X    setbuf(Out, Outbuffer);
X
X    /* Put out a translation table. */
X    Fprintf(Out, "table\n");
X    for (i = ' '; i <= '_'; i++) {
X	(void)putc(i, Out);
X	if (i == ' ' + 31)
X	    (void)putc('\n', Out);
X    }
X    (void)putc('\n', Out);
X
X    /* Print the file's mode and name. */
X    if (fstat(fileno(In), &Sb) < 0) {
X	Fprintf(stderr, "Can't get modes of \"%s\", %s.\n",
X		Name, Ermsg(errno));
X	exit(1);
X	/* NOTREACHED */
X    }
X    Fprintf(Out, "begin %o %s\n", Sb.st_mode & 0777, Name);
X
X    do {
X	/* Read one line, put out the length. */
X	n = fread(buff, sizeof (char), UULINE_SIZE, In);
X	(void)putc(ENC(n), Out);
X
X	/* Put out the line. */
X	for (p = buff, i = 0; i < n; i += 3, p += 3) {
X	    c = (p[0] >> 2);
X	    (void)putc(ENC(c), Out);
X	    c = (p[0] << 4) & 060 | (p[1] >> 4) & 017;
X	    (void)putc(ENC(c), Out);
X	    c = (p[1] << 2) & 074 | (p[2] >> 6) & 03;
X	    (void)putc(ENC(c), Out);
X	    c = p[2] & 077;
X	    (void)putc(ENC(c), Out);
X	}
X	(void)putc('\n', Out);
X    } while (n > 0);
X
X    Fprintf(Out, "end\n");
X
X    (void)fclose(In);
X    (void)fclose(Out);
X}
X
X#ifdef	STANDALONE
Xmain(ac, av)
X    int		 ac;
X    char	*av[];
X{
X    int		 Oops;
X    int		 i;
X
X    /* Parse JCL. */
X    for (Oops = FALSE; (i = getopt(ac, av, "")) != EOF; )
X	switch (i) {
X	default:
X	    Oops = TRUE;
X	    break;
X	}
X    ac -= optind;
X    av += optind;
X
X    if (Oops || ac != 2) {
X	Fprintf(stderr, "Usage:\n  uuencode \n", "infile outfile");
X	exit(1);
X	/* NOTREACHED */
X    }
X
X    uuencode(av[0], av[1]);
X    exit(0);
X    /* NOTREACHED */
X}
X#endif	/* STANDALONE */
END_OF_FILE
if test 2666 -ne `wc -c <'uuencode.c'`; then
    echo shar: \"'uuencode.c'\" unpacked with wrong size!
fi
# end of 'uuencode.c'
fi
if test -f 'uuencode.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'uuencode.man'\"
else
echo shar: Extracting \"'uuencode.man'\" \(1411 characters\)
sed "s/^X//" >'uuencode.man' <<'END_OF_FILE'
X.\" $Header$
X.TH UUENCODE 1L
X.SH NAME
Xuuencode \- decode a binary file into printable encoding
X.SH SYNOPSIS
X.B uuencode
X.I input
X.I output
X.SH DESCRIPTION
X.I Uuencode
Xreads the named binary input file and writes a printable version of it
Xto the named output file.
XThe output file is an ordinary text file and can be edited by any
Xtext editor to change the destination name, add introductory matter,
Xand the like.
XIn particular, it is very common to use
X.I uuencode
Xand
X.I uudecode
Xto send binary files around as electronic mail, Usenet, or general
Xbulletin-board messages.
X.PP
XSeveral versions of the original
X.I uuencode
Xand
X.I uudecode
Xprograms are available and have been widely distributed; luckily, all
Xthe changes seem to have been made in a compatible manner.
XThis distribution does not provide all the features of other versions,
Xjust the basic format and the ``translation table.''
XNo per-line or per-file checksumming is performed, and the
X.SM UNIX
X\&``tilde'' syntax to represent a home directory (e.g.,
X.I \&~rsalz/vmunix
Xrepresents the file named
X.I vmunix
Xin the home directory of the user
X.IR rsalz )
Xis not supported.
XOnly one file can be sent per message; use
X.IR shar (1L)
Xto bundle multiple binary files.
X.PP
X.I "describe translation table"
X.PP
XNote that the encoded file is about 35% bigger (three bytes become four,
Xplus control information) than the original.
X.SH "SEE ALSO"
Xuudecode(1L).
END_OF_FILE
if test 1411 -ne `wc -c <'uuencode.man'`; then
    echo shar: \"'uuencode.man'\" unpacked with wrong size!
fi
# end of 'uuencode.man'
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    echo "Now go find those bugs, and report them to rsalz@uunet.uu.net"
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.