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