remove BSD ifdefs
[unix-history] / usr / src / usr.bin / size / size.c
CommitLineData
14a73586 1/*
faede1d2
KB
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
b8c620d6
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14a73586 16 */
c7485fe5 17
faede1d2
KB
18#ifndef lint
19char copyright[] =
20"@(#) Copyright (c) 1988 Regents of the University of California.\n\
21 All rights reserved.\n";
22#endif /* not lint */
14a73586 23
faede1d2 24#ifndef lint
b8c620d6 25static char sccsid[] = "@(#)size.c 4.6 (Berkeley) %G%";
faede1d2
KB
26#endif /* not lint */
27
28#include <sys/param.h>
29#include <sys/file.h>
30#include <a.out.h>
31#include <stdio.h>
c7485fe5 32
14a73586 33main(argc, argv)
faede1d2
KB
34 int argc;
35 char **argv;
14a73586 36{
faede1d2
KB
37 struct exec head;
38 u_long total;
39 int exval, fd, first;
14a73586 40
faede1d2 41 if (!*argv[1])
14a73586 42 *argv = "a.out";
faede1d2 43 else
14a73586 44 ++argv;
faede1d2
KB
45 for (first = 1, exval = 0; *argv; ++argv) {
46 if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
47 fprintf(stderr, "size: ");
48 perror(*argv);
49 exval = 1;
14a73586
BJ
50 continue;
51 }
faede1d2
KB
52 if (read(fd, (char *)&head, sizeof(head)) != sizeof(head) ||
53 N_BADMAG(head)) {
54 fprintf(stderr, "size: %s: not in a.out format.\n",
55 *argv);
56 exval = 1;
14a73586
BJ
57 continue;
58 }
faede1d2
KB
59 (void)close(fd);
60 if (first) {
61 first = 0;
c7485fe5 62 printf("text\tdata\tbss\tdec\thex\n");
c7485fe5 63 }
faede1d2
KB
64 total = head.a_text + head.a_data + head.a_bss;
65 printf("%lu\t%lu\t%lu\t%lu\t%lx", head.a_text, head.a_data,
66 head.a_bss, total, total);
67 if (argc > 2)
c7485fe5
BJ
68 printf("\t%s", *argv);
69 printf("\n");
14a73586 70 }
faede1d2 71 exit(exval);
14a73586 72}