Change in osmo-iuh[master]: main: add --vty-ref-mode, use vty_dump_xml_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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Feb 23 17:28:35 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/23061 )

Change subject: main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
......................................................................

main: add --vty-ref-mode, use vty_dump_xml_ref_mode()

Change-Id: If07b00e928fbecc596a7f75fc55e811bd9199b72
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Relates: OS#5041
---
M src/hnbgw.c
1 file changed, 34 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/hnbgw.c b/src/hnbgw.c
index a6e0d29..5e01b63 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -415,12 +415,42 @@
 	printf("  -T --timestamp             Prefix every log line with a timestamp.\n");
 	printf("  -V --version               Print the version of OsmoHNBGW.\n");
 	printf("  -e --log-level number      Set a global loglevel.\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'},
@@ -430,6 +460,8 @@
 			{"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},
 			{0, 0, 0, 0}
 		};
 
@@ -439,6 +471,8 @@
 			break;
 
 		switch (c) {
+		case 0:
+			handle_long_options(argv[0], long_option);
 		case 'h':
 			print_usage();
 			print_help();

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

Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: If07b00e928fbecc596a7f75fc55e811bd9199b72
Gerrit-Change-Number: 23061
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210223/2f92f7a9/attachment.htm>


More information about the gerrit-log mailing list