]> mj.ucw.cz Git - nwho.git/commitdiff
Implemented --version
authorMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:38:25 +0000 (16:38 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:38:25 +0000 (16:38 +0100)
Makefile
nwho.c
nwho.h
nwhod.c

index 98a6d5449d1b10372b88803e3798e4eea2b12c0c..4ad4601315a12d452e373c6bb29f6dde384ba96a 100644 (file)
--- 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 33768033398a98fc2e20165fb5f6d66ba8ba44cb..6dfa7ab2c95d10306f53b59dfd7e0629caf7d10a 100644 (file)
--- 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 23fdf3088f09bf5b986752a6b9fc92347cc8ecbb..1c22c54f4e611b14768e0b6e7e49d9b4509d0dad 100644 (file)
--- 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 188bd6d781e116d23ab78ac3fce3ec66d0ccbf0a..b5fc22d288df218a6a023ffbfef165e28da99506 100644 (file)
--- 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)