summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-12-09 08:24:46 -0500
committerPaul Jakma <paul.jakma@hpe.com>2016-02-26 14:11:47 +0000
commitb2a2fd788f34a4f5d1bbd92a283e47704f05ae8f (patch)
tree60c789a8376edf88f1d0206ece1be43451c7a9cd
parent91ce87aacfd8718b5a52fb0f4453e9f72d8bdb53 (diff)
downloadquagga-b2a2fd788f34a4f5d1bbd92a283e47704f05ae8f.tar.bz2
quagga-b2a2fd788f34a4f5d1bbd92a283e47704f05ae8f.tar.xz
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>
-rw-r--r--lib/command.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/command.h b/lib/command.h
index fd55f2d5..6a20e232 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -459,6 +459,17 @@ struct cmd_token
#endif /* VTYSH_EXTRACT_PL */
+/*
+ * 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) ">"
+
+
/* Common descriptions. */
#define SHOW_STR "Show running system information\n"
#define IP_STR "IP information\n"