1: char *sccsid = "@(#)size.c	2.5";
   2: #include    <stdio.h>
   3: #include    <a.out.h>
   4: #include    <whoami.h>
   5: 
   6: /*
   7:  *	size -- determine object size
   8:  */
   9: 
  10: main(argc, argv)
  11: register char **argv;
  12: {
  13:     struct exec buf;
  14:     long sum;
  15: #ifdef MENLO_OVLY
  16:     long coresize;
  17:     struct ovlhdr ovlbuf;
  18: #endif MENLO_OVLY
  19:     register gorp,i;
  20:     FILE *f;
  21: 
  22:     if (argc == 1) {
  23:         *argv = "a.out";
  24:         argc++;
  25:         --argv;
  26:     }
  27:     gorp = argc;
  28:     printf("text\tdata\tbss\tdec\toct\n");
  29:     while (--argc) {
  30:         ++argv;
  31:         if ((f = fopen(*argv, "r")) == NULL) {
  32:             perror(*argv);
  33:             continue;
  34:         }
  35:         if (fread((char *)&buf, sizeof(buf), 1, f) != 1) {
  36:             printf("%s:  not in object file format\n", *argv);
  37:             fclose(f);
  38:             continue;
  39:         }
  40:         if (N_BADMAG(buf)) {
  41:             printf("%s:  not in object file format\n", *argv);
  42:             fclose(f);
  43:             continue;
  44:         }
  45:         printf("%u +\t%u +\t%u =\t", buf.a_text,buf.a_data,buf.a_bss);
  46:         sum = (long) buf.a_text + (long) buf.a_data + (long) buf.a_bss;
  47:         printf("%ld =\t%lo", sum, sum);
  48:         printf("\t%s\n", *argv);
  49: #ifdef MENLO_OVLY
  50:         if (buf.a_magic == A_MAGIC5 || buf.a_magic == A_MAGIC6) {
  51:             fread(&ovlbuf, sizeof ovlbuf, 1, f);
  52:             coresize = buf.a_text;
  53:             for (i = 0; i < NOVL; i++)
  54:                 if (ovlbuf.ov_siz[i])
  55:                     coresize += ovlbuf.ov_siz[i];
  56:             printf("%ld total text, overlays: (", coresize);
  57:             for (i = 0; i < NOVL; i++)
  58:                 if (ovlbuf.ov_siz[i]) {
  59:                     if (i > 0)
  60:                         printf(",");
  61:                     printf("%u", ovlbuf.ov_siz[i]);
  62:                 }
  63:             printf(")\n");
  64:         }
  65: #endif MENLO_OVLY
  66:         fclose(f);
  67:     }
  68:     exit(0);
  69: }

Defined functions

main defined in line 10; never used

Defined variables

sccsid defined in line 1; never used
Last modified: 1983-07-20
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 768
Valid CSS Valid XHTML 1.0 Strict