From de3ceebeb4d24658fef4412d7b307a7897e00d6e Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 22 Oct 1999 22:39:52 +0000 Subject: [PATCH] New documented interface for tracing. Organization: Straylight/Edgeware From: mdw --- trace.c | 25 ++++++++++++++----------- trace.h | 52 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/trace.c b/trace.c index c1688ef..9e1cf0f 100644 --- a/trace.c +++ b/trace.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: trace.c,v 1.4 1999/05/19 20:27:11 mdw Exp $ + * $Id: trace.c,v 1.5 1999/10/22 22:39:52 mdw Exp $ * * Tracing functions for debugging * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: trace.c,v $ + * Revision 1.5 1999/10/22 22:39:52 mdw + * New documented interface for tracing. + * * Revision 1.4 1999/05/19 20:27:11 mdw * Change naming to match newer mLib conventions. * @@ -62,13 +65,13 @@ /*----- Private state information -----------------------------------------*/ static FILE *tracefp = 0; /* Where does debugging go? */ -static unsigned int tracelvl = 0; /* How much tracing gets done? */ +static unsigned tracelvl = 0; /* How much tracing gets done? */ /*----- Functions provided ------------------------------------------------*/ /* --- @trace@ --- * * - * Arguments: @unsigned int l@ = trace level for output + * Arguments: @unsigned l@ = trace level for output * @const char *f@ = a @printf@-style format string * @...@ = other arguments * @@ -77,7 +80,7 @@ static unsigned int tracelvl = 0; /* How much tracing gets done? */ * Use: Reports a message to the trace output. */ -void trace(unsigned int l, const char *f, ...) +void trace(unsigned l, const char *f, ...) { va_list ap; if ((l & tracing()) == 0) @@ -92,7 +95,7 @@ void trace(unsigned int l, const char *f, ...) /* --- @trace_block@ --- * * - * Arguments: @unsigned int l@ = trace level for output + * Arguments: @unsigned l@ = trace level for output * @const char *s@ = some header string to write * @const void *b@ = pointer to a block of memory to dump * @size_t sz@ = size of the block of memory @@ -102,7 +105,7 @@ void trace(unsigned int l, const char *f, ...) * Use: Dumps the contents of a block to the trace output. */ -void trace_block(unsigned int l, const char *s, const void *b, size_t sz) +void trace_block(unsigned l, const char *s, const void *b, size_t sz) { const unsigned char *p = b; size_t i; @@ -143,14 +146,14 @@ void trace_block(unsigned int l, const char *s, const void *b, size_t sz) /* --- @trace_on@ --- * * * Arguments: @FILE *fp@ = a file to trace on - * @unsigned int l@ = trace level to set + * @unsigned l@ = trace level to set * * Returns: --- * * Use: Enables tracing to a file. */ -void trace_on(FILE *fp, unsigned int l) +void trace_on(FILE *fp, unsigned l) { tracefp = fp; if (!tracelvl) @@ -159,14 +162,14 @@ void trace_on(FILE *fp, unsigned int l) /* --- @trace_setLevel@ --- * * - * Arguments: @unsigned int l@ = trace level to set + * Arguments: @unsigned l@ = trace level to set * * Returns: --- * * Use: Sets the tracing level. */ -void trace_setLevel(unsigned int l) +void trace_setLevel(unsigned l) { tracelvl = l; } @@ -180,7 +183,7 @@ void trace_setLevel(unsigned int l) * Use: Informs the caller whether tracing is enabled. */ -unsigned int tracing(void) +unsigned tracing(void) { return (tracefp ? tracelvl : 0u); } diff --git a/trace.h b/trace.h index 591f69f..1e02a26 100644 --- a/trace.h +++ b/trace.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: trace.h,v 1.3 1999/05/06 19:51:35 mdw Exp $ + * $Id: trace.h,v 1.4 1999/10/22 22:39:52 mdw Exp $ * * Tracing functions for debugging * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: trace.h,v $ + * Revision 1.4 1999/10/22 22:39:52 mdw + * New documented interface for tracing. + * * Revision 1.3 1999/05/06 19:51:35 mdw * Reformatted the LGPL notice a little bit. * @@ -48,13 +51,23 @@ extern "C" { #endif +/*----- Header files ------------------------------------------------------*/ + #include +/*----- Data structures ---------------------------------------------------*/ + +typedef struct trace_opt { + char ch; + unsigned f; + const char *help; +} trace_opt; + /*----- Functions provided ------------------------------------------------*/ /* --- @trace@ --- * * - * Arguments: @unsigned int l@ = trace level for output + * Arguments: @unsigned l@ = trace level for output * @const char *f@ = a @printf@-style format string * @...@ = other arguments * @@ -63,11 +76,11 @@ * Use: Reports a message to the trace output. */ -extern void trace(unsigned int /*l*/, const char */*f*/, ...); +extern void trace(unsigned /*l*/, const char */*f*/, ...); /* --- @trace_block@ --- * * - * Arguments: @unsigned int l@ = trace level for output + * Arguments: @unsigned l@ = trace level for output * @const char *s@ = some header string to write * @const void *b@ = pointer to a block of memory to dump * @size_t sz@ = size of the block of memory @@ -77,31 +90,31 @@ extern void trace(unsigned int /*l*/, const char */*f*/, ...); * Use: Dumps the contents of a block to the trace output. */ -extern void trace_block(unsigned int /*l*/, const char */*s*/, +extern void trace_block(unsigned /*l*/, const char */*s*/, const void */*b*/, size_t /*sz*/); /* --- @trace_on@ --- * * * Arguments: @FILE *fp@ = a file to trace on - * @unsigned int l@ = trace level to set + * @unsigned l@ = trace level to set * * Returns: --- * * Use: Enables tracing to a file. */ -extern void trace_on(FILE */*fp*/, unsigned int /*l*/); +extern void trace_on(FILE */*fp*/, unsigned /*l*/); -/* --- @trace_setLevel@ --- * +/* --- @trace_level@ --- * * - * Arguments: @unsigned int l@ = trace level to set + * Arguments: @unsigned l@ = trace level to set * * Returns: --- * * Use: Sets the tracing level. */ -extern void trace_setLevel(unsigned int /*l*/); +extern void trace_level(unsigned /*l*/); /* --- @tracing@ --- * * @@ -112,7 +125,24 @@ extern void trace_setLevel(unsigned int /*l*/); * Use: Informs the caller whether tracing is enabled. */ -extern unsigned int tracing(void); +extern unsigned tracing(void); + +/* --- @traceopt@ --- * + * + * Arguments: @trace_opt *t@ = pointer to trace options table + * @const char *p@ = option string supplied by user + * @unsigned f@ = initial tracing flags + * @unsigned bad@ = forbidden tracing flags + * + * Returns: Trace flags as set by user. + * + * Use: Parses an option string from the user and sets the + * appropriate trace flags. If the argument is null or a single + * `?' character, a help message is displayed. + */ + +extern unsigned traceopt(trace_opt */*t*/, const char */*p*/, + unsigned /*f*/, unsigned /*bad*/); /*----- Tracing macros ----------------------------------------------------*/ -- [mdw]