summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-12-08 18:06:42 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-12-08 19:07:14 +0100
commitba6d273b004cc8e03b5314c1931ee7e18ae6f29b (patch)
tree2e4d07dc93a14b40ea058732a1c015cbd258e88f /lib
parentbgpd: Convert BGP_MAXIMUM_MAXPATHS to MULTIPATH_NUM (diff)
downloadfrr-ba6d273b004cc8e03b5314c1931ee7e18ae6f29b.tar.xz
frr-ba6d273b004cc8e03b5314c1931ee7e18ae6f29b.zip
lib: Add CMD_RANGE_STR macro to command.h
Allow the auto-generation of a "<X-Y>" string for cli handline. Where X or Y can be a #define. CMD_RANGE_STR(LOW, HIGH) translates to: "<4-99>" Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/command.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/command.h b/lib/command.h
index 4eb31a694..f9f4c7e39 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -437,6 +437,17 @@ struct cmd_token
#endif /* VTYSH_EXTRACT_PL */
/* Some macroes */
+
+/*
+ * Sometimes #defines create maximum values that
+ * need to have strings created from them that
+ * allow the parser to match against them.
+ * These macros allow that.
+ */
+#define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s)
+#define CMD_CREATE_STR_HELPER(s) #s
+#define CMD_RANGE_STR(a,s) "<" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ">"
+
#define CMD_OPTION(S) ((S[0]) == '[')
#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
#define CMD_VARARG(S) ((S[0]) == '.')