summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2010-05-28 14:58:08 +0200
committerLinus Nordberg <linus@nordberg.se>2010-05-28 14:58:08 +0200
commit17f018e2cfc08146f427b82740c686f4a5024272 (patch)
tree87d440270a3dd09f1594f32713dd8fb1645583d5 /debug.c
parent9b8862284cdab3fca45eb539a07938fa651e7562 (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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/debug.c b/debug.c
index b8c7ed1..a01c2dc 100644
--- a/debug.c
+++ b/debug.c
@@ -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: */