6 * (c) 2006, Luis E. Garcia Ontanon <luis@ontanon.org>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/funnel.h>
35 #include <epan/stat_cmd_args.h>
38 struct _funnel_text_window_t {
43 static GPtrArray* text_windows = NULL;
45 static funnel_text_window_t* new_text_window(const gchar* title) {
46 funnel_text_window_t* tw = g_malloc(sizeof(funnel_text_window_t));
47 tw->title = g_strdup(title);
48 tw->text = g_string_new("");
51 text_windows = g_ptr_array_new();
53 g_ptr_array_add(text_windows,tw);
58 static void text_window_clear(funnel_text_window_t* tw) {
59 g_string_free(tw->text,TRUE);
60 tw->text = g_string_new("");
63 static void text_window_append(funnel_text_window_t* tw, const char *text ) {
64 g_string_append(tw->text,text);
67 static void text_window_set_text(funnel_text_window_t* tw, const char* text) {
68 g_string_free(tw->text,TRUE);
69 tw->text = g_string_new(text);
72 static void text_window_prepend(funnel_text_window_t* tw, const char *text) {
73 g_string_prepend(tw->text,text);
76 static const gchar* text_window_get_text(funnel_text_window_t* tw) {
80 /* XXX: finish this */
81 static void funnel_logger(const gchar *log_domain _U_,
82 GLogLevelFlags log_level _U_,
84 gpointer user_data _U_) {
85 fputs(message,stderr);
90 static const funnel_ops_t funnel_ops = {
118 void initialize_funnel_ops(void) {
119 funnel_set_funnel_ops(&funnel_ops);
123 void funnel_dump_all_text_windows(void) {
126 if (!text_windows) return;
128 for ( i = 0 ; i < text_windows->len; i++) {
129 funnel_text_window_t* tw = g_ptr_array_index(text_windows,i);
130 printf("\n========================== %s "
131 "==========================\n%s\n",tw->title,tw->text->str);
133 g_ptr_array_remove_index(text_windows,i);
135 g_string_free(tw->text,TRUE);
142 GHashTable* menus = NULL;;
143 typedef struct _menu_cb_t {
144 void (*callback)(gpointer);
149 static void init_funnel_cmd(const char *optarg, void* data ) {
150 gchar** args = g_strsplit(optarg,",",0);
152 menu_cb_t* mcb = data;
154 for(arg = args; *arg ; arg++) {
159 mcb->callback(mcb->callback_data);
164 static void register_menu_cb(const char *name,
165 register_stat_group_t group _U_,
166 void (*callback)(gpointer),
167 gpointer callback_data,
168 gboolean retap _U_) {
169 menu_cb_t* mcb = g_malloc(sizeof(menu_cb_t));
171 mcb->callback = callback;
172 mcb->callback_data = callback_data;
175 menus = g_hash_table_new(g_str_hash,g_str_equal);
177 g_hash_table_insert(menus,g_strdup(name),mcb);
179 register_stat_cmd_arg(name,init_funnel_cmd,mcb);
182 void initialize_funnel_ops(void) {
183 funnel_set_funnel_ops(&funnel_ops);
188 register_tap_listener_gtkfunnel(void)
191 funnel_register_all_menus(register_menu_cb);