aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-02-23 15:52:25 +0100
committerHarald Welte <laforge@osmocom.org>2021-02-23 15:52:54 +0100
commit999a776b705ce00d3bba37e77ed001f1e380ef8f (patch)
tree200f1914d3134d28db6c2c29c41cd9da0a7de8ae
parent11ccc4305d8a29969018111a1f6dfad062842f47 (diff)
main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
-rw-r--r--src/sgsn/sgsn_main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/sgsn/sgsn_main.c b/src/sgsn/sgsn_main.c
index c3a6061f9..6c57071a2 100644
--- a/src/sgsn/sgsn_main.c
+++ b/src/sgsn/sgsn_main.c
@@ -183,12 +183,43 @@ static void print_help(void)
printf(" -s --disable-color\n");
printf(" -c --config-file\tThe config file to use [%s]\n", CONFIG_FILE_DEFAULT);
printf(" -e --log-level number\tSet a global log level\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
+
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
+ static int long_option = 0;
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"debug", 1, 0, 'd'},
@@ -198,6 +229,8 @@ static void handle_options(int argc, char **argv)
{"timestamp", 0, 0, 'T'},
{ "version", 0, 0, 'V' },
{"log-level", 1, 0, 'e'},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{NULL, 0, 0, 0}
};
@@ -207,6 +240,9 @@ static void handle_options(int argc, char **argv)
break;
switch (c) {
+ case 0:
+ handle_long_options(argv[0], long_option);
+ break;
case 'h':
//print_usage();
print_help();