static clib_error_t * cj_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { int is_enable = -1; int is_dump = -1; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "enable") || unformat (input, "on")) is_enable = 1; else if (unformat (input, "disable") || unformat (input, "off")) is_enable = 0; else if (unformat (input, "dump")) is_dump = 1; else return clib_error_return (0, "unknown input `%U'", format_unformat_error, input); } if (is_enable >= 0) cj_enable_disable (is_enable); if (is_dump > 0) cj_dump (); return 0; }
static clib_error_t * cj_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { int is_enable = -1; int is_dump = -1; unformat_input_t _line_input, *line_input = &_line_input; clib_error_t *error = NULL; /* 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 (line_input, "enable") || unformat (line_input, "on")) is_enable = 1; else if (unformat (line_input, "disable") || unformat (line_input, "off")) is_enable = 0; else if (unformat (line_input, "dump")) is_dump = 1; else { error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); goto done; } } if (is_enable >= 0) cj_enable_disable (is_enable); if (is_dump > 0) cj_dump (); done: unformat_free (line_input); return error; }