summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-12-27 14:51:13 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-12-27 19:01:37 +0100
commitace267cfc20cbd05a6aa953d1d05733b4d174dd6 (patch)
tree04702670f9e4ef3601ab1fcceba49c56763f1a31 /src/host/layer23/src
parent63c0e6d1996733d107434585fbef5e888b3075ed (diff)
layer23: Enable combining the long options
Combine the long options from the base and the application. Provide the long option for the cell log application.
Diffstat (limited to 'src/host/layer23/src')
-rw-r--r--src/host/layer23/src/common/main.c12
-rw-r--r--src/host/layer23/src/misc/app_cell_log.c13
2 files changed, 23 insertions, 2 deletions
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,
};