diff options
author | Linus Nordberg <linus@nordberg.se> | 2010-05-28 14:58:08 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2010-05-28 14:58:08 +0200 |
commit | 17f018e2cfc08146f427b82740c686f4a5024272 (patch) | |
tree | 87d440270a3dd09f1594f32713dd8fb1645583d5 /debug.c | |
parent | 9b8862284cdab3fca45eb539a07938fa651e7562 (diff) |
* debug.c (debugerrno): New function.
(debugerrnox): New function.
* radsecproxy.c: Use debugerrno() and debugerrnox() when appropriate.
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -18,6 +18,7 @@ #include <sys/time.h> #include <syslog.h> #include <errno.h> +#include <assert.h> #include "debug.h" #include "util.h" @@ -178,6 +179,33 @@ void debugx(int status, uint8_t level, char *format, ...) { exit(status); } +void debugerrno(int err, uint8_t level, char *format, ...) { + if (level >= debug_level) { + va_list ap; + size_t len = strlen(format); + char *tmp = malloc(len + 1024 + 2); + assert(tmp); + strcpy(tmp, format); + tmp[len++] = ':'; + tmp[len++] = ' '; + if (strerror_r(err, tmp + len, 1024)) + tmp = format; + va_start(ap, format); + debug_logit(level, tmp, ap); + va_end(ap); + } +} + +void debugerrnox(int err, uint8_t level, char *format, ...) { + if (level >= debug_level) { + va_list ap; + va_start(ap, format); + debugerrno(err, level, format, ap); + va_end(ap); + } + exit(err); +} + /* Local Variables: */ /* c-file-style: "stroustrup" */ /* End: */ |