aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/command.c
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2016-05-16 16:01:45 +0200
committerHarald Welte <laforge@gnumonks.org>2016-06-14 10:38:17 +0000
commitad580ba7c400835fdff0226700dd02c7ffff32c6 (patch)
treede71080d77d902df017d4e5d01c8a7ee69314f0c /src/vty/command.c
parent0167e3f35535b1b19eab659659180fa549da52b0 (diff)
add vty call show asciidoc: generate a documentation for counters
For each counter group a ascii doc table is generated containing all single counter with a reference to a section to add additional information to the counter Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb Reviewed-on: https://gerrit.osmocom.org/70 Reviewed-by: Harald Welte <laforge@gnumonks.org> Tested-by: Harald Welte <laforge@gnumonks.org>
Diffstat (limited to 'src/vty/command.c')
-rw-r--r--src/vty/command.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 1f1dddbe..483ca801 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -402,6 +402,59 @@ const char *cmd_prompt(enum node_type node)
return cnode->prompt;
}
+/*!
+ * \brief escape all special asciidoc symbols
+ * \param unsafe string
+ * \return a new talloc char *
+ */
+char *osmo_asciidoc_escape(const char *inp)
+{
+ int _strlen;
+ char *out, *out_ptr;
+ int len = 0, i, j;
+
+ if (!inp)
+ return NULL;
+ _strlen = strlen(inp);
+
+ for (i = 0; i < _strlen; ++i) {
+ switch (inp[i]) {
+ case '|':
+ len += 2;
+ break;
+ default:
+ len += 1;
+ break;
+ }
+ }
+
+ out = talloc_size(NULL, len + 1);
+ if (!out)
+ return NULL;
+
+ out_ptr = out;
+
+#define ADD(out, str) \
+ for (j = 0; j < strlen(str); ++j) \
+ *(out++) = str[j];
+
+ for (i = 0; i < _strlen; ++i) {
+ switch (inp[i]) {
+ case '|':
+ ADD(out_ptr, "\\|");
+ break;
+ default:
+ *(out_ptr++) = inp[i];
+ break;
+ }
+ }
+
+#undef ADD
+
+ out_ptr[0] = '\0';
+ return out;
+}
+
static char *xml_escape(const char *inp)
{
int _strlen;