xref: /csrg-svn/usr.sbin/sendmail/src/trace.c (revision 33731)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  *  Sendmail
13  *  Copyright (c) 1983  Eric P. Allman
14  *  Berkeley, California
15  */
16 
17 #ifndef lint
18 static char sccsid[] = "@(#)trace.c	5.4 (Berkeley) 03/13/88";
19 #endif /* not lint */
20 
21 # include "sendmail.h"
22 
23 /*
24 **  TtSETUP -- set up for trace package.
25 **
26 **	Parameters:
27 **		vect -- pointer to trace vector.
28 **		size -- number of flags in trace vector.
29 **		defflags -- flags to set if no value given.
30 **
31 **	Returns:
32 **		none
33 **
34 **	Side Effects:
35 **		environment is set up.
36 */
37 
38 u_char		*tTvect;
39 int		tTsize;
40 static char	*DefFlags;
41 
42 tTsetup(vect, size, defflags)
43 	u_char *vect;
44 	int size;
45 	char *defflags;
46 {
47 	tTvect = vect;
48 	tTsize = size;
49 	DefFlags = defflags;
50 }
51 /*
52 **  TtFLAG -- process an external trace flag description.
53 **
54 **	Parameters:
55 **		s -- the trace flag.
56 **
57 **	Returns:
58 **		none.
59 **
60 **	Side Effects:
61 **		sets/clears trace flags.
62 */
63 
64 tTflag(s)
65 	register char *s;
66 {
67 	int first, last;
68 	register int i;
69 
70 	if (*s == '\0')
71 		s = DefFlags;
72 
73 	for (;;)
74 	{
75 		/* find first flag to set */
76 		i = 0;
77 		while (isdigit(*s))
78 			i = i * 10 + (*s++ - '0');
79 		first = i;
80 
81 		/* find last flag to set */
82 		if (*s == '-')
83 		{
84 			i = 0;
85 			while (isdigit(*++s))
86 				i = i * 10 + (*s - '0');
87 		}
88 		last = i;
89 
90 		/* find the level to set it to */
91 		i = 1;
92 		if (*s == '.')
93 		{
94 			i = 0;
95 			while (isdigit(*++s))
96 				i = i * 10 + (*s - '0');
97 		}
98 
99 		/* clean up args */
100 		if (first >= tTsize)
101 			first = tTsize - 1;
102 		if (last >= tTsize)
103 			last = tTsize - 1;
104 
105 		/* set the flags */
106 		while (first <= last)
107 			tTvect[first++] = i;
108 
109 		/* more arguments? */
110 		if (*s++ == '\0')
111 			return;
112 	}
113 }
114