home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / archivers / arcppc / src / rcs / arc.c,v next >
Text File  |  1998-04-23  |  25KB  |  1,075 lines

  1. head     1.12;
  2. branch   ;
  3. access   ;
  4. symbols  patch1:1.12 arc521:1.7;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.12
  10. date     88.07.31.18.39.50;  author hyc;  state Exp;
  11. branches ;
  12. next     1.11;
  13.  
  14. 1.11
  15. date     88.07.19.15.59.35;  author hyc;  state Exp;
  16. branches ;
  17. next     1.10;
  18.  
  19. 1.10
  20. date     88.06.17.15.22.48;  author hyc;  state Exp;
  21. branches ;
  22. next     1.9;
  23.  
  24. 1.9
  25. date     88.06.02.16.27.05;  author hyc;  state Exp;
  26. branches ;
  27. next     1.8;
  28.  
  29. 1.8
  30. date     88.06.01.19.16.10;  author hyc;  state Exp;
  31. branches ;
  32. next     1.7;
  33.  
  34. 1.7
  35. date     88.06.01.17.36.36;  author hyc;  state Exp;
  36. branches ;
  37. next     1.6;
  38.  
  39. 1.6
  40. date     88.06.01.15.05.12;  author hyc;  state Exp;
  41. branches ;
  42. next     1.5;
  43.  
  44. 1.5
  45. date     88.05.16.15.49.46;  author hyc;  state Exp;
  46. branches ;
  47. next     1.4;
  48.  
  49. 1.4
  50. date     88.04.11.19.03.58;  author hyc;  state Exp;
  51. branches ;
  52. next     1.3;
  53.  
  54. 1.3
  55. date     88.04.11.19.01.11;  author hyc;  state Exp;
  56. branches ;
  57. next     1.2;
  58.  
  59. 1.2
  60. date     88.04.11.17.35.34;  author hyc;  state Exp;
  61. branches ;
  62. next     1.1;
  63.  
  64. 1.1
  65. date     88.04.11.17.24.19;  author hyc;  state Exp;
  66. branches ;
  67. next     ;
  68.  
  69.  
  70. desc
  71. @@
  72.  
  73.  
  74. 1.12
  75. log
  76. @Fixed declarations...
  77. GEMDOS:
  78.     change stack size from 24K to 64K
  79.     add redirection of stdout when run from GEM desktop
  80. Unix:
  81.     create temp files in /tmp if not otherwise specified
  82.     allow arbitrary names for archives
  83. @
  84. text
  85. @/*
  86.  * $Header: arc.c,v 1.11 88/07/19 15:59:35 hyc Locked $
  87.  */
  88.  
  89. /*  ARC - Archive utility
  90.   
  91.     Version 5.21, created on 04/22/87 at 15:05:21
  92.   
  93. (C) COPYRIGHT 1985-87 by System Enhancement Associates; ALL RIGHTS RESERVED
  94.   
  95.     By:     Thom Henderson
  96.   
  97.     Description:
  98.      This program is a general archive utility, and is used to maintain
  99.      an archive of files.  An "archive" is a single file that combines
  100.      many files, reducing storage space and allowing multiple files to
  101.      be handled as one.
  102.   
  103.     Instructions:
  104.      Run this program with no arguments for complete instructions.
  105.   
  106.     Programming notes:
  107.      ARC Version 2 differs from version 1 in that archive entries
  108.      are automatically compressed when they are added to the archive,
  109.      making a separate compression step unecessary.     The nature of the
  110.      compression is indicated by the header version number placed in
  111.      each archive entry, as follows:
  112.   
  113.      1 = Old style, no compression
  114.      2 = New style, no compression
  115.      3 = Compression of repeated characters only
  116.      4 = Compression of repeated characters plus Huffman SQueezing
  117.      5 = Lempel-Zev packing of repeated strings (old style)
  118.      6 = Lempel-Zev packing of repeated strings (new style)
  119.      7 = Lempel-Zev Williams packing with improved hash function
  120.      8 = Dynamic Lempel-Zev packing with adaptive reset
  121.      9 = Dynamic Lempel-Zev packing, larger hash table
  122.   
  123.      Type 5, Lempel-Zev packing, was added as of version 4.0
  124.   
  125.      Type 6 is Lempel-Zev packing where runs of repeated characters
  126.      have been collapsed, and was added as of version 4.1
  127.   
  128.      Type 7 is a variation of Lempel-Zev using a different hash
  129.      function which yields speed improvements of 20-25%, and was
  130.      added as of version 4.6
  131.   
  132.      Type 8 is a different implementation of Lempel-Zev, using a
  133.      variable code size and an adaptive block reset, and was added
  134.      as of version 5.0
  135.   
  136.      Type 9 is a slight modification of type 8, first used by Phil
  137.      Katz in his PKARC utilites. The primary difference is the use
  138.      of a hash table twice as large as for type 8, and that this
  139.      algorithm called Squashing, doesn't perform run-length encoding
  140.      on the input data.
  141.   
  142.      Verion 4.3 introduced a temporary file for holding the result
  143.      of the first crunch pass, thus speeding up crunching.
  144.   
  145.      Version 4.4 introduced the ARCTEMP environment string, so that
  146.      the temporary crunch file may be placed on a ramdisk.    Also
  147.      added was the distinction bewteen Adding a file in all cases,
  148.      and Updating a file only if the disk file is newer than the
  149.      corresponding archive entry.
  150.   
  151.      The compression method to use is determined when the file is
  152.      added, based on whichever method yields the smallest result.
  153.   
  154.     Language:
  155.      Computer Innovations Optimizing C86
  156. */
  157. #include <stdio.h>
  158. #include "arc.h"
  159.  
  160. #if    UNIX
  161. #include <sys/types.h>
  162. #include <sys/stat.h>
  163. #endif
  164.  
  165. int        strlen();
  166. void        addarc(), delarc(), extarc(), lstarc(), tstarc(), cvtarc(), runarc();
  167. void        abort();
  168. static    void    expandlst();
  169. #if    MTS
  170. void        etoa();
  171. #endif
  172. #if    GEMDOS
  173. long        _stksize = 65536L;
  174. #endif
  175. char        *strcpy(), *strcat();
  176. char        *makefnam();    /* filename fixup routine */
  177.  
  178. static char   **lst;        /* files list */
  179. static int    lnum;        /* length of files list */
  180.  
  181. main(num, arg)            /* system entry point */
  182.     int        num;    /* number of arguments */
  183.     char           *arg[];    /* pointers to arguments */
  184. {
  185.     char        opt = 0;/* selected action */
  186.     char           *a;    /* option pointer */
  187.     void        upper();/* case conversion routine */
  188.     char           *index();/* string index utility */
  189.     char           *envfind();    /* environment searcher */
  190.     int        n;    /* index */
  191.     char           *arctemp2, *calloc(), *mktemp();
  192. #if    GEMDOS
  193.     void        exitpause();
  194.     int        append;
  195. #endif
  196. #if    MTS
  197.     fortran void    guinfo();
  198.     char        gotinf[4];
  199. #endif
  200. #if    UNIX
  201.     struct    stat    sbuf;
  202. #endif
  203.  
  204.     if (num < 3) {
  205.         printf("ARC - Archive utility, Version 5.21, created on 04/22/87 at 15:05:21\n");
  206. /*        printf("(C) COPYRIGHT 1985,86,87 by System Enhancement Associates;");
  207.         printf(" ALL RIGHTS RESERVED\n\n");
  208.         printf("Please refer all inquiries to:\n\n");
  209.         printf("       System Enhancement Associates\n");
  210.         printf("       21 New Street, Wayne NJ 07470\n\n");
  211.         printf("You may copy and distribute this program freely,");
  212.         printf(" provided that:\n");
  213.         printf("    1)     No fee is charged for such copying and");
  214.         printf(" distribution, and\n");
  215.         printf("    2)     It is distributed ONLY in its original,");
  216.         printf(" unmodified state.\n\n");
  217.         printf("If you like this program, and find it of use, then your");
  218.         printf(" contribution will\n");
  219.         printf("be appreciated.     You may not use this product in a");
  220.         printf(" commercial environment\n");
  221.         printf("or a governmental organization without paying a license");
  222.         printf(" fee of $35.  Site\n");
  223.         printf("licenses and commercial distribution licenses are");
  224.         printf(" available.  A program\n");
  225.         printf("disk and printed documentation are available for $50.\n");
  226.         printf("\nIf you fail to abide by the terms of this license, ");
  227.         printf(" then your conscience\n");
  228.         printf("will haunt you for the rest of your life.\n\n"); */
  229. #if    MSDOS
  230.         printf("Usage: ARC {amufdxerplvtc}[bswnoq][g<password>]");
  231. #endif
  232. #if    GEMDOS
  233.         printf("Usage: ARC {amufdxerplvtc}[bhswnoq][g<password>]");
  234. #endif
  235. #if    UNIX
  236.         printf("Usage: arc {amufdxerplvtc}[biswnoq][g<password>]");
  237. #endif
  238. #if    MTS
  239.         printf("Parameters: {amufdxeplvtc}[biswnoq][g<password>]");
  240. #endif
  241.         printf(" <archive> [<filename> . . .]\n");
  242.         printf("Where:     a   = add files to archive\n");
  243.         printf("     m   = move files to archive\n");
  244.         printf("     u   = update files in archive\n");
  245.         printf("     f   = freshen files in archive\n");
  246.         printf("     d   = delete files from archive\n");
  247.         printf("     x,e = extract files from archive\n");
  248. #if    !MTS
  249.         printf("     r   = run files from archive\n");
  250. #endif
  251.         printf("     p   = copy files from archive to");
  252.         printf(" standard output\n");
  253.         printf("     l   = list files in archive\n");
  254.         printf("     v   = verbose listing of files in archive\n");
  255.         printf("     t   = test archive integrity\n");
  256.         printf("     c   = convert entry to new packing method\n");
  257.         printf("     b   = retain backup copy of archive\n");
  258. #if    GEMDOS
  259.         printf("     h   = hold screen after finishing\n");
  260. #endif
  261. #if    MTS
  262.         printf("     i   = suppress ASCII/EBCDIC translation\n");
  263. #endif
  264. #if    UNIX
  265.         printf("     i   = suppress image mode (translate EOL)\n");
  266. #endif
  267.         printf("     s   = suppress compression (store only)\n");
  268.         printf("     w   = suppress warning messages\n");
  269.         printf("     n   = suppress notes and comments\n");
  270.         printf("     o   = overwrite existing files when");
  271.         printf(" extracting\n");
  272.         printf("     q   = squash instead of crunching\n");
  273.         printf("     g   = Encrypt/decrypt archive entry\n");
  274.         printf("\nAdapted from MSDOS by Howard Chu\n");
  275.         /*
  276.          * printf("\nPlease refer to the program documentation for");
  277.          * printf(" complete instructions.\n"); 
  278.          */
  279. #if    GEMDOS
  280.         exitpause();
  281. #endif
  282.         return 1;
  283.     }
  284.     /* see where temp files go */
  285. #if    !MTS
  286.     arctemp = calloc(1, STRLEN);
  287.     if (!(arctemp2 = envfind("ARCTEMP")))
  288.         arctemp2 = envfind("TMPDIR");
  289.     if (arctemp2) {
  290.         strcpy(arctemp, arctemp2);
  291.         n = strlen(arctemp);
  292.         if (arctemp[n - 1] != CUTOFF)
  293.             arctemp[n] = CUTOFF;
  294.     }
  295. #if    UNIX
  296.     else    strcpy(arctemp, "/tmp/");
  297. #endif
  298. #if    !MSDOS
  299.     {
  300.         static char tempname[] = "AXXXXXX";
  301.         strcat(arctemp, mktemp(tempname));
  302.     }
  303. #else
  304.     strcat(arctemp, "$ARCTEMP");
  305.     arctemp2 = NULL;
  306. #endif
  307. #else
  308.     guinfo("SHFSEP    ", gotinf);
  309.     sepchr[0] = gotinf[0];
  310.     guinfo("SCRFCHAR", gotinf);
  311.     tmpchr[0] = gotinf[0];
  312.     arctemp = "-$$$";
  313.     arctemp[0] = tmpchr[0];
  314. #endif
  315.  
  316. #if    !UNIX
  317.     /* avoid any case problems with arguments */
  318.  
  319.     for (n = 1; n < num; n++)    /* for each argument */
  320.         upper(arg[n]);    /* convert it to uppercase */
  321. #else
  322.     /* avoid case problems with command options */
  323.     upper(arg[1]);        /* convert to uppercase */
  324. #endif
  325.  
  326.     /* create archive names, supplying defaults */
  327. #if    UNIX
  328.     if (!stat(arg[2],&sbuf))
  329.         strcpy(arcname,arg[2]);
  330.     else
  331.         makefnam(arg[2],".arc",arcname);
  332. #else
  333.     makefnam(arg[2], ".ARC", arcname);
  334. #endif
  335.     /* makefnam(".$$$",arcname,newname); */
  336.     sprintf(newname, "%s.arc", arctemp);
  337.     makefnam(".BAK", arcname, bakname);
  338.  
  339.     /* now scan the command and see what we are to do */
  340.  
  341.     for (a = arg[1]; *a; a++) {    /* scan the option flags */
  342. #if    !MTS
  343.         if (index("AMUFDXEPLVTCR", *a)) {    /* if a known command */
  344. #else
  345.         if (index("AMUFDXEPLVTC", *a)) {
  346. #endif
  347.             if (opt)/* do we have one yet? */
  348.                 abort("Cannot mix %c and %c", opt, *a);
  349.             opt = *a;    /* else remember it */
  350.         } else if (*a == 'B')    /* retain backup copy */
  351.             keepbak = 1;
  352.  
  353.         else if (*a == 'W')    /* suppress warnings */
  354.             warn = 0;
  355. #if    !DOS
  356.         else if (*a == 'I')    /* image mode, no ASCII/EBCDIC x-late */
  357.             image = !image;
  358. #endif
  359. #if    GEMDOS
  360.         else if (*a == 'H')    /* pause before exit */
  361.             hold = 1;
  362. #endif
  363.  
  364.         else if (*a == 'N')    /* suppress notes and comments */
  365.             note = 0;
  366.  
  367.         else if (*a == 'O')    /* overwrite file on extract */
  368.             overlay = 1;
  369.  
  370.         else if (*a == 'G') {    /* garble */
  371.             password = a + 1;
  372.             while (*a)
  373.                 a++;
  374.             a--;
  375. #if    MTS
  376.             etoa(password, strlen(password));
  377. #endif
  378.         } else if (*a == 'S')    /* storage kludge */
  379.             nocomp = 1;
  380.  
  381.         else if (*a == 'K')    /* special kludge */
  382.             kludge = 1;
  383.  
  384.         else if (*a == 'Q')    /* use squashing */
  385.             dosquash = 1;
  386.  
  387.         else if (*a == '-' || *a == '/')    /* UNIX and PC-DOS
  388.                              * option markers */
  389.             ;
  390.  
  391.         else
  392.             abort("%c is an unknown command", *a);
  393.     }
  394.  
  395.     if (!opt)
  396.         abort("I have nothing to do!");
  397.  
  398.     /* get the files list set up */
  399.  
  400.     lnum = num - 3;        /* initial length of list */
  401.     lst = (char **) calloc((lnum==0) ? 1:lnum,
  402.                  sizeof(char *));    /* initial list */
  403.     for (n = 3; n < num; n++)
  404.         lst[n - 3] = arg[n];
  405.  
  406.     for (n = 0; n < lnum;) {/* expand indirect references */
  407.         if (*lst[n] == '@@')
  408.             expandlst(n);
  409. #if    GEMDOS        /* redirect stdout from the desktop...*/
  410.         else if (*lst[n] == '>') {
  411.             arctemp2 = (++lst[n]);
  412.             lst[n] = lst[lnum-1];    /* delete this entry */
  413.             lnum--;
  414.             if (arctemp2[0] == '>') {
  415.                 append = 1;
  416.                 arctemp2++;
  417.             }
  418.             else    append = 0;
  419.         }
  420. #endif
  421.         else
  422.             n++;
  423.     }
  424. #if    GEMDOS
  425.     if (arctemp2)
  426.         freopen(arctemp2,append ? "a" : "w",stdout);
  427. #endif
  428.  
  429.     /* act on whatever action command was given */
  430.  
  431.     switch (opt) {        /* action depends on command */
  432.     case 'A':        /* Add */
  433.     case 'M':        /* Move */
  434.     case 'U':        /* Update */
  435.     case 'F':        /* Freshen */
  436.         addarc(lnum, lst, (opt == 'M'), (opt == 'U'), (opt == 'F'));
  437.         break;
  438.  
  439.     case 'D':        /* Delete */
  440.         delarc(lnum, lst);
  441.         break;
  442.  
  443.     case 'E':        /* Extract */
  444.     case 'X':        /* eXtract */
  445.     case 'P':        /* Print */
  446.         extarc(lnum, lst, (opt == 'P'));
  447.         break;
  448.  
  449.     case 'V':        /* Verbose list */
  450.         bose = 1;
  451.     case 'L':        /* List */
  452.         lstarc(lnum, lst);
  453.         break;
  454.  
  455.     case 'T':        /* Test */
  456.         tstarc();
  457.         break;
  458.  
  459.     case 'C':        /* Convert */
  460.         cvtarc(lnum, lst);
  461.         break;
  462. #if    !MTS
  463.     case 'R':        /* Run */
  464.         runarc(lnum, lst);
  465.         break;
  466. #endif
  467.     default:
  468.         abort("I don't know how to do %c yet!", opt);
  469.     }
  470. #if    GEMDOS
  471.     if (hold)
  472.         exitpause();
  473. #endif
  474.     return nerrs;
  475. }
  476. static    void
  477. expandlst(n)            /* expand an indirect reference */
  478.     int        n;    /* number of entry to expand */
  479. {
  480.     FILE           *lf, *fopen();    /* list file, opener */
  481.     char           *malloc(), *realloc();    /* memory managers */
  482.     char        buf[100];    /* input buffer */
  483.     int        x;    /* index */
  484.     char           *p = lst[n] + 1; /* filename pointer */
  485.  
  486.     if (*p) {        /* use name if one was given */
  487.         makefnam(p, ".CMD", buf);
  488.         if (!(lf = fopen(buf, "r")))
  489.             abort("Cannot read list of files in %s", buf);
  490.     } else
  491.         lf = stdin;    /* else use standard input */
  492.  
  493.     for (x = n + 1; x < lnum; x++)    /* drop reference from the list */
  494.         lst[x - 1] = lst[x];
  495.     lnum--;
  496.  
  497.     while (fscanf(lf, "%99s", buf) > 0) {    /* read in the list */
  498.         if (!(lst =(char **)realloc(lst, (lnum + 1) * sizeof(char *))))
  499.             abort("too many file references");
  500.  
  501.         lst[lnum] = malloc(strlen(buf) + 1);
  502.         strcpy(lst[lnum], buf); /* save the name */
  503.         lnum++;
  504.     }
  505.  
  506.     if (lf != stdin)    /* avoid closing standard input */
  507.         fclose(lf);
  508. }
  509. @
  510.  
  511.  
  512. 1.11
  513. log
  514. @Fixes from John Gilmore, message date Mon, 4 Jul 88 03:02:43 PDT
  515. @
  516. text
  517. @d2 1
  518. a2 1
  519.  * $Header: arc.c,v 1.10 88/06/17 15:22:48 hyc Locked $
  520. d76 5
  521. d84 1
  522. d89 1
  523. a89 1
  524. long        _stksize = 24576;
  525. d92 1
  526. a102 1
  527.     char           *makefnam();    /* filename fixup routine */
  528. d110 1
  529. d116 3
  530. d211 3
  531. d221 1
  532. d243 8
  533. a250 1
  534.     makefnam(arg[2], ".arc", arcname);
  535. d325 12
  536. d340 4
  537. d392 1
  538. a392 1
  539. static
  540. @
  541.  
  542.  
  543. 1.10
  544. log
  545. @Changed description of 'i' option for Unix.
  546. @
  547. text
  548. @d2 1
  549. a2 1
  550.  * $Header: arc.c,v 1.9 88/06/02 16:27:05 hyc Locked $
  551. d171 1
  552. a171 1
  553.         printf("     i   = suppress image mode (translate EOL)");
  554. d202 4
  555. a205 1
  556.     strcat(arctemp, mktemp("AXXXXXX"));
  557. @
  558.  
  559.  
  560. 1.9
  561. log
  562. @Minor fixes & speedups
  563. @
  564. text
  565. @d2 1
  566. a2 1
  567.  * $Header: arc.c,v 1.8 88/06/01 19:16:10 hyc Locked $
  568. d85 1
  569. d171 1
  570. a171 1
  571.         printf("     i   = suppress CRLF to '\\n' translation\n");
  572. d249 1
  573. a249 1
  574.             image = 1;
  575. @
  576.  
  577.  
  578. 1.8
  579. log
  580. @Change compilation conditionals
  581. @
  582. text
  583. @d2 1
  584. a2 1
  585.  * $Header: arc.c,v 1.7 88/06/01 17:36:36 hyc Locked $
  586. d292 2
  587. a293 1
  588.     lst = (char **) calloc(lnum, sizeof(char *));    /* initial list */
  589. @
  590.  
  591.  
  592. 1.7
  593. log
  594. @Merged Arc 5.21 changes
  595. @
  596. text
  597. @d2 1
  598. a2 1
  599.  * $Header: arc.c,v 1.6 88/06/01 15:05:12 hyc Locked $
  600. d79 1
  601. a79 1
  602. #ifdef MTS
  603. d82 1
  604. a82 1
  605. #ifdef    GEMDOS
  606. d101 1
  607. a101 1
  608. #ifdef    GEMDOS
  609. d104 1
  610. a104 1
  611. #ifdef MTS
  612. d111 1
  613. a111 1
  614.         printf("(C) COPYRIGHT 1985,86,87 by System Enhancement Associates;");
  615. d133 2
  616. a134 2
  617.         printf("will haunt you for the rest of your life.\n\n");
  618. #ifdef MSDOS
  619. d137 1
  620. a137 1
  621. #ifdef GEMDOS
  622. d140 1
  623. a140 1
  624. #ifdef BSD
  625. d143 1
  626. a143 1
  627. #ifdef MTS
  628. d153 1
  629. a153 1
  630. #ifndef MTS
  631. d163 1
  632. a163 1
  633. #ifdef    GEMDOS
  634. d166 1
  635. a166 1
  636. #ifdef    MTS
  637. d169 1
  638. a169 1
  639. #ifdef    BSD
  640. d184 1
  641. a184 1
  642. #ifdef    GEMDOS
  643. d190 1
  644. a190 1
  645. #ifndef MTS
  646. d200 1
  647. d203 3
  648. d214 1
  649. a214 1
  650. #ifndef BSD
  651. d233 1
  652. a233 1
  653. #ifndef MTS
  654. d246 1
  655. a246 1
  656. #ifndef DOS
  657. d250 1
  658. a250 1
  659. #ifdef    GEMDOS
  660. d266 1
  661. a266 1
  662. #ifdef MTS
  663. d292 1
  664. a292 1
  665.     lst = calloc(lnum, sizeof(char *));    /* initial list */
  666. d336 1
  667. a336 1
  668. #ifndef MTS
  669. d344 1
  670. a344 1
  671. #ifdef    GEMDOS
  672. d372 1
  673. a372 1
  674.         if (!(lst = realloc(lst, (lnum + 1) * sizeof(char *))))
  675. @
  676.  
  677.  
  678. 1.6
  679. log
  680. @Merged Atari ST changes in.
  681. @
  682. text
  683. @d2 1
  684. a2 1
  685.  * $Header: arc.c,v 1.5 88/05/16 15:49:46 hyc Locked $
  686. d5 68
  687. a72 59
  688. /*
  689.  * ARC - Archive utility
  690.  * 
  691.  * Version 5.20, created on 10/24/86 at 14:56:41
  692.  * 
  693.  * (C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
  694.  * 
  695.  * By:  Thom Henderson
  696.  * 
  697.  * Description: This program is a general archive utility, and is used to
  698.  * maintain an archive of files.  An "archive" is a single file that combines
  699.  * many files, reducing storage space and allowing multiple files to be
  700.  * handled as one.
  701.  * 
  702.  * Instructions: Run this program with no arguments for complete instructions.
  703.  * 
  704.  * Programming notes: ARC Version 2 differs from version 1 in that archive
  705.  * entries are automatically compressed when they are added to the archive,
  706.  * making a separate compression step unecessary.  The nature of the
  707.  * compression is indicated by the header version number placed in each
  708.  * archive entry, as follows:
  709.  * 
  710.  *    1 = Old style, no compression
  711.  *    2 = New style, no compression
  712.  *    3 = Compression of repeated characters only
  713.  *    4 = Compression of repeated characters plus Huffman SQueezing
  714.  *    5 = Lempel-Zev packing of repeated strings (old style)
  715.  *    6 = Lempel-Zev packing of repeated strings (new style)
  716.  *    7 = Lempel-Zev Williams packing with improved hash function
  717.  *    8 = Dynamic Lempel-Zev packing with adaptive reset
  718.  *    9 = Squashing, ala Phil Katz's PKARC
  719.  * 
  720.  * Type 5, Lempel-Zev packing, was added as of version 4.0
  721.  * 
  722.  * Type 6 is Lempel-Zev packing where runs of repeated characters have been
  723.  * collapsed, and was added as of version 4.1
  724.  * 
  725.  * Type 7 is a variation of Lempel-Zev using a different hash function which
  726.  * yields speed improvements of 20-25%, and was added as of version 4.6
  727.  * 
  728.  * Type 8 is a different implementation of Lempel-Zev, using a variable code
  729.  * size and an adaptive block reset, and was added as of version 5.0
  730.  *
  731.  * Type 9 is yet another implementation of Lempel-Zev, used originally by
  732.  * Phil Katz in his PKARC utility.
  733.  * 
  734.  * Verion 4.3 introduced a temporary file for holding the result of the first
  735.  * crunch pass, thus speeding up crunching.
  736.  * 
  737.  * Version 4.4 introduced the ARCTEMP environment string, so that the temporary
  738.  * crunch file may be placed on a ramdisk.  Also added was the distinction
  739.  * bewteen Adding a file in all cases, and Updating a file only if the disk
  740.  * file is newer than the corresponding archive entry.
  741.  * 
  742.  * The compression method to use is determined when the file is added, based on
  743.  * whichever method yields the smallest result.
  744.  * 
  745.  * Language: Computer Innovations Optimizing C86
  746.  */
  747. d76 3
  748. a78 3
  749. int    strlen();
  750. void    addarc(), delarc(), extarc(), lstarc(), tstarc(), cvtarc(), runarc();
  751. void    abort();
  752. d80 1
  753. a80 1
  754. void    etoa();
  755. d83 1
  756. a83 1
  757.     long    _stksize=24576;
  758. d86 3
  759. d90 2
  760. a91 2
  761.     int             num;    /* number of arguments */
  762.     char           *arg[];    /* pointers to arguments */
  763. d93 8
  764. a100 8
  765.     char            opt = 0;/* selected action */
  766.     char           *a;    /* option pointer */
  767.     char           *makefnam();    /* filename fixup routine */
  768.     void            upper();/* case conversion routine */
  769.     char           *index();/* string index utility */
  770.     char           *envfind();    /* environment searcher */
  771.     int             n;    /* argument index */
  772.     char           *arctemp2, *calloc(), *mktemp();
  773. d105 1
  774. a105 1
  775.     fortran    void    guinfo();
  776. d110 24
  777. a133 24
  778.         printf("ARC - Archive utility, Version 5.20, created on 10/24/86 at 14:56:41\n");
  779.         /*
  780.          * printf("(C) COPYRIGHT 1985,86 by System Enhancement
  781.          * Associates;"); printf(" ALL RIGHTS RESERVED\n\n");
  782.          * printf("Please refer all inquiries to:\n\n"); printf("
  783.          * System Enhancement Associates\n"); printf("       21 New
  784.          * Street, Wayne NJ 07470\n\n"); printf("You may copy and
  785.          * distribute this program freely,"); printf(" provided
  786.          * that:\n"); printf("    1)   No fee is charged for such
  787.          * copying and"); printf(" distribution, and\n"); printf(" 2) 
  788.          * It is distributed ONLY in its original,"); printf("
  789.          * unmodified state.\n\n"); printf("If you like this program,
  790.          * and find it of use, then your"); printf(" contribution
  791.          * will\n"); printf("be appreciated.  You may not use this
  792.          * product in a"); printf(" commercial environment\n");
  793.          * printf("or a governmental organization without paying a
  794.          * license"); printf(" fee of $35.  Site\n");
  795.          * printf("licenses and commercial distribution licenses
  796.          * are"); printf(" available.  A program\n"); printf("disk
  797.          * and printed documentation are available for $50.\n");
  798.          * printf("\nIf you fail to abide by the terms of this
  799.          * license, "); printf(" then your conscience\n");
  800.          * printf("will haunt you for the rest of your life.\n\n"); 
  801.          */
  802. d147 6
  803. a152 6
  804.         printf("Where:   a   = add files to archive\n");
  805.         printf("         m   = move files to archive\n");
  806.         printf("         u   = update files in archive\n");
  807.         printf("         f   = freshen files in archive\n");
  808.         printf("         d   = delete files from archive\n");
  809.         printf("         x,e = extract files from archive\n");
  810. d154 1
  811. a154 1
  812.         printf("         r   = run files from archive\n");
  813. d156 1
  814. a156 1
  815.         printf("         p   = copy files from archive to");
  816. d158 5
  817. a162 5
  818.         printf("         l   = list files in archive\n");
  819.         printf("         v   = verbose listing of files in archive\n");
  820.         printf("         t   = test archive integrity\n");
  821.         printf("         c   = convert entry to new packing method\n");
  822.         printf("         b   = retain backup copy of archive\n");
  823. d164 1
  824. a164 1
  825.         printf("         h   = hold screen after finishing\n");
  826. d167 1
  827. a167 1
  828.         printf("         i   = suppress ASCII/EBCDIC translation\n");
  829. d170 1
  830. a170 1
  831.         printf("         i   = suppress CRLF to '\\n' translation\n");
  832. d172 4
  833. a175 4
  834.         printf("         s   = suppress compression (store only)\n");
  835.         printf("         w   = suppress warning messages\n");
  836.         printf("         n   = suppress notes and comments\n");
  837.         printf("         o   = overwrite existing files when");
  838. d177 2
  839. a178 2
  840.         printf("         q   = squash instead of crunching\n");
  841.         printf("         g   = Encrypt/decrypt archive entry\n");
  842. d180 4
  843. a183 2
  844.     /*    printf("\nPlease refer to the program documentation for");
  845.         printf(" complete instructions.\n"); */
  846. a188 1
  847.  
  848. d191 1
  849. a191 1
  850.     arctemp = calloc(1,STRLEN);
  851. d197 1
  852. a197 1
  853.         if(arctemp[n-1] != CUTOFF)
  854. a199 1
  855.  
  856. d202 1
  857. a202 1
  858.     guinfo("SHFSEP  ", gotinf);
  859. d285 14
  860. d306 1
  861. a306 1
  862.         addarc(num - 3, &arg[3], (opt == 'M'), (opt == 'U'), (opt == 'F'));
  863. d310 1
  864. a310 1
  865.         delarc(num - 3, &arg[3]);
  866. d316 1
  867. a316 1
  868.         extarc(num - 3, &arg[3], (opt == 'P'));
  869. d322 1
  870. a322 1
  871.         lstarc(num - 3, &arg[3]);
  872. d330 1
  873. a330 1
  874.         cvtarc(num - 3, &arg[3]);
  875. d334 1
  876. a334 1
  877.         runarc(num - 3, &arg[3]);
  878. d345 33
  879. @
  880.  
  881.  
  882. 1.5
  883. log
  884. @Normalize all the INT/LONG declarations,
  885. various MTS stuff, straighten out external routine declarations.
  886. @
  887. text
  888. @d2 1
  889. a2 1
  890.  * $Header: arc.c,v 1.8 88/04/19 01:37:51 hyc Exp $
  891. d73 3
  892. a86 1
  893. #ifndef BSD
  894. d88 3
  895. a91 4
  896.     char           *arctemp2, *malloc();
  897. #ifdef BSD
  898.     int             getpid();
  899. #endif
  900. d93 2
  901. a94 2
  902.     fortran         guinfo();
  903.     char            gotinf[4];
  904. d125 3
  905. d151 3
  906. d167 1
  907. d170 3
  908. d175 1
  909. a176 2
  910.     /* use process id to insure unique temp files */
  911.  
  912. d178 1
  913. a178 1
  914.     arctemp = malloc(STRLEN);
  915. d180 9
  916. a188 5
  917.         arctemp2 = envfind("TEMP");
  918.     if (arctemp2)
  919.         sprintf(arctemp, "%s.Arc%d", arctemp2, getpid());
  920.     else
  921.         sprintf(arctemp, ".Arc%d", getpid());
  922. a208 3
  923. #ifndef BSD
  924.     makefnam(arg[2], ".ARC", arcname);
  925. #else
  926. a209 1
  927. #endif
  928. d211 1
  929. a211 1
  930.     sprintf(newname, "%s.ARC", arctemp);
  931. d230 1
  932. a230 1
  933. #ifndef MSDOS
  934. d234 4
  935. d314 4
  936. a317 1
  937.  
  938. @
  939.  
  940.  
  941. 1.4
  942. log
  943. @another omitted section. Ooops.
  944. @
  945. text
  946. @d2 1
  947. a2 31
  948.  * $Log:    arc.c,v $
  949.  * Revision 1.3  88/04/11  19:01:11  hyc
  950.  * added printf accidentally omitted...
  951.  * 
  952.  * Revision 1.2  88/04/11  17:35:34  hyc
  953.  * re-synch with MTS version, add squashing support.
  954.  * 
  955.  * Revision 1.1  88/04/11  17:24:19  hyc
  956.  * Initial revision
  957.  * 
  958.  * Revision 1.4  87/12/20  03:39:46  hyc
  959.  * Fix command description (MTS vs Unix usage of 'i' flag...)
  960.  * 
  961.  * Revision 1.3  87/12/19  04:35:12  hyc
  962.  * Change MTS to MSDOS for #ifdef of printf for image mode...
  963.  * 
  964.  * Revision 1.2  87/12/19  04:00:18  hyc
  965.  * MAde #ifdef of image #ifndef MSDOS...
  966.  * 
  967.  * Revision 1.1  87/12/19  03:59:14  hyc
  968.  * Initial revision
  969.  * 
  970.  * Revision 1.5  87/08/13  17:02:39  hyc
  971.  * Run thru the indent program...
  972.  *  Revision 1.4  87/07/30  03:38:15  hyc Minor junk
  973.  * 
  974.  * Revision 1.3  87/07/21  11:39:35  hyc minor fixups
  975.  * 
  976.  * Revision 1.2  87/07/21  06:23:13  hyc Modified according to the mods made to
  977.  * arc 5.12 for unix.
  978.  * 
  979. d67 7
  980. d75 1
  981. a75 1
  982.     INT             num;    /* number of arguments */
  983. d81 1
  984. a81 1
  985.     char           *upper();/* case conversion routine */
  986. d84 3
  987. a86 1
  988.     INT             n;    /* argument index */
  989. d89 1
  990. a89 1
  991.     LONG            getpid();
  992. d168 1
  993. a168 1
  994.     arctemp = malloc(256);
  995. d172 1
  996. a172 1
  997.         sprintf(arctemp, "%s.Arc%ld", arctemp2, getpid());
  998. d174 1
  999. a174 1
  1000.         sprintf(arctemp, ".Arc%ld", getpid());
  1001. @
  1002.  
  1003.  
  1004. 1.3
  1005. log
  1006. @added printf accidentally omitted...
  1007. @
  1008. text
  1009. @d3 3
  1010. d265 3
  1011. @
  1012.  
  1013.  
  1014. 1.2
  1015. log
  1016. @re-synch with MTS version, add squashing support.
  1017. @
  1018. text
  1019. @d3 3
  1020. d176 1
  1021. @
  1022.  
  1023.  
  1024. 1.1
  1025. log
  1026. @Initial revision
  1027. @
  1028. text
  1029. @d3 3
  1030. d51 9
  1031. a59 6
  1032.  * 1 = Old style, no compression 2 = New style, no compression 3 = Compression
  1033.  * of repeated characters only 4 = Compression of repeated characters plus
  1034.  * Huffman SQueezing 5 = Lempel-Zev packing of repeated strings (old style) 6
  1035.  * = Lempel-Zev packing of repeated strings (new style) 7 = Lempel-Zev
  1036.  * Williams packing with improved hash function 8 = Dynamic Lempel-Zev
  1037.  * packing with adaptive reset
  1038. d71 3
  1039. d136 2
  1040. a137 4
  1041. #ifndef MTS
  1042.         printf("Usage: ARC {amufdxerplvtc}[bswno][g<password>]");
  1043. #else
  1044.         printf("Parameters: {amufdxeplvtc}[biswno][g<password>]");
  1045. d139 6
  1046. d174 2
  1047. a175 2
  1048.         printf("\nPlease refer to the program documentation for");
  1049.         printf(" complete instructions.\n");
  1050. d235 1
  1051. a235 2
  1052.         else if (*a == 'I')
  1053.             /* image mode, no ASCII/EBCDIC x-late */
  1054. d239 1
  1055. a239 2
  1056.         else if (*a == 'N')
  1057.             /* suppress notes and comments */
  1058. d242 1
  1059. a242 2
  1060.         else if (*a == 'O')
  1061.             /* overwrite file on extract */
  1062. d253 1
  1063. a253 2
  1064.         } else if (*a == 'S')
  1065.             /* storage kludge */
  1066. d256 1
  1067. a256 2
  1068.         else if (*a == 'K')
  1069.             /* special kludge */
  1070. d259 2
  1071. a260 2
  1072.         else if (*a == '-' || *a == '/')
  1073.             /* UNIX and PC-DOS * option markers */
  1074. @
  1075.