ack/util/amisc/asize.c

64 lines
976 B
C
Raw Normal View History

1985-04-12 15:06:05 +00:00
/* $Header$ */
1985-04-12 14:55:00 +00:00
#include <stdio.h>
#include "out.h"
/*
asize -- determine object size
*/
main(argc, argv)
char **argv;
{
struct outhead buf;
struct outsect sbuf;
ushort nrsect;
long sum;
int gorp;
if (--argc == 0) {
argc = 1;
argv[1] = "a.out";
}
gorp = argc;
while(argc--) {
1987-01-15 22:06:16 +00:00
if (! rd_open(*++argv)) {
1985-04-12 14:55:00 +00:00
fprintf(stderr, "asize: cannot open %s\n", *argv);
continue;
}
1987-01-15 22:06:16 +00:00
rd_ohead(&buf);
1985-04-12 14:55:00 +00:00
if(BADMAGIC(buf)) {
fprintf(stderr, "asize: %s-- bad format\n", *argv);
1987-01-15 22:06:16 +00:00
rd_close();
1985-04-12 14:55:00 +00:00
continue;
}
nrsect = buf.oh_nsect;
if (nrsect == 0) {
fprintf(stderr, "asize: %s-- no sections\n", *argv);
1987-01-15 22:06:16 +00:00
rd_close();
1985-04-12 14:55:00 +00:00
continue;
}
if (gorp > 1)
printf("%s: ", *argv);
sum = 0;
while (nrsect-- > 0) {
1987-01-15 22:06:16 +00:00
rd_sect(&sbuf, 1);
1985-04-12 14:55:00 +00:00
printf("%ld", sbuf.os_size);
sum += sbuf.os_size;
if (nrsect > 0)
putchar('+');
}
printf(" = %ld = 0x%lx\n", sum, sum);
1987-01-15 22:06:16 +00:00
rd_close();
1985-04-12 14:55:00 +00:00
}
}
1987-01-15 22:06:16 +00:00
rd_fatal()
1985-04-12 14:55:00 +00:00
{
1987-01-15 22:06:16 +00:00
fprintf(stderr, "read error\n");
exit(2);
1985-04-12 14:55:00 +00:00
}