Browse Source

The dynamic version definition in utilities.

git-svn-id: https://klish.googlecode.com/svn/trunk@231 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
2270083925
4 changed files with 14 additions and 26 deletions
  1. 1 1
      Makefile.am
  2. 1 1
      Makefile.in
  3. 6 12
      bin/konf.c
  4. 6 12
      bin/konfd.c

+ 1 - 1
Makefile.am

@@ -8,7 +8,7 @@ if DEBUG
   DEBUG_CFLAGS = -DDEBUG
 endif
 
-AM_CFLAGS               = -ansi -pedantic -Werror -Wall -D_POSIX_C_SOURCE=199309 $(DEBUG_CFLAGS)
+AM_CFLAGS               = -ansi -pedantic -Werror -Wall -D_POSIX_C_SOURCE=199309 -DVERSION=$(VERSION) $(DEBUG_CFLAGS)
 
 bin_PROGRAMS            =
 lib_LTLIBRARIES         =

+ 1 - 1
Makefile.in

@@ -677,7 +677,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc
 AM_CPPFLAGS = -I. -I$(top_srcdir)
 AM_LD = $(CXX)
 @DEBUG_TRUE@DEBUG_CFLAGS = -DDEBUG
-AM_CFLAGS = -ansi -pedantic -Werror -Wall -D_POSIX_C_SOURCE=199309 $(DEBUG_CFLAGS)
+AM_CFLAGS = -ansi -pedantic -Werror -Wall -D_POSIX_C_SOURCE=199309 -DVERSION=$(VERSION) $(DEBUG_CFLAGS)
 lib_LTLIBRARIES = libclish.la liblub.la $(am__append_3) libtinyrl.la \
 	libtinyxml.la libkonf.la
 lib_LIBRARIES = 

+ 6 - 12
bin/konf.c

@@ -20,11 +20,12 @@
 #endif
 #define MAXMSG 1024
 
-#define VER_MAJ 1
-#define VER_MIN 2
-#define VER_BUG 2
+#ifndef VERSION
+#define VERSION 1.2.2
+#endif
+#define QUOTE(t) #t
+#define version(v) printf("%s\n", QUOTE(v))
 
-static void version(void);
 static void help(int status, const char *argv0);
 
 static const char *escape_chars = "\"\\'";
@@ -65,7 +66,7 @@ int main(int argc, char **argv)
 			exit(0);
 			break;
 		case 'v':
-			version();
+			version(VERSION);
 			exit(0);
 			break;
 		default:
@@ -167,10 +168,3 @@ static void help(int status, const char *argv0)
 			"of the konfd daemon.\n");
 	}
 }
-
-/*--------------------------------------------------------- */
-/* Print version */
-static void version(void)
-{
-	printf("%u.%u.%u\n", VER_MAJ, VER_MIN, VER_BUG);
-}

+ 6 - 12
bin/konfd.c

@@ -25,9 +25,11 @@
 #include "lub/argv.h"
 #include "lub/string.h"
 
-#define VER_MAJ 1
-#define VER_MIN 2
-#define VER_BUG 2
+#ifndef VERSION
+#define VERSION 1.2.2
+#endif
+#define QUOTE(t) #t
+#define version(v) printf("%s\n", QUOTE(v))
 
 #define KONFD_CONFIG_PATH "/tmp/running-config"
 
@@ -42,7 +44,6 @@
 static volatile int sigterm = 0;
 static void sighandler(int signo);
 
-static void version(void);
 static void help(int status, const char *argv0);
 static char * process_query(int sock, konf_tree_t * conf, char *str);
 int answer_send(int sock, char *command);
@@ -95,7 +96,7 @@ int main(int argc, char **argv)
 			exit(0);
 			break;
 		case 'v':
-			version();
+			version(VERSION);
 			exit(0);
 			break;
 		default:
@@ -417,10 +418,3 @@ static void help(int status, const char *argv0)
 			"filesystem path to listen on.\n");
 	}
 }
-
-/*--------------------------------------------------------- */
-/* Print version */
-static void version(void)
-{
-	printf("%u.%u.%u\n", VER_MAJ, VER_MIN, VER_BUG);
-}