New function: debug_printv() to complement debug_print().
Showing
2 changed files
with
16 additions
and
2 deletions
... | @@ -45,6 +45,8 @@ extern int debug_set_level __P ((debug_t, size_t level)); | ... | @@ -45,6 +45,8 @@ extern int debug_set_level __P ((debug_t, size_t level)); |
45 | extern int debug_get_level __P ((debug_t, size_t *plevel)); | 45 | extern int debug_get_level __P ((debug_t, size_t *plevel)); |
46 | extern int debug_print __P ((debug_t debug, size_t level, | 46 | extern int debug_print __P ((debug_t debug, size_t level, |
47 | const char *format, ...)); | 47 | const char *format, ...)); |
48 | extern int debug_printv __P ((debug_t debug, size_t level, | ||
49 | const char *format, va_list argp)); | ||
48 | extern int debug_set_print __P ((debug_t, int (*_print) __P ((debug_t, const char *, va_list)), void *owner)); | 50 | extern int debug_set_print __P ((debug_t, int (*_print) __P ((debug_t, const char *, va_list)), void *owner)); |
49 | 51 | ||
50 | #ifdef __cplusplus | 52 | #ifdef __cplusplus | ... | ... |
... | @@ -98,17 +98,29 @@ debug_print (debug_t debug, size_t level, const char *format, ...) | ... | @@ -98,17 +98,29 @@ debug_print (debug_t debug, size_t level, const char *format, ...) |
98 | { | 98 | { |
99 | va_list ap; | 99 | va_list ap; |
100 | 100 | ||
101 | va_start (ap, format); | ||
102 | |||
103 | debug_printv (debug, level, format, ap); | ||
104 | |||
105 | va_end (ap); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | int | ||
111 | debug_printv (debug_t debug, size_t level, const char *format, va_list ap) | ||
112 | { | ||
101 | if (debug == NULL || format == NULL) | 113 | if (debug == NULL || format == NULL) |
102 | return EINVAL; | 114 | return EINVAL; |
103 | 115 | ||
104 | if (!(debug->level & level)) | 116 | if (!(debug->level & level)) |
105 | return 0; | 117 | return 0; |
106 | 118 | ||
107 | va_start (ap, format); | ||
108 | if (debug->_print) | 119 | if (debug->_print) |
109 | debug->_print (debug, format, ap); | 120 | debug->_print (debug, format, ap); |
110 | else | 121 | else |
111 | vfprintf (stderr, format, ap); | 122 | vfprintf (stderr, format, ap); |
112 | va_end (ap); | 123 | |
113 | return 0; | 124 | return 0; |
114 | } | 125 | } |
126 | ... | ... |
-
Please register or sign in to post a comment