* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char copyright
[] =
"@(#) Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
static char sccsid
[] = "@(#)size.c 8.2 (Berkeley) %G%";
void err
__P((const char *, ...));
int show
__P((int, char *));
while ((ch
= getopt(argc
, argv
, "")) != EOF
)
eval
|= show(argc
, *argv
);
eval
|= show(1, "a.out");
if ((fd
= open(name
, O_RDONLY
, 0)) < 0) {
err("%s: %s", name
, strerror(errno
));
if (read(fd
, &head
, sizeof(head
)) != sizeof(head
) || N_BADMAG(head
)) {
err("%s: not in a.out format", name
);
(void)printf("text\tdata\tbss\tdec\thex\n");
total
= head
.a_text
+ head
.a_data
+ head
.a_bss
;
(void)printf("%lu\t%lu\t%lu\t%lu\t%lx", head
.a_text
, head
.a_data
,
head
.a_bss
, total
, total
);
(void)printf("\t%s", name
);
(void)fprintf(stderr
, "usage: size [file ...]\n");
err(const char *fmt
, ...)
(void)fprintf(stderr
, "size: ");
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");