aboutsummaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/log.c b/log.c
new file mode 100644
index 0000000..ef518cd
--- /dev/null
+++ b/log.c
@@ -0,0 +1,48 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "log.h"
+
+int dodebug = 0;
+
+void
+edie(char *fmt, ...)
+{
+ va_list fmtargs;
+
+ va_start(fmtargs, fmt);
+ vfprintf(stderr, fmt, fmtargs);
+ va_end(fmtargs);
+ fprintf(stderr, ": ");
+
+ perror(NULL);
+
+ exit(1);
+}
+
+void
+die(char *fmt, ...)
+{
+ va_list fmtargs;
+
+ va_start(fmtargs, fmt);
+ vfprintf(stderr, fmt, fmtargs);
+ va_end(fmtargs);
+
+ exit(1);
+}
+
+void
+dbg(char *fmt, ...)
+{
+ va_list fmtargs;
+
+ if (dodebug) {
+ fprintf(stderr, "%s: ", argv0);
+ va_start(fmtargs, fmt);
+ vfprintf(stderr, fmt, fmtargs);
+ va_end(fmtargs);
+ fprintf(stderr, "\n");
+ }
+}