xref: /csrg-svn/usr.sbin/sendmail/src/trace.c (revision 22719)
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.1 (Berkeley) 06/07/85";
13 #endif not lint
14 
15 # include <ctype.h>
16 # include "sendmail.h"
17 
18 SCCSID(@(#)trace.c	5.1		06/07/85);
19 
20 /*
21 **  TtSETUP -- set up for trace package.
22 **
23 **	Parameters:
24 **		vect -- pointer to trace vector.
25 **		size -- number of flags in trace vector.
26 **		defflags -- flags to set if no value given.
27 **
28 **	Returns:
29 **		none
30 **
31 **	Side Effects:
32 **		environment is set up.
33 */
34 
35 u_char		*tTvect;
36 int		tTsize;
37 static char	*DefFlags;
38 
39 tTsetup(vect, size, defflags)
40 	u_char *vect;
41 	int size;
42 	char *defflags;
43 {
44 	tTvect = vect;
45 	tTsize = size;
46 	DefFlags = defflags;
47 }
48 /*
49 **  TtFLAG -- process an external trace flag description.
50 **
51 **	Parameters:
52 **		s -- the trace flag.
53 **
54 **	Returns:
55 **		none.
56 **
57 **	Side Effects:
58 **		sets/clears trace flags.
59 */
60 
61 tTflag(s)
62 	register char *s;
63 {
64 	int first, last;
65 	register int i;
66 
67 	if (*s == '\0')
68 		s = DefFlags;
69 
70 	for (;;)
71 	{
72 		/* find first flag to set */
73 		i = 0;
74 		while (isdigit(*s))
75 			i = i * 10 + (*s++ - '0');
76 		first = i;
77 
78 		/* find last flag to set */
79 		if (*s == '-')
80 		{
81 			i = 0;
82 			while (isdigit(*++s))
83 				i = i * 10 + (*s - '0');
84 		}
85 		last = i;
86 
87 		/* find the level to set it to */
88 		i = 1;
89 		if (*s == '.')
90 		{
91 			i = 0;
92 			while (isdigit(*++s))
93 				i = i * 10 + (*s - '0');
94 		}
95 
96 		/* clean up args */
97 		if (first >= tTsize)
98 			first = tTsize - 1;
99 		if (last >= tTsize)
100 			last = tTsize - 1;
101 
102 		/* set the flags */
103 		while (first <= last)
104 			tTvect[first++] = i;
105 
106 		/* more arguments? */
107 		if (*s++ == '\0')
108 			return;
109 	}
110 }
111