From: Martin Mares Date: Fri, 31 Dec 2010 15:56:08 +0000 (+0100) Subject: Let die() be shared between nwho and nwhod X-Git-Tag: v1.13~9 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=a04f8cb95fe47572dbddbcdeb28a1b586abf713c;p=nwho.git Let die() be shared between nwho and nwhod --- diff --git a/Makefile b/Makefile index 4ad4601..bafcc26 100644 --- 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 91a4e73..69bc7a4 100644 --- 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 02e6a3f..878db6b 100644 --- a/nwhod.c +++ b/nwhod.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -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 index 0000000..0b4a57a --- /dev/null +++ b/util.c @@ -0,0 +1,24 @@ +/* + * The Remote User Information Lister -- Utility Functions + * + * (c) 1997--2010 Martin Mares + */ + +#include +#include +#include + +#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); +} +