1: int fout;
   2: int cflg;
   3: int nflg;
   4: int uflg;
   5: int rflg    1;
   6: int gflg;
   7: int pflg;
   8: struct  nl
   9: {
  10:     char    name[8];
  11:     int typ;
  12:     int *val;
  13: } *nlp;
  14: int fi;
  15: int buf[8];
  16: main(argc, argv)
  17: char **argv;
  18: {
  19:     int n, i, j;
  20:     int compare();
  21: 
  22:     if (--argc > 0 && *argv[1] == '-') {
  23:         argv++;
  24:         while (*++*argv) switch (**argv) {
  25:         case 'n':
  26:             nflg++;
  27:             continue;
  28: 
  29:         case 'c':
  30:             cflg++;
  31:             continue;
  32: 
  33:         case 'g':
  34:             gflg++;
  35:             continue;
  36: 
  37:         case 'u':
  38:             uflg++;
  39:             continue;
  40: 
  41:         case 'r':
  42:             rflg = -1;
  43:             continue;
  44: 
  45:         case 'p':
  46:             pflg ++;
  47:             continue;
  48: 
  49:         default:
  50:             continue;
  51:         }
  52:         argc--;
  53:     }
  54:     if (argc==0)
  55:         fi = open("a.out", 0); else
  56:         fi = open(*++argv, 0);
  57:     if(fi < 0) {
  58:         printf("cannot open input\n");
  59:         exit();
  60:     }
  61:     read(fi, buf, 020);
  62:     if(buf[0]!=0407 && buf[0]!=0410 && buf[0]!=0411) {
  63:         printf("bad format\n");
  64:         exit();
  65:     }
  66:     seek(fi, buf[1], 1);        /* text */
  67:     seek(fi, buf[2], 1);        /* data */
  68:     if(buf[7] != 1) {
  69:         seek(fi, buf[1], 1);
  70:         seek(fi, buf[2], 1);    /* reloc */
  71:     }
  72:     n = ldiv(0, buf[4], 12);
  73:     if(n == 0) {
  74:         printf("no name list\n");
  75:         exit();
  76:     }
  77:     nlp = sbrk(12*n);
  78:     read(fi, nlp, n*12);
  79:     if (pflg==0)
  80:         qsort(nlp, n, 12, compare);
  81:     fout = dup(1);
  82:     close(1);
  83:     for(i=0; i<n; i++) {
  84:         if(gflg && (nlp->typ&040)==0)
  85:             goto out;
  86:         if(cflg) {
  87:             if(nlp->name[0] != '_')
  88:                 goto out;
  89:             for(j=0; j<7; j++)
  90:                 nlp->name[j] = nlp->name[j+1];
  91:             nlp->name[7] = '\0';
  92:         }
  93:         j = nlp->typ&037;
  94:         if(j > 4)
  95:             j = 1;
  96:         if(j==0 && nlp->val)
  97:             j = 5;
  98:         if(uflg && j!=0)
  99:             goto out;
 100:         if(!uflg) {
 101:             if(j==0)
 102:                 printf("      "); else
 103:                 printo(nlp->val);
 104:             printf("%c ", (nlp->typ&040? "UATDBC":"uatdbc")[j]);
 105:         }
 106:         printf("%.8s\n", nlp);
 107:     out:
 108:         nlp++;
 109:     }
 110:     flush();
 111: }
 112: 
 113: compare(p1, p2)
 114: struct nl *p1, *p2;
 115: {
 116:     int a, i;
 117: 
 118:     a = 0;
 119:     if(nflg) {
 120:         if(p1->val > p2->val) {
 121:             a = 1;
 122:             goto out;
 123:         }
 124:         if(p1->val < p2->val) {
 125:             a = -1;
 126:             goto out;
 127:         }
 128:     }
 129:     for(i=0; i<8; i++)
 130:     if(p1->name[i] != p2->name[i]) {
 131:         if(p1->name[i] > p2->name[i])
 132:             a = 1; else
 133:             a = -1;
 134:         goto out;
 135:     }
 136: out:
 137:     return(a*rflg);
 138: }
 139: 
 140: printo(v)
 141: {
 142:     int i;
 143: 
 144:     printf("%c", v<0?'1':'0');
 145:     for(i=0; i<5; i++) {
 146:         printf("%c", ((v>>12)&7)+'0');
 147:         v =<<3;
 148:     }
 149: }

Defined functions

compare defined in line 113; used 2 times
main defined in line 16; never used
printo defined in line 140; used 1 times

Defined variables

buf defined in line 15; used 10 times
cflg defined in line 2; used 2 times
fi defined in line 14; used 9 times
fout defined in line 1; used 1 times
  • in line 81
gflg defined in line 6; used 2 times
nflg defined in line 3; used 2 times
nlp defined in line 13; used 14 times
pflg defined in line 7; used 2 times
rflg defined in line 5; used 2 times
uflg defined in line 4; used 3 times

Defined struct's

nl defined in line 8; used 2 times
  • in line 114(2)
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 858
Valid CSS Valid XHTML 1.0 Strict