home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / cpm68k / arc68k.arc / ARCTST.C < prev    next >
Encoding:
Text File  |  1987-11-27  |  1.8 KB  |  63 lines

  1.  
  2. /*
  3.  *      arctst.c        1.1
  4.  *
  5.  *      Author: Thom Henderson
  6.  *      Original System V port: Mike Stump
  7.  *      Enhancements, Bug fixes, and cleanup: Chris Seaman
  8.  *      Date: Fri Mar 20 09:57:02 1987
  9.  *      Last Mod.       3/21/87
  10.  *
  11.  */
  12.  
  13. /*
  14.  * ARC - Archive utility - ARCTST
  15.  * 
  16.  * Version 2.12, created on 02/03/86 at 23:00:40
  17.  * 
  18.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  19.  * 
  20.  *     Description:
  21.  *          This file contains the routines used to test archive integrity.
  22.  */
  23.  
  24. #include "arc.h"
  25.  
  26. INT tstarc()                           /* test integrity of an archive */
  27. {
  28.     struct heads hdr;                  /* file header */
  29.     long arcsize, ftell();             /* archive size */
  30.  
  31.     openarc(0);                        /* open archive for reading */
  32.     fseek(arc,0L,2);                   /* move to end of archive */
  33.     arcsize = ftell(arc);              /* see how big it is */
  34.     fseek(arc,0L,0);                   /* return to top of archive */
  35.  
  36.     printf("Testing archive...\n");
  37.     while (readhdr(&hdr,arc))
  38.     {
  39.         if (ftell(arc)+hdr.size>arcsize)
  40.         {
  41.             printf("Archive truncated in file %s\n",hdr.name);
  42.             nerrs++;
  43.             break;
  44.         }
  45.         else
  46.         {
  47.             printf("    File: %-14s  ",hdr.name);
  48. /*            fflush(stdout);             */
  49.             if (unpack(arc,0L,&hdr))
  50.                 nerrs++;
  51.             else
  52.                 printf("okay\n");
  53.         }
  54.     }
  55.  
  56.     if (nerrs<1)
  57.         printf("No errors detected\n");
  58.     else if (nerrs==1)
  59.         printf("One error detected\n");
  60.     else
  61.         printf("%d errors detected\n",nerrs);
  62. }
  63.