2014-02-25 13:05:11 +00:00
|
|
|
/* extcap_parser.c
|
|
|
|
*
|
|
|
|
* Routines for extcap external capture
|
|
|
|
* Copyright 2013, Mike Ryan <mikeryan@lacklustre.net>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-08-22 21:13:05 +00:00
|
|
|
#include <config.h>
|
2014-02-25 13:05:11 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
#include "extcap.h"
|
2014-02-25 13:05:11 +00:00
|
|
|
#include "extcap_parser.h"
|
|
|
|
|
|
|
|
void extcap_printf_complex(extcap_complex *comp) {
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar *ret = extcap_get_complex_as_string(comp);
|
|
|
|
printf("%s", ret);
|
|
|
|
g_free(ret);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *extcap_get_complex_as_string(extcap_complex *comp) {
|
2016-01-28 09:41:38 +00:00
|
|
|
return (comp ? g_strdup(comp->_val) : NULL);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
|
2014-10-06 18:03:47 +00:00
|
|
|
const gchar *data) {
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
extcap_complex *rc = g_new0(extcap_complex, 1);
|
2014-10-06 18:03:47 +00:00
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
rc->_val = g_strdup( (gchar *) data);
|
2014-10-06 18:03:47 +00:00
|
|
|
rc->complex_type = complex_type;
|
|
|
|
|
|
|
|
return rc;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test) {
|
2016-01-28 09:41:38 +00:00
|
|
|
if ( element == NULL || element->default_complex == NULL || test == NULL )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( g_strcmp0(element->default_complex->_val, test->_val) == 0 )
|
|
|
|
return TRUE;
|
2014-10-06 18:03:47 +00:00
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_complex(extcap_complex *comp) {
|
2016-01-28 09:41:38 +00:00
|
|
|
if ( comp )
|
|
|
|
g_free(comp->_val);
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(comp);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
gint extcap_complex_get_int(extcap_complex *comp) {
|
|
|
|
if ( comp == NULL || comp->_val == NULL || comp->complex_type != EXTCAP_ARG_INTEGER )
|
|
|
|
return (gint)0;
|
|
|
|
|
|
|
|
return (gint) g_ascii_strtoll(comp->_val, NULL, 10);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
guint extcap_complex_get_uint(extcap_complex *comp) {
|
|
|
|
if ( comp == NULL || comp->_val == NULL || comp->complex_type != EXTCAP_ARG_UNSIGNED )
|
|
|
|
return (guint)0;
|
|
|
|
return (guint) g_ascii_strtoull(comp->_val, NULL, 10);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
gint64 extcap_complex_get_long(extcap_complex *comp) {
|
|
|
|
if ( comp == NULL || comp->_val == NULL || comp->complex_type != EXTCAP_ARG_LONG )
|
|
|
|
return (gint64)0;
|
|
|
|
return g_ascii_strtoll( comp->_val, NULL, 10 );
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
gdouble extcap_complex_get_double(extcap_complex *comp) {
|
|
|
|
if ( comp == NULL || comp->_val == NULL || comp->complex_type != EXTCAP_ARG_DOUBLE )
|
|
|
|
return (gdouble)0;
|
|
|
|
return g_strtod( comp->_val, NULL );
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean extcap_complex_get_bool(extcap_complex *comp) {
|
2016-01-28 09:41:38 +00:00
|
|
|
if ( comp == NULL || comp->_val == NULL )
|
2014-10-06 18:03:47 +00:00
|
|
|
return FALSE;
|
2016-01-28 09:41:38 +00:00
|
|
|
|
|
|
|
if ( comp->complex_type != EXTCAP_ARG_BOOLEAN && comp->complex_type != EXTCAP_ARG_BOOLFLAG )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, comp->_val, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gchar *extcap_complex_get_string(extcap_complex *comp) {
|
2016-01-28 09:41:38 +00:00
|
|
|
/* Not checking for argument type, to use this method as fallback if only strings are needed */
|
|
|
|
return comp != NULL ? comp->_val : NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_tokenized_param(extcap_token_param *v) {
|
2016-01-28 09:41:38 +00:00
|
|
|
if (v != NULL)
|
|
|
|
{
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(v->arg);
|
|
|
|
g_free(v->value);
|
2016-01-28 09:41:38 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(v);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_tokenized_sentence(extcap_token_sentence *s) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_param *tv;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (s == NULL)
|
|
|
|
return;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (s->sentence != NULL)
|
|
|
|
g_free(s->sentence);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (s->param_list != NULL ) {
|
|
|
|
tv = s->param_list;
|
|
|
|
s->param_list = tv->next_token;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_free_tokenized_param(tv);
|
|
|
|
}
|
2015-12-11 10:42:28 +00:00
|
|
|
g_free(s);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_tokenized_sentence_list(extcap_token_sentence *f) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_sentence *t;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (f != NULL ) {
|
|
|
|
t = f->next_sentence;
|
|
|
|
extcap_free_tokenized_sentence(f);
|
|
|
|
f = t;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_param *tv = NULL;
|
2016-01-04 13:19:55 +00:00
|
|
|
GRegex * regex = NULL;
|
|
|
|
GMatchInfo * match_info = NULL;
|
|
|
|
GError * error = NULL;
|
2014-10-06 18:03:47 +00:00
|
|
|
|
|
|
|
extcap_token_sentence *rs = g_new(extcap_token_sentence, 1);
|
|
|
|
|
|
|
|
rs->sentence = NULL;
|
|
|
|
rs->next_sentence = NULL;
|
|
|
|
rs->param_list = NULL;
|
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
/* Regex for catching just the allowed values for sentences */
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( ( regex = g_regex_new ( "^[\\t| ]*(arg|value|interface|extcap|dlt)(?=[\\t| ]+\\{)",
|
2016-01-04 13:19:55 +00:00
|
|
|
(GRegexCompileFlags) G_REGEX_CASELESS, (GRegexMatchFlags) 0, NULL ) ) != NULL ) {
|
|
|
|
g_regex_match ( regex, s, (GRegexMatchFlags) 0, &match_info );
|
2014-10-06 18:03:47 +00:00
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
if ( g_match_info_matches ( match_info ) )
|
|
|
|
rs->sentence = g_match_info_fetch(match_info, 0);
|
2014-10-06 18:03:47 +00:00
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
g_match_info_free ( match_info );
|
|
|
|
g_regex_unref ( regex );
|
|
|
|
}
|
|
|
|
/* No valid sentence found, exiting here */
|
|
|
|
if ( rs->sentence == NULL ) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_free_tokenized_sentence(rs);
|
2016-01-04 13:19:55 +00:00
|
|
|
return NULL;
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
/* Capture the argument and the value of the list. This will ensure,
|
|
|
|
* that regex patterns given to {validation=} are parsed correctly,
|
|
|
|
* as long as }{ does not occur within the pattern */
|
|
|
|
regex = g_regex_new ( "\\{([a-zA-Z_-]*?)\\=(.*?)\\}(?=\\{|$|\\s)",
|
|
|
|
(GRegexCompileFlags) G_REGEX_CASELESS, (GRegexMatchFlags) 0, NULL );
|
|
|
|
if ( regex != NULL ) {
|
|
|
|
g_regex_match_full(regex, s, -1, 0, (GRegexMatchFlags) 0, &match_info, &error );
|
|
|
|
while(g_match_info_matches(match_info)) {
|
|
|
|
gchar * arg = g_match_info_fetch ( match_info, 1 );
|
|
|
|
|
|
|
|
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;
|
2016-01-28 09:41:38 +00:00
|
|
|
} else if (g_ascii_strcasecmp(tv->arg, "save") == 0) {
|
|
|
|
tv->param_type = EXTCAP_PARAM_SAVE;
|
2016-01-04 13:19:55 +00:00
|
|
|
} else if (g_ascii_strcasecmp(tv->arg, "validation") == 0) {
|
|
|
|
tv->param_type = EXTCAP_PARAM_VALIDATION;
|
2016-01-12 12:45:20 +00:00
|
|
|
} else if (g_ascii_strcasecmp(tv->arg, "version") == 0) {
|
|
|
|
tv->param_type = EXTCAP_PARAM_VERSION;
|
2016-01-04 13:19:55 +00:00
|
|
|
} else {
|
|
|
|
tv->param_type = EXTCAP_PARAM_UNKNOWN;
|
2015-12-29 14:35:43 +00:00
|
|
|
}
|
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
tv->next_token = rs->param_list;
|
|
|
|
rs->param_list = tv;
|
2015-12-29 14:35:43 +00:00
|
|
|
|
2016-01-04 13:19:55 +00:00
|
|
|
g_match_info_next(match_info, &error);
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2016-01-04 13:19:55 +00:00
|
|
|
g_match_info_free(match_info);
|
|
|
|
g_regex_unref(regex);
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rs;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_token_sentence *extcap_tokenize_sentences(const gchar *s) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_sentence *first = NULL, *cur = NULL, *last = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar **list, **list_iter;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
list_iter = list = g_strsplit(s, "\n", 0);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (*list_iter != NULL ) {
|
|
|
|
cur = extcap_tokenize_sentence(*list_iter);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (cur != NULL) {
|
|
|
|
if (first == NULL) {
|
|
|
|
first = cur;
|
|
|
|
last = cur;
|
|
|
|
} else {
|
|
|
|
last->next_sentence = cur;
|
|
|
|
last = cur;
|
|
|
|
}
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
list_iter++;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_strfreev(list);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return first;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_token_param *extcap_find_param_by_type(extcap_token_param *first,
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_param_type t) {
|
|
|
|
while (first != NULL ) {
|
|
|
|
if (first->param_type == t) {
|
|
|
|
return first;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
first = first->next_token;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return NULL ;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_value(extcap_value *v) {
|
2014-10-06 18:03:47 +00:00
|
|
|
if (v == NULL)
|
|
|
|
return;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
g_free(v->call);
|
|
|
|
g_free(v->display);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(v);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_interface *extcap_new_interface(void) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_interface *r = g_new(extcap_interface, 1);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
r->call = r->display = r->version = NULL;
|
|
|
|
r->if_type = EXTCAP_SENTENCE_UNKNOWN;
|
2014-10-06 18:03:47 +00:00
|
|
|
r->next_interface = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return r;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_interface(extcap_interface *i) {
|
2015-12-11 10:42:28 +00:00
|
|
|
extcap_interface *next_i = i;
|
|
|
|
|
|
|
|
while (i) {
|
|
|
|
next_i = i->next_interface;
|
2016-02-03 17:38:53 +00:00
|
|
|
g_free(i->call);
|
|
|
|
g_free(i->display);
|
|
|
|
g_free(i->version);
|
2015-12-11 10:42:28 +00:00
|
|
|
g_free(i);
|
|
|
|
i = next_i;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_dlt *extcap_new_dlt(void) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_dlt *r = g_new(extcap_dlt, 1);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
r->number = -1;
|
|
|
|
r->name = r->display = NULL;
|
|
|
|
r->next_dlt = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return r;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_dlt(extcap_dlt *d) {
|
2014-10-06 18:03:47 +00:00
|
|
|
if (d == NULL)
|
|
|
|
return;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
g_free(d->name);
|
|
|
|
g_free(d->display);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void extcap_free_valuelist(gpointer data, gpointer user_data _U_) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_free_value((extcap_value *) data);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_arg(extcap_arg *a) {
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (a == NULL)
|
|
|
|
return;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
g_free(a->call);
|
|
|
|
g_free(a->display);
|
|
|
|
g_free(a->tooltip);
|
|
|
|
g_free(a->fileextension);
|
|
|
|
g_free(a->regexp);
|
2015-12-29 06:57:36 +00:00
|
|
|
g_free(a->storeval);
|
2015-12-29 14:35:43 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (a->range_start != NULL)
|
|
|
|
extcap_free_complex(a->range_start);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (a->range_end != NULL)
|
|
|
|
extcap_free_complex(a->range_end);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (a->default_complex != NULL)
|
|
|
|
extcap_free_complex(a->default_complex);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_list_foreach(a->values, (GFunc) extcap_free_valuelist, NULL);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2014-08-24 20:35:52 +00:00
|
|
|
static void extcap_free_arg_list_cb(gpointer listentry, gpointer data _U_) {
|
2014-10-06 18:03:47 +00:00
|
|
|
if (listentry != NULL)
|
|
|
|
extcap_free_arg((extcap_arg *) listentry);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void extcap_free_arg_list(GList *a) {
|
2014-10-06 18:03:47 +00:00
|
|
|
g_list_foreach(a, extcap_free_arg_list_cb, NULL);
|
|
|
|
g_list_free(a);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint glist_find_numbered_arg(gconstpointer listelem, gconstpointer needle) {
|
2014-10-06 18:03:47 +00:00
|
|
|
if (((const extcap_arg *) listelem)->arg_num == *((const int*) needle))
|
|
|
|
return 0;
|
|
|
|
return 1;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_param *v = NULL;
|
|
|
|
extcap_arg *target_arg = NULL;
|
|
|
|
extcap_value *value = NULL;
|
|
|
|
GList * entry = NULL;
|
|
|
|
int tint;
|
|
|
|
extcap_sentence_type sent = EXTCAP_SENTENCE_UNKNOWN;
|
|
|
|
|
|
|
|
if (s == NULL)
|
|
|
|
return target_arg;
|
|
|
|
|
|
|
|
if (g_ascii_strcasecmp(s->sentence, "arg") == 0) {
|
|
|
|
sent = EXTCAP_SENTENCE_ARG;
|
|
|
|
/* printf("ARG sentence\n"); */
|
|
|
|
} else if (g_ascii_strcasecmp(s->sentence, "value") == 0) {
|
|
|
|
sent = EXTCAP_SENTENCE_VALUE;
|
|
|
|
/* printf("VALUE sentence\n"); */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sent == EXTCAP_SENTENCE_ARG) {
|
2016-01-28 09:41:38 +00:00
|
|
|
target_arg = g_new0(extcap_arg, 1);
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_UNKNOWN;
|
2015-12-29 06:57:36 +00:00
|
|
|
target_arg->save = TRUE;
|
2014-10-06 18:03:47 +00:00
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARGNUM))
|
|
|
|
== NULL) {
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf(v->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) {
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
target_arg->call = g_strdup(v->value);
|
|
|
|
|
|
|
|
/* No value only parameters allowed */
|
|
|
|
if (strlen(target_arg->call) == 0) {
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
|
|
|
|
== NULL) {
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
target_arg->display = g_strdup(v->value);
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_TOOLTIP))
|
|
|
|
!= NULL) {
|
|
|
|
target_arg->tooltip = g_strdup(v->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_FILE_MUSTEXIST))
|
|
|
|
!= NULL) {
|
2016-01-28 09:41:38 +00:00
|
|
|
target_arg->fileexists = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 13:57:53 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_FILE_EXTENSION))
|
|
|
|
!= NULL) {
|
|
|
|
target_arg->fileextension = g_strdup(v->value);
|
|
|
|
}
|
|
|
|
|
2015-12-29 14:35:43 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALIDATION))
|
|
|
|
!= NULL) {
|
|
|
|
target_arg->regexp = g_strdup(v->value);
|
|
|
|
}
|
|
|
|
|
2015-12-29 13:50:55 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_REQUIRED))
|
|
|
|
!= NULL) {
|
2016-01-28 09:41:38 +00:00
|
|
|
target_arg->is_required = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2015-12-29 13:50:55 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, 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) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_INTEGER;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "unsigned") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_UNSIGNED;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "long") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_LONG;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "double") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_DOUBLE;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "boolean") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_BOOLEAN;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "boolflag") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_BOOLFLAG;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "selector") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_SELECTOR;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "radio") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_RADIO;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "string") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_STRING;
|
2016-01-18 11:01:14 +00:00
|
|
|
} else if (g_ascii_strcasecmp(v->value, "password") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_PASSWORD;
|
2016-01-28 09:41:38 +00:00
|
|
|
/* default setting is to not save passwords */
|
2015-12-29 06:57:36 +00:00
|
|
|
target_arg->save = FALSE;
|
2014-10-06 18:03:47 +00:00
|
|
|
} else if (g_ascii_strcasecmp(v->value, "fileselect") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_FILESELECT;
|
|
|
|
} else if (g_ascii_strcasecmp(v->value, "multicheck") == 0) {
|
|
|
|
target_arg->arg_type = EXTCAP_ARG_MULTICHECK;
|
|
|
|
} else {
|
|
|
|
printf("invalid type %s in ARG sentence\n", v->value);
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_SAVE))
|
|
|
|
!= NULL) {
|
2015-12-29 06:57:36 +00:00
|
|
|
target_arg->save = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2016-01-28 09:41:38 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_RANGE))
|
|
|
|
!= NULL) {
|
|
|
|
gchar *cp = g_strstr_len(v->value, -1, ",");
|
|
|
|
|
|
|
|
if (cp == NULL) {
|
|
|
|
printf("invalid range, expected value,value got %s\n",
|
|
|
|
v->value);
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((target_arg->range_start = extcap_parse_complex(
|
|
|
|
target_arg->arg_type, v->value)) == NULL) {
|
|
|
|
printf("invalid range, expected value,value got %s\n",
|
|
|
|
v->value);
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
extcap_free_arg(target_arg);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DEFAULT))
|
|
|
|
!= NULL) {
|
2016-01-28 09:41:38 +00:00
|
|
|
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);
|
|
|
|
}
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (sent == EXTCAP_SENTENCE_VALUE) {
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARG))
|
|
|
|
== NULL) {
|
|
|
|
printf("no arg in VALUE sentence\n");
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf(v->value, "%d", &tint) != 1) {
|
|
|
|
printf("invalid arg in VALUE sentence\n");
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
;
|
|
|
|
if ((entry = g_list_find_custom(args, &tint, glist_find_numbered_arg))
|
|
|
|
== NULL) {
|
|
|
|
printf("couldn't find arg %d in list for VALUE sentence\n", tint);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
2016-01-28 09:41:38 +00:00
|
|
|
value = g_new0(extcap_value, 1);
|
2014-10-06 18:03:47 +00:00
|
|
|
value->arg_num = tint;
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALUE))
|
|
|
|
== NULL) {
|
|
|
|
/* printf("no value in VALUE sentence\n"); */
|
|
|
|
extcap_free_value(value);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
value->call = g_strdup(v->value);
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
|
|
|
|
== NULL) {
|
|
|
|
/* printf("no display in VALUE sentence\n"); */
|
|
|
|
extcap_free_value(value);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
value->display = g_strdup(v->value);
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_PARENT))
|
|
|
|
!= NULL) {
|
|
|
|
value->parent = g_strdup(v->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DEFAULT))
|
|
|
|
!= NULL) {
|
|
|
|
/* printf("found default value\n"); */
|
2016-01-28 09:41:38 +00:00
|
|
|
value->is_default = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ENABLED))
|
|
|
|
!= NULL) {
|
2016-01-28 09:41:38 +00:00
|
|
|
value->enabled = g_regex_match_simple(EXTCAP_BOOLEAN_REGEX, v->value, G_REGEX_CASELESS, (GRegexMatchFlags)0 );
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
((extcap_arg*) entry->data)->values = g_list_append(
|
|
|
|
((extcap_arg*) entry->data)->values, value);
|
|
|
|
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
return target_arg;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GList * extcap_parse_args(extcap_token_sentence *first_s) {
|
2014-10-06 18:03:47 +00:00
|
|
|
GList * args = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (first_s) {
|
|
|
|
extcap_arg *ra = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((ra = extcap_parse_arg_sentence(args, first_s)) != NULL)
|
|
|
|
args = g_list_append(args, (gpointer) ra);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
first_s = first_s->next_sentence;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return args;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int extcap_parse_interface_sentence(extcap_token_sentence *s,
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_interface **ri) {
|
|
|
|
extcap_token_param *v = NULL;
|
|
|
|
extcap_sentence_type sent = EXTCAP_SENTENCE_UNKNOWN;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
*ri = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (s == NULL)
|
|
|
|
return -1;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (g_ascii_strcasecmp(s->sentence, "interface") == 0) {
|
|
|
|
sent = EXTCAP_SENTENCE_INTERFACE;
|
2016-01-12 12:45:20 +00:00
|
|
|
} else if (g_ascii_strcasecmp(s->sentence, "extcap") == 0) {
|
|
|
|
sent = EXTCAP_SENTENCE_EXTCAP;
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (sent == EXTCAP_SENTENCE_UNKNOWN)
|
|
|
|
return -1;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
*ri = extcap_new_interface();
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
(*ri)->if_type = sent;
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VALUE))
|
2016-01-12 12:45:20 +00:00
|
|
|
== NULL && sent == EXTCAP_SENTENCE_INTERFACE) {
|
2014-10-06 18:03:47 +00:00
|
|
|
printf("No value in INTERFACE sentence\n");
|
|
|
|
extcap_free_interface(*ri);
|
|
|
|
return -1;
|
|
|
|
}
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( v != NULL )
|
|
|
|
(*ri)->call = g_strdup(v->value);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
|
2016-01-12 12:45:20 +00:00
|
|
|
== NULL && sent == EXTCAP_SENTENCE_INTERFACE) {
|
2014-10-06 18:03:47 +00:00
|
|
|
printf("No display in INTERFACE sentence\n");
|
|
|
|
extcap_free_interface(*ri);
|
|
|
|
return -1;
|
|
|
|
}
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( v != NULL )
|
|
|
|
(*ri)->display = g_strdup(v->value);
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_VERSION))
|
|
|
|
!= NULL) {
|
|
|
|
(*ri)->version = g_strdup(v->value);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return 1;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int extcap_parse_interfaces(extcap_token_sentence *first_s,
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_interface **first_int) {
|
|
|
|
extcap_interface *first_i = NULL, *last_i = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (first_s) {
|
|
|
|
extcap_interface *ri;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
first_s = first_s->next_sentence;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
*first_int = first_i;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return 1;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int extcap_parse_dlt_sentence(extcap_token_sentence *s, extcap_dlt **rd) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_token_param *v = NULL;
|
|
|
|
extcap_sentence_type sent = EXTCAP_SENTENCE_UNKNOWN;
|
|
|
|
|
|
|
|
*rd = NULL;
|
|
|
|
|
|
|
|
if (s == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (g_ascii_strcasecmp(s->sentence, "dlt") == 0) {
|
|
|
|
sent = EXTCAP_SENTENCE_DLT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sent == EXTCAP_SENTENCE_UNKNOWN)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*rd = extcap_new_dlt();
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_ARGNUM))
|
|
|
|
== NULL) {
|
|
|
|
printf("No number in DLT sentence\n");
|
|
|
|
extcap_free_dlt(*rd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (sscanf(v->value, "%d", &((*rd)->number)) != 1) {
|
|
|
|
printf("Invalid number in DLT sentence\n");
|
|
|
|
extcap_free_dlt(*rd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_NAME))
|
|
|
|
== NULL) {
|
|
|
|
printf("No name in DLT sentence\n");
|
|
|
|
extcap_free_dlt(*rd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
(*rd)->name = g_strdup(v->value);
|
|
|
|
|
|
|
|
if ((v = extcap_find_param_by_type(s->param_list, EXTCAP_PARAM_DISPLAY))
|
|
|
|
== NULL) {
|
|
|
|
printf("No display in DLT sentence\n");
|
|
|
|
extcap_free_dlt(*rd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
(*rd)->display = g_strdup(v->value);
|
|
|
|
|
|
|
|
return 1;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int extcap_parse_dlts(extcap_token_sentence *first_s, extcap_dlt **first_dlt) {
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_dlt *first_d = NULL, *last_d = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
while (first_s) {
|
|
|
|
extcap_dlt *rd;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
first_s = first_s->next_sentence;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
*first_dlt = first_d;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return 1;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
2014-10-06 18:03:47 +00:00
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
2014-02-25 13:05:11 +00:00
|
|
|
* End:
|
|
|
|
*
|
2014-10-06 18:03:47 +00:00
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
2014-02-25 13:05:11 +00:00
|
|
|
*/
|