Fix a comparison.
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 #ifndef  __COLOR_FILTERS_H__
25 #define  __COLOR_FILTERS_H__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 #define CONVERSATION_COLOR_PREFIX       "___conversation_color_filter___"
32 /** @file
33  *  Color filters.
34  */
35
36 /* Data for a color filter. */
37 typedef struct _color_filter {
38     gchar     *filter_name;         /* name of the filter */
39     gchar     *filter_text;         /* text of the filter expression */
40     color_t    bg_color;            /* background color for packets that match */
41     color_t    fg_color;            /* foreground color for packets that match */
42     gboolean   disabled;            /* set if the filter is disabled */
43     gboolean   selected;            /* set if the filter is selected in the color dialog box */
44
45                                     /* only used inside of color_filters.c */
46     dfilter_t *c_colorfilter;       /* compiled filter expression */
47
48                                     /* only used outside of color_filters.c (beside init) */
49     void      *color_edit_dlg_info; /* if filter is being edited, ptr to req'd info */
50 } color_filter_t;
51
52
53 /** Init the color filters (incl. initial read from file). */
54 void color_filters_init(void);
55
56 /** Reload the color filters */
57 void color_filters_reload(void);
58
59 /** Cleanup remaining color filter zombies */
60 void color_filters_cleanup(void);
61
62 /** Color filters currently used?
63  *
64  * @return TRUE, if filters are used
65  */
66 gboolean color_filters_used(void);
67
68 /** Are there any temporary coloring filters used?
69  *
70  * @return TRUE, if temporary coloring filters are used
71  */
72 gboolean tmp_color_filters_used(void);
73
74 /** En-/disable color filters
75  *
76  * @param enable TRUE to enable (default)
77  */
78 void
79 color_filters_enable(gboolean enable);
80
81 /** Set the filter string of a temporary color filter
82  *
83  * @param filt_nr a number 1-10 pointing to a temporary color
84  * @param filter the new filter-string
85  * @param disabled whether the filter-rule should be disabled
86  */
87 void
88 color_filters_set_tmp(guint8 filt_nr, gchar *filter, gboolean disabled);
89
90 /** Reset the temporary color filters
91  *
92  */
93 void
94 color_filters_reset_tmp(void);
95
96 /* Prime the epan_dissect_t with all the compiler
97  * color filters of the current filter list.
98  *
99  * @param the epan dissector details
100  */
101 void color_filters_prime_edt(epan_dissect_t *edt);
102
103 /** Colorize a specific packet.
104  *
105  * @param edt the dissected packet
106  * @return the matching color filter or NULL
107  */
108 const color_filter_t *
109 color_filters_colorize_packet(epan_dissect_t *edt);
110
111 /** Clone the currently active filter list.
112  *
113  * @param user_data will be returned by each call to to color_filter_add_cb()
114  */
115 void color_filters_clone(gpointer user_data);
116
117 /** Load filters (import) from some other filter file.
118  *
119  * @param path the path to the import file
120  * @param user_data will be returned by each call to to color_filter_add_cb()
121  * @return TRUE, if read succeeded
122  */
123 gboolean color_filters_import(gchar *path, gpointer user_data);
124
125 /** Read filters from the global filter file (not the users file).
126  *
127  * @param user_data will be returned by each call to to color_filter_add_cb()
128  * @return TRUE, if read succeeded
129  */
130 gboolean color_filters_read_globals(gpointer user_data);
131
132 /** A color filter was added (while importing).
133  * (color_filters.c calls this for every filter coming in)
134  *
135  * @param colorf the new color filter
136  * @param user_data from caller
137  */
138 void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
139
140
141
142 /** Apply a changed filter list.
143  *
144  * @param tmp_cfl the temporary color filter list to apply
145  * @param edit_cfl the edited permanent color filter list to apply
146  */
147 void color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl);
148
149 /** Save filters in users filter file.
150  *
151  * @param cfl the filter list to write
152  * @return TRUE if write succeeded
153  */
154 gboolean color_filters_write(GSList *cfl);
155
156 /** Save filters (export) to some other filter file.
157  *
158  * @param path the path to the filter file
159  * @param cfl the filter list to write
160  * @param only_selected TRUE if only the selected filters should be saved
161  * @return TRUE, if write succeeded
162  */
163 gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected);
164
165
166
167 /** Create a new color filter (g_malloc'ed).
168  *
169  * @param name the name of the filter
170  * @param filter_string the filter string
171  * @param bg_color background color
172  * @param fg_color foreground color
173  * @param disabled gboolean
174  * @return the new color filter
175  */
176 color_filter_t *color_filter_new(
177     const gchar *name, const gchar *filter_string,
178     color_t *bg_color, color_t *fg_color, gboolean disabled);
179
180 /** Delete a single color filter (g_free'ed).
181  *
182  * @param colorf the color filter to be removed
183  */
184 void color_filter_delete(color_filter_t *colorf);
185
186
187
188
189 /** Delete a filter list including all entries.
190  *
191  * @param cfl the filter list to delete
192  */
193 void color_filter_list_delete(GSList **cfl);
194
195 #ifdef __cplusplus
196 }
197 #endif /* __cplusplus */
198
199 #endif
200
201 /*
202  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
203  *
204  * Local variables:
205  * c-basic-offset: 4
206  * tab-width: 8
207  * indent-tabs-mode: nil
208  * End:
209  *
210  * vi: set shiftwidth=4 tabstop=8 expandtab:
211  * :indentSize=4:tabSize=8:noTabs=true:
212  */