Annotation of researchv9/cmd/strip/strip.c, revision 1.1.1.1

1.1       root        1: #include "strip.h"
                      2: #include "hash.h"
                      3: #include <signal.h>
                      4: 
                      5: main(argc, argv)
                      6: int argc; char **argv;
                      7: {
                      8:        register Adotout *a;
                      9:        register struct nlist *sym;
                     10:        int sighup();
                     11: 
                     12:        prognam = *argv;
                     13:        ++stripflag;
                     14: 
                     15:        if (argc < 2) {
                     16:                fprintf(stderr, "Usage: %s [options] file.out...\n", prognam);
                     17:                exit(1);
                     18:        }
                     19: 
                     20:        while (--argc > 0 && (*++argv)[0] == '-' && (*argv)[1])
                     21:                switch ((*argv)[1]) {
                     22:                case 'D':
                     23:                        ++strdebug; break;
                     24:                case 'v':
                     25:                        ++prtflag; break;
                     26:                case 'g':
                     27:                        ++gflag; /* fall through */
                     28:                case 's':
                     29:                        ++shrinkflag; stripflag = 0; break;
                     30:                default:
                     31:                        fatal("unknown option " ,*argv);
                     32:                }
                     33: 
                     34:        Signal(SIGHUP, sighup);
                     35:        Signal(SIGINT, sighup);
                     36:        Signal(SIGQUIT, sighup);
                     37: 
                     38:        while (--argc >= 0) {
                     39:                tmpnam[0] = 0;
                     40:                if ((a = rdout(*argv++, !stripflag)) == 0)
                     41:                        continue;
                     42:                if (prtflag)
                     43:                        prtout(a);
                     44:                if (a->hd.a_syms == 0) {
                     45:                        fprintf(stderr, "%s already stripped\n", a->name);
                     46:                        freeout(a);
                     47:                        continue;
                     48:                }
                     49:                if (shrinkflag)
                     50:                        shrink(a);
                     51:                symwrite(a);
                     52:                freeout(a);
                     53:        }
                     54:        exit(0);
                     55: }
                     56: 
                     57: fatal(m1, m2)
                     58: char *m1, *m2;
                     59: {
                     60:        if (m1)
                     61:                fprintf(stderr,"%s: %s%s\n", prognam, m1, m2);
                     62:        if (!copyrace && tmpnam[0])
                     63:                unlink(tmpnam);
                     64:        exit(1);
                     65: }
                     66: 
                     67: sighup(s)
                     68: {
                     69:        if (copyrace) {
                     70:                signal(s, sighup);
                     71:                return;
                     72:        }
                     73:        if (tmpnam[0])
                     74:                unlink(tmpnam);
                     75:        exit(1);
                     76: }

unix.superglobalmegacorp.com

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