Update:
[obnox/wireshark/wip.git] / color_filters.h
index f30404763892c2de5ca6fbeba3b281f84f167699..5d5c1ad1cff213523f913389ffc76a340e940368 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * 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
 #ifndef  __COLOR_FILTERS_H__
 #define  __COLOR_FILTERS_H__
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define CONVERSATION_COLOR_PREFIX       "___conversation_color_filter___"
 /** @file
  *  Color filters.
  */
-#include "epan/dfilter/dfilter.h"
 
 /* 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 */
-        dfilter_t *c_colorfilter; /* compiled filter expression */
-        void      *edit_dialog;   /* if filter is being edited, dialog
-                                   * box for it */
-       gboolean    marked;         /* set if the filter is marked in the color dialog box */
+    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 */
+
+    /* only used inside of color_filters.c */
+    dfilter_t *c_colorfilter; /* compiled filter expression */
+
+    /* only used outside of color_filters.c (beside init) */
+    void      *edit_dialog;   /* if filter is being edited, dialog
+                               * box for it */
 } color_filter_t;
 
-/* List of all color filters. */
-extern GSList *filter_list;
-extern GSList *removed_filter_list;
 
-/** Init the color filters. */
-void colfilter_init(void);
+/** Init the color filters (incl. initial read from file). */
+void color_filters_init(void);
+
+/** Reload the color filters */
+void color_filters_reload(void);
+
+/** Cleanup remaining color filter zombies */
+void color_filters_cleanup(void);
+
+/** Color filters currently used?
+ *
+ * @return TRUE, if filters are used
+ */
+gboolean color_filters_used(void);
+
+/** Are there any temporary coloring filters used?
+ *
+ * @return TRUE, if temporary coloring filters are used
+ */
+gboolean tmp_color_filters_used(void);
+
+/** En-/disable color filters
+ *
+ * @param enable TRUE to enable (default)
+ */
+void
+color_filters_enable(gboolean enable);
+
+/** 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
+ */
+void
+color_filters_set_tmp(guint8 filt_nr, gchar *filter, gboolean disabled);
+
+/** Reset the temporary color filters
+ *
+ */
+void
+color_filters_reset_tmp(void);
+
+/* Prime the epan_dissect_t with all the compiler
+ * color filters of the current filter list.
+ *
+ * @param the epan dissector details
+ */
+void color_filters_prime_edt(epan_dissect_t *edt);
+
+/** Colorize a specific packet.
+ *
+ * @param row the row in the packet list
+ * @param edt the dissected packet
+ * @return the matching color filter or NULL
+ */
+const color_filter_t *
+color_filters_colorize_packet(epan_dissect_t *edt);
+
+/** Clone the currently active filter list.
+ *
+ * @param user_data will be returned by each call to to color_filter_add_cb()
+ */
+void color_filters_clone(gpointer user_data);
+
+/** 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
+ */
+gboolean color_filters_import(gchar *path, gpointer user_data);
+
+/** 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
+ */
+gboolean color_filters_read_globals(gpointer user_data);
+
+/** 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
+ */
+void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
+
+
+
+/** 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
+ */
+void color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl);
 
 /** Save filters in users filter file.
  *
+ * @param cfl the filter list to write
  * @return TRUE if write succeeded
  */
-gboolean write_filters(void);
+gboolean color_filters_write(GSList *cfl);
 
-/** Delete users filter file and reload global filters.
+/** Save filters (export) to some other filter file.
  *
- * @return TRUE if write succeeded
+ * @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
  */
-gboolean revert_filters(void);
+gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected);
+
 
-/** Create a new color filter.
+
+/** 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
  */
-color_filter_t *new_color_filter(gchar *name, gchar *filter_string,
-    color_t *bg_color, color_t *fg_color);
+color_filter_t *color_filter_new(
+    const gchar *name, const gchar *filter_string,
+    color_t *bg_color, color_t *fg_color, gboolean disabled);
 
-/** Remove the color filter.
+/** Delete a single color filter (g_free'ed).
  *
  * @param colorf the color filter to be removed
  */
-void remove_color_filter(color_filter_t *colorf);
+void color_filter_delete(color_filter_t *colorf);
+
 
-/** Load filters from some other filter file.
- *
- * @param path the path to the filter file
- * @param arg the color filter widget
- * @return TRUE, if read succeeded
- */
-gboolean read_other_filters(gchar *path, gpointer arg);
 
-/** Save filters to some other filter file.
- *
- * @param path the path to the filter file
- * @param only_marked TRUE if only the marked filters should be saved
- * @return TRUE, if write succeeded
- */
-gboolean write_other_filters(gchar *path, gboolean only_marked);
 
-/** Add a color filter.
+/** Delete a filter list including all entries.
  *
- * @param colorf the new color filter
- * @param arg the color filter widget
+ * @param cfl the filter list to delete
  */
-void color_add_filter_cb (color_filter_t *colorf, gpointer arg);
+void color_filter_list_delete(GSList **cfl);
 
-void filter_list_prime_edt(epan_dissect_t *edt);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
 
 #endif