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