2 * Definitions for color filters
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __COLOR_FILTERS_H__
23 #define __COLOR_FILTERS_H__
25 #include "ws_symbol_export.h"
29 #endif /* __cplusplus */
31 #include <wsutil/color.h>
35 #define CONVERSATION_COLOR_PREFIX "___conversation_color_filter___"
40 /* Data for a color filter. */
41 typedef struct _color_filter {
42 gchar *filter_name; /* name of the filter */
43 gchar *filter_text; /* text of the filter expression */
44 color_t bg_color; /* background color for packets that match */
45 color_t fg_color; /* foreground color for packets that match */
46 gboolean disabled; /* set if the filter is disabled */
47 gboolean selected; /* set if the filter is selected in the color dialog box. GTK+ only. */
49 /* only used inside of color_filters.c */
50 struct epan_dfilter *c_colorfilter; /* compiled filter expression */
52 /* only used outside of color_filters.c (beside init) */
53 void *color_edit_dlg_info; /* if filter is being edited, ptr to req'd info. GTK+ only. */
56 /** A color filter was added (while importing).
57 * (color_filters.c calls this for every filter coming in)
59 * @param colorf the new color filter
60 * @param user_data from caller
62 typedef void (*color_filter_add_cb_func)(color_filter_t *colorf, gpointer user_data);
64 /** Init the color filters (incl. initial read from file). */
65 WS_DLL_PUBLIC gboolean color_filters_init(gchar** err_msg, color_filter_add_cb_func add_cb);
67 /** Reload the color filters */
68 WS_DLL_PUBLIC gboolean color_filters_reload(gchar** err_msg, color_filter_add_cb_func add_cb);
70 /** Cleanup remaining color filter zombies */
71 WS_DLL_PUBLIC void color_filters_cleanup(void);
73 /** Color filters currently used?
75 * @return TRUE, if filters are used
77 WS_DLL_PUBLIC gboolean color_filters_used(void);
79 /** Are there any temporary coloring filters used?
81 * @return TRUE, if temporary coloring filters are used
83 WS_DLL_PUBLIC gboolean tmp_color_filters_used(void);
85 /** Set the filter string of a temporary color filter
87 * @param filt_nr a number 1-10 pointing to a temporary color
88 * @param filter the new filter-string
89 * @param disabled whether the filter-rule should be disabled
90 * @param err_msg a string with error message
92 WS_DLL_PUBLIC gboolean
93 color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg);
95 /** Get a temporary color filter.
97 * @param filter_num A number from 1 to 10 specifying the color to fetch.
98 * @return The corresponding color or NULL.
100 WS_DLL_PUBLIC const color_filter_t *
101 color_filters_tmp_color(guint8 filter_num);
103 /** Reset the temporary color filters
106 WS_DLL_PUBLIC gboolean
107 color_filters_reset_tmp(gchar **err_msg);
109 /* Prime the epan_dissect_t with all the compiler
110 * color filters of the current filter list.
112 * @param the epan dissector details
114 WS_DLL_PUBLIC void color_filters_prime_edt(struct epan_dissect *edt);
116 /** Colorize a specific packet.
118 * @param edt the dissected packet
119 * @return the matching color filter or NULL
121 WS_DLL_PUBLIC const color_filter_t *
122 color_filters_colorize_packet(struct epan_dissect *edt);
124 /** Clone the currently active filter list.
126 * @param user_data will be returned by each call to to color_filter_add_cb()
127 * @param add_cb the callback function to add color filter
129 WS_DLL_PUBLIC void color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb);
131 /** Load filters (import) from some other filter file.
133 * @param path the path to the import file
134 * @param user_data will be returned by each call to to color_filter_add_cb()
135 * @param err_msg a string with error message
136 * @param add_cb the callback function to add color filter
137 * @return TRUE, if read succeeded
139 WS_DLL_PUBLIC gboolean color_filters_import(const gchar *path, gpointer user_data, gchar **err_msg, color_filter_add_cb_func add_cb);
141 /** Read filters from the global filter file (not the users file).
143 * @param user_data will be returned by each call to to color_filter_add_cb()
144 * @param err_msg a string with error message
145 * @param add_cb the callback function to add color filter
146 * @return TRUE, if read succeeded
148 WS_DLL_PUBLIC gboolean color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add_cb_func add_cb);
151 /** Apply a changed filter list.
153 * @param tmp_cfl the temporary color filter list to apply
154 * @param edit_cfl the edited permanent color filter list to apply
155 * @param err_msg a string with error message
157 WS_DLL_PUBLIC gboolean color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg);
159 /** Save filters in users filter file.
161 * @param cfl the filter list to write
162 * @param err_msg a string with error message
163 * @return TRUE if write succeeded
165 WS_DLL_PUBLIC gboolean color_filters_write(GSList *cfl, gchar** err_msg);
167 /** Save filters (export) to some other filter file.
169 * @param path the path to the filter file
170 * @param cfl the filter list to write
171 * @param only_selected TRUE if only the selected filters should be saved
172 * @param err_msg a string with error message
173 * @return TRUE, if write succeeded
175 WS_DLL_PUBLIC gboolean color_filters_export(const gchar *path, GSList *cfl, gboolean only_selected, gchar** err_msg);
177 /** Create a new color filter (g_malloc'ed).
179 * @param name the name of the filter
180 * @param filter_string the filter string
181 * @param bg_color background color
182 * @param fg_color foreground color
183 * @param disabled gboolean
184 * @return the new color filter
186 WS_DLL_PUBLIC color_filter_t *color_filter_new(
187 const gchar *name, const gchar *filter_string,
188 color_t *bg_color, color_t *fg_color, gboolean disabled);
190 /** Delete a single color filter (g_free'ed).
192 * @param colorf the color filter to be removed
194 WS_DLL_PUBLIC void color_filter_delete(color_filter_t *colorf);
196 /** Delete a filter list including all entries.
198 * @param cfl the filter list to delete
200 WS_DLL_PUBLIC void color_filter_list_delete(GSList **cfl);
204 #endif /* __cplusplus */
209 * Editor modelines - http://www.wireshark.org/tools/modelines.html
214 * indent-tabs-mode: nil
217 * vi: set shiftwidth=4 tabstop=8 expandtab:
218 * :indentSize=4:tabSize=8:noTabs=true: