Commit 4e0484df 4e0484dff6d9d62f18e808cd76466a6323695828 by Sam Roberts

New function: debug_printv() to complement debug_print().

1 parent 2ca7e23d
......@@ -45,6 +45,8 @@ extern int debug_set_level __P ((debug_t, size_t level));
extern int debug_get_level __P ((debug_t, size_t *plevel));
extern int debug_print __P ((debug_t debug, size_t level,
const char *format, ...));
extern int debug_printv __P ((debug_t debug, size_t level,
const char *format, va_list argp));
extern int debug_set_print __P ((debug_t, int (*_print) __P ((debug_t, const char *, va_list)), void *owner));
#ifdef __cplusplus
......
......@@ -98,17 +98,29 @@ debug_print (debug_t debug, size_t level, const char *format, ...)
{
va_list ap;
va_start (ap, format);
debug_printv (debug, level, format, ap);
va_end (ap);
return 0;
}
int
debug_printv (debug_t debug, size_t level, const char *format, va_list ap)
{
if (debug == NULL || format == NULL)
return EINVAL;
if (!(debug->level & level))
return 0;
va_start (ap, format);
if (debug->_print)
debug->_print (debug, format, ap);
else
vfprintf (stderr, format, ap);
va_end (ap);
return 0;
}
......