Change-Id: I47dd6f9637f0214971e3191852d84aa92d64b8c0
Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
{
int is_enable = -1;
int is_dump = -1;
{
int is_enable = -1;
int is_dump = -1;
+ unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error = NULL;
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable | dump");
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- if (unformat (input, "enable") || unformat (input, "on"))
+ if (unformat (line_input, "enable") || unformat (line_input, "on"))
- else if (unformat (input, "disable") || unformat (input, "off"))
+ else if (unformat (line_input, "disable")
+ || unformat (line_input, "off"))
- else if (unformat (input, "dump"))
+ else if (unformat (line_input, "dump"))
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
if (is_dump > 0)
cj_dump ();
if (is_dump > 0)
cj_dump ();
+done:
+ unformat_free (line_input);
+ return error;
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
clib_error_t *error;
if (!unformat_user (input, unformat_line_input, line_input))
clib_error_t *error;
if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{