From: Martin Mares Date: Fri, 31 Dec 2010 15:38:25 +0000 (+0100) Subject: Implemented --version X-Git-Tag: v1.13~12 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=6f436fe1021f801f29cee16af7f75358673374bc;p=nwho.git Implemented --version --- diff --git a/Makefile b/Makefile index 98a6d54..4ad4601 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,17 @@ # Makefile for the nwho toolkit -CFLAGS=-O2 -Wall -Wno-parentheses +VERSION=1.12 +CFLAGS=-O2 -Wall -Wno-parentheses -DVERSION=$(VERSION) LDFLAGS=-s ROOT=/ -REL=nwho-1.12 +REL=nwho-$(VERSION) all: nwhod nwho nwhod: nwhod.o - nwhod.o: nwhod.c nwho.h nwho: nwho.o - nwho.o: nwho.c nwho.h clean: diff --git a/nwho.c b/nwho.c index 3376803..6dfa7ab 100644 --- a/nwho.c +++ b/nwho.c @@ -136,6 +136,12 @@ scan(void) int main(int argc, char **argv) { + if (argc == 2 && !strcmp(argv[1], "--version")) + { + printf("nwho " STRINGIFY(VERSION) "\n"); + return 0; + } + if (strstr(argv[0], "uptime")) is_uptime = 1; if (argc != 1) diff --git a/nwho.h b/nwho.h index 23fdf30..1c22c54 100644 --- a/nwho.h +++ b/nwho.h @@ -37,3 +37,6 @@ struct nwho_pkt { #define DEFAULT_PRUNE_TIME 30 #define DEFAULT_DOWN_TIME 120 #define DEFAULT_DEAD_TIME 4*86400 + +#define STRINGIFY(x) STRINGIFY2(x) +#define STRINGIFY2(x) #x diff --git a/nwhod.c b/nwhod.c index 188bd6d..b5fc22d 100644 --- a/nwhod.c +++ b/nwhod.c @@ -368,6 +368,12 @@ client(char *serv) int main(int argc, char **argv) { + if (argc == 2 && !strcmp(argv[1], "--version")) + { + printf("nwho " STRINGIFY(VERSION) "\n"); + return 0; + } + if (argc == 2) client(argv[1]); else if (argc == 1)