sshdump: fix bug in --remote-sudo.
[gd/wireshark/.git] / extcap_parser.h
1 /* extcap_parser.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9
10 #ifndef __EXTCAP_PARSER_H__
11 #define __EXTCAP_PARSER_H__
12
13 #include <stdio.h>
14 #include <glib.h>
15 #include <string.h>
16
17 #include <config.h>
18 #include "ui/iface_toolbar.h"
19
20 typedef enum {
21     EXTCAP_SENTENCE_UNKNOWN,
22     EXTCAP_SENTENCE_ARG,
23     EXTCAP_SENTENCE_VALUE,
24     EXTCAP_SENTENCE_EXTCAP,
25     EXTCAP_SENTENCE_INTERFACE,
26     EXTCAP_SENTENCE_DLT,
27     EXTCAP_SENTENCE_CONTROL
28 } extcap_sentence_type;
29
30 typedef enum {
31     /* Simple types */
32     EXTCAP_ARG_UNKNOWN,
33     EXTCAP_ARG_INTEGER,
34     EXTCAP_ARG_UNSIGNED,
35     EXTCAP_ARG_LONG,
36     EXTCAP_ARG_DOUBLE,
37     EXTCAP_ARG_BOOLEAN,
38     EXTCAP_ARG_BOOLFLAG,
39     EXTCAP_ARG_STRING,
40     EXTCAP_ARG_PASSWORD,
41     /* Complex GUI types which are populated with value sentences */
42     EXTCAP_ARG_SELECTOR,
43     EXTCAP_ARG_RADIO,
44     EXTCAP_ARG_MULTICHECK,
45     EXTCAP_ARG_FILESELECT,
46     EXTCAP_ARG_TIMESTAMP
47 } extcap_arg_type;
48
49 typedef enum {
50     /* value types */
51     EXTCAP_PARAM_UNKNOWN,
52     EXTCAP_PARAM_ARGNUM,
53     EXTCAP_PARAM_CALL,
54     EXTCAP_PARAM_DISPLAY,
55     EXTCAP_PARAM_TYPE,
56     EXTCAP_PARAM_ARG,
57     EXTCAP_PARAM_DEFAULT,
58     EXTCAP_PARAM_VALUE,
59     EXTCAP_PARAM_RANGE,
60     EXTCAP_PARAM_TOOLTIP,
61     EXTCAP_PARAM_PLACEHOLDER,
62     EXTCAP_PARAM_NAME,
63     EXTCAP_PARAM_ENABLED,
64     EXTCAP_PARAM_FILE_MUSTEXIST,
65     EXTCAP_PARAM_FILE_EXTENSION,
66     EXTCAP_PARAM_GROUP,
67     EXTCAP_PARAM_PARENT,
68     EXTCAP_PARAM_REQUIRED,
69     EXTCAP_PARAM_RELOAD,
70     EXTCAP_PARAM_SAVE,
71     EXTCAP_PARAM_VALIDATION,
72     EXTCAP_PARAM_VERSION,
73     EXTCAP_PARAM_HELP,
74     EXTCAP_PARAM_CONTROL,
75     EXTCAP_PARAM_ROLE
76 } extcap_param_type;
77
78 #define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
79
80 /* Values for a given sentence; values are all stored as a call
81  * and a value string, or a valid range, so we only need to store
82  * those and repeat them */
83 typedef struct _extcap_value {
84     int arg_num;
85
86     gchar *call;
87     gchar *display;
88     gboolean enabled;
89     gboolean is_default;
90     gchar *parent;
91 } extcap_value;
92
93 /* Complex-ish struct for storing complex values */
94 typedef struct _extcap_complex {
95     extcap_arg_type complex_type;
96     gchar * _val;
97 } extcap_complex;
98
99 /* An argument sentence and accompanying options */
100 typedef struct _extcap_arg {
101     int arg_num;
102
103     gchar *call;
104     gchar *display;
105     gchar *tooltip;
106     gchar *placeholder;
107
108     gchar * fileextension;
109     gboolean fileexists;
110
111     gboolean is_required;
112     gboolean save;
113
114     gboolean reload;
115
116     gchar * regexp;
117
118     gchar * group;
119
120     extcap_arg_type arg_type;
121
122     extcap_complex *range_start;
123     extcap_complex *range_end;
124     extcap_complex *default_complex;
125
126     gchar ** pref_valptr; /**< A copy of the pointer containing the current preference value. */
127     gchar * device_name;
128
129     GList * values;
130 } extcap_arg;
131
132 typedef struct _extcap_interface {
133     gchar * call;
134     gchar * display;
135     gchar * version;
136     gchar * help;
137     gchar * extcap_path;
138
139     extcap_sentence_type if_type;
140 } extcap_interface;
141
142 typedef struct _extcap_dlt {
143     gint number;
144     gchar *name;
145     gchar *display;
146 } extcap_dlt;
147
148 typedef struct _extcap_token_sentence {
149     gchar *sentence;
150
151     GHashTable *param_list;
152 } extcap_token_sentence;
153
154 #ifdef __cplusplus
155 extern "C" {
156 #endif
157
158 /* Parse a string into a complex type */
159 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
160         const gchar *data);
161
162 /* Free a complex */
163 void extcap_free_complex(extcap_complex *comp);
164
165 /* Print a complex value out for debug */
166 void extcap_printf_complex(extcap_complex *comp);
167
168 /*
169  * Return a string representation of a complex type
170  * Caller is responsible for calling g_free on the returned string
171  */
172 gchar *extcap_get_complex_as_string(extcap_complex *comp);
173
174 gint extcap_complex_get_int(extcap_complex *comp);
175 guint extcap_complex_get_uint(extcap_complex *comp);
176 gint64 extcap_complex_get_long(extcap_complex *comp);
177 gdouble extcap_complex_get_double(extcap_complex *comp);
178 gboolean extcap_complex_get_bool(extcap_complex *comp);
179 gchar *extcap_complex_get_string(extcap_complex *comp);
180
181 /* compares the default value of an element with a given parameter */
182 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
183
184
185 /* Free a single argument */
186 void extcap_free_arg(extcap_arg *a);
187
188 /* Free entire toolbar control structure */
189 void extcap_free_toolbar_control(iface_toolbar_control *control);
190
191 /* Free an entire arg list */
192 void extcap_free_arg_list(GList *a);
193
194
195 /** Parser for extcap data */
196
197 /* Parse all sentences for args and values */
198 GList * extcap_parse_args(gchar *output);
199
200 /* Parse all sentences for values */
201 GList * extcap_parse_values(gchar *output);
202
203 /* Parse all sentences for interfaces */
204 GList * extcap_parse_interfaces(gchar *output, GList **control_items);
205
206 /* Parse all sentences for DLTs */
207 GList * extcap_parse_dlts(gchar *output);
208
209 #ifdef __cplusplus
210 }
211 #endif
212
213 #endif
214
215 /*
216  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
217  *
218  * Local variables:
219  * c-basic-offset: 4
220  * tab-width: 8
221  * indent-tabs-mode: nil
222  * End:
223  *
224  * vi: set shiftwidth=4 tabstop=8 expandtab:
225  * :indentSize=4:tabSize=8:noTabs=true:
226  */