Change in libosmocore[master]: vty/command: introduce 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 13:39:54 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20847 )


Change subject: vty/command: introduce vty_dump_xml_ref_mode()
......................................................................

vty/command: introduce vty_dump_xml_ref_mode()

This change introduces an enumerated type 'vty_ref_gen_mode' that
(as the name suggests) defines the VTY reference generation mode:

  - DEFAULT - all commands except deprecated and hidden,
  - EXPERT - all commands including hidden, excluding deprecated;

and a new function vty_dump_xml_ref_mode(), that allows to specify
that mode.  The old vty_dump_xml_ref() is now deprecated.

Change-Id: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
---
M include/osmocom/vty/command.h
M src/vty/command.c
2 files changed, 53 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/20847/1

diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h
index 92701fc..eb7ee35 100644
--- a/include/osmocom/vty/command.h
+++ b/include/osmocom/vty/command.h
@@ -29,6 +29,7 @@
 #include "vector.h"
 
 #include <osmocom/core/defs.h>
+#include <osmocom/core/utils.h>
 
 /*! \defgroup command VTY Command
  *  @{
@@ -460,6 +461,18 @@
 
 extern void *tall_vty_cmd_ctx;
 
-int vty_dump_xml_ref(FILE *stream);
+/*! VTY reference generation mode. */
+enum vty_ref_gen_mode {
+	/*! Default mode: all commands except deprecated and hidden. */
+	VTY_REF_GEN_MODE_DEFAULT = 0,
+	/*! Expert mode: all commands including hidden, excluding deprecated. */
+	VTY_REF_GEN_MODE_EXPERT,
+};
+
+extern const struct value_string vty_ref_gen_mode_names[];
+extern const struct value_string vty_ref_gen_mode_desc[];
+
+int vty_dump_xml_ref_mode(FILE *stream, enum vty_ref_gen_mode mode);
+int vty_dump_xml_ref(FILE *stream) OSMO_DEPRECATED("Use vty_dump_xml_ref_mode() instead");
 
 /*! @} */
diff --git a/src/vty/command.c b/src/vty/command.c
index 53ebcd8..b83522f 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -876,11 +876,49 @@
 	return rc;
 }
 
+const struct value_string vty_ref_gen_mode_names[] = {
+	{ VTY_REF_GEN_MODE_DEFAULT,	"default" },
+	{ VTY_REF_GEN_MODE_EXPERT,	"expert" },
+	{ 0, NULL }
+};
+
+const struct value_string vty_ref_gen_mode_desc[] = {
+	{ VTY_REF_GEN_MODE_DEFAULT,	"all commands except deprecated and hidden" },
+	{ VTY_REF_GEN_MODE_EXPERT,	"all commands including hidden, excluding deprecated" },
+	{ 0, NULL }
+};
+
 /*! Print the XML reference of all VTY nodes to the given stream.
+ * \param[out] stream  Output stream to print the XML reference to.
+ * \param[in]  mode    The XML reference generation mode.
+ * \returns always 0 for now, no errors possible.
+ */
+int vty_dump_xml_ref_mode(FILE *stream, enum vty_ref_gen_mode mode)
+{
+	switch (mode) {
+	case VTY_REF_GEN_MODE_EXPERT:
+		host.expert_mode = true;
+		break;
+	case VTY_REF_GEN_MODE_DEFAULT:
+	default:
+		host.expert_mode = false;
+		break;
+	}
+
+	return vty_dump_nodes(print_func_stream, stream, "\n");
+}
+
+/*! Print the XML reference of all VTY nodes to the given stream.
+ * \param[out] stream  Output stream to print the XML reference to.
+ * \returns always 0 for now, no errors possible.
+ *
+ * NOTE: this function is deprecated because it does not allow to
+ *	 specify the XML reference generation mode (default mode
+ *	 is hard-coded).  Use vty_dump_xml_ref_mode() instead.
  */
 int vty_dump_xml_ref(FILE *stream)
 {
-	return vty_dump_nodes(print_func_stream, stream, "\n");
+	return vty_dump_xml_ref_mode(stream, VTY_REF_GEN_MODE_DEFAULT);
 }
 
 /* Check if a command with given string exists at given node */

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Gerrit-Change-Number: 20847
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/087de092/attachment.htm>


More information about the gerrit-log mailing list