This patch makes it possible to disable individual coloring rules
[metze/wireshark/wip.git] / color_filters.h
1 /* color_filters.h
2  * Definitions for color filters
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24 #ifndef  __COLOR_FILTERS_H__
25 #define  __COLOR_FILTERS_H__
26
27 /** @file
28  *  Color filters.
29  */
30
31 /* Data for a color filter. */
32 typedef struct _color_filter {
33         gchar     *filter_name;   /* name of the filter */
34         gchar     *filter_text;   /* text of the filter expression */
35         color_t    bg_color;      /* background color for packets that match */
36         color_t    fg_color;      /* foreground color for packets that match */
37         gboolean   disabled;      /* set if the filter is disabled */
38         gboolean   selected;      /* set if the filter is selected in the color dialog box */
39
40         /* only used inside of color_filters.c */
41         dfilter_t *c_colorfilter; /* compiled filter expression */
42
43         /* only used outside of color_filters.c (beside init) */
44         void      *edit_dialog;   /* if filter is being edited, dialog
45                                    * box for it */
46 } color_filter_t;
47
48
49 /** Init the color filters (incl. initial read from file). */
50 void color_filters_init(void);
51
52 /** Cleanup remaining color filter zombies */
53 void color_filters_cleanup(void);
54
55 /** Color filters currently used?
56  *
57  * @return TRUE, if filters are used
58  */
59 gboolean color_filters_used(void);
60
61 /** En-/disable color filters
62  *
63  * @param enable TRUE to enable (default)
64  */
65 void
66 color_filters_enable(gboolean enable);
67
68
69
70 /* Prime the epan_dissect_t with all the compiler
71  * color filters of the current filter list. 
72  *
73  * @param the epan dissector details
74  */
75 void color_filters_prime_edt(epan_dissect_t *edt);
76
77 /** Colorize a specific packet.
78  *
79  * @param row the row in the packet list
80  * @param edt the dissected packet
81  * @return the matching color filter or NULL
82  */
83 color_filter_t *
84 color_filters_colorize_packet(gint row, epan_dissect_t *edt);
85
86
87
88 /** Clone the currently active filter list.
89  *
90  * @param user_data will be returned by each call to to color_filter_add_cb()
91  */
92 void color_filters_clone(gpointer user_data);
93
94 /** Load filters (import) from some other filter file.
95  *
96  * @param path the path to the import file
97  * @param user_data will be returned by each call to to color_filter_add_cb()
98  * @return TRUE, if read succeeded
99  */
100 gboolean color_filters_import(gchar *path, gpointer user_data);
101
102 /** Read filters from the global filter file (not the users file).
103  *
104  * @param user_data will be returned by each call to to color_filter_add_cb()
105  * @return TRUE, if read succeeded
106  */
107 gboolean color_filters_read_globals(gpointer user_data);
108
109 /** A color filter was added (while importing).
110  * (color_filters.c calls this for every filter coming in)
111  *
112  * @param colorf the new color filter
113  * @param user_data from caller
114  */
115 void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
116
117
118
119 /** Apply a changed filter list.
120  *
121  * @param cfl the filter list to apply
122  */
123 void color_filters_apply(GSList *cfl);
124
125 /** Save filters in users filter file.
126  *
127  * @param cfl the filter list to write
128  * @return TRUE if write succeeded
129  */
130 gboolean color_filters_write(GSList *cfl);
131
132 /** Save filters (export) to some other filter file.
133  *
134  * @param path the path to the filter file
135  * @param cfl the filter list to write
136  * @param only_selected TRUE if only the selected filters should be saved
137  * @return TRUE, if write succeeded
138  */
139 gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected);
140
141
142
143 /** Create a new color filter (g_malloc'ed).
144  *
145  * @param name the name of the filter
146  * @param filter_string the filter string
147  * @param bg_color background color
148  * @param fg_color foreground color
149  * @return the new color filter
150  */
151 color_filter_t *color_filter_new(
152     const gchar *name, const gchar *filter_string,
153     color_t *bg_color, color_t *fg_color, gboolean disabled);
154
155 /** Delete a single color filter (g_free'ed).
156  *
157  * @param colorf the color filter to be removed
158  */
159 void color_filter_delete(color_filter_t *colorf);
160
161
162
163
164 /** Delete a filter list including all entries.
165  *
166  * @param cfl the filter list to delete
167  */
168 void color_filter_list_delete(GSList **cfl);
169
170
171
172 #endif