From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP  2-SEP-1988 11:11
To:	ARISIA::EVERHART
Subj:	ARC mods 1/7


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu,  1 SEP 88 06:27:30 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Thu, 1 Sep 88 05:59:00 PDT
Received: from UKACRL.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 7761; Thu, 01 Sep 88 08:57:53 EDT
Received: from RL.IB by UKACRL.BITNET (Mailer X1.25) with BSMTP id 3121; Thu,
 01 Sep 88 13:57:00 BST
Received: from RL.IB by UK.AC.RL.IB (Mailer X1.25) with BSMTP id 3116; Thu, 01
          Sep 88 13:56:59 BS
Via:      UK.AC.KCL.CC.OAK;  1 SEP 88 13:56:42 BST
Date:     1-SEP-1988 13:57:27 GMT
From:     UDAA055%OAK.CC.KCL.AC.UK@CUNYVM.CUNY.EDU
To:       info-vax@KL.SRI.COM
Subject:  ARC mods 1/7
Sender:   Andy Harper, Kings College London <A.Harper%OAK.CC.KCL.AC.UK@CUNYVM.CUNY.EDU>

....................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.00 26-May-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user UDAA055
$! on  6-APR-1866 20:07:23.77.
$!
$! ATTENTION: To keep each article below 31 blocks (15872 bytes), this
$!            program has been transmitted in 7 parts.  You should
$!            concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 9 files:
$!        ARC.C
$!        ARC.H
$!        ARC.HLP
$!        ARCADD.C
$!        ARCDOS.C
$!        ARCEXT.C
$!        ARCIO.C
$!        ARCLZW.C
$!        ARCPACK.C
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.00 26-May-1988 requires VMS V4.4 or higher."
$ EXIT 44
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "$Part", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "$Errors" ); i_errors
:= 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE
) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 ); IF s_x = "+" THEN r_skip
:= SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <> 0 THEN s_x := ""
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF
; IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = "V" THEN s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL
( 1 ); ENDIF; IF s_x = "X" THEN s_x := ""; IF i_append_line <
> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF
; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> "" THEN i_errors
:= i_errors + 1; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE
; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL( 1
); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH( "`"
, FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1 )
; IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) )
; COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors
, "SYS$COMMAND" ); ENDIF; EXIT;
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "ARC.C"
$ CHECKSUM_IS = 1261875489
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
Xstatic char *RCSid = "$Header: arc.c,v 1.2 86/07/15 07:52:04 turner Exp $";
X
X/*
X * $Log:`009arc.c,v $
X * Hack-attack 1.3  86/12/20  01:23:45  wilhite@usceast.uucp
X * `009Bludgeoned into submission for VAX 11/780 BSD4.2
X *`009(ugly code, but fewer core dumps)
X *
X * VAXC modifications       31-AUG-1988`009`009Andy Harper, KCL
X * Separated VAXC and BSD dependencies
X *
X * Revision 1.2  86/07/15  07:52:04  turner
X * first working version for the vax
X *
X * Revision 1.1  86/06/26  14:59:15  turner
X * initial version
X *
X *
X */
X
X#define version "5.12 (VMS01b), created on"
X
X/*  ARC - Archive utility
X
X$define(tag,$$segment(@1,$$index(@1,=)+1))#
X$define(version,Version $tag(
XTED_VERSION DB =5.12), created on $tag(
XTED_DATE DB =02/05/86) at $tag(
XTED_TIME DB =22:22:01))#
X$undefine(tag)#
X    $version
X
X(C) COPYRIGHT 1985,86 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 has function
X         8 = Dynamic Lempel-Zev packing with adaptive reset
X`009 9 = Squashing
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         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
Xmain(num,arg)                          /* system entry point */
XINT num;                               /* number of arguments */
Xchar *arg[];                           /* pointers to arguments */
X$
X    char opt = 0;                      /* selected action */
X    char *a;                           /* option pointer */
X    char *makefnam();                  /* filename fixup routine */
X    char *upper();                     /* case conversion routine */
X/*    char *index(); */                     /* string index utility */
X    char *envfind();                   /* environment searcher */
X    INT n;                             /* argument index */
X    char *arctemp2;
X    long getpid();
X
X    warn = 1;
X    note = 1;
X    if(num<3)
V    $  printf("ARC - Archive utility, %s %s at %s\n",version,__DATE__,__TIME__)
X;
X         printf("(C) COPYRIGHT 1985,86 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         printf("Usage: ARC $amufdxerplvtc[bswn][g<password>]");
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         printf("         r   = run files from archive\n");
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         printf("         s   = suppress compression (store only)\n");
X         printf("         w   = suppress warning messages\n");
X         printf("         n   = suppress notes and comments\n");
X         printf("         g   = Encrypt/decrypt archive entry\n");
X#ifdef VAXC
X         printf("         %%   = print statistics information\n");
X#endif VAXC
X         printf("         q   = squash instead of crunching\n\n");
X/*       printf("\nPlease refer to the program documentation for");          */
X/*       printf(" complete instructions.\n");                                */
X         return 1;
X    
X
X    /* see where temp files go */
X    /* use process id to "enhance uniquity" of temp filenames */
X    /* (avoids multi-user or background foolishness) */
X
X    if(!(arctemp2 = envfind("ARCTEMP")))
X         arctemp2 = envfind("TEMP");
X#ifdef VAXC
X    if (arctemp2) printf("Temprary file will be on %s\n",arctemp2);
X    if (arctemp2) sprintf(arctemp,"%s.Arc_%08lx",arctemp2,getpid());
X#else
X    if (arctemp2) sprintf(arctemp,"%s.Arc%ld",arctemp2,getpid());
X#endif
X#ifdef VAXC
X    else sprintf(arctemp,"Arc_%08lx",getpid());
X#else
X    else sprintf(arctemp,".Arc%ld",getpid());
X#endif VAXC
X
X#if MSDOS
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#endif
X#if VAXC | BSD | ST
X    /* avoid any case problems with command options */
X
X         upper(arg[1]);                /* convert it to uppercase */
X#endif
X
X    /* create archive names, supplying defaults */
X
X#if MSDOS
X    makefnam(arg[2],".ARC",arcname);
X#endif
X#if VAXC | BSD | ST
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(index("AMUFDXEPLVTCR",*a)) /* if a known command */
X         $    if(opt)                  /* do we have one yet? */
X                   abort("Cannot mix %c and %c",opt,*a);
X              opt = *a;                /* else remember it */
X         
X
X         else if(*a=='B')              /* retain backup copy */
X              keepbak = 1;
X
X         else if(*a=='W')              /* suppress warnings */
X              warn = 0;
X
X         else if(*a=='N')              /* suppress notes and comments */
X              note = 0;
X
X         else if(*a=='G')              /* garble */
X         $    password = a+1;
X              while(*a)
X                   a++;
X              a--;
X         
X
X         else if(*a=='S')              /* storage kludge */
X              nocomp = 1;
X
X         else if(*a=='K')              /* special kludge */
X              kludge = 1;
X
X`009 else if(*a=='Q')
X`009      $
X`009      printf("%%ARC-W-PRBLMS, Squash still has bugs; MIGHT work.\n");
X`009      dosquash = 1;
X`009      
X#ifdef VAXC
X`009else if(*a=='%')`009    /* Print VMS stat's if they want them */
X`009     vmsstats = 1;
X#endif VAXC
X
X         else if(*a=='-' || *a=='/')   /* UNIX and PC-DOS option markers */
X              ;
X
X         else abort("%c is an unknown command",*a);
X    
X
X    if(!opt)
X         abort("I have nothing to do!");
X
X    /* act on whatever action command was given */
X
X#ifdef VAXC
X    initvmsstats();
X#endif VAXC
X    switch(opt)                        /* action depends on command */
X    $
X    case 'A':                          /* Add */
X    case 'M':                          /* Move */
X    case 'U':                          /* Update */
X    case 'F':                          /* Freshen */
X         addarc(num-3,&arg[3],(opt=='M'),(opt=='U'),(opt=='F'));
X         break;
X
X    case 'D':                          /* Delete */
X         delarc(num-3,&arg[3]);
X         break;
X
X    case 'E':                          /* Extract */
X    case 'X':                          /* eXtract */
X    case 'P':                          /* Print */
X         extarc(num-3,&arg[3],(opt=='P'));
X         break;
X
X    case 'V':                          /* Verbose list */
X         bose = 1;
X    case 'L':                          /* List */
X         lstarc(num-3,&arg[3]);
X         break;
X
X    case 'T':                          /* Test */
X         tstarc();
X         break;
X
X    case 'C':                          /* Convert */
-+-+-+-+-+ End of part 1 +-+-+-+-+-

