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