home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8707 / 67 / arctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-13  |  1.9 KB  |  71 lines

  1. static char *RCSid = "$Header: arctst.c,v 1.1 86/06/26 15:01:02 turner Exp $";
  2.  
  3. /*
  4.  * $Log:    arctst.c,v $
  5.  * Hack-attack 1.3  86/12/20  01:23:45  wilhite@usceast.uucp
  6.  *     Bludgeoned into submission for VAX 11/780 BSD4.2
  7.  *    (ugly code, but fewer core dumps)
  8.  *
  9.  * Revision 1.1  86/06/26  15:01:02  turner
  10.  * initial version
  11.  * 
  12.  * 
  13.  */
  14.  
  15. /*  ARC - Archive utility - ARCTST
  16.  
  17. $define(tag,$$segment(@1,$$index(@1,=)+1))#
  18. $define(version,Version $tag(
  19. TED_VERSION DB =2.12), created on $tag(
  20. TED_DATE DB =02/03/86) at $tag(
  21. TED_TIME DB =23:00:40))#
  22. $undefine(tag)#
  23.     $version
  24.  
  25. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  26.  
  27.     By:  Thom Henderson
  28.  
  29.     Description:
  30.          This file contains the routines used to test archive integrity.
  31.  
  32.     Language:
  33.          Computer Innovations Optimizing C86
  34. */
  35. #include <stdio.h>
  36. #include "arc.h"
  37.  
  38. INT tstarc()                               /* test integrity of an archive */
  39. {
  40.     struct heads hdr;                  /* file header */
  41.     long arcsize, ftell();             /* archive size */
  42.  
  43.     openarc(0);                        /* open archive for reading */
  44.     fseek(arc,0L,2);                   /* move to end of archive */
  45.     arcsize = ftell(arc);              /* see how big it is */
  46.     fseek(arc,0L,0);                   /* return to top of archive */
  47.  
  48.     printf ("Testing archive...\n");
  49.     while(readhdr(&hdr,arc))
  50.     {    if(ftell(arc)+hdr.size>arcsize)
  51.          {    printf("Archive truncated in file %s\n",hdr.name);
  52.               nerrs++;
  53.               break;
  54.          }
  55.  
  56.          else
  57.          {    printf("    File: %-12s  ",hdr.name);
  58.               fflush(stdout);
  59.               if(unpack(arc,NULL,&hdr))
  60.                    nerrs++;
  61.               else printf("okay\n");
  62.          }
  63.     }
  64.  
  65.     if(nerrs<1)
  66.          printf("No errors detected\n");
  67.     else if(nerrs==1)
  68.          printf("One error detected\n");
  69.     else printf("%d errors detected\n",nerrs);
  70. }
  71.