xref: /csrg-svn/usr.sbin/sendmail/src/trace.c (revision 34921)
122719Sdist /*
2*34921Sbostic  * Copyright (c) 1983 Eric P. Allman
333731Sbostic  * Copyright (c) 1988 Regents of the University of California.
433731Sbostic  * All rights reserved.
533731Sbostic  *
633731Sbostic  * Redistribution and use in source and binary forms are permitted
7*34921Sbostic  * provided that the above copyright notice and this paragraph are
8*34921Sbostic  * duplicated in all such forms and that any documentation,
9*34921Sbostic  * advertising materials, and other materials related to such
10*34921Sbostic  * distribution and use acknowledge that the software was developed
11*34921Sbostic  * by the University of California, Berkeley.  The name of the
12*34921Sbostic  * University may not be used to endorse or promote products derived
13*34921Sbostic  * from this software without specific prior written permission.
14*34921Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15*34921Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16*34921Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1733731Sbostic  */
1822719Sdist 
1922719Sdist #ifndef lint
20*34921Sbostic static char sccsid[] = "@(#)trace.c	5.5 (Berkeley) 06/30/88";
2133731Sbostic #endif /* not lint */
2222719Sdist 
237668Seric # include "sendmail.h"
247668Seric 
257668Seric /*
267668Seric **  TtSETUP -- set up for trace package.
277668Seric **
287668Seric **	Parameters:
297668Seric **		vect -- pointer to trace vector.
307668Seric **		size -- number of flags in trace vector.
317668Seric **		defflags -- flags to set if no value given.
327668Seric **
337668Seric **	Returns:
347668Seric **		none
357668Seric **
367668Seric **	Side Effects:
377668Seric **		environment is set up.
387668Seric */
397668Seric 
407668Seric u_char		*tTvect;
417668Seric int		tTsize;
427668Seric static char	*DefFlags;
437668Seric 
447668Seric tTsetup(vect, size, defflags)
457668Seric 	u_char *vect;
467668Seric 	int size;
477668Seric 	char *defflags;
487668Seric {
497668Seric 	tTvect = vect;
507668Seric 	tTsize = size;
517668Seric 	DefFlags = defflags;
527668Seric }
537668Seric /*
547668Seric **  TtFLAG -- process an external trace flag description.
557668Seric **
567668Seric **	Parameters:
577668Seric **		s -- the trace flag.
587668Seric **
597668Seric **	Returns:
607668Seric **		none.
617668Seric **
627668Seric **	Side Effects:
637668Seric **		sets/clears trace flags.
647668Seric */
657668Seric 
667668Seric tTflag(s)
677668Seric 	register char *s;
687668Seric {
697668Seric 	int first, last;
707668Seric 	register int i;
717668Seric 
727668Seric 	if (*s == '\0')
737668Seric 		s = DefFlags;
747668Seric 
757668Seric 	for (;;)
767668Seric 	{
777668Seric 		/* find first flag to set */
787668Seric 		i = 0;
797668Seric 		while (isdigit(*s))
807668Seric 			i = i * 10 + (*s++ - '0');
817668Seric 		first = i;
827668Seric 
837668Seric 		/* find last flag to set */
847668Seric 		if (*s == '-')
857668Seric 		{
867668Seric 			i = 0;
877668Seric 			while (isdigit(*++s))
887668Seric 				i = i * 10 + (*s - '0');
897668Seric 		}
907668Seric 		last = i;
917668Seric 
927668Seric 		/* find the level to set it to */
937668Seric 		i = 1;
947668Seric 		if (*s == '.')
957668Seric 		{
967668Seric 			i = 0;
977668Seric 			while (isdigit(*++s))
987668Seric 				i = i * 10 + (*s - '0');
997668Seric 		}
1007668Seric 
1017668Seric 		/* clean up args */
1027668Seric 		if (first >= tTsize)
1037668Seric 			first = tTsize - 1;
1047668Seric 		if (last >= tTsize)
1057668Seric 			last = tTsize - 1;
1067668Seric 
1077668Seric 		/* set the flags */
1087668Seric 		while (first <= last)
1097668Seric 			tTvect[first++] = i;
1107668Seric 
1117668Seric 		/* more arguments? */
1127668Seric 		if (*s++ == '\0')
1137668Seric 			return;
1147668Seric 	}
1157668Seric }
116