pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / autil / asize.c
blob337338e789b761460dbff5c8dde30beb20fec6ff
1 /* @(#)asize.c 1.4 */
2 #define ushort unsigned short
4 #include <stdio.h>
5 #include "out.h"
7 /*
8 asize -- determine object size
12 main(argc, argv)
13 char **argv;
15 struct outhead buf;
16 struct outsect sbuf;
17 ushort nrsect;
18 long sum;
19 int gorp;
20 FILE *f;
22 if (--argc == 0) {
23 argc = 1;
24 argv[1] = "a.out";
26 gorp = argc;
28 while(argc--) {
29 if ((f = fopen(*++argv, "r"))==NULL) {
30 fprintf(stderr, "asize: cannot open %s\n", *argv);
31 continue;
33 getofmt ((char *)&buf, SF_HEAD , f);
34 if(BADMAGIC(buf)) {
35 fprintf(stderr, "asize: %s-- bad format\n", *argv);
36 fclose(f);
37 continue;
39 nrsect = buf.oh_nsect;
40 if (nrsect == 0) {
41 fprintf(stderr, "asize: %s-- no sections\n", *argv);
42 fclose(f);
43 continue;
45 if (gorp > 1)
46 printf("%s: ", *argv);
48 sum = 0;
49 while (nrsect-- > 0) {
50 getofmt ((char *)&sbuf, SF_SECT , f);
51 printf("%ld", sbuf.os_size);
52 sum += sbuf.os_size;
53 if (nrsect > 0)
54 putchar('+');
56 printf(" = %ld = 0x%lx\n", sum, sum);
57 fclose(f);
61 getofmt(p, s, f)
62 register char *p;
63 register char *s;
64 register FILE *f;
66 register i;
67 register long l;
69 for (;;) {
70 switch (*s++) {
71 /* case '0': p++; continue; */
72 case '1':
73 *p++ = getc(f);
74 continue;
75 case '2':
76 i = getc(f);
77 i |= (getc(f) << 8);
78 *((short *)p) = i; p += sizeof(short);
79 continue;
80 case '4':
81 l = (long)getc(f);
82 l |= ((long)getc(f) << 8);
83 l |= ((long)getc(f) << 16);
84 l |= ((long)getc(f) << 24);
85 *((long *)p) = l; p += sizeof(long);
86 continue;
87 default:
88 case '\0':
89 break;
91 break;