1 /* 2 * Copyright (c) 1983, 1995 Eric P. Allman 3 * Copyright (c) 1988, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * %sccs.include.redist.c% 7 */ 8 9 #ifndef lint 10 static char sccsid[] = "@(#)trace.c 8.4 (Berkeley) 05/28/95"; 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 void 35 tTsetup(vect, size, defflags) 36 u_char *vect; 37 int size; 38 char *defflags; 39 { 40 tTvect = vect; 41 tTsize = size; 42 DefFlags = defflags; 43 } 44 /* 45 ** TtFLAG -- process an external trace flag description. 46 ** 47 ** Parameters: 48 ** s -- the trace flag. 49 ** 50 ** Returns: 51 ** none. 52 ** 53 ** Side Effects: 54 ** sets/clears trace flags. 55 */ 56 57 void 58 tTflag(s) 59 register char *s; 60 { 61 unsigned int first, last; 62 register unsigned 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