* 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
*/
#include "config.h"
+#include "ws_diag_control.h"
+
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <epan/address.h>
#include <epan/addr_resolv.h>
#include <epan/oids.h>
-#ifdef HAVE_GEOIP
-#include <epan/geoip_db.h>
-#endif
+#include <epan/maxmind_db.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto.h>
#include <epan/strutil.h>
#include <epan/column.h>
+#include <epan/decode_as.h>
#include "print.h"
#include <wsutil/file_util.h>
+#include <wsutil/ws_printf.h> /* ws_g_warning */
+#include <wsutil/report_message.h>
#include <epan/prefs-int.h>
#include <epan/uat-int.h>
static module_t *prefs_register_module_or_subtree(module_t *parent,
const char *name, const char *title, const char *description, gboolean is_subtree,
void (*apply_cb)(void), gboolean use_gui);
+static void prefs_register_modules(void);
static prefs_set_pref_e set_pref(gchar*, const gchar*, void *, gboolean);
static void free_col_info(GList *);
static void pre_init_prefs(void);
static gboolean prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt);
static gboolean parse_column_format(fmt_data *cfmt, const char *fmt);
static void try_convert_to_custom_column(gpointer *el_data);
+static guint prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
+ gpointer user_data, gboolean skip_obsolete);
+#define IS_PREF_OBSOLETE(p) ((p) & PREF_OBSOLETE)
+#define SET_PREF_OBSOLETE(p) ((p) |= PREF_OBSOLETE)
+#define RESET_PREF_OBSOLETE(p) ((p) &= ~PREF_OBSOLETE)
#define PF_NAME "preferences"
#define OLD_GPF_NAME "wireshark.conf" /* old name for global preferences file */
static gboolean prefs_initialized = FALSE;
static gchar *gpf_path = NULL;
static gchar *cols_hidden_list = NULL;
+static gboolean gui_theme_is_dark = FALSE;
/*
* XXX - variables to allow us to attempt to interpret the first
{NULL, NULL, -1}
};
-static const enum_val_t gui_hex_dump_highlight_style[] = {
- {"BOLD", "BOLD", 0},
- {"INVERSE", "INVERSE", 1},
- {NULL, NULL, -1}
-};
-
static const enum_val_t gui_console_open_type[] = {
{"NEVER", "NEVER", console_open_never},
{"AUTOMATIC", "AUTOMATIC", console_open_auto},
{NULL, NULL, -1}
};
-/* GTK knows of two ways representing "both", vertical and horizontal aligned.
- * as this may not work on other guis, we use only "both" in general here */
static const enum_val_t gui_toolbar_style[] = {
{"ICONS", "ICONS", 0},
{"TEXT", "TEXT", 1},
{NULL, NULL, -1}
};
+/** Struct to hold preference data */
+struct preference {
+ const char *name; /**< name of preference */
+ const char *title; /**< title to use in GUI */
+ const char *description; /**< human-readable description of preference */
+ int ordinal; /**< ordinal number of this preference */
+ int type; /**< type of that preference */
+ unsigned int effect_flags; /**< Flags of types effected by preference (PREF_TYPE_DISSECTION, PREF_EFFECT_CAPTURE, etc).
+ Flags must be non-zero to ensure saving to disk */
+ gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
+ union { /* The Qt preference code assumes that these will all be pointers (and unique) */
+ guint *uint;
+ gboolean *boolp;
+ gint *enump;
+ char **string;
+ range_t **range;
+ struct epan_uat* uat;
+ color_t *colorp;
+ GList** list;
+ } varp; /**< pointer to variable storing the value */
+ union {
+ guint uint;
+ gboolean boolval;
+ gint enumval;
+ char *string;
+ range_t *range;
+ color_t color;
+ GList* list;
+ } stashed_val; /**< original value, when editing from the GUI */
+ union {
+ guint uint;
+ gboolean boolval;
+ gint enumval;
+ char *string;
+ range_t *range;
+ color_t color;
+ GList* list;
+ } default_val; /**< the default value of the preference */
+ union {
+ guint base; /**< input/output base, for PREF_UINT */
+ guint32 max_value; /**< maximum value of a range */
+ struct {
+ const enum_val_t *enumvals; /**< list of name & values */
+ gboolean radio_buttons; /**< TRUE if it should be shown as
+ radio buttons rather than as an
+ option menu or combo box in
+ the preferences tab */
+ } enum_info; /**< for PREF_ENUM */
+ } info; /**< display/text file information */
+ struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
+ void *control; /**< handle for GUI control for this preference. GTK+ only? */
+};
+
+const char* prefs_get_description(pref_t *pref)
+{
+ return pref->description;
+}
+
+const char* prefs_get_title(pref_t *pref)
+{
+ return pref->title;
+}
+
+int prefs_get_type(pref_t *pref)
+{
+ return pref->type;
+}
+
+gui_type_t prefs_get_gui_type(pref_t *pref)
+{
+ return pref->gui;
+}
+
+const char* prefs_get_name(pref_t *pref)
+{
+ return pref->name;
+}
+
+guint32 prefs_get_max_value(pref_t *pref)
+{
+ return pref->info.max_value;
+}
+
/*
* List of all modules with preference settings.
*/
prefs_top_level_modules = wmem_tree_new(wmem_epan_scope());
}
+/*
+ * Free the strings for a string-like preference.
+ */
+static void
+free_string_like_preference(pref_t *pref)
+{
+DIAG_OFF(cast-qual)
+ g_free((char *)*pref->varp.string);
+DIAG_ON(cast-qual)
+ *pref->varp.string = NULL;
+ g_free(pref->default_val.string);
+ pref->default_val.string = NULL;
+}
+
static void
free_pref(gpointer data, gpointer user_data _U_)
{
pref_t *pref = (pref_t *)data;
+ int type = pref->type;
- switch (pref->type) {
- case PREF_OBSOLETE:
+ /* we reset the PREF_OBSOLETE bit in order to allow the original preference to be freed */
+ RESET_PREF_OBSOLETE(type);
+
+ switch (type) {
case PREF_BOOL:
case PREF_ENUM:
case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
case PREF_STATIC_TEXT:
case PREF_UAT:
case PREF_COLOR:
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- g_free((char *)*pref->varp.string);
- *pref->varp.string = NULL;
- g_free(pref->default_val.string);
- pref->default_val.string = NULL;
+ free_string_like_preference(pref);
break;
case PREF_RANGE:
- g_free(*pref->varp.range);
+ case PREF_DECODE_AS_RANGE:
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = NULL;
- g_free(pref->default_val.range);
+ wmem_free(wmem_epan_scope(), pref->default_val.range);
pref->default_val.range = NULL;
break;
case PREF_CUSTOM:
module->prefs = NULL;
module->numprefs = 0;
if (module->submodules) {
- prefs_modules_foreach_submodules(module, free_module_prefs, NULL);
+ prefs_module_list_foreach(module->submodules, free_module_prefs, NULL, FALSE);
}
/* We don't free the actual module: its submodules pointer points to
a wmem_tree and the module itself is stored in a wmem_tree
/* This isn't strictly necessary since we're exiting anyway, but let's
* do what clean up we can.
*/
- prefs_modules_foreach(free_module_prefs, NULL);
+ prefs_module_list_foreach(prefs_modules, free_module_prefs, NULL, FALSE);
+
+ /* Clean the uats */
+ uat_cleanup();
+
+ /* Shut down mmdbresolve */
+ maxmind_db_pref_cleanup();
+
+ g_free(prefs.saved_at_version);
+ g_free(gpf_path);
+ gpf_path = NULL;
+}
+
+void prefs_set_gui_theme_is_dark(gboolean is_dark)
+{
+ gui_theme_is_dark = is_dark;
}
/*
* the title used in the tab for it in a preferences dialog box, and a
* routine to call back when we apply the preferences.
*/
-module_t *
+static module_t *
prefs_register_module(module_t *parent, const char *name, const char *title,
const char *description, void (*apply_cb)(void),
const gboolean use_gui)
* at the top level and the title used in the tab for it in a preferences
* dialog box.
*/
-module_t *
+static module_t *
prefs_register_subtree(module_t *parent, const char *title, const char *description,
void (*apply_cb)(void))
{
module->parent = parent;
module->submodules = NULL; /* no submodules, to start */
module->numprefs = 0;
- module->prefs_changed = FALSE;
+ module->prefs_changed_flags = 0;
module->obsolete = FALSE;
module->use_gui = use_gui;
+ /* A module's preferences affects dissection unless otherwise told */
+ module->effect_flags = PREF_EFFECT_DISSECTION;
/*
* Do we have a module name?
* on the command line, and shouldn't require quoting,
* shifting, etc.
*/
- for (p = name; (c = *p) != '\0'; p++)
- g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
- c == '-' || c == '.');
+ for (p = name; (c = *p) != '\0'; p++) {
+ if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
+ c == '-' || c == '.'))
+ g_error("Preference module \"%s\" contains invalid characters", name);
+ }
/*
* Make sure there's not already a module with that
prefs_register_modules();
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol preferences being registered with an invalid protocol ID");
return prefs_register_module(protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
prefs_deregister_protocol (int id)
{
protocol_t *protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol preferences being de-registered with an invalid protocol ID");
prefs_deregister_module (protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol));
* being the name (if it's later registered explicitly
* with a description, that will override it).
*/
- ptr = wmem_strdup(wmem_epan_scope(), ptr),
+ ptr = wmem_strdup(wmem_epan_scope(), ptr);
new_module = prefs_register_subtree(subtree_module, ptr, ptr, NULL);
}
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol subtree being registered with an invalid protocol ID");
return prefs_register_module(subtree_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
prefs_register_modules();
}
protocol = find_protocol_by_id(id);
+ if (protocol == NULL)
+ g_error("Protocol being registered with an invalid protocol ID");
module = prefs_register_module(protocols_module,
proto_get_protocol_filter_name(id),
proto_get_protocol_short_name(protocol),
apply_cb, TRUE);
}
+/*
+ * Register that a codec has preferences.
+ *
+ * "name" is a name for the codec to use on the command line with "-o"
+ * and in preference files.
+ *
+ * "title" is a short human-readable name for the codec.
+ *
+ * "description" is a longer human-readable description of the codec.
+ */
+module_t *codecs_module = NULL;
+
+module_t *
+prefs_register_codec(const char *name, const char *title,
+ const char *description, void (*apply_cb)(void))
+{
+ /*
+ * Have we yet created the "Codecs" subtree?
+ */
+ if (codecs_module == NULL) {
+ /*
+ * No. Register Codecs subtree as well as any preferences
+ * for non-dissector modules.
+ */
+ pre_init_prefs();
+ prefs_register_modules();
+ }
+
+ return prefs_register_module(codecs_module, name, title, description,
+ apply_cb, TRUE);
+}
+
module_t *
prefs_find_module(const char *name)
{
* non-zero value, we stop and return that value, otherwise we
* return 0.
*
- * Ignores "obsolete" modules; their sole purpose is to allow old
+ * Normally "obsolete" modules are ignored; their sole purpose is to allow old
* preferences for dissectors that no longer have preferences to be
* silently ignored in preference files. Does not ignore subtrees,
* as this can be used when walking the display tree of modules.
module_cb callback;
gpointer user_data;
guint ret;
+ gboolean skip_obsolete;
} call_foreach_t;
static gboolean
module_t *module = (module_t*)value;
call_foreach_t *call_data = (call_foreach_t*)data;
- if (!module->obsolete)
+ if (!call_data->skip_obsolete || !module->obsolete)
call_data->ret = (*call_data->callback)(module, call_data->user_data);
return (call_data->ret != 0);
static guint
prefs_module_list_foreach(wmem_tree_t *module_list, module_cb callback,
- gpointer user_data)
+ gpointer user_data, gboolean skip_obsolete)
{
call_foreach_t call_data;
call_data.callback = callback;
call_data.user_data = user_data;
call_data.ret = 0;
+ call_data.skip_obsolete = skip_obsolete;
wmem_tree_foreach(module_list, call_foreach_cb, &call_data);
return call_data.ret;
}
guint
prefs_modules_foreach(module_cb callback, gpointer user_data)
{
- return prefs_module_list_foreach(prefs_modules, callback, user_data);
+ return prefs_module_list_foreach(prefs_modules, callback, user_data, TRUE);
}
/*
prefs_modules_foreach_submodules(module_t *module, module_cb callback,
gpointer user_data)
{
- return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data);
+ return prefs_module_list_foreach((module)?module->submodules:prefs_top_level_modules, callback, user_data, TRUE);
}
static gboolean
if (module->obsolete)
return FALSE;
- if (module->prefs_changed) {
+ if (module->prefs_changed_flags) {
if (module->apply_cb != NULL)
(*module->apply_cb)();
- module->prefs_changed = FALSE;
+ module->prefs_changed_flags = 0;
}
+ if (module->submodules)
+ wmem_tree_foreach(module->submodules, call_apply_cb, NULL);
return FALSE;
}
void
prefs_apply(module_t *module)
{
- if (module && module->prefs_changed)
+ if (module && module->prefs_changed_flags)
call_apply_cb(NULL, module, NULL);
}
*/
static pref_t *
register_preference(module_t *module, const char *name, const char *title,
- const char *description, pref_type_t type)
+ const char *description, int type)
{
pref_t *preference;
const gchar *p;
+ const char *name_prefix = (module->name != NULL) ? module->name : module->parent->name;
preference = g_new(pref_t,1);
preference->name = name;
preference->title = title;
preference->description = description;
preference->type = type;
+ /* Default to module's preference effects */
+ preference->effect_flags = module->effect_flags;
+
preference->gui = GUI_ALL; /* default */
if (title != NULL)
preference->ordinal = module->numprefs;
*/
for (p = name; *p != '\0'; p++)
if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
- g_error("Preference %s.%s contains invalid characters", module->name, name);
+ g_error("Preference \"%s.%s\" contains invalid characters", module->name, name);
/*
* Make sure there's not already a preference with that
if (prefs_find_preference(module, name) != NULL)
g_error("Preference %s has already been registered", name);
- if ((type != PREF_OBSOLETE) &&
+ if ((!IS_PREF_OBSOLETE(type)) &&
/* Don't compare if it's a subtree */
(module->name != NULL)) {
/*
g_error("Preference %s begins with the module name", name);
}
+ /* The title shows up in the preferences dialog. Make sure it's UI-friendly. */
+ if (preference->title) {
+ const char *cur_char;
+ if (preference->type != PREF_STATIC_TEXT && g_utf8_strlen(preference->title, -1) > 80) { // Arbitrary.
+ g_error("Title for preference %s.%s is too long: %s", name_prefix, preference->name, preference->title);
+ }
+
+ if (!g_utf8_validate(preference->title, -1, NULL)) {
+ g_error("Title for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+ }
+
+ for (cur_char = preference->title; *cur_char; cur_char = g_utf8_next_char(cur_char)) {
+ if (!g_unichar_isprint(g_utf8_get_char(cur_char))) {
+ g_error("Title for preference %s.%s isn't printable UTF-8.", name_prefix, preference->name);
+ }
+ }
+ }
+
+ if (preference->description) {
+ if (!g_utf8_validate(preference->description, -1, NULL)) {
+ g_error("Description for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+ }
+ }
+
/*
- * There isn't already one with that name, so add the
- * preference.
+ * We passed all of our checks. Add the preference.
*/
module->prefs = g_list_append(module->prefs, preference);
if (title != NULL)
typedef struct {
GList *list_entry;
const char *name;
+ module_t *submodule;
} find_pref_arg_t;
static gint
return FALSE;
arg->list_entry = list_entry;
+ arg->submodule = module;
return TRUE;
}
-struct preference *
-prefs_find_preference(module_t *module, const char *name)
+/* Tries to find a preference, setting containing_module to the (sub)module
+ * holding this preference. */
+static struct preference *
+prefs_find_preference_with_submodule(module_t *module, const char *name,
+ module_t **containing_module)
{
find_pref_arg_t arg;
GList *list_entry;
list_entry = g_list_find_custom(module->prefs, name,
preference_match);
+ arg.submodule = NULL;
if (list_entry == NULL)
{
if (list_entry == NULL)
return NULL; /* no such preference */
+ if (containing_module)
+ *containing_module = arg.submodule ? arg.submodule : module;
+
return (struct preference *) list_entry->data;
}
+struct preference *
+prefs_find_preference(module_t *module, const char *name)
+{
+ return prefs_find_preference_with_submodule(module, name, NULL);
+}
+
/*
* Returns TRUE if the given protocol has registered preferences
*/
preference->default_val.boolval = *var;
}
+unsigned int prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
+{
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.boolval != value) {
+ pref->default_val.boolval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.boolval != value) {
+ pref->stashed_val.boolval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.boolp != value) {
+ *pref->varp.boolp = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+void prefs_invert_bool_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ pref->default_val.boolval = !pref->default_val.boolval;
+ break;
+ case pref_stashed:
+ pref->stashed_val.boolval = !pref->stashed_val.boolval;
+ break;
+ case pref_current:
+ *pref->varp.boolp = !(*pref->varp.boolp);
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+}
+
+gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.boolval;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.boolval;
+ break;
+ case pref_current:
+ return *pref->varp.boolp;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return FALSE;
+}
+
/*
* Register a preference with an enumerated value.
*/
+/*
+ * XXX Should we get rid of the radio_buttons parameter and make that
+ * behavior automatic depending on the number of items?
+ */
void
prefs_register_enum_preference(module_t *module, const char *name,
const char *title, const char *description,
preference->info.enum_info.radio_buttons = radio_buttons;
}
-static pref_t*
+unsigned int prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
+{
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.enumval != value) {
+ pref->default_val.enumval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.enumval != value) {
+ pref->stashed_val.enumval = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.enump != value) {
+ *pref->varp.enump = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+gint prefs_get_enum_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.enumval;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.enumval;
+ break;
+ case pref_current:
+ return *pref->varp.enump;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return 0;
+}
+
+const enum_val_t* prefs_get_enumvals(pref_t *pref)
+{
+ return pref->info.enum_info.enumvals;
+}
+
+gboolean prefs_get_enum_radiobuttons(pref_t *pref)
+{
+ return pref->info.enum_info.radio_buttons;
+}
+
+static void
register_string_like_preference(module_t *module, const char *name,
const char *title, const char *description,
- const char **var, pref_type_t type)
+ char **var, int type,
+ struct pref_custom_cbs* custom_cbs,
+ gboolean free_tmp)
{
- pref_t *preference;
- char *varcopy;
+ pref_t *pref;
+ gchar *tmp;
- preference = register_preference(module, name, title, description,
- type);
+ pref = register_preference(module, name, title, description, type);
/*
* String preference values should be non-null (as you can't
* If the value is a null pointer, make it a copy of a null
* string, otherwise make it a copy of the value.
*/
+ tmp = *var;
if (*var == NULL) {
*var = g_strdup("");
- varcopy = g_strdup("");
} else {
*var = g_strdup(*var);
- varcopy = g_strdup(*var);
}
- preference->varp.string = var;
- preference->default_val.string = varcopy;
- preference->stashed_val.string = NULL;
-
- return preference;
+ if (free_tmp) {
+ g_free(tmp);
+ }
+ pref->varp.string = var;
+ pref->default_val.string = g_strdup(*var);
+ pref->stashed_val.string = NULL;
+ if (type == PREF_CUSTOM) {
+ g_assert(custom_cbs);
+ pref->custom_cbs = *custom_cbs;
+ }
}
/*
- * Register a preference with a character-string value.
+ * Assign to a string preference.
*/
-void
-prefs_register_string_preference(module_t *module, const char *name,
- const char *title, const char *description,
- const char **var)
+static void
+pref_set_string_like_pref_value(pref_t *pref, const gchar *value)
{
- register_string_like_preference(module, name, title, description, var,
- PREF_STRING);
+DIAG_OFF(cast-qual)
+ g_free((void *)*pref->varp.string);
+DIAG_ON(cast-qual)
+ *pref->varp.string = g_strdup(value);
}
/*
- * Register a "custom" preference with a character-string value.
- * XXX - This should be temporary until we can find a better way
- * to do "custom" preferences
+ * For use by UI code that sets preferences.
*/
-static void
-prefs_register_string_custom_preference(module_t *module, const char *name,
- const char *title, const char *description,
- struct pref_custom_cbs* custom_cbs, const char **var)
+unsigned int
+prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
{
- pref_t *preference;
+ unsigned int changed = 0;
+
+ switch (source)
+ {
+ case pref_default:
+ if (*pref->default_val.string) {
+ if (strcmp(pref->default_val.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ g_free(pref->default_val.string);
+ pref->default_val.string = g_strdup(value);
+ }
+ } else if (value) {
+ pref->default_val.string = g_strdup(value);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.string) {
+ if (strcmp(pref->stashed_val.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(value);
+ }
+ } else if (value) {
+ pref->stashed_val.string = g_strdup(value);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.string) {
+ if (strcmp(*pref->varp.string, value) != 0) {
+ changed = prefs_get_effect_flags(pref);
+ pref_set_string_like_pref_value(pref, value);
+ }
+ } else if (value) {
+ pref_set_string_like_pref_value(pref, value);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
- preference = register_string_like_preference(module, name, title, description, var,
- PREF_CUSTOM);
+ return changed;
+}
- preference->custom_cbs = *custom_cbs;
+char* prefs_get_string_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.string;
+ case pref_stashed:
+ return pref->stashed_val.string;
+ case pref_current:
+ return *pref->varp.string;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return NULL;
+}
+
+/*
+ * Reset the value of a string-like preference.
+ */
+static void
+reset_string_like_preference(pref_t *pref)
+{
+ g_free(*pref->varp.string);
+ *pref->varp.string = g_strdup(pref->default_val.string);
}
+/*
+ * Register a preference with a character-string value.
+ */
+void
+prefs_register_string_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ const char **var)
+{
+DIAG_OFF(cast-qual)
+ register_string_like_preference(module, name, title, description,
+ (char **)var, PREF_STRING, NULL, FALSE);
+DIAG_ON(cast-qual)
+}
/*
* Register a preference with a file name (string) value.
void
prefs_register_filename_preference(module_t *module, const char *name,
const char *title, const char *description,
- const char **var)
+ const char **var, gboolean for_writing)
{
- register_string_like_preference(module, name, title, description, var,
- PREF_FILENAME);
+DIAG_OFF(cast-qual)
+ register_string_like_preference(module, name, title, description, (char **)var,
+ for_writing ? PREF_SAVE_FILENAME : PREF_OPEN_FILENAME, NULL, FALSE);
+DIAG_ON(cast-qual)
}
/*
const char *title, const char *description,
const char **var)
{
- register_string_like_preference(module, name, title, description, var,
- PREF_DIRNAME);
+DIAG_OFF(cast-qual)
+ register_string_like_preference(module, name, title, description,
+ (char **)var, PREF_DIRNAME, NULL, FALSE);
+DIAG_ON(cast-qual)
}
-/*
- * Register a preference with a ranged value.
- */
-void
-prefs_register_range_preference(module_t *module, const char *name,
+/* Refactoring to handle both PREF_RANGE and PREF_DECODE_AS_RANGE */
+static void
+prefs_register_range_preference_common(module_t *module, const char *name,
const char *title, const char *description,
- range_t **var, guint32 max_value)
+ range_t **var, guint32 max_value, int type)
{
pref_t *preference;
- preference = register_preference(module, name, title, description,
- PREF_RANGE);
+ preference = register_preference(module, name, title, description, type);
preference->info.max_value = max_value;
-
/*
* Range preference values should be non-null (as you can't
* keep them null after using the preferences GUI, you can at best
* If the value is a null pointer, make it an empty range.
*/
if (*var == NULL)
- *var = range_empty();
+ *var = range_empty(wmem_epan_scope());
preference->varp.range = var;
- preference->default_val.range = range_copy(*var);
+ preference->default_val.range = range_copy(wmem_epan_scope(), *var);
preference->stashed_val.range = NULL;
}
/*
- * Register a static text 'preference'. It can be used to add explanatory
- * text inline with other preferences in the GUI.
- * Note: Static preferences are not saved to the preferences file.
+ * Register a preference with a ranged value.
*/
void
-prefs_register_static_text_preference(module_t *module, const char *name,
- const char *title,
- const char *description)
+prefs_register_range_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ range_t **var, guint32 max_value)
{
- register_preference(module, name, title, description, PREF_STATIC_TEXT);
+ prefs_register_range_preference_common(module, name, title,
+ description, var, max_value, PREF_RANGE);
}
-/*
- * Register a uat 'preference'. It adds a button that opens the uat's window in the
- * preferences tab of the module.
- */
-extern void
-prefs_register_uat_preference(module_t *module, const char *name,
- const char *title, const char *description,
- uat_t* uat)
+gboolean
+prefs_set_range_value_work(pref_t *pref, const gchar *value,
+ gboolean return_range_errors, unsigned int *changed_flags)
+{
+ range_t *newrange;
+
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+ return_range_errors) != CVT_NO_ERROR) {
+ return FALSE; /* number was bad */
+ }
+
+ if (!ranges_are_equal(*pref->varp.range, newrange)) {
+ *changed_flags |= prefs_get_effect_flags(pref);
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = newrange;
+ } else {
+ wmem_free(wmem_epan_scope(), newrange);
+ }
+ return TRUE;
+}
+
+/*
+ * For use by UI code that sets preferences.
+ */
+unsigned int
+prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
+{
+ range_t *newrange;
+
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
+ TRUE) != CVT_NO_ERROR) {
+ return 0; /* number was bad */
+ }
+
+ if (!ranges_are_equal(pref->stashed_val.range, newrange)) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = newrange;
+ } else {
+ wmem_free(wmem_epan_scope(), newrange);
+ }
+ return prefs_get_effect_flags(pref);
+
+}
+
+gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source)
+{
+ gboolean changed = FALSE;
+
+ switch (source)
+ {
+ case pref_default:
+ if (!ranges_are_equal(pref->default_val.range, value)) {
+ wmem_free(wmem_epan_scope(), pref->default_val.range);
+ pref->default_val.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ case pref_stashed:
+ if (!ranges_are_equal(pref->stashed_val.range, value)) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ case pref_current:
+ if (!ranges_are_equal(*pref->varp.range, value)) {
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), value);
+ changed = TRUE;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.range;
+ case pref_stashed:
+ return pref->stashed_val.range;
+ break;
+ case pref_current:
+ return *pref->varp.range;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return NULL;
+}
+
+range_t* prefs_get_range_value(const char *module_name, const char* pref_name)
+{
+ return prefs_get_range_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+void
+prefs_range_add_value(pref_t *pref, guint32 val)
+{
+ range_add_value(wmem_epan_scope(), pref->varp.range, val);
+}
+
+void
+prefs_range_remove_value(pref_t *pref, guint32 val)
+{
+ range_remove_value(wmem_epan_scope(), pref->varp.range, val);
+}
+
+/*
+ * Register a static text 'preference'. It can be used to add explanatory
+ * text inline with other preferences in the GUI.
+ * Note: Static preferences are not saved to the preferences file.
+ */
+void
+prefs_register_static_text_preference(module_t *module, const char *name,
+ const char *title,
+ const char *description)
+{
+ register_preference(module, name, title, description, PREF_STATIC_TEXT);
+}
+
+/*
+ * Register a uat 'preference'. It adds a button that opens the uat's window in the
+ * preferences tab of the module.
+ */
+extern void
+prefs_register_uat_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ uat_t* uat)
{
pref_t* preference = register_preference(module, name, title, description, PREF_UAT);
preference->gui = GUI_QT;
}
+struct epan_uat* prefs_get_uat_value(pref_t *pref)
+{
+ return pref->varp.uat;
+}
+
/*
* Register a color preference.
*/
preference->default_val.color = *color;
}
-/*
- * Register a "custom" preference with a list.
- * XXX - This should be temporary until we can find a better way
- * to do "custom" preferences
- */
-typedef void (*pref_custom_list_init_cb) (pref_t* pref, GList** value);
+gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source)
+{
+ gboolean changed = FALSE;
+
+ switch (source)
+ {
+ case pref_default:
+ if ((pref->default_val.color.red != value.red) &&
+ (pref->default_val.color.green != value.green) &&
+ (pref->default_val.color.blue != value.blue)) {
+ changed = TRUE;
+ pref->default_val.color = value;
+ }
+ break;
+ case pref_stashed:
+ if ((pref->stashed_val.color.red != value.red) &&
+ (pref->stashed_val.color.green != value.green) &&
+ (pref->stashed_val.color.blue != value.blue)) {
+ changed = TRUE;
+ pref->stashed_val.color = value;
+ }
+ break;
+ case pref_current:
+ if ((pref->varp.colorp->red != value.red) &&
+ (pref->varp.colorp->green != value.green) &&
+ (pref->varp.colorp->blue != value.blue)) {
+ changed = TRUE;
+ *pref->varp.colorp = value;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return changed;
+}
+
+color_t* prefs_get_color_value(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return &pref->default_val.color;
+ case pref_stashed:
+ return &pref->stashed_val.color;
+ break;
+ case pref_current:
+ return pref->varp.colorp;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return NULL;
+}
+
+/*
+ * Register a "custom" preference with a list.
+ * XXX - This should be temporary until we can find a better way
+ * to do "custom" preferences
+ */
+typedef void (*pref_custom_list_init_cb) (pref_t* pref, GList** value);
+
+static void
+prefs_register_list_custom_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ struct pref_custom_cbs* custom_cbs,
+ pref_custom_list_init_cb init_cb,
+ GList** list)
+{
+ pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+
+ preference->custom_cbs = *custom_cbs;
+ init_cb(preference, list);
+}
+
+/*
+ * Register a custom preference.
+ */
+void
+prefs_register_custom_preference(module_t *module, const char *name,
+ const char *title, const char *description,
+ struct pref_custom_cbs* custom_cbs,
+ void **custom_data _U_)
+{
+ pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+
+ preference->custom_cbs = *custom_cbs;
+ /* XXX - wait until we can handle void** pointers
+ preference->custom_cbs.init_cb(preference, custom_data);
+ */
+}
+
+/*
+ * Register a (internal) "Decode As" preference with a ranged value.
+ */
+void prefs_register_decode_as_range_preference(module_t *module, const char *name,
+ const char *title, const char *description, range_t **var,
+ guint32 max_value)
+{
+ prefs_register_range_preference_common(module, name, title,
+ description, var, max_value, PREF_DECODE_AS_RANGE);
+}
+
+/*
+ * Register a (internal) "Decode As" preference with an unsigned integral value
+ * for a dissector table.
+ */
+void prefs_register_decode_as_preference(module_t *module, const char *name,
+ const char *title, const char *description, guint *var)
+{
+ pref_t *preference;
+
+ preference = register_preference(module, name, title, description,
+ PREF_DECODE_AS_UINT);
+ preference->varp.uint = var;
+ preference->default_val.uint = *var;
+ /* XXX - Presume base 10 for now */
+ preference->info.base = 10;
+}
+
+gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace)
+{
+ switch(pref->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ /* This doesn't support multiple values for a dissector in Decode As because the
+ preference only supports a single value. This leads to a "last port for
+ dissector in Decode As wins" */
+ *pref->varp.uint = value;
+ break;
+ case PREF_DECODE_AS_RANGE:
+ if (replace)
+ {
+ /* If range has single value, replace it */
+ if (((*pref->varp.range)->nranges == 1) &&
+ ((*pref->varp.range)->ranges[0].low == (*pref->varp.range)->ranges[0].high)) {
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_empty(wmem_epan_scope());
+ }
+ }
+
+ prefs_range_add_value(pref, value);
+ break;
+ default:
+ /* XXX - Worth asserting over? */
+ break;
+ }
+
+ return TRUE;
+}
+
+gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default)
+{
+ switch(pref->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ if (set_default) {
+ *pref->varp.uint = pref->default_val.uint;
+ } else {
+ *pref->varp.uint = 0;
+ }
+ break;
+ case PREF_DECODE_AS_RANGE:
+ prefs_range_remove_value(pref, value);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Register a preference that used to be supported but no longer is.
+ */
+void
+prefs_register_obsolete_preference(module_t *module, const char *name)
+{
+ register_preference(module, name, NULL, NULL, PREF_OBSOLETE);
+}
+
+/*
+ * Check to see if a preference is obsolete.
+ */
+extern gboolean
+prefs_get_preference_obsolete(pref_t *pref)
+{
+ if (pref)
+ return (IS_PREF_OBSOLETE(pref->type) ? TRUE : FALSE);
+
+ return TRUE;
+}
+
+/*
+ * Make a preference obsolete.
+ */
+extern prefs_set_pref_e
+prefs_set_preference_obsolete(pref_t *pref)
+{
+ if (pref) {
+ SET_PREF_OBSOLETE(pref->type);
+ return PREFS_SET_OK;
+ }
+ return PREFS_SET_NO_SUCH_PREF;
+}
+
+guint
+pref_stash(pref_t *pref, gpointer unused _U_)
+{
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ pref->stashed_val.uint = *pref->varp.uint;
+ break;
+
+ case PREF_UINT:
+ pref->stashed_val.uint = *pref->varp.uint;
+ break;
+
+ case PREF_BOOL:
+ pref->stashed_val.boolval = *pref->varp.boolp;
+ break;
+
+ case PREF_ENUM:
+ pref->stashed_val.enumval = *pref->varp.enump;
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(*pref->varp.string);
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), *pref->varp.range);
+ break;
+
+ case PREF_COLOR:
+ pref->stashed_val.color = *pref->varp.colorp;
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+ return 0;
+}
+
+guint
+pref_unstash(pref_t *pref, gpointer unstash_data_p)
+{
+ pref_unstash_data_t *unstash_data = (pref_unstash_data_t *)unstash_data_p;
+ dissector_table_t sub_dissectors = NULL;
+ dissector_handle_t handle = NULL;
+
+ /* Revert the preference to its saved value. */
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ if (*pref->varp.uint != pref->stashed_val.uint) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ if (unstash_data->handle_decode_as) {
+ if (*pref->varp.uint != pref->default_val.uint) {
+ dissector_reset_uint(pref->name, *pref->varp.uint);
+ }
+ }
+
+ *pref->varp.uint = pref->stashed_val.uint;
+
+ if (unstash_data->handle_decode_as) {
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+ if (handle != NULL) {
+ dissector_change_uint(pref->name, *pref->varp.uint, handle);
+ }
+ }
+ }
+ }
+ break;
+
+ case PREF_UINT:
+ if (*pref->varp.uint != pref->stashed_val.uint) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = pref->stashed_val.uint;
+ }
+ break;
+
+ case PREF_BOOL:
+ if (*pref->varp.boolp != pref->stashed_val.boolval) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.boolp = pref->stashed_val.boolval;
+ }
+ break;
+
+ case PREF_ENUM:
+ if (*pref->varp.enump != pref->stashed_val.enumval) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.enump = pref->stashed_val.enumval;
+ }
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ g_free(*pref->varp.string);
+ *pref->varp.string = g_strdup(pref->stashed_val.string);
+ }
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+ guint32 i, j;
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ if (unstash_data->handle_decode_as) {
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, unstash_data->module->title);
+ if (handle != NULL) {
+ /* Delete all of the old values from the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_delete_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+
+ if (unstash_data->handle_decode_as) {
+ if ((sub_dissectors != NULL) && (handle != NULL)) {
+
+ /* Add new values to the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_change_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_change_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+ break;
+
+ case PREF_RANGE:
+ if (!ranges_are_equal(*pref->varp.range, pref->stashed_val.range)) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->stashed_val.range);
+ }
+ break;
+
+ case PREF_COLOR:
+ if ((pref->varp.colorp->blue != pref->stashed_val.color.blue) ||
+ (pref->varp.colorp->red != pref->stashed_val.color.red) ||
+ (pref->varp.colorp->green != pref->stashed_val.color.green)) {
+ unstash_data->module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.colorp = pref->stashed_val.color;
+ }
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
+ return 0;
+}
+
+void
+reset_stashed_pref(pref_t *pref) {
+ switch (pref->type) {
+
+ case PREF_DECODE_AS_UINT:
+ pref->stashed_val.uint = pref->default_val.uint;
+ break;
+
+ case PREF_UINT:
+ pref->stashed_val.uint = pref->default_val.uint;
+ break;
+
+ case PREF_BOOL:
+ pref->stashed_val.boolval = pref->default_val.boolval;
+ break;
+
+ case PREF_ENUM:
+ pref->stashed_val.enumval = pref->default_val.enumval;
+ break;
+
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = g_strdup(pref->default_val.string);
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = range_copy(wmem_epan_scope(), pref->default_val.range);
+ break;
-static void
-prefs_register_list_custom_preference(module_t *module, const char *name,
- const char *title, const char *description,
- struct pref_custom_cbs* custom_cbs,
- pref_custom_list_init_cb init_cb,
- GList** list)
-{
- pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+ case PREF_COLOR:
+ memcpy(&pref->stashed_val.color, &pref->default_val.color, sizeof(color_t));
+ break;
- preference->custom_cbs = *custom_cbs;
- init_cb(preference, list);
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
+ }
}
-/*
- * Register a custom preference.
- */
-void
-prefs_register_custom_preference(module_t *module, const char *name,
- const char *title, const char *description,
- struct pref_custom_cbs* custom_cbs,
- void **custom_data _U_)
+guint
+pref_clean_stash(pref_t *pref, gpointer unused _U_)
{
- pref_t* preference = register_preference(module, name, title, description, PREF_CUSTOM);
+ switch (pref->type) {
- preference->custom_cbs = *custom_cbs;
- /* XXX - wait until we can handle void** pointers
- preference->custom_cbs.init_cb(preference, custom_data);
- */
-}
+ case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
+ break;
-/*
- * Register a preference that used to be supported but no longer is.
- */
-void
-prefs_register_obsolete_preference(module_t *module, const char *name)
-{
- register_preference(module, name, NULL, NULL, PREF_OBSOLETE);
-}
+ case PREF_BOOL:
+ break;
-/*
- * Check to see if a preference is obsolete.
- */
-extern gboolean
-prefs_get_preference_obsolete(pref_t *pref)
-{
- if (pref)
- return pref->type == PREF_OBSOLETE ? TRUE : FALSE;
+ case PREF_ENUM:
+ break;
- return TRUE;
-}
+ case PREF_STRING:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
+ case PREF_DIRNAME:
+ if (pref->stashed_val.string != NULL) {
+ g_free(pref->stashed_val.string);
+ pref->stashed_val.string = NULL;
+ }
+ break;
-/*
- * Make a preference obsolete.
- */
-extern prefs_set_pref_e
-prefs_set_preference_obsolete(pref_t *pref)
-{
- if (pref) {
- pref->type = PREF_OBSOLETE;
- return PREFS_SET_OK;
+ case PREF_DECODE_AS_RANGE:
+ case PREF_RANGE:
+ if (pref->stashed_val.range != NULL) {
+ wmem_free(wmem_epan_scope(), pref->stashed_val.range);
+ pref->stashed_val.range = NULL;
+ }
+ break;
+
+ case PREF_STATIC_TEXT:
+ case PREF_UAT:
+ case PREF_COLOR:
+ case PREF_CUSTOM:
+ break;
+
+ case PREF_OBSOLETE:
+ g_assert_not_reached();
+ break;
}
- return PREFS_SET_NO_SUCH_PREF;
+ return 0;
}
#if 0
for (elem = g_list_first(module->prefs); elem != NULL; elem = g_list_next(elem)) {
pref = (pref_t *)elem->data;
- if (pref->type == PREF_OBSOLETE) {
+ if (IS_PREF_OBSOLETE(pref->type)) {
/*
* This preference is no longer supported; it's
* not a real preference, so we don't call the
if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000)
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
-#ifdef HAVE_LIBPORTAUDIO
- /* Test for a sane max channels entry */
- if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
-#endif
-
/* burst resolution can't be less than 1 (ms) */
if (prefs.st_burst_resolution < 1) {
prefs.st_burst_resolution = 1;
}
static prefs_set_pref_e
-console_log_level_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+console_log_level_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
guint uval;
uval = (guint)strtoul(value, NULL, 10);
if (*pref->varp.uint != uval) {
- *changed = TRUE;
+ *changed_flags = prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
#define PRS_COL_NUM "column.number"
static module_t *gui_column_module = NULL;
-static void
-column_hidden_free_cb(pref_t* pref)
-{
- g_free((char *)*pref->varp.string);
- *pref->varp.string = NULL;
- g_free(pref->default_val.string);
- pref->default_val.string = NULL;
-}
-
-static void
-column_hidden_reset_cb(pref_t* pref)
-{
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(pref->default_val.string);
-}
-
static prefs_set_pref_e
-column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+column_hidden_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
GList *clp;
fmt_data *cfmt;
pref_t *format_pref;
- if (*pref->varp.string) {
- if (strcmp(*pref->varp.string, value) != 0) {
- *changed = TRUE;
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(value);
- }
- } else if (value) {
- *pref->varp.string = g_strdup(value);
- }
+ (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
/*
* Set the "visible" flag for the existing columns; we need to
while (clp) {
gchar *prefs_fmt;
cfmt = (fmt_data *) clp->data;
- if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) {
+ if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
col_format_to_string(cfmt->fmt),
- cfmt->custom_field,
+ cfmt->custom_fields,
cfmt->custom_occurrence,
cfmt->resolved ? 'R' : 'U');
} else {
}
static prefs_set_pref_e
-column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, gboolean* changed _U_)
+column_num_set_cb(pref_t* pref _U_, const gchar* value _U_, unsigned int* changed_flags _U_)
{
/* Don't write this to the preferences file */
return PREFS_SET_OK;
dest_cfmt = g_new(fmt_data,1);
dest_cfmt->title = g_strdup(src_cfmt->title);
dest_cfmt->fmt = src_cfmt->fmt;
- if (src_cfmt->custom_field) {
- dest_cfmt->custom_field = g_strdup(src_cfmt->custom_field);
+ if (src_cfmt->custom_fields) {
+ dest_cfmt->custom_fields = g_strdup(src_cfmt->custom_fields);
dest_cfmt->custom_occurrence = src_cfmt->custom_occurrence;
} else {
- dest_cfmt->custom_field = NULL;
+ dest_cfmt->custom_fields = NULL;
dest_cfmt->custom_occurrence = 0;
}
dest_cfmt->visible = src_cfmt->visible;
dest_cfmt = g_new(fmt_data,1);
dest_cfmt->title = g_strdup(src_cfmt->title);
dest_cfmt->fmt = src_cfmt->fmt;
- if (src_cfmt->custom_field) {
- dest_cfmt->custom_field = g_strdup(src_cfmt->custom_field);
+ if (src_cfmt->custom_fields) {
+ dest_cfmt->custom_fields = g_strdup(src_cfmt->custom_fields);
dest_cfmt->custom_occurrence = src_cfmt->custom_occurrence;
} else {
- dest_cfmt->custom_field = NULL;
+ dest_cfmt->custom_fields = NULL;
dest_cfmt->custom_occurrence = 0;
}
dest_cfmt->visible = src_cfmt->visible;
}
static prefs_set_pref_e
-column_format_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+column_format_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
{
GList *col_l, *col_l_elt;
fmt_data *cfmt;
try_convert_to_custom_column(&col_l_elt->data);
} else {
/* We don't need the custom column field on this pass. */
- g_free(cfmt_check.custom_field);
+ g_free(cfmt_check.custom_fields);
}
/* Go past the format. */
}
prefs_clear_string_list(col_l);
- column_hidden_free_cb(hidden_pref);
+ free_string_like_preference(hidden_pref);
return PREFS_SET_OK;
}
def_cfmt = (fmt_data *) def_col->data;
if ((g_strcmp0(cfmt->title, def_cfmt->title) != 0) ||
(cfmt->fmt != def_cfmt->fmt) ||
- (((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) &&
- ((g_strcmp0(cfmt->custom_field, def_cfmt->custom_field) != 0) ||
+ (((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) &&
+ ((g_strcmp0(cfmt->custom_fields, def_cfmt->custom_fields) != 0) ||
(cfmt->resolved != def_cfmt->resolved)))) {
is_default = FALSE;
break;
while (clp) {
cfmt = (fmt_data *) clp->data;
col_l = g_list_append(col_l, g_strdup(cfmt->title));
- if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) {
+ if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
col_format_to_string(cfmt->fmt),
- cfmt->custom_field,
+ cfmt->custom_fields,
cfmt->custom_occurrence,
cfmt->resolved ? 'R' : 'U');
} else {
}
static prefs_set_pref_e
-capture_column_set_cb(pref_t* pref, const gchar* value, gboolean* changed _U_)
+capture_column_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags _U_)
{
GList *col_l = prefs_get_string_list(value);
GList *col_l_elt;
return capture_column_str;
}
-
-static void
-colorized_frame_free_cb(pref_t* pref)
-{
- g_free((char *)*pref->varp.string);
- *pref->varp.string = NULL;
- g_free(pref->default_val.string);
- pref->default_val.string = NULL;
-
-}
-
-static void
-colorized_frame_reset_cb(pref_t* pref)
-{
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(pref->default_val.string);
-}
-
static prefs_set_pref_e
-colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
+colorized_frame_set_cb(pref_t* pref, const gchar* value, unsigned int* changed_flags)
{
- if (strcmp(*pref->varp.string, value) != 0) {
- *changed = TRUE;
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(value);
- }
-
+ (*changed_flags) |= prefs_set_string_value(pref, value, pref_current);
return PREFS_SET_OK;
}
static module_t *gui_color_module = NULL;
static module_t *nameres_module = NULL;
-void
+static void
prefs_register_modules(void)
{
module_t *printing, *capture_module, *console_module,
*gui_layout_module, *gui_font_module;
+ module_t *extcap_module;
+ unsigned int layout_gui_flags;
struct pref_custom_cbs custom_cbs;
- gchar *tmp;
if (protocols_module != NULL) {
/* Already setup preferences */
return;
}
+ /* GUI
+ * These are "simple" GUI preferences that can be read/written using the
+ * preference module API. These preferences still use their own
+ * configuration screens for access, but this cuts down on the
+ * preference "string compare list" in set_pref()
+ */
+ extcap_module = prefs_register_module(NULL, "extcap", "Extcap Utilities",
+ "Extcap Utilities", NULL, FALSE);
+
+ /* Setting default value to true */
+ prefs.extcap_save_on_start = TRUE;
+ prefs_register_bool_preference(extcap_module, "gui_save_on_start",
+ "Save arguments on start of capture",
+ "Save arguments on start of capture",
+ &prefs.extcap_save_on_start);
+
/* GUI
* These are "simple" GUI preferences that can be read/written using the
* preference module API. These preferences still use their own
prefs_register_obsolete_preference(gui_module, "scrollbar_on_right");
prefs_register_obsolete_preference(gui_module, "packet_list_sel_browse");
prefs_register_obsolete_preference(gui_module, "protocol_tree_sel_browse");
-
- prefs_register_bool_preference(gui_module, "tree_view_altern_colors",
- "Alternating colors in TreeViews",
- "Alternating colors in TreeViews?",
- &prefs.gui_altern_colors);
+ prefs_register_obsolete_preference(gui_module, "tree_view_altern_colors");
prefs_register_bool_preference(gui_module, "expert_composite_eyecandy",
"Display Icons on Expert Composite Dialog Tabs",
"Place filter toolbar inside the statusbar?",
&prefs.filter_toolbar_show_in_statusbar);
+ prefs_register_bool_preference(gui_module, "restore_filter_after_following_stream",
+ "Restore current display filter after following a stream",
+ "Restore current display filter after following a stream?",
+ &prefs.restore_filter_after_following_stream);
+
prefs_register_enum_preference(gui_module, "protocol_tree_line_style",
"Protocol-tree line style",
"Protocol-tree line style",
"Protocol-tree expander style",
&prefs.gui_ptree_expander_style, gui_ptree_expander_style, FALSE);
- prefs_register_enum_preference(gui_module, "hex_dump_highlight_style",
- "Hex dump highlight style",
- "Hex dump highlight style",
- &prefs.gui_hex_dump_highlight_style, gui_hex_dump_highlight_style, FALSE);
+ prefs_register_obsolete_preference(gui_module, "hex_dump_highlight_style");
gui_column_module = prefs_register_subtree(gui_module, "Columns", "Columns", NULL);
- custom_cbs.free_cb = column_hidden_free_cb;
- custom_cbs.reset_cb = column_hidden_reset_cb;
+ custom_cbs.free_cb = free_string_like_preference;
+ custom_cbs.reset_cb = reset_string_like_preference;
custom_cbs.set_cb = column_hidden_set_cb;
custom_cbs.type_name_cb = column_hidden_type_name_cb;
custom_cbs.type_description_cb = column_hidden_type_description_cb;
custom_cbs.is_default_cb = column_hidden_is_default_cb;
custom_cbs.to_str_cb = column_hidden_to_str_cb;
- prefs_register_string_custom_preference(gui_column_module, PRS_COL_HIDDEN, "Packet list hidden columns",
- "List all columns to hide in the packet list", &custom_cbs, (const char **)&cols_hidden_list);
+ register_string_like_preference(gui_column_module, PRS_COL_HIDDEN, "Packet list hidden columns",
+ "List all columns to hide in the packet list",
+ &cols_hidden_list, PREF_CUSTOM, &custom_cbs, FALSE);
custom_cbs.free_cb = column_format_free_cb;
custom_cbs.reset_cb = column_format_reset_cb;
prefs_register_obsolete_preference(gui_font_module, "font_name");
- tmp = prefs.gui_gtk2_font_name;
- prefs_register_string_preference(gui_font_module, "gtk2.font_name", "Font name",
- "Font name for packet list, protocol tree, and hex dump panes. (GTK+)", (const char **)&prefs.gui_gtk2_font_name);
- g_free(tmp);
+ prefs_register_obsolete_preference(gui_font_module, "gtk2.font_name");
- tmp = prefs.gui_qt_font_name;
- prefs_register_string_preference(gui_font_module, "qt.font_name", "Font name",
- "Font name for packet list, protocol tree, and hex dump panes. (Qt)", (const char **)&prefs.gui_qt_font_name);
- g_free(tmp);
+ register_string_like_preference(gui_font_module, "qt.font_name", "Font name",
+ "Font name for packet list, protocol tree, and hex dump panes. (Qt)",
+ &prefs.gui_qt_font_name, PREF_STRING, NULL, TRUE);
/* User Interface : Colors */
gui_color_module = prefs_register_subtree(gui_module, "Colors", "Colors", NULL);
prefs_register_color_preference(gui_color_module, "stream.server.bg", "TCP stream window color preference",
"TCP stream window color preference", &prefs.st_server_bg);
- custom_cbs.free_cb = colorized_frame_free_cb;
- custom_cbs.reset_cb = colorized_frame_reset_cb;
+ custom_cbs.free_cb = free_string_like_preference;
+ custom_cbs.reset_cb = reset_string_like_preference;
custom_cbs.set_cb = colorized_frame_set_cb;
custom_cbs.type_name_cb = colorized_frame_type_name_cb;
custom_cbs.type_description_cb = colorized_frame_type_description_cb;
custom_cbs.is_default_cb = colorized_frame_is_default_cb;
custom_cbs.to_str_cb = colorized_frame_to_str_cb;
- tmp = prefs.gui_colorized_fg;
- prefs_register_string_custom_preference(gui_column_module, "colorized_frame.fg", "Colorized Foreground",
- "Filter Colorized Foreground", &custom_cbs, (const char **)&prefs.gui_colorized_fg);
- g_free(tmp);
+ register_string_like_preference(gui_column_module, "colorized_frame.fg", "Colorized Foreground",
+ "Filter Colorized Foreground",
+ &prefs.gui_colorized_fg, PREF_CUSTOM, &custom_cbs, TRUE);
- custom_cbs.free_cb = colorized_frame_free_cb;
- custom_cbs.reset_cb = colorized_frame_reset_cb;
+ custom_cbs.free_cb = free_string_like_preference;
+ custom_cbs.reset_cb = reset_string_like_preference;
custom_cbs.set_cb = colorized_frame_set_cb;
custom_cbs.type_name_cb = colorized_frame_type_name_cb;
custom_cbs.type_description_cb = colorized_frame_type_description_cb;
custom_cbs.is_default_cb = colorized_frame_is_default_cb;
custom_cbs.to_str_cb = colorized_frame_to_str_cb;
- tmp = prefs.gui_colorized_bg;
- prefs_register_string_custom_preference(gui_column_module, "colorized_frame.bg", "Colorized Background",
- "Filter Colorized Background", &custom_cbs, (const char **)&prefs.gui_colorized_bg);
- g_free(tmp);
+ register_string_like_preference(gui_column_module, "colorized_frame.bg", "Colorized Background",
+ "Filter Colorized Background",
+ &prefs.gui_colorized_bg, PREF_CUSTOM, &custom_cbs, TRUE);
prefs_register_color_preference(gui_color_module, "color_filter_bg.valid", "Valid color filter background",
"Valid color filter background", &prefs.gui_text_valid);
10,
&prefs.gui_recent_df_entries_max);
- tmp = prefs.gui_fileopen_dir;
- prefs_register_directory_preference(gui_module, "fileopen.dir", "Start Directory",
- "Directory to start in when opening File Open dialog.", (const char **)&prefs.gui_fileopen_dir);
- g_free(tmp);
+ register_string_like_preference(gui_module, "fileopen.dir", "Start Directory",
+ "Directory to start in when opening File Open dialog.",
+ &prefs.gui_fileopen_dir, PREF_DIRNAME, NULL, TRUE);
prefs_register_obsolete_preference(gui_module, "fileopen.remembered_dir");
"Save window maximized state at exit?",
&prefs.gui_geometry_save_maximized);
- prefs_register_bool_preference(gui_module, "macosx_style",
- "Use OS X style",
- "Use OS X style (OS X with native GTK only)?",
- &prefs.gui_macosx_style);
+ prefs_register_obsolete_preference(gui_module, "macosx_style");
prefs_register_obsolete_preference(gui_module, "geometry.main.x");
prefs_register_obsolete_preference(gui_module, "geometry.main.y");
"Filter Toolbar style",
&prefs.gui_toolbar_filter_style, gui_toolbar_style, FALSE);
- tmp = prefs.gui_webbrowser;
- prefs_register_string_preference(gui_module, "webbrowser", "The path to the webbrowser",
- "The path to the webbrowser (Ex: mozilla)", (const char **)&prefs.gui_webbrowser);
- g_free(tmp);
+ register_string_like_preference(gui_module, "webbrowser", "The path to the webbrowser",
+ "The path to the webbrowser (Ex: mozilla)",
+ &prefs.gui_webbrowser, PREF_STRING, NULL, TRUE);
prefs_register_bool_preference(gui_module, "update.enabled",
"Check for updates",
10,
&prefs.gui_update_interval);
- tmp = prefs.gui_window_title;
- prefs_register_string_preference(gui_module, "window_title", "Custom window title",
- "Custom window title. (Appended to existing titles.)", (const char **)&prefs.gui_window_title);
- g_free(tmp);
+ register_string_like_preference(gui_module, "window_title", "Custom window title",
+ "Custom window title to be appended to the existing title\n%P = profile name\n%V = version info",
+ &prefs.gui_window_title, PREF_STRING, NULL, TRUE);
+
+ register_string_like_preference(gui_module, "prepend_window_title", "Custom window title prefix",
+ "Custom window title to be prepended to the existing title\n%P = profile name\n%V = version info",
+ &prefs.gui_prepend_window_title, PREF_STRING, NULL, TRUE);
- tmp = prefs.gui_start_title;
- prefs_register_string_preference(gui_module, "start_title", "Custom start page title",
- "Custom start page title", (const char**)(&prefs.gui_start_title));
- g_free(tmp);
+ register_string_like_preference(gui_module, "start_title", "Custom start page title",
+ "Custom start page title",
+ &prefs.gui_start_title, PREF_STRING, NULL, TRUE);
prefs_register_enum_preference(gui_module, "version_placement",
"Show version in the start page and/or main screen's title bar",
"Show version in the start page and/or main screen's title bar",
(gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
- prefs_register_bool_preference(gui_module, "auto_scroll_on_expand",
- "Automatically scroll the recently expanded item",
- "Automatically scroll the recently expanded item",
- &prefs.gui_auto_scroll_on_expand);
-
- prefs_register_uint_preference(gui_module, "auto_scroll_percentage",
- "The percentage down the view the recently expanded item should be scrolled",
- "The percentage down the view the recently expanded item should be scrolled",
- 10,
- &prefs.gui_auto_scroll_percentage);
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_on_expand");
+ prefs_register_obsolete_preference(gui_module, "auto_scroll_percentage");
/* User Interface : Layout */
gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
+ /* Adjust the preference effects of layout GUI for better handling of preferences at Wireshark (GUI) level */
+ layout_gui_flags = prefs_get_module_effect_flags(gui_layout_module);
+ layout_gui_flags |= PREF_EFFECT_GUI_LAYOUT;
+ layout_gui_flags &= (~PREF_EFFECT_DISSECTION);
prefs_register_uint_preference(gui_layout_module, "layout_type",
"Layout type",
"Layout type (1-6)",
10,
(guint*)(void*)(&prefs.gui_layout_type));
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_type", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_1",
"Layout content of the pane 1",
"Layout content of the pane 1",
(gint*)(void*)(&prefs.gui_layout_content_1), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_1", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_2",
"Layout content of the pane 2",
"Layout content of the pane 2",
(gint*)(void*)(&prefs.gui_layout_content_2), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_2", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_3",
"Layout content of the pane 3",
"Layout content of the pane 3",
(gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
+ prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_3", layout_gui_flags);
prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
"Enable Packet List Separator",
"Enable Packet List Separator",
&prefs.gui_qt_packet_list_separator);
+ prefs_register_bool_preference(gui_layout_module, "show_selected_packet.enabled",
+ "Show selected packet in the Status Bar",
+ "Show selected packet in the Status Bar",
+ &prefs.gui_qt_show_selected_packet);
+
+ prefs_register_bool_preference(gui_layout_module, "show_file_load_time.enabled",
+ "Show file load time in the Status Bar",
+ "Show file load time in the Status Bar",
+ &prefs.gui_qt_show_file_load_time);
+
prefs_register_bool_preference(gui_module, "packet_editor.enabled",
"Enable Packet Editor",
"Enable Packet Editor (Experimental)",
"Show the intelligent scroll bar (a minimap of packet list colors in the scrollbar)",
&prefs.gui_packet_list_show_minimap);
+
+ prefs_register_bool_preference(gui_module, "interfaces_show_hidden",
+ "Show hidden interfaces",
+ "Show all interfaces, including interfaces marked as hidden",
+ &prefs.gui_interfaces_show_hidden);
+
+#ifdef HAVE_PCAP_REMOTE
+ prefs_register_bool_preference(gui_module, "interfaces_remote_display",
+ "Show Remote interfaces",
+ "Show remote interfaces in the interface selection",
+ &prefs.gui_interfaces_remote_display);
+#endif
+
+ register_string_like_preference(gui_module, "interfaces_hidden_types", "Hide interface types in list",
+ "Hide the given interface types in the startup list",
+ &prefs.gui_interfaces_hide_types, PREF_STRING, NULL, TRUE);
+
/* Console
* These are preferences that can be read/written using the
* preference module API. These preferences still use their own
* preference "string compare list" in set_pref()
*/
console_module = prefs_register_module(NULL, "console", "Console",
- "CONSOLE", NULL, FALSE);
+ "Console logging and debugging output", NULL, FALSE);
custom_cbs.free_cb = custom_pref_no_cb;
custom_cbs.reset_cb = console_log_level_reset_cb;
custom_cbs.is_default_cb = console_log_level_is_default_cb;
custom_cbs.to_str_cb = console_log_level_to_str_cb;
prefs_register_uint_custom_preference(console_module, "log.level", "logging level",
- "A bitmask of glib log levels", &custom_cbs, &prefs.console_log_level);
+ "A bitmask of GLib log levels", &custom_cbs, &prefs.console_log_level);
+
+ prefs_register_bool_preference(console_module, "incomplete_dissectors_check_debug",
+ "Print debug line for incomplete dissectors",
+ "Look for dissectors that left some bytes undecoded (debug)",
+ &prefs.incomplete_dissectors_check_debug);
+
+ /* Display filter Expressions
+ * This used to be an array of individual fields that has now been
+ * converted to a UAT. Just make it part of the GUI category even
+ * though the name of the preference will never be seen in preference
+ * file
+ */
+ filter_expression_register_uat(gui_module);
/* Capture
* These are preferences that can be read/written using the
* preference "string compare list" in set_pref()
*/
capture_module = prefs_register_module(NULL, "capture", "Capture",
- "CAPTURE", NULL, FALSE);
+ "Capture preferences", NULL, FALSE);
+ /* Capture preferences don't affect dissection */
+ prefs_set_module_effect_flags(capture_module, PREF_EFFECT_CAPTURE);
- prefs_register_string_preference(capture_module, "device", "Default capture device",
- "Default capture device", (const char **)&prefs.capture_device);
+ register_string_like_preference(capture_module, "device", "Default capture device",
+ "Default capture device",
+ &prefs.capture_device, PREF_STRING, NULL, FALSE);
- prefs_register_string_preference(capture_module, "devices_linktypes", "Interface link-layer header type",
+ register_string_like_preference(capture_module, "devices_linktypes", "Interface link-layer header type",
"Interface link-layer header types (Ex: en0(1),en1(143),...)",
- (const char **)&prefs.capture_devices_linktypes);
+ &prefs.capture_devices_linktypes, PREF_STRING, NULL, FALSE);
- prefs_register_string_preference(capture_module, "devices_descr", "Interface descriptions",
+ register_string_like_preference(capture_module, "devices_descr", "Interface descriptions",
"Interface descriptions (Ex: eth0(eth0 descr),eth1(eth1 descr),...)",
- (const char **)&prefs.capture_devices_descr);
+ &prefs.capture_devices_descr, PREF_STRING, NULL, FALSE);
- prefs_register_string_preference(capture_module, "devices_hide", "Hide interface",
- "Hide interface? (Ex: eth0,eth3,...)", (const char **)&prefs.capture_devices_hide);
+ register_string_like_preference(capture_module, "devices_hide", "Hide interface",
+ "Hide interface? (Ex: eth0,eth3,...)",
+ &prefs.capture_devices_hide, PREF_STRING, NULL, FALSE);
- prefs_register_string_preference(capture_module, "devices_monitor_mode", "Capture in monitor mode",
+ register_string_like_preference(capture_module, "devices_monitor_mode", "Capture in monitor mode",
"By default, capture in monitor mode on interface? (Ex: eth0,eth3,...)",
- (const char **)&prefs.capture_devices_monitor_mode);
+ &prefs.capture_devices_monitor_mode, PREF_STRING, NULL, FALSE);
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
- prefs_register_string_preference(capture_module, "devices_buffersize", "Interface buffer size",
+ register_string_like_preference(capture_module, "devices_buffersize", "Interface buffer size",
"Interface buffer size (Ex: en0(1),en1(143),...)",
- ((const char **)&prefs.capture_devices_buffersize));
+ &prefs.capture_devices_buffersize, PREF_STRING, NULL, FALSE);
#endif
- prefs_register_string_preference(capture_module, "devices_snaplen", "Interface snap length",
+ register_string_like_preference(capture_module, "devices_snaplen", "Interface snap length",
"Interface snap length (Ex: en0(65535),en1(1430),...)",
- (const char **)&prefs.capture_devices_snaplen);
+ &prefs.capture_devices_snaplen, PREF_STRING, NULL, FALSE);
- prefs_register_string_preference(capture_module, "devices_pmode", "Interface promiscuous mode",
+ register_string_like_preference(capture_module, "devices_pmode", "Interface promiscuous mode",
"Interface promiscuous mode (Ex: en0(0),en1(1),...)",
- (const char **)&prefs.capture_devices_pmode);
+ &prefs.capture_devices_pmode, PREF_STRING, NULL, FALSE);
prefs_register_bool_preference(capture_module, "prom_mode", "Capture in promiscuous mode",
"Capture in promiscuous mode?", &prefs.capture_prom_mode);
- prefs_register_string_preference(capture_module, "devices_filter", "Interface capture filter",
+ register_string_like_preference(capture_module, "devices_filter", "Interface capture filter",
"Interface capture filter (Ex: en0(tcp),en1(udp),...)",
- (const char **)&prefs.capture_devices_filter);
+ &prefs.capture_devices_filter, PREF_STRING, NULL, FALSE);
- prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in Pcap-NG format",
- "Capture in Pcap-NG format?", &prefs.capture_pcap_ng);
+ prefs_register_bool_preference(capture_module, "pcap_ng", "Capture in pcapng format",
+ "Capture in pcapng format?", &prefs.capture_pcap_ng);
prefs_register_bool_preference(capture_module, "real_time_update", "Update packet list in real time during capture",
"Update packet list in real time during capture?", &prefs.capture_real_time);
+ prefs_register_bool_preference(capture_module, "no_extcap", "Disable external capture interfaces",
+ "Disable external capture modules (extcap)", &prefs.capture_no_extcap);
+
/* We might want to make this a "recent" setting. */
prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture",
"Scroll packet list during capture?", &prefs.capture_auto_scroll);
+ /* GTK+ only, but we might implement this in Qt */
prefs_register_bool_preference(capture_module, "show_info", "Show capture info dialog while capturing",
"Show capture info dialog while capturing?", &prefs.capture_show_info);
"Name Resolution", NULL, TRUE);
addr_resolve_pref_init(nameres_module);
oid_pref_init(nameres_module);
-#ifdef HAVE_GEOIP
- geoip_db_pref_init(nameres_module);
-#endif
+ maxmind_db_pref_init(nameres_module);
/* Printing */
printing = prefs_register_module(NULL, "print", "Printing",
&prefs.pr_dest, print_dest_vals, TRUE);
#ifndef _WIN32
- tmp = prefs.pr_cmd;
- prefs_register_string_preference(printing, "command", "Command",
- "Output gets piped to this command when the destination is set to \"command\"", (const char**)(&prefs.pr_cmd));
- g_free(tmp);
+ register_string_like_preference(printing, "command", "Command",
+ "Output gets piped to this command when the destination is set to \"command\"",
+ &prefs.pr_cmd, PREF_STRING, NULL, TRUE);
#endif
- tmp = prefs.pr_file;
- prefs_register_filename_preference(printing, "file", "File",
- "This is the file that gets written to when the destination is set to \"file\"", (const char**)(&prefs.pr_file));
- g_free(tmp);
+ register_string_like_preference(printing, "file", "File",
+ "This is the file that gets written to when the destination is set to \"file\"",
+ &prefs.pr_file, PREF_SAVE_FILENAME, NULL, TRUE);
+
+ /* Codecs */
+ codecs_module = prefs_register_module(NULL, "codecs", "Codecs",
+ "Codecs", NULL, TRUE);
/* Statistics */
stats_module = prefs_register_module(NULL, "statistics", "Statistics",
10,
&prefs.tap_update_interval);
-#ifdef HAVE_LIBPORTAUDIO
- prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
- "Max visible channels in RTP Player",
- "Determines maximum height of RTP Player window",
- 10,
- &prefs.rtp_player_max_visible);
-#endif
+ prefs_register_obsolete_preference(stats_module, "rtp_player_max_visible");
prefs_register_bool_preference(stats_module, "st_enable_burstinfo",
"Enable the calculation of burst information",
"Look for dissectors that left some bytes undecoded.",
&prefs.enable_incomplete_dissectors_check);
+ prefs_register_bool_preference(protocols_module, "strict_conversation_tracking_heuristics",
+ "Enable stricter conversation tracking heuristics",
+ "Protocols may use things like VLAN ID or interface ID to narrow the potential for duplicate conversations."
+ "Currently only ICMP and ICMPv6 use this preference to add VLAN ID to conversation tracking",
+ &prefs.strict_conversation_tracking_heuristics);
+
/* Obsolete preferences
* These "modules" were reorganized/renamed to correspond to their GUI
* configuration screen within the preferences dialog
return NULL;
}
slstr[j] = '\0';
- sl = g_list_append(sl, slstr);
+ if (j > 0)
+ sl = g_list_append(sl, slstr);
+ else
+ g_free(slstr);
break;
}
if (cur_c == '"' && ! backslash) {
and it wasn't preceded by a backslash; it's the end of
the string we were working on... */
slstr[j] = '\0';
- sl = g_list_append(sl, slstr);
+ if (j > 0) {
+ sl = g_list_append(sl, slstr);
+ slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ }
/* ...and the beginning of a new string. */
state = PRE_STRING;
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
j = 0;
} else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) {
/* Either this isn't a white-space character, or we've started a
GString *joined_str = g_string_new("");
GList *cur, *first;
gchar *str;
- gchar *quoted_str;
guint item_count = 0;
cur = first = g_list_first(sl);
} else
g_string_append_c(joined_str, ' ');
- quoted_str = g_strescape(str, "");
- g_string_append_printf(joined_str, "\"%s\"", quoted_str);
- g_free(quoted_str);
+ g_string_append_c(joined_str, '"');
+ while (*str) {
+ gunichar uc = g_utf8_get_char (str);
+
+ if (uc == '"' || uc == '\\')
+ g_string_append_c(joined_str, '\\');
+
+ if (g_unichar_isprint(uc))
+ g_string_append_unichar (joined_str, uc);
+
+ str = g_utf8_next_char (str);
+ }
+
+ g_string_append_c(joined_str, '"');
cur = cur->next;
}
return default_value;
}
+
+/* Array of columns that have been migrated to custom columns */
+struct deprecated_columns {
+ const gchar *col_fmt;
+ const gchar *col_expr;
+};
+static struct deprecated_columns migrated_columns[] = {
+ { /* COL_COS_VALUE */ "%U", "vlan.priority" },
+ { /* COL_CIRCUIT_ID */ "%c", "iax2.call" },
+ { /* COL_BSSGP_TLLI */ "%l", "bssgp.tlli" },
+ { /* COL_HPUX_SUBSYS */ "%H", "nettl.subsys" },
+ { /* COL_HPUX_DEVID */ "%P", "nettl.devid" },
+ { /* COL_FR_DLCI */ "%C", "fr.dlci" },
+ { /* COL_REL_CONV_TIME */ "%rct", "tcp.time_relative" },
+ { /* COL_DELTA_CONV_TIME */ "%dct", "tcp.time_delta" },
+ { /* COL_OXID */ "%XO", "fc.ox_id" },
+ { /* COL_RXID */ "%XR", "fc.rx_id" },
+ { /* COL_SRCIDX */ "%Xd", "mdshdr.srcidx" },
+ { /* COL_DSTIDX */ "%Xs", "mdshdr.dstidx" },
+ { /* COL_DCE_CTX */ "%z", "dcerpc.cn_ctx_id" }
+};
+
+static gboolean
+is_deprecated_column_format(const gchar* fmt)
+{
+ guint haystack_idx;
+
+ for (haystack_idx = 0;
+ haystack_idx < G_N_ELEMENTS(migrated_columns);
+ ++haystack_idx) {
+
+ if (strcmp(migrated_columns[haystack_idx].col_fmt, fmt) == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
/* Preferences file format:
* - Configuration directives start at the beginning of the line, and
* are terminated with a colon.
gchar **cust_format_info;
char *p;
int col_fmt;
- gchar *col_custom_field = NULL;
+ gchar *col_custom_fields = NULL;
long col_custom_occurrence = 0;
gboolean col_resolved = TRUE;
/* Yes. */
col_fmt = COL_CUSTOM;
cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */
- col_custom_field = g_strdup(cust_format_info[0]);
- if (col_custom_field && cust_format_info[1]) {
+ col_custom_fields = g_strdup(cust_format_info[0]);
+ if (col_custom_fields && cust_format_info[1]) {
col_custom_occurrence = strtol(cust_format_info[1], &p, 10);
if (p == cust_format_info[1] || *p != '\0') {
/* Not a valid number. */
- g_free(col_custom_field);
+ g_free(col_custom_fields);
g_strfreev(cust_format_info);
return FALSE;
}
}
- if (col_custom_field && cust_format_info[1] && cust_format_info[2]) {
+ if (col_custom_fields && cust_format_info[1] && cust_format_info[2]) {
col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE;
}
g_strfreev(cust_format_info);
} else {
col_fmt = get_column_format_from_str(fmt);
- if (col_fmt == -1)
+ if ((col_fmt == -1) && (!is_deprecated_column_format(fmt)))
return FALSE;
}
cfmt->fmt = col_fmt;
- cfmt->custom_field = col_custom_field;
+ cfmt->custom_fields = col_custom_fields;
cfmt->custom_occurrence = (int)col_custom_occurrence;
cfmt->resolved = col_resolved;
return TRUE;
prefs_register_modules();
- filter_expression_init(TRUE);
-
prefs_initialized = TRUE;
}
prefs.pr_format = PR_FMT_TEXT;
prefs.pr_dest = PR_DEST_CMD;
- if (prefs.pr_file) g_free(prefs.pr_file);
+ g_free(prefs.pr_file);
prefs.pr_file = g_strdup("wireshark.out");
- if (prefs.pr_cmd) g_free(prefs.pr_cmd);
+ g_free(prefs.pr_cmd);
prefs.pr_cmd = g_strdup("lpr");
- prefs.gui_altern_colors = FALSE;
prefs.gui_expert_composite_eyecandy = FALSE;
prefs.gui_ptree_line_style = 0;
prefs.gui_ptree_expander_style = 1;
- prefs.gui_hex_dump_highlight_style = 1;
prefs.filter_toolbar_show_in_statusbar = FALSE;
+ prefs.restore_filter_after_following_stream = FALSE;
prefs.gui_toolbar_main_style = TB_STYLE_ICONS;
prefs.gui_toolbar_filter_style = TB_STYLE_TEXT;
- /* These will be g_freed, so they must be g_mallocated. */
- if (prefs.gui_gtk2_font_name) g_free(prefs.gui_gtk2_font_name);
-#ifdef _WIN32
- prefs.gui_gtk2_font_name = g_strdup("Lucida Console 10");
-#else
- prefs.gui_gtk2_font_name = g_strdup("Monospace 10");
-#endif
/* We try to find the best font in the Qt code */
- if (prefs.gui_qt_font_name) g_free(prefs.gui_qt_font_name);
+ g_free(prefs.gui_qt_font_name);
prefs.gui_qt_font_name = g_strdup("");
- prefs.gui_marked_fg.pixel = 65535;
prefs.gui_marked_fg.red = 65535;
prefs.gui_marked_fg.green = 65535;
prefs.gui_marked_fg.blue = 65535;
- prefs.gui_marked_bg.pixel = 0;
prefs.gui_marked_bg.red = 0;
prefs.gui_marked_bg.green = 8224;
prefs.gui_marked_bg.blue = 10794;
- prefs.gui_ignored_fg.pixel = 32767;
prefs.gui_ignored_fg.red = 32767;
prefs.gui_ignored_fg.green = 32767;
prefs.gui_ignored_fg.blue = 32767;
- prefs.gui_ignored_bg.pixel = 65535;
prefs.gui_ignored_bg.red = 65535;
prefs.gui_ignored_bg.green = 65535;
prefs.gui_ignored_bg.blue = 65535;
- if (prefs.gui_colorized_fg) g_free(prefs.gui_colorized_fg);
+ g_free(prefs.gui_colorized_fg);
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
- if (prefs.gui_colorized_bg) g_free(prefs.gui_colorized_bg);
+ g_free(prefs.gui_colorized_bg);
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
- prefs.st_client_fg.pixel = 0;
prefs.st_client_fg.red = 32767;
prefs.st_client_fg.green = 0;
prefs.st_client_fg.blue = 0;
- prefs.st_client_bg.pixel = 0;
prefs.st_client_bg.red = 64507;
prefs.st_client_bg.green = 60909;
prefs.st_client_bg.blue = 60909;
- prefs.st_server_fg.pixel = 0;
prefs.st_server_fg.red = 0;
prefs.st_server_fg.green = 0;
prefs.st_server_fg.blue = 32767;
- prefs.st_server_bg.pixel = 0;
prefs.st_server_bg.red = 60909;
prefs.st_server_bg.green = 60909;
prefs.st_server_bg.blue = 64507;
- prefs.gui_text_valid.pixel = 0; /* light green */
- prefs.gui_text_valid.red = 0xAFFF;
- prefs.gui_text_valid.green = 0xFFFF;
- prefs.gui_text_valid.blue = 0xAFFF;
- prefs.gui_text_invalid.pixel = 0; /* light red */
- prefs.gui_text_invalid.red = 0xFFFF;
- prefs.gui_text_invalid.green = 0xAFFF;
- prefs.gui_text_invalid.blue = 0xAFFF;
- prefs.gui_text_deprecated.pixel = 0; /* light yellow */
- prefs.gui_text_deprecated.red = 0xFFFF;
- prefs.gui_text_deprecated.green = 0xFFFF;
- prefs.gui_text_deprecated.blue = 0xAFFF;
+
+ if (gui_theme_is_dark) {
+ // Green, red and yellow with HSV V = 84
+ prefs.gui_text_valid.red = 0x0000; /* dark green */
+ prefs.gui_text_valid.green = 0x66ff;
+ prefs.gui_text_valid.blue = 0x0000;
+ prefs.gui_text_invalid.red = 0x66FF; /* dark red */
+ prefs.gui_text_invalid.green = 0x0000;
+ prefs.gui_text_invalid.blue = 0x0000;
+ prefs.gui_text_deprecated.red = 0x66FF; /* dark yellow / olive */
+ prefs.gui_text_deprecated.green = 0x66FF;
+ prefs.gui_text_deprecated.blue = 0x0000;
+ } else {
+ // Green, red and yellow with HSV V = 20
+ prefs.gui_text_valid.red = 0xAFFF; /* light green */
+ prefs.gui_text_valid.green = 0xFFFF;
+ prefs.gui_text_valid.blue = 0xAFFF;
+ prefs.gui_text_invalid.red = 0xFFFF; /* light red */
+ prefs.gui_text_invalid.green = 0xAFFF;
+ prefs.gui_text_invalid.blue = 0xAFFF;
+ prefs.gui_text_deprecated.red = 0xFFFF; /* light yellow */
+ prefs.gui_text_deprecated.green = 0xFFFF;
+ prefs.gui_text_deprecated.blue = 0xAFFF;
+ }
+
prefs.gui_geometry_save_position = TRUE;
prefs.gui_geometry_save_size = TRUE;
prefs.gui_geometry_save_maximized= TRUE;
- prefs.gui_macosx_style = TRUE;
prefs.gui_console_open = console_open_never;
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
prefs.gui_recent_df_entries_max = 10;
prefs.gui_recent_files_count_max = 10;
- if (prefs.gui_fileopen_dir) g_free(prefs.gui_fileopen_dir);
+ g_free(prefs.gui_fileopen_dir);
prefs.gui_fileopen_dir = g_strdup(get_persdatafile_dir());
prefs.gui_fileopen_preview = 3;
prefs.gui_ask_unsaved = TRUE;
prefs.gui_update_enabled = TRUE;
prefs.gui_update_channel = UPDATE_CHANNEL_STABLE;
prefs.gui_update_interval = 60*60*24; /* Seconds */
- if (prefs.gui_webbrowser) g_free(prefs.gui_webbrowser);
-#ifdef HTML_VIEWER
- prefs.gui_webbrowser = g_strdup(HTML_VIEWER " %s");
-#else
+ g_free(prefs.gui_webbrowser);
prefs.gui_webbrowser = g_strdup("");
-#endif
- if (prefs.gui_window_title) g_free(prefs.gui_window_title);
+ g_free(prefs.gui_window_title);
prefs.gui_window_title = g_strdup("");
- if (prefs.gui_start_title) g_free(prefs.gui_start_title);
+ g_free(prefs.gui_prepend_window_title);
+ prefs.gui_prepend_window_title = g_strdup("");
+ g_free(prefs.gui_start_title);
prefs.gui_start_title = g_strdup("The World's Most Popular Network Protocol Analyzer");
prefs.gui_version_placement = version_both;
- prefs.gui_auto_scroll_on_expand = FALSE;
- prefs.gui_auto_scroll_percentage = 0;
prefs.gui_layout_type = layout_type_5;
prefs.gui_layout_content_1 = layout_pane_content_plist;
prefs.gui_layout_content_2 = layout_pane_content_pdetails;
prefs.gui_packet_list_elide_mode = ELIDE_RIGHT;
prefs.gui_packet_list_show_related = TRUE;
prefs.gui_packet_list_show_minimap = TRUE;
+ g_free (prefs.gui_interfaces_hide_types);
+ prefs.gui_interfaces_hide_types = g_strdup("");
+ prefs.gui_interfaces_show_hidden = FALSE;
+#ifdef HAVE_PCAP_REMOTE
+ prefs.gui_interfaces_remote_display = TRUE;
+#endif
prefs.gui_qt_packet_list_separator = FALSE;
+ prefs.gui_qt_show_selected_packet = FALSE;
+ prefs.gui_qt_show_file_load_time = FALSE;
- if (!prefs.col_list) {
- /* First time through */
- for (i = 0; i < DEF_NUM_COLS; i++) {
- cfmt = g_new(fmt_data,1);
- cfmt->title = g_strdup(col_fmt[i * 2]);
- parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
- cfmt->visible = TRUE;
- cfmt->resolved = TRUE;
- cfmt->custom_field = NULL;
- cfmt->custom_occurrence = 0;
- prefs.col_list = g_list_append(prefs.col_list, cfmt);
- }
- prefs.num_cols = DEF_NUM_COLS;
+ if (prefs.col_list) {
+ free_col_info(prefs.col_list);
+ prefs.col_list = NULL;
}
+ for (i = 0; i < DEF_NUM_COLS; i++) {
+ cfmt = g_new(fmt_data,1);
+ cfmt->title = g_strdup(col_fmt[i * 2]);
+ parse_column_format(cfmt, col_fmt[(i * 2) + 1]);
+ cfmt->visible = TRUE;
+ cfmt->resolved = TRUE;
+ cfmt->custom_fields = NULL;
+ cfmt->custom_occurrence = 0;
+ prefs.col_list = g_list_append(prefs.col_list, cfmt);
+ }
+ prefs.num_cols = DEF_NUM_COLS;
/* set the default values for the capture dialog box */
prefs.capture_prom_mode = TRUE;
prefs.capture_pcap_ng = FALSE;
#endif
prefs.capture_real_time = TRUE;
+ prefs.capture_no_extcap = FALSE;
prefs.capture_auto_scroll = TRUE;
prefs.capture_show_info = FALSE;
/* set the default values for the tap/statistics dialog box */
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs.st_enable_burstinfo = TRUE;
prefs.st_burst_showcount = FALSE;
prefs.st_burst_resolution = ST_DEF_BURSTRES;
/*
* Reset a single dissector preference.
*/
-static void
+void
reset_pref(pref_t *pref)
{
+ int type;
if (!pref) return;
- switch (pref->type) {
+ type = pref->type;
+
+ /*
+ * This preference is no longer supported; it's not a
+ * real preference, so we don't reset it (i.e., we
+ * treat it as if it weren't found in the list of
+ * preferences, and we weren't called in the first place).
+ */
+ if (IS_PREF_OBSOLETE(type))
+ return;
+ else
+ RESET_PREF_OBSOLETE(type);
+
+ switch (type) {
case PREF_UINT:
+ case PREF_DECODE_AS_UINT:
*pref->varp.uint = pref->default_val.uint;
break;
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(pref->default_val.string);
+ reset_string_like_preference(pref);
break;
case PREF_RANGE:
- g_free(*pref->varp.range);
- *pref->varp.range = range_copy(pref->default_val.range);
+ case PREF_DECODE_AS_RANGE:
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
+ *pref->varp.range = range_copy(wmem_epan_scope(), pref->default_val.range);
break;
case PREF_STATIC_TEXT:
case PREF_CUSTOM:
pref->custom_cbs.reset_cb(pref);
break;
-
- case PREF_OBSOLETE:
- /*
- * This preference is no longer supported; it's not a
- * real preference, so we don't reset it (i.e., we
- * treat it as if it weren't found in the list of
- * preferences, and we weren't called in the first place).
- */
- break;
}
}
*/
oids_cleanup();
- /*
- * Free the filter expression list.
- */
-
- filter_expression_free(*pfilter_expression_head);
- *pfilter_expression_head = NULL;
-
/*
* Reset the non-dissector preferences.
*/
/* Read the preferences file, fill in "prefs", and return a pointer to it.
- If we got an error (other than "it doesn't exist") trying to read
- the global preferences file, stuff the errno into "*gpf_errno_return"
- and a pointer to the path of the file into "*gpf_path_return", and
- return NULL.
-
- If we got an error (other than "it doesn't exist") trying to read
- the user's preferences file, stuff the errno into "*pf_errno_return"
- and a pointer to the path of the file into "*pf_path_return", and
- return NULL. */
+ If we got an error (other than "it doesn't exist") we report it through
+ the UI. */
e_prefs *
-
-read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
- char **gpf_path_return, int *pf_errno_return,
- int *pf_read_errno_return, char **pf_path_return)
+read_prefs(void)
{
int err;
char *pf_path;
* XXX - if it failed for a reason other than "it doesn't exist",
* report the error.
*/
- *gpf_path_return = NULL;
if (pf != NULL) {
/*
* Start out the counters of "mgcp.{tcp,udp}.port" entries we've
/* We succeeded in opening it; read it. */
err = read_prefs_file(gpf_path, pf, set_pref, NULL);
if (err != 0) {
- /* We had an error reading the file; return the errno and the
- pathname, so our caller can report the error. */
- *gpf_errno_return = 0;
- *gpf_read_errno_return = err;
- *gpf_path_return = gpf_path;
+ /* We had an error reading the file; report it. */
+ report_warning("Error reading global preferences file \"%s\": %s.",
+ gpf_path, g_strerror(err));
}
fclose(pf);
} else {
/* We failed to open it. If we failed for some reason other than
- "it doesn't exist", return the errno and the pathname, so our
- caller can report the error. */
+ "it doesn't exist", report the error. */
if (errno != ENOENT) {
- *gpf_errno_return = errno;
- *gpf_read_errno_return = 0;
- *gpf_path_return = gpf_path;
+ if (errno != 0) {
+ report_warning("Can't open global preferences file \"%s\": %s.",
+ gpf_path, g_strerror(errno));
+ }
}
}
pf_path = get_persconffile_path(PF_NAME, TRUE);
/* Read the user's preferences file, if it exists. */
- *pf_path_return = NULL;
if ((pf = ws_fopen(pf_path, "r")) != NULL) {
/*
* Start out the counters of "mgcp.{tcp,udp}.port" entries we've
/* We succeeded in opening it; read it. */
err = read_prefs_file(pf_path, pf, set_pref, NULL);
if (err != 0) {
- /* We had an error reading the file; return the errno and the
- pathname, so our caller can report the error. */
- *pf_errno_return = 0;
- *pf_read_errno_return = err;
- *pf_path_return = pf_path;
+ /* We had an error reading the file; report it. */
+ report_warning("Error reading your preferences file \"%s\": %s.",
+ pf_path, g_strerror(err));
} else
g_free(pf_path);
fclose(pf);
"it doesn't exist", return the errno and the pathname, so our
caller can report the error. */
if (errno != ENOENT) {
- *pf_errno_return = errno;
- *pf_read_errno_return = 0;
- *pf_path_return = pf_path;
+ report_warning("Can't open your preferences file \"%s\": %s.",
+ pf_path, g_strerror(errno));
} else
g_free(pf_path);
}
return &prefs;
}
-/* read the preferences file (or similiar) and call the callback
+/* read the preferences file (or similar) and call the callback
* function to set each key/value pair found */
int
read_prefs_file(const char *pf_path, FILE *pf,
}
rewind(pf);
- while ((got_c = getc(pf)) != EOF) {
+ while ((got_c = ws_getc_unlocked(pf)) != EOF) {
if (got_c == '\r') {
/* Treat CR-LF at the end of a line like LF, so that if we're reading
* a Windows-format file on UN*X, we handle it the same way we'd handle
* a UN*X-format file. */
- got_c = getc(pf);
+ got_c = ws_getc_unlocked(pf);
if (got_c == EOF)
break;
if (got_c != '\n') {
* If the pref has a trailing comma, eliminate it.
*/
cur_val->str[cur_val->len-1] = '\0';
- g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
+ ws_g_warning ("%s line %d: trailing comma in \"%s\" %s", pf_path, pline, cur_var->str, hint);
}
}
/* Call the routine to set the preference; it will parse
break;
case PREFS_SET_SYNTAX_ERR:
- g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
+ ws_g_warning ("Syntax error in preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
break;
* on non-Win32 platforms.
*/
if (strcmp(cur_var->str, "print.command") != 0)
- g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+ ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
The prefs in question need to be listed in the console window so that the
user can make an informed choice.
*/
- g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
+ ws_g_warning ("Obsolete preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
}
} else {
- g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
+ ws_g_warning ("Incomplete preference at line %d: of\n%s %s", pline, pf_path, hint);
}
}
state = IN_VAR;
} else if (got_c == '#') {
state = IN_SKIP;
} else {
- g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
+ ws_g_warning ("Malformed preference at line %d of\n%s %s", fline, pf_path, hint);
}
break;
case IN_VAR:
break;
case PREFS_SET_SYNTAX_ERR:
- g_warning ("Syntax error in preference %s at line %d of\n%s %s",
+ ws_g_warning ("Syntax error in preference %s at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
break;
case PREFS_SET_NO_SUCH_PREF:
- g_warning ("No such preference \"%s\" at line %d of\n%s %s",
+ ws_g_warning ("No such preference \"%s\" at line %d of\n%s %s",
cur_var->str, pline, pf_path, hint);
prefs.unknown_prefs = TRUE;
break;
break;
}
} else {
- g_warning ("Incomplete preference at line %d of\n%s %s",
+ ws_g_warning("Incomplete preference at line %d of\n%s %s",
pline, pf_path, hint);
}
}
* a valid uat entry.
*/
static gboolean
-prefs_set_uat_pref(char *uat_entry) {
+prefs_set_uat_pref(char *uat_entry, char **errmsg) {
gchar *p, *colonp;
uat_t *uat;
- gchar *err = NULL;
gboolean ret;
colonp = strchr(uat_entry, ':');
uat = uat_find(uat_entry);
*colonp = ':';
if (uat == NULL) {
+ *errmsg = g_strdup("Unknown preference");
return FALSE;
}
- ret = uat_load_str(uat, p, &err);
- g_free(err);
+ ret = uat_load_str(uat, p, errmsg);
return ret;
}
* in some fashion.
*/
prefs_set_pref_e
-prefs_set_pref(char *prefarg)
+prefs_set_pref(char *prefarg, char **errmsg)
{
gchar *p, *colonp;
prefs_set_pref_e ret;
mgcp_tcp_port_count = -1;
mgcp_udp_port_count = -1;
+ *errmsg = NULL;
+
colonp = strchr(prefarg, ':');
if (colonp == NULL)
return PREFS_SET_SYNTAX_ERR;
if (strcmp(prefarg, "uat")) {
ret = set_pref(prefarg, p, NULL, TRUE);
} else {
- ret = prefs_set_uat_pref(p) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
+ ret = prefs_set_uat_pref(p, errmsg) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
+ }
+ *colonp = ':'; /* put the colon back */
+ return ret;
+}
+
+guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source)
+{
+ switch (source)
+ {
+ case pref_default:
+ return pref->default_val.uint;
+ break;
+ case pref_stashed:
+ return pref->stashed_val.uint;
+ break;
+ case pref_current:
+ return *pref->varp.uint;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+
+ return 0;
+}
+
+guint prefs_get_uint_value(const char *module_name, const char* pref_name)
+{
+ return prefs_get_uint_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
+}
+
+unsigned int prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
+{
+ unsigned int changed = 0;
+ switch (source)
+ {
+ case pref_default:
+ if (pref->default_val.uint != value) {
+ pref->default_val.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_stashed:
+ if (pref->stashed_val.uint != value) {
+ pref->stashed_val.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ case pref_current:
+ if (*pref->varp.uint != value) {
+ *pref->varp.uint = value;
+ changed = prefs_get_effect_flags(pref);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ break;
}
- *colonp = ':'; /* put the colon back */
- return ret;
+
+ return changed;
+}
+
+guint prefs_get_uint_base(pref_t *pref)
+{
+ return pref->info.base;
}
/*
*/
if (cfmt->fmt != cfmt_hidden.fmt) {
/* No. */
- g_free(cfmt_hidden.custom_field);
- cfmt_hidden.custom_field = NULL;
+ g_free(cfmt_hidden.custom_fields);
+ cfmt_hidden.custom_fields = NULL;
continue;
}
if (cfmt->fmt == COL_CUSTOM) {
* A custom column has to have the
* same custom field and occurrence.
*/
- if (cfmt_hidden.custom_field && cfmt->custom_field) {
- if (strcmp(cfmt->custom_field,
- cfmt_hidden.custom_field) != 0) {
+ if (cfmt_hidden.custom_fields && cfmt->custom_fields) {
+ if (strcmp(cfmt->custom_fields,
+ cfmt_hidden.custom_fields) != 0) {
/* Different fields. */
- g_free(cfmt_hidden.custom_field);
- cfmt_hidden.custom_field = NULL;
+ g_free(cfmt_hidden.custom_fields);
+ cfmt_hidden.custom_fields = NULL;
continue;
}
if (cfmt->custom_occurrence != cfmt_hidden.custom_occurrence) {
/* Different occurrences. */
- g_free(cfmt_hidden.custom_field);
- cfmt_hidden.custom_field = NULL;
+ g_free(cfmt_hidden.custom_fields);
+ cfmt_hidden.custom_fields = NULL;
continue;
}
}
* OK, they match, so it's one of the hidden fields,
* hence not visible.
*/
- g_free(cfmt_hidden.custom_field);
+ g_free(cfmt_hidden.custom_fields);
g_free(cols);
return FALSE;
}
return FALSE;
}
+gboolean
+prefs_has_layout_pane_content (layout_pane_content_e layout_pane_content)
+{
+ return ((prefs.gui_layout_content_1 == layout_pane_content) ||
+ (prefs.gui_layout_content_2 == layout_pane_content) ||
+ (prefs.gui_layout_content_3 == layout_pane_content));
+}
+
#define PRS_GUI_FILTER_LABEL "gui.filter_expressions.label"
#define PRS_GUI_FILTER_EXPR "gui.filter_expressions.expr"
#define PRS_GUI_FILTER_ENABLED "gui.filter_expressions.enabled"
+/*
+ * Extract the red, green, and blue components of a 24-bit RGB value
+ * and convert them from [0,255] to [0,65535].
+ */
#define RED_COMPONENT(x) (guint16) (((((x) >> 16) & 0xff) * 65535 / 255))
#define GREEN_COMPONENT(x) (guint16) (((((x) >> 8) & 0xff) * 65535 / 255))
#define BLUE_COMPONENT(x) (guint16) ( (((x) & 0xff) * 65535 / 255))
name_resolve->transport_name = TRUE;
break;
case 'C':
- name_resolve->concurrent_dns = TRUE;
+ /* DEPRECATED */
+ /* name_resolve->concurrent_dns */
break;
case 'd':
name_resolve->dns_pkt_addr_resolution = TRUE;
break;
+ case 'v':
+ name_resolve->vlan_name = TRUE;
+ break;
default:
/*
* Unrecognized letter.
return '\0';
}
-
static void
try_convert_to_custom_column(gpointer *el_data)
{
- /* Array of columns that have been migrated to custom columns */
- struct {
- gint el;
- const gchar *col_expr;
- } migrated_columns[] = {
- { COL_COS_VALUE, "vlan.priority" },
- { COL_CIRCUIT_ID, "iax2.call" },
- { COL_BSSGP_TLLI, "bssgp.tlli" },
- { COL_HPUX_SUBSYS, "nettl.subsys" },
- { COL_HPUX_DEVID, "nettl.devid" },
- { COL_FR_DLCI, "fr.dlci" },
- { COL_REL_CONV_TIME, "tcp.time_relative" },
- { COL_DELTA_CONV_TIME, "tcp.time_delta" },
- { COL_OXID, "fc.ox_id" },
- { COL_RXID, "fc.rx_id" },
- { COL_SRCIDX, "mdshdr.srcidx" },
- { COL_DSTIDX, "mdshdr.dstidx" },
- { COL_DCE_CTX, "dcerpc.cn_ctx_id" }
- };
-
guint haystack_idx;
- const gchar *haystack_fmt;
gchar **fmt = (gchar **) el_data;
haystack_idx < G_N_ELEMENTS(migrated_columns);
++haystack_idx) {
- haystack_fmt = col_format_to_string(migrated_columns[haystack_idx].el);
- if (strcmp(haystack_fmt, *fmt) == 0) {
+ if (strcmp(migrated_columns[haystack_idx].col_fmt, *fmt) == 0) {
gchar *cust_col = g_strdup_printf("%%Cus:%s:0",
migrated_columns[haystack_idx].col_expr);
{"gvsp.enable_heuristic", "gvsp_udp", 0},
{"hdcp2.enable", "hdcp2_tcp", 0},
{"hislip.enable_heuristic", "hislip_tcp", 0},
+ {"infiniband.dissect_eoib", "mellanox_eoib", 1},
+ {"infiniband.identify_payload", "eth_over_ib", 0},
{"jxta.udp.heuristic", "jxta_udp", 0},
{"jxta.tcp.heuristic", "jxta_tcp", 0},
{"jxta.sctp.heuristic", "jxta_sctp", 0},
return FALSE;
}
+static gboolean
+deprecated_enable_dissector_pref(gchar *pref_name, const gchar *value)
+{
+ struct dissector_pref_name
+ {
+ const char* pref_name;
+ const char* short_name;
+ };
+
+ struct dissector_pref_name dissector_prefs[] = {
+ {"transum.tsumenabled", "TRANSUM"},
+ {"snort.enable_snort_dissector", "Snort"},
+ {"prp.enable", "PRP"},
+ };
+
+ unsigned int i;
+ int proto_id;
+
+ for (i = 0; i < sizeof(dissector_prefs)/sizeof(struct dissector_pref_name); i++)
+ {
+ if (strcmp(pref_name, dissector_prefs[i].pref_name) == 0)
+ {
+ proto_id = proto_get_id_by_short_name(dissector_prefs[i].short_name);
+ if (proto_id >= 0)
+ proto_set_decoding(proto_id, ((g_ascii_strcasecmp(value, "true") == 0) ? TRUE : FALSE));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+deprecated_port_pref(gchar *pref_name, const gchar *value)
+{
+ struct port_pref_name
+ {
+ const char* pref_name;
+ const char* module_name;
+ const char* table_name;
+ guint base;
+ };
+
+ struct obsolete_pref_name
+ {
+ const char* pref_name;
+ };
+
+ /* For now this is only supporting TCP/UDP port dissector preferences
+ which are assumed to be decimal */
+ struct port_pref_name port_prefs[] = {
+ /* TCP */
+ {"cmp.tcp_alternate_port", "CMP", "tcp.port", 10},
+ {"h248.tcp_port", "H248", "tcp.port", 10},
+ {"cops.tcp.cops_port", "COPS", "tcp.port", 10},
+ {"dhcpfo.tcp_port", "DHCPFO", "tcp.port", 10},
+ {"enttec.tcp_port", "ENTTEC", "tcp.port", 10},
+ {"forces.tcp_alternate_port", "ForCES", "tcp.port", 10},
+ {"ged125.tcp_port", "GED125", "tcp.port", 10},
+ {"hpfeeds.dissector_port", "HPFEEDS", "tcp.port", 10},
+ {"lsc.port", "LSC", "tcp.port", 10},
+ {"megaco.tcp.txt_port", "MEGACO", "tcp.port", 10},
+ {"netsync.tcp_port", "Netsync", "tcp.port", 10},
+ {"osi.tpkt_port", "OSI", "tcp.port", 10},
+ {"rsync.tcp_port", "RSYNC", "tcp.port", 10},
+ {"sametime.tcp_port", "SAMETIME", "tcp.port", 10},
+ {"sigcomp.tcp.port2", "SIGCOMP", "tcp.port", 10},
+ {"synphasor.tcp_port", "SYNCHROPHASOR", "tcp.port", 10},
+ {"tipc.alternate_port", "TIPC", "tcp.port", 10},
+ {"vnc.alternate_port", "VNC", "tcp.port", 10},
+ {"scop.port", "SCoP", "tcp.port", 10},
+ {"scop.port_secure", "SCoP", "tcp.port", 10},
+ /* UDP */
+ {"h248.udp_port", "H248", "udp.port", 10},
+ {"actrace.udp_port", "ACtrace", "udp.port", 10},
+ {"brp.port", "BRP", "udp.port", 10},
+ {"bvlc.additional_udp_port", "BVLC", "udp.port", 10},
+ {"capwap.udp.port.control", "CAPWAP-CONTROL", "udp.port", 10},
+ {"capwap.udp.port.data", "CAPWAP-CONTROL", "udp.port", 10},
+ {"coap.udp_port", "CoAP", "udp.port", 10},
+ {"enttec.udp_port", "ENTTEC", "udp.port", 10},
+ {"forces.udp_alternate_port", "ForCES", "udp.port", 10},
+ {"ldss.udp_port", "LDSS", "udp.port", 10},
+ {"lmp.udp_port", "LMP", "udp.port", 10},
+ {"ltp.port", "LTP", "udp.port", 10},
+ {"lwres.udp.lwres_port", "LWRES", "udp.port", 10},
+ {"megaco.udp.txt_port", "MEGACO", "udp.port", 10},
+ {"pgm.udp.encap_ucast_port", "PGM", "udp.port", 10},
+ {"pgm.udp.encap_mcast_port", "PGM", "udp.port", 10},
+ {"quic.udp.quic.port", "QUIC", "udp.port", 10},
+ {"quic.udp.quics.port", "QUIC", "udp.port", 10},
+ {"radius.alternate_port", "RADIUS", "udp.port", 10},
+ {"rdt.default_udp_port", "RDT", "udp.port", 10},
+ {"alc.default.udp_port", "ALC", "udp.port", 10},
+ {"sigcomp.udp.port2", "SIGCOMP", "udp.port", 10},
+ {"synphasor.udp_port", "SYNCHROPHASOR", "udp.port", 10},
+ {"tdmop.udpport", "TDMoP", "udp.port", 10},
+ {"uaudp.port1", "UAUDP", "udp.port", 10},
+ {"uaudp.port2", "UAUDP", "udp.port", 10},
+ {"uaudp.port3", "UAUDP", "udp.port", 10},
+ {"uaudp.port4", "UAUDP", "udp.port", 10},
+ {"uhd.dissector_port", "UHD", "udp.port", 10},
+ {"vrt.dissector_port", "VITA 49", "udp.port", 10},
+ {"vuze-dht.udp_port", "Vuze-DHT", "udp.port", 10},
+ {"wimaxasncp.udp.wimax_port", "WiMAX ASN CP", "udp.port", 10},
+ };
+
+ struct port_pref_name port_range_prefs[] = {
+ /* TCP */
+ {"couchbase.tcp.ports", "Couchbase", "tcp.port", 10},
+ {"gsm_ipa.tcp_ports", "GSM over IP", "tcp.port", 10},
+ {"kafka.tcp.ports", "Kafka", "tcp.port", 10},
+ {"kt.tcp.ports", "Kyoto Tycoon", "tcp.port", 10},
+ {"memcache.tcp.ports", "MEMCACHE", "tcp.port", 10},
+ {"mrcpv2.tcp.port_range", "MRCPv2", "tcp.port", 10},
+ {"rtsp.tcp.port_range", "RTSP", "tcp.port", 10},
+ {"sip.tcp.ports", "SIP", "tcp.port", 10},
+ {"tds.tcp_ports", "TDS", "tcp.port", 10},
+ {"uma.tcp.ports", "UMA", "tcp.port", 10},
+ /* UDP */
+ {"aruba_erm.udp.ports", "ARUBA_ERM", "udp.port", 10},
+ {"diameter.udp.ports", "DIAMETER", "udp.port", 10},
+ {"dmp.udp_ports", "DMP", "udp.port", 10},
+ {"dns.udp.ports", "DNS", "udp.port", 10},
+ {"gsm_ipa.udp_ports", "GSM over IP", "udp.port", 10},
+ {"hcrt.dissector_udp_port", "HCrt", "udp.port", 10},
+ {"memcache.udp.ports", "MEMCACHE", "udp.port", 10},
+ {"nb_rtpmux.udp_ports", "NB_RTPMUX", "udp.port", 10},
+ {"gprs-ns.udp.ports", "GPRS-NS", "udp.port", 10},
+ {"p_mul.udp_ports", "P_MUL", "udp.port", 10},
+ {"radius.ports", "RADIUS", "udp.port", 10},
+ {"sflow.ports", "sFlow", "udp.port", 10},
+ {"sscop.udp.ports", "SSCOP", "udp.port", 10},
+ {"tftp.udp_ports", "TFTP", "udp.port", 10},
+ {"tipc.udp.ports", "TIPC", "udp.port", 10},
+ };
+
+ /* These are subdissectors of TPKT/OSITP that used to have a
+ TCP port preference even though they were never
+ directly on TCP. Convert them to use Decode As
+ with the TPKT dissector handle */
+ struct port_pref_name tpkt_subdissector_port_prefs[] = {
+ {"dap.tcp.port", "DAP", "tcp.port", 10},
+ {"disp.tcp.port", "DISP", "tcp.port", 10},
+ {"dop.tcp.port", "DOP", "tcp.port", 10},
+ {"dsp.tcp.port", "DSP", "tcp.port", 10},
+ {"p1.tcp.port", "P1", "tcp.port", 10},
+ {"p7.tcp.port", "P7", "tcp.port", 10},
+ {"rdp.tcp.port", "RDP", "tcp.port", 10},
+ };
+
+ /* These are obsolete preferences from the dissectors' view,
+ (typically because of a switch from a single value to a
+ range value) but the name of the preference conflicts
+ with the generated preference name from the dissector table.
+ Don't allow the obsolete preference through to be handled */
+ struct obsolete_pref_name obsolete_prefs[] = {
+ {"diameter.tcp.port"},
+ {"kafka.tcp.port"},
+ {"mrcpv2.tcp.port"},
+ {"rtsp.tcp.port"},
+ {"sip.tcp.port"},
+ {"t38.tcp.port"},
+ };
+
+ unsigned int i;
+ char *p;
+ guint uval;
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle, tpkt_handle;
+ module_t *module;
+ pref_t *pref;
+
+ for (i = 0; i < sizeof(port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ module = prefs_find_module(port_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_prefs[i].table_name);
+ if (pref != NULL)
+ {
+ module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = uval;
+ }
+
+ /* If the value is zero, it wouldn't add to the Decode As tables */
+ if (uval != 0)
+ {
+ sub_dissectors = find_dissector_table(port_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_prefs[i].module_name);
+ if (handle != NULL) {
+ dissector_change_uint(port_prefs[i].table_name, uval, handle);
+ decode_build_reset_list(port_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(port_range_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, port_range_prefs[i].pref_name) == 0)
+ {
+ guint32 range_i, range_j;
+
+ sub_dissectors = find_dissector_table(port_range_prefs[i].table_name);
+ if (sub_dissectors != NULL) {
+ switch (dissector_table_get_type(sub_dissectors)) {
+ case FT_UINT8:
+ case FT_UINT16:
+ case FT_UINT24:
+ case FT_UINT32:
+ break;
+
+ default:
+ g_error("The dissector table %s (%s) is not an integer type - are you using a buggy plugin?", port_range_prefs[i].table_name, get_dissector_table_ui_name(port_range_prefs[i].table_name));
+ g_assert_not_reached();
+ }
+
+ module = prefs_find_module(port_range_prefs[i].module_name);
+ pref = prefs_find_preference(module, port_range_prefs[i].table_name);
+ if (pref != NULL)
+ {
+ if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed_flags))
+ {
+ return FALSE; /* number was bad */
+ }
+
+ handle = dissector_table_get_dissector_handle(sub_dissectors, port_range_prefs[i].module_name);
+ if (handle != NULL) {
+
+ for (range_i = 0; range_i < (*pref->varp.range)->nranges; range_i++) {
+ for (range_j = (*pref->varp.range)->ranges[range_i].low; range_j < (*pref->varp.range)->ranges[range_i].high; range_j++) {
+ dissector_change_uint(port_range_prefs[i].table_name, range_j, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(range_j), NULL, NULL);
+ }
+
+ dissector_change_uint(port_range_prefs[i].table_name, (*pref->varp.range)->ranges[range_i].high, handle);
+ decode_build_reset_list(port_range_prefs[i].table_name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[range_i].high), NULL, NULL);
+ }
+ }
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(tpkt_subdissector_port_prefs)/sizeof(struct port_pref_name); i++)
+ {
+ if (strcmp(pref_name, tpkt_subdissector_port_prefs[i].pref_name) == 0)
+ {
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, tpkt_subdissector_port_prefs[i].base);
+ if (p == value || *p != '\0')
+ return FALSE; /* number was bad */
+
+ /* If the value is 0 or 102 (default TPKT port), don't add to the Decode As tables */
+ if ((uval != 0) && (uval != 102))
+ {
+ tpkt_handle = find_dissector("tpkt");
+ if (tpkt_handle != NULL) {
+ dissector_change_uint(tpkt_subdissector_port_prefs[i].table_name, uval, tpkt_handle);
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < sizeof(obsolete_prefs)/sizeof(struct obsolete_pref_name); i++)
+ {
+ if (strcmp(pref_name, obsolete_prefs[i].pref_name) == 0)
+ {
+ /* Just ignore the preference */
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static prefs_set_pref_e
set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
gboolean return_range_errors)
static gchar *filter_label = NULL;
static gboolean filter_enabled = FALSE;
gchar *filter_expr = NULL;
- module_t *module;
+ module_t *module, *containing_module;
pref_t *pref;
+ int type;
+ //The PRS_GUI field names are here for backwards compatibility
+ //display filters have been converted to a UAT.
if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) {
filter_label = g_strdup(value);
} else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) {
filter_enabled = (strcmp(value, "TRUE") == 0) ? TRUE : FALSE;
} else if (strcmp(pref_name, PRS_GUI_FILTER_EXPR) == 0) {
filter_expr = g_strdup(value);
- filter_expression_new(filter_label, filter_expr, filter_enabled);
+ /* Comments not supported for "old" preference style */
+ filter_expression_new(filter_label, filter_expr, "", filter_enabled);
g_free(filter_label);
g_free(filter_expr);
} else if (strcmp(pref_name, "gui.version_in_start_page") == 0) {
gbl_resolv_flags.mac_name = TRUE;
gbl_resolv_flags.network_name = TRUE;
gbl_resolv_flags.transport_name = TRUE;
- gbl_resolv_flags.concurrent_dns = TRUE;
}
else if (g_ascii_strcasecmp(value, "false") == 0) {
disable_name_resolution();
}
} else if (deprecated_heur_dissector_pref(pref_name, value)) {
/* Handled within deprecated_heur_dissector_pref() if found */
+ } else if (deprecated_enable_dissector_pref(pref_name, value)) {
+ /* Handled within deprecated_enable_dissector_pref() if found */
+ } else if (deprecated_port_pref(pref_name, value)) {
+ /* Handled within deprecated_port_pref() if found */
} else {
/* Handle deprecated "global" options that don't have a module
* associated with them
return PREFS_SET_OBSOLETE;
}
if (module) {
- g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
+ ws_g_warning ("Preference \"%s.%s\" has been converted to \"%s.%s.%s\"\n"
"Save your preferences to make this change permanent.",
pref_name, dotp+1, module->parent->name, pref_name, dotp+1);
prefs.unknown_prefs = TRUE;
}
}
- pref = prefs_find_preference(module, dotp);
+ /* The pref is located in the module or a submodule.
+ * Assume module, then search for a submodule holding the pref. */
+ containing_module = module;
+ pref = prefs_find_preference_with_submodule(module, dotp, &containing_module);
if (pref == NULL) {
prefs.unknown_prefs = TRUE;
/* "gui" prefix was added to column preferences for better organization
* within the preferences file
*/
- if ((strcmp(pref_name, PRS_COL_HIDDEN) == 0) ||
- (strcmp(pref_name, PRS_COL_FMT) == 0)) {
+ if (module == gui_column_module) {
+ /* While this has a subtree, there is no apply callback, so no
+ * need to use prefs_find_preference_with_submodule to update
+ * containing_module. It would not be useful. */
pref = prefs_find_preference(module, pref_name);
}
else if (strcmp(module->name, "mgcp") == 0) {
} else if (strcmp(module->name, "smpp") == 0) {
/* Handle preferences that moved from SMPP. */
module_t *new_module = prefs_find_module("gsm-sms-ud");
- if (new_module){
- if (strcmp(dotp, "port_number_udh_means_wsp") == 0)
+ if (new_module) {
+ if (strcmp(dotp, "port_number_udh_means_wsp") == 0) {
pref = prefs_find_preference(new_module, "port_number_udh_means_wsp");
- else if (strcmp(dotp, "try_dissect_1st_fragment") == 0)
+ containing_module = new_module;
+ } else if (strcmp(dotp, "try_dissect_1st_fragment") == 0) {
pref = prefs_find_preference(new_module, "try_dissect_1st_fragment");
+ containing_module = new_module;
+ }
}
} else if (strcmp(module->name, "asn1") == 0) {
/* Handle old generic ASN.1 preferences (it's not really a
module_t *new_module = prefs_find_module("vlan");
if (new_module) {
pref = prefs_find_preference(new_module, "qinq_ethertype");
- module = new_module;
+ containing_module = new_module;
}
}
} else if (strcmp(module->name, "taps") == 0) {
/* taps preferences moved to "statistics" module */
- if (strcmp(dotp, "update_interval") == 0 ||
- strcmp(dotp, "rtp_player_max_visible") == 0)
+ if (strcmp(dotp, "update_interval") == 0)
pref = prefs_find_preference(stats_module, dotp);
} else if (strcmp(module->name, "packet_list") == 0) {
/* packet_list preferences moved to protocol module */
if (pref == NULL)
return PREFS_SET_NO_SUCH_PREF; /* no such preference */
- switch (pref->type) {
+ type = pref->type;
+ if (IS_PREF_OBSOLETE(type)) {
+ return PREFS_SET_OBSOLETE; /* no such preference any more */
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
case PREF_UINT:
/* XXX - give an error if it doesn't fit in a guint? */
if (p == value || *p != '\0')
return PREFS_SET_SYNTAX_ERR; /* number was bad */
if (*pref->varp.uint != uval) {
- module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.uint = uval;
}
break;
+ case PREF_DECODE_AS_UINT:
+ {
+ /* This is for backwards compatibility in case any of the preferences
+ that shared the "Decode As" preference name and used to be PREF_UINT
+ are now applied directly to the Decode As funtionality */
+
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle;
+
+ /* XXX - give an error if it doesn't fit in a guint? */
+ uval = (guint)strtoul(value, &p, pref->info.base);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+
+ if (*pref->varp.uint != uval) {
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+ *pref->varp.uint = uval;
+
+ /* Name of preference is the dissector table */
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+ if (handle != NULL) {
+ if (uval != 0) {
+ dissector_change_uint(pref->name, uval, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(uval), NULL, NULL);
+ } else {
+ dissector_delete_uint(pref->name, *pref->varp.uint, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), pref->varp.uint, NULL, NULL);
+ }
+ /* XXX - Do we save the decode_as_entries file here? */
+ }
+ }
+ }
+ break;
+ }
case PREF_BOOL:
/* XXX - give an error if it's neither "true" nor "false"? */
if (g_ascii_strcasecmp(value, "true") == 0)
else
bval = FALSE;
if (*pref->varp.boolp != bval) {
- module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.boolp = bval;
}
break;
enum_val = find_val_for_string(value, pref->info.enum_info.enumvals,
*pref->varp.enump);
if (*pref->varp.enump != enum_val) {
- module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
*pref->varp.enump = enum_val;
}
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
- if (strcmp(*pref->varp.string, value) != 0) {
- module->prefs_changed = TRUE;
- g_free((void *)*pref->varp.string);
- *pref->varp.string = g_strdup(value);
- }
+ containing_module->prefs_changed_flags |= prefs_set_string_value(pref, value, pref_current);
break;
case PREF_RANGE:
{
+ if (!prefs_set_range_value_work(pref, value, return_range_errors,
+ &containing_module->prefs_changed_flags))
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ break;
+ }
+ case PREF_DECODE_AS_RANGE:
+ {
+ /* This is for backwards compatibility in case any of the preferences
+ that shared the "Decode As" preference name and used to be PREF_RANGE
+ are now applied directly to the Decode As funtionality */
range_t *newrange;
+ dissector_table_t sub_dissectors;
+ dissector_handle_t handle;
+ guint32 i, j;
- if (range_convert_str_work(&newrange, value, pref->info.max_value,
+ if (range_convert_str_work(wmem_epan_scope(), &newrange, value, pref->info.max_value,
return_range_errors) != CVT_NO_ERROR) {
return PREFS_SET_SYNTAX_ERR; /* number was bad */
}
if (!ranges_are_equal(*pref->varp.range, newrange)) {
- module->prefs_changed = TRUE;
- g_free(*pref->varp.range);
+ wmem_free(wmem_epan_scope(), *pref->varp.range);
*pref->varp.range = newrange;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
+
+ /* Name of preference is the dissector table */
+ sub_dissectors = find_dissector_table(pref->name);
+ if (sub_dissectors != NULL) {
+ handle = dissector_table_get_dissector_handle(sub_dissectors, module->title);
+ if (handle != NULL) {
+ /* Delete all of the old values from the dissector table */
+ for (i = 0; i < (*pref->varp.range)->nranges; i++) {
+ for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
+ dissector_delete_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
+ }
+
+ /* Add new values to the dissector table */
+ for (i = 0; i < newrange->nranges; i++) {
+ for (j = newrange->ranges[i].low; j < newrange->ranges[i].high; j++) {
+ dissector_change_uint(pref->name, j, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
+ }
+
+ dissector_change_uint(pref->name, newrange->ranges[i].high, handle);
+ decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(newrange->ranges[i].high), NULL, NULL);
+ }
+
+ /* XXX - Do we save the decode_as_entries file here? */
+ }
+ }
} else {
- g_free (newrange);
+ wmem_free(wmem_epan_scope(), newrange);
}
break;
}
case PREF_COLOR:
{
cval = strtoul(value, NULL, 16);
- pref->varp.colorp->pixel = 0;
if ((pref->varp.colorp->red != RED_COMPONENT(cval)) ||
(pref->varp.colorp->green != GREEN_COMPONENT(cval)) ||
(pref->varp.colorp->blue != BLUE_COMPONENT(cval))) {
- module->prefs_changed = TRUE;
+ containing_module->prefs_changed_flags |= prefs_get_effect_flags(pref);
pref->varp.colorp->red = RED_COMPONENT(cval);
pref->varp.colorp->green = GREEN_COMPONENT(cval);
pref->varp.colorp->blue = BLUE_COMPONENT(cval);
}
case PREF_CUSTOM:
- return pref->custom_cbs.set_cb(pref, value, &module->prefs_changed);
+ return pref->custom_cbs.set_cb(pref, value, &containing_module->prefs_changed_flags);
case PREF_STATIC_TEXT:
case PREF_UAT:
{
break;
}
-
- case PREF_OBSOLETE:
- return PREFS_SET_OBSOLETE; /* no such preference any more */
}
}
prefs_pref_type_name(pref_t *pref)
{
const char *type_name = "[Unknown]";
+ int type;
if (!pref) {
return type_name; /* ...or maybe assert? */
}
- switch (pref->type) {
+ type = pref->type;
+
+ if (IS_PREF_OBSOLETE(type)) {
+ type_name = "Obsolete";
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
case PREF_UINT:
switch (pref->info.base) {
type_name = "String";
break;
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
type_name = "Filename";
break;
type_name = "Custom";
break;
- case PREF_OBSOLETE:
- type_name = "Obsolete";
+ case PREF_DECODE_AS_UINT:
+ type_name = "Decode As value";
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ type_name = "Range (for Decode As)";
break;
case PREF_STATIC_TEXT:
return type_name;
}
+unsigned int
+prefs_get_effect_flags(pref_t *pref)
+{
+ if (pref == NULL)
+ return 0;
+
+ return pref->effect_flags;
+}
+
+void
+prefs_set_effect_flags(pref_t *pref, unsigned int flags)
+{
+ if (pref != NULL) {
+ pref->effect_flags = flags;
+ }
+}
+
+void
+prefs_set_effect_flags_by_name(module_t * module, const char *pref, unsigned int flags)
+{
+ prefs_set_effect_flags(prefs_find_preference(module, pref), flags);
+}
+
+unsigned int
+prefs_get_module_effect_flags(module_t * module)
+{
+ if (module == NULL)
+ return 0;
+
+ return module->effect_flags;
+}
+
+void
+prefs_set_module_effect_flags(module_t * module, unsigned int flags)
+{
+ if (module != NULL) {
+ module->effect_flags = flags;
+ }
+}
+
char *
prefs_pref_type_description(pref_t *pref)
{
- const char *type_desc = "An unkown preference type";
+ const char *type_desc = "An unknown preference type";
+ int type;
if (!pref) {
return g_strdup_printf("%s.", type_desc); /* ...or maybe assert? */
}
- switch (pref->type) {
+ type = pref->type;
+
+ if (IS_PREF_OBSOLETE(type)) {
+ type_desc = "An obsolete preference";
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
case PREF_UINT:
switch (pref->info.base) {
type_desc = "A string";
break;
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
type_desc = "A path to a file";
break;
type_desc = "A custom value";
break;
- case PREF_OBSOLETE:
- type_desc = "An obsolete preference";
+ case PREF_DECODE_AS_UINT:
+ type_desc = "An integer value used in Decode As";
+ break;
+
+ case PREF_DECODE_AS_RANGE:
+ type_desc = "A string denoting an positive integer range for Decode As";
break;
case PREF_STATIC_TEXT:
return g_strdup(type_desc);
}
-static gboolean
-prefs_pref_is_default(pref_t *pref) {
+gboolean
+prefs_pref_is_default(pref_t *pref)
+{
+ int type;
if (!pref) return FALSE;
- switch (pref->type) {
+ type = pref->type;
+ if (IS_PREF_OBSOLETE(type)) {
+ return FALSE;
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
+
+ case PREF_DECODE_AS_UINT:
+ if (pref->default_val.uint == *pref->varp.uint)
+ return TRUE;
+ break;
case PREF_UINT:
if (pref->default_val.uint == *pref->varp.uint)
break;
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
if (!(g_strcmp0(pref->default_val.string, *pref->varp.string)))
return TRUE;
break;
+ case PREF_DECODE_AS_RANGE:
case PREF_RANGE:
{
if ((ranges_are_equal(pref->default_val.range, *pref->varp.range)))
case PREF_CUSTOM:
return pref->custom_cbs.is_default_cb(pref);
- case PREF_OBSOLETE:
case PREF_STATIC_TEXT:
case PREF_UAT:
return FALSE;
void *valp; /* pointer to preference value */
color_t *pref_color;
gchar *tmp_value, *ret_value;
+ int type;
if (!pref) {
return g_strdup(pref_text);
return g_strdup(pref_text);
}
- switch (pref->type) {
+ type = pref->type;
+ if (IS_PREF_OBSOLETE(type)) {
+ pref_text = "[Obsolete]";
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
+ case PREF_DECODE_AS_UINT:
case PREF_UINT:
{
guint pref_uint = *(guint *) valp;
}
case PREF_BOOL:
- return g_strdup_printf("%s", (*(gboolean *) valp) ? "TRUE" : "FALSE");
+ return g_strdup((*(gboolean *) valp) ? "TRUE" : "FALSE");
case PREF_ENUM:
{
}
case PREF_STRING:
- case PREF_FILENAME:
+ case PREF_SAVE_FILENAME:
+ case PREF_OPEN_FILENAME:
case PREF_DIRNAME:
return g_strdup(*(const char **) valp);
+ case PREF_DECODE_AS_RANGE:
case PREF_RANGE:
/* Convert wmem to g_alloc memory */
tmp_value = range_convert_range(NULL, *(range_t **) valp);
pref_text = "[Custom]";
break;
- case PREF_OBSOLETE:
- pref_text = "[Obsolete]";
- break;
-
case PREF_STATIC_TEXT:
pref_text = "[Static text]";
break;
write_pref_arg_t *arg = (write_pref_arg_t *)user_data;
gchar **desc_lines;
int i;
+ int type;
- switch (pref->type) {
- case PREF_OBSOLETE:
+ type = pref->type;
+
+ if (IS_PREF_OBSOLETE(type)) {
/*
* This preference is no longer supported; it's not a
* real preference, so we don't write it out (i.e., we
* preferences, and we weren't called in the first place).
*/
return;
+ } else {
+ RESET_PREF_OBSOLETE(type);
+ }
+
+ switch (type) {
case PREF_STATIC_TEXT:
case PREF_UAT:
/* Nothing to do; don't bother printing the description */
return;
+ case PREF_DECODE_AS_UINT:
+ case PREF_DECODE_AS_RANGE:
+ /* Data is saved through Decode As mechanism and not part of preferences file */
+ return;
default:
break;
}
}
+static void
+count_non_uat_pref(gpointer data, gpointer user_data)
+{
+ pref_t *pref = (pref_t *)data;
+ int *arg = (int *)user_data;
+
+ switch (pref->type)
+ {
+ case PREF_UAT:
+ case PREF_OBSOLETE:
+ case PREF_DECODE_AS_UINT:
+ case PREF_DECODE_AS_RANGE:
+ //These types are not written in preference file
+ break;
+ default:
+ (*arg)++;
+ break;
+ }
+}
+
+static int num_non_uat_prefs(module_t *module)
+{
+ int num = 0;
+
+ g_list_foreach(module->prefs, count_non_uat_pref, &num);
+
+ return num;
+}
+
/*
* Write out all preferences for a module.
*/
/* Write a header for the main modules and GUI sub-modules */
if (((module->parent == NULL) || (module->parent == gui_module)) &&
((prefs_module_has_submodules(module)) ||
- (module->numprefs > 0) ||
+ (num_non_uat_prefs(module) > 0) ||
(module->name == NULL))) {
if ((module->name == NULL) && (module->parent != NULL)) {
fprintf(gui_pref_arg->pf, "\n####### %s: %s ########\n", module->parent->title, module->title);
*pf_path_return = pf_path;
return errno;
}
+ g_free(pf_path);
} else {
pf = stdout;
}
write_module_prefs(gui_module, &write_gui_pref_info);
- {
- struct filter_expression *fe = *(struct filter_expression **)prefs.filter_expressions;
-
- if (fe != NULL)
- fprintf(pf, "\n####### Filter Expressions ########\n");
-
- while (fe != NULL) {
- if (fe->deleted == FALSE) {
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_LABEL, fe->label);
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_ENABLED,
- fe->enabled == TRUE ? "TRUE" : "FALSE");
- fprintf(pf, "%s: %s\n", PRS_GUI_FILTER_EXPR, fe->expression);
- }
- fe = fe->next;
- }
- }
-
write_gui_pref_info.is_gui_module = FALSE;
prefs_modules_foreach_submodules(NULL, write_module_prefs, &write_gui_pref_info);
cfmt = (fmt_data *)list->data;
g_free(cfmt->title);
- g_free(cfmt->custom_field);
+ g_free(cfmt->custom_fields);
g_free(cfmt);
list = g_list_next(list);
}