1 /* 2 ** Sendmail 3 ** Copyright (c) 1983 Eric P. Allman 4 ** Berkeley, California 5 ** 6 ** Copyright (c) 1983 Regents of the University of California. 7 ** All rights reserved. The Berkeley software License Agreement 8 ** specifies the terms and conditions for redistribution. 9 */ 10 11 #ifndef lint 12 static char SccsId[] = "@(#)trace.c 5.3 (Berkeley) 12/17/86"; 13 #endif not lint 14 15 # include "sendmail.h" 16 17 /* 18 ** TtSETUP -- set up for trace package. 19 ** 20 ** Parameters: 21 ** vect -- pointer to trace vector. 22 ** size -- number of flags in trace vector. 23 ** defflags -- flags to set if no value given. 24 ** 25 ** Returns: 26 ** none 27 ** 28 ** Side Effects: 29 ** environment is set up. 30 */ 31 32 u_char *tTvect; 33 int tTsize; 34 static char *DefFlags; 35 36 tTsetup(vect, size, defflags) 37 u_char *vect; 38 int size; 39 char *defflags; 40 { 41 tTvect = vect; 42 tTsize = size; 43 DefFlags = defflags; 44 } 45 /* 46 ** TtFLAG -- process an external trace flag description. 47 ** 48 ** Parameters: 49 ** s -- the trace flag. 50 ** 51 ** Returns: 52 ** none. 53 ** 54 ** Side Effects: 55 ** sets/clears trace flags. 56 */ 57 58 tTflag(s) 59 register char *s; 60 { 61 int first, last; 62 register int i; 63 64 if (*s == '\0') 65 s = DefFlags; 66 67 for (;;) 68 { 69 /* find first flag to set */ 70 i = 0; 71 while (isdigit(*s)) 72 i = i * 10 + (*s++ - '0'); 73 first = i; 74 75 /* find last flag to set */ 76 if (*s == '-') 77 { 78 i = 0; 79 while (isdigit(*++s)) 80 i = i * 10 + (*s - '0'); 81 } 82 last = i; 83 84 /* find the level to set it to */ 85 i = 1; 86 if (*s == '.') 87 { 88 i = 0; 89 while (isdigit(*++s)) 90 i = i * 10 + (*s - '0'); 91 } 92 93 /* clean up args */ 94 if (first >= tTsize) 95 first = tTsize - 1; 96 if (last >= tTsize) 97 last = tTsize - 1; 98 99 /* set the flags */ 100 while (first <= last) 101 tTvect[first++] = i; 102 103 /* more arguments? */ 104 if (*s++ == '\0') 105 return; 106 } 107 } 108