Arc v5.21 (2 of 6)

egray at fthood.UUCP egray at fthood.UUCP
Mon Jan 2 05:37:00 AEST 1989


This is part 2 (of 6) to the Arc v5.21 distribution package.

Emmet P. Gray				US Army, HQ III Corps & Fort Hood
...!uunet!uiucuxc!fthood!egray		Attn: AFZF-DE-ENV
					Directorate of Engineering & Housing
					Environmental Management Office
					Fort Hood, TX 76544-5057

------------------------------------------------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	Arc.1
#	Arcinfo
#	Changes.521
#	Makefile
#	Manifest
#	README
#	Read.me
#	Readme.local
#	Readme.too
#	arc.c
#	arc.h
# This archive created: Sun Jan  1 12:48:09 1989
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Arc.1'" '(7232 characters)'
if test -f 'Arc.1'
then
	echo shar: "will not over-write existing file 'Arc.1'"
else
sed 's/^X//' << \SHAR_EOF > 'Arc.1'
X.TH ARC 1L "12 Jun 1988" "Local" "LOCAL COMMANDS"
X.SH NAME
Xarc \- pc archive utility
X.SH SYNOPSIS
X.B arc
Xa|m|u|f|d|x|e|r|p|l|v|t|c [ biswnoq ] [ g\fIpassword\fR ]
X.I archive 
X[ \fIfilename\fR ...]
X.SH DESCRIPTION
X.I Arc
Xis a general archive and file compression utility, used to maintain
Xa compressed archive of files.
XAn
X.I archive
Xis a single file that combines many files, reducing storage space
Xand allowing multiple files to be handled as one.
X.I Arc
Xuses one of several compression methods for each file within the
X.IR archive ,
Xbased on whichever method yields the smallest result.
X.SH INSTRUCTIONS
XExecute
X.I arc
Xwith no arguments for fairly verbose, usable instructions.
X.SH COMMAND SWITCHES
X.TP 3
Xa
Xadd files to archive.  Copies the indicated files to the archive.
X.TP
Xm
Xmove files to archive.  Same as 'a' switch except
Xthat the files are deleted from the directory as
Xthey are moved to the archive.
X.TP
Xu
Xupdate files in archive.  This switch will replace archived
Xfiles when the named file is newer than the archived copy.
XNew files will be added automatically.
X.TP
Xf
Xfreshen files in archive.  Same as 'u' except that
Xnew files will not be added.
X.TP
Xd
Xdelete files in archive.  The named files are removed from the archive.
X.TP
Xx,e
Xextract files from archive.  The named files are extracted
Xfrom the archive and created in the current directory
Xin an uncompressed state.
X.TP
Xr
Xrun one file with arguments from archive.  Any
Xprogram may be executed directly from the archive.
XThe parameters given after the program name are passed to
Xthe program without modification.
X.TP
Xp
Xcopy files from archive to standard output.  Useful
Xwith I/O redirection. A form-feed is appended after each file,
Xto ease use with printers.
X.TP
Xl
Xlist files in archive.  Limited information listing
Xof files contained in an archive.  Displays the
Xfilename, original length, and date last modified.
XIf the 'n' option (see below) is used, only the
Xfilename is displayed.
X.TP
Xv
Xverbose listing of files in archive.  Complete
Xinformation listing of files contained in an archive.
XDisplays the filename, original length, storage method,
Xstorage factor (% savings), compressed size, date, time,
Xand CRC.
X.TP
Xt
Xtest archive integrity.  Computes CRC values for each member of
Xthe archive and compares against the previously saved value.
X.TP
Xc
Xconvert entry to new packing method.  Convert files
Xstored with older methods to newer methods that are
Xmore efficient. Also useful for files previously
Xarchived with the 's' option.
X.SH OPTIONS
X.TP 3
Xb
Xretain backup copy of archive.  Keep the original
Xarchive file and rename to .BAK.
XThis switch may be used with the
Xfollowing commands:  a, m, u, f, d, c.
X.TP
Xi
Xsuppress image mode.  This switch causes files to
Xbe treated as text files, and will translate their
Xend-of-line sequence. (Unix's '\\n' vs. '\\r\\n' used
Xon many other systems.)  The default is to perform
Xno translation when compressing or extracting files.
XThis option makes dealing with text files much nicer,
Xthough the 'tr' command can also be used. ('\\r' in
Xmakefiles and C source code is such a nuisance...)
X.TP
Xs
Xsuppress compression.  This forces new files to be
Xsaved using Method 2 (no compression).  This switch
Xmay be used with the following commands:  a, m, u, f, c.
X.TP
Xw
Xsuppress warning messages.  This switch will keep
Xwarning messages from being displayed which is the default.
XMost warnings concern the deletion or existence of
Xfiles with the same name.
X.TP
Xn
Xsuppress notes and comments.  This switch will keep
Xuseful notes from being displayed which is the default.
XMost notes indicate what stage of compression is
Xbeing run (analyze, compaction, storage).
X.TP
Xo
Xoverwrite existing files when extracting.  This switch
Xwill make existing files silently get overwritten, instead
Xof asking for confirmation, which is the default.
X.TP
Xq
Xforce Squash compression method.  This switch causes
Xthe Squash compression method to be used, instead of
XCrunch, which is the default.
X.TP
Xg
Xencrypt/decrypt archive entry.  This is used to encode
Xfiles so that others may not read them.  BE CAREFUL!
XThis must be the last parameter in the switches because
Xeverything following is part of the password.
X.SH PROGRAMMING NOTES
X.I Arc
XVersion 2 differs from version 1 in that archive entries
Xare automatically compressed when they are added to the archive,
Xmaking a separate compression step unecessary.  The nature of the
Xcompression is indicated by the header version number placed in
Xeach archive entry, as follows:
X.nf
X         1 = Old style, no compression
X         2 = New style, no compression
X         3 = Compression of repeated characters only
X         4 = Compression of repeated characters plus Huffman SQueezing
X         5 = Lempel-Zev packing of repeated strings (old style)
X         6 = Lempel-Zev packing of repeated strings (new style)
X         7 = Lempel-Zev Williams packing with improved hash function
X         8 = Dynamic Lempel-Zev packing with adaptive reset
X         9 = Squashing
X.fi
X
XType 5, Lempel-Zev packing, was added as of version 4.0
X
XType 6 is Lempel-Zev packing where runs of repeated characters
Xhave been collapsed, and was added as of version 4.1
X
XType 7 is a variation of Lempel-Zev using a different hash
Xfunction which yields speed improvements of 20-25%, and was
Xadded as of version 4.6
X
XType 8 is a different implementation of Lempel-Zev, using a
Xvariable code size and an adaptive block reset, and was added
Xas of version 5.0
X
XType 9 is another variation of Lempel-Zev, using a larger
Xhash table. This method was developed by Phil Katz, and is
Xnot supported by the "official" \fBARC\fP programs.
X
X.I Arc
Xwill look for environment variables named \fIARCTEMP\fP or
X\fITMPDIR\fP, which, if present, indicates the pathname
Xwhere temporary files should be created. This is typically
Xthe location of a RAMdisk on a microcomputer, "/tmp/" or
Xleft unset.
X
XSee the included documentation file for more details.
X.SH HISTORY
X\fIArc\fP has been in use in the CP/M and MSDOS world for many years.
XThom Henderson developed the original version, but it is important to note that
X\fIarc\fP is based on the file compression theories developed by Huffman, Welch,
XKnott, Knuth, and many other scientists. This implementation is based on
Xversion 5.21 of the MSDOS program.
X.SH BUGS
X\fIArc\fP behaves just like the PC version of the program; all functions
Xof the "usage" display are working.
XFull compatibility with PC ARC files is maintained, the price for which is
Xthat \fIarc\fP doesn't like long filenames, and can only archive files with
Xnames of up to 12 characters.
XIt will *sometimes* do The Right Thing with them, but I suggest
Xyou put long-winded filenames in a "shar" before
X.IR arc ing
Xthem.
X
XThere shouldn't be any problems, (hah!) but if you find any, please
Xsend them to me at:
X
X	hyc at umix.cc.umich.edu
X	{rutgers, uunet}!umix!hyc
X
X.SH AUTHORS
XOriginal MSDOS program by Thom Henderson
X.br
XCOPYRIGHT(C) 1985-87 by System Enhancement Associates; ALL RIGHTS RESERVED
X
XOriginal Lempel-Zev code derived from compress 4.0.
XModified to support Squashing by Dan Lanciani (ddl at harvard.edu)
XPorted from MSDOS by Howard Chu (umix!hyc),
Xwith help from John Gilmore (hoptoad!gnu), James Turner (daisy!turner)
Xand others.
SHAR_EOF
if test 7232 -ne "`wc -c < 'Arc.1'`"
then
	echo shar: "error transmitting 'Arc.1'" '(should have been 7232 characters)'
fi
fi
echo shar: "extracting 'Arcinfo'" '(5577 characters)'
if test -f 'Arcinfo'
then
	echo shar: "will not over-write existing file 'Arcinfo'"
else
sed 's/^X//' << \SHAR_EOF > 'Arcinfo'
X
XARC-FILE.INF, created by Keith Petersen, W8SDZ, 21-Sep-86, extracted
Xfrom UNARC.INF by Robert A. Freed.
X
XFrom:     Robert A. Freed
XSubject:  Technical Information for ARC files
XDate:     June 24, 1986
X
XNote: In the following discussion, UNARC refers to my CP/M-80 program
Xfor extracting files from MSDOS ARCs.  The definitions of the ARC file
Xformat are based on MSDOS ARC512.EXE.
X
XARCHIVE FILE FORMAT
X-------------------
X
XComponent files are stored sequentially within an archive.  Each entry
Xis preceded by a 29-byte header, which contains the directory
Xinformation.  There is no wasted space between entries.  (This is in
Xcontrast to the centralized directory used by Novosielski libraries.
XAlthough random access to subfiles within an archive can be noticeably
Xslower than with libraries, archives do have the advantage of not
Xrequiring pre-allocation of directory space.)
X
XArchive entries are normally maintained in sorted name order.  The
Xformat of the 29-byte archive header is as follows:
X
XByte 1:  1A Hex.
X         This marks the start of an archive header.  If this byte is not found 
X         when expected, UNARC will scan forward in the file (up to 64K bytes) 
X         in an attempt to find it (followed by a valid compression version).  
X         If a valid header is found in this manner, a warning message is 
X         issued and archive file processing continues.  Otherwise, the file is 
X         assumed to be an invalid archive and processing is aborted.  (This is 
X         compatible with MS-DOS ARC version 5.12).  Note that a special 
X         exception is made at the beginning of an archive file, to accomodate 
X         "self-unpacking" archives (see below).
X
XByte 2:  Compression version, as follows:
X
X         0 = end of file marker (remaining bytes not present)
X         1 = unpacked (obsolete)
X         2 = unpacked
X         3 = packed
X         4 = squeezed (after packing)
X         5 = crunched (obsolete)
X         6 = crunched (after packing) (obsolete)
X         7 = crunched (after packing, using faster hash algorithm) (obsolete)
X         8 = crunched (after packing, using dynamic LZW variations)
X
XBytes 3-15:  ASCII file name, nul-terminated.
X
X(All of the following numeric values are stored low-byte first.)
X
XBytes 16-19:  Compressed file size in bytes.
X
XBytes 20-21:  File date, in 16-bit MS-DOS format:
X              Bits 15:9 = year - 1980
X              Bits  8:5 = month of year
X              Bits  4:0 = day of month
X              (All zero means no date.)
X
XBytes 22-23:  File time, in 16-bit MS-DOS format:
X              Bits 15:11 = hour (24-hour clock)
X              Bits 10:5  = minute
X              Bits  4:0  = second/2 (not displayed by UNARC)
X
XBytes 24-25:  Cyclic redundancy check (CRC) value (see below).
X
XBytes 26-29:  Original (uncompressed) file length in bytes.
X              (This field is not present for version 1 entries, byte 2 = 1.  
X              I.e., in this case the header is only 25 bytes long.  Because 
X              version 1 files are uncompressed, the value normally found in 
X              this field may be obtained from bytes 16-19.)
X
X
XSELF-UNPACKING ARCHIVES
X-----------------------
X
XA "self-unpacking" archive is one which can be renamed to a .COM file
Xand executed as a program.  An example of such a file is the MS-DOS
Xprogram ARC512.COM, which is a standard archive file preceded by a
Xthree-byte jump instruction.  The first entry in this file is a simple
X"bootstrap" program in uncompressed form, which loads the subfile
XARC.EXE (also uncompressed) into memory and passes control to it.  In
Xanticipation of a similar scheme for future distribution of UNARC, the
Xprogram permits up to three bytes to precede the first header in an
Xarchive file (with no error message).
X
X
XCRC COMPUTATION
X---------------
X
XArchive files use a 16-bit cyclic redundancy check (CRC) for error
Xcontrol.  The particular CRC polynomial used is x^16 + x^15 + x^2 + 1,
Xwhich is commonly known as "CRC-16" and is used in many data
Xtransmission protocols (e.g. DEC DDCMP and IBM BSC), as well as by
Xmost floppy disk controllers.  Note that this differs from the CCITT
Xpolynomial (x^16 + x^12 + x^5 + 1), which is used by the XMODEM-CRC
Xprotocol and the public domain CHEK program (although these do not
Xadhere strictly to the CCITT standard).  The MS-DOS ARC program does
Xperform a mathematically sound and accurate CRC calculation.  (We
Xmention this because it contrasts with some unfortunately popular
Xpublic domain programs we have witnessed, which from time immemorial
Xhave based their calculation on an obscure magazine article which
Xcontained a typographical error!)
X
XAdditional note (while we are on the subject of CRC's): The validity
Xof using a 16-bit CRC for checking an entire file is somewhat
Xquestionable.  Many people quote the statistics related to these
Xfunctions (e.g. "all two-bit errors, all single burst errors of 16 or
Xfewer bits, 99.997% of all single 17-bit burst errors, etc."), without
Xrealizing that these claims are valid only if the total number of bits
Xchecked is less than 32767 (which is why they are used in small-packet
Xdata transmission protocols).  I.e., for file sizes in excess of about
X4K bytes, a 16-bit CRC is not really as good as what is often claimed.
XThis is not to say that it is bad, but there are more reliable methods
Xavailable (e.g. the 32-bit AUTODIN-II polynomial).  (End of lecture!)
X
X                           Bob Freed
X                           62 Miller Road
X                           Newton Centre, MA  02159
X                           Telephone (617) 332-3533
X
X
SHAR_EOF
if test 5577 -ne "`wc -c < 'Arcinfo'`"
then
	echo shar: "error transmitting 'Arcinfo'" '(should have been 5577 characters)'
fi
fi
echo shar: "extracting 'Changes.521'" '(1892 characters)'
if test -f 'Changes.521'
then
	echo shar: "will not over-write existing file 'Changes.521'"
else
sed 's/^X//' << \SHAR_EOF > 'Changes.521'
X                        CHANGES IN VERSION 5.21
X
X
XThe following changes have been made in ARC version 5.21, but have not
Xyet been included in the manual:
X
Xo   When adding files to an archive, ARC now shows the stowage facter
X    achieved on each file.
X
Xo   A bug was found that would keep an archive entry from being
X    encrypted if it was stored without compression.  This has now been
X    fixed.
X
Xo   If changes are made to a corrupted archive, the corrupted entries
X    are discarded.  This makes it possible to lose data accidentally.
X    ARC will now only make changes to a corrupted archive if the W
X    (suppress Warnings) option has been given.
X
Xo   The N (suppress Notes) option now suppresses the "Creating
X    archive" note when a new archive is being created.
X
Xo   The N (suppress Notes) option formerly did nothing useful when
X    used with the L (List files) command.  It now causes a terse
X    listing of filenames only, suitable for use with pipes and
X    redirection.
X
Xo   The list of filenames given to ARC may now include indirect
X    references.  If a filename begins with an "at sign" ("@"), it is
X    taken to be the name of a file which contains a list of file
X    names.  The list of file names may include further indirection.
X    If no extension is given, ".CMD" is assumed.  For example, the
X    command:
X
X         arc a waste junk.txt @trash
X
X    would cause ARC to add JUNK.TXT plus all files listed in the file
X    TRASH.CMD to an archive named WASTE.ARC.  If no file is specified,
X    then the list is read from standard input.  For example, the
X    command:
X
X         arc ln waste | arc a trash @
X
X    would cause ARC to add files to TRASH.ARC based on the names of
X    the files stored in WASTE.ARC.  It is probably a good idea to give
X    the O (Overwrite) option if you are extracting files this way.
X
X    Version 5.21 of MARC also allows for indirection.
SHAR_EOF
if test 1892 -ne "`wc -c < 'Changes.521'`"
then
	echo shar: "error transmitting 'Changes.521'" '(should have been 1892 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(4440 characters)'
if test -f 'Makefile'
then
	echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X#
X#       Makefile for Arc v5.21
X#
X# Originals from Dan Lanciani, James Turner, and others...
X#
X# Modified to support squashing, also added targets for the time routine
X# library.  -- Howard Chu, hyc at umix.cc.umich.edu, 4-11-88
X#
X# Modified again by John Gilmore & Howard Chu, July 1988.
X#
X# I put SRCDIR on a real disk on the ST, but copy the makefile to a
X# RAMdisk and compile from there. Makes things go a bit quicker...
X# This has to be done in the shell, to get the trailing backslash
X# specified correctly. e.g., setenv SRCDIR='d:\src\arc\'
XSRCDIR = 
X
XHEADER = $(SRCDIR)arc.h $(SRCDIR)arcs.h
X
X# Add a ".TTP" suffix to the executable files on an ST.
X#PROG = .ttp
XPROG =
X
X# SYSTEM defines your operating system:
X# MSDOS for IBM PCs or other MSDOS machines
X# GEMDOS for Atari ST (Predefined by MWC, so you don't need to define it.)
X# BSD for Berkeley Unix
X# SYSV for AT&T System V Unix
X# (MTS for Michigan Terminal System, which requires a different makefile)
X# (MTS also requires one of USEGFINFO or USECATSCAN for directory search)
XSYSTEM = -DSYSV=1
X
X# For MWC 3.0 on the Atari ST, use:
X#CFLAGS = -VCOMPAC -VPEEP
XCFLAGS = -O $(SYSTEM) -Dabort=xabort -Dgetch=xgetch -DLOCAL
XLDFLAGS = -s
XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile
X
X# GNU's gcc is very nice, if you've got it. Otherwise just cc.
XCC = cc
X
X# tmclock is only needed on Unix systems...
XTMCLOCK = tmclock.o
X
X# Files needed for System V 
XSYSVOBJ =	getwd.o rename.o scandir.o utimes.o
X#SYSVOBJ =
X
XOBJS = arc.o arcadd.o arccode.o arccvt.o arcdata.o arcdel.o arcdos.o \
Xarcext.o arcio.o arclst.o arclzw.o arcmatch.o arcpack.o arcrun.o \
Xarcsq.o arcsqs.o arcsvc.o arctst.o arcunp.o arcusq.o arcmisc.o $(SYSVOBJ)
X
XMOBJ = marc.o arcdata.o arcdos.o arcio.o arcmatch.o arcmisc.o $(SYSVOBJ)
X
Xall:	arc$(PROG) $(PROG)marc
X
Xarc$(PROG):	$(OBJS) $(TMCLOCK) 
X#	$(CC) $(LDFLAGS) -o arc$(PROG) $(OBJS) $(TMCLOCK)
X	$(LD) $(LDFLAGS) -o arc$(PROG) $(OBJS) $(TMCLOCK) $(SHAREDLIB)
X
Xmarc$(PROG):	$(MOBJ) $(TMCLOCK)
X#	$(CC) $(LDFLAGS) -o marc$(PROG) $(MOBJ) $(TMCLOCK)
X	$(LD) $(LDFLAGS) -o marc$(PROG) $(MOBJ) $(TMCLOCK) $(SHAREDLIB)
X
Xclean:
X	-rm *.o arc$(PROG) marc$(PROG)
X
Xshar:
X	shar -a Arc521.doc > arc_sh.1
X	shar -a Arc.1 Arcinfo Changes.521 Makefile Manifest README \
X	Read.me Readme.local Readme.too arc.c arc.h > arc_sh.2
X	shar -a arcadd.c arccode.c arccvt.c arcdata.c arcdel.c arcdos.c \
X	arcext.c arcio.c arclst.c > arc_sh.3
X	shar -a arclzw.c arcmatch.c arcmisc.c arcpack.c arcrun.c arcs.h \
X	> arc_sh.4
X	shar -a arcsq.c arcsqs.c arcsvc.c arctst.c arcunp.c arcusq.c \
X	getwd.c > arc_sh.5
X	shar -a marc.c memset.c rename.c scandir.3 scandir.c tmclock.c \
X	utimes.c > arc_sh.6
X
Xarc.o:	$(SRCDIR)arc.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arc.c
Xmarc.o:	$(SRCDIR)marc.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)marc.c
Xarcadd.o:	$(SRCDIR)arcadd.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcadd.c
Xarccode.o:	$(SRCDIR)arccode.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arccode.c
Xarccvt.o:	$(SRCDIR)arccvt.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arccvt.c
Xarcdata.o:	$(SRCDIR)arcdata.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcdata.c
Xarcdel.o:	$(SRCDIR)arcdel.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcdel.c
Xarcdir.o:	$(SRCDIR)arcdir.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcdir.c
Xarcdos.o:	$(SRCDIR)arcdos.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcdos.c
Xarcext.o:	$(SRCDIR)arcext.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcext.c
Xarcio.o:	$(SRCDIR)arcio.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcio.c
Xarclst.o:	$(SRCDIR)arclst.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arclst.c
Xarclzw.o:	$(SRCDIR)arclzw.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arclzw.c
Xarcmatch.o:	$(SRCDIR)arcmatch.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcmatch.c
Xarcmisc.o:	$(SRCDIR)arcmisc.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcmisc.c
Xarcpack.o:	$(SRCDIR)arcpack.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcpack.c
Xarcrun.o:	$(SRCDIR)arcrun.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcrun.c
Xarcsq.o:	$(SRCDIR)arcsq.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcsq.c
Xarcsqs.o:	$(SRCDIR)arcsqs.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcsqs.c
Xarcsvc.o:	$(SRCDIR)arcsvc.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcsvc.c
Xarctst.o:	$(SRCDIR)arctst.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arctst.c
Xarcunp.o:	$(SRCDIR)arcunp.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcunp.c
Xarcusq.o:	$(SRCDIR)arcusq.c	$(HEADER)
X	$(CC) $(CFLAGS) -c $(SRCDIR)arcusq.c
X
Xtmclock.o:	$(SRCDIR)tmclock.c
X	$(CC) $(CFLAGS) -c $(SRCDIR)tmclock.c
SHAR_EOF
if test 4440 -ne "`wc -c < 'Makefile'`"
then
	echo shar: "error transmitting 'Makefile'" '(should have been 4440 characters)'
fi
fi
echo shar: "extracting 'Manifest'" '(2413 characters)'
if test -f 'Manifest'
then
	echo shar: "will not over-write existing file 'Manifest'"
else
sed 's/^X//' << \SHAR_EOF > 'Manifest'
XContents of this distribution....
X   5577 Apr 11 19:15 Arcinfo	   Description of .ARC file format
X  54144 Jun 13 05:26 Arc521.doc	   Full program documentation, no CRs.
X   1892 May 14  1987 Changes.521   Differences between 5.20 and 5.21
X   1323 Apr 11 19:10 Make.tws	   Makefile for the time routine library
X   1731 Jun 13 03:58 Makefile	   Makefile for ARC
X   2413 Jun 13 05:29 Manifest	   This file
X   2269 Jun 18 03:39 Read.me	   Spiel
X   2190 Jun 13 04:23 Readme.too	   More spiel
X  18327 Jun 13 04:09 Sysvarcstuf   Useful for Sys V users.
X   7232 Jun 12 19:31 arc.1	   A man page, *roff source
X  11116 Jun 13 04:27 arc.c	   Main routine, option parser...
X   3318 Jun  1 19:59 arc.h	   System dependencies, externs
X   9286 Jun 13 00:31 arcadd.c	   Top level routine for adding to archive
X   1204 Jun  1 15:16 arccode.c	   Code for file encryption/decryption
X   3396 Jun  1 19:18 arccvt.c	   Convert to new packing method
X   2070 Jun 13 04:26 arcdata.c	   Declarations of externs from arc.h
X   2055 Apr 19 01:39 arcdel.c	   Delete files from archive
X   4970 Jun 13 00:41 arcdos.c	   OS specific file management routines
X   4897 Jun  1 20:18 arcext.c	   Top level routine for extraction
X   7384 Jun  2 16:27 arcio.c	   OS specific low-level I/O routines
X   4418 Jun  1 18:06 arclst.c	   List contents of archive
X  22109 Jun  1 20:01 arclzw.c	   Low-level Lempel-Zev compression
X   3026 Jun  1 19:41 arcmatch.c	   Pattern matching routines
X   8319 Jun 13 04:07 arcmisc.c	   OS specific miscellaneous functions
X   7376 Jun  2 16:27 arcpack.c	   Mid-level compression code
X   3838 Jun  1 19:57 arcrun.c	   Run files from archive
X   1645 Apr 17 18:53 arcs.h	   Declaration of .ARC header format
X  14613 Jun  2 16:27 arcsq.c	   Low-level Huffman Squeeze code
X  11587 Jun  1 20:02 arcsqs.c	   Low-level Squash code
X   4680 Jun 13 00:43 arcsvc.c	   .ARC file utilities
X   1284 Apr 19 01:40 arctst.c	   Test archive integrity
X   5325 Jun  7 03:16 arcunp.c	   Mid-level extraction code
X   2484 Jun  2 16:28 arcusq.c	   Low-level Huffman unSqueezer
X   9035 Apr 11 19:10 dtime.c	   sources for the time routine library...
X   7327 Apr 11 19:11 dtimep.lex
X    356 Apr 11 19:12 lexedit.sed
X   3765 Apr 11 19:12 lexstring.c
X   2241 Apr 11 19:13 libtws.3	   man page for the time routine library
X   9053 Jun  6 01:04 marc.c	   source for the marc program
X   2993 Jun  2 00:38 tws.h	   header file for the time routine library
SHAR_EOF
if test 2413 -ne "`wc -c < 'Manifest'`"
then
	echo shar: "error transmitting 'Manifest'" '(should have been 2413 characters)'
fi
fi
echo shar: "extracting 'README'" '(539 characters)'
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
sed 's/^X//' << \SHAR_EOF > 'README'
XThe enclosed files should be sufficient for bringing up ARC on a Sys V R3
Xsystem. As Jon mentions, Doug Gwyn's directory routines are needed for
XSys V R2. The enclosed copy of scandir is new, as far as I can tell, and
XI've removed the (unneeded) ftw.? files. Also added a rename() routine,
Xcourtesy of Janet Walz. (And an addition from Rich Salz.)
X
X[see comp.sources.unix, volume 9, for gwyn-dir-lib...]
X
XThanks again to Jon Zeeff, Janet Walz, and Rich Salz for their help.
X  -- Howard Chu
X	hyc at umix.cc.umich.edu
X	{uunet,rutgers}!umix!hyc
SHAR_EOF
if test 539 -ne "`wc -c < 'README'`"
then
	echo shar: "error transmitting 'README'" '(should have been 539 characters)'
fi
fi
echo shar: "extracting 'Read.me'" '(2269 characters)'
if test -f 'Read.me'
then
	echo shar: "will not over-write existing file 'Read.me'"
else
sed 's/^X//' << \SHAR_EOF > 'Read.me'
XHello again,
X	herein you should be pleased to find the complete sources for the
Xlatest and greatest version of ARC, based on the sources for version 5.21
Xof the MSDOS ARC program. The patches to the previous release, 5.12, with
Xsquashing algorithm, have also been applied here. The code is known to
Xwork on a Sun 3 running SunOS 3.4, Apollo DN3000 running SR9.7 DOMAIN/IX,
XVax 750 running 4.3BSD, and IBM 3090 running MTS. It is also now working
Xon Atari STs, as well as Apollo DN3000 running SR10 DOMAIN/OS (Beta).
X
X	Also included is a detailed description of the format of a .ARC
Xfile directory entry, in the file named Arcinfo. Could be useful if you're
Xtrying to port ARC to any more esoteric systems...
X
X	Jon Zeeff has sent along some code he used to get this working on
XSys V style machines. Looks like scandir is all that's really missing. I
Xhaven't tried any of it out for myself yet, but the code is in the file
X"Sysvarcstuf" should you need it.
X
X	One final necessary inclusion: sources for libtws.a, which was
Xposted a long time ago to mod.sources as part of a package he called
X"phoon" - a program that calculated and displayed the PHase of the mOON.
XThe only thing I use the time routines for here is to convert an expanded
Xdate/time back into a Unix style time value, for keeping file modification
Xtimes straight.
X
X	Thanks to Leo Wilson (leo at cs.buffalo.edu) for sending his copy of
Xa man page for ARC. I've updated it for this version, and included it here
Xas well.
X
X	The default value of the (I)mage mode flag has changed. ARC will
Xnow treat files as binary files, unless the 'i' flag is given. Handling of
XCarriage Returns has been improved a bit. ARC is now a little smarter about
Xtemporary files as well.
X
XTo compile all this stuff... Edit Make.tws (shouldn't need to change anything
Xhere, really.) Edit arc.h. After that, just type make and wait a while...
X(Oh yeah - there's a few makefile macros that need redefining for Atari ST...)
XOk... Well, I've had this for a while, and it works for me, but if somehow
XI've goofed, let me know.
X	
X  /
X /_ , ,_.                      Howard Chu
X/ /(_/(__                University of Michigan
X    /           Computing Center          College of LS&A
X   '              Unix Project          Information Systems
SHAR_EOF
if test 2269 -ne "`wc -c < 'Read.me'`"
then
	echo shar: "error transmitting 'Read.me'" '(should have been 2269 characters)'
fi
fi
echo shar: "extracting 'Readme.local'" '(777 characters)'
if test -f 'Readme.local'
then
	echo shar: "will not over-write existing file 'Readme.local'"
else
sed 's/^X//' << \SHAR_EOF > 'Readme.local'
X
XThis distribution of Arc v5.21 was derived almost entirely from work by
XHoward Chu (uunet!umix!hyc).
X
XWith the use of the preprocessor definition LOCAL, you can include my
Xlocal enhancements and changes.  The following changes were made:
X
X	1) By default, Unix file names are changed to meet MSDOS
X	file name restrictions when added to an archive.  Also, 
X	file names are folded to lowercase when extracted.  This
X	feature can be disabled by the use of the -z option.
X
X	2) Duplicate file names no longer cause a fatal error, the
X	second file name is mearly skipped.
X
XEmmet P. Gray				US Army, HQ III Corps & Fort Hood
X...!uunet!uiucuxc!fthood!egray		Attn: AFZF-DE-ENV
X					Directorate of Engineering & Housing
X					Environmental Management Office
X					Fort Hood, TX 76544-5057
SHAR_EOF
if test 777 -ne "`wc -c < 'Readme.local'`"
then
	echo shar: "error transmitting 'Readme.local'" '(should have been 777 characters)'
fi
fi
echo shar: "extracting 'Readme.too'" '(4064 characters)'
if test -f 'Readme.too'
then
	echo shar: "will not over-write existing file 'Readme.too'"
else
sed 's/^X//' << \SHAR_EOF > 'Readme.too'
XNotes for ARC 5.21                                        June 6, 1988
X 
XThis program is based on the MSDOS ARC program, version 5.21, plus
Xa few enhancements... 
X 
X o ARC also performs Huffman Squeezing on data. The Huffman Squeeze
X   algorithm was removed from MSDOS ARC after version 5.12. It turns
X   out to be more efficient than Lempel-Ziv style compression when
X   compressing graphic images. Squeeze analysis is always done now,
X   and the best of packing, squeezing, or crunching is used.
X 
X o Compresses and extracts Squashed files. "Squashing" was created
X   by Phil Katz in his PKxxx series of ARC utility programs for
X   MSDOS. Dan Lanciani wrote the original modifications to ARC's
X   Crunch code to handle Squashing. I've made minor changes since
X   then, mostly to reduce the amount of memory required. The 'q'
X   option flag must be specified to Squash files. The Squashing
X   algorithm will be used instead of the usual Crunch algorithm,
X   and will be compared against packing and squeezing, as before.
X 
XSystem specific notes:
X 
X   On MTS, an additional option flag, 'i' for "image mode," was
Xused. ARC assumes files are text, by default, and will translate
XMTS files from EBCDIC to ASCII before storing in an archive, and
Xtranslates from ASCII to EBCDIC upon extraction. Specifying the
X'i' flag will inhibit this translation. This would most commonly
Xbe used when shipping binary images such as TeX DVI files, other
X.ARC files stored within an archive, etc... The 'r' (run) command
Xis omitted. It just doesn't seem very useful. Also, ARC cannot
Xrestore MTS files with their original time stamps. (Maybe in a
Xfuture release...)
X 
X   On Unix(tm) systems, the 'i' flag is also present. Unix ARC
Xassumes a binary file, by default. Here the only translation
Xinvolved is in end-of-line processing. When storing text files, ARC will
Xchange '\n' to '\r\n', and does the opposite when extracting files.
XCarriage returns in any other location are preserved when extracting.
XThis translation only occurs if the 'i' flag is given.
X
X   On the Atari ST, the 'h' (for "hold screen") option is present,
Xwhich simply delays exiting the program. This is typically used when
Xexecuting ARC from the desktop, to allow reading all of ARC's output
Xbefore the screen is cleared and the desktop is redrawn. The program
Xwill prompt and wait for a keypress before exiting. Note that since
Xthere are no "options" for the MARC program, the "hold screen" option
Xis always active for MARC.
X 
X   On both Unix and Atari systems, ARC & MARC will search for an
Xenvironment variable named "ARCTEMP" or "TMPDIR." If present, any
Xtemporary files will be created in the specified directory. This is
Xprobably insignificant for Unix users, but can be handy on the Atari,
Xin combination with a RAMdisk. Highly recommended for floppy users.
X(Unfortunately, you can only take advantage of this when running some
Xform of command shell that allows setting environment variables. Thus,
Xyou won't see any speed gains when running from the desktop.)
X 
X 
XThat about covers things. The enclosed documentation is taken directly
Xfrom the MSDOS distribution of ARC. Unless specified differently here,
Xthe programs behave indentically. Note that ARC521.DOC is identical to
XARC520.DOC - the differences between the two versions are described in
Xthe file CHANGES.521.
X 
XOh yeah - this program may be distributed freely so long as you don't
Xmodify it in any way. You may not charge for distributing it. (Don't
Xfeel bad, I can't charge for it either. }-) It'd be nice if you kept
Xthis and the other enclosed doc files with it when distributing, but
XI'm not going to make a fuss about it. Most people are so familiar
Xwith the program by now that it wouldn't matter much anyway. You
Xshould keep this README file around, so bug reports & such will find
Xtheir way back to me. (Bugs? What bugs? Nah, there aren't any bugs...)
X 
X         /                 Howard Chu
X   ___  /_ , ,_.     University of Michigan
X       / /(_/(__     hyc at umix.cc.umich.edu
X           /                umix!hyc
X          '     
SHAR_EOF
if test 4064 -ne "`wc -c < 'Readme.too'`"
then
	echo shar: "error transmitting 'Readme.too'" '(should have been 4064 characters)'
fi
fi
echo shar: "extracting 'arc.c'" '(12303 characters)'
if test -f 'arc.c'
then
	echo shar: "will not over-write existing file 'arc.c'"
else
sed 's/^X//' << \SHAR_EOF > 'arc.c'
X/*
X * $Header: arc.c,v 1.13 88/11/01 02:22:23 hyc Exp $
X */
X
X/*  ARC - Archive utility
X  
X    Version 5.21, created on 04/22/87 at 15:05:21
X  
X(C) COPYRIGHT 1985-87 by System Enhancement Associates; ALL RIGHTS RESERVED
X  
X    By:	 Thom Henderson
X  
X    Description:
X	 This program is a general archive utility, and is used to maintain
X	 an archive of files.  An "archive" is a single file that combines
X	 many files, reducing storage space and allowing multiple files to
X	 be handled as one.
X  
X    Instructions:
X	 Run this program with no arguments for complete instructions.
X  
X    Programming notes:
X	 ARC Version 2 differs from version 1 in that archive entries
X	 are automatically compressed when they are added to the archive,
X	 making a separate compression step unecessary.	 The nature of the
X	 compression is indicated by the header version number placed in
X	 each archive entry, as follows:
X  
X	 1 = Old style, no compression
X	 2 = New style, no compression
X	 3 = Compression of repeated characters only
X	 4 = Compression of repeated characters plus Huffman SQueezing
X	 5 = Lempel-Zev packing of repeated strings (old style)
X	 6 = Lempel-Zev packing of repeated strings (new style)
X	 7 = Lempel-Zev Williams packing with improved hash function
X	 8 = Dynamic Lempel-Zev packing with adaptive reset
X	 9 = Dynamic Lempel-Zev packing, larger hash table
X  
X	 Type 5, Lempel-Zev packing, was added as of version 4.0
X  
X	 Type 6 is Lempel-Zev packing where runs of repeated characters
X	 have been collapsed, and was added as of version 4.1
X  
X	 Type 7 is a variation of Lempel-Zev using a different hash
X	 function which yields speed improvements of 20-25%, and was
X	 added as of version 4.6
X  
X	 Type 8 is a different implementation of Lempel-Zev, using a
X	 variable code size and an adaptive block reset, and was added
X	 as of version 5.0
X  
X	 Type 9 is a slight modification of type 8, first used by Phil
X	 Katz in his PKARC utilites. The primary difference is the use
X	 of a hash table twice as large as for type 8, and that this
X	 algorithm called Squashing, doesn't perform run-length encoding
X	 on the input data.
X  
X	 Verion 4.3 introduced a temporary file for holding the result
X	 of the first crunch pass, thus speeding up crunching.
X  
X	 Version 4.4 introduced the ARCTEMP environment string, so that
X	 the temporary crunch file may be placed on a ramdisk.	Also
X	 added was the distinction bewteen Adding a file in all cases,
X	 and Updating a file only if the disk file is newer than the
X	 corresponding archive entry.
X  
X	 The compression method to use is determined when the file is
X	 added, based on whichever method yields the smallest result.
X  
X    Language:
X	 Computer Innovations Optimizing C86
X*/
X#include <stdio.h>
X#include "arc.h"
X
X#if	UNIX
X#include <sys/types.h>
X#include <sys/stat.h>
X#endif
X
X#ifdef LOCAL
Xint unix_names = 0;
X#endif /* LOCAL */
X
Xint		strlen();
Xvoid		addarc(), delarc(), extarc(), lstarc(), tstarc(), cvtarc(), runarc();
Xvoid		abort();
Xstatic	void	expandlst();
X#if	MTS
Xvoid		etoa();
X#endif
X#if	GEMDOS
Xlong		_stksize = 65536L;
X#endif
Xchar		*strcpy(), *strcat();
Xchar		*makefnam();	/* filename fixup routine */
X
Xstatic char   **lst;		/* files list */
Xstatic int	lnum;		/* length of files list */
X
Xmain(num, arg)			/* system entry point */
X	int		num;	/* number of arguments */
X	char	       *arg[];	/* pointers to arguments */
X{
X	char		opt = 0;/* selected action */
X	char	       *a;	/* option pointer */
X	void		upper();/* case conversion routine */
X	char	       *index();/* string index utility */
X	char	       *envfind();	/* environment searcher */
X	int		n;	/* index */
X	char	       *arctemp2, *calloc(), *mktemp();
X#if	GEMDOS
X	void		exitpause();
X	int		append;
X#endif
X#if	MTS
X	fortran void	guinfo();
X	char		gotinf[4];
X#endif
X#if	UNIX
X	struct	stat	sbuf;
X#endif
X
X	if (num < 3) {
X		printf("ARC - Archive utility, Version 5.21, created on 04/22/87 at 15:05:21\n");
X/*		printf("(C) COPYRIGHT 1985,86,87 by System Enhancement Associates;");
X		printf(" ALL RIGHTS RESERVED\n\n");
X		printf("Please refer all inquiries to:\n\n");
X		printf("       System Enhancement Associates\n");
X		printf("       21 New Street, Wayne NJ 07470\n\n");
X		printf("You may copy and distribute this program freely,");
X		printf(" provided that:\n");
X		printf("    1)	 No fee is charged for such copying and");
X		printf(" distribution, and\n");
X		printf("    2)	 It is distributed ONLY in its original,");
X		printf(" unmodified state.\n\n");
X		printf("If you like this program, and find it of use, then your");
X		printf(" contribution will\n");
X		printf("be appreciated.	 You may not use this product in a");
X		printf(" commercial environment\n");
X		printf("or a governmental organization without paying a license");
X		printf(" fee of $35.  Site\n");
X		printf("licenses and commercial distribution licenses are");
X		printf(" available.  A program\n");
X		printf("disk and printed documentation are available for $50.\n");
X		printf("\nIf you fail to abide by the terms of this license, ");
X		printf(" then your conscience\n");
X		printf("will haunt you for the rest of your life.\n\n"); */
X#if	MSDOS
X		printf("Usage: ARC {amufdxerplvtc}[bswnoq][g<password>]");
X#endif
X#if	GEMDOS
X		printf("Usage: ARC {amufdxerplvtc}[bhswnoq][g<password>]");
X#endif
X#if	UNIX
X#ifdef LOCAL
X		printf("Usage: arc {amufdxerplvtc}[biswnoqz][g<password>]");
X#else /* LOCAL */
X		printf("Usage: arc {amufdxerplvtc}[biswnoq][g<password>]");
X#endif /* LOCAL */
X#endif
X#if	MTS
X		printf("Parameters: {amufdxeplvtc}[biswnoq][g<password>]");
X#endif
X		printf(" <archive> [<filename> . . .]\n");
X		printf("Where:	 a   = add files to archive\n");
X		printf("	 m   = move files to archive\n");
X		printf("	 u   = update files in archive\n");
X		printf("	 f   = freshen files in archive\n");
X		printf("	 d   = delete files from archive\n");
X		printf("	 x,e = extract files from archive\n");
X#if	!MTS
X		printf("	 r   = run files from archive\n");
X#endif
X		printf("	 p   = copy files from archive to");
X		printf(" standard output\n");
X		printf("	 l   = list files in archive\n");
X		printf("	 v   = verbose listing of files in archive\n");
X		printf("	 t   = test archive integrity\n");
X		printf("	 c   = convert entry to new packing method\n");
X		printf("	 b   = retain backup copy of archive\n");
X#if	GEMDOS
X		printf("	 h   = hold screen after finishing\n");
X#endif
X#if	MTS
X		printf("	 i   = suppress ASCII/EBCDIC translation\n");
X#endif
X#if	UNIX
X		printf("	 i   = suppress image mode (translate EOL)\n");
X#endif
X		printf("	 s   = suppress compression (store only)\n");
X		printf("	 w   = suppress warning messages\n");
X		printf("	 n   = suppress notes and comments\n");
X		printf("	 o   = overwrite existing files when");
X		printf(" extracting\n");
X		printf("	 q   = squash instead of crunching\n");
X		printf("	 g   = Encrypt/decrypt archive entry\n");
X#ifdef LOCAL
X		printf("	 z   = use Unix file names (as much as possible)\n");
X#endif /* LOCAL */
X		printf("\nAdapted from MSDOS by Howard Chu\n");
X		/*
X		 * printf("\nPlease refer to the program documentation for");
X		 * printf(" complete instructions.\n"); 
X		 */
X#if	GEMDOS
X		exitpause();
X#endif
X		return 1;
X	}
X	/* see where temp files go */
X#if	!MTS
X	arctemp = calloc(1, STRLEN);
X	if (!(arctemp2 = envfind("ARCTEMP")))
X		arctemp2 = envfind("TMPDIR");
X	if (arctemp2) {
X		strcpy(arctemp, arctemp2);
X		n = strlen(arctemp);
X		if (arctemp[n - 1] != CUTOFF)
X			arctemp[n] = CUTOFF;
X	}
X#if	UNIX
X	else	strcpy(arctemp, "/tmp/");
X#endif
X#if	!MSDOS
X	{
X		static char tempname[] = "AXXXXXX";
X		strcat(arctemp, mktemp(tempname));
X	}
X#else
X	strcat(arctemp, "$ARCTEMP");
X	arctemp2 = NULL;
X#endif
X#else
X	guinfo("SHFSEP	", gotinf);
X	sepchr[0] = gotinf[0];
X	guinfo("SCRFCHAR", gotinf);
X	tmpchr[0] = gotinf[0];
X	arctemp = "-$$$";
X	arctemp[0] = tmpchr[0];
X#endif
X
X#if	!UNIX
X	/* avoid any case problems with arguments */
X
X	for (n = 1; n < num; n++)	/* for each argument */
X		upper(arg[n]);	/* convert it to uppercase */
X#else
X	/* avoid case problems with command options */
X	upper(arg[1]);		/* convert to uppercase */
X#endif
X
X	/* create archive names, supplying defaults */
X#if	UNIX
X	if (!stat(arg[2],&sbuf)) {
X		if ((sbuf.st_mode & S_IFMT) == S_IFDIR)
X			makefnam(arg[2],".arc",arcname);
X		else
X			strcpy(arcname,arg[2]);
X	} else
X		makefnam(arg[2],".arc",arcname);
X#else
X	makefnam(arg[2], ".ARC", arcname);
X#endif
X	/* makefnam(".$$$",arcname,newname); */
X	sprintf(newname, "%s.arc", arctemp);
X	makefnam(".BAK", arcname, bakname);
X
X	/* now scan the command and see what we are to do */
X
X	for (a = arg[1]; *a; a++) {	/* scan the option flags */
X#if	!MTS
X		if (index("AMUFDXEPLVTCR", *a)) {	/* if a known command */
X#else
X		if (index("AMUFDXEPLVTC", *a)) {
X#endif
X			if (opt)/* do we have one yet? */
X				abort("Cannot mix %c and %c", opt, *a);
X			opt = *a;	/* else remember it */
X		} else if (*a == 'B')	/* retain backup copy */
X			keepbak = 1;
X
X		else if (*a == 'W')	/* suppress warnings */
X			warn = 0;
X#if	!DOS
X		else if (*a == 'I')	/* image mode, no ASCII/EBCDIC x-late */
X			image = !image;
X#endif
X#if	GEMDOS
X		else if (*a == 'H')	/* pause before exit */
X			hold = 1;
X#endif
X
X		else if (*a == 'N')	/* suppress notes and comments */
X			note = 0;
X
X		else if (*a == 'O')	/* overwrite file on extract */
X			overlay = 1;
X
X		else if (*a == 'G') {	/* garble */
X			password = a + 1;
X			while (*a)
X				a++;
X			a--;
X#if	MTS
X			etoa(password, strlen(password));
X#endif
X		} else if (*a == 'S')	/* storage kludge */
X			nocomp = 1;
X
X		else if (*a == 'K')	/* special kludge */
X			kludge = 1;
X
X		else if (*a == 'Q')	/* use squashing */
X			dosquash = 1;
X#ifdef LOCAL
X		else if (*a == 'Z')	/* use Unix file names */
X			unix_names = 1;
X#endif /* LOCAL */
X
X		else if (*a == '-' || *a == '/')	/* UNIX and PC-DOS
X							 * option markers */
X			;
X
X		else
X			abort("%c is an unknown command", *a);
X	}
X
X	if (!opt)
X		abort("I have nothing to do!");
X
X	/* get the files list set up */
X
X	lnum = num - 3;		/* initial length of list */
X	lst = (char **) calloc((lnum==0) ? 1:lnum,
X				 sizeof(char *));	/* initial list */
X	for (n = 3; n < num; n++)
X		lst[n - 3] = arg[n];
X
X	for (n = 0; n < lnum;) {/* expand indirect references */
X		if (*lst[n] == '@')
X			expandlst(n);
X#if	GEMDOS
X				/* redirect stdout from the desktop...*/
X		else if (*lst[n] == '>') {
X			arctemp2 = (++lst[n]);
X			lst[n] = lst[lnum-1];	/* delete this entry */
X			lnum--;
X			if (arctemp2[0] == '>') {
X				append = 1;
X				arctemp2++;
X			}
X			else	append = 0;
X		}
X#endif
X		else
X			n++;
X	}
X#if	GEMDOS
X	if (arctemp2)
X		freopen(arctemp2,append ? "a" : "w",stdout);
X#endif
X
X	/* act on whatever action command was given */
X
X	switch (opt) {		/* action depends on command */
X	case 'A':		/* Add */
X	case 'M':		/* Move */
X	case 'U':		/* Update */
X	case 'F':		/* Freshen */
X		addarc(lnum, lst, (opt == 'M'), (opt == 'U'), (opt == 'F'));
X		break;
X
X	case 'D':		/* Delete */
X		delarc(lnum, lst);
X		break;
X
X	case 'E':		/* Extract */
X	case 'X':		/* eXtract */
X	case 'P':		/* Print */
X		extarc(lnum, lst, (opt == 'P'));
X		break;
X
X	case 'V':		/* Verbose list */
X		bose = 1;
X	case 'L':		/* List */
X		lstarc(lnum, lst);
X		break;
X
X	case 'T':		/* Test */
X		tstarc();
X		break;
X
X	case 'C':		/* Convert */
X		cvtarc(lnum, lst);
X		break;
X#if	!MTS
X	case 'R':		/* Run */
X		runarc(lnum, lst);
X		break;
X#endif
X	default:
X		abort("I don't know how to do %c yet!", opt);
X	}
X#if	GEMDOS
X	if (hold)
X		exitpause();
X#endif
X	return nerrs;
X}
Xstatic	void
Xexpandlst(n)			/* expand an indirect reference */
X	int		n;	/* number of entry to expand */
X{
X	FILE	       *lf, *fopen();	/* list file, opener */
X	char	       *malloc(), *realloc();	/* memory managers */
X	char		buf[100];	/* input buffer */
X	int		x;	/* index */
X	char	       *p = lst[n] + 1; /* filename pointer */
X
X	if (*p) {		/* use name if one was given */
X		makefnam(p, ".CMD", buf);
X		if (!(lf = fopen(buf, "r")))
X			abort("Cannot read list of files in %s", buf);
X	} else
X		lf = stdin;	/* else use standard input */
X
X	for (x = n + 1; x < lnum; x++)	/* drop reference from the list */
X		lst[x - 1] = lst[x];
X	lnum--;
X
X	while (fscanf(lf, "%99s", buf) > 0) {	/* read in the list */
X		if (!(lst =(char **)realloc(lst, (lnum + 1) * sizeof(char *))))
X			abort("too many file references");
X
X		lst[lnum] = malloc(strlen(buf) + 1);
X		strcpy(lst[lnum], buf); /* save the name */
X		lnum++;
X	}
X
X	if (lf != stdin)	/* avoid closing standard input */
X		fclose(lf);
X}
SHAR_EOF
if test 12303 -ne "`wc -c < 'arc.c'`"
then
	echo shar: "error transmitting 'arc.c'" '(should have been 12303 characters)'
fi
fi
echo shar: "extracting 'arc.h'" '(2930 characters)'
if test -f 'arc.h'
then
	echo shar: "will not over-write existing file 'arc.h'"
else
sed 's/^X//' << \SHAR_EOF > 'arc.h'
X/*
X * $Header: arc.h,v 1.10 88/08/01 14:28:29 hyc Exp $
X */
X
X#undef	DOS	/* Just in case... */
X#undef	UNIX
X
X/*
X * Assumptions:
X * char = 8 bits
X * short = 16 bits
X * long = 32 bits
X * int >= 16 bits
X */
X
X#if	MSDOS || GEMDOS
X#define	DOS	1
X#define	CUTOFF	'\\'
X#define	OPEN_R	"rb"
X#define	OPEN_W	"wb"
X#endif
X
X#if	!MSDOS
X#define	envfind	getenv
X#define	setmem(a, b, c)	memset(a, c, b)
X#endif
X
X#if	BSD || SYSV
X#define	UNIX	1
X#define	CUTOFF	'/'
X#define	OPEN_R	"r"
X#define	OPEN_W	"w"
X#include <ctype.h>
X#endif
X
X#if	MTS
X#define	CUTOFF	sepchr[0]
X#endif
X
X#if	MTS || SYSV
X#define	rindex	strrchr
X#define	index	strchr
X#endif
X
X/*  ARC - Archive utility - ARC Header
X  
X    Version 2.17, created on 04/22/87 at 13:09:43
X  
X(C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
X  
X    By:	 Thom Henderson
X  
X    Description: 
X	 This is the header file for the ARC archive utility.  It defines
X	 global parameters and the references to the external data.
X  
X  
X    Language:
X	 Computer Innovations Optimizing C86
X*/
X
X#define ARCMARK 26		/* special archive marker        */
X#define ARCVER 9		/* archive header version code   */
X#define STRLEN 100		/* system standard string length */
X#define FNLEN 13		/* file name length              */
X#define MAXARG 400		/* maximum number of arguments   */
X
X#ifndef DONT_DEFINE		/* Defined by arcdata.c */
X#include "arcs.h"
X
Xextern int      keepbak;	/* true if saving the old archive */
X#if	!DOS
Xextern int      image;		/* true to suppress CRLF/LF x-late */
X#endif
X#if	MTS
Xextern char     sepchr[2];	/* Shared file separator, default = ':' */
Xextern char     tmpchr[2];	/* Temporary file prefix, default = '-' */
X#endif
X#if	GEMDOS
Xextern int      hold;		/* hold screen before exiting */
X#endif
Xextern int      warn;		/* true to print warnings */
Xextern int      note;		/* true to print comments */
Xextern int      bose;		/* true to be verbose */
Xextern int      nocomp;		/* true to suppress compression */
Xextern int      overlay;	/* true to overlay on extract */
Xextern int      kludge;		/* kludge flag */
Xextern char    *arctemp;	/* arc temp file prefix */
Xextern char    *password;	/* encryption password pointer */
Xextern int      nerrs;		/* number of errors encountered */
Xextern int      changing;	/* true if archive being modified */
X
Xextern char     hdrver;		/* header version */
X
Xextern FILE    *arc;		/* the old archive */
Xextern FILE    *new;		/* the new archive */
Xextern char     arcname[STRLEN];/* storage for archive name */
Xextern char     bakname[STRLEN];/* storage for backup copy name */
Xextern char     newname[STRLEN];/* storage for new archive name */
Xextern unsigned short arcdate;	/* archive date stamp */
Xextern unsigned short arctime;	/* archive time stamp */
Xextern unsigned short olddate;	/* old archive date stamp */
Xextern unsigned short oldtime;	/* old archive time stamp */
Xextern int      dosquash;	/* squash instead of crunch */
X#endif				/* DONT_DEFINE */
SHAR_EOF
if test 2930 -ne "`wc -c < 'arc.h'`"
then
	echo shar: "error transmitting 'arc.h'" '(should have been 2930 characters)'
fi
fi
exit 0
#	End of shell archive



More information about the Unix-pc.sources mailing list