chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generate the CRC table rather than hardcoding it.
[mLib]
/
trace.c
diff --git
a/trace.c
b/trace.c
index d5bdcb7a2b3cf9403ec2aedaf4f3c6663727a767..9e1cf0f11fc3b08dd248fd4bc27140f7dd568850 100644
(file)
--- a/
trace.c
+++ b/
trace.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: trace.c,v 1.
3 1999/05/06 19:51:35
mdw Exp $
+ * $Id: trace.c,v 1.
5 1999/10/22 22:39:52
mdw Exp $
*
* Tracing functions for debugging
*
*
* Tracing functions for debugging
*
@@
-30,6
+30,12
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: trace.c,v $
/*----- 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.
+ *
* Revision 1.3 1999/05/06 19:51:35 mdw
* Reformatted the LGPL notice a little bit.
*
* Revision 1.3 1999/05/06 19:51:35 mdw
* Reformatted the LGPL notice a little bit.
*
@@
-58,14
+64,14
@@
/*----- Private state information -----------------------------------------*/
/*----- Private state information -----------------------------------------*/
-static FILE *trace
__fp = 0;
/* Where does debugging go? */
-static unsigned
int trace__lvl = 0;
/* How much tracing gets done? */
+static FILE *trace
fp = 0;
/* Where does debugging go? */
+static unsigned
tracelvl = 0;
/* How much tracing gets done? */
/*----- Functions provided ------------------------------------------------*/
/* --- @trace@ --- *
*
/*----- 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
*
* @const char *f@ = a @printf@-style format string
* @...@ = other arguments
*
@@
-74,22
+80,22
@@
static unsigned int trace__lvl = 0; /* How much tracing gets done? */
* Use: Reports a message to the trace output.
*/
* 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)
return;
va_start(ap, f);
{
va_list ap;
if ((l & tracing()) == 0)
return;
va_start(ap, f);
- fprintf(trace
__
fp, "*** %s: ", QUIS);
- vfprintf(trace
__
fp, f, ap);
+ fprintf(tracefp, "*** %s: ", QUIS);
+ vfprintf(tracefp, f, ap);
va_end(ap);
va_end(ap);
- putc('\n', trace
__
fp);
- fflush(trace
__
fp);
+ putc('\n', tracefp);
+ fflush(tracefp);
}
/* --- @trace_block@ --- *
*
}
/* --- @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
* @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
@@
-99,7
+105,7
@@
void trace(unsigned int l, const char *f, ...)
* Use: Dumps the contents of a block to the trace output.
*/
* 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;
{
const unsigned char *p = b;
size_t i;
@@
-113,59
+119,59
@@
void trace_block(unsigned int l, const char *s, const void *b, size_t sz)
/* --- Now start work --- */
/* --- Now start work --- */
- fprintf(trace
__
fp, "*** %s: %s\n", QUIS, s);
+ fprintf(tracefp, "*** %s: %s\n", QUIS, s);
while (sz) {
while (sz) {
- fprintf(trace
__
fp, "*** %s: %08lx : ", QUIS, o);
+ fprintf(tracefp, "*** %s: %08lx : ", QUIS, o);
for (i = 0; i < 8; i++) {
if (i < sz)
for (i = 0; i < 8; i++) {
if (i < sz)
- fprintf(trace
__
fp, "%02x ", p[i]);
+ fprintf(tracefp, "%02x ", p[i]);
else
else
- fputs("** ", trace
__
fp);
+ fputs("** ", tracefp);
}
}
- fputs(": ", trace
__
fp);
+ fputs(": ", tracefp);
for (i = 0; i < 8; i++) {
if (i < sz)
for (i = 0; i < 8; i++) {
if (i < sz)
- fputc(isprint(p[i]) ? p[i] : '.', trace
__
fp);
+ fputc(isprint(p[i]) ? p[i] : '.', tracefp);
else
else
- fputc('*', trace
__
fp);
+ fputc('*', tracefp);
}
}
- fputc('\n', trace
__
fp);
+ fputc('\n', tracefp);
c = (sz >= 8) ? 8 : sz;
sz -= c, p += c, o += c;
}
c = (sz >= 8) ? 8 : sz;
sz -= c, p += c, o += c;
}
- fflush(trace
__
fp);
+ fflush(tracefp);
}
/* --- @trace_on@ --- *
*
* Arguments: @FILE *fp@ = a file to trace on
}
/* --- @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.
*/
*
* Returns: ---
*
* Use: Enables tracing to a file.
*/
-void trace_on(FILE *fp, unsigned
int
l)
+void trace_on(FILE *fp, unsigned l)
{
{
- trace
__
fp = fp;
- if (!trace
__
lvl)
- trace
__
lvl = l;
+ tracefp = fp;
+ if (!tracelvl)
+ tracelvl = l;
}
/* --- @trace_setLevel@ --- *
*
}
/* --- @trace_setLevel@ --- *
*
- * Arguments: @unsigned
int
l@ = trace level to set
+ * Arguments: @unsigned l@ = trace level to set
*
* Returns: ---
*
* Use: Sets the tracing level.
*/
*
* Returns: ---
*
* Use: Sets the tracing level.
*/
-void trace_setLevel(unsigned
int
l)
+void trace_setLevel(unsigned l)
{
{
- trace
__
lvl = l;
+ tracelvl = l;
}
/* --- @tracing@ --- *
}
/* --- @tracing@ --- *
@@
-177,9
+183,9
@@
void trace_setLevel(unsigned int l)
* Use: Informs the caller whether tracing is enabled.
*/
* Use: Informs the caller whether tracing is enabled.
*/
-unsigned
int
tracing(void)
+unsigned tracing(void)
{
{
- return (trace
__fp ? trace__
lvl : 0u);
+ return (trace
fp ? trace
lvl : 0u);
}
/*----- That's all, folks -------------------------------------------------*/
}
/*----- That's all, folks -------------------------------------------------*/