Annotation of 3BSD/cmd/size.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       <a.out.h>
        !             3: 
        !             4: /*
        !             5:        size -- determine object size
        !             6: 
        !             7: */
        !             8: 
        !             9: int a_magic[] = {A_MAGIC1,A_MAGIC2,A_MAGIC3,A_MAGIC4,0412,0413,0};
        !            10: 
        !            11: main(argc, argv)
        !            12: char **argv;
        !            13: {
        !            14:        struct exec buf;
        !            15:        long sum;
        !            16:        int gorp,i;
        !            17:        FILE *f;
        !            18: 
        !            19:        if (argc==1) {
        !            20:                *argv = "a.out";
        !            21:                argc++;
        !            22:                --argv;
        !            23:        }
        !            24:        gorp = argc;
        !            25:        while(--argc) {
        !            26:                ++argv;
        !            27:                if ((f = fopen(*argv, "r"))==NULL) {
        !            28:                        printf("size: %s not found\n", *argv);
        !            29:                        continue;
        !            30:                }
        !            31:                fread((char *)&buf, sizeof(buf), 1, f);
        !            32:                for(i=0;a_magic[i];i++)
        !            33:                        if(a_magic[i] == buf.a_magic) break;
        !            34:                if(a_magic[i] == 0) {
        !            35:                        printf("size: %s not an object file\n", *argv);
        !            36:                        fclose(f);
        !            37:                        continue;
        !            38:                }
        !            39:                if (gorp>2)
        !            40:                        printf("%s: ", *argv);
        !            41:                printf("%u+%u+%u = ", buf.a_text,buf.a_data,buf.a_bss);
        !            42:                sum = (long) buf.a_text + (long) buf.a_data + (long) buf.a_bss;
        !            43:                printf("%Db = 0x%Xb\n", sum, sum);
        !            44:                fclose(f);
        !            45:        }
        !            46: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.