summaryrefslogtreecommitdiff
path: root/epan/prefs.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-10-12 03:13:17 +0000
committerGuy Harris <guy@alum.mit.edu>2004-10-12 03:13:17 +0000
commiteb088099b072573c67bc1a1be5e0bebea63606f0 (patch)
treedfcd8547c0c8a6a202b15be471f2b0a59d8de34d /epan/prefs.c
parent38ed258bc5871f85fc52a83d60f2dc9d92fd7a83 (diff)
downloadwireshark-eb088099b072573c67bc1a1be5e0bebea63606f0.tar.gz
Check the values of the protocol preferences before fetching them; if
any are not valid, pop up an alert box and don't dismiss the preferences dialog. svn path=/trunk/; revision=12269
Diffstat (limited to 'epan/prefs.c')
-rw-r--r--epan/prefs.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index a2b77bdace..1def43c844 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -316,43 +316,39 @@ find_module(const char *name)
return (module_t *) list_entry->data;
}
-typedef struct {
- module_cb callback;
- gpointer user_data;
-} module_cb_arg_t;
-
-static void
-do_module_callback(gpointer data, gpointer user_data)
-{
- module_t *module = data;
- module_cb_arg_t *arg = user_data;
-
- if (!module->obsolete)
- (*arg->callback)(module, arg->user_data);
-}
-
/*
* Call a callback function, with a specified argument, for each module
* in a list of modules. If the list is NULL, searches the top-level
- * list in the display tree of modules.
+ * list in the display tree of modules. If any callback returns a
+ * non-zero value, we stop and return that value, otherwise we
+ * return 0.
*
* Ignores "obsolete" modules; 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.
*/
-void
+guint
prefs_module_list_foreach(GList *module_list, module_cb callback,
gpointer user_data)
{
- module_cb_arg_t arg;
+ GList *elem;
+ module_t *module;
+ guint ret;
if (module_list == NULL)
module_list = top_level_modules;
- arg.callback = callback;
- arg.user_data = user_data;
- g_list_foreach(module_list, do_module_callback, &arg);
+ for (elem = g_list_first(module_list); elem != NULL;
+ elem = g_list_next(elem)) {
+ module = elem->data;
+ if (!module->obsolete) {
+ ret = (*callback)(module, user_data);
+ if (ret != 0)
+ return ret;
+ }
+ }
+ return 0;
}
/*
@@ -363,10 +359,10 @@ prefs_module_list_foreach(GList *module_list, module_cb callback,
* preferences for dissectors that no longer have preferences to be
* silently ignored in preference files.
*/
-void
+guint
prefs_modules_foreach(module_cb callback, gpointer user_data)
{
- prefs_module_list_foreach(modules, callback, user_data);
+ return prefs_module_list_foreach(modules, callback, user_data);
}
static void