extcap:Replace self-organized lists with glib ones
authorRoland Knall <roland.knall@br-automation.com>
Mon, 5 Sep 2016 11:29:23 +0000 (13:29 +0200)
committerAnders Broman <a.broman58@gmail.com>
Tue, 6 Sep 2016 04:19:45 +0000 (04:19 +0000)
Replace the error-prone next/prev handling with GList and GHashTable
Cleanup extcap_parser to only expose necessary functions
Remove token know-how from extcap

Change-Id: I7cc5ea06f58ad6c7a85ac292f5d2cb3d33e59833
Reviewed-on: https://code.wireshark.org/review/17496
Reviewed-by: Anders Broman <a.broman58@gmail.com>
extcap.c
extcap_parser.c
extcap_parser.h

index 28312a01a1d6484a5e6e74fa166faf967049bc34..2cdbf44051973bba6e3e53dbf9bbad843d924e98 100644 (file)
--- a/extcap.c
+++ b/extcap.c
@@ -90,11 +90,6 @@ static GHashTable *extcap_prefs_dynamic_vals = NULL;
 typedef gboolean (*extcap_cb_t)(const gchar *extcap, const gchar *ifname, gchar *output, void *data,
         gchar **err_str);
 
-/* #define ARG_DEBUG */
-#if ARG_DEBUG
-static void extcap_debug_arguments ( extcap_arg *arg_iter );
-#endif
-
 static gboolean
 extcap_if_exists(const gchar *ifname)
 {
@@ -201,18 +196,25 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
 
 }
 
+static void extcap_free_dlt(gpointer d, gpointer user_data _U_) {
+    if (d == NULL)
+        return;
+
+    g_free(((extcap_dlt *)d)->name);
+    g_free(((extcap_dlt *)d)->display);
+}
+
 static gboolean dlt_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *output, void *data,
         char **err_str) {
-    extcap_token_sentence *tokens;
-    extcap_dlt *dlts, *dlt_iter, *next;
+    GList *dlts = NULL, *temp = NULL;
+
     if_capabilities_t *caps;
     GList *linktype_list = NULL;
     data_link_info_t *data_link_info;
+    extcap_dlt * dlt_item;
 
-    tokens = extcap_tokenize_sentences(output);
-    extcap_parse_dlts(tokens, &dlts);
-
-    extcap_free_tokenized_sentence_list(tokens);
+    dlts = extcap_parse_dlts(output);
+    temp = dlts;
 
     g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap pipe %s ", extcap);
 
@@ -222,18 +224,21 @@ static gboolean dlt_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *
     caps = (if_capabilities_t *) g_malloc(sizeof *caps);
     caps->can_set_rfmon = FALSE;
 
-    dlt_iter = dlts;
-    while (dlt_iter != NULL ) {
-        g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
-                "  DLT %d name=\"%s\" display=\"%s\" ", dlt_iter->number,
-                dlt_iter->name, dlt_iter->display);
-
-        data_link_info = g_new(data_link_info_t, 1);
-        data_link_info->dlt = dlt_iter->number;
-        data_link_info->name = g_strdup(dlt_iter->name);
-        data_link_info->description = g_strdup(dlt_iter->display);
-        linktype_list = g_list_append(linktype_list, data_link_info);
-        dlt_iter = dlt_iter->next_dlt;
+    while (dlts) {
+        dlt_item = (extcap_dlt *)dlts->data;
+        if (dlt_item) {
+            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
+                "  DLT %d name=\"%s\" display=\"%s\" ", dlt_item->number,
+                dlt_item->name, dlt_item->display);
+
+            data_link_info = g_new(data_link_info_t, 1);
+            data_link_info->dlt = dlt_item->number;
+            data_link_info->name = g_strdup(dlt_item->name);
+            data_link_info->description = g_strdup(dlt_item->display);
+            linktype_list = g_list_append(linktype_list, data_link_info);
+        }
+
+        dlts = g_list_next(dlts);
     }
 
     /* Check to see if we built a list */
@@ -248,12 +253,7 @@ static gboolean dlt_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *
         g_free(caps);
     }
 
-    dlt_iter = dlts;
-    while (dlt_iter != NULL ) {
-        next = dlt_iter->next_dlt;
-        extcap_free_dlt(dlt_iter);
-        dlt_iter = next;
-    }
+    g_list_foreach(temp, extcap_free_dlt, NULL);
 
     return FALSE;
 }
@@ -282,27 +282,37 @@ extcap_get_if_dlts(const gchar *ifname, char **err_str) {
     return caps;
 }
 
+static void extcap_free_interface(gpointer i, gpointer user_data _U_) {
+
+    extcap_interface * interface = (extcap_interface *)i;
+
+    if ( i == NULL )
+        return;
+
+    g_free(interface->call);
+    g_free(interface->display);
+    g_free(interface->version);
+}
+
 static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gchar *output, void *data,
         char **err_str _U_) {
     GList **il = (GList **) data;
-    extcap_token_sentence *tokens;
-    extcap_interface *interfaces, *int_iter; /*, *next; */
-    if_info_t *if_info;
-
-    tokens = extcap_tokenize_sentences(output);
-    extcap_parse_interfaces(tokens, &interfaces);
+    GList *interfaces = NULL, *walker = NULL;
+    extcap_interface *int_iter = NULL;
+    if_info_t *if_info = NULL;
 
-    extcap_free_tokenized_sentence_list(tokens);
+    interfaces = extcap_parse_interfaces(output);
 
     g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap pipe %s ", extcap);
 
-    int_iter = interfaces;
-    while (int_iter != NULL ) {
+    walker = interfaces;
+    while (walker != NULL ) {
+        int_iter = (extcap_interface *)walker->data;
         if ( int_iter->if_type == EXTCAP_SENTENCE_INTERFACE && extcap_if_exists(int_iter->call) )
         {
             g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Extcap interface \"%s\" is already provided by \"%s\" ",
                     int_iter->call, (gchar *)extcap_if_executable(int_iter->call) );
-            int_iter = int_iter->next_interface;
+            walker = g_list_next(walker);
             continue;
         }
 
@@ -331,9 +341,10 @@ static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gcha
          * interfaces) are handled internally */
         extcap_tool_add(extcap, int_iter);
 
-        int_iter = int_iter->next_interface;
+        walker = g_list_next(walker);
     }
-    extcap_free_interface(interfaces);
+
+    g_list_foreach(interfaces, extcap_free_interface, NULL);
 
     return TRUE;
 }
@@ -517,19 +528,11 @@ extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg * arg) {
 
 static gboolean search_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *output, void *data,
         char **err_str _U_) {
-    extcap_token_sentence *tokens = NULL;
     GList *arguments = NULL;
     GList **il = (GList **) data;
     module_t * dev_module = NULL;
 
-    tokens = extcap_tokenize_sentences(output);
-    arguments = extcap_parse_args(tokens);
-
-    extcap_free_tokenized_sentence_list(tokens);
-
-#if ARG_DEBUG
-    extcap_debug_arguments ( arguments );
-#endif
+    arguments = extcap_parse_args(output);
 
     dev_module = prefs_find_module("extcap");
 
@@ -894,10 +897,6 @@ static
 GPtrArray * extcap_prepare_arguments(interface_options interface_opts)
 {
     GPtrArray *result = NULL;
-#if ARG_DEBUG
-    gchar **tmp;
-    int tmp_i;
-#endif
 
     if (interface_opts.if_type == IF_EXTCAP )
     {
@@ -975,14 +974,6 @@ GPtrArray * extcap_prepare_arguments(interface_options interface_opts)
         add_arg(NULL);
 #undef add_arg
 
-#if ARG_DEBUG
-        /* Dump commandline parameters sent to extcap. */
-        for (tmp = (gchar **)result->pdata, tmp_i = 0; *tmp && **tmp; ++tmp_i, ++tmp)
-        {
-            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "argv[%d]: %s", tmp_i, *tmp);
-        }
-#endif
-
     }
 
     return result;
@@ -1129,77 +1120,6 @@ gboolean extcap_create_pipe(char ** fifo)
     return TRUE;
 }
 
-#if ARG_DEBUG
-void extcap_debug_arguments ( extcap_arg *arg_iter )
-{
-    extcap_value *v = NULL;
-    GList *walker = NULL;
-
-    printf("debug - parser dump\n");
-    while (arg_iter != NULL) {
-        printf("ARG %d call=%s display=\"%s\" type=", arg_iter->arg_num, arg_iter->call, arg_iter->display);
-
-        switch (arg_iter->arg_type) {
-            case EXTCAP_ARG_INTEGER:
-            printf("int\n");
-            break;
-            case EXTCAP_ARG_UNSIGNED:
-            printf("unsigned\n");
-            break;
-            case EXTCAP_ARG_LONG:
-            printf("long\n");
-            break;
-            case EXTCAP_ARG_DOUBLE:
-            printf("double\n");
-            break;
-            case EXTCAP_ARG_BOOLEAN:
-            printf("boolean\n");
-            break;
-            case EXTCAP_ARG_MENU:
-            printf("menu\n");
-            break;
-            case EXTCAP_ARG_RADIO:
-            printf("radio\n");
-            break;
-            case EXTCAP_ARG_SELECTOR:
-            printf("selctor\n");
-            break;
-            case EXTCAP_ARG_STRING:
-            printf ( "string\n" );
-            break;
-            case EXTCAP_ARG_PASSWORD:
-            printf ( "PASSWORD\n" );
-            break;
-            case EXTCAP_ARG_MULTICHECK:
-            printf ( "unknown\n" );
-            break;
-            case EXTCAP_ARG_UNKNOWN:
-            printf ( "unknown\n" );
-            break;
-        }
-
-        if (arg_iter->range_start != NULL && arg_iter->range_end != NULL) {
-            printf("\tRange: ");
-            extcap_printf_complex(arg_iter->range_start);
-            printf(" - ");
-            extcap_printf_complex(arg_iter->range_end);
-            printf("\n");
-        }
-
-        for ( walker = g_list_first ( arg_iter->value_list ); walker; walker = walker->next )
-        {
-            v = (extcap_value *)walker->data;
-            if (v->is_default)
-            printf("*");
-            printf("\tcall=\"%p\" display=\"%p\"\n", v->call, v->display);
-            printf("\tcall=\"%s\" display=\"%s\"\n", v->call, v->display);
-        }
-
-        arg_iter = arg_iter->next_arg;
-    }
-}
-#endif
-
 /*
  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
  *
index 3fe0817465f02c0eaadfd750e4c9acf4fa848a7b..f2271399d9f6da316fbc72731e592ec43f0bff2b 100644 (file)
@@ -108,55 +108,17 @@ gchar *extcap_complex_get_string(extcap_complex *comp) {
     return comp != NULL ? comp->_val : NULL;
 }
 
-void extcap_free_tokenized_param(extcap_token_param *v) {
-    if (v != NULL)
-    {
-        g_free(v->arg);
-        g_free(v->value);
-    }
-
-    g_free(v);
-}
-
-void extcap_free_tokenized_sentence(extcap_token_sentence *s) {
-    extcap_token_param *tv;
-
-    if (s == NULL)
-        return;
-
-    if (s->sentence != NULL)
-        g_free(s->sentence);
-
-    while (s->param_list != NULL ) {
-        tv = s->param_list;
-        s->param_list = tv->next_token;
-
-        extcap_free_tokenized_param(tv);
-    }
-    g_free(s);
-}
-
-void extcap_free_tokenized_sentence_list(extcap_token_sentence *f) {
-    extcap_token_sentence *t;
-
-    while (f != NULL ) {
-        t = f->next_sentence;
-        extcap_free_tokenized_sentence(f);
-        f = t;
-    }
-}
-
-extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
-    extcap_token_param *tv = NULL;
+static extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
     GRegex * regex = NULL;
     GMatchInfo * match_info = NULL;
     GError * error = NULL;
+    gchar * param_value = NULL;
+    guint param_type = EXTCAP_PARAM_UNKNOWN;
 
-    extcap_token_sentence *rs = g_new(extcap_token_sentence, 1);
+    extcap_token_sentence *rs = g_new0(extcap_token_sentence, 1);
 
     rs->sentence = NULL;
-    rs->next_sentence = NULL;
-    rs->param_list = NULL;
+    rs->param_list = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
 
     /* Regex for catching just the allowed values for sentences */
     if ( ( regex = g_regex_new ( "^[\\t| ]*(arg|value|interface|extcap|dlt)(?=[\\t| ]+\\{)",
@@ -171,7 +133,7 @@ extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
     }
     /* No valid sentence found, exiting here */
     if ( rs->sentence == NULL ) {
-        extcap_free_tokenized_sentence(rs);
+        g_free(rs);
         return NULL;
     }
 
@@ -188,52 +150,49 @@ extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
             if ( arg == NULL )
                 break;
 
-            tv = g_new(extcap_token_param, 1);
-            tv->arg = arg;
-            tv->value = g_match_info_fetch ( match_info, 2 );
-
-            if (g_ascii_strcasecmp(tv->arg, "number") == 0) {
-                tv->param_type = EXTCAP_PARAM_ARGNUM;
-            } else if (g_ascii_strcasecmp(tv->arg, "call") == 0) {
-                tv->param_type = EXTCAP_PARAM_CALL;
-            } else if (g_ascii_strcasecmp(tv->arg, "display") == 0) {
-                tv->param_type = EXTCAP_PARAM_DISPLAY;
-            } else if (g_ascii_strcasecmp(tv->arg, "type") == 0) {
-                tv->param_type = EXTCAP_PARAM_TYPE;
-            } else if (g_ascii_strcasecmp(tv->arg, "arg") == 0) {
-                tv->param_type = EXTCAP_PARAM_ARG;
-            } else if (g_ascii_strcasecmp(tv->arg, "default") == 0) {
-                tv->param_type = EXTCAP_PARAM_DEFAULT;
-            } else if (g_ascii_strcasecmp(tv->arg, "value") == 0) {
-                tv->param_type = EXTCAP_PARAM_VALUE;
-            } else if (g_ascii_strcasecmp(tv->arg, "range") == 0) {
-                tv->param_type = EXTCAP_PARAM_RANGE;
-            } else if (g_ascii_strcasecmp(tv->arg, "tooltip") == 0) {
-                tv->param_type = EXTCAP_PARAM_TOOLTIP;
-            } else if (g_ascii_strcasecmp(tv->arg, "mustexist") == 0) {
-                tv->param_type = EXTCAP_PARAM_FILE_MUSTEXIST;
-            } else if (g_ascii_strcasecmp(tv->arg, "fileext") == 0) {
-                tv->param_type = EXTCAP_PARAM_FILE_EXTENSION;
-            } else if (g_ascii_strcasecmp(tv->arg, "name") == 0) {
-                tv->param_type = EXTCAP_PARAM_NAME;
-            } else if (g_ascii_strcasecmp(tv->arg, "enabled") == 0) {
-                tv->param_type = EXTCAP_PARAM_ENABLED;
-            } else if (g_ascii_strcasecmp(tv->arg, "parent") == 0) {
-                tv->param_type = EXTCAP_PARAM_PARENT;
-            } else if (g_ascii_strcasecmp(tv->arg, "required") == 0) {
-                tv->param_type = EXTCAP_PARAM_REQUIRED;
-            } else if (g_ascii_strcasecmp(tv->arg, "save") == 0) {
-                tv->param_type = EXTCAP_PARAM_SAVE;
-            } else if (g_ascii_strcasecmp(tv->arg, "validation") == 0) {
-                tv->param_type = EXTCAP_PARAM_VALIDATION;
-            } else if (g_ascii_strcasecmp(tv->arg, "version") == 0) {
-                tv->param_type = EXTCAP_PARAM_VERSION;
+            param_value = g_strdup(g_match_info_fetch ( match_info, 2 ));
+
+            if (g_ascii_strcasecmp(arg, "number") == 0) {
+                param_type = EXTCAP_PARAM_ARGNUM;
+            } else if (g_ascii_strcasecmp(arg, "call") == 0) {
+                param_type = EXTCAP_PARAM_CALL;
+            } else if (g_ascii_strcasecmp(arg, "display") == 0) {
+                param_type = EXTCAP_PARAM_DISPLAY;
+            } else if (g_ascii_strcasecmp(arg, "type") == 0) {
+                param_type = EXTCAP_PARAM_TYPE;
+            } else if (g_ascii_strcasecmp(arg, "arg") == 0) {
+                param_type = EXTCAP_PARAM_ARG;
+            } else if (g_ascii_strcasecmp(arg, "default") == 0) {
+                param_type = EXTCAP_PARAM_DEFAULT;
+            } else if (g_ascii_strcasecmp(arg, "value") == 0) {
+                param_type = EXTCAP_PARAM_VALUE;
+            } else if (g_ascii_strcasecmp(arg, "range") == 0) {
+                param_type = EXTCAP_PARAM_RANGE;
+            } else if (g_ascii_strcasecmp(arg, "tooltip") == 0) {
+                param_type = EXTCAP_PARAM_TOOLTIP;
+            } else if (g_ascii_strcasecmp(arg, "mustexist") == 0) {
+                param_type = EXTCAP_PARAM_FILE_MUSTEXIST;
+            } else if (g_ascii_strcasecmp(arg, "fileext") == 0) {
+                param_type = EXTCAP_PARAM_FILE_EXTENSION;
+            } else if (g_ascii_strcasecmp(arg, "name") == 0) {
+                param_type = EXTCAP_PARAM_NAME;
+            } else if (g_ascii_strcasecmp(arg, "enabled") == 0) {
+                param_type = EXTCAP_PARAM_ENABLED;
+            } else if (g_ascii_strcasecmp(arg, "parent") == 0) {
+                param_type = EXTCAP_PARAM_PARENT;
+            } else if (g_ascii_strcasecmp(arg, "required") == 0) {
+                param_type = EXTCAP_PARAM_REQUIRED;
+            } else if (g_ascii_strcasecmp(arg, "save") == 0) {
+                param_type = EXTCAP_PARAM_SAVE;
+            } else if (g_ascii_strcasecmp(arg, "validation") == 0) {
+                param_type = EXTCAP_PARAM_VALIDATION;
+            } else if (g_ascii_strcasecmp(arg, "version") == 0) {
+                param_type = EXTCAP_PARAM_VERSION;
             } else {
-                tv->param_type = EXTCAP_PARAM_UNKNOWN;
+                param_type = EXTCAP_PARAM_UNKNOWN;
             }
 
-            tv->next_token = rs->param_list;
-            rs->param_list = tv;
+            g_hash_table_insert(rs->param_list, ENUM_KEY(param_type), param_value);
 
             g_match_info_next(match_info, &error);
         }
@@ -244,48 +203,26 @@ extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
     return rs;
 }
 
-extcap_token_sentence *extcap_tokenize_sentences(const gchar *s) {
-    extcap_token_sentence *first = NULL, *cur = NULL, *last = NULL;
+static GList *extcap_tokenize_sentences(const gchar *s) {
 
+    GList * sentences = NULL;
+    extcap_token_sentence *item = NULL;
     gchar **list, **list_iter;
 
     list_iter = list = g_strsplit(s, "\n", 0);
-
-    while (*list_iter != NULL ) {
-        cur = extcap_tokenize_sentence(*list_iter);
-
-        if (cur != NULL) {
-            if (first == NULL) {
-                first = cur;
-                last = cur;
-            } else {
-                last->next_sentence = cur;
-                last = cur;
-            }
-        }
-
+    while ( *list_iter != NULL ) {
+        item = extcap_tokenize_sentence(*list_iter);
+        if (item)
+            sentences = g_list_append(sentences, item);
         list_iter++;
     }
 
     g_strfreev(list);
 
-    return first;
+    return sentences;
 }
 
-extcap_token_param *extcap_find_param_by_type(extcap_token_param *first,
-        extcap_param_type t) {
-    while (first != NULL ) {
-        if (first->param_type == t) {
-            return first;
-        }
-
-        first = first->next_token;
-    }
-
-    return NULL ;
-}
-
-void extcap_free_value(extcap_value *v) {
+static void extcap_free_value(extcap_value *v) {
     if (v == NULL)
         return;
 
@@ -295,47 +232,6 @@ void extcap_free_value(extcap_value *v) {
     g_free(v);
 }
 
-extcap_interface *extcap_new_interface(void) {
-    extcap_interface *r = g_new(extcap_interface, 1);
-
-    r->call = r->display = r->version = NULL;
-    r->if_type = EXTCAP_SENTENCE_UNKNOWN;
-    r->next_interface = NULL;
-
-    return r;
-}
-
-void extcap_free_interface(extcap_interface *i) {
-    extcap_interface *next_i = i;
-
-    while (i) {
-        next_i = i->next_interface;
-        g_free(i->call);
-        g_free(i->display);
-        g_free(i->version);
-        g_free(i);
-        i = next_i;
-    }
-}
-
-extcap_dlt *extcap_new_dlt(void) {
-    extcap_dlt *r = g_new(extcap_dlt, 1);
-
-    r->number = -1;
-    r->name = r->display = NULL;
-    r->next_dlt = NULL;
-
-    return r;
-}
-
-void extcap_free_dlt(extcap_dlt *d) {
-    if (d == NULL)
-        return;
-
-    g_free(d->name);
-    g_free(d->display);
-}
-
 static void extcap_free_valuelist(gpointer data, gpointer user_data _U_) {
     extcap_free_value((extcap_value *) data);
 }
@@ -380,8 +276,18 @@ static gint glist_find_numbered_arg(gconstpointer listelem, gconstpointer needle
     return 1;
 }
 
-extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
-    extcap_token_param *v = NULL;
+static void extcap_free_tokenized_sentence(gpointer s, gpointer user_data _U_) {
+
+    if (s == NULL)
+        return;
+
+    g_free(((extcap_token_sentence *)s)->sentence);
+    g_hash_table_destroy(((extcap_token_sentence *)s)->param_list);
+}
+
+static extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
+    gchar * param_value = NULL;
+
     extcap_arg *target_arg = NULL;
     extcap_value *value = NULL;
     GList * entry = NULL;
@@ -404,23 +310,22 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
         target_arg->arg_type = EXTCAP_ARG_UNKNOWN;
         target_arg->save = TRUE;
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARGNUM))
-                == NULL) {
+
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_ARGNUM))) == NULL) {
             extcap_free_arg(target_arg);
             return NULL ;
         }
 
-        if (sscanf(v->value, "%d", &(target_arg->arg_num)) != 1) {
+        if (sscanf(param_value, "%d", &(target_arg->arg_num)) != 1) {
             extcap_free_arg(target_arg);
             return NULL ;
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_CALL))
-                == NULL) {
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_CALL))) == NULL) {
             extcap_free_arg(target_arg);
             return NULL ;
         }
-        target_arg->call = g_strdup(v->value);
+        target_arg->call = g_strdup(param_value);
 
         /* No value only parameters allowed */
         if (strlen(target_arg->call) == 0) {
@@ -428,97 +333,96 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
             return NULL ;
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
-                == NULL) {
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DISPLAY))) == NULL) {
             extcap_free_arg(target_arg);
             return NULL ;
         }
-        target_arg->display = g_strdup(v->value);
+        target_arg->display = g_strdup(param_value);
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_TOOLTIP))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_TOOLTIP)))
                 != NULL) {
-            target_arg->tooltip = g_strdup(v->value);
+            target_arg->tooltip = g_strdup(param_value);
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_FILE_MUSTEXIST))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_FILE_MUSTEXIST)))
                 != NULL) {
-            target_arg->fileexists = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
+            target_arg->fileexists = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, param_value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_FILE_EXTENSION))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_FILE_EXTENSION)))
                 != NULL) {
-            target_arg->fileextension = g_strdup(v->value);
+            target_arg->fileextension = g_strdup(param_value);
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALIDATION))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_VALIDATION)))
                 != NULL) {
-            target_arg->regexp = g_strdup(v->value);
+            target_arg->regexp = g_strdup(param_value);
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_REQUIRED))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_REQUIRED)))
                 != NULL) {
-            target_arg->is_required = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
+            target_arg->is_required = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, param_value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_TYPE))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_TYPE)))
                 == NULL) {
             /* printf("no type in ARG sentence\n"); */
             extcap_free_arg(target_arg);
             return NULL ;
         }
 
-        if (g_ascii_strcasecmp(v->value, "integer") == 0) {
+        if (g_ascii_strcasecmp(param_value, "integer") == 0) {
             target_arg->arg_type = EXTCAP_ARG_INTEGER;
-        } else if (g_ascii_strcasecmp(v->value, "unsigned") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "unsigned") == 0) {
             target_arg->arg_type = EXTCAP_ARG_UNSIGNED;
-        } else if (g_ascii_strcasecmp(v->value, "long") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "long") == 0) {
             target_arg->arg_type = EXTCAP_ARG_LONG;
-        } else if (g_ascii_strcasecmp(v->value, "double") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "double") == 0) {
             target_arg->arg_type = EXTCAP_ARG_DOUBLE;
-        } else if (g_ascii_strcasecmp(v->value, "boolean") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "boolean") == 0) {
             target_arg->arg_type = EXTCAP_ARG_BOOLEAN;
-        } else if (g_ascii_strcasecmp(v->value, "boolflag") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "boolflag") == 0) {
             target_arg->arg_type = EXTCAP_ARG_BOOLFLAG;
-        } else if (g_ascii_strcasecmp(v->value, "selector") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "selector") == 0) {
             target_arg->arg_type = EXTCAP_ARG_SELECTOR;
-        } else if (g_ascii_strcasecmp(v->value, "radio") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "radio") == 0) {
             target_arg->arg_type = EXTCAP_ARG_RADIO;
-        } else if (g_ascii_strcasecmp(v->value, "string") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "string") == 0) {
             target_arg->arg_type = EXTCAP_ARG_STRING;
-        } else if (g_ascii_strcasecmp(v->value, "password") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "password") == 0) {
             target_arg->arg_type = EXTCAP_ARG_PASSWORD;
             /* default setting is to not save passwords */
             target_arg->save = FALSE;
-        } else if (g_ascii_strcasecmp(v->value, "fileselect") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "fileselect") == 0) {
             target_arg->arg_type = EXTCAP_ARG_FILESELECT;
-        } else if (g_ascii_strcasecmp(v->value, "multicheck") == 0) {
+        } else if (g_ascii_strcasecmp(param_value, "multicheck") == 0) {
             target_arg->arg_type = EXTCAP_ARG_MULTICHECK;
         } else {
-            printf("invalid type %s in ARG sentence\n", v->value);
+            printf("invalid type %s in ARG sentence\n", param_value);
             extcap_free_arg(target_arg);
             return NULL ;
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_SAVE))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_SAVE)))
                 != NULL) {
-            target_arg->save = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
+            target_arg->save = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, param_value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_RANGE))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_RANGE)))
                 != NULL) {
-            gchar *cp = g_strstr_len(v->value, -1, ",");
+            gchar *cp = g_strstr_len(param_value, -1, ",");
 
             if (cp == NULL) {
                 printf("invalid range, expected value,value got %s\n",
-                        v->value);
+                        param_value);
                 extcap_free_arg(target_arg);
                 return NULL ;
             }
 
             if ((target_arg->range_start = extcap_parse_complex(
-                    target_arg->arg_type, v->value)) == NULL) {
+                    target_arg->arg_type, param_value)) == NULL) {
                 printf("invalid range, expected value,value got %s\n",
-                        v->value);
+                        param_value);
                 extcap_free_arg(target_arg);
                 return NULL ;
             }
@@ -526,31 +430,31 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
             if ((target_arg->range_end = extcap_parse_complex(
                     target_arg->arg_type, cp + 1)) == NULL) {
                 printf("invalid range, expected value,value got %s\n",
-                        v->value);
+                        param_value);
                 extcap_free_arg(target_arg);
                 return NULL ;
             }
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DEFAULT))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DEFAULT)))
                 != NULL) {
             if ( target_arg->arg_type != EXTCAP_ARG_MULTICHECK && target_arg->arg_type != EXTCAP_ARG_SELECTOR )
             {
                 if ((target_arg->default_complex = extcap_parse_complex(
-                        target_arg->arg_type, v->value)) == NULL) {
-                    printf("invalid default, couldn't parse %s\n", v->value);
+                        target_arg->arg_type, param_value)) == NULL) {
+                    printf("invalid default, couldn't parse %s\n", param_value);
                 }
             }
         }
 
     } else if (sent == EXTCAP_SENTENCE_VALUE) {
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARG))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_ARG)))
                 == NULL) {
             printf("no arg in VALUE sentence\n");
             return NULL ;
         }
 
-        if (sscanf(v->value, "%d", &tint) != 1) {
+        if (sscanf(param_value, "%d", &tint) != 1) {
             printf("invalid arg in VALUE sentence\n");
             return NULL ;
         }
@@ -565,36 +469,36 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
         value = g_new0(extcap_value, 1);
         value->arg_num = tint;
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALUE))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_VALUE)))
                 == NULL) {
             /* printf("no value in VALUE sentence\n"); */
             extcap_free_value(value);
             return NULL ;
         }
-        value->call = g_strdup(v->value);
+        value->call = g_strdup(param_value);
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DISPLAY)))
                 == NULL) {
             /* printf("no display in VALUE sentence\n"); */
             extcap_free_value(value);
             return NULL ;
         }
-        value->display = g_strdup(v->value);
+        value->display = g_strdup(param_value);
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_PARENT))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_PARENT)))
                 != NULL) {
-            value->parent = g_strdup(v->value);
+            value->parent = g_strdup(param_value);
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DEFAULT))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DEFAULT)))
                 != NULL) {
             /* printf("found default value\n"); */
-            value->is_default = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
+            value->is_default = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, param_value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
         }
 
-        if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ENABLED))
+        if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_ENABLED)))
                 != NULL) {
-            value->enabled = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
+            value->enabled = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, param_value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
         }
 
         ((extcap_arg*) entry->data)->values = g_list_append(
@@ -606,30 +510,36 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
     return target_arg;
 }
 
-GList * extcap_parse_args(extcap_token_sentence *first_s) {
-    GList * args = NULL;
+GList * extcap_parse_args(gchar *output) {
+    GList * result = NULL;
+    GList * walker = NULL;
+    GList * temp = NULL;
 
-    while (first_s) {
+    walker = extcap_tokenize_sentences(output);
+    temp = walker;
+
+    while (walker) {
         extcap_arg *ra = NULL;
+        extcap_token_sentence * sentence = (extcap_token_sentence *)walker->data;
 
-        if ((ra = extcap_parse_arg_sentence(args, first_s)) != NULL)
-            args = g_list_append(args, (gpointer) ra);
+        if ((ra = extcap_parse_arg_sentence(result, sentence)) != NULL)
+            result = g_list_append(result, (gpointer) ra);
 
-        first_s = first_s->next_sentence;
+        walker = g_list_next(walker);
     }
 
-    return args;
+    g_list_foreach(temp, extcap_free_tokenized_sentence, NULL);
+
+    return result;
 }
 
-int extcap_parse_interface_sentence(extcap_token_sentence *s,
-        extcap_interface **ri) {
-    extcap_token_param *v = NULL;
+static extcap_interface * extcap_parse_interface_sentence(extcap_token_sentence *s) {
     extcap_sentence_type sent = EXTCAP_SENTENCE_UNKNOWN;
-
-    *ri = NULL;
+    gchar * param_value = NULL;
+    extcap_interface * ri = NULL;
 
     if (s == NULL)
-        return -1;
+        return NULL;
 
     if (g_ascii_strcasecmp(s->sentence, "interface") == 0) {
         sent = EXTCAP_SENTENCE_INTERFACE;
@@ -638,132 +548,139 @@ int extcap_parse_interface_sentence(extcap_token_sentence *s,
     }
 
     if (sent == EXTCAP_SENTENCE_UNKNOWN)
-        return -1;
+        return NULL;
 
-    *ri = extcap_new_interface();
+    ri = g_new(extcap_interface, 1);
 
-    (*ri)->if_type = sent;
+    ri->call = NULL;
+    ri->display = NULL;
+    ri->version = NULL;
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALUE))
+    ri->if_type = sent;
+
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_VALUE)))
             == NULL && sent == EXTCAP_SENTENCE_INTERFACE) {
         printf("No value in INTERFACE sentence\n");
-        extcap_free_interface(*ri);
-        return -1;
+        g_free(ri);
+        return NULL;
     }
-    if ( v != NULL )
-       (*ri)->call = g_strdup(v->value);
+    ri->call = g_strdup(param_value);
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DISPLAY)))
             == NULL && sent == EXTCAP_SENTENCE_INTERFACE) {
         printf("No display in INTERFACE sentence\n");
-        extcap_free_interface(*ri);
-        return -1;
+        g_free(ri->call);
+        g_free(ri);
+        return NULL;
     }
-    if ( v != NULL )
-        (*ri)->display = g_strdup(v->value);
+    ri->display = g_strdup(param_value);
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VERSION))
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_VERSION)))
             != NULL) {
-        (*ri)->version = g_strdup(v->value);
+        ri->version = g_strdup(param_value);
     }
 
-    return 1;
+    return ri;
 }
 
-int extcap_parse_interfaces(extcap_token_sentence *first_s,
-        extcap_interface **first_int) {
-    extcap_interface *first_i = NULL, *last_i = NULL;
+GList * extcap_parse_interfaces(gchar *output) {
 
-    while (first_s) {
-        extcap_interface *ri;
+    GList * result = NULL;
+    GList * tokens = NULL;
+    GList * walker = extcap_tokenize_sentences(output);
+    tokens = walker;
 
-        if (extcap_parse_interface_sentence(first_s, &ri) >= 0 && ri != NULL) {
-            if (first_i == NULL) {
-                first_i = last_i = ri;
-            } else {
-                last_i->next_interface = ri;
-                last_i = ri;
-            }
-        }
+    while (walker) {
+        extcap_interface * ri = NULL;
+        extcap_token_sentence * if_sentence = (extcap_token_sentence *) walker->data;
+
+        if ( if_sentence != NULL && ( ri = extcap_parse_interface_sentence ( if_sentence ) ) != NULL )
+            result = g_list_append(result, ri);
 
-        first_s = first_s->next_sentence;
+        walker = g_list_next(walker);
     }
 
-    *first_int = first_i;
+    g_list_foreach(tokens, extcap_free_tokenized_sentence, NULL);
 
-    return 1;
+    return result;
 }
 
-int extcap_parse_dlt_sentence(extcap_token_sentence *s, extcap_dlt **rd) {
-    extcap_token_param *v = NULL;
+/* Parse a tokenized set of sentences and validate, looking for DLT definitions */
+static extcap_dlt * extcap_parse_dlt_sentence(extcap_token_sentence *s) {
+    gchar *param_value = NULL;
     extcap_sentence_type sent = EXTCAP_SENTENCE_UNKNOWN;
-
-    *rd = NULL;
+    extcap_dlt * result = NULL;
 
     if (s == NULL)
-        return -1;
+        return result;
 
     if (g_ascii_strcasecmp(s->sentence, "dlt") == 0) {
         sent = EXTCAP_SENTENCE_DLT;
     }
 
     if (sent == EXTCAP_SENTENCE_UNKNOWN)
-        return -1;
+        return result;
+
+    result = g_new0(extcap_dlt, 1);
 
-    *rd = extcap_new_dlt();
+    result->number = -1;
+    result->name = NULL;
+    result->display = NULL;
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARGNUM))
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_ARGNUM)))
             == NULL) {
         printf("No number in DLT sentence\n");
-        extcap_free_dlt(*rd);
-        return -1;
+        g_free(result);
+        return NULL;
     }
-    if (sscanf(v->value, "%d", &((*rd)->number)) != 1) {
+    if (sscanf(param_value, "%d", &(result->number)) != 1) {
         printf("Invalid number in DLT sentence\n");
-        extcap_free_dlt(*rd);
-        return -1;
+        g_free(result);
+        return NULL;
     }
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_NAME))
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_NAME)))
             == NULL) {
         printf("No name in DLT sentence\n");
-        extcap_free_dlt(*rd);
-        return -1;
+        g_free(result);
+        return NULL;
     }
-    (*rd)->name = g_strdup(v->value);
+    result->name = g_strdup(param_value);
 
-    if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
+    if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_DISPLAY)))
             == NULL) {
         printf("No display in DLT sentence\n");
-        extcap_free_dlt(*rd);
-        return -1;
+        g_free(result->name);
+        g_free(result);
+        return NULL;
     }
-    (*rd)->display = g_strdup(v->value);
+    result->display = g_strdup(param_value);
 
-    return 1;
+    return result;
 }
 
-int extcap_parse_dlts(extcap_token_sentence *first_s, extcap_dlt **first_dlt) {
-    extcap_dlt *first_d = NULL, *last_d = NULL;
+GList * extcap_parse_dlts(gchar *output) {
 
-    while (first_s) {
-        extcap_dlt *rd;
+    GList * walker = NULL;
+    GList * temp = NULL;
+    GList * result = NULL;
 
-        if (extcap_parse_dlt_sentence(first_s, &rd) >= 0 && rd != NULL) {
-            if (first_d == NULL) {
-                first_d = last_d = rd;
-            } else {
-                last_d->next_dlt = rd;
-                last_d = rd;
-            }
-        }
+    walker = extcap_tokenize_sentences(output);
+
+    temp = walker;
+
+    while (walker) {
+        extcap_dlt *data = NULL;
 
-        first_s = first_s->next_sentence;
+        if ((data = extcap_parse_dlt_sentence((extcap_token_sentence *)walker->data)) != NULL)
+            result = g_list_append(result, data);
+
+        walker = g_list_next(walker);
     }
 
-    *first_dlt = first_d;
+    g_list_foreach(temp, extcap_free_tokenized_sentence, NULL);
 
-    return 1;
+    return result;
 }
 
 /*
index b6cc7627970054f404183cdc1bddc2ba22135fcb..298fbd7558cefdfe5f00381db4894e30e0b0eb76 100644 (file)
@@ -26,6 +26,8 @@
 #include <glib.h>
 #include <string.h>
 
+#include <config.h>
+
 typedef enum {
     EXTCAP_SENTENCE_UNKNOWN,
     EXTCAP_SENTENCE_ARG,
@@ -76,6 +78,8 @@ typedef enum {
     EXTCAP_PARAM_VERSION
 } 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 */
@@ -134,45 +138,24 @@ typedef struct _extcap_interface {
     gchar *version;
 
     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);
@@ -199,24 +182,6 @@ 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);
 
 /* Free a single argument */
 void extcap_free_arg(extcap_arg *a);
@@ -224,31 +189,17 @@ 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);
 
-/* Parse all sentences for args and values */
-GList * extcap_parse_args(extcap_token_sentence *first_s);
+/** Parser for extcap data */
 
-/*
- * 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 args and values */
+GList * extcap_parse_args(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);
 
 /* 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
 }