Zbee ZCL se: fix typo found by conflict hf
[metze/wireshark/wip.git] / epan / color_filters.h
1 /* color_filters.h
2  * Definitions for color filters
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
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.
12  *
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.
17  *
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.
21  */
22 #ifndef  __COLOR_FILTERS_H__
23 #define  __COLOR_FILTERS_H__
24
25 #include "ws_symbol_export.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 #include <wsutil/color.h>
32
33 struct epan_dissect;
34
35 #define CONVERSATION_COLOR_PREFIX       "___conversation_color_filter___"
36 /** @file
37  *  Color filters.
38  */
39
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. */
48
49                                     /* only used inside of color_filters.c */
50     struct epan_dfilter *c_colorfilter;  /* compiled filter expression */
51
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. */
54 } color_filter_t;
55
56 /** A color filter was added (while importing).
57  * (color_filters.c calls this for every filter coming in)
58  *
59  * @param colorf the new color filter
60  * @param user_data from caller
61  */
62 typedef void (*color_filter_add_cb_func)(color_filter_t *colorf, gpointer user_data);
63
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);
66
67 /** Reload the color filters */
68 WS_DLL_PUBLIC gboolean color_filters_reload(gchar** err_msg, color_filter_add_cb_func add_cb);
69
70 /** Cleanup remaining color filter zombies */
71 WS_DLL_PUBLIC void color_filters_cleanup(void);
72
73 /** Color filters currently used?
74  *
75  * @return TRUE, if filters are used
76  */
77 WS_DLL_PUBLIC gboolean color_filters_used(void);
78
79 /** Are there any temporary coloring filters used?
80  *
81  * @return TRUE, if temporary coloring filters are used
82  */
83 WS_DLL_PUBLIC gboolean tmp_color_filters_used(void);
84
85 /** Set the filter string of a temporary color filter
86  *
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
91  */
92 WS_DLL_PUBLIC gboolean
93 color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg);
94
95 /** Get a temporary color filter.
96  *
97  * @param filter_num A number from 1 to 10 specifying the color to fetch.
98  * @return The corresponding color or NULL.
99  */
100 WS_DLL_PUBLIC const color_filter_t *
101 color_filters_tmp_color(guint8 filter_num);
102
103 /** Reset the temporary color filters
104  *
105  */
106 WS_DLL_PUBLIC gboolean
107 color_filters_reset_tmp(gchar **err_msg);
108
109 /* Prime the epan_dissect_t with all the compiler
110  * color filters of the current filter list.
111  *
112  * @param the epan dissector details
113  */
114 WS_DLL_PUBLIC void color_filters_prime_edt(struct epan_dissect *edt);
115
116 /** Colorize a specific packet.
117  *
118  * @param edt the dissected packet
119  * @return the matching color filter or NULL
120  */
121 WS_DLL_PUBLIC const color_filter_t *
122 color_filters_colorize_packet(struct epan_dissect *edt);
123
124 /** Clone the currently active filter list.
125  *
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
128  */
129 WS_DLL_PUBLIC void color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb);
130
131 /** Load filters (import) from some other filter file.
132  *
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
138  */
139 WS_DLL_PUBLIC gboolean color_filters_import(const gchar *path, gpointer user_data, gchar **err_msg, color_filter_add_cb_func add_cb);
140
141 /** Read filters from the global filter file (not the users file).
142  *
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
147  */
148 WS_DLL_PUBLIC gboolean color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add_cb_func add_cb);
149
150
151 /** Apply a changed filter list.
152  *
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
156  */
157 WS_DLL_PUBLIC gboolean color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg);
158
159 /** Save filters in users filter file.
160  *
161  * @param cfl the filter list to write
162  * @param err_msg a string with error message
163  * @return TRUE if write succeeded
164  */
165 WS_DLL_PUBLIC gboolean color_filters_write(GSList *cfl, gchar** err_msg);
166
167 /** Save filters (export) to some other filter file.
168  *
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
174  */
175 WS_DLL_PUBLIC gboolean color_filters_export(const gchar *path, GSList *cfl, gboolean only_selected, gchar** err_msg);
176
177 /** Create a new color filter (g_malloc'ed).
178  *
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
185  */
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);
189
190 /** Delete a single color filter (g_free'ed).
191  *
192  * @param colorf the color filter to be removed
193  */
194 WS_DLL_PUBLIC void color_filter_delete(color_filter_t *colorf);
195
196 /** Delete a filter list including all entries.
197  *
198  * @param cfl the filter list to delete
199  */
200 WS_DLL_PUBLIC void color_filter_list_delete(GSList **cfl);
201
202 #ifdef __cplusplus
203 }
204 #endif /* __cplusplus */
205
206 #endif
207
208 /*
209  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
210  *
211  * Local variables:
212  * c-basic-offset: 4
213  * tab-width: 8
214  * indent-tabs-mode: nil
215  * End:
216  *
217  * vi: set shiftwidth=4 tabstop=8 expandtab:
218  * :indentSize=4:tabSize=8:noTabs=true:
219  */