Committer: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx> Date: 03/05/2010 at 20:13:59 Revision: 4458 Revision-id: mircea.gherzan@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: libhipcore: move and fix hip_print_version. A function named like this shoud _not_ call exit(3), even it's documented in the doxy-comment (it was not the case). Such "flow control" decisions should only be taken by its caller. Even more, a function with just 2 statements does not deserve its own source file, therefore relocate it as "static inline" to the corresponding header file. Modified: D lib/core/util.c M Makefile.am M agent/agent.c M firewall/firewall.c M hipd/hipd.c M lib/core/util.h === modified file 'Makefile.am' --- Makefile.am 2010-05-03 16:43:45 +0000 +++ Makefile.am 2010-05-03 17:08:15 +0000 @@ -243,7 +243,6 @@ lib/core/solve.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-05-03 16:43:45 +0000 +++ agent/agent.c 2010-05-03 17:08:15 +0000 @@ -203,6 +203,7 @@ case ':': case 'V': hip_print_version("hipagent"); + goto out_err; case 'h': fprintf(stderr, "no help available currently\n"); goto out_err; === modified file 'firewall/firewall.c' --- firewall/firewall.c 2010-05-03 16:43:45 +0000 +++ firewall/firewall.c 2010-05-03 17:08:15 +0000 @@ -2211,6 +2211,7 @@ break; case 'V': hip_print_version("hipfw"); + return 0; case ':': /* option without operand */ printf("Option -%c requires an operand\n", optopt); errflg++; === modified file 'hipd/hipd.c' --- hipd/hipd.c 2010-05-03 16:43:45 +0000 +++ hipd/hipd.c 2010-05-03 17:08:15 +0000 @@ -390,6 +390,7 @@ break; case 'V': hip_print_version("hipd"); + return 0; case '?': case 'h': default: === modified file 'lib/core/util.h' --- lib/core/util.h 2010-04-09 18:50:26 +0000 +++ lib/core/util.h 2010-05-03 17:08:15 +0000 @@ -6,6 +6,20 @@ #ifndef HIP_LIB_CORE_UTIL_H #define HIP_LIB_CORE_UTIL_H -int hip_print_version(const char *name); +#include <stdio.h> + +#include "config.h" +#include "util.h" +#include "version.h" + +/** + * Print version information to stdout. + */ +static inline void hip_print_version(const char *name) +{ + printf("%s %s (Bazaar branch-nick: '%s', revision: %s)\n", + name, VERSION, BZR_BRANCH, BZR_REVISION); + printf("build configuration: %s\n", HIPL_CONFIGURATION); +} #endif /* HIP_LIB_CORE_UTIL_H */