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