]> git.proxmox.com Git - mirror_frr.git/blob - lib/command_match.h
lib: Break up functions, begin matcher
[mirror_frr.git] / lib / command_match.h
1 #ifndef COMMAND_MATCH_H
2 #define COMMAND_MATCH_H
3
4 #include "command_graph.h"
5
6 /**
7 * Filter types. These tell the parser whether to allow
8 * partial matching on tokens.
9 */
10 enum filter_type
11 {
12 FILTER_RELAXED,
13 FILTER_STRICT
14 };
15
16 /**
17 * Command matcher result value.
18 */
19 enum matcher_rv
20 {
21 MATCHER_OK,
22 MATCHER_COMPLETE,
23 MATCHER_INCOMPLETE,
24 MATCHER_NO_MATCH,
25 MATCHER_AMBIGUOUS,
26 MATCHER_EXCEED_ARGC_MAX
27 };
28
29 /* Completion match types. */
30 enum match_type
31 {
32 no_match,
33 partly_match,
34 exact_match
35 };
36 /**
37 * Defines which matcher_rv values constitute
38 * an error. Should be used against matcher_rv
39 * return values to do basic error checking.
40 */
41 #define MATCHER_ERROR(matcher_rv) \
42 ( (matcher_rv) == MATCHER_INCOMPLETE \
43 || (matcher_rv) == MATCHER_NO_MATCH \
44 || (matcher_rv) == MATCHER_AMBIGUOUS \
45 || (matcher_rv) == MATCHER_EXCEED_ARGC_MAX \
46 )
47
48 enum match_type
49 cmd_ipv4_match (const char *);
50
51 enum match_type
52 cmd_ipv4_prefix_match (const char *);
53
54 enum match_type
55 cmd_ipv6_match (const char *);
56
57 enum match_type
58 cmd_ipv6_prefix_match (const char *);
59
60 enum match_type
61 cmd_range_match (struct graph_node *, const char *str);
62
63 enum match_type
64 cmd_word_match (struct graph_node *, enum filter_type, const char *);
65
66 enum match_type
67 match_command (struct graph_node *, enum filter_type, const char *);
68
69 #endif