diff options
author | Harald Welte <laforge@osmocom.org> | 2019-12-03 22:06:17 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2019-12-04 12:08:33 +0100 |
commit | 06e3198e70d244c250d44201f95402ca87c5ff8e (patch) | |
tree | f7924d28bc8de8157a196a13ef263dfba8be2d07 /src | |
parent | 2c5c079e5339c64b6bc0b65c2af7b1d60a2f9be9 (diff) |
e1_recorder: Add --help and --version command line arguments
Change-Id: Ie676466e5406243cf4205948cddd95426e2b8c10
Diffstat (limited to 'src')
-rw-r--r-- | src/e1_recorder.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/e1_recorder.c b/src/e1_recorder.c index 07fd4a6..d77c0ff 100644 --- a/src/e1_recorder.c +++ b/src/e1_recorder.c @@ -15,6 +15,8 @@ #include "storage.h" #include "recorder.h" +#include "config.h" + static enum osmo_e1cap_capture_mode ts2cap_mode(struct e1inp_ts *ts) { switch (ts->type) { @@ -84,8 +86,8 @@ static struct log_info info = { struct vty_app_info vty_info = { .name = "osmo-e1-recorder", - .version = "0", - .copyright = "(C) 2016 by Harald Welte <laforge@gnumonks.org>\n", + .version = PACKAGE_VERSION, + .copyright = "(C) 2016-2019 by Harald Welte <laforge@gnumonks.org>\n", }; static void *rec_tall_ctx; @@ -104,16 +106,26 @@ static void signal_handler(int signo) } } +static void print_help(void) +{ + printf( " -h --help This help\n" + " -V --version Print version of the program\n" + " -c --config FILE Specify configuration file\n" + ); +} + static void handle_options(int argc, char **argv) { while (1) { int option_index = 0, c; static const struct option long_options[] = { { "config-file", 1, 0, 'c' }, + { "help", 0, 0, 'h' }, + { "version", 0, 0, 'V' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "c:", + c = getopt_long(argc, argv, "c:hV", long_options, &option_index); if (c == -1) break; @@ -122,6 +134,14 @@ static void handle_options(int argc, char **argv) case 'c': g_config_file = optarg; break; + case 'h': + print_help(); + exit(0); + break; + case 'V': + print_version(1); + exit(0); + break; } } |