aboutsummaryrefslogtreecommitdiffstats
path: root/epan/color_filters.h
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-12-22 15:07:00 -0500
committerMichael Mann <mmann78@netscape.net>2015-12-28 18:33:41 +0000
commit5e4bbcda9839d9fd4480db8c4f9386ff388d166c (patch)
tree9801cea61222e0e9e3f8c57f4574ddb6bab075c7 /epan/color_filters.h
parentc752daf4b8816d809a92894155ce8de1b24613c7 (diff)
Refactor GUI dependencies out of color_filters.[ch] and move it to epan directory.
This also moved color.h into color_filters.h Change-Id: Ic19e27aa1b3ec67e764aa7ee8bbef7b1187bb12e Reviewed-on: https://code.wireshark.org/review/12831 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/color_filters.h')
-rw-r--r--epan/color_filters.h235
1 files changed, 235 insertions, 0 deletions
diff --git a/epan/color_filters.h b/epan/color_filters.h
new file mode 100644
index 0000000000..2fe8b018cb
--- /dev/null
+++ b/epan/color_filters.h
@@ -0,0 +1,235 @@
+/* color_filters.h
+ * Definitions for color filters
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef __COLOR_FILTERS_H__
+#define __COLOR_FILTERS_H__
+
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct epan_dissect;
+
+/*
+ * Data structure holding RGB value for a color.
+ *
+ * XXX - yes, I know, there's a "pixel" value in there as well; for
+ * now, it's intended to look just like a GdkColor but not to require
+ * that any GTK+ header files be included in order to use it.
+ * The way we handle colors needs to be cleaned up somewhat, in order
+ * to keep toolkit-specific stuff separate from toolkit-independent stuff.
+ */
+typedef struct {
+ guint32 pixel;
+ guint16 red;
+ guint16 green;
+ guint16 blue;
+} color_t;
+
+/** Initialize a color with R, G, and B values, including any toolkit-dependent
+ ** work that needs to be done.
+ *
+ * @param color the color_t to be filled
+ * @param red the red value for the color
+ * @param green the green value for the color
+ * @param blue the blue value for the color
+ * @return TRUE if it succeeds, FALSE if it fails
+ */
+typedef gboolean (*initialize_color_func)(color_t *color, guint16 red, guint16 green, guint16 blue);
+
+#define CONVERSATION_COLOR_PREFIX "___conversation_color_filter___"
+/** @file
+ * Color filters.
+ */
+
+/* Data for a color filter. */
+typedef struct _color_filter {
+ gchar *filter_name; /* name of the filter */
+ gchar *filter_text; /* text of the filter expression */
+ color_t bg_color; /* background color for packets that match */
+ color_t fg_color; /* foreground color for packets that match */
+ gboolean disabled; /* set if the filter is disabled */
+ gboolean selected; /* set if the filter is selected in the color dialog box. GTK+ only. */
+
+ /* only used inside of color_filters.c */
+ struct epan_dfilter *c_colorfilter; /* compiled filter expression */
+
+ /* only used outside of color_filters.c (beside init) */
+ void *color_edit_dlg_info; /* if filter is being edited, ptr to req'd info. GTK+ only. */
+} color_filter_t;
+
+/** A color filter was added (while importing).
+ * (color_filters.c calls this for every filter coming in)
+ *
+ * @param colorf the new color filter
+ * @param user_data from caller
+ */
+typedef void (*color_filter_add_cb_func)(color_filter_t *colorf, gpointer user_data);
+
+/** Init the color filters (incl. initial read from file). */
+WS_DLL_PUBLIC gboolean color_filters_init(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
+
+/** Reload the color filters */
+WS_DLL_PUBLIC gboolean color_filters_reload(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
+
+/** Cleanup remaining color filter zombies */
+WS_DLL_PUBLIC void color_filters_cleanup(void);
+
+/** Color filters currently used?
+ *
+ * @return TRUE, if filters are used
+ */
+WS_DLL_PUBLIC gboolean color_filters_used(void);
+
+/** Are there any temporary coloring filters used?
+ *
+ * @return TRUE, if temporary coloring filters are used
+ */
+WS_DLL_PUBLIC gboolean tmp_color_filters_used(void);
+
+/** Set the filter string of a temporary color filter
+ *
+ * @param filt_nr a number 1-10 pointing to a temporary color
+ * @param filter the new filter-string
+ * @param disabled whether the filter-rule should be disabled
+ */
+WS_DLL_PUBLIC gboolean
+color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg);
+
+/** Get a temporary color filter.
+ *
+ * @param filter_num A number from 1 to 10 specifying the color to fetch.
+ * @return The corresponding color or NULL.
+ */
+WS_DLL_PUBLIC const color_filter_t *
+color_filters_tmp_color(guint8 filter_num);
+
+/** Reset the temporary color filters
+ *
+ */
+WS_DLL_PUBLIC gboolean
+color_filters_reset_tmp(gchar **err_msg);
+
+/* Prime the epan_dissect_t with all the compiler
+ * color filters of the current filter list.
+ *
+ * @param the epan dissector details
+ */
+WS_DLL_PUBLIC void color_filters_prime_edt(struct epan_dissect *edt);
+
+/** Colorize a specific packet.
+ *
+ * @param edt the dissected packet
+ * @return the matching color filter or NULL
+ */
+WS_DLL_PUBLIC const color_filter_t *
+color_filters_colorize_packet(struct epan_dissect *edt);
+
+/** Clone the currently active filter list.
+ *
+ * @param user_data will be returned by each call to to color_filter_add_cb()
+ */
+WS_DLL_PUBLIC void color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb);
+
+/** Load filters (import) from some other filter file.
+ *
+ * @param path the path to the import file
+ * @param user_data will be returned by each call to to color_filter_add_cb()
+ * @return TRUE, if read succeeded
+ */
+WS_DLL_PUBLIC gboolean color_filters_import(const gchar *path, const gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
+
+/** Read filters from the global filter file (not the users file).
+ *
+ * @param user_data will be returned by each call to to color_filter_add_cb()
+ * @return TRUE, if read succeeded
+ */
+WS_DLL_PUBLIC gboolean color_filters_read_globals(gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
+
+
+/** Apply a changed filter list.
+ *
+ * @param tmp_cfl the temporary color filter list to apply
+ * @param edit_cfl the edited permanent color filter list to apply
+ */
+WS_DLL_PUBLIC gboolean color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg);
+
+/** Save filters in users filter file.
+ *
+ * @param cfl the filter list to write
+ * @return TRUE if write succeeded
+ */
+WS_DLL_PUBLIC gboolean color_filters_write(GSList *cfl, gchar** err_msg);
+
+/** Save filters (export) to some other filter file.
+ *
+ * @param path the path to the filter file
+ * @param cfl the filter list to write
+ * @param only_selected TRUE if only the selected filters should be saved
+ * @return TRUE, if write succeeded
+ */
+WS_DLL_PUBLIC gboolean color_filters_export(const gchar *path, const GSList *cfl, gboolean only_selected, gchar** err_msg);
+
+/** Create a new color filter (g_malloc'ed).
+ *
+ * @param name the name of the filter
+ * @param filter_string the filter string
+ * @param bg_color background color
+ * @param fg_color foreground color
+ * @param disabled gboolean
+ * @return the new color filter
+ */
+WS_DLL_PUBLIC color_filter_t *color_filter_new(
+ const gchar *name, const gchar *filter_string,
+ color_t *bg_color, color_t *fg_color, gboolean disabled);
+
+/** Delete a single color filter (g_free'ed).
+ *
+ * @param colorf the color filter to be removed
+ */
+WS_DLL_PUBLIC void color_filter_delete(color_filter_t *colorf);
+
+/** Delete a filter list including all entries.
+ *
+ * @param cfl the filter list to delete
+ */
+WS_DLL_PUBLIC void color_filter_list_delete(GSList **cfl);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */