Don't use the non-existent decoded data if decode_rtp_packet() returns 0.
[metze/wireshark/wip.git] / 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 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 struct epan_dissect;
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. GTK+ only. */
44
45                                     /* only used inside of color_filters.c */
46     struct epan_dfilter *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. GTK+ only. */
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, const gchar *filter, gboolean disabled);
89
90 /** Get a temporary color filter.
91  *
92  * @param filter_num A number from 1 to 10 specifying the color to fetch.
93  * @return The corresponding color or NULL.
94  */
95 const color_filter_t *
96 color_filters_tmp_color(guint8 filter_num);
97
98 /** Reset the temporary color filters
99  *
100  */
101 void
102 color_filters_reset_tmp(void);
103
104 /* Prime the epan_dissect_t with all the compiler
105  * color filters of the current filter list.
106  *
107  * @param the epan dissector details
108  */
109 void color_filters_prime_edt(struct epan_dissect *edt);
110
111 /** Colorize a specific packet.
112  *
113  * @param edt the dissected packet
114  * @return the matching color filter or NULL
115  */
116 const color_filter_t *
117 color_filters_colorize_packet(struct epan_dissect *edt);
118
119 /** Clone the currently active filter list.
120  *
121  * @param user_data will be returned by each call to to color_filter_add_cb()
122  */
123 void color_filters_clone(gpointer user_data);
124
125 /** Load filters (import) from some other filter file.
126  *
127  * @param path the path to the import file
128  * @param user_data will be returned by each call to to color_filter_add_cb()
129  * @return TRUE, if read succeeded
130  */
131 gboolean color_filters_import(const gchar *path, const gpointer user_data);
132
133 /** Read filters from the global filter file (not the users file).
134  *
135  * @param user_data will be returned by each call to to color_filter_add_cb()
136  * @return TRUE, if read succeeded
137  */
138 gboolean color_filters_read_globals(gpointer user_data);
139
140 /** A color filter was added (while importing).
141  * (color_filters.c calls this for every filter coming in)
142  *
143  * @param colorf the new color filter
144  * @param user_data from caller
145  */
146 void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
147
148
149
150 /** Apply a changed filter list.
151  *
152  * @param tmp_cfl the temporary color filter list to apply
153  * @param edit_cfl the edited permanent color filter list to apply
154  */
155 void color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl);
156
157 /** Save filters in users filter file.
158  *
159  * @param cfl the filter list to write
160  * @return TRUE if write succeeded
161  */
162 gboolean color_filters_write(GSList *cfl);
163
164 /** Save filters (export) to some other filter file.
165  *
166  * @param path the path to the filter file
167  * @param cfl the filter list to write
168  * @param only_selected TRUE if only the selected filters should be saved
169  * @return TRUE, if write succeeded
170  */
171 gboolean color_filters_export(const gchar *path, const GSList *cfl, gboolean only_selected);
172
173 /** Create a new color filter (g_malloc'ed).
174  *
175  * @param name the name of the filter
176  * @param filter_string the filter string
177  * @param bg_color background color
178  * @param fg_color foreground color
179  * @param disabled gboolean
180  * @return the new color filter
181  */
182 color_filter_t *color_filter_new(
183     const gchar *name, const gchar *filter_string,
184     color_t *bg_color, color_t *fg_color, gboolean disabled);
185
186 /** Delete a single color filter (g_free'ed).
187  *
188  * @param colorf the color filter to be removed
189  */
190 void color_filter_delete(color_filter_t *colorf);
191
192 /** Delete a filter list including all entries.
193  *
194  * @param cfl the filter list to delete
195  */
196 void color_filter_list_delete(GSList **cfl);
197
198 #ifdef __cplusplus
199 }
200 #endif /* __cplusplus */
201
202 #endif
203
204 /*
205  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
206  *
207  * Local variables:
208  * c-basic-offset: 4
209  * tab-width: 8
210  * indent-tabs-mode: nil
211  * End:
212  *
213  * vi: set shiftwidth=4 tabstop=8 expandtab:
214  * :indentSize=4:tabSize=8:noTabs=true:
215  */