Commit 404a5250 authored by Niels Möller's avatar Niels Möller
Browse files

Addedverbose() and verbose_safe() methods.

Rev: src/werror.c:1.5
Rev: src/werror.h:1.4
parent 3a9b7529
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
int debug_flag = 0; int debug_flag = 0;
int quiet_flag = 0; int quiet_flag = 0;
int verbose_flag = 0;
void werror(char *format, ...) void werror(char *format, ...)
{ {
...@@ -35,6 +36,18 @@ void debug(char *format, ...) ...@@ -35,6 +36,18 @@ void debug(char *format, ...)
} }
} }
void verbose(char *format, ...)
{
va_list args;
if (verbose_flag)
{
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
}
/* Escape non-printable characters. */ /* Escape non-printable characters. */
void werror_washed(UINT32 length, UINT8 *msg) void werror_washed(UINT32 length, UINT8 *msg)
{ {
...@@ -53,7 +66,7 @@ void werror_washed(UINT32 length, UINT8 *msg) ...@@ -53,7 +66,7 @@ void werror_washed(UINT32 length, UINT8 *msg)
default: default:
if (!isprint(msg[i])) if (!isprint(msg[i]))
{ {
fprintf(stderr, "\\x%2x", msg[i]); fprintf(stderr, "\\x%02x", msg[i]);
break; break;
} }
/* Fall through */ /* Fall through */
...@@ -77,6 +90,12 @@ void debug_safe(UINT32 length, UINT8 *msg) ...@@ -77,6 +90,12 @@ void debug_safe(UINT32 length, UINT8 *msg)
werror_washed(length, msg); werror_washed(length, msg);
} }
void verbose_safe(UINT32 length, UINT8 *msg)
{
if (verbose_flag)
werror_washed(length, msg);
}
void fatal(char *format, ...) void fatal(char *format, ...)
{ {
va_list args; va_list args;
......
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
/* Global variables */ /* Global variables */
extern int debug_flag; extern int debug_flag;
extern int quiet_flag; extern int quiet_flag;
extern int verbose_flag;
void werror(char *format, ...) PRINTF_STYLE(1,2); void werror(char *format, ...) PRINTF_STYLE(1,2);
void debug(char *format, ...) PRINTF_STYLE(1,2); void debug(char *format, ...) PRINTF_STYLE(1,2);
void verbose(char *format, ...) PRINTF_STYLE(1,2);
/* For outputting data recieved from the other end */ /* For outputting data recieved from the other end */
void werror_safe(UINT32 length, UINT8 *msg); void werror_safe(UINT32 length, UINT8 *msg);
void debug_safe(UINT32 length, UINT8 *msg); void debug_safe(UINT32 length, UINT8 *msg);
void verbose_safe(UINT32 length, UINT8 *msg);
void fatal(char *format, ...) PRINTF_STYLE(1,2) NORETURN; void fatal(char *format, ...) PRINTF_STYLE(1,2) NORETURN;
......
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