-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathcligen_handle_internal.h
122 lines (105 loc) · 5.93 KB
/
cligen_handle_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL"),
in which case the provisions of the GPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
***** END LICENSE BLOCK *****
* This is an internal CLIgen header file
* Do not use these struct for external use, the internal structure may change.
* @see cligen_handle.h for external API use
*/
#ifndef _CLIGEN_HANDLE_INTERNAL_H_
#define _CLIGEN_HANDLE_INTERNAL_H_
#if 1
#define handle(h) ((struct cligen_handle *)(h))
#else /* Sanity test but requires assert all over */
#define handle(h) (assert(cligen_check(h)==0),(struct cligen_handle *)(h))
#endif
/*
* CLIgen handle code.
* Should be moved into its own, but there are some quirks with mutual dependencies
* with rest cligen_object.h that I didnt have time to sort out.
*/
/*
* Constants
*/
#define TERM_ROWS_DEFAULT 24
#define GETLINE_BUFLEN_DEFAULT 64 /* startsize, increased with 2x when run out */
#define CLIGEN_MAGIC 0x56ab55aa
/*
* Types
*/
/*! List of cligen parse-trees, can be searched, and activated */
typedef struct pt_head { /* Linked list of cligen parse-trees */
struct pt_head *ph_next;
char *ph_name; /* Parse-tree head */
parse_tree *ph_parsetree; /* Should be free:d */
char *ph_prompt; /* Tree-specific prompt */
cg_obj *ph_workpt; /* Shortcut to "working point" cligen object, or more
* specifically its parse-tree sub vector. */
char *ph_output_pipe; /* Name of output-pipe tree associated w this tree */
} pt_head;
/* CLIgen handle. Its members should be hidden and only the typedef visible */
struct cligen_handle{
int ch_magic; /* magic */
char ch_exiting; /* Set by callback to request exit of CLIgen */
char ch_comment; /* comment sign - everything behind it is ignored */
char *ch_prompt; /* current prompt used */
pt_head *ch_pt_head; /* Linked list of parsetrees */
pt_head *ch_pt_head_active; /* Pointer to the currently acrive parsetree */
char *ch_treename_keyword; /* Name of treename parsing keyword */
cg_obj *ch_co_match; /* Matching object in latest evaluation */
cvec *ch_callback_arguments; /* Callback arguments */
char *ch_fn_str; /* Name of active callback function (useful in callbacks) */
int ch_spipe; /* Socket of active output pipe if != -1 (useful in callbacks) */
int ch_completion; /* completion mode */
char *ch_nomatch; /* Why did a string not match an evaluation? */
int ch_tabmode; /* short or long output mode on TAB */
int ch_lexicalorder; /* strcmp (0) or strverscmp (1) syntax order.
Also, this is global for now */
int ch_ignorecase; /* dont care about aA (0), care about aA (1)
does not work if lexicalorder is set.
Also this is global for now
*/
char *ch_buf; /* getline input buffer */
char *ch_killbuf; /* getline killed text */
int ch_logsyntax; /* Debug syntax by printing dynamically on stderr */
int ch_hist_size; /* Number of history lines MUST be >0 */
char **ch_hist_buf; /* Array of history lines */
int ch_hist_cur; /* Current position (line) in history */
int ch_hist_last; /* Last position in history */
char *ch_hist_pre; /* Previous position in history */
cligen_hist_fn *ch_hist_fn; /* Callback for mirroring command history, e.g. logging */
void *ch_hist_arg; /* Argument to history callback */
void *ch_userhandle; /* Use this as app-specific callback handle */
void *ch_userdata; /* application-specific data (any data) */
int ch_regex_xsd; /* 0: POSIX / REGEX(3); 1: LIBXML2 XSD */
char ch_delimiter; /* Delimiter between objects */
int ch_preference_mode; /* Relaxed variable match preference handling */
int ch_ignore_case; /* Set if ignore case of commands, eg aA = aa */
int ch_expand_first; /* Set if expand arg 1 of callback cvv */
int ch_exclude_keys; /* Set if exclude keywords from callback cvv */
cligen_eval_wrap_fn *ch_eval_wrap_fn; /* Wrap function check state around cligen_eval */
void *ch_eval_wrap_arg; /* Argument to eval wrap function */
cligen_tree_resolve_wrapper_fn *ch_tree_resolve_wrapper_fn; /* Wrap function for treeref lookup */
void *ch_tree_resolve_wrapper_arg; /* Argument to treeref wrap function */
};
#endif /* _CLIGEN_HANDLE_INTERNAL_H_ */