checkhf: handle C++-style comments
[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_TIMESTAMP
57 } extcap_arg_type;
58
59 typedef enum {
60     /* value types */
61     EXTCAP_PARAM_UNKNOWN,
62     EXTCAP_PARAM_ARGNUM,
63     EXTCAP_PARAM_CALL,
64     EXTCAP_PARAM_DISPLAY,
65     EXTCAP_PARAM_TYPE,
66     EXTCAP_PARAM_ARG,
67     EXTCAP_PARAM_DEFAULT,
68     EXTCAP_PARAM_VALUE,
69     EXTCAP_PARAM_RANGE,
70     EXTCAP_PARAM_TOOLTIP,
71     EXTCAP_PARAM_PLACEHOLDER,
72     EXTCAP_PARAM_NAME,
73     EXTCAP_PARAM_ENABLED,
74     EXTCAP_PARAM_FILE_MUSTEXIST,
75     EXTCAP_PARAM_FILE_EXTENSION,
76     EXTCAP_PARAM_PARENT,
77     EXTCAP_PARAM_REQUIRED,
78     EXTCAP_PARAM_SAVE,
79     EXTCAP_PARAM_VALIDATION,
80     EXTCAP_PARAM_VERSION,
81     EXTCAP_PARAM_HELP
82 } extcap_param_type;
83
84 #define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
85
86 /* Values for a given sentence; values are all stored as a call
87  * and a value string, or a valid range, so we only need to store
88  * those and repeat them */
89 typedef struct _extcap_value {
90     int arg_num;
91
92     gchar *call;
93     gchar *display;
94     gboolean enabled;
95     gboolean is_default;
96     gchar *parent;
97 } extcap_value;
98
99 /* Complex-ish struct for storing complex values */
100 typedef struct _extcap_complex {
101     extcap_arg_type complex_type;
102     gchar * _val;
103 } extcap_complex;
104
105 /* An argument sentence and accompanying options */
106 typedef struct _extcap_arg {
107     int arg_num;
108
109     gchar *call;
110     gchar *display;
111     gchar *tooltip;
112     gchar *placeholder;
113
114     gchar * fileextension;
115     gboolean fileexists;
116
117     gboolean is_required;
118     gboolean save;
119
120     gchar * regexp;
121
122     extcap_arg_type arg_type;
123
124     extcap_complex *range_start;
125     extcap_complex *range_end;
126     extcap_complex *default_complex;
127
128     gchar ** pref_valptr; /**< A copy of the pointer containing the current preference value. */
129     gchar * device_name;
130
131     GList * values;
132 } extcap_arg;
133
134 typedef struct _extcap_interface {
135     gchar * call;
136     gchar * display;
137     gchar * version;
138     gchar * help;
139     gchar * extcap_path;
140
141     extcap_sentence_type if_type;
142 } extcap_interface;
143
144 typedef struct _extcap_dlt {
145     gint number;
146     gchar *name;
147     gchar *display;
148 } extcap_dlt;
149
150 typedef struct _extcap_token_sentence {
151     gchar *sentence;
152
153     GHashTable *param_list;
154 } extcap_token_sentence;
155
156 #ifdef __cplusplus
157 extern "C" {
158 #endif
159
160 /* Parse a string into a complex type */
161 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
162         const gchar *data);
163
164 /* Free a complex */
165 void extcap_free_complex(extcap_complex *comp);
166
167 /* Print a complex value out for debug */
168 void extcap_printf_complex(extcap_complex *comp);
169
170 /*
171  * Return a string representation of a complex type
172  * Caller is responsible for calling g_free on the returned string
173  */
174 gchar *extcap_get_complex_as_string(extcap_complex *comp);
175
176 gint extcap_complex_get_int(extcap_complex *comp);
177 guint extcap_complex_get_uint(extcap_complex *comp);
178 gint64 extcap_complex_get_long(extcap_complex *comp);
179 gdouble extcap_complex_get_double(extcap_complex *comp);
180 gboolean extcap_complex_get_bool(extcap_complex *comp);
181 gchar *extcap_complex_get_string(extcap_complex *comp);
182
183 /* compares the default value of an element with a given parameter */
184 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
185
186
187 /* Free a single argument */
188 void extcap_free_arg(extcap_arg *a);
189
190 /* Free an entire arg list */
191 void extcap_free_arg_list(GList *a);
192
193
194 /** Parser for extcap data */
195
196 /* Parse all sentences for args and values */
197 GList * extcap_parse_args(gchar *output);
198
199 /* Parse all sentences for interfaces */
200 GList * extcap_parse_interfaces(gchar *output);
201
202 /* Parse all sentences for DLTs */
203 GList * extcap_parse_dlts(gchar *output);
204
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif
210
211 /*
212  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
213  *
214  * Local variables:
215  * c-basic-offset: 4
216  * tab-width: 8
217  * indent-tabs-mode: nil
218  * End:
219  *
220  * vi: set shiftwidth=4 tabstop=8 expandtab:
221  * :indentSize=4:tabSize=8:noTabs=true:
222  */