/*
* Copyright (c) 1998-2001 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
#include <sendmail.h>
/*
** TtSETUP -- set up for trace package.
**
** Parameters:
** vect -- pointer to trace vector.
** size -- number of flags in trace vector.
** defflags -- flags to set if no value given.
**
** Returns:
** none
**
** Side Effects:
** environment is set up.
*/
static unsigned char *tTvect;
static unsigned int tTsize;
static char *DefFlags;
void
unsigned char *vect;
unsigned int size;
char *defflags;
{
}
/*
** tToldflag -- process an old style trace flag
**
** Parameters:
** s -- points to a [\0, \t] terminated string,
** and the initial character is a digit.
**
** Returns:
** pointer to terminating [\0, \t] character
**
** Side Effects:
** modifies tTvect
*/
static char *
tToldflag(s)
register char *s;
{
register unsigned int i;
/* find first flag to set */
i = 0;
i = i * 10 + (*s++ - '0');
/*
** skip over rest of a too large number
** Maybe we should complain if out-of-bounds values are used.
*/
s++;
first = i;
/* find last flag to set */
if (*s == '-')
{
i = 0;
i = i * 10 + (*s - '0');
/* skip over rest of a too large number */
s++;
}
last = i;
/* find the level to set it to */
i = 1;
if (*s == '.')
{
i = 0;
i = i * 10 + (*s - '0');
}
/* clean up args */
/* set the flags */
/* skip trailing junk */
while (*s != '\0' && *s != ',' && *s != ' ' && *s != '\t')
++s;
return s;
}
/*
** tTnewflag -- process a new style trace flag
**
** Parameters:
** s -- Points to a non-empty [\0, \t] terminated string,
** of which the initial character is not a digit.
**
** Returns:
** pointer to terminating [\0, \t] character
**
** Side Effects:
** adds trace flag to libsm debug database
*/
static char *
tTnewflag(s)
register char *s;
{
int level;
pat = s;
while (*s != '\0' && *s != ',' && *s != ' ' && *s != '\t' && *s != '.')
++s;
endpat = s;
if (*s == '.')
{
++s;
level = 0;
{
++s;
}
if (level < 0)
level = 0;
}
else
{
level = 1;
}
/* skip trailing junk */
while (*s != '\0' && *s != ',' && *s != ' ' && *s != '\t')
++s;
return s;
}
/*
** TtFLAG -- process an external trace flag list.
**
** Parameters:
** s -- the trace flag.
**
** The syntax of a trace flag list is as follows:
**
** <flags> ::= <flag> | <flags> "," <flag>
** <flag> ::= <categories> | <categories> "." <level>
** <categories> ::= <int> | <int> "-" <int> | <pattern>
** <pattern> ::= <an sh glob pattern matching a C identifier>
**
** White space is ignored before and after a flag.
** However, note that we skip over anything we don't
** understand, rather than report an error.
**
** Returns:
** none.
**
** Side Effects:
** registers new-style trace flags with the libsm debug package.
*/
void
tTflag(s)
register char *s;
{
if (s == NULL || *s == '\0')
s = DefFlags;
for (;;)
{
if (*s == '\0')
return;
if (*s == ',' || *s == ' ' || *s == '\t')
{
++s;
continue;
}
s = tToldflag(s);
else
s = tTnewflag(s);
}
}