[quagga-dev 14127] Re: [PATCH 3/4] lib: Add CMD_RANGE_STR macro to command.h

Donald Sharp sharpd at cumulusnetworks.com
Wed Dec 9 13:27:48 GMT 2015


<sigh> my commit comment is broken.  I never finished it.

#define LOW 4
#define HIGH 99

needs to be added.

donald

On Wed, Dec 9, 2015 at 8:24 AM, Donald Sharp <sharpd at cumulusnetworks.com>
wrote:

> 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 at cumulusnetworks.com>
> ---
>  lib/command.h |   11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/lib/command.h b/lib/command.h
> index 6030069..009f2ee 100644
> --- a/lib/command.h
> +++ b/lib/command.h
> @@ -456,6 +456,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"
> --
> 1.7.10.4
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20151209/5d061e6e/attachment-0001.html>


More information about the Quagga-dev mailing list