122719Sdist /* 2*33731Sbostic * Copyright (c) 1988 Regents of the University of California. 3*33731Sbostic * All rights reserved. 4*33731Sbostic * 5*33731Sbostic * Redistribution and use in source and binary forms are permitted 6*33731Sbostic * provided that this notice is preserved and that due credit is given 7*33731Sbostic * to the University of California at Berkeley. The name of the University 8*33731Sbostic * may not be used to endorse or promote products derived from this 9*33731Sbostic * software without specific prior written permission. This software 10*33731Sbostic * is provided ``as is'' without express or implied warranty. 11*33731Sbostic * 12*33731Sbostic * Sendmail 13*33731Sbostic * Copyright (c) 1983 Eric P. Allman 14*33731Sbostic * Berkeley, California 15*33731Sbostic */ 1622719Sdist 1722719Sdist #ifndef lint 18*33731Sbostic static char sccsid[] = "@(#)trace.c 5.4 (Berkeley) 03/13/88"; 19*33731Sbostic #endif /* not lint */ 2022719Sdist 217668Seric # include "sendmail.h" 227668Seric 237668Seric /* 247668Seric ** TtSETUP -- set up for trace package. 257668Seric ** 267668Seric ** Parameters: 277668Seric ** vect -- pointer to trace vector. 287668Seric ** size -- number of flags in trace vector. 297668Seric ** defflags -- flags to set if no value given. 307668Seric ** 317668Seric ** Returns: 327668Seric ** none 337668Seric ** 347668Seric ** Side Effects: 357668Seric ** environment is set up. 367668Seric */ 377668Seric 387668Seric u_char *tTvect; 397668Seric int tTsize; 407668Seric static char *DefFlags; 417668Seric 427668Seric tTsetup(vect, size, defflags) 437668Seric u_char *vect; 447668Seric int size; 457668Seric char *defflags; 467668Seric { 477668Seric tTvect = vect; 487668Seric tTsize = size; 497668Seric DefFlags = defflags; 507668Seric } 517668Seric /* 527668Seric ** TtFLAG -- process an external trace flag description. 537668Seric ** 547668Seric ** Parameters: 557668Seric ** s -- the trace flag. 567668Seric ** 577668Seric ** Returns: 587668Seric ** none. 597668Seric ** 607668Seric ** Side Effects: 617668Seric ** sets/clears trace flags. 627668Seric */ 637668Seric 647668Seric tTflag(s) 657668Seric register char *s; 667668Seric { 677668Seric int first, last; 687668Seric register int i; 697668Seric 707668Seric if (*s == '\0') 717668Seric s = DefFlags; 727668Seric 737668Seric for (;;) 747668Seric { 757668Seric /* find first flag to set */ 767668Seric i = 0; 777668Seric while (isdigit(*s)) 787668Seric i = i * 10 + (*s++ - '0'); 797668Seric first = i; 807668Seric 817668Seric /* find last flag to set */ 827668Seric if (*s == '-') 837668Seric { 847668Seric i = 0; 857668Seric while (isdigit(*++s)) 867668Seric i = i * 10 + (*s - '0'); 877668Seric } 887668Seric last = i; 897668Seric 907668Seric /* find the level to set it to */ 917668Seric i = 1; 927668Seric if (*s == '.') 937668Seric { 947668Seric i = 0; 957668Seric while (isdigit(*++s)) 967668Seric i = i * 10 + (*s - '0'); 977668Seric } 987668Seric 997668Seric /* clean up args */ 1007668Seric if (first >= tTsize) 1017668Seric first = tTsize - 1; 1027668Seric if (last >= tTsize) 1037668Seric last = tTsize - 1; 1047668Seric 1057668Seric /* set the flags */ 1067668Seric while (first <= last) 1077668Seric tTvect[first++] = i; 1087668Seric 1097668Seric /* more arguments? */ 1107668Seric if (*s++ == '\0') 1117668Seric return; 1127668Seric } 1137668Seric } 114