Change in osmo-pcap[master]: add --vty-ref-* support in osmo-pcap-client and -server

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/.

roh gerrit-no-reply at lists.osmocom.org
Fri Apr 9 21:58:44 UTC 2021


roh has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcap/+/23691 )


Change subject: add --vty-ref-* support in osmo-pcap-client and -server
......................................................................

add --vty-ref-* support in osmo-pcap-client and -server

Change-Id: I28353f51de798535a3bb6efdc6c2da443d96ddfb
---
M .gitignore
M configure.ac
M src/osmo_client_main.c
M src/osmo_server_main.c
4 files changed, 138 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/91/23691/1

diff --git a/.gitignore b/.gitignore
index dd48c7d..19c1a47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,16 @@
 tests/testsuite.log
 
 contrib/osmo-pcap.spec
+
+# manuals
+doc/manuals/*.html
+doc/manuals/*.svg
+doc/manuals/*.pdf
+doc/manuals/*__*.png
+doc/manuals/*.check
+doc/manuals/generated/
+doc/manuals/osmo-pcap-usermanual.xml
+doc/manuals/common
+doc/manuals/build
+doc/manuals/vty/osmo-pcap_vty_reference.xml
+
diff --git a/configure.ac b/configure.ac
index 8ec9c88..90dbc3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,46 @@
 
 AM_INIT_AUTOMAKE([dist-bzip2])
 AC_CONFIG_TESTDIR(tests)
+AC_ARG_ENABLE(manuals,
+	[AS_HELP_STRING(
+		[--enable-manuals],
+		[Generate manual PDFs [default=no]],
+	)],
+	[osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
+AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
+AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
+	fallback])
+if test x"$osmo_ac_build_manuals" = x"yes"
+then
+	# Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
+	if test -n "$OSMO_GSM_MANUALS_DIR"; then
+		echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
+	else
+		OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
+		if test -n "$OSMO_GSM_MANUALS_DIR"; then
+			echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
+		else
+			OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
+			echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
+		fi
+	fi
+	if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
+		AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
+	fi
+
+	# Find and run check-depends
+	CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
+	if ! test -x "$CHECK_DEPENDS"; then
+		CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
+	fi
+	if ! $CHECK_DEPENDS; then
+		AC_MSG_ERROR("missing dependencies for --enable-manuals")
+	fi
+
+	# Put in Makefile with absolute path
+	OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
+	AC_SUBST([OSMO_GSM_MANUALS_DIR])
+fi
 
 CFLAGS="$CFLAGS -std=gnu11"
 
@@ -61,6 +101,8 @@
 	CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
 fi
 
+
+
 # https://www.freedesktop.org/software/systemd/man/daemon.html
 AC_ARG_WITH([systemdsystemunitdir],
      [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
@@ -150,5 +192,6 @@
     contrib/osmo-pcap.spec
     doc/Makefile
     doc/examples/Makefile
+    doc/manuals/Makefile
     tests/Makefile
     Makefile)
diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c
index c7d68d4..b0727d6 100644
--- a/src/osmo_client_main.c
+++ b/src/osmo_client_main.c
@@ -98,20 +98,51 @@
 	printf("  -T --timestamp. Print a timestamp in the debug output.\n");
 	printf("  -e --log-level number. Set a global loglevel.\n");
 	printf("  -c --config-file filename The config file to use.\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'},
-			{"daemonize", 0, 0, 'D'},
-			{"debug", 1, 0, 'd'},
-			{"disable-color", 0, 0, 's'},
-			{"timestamp", 0, 0, 'T'},
-			{"log-level", 1, 0, 'e'},
-			{"config-file", 1, 0, 'c'},
+			{ "help", 0, 0, 'h'},
+			{ "daemonize", 0, 0, 'D'},
+			{ "debug", 1, 0, 'd'},
+			{ "disable-color", 0, 0, 's'},
+			{ "timestamp", 0, 0, 'T'},
+			{ "log-level", 1, 0, 'e'},
+			{ "config-file", 1, 0, 'c'},
+			{ "vty-ref-mode", 1, &long_option, 1},
+			{ "vty-ref-xml", 0, &long_option, 2},
 			{0, 0, 0, 0}
 		};
 
@@ -125,6 +156,9 @@
 			print_usage();
 			print_help();
 			exit(0);
+		case 0:
+			handle_long_options(argv[0], long_option);
+			break;
 		case 'D':
 			daemonize = 1;
 			break;
diff --git a/src/osmo_server_main.c b/src/osmo_server_main.c
index 51441a7..ad6260c 100644
--- a/src/osmo_server_main.c
+++ b/src/osmo_server_main.c
@@ -108,20 +108,51 @@
 	printf("  -T --timestamp. Print a timestamp in the debug output.\n");
 	printf("  -e --log-level number. Set a global loglevel.\n");
 	printf("  -c --config-file filename The config file to use.\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'},
-			{"daemonize", 0, 0, 'D'},
-			{"debug", 1, 0, 'd'},
-			{"disable-color", 0, 0, 's'},
-			{"timestamp", 0, 0, 'T'},
-			{"log-level", 1, 0, 'e'},
-			{"config-file", 1, 0, 'c'},
+			{ "help", 0, 0, 'h'},
+			{ "daemonize", 0, 0, 'D'},
+			{ "debug", 1, 0, 'd'},
+			{ "disable-color", 0, 0, 's'},
+			{ "timestamp", 0, 0, 'T'},
+			{ "log-level", 1, 0, 'e'},
+			{ "config-file", 1, 0, 'c'},
+			{ "vty-ref-mode", 1, &long_option, 1},
+			{ "vty-ref-xml", 0, &long_option, 2},
 			{0, 0, 0, 0}
 		};
 
@@ -135,6 +166,9 @@
 			print_usage();
 			print_help();
 			exit(0);
+		case 0:
+			handle_long_options(argv[0], long_option);
+			break;
 		case 'D':
 			daemonize = 1;
 			break;

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

Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I28353f51de798535a3bb6efdc6c2da443d96ddfb
Gerrit-Change-Number: 23691
Gerrit-PatchSet: 1
Gerrit-Owner: roh <jsteiger at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210409/34e6e012/attachment.htm>


More information about the gerrit-log mailing list