1: static char *sccsid = "@(#)pti.c	4.1 (Berkeley) 10/1/80";
   2: #define DBL 0200
   3: /*
   4: C version of pti
   5: */
   6: 
   7: char *ap;
   8: char ibuf[512];
   9: char *ibufp = ibuf;
  10: char *eibufp = ibuf;
  11: int fid;
  12: int esc;
  13: int escd;
  14: int verd;
  15: int esct;
  16: int osize = 02;
  17: int size = 02;
  18: int leadtot;
  19: int railmag;
  20: int lead;
  21: int mcase;
  22: int stab[] = {010,0,01,07,02,03,04,05,0211,06,0212,0213,0214,0215,0216,0217};
  23: int rtab[] = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 36, 18};
  24: char *asctab[128];
  25: char *spectab[128];
  26: long offset;
  27: int lflg;
  28: int xxx;
  29: 
  30: main(argc,argv)
  31: int argc;
  32: char **argv;
  33: {
  34:     register i, j;
  35:     register char *k;
  36:     extern ex();
  37: 
  38:     while((--argc > 0) && ((++argv)[0][0]=='-')){
  39:         switch(argv[0][1]){
  40:             case 'l':
  41:                 lflg++;
  42:                 continue;
  43:             default:
  44:                 ap = &argv[0][1];
  45:                 while(((j = *ap++ - '0') >= 0)
  46:                     && (j <= 9))offset = 8*offset +j;
  47:                 continue;
  48:         }
  49:     }
  50:     if(argc){
  51:         if((fid=open(argv[0], 0)) < 0){
  52:             printf("Cannot open: %s\n",argv[0]);
  53:             exit(1);
  54:         }
  55:     }
  56:     lseek(fid,offset,0);
  57:     while((i = getc()) >= 0){
  58:         if(i & 0200){
  59:             if(!lflg)printf("%o ",i);
  60:             esc += (~i) & 0177;
  61:             continue;
  62:         }
  63:         if(esc){
  64:             if(escd){
  65:                 if(!lflg)printf("< %d\n",esc);
  66:                 esc = -esc;
  67:             }else{
  68:                 if(!lflg)printf("> %d\n",esc);
  69:             }
  70:             esct += esc;
  71:             esc = 0;
  72:         }
  73:         if(!lflg)printf("%o ",i);
  74:         if(!i){if(!lflg)printf("\n"); continue;}
  75:         switch(i){
  76:             case 0100:  /*init*/
  77:                 escd = verd = mcase = railmag = 0;
  78:                 if(!lflg)printf("Initialize\n");
  79:                 continue;
  80:             case 0101:  /*lower rail*/
  81:                 railmag &= ~01;
  82:                 if(!lflg)printf("Lower rail\n");
  83:                 continue;
  84:             case 0102:  /*upper rail*/
  85:                 railmag |= 01;
  86:                 if(!lflg)printf("Upper rail\n");
  87:                 continue;
  88:             case 0103:  /*upper mag*/
  89:                 railmag |= 02;
  90:                 if(!lflg)printf("Upper mag\n");
  91:                 continue;
  92:             case 0104:  /*lower mag*/
  93:                 railmag &= ~02;
  94:                 if(!lflg)printf("Lower mag\n");
  95:                 continue;
  96:             case 0105:  /*lower case*/
  97:                 mcase = 0;
  98:                 if(!lflg)printf("Lower case\n");
  99:                 continue;
 100:             case 0106:  /*upper case*/
 101:                 mcase = 0100;
 102:                 if(!lflg)printf("Upper case\n");
 103:                 continue;
 104:             case 0107:  /*escape forward*/
 105:                 escd = 0;
 106:                 if(!lflg)printf("> mode, %d\n",esct);
 107:                 continue;
 108:             case 0110:  /*escape backward*/
 109:                 escd = 1;
 110:                 if(!lflg)printf("< mode, %d\n",esct);
 111:                 continue;
 112:             case 0111:  /*stop*/
 113:                 if(!lflg)printf("STOP\n");
 114:                 continue;
 115:             case 0112:  /*lead forward*/
 116:                 verd = 0;
 117:                 if(!lflg)printf("Lead forward, %d\n",leadtot);
 118:                 continue;
 119:             case 0114:  /*lead backward*/
 120:                 verd = 1;
 121:                 if(!lflg)printf("Lead backward, %d\n",leadtot);
 122:                 continue;
 123:             case 0115:  /*undefined*/
 124:                 if(!lflg)printf("New page\n");
 125:                 continue;
 126:             case 0116:
 127:                 lead = 64 * getc();
 128:                 goto leadin;
 129:             case 0117:
 130:             case 0113:
 131:                 if(!lflg)printf("Undefined code\n");
 132:                 continue;
 133:         }
 134:         if((i & 0340) == 0140){ /*leading*/
 135:             lead = (~i) & 037;
 136: leadin:
 137:             if(!lflg)printf("Lead %d\n",lead);
 138:             if(verd)lead = -lead;
 139:             leadtot += lead;
 140:             continue;
 141:         }
 142:         if((i & 0360) == 0120){ /*size change*/
 143:             i &= 017;
 144:             for(j = 0; i != (stab[j] & 017); j++);
 145:             osize = size;
 146:             size = stab[j];
 147:             if(!lflg){
 148:                 printf("Size %d",rtab[j]);
 149:                 if(!(osize & DBL) && (size & DBL))printf(", double\n");
 150:                 else if((osize & DBL) && !(size & DBL))printf(", single\n");
 151:                 else printf("\n");
 152:             }
 153:             continue;
 154:         }
 155:         if(i & 0300)continue;
 156:         i = (i & 077) | mcase;
 157:         if(railmag != 03)k = asctab[i];
 158:         else k = spectab[i];
 159:         if(!lflg)printf("%s\n",k);
 160:         continue;
 161:     }
 162:     ex();
 163: }
 164: ex(){
 165:     printf("Total lead %d\n",leadtot);
 166:     exit(0);
 167: }
 168: getc(){
 169:     register i;
 170: 
 171:     if(ibufp >= eibufp){
 172:         if((i=read(fid,ibuf,512)) <= 0)ex();
 173:         eibufp = ibuf + i;
 174:         ibufp = ibuf;
 175:     }
 176:     return(*ibufp++ & 0377);
 177: }
 178: char *asctab[128] = {
 179:   0,    /*blank*/
 180: "h",    /*h*/
 181: "t",    /*t*/
 182: "n",    /*n*/
 183: "m",    /*m*/
 184: "l",    /*l*/
 185: "i",    /*i*/
 186: "z",    /*z*/
 187: "s",    /*s*/
 188: "d",    /*d*/
 189: "b",    /*b*/
 190: "x",    /*x*/
 191: "f",    /*f*/
 192: "j",    /*j*/
 193: "u",    /*u*/
 194: "k",    /*k*/
 195:   0,    /*blank*/
 196: "p",    /*p*/
 197: "-",    /*_ 3/4 em dash*/
 198: ";",    /*;*/
 199:   0,    /*blank*/
 200: "a",    /*a*/
 201: "_",    /*rule*/
 202: "c",    /*c*/
 203: "`",    /*` open*/
 204: "e",    /*e*/
 205: "'",    /*' close*/
 206: "o",    /*o*/
 207:   0,    /*1/4*/
 208: "r",    /*r*/
 209:   0,    /*1/2*/
 210: "v",    /*v*/
 211: "-",    /*- hyphen*/
 212: "w",    /*w*/
 213: "q",    /*q*/
 214: "/",    /*/*/
 215: ".",    /*.*/
 216: "g",    /*g*/
 217:   0,    /*3/4*/
 218: ",",    /*,*/
 219: "&",    /*&*/
 220: "y",    /*y*/
 221:   0,    /*blank*/
 222: "%",    /*%*/
 223:   0,    /*blank*/
 224: "Q",    /*Q*/
 225: "T",    /*T*/
 226: "O",    /*O*/
 227: "H",    /*H*/
 228: "N",    /*N*/
 229: "M",    /*M*/
 230: "L",    /*L*/
 231: "R",    /*R*/
 232: "G",    /*G*/
 233: "I",    /*I*/
 234: "P",    /*P*/
 235: "C",    /*C*/
 236: "V",    /*V*/
 237: "E",    /*E*/
 238: "Z",    /*Z*/
 239: "D",    /*D*/
 240: "B",    /*B*/
 241: "S",    /*S*/
 242: "Y",    /*Y*/
 243:   0,    /*blank*/
 244: "F",    /*F*/
 245: "X",    /*X*/
 246: "A",    /*A*/
 247: "W",    /*W*/
 248: "J",    /*J*/
 249: "U",    /*U*/
 250: "K",    /*K*/
 251: "0",    /*0*/
 252: "1",    /*1*/
 253: "2",    /*2*/
 254: "3",    /*3*/
 255: "4",    /*4*/
 256: "5",    /*5*/
 257: "6",    /*6*/
 258: "7",    /*7*/
 259: "8",    /*8*/
 260: "9",    /*9*/
 261: "*",    /***/
 262: "-",    /*minus*/
 263:    0,   /*fi*/
 264:   0,    /*fl*/
 265:   0,    /*ff*/
 266:   0,    /*cent mark*/
 267:   0,    /*ffl*/
 268:   0,    /* ffi */
 269: "(",    /*(*/
 270: ")",    /*)*/
 271: "[",    /*[*/
 272: "]",    /*]*/
 273:   0,    /*degree*/
 274:   0,    /*dagger*/
 275: "=",    /*=*/
 276:   0,    /*registered*/
 277: ":",    /*:*/
 278: "+",    /*+*/
 279:   0,    /*blank*/
 280: "!",    /*!*/
 281:   0,    /*bullet*/
 282: "?",    /*?*/
 283: "'",    /*foot mark*/
 284: "|",    /*|*/
 285:   0,    /*blank*/
 286:   0,    /*copyright*/
 287:   0,    /*square*/
 288: "$" };  /*$*/
 289: 
 290: char *spectab[128] = {
 291:   0,    /*blank*/
 292:   0,    /*psi*/
 293:   0,    /*theta*/
 294:   0,    /*nu*/
 295:   0,    /*mu*/
 296:   0,    /*lambda*/
 297:   0,    /*iota*/
 298:   0,    /*zeta*/
 299:   0,    /*sigma*/
 300:   0,    /*delta*/
 301:   0,    /*beta*/
 302:   0,    /*xi*/
 303:   0,    /*eta*/
 304:   0,    /*phi*/
 305:   "u",  /*upsilon*/
 306:   0,    /*kappa*/
 307:   0,    /*blank*/
 308:   0,    /*pi*/
 309:   "@",  /*at sign @*/
 310:   0,    /*down arrow*/
 311:   0,    /*blank*/
 312:   0,    /*alpha*/
 313: "|",    /*or*/
 314:   0,    /*chi*/
 315: "\"",   /*"*/
 316:   0,    /*epsilon*/
 317:   "=",  /*equals*/
 318:   "o",  /*omicron*/
 319:   0,    /*left arrow*/
 320:   0,    /*rho*/
 321:   0,    /*up arrow*/
 322:   0,    /*tau*/
 323: "_",    /*underrule*/
 324: "\\",   /*\*/
 325:   0,    /*Psi*/
 326:   0,    /*bell system sign*/
 327:   0,    /*infinity*/
 328:   0,    /*gamma*/
 329:   0,    /*improper superset*/
 330:   0,    /*proportional to*/
 331:   0,    /*right hand*/
 332:   0,    /*omega*/
 333:   0,    /*blank*/
 334:   0,    /*gradient*/
 335:   0,    /*blank*/
 336:   0,    /*Phi*/
 337:   0,    /*Theta*/
 338:   0,    /*Omega*/
 339:   0,    /*cup (union)*/
 340:   0,    /*root en*/
 341:   0,    /*terminal sigma*/
 342:   0,    /*Lambda*/
 343:   "-",  /*some horizontal line*/
 344:   0,    /*Gamma*/
 345:   0,    /*integral sign*/
 346:   0,    /*Pi*/
 347:   0,    /*subset of*/
 348:   0,    /*superset of*/
 349:   0,    /*approximates*/
 350:   0,    /*partial derivative*/
 351:   0,    /*Delta*/
 352:   0,    /*square root*/
 353:   0,    /*Sigma*/
 354:   0,    /*approx =*/
 355:   0,    /*blank*/
 356: ">",    /*>*/
 357:   0,    /*Xi*/
 358: "<",    /*<*/
 359: "/",    /*slash (longer)*/
 360:   0,    /*cap (intersection)*/
 361:   "Y",  /*Upsilon*/
 362:   0,    /*not*/
 363: "|",    /*right ceiling (rt of ")*/
 364: "|",    /*left top (of big curly)*/
 365: "|",    /*bold vertical*/
 366: "|",    /*left center of big curly bracket*/
 367: "|",    /*left bottom*/
 368: "|",    /*right top*/
 369: "|",    /*right center of big curly bracket*/
 370: "|",    /*right bot*/
 371: "|",    /*right floor (rb of ")*/
 372: "|",    /*left floor (left bot of big sq bract)*/
 373: "|",    /*left ceiling (lt of ")*/
 374: "x",    /*multiply*/
 375:   0,    /*divide*/
 376:   0,    /*plus-minus*/
 377:   0,    /*<=*/
 378:   0,    /*>=*/
 379:   0,    /*identically equal*/
 380:   0,    /*not equal*/
 381: "{",    /*{*/
 382: "}",    /*}*/
 383: "'",    /*' acute accent*/
 384: "`",    /*` grave accent*/
 385: "^",    /*^*/
 386:   "#",  /*sharp*/
 387:   0,    /*left hand*/
 388:   0,    /*member of*/
 389: "~",    /*~*/
 390:   0,    /*empty set*/
 391:   0,    /*blank*/
 392:   0,    /*dbl dagger*/
 393: "|",    /*box rule*/
 394:   "*",  /*telephone asterisk?*/
 395:   0,    /*improper subset*/
 396:   0,    /*circle*/
 397:   0,    /*blank*/
 398:   "+",  /*eqn plus sign*/
 399:   0,    /*right arrow*/
 400:   0 };  /*section mark*/

Defined functions

ex defined in line 164; used 3 times
getc defined in line 168; used 2 times
main defined in line 30; never used

Defined variables

ap defined in line 7; used 2 times
asctab defined in line 178; used 1 times
eibufp defined in line 10; used 2 times
esc defined in line 12; used 8 times
escd defined in line 13; used 4 times
esct defined in line 15; used 3 times
fid defined in line 11; used 3 times
ibuf defined in line 8; used 5 times
ibufp defined in line 9; used 3 times
lead defined in line 20; used 6 times
leadtot defined in line 18; used 4 times
lflg defined in line 27; used 23 times
mcase defined in line 21; used 4 times
offset defined in line 26; used 3 times
osize defined in line 16; used 3 times
railmag defined in line 19; used 6 times
rtab defined in line 23; used 1 times
sccsid defined in line 1; never used
size defined in line 17; used 4 times
spectab defined in line 290; used 1 times
stab defined in line 22; used 2 times
verd defined in line 14; used 4 times
xxx defined in line 28; never used

Defined macros

DBL defined in line 2; used 4 times
Last modified: 1982-06-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1373
Valid CSS Valid XHTML 1.0 Strict