Change in osmo-pcu[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/.

fixeria gerrit-no-reply at lists.osmocom.org
Fri Oct 23 22:15:34 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/20869 )


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: If82208ecb931a6024f1a83c8648c5855b15dcc96
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
---
M src/pcu_main.cpp
1 file changed, 32 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/69/20869/1

diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 723f101..cda10e7 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -77,10 +77,37 @@
 		"  -r	--realtime PRIO		Use SCHED_RR with the specified priority\n"
 		"  -D	--daemonize		Fork the process into a background daemon\n"
 		"  -i	--gsmtap-ip		The destination IP used for GSMTAP\n"
-		"    	--vty-ref-xml   	Generate the VTY reference XML output and exit.\n"
+		"\nVTY reference generation:\n"
+		"    	--vty-ref-mode MODE	VTY reference generation mode (e.g. 'expert').\n"
+		"    	--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);
+	}
+}
+
 /* FIXME: finally get some option parsing code into libosmocore */
 static void handle_options(int argc, char **argv)
 {
@@ -97,7 +124,8 @@
 			{ "daemonize", 0, 0, 'D' },
 			{ "exit", 0, 0, 'e' },
 			{ "gsmtap-ip", 1, 0, 'i' },
-			{ "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 }
 		};
 
@@ -112,14 +140,8 @@
 			exit(0);
 			break;
 		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 'c':
 			free(config_file);
 			config_file = strdup(optarg);

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: If82208ecb931a6024f1a83c8648c5855b15dcc96
Gerrit-Change-Number: 20869
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201023/13910821/attachment.htm>


More information about the gerrit-log mailing list