diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-10-12 03:13:17 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-10-12 03:13:17 +0000 |
commit | eb088099b072573c67bc1a1be5e0bebea63606f0 (patch) | |
tree | dfcd8547c0c8a6a202b15be471f2b0a59d8de34d /epan/prefs.c | |
parent | 38ed258bc5871f85fc52a83d60f2dc9d92fd7a83 (diff) | |
download | wireshark-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.c | 42 |
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 |