home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 157.lha / Arc_Src / arctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-27  |  1.4 KB  |  48 lines

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