[alt.sources] ARC 5.20 w/Squashing, 3/9

hyc@umix.cc.umich.edu (Howard Chu) (04/14/88)

XXhandle at one time.
XX
XXWe've also introduced a new packaging method for ARC
XXand its documentation, since we are in the unique
XXposition of being unable to use ARC for this purpose.
XXWe've created a program called ARC51.COM which, when
XXexecuted, attempts to create the ARC program and
XXmanual.  You must be in the same directory as
XXARC51.COM when you run it.
XX
XX
XX
XX______________________
XX
XXWe've made some changes to Lempel-Zev coding to
XXfurther improve its compression ability on "poor fit"
XXfiles (mainly .EXE and .COM files).  The result is
XXthat crunching now works better than squeezing on
XXalmost all files, and comes close on most of the rest
XX(within 5%, by our benchmarks).  Accordingly, we have
XXdropped Huffman encoding in this version.  Our
XXbenchmarks show a speed improvement of around 14% when
XXadding a file to an archive.
XX
XXA low-level file copy routine was implemented to speed
XXup bulk data moves.  Deleting or adding a file to a
XXlarge existing archive is now much faster.
XX
XXThe Run command has been modified to allow passing
XXcommand line arguments to the program being run.
XX
XXThe temporary file introduced in version 4.3 has been
XXeliminated.  Crunched output generated in the analysis
XXphase is now placed directly in the output archive,
XXand is rewritten if crunching turns out not to be the
XXbest choice.  This can, in rare circumstances, cause
XXan archive to be slightly larger than it should be,
XXbut it also makes ARC considerably faster at adding
XXfiles to an archive.
XX
XX
XX
XX
XX
XXARC                                             Page 30
XX  PROGRAM HISTORY AND CREDITS
XX
XX
XX
XXIn its short life thus far, ARC has astounded us with
XXits popularity.  We first wrote it in March of 1985
XXbecause we wanted an archive utility that used a
XXdistributive directory approach, since this has
XXcertain advantages over the then popular central
XXdirectory approach.  We added automatic squeezing in
XXversion 2 at the prompting of a friend.  In version
XX2.1 we added the code to test for the best compression
XXmethod.  In less than a year we found that our humble
XXlittle program had spread across the country, and
XXseems to have become a new institution.
XX
XXWe are thankful for the support and appreciation we
XXhave received.  We hope that you find this program of
XXuse.
XX
XX
XXIf we have achieved greatness, it is because we have
XXstood upon the shoulders of giants.  Nothing is
XXcreated as a thing unto itself, and ARC is no
XXexception.  Therefore, we would like to give credit to
XXthe following people, without whose efforts ARC could
XXnot exist:
XX
XX
XXBrian W. Kernighan and P. J. Plauger, whose book
XX"Software Tools" provided many of the ideas behind the
XXdistributive directory approach used by ARC.
XX
XXDick Greenlaw, who wrote the public domain SQ and USQ
XXprograms, in which the Huffman squeezing algorithm was
XXfirst developed.
XX
XXRobert J. Beilstein, who adapted SQ and USQ to
XXComputer Innovations C86 (the language we use), thus
XXproviding us with important parts of our squeezing
XXlogic.
XX
XXKent Williams, who graciously allowed us to use his
XXLZWCOM and LZWUNC programs as a basis for our Lempel-
XXZev compression logic, and who continues to make
XXvaluable contributions.
XX
XXDavid Schwaderer, whose article in the April 1985
XXissue of PC Tech Journal provided us with the logic
XXfor calculating the CRC 16 bit polynomial.
XX
XX
XX
XX
XXARC                                             Page 31
XXTerry A. Welch, whose article "A Technique for High
XXPerformance Data Compression", IEEE Computer Vol 17 No
XX6 (June 1984) seems to have started all the research
XXon Lempel-Zev coding.
XX
XXSpencer W. Thomas, Jim McKie, Steve Davies, Ken
XXTurkowski, James A.  Woods, and Joe Orost, who are the
XXauthors of the UNIX compress utility.
XX
XXAlex Jacobs, who in June of 1985 sent us the very
XXfirst shareware contribution we ever received.
XX
XX
XXAnd many, many others whom we could not identify.
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XXARC                                             Page 32
XX        BULLETIN BOARDS
XX
XX
XX
XXARC is distributed mainly through shareware channels.
XXAmong other things, this means that ARC is available
XXfrom many bulletin board systems.  In fact, the system
XXoperators (sysops) of many bulletin boards have taken
XXto storing almost all of their downloadable files in
XXarchives to save themselves disk space and to save
XXtheir users time.
XX
XXThis also makes things more convenient for the
XXbulletin board users, since one archive may contain
XXseveral programs, any related data files, and the
XXdocumentation.  Many shareware authors have taken to
XXdistributing their software in archives to help ensure
XXthat the users receive everything.
XX
XXObviously, we can't do that with ARC.  As a result,
XXmany of our users have ARC, but don't have the manual.
XXMost of our customer support calls come from people
XXwho have never seen the manual, and in many cases
XXdidn't even know that one exists!
XX
XXTo solve this problem we developed what is in essence
XXa self-unpacking archive.  We distribute this as
XX"ARCxxx.COM", where "xxx" is the current version
XXnumber.  For example, ARC version 5.20 would be
XXdistributed as "ARC520.COM".  This program, when run,
XXunpacks itself into a copy of ARC plus its
XXdocumentation.
XX
XXNow that we've gone to all that work, we'd really
XXappreciate it if you would use this program when you
XXdistribute ARC.
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XXARC                                             Page 33
XX         SITE LICENSES
XX
XX
XX
XXCorporate users may wish to obtain a site license for
XXthe use of ARC.  Please use the order form in this
XXmanual to order a site license.  Site licenses are
XXgranted as of when we receive your payment.  License
XXfees vary depending on the number of computers on
XXwhich ARC will be used, as follows:
XX
XX     1 to  9 machines  $35 each
XX    10 to 24 machines  $25 each
XX    25 to 49 machines  $20 each
XX    50 to 99 machines  $15 each
XX    over  99 machines  $1500 one time fee
XX
XX
XX
XXEnclosed is a site license agreement, which should be
XXsigned and sent with your payment when ordering a
XXcommercial site license.
XX
XX
XXA commercial site license does not include additional
XXcopies of the ARC program disk and the ARC manual.
XXInstead, you make your own copies of the disk and
XXmanual as you need them.  If you wish, you can order
XXadditional program disks and manuals from us.
XX
XXAdditional program disks cost $10 each.  Additional
XXmanuals cost $20 each.  If you wish, you can order
XXprogram sets for $40 each.  A "program set" is a
XXprogram disk and manual enclosed in a vinyl binder.
XXThere is a $50 minimum on all orders.
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XXARC                                             Page 34
XX             SITE LICENSE APPLICATION
XX
XX
XX
XXThe use of ARC in a commercial environment or government organization
XXis granted under the following terms:
XX
XX1.  Payment of the license fee must be made to System Enhancement
XX    Associates, Inc.  The fee is based on the number of computers
XX    which will be used to run ARC, as follows:
XX
XX          1 to  9 machines  $35 each
XX         10 to 24 machines  $25 each
XX         25 to 49 machines  $20 each
XX         50 to 99 machines  $15 each
XX         over  99 machines  $1500 one time fee
XX
XX2.  You may use ARC on the number of computers included in the license
XX    fee.  If you have paid the fee for over 99 machines, then you may
XX    use ARC on any number of computers within your organization.
XX
XX3.  You may make copies of the program and documentation, in their
XX    original,  unmodified form,  without restriction.  You may
XX    distribute these copies without restriction.
XX
XX4.  If these copies are distributed outside of your organization,  you
XX    have no obligation to control the use of those copies which are
XX    outside of your organization.
XX
XX5.  You may make copies of the program documentation, in both its
XX    printed form and machine readable form, without restriction.
XX
XX6.  You may use all future versions of ARC under this license.
XX
XX            ___
XX    distributing the program or its documentation.
XX
XX8.  It is your responsibility to make the necessary copies and to
XX    deliver them to the computers which they will be used on.  If you
XX    wish, you can order additional ARC program disks and manuals.
XX
XX                               ________
XX    if you use ARC.  You're on your own.
XX
XX
XX    I agree to abide by the terms and conditions of this license.
XX
XX    _____________________________         __________________________
XX    Signature                             Date
XX
XX    _____________________________
XX    Name (please print or type)
XX
XX    _____________________________
XX    Title
XX
XX    _____________________________
XX    Company
XX
XX
XX                   ORDER FORM
XX
XX
XX
XXCheck which items you wish to purchase:
XX
XX    [] Noncommercial license for the use of ARC.
XX
XX                                                ___
XX       attached price schedule and terms).
XX
XX    [] Program disk and documentation (only on orders of $50 or more,
XX       not counting maintenance contracts).
XX
XX       ____
XX
XX       ____
XX
XX       ____
XX       per program set.
XX
XX    [] One year maintenance agreement at $50 per year.
XX
XX                   _____
XX
XX                      _____
XX
XX                    _______________________________
XX
XX                        ___________________________
XX
XX                  _________________________________
XX
XX    _______________________________________________
XX    Name
XX
XX    _______________________________________________
XX
XX
XX    _______________________________________________
XX    Address
XX
XX    ______________________   ________  ____________
XX    City                     State     Zip
XX
XX    _______________           /
XX    FidoNet address
XX
XX
XXSend this completed form to:
XX
XX                  System Enhancement Associates, Inc.
XX                     21 New Street, Wayne NJ 07470
XX
XXFor program disk orders outside the U.S., please add an additional $5,
XXand enclose an international money order payable in U.S. currency.
XX
XXFor commercial site license orders, please enclose a signed copy of
XXthe site license agreement.
XX
XX
SHAR_EOF
if test 55115 -ne "`wc -c Arc.doc`"
then
echo shar: error transmitting Arc.doc '(should have been 55115 characters)'
fi
echo shar: extracting Arcinfo '(5577 characters)'
sed 's/^XX//' << \SHAR_EOF > Arcinfo
XX
XXARC-FILE.INF, created by Keith Petersen, W8SDZ, 21-Sep-86, extracted
XXfrom UNARC.INF by Robert A. Freed.
XX
XXFrom:     Robert A. Freed
XXSubject:  Technical Information for ARC files
XXDate:     June 24, 1986
XX
XXNote: In the following discussion, UNARC refers to my CP/M-80 program
XXfor extracting files from MSDOS ARCs.  The definitions of the ARC file
XXformat are based on MSDOS ARC512.EXE.
XX
XXARCHIVE FILE FORMAT
XX-------------------
XX
XXComponent files are stored sequentially within an archive.  Each entry
XXis preceded by a 29-byte header, which contains the directory
XXinformation.  There is no wasted space between entries.  (This is in
XXcontrast to the centralized directory used by Novosielski libraries.
XXAlthough random access to subfiles within an archive can be noticeably
XXslower than with libraries, archives do have the advantage of not
XXrequiring pre-allocation of directory space.)
XX
XXArchive entries are normally maintained in sorted name order.  The
XXformat of the 29-byte archive header is as follows:
XX
XXByte 1:  1A Hex.
XX         This marks the start of an archive header.  If this byte is not found 
XX         when expected, UNARC will scan forward in the file (up to 64K bytes) 
XX         in an attempt to find it (followed by a valid compression version).  
XX         If a valid header is found in this manner, a warning message is 
XX         issued and archive file processing continues.  Otherwise, the file is 
XX         assumed to be an invalid archive and processing is aborted.  (This is 
XX         compatible with MS-DOS ARC version 5.12).  Note that a special 
XX         exception is made at the beginning of an archive file, to accomodate 
XX         "self-unpacking" archives (see below).
XX
XXByte 2:  Compression version, as follows:
XX
XX         0 = end of file marker (remaining bytes not present)
XX         1 = unpacked (obsolete)
XX         2 = unpacked
XX         3 = packed
XX         4 = squeezed (after packing)
XX         5 = crunched (obsolete)
XX         6 = crunched (after packing) (obsolete)
XX         7 = crunched (after packing, using faster hash algorithm) (obsolete)
XX         8 = crunched (after packing, using dynamic LZW variations)
XX
XXBytes 3-15:  ASCII file name, nul-terminated.
XX
XX(All of the following numeric values are stored low-byte first.)
XX
XXBytes 16-19:  Compressed file size in bytes.
XX
XXBytes 20-21:  File date, in 16-bit MS-DOS format:
XX              Bits 15:9 = year - 1980
XX              Bits  8:5 = month of year
XX              Bits  4:0 = day of month
XX              (All zero means no date.)
XX
XXBytes 22-23:  File time, in 16-bit MS-DOS format:
XX              Bits 15:11 = hour (24-hour clock)
XX              Bits 10:5  = minute
XX              Bits  4:0  = second/2 (not displayed by UNARC)
XX
XXBytes 24-25:  Cyclic redundancy check (CRC) value (see below).
XX
XXBytes 26-29:  Original (uncompressed) file length in bytes.
XX              (This field is not present for version 1 entries, byte 2 = 1.  
XX              I.e., in this case the header is only 25 bytes long.  Because 
XX              version 1 files are uncompressed, the value normally found in 
XX              this field may be obtained from bytes 16-19.)
XX
XX
XXSELF-UNPACKING ARCHIVES
XX-----------------------
XX
XXA "self-unpacking" archive is one which can be renamed to a .COM file
XXand executed as a program.  An example of such a file is the MS-DOS
XXprogram ARC512.COM, which is a standard archive file preceded by a
XXthree-byte jump instruction.  The first entry in this file is a simple
XX"bootstrap" program in uncompressed form, which loads the subfile
XXARC.EXE (also uncompressed) into memory and passes control to it.  In
XXanticipation of a similar scheme for future distribution of UNARC, the
XXprogram permits up to three bytes to precede the first header in an
XXarchive file (with no error message).
XX
XX
XXCRC COMPUTATION
XX---------------
XX
XXArchive files use a 16-bit cyclic redundancy check (CRC) for error
XXcontrol.  The particular CRC polynomial used is x^16 + x^15 + x^2 + 1,
XXwhich is commonly known as "CRC-16" and is used in many data
XXtransmission protocols (e.g. DEC DDCMP and IBM BSC), as well as by
XXmost floppy disk controllers.  Note that this differs from the CCITT
XXpolynomial (x^16 + x^12 + x^5 + 1), which is used by the XMODEM-CRC
XXprotocol and the public domain CHEK program (although these do not
XXadhere strictly to the CCITT standard).  The MS-DOS ARC program does
XXperform a mathematically sound and accurate CRC calculation.  (We
XXmention this because it contrasts with some unfortunately popular
XXpublic domain programs we have witnessed, which from time immemorial
XXhave based their calculation on an obscure magazine article which
XXcontained a typographical error!)
XX
XXAdditional note (while we are on the subject of CRC's): The validity
XXof using a 16-bit CRC for checking an entire file is somewhat
XXquestionable.  Many people quote the statistics related to these
XXfunctions (e.g. "all two-bit errors, all single burst errors of 16 or
XXfewer bits, 99.997% of all single 17-bit burst errors, etc."), without
XXrealizing that these claims are valid only if the total number of bits
XXchecked is less than 32767 (which is why they are used in small-packet
XXdata transmission protocols).  I.e., for file sizes in excess of about
XX4K bytes, a 16-bit CRC is not really as good as what is often claimed.
XXThis is not to say that it is bad, but there are more reliable methods
XXavailable (e.g. the 32-bit AUTODIN-II polynomial).  (End of lecture!)
XX
XX                           Bob Freed
XX                           62 Miller Road
XX                           Newton Centre, MA  02159
XX                           Telephone (617) 332-3533
XX
XX
SHAR_EOF
if test 5577 -ne "`wc -c Arcinfo`"
then
echo shar: error transmitting Arcinfo '(should have been 5577 characters)'
fi
echo shar: extracting arc.c '(10348 characters)'
sed 's/^XX//' << \SHAR_EOF > arc.c
XX/*
XX * $Log:	arc.c,v $
XX * Revision 1.4  88/04/11  19:03:58  hyc
XX * another omitted section. Ooops.
XX * 
XX * Revision 1.3  88/04/11  19:01:11  hyc
XX * added printf accidentally omitted...
XX * 
XX * Revision 1.2  88/04/11  17:35:34  hyc
XX * re-synch with MTS version, add squashing support.
XX * 
XX * Revision 1.1  88/04/11  17:24:19  hyc
XX * Initial revision
XX * 
XX * Revision 1.4  87/12/20  03:39:46  hyc
XX * Fix command description (MTS vs Unix usage of 'i' flag...)
XX * 
XX * Revision 1.3  87/12/19  04:35:12  hyc
XX * Change MTS to MSDOS for #ifdef of printf for image mode...
XX * 
XX * Revision 1.2  87/12/19  04:00:18  hyc
XX * MAde #ifdef of image #ifndef MSDOS...
XX * 
XX * Revision 1.1  87/12/19  03:59:14  hyc
XX * Initial revision
XX * 
XX * Revision 1.5  87/08/13  17:02:39  hyc
XX * Run thru the indent program...
XX *  Revision 1.4  87/07/30  03:38:15  hyc Minor junk
XX * 
XX * Revision 1.3  87/07/21  11:39:35  hyc minor fixups
XX * 
XX * Revision 1.2  87/07/21  06:23:13  hyc Modified according to the mods made to
XX * arc 5.12 for unix.
XX * 
XX */
XX
XX/*
XX * ARC - Archive utility
XX * 
XX * Version 5.20, created on 10/24/86 at 14:56:41
XX * 
XX * (C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
XX * 
XX * By:  Thom Henderson
XX * 
XX * Description: This program is a general archive utility, and is used to
XX * maintain an archive of files.  An "archive" is a single file that combines
XX * many files, reducing storage space and allowing multiple files to be
XX * handled as one.
XX * 
XX * Instructions: Run this program with no arguments for complete instructions.
XX * 
XX * Programming notes: ARC Version 2 differs from version 1 in that archive
XX * entries are automatically compressed when they are added to the archive,
XX * making a separate compression step unecessary.  The nature of the
XX * compression is indicated by the header version number placed in each
XX * archive entry, as follows:
XX * 
XX *	1 = Old style, no compression
XX *	2 = New style, no compression
XX *	3 = Compression of repeated characters only
XX *	4 = Compression of repeated characters plus Huffman SQueezing
XX *	5 = Lempel-Zev packing of repeated strings (old style)
XX *	6 = Lempel-Zev packing of repeated strings (new style)
XX *	7 = Lempel-Zev Williams packing with improved hash function
XX *	8 = Dynamic Lempel-Zev packing with adaptive reset
XX *	9 = Squashing, ala Phil Katz's PKARC
XX * 
XX * Type 5, Lempel-Zev packing, was added as of version 4.0
XX * 
XX * Type 6 is Lempel-Zev packing where runs of repeated characters have been
XX * collapsed, and was added as of version 4.1
XX * 
XX * Type 7 is a variation of Lempel-Zev using a different hash function which
XX * yields speed improvements of 20-25%, and was added as of version 4.6
XX * 
XX * Type 8 is a different implementation of Lempel-Zev, using a variable code
XX * size and an adaptive block reset, and was added as of version 5.0
XX *
XX * Type 9 is yet another implementation of Lempel-Zev, used originally by
XX * Phil Katz in his PKARC utility.
XX * 
XX * Verion 4.3 introduced a temporary file for holding the result of the first
XX * crunch pass, thus speeding up crunching.
XX * 
XX * Version 4.4 introduced the ARCTEMP environment string, so that the temporary
XX * crunch file may be placed on a ramdisk.  Also added was the distinction
XX * bewteen Adding a file in all cases, and Updating a file only if the disk
XX * file is newer than the corresponding archive entry.
XX * 
XX * The compression method to use is determined when the file is added, based on
XX * whichever method yields the smallest result.
XX * 
XX * Language: Computer Innovations Optimizing C86
XX */
XX#include <stdio.h>
XX#include "arc.h"
XX
XXmain(num, arg)			/* system entry point */
XX	INT             num;	/* number of arguments */
XX	char           *arg[];	/* pointers to arguments */
XX{
XX	char            opt = 0;/* selected action */
XX	char           *a;	/* option pointer */
XX	char           *makefnam();	/* filename fixup routine */
XX	char           *upper();/* case conversion routine */
XX	char           *index();/* string index utility */
XX	char           *envfind();	/* environment searcher */
XX	INT             n;	/* argument index */
XX	char           *arctemp2, *malloc();
XX#ifdef BSD
XX	LONG            getpid();
XX#endif
XX#ifdef MTS
XX	fortran         guinfo();
XX	char            gotinf[4];
XX#endif
XX
XX	if (num < 3) {
XX		printf("ARC - Archive utility, Version 5.20, created on 10/24/86 at 14:56:41\n");
XX		/*
XX		 * printf("(C) COPYRIGHT 1985,86 by System Enhancement
XX		 * Associates;"); printf(" ALL RIGHTS RESERVED\n\n");
XX		 * printf("Please refer all inquiries to:\n\n"); printf("
XX		 * System Enhancement Associates\n"); printf("       21 New
XX		 * Street, Wayne NJ 07470\n\n"); printf("You may copy and
XX		 * distribute this program freely,"); printf(" provided
XX		 * that:\n"); printf("    1)   No fee is charged for such
XX		 * copying and"); printf(" distribution, and\n"); printf(" 2) 
XX		 * It is distributed ONLY in its original,"); printf("
XX		 * unmodified state.\n\n"); printf("If you like this program,
XX		 * and find it of use, then your"); printf(" contribution
XX		 * will\n"); printf("be appreciated.  You may not use this
XX		 * product in a"); printf(" commercial environment\n");
XX		 * printf("or a governmental organization without paying a
XX		 * license"); printf(" fee of $35.  Site\n");
XX		 * printf("licenses and commercial distribution licenses
XX		 * are"); printf(" available.  A program\n"); printf("disk
XX		 * and printed documentation are available for $50.\n");
XX		 * printf("\nIf you fail to abide by the terms of this
XX		 * license, "); printf(" then your conscience\n");
XX		 * printf("will haunt you for the rest of your life.\n\n"); 
XX		 */
XX#ifdef MSDOS
XX		printf("Usage: ARC {amufdxerplvtc}[bswnoq][g<password>]");
XX#endif
XX#ifdef BSD
XX		printf("Usage: arc {amufdxerplvtc}[biswnoq][g<password>]");
XX#endif
XX#ifdef MTS
XX		printf("Parameters: {amufdxeplvtc}[biswnoq][g<password>]");
XX#endif
XX		printf(" <archive> [<filename> . . .]\n");
XX		printf("Where:   a   = add files to archive\n");
XX		printf("         m   = move files to archive\n");
XX		printf("         u   = update files in archive\n");
XX		printf("         f   = freshen files in archive\n");
XX		printf("         d   = delete files from archive\n");
XX		printf("         x,e = extract files from archive\n");
XX#ifndef MTS
XX		printf("         r   = run files from archive\n");
XX#endif
XX		printf("         p   = copy files from archive to");
XX		printf(" standard output\n");
XX		printf("         l   = list files in archive\n");
XX		printf("         v   = verbose listing of files in archive\n");
XX		printf("         t   = test archive integrity\n");
XX		printf("         c   = convert entry to new packing method\n");
XX		printf("         b   = retain backup copy of archive\n");
XX#ifdef	MTS
XX		printf("         i   = suppress ASCII/EBCDIC translation\n");
XX#endif
XX#ifdef	BSD
XX		printf("         i   = suppress CRLF to '\\n' translation\n");
XX#endif
XX		printf("         s   = suppress compression (store only)\n");
XX		printf("         w   = suppress warning messages\n");
XX		printf("         n   = suppress notes and comments\n");
XX		printf("         o   = overwrite existing files when");
XX		printf(" extracting\n");
XX		printf("         q   = squash instead of crunching\n");
XX		printf("         g   = Encrypt/decrypt archive entry\n");
XX	/*	printf("\nPlease refer to the program documentation for");
XX		printf(" complete instructions.\n"); */
XX		return 1;
XX	}
XX	/* see where temp files go */
XX	/* use process id to insure unique temp files */
XX
XX#ifndef MTS
XX	arctemp = malloc(256);
XX	if (!(arctemp2 = envfind("ARCTEMP")))
XX		arctemp2 = envfind("TEMP");
XX	if (arctemp2)
XX		sprintf(arctemp, "%s.Arc%ld", arctemp2, getpid());
XX	else
XX		sprintf(arctemp, ".Arc%ld", getpid());
XX#else
XX	guinfo("SHFSEP  ", gotinf);
XX	sepchr[0] = gotinf[0];
XX	guinfo("SCRFCHAR", gotinf);
XX	tmpchr[0] = gotinf[0];
XX	arctemp = "-$$$";
XX	arctemp[0] = tmpchr[0];
XX#endif
XX
XX#ifndef BSD
XX	/* avoid any case problems with arguments */
XX
XX	for (n = 1; n < num; n++)	/* for each argument */
XX		upper(arg[n]);	/* convert it to uppercase */
XX#else
XX	/* avoid case problems with command options */
XX	upper(arg[1]);		/* convert to uppercase */
XX#endif
XX
XX	/* create archive names, supplying defaults */
XX#ifndef BSD
XX	makefnam(arg[2], ".ARC", arcname);
XX#else
XX	makefnam(arg[2], ".arc", arcname);
XX#endif
XX	/* makefnam(".$$$",arcname,newname); */
XX	sprintf(newname, "%s.ARC", arctemp);
XX	makefnam(".BAK", arcname, bakname);
XX
XX	/* now scan the command and see what we are to do */
XX
XX	for (a = arg[1]; *a; a++) {	/* scan the option flags */
XX#ifndef MTS
XX		if (index("AMUFDXEPLVTCR", *a)) {	/* if a known command */
XX#else
XX		if (index("AMUFDXEPLVTC", *a)) {
XX#endif
XX			if (opt)/* do we have one yet? */
XX				abort("Cannot mix %c and %c", opt, *a);
XX			opt = *a;	/* else remember it */
XX		} else if (*a == 'B')	/* retain backup copy */
XX			keepbak = 1;
XX
XX		else if (*a == 'W')	/* suppress warnings */
XX			warn = 0;
XX#ifndef MSDOS
XX		else if (*a == 'I')	/* image mode, no ASCII/EBCDIC x-late */
XX			image = 1;
XX#endif
XX
XX		else if (*a == 'N')	/* suppress notes and comments */
XX			note = 0;
XX
XX		else if (*a == 'O')	/* overwrite file on extract */
XX			overlay = 1;
XX
XX		else if (*a == 'G') {	/* garble */
XX			password = a + 1;
XX			while (*a)
XX				a++;
XX			a--;
XX#ifdef MTS
XX			etoa(password, strlen(password));
XX#endif
XX		} else if (*a == 'S')	/* storage kludge */
XX			nocomp = 1;
XX
XX		else if (*a == 'K')	/* special kludge */
XX			kludge = 1;
XX
XX		else if (*a == 'Q')	/* use squashing */
XX			dosquash = 1;
XX
XX		else if (*a == '-' || *a == '/')	/* UNIX and PC-DOS
XX							 * option markers */
XX			;
XX
XX		else
XX			abort("%c is an unknown command", *a);
XX	}
XX
XX	if (!opt)
XX		abort("I have nothing to do!");
XX
XX	/* act on whatever action command was given */
XX
XX	switch (opt) {		/* action depends on command */
XX	case 'A':		/* Add */
XX	case 'M':		/* Move */
XX	case 'U':		/* Update */
XX	case 'F':		/* Freshen */
XX		addarc(num - 3, &arg[3], (opt == 'M'), (opt == 'U'), (opt == 'F'));
XX		break;
XX
XX	case 'D':		/* Delete */
XX		delarc(num - 3, &arg[3]);
XX		break;
XX
XX	case 'E':		/* Extract */
XX	case 'X':		/* eXtract */
XX	case 'P':		/* Print */
XX		extarc(num - 3, &arg[3], (opt == 'P'));
XX		break;
XX
XX	case 'V':		/* Verbose list */
XX		bose = 1;
XX	case 'L':		/* List */
XX		lstarc(num - 3, &arg[3]);
XX		break;
XX
XX	case 'T':		/* Test */
XX		tstarc();
XX		break;
XX
XX	case 'C':		/* Convert */
XX		cvtarc(num - 3, &arg[3]);
XX		break;
XX#ifndef MTS
XX	case 'R':		/* Run */
XX		runarc(num - 3, &arg[3]);
XX		break;
XX#endif
XX	default:
XX		abort("I don't know how to do %c yet!", opt);
XX	}
XX
XX	return nerrs;
XX}
SHAR_EOF
if test 10348 -ne "`wc -c arc.c`"
then
echo shar: error transmitting arc.c '(should have been 10348 characters)'
fi
echo shar: extracting arc.h '(3115 characters)'
sed 's/^XX//' << \SHAR_EOF > arc.h
XX/*
XX * $Log:	arc.h,v $
XX * Revision 1.3  88/04/11  17:42:21  hyc
XX * nothing much, just run thru indent...
XX * 
XX * Revision 1.2  88/04/11  17:40:24  hyc
XX * added flag for squashing, got rid of EXTERN macro.
XX * 
XX * Revision 1.1  88/04/11  17:36:04  hyc
XX * Initial revision
XX * 
XX * Revision 1.2  87/12/19  03:58:14  hyc
XX * #define BSD instead of MTS, make the image mode flag ndef'ed to MSDOS
XX * instead of def'ed to MTS...
XX * 
XX * Revision 1.1  87/12/19  03:54:37  hyc
XX * Initial revision
XX * 
XX * Revision 1.4  87/08/13  17:02:56  hyc
XX * Run thru the indent program...
XX *  Revision 1.3  87/07/21  11:45:29  hyc *** empty log
XX * message ***
XX * 
XX * Revision 1.2  87/07/21  06:30:26  hyc modified for unix
XX * 
XX */
XX
XX#undef  MSDOS			/* MSDOS machine */
XX#define BSD			/* BSD4.2 or 4.3 */
XX#undef	MTS			/* MTS or 370(?) */
XX
XX#ifdef BSD
XX#include <ctype.h>
XX#define INT short
XX#define LONG long
XX#define envfind getenv
XX#endif
XX
XX#ifdef MTS
XX#define INT short
XX#define LONG long
XX#define rindex strrchr
XX#define index strchr
XX#define envfind getenv
XX#undef  USEGFINFO		/* define this to use GFINFO for directory */
XX#define USECATSCAN		/* scanning, else use CATSCAN/FILEINFO... */
XX#endif
XX
XX#ifdef MSDOS
XX#define INT int
XX#define LONG long
XX#endif
XX
XX/*
XX * ARC - Archive utility - ARC Header
XX * 
XX * Version 2.16, created on 10/24/86 at 14:54:17
XX * 
XX * (C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
XX * 
XX * By:  Thom Henderson
XX * 
XX * Description: This is the header file for the ARC archive utility.  It defines
XX * global parameters and the references to the external data.
XX * 
XX * 
XX * Language: Computer Innovations Optimizing C86
XX */
XX
XX#ifndef DONT_DEFINE		/* Defined by arcdata.c */
XX#include "arcs.h"
XX
XXextern INT      keepbak;	/* true if saving the old archive */
XX#ifndef	MSDOS
XXextern INT      image;		/* true to suppress CRLF/LF x-late */
XX#endif
XX#ifdef MTS
XXextern char     sepchr[2];	/* Shared file separator, default = ':' */
XXextern char     tmpchr[2];	/* Temporary file prefix, default = '-' */
XX#endif
XXextern INT      warn;		/* true to print warnings */
XXextern INT      note;		/* true to print comments */
XXextern INT      bose;		/* true to be verbose */
XXextern INT      nocomp;		/* true to suppress compression */
XXextern INT      overlay;	/* true to overlay on extract */
XXextern INT      kludge;		/* kludge flag */
XXextern char    *arctemp;	/* arc temp file prefix */
XXextern char    *password;	/* encryption password pointer */
XXextern INT      nerrs;		/* number of errors encountered */
XX
XXextern char     hdrver;		/* header version */
XX
XXextern FILE    *arc;		/* the old archive */
XXextern FILE    *new;		/* the new archive */
XXextern char     arcname[100];	/* storage for archive name */
XXextern char     bakname[100];	/* storage for backup copy name */
XXextern char     newname[100];	/* storage for new archive name */
XXextern unsigned INT arcdate;	/* archive date stamp */
XXextern unsigned INT arctime;	/* archive time stamp */
XXextern unsigned INT olddate;	/* old archive date stamp */
XXextern unsigned INT oldtime;	/* old archive time stamp */
XXextern INT      dosquash;	/* squash instead of crunch */
XX#endif				/* DONT_DEFINE */
SHAR_EOF
if test 3115 -ne "`wc -c arc.h`"
then
echo shar: error transmitting arc.h '(should have been 3115 characters)'
fi
echo shar: extracting arcadd.c '(9205 characters)'
sed 's/^XX//' << \SHAR_EOF > arcadd.c
XX/*
XX * $Log:	arcadd.c,v $
XX * Revision 1.2  88/04/11  17:49:38  hyc
XX * formatting changes...
XX * 
XX * Revision 1.1  88/04/11  17:43:01  hyc
XX * Initial revision
XX * 
XX * Revision 1.1  87/12/19  04:00:40  hyc
XX * Initial revision
XX * 
XX * Revision 1.4  87/08/13  17:03:01  hyc
XX * Run thru the indent program...
XX *  Revision 1.3  87/07/21  11:39:49  hyc minor
XX * fixups
XX * 
XX * Revision 1.2  87/07/21  06:50:06  hyc *** empty log message ***
XX * 
XX */
XX
XX/*
XX * ARC - Archive utility - ARCADD
XX * 
XX * Version 3.40, created on 06/18/86 at 13:10:18
XX * 
XX * (C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
XX * 
XX * By:  Thom Henderson
XX * 
XX * Description: This file contains the routines used to add files to an archive.
XX * 
XX * Language: Computer Innovations Optimizing C86
XX */