home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / archivers / arcppc / src / rcs / arclst.c,v < prev    next >
Text File  |  1998-04-23  |  7KB  |  372 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  arc521:1.5;
  5. locks    hyc:1.5; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     88.06.01.18.05.57;  author hyc;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.06.01.15.41.54;  author hyc;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.06.01.15.41.19;  author hyc;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.04.11.18.03.10;  author hyc;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.04.11.18.01.46;  author hyc;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Merge ARC 5.21 changes
  42. @
  43. text
  44. @/*
  45.  * $Header: arclst.c,v 1.4 88/06/01 15:41:54 hyc Locked $
  46.  */
  47.  
  48. /*  ARC - Archive utility - ARCLST
  49.   
  50.     Version 2.39, created on 04/22/87 at 13:48:29
  51.   
  52. (C) COPYRIGHT 1985-87 by System Enhancement Associates; ALL RIGHTS RESERVED
  53.   
  54.     By:     Thom Henderson
  55.   
  56.     Description:
  57.      This file contains the routines used to list the contents
  58.      of an archive.
  59.   
  60.     Language:
  61.      Computer Innovations Optimizing C86
  62. */
  63. #include <stdio.h>
  64. #include "arc.h"
  65.  
  66. void            rempath(), openarc(), closearc();
  67. int             readhdr(), match();
  68.  
  69. void
  70. lstarc(num, arg)        /* list files in archive */
  71.     int             num;    /* number of arguments */
  72.     char           *arg[];    /* pointers to arguments */
  73. {
  74.     struct heads    hdr;    /* header data */
  75.     int             list;    /* true to list a file */
  76.     int             did[MAXARG];    /* true when argument was used */
  77.     long            tnum, tlen, tsize;    /* totals */
  78.     int             n;    /* index */
  79.     void            lstfile();
  80.  
  81.     tnum = tlen = tsize = 0;/* reset totals */
  82.  
  83.     for (n = 0; n < num; n++)    /* for each argument */
  84.         did[n] = 0;    /* reset usage flag */
  85.     rempath(num, arg);    /* strip off paths */
  86.  
  87.     if (note && !kludge) {
  88.         printf("Name          Length  ");
  89.         if (bose)
  90.             printf("  Stowage    SF   Size now");
  91.         printf("  Date     ");
  92.         if (bose)
  93.             printf("  Time    CRC");
  94.         printf("\n");
  95.  
  96.         printf("============  ========");
  97.         if (bose)
  98.             printf("  ========  ====  ========");
  99.         printf("  =========");
  100.         if (bose)
  101.             printf("  ======  ====");
  102.         printf("\n");
  103.     }
  104.     openarc(0);        /* open archive for reading */
  105.  
  106.     if (num) {        /* if files were named */
  107.         while (readhdr(&hdr, arc)) {    /* process all archive files */
  108.             list = 0;    /* reset list flag */
  109.             for (n = 0; n < num; n++) {    /* for each template
  110.                              * given */
  111.                 if (match(hdr.name, arg[n])) {
  112.                     list = 1;    /* turn on list flag */
  113.                     did[n] = 1;    /* turn on usage flag */
  114.                     break;    /* stop looking */
  115.                 }
  116.             }
  117.  
  118.             if (list) {    /* if this file is wanted */
  119.                 if (!kludge)
  120.                     lstfile(&hdr);    /* then tell about it */
  121.                 tnum++;    /* update totals */
  122.                 tlen += hdr.length;
  123.                 tsize += hdr.size;
  124.             }
  125.             fseek(arc, hdr.size, 1);    /* move to next header */
  126.         }
  127.     } else
  128.         while (readhdr(&hdr, arc)) {    /* else report on all files */
  129.             if (!kludge)
  130.                 lstfile(&hdr);
  131.             tnum++;    /* update totals */
  132.             tlen += hdr.length;
  133.             tsize += hdr.size;
  134.             fseek(arc, hdr.size, 1);    /* skip to next header */
  135.         }
  136.  
  137.     closearc(0);        /* close archive after reading */
  138.  
  139.     if (note && !kludge) {
  140.         printf("        ====  ========");
  141.         if (bose)
  142.             printf("            ====  ========");
  143.         printf("\n");
  144.     }
  145.     if (note) {
  146.         printf("Total %6ld  %8ld", tnum, tlen);
  147.         if (bose) {
  148.             if (tlen)
  149.                 printf("            %3ld%%", 100L - (100L * tsize) / tlen);
  150.             else
  151.                 printf("            ---");
  152.             printf("  %8ld", tsize);
  153.         }
  154.         printf("\n");
  155.  
  156.         for (n = 0; n < num; n++) {    /* report unused args */
  157.             if (!did[n]) {
  158.                 printf("File not found: %s\n", arg[n]);
  159.                 nerrs++;
  160.             }
  161.         }
  162.     }
  163. }
  164.  
  165. void
  166. lstfile(hdr)            /* tell about a file */
  167.     struct heads   *hdr;    /* pointer to header data */
  168. {
  169.     int             yr, mo, dy;    /* parts of a date */
  170.     int             hh, mm;    /* parts of a time */
  171.  
  172.     static char    *mon[] =    /* month abbreviations */
  173.     {
  174.      "Jan", "Feb", "Mar", "Apr",
  175.      "May", "Jun", "Jul", "Aug",
  176.      "Sep", "Oct", "Nov", "Dec"
  177.     };
  178.  
  179.     if (!note) {        /* no notes means short listing */
  180.         printf("%s\n", hdr->name);
  181.         return;
  182.     }
  183.  
  184.     yr = (hdr->date >> 9) & 0x7f;    /* dissect the date */
  185.     mo = (hdr->date >> 5) & 0x0f;
  186.     dy = hdr->date & 0x1f;
  187.  
  188.     hh = (hdr->time >> 11) & 0x1f;    /* dissect the time */
  189.     mm = (hdr->time >> 5) & 0x3f;
  190. /*    ss = (hdr->time & 0x1f) * 2;    seconds, not used. */
  191.  
  192.     printf("%-12s  %8ld  ", hdr->name, hdr->length);
  193.  
  194.     if (bose) {
  195.         switch (hdrver) {
  196.         case 1:
  197.         case 2:
  198.             printf("   --   ");
  199.             break;
  200.         case 3:
  201.             printf(" Packed ");
  202.             break;
  203.         case 4:
  204.             printf("Squeezed");
  205.             break;
  206.         case 5:
  207.         case 6:
  208.         case 7:
  209.             printf("crunched");
  210.             break;
  211.         case 8:
  212.             printf("Crunched");
  213.             break;
  214.         case 9:
  215.             printf("Squashed");
  216.             break;
  217.         default:
  218.             printf("Unknown!");
  219.         }
  220.  
  221.         if (hdr->length)
  222.             printf("  %3ld%%", 100L - (100L * hdr->size) / hdr->length);
  223.         else
  224.             printf("  ---");
  225.         printf("  %8ld  ", hdr->size);
  226.     }
  227.     printf("%2d %3s %02d", dy, mon[mo - 1], (yr + 80) % 100);
  228.  
  229.     if (bose)
  230.         printf("  %2d:%02d%c  %04x",
  231.                (hh > 12 ? hh - 12 : hh), mm, (hh > 11 ? 'p' : 'a'),
  232.                hdr->crc & 0xffff);
  233.  
  234.     printf("\n");
  235. }
  236. @
  237.  
  238.  
  239. 1.4
  240. log
  241. @Merge Atari ST code
  242. @
  243. text
  244. @d2 1
  245. a2 1
  246.  * $Header: arclst.c,v 1.3 88/06/01 15:41:19 hyc Locked $
  247. d5 15
  248. a19 14
  249. /*
  250.  * ARC - Archive utility - ARCLST
  251.  * 
  252.  * Version 2.38, created on 07/25/86 at 17:52:20
  253.  * 
  254.  * (C) COPYRIGHT 1985,86 by System Enhancement Associates; ALL RIGHTS RESERVED
  255.  * 
  256.  * By:  Thom Henderson
  257.  * 
  258.  * Description: This file contains the routines used to list the contents of an
  259.  * archive.
  260.  * 
  261.  * Language: Computer Innovations Optimizing C86
  262.  */
  263. a21 3
  264.     
  265. void    rempath(), openarc(), closearc();
  266. int    readhdr(), match();
  267. d23 3
  268. d33 1
  269. a33 1
  270.     int             did[MAXARG];/* true when argument was used */
  271. d44 1
  272. a44 1
  273.     if (!kludge) {
  274. d96 1
  275. a96 1
  276.     if (!kludge) {
  277. d102 10
  278. a111 9
  279.     printf("Total %6ld  %8ld", tnum, tlen);
  280.     if (bose) {
  281.         if (tlen)
  282.             printf("            %3ld%%", 100L - (100L * tsize) / tlen);
  283.         else
  284.             printf("            ---");
  285.         printf("  %8ld", tsize);
  286.     }
  287.     printf("\n");
  288. a112 1
  289.     if (note) {
  290. d127 1
  291. a127 1
  292.     int             hh, mm;        /* parts of a time */
  293. d135 5
  294. @
  295.  
  296.  
  297. 1.3
  298. log
  299. @Fix declarations
  300. @
  301. text
  302. @d2 1
  303. a2 1
  304.  * $Header: arclst.c,v 1.4 88/04/18 15:52:20 hyc Exp $
  305. d173 1
  306. a173 1
  307.             printf("  %3d%%", 100L - (100L * hdr->size) / hdr->length);
  308. @
  309.  
  310.  
  311. 1.2
  312. log
  313. @added support for squashing, re-synch with MTS
  314. @
  315. text
  316. @d2 1
  317. a2 11
  318.  * $Log:    arclst.c,v $
  319.  * Revision 1.1  88/04/11  18:01:46  hyc
  320.  * Initial revision
  321.  * 
  322.  * Revision 1.4  87/08/13  17:03:30  hyc
  323.  * Run thru the indent program...
  324.  *  Revision 1.3  87/07/21  11:41:35  hyc *** empty
  325.  * log message ***
  326.  * 
  327.  * Revision 1.2  87/07/21  08:23:17  hyc *** empty log message ***
  328.  * 
  329. d21 3
  330. d25 1
  331. a25 1
  332. INT
  333. d27 1
  334. a27 1
  335.     INT             num;    /* number of arguments */
  336. d31 5
  337. a35 5
  338.     INT             list;    /* true to list a file */
  339.     INT             did[25];/* true when argument was used */
  340.     LONG            tnum, tlen, tsize;    /* totals */
  341.     INT             n;    /* index */
  342.     INT             lstfile();
  343. d121 1
  344. a121 1
  345. INT
  346. d125 2
  347. a126 2
  348.     INT             yr, mo, dy;    /* parts of a date */
  349.     INT             hh, mm, ss;    /* parts of a time */
  350. d141 1
  351. a141 1
  352.     ss = (hdr->time & 0x1f) * 2;
  353. @
  354.  
  355.  
  356. 1.1
  357. log
  358. @Initial revision
  359. @
  360. text
  361. @d2 4
  362. a5 1
  363.  * $Log:        arclst.c,v $
  364. d72 1
  365. a72 1
  366.             for (n = 0; n < num; n++) {    /* for each template *
  367. d128 1
  368. a128 1
  369. static          INT
  370. d171 3
  371. @
  372.