summaryrefslogtreecommitdiffstats
path: root/gnu/usr.sbin/isdn/misc/tst.c
blob: 535de1eab73e6a970c126d31a8034ae540a62991 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
static char     rcsid[] = "@(#)$Id: tst.c,v 1.1 1995/01/25 14:14:58 jkr Exp jkr $";
/*******************************************************************************
 *  II - Version 0.1 $Revision: 1.1 $   $State: Exp $
 *
 * Copyright 1994 Dietmar Friede
 *******************************************************************************
 * Bug reports, patches, comments, suggestions should be sent to:
 *
 *	jkr@saarlink.de or jkrause@guug.de
 *
 *******************************************************************************
 * $Log: tst.c,v $
 *
 ******************************************************************************/

/*
 * This program reads a 3008 or 5000 or ... download file and shows Headers
 * and statistics
 */

#include <sys/types.h>
#include <machine/endian.h>
#include <stdio.h>

struct head
{
	u_long          len;
	u_long          sig;
	char            nam[8];
	char            ver[5];
	u_char          typ;
}               head;

void
main(int argc, char **argv)
{
	FILE           *f;
	argv++;

	if (!*argv)
	{
		process(stdin);
	} else
		while (*argv)
		{
			if ((f = fopen(*argv, "r")) == NULL)
			{
				perror(*argv);
				exit(1);
			} else
			{
				process(f);
				fclose(f);
			}
			argv++;
		}
	exit(0);
}

process(FILE * f)
{
	long            off;

	off = 0;

	while (fread(&head, 1, 0x16, f) == 0x16)
	{
		printf("%d\t %x %.8s %.5s %x\n",
		   ntohl(head.len), head.sig, head.nam, head.ver, head.typ);
		off += ntohl(head.len);
		fseek(f, off, SEEK_SET);
	}
	printf("%d\n", off);
}
OpenPOWER on IntegriCloud