home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d0xx / d050 / unixarc.lha / UnixArc / arctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-17  |  1.3 KB  |  47 lines

  1. /*  ARC - Archive utility - ARCTST
  2.  
  3. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  4.  
  5.     By:  Thom Henderson
  6.  
  7.     Description:
  8.          This file contains the routines used to test archive integrity.
  9.  
  10.     Language:
  11.          Computer Innovations Optimizing C86
  12. */
  13. #include <stdio.h>
  14. #include "arc.h"
  15.  
  16. tstarc()                               /* test integrity of an archive */
  17. {
  18.     struct heads hdr;                  /* file header */
  19.     long arcsize, ftell();             /* archive size */
  20.  
  21.     openarc(0);                        /* open archive for reading */
  22.     fseek(arc,0L,2);                   /* move to end of archive */
  23.     arcsize = ftell(arc);              /* see how big it is */
  24.     fseek(arc,0L,0);                   /* return to top of archive */
  25.  
  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("Testing file: %-12s  ",hdr.name);
  35.               if(unpack(arc,NULL,&hdr))
  36.                    nerrs++;
  37.               else printf("okay\n");
  38.          }
  39.     }
  40.  
  41.     if(nerrs<1)
  42.          printf("No errors detected\n");
  43.     else if(nerrs==1)
  44.          printf("One error detected\n");
  45.     else printf("%d errors detected\n",nerrs);
  46. }
  47.