more
[metze/wireshark/wip.git] / extcap_parser.h
index d10c5cd8cc3f779be7279feeb40fb7cfc34feb6b..a05f4de6ae2461f947ba15ac56457956f815c1ef 100644 (file)
@@ -4,19 +4,7 @@
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #ifndef __EXTCAP_PARSER_H__
 #include <glib.h>
 #include <string.h>
 
+#include <config.h>
+
 typedef enum {
     EXTCAP_SENTENCE_UNKNOWN,
     EXTCAP_SENTENCE_ARG,
     EXTCAP_SENTENCE_VALUE,
     EXTCAP_SENTENCE_EXTCAP,
     EXTCAP_SENTENCE_INTERFACE,
-    EXTCAP_SENTENCE_DLT
+    EXTCAP_SENTENCE_DLT,
+    EXTCAP_SENTENCE_CONTROL
 } extcap_sentence_type;
 
 typedef enum {
@@ -45,11 +36,13 @@ typedef enum {
     EXTCAP_ARG_BOOLEAN,
     EXTCAP_ARG_BOOLFLAG,
     EXTCAP_ARG_STRING,
+    EXTCAP_ARG_PASSWORD,
     /* Complex GUI types which are populated with value sentences */
     EXTCAP_ARG_SELECTOR,
     EXTCAP_ARG_RADIO,
     EXTCAP_ARG_MULTICHECK,
-    EXTCAP_ARG_FILESELECT
+    EXTCAP_ARG_FILESELECT,
+    EXTCAP_ARG_TIMESTAMP
 } extcap_arg_type;
 
 typedef enum {
@@ -64,16 +57,25 @@ typedef enum {
     EXTCAP_PARAM_VALUE,
     EXTCAP_PARAM_RANGE,
     EXTCAP_PARAM_TOOLTIP,
+    EXTCAP_PARAM_PLACEHOLDER,
     EXTCAP_PARAM_NAME,
     EXTCAP_PARAM_ENABLED,
     EXTCAP_PARAM_FILE_MUSTEXIST,
     EXTCAP_PARAM_FILE_EXTENSION,
+    EXTCAP_PARAM_GROUP,
     EXTCAP_PARAM_PARENT,
     EXTCAP_PARAM_REQUIRED,
+    EXTCAP_PARAM_RELOAD,
+    EXTCAP_PARAM_SAVE,
     EXTCAP_PARAM_VALIDATION,
-    EXTCAP_PARAM_VERSION
+    EXTCAP_PARAM_VERSION,
+    EXTCAP_PARAM_HELP,
+    EXTCAP_PARAM_CONTROL,
+    EXTCAP_PARAM_ROLE
 } extcap_param_type;
 
+#define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
+
 /* Values for a given sentence; values are all stored as a call
  * and a value string, or a valid range, so we only need to store
  * those and repeat them */
@@ -90,15 +92,7 @@ typedef struct _extcap_value {
 /* Complex-ish struct for storing complex values */
 typedef struct _extcap_complex {
     extcap_arg_type complex_type;
-    union {
-        int int_value;
-        unsigned int uint_value;
-        long long_value;
-        double double_value;
-        gboolean bool_value;
-        gchar *string_value;
-    } complex_value;
-    gboolean value_filled;
+    gchar * _val;
 } extcap_complex;
 
 /* An argument sentence and accompanying options */
@@ -108,73 +102,58 @@ typedef struct _extcap_arg {
     gchar *call;
     gchar *display;
     gchar *tooltip;
+    gchar *placeholder;
 
     gchar * fileextension;
     gboolean fileexists;
 
     gboolean is_required;
+    gboolean save;
+
+    gboolean reload;
 
     gchar * regexp;
 
+    gchar * group;
+
     extcap_arg_type arg_type;
 
     extcap_complex *range_start;
     extcap_complex *range_end;
     extcap_complex *default_complex;
 
+    gchar ** pref_valptr; /**< A copy of the pointer containing the current preference value. */
+    gchar * device_name;
+
     GList * values;
 } extcap_arg;
 
-typedef struct _extcap_if {
-    gchar * extcap_path;
-    GList * interfaces;
-} extcap_if;
-
 typedef struct _extcap_interface {
-    gchar *call;
-    gchar *display;
-    gchar *version;
+    gchar * call;
+    gchar * display;
+    gchar * version;
+    gchar * help;
+    gchar * extcap_path;
 
     extcap_sentence_type if_type;
-    struct _extcap_interface *next_interface;
 } extcap_interface;
 
 typedef struct _extcap_dlt {
     gint number;
     gchar *name;
     gchar *display;
-
-    struct _extcap_dlt *next_dlt;
 } extcap_dlt;
 
-/* Parser internals */
-typedef struct _extcap_token_param {
-    gchar *arg;
-    gchar *value;
-
-    extcap_param_type param_type;
-
-    struct _extcap_token_param *next_token;
-} extcap_token_param;
-
 typedef struct _extcap_token_sentence {
     gchar *sentence;
 
-    extcap_token_param *param_list;
-
-    struct _extcap_token_sentence *next_sentence;
+    GHashTable *param_list;
 } extcap_token_sentence;
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extcap_interface *extcap_new_interface(void);
-void extcap_free_interface(extcap_interface *interface);
-
-extcap_dlt *extcap_new_dlt(void);
-void extcap_free_dlt(extcap_dlt *dlt);
-
 /* Parse a string into a complex type */
 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
         const gchar *data);
@@ -191,36 +170,16 @@ void extcap_printf_complex(extcap_complex *comp);
  */
 gchar *extcap_get_complex_as_string(extcap_complex *comp);
 
-int extcap_complex_get_int(extcap_complex *comp);
-unsigned int extcap_complex_get_uint(extcap_complex *comp);
-long extcap_complex_get_long(extcap_complex *comp);
-double extcap_complex_get_double(extcap_complex *comp);
+gint extcap_complex_get_int(extcap_complex *comp);
+guint extcap_complex_get_uint(extcap_complex *comp);
+gint64 extcap_complex_get_long(extcap_complex *comp);
+gdouble extcap_complex_get_double(extcap_complex *comp);
 gboolean extcap_complex_get_bool(extcap_complex *comp);
 gchar *extcap_complex_get_string(extcap_complex *comp);
 
 /* compares the default value of an element with a given parameter */
 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
 
-void extcap_free_tokenized_param(extcap_token_param *v);
-void extcap_free_tokenized_sentence(extcap_token_sentence *s);
-void extcap_free_tokenized_sentence_list(extcap_token_sentence *f);
-
-/* Turn a sentence into logical tokens, don't validate beyond basic syntax */
-extcap_token_sentence *extcap_tokenize_sentence(const gchar *s);
-
-/* Tokenize a set of sentences (such as the output of a g_spawn_sync) */
-extcap_token_sentence *extcap_tokenize_sentences(const gchar *s);
-
-/* Find an argument in the extcap_arg list which matches the given arg=X number */
-extcap_arg *extcap_find_numbered_arg(extcap_arg *first, int number);
-
-/* Find the first occurrence in a parameter list of a parameter of the given type */
-extcap_token_param *extcap_find_param_by_type(extcap_token_param *first,
-        extcap_param_type t);
-
-void extcap_free_value(extcap_value *v);
-
-extcap_arg *extcap_new_arg(void);
 
 /* Free a single argument */
 void extcap_free_arg(extcap_arg *a);
@@ -228,31 +187,20 @@ void extcap_free_arg(extcap_arg *a);
 /* Free an entire arg list */
 void extcap_free_arg_list(GList *a);
 
-/*
- * Parse a tokenized sentence and validate.  If a new sentence is created, the result
- * is returned in 'ra'.  On error, < 0 is returned.  Not all sentences will create a
- * new returned sentence (VALUE sentences, for example)
- */
-extcap_arg * extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s);
+
+/** Parser for extcap data */
 
 /* Parse all sentences for args and values */
-GList * extcap_parse_args(extcap_token_sentence *first_s);
+GList * extcap_parse_args(gchar *output);
 
-/*
- * Parse a tokenized set of sentences and validate, looking for interface definitions.
- */
-int extcap_parse_interface_sentence(extcap_token_sentence *s,
-        extcap_interface **ri);
+/* Parse all sentences for values */
+GList * extcap_parse_values(gchar *output);
 
 /* Parse all sentences for interfaces */
-int extcap_parse_interfaces(extcap_token_sentence *first_s,
-        extcap_interface **first_int);
-
-/* Parse a tokenized set of sentences and validate, looking for DLT definitions */
-int extcap_parse_dlt_sentence(extcap_token_sentence *s, extcap_dlt **ri);
+GList * extcap_parse_interfaces(gchar *output, GList **control_items);
 
 /* Parse all sentences for DLTs */
-int extcap_parse_dlts(extcap_token_sentence *first_s, extcap_dlt **first_dlt);
+GList * extcap_parse_dlts(gchar *output);
 
 #ifdef __cplusplus
 }