]>
git.proxmox.com Git - mirror_frr.git/blob - lib/command_match.h
24cd1287e6bccf1ef81d97a03fa8dd340fd319b2
1 #ifndef COMMAND_MATCH_H
2 #define COMMAND_MATCH_H
5 #include "command_graph.h"
9 /** These definitions exist in command.c in
10 * the current engine but will be relocated
11 * here in the new engine*/
18 /* matcher result value. */
26 MATCHER_EXCEED_ARGC_MAX
29 /* Completion match types. */
37 /* Defines which matcher_rv values constitute
38 * an error. Should be used against matcher_rv
39 * return values to do basic error checking.
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 \
49 * Attempt to find an exact command match for a line of user input.
51 * @return cmd_element found, or NULL if there is no match.
54 match_command (struct graph_node
*, const char *, enum filter_type
);
57 * Compiles next-hops for a given line of user input.
59 * Given a string of input and a start node for a matching DFA, runs the input
60 * against the DFA until the input is exhausted or a mismatch is encountered.
62 * This function returns all valid next hops away from the current node.
63 * - If the input is a valid prefix to a longer command(s), the set of next
64 * hops determines what tokens are valid to follow the prefix. In other words,
65 * the returned list is a list of possible completions.
66 * - If the input matched a full command, exactly one of the next hops will be
67 * a node of type END_GN and its function pointer will be set.
68 * - If the input did not match any valid token sequence, the returned list
69 * will be empty (there are no transitions away from a nonexistent state).
71 * @param[in] start the start node of the DFA to match against
72 * @param[in] filter the filtering method
73 * @param[in] input the input string
74 * @return pointer to linked list with all possible next hops from the last
75 * matched token. If this is empty, the input did not match any command.
78 match_command_complete (struct graph_node
*, const char *, enum filter_type
);
81 * Builds an argument list given a cmd_element and a matching input line.
83 * @param[in] input line
84 * @param[in] cmd_element struct
85 * @return pointer to argument linked list
88 match_build_argv (const char *, struct cmd_element
*);