]> git.proxmox.com Git - mirror_frr.git/blob - lib/grammar_sandbox.h
*: make DEFUN installations file-local
[mirror_frr.git] / lib / grammar_sandbox.h
1 #ifndef _GRAMMAR_SANDBOX_H
2 #define _GRAMMAR_SANDBOX_H
3
4 /**
5 * Houses functionality for testing shim as well as code that should go into
6 * command.h and command.c during integration.
7 */
8 #include "memory.h"
9
10 #define CMD_CR_TEXT "<cr>"
11
12 void
13 grammar_sandbox_init (void);
14
15 /**
16 * Types for tokens.
17 *
18 * The type determines what kind of data the token can match (in the
19 * matching use case) or hold (in the argv use case).
20 */
21 enum cmd_token_type_t
22 {
23 WORD_TKN, // words
24 NUMBER_TKN, // integral numbers
25 VARIABLE_TKN, // almost anything
26 RANGE_TKN, // integer range
27 IPV4_TKN, // IPV4 addresses
28 IPV4_PREFIX_TKN, // IPV4 network prefixes
29 IPV6_TKN, // IPV6 prefixes
30 IPV6_PREFIX_TKN, // IPV6 network prefixes
31
32 /* plumbing types */
33 SELECTOR_TKN, // marks beginning of selector
34 OPTION_TKN, // marks beginning of option
35 NUL_TKN, // dummy token
36 START_TKN, // first token in line
37 END_TKN, // last token in line
38 };
39
40 /**
41 * Token struct.
42 */
43 struct cmd_token_t
44 {
45 enum cmd_token_type_t type; // token type
46
47 char *text; // token text
48 char *desc; // token description
49
50 long long value; // for numeric types
51 long long min, max; // for ranges
52
53 char *arg; // user input that matches this token
54 };
55
56 struct cmd_token_t *
57 new_cmd_token (enum cmd_token_type_t, char *, char *);
58
59 void
60 del_cmd_token (struct cmd_token_t *);
61
62 struct cmd_token_t *
63 copy_cmd_token (struct cmd_token_t *);
64
65 #endif /* _GRAMMAR_SANDBOX_H */