diff options
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/layer23/include/osmocom/bb/common/l23_app.h | 3 | ||||
-rw-r--r-- | src/host/layer23/src/common/main.c | 12 | ||||
-rw-r--r-- | src/host/layer23/src/misc/app_cell_log.c | 13 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/l23_app.h b/src/host/layer23/include/osmocom/bb/common/l23_app.h index fcfd4bdf..e4c5d55e 100644 --- a/src/host/layer23/include/osmocom/bb/common/l23_app.h +++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h @@ -1,6 +1,8 @@ #ifndef _L23_APP_H #define _L23_APP_H +struct option; + /* Options supported by the l23 app */ enum { L23_OPT_SAP = 1, @@ -24,6 +26,7 @@ struct l23_app_info { char *getopt_string; int (*cfg_supported)(); int (*cfg_print_help)(); + int (*cfg_getopt_opt)(struct option **options); int (*cfg_handle_opt)(int c,const char *optarg); }; diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c index a791ccf4..cb9564a4 100644 --- a/src/host/layer23/src/common/main.c +++ b/src/host/layer23/src/common/main.c @@ -110,6 +110,9 @@ static void print_help() static void build_config(char **opt, struct option **option) { struct l23_app_info *app; + struct option *app_opp = NULL; + int app_len = 0, len; + static struct option long_options[] = { {"help", 0, 0, 'h'}, {"socket", 1, 0, 's'}, @@ -124,9 +127,14 @@ static void build_config(char **opt, struct option **option) app = l23_app_info(); *opt = talloc_asprintf(l23_ctx, "hs:S:a:i:v:d:%s", app && app->getopt_string ? app->getopt_string : ""); - *option = talloc_zero_array(l23_ctx, struct option, - ARRAY_SIZE(long_options) + 1); + + len = ARRAY_SIZE(long_options); + if (app && app->cfg_getopt_opt) + app_len = app->cfg_getopt_opt(&app_opp); + + *option = talloc_zero_array(l23_ctx, struct option, len + app_len + 1); memcpy(*option, long_options, sizeof(long_options)); + memcpy(*option + len, app_opp, app_len * sizeof(struct option)); } static void handle_options(int argc, char **argv) diff --git a/src/host/layer23/src/misc/app_cell_log.c b/src/host/layer23/src/misc/app_cell_log.c index e80a7b25..a0a1c093 100644 --- a/src/host/layer23/src/misc/app_cell_log.c +++ b/src/host/layer23/src/misc/app_cell_log.c @@ -23,6 +23,7 @@ #include <signal.h> #include <stdlib.h> #include <time.h> +#include <getopt.h> #include <osmocom/bb/common/osmocom_data.h> #include <osmocom/bb/common/l1ctl.h> @@ -31,6 +32,7 @@ #include <osmocom/bb/misc/cell_log.h> #include <osmocore/talloc.h> +#include <osmocore/utils.h> extern struct log_target *stderr_target; extern void *l23_ctx; @@ -82,6 +84,16 @@ static int l23_cfg_supported() return L23_OPT_TAP | L23_OPT_DBG; } +static int l23_getopt_options(struct option **options) +{ + static struct option opts [] = { + {"logfile", 1, 0, 'l'}, + }; + + *options = opts; + return ARRAY_SIZE(opts); +} + static int l23_cfg_print_help() { printf("\nApplication specific\n"); @@ -104,6 +116,7 @@ static struct l23_app_info info = { .copyright = "Copyright (C) 2010 Andreas Eversberg\n", .getopt_string = "l:", .cfg_supported = l23_cfg_supported, + .cfg_getopt_opt = l23_getopt_options, .cfg_handle_opt = l23_cfg_handle, .cfg_print_help = l23_cfg_print_help, }; |