7 #include <epan/funnel.h>
9 #include <epan/stat_cmd_args.h>
12 struct _funnel_text_window_t {
17 static GPtrArray* text_windows = NULL;
19 static funnel_text_window_t* new_text_window(const gchar* title) {
20 funnel_text_window_t* tw = g_malloc(sizeof(funnel_text_window_t));
21 tw->title = g_strdup(title);
22 tw->text = g_string_new("");
25 text_windows = g_ptr_array_new();
27 g_ptr_array_add(text_windows,tw);
32 static void text_window_clear(funnel_text_window_t* tw) {
33 g_string_free(tw->text,TRUE);
34 tw->text = g_string_new("");
37 static void text_window_append(funnel_text_window_t* tw, const char *text ) {
38 g_string_append(tw->text,text);
41 static void text_window_set_text(funnel_text_window_t* tw, const char* text) {
42 g_string_free(tw->text,TRUE);
43 tw->text = g_string_new(text);
46 static void text_window_prepend(funnel_text_window_t* tw, const char *text) {
47 g_string_prepend(tw->text,text);
50 static const gchar* text_window_get_text(funnel_text_window_t* tw) {
54 /* XXX: finish this */
55 static void funnel_logger(const gchar *log_domain _U_,
56 GLogLevelFlags log_level _U_,
58 gpointer user_data _U_) {
59 fputs(message,stderr);
64 static const funnel_ops_t funnel_ops = {
82 void initialize_funnel_ops(void) {
83 funnel_set_funnel_ops(&funnel_ops);
87 void funnel_dump_all_text_windows(void) {
90 if (!text_windows) return;
92 for ( i = 0 ; i < text_windows->len; i++) {
93 funnel_text_window_t* tw = g_ptr_array_index(text_windows,i);
94 printf("\n========================== %s "
95 "==========================\n%s\n",tw->title,tw->text->str);
97 g_ptr_array_remove_index(text_windows,i);
99 g_string_free(tw->text,TRUE);
106 GHashTable* menus = NULL;;
107 typedef struct _menu_cb_t {
108 void (*callback)(gpointer);
113 static void init_funnel_cmd(const char *optarg, void* data ) {
114 gchar** args = g_strsplit(optarg,",",0);
116 menu_cb_t* mcb = data;
118 for(arg = args; *arg ; arg++) {
123 mcb->callback(mcb->callback_data);
128 static void register_menu_cb(const char *name,
129 REGISTER_STAT_GROUP_E group _U_,
130 void (*callback)(gpointer),
131 gpointer callback_data,
132 gboolean retap _U_) {
133 menu_cb_t* mcb = g_malloc(sizeof(menu_cb_t));
135 mcb->callback = callback;
136 mcb->callback_data = callback_data;
139 menus = g_hash_table_new(g_str_hash,g_str_equal);
141 g_hash_table_insert(menus,g_strdup(name),mcb);
143 register_stat_cmd_arg(name,init_funnel_cmd,mcb);
146 void initialize_funnel_ops(void) {
147 funnel_set_funnel_ops(&funnel_ops);
152 register_tap_listener_gtkfunnel(void)
155 funnel_register_all_menus(register_menu_cb);