122719Sdist /* 234921Sbostic * Copyright (c) 1983 Eric P. Allman 3*62532Sbostic * Copyright (c) 1988, 1993 4*62532Sbostic * The Regents of the University of California. All rights reserved. 533731Sbostic * 642829Sbostic * %sccs.include.redist.c% 733731Sbostic */ 822719Sdist 922719Sdist #ifndef lint 10*62532Sbostic static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 06/07/93"; 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 347668Seric tTsetup(vect, size, defflags) 357668Seric u_char *vect; 367668Seric int size; 377668Seric char *defflags; 387668Seric { 397668Seric tTvect = vect; 407668Seric tTsize = size; 417668Seric DefFlags = defflags; 427668Seric } 437668Seric /* 447668Seric ** TtFLAG -- process an external trace flag description. 457668Seric ** 467668Seric ** Parameters: 477668Seric ** s -- the trace flag. 487668Seric ** 497668Seric ** Returns: 507668Seric ** none. 517668Seric ** 527668Seric ** Side Effects: 537668Seric ** sets/clears trace flags. 547668Seric */ 557668Seric 567668Seric tTflag(s) 577668Seric register char *s; 587668Seric { 597668Seric int first, last; 607668Seric register int i; 617668Seric 627668Seric if (*s == '\0') 637668Seric s = DefFlags; 647668Seric 657668Seric for (;;) 667668Seric { 677668Seric /* find first flag to set */ 687668Seric i = 0; 697668Seric while (isdigit(*s)) 707668Seric i = i * 10 + (*s++ - '0'); 717668Seric first = i; 727668Seric 737668Seric /* find last flag to set */ 747668Seric if (*s == '-') 757668Seric { 767668Seric i = 0; 777668Seric while (isdigit(*++s)) 787668Seric i = i * 10 + (*s - '0'); 797668Seric } 807668Seric last = i; 817668Seric 827668Seric /* find the level to set it to */ 837668Seric i = 1; 847668Seric if (*s == '.') 857668Seric { 867668Seric i = 0; 877668Seric while (isdigit(*++s)) 887668Seric i = i * 10 + (*s - '0'); 897668Seric } 907668Seric 917668Seric /* clean up args */ 927668Seric if (first >= tTsize) 937668Seric first = tTsize - 1; 947668Seric if (last >= tTsize) 957668Seric last = tTsize - 1; 967668Seric 977668Seric /* set the flags */ 987668Seric while (first <= last) 997668Seric tTvect[first++] = i; 1007668Seric 1017668Seric /* more arguments? */ 1027668Seric if (*s++ == '\0') 1037668Seric return; 1047668Seric } 1057668Seric } 106