122719Sdist /* 268839Seric * Copyright (c) 1983, 1995 Eric P. Allman 362532Sbostic * Copyright (c) 1988, 1993 462532Sbostic * The Regents of the University of California. All rights reserved. 533731Sbostic * 642829Sbostic * %sccs.include.redist.c% 733731Sbostic */ 822719Sdist 922719Sdist #ifndef lint 10*69748Seric static char sccsid[] = "@(#)trace.c 8.4 (Berkeley) 05/28/95"; 1133731Sbostic #endif /* not lint */ 1222719Sdist 137668Seric # include "sendmail.h" 147668Seric 157668Seric /* 167668Seric ** TtSETUP -- set up for trace package. 177668Seric ** 187668Seric ** Parameters: 197668Seric ** vect -- pointer to trace vector. 207668Seric ** size -- number of flags in trace vector. 217668Seric ** defflags -- flags to set if no value given. 227668Seric ** 237668Seric ** Returns: 247668Seric ** none 257668Seric ** 267668Seric ** Side Effects: 277668Seric ** environment is set up. 287668Seric */ 297668Seric 307668Seric u_char *tTvect; 317668Seric int tTsize; 327668Seric static char *DefFlags; 337668Seric 34*69748Seric void tTsetup(vect,size,defflags)357668SerictTsetup(vect, size, defflags) 367668Seric u_char *vect; 377668Seric int size; 387668Seric char *defflags; 397668Seric { 407668Seric tTvect = vect; 417668Seric tTsize = size; 427668Seric DefFlags = defflags; 437668Seric } 447668Seric /* 457668Seric ** TtFLAG -- process an external trace flag description. 467668Seric ** 477668Seric ** Parameters: 487668Seric ** s -- the trace flag. 497668Seric ** 507668Seric ** Returns: 517668Seric ** none. 527668Seric ** 537668Seric ** Side Effects: 547668Seric ** sets/clears trace flags. 557668Seric */ 567668Seric 57*69748Seric void tTflag(s)587668SerictTflag(s) 597668Seric register char *s; 607668Seric { 6166355Seric unsigned int first, last; 6266355Seric register unsigned int i; 637668Seric 647668Seric if (*s == '\0') 657668Seric s = DefFlags; 667668Seric 677668Seric for (;;) 687668Seric { 697668Seric /* find first flag to set */ 707668Seric i = 0; 717668Seric while (isdigit(*s)) 727668Seric i = i * 10 + (*s++ - '0'); 737668Seric first = i; 747668Seric 757668Seric /* find last flag to set */ 767668Seric if (*s == '-') 777668Seric { 787668Seric i = 0; 797668Seric while (isdigit(*++s)) 807668Seric i = i * 10 + (*s - '0'); 817668Seric } 827668Seric last = i; 837668Seric 847668Seric /* find the level to set it to */ 857668Seric i = 1; 867668Seric if (*s == '.') 877668Seric { 887668Seric i = 0; 897668Seric while (isdigit(*++s)) 907668Seric i = i * 10 + (*s - '0'); 917668Seric } 927668Seric 937668Seric /* clean up args */ 947668Seric if (first >= tTsize) 957668Seric first = tTsize - 1; 967668Seric if (last >= tTsize) 977668Seric last = tTsize - 1; 987668Seric 997668Seric /* set the flags */ 1007668Seric while (first <= last) 1017668Seric tTvect[first++] = i; 1027668Seric 1037668Seric /* more arguments? */ 1047668Seric if (*s++ == '\0') 1057668Seric return; 1067668Seric } 1077668Seric } 108