Committer: Diego Biurrun <diego@xxxxxxxxxx> Date: 09/04/2010 at 21:51:49 Revision: 4227 Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Add standard -V option to hipd, hipagent and hipfw. This prints the HIPL version, Bazaar revision and build configuration. Modified: A lib/core/util.c A lib/core/util.h M Makefile.am M agent/agent.c M firewall/firewall.c M hipd/hipd.c === modified file 'Makefile.am' --- Makefile.am 2010-04-09 17:56:34 +0000 +++ Makefile.am 2010-04-09 18:50:26 +0000 @@ -245,6 +245,7 @@ lib/core/sqlitedbapi.c \ lib/core/straddr.c \ lib/core/transform.c \ + lib/core/util.c \ lib/tool/checksum.c \ lib/tool/lutil.c \ lib/tool/nlink.c \ === modified file 'agent/agent.c' --- agent/agent.c 2010-04-07 13:59:14 +0000 +++ agent/agent.c 2010-04-09 18:50:26 +0000 @@ -37,6 +37,7 @@ #include "language.h" #include "lib/core/hip_capability.h" #include "lib/core/sqlitedbapi.h" +#include "lib/core/util.h" #include "lib/gui/hipgui.h" @@ -198,9 +199,11 @@ signal(SIGTERM, sig_catch_term); /* Parse command line options. */ - while ((c = getopt(argc, argv, ":hl")) != -1) { + while ((c = getopt(argc, argv, ":hlV")) != -1) { switch (c) { case ':': + case 'V': + hip_print_version("hipagent"); case 'h': fprintf(stderr, "no help available currently\n"); goto out_err; === modified file 'firewall/firewall.c' --- firewall/firewall.c 2010-04-09 17:56:34 +0000 +++ firewall/firewall.c 2010-04-09 18:50:26 +0000 @@ -52,6 +52,7 @@ #include "helpers.h" #include "lib/core/filemanip.h" #include "lib/core/performance.h" +#include "lib/core/util.h" /* packet types handled by the firewall */ #define OTHER_PACKET 0 @@ -2199,7 +2200,7 @@ hip_set_logdebug(LOGDEBUG_ALL); - while ((ch = getopt(argc, argv, "aAbcdef:FhHiIklmopv")) != -1) { + while ((ch = getopt(argc, argv, "aAbcdef:FhHiIklmopvV")) != -1) { switch (ch) { case 'A': accept_hip_esp_traffic_by_default = 1; @@ -2259,6 +2260,8 @@ log_level = LOGDEBUG_MEDIUM; hip_set_logfmt(LOGFMT_SHORT); break; + case 'V': + hip_print_version("hipfw"); case ':': /* option without operand */ printf("Option -%c requires an operand\n", optopt); errflg++; === modified file 'hipd/hipd.c' --- hipd/hipd.c 2010-04-09 17:56:34 +0000 +++ hipd/hipd.c 2010-04-09 18:50:26 +0000 @@ -15,6 +15,7 @@ #include "lib/core/filemanip.h" #include "lib/core/performance.h" #include "lib/core/straddr.h" +#include "lib/core/util.h" #include "heartbeat.h" @@ -401,7 +402,7 @@ hip_set_logfmt(LOGFMT_LONG); /* Parse command-line options */ - while ((ch = getopt(argc, argv, ":bi:kNchaf")) != -1) { + while ((ch = getopt(argc, argv, ":bi:kNchafV")) != -1) { switch (ch) { case 'b': foreground = 0; @@ -430,6 +431,8 @@ HIP_INFO("Setting output format to short\n"); hip_set_logfmt(LOGFMT_SHORT); break; + case 'V': + hip_print_version("hipd"); case '?': case 'h': default: === added file 'lib/core/util.c' --- lib/core/util.c 1970-01-01 00:00:00 +0000 +++ lib/core/util.c 2010-04-09 18:50:26 +0000 @@ -0,0 +1,20 @@ +/** @file + * utility functions + * @author Diego Biurrun <diego@xxxxxxxxxx> + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "config.h" +#include "version.h" + +/** + * Print version information to stdout. + */ +int hip_print_version(const char *name) +{ + printf("%s %s (Bazaar revision %s)\n", name, VERSION, BZR_REVISION); + printf("build configuration: %s\n", HIPL_CONFIGURATION); + exit(EXIT_SUCCESS); +} === added file 'lib/core/util.h' --- lib/core/util.h 1970-01-01 00:00:00 +0000 +++ lib/core/util.h 2010-04-09 18:50:26 +0000 @@ -0,0 +1,11 @@ +/** @file + * utility functions + * @author Diego Biurrun <diego@xxxxxxxxxx> + */ + +#ifndef HIP_LIB_CORE_UTIL_H +#define HIP_LIB_CORE_UTIL_H + +int hip_print_version(const char *name); + +#endif /* HIP_LIB_CORE_UTIL_H */