Qt: Clean up the byte view hover highlight.
[metze/wireshark/wip.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  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef __EXTCAP_PARSER_H__
23 #define __EXTCAP_PARSER_H__
24
25 #include <stdio.h>
26 #include <glib.h>
27 #include <string.h>
28
29 #include <config.h>
30
31 typedef enum {
32     EXTCAP_SENTENCE_UNKNOWN,
33     EXTCAP_SENTENCE_ARG,
34     EXTCAP_SENTENCE_VALUE,
35     EXTCAP_SENTENCE_EXTCAP,
36     EXTCAP_SENTENCE_INTERFACE,
37     EXTCAP_SENTENCE_DLT
38 } extcap_sentence_type;
39
40 typedef enum {
41     /* Simple types */
42     EXTCAP_ARG_UNKNOWN,
43     EXTCAP_ARG_INTEGER,
44     EXTCAP_ARG_UNSIGNED,
45     EXTCAP_ARG_LONG,
46     EXTCAP_ARG_DOUBLE,
47     EXTCAP_ARG_BOOLEAN,
48     EXTCAP_ARG_BOOLFLAG,
49     EXTCAP_ARG_STRING,
50     EXTCAP_ARG_PASSWORD,
51     /* Complex GUI types which are populated with value sentences */
52     EXTCAP_ARG_SELECTOR,
53     EXTCAP_ARG_RADIO,
54     EXTCAP_ARG_MULTICHECK,
55     EXTCAP_ARG_FILESELECT
56 } extcap_arg_type;
57
58 typedef enum {
59     /* value types */
60     EXTCAP_PARAM_UNKNOWN,
61     EXTCAP_PARAM_ARGNUM,
62     EXTCAP_PARAM_CALL,
63     EXTCAP_PARAM_DISPLAY,
64     EXTCAP_PARAM_TYPE,
65     EXTCAP_PARAM_ARG,
66     EXTCAP_PARAM_DEFAULT,
67     EXTCAP_PARAM_VALUE,
68     EXTCAP_PARAM_RANGE,
69     EXTCAP_PARAM_TOOLTIP,
70     EXTCAP_PARAM_NAME,
71     EXTCAP_PARAM_ENABLED,
72     EXTCAP_PARAM_FILE_MUSTEXIST,
73     EXTCAP_PARAM_FILE_EXTENSION,
74     EXTCAP_PARAM_PARENT,
75     EXTCAP_PARAM_REQUIRED,
76     EXTCAP_PARAM_SAVE,
77     EXTCAP_PARAM_VALIDATION,
78     EXTCAP_PARAM_VERSION,
79     EXTCAP_PARAM_HELP
80 } extcap_param_type;
81
82 #define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
83
84 /* Values for a given sentence; values are all stored as a call
85  * and a value string, or a valid range, so we only need to store
86  * those and repeat them */
87 typedef struct _extcap_value {
88     int arg_num;
89
90     gchar *call;
91     gchar *display;
92     gboolean enabled;
93     gboolean is_default;
94     gchar *parent;
95 } extcap_value;
96
97 /* Complex-ish struct for storing complex values */
98 typedef struct _extcap_complex {
99     extcap_arg_type complex_type;
100     gchar * _val;
101 } extcap_complex;
102
103 /* An argument sentence and accompanying options */
104 typedef struct _extcap_arg {
105     int arg_num;
106
107     gchar *call;
108     gchar *display;
109     gchar *tooltip;
110
111     gchar * fileextension;
112     gboolean fileexists;
113
114     gboolean is_required;
115     gboolean save;
116
117     gchar * regexp;
118
119     extcap_arg_type arg_type;
120
121     extcap_complex *range_start;
122     extcap_complex *range_end;
123     extcap_complex *default_complex;
124
125     gchar ** pref_valptr; /**< A copy of the pointer containing the current preference value. */
126     gchar * device_name;
127
128     GList * values;
129 } extcap_arg;
130
131 typedef struct _extcap_interface {
132     gchar * call;
133     gchar * display;
134     gchar * version;
135     gchar * help;
136     gchar * extcap_path;
137
138     extcap_sentence_type if_type;
139 } extcap_interface;
140
141 typedef struct _extcap_dlt {
142     gint number;
143     gchar *name;
144     gchar *display;
145 } extcap_dlt;
146
147 typedef struct _extcap_token_sentence {
148     gchar *sentence;
149
150     GHashTable *param_list;
151 } extcap_token_sentence;
152
153 #ifdef __cplusplus
154 extern "C" {
155 #endif
156
157 /* Parse a string into a complex type */
158 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
159         const gchar *data);
160
161 /* Free a complex */
162 void extcap_free_complex(extcap_complex *comp);
163
164 /* Print a complex value out for debug */
165 void extcap_printf_complex(extcap_complex *comp);
166
167 /*
168  * Return a string representation of a complex type
169  * Caller is responsible for calling g_free on the returned string
170  */
171 gchar *extcap_get_complex_as_string(extcap_complex *comp);
172
173 gint extcap_complex_get_int(extcap_complex *comp);
174 guint extcap_complex_get_uint(extcap_complex *comp);
175 gint64 extcap_complex_get_long(extcap_complex *comp);
176 gdouble extcap_complex_get_double(extcap_complex *comp);
177 gboolean extcap_complex_get_bool(extcap_complex *comp);
178 gchar *extcap_complex_get_string(extcap_complex *comp);
179
180 /* compares the default value of an element with a given parameter */
181 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
182
183
184 /* Free a single argument */
185 void extcap_free_arg(extcap_arg *a);
186
187 /* Free an entire arg list */
188 void extcap_free_arg_list(GList *a);
189
190
191 /** Parser for extcap data */
192
193 /* Parse all sentences for args and values */
194 GList * extcap_parse_args(gchar *output);
195
196 /* Parse all sentences for interfaces */
197 GList * extcap_parse_interfaces(gchar *output);
198
199 /* Parse all sentences for DLTs */
200 GList * extcap_parse_dlts(gchar *output);
201
202 #ifdef __cplusplus
203 }
204 #endif
205
206 #endif
207
208 /*
209  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
210  *
211  * Local variables:
212  * c-basic-offset: 4
213  * tab-width: 8
214  * indent-tabs-mode: nil
215  * End:
216  *
217  * vi: set shiftwidth=4 tabstop=8 expandtab:
218  * :indentSize=4:tabSize=8:noTabs=true:
219  */