Commit 14b3895a authored by Niels Möller's avatar Niels Möller
Browse files

New functions debug(), debug_safe() and werror_safe(). New global

variables quiet_flag and debug_flag.

Rev: src/werror.c:1.2
parent 43da4e84
......@@ -7,13 +7,73 @@
#include <stdio.h>
#include <stdarg.h>
int debug_flag = 0;
int quiet_flag = 0;
void werror(char *format, ...)
{
va_list args;
if (!quiet_flag)
{
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
}
void debug(char *format, ...)
{
va_list args;
if (debug_flag)
{
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
}
/* Escape non-printable characters. */
void werror_washed(UINT32 length, UINT8 *msg)
{
int i;
for(i = 0; i<lengh; i++)
{
switch(msg[i])
{
case '\\':
fputs("\\\\", stderr);
break;
case '\r':
/* Ignore */
break;
default:
if (!isprint(msg[i]))
{
fprintf("\\x%2x", msg[i]);
break;
}
/* Fall through */
case '\n':
putc('\n', stderr);
break;
}
}
}
/* For outputting data recieved from the other end */
void werror_safe(UINT32 length, UINT8 *msg)
{
if (!quiet_flag)
werror_washed(length, msg);
}
void debug_safe(UINT32 length, UINT8 *msg)
{
if (debug_flag)
werror_washed(length, msg);
}
void fatal(char *format, ...)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment