diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-10-19 10:53:47 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-10-19 10:55:25 +0200 |
commit | 4dc14a751b7c9ad0030d2cebb1f87b22bac1d5a4 (patch) | |
tree | 60cf8604030199cfb3f801274e057e811ace72fe /src | |
parent | 2ac78497ddb0320f8b6c3f38f1acd0a0b70dcf00 (diff) |
e1_recorder: add config option for configuration file0.1
Diffstat (limited to 'src')
-rw-r--r-- | src/e1_recorder.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/e1_recorder.c b/src/e1_recorder.c index 11ec93e..9110ccb 100644 --- a/src/e1_recorder.c +++ b/src/e1_recorder.c @@ -1,4 +1,5 @@ #include <signal.h> +#include <getopt.h> #include <osmocom/core/signal.h> #include <osmocom/core/logging.h> @@ -88,6 +89,7 @@ struct vty_app_info vty_info = { static void *rec_tall_ctx; struct e1_recorder g_recorder; +static char *g_config_file = "osmo-e1-recorder.cfg"; static void signal_handler(int signo) { @@ -101,6 +103,28 @@ static void signal_handler(int signo) } } +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' }, + { 0, 0, 0, 0 } + }; + + c = getopt_long(argc, argv, "c:", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'c': + g_config_file = optarg; + break; + } + } +} + int main(int argc, char **argv) { int rc; @@ -118,7 +142,9 @@ int main(int argc, char **argv) signal(SIGHUP, &signal_handler); signal(SIGUSR1, &signal_handler); - rc = vty_read_config_file("osmo-e1-recorder.cfg", NULL); + handle_options(argc, argv); + + rc = vty_read_config_file(g_config_file, NULL); if (rc < 0) exit(1); |