# 2.11BSD#431 - /usr/src/bin/adb/main.c

##### Functions

    chkerr            X
    done              X
    error             X
    fault             X
    main              X
    round             X

##### Variables

    Ipath             X
    NOEOR             X
    argcount          X
    corfil            X
    datbas            X
    datsiz            X
    entrypt           X
    eof               X
    errflg            X
    executing         X
    exitflg           X
    infile            X
    kernel            X
    lastc             X
    lastcom           X
    lp                X
    magic             X
    maxfile           X
    maxoff            X
    maxpos            X
    maxstor           X
    mkfault           X
    myname            X
    overlay           X
    ovlsiz            X
    printptr          X
    stksiz            X
    symfil            X
    txtsiz            X
    var               X
    wtflag            X

       1: #include "defs.h"
       2:
       3:     MSG NOEOR;
       4:     char    *myname;    /* program name */
       5:     int argcount;
       6:     int mkfault;
       7:     int executing;
       8:     int infile;
       9:     char    *lp;
      10:     int maxoff;
      11:     int maxpos;
      12:     int (*sigint)();
      13:     int (*sigqit)();
      14:     int wtflag;
      15:     int kernel;
      16:     long    maxfile;
      17:     long    maxstor;
      18:     long    txtsiz;
      19:     long    datsiz;
      20:     long    datbas;
      21:     long    stksiz;
      22:     long    ovlsiz;
      23:     int overlay;
      24:     char    *errflg;
      25:     int exitflg;
      26:     int magic;
      27:     long    entrypt;
      28:     char    lastc;
      29:     int eof;
      30:     int lastcom;
      31:     long    var[36];
      32:     char    *symfil;
      33:     char    *corfil;
      34:     char    *printptr;
      35:     char    *Ipath = "/usr/share/adb";
      36:
      37: long    round(a,b)
      38: long        a, b;
      39: {
      40:     long        w;
      41:     w = ((a+b-1)/b)*b;
      42:     return(w);
      43: }
      44:
      45: /* error handling */
      46:
      47: chkerr()
      48: {
      49:     IF errflg ORF mkfault
      50:     THEN    error(errflg);
      51:     FI
      52: }
      53:
      54: error(n)
      55:     char    *n;
      56: {
      57:     errflg=n;
      58:     iclose(0, 1); oclose();
      59:     longjmp(erradb,1);
      60: }
      61:
      62: fault(a)
      63: {
      64:     signal(a,fault);
      65:     lseek(infile,0L,2);
      66:     mkfault++;
      67: }
      68:
      69: /* set up files and initial address mappings */
      70:
      71: main(argc, argv)
      72:     register char   **argv;
      73:     int argc;
      74: {
      75:     short   mynamelen;      /* length of program name */
      76:
      77:     maxfile = 1L << 24;
      78:     maxstor = 1L << 16;
      79:     if  (isatty(0))
      80:         myname = *argv;
      81:     else
      82:         myname = "adb";
      83:     mynamelen = strlen(myname);
      84:
      85:     gtty(0,&adbtty);
      86:     gtty(0,&usrtty);
      87:     WHILE argc>1
      88:     DO  IF !strcmp("-w",argv[1])
      89:         THEN    wtflag=2; argc--; argv++; continue;
      90:         ELIF !strcmp("-k",argv[1])
      91:         THEN    kernel++; argc--; argv++; continue;
      92:         ELIF !strcmp("-I",argv[1])
      93:         THEN    Ipath = argv[2]; argc -= 2; argv += 2; continue;
      94:         ELSE    break;
      95:         FI
      96:     OD
      97:
      98:     IF argc>1 THEN symfil = argv[1]; FI
      99:     IF argc>2 THEN corfil = argv[2]; FI
     100:     argcount=argc;
     101:     setsym(); setcor();
     102:
     103:     /* set up variables for user */
     104:     maxoff=MAXOFF; maxpos=MAXPOS;
     105:     var[VARB] = datbas;
     106:     var[VARD] = datsiz;
     107:     var[VARE] = entrypt;
     108:     var[VARM] = magic;
     109:     var[VARS] = stksiz;
     110:     var[VART] = txtsiz;
     111:     /* if text overlay, enter total overlay area size */
     112:     IF overlay
     113:     THEN    var[VARO] = ovlsiz;
     114:     FI
     115:
     116:     IF (sigint=signal(SIGINT,SIG_IGN))!=SIG_IGN
     117:     THEN    sigint=fault; signal(SIGINT,fault);
     118:     FI
     119:     sigqit=signal(SIGQUIT,SIG_IGN);
     120:     siginterrupt(SIGINT, 1);
     121:     siginterrupt(SIGQUIT, 1);
     122:     setjmp(erradb);
     123:     IF executing THEN delbp(); FI
     124:     executing=FALSE;
     125:
     126:     LOOP    flushbuf();
     127:         IF errflg
     128:         THEN printf("%s\n",errflg);
     129:              exitflg=(int)errflg;
     130:              errflg=0;
     131:         FI
     132:         IF mkfault
     133:         THEN    mkfault=0; printc(EOR);
     134:             printf("%s\n", myname);
     135:         FI
     136:         IF myname ANDF !infile
     137:         THEN    write(1,myname,mynamelen);
     138:             write(1,"> ",2);
     139:         FI
     140:         lp=0; rdc(); lp--;
     141:         IF eof
     142:         THEN    IF infile
     143:             THEN    iclose(-1, 0); eof=0; longjmp(erradb,1);
     144:             ELSE    done();
     145:             FI
     146:         ELSE    exitflg=0;
     147:         FI
     148:         command(0,lastcom);
     149:         IF lp ANDF lastc!=EOR THEN error(NOEOR); FI
     150:     POOL
     151: }
     152:
     153: done()
     154: {
     155:     endpcs();
     156:     exit(exitflg);
     157: }

#### Defined functions

chkerr defined in line 47; used 7 times

- in /usr/src/bin/adb/access.c line 40
- in /usr/src/bin/adb/command.c line 155
- in /usr/src/bin/adb/print.c line 196, 245, 257
- in /usr/src/bin/adb/runpcs.c line 57, 120

done defined in line 153; used 2 times

- in line 144
- in /usr/src/bin/adb/print.c line 150

error defined in line 54; used 39 times

- in line 50, 149
- in /usr/src/bin/adb/access.c line 54, 76
- in /usr/src/bin/adb/command.c line 102, 122, 142, 186, 211
- in /usr/src/bin/adb/expr.c line 71, 101, 141, 152, 163, 209, 218-223(2), 307
- in /usr/src/bin/adb/format.c line 57, 63, 102, 217, 239, 263
- in /usr/src/bin/adb/input.c line 32
- in /usr/src/bin/adb/output.c line 296
- in /usr/src/bin/adb/pcs.c line 45, 63, 81, 89, 110-115(2)
- in /usr/src/bin/adb/print.c line 105, 123, 263-267(2), 309
- in /usr/src/bin/adb/runpcs.c line 99-104(2)

fault defined in line 62; used 3 times

- in line 64, 117(2)

main defined in line 71; never used
round defined in line 37; used 9 times

- in /usr/src/bin/adb/defs.h line 194
- in /usr/src/bin/adb/expr.c line 56
- in /usr/src/bin/adb/setup.c line 63, 77, 85, 116, 135, 153(2)

#### Defined variables

Ipath defined in line 35; used 1 times

- in line 93

NOEOR defined in line 3; used 1 times

- in line 149

argcount defined in line 5; used 1 times

- in line 100

corfil defined in line 33; used 1 times

- in line 99

datbas defined in line 20; used 1 times

- in line 105

datsiz defined in line 19; used 1 times

- in line 106

entrypt defined in line 27; used 1 times

- in line 107

eof defined in line 29; used 2 times

- in line 141-143(2)

errflg defined in line 24; used 7 times

- in line 49-50(2), 57, 127-130(4)

executing defined in line 7; used 2 times

- in line 123-124(2)

exitflg defined in line 25; used 3 times

- in line 129, 146, 156

infile defined in line 8; used 3 times

- in line 65, 136, 142

kernel defined in line 15; used 1 times

- in line 91

lastc defined in line 28; used 1 times

- in line 149

lastcom defined in line 30; used 1 times

- in line 148

lp defined in line 9; used 3 times

- in line 140(2), 149

magic defined in line 26; used 1 times

- in line 108

maxfile defined in line 16; used 1 times

- in line 77

maxoff defined in line 10; used 1 times

- in line 104

maxpos defined in line 11; used 1 times

- in line 104

maxstor defined in line 17; used 1 times

- in line 78

mkfault defined in line 6; used 4 times

- in line 49, 66, 132-133(2)

myname defined in line 4; used 9 times

- in line 80-83(3), 134-137(3)
- in /usr/src/bin/adb/command.c line 208
- in /usr/src/bin/adb/sym.c line 205, 232

overlay defined in line 23; used 1 times

- in line 112

ovlsiz defined in line 22; used 1 times

- in line 113

printptr defined in line 34; never used
stksiz defined in line 21; used 1 times

- in line 109

symfil defined in line 32; used 1 times

- in line 98

txtsiz defined in line 18; used 1 times

- in line 110

var defined in line 31; used 7 times

- in line 105-113(7)

wtflag defined in line 14; used 1 times

- in line 89

Last modified: 1996-10-22 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1255 |