diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-19 21:14:27 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-19 21:14:27 +0000 |
| commit | 9d0662e009c0cf4532b88c9a1fb0f7c0dc174584 (patch) | |
| tree | ab301ab5ec4b58a249df43e09fbc21154e879499 /lib/command_match.h | |
| parent | 340a2b4ac0bcc737e24aa6c0e383f1188aaaaf61 (diff) | |
lib: Break up functions, begin matcher
Moved test hook out of command.c into vtysh.c,
renamed graph modules, added matching code
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_match.h')
| -rw-r--r-- | lib/command_match.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/command_match.h b/lib/command_match.h new file mode 100644 index 0000000000..cddeb08af7 --- /dev/null +++ b/lib/command_match.h @@ -0,0 +1,69 @@ +#ifndef COMMAND_MATCH_H +#define COMMAND_MATCH_H + +#include "command_graph.h" + +/** + * Filter types. These tell the parser whether to allow + * partial matching on tokens. + */ +enum filter_type +{ + FILTER_RELAXED, + FILTER_STRICT +}; + +/** + * Command matcher result value. + */ +enum matcher_rv +{ + MATCHER_OK, + MATCHER_COMPLETE, + MATCHER_INCOMPLETE, + MATCHER_NO_MATCH, + MATCHER_AMBIGUOUS, + MATCHER_EXCEED_ARGC_MAX +}; + +/* Completion match types. */ +enum match_type +{ + no_match, + partly_match, + exact_match +}; +/** + * Defines which matcher_rv values constitute + * an error. Should be used against matcher_rv + * return values to do basic error checking. + */ +#define MATCHER_ERROR(matcher_rv) \ + ( (matcher_rv) == MATCHER_INCOMPLETE \ + || (matcher_rv) == MATCHER_NO_MATCH \ + || (matcher_rv) == MATCHER_AMBIGUOUS \ + || (matcher_rv) == MATCHER_EXCEED_ARGC_MAX \ + ) + +enum match_type +cmd_ipv4_match (const char *); + +enum match_type +cmd_ipv4_prefix_match (const char *); + +enum match_type +cmd_ipv6_match (const char *); + +enum match_type +cmd_ipv6_prefix_match (const char *); + +enum match_type +cmd_range_match (struct graph_node *, const char *str); + +enum match_type +cmd_word_match (struct graph_node *, enum filter_type, const char *); + +enum match_type +match_command (struct graph_node *, enum filter_type, const char *); + +#endif |
