2 * Definitions for color filters
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef __COLOR_FILTERS_H__
25 #define __COLOR_FILTERS_H__
27 #define TEMP_COLOR_PREFIX "___tmp_color_filter___"
32 /* Data for a color filter. */
33 typedef struct _color_filter {
34 gchar *filter_name; /* name of the filter */
35 gchar *filter_text; /* text of the filter expression */
36 color_t bg_color; /* background color for packets that match */
37 color_t fg_color; /* foreground color for packets that match */
38 gboolean disabled; /* set if the filter is disabled */
39 gboolean selected; /* set if the filter is selected in the color dialog box */
41 /* only used inside of color_filters.c */
42 dfilter_t *c_colorfilter; /* compiled filter expression */
44 /* only used outside of color_filters.c (beside init) */
45 void *edit_dialog; /* if filter is being edited, dialog
50 /** Init the color filters (incl. initial read from file). */
51 void color_filters_init(void);
53 /** Reload the color filters */
54 void color_filters_reload(void);
56 /** Cleanup remaining color filter zombies */
57 void color_filters_cleanup(void);
59 /** Color filters currently used?
61 * @return TRUE, if filters are used
63 gboolean color_filters_used(void);
65 /** Are there any temporary coloring filters used?
67 * @return TRUE, if temporary coloring filters are used
69 gboolean tmp_color_filters_used(void);
71 /** En-/disable color filters
73 * @param enable TRUE to enable (default)
76 color_filters_enable(gboolean enable);
78 /** Set the filter string of a temporary color filter
80 * @param filt_nr a number 1-10 pointing to a temporary color
81 * @param filter the new filter-string
82 * @param disabled whether the filter-rule should be disabled
85 color_filters_set_tmp(guint8 filt_nr, gchar *filter, gboolean disabled);
87 /** Reset the temporary color filters
91 color_filters_reset_tmp(void);
93 /* Prime the epan_dissect_t with all the compiler
94 * color filters of the current filter list.
96 * @param the epan dissector details
98 void color_filters_prime_edt(epan_dissect_t *edt);
100 /** Colorize a specific packet.
102 * @param row the row in the packet list
103 * @param edt the dissected packet
104 * @return the matching color filter or NULL
106 const color_filter_t *
107 #ifdef NEW_PACKET_LIST
108 color_filters_colorize_packet(epan_dissect_t *edt);
110 color_filters_colorize_packet(gint row, epan_dissect_t *edt);
113 /** Clone the currently active filter list.
115 * @param user_data will be returned by each call to to color_filter_add_cb()
117 void color_filters_clone(gpointer user_data);
119 /** Load filters (import) from some other filter file.
121 * @param path the path to the import file
122 * @param user_data will be returned by each call to to color_filter_add_cb()
123 * @return TRUE, if read succeeded
125 gboolean color_filters_import(gchar *path, gpointer user_data);
127 /** Read filters from the global filter file (not the users file).
129 * @param user_data will be returned by each call to to color_filter_add_cb()
130 * @return TRUE, if read succeeded
132 gboolean color_filters_read_globals(gpointer user_data);
134 /** A color filter was added (while importing).
135 * (color_filters.c calls this for every filter coming in)
137 * @param colorf the new color filter
138 * @param user_data from caller
140 void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
144 /** Apply a changed filter list.
146 * @param tmp_cfl the temporary color filter list to apply
147 * @param edit_cfl the edited permanent color filter list to apply
149 void color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl);
151 /** Save filters in users filter file.
153 * @param cfl the filter list to write
154 * @return TRUE if write succeeded
156 gboolean color_filters_write(GSList *cfl);
158 /** Save filters (export) to some other filter file.
160 * @param path the path to the filter file
161 * @param cfl the filter list to write
162 * @param only_selected TRUE if only the selected filters should be saved
163 * @return TRUE, if write succeeded
165 gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected);
169 /** Create a new color filter (g_malloc'ed).
171 * @param name the name of the filter
172 * @param filter_string the filter string
173 * @param bg_color background color
174 * @param fg_color foreground color
175 * @return the new color filter
177 color_filter_t *color_filter_new(
178 const gchar *name, const gchar *filter_string,
179 color_t *bg_color, color_t *fg_color, gboolean disabled);
181 /** Delete a single color filter (g_free'ed).
183 * @param colorf the color filter to be removed
185 void color_filter_delete(color_filter_t *colorf);
190 /** Delete a filter list including all entries.
192 * @param cfl the filter list to delete
194 void color_filter_list_delete(GSList **cfl);