]> mj.ucw.cz Git - nwho.git/commitdiff
Let die() be shared between nwho and nwhod
authorMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:56:08 +0000 (16:56 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:56:08 +0000 (16:56 +0100)
Makefile
nwho.h
nwhod.c
util.c [new file with mode: 0644]

index 4ad4601315a12d452e373c6bb29f6dde384ba96a..bafcc26d2515b9efa0ad785456e76d7db800ab19 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,10 +8,11 @@ REL=nwho-$(VERSION)
 
 all: nwhod nwho
 
-nwhod: nwhod.o
+nwhod: nwhod.o util.o
 nwhod.o: nwhod.c nwho.h
+util.o: util.c nwho.h
 
-nwho: nwho.o
+nwho: nwho.o util.o
 nwho.o: nwho.c nwho.h
 
 clean:
diff --git a/nwho.h b/nwho.h
index 91a4e73c99cd418061b4d9e82b780af8dec0aa44..69bc7a469b5ea3bc8aceca1dd4541b34487cb326 100644 (file)
--- a/nwho.h
+++ b/nwho.h
@@ -46,3 +46,7 @@ static inline int nwho_pkt_size(struct nwho_pkt *pkt)
 {
   return sizeof(struct nwho_pkt) - (MAX_USERS - ntohl(pkt->num_users))*sizeof(struct userinfo);
 }
+
+/* util.c */
+
+void die(char *msg, ...) __attribute__((noreturn));
diff --git a/nwhod.c b/nwhod.c
index 02e6a3f825e34f8e5e3792b654abb2dd6c111968..878db6b3844247f7a0b24b8f9e2a64b5fe7ee8a5 100644 (file)
--- a/nwhod.c
+++ b/nwhod.c
@@ -7,7 +7,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdarg.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/socket.h>
@@ -36,20 +35,6 @@ static struct hostrec *first_host;
 static time_t now, last_local_scan;
 static char hostname[64];
 
-static void die(char *msg, ...) __attribute__((noreturn));
-
-static void
-die(char *msg, ...)
-{
-  va_list args;
-
-  va_start(args, msg);
-  fprintf(stderr, "nwhod: ");
-  vfprintf(stderr, msg, args);
-  fputc('\n', stderr);
-  exit(1);
-}
-
 static void
 net_init(char *name)
 {
diff --git a/util.c b/util.c
new file mode 100644 (file)
index 0000000..0b4a57a
--- /dev/null
+++ b/util.c
@@ -0,0 +1,24 @@
+/*
+ *     The Remote User Information Lister -- Utility Functions
+ *
+ *     (c) 1997--2010 Martin Mares <mj@ucw.cz>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "nwho.h"
+
+void
+die(char *msg, ...)
+{
+  va_list args;
+
+  va_start(args, msg);
+  fprintf(stderr, "nwhod: ");
+  vfprintf(stderr, msg, args);
+  fputc('\n', stderr);
+  exit(1);
+}
+