Fix handling of extcap boolflags which defaults to true.
Example: arg {number=0}{call=--test}{type=boolflag}{default=true} Before this change --test was never added to argument list (no matter if user left it selected or explicitly deselected it). After this change --test will be added to argument list unless user explicitly deselects it. Change-Id: Ia5bc11f900b03e630aba882ef918dcb7f0b79291 Reviewed-on: https://code.wireshark.org/review/4618 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
parent
1b8b2a8aa8
commit
fc2f31810a
64
extcap.c
64
extcap.c
|
@ -342,6 +342,24 @@ extcap_interface_list(char **err_str) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void extcap_free_if_configuration(GList *list)
|
||||
{
|
||||
GList *elem;
|
||||
|
||||
for (elem = g_list_first(list); elem; elem = elem->next)
|
||||
{
|
||||
GList *arg_list;
|
||||
if (elem->data == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
arg_list = g_list_first((GList *)elem->data);
|
||||
g_list_free_full(arg_list, g_free);
|
||||
}
|
||||
g_list_free(list);
|
||||
}
|
||||
|
||||
static gboolean search_cb(const gchar *extcap _U_, gchar *output, void *data,
|
||||
char **err_str _U_) {
|
||||
extcap_token_sentence *tokens = NULL;
|
||||
|
@ -519,8 +537,52 @@ extcaps_init_initerfaces(capture_options *capture_opts)
|
|||
add_arg(interface_opts.name);
|
||||
add_arg(EXTCAP_ARGUMENT_RUN_PIPE);
|
||||
add_arg(interface_opts.extcap_fifo);
|
||||
if (interface_opts.extcap_args != NULL)
|
||||
if (interface_opts.extcap_args == NULL)
|
||||
{
|
||||
/* User did not perform interface configuration.
|
||||
*
|
||||
* Check if there are any boolean flags that are set by default
|
||||
* and hence their argument should be added.
|
||||
*/
|
||||
GList *arglist;
|
||||
GList *elem;
|
||||
|
||||
arglist = extcap_get_if_configuration(interface_opts.name);
|
||||
for (elem = g_list_first(arglist); elem; elem = elem->next)
|
||||
{
|
||||
GList * arg_list;
|
||||
extcap_arg *arg_iter;
|
||||
|
||||
if (elem->data == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
arg_list = g_list_first((GList *)elem->data);
|
||||
while (arg_list != NULL)
|
||||
{
|
||||
/* In case of boolflags only first element in arg_list is relevant. */
|
||||
arg_iter = (extcap_arg*) (arg_list->data);
|
||||
|
||||
if (arg_iter->arg_type == EXTCAP_ARG_BOOLFLAG)
|
||||
{
|
||||
if (arg_iter->default_complex != NULL
|
||||
&& extcap_complex_get_bool(arg_iter->default_complex))
|
||||
{
|
||||
add_arg(arg_iter->call);
|
||||
}
|
||||
}
|
||||
|
||||
arg_list = arg_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
extcap_free_if_configuration(arglist);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hash_table_foreach(interface_opts.extcap_args, extcap_arg_cb, args);
|
||||
}
|
||||
add_arg(NULL);
|
||||
#undef add_arg
|
||||
|
||||
|
|
|
@ -289,9 +289,6 @@ GHashTable *extcap_gtk_get_state(GtkWidget *widget) {
|
|||
if (parsed_complex == NULL && call_string == NULL)
|
||||
continue;
|
||||
|
||||
/* Comparing if the user has changed the value at all, and ignoring it if so */
|
||||
if (extcap_compare_is_default(arg, parsed_complex))
|
||||
continue;
|
||||
|
||||
/* Flags are set as is, and have not true/false switch */
|
||||
if (arg->arg_type == EXTCAP_ARG_BOOLFLAG)
|
||||
|
@ -312,6 +309,14 @@ GHashTable *extcap_gtk_get_state(GtkWidget *widget) {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Comparing if the user has changed the value at all, and ignoring it if so.
|
||||
* This does not apply to EXTCAP_ARG_BOOLFLAG.
|
||||
*/
|
||||
if (extcap_compare_is_default(arg, parsed_complex))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parsed_complex != NULL && call_string == NULL)
|
||||
call_string = extcap_get_complex_as_string(parsed_complex);
|
||||
|
|
Loading…
Reference in New Issue