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 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include <epan/funnel.h>
21 #include "ws_attributes.h"
23 void register_tap_listener_funnel(void);
25 struct _funnel_text_window_t {
30 static GPtrArray *text_windows = NULL;
32 static funnel_text_window_t *new_text_window(const gchar *title) {
33 funnel_text_window_t *tw = g_new(funnel_text_window_t, 1);
34 tw->title = g_strdup(title);
35 tw->text = g_string_new("");
38 text_windows = g_ptr_array_new();
40 g_ptr_array_add(text_windows, tw);
45 static void text_window_clear(funnel_text_window_t *tw) {
46 g_string_free(tw->text, TRUE);
47 tw->text = g_string_new("");
50 static void text_window_append(funnel_text_window_t *tw, const char *text ) {
51 g_string_append(tw->text, text);
54 static void text_window_set_text(funnel_text_window_t *tw, const char *text) {
55 g_string_free(tw->text, TRUE);
56 tw->text = g_string_new(text);
59 static void text_window_prepend(funnel_text_window_t *tw, const char *text) {
60 g_string_prepend(tw->text, text);
63 static const gchar *text_window_get_text(funnel_text_window_t *tw) {
67 /* XXX: finish this */
68 static void funnel_logger(const gchar *log_domain _U_,
69 GLogLevelFlags log_level _U_,
71 gpointer user_data _U_) {
72 fputs(message, stderr);
77 static const funnel_ops_t funnel_ops = {
110 void initialize_funnel_ops(void) {
111 funnel_set_funnel_ops(&funnel_ops);
115 void funnel_dump_all_text_windows(void) {
118 if (!text_windows) return;
120 for ( i = 0 ; i < text_windows->len; i++) {
121 funnel_text_window_t *tw = (funnel_text_window_t *)g_ptr_array_index(text_windows, i);
122 printf("\n========================== %s "
123 "==========================\n%s\n", tw->title, tw->text->str);
125 g_ptr_array_remove_index(text_windows, i);
127 g_string_free(tw->text, TRUE);
134 GHashTable *menus = NULL;
135 typedef struct _menu_cb_t {
136 void (*callback)(gpointer);
141 static void init_funnel_cmd(const char *opt_arg, void *data ) {
142 gchar **args = g_strsplit(opt_arg, ",", 0);
144 menu_cb_t *mcb = data;
146 for (arg = args; *arg ; arg++) {
151 mcb->callback(mcb->callback_data);
156 static void register_menu_cb(const char *name,
157 register_stat_group_t group _U_,
158 void (*callback)(gpointer),
159 gpointer callback_data,
160 gboolean retap _U_) {
161 menu_cb_t *mcb = g_malloc(sizeof(menu_cb_t));
164 mcb->callback = callback;
165 mcb->callback_data = callback_data;
168 menus = g_hash_table_new(g_str_hash, g_str_equal);
170 g_hash_table_insert(menus, g_strdup(name), mcb);
172 ui_info.group = REGISTER_STAT_GROUP_GENERIC;
173 ui_info.title = NULL;
174 ui_info.cli_string = name;
175 ui_info.tap_init_cb = init_funnel_cmd;
177 ui_info.params = NULL;
178 register_stat_tap_ui(&ui_info, mcb);
181 void initialize_funnel_ops(void) {
182 funnel_set_funnel_ops(&funnel_ops);
187 register_tap_listener_funnel(void)
190 /* #if 0 at least since Revision Rev 17396 */
191 funnel_register_all_menus(register_menu_cb);
196 * Editor modelines - https://www.wireshark.org/tools/modelines.html
201 * indent-tabs-mode: nil
204 * vi: set shiftwidth=4 tabstop=8 expandtab:
205 * :indentSize=4:tabSize=8:noTabs=true: