home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / COMPRESS / ARC520S.ZIP / ARCTST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-23  |  1.4 KB  |  49 lines

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