Commit | Line | Data |
---|---|---|
b2a81223 | 1 | /* |
dc45ba8c | 2 | * Copyright (c) 1983 Eric P. Allman |
bee79b64 KB |
3 | * Copyright (c) 1988 Regents of the University of California. |
4 | * All rights reserved. | |
5 | * | |
1c15e888 C |
6 | * Redistribution and use in source and binary forms are permitted provided |
7 | * that: (1) source distributions retain this entire copyright notice and | |
8 | * comment, and (2) distributions including binaries display the following | |
9 | * acknowledgement: ``This product includes software developed by the | |
10 | * University of California, Berkeley and its contributors'' in the | |
11 | * documentation or other materials provided with the distribution and in | |
12 | * all advertising materials mentioning features or use of this software. | |
13 | * Neither the name of the University nor the names of its contributors may | |
14 | * be used to endorse or promote products derived from this software without | |
15 | * specific prior written permission. | |
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | |
17 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
bee79b64 | 19 | */ |
b2a81223 DF |
20 | |
21 | #ifndef lint | |
1c15e888 | 22 | static char sccsid[] = "@(#)trace.c 5.6 (Berkeley) 6/1/90"; |
bee79b64 | 23 | #endif /* not lint */ |
b2a81223 | 24 | |
f067c0e8 EA |
25 | # include "sendmail.h" |
26 | ||
f067c0e8 EA |
27 | /* |
28 | ** TtSETUP -- set up for trace package. | |
29 | ** | |
30 | ** Parameters: | |
31 | ** vect -- pointer to trace vector. | |
32 | ** size -- number of flags in trace vector. | |
33 | ** defflags -- flags to set if no value given. | |
34 | ** | |
35 | ** Returns: | |
36 | ** none | |
37 | ** | |
38 | ** Side Effects: | |
39 | ** environment is set up. | |
40 | */ | |
41 | ||
42 | u_char *tTvect; | |
43 | int tTsize; | |
44 | static char *DefFlags; | |
45 | ||
46 | tTsetup(vect, size, defflags) | |
47 | u_char *vect; | |
48 | int size; | |
49 | char *defflags; | |
50 | { | |
51 | tTvect = vect; | |
52 | tTsize = size; | |
53 | DefFlags = defflags; | |
54 | } | |
55 | \f/* | |
56 | ** TtFLAG -- process an external trace flag description. | |
57 | ** | |
58 | ** Parameters: | |
59 | ** s -- the trace flag. | |
60 | ** | |
61 | ** Returns: | |
62 | ** none. | |
63 | ** | |
64 | ** Side Effects: | |
65 | ** sets/clears trace flags. | |
66 | */ | |
67 | ||
68 | tTflag(s) | |
69 | register char *s; | |
70 | { | |
71 | int first, last; | |
72 | register int i; | |
73 | ||
74 | if (*s == '\0') | |
75 | s = DefFlags; | |
76 | ||
77 | for (;;) | |
78 | { | |
79 | /* find first flag to set */ | |
80 | i = 0; | |
81 | while (isdigit(*s)) | |
82 | i = i * 10 + (*s++ - '0'); | |
83 | first = i; | |
84 | ||
85 | /* find last flag to set */ | |
86 | if (*s == '-') | |
87 | { | |
88 | i = 0; | |
89 | while (isdigit(*++s)) | |
90 | i = i * 10 + (*s - '0'); | |
91 | } | |
92 | last = i; | |
93 | ||
94 | /* find the level to set it to */ | |
95 | i = 1; | |
96 | if (*s == '.') | |
97 | { | |
98 | i = 0; | |
99 | while (isdigit(*++s)) | |
100 | i = i * 10 + (*s - '0'); | |
101 | } | |
102 | ||
103 | /* clean up args */ | |
104 | if (first >= tTsize) | |
105 | first = tTsize - 1; | |
106 | if (last >= tTsize) | |
107 | last = tTsize - 1; | |
108 | ||
109 | /* set the flags */ | |
110 | while (first <= last) | |
111 | tTvect[first++] = i; | |
112 | ||
113 | /* more arguments? */ | |
114 | if (*s++ == '\0') | |
115 | return; | |
116 | } | |
117 | } |