From acf724c270fa40dff64a04572f775729652c1870 Mon Sep 17 00:00:00 2001 From: Emmanuel Roullit Date: Thu, 2 Aug 2012 22:53:16 +0200 Subject: [PATCH] Added --version option to get dabbad version info. --- dabbad/dabbad.c | 6 ++++++ dabbad/help.c | 8 +++++++- dabbad/include/dabbad/help.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dabbad/dabbad.c b/dabbad/dabbad.c index 777256f..8f9806b 100644 --- a/dabbad/dabbad.c +++ b/dabbad/dabbad.c @@ -108,6 +108,7 @@ Written by Emmanuel Roullit enum dabbad_opts { OPT_DAEMONIZE, + OPT_VERSION, OPT_HELP }; @@ -120,6 +121,7 @@ const struct option *dabbad_options_get(void) { static const struct option dabbad_long_options[] = { {"daemonize", no_argument, NULL, OPT_DAEMONIZE}, + {"version", no_argument, NULL, OPT_VERSION}, {"help", no_argument, NULL, OPT_HELP}, {NULL, 0, NULL, 0} }; @@ -183,6 +185,10 @@ int main(int argc, char **argv) case OPT_DAEMONIZE: daemonize = 1; break; + case OPT_VERSION: + print_version(); + return EXIT_SUCCESS; + break; case OPT_HELP: default: show_usage(dabbad_options_get()); diff --git a/dabbad/help.c b/dabbad/help.c index 374a1f1..ef57d0f 100644 --- a/dabbad/help.c +++ b/dabbad/help.c @@ -38,7 +38,7 @@ static const char _usage[] = * \brief Show dabbad usage options */ -void show_usage(const struct option * opt) +void show_usage(const struct option *opt) { assert(opt); @@ -57,3 +57,9 @@ void show_usage(const struct option * opt) } } } + +int print_version(void) +{ + printf("dabbad version %s\n", DABBA_VERSION); + return 0; +} diff --git a/dabbad/include/dabbad/help.h b/dabbad/include/dabbad/help.h index bdfee57..26c86d9 100644 --- a/dabbad/include/dabbad/help.h +++ b/dabbad/include/dabbad/help.h @@ -25,5 +25,6 @@ #define HELP_H void show_usage(const struct option *opt); +int print_version(void); #endif /* HELP_H */ -- 2.11.4.GIT