Change in osmo-smlc[master]: main: Support setting cmdline --vty-ref-mode

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Feb 24 13:29:23 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-smlc/+/23094 )


Change subject: main: Support setting cmdline --vty-ref-mode
......................................................................

main: Support setting cmdline --vty-ref-mode

Change-Id: Iadb004319514cb134b0863ea16b3289e6f1a097a
---
M src/osmo-smlc/smlc_main.c
1 file changed, 29 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-smlc refs/changes/94/23094/1

diff --git a/src/osmo-smlc/smlc_main.c b/src/osmo-smlc/smlc_main.c
index 105ced3..3f24a42 100644
--- a/src/osmo-smlc/smlc_main.c
+++ b/src/osmo-smlc/smlc_main.c
@@ -78,6 +78,31 @@
 	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) {
@@ -90,7 +115,8 @@
 			{"config-file", 1, 0, 'c'},
 			{"version", 0, 0, 'V' },
 			{"log-level", 1, 0, 'e'},
-			{"vty-ref-xml", 0, &long_option, 1},
+			{"vty-ref-mode", 1, &long_option, 1},
+			{"vty-ref-xml", 0, &long_option, 2},
 			{0, 0, 0, 0}
 		};
 
@@ -105,14 +131,8 @@
 			print_help();
 			exit(0);
 		case 0:
-			switch (long_option) {
-			case 1:
-				vty_dump_xml_ref(stdout);
-				exit(0);
-			default:
-				fprintf(stderr, "error parsing cmdline options\n");
-				exit(2);
-			}
+			handle_long_options(argv[0], long_option);
+			break;
 		case 'd':
 			log_parse_category_mask(osmo_stderr_target, optarg);
 			break;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-smlc/+/23094
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-smlc
Gerrit-Branch: master
Gerrit-Change-Id: Iadb004319514cb134b0863ea16b3289e6f1a097a
Gerrit-Change-Number: 23094
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210224/13109728/attachment.htm>


More information about the gerrit-log mailing list