
#include "V.h"
#include "exit.h"
/*
* This is global data for John Chambers' C audit/debug/verbose module.
* Most of the symbols here start with "V",
*
* SEE ALSO
*   V.h sys.c
*
* Here are some global symbols which you may wish to modify:
*/
char  Vflgchr = '%';	/* Debug option flag */
int   Vsleep = 0;	/* Sleep after debug output lines */
int   mypid    = 0;	/* This process's pid */
char* progname = unknown;/* Full program name */
char* pname    = unknown;/* Short program name, usually lastfld(progname) */
Flag  stdiofl  = 1;	/* Permission to write to stdio */
int   verbose  = 1;	/* Verbose output goes to stderr */
/*
* Assorted global variables used by the debug package:
*/
#ifdef VBS_SET_FCTS
char V_chrval[] = "%s=%02X='%c'";
char V_intval[] = "%s=%d";
char V_ptrval[] = "%s=%08X";
char V_strval[] = "%s=\"%s\"";
#endif

char*  Venvvar= 0;	/* Name of this program's environment variable */
char*  Venvar1= 0;	/* Name of this program's environment D_ variable */
char*  Venvar2= 0;	/* Name of this program's environment V_ variable */
V_f   Vfct   = {"???"};	/* Name of current function */
V_f   Vf     = {"???"};	/* Name of dummy function */
V_f*  Vfcts  = 0;	/* List of function entry structures */
char*  Vfile  = 0;	/* Name of debug output file, if known */
char   Vflg[CHARSETSIZE] = {0};	/* Debug flags */
int    Vflvl  = -1;	/* Debug function level, 0 should be prog name */
int    Vfshow = 1;	/* Levels to show in V output; -1 means Vlvl */
int    Vlvl   = 1;	/* Debug level, default is 1 (warnings only) */
int    Vl     = 0;	/* Debug level of most recent message */
char*  Vmodule= unknown;	/* Name of current module, if known */
char*  Vmsg   = null;	/* Error message */
Str    Voptstr= {"1",1};	/* Current debug option string */
int    VoptLvl= 0;	/* For preventing recursion in Vopt() */
FILE*  Vout  = 0;		/* Debug output file */
Flag   VshowLvl = 0;	/* Show the debug level */
Flag   Vshowtim = 0;	/* Show the current time */
Sizt   Vsizlim = 0;	/* Output file size limit */
global struct tm *Vtimep = 0;
TIMV   Vtimev = {0};	/* Latest timestamp */
TIMZ   Vtimez = {0};	/* The kernel's timezone, if known */
char*  Vtimh = 0;		/* ASCII version of latest time, starts with hour */
char*  Vtimm = 0;		/* ASCII version of latest time, starts with month */
char*  Vtimp = null;	/* ASCII version of latest time */
char*  Vtimy = 0;		/* ASCII version of latest time, starts with year */
char   Vtims[32];		/* Latest time, UT, ASCII */
char*  Vtimezone = 0;	/* Time zone; see Vtime() */
Flag   V_locking = 0;	/* Should we use pthread_lock_global_np? */

#if defined(USE_pthreads) && (USE_pthreads > 0)
global Flag V_pthreads = 0;	/* Are we debugging pthreads? */
#endif	/*USE_pthreads*/
global Flag use_pthreads = 0;	/* Run-time flag to enable use of pthreads */
global Flag use_poll     = 0;	/* Run-time flag to use poll() for I/O waits */
global Flag use_select   = 1;	/* Run-time flag to use select() for I/O waits */

Flag   Vchknull =  0;	/* If true, check for nulls */
int    Vmaxnull = 64;	/* Max length string of nulls */
int    Vlennull =  0;	/* Longest string of nulls so far */

/*
* These are a kludge used in the SNMP agent for switching  between  two  debug
* levels,  so  that we can have debugging enabled for some clients and not for
* others.  Is there a simple way to generalize this?
*/
int    dfltVlvl= 1;	/* Kludge by jc [90/7/10] */
int    realVlvl= 1;	/* Kludge by jc [90/7/10] */
/*
#include "pktime.h"
* Here is our list  of open files.  Note that we prime the list with our four
* (count 'em) default files, but they aren't yet marked open.  That should be
* done in Vinit(), when it checks out the entire OPEN_MAX list of files.
*/
char n_Vout[]   = "Vout";
char n_stderr[] = "stderr";
char n_stdout[] = "stdout";
char n_stdin[]  = "stdin";
File  d_Vout   = {0         ,{(CP)&n_Vout   ,4},3};
File  d_stderr = {&d_Vout   ,{(CP)&n_stderr ,6},2};
File  d_stdout = {&d_stderr ,{(CP)&n_stdout ,6},1};
File  d_stdin  = {&d_stdout ,{(CP)&n_stdin  ,5},0};
File *openfiles = &d_stdin;	/* List of open-file descriptors */
File *openfilez = &d_Vout;	/* Last of open-file descriptors */
int   openfilemax = 3;		/* Highest openfile list number */

/*
* Here are some useful "constant" strings.
*/
char  null[]    = "";			/* Should always be a null string */
char  unknown[] = "unknown";	/* Should always be "unknown" */
char* Fctname   = "?";			/* Name of current function */
/*
* Here are some useful "constant" integers.
*/
int   zero = 0;				/* Should always contain a 0 */
int   one  = 1;				/* Should always contain a 1 */
/*
* Here are some exit-status things:
*/
global char*  exitfile   = "?";  /* File name for ExitStat() */
global int    exitline   = 0;    /* Line number for ExitStat() */
global int    exitstat   = 0;    /* Exit code, nonzero for any failure */
global char m_exitstat[] = "Exit status set to %d in file %s line %d.";
/*
* And here are some brief "message" strings.
*/
char m_access []= "%s	### Can't %s %s \"%s\" [Err %d=%s=%s]";
char m_fctbad []= "### Wrong function name, should be \"%s\"[file %s line %d]";
char m_nomem  []= "%s	### Can't alloc %d bytes for %s [Err %d=%s=%s]";
char m_nothere[]= "### Not implemented here ###";
char m_null   []= "[NULL]";		/* What to show for null pointers */
char m_unknown[]= "[unknown]";
char m_unnamed[]= "[unnamed]";
