[comp.os.vms] ARC_C.SHAR01_OF_19

ewilts%Ins.MRC.AdhocNet.CA%Stasis.MRC.AdhocNet.CA%UNCAEDU.@CORNELLC.CCS.CORNELL.EDU.BITNET (Ed Wilts) (06/24/88)

....................... Cut between dotted lines and save .....................
.
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by EWILTS
$! on Friday 24-JUN-1988 08:13:22.18
$!
$! ATTENTION: To keep each article below 15872 bytes, this program
$! has been transmitted in 16 parts.
$! You should concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 23 files:
$! ARC.C ARCADD.C ARCCODE.C ARCCVT.C ARCDEL.C ARCDIR.C ARCDOS.C ARCEXT.C ARCIO.C
$! ARCLST.C ARCLZW.C ARCMATCH.C ARCMISC.C ARCPACK.C ARCRUN.C ARCS.C ARCSQ.C
$! ARCSVC.C ARCTST.C ARCUNP.C ARCUSQ.C ARCVAX.C SQUASH.C
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="ARC.C"
$ Check_Sum_is=924119136
$ Copy SYS$Input VMS_SHAR_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 * 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 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 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 */
X         cvtarc(num-3,&arg[3]);
X         break;
X
X    case 'R':                          /* Run */
X         runarc(num-3,&arg[3]);
X         break;
X
X    default:
X         abort("I don't know how to do %c yet!",opt);
X    }
X#ifdef VAXC
X    printvmsstats();
X#endif VAXC
X
X    return nerrs;
X}
X
$ GoSub Convert_File
$ Goto Part02