]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Add CMD_RANGE_STR macro to command.h
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 8 Dec 2015 17:06:42 +0000 (17:06 +0000)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 8 Dec 2015 18:07:14 +0000 (10:07 -0800)
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>
lib/command.h

index 4eb31a6947fb6319569f5dc96c180f371f4cf08a..f9f4c7e397b1b23a2b1118d82579ea7bd7a24573 100644 (file)
@@ -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]) == '.')