home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / COMPRESS / ARC.ZIP / ARCTST.MAC < prev    next >
Encoding:
Text File  |  1986-02-03  |  2.0 KB  |  55 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.     fseek(arc,0L,0);                   /* return to top of archive */
  33.  
  34.     while(readhdr(&hdr,arc))
  35.     {    if(ftell(arc)+hdr.size>arcsize)
  36.          {    printf("Archive truncated in file %s\n",hdr.name);
  37.               nerrs++;
  38.               break;
  39.          }
  40.  
  41.          else
  42.          {    printf("Testing file: %-12s  ",hdr.name);
  43.               if(unpack(arc,NULL,&hdr))
  44.                    nerrs++;
  45.               else printf("okay\n");
  46.          }
  47.     }
  48.  
  49.     if(nerrs<1)
  50.          printf("No errors detected\n");
  51.     else if(nerrs==1)
  52.          printf("One error detected\n");
  53.     else printf("%d errors detected\n",nerrs);
  54. }
  55.