diff options
Diffstat (limited to 'vlib/vlib/cli.h')
-rw-r--r-- | vlib/vlib/cli.h | 97 |
1 files changed, 53 insertions, 44 deletions
diff --git a/vlib/vlib/cli.h b/vlib/vlib/cli.h index a9e08ba1f6e..009c7e82cf7 100644 --- a/vlib/vlib/cli.h +++ b/vlib/vlib/cli.h @@ -44,58 +44,62 @@ struct vlib_cli_command_t; -typedef struct { +typedef struct +{ u32 min_char; /* Indexed by name[position] - min_char. */ - uword ** bitmaps; + uword **bitmaps; } vlib_cli_parse_position_t; -typedef struct { - u8 * name; +typedef struct +{ + u8 *name; u32 index; } vlib_cli_sub_command_t; -typedef struct { - u8 * name; +typedef struct +{ + u8 *name; u32 rule_index; u32 command_index; } vlib_cli_sub_rule_t; -typedef struct { - char * name; - char * short_help; - char * long_help; +typedef struct +{ + char *name; + char *short_help; + char *long_help; /* Number of bytes in parsed data. Zero for vector. */ uword data_size; - unformat_function_t * unformat_function; + unformat_function_t *unformat_function; /* Opaque for unformat function. */ uword unformat_function_arg[2]; } vlib_cli_parse_rule_t; /* CLI command callback function. */ -typedef clib_error_t * (vlib_cli_command_function_t) +typedef clib_error_t *(vlib_cli_command_function_t) (struct vlib_main_t * vm, - unformat_input_t * input, - struct vlib_cli_command_t * cmd); + unformat_input_t * input, struct vlib_cli_command_t * cmd); -typedef struct vlib_cli_command_t { +typedef struct vlib_cli_command_t +{ /* Command path (e.g. "show something"). Spaces delimit elements of path. */ - char * path; + char *path; /* Short/long help strings. */ - char * short_help; - char * long_help; + char *short_help; + char *long_help; /* Callback function. */ - vlib_cli_command_function_t * function; + vlib_cli_command_function_t *function; /* Opaque. */ uword function_arg; @@ -104,44 +108,44 @@ typedef struct vlib_cli_command_t { uword is_mp_safe; /* Sub commands for this command. */ - vlib_cli_sub_command_t * sub_commands; + vlib_cli_sub_command_t *sub_commands; /* Hash table mapping name (e.g. last path element) to sub command index. */ - uword * sub_command_index_by_name; + uword *sub_command_index_by_name; /* bitmap[p][c][i] says whether sub-command i has character c in position p. */ - vlib_cli_parse_position_t * sub_command_positions; + vlib_cli_parse_position_t *sub_command_positions; /* Hash table mapping name (e.g. last path element) to sub rule index. */ - uword * sub_rule_index_by_name; + uword *sub_rule_index_by_name; /* Vector of possible parse rules for this path. */ - vlib_cli_sub_rule_t * sub_rules; + vlib_cli_sub_rule_t *sub_rules; /* List of CLI commands, built by constructors */ - struct vlib_cli_command_t * next_cli_command; + struct vlib_cli_command_t *next_cli_command; } vlib_cli_command_t; typedef void (vlib_cli_output_function_t) (uword arg, - u8 * buffer, - uword buffer_bytes); -typedef struct { + u8 * buffer, uword buffer_bytes); +typedef struct +{ /* Vector of all known commands. */ - vlib_cli_command_t * commands; + vlib_cli_command_t *commands; /* Hash table mapping normalized path to index into all_commands. */ - uword * command_index_by_path; + uword *command_index_by_path; /* Vector of all known parse rules. */ - vlib_cli_parse_rule_t * parse_rules; + vlib_cli_parse_rule_t *parse_rules; /* Hash table mapping parse rule name to index into parse_rule vector. */ - uword * parse_rule_index_by_name; + uword *parse_rule_index_by_name; /* Data parsed for rules. */ - void ** parse_rule_data; + void **parse_rule_data; /* registration list added by constructors */ vlib_cli_command_t *cli_command_registrations; @@ -158,26 +162,31 @@ static void __vlib_cli_command_registration_##x (void) \ x.next_cli_command = cm->cli_command_registrations; \ cm->cli_command_registrations = &x; \ } \ -__VA_ARGS__ vlib_cli_command_t x - - +__VA_ARGS__ vlib_cli_command_t x #define VLIB_CLI_PARSE_RULE(x) \ - vlib_cli_parse_rule_t x - + vlib_cli_parse_rule_t x /* Output to current CLI connection. */ -void vlib_cli_output (struct vlib_main_t * vm, char * fmt, ...); +void vlib_cli_output (struct vlib_main_t *vm, char *fmt, ...); /* Process CLI input. */ -void vlib_cli_input (struct vlib_main_t * vm, +void vlib_cli_input (struct vlib_main_t *vm, unformat_input_t * input, vlib_cli_output_function_t * function, uword function_arg); -clib_error_t * vlib_cli_register (struct vlib_main_t * vm, - vlib_cli_command_t * c); -clib_error_t * vlib_cli_register_parse_rule (struct vlib_main_t * vm, - vlib_cli_parse_rule_t * c); +clib_error_t *vlib_cli_register (struct vlib_main_t *vm, + vlib_cli_command_t * c); +clib_error_t *vlib_cli_register_parse_rule (struct vlib_main_t *vm, + vlib_cli_parse_rule_t * c); uword unformat_vlib_cli_sub_input (unformat_input_t * i, va_list * args); #endif /* included_vlib_cli_h */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ |