Commit 6b10a54f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement kdebugf.

parent 6f66e559
...@@ -133,11 +133,11 @@ timeval_min_sec(struct timeval *d, int secs) ...@@ -133,11 +133,11 @@ timeval_min_sec(struct timeval *d, int secs)
} }
void void
do_debugf(const char *format, ...) do_debugf(int level, const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
if(debug >= 2) if(debug >= level)
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fflush(stderr); fflush(stderr);
......
...@@ -36,7 +36,8 @@ int timeval_compare(const struct timeval *s1, const struct timeval *s2) ...@@ -36,7 +36,8 @@ int timeval_compare(const struct timeval *s1, const struct timeval *s2)
ATTRIBUTE ((pure)); ATTRIBUTE ((pure));
void timeval_min(struct timeval *d, const struct timeval *s); void timeval_min(struct timeval *d, const struct timeval *s);
void timeval_min_sec(struct timeval *d, int secs); void timeval_min_sec(struct timeval *d, int secs);
void do_debugf(const char *format, ...) ATTRIBUTE ((format (printf, 1, 2))); void do_debugf(int leve, const char *format, ...)
ATTRIBUTE ((format (printf, 2, 3)));
int in_prefix(const unsigned char *address, int in_prefix(const unsigned char *address,
const unsigned char *prefix, unsigned char plen) const unsigned char *prefix, unsigned char plen)
ATTRIBUTE ((pure)); ATTRIBUTE ((pure));
...@@ -58,12 +59,20 @@ void v4tov6(unsigned char *dst, const unsigned char *src); ...@@ -58,12 +59,20 @@ void v4tov6(unsigned char *dst, const unsigned char *src);
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#define debugf(...) \ #define debugf(...) \
do { \ do { \
if(debug >= 2) do_debugf(__VA_ARGS__); \ if(debug >= 2) do_debugf(2, __VA_ARGS__); \
} while(0)
#define kdebugf(...) \
do { \
if(debug >= 3) do_debugf(3, __VA_ARGS__); \
} while(0) } while(0)
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define debugf(_args...) \ #define debugf(_args...) \
do { \ do { \
if(debug >= 2) do_debugf(_args); \ if(debug >= 2) do_debugf(2, _args); \
} while(0)
#define kdebugf(_args...) \
do { \
if(debug >= 3) do_debugf(3, _args); \
} while(0) } while(0)
#else #else
#define debugf do_debugf #define debugf do_debugf
......
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