home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / OS2ARC_S.ZIP / ARCTST.C < prev    next >
Text File  |  1987-10-15  |  2KB  |  56 lines

  1. /*  ARC - Archive utility - ARCTST
  2.  
  3. $define(tag,$$segment(@1,$$index(@1,=)+1))#
  4. $define(version,Version $tag(
  5. TED_VERSION DB =2.12), created on $tag(
  6. TED_DATE DB =02/03/86) at $tag(
  7. TED_TIME DB =23:00:40))#
  8. $undefine(tag)#
  9.     $version
  10.  
  11. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  12.  
  13.     By:  Thom Henderson
  14.  
  15.     Description:
  16.          This file contains the routines used to test archive integrity.
  17.  
  18.     Language:
  19.          Computer Innovations Optimizing C86
  20. */
  21. #include <stdio.h>
  22. #include "arc.h"
  23.  
  24. tstarc()                               /* test integrity of an archive */
  25. {
  26.     struct heads hdr;                  /* file header */
  27.     long arcsize, ftell();             /* archive size */
  28.  
  29.     openarc(0);                        /* open archive for reading */
  30.     fseek(arc,0L,2);                   /* move to end of archive */
  31.     arcsize = ftell(arc);              /* see how big it is */
  32.     rewind(arc);            /* rew with error fix*/
  33.     /*fseek(arc,0L,0);                   /* return to top of archive */
  34.  
  35.     while(readhdr(&hdr,arc))
  36.     {    if(ftell(arc)+hdr.size>arcsize)
  37.          {    printf("Archive truncated in file %s\n",hdr.name);
  38.               nerrs++;
  39.               break;
  40.          }
  41.  
  42.          else
  43.          {    printf("Testing file: %-12s  ",hdr.name);
  44.               if(unpack(arc,NULL,&hdr))
  45.                    nerrs++;
  46.               else printf("okay\n");
  47.          }
  48.     }
  49.  
  50.     if(nerrs<1)
  51.          printf("No errors detected\n");
  52.     else if(nerrs==1)
  53.          printf("One error detected\n");
  54.     else printf("%d errors detected\n",nerrs);
  55. }
  56.