File: arctst.c

package info (click to toggle)
arc 5.21q-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 412 kB
  • ctags: 311
  • sloc: ansic: 4,124; makefile: 86
file content (54 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * ARC - Archive utility - ARCTST
 * 
 * Version 2.12, created on 02/03/86 at 23:00:40
 * 
 * (C) COPYRIGHT 1985-87 by System Enhancement Associates.
 * You may copy and distribute this program freely,
 * under the terms of the General Public License.
 * 
 * By:  Thom Henderson
 * 
 * Description: This file contains the routines used to test archive integrity.
 * 
 * Language: Computer Innovations Optimizing C86
 */
#include <stdio.h>
#include "arc.h"

VOID	openarc();
int	readhdr(), unpack();

VOID
tstarc()
{				/* test integrity of an archive */
	struct heads    hdr;	/* file header */
	long            arcsize, ftell();	/* archive size */

	openarc(0);		/* open archive for reading */
	fseek(arc, 0L, 2);	/* move to end of archive */
	arcsize = ftell(arc);	/* see how big it is */
	fseek(arc, 0L, 0);	/* return to top of archive */

	while (readhdr(&hdr, arc)) {
		if (ftell(arc) + hdr.size > arcsize) {
			printf("Archive truncated in file %s\n", hdr.name);
			nerrs++;
			break;
		} else {
			printf("Testing file: %-12s  ", hdr.name);
			fflush(stdout);
			if (unpack(arc, NULL, &hdr))
				nerrs++;
			else
				printf("okay\n");
		}
	}

	if (nerrs < 1)
		printf("No errors detected\n");
	else if (nerrs == 1)
		printf("One error detected\n");
	else
		printf("%d errors detected\n", nerrs);
}