1: # include   <useful.h>
   2: # include   <sccs.h>
   3: 
   4: SCCSID(@(#)trace.c	8.1	12/31/84)
   5: 
   6: # define    tTNCUTOFF   30
   7: 
   8: short       *tT;
   9: int     tTsize;
  10: char        *tTp, tTsav, tTany;
  11: int     (*tTsetf)();
  12: int     tTon(), tToff();
  13: 
  14: tTrace(argv, tflag, tvect, tsize)
  15: char    **argv;
  16: char    tflag;
  17: short   *tvect;
  18: int tsize;
  19: {
  20:     register char   **pp;
  21:     register bool   rtval;
  22: 
  23:     tT = tvect;
  24:     tTsize = tsize;
  25:     tTsetf = tTon;
  26:     rtval = FALSE;
  27: 
  28:     for (pp = argv; *pp != NULL; pp++)
  29:     {
  30:         if ((*pp)[0] != '-' || (*pp)[1] != tflag)
  31:             continue;
  32:         tTflag(&(*pp)[2]);
  33:         rtval = TRUE;
  34:     }
  35:     return (rtval);
  36: }
  37: /*
  38: **  TTAMPER -- internal interface to set & clear trace flags
  39: **
  40: **	This routine is called from the ctlmod or whatever.
  41: **
  42: **	Parameters:
  43: **		line -- a line like the normal trace flag lines.
  44: **		tflag -- the trace flag to deal with.
  45: **		tvect -- a pointer to a trace vector.
  46: **		tsize -- the size of the trace vector.
  47: **
  48: **	Returns:
  49: **		??
  50: **
  51: **	Side Effects:
  52: **		none.
  53: */
  54: 
  55: tTamper(line, tflag, tvect, tsize)
  56: char    *line;
  57: char    tflag;
  58: short   *tvect;
  59: int tsize;
  60: {
  61:     register char   *p;
  62:     register char   *endp;
  63:     register bool   rtval;
  64:     char        save;
  65:     short       *otvect;
  66:     int     otsize;
  67: 
  68:     otvect = tT;
  69:     otsize = tTsize;
  70:     tT = tvect;
  71:     tTsize = tsize;
  72:     rtval = FALSE;
  73: 
  74:     for (p = line; *p != '\n' && *p != '\0'; p++)
  75:     {
  76:         switch (*p)
  77:         {
  78:           case '+':
  79:             tTsetf = tTon;
  80:             break;
  81: 
  82:           case '-':
  83:             tTsetf = tToff;
  84:             break;
  85: 
  86:           default:
  87:             continue;
  88:         }
  89:         if (*(++p) != tflag)
  90:         {
  91:             p--;
  92:             continue;
  93:         }
  94: 
  95:         for (endp = ++p; *endp != ' ' && *endp != '\t' && *endp != '\0' && *endp != '\n'; endp++)
  96:             continue;
  97: 
  98:         save = *endp;
  99:         *endp = '\0';
 100: 
 101:         tTflag(p);
 102: 
 103:         *endp = save;
 104:         p = --endp;
 105:         rtval = TRUE;
 106:     }
 107:     tT = otvect;
 108:     tTsize = otsize;
 109:     return (rtval);
 110: }
 111: 
 112: tTflag(args)
 113: char    *args;
 114: {
 115:     register int    fno;
 116:     int     f;
 117: 
 118:     tTany++;
 119:     tTp = args;
 120:     if (*tTp == '\0')
 121:     {
 122:         for (fno = tTNCUTOFF; fno < tTsize; fno++)
 123:             (*tTsetf)(fno, -1);
 124:         return;
 125:     }
 126:     do
 127:     {
 128:         fno = tTnext();
 129:         tTurn(fno);
 130: 
 131:         if (tTsav == '/')
 132:         {
 133:             f = fno + 1;
 134:             fno = tTnext();
 135:             while (f < fno)
 136:                 (*tTsetf)(f++, -1);
 137:             tTurn(fno);
 138:         }
 139:     }  while(tTsav != '\0');
 140: }
 141: 
 142: tTnext()
 143: {
 144:     register char   *c;
 145:     auto int    ix;
 146: 
 147:     c = tTp;
 148:     while (*tTp >= '0' && *tTp <= '9')
 149:         tTp++;
 150:     tTsav = *tTp;
 151:     *tTp = '\0';
 152:     ix = atoi(c);
 153:     *tTp++ = tTsav;
 154:     return (ix);
 155: }
 156: 
 157: tTurn(fno)
 158: register int    fno;
 159: {
 160:     register int    pt;
 161: 
 162:     if (tTsav == '.')
 163:     {
 164:         while (tTsav == '.')
 165:         {
 166:             pt = tTnext();
 167:             (*tTsetf)(fno, pt);
 168:         }
 169:     }
 170:     else
 171:         (*tTsetf)(fno, -1);
 172: }
 173: 
 174: 
 175: tTon(fun, pt)
 176: register int    fun;
 177: register int    pt;
 178: {
 179:     if (fun >= tTsize || fun < 0)
 180:         return;
 181: 
 182:     if (pt >= 0)
 183:         tT[fun] |= (1<<pt%16);
 184:     else
 185:         tT[fun] = 0177777;
 186: }
 187: 
 188: 
 189: tToff(fun, pt)
 190: register int    fun;
 191: register int    pt;
 192: {
 193:     if (fun >= tTsize || fun < 0)
 194:         return;
 195: 
 196:     if (pt >= 0)
 197:         tT[fun] ^= (1<<pt%16);
 198:     else
 199:         tT[fun] = 0;
 200: }
 201: 
 202: 
 203: /*
 204: **  CHECK TRACE FLAG AND PRINT INFORMATION
 205: **
 206: **	This routine is equivalent to
 207: **		if (tTf(m, n))
 208: **			printf(a1, a2, a3, a4, a5, a6);
 209: **
 210: **	and can be called to reduce process space.  The return value
 211: **	is the value of the flag.
 212: */
 213: 
 214: # define    tTf(a, b)   ((b < 0) ? tT[a] : (tT[a] & (1 << b)))
 215: 
 216: tTfp(m, n, a1, a2, a3, a4, a5, a6)
 217: int m;
 218: int n;
 219: char    *a1, *a2, *a3, *a4, *a5, *a6;
 220: {
 221:     register int    rtval;
 222: 
 223:     if (rtval = tTf(m, n))
 224:         printf(a1, a2, a3, a4, a5, a6);
 225:     return (rtval);
 226: }

Defined functions

tTamper defined in line 55; never used
tTflag defined in line 112; used 2 times
tTfp defined in line 216; never used
tTnext defined in line 142; used 3 times
tToff defined in line 189; used 2 times
tTon defined in line 175; used 3 times
tTrace defined in line 14; never used
tTurn defined in line 157; used 2 times

Defined variables

tT defined in line 8; used 10 times
tTany defined in line 10; used 1 times
tTp defined in line 10; used 9 times
tTsav defined in line 10; used 6 times
tTsize defined in line 9; used 7 times

Defined macros

tTNCUTOFF defined in line 6; used 1 times
tTf defined in line 214; used 1 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1021
Valid CSS Valid XHTML 1.0 Strict