6 * (c) 2006, Luis E. Garcia Ontanon <luis@ontanon.org>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/funnel.h>
31 typedef struct _funnel_menu_t {
33 register_stat_group_t group;
34 funnel_menu_callback callback;
35 gpointer callback_data;
37 struct _funnel_menu_t* next;
40 /* XXX This assumes one main window and one capture file. */
41 static const funnel_ops_t* ops = NULL;
42 static funnel_menu_t* registered_menus = NULL;
43 static funnel_menu_t* added_menus = NULL;
44 static funnel_menu_t* removed_menus = NULL;
45 static gboolean menus_registered = FALSE;
47 const funnel_ops_t* funnel_get_funnel_ops(void) { return ops; }
48 void funnel_set_funnel_ops(const funnel_ops_t* o) { ops = o; }
50 static void funnel_insert_menu (funnel_menu_t** menu_list, funnel_menu_t *menu)
56 for (c = *menu_list; c->next; c = c->next);
61 static void funnel_remove_menu (funnel_menu_t ** menu_list, funnel_menu_t *menu)
63 funnel_menu_t *m = *menu_list, *p = NULL;
66 if (m->callback == menu->callback) {
72 g_free((char *)m->name);
77 m = *menu_list ? (*menu_list)->next : NULL;
86 static void funnel_clear_menu (funnel_menu_t** menu_list)
93 g_free((char *)m->name);
99 void funnel_register_menu(const char *name,
100 register_stat_group_t group,
101 funnel_menu_callback callback,
102 gpointer callback_data,
105 funnel_menu_t* m = (funnel_menu_t *)g_malloc(sizeof(funnel_menu_t));
106 m->name = g_strdup(name);
108 m->callback = callback;
109 m->callback_data = callback_data;
113 funnel_insert_menu(®istered_menus, m);
114 if (menus_registered) {
115 funnel_menu_t* m_r = (funnel_menu_t *)g_memdup(m, sizeof *m);
116 m_r->name = g_strdup(name);
117 funnel_insert_menu(&added_menus, m_r);
121 void funnel_deregister_menus(funnel_menu_callback callback)
123 funnel_menu_t* m = (funnel_menu_t *)g_malloc0(sizeof(funnel_menu_t));
124 m->callback = callback;
126 funnel_remove_menu(®istered_menus, m);
127 funnel_insert_menu(&removed_menus, m);
130 void funnel_register_all_menus(funnel_registration_cb_t r_cb)
133 for (c = registered_menus; c; c = c->next) {
134 r_cb(c->name,c->group,c->callback,c->callback_data,c->retap);
136 menus_registered = TRUE;
139 void funnel_reload_menus(funnel_deregistration_cb_t d_cb,
140 funnel_registration_cb_t r_cb)
143 for (c = removed_menus; c; c = c->next) {
146 for (c = added_menus; c; c = c->next) {
147 r_cb(c->name,c->group,c->callback,c->callback_data,c->retap);
150 funnel_clear_menu(&removed_menus);
151 funnel_clear_menu(&added_menus);
155 * Editor modelines - http://www.wireshark.org/tools/modelines.html
160 * indent-tabs-mode: nil
163 * vi: set shiftwidth=4 tabstop=8 expandtab:
164 * :indentSize=4:tabSize=8:noTabs=true: