aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--log.c48
-rw-r--r--log.h10
-rw-r--r--nldev.c44
4 files changed, 61 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 54cab33..e28138f 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
include config.mk
SRC = ${NAME}.c
-OBJ = ${SRC:.c=.o}
+OBJ = ${SRC:.c=.o} log.o
all: options ${NAME}
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");
+ }
+}
diff --git a/log.h b/log.h
new file mode 100644
index 0000000..949ecce
--- /dev/null
+++ b/log.h
@@ -0,0 +1,10 @@
+
+#include <stdarg.h>
+
+#include "arg.h"
+
+void edie(char *fmt, ...);
+void die(char *fmt, ...);
+void dbg(char *fmt, ...);
+
+extern int dodebug;
diff --git a/nldev.c b/nldev.c
index 72c9656..eab53ff 100644
--- a/nldev.c
+++ b/nldev.c
@@ -22,51 +22,11 @@
#include <linux/netlink.h>
#include "arg.h"
+#include "log.h"
char *argv0;
int listfd = -1;
-int dofork = 0, 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");
- }
-}
+int dofork = 0;
void
disableoom(void)