code cleanup: the term filter_list was used with different meanings throughout the...
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 25 Mar 2005 22:52:45 +0000 (22:52 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 25 Mar 2005 22:52:45 +0000 (22:52 +0000)
use appropriate prefixes to avoid confusion and bugs

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13905 f5534014-38df-0310-8fa8-9805f1628bb7

color_filters.c
color_filters.h
file.c
gtk/capture_dlg.c
gtk/cfilter_combo_utils.c
gtk/color_dlg.c
gtk/main.c

index f76e403..e7a06b9 100644 (file)
@@ -47,7 +47,7 @@ static gboolean read_global_filters(void);
 
 /* Variables and routines defined in color.h */
 
-GSList *filter_list = NULL;
+GSList *color_filter_list = NULL;
 GSList *removed_filter_list = NULL;
 
 /* Remove the specified filter from the list of existing color filters,
@@ -58,7 +58,7 @@ GSList *removed_filter_list = NULL;
 void remove_color_filter(color_filter_t *colorf)
 {
        /* Remove colorf from the list of color filters */
-       filter_list = g_slist_remove(filter_list, colorf);
+       color_filter_list = g_slist_remove(color_filter_list, colorf);
        /* Add colorf to the list of removed color filters */
        removed_filter_list = g_slist_prepend(removed_filter_list, colorf);
 }
@@ -88,9 +88,9 @@ delete_color_filter_it(gpointer filter_arg, gpointer unused _U_)
 static void
 delete_all_color_filters (void)
 {
-        g_slist_foreach(filter_list, delete_color_filter_it, NULL);
-       g_slist_free(filter_list);
-       filter_list = NULL;
+        g_slist_foreach(color_filter_list, delete_color_filter_it, NULL);
+       g_slist_free(color_filter_list);
+       color_filter_list = NULL;
         g_slist_foreach(removed_filter_list, delete_color_filter_it, NULL);
        g_slist_free(removed_filter_list);
        removed_filter_list = NULL;
@@ -122,7 +122,7 @@ new_color_filter(gchar *name,          /* The name of the filter to create */
        colorf->c_colorfilter = NULL;
        colorf->edit_dialog = NULL;
        colorf->marked = FALSE;
-       filter_list = g_slist_append(filter_list, colorf);
+       color_filter_list = g_slist_append(color_filter_list, colorf);
         return colorf;
 }
 
@@ -137,11 +137,11 @@ prime_edt(gpointer data, gpointer user_data)
 }
 
 /* Prime the epan_dissect_t with all the compiler
- * color filters in 'filter_list'. */
+ * color filters in 'color_filter_list'. */
 void
 filter_list_prime_edt(epan_dissect_t *edt)
 {
-       g_slist_foreach(filter_list, prime_edt, edt);
+       g_slist_foreach(color_filter_list, prime_edt, edt);
 }
 
 /* read filters from the given file */
@@ -402,7 +402,7 @@ write_filters_file(FILE *f, gboolean only_marked)
        data.only_marked = only_marked;
   
        fprintf(f,"# DO NOT EDIT THIS FILE!  It was created by Ethereal\n");
-        g_slist_foreach(filter_list, write_filter, &data);
+        g_slist_foreach(color_filter_list, write_filter, &data);
        return TRUE;
 }
 
index c851c2d..214becc 100644 (file)
@@ -41,7 +41,7 @@ typedef struct _color_filter {
 } color_filter_t;
 
 /* List of all color filters. */
-extern GSList *filter_list;
+extern GSList *color_filter_list;
 extern GSList *removed_filter_list;
 
 /** Init the color filters. */
diff --git a/file.c b/file.c
index 346d73e..9c44f03 100644 (file)
--- a/file.c
+++ b/file.c
@@ -778,7 +778,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
      allocate a protocol tree root node, so that we'll construct
      a protocol tree against which a filter expression can be
      evaluated. */
-  if ((cf->dfcode != NULL && refilter) || filter_list != NULL
+  if ((cf->dfcode != NULL && refilter) || color_filter_list != NULL
         || num_tap_filters != 0)
          create_proto_tree = TRUE;
 
@@ -788,7 +788,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
   if (cf->dfcode != NULL && refilter) {
       epan_dissect_prime_dfilter(edt, cf->dfcode);
   }
-  if (filter_list) {
+  if (color_filter_list) {
       filter_list_prime_edt(edt);
   }
   tap_queue_init(edt);
@@ -809,9 +809,9 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
   /* If we have color filters, and the frame is to be displayed, apply
      the color filters. */
   if (fdata->flags.passed_dfilter) {
-    if (filter_list != NULL) {
+    if (color_filter_list != NULL) {
       args.edt = edt;
-      g_slist_foreach(filter_list, apply_color_filter, &args);
+      g_slist_foreach(color_filter_list, apply_color_filter, &args);
     }
   }
 
@@ -855,13 +855,13 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 
     /* If the packet matches a color filter,
      * store matching color_filter_t object in frame data. */
-    if (filter_list != NULL && (args.colorf != NULL)) {
+    if (color_filter_list != NULL && (args.colorf != NULL)) {
       /* add the matching colorfilter to the frame data */
       fdata->color_filter = args.colorf;
       /* If packet is marked, use colors from preferences */
       if (fdata->flags.marked) {
           packet_list_set_colors(row, &prefs.gui_marked_fg, &prefs.gui_marked_bg);
-      } else /* if (filter_list != NULL && (args.colorf != NULL)) */ {
+      } else /* if (color_filter_list != NULL && (args.colorf != NULL)) */ {
           packet_list_set_colors(row, &(args.colorf->fg_color),
              &(args.colorf->bg_color));
       }
index 20a744d..dcaad05 100644 (file)
@@ -518,7 +518,7 @@ capture_prep(void)
   GtkTooltips   *tooltips;
   GtkAdjustment *snap_adj, *ringbuffer_nbf_adj,
                *stop_packets_adj, *stop_filesize_adj, *stop_duration_adj, *stop_files_adj, *ring_filesize_adj, *file_duration_adj;
-  GList         *if_list, *combo_list, *filter_list;
+  GList         *if_list, *combo_list, *cfilter_list;
   int           err;
   int           row;
   char          err_str[PCAP_ERRBUF_SIZE];
@@ -735,15 +735,15 @@ capture_prep(void)
   /* Create the capture filter combo */
   filter_cm = gtk_combo_new();
 
-  filter_list = OBJECT_GET_DATA(top_level, E_CFILTER_FL_KEY);
+  cfilter_list = OBJECT_GET_DATA(top_level, E_CFILTER_FL_KEY);
   gtk_combo_disable_activate(GTK_COMBO(filter_cm));
   gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
-  OBJECT_SET_DATA(top_level, E_CFILTER_FL_KEY, filter_list);
+  OBJECT_SET_DATA(top_level, E_CFILTER_FL_KEY, cfilter_list);
   OBJECT_SET_DATA(top_level, E_CFILTER_CM_KEY, filter_cm);
   filter_te = GTK_COMBO(filter_cm)->entry;
 
-  if (filter_list != NULL)
-    gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), filter_list);
+  if (cfilter_list != NULL)
+    gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), cfilter_list);
   if (capture_opts->cfilter)
     gtk_entry_set_text(GTK_ENTRY(filter_te), capture_opts->cfilter);
   gtk_tooltips_set_tip(tooltips, filter_te,
index 3100a1f..a114530 100644 (file)
@@ -65,12 +65,12 @@ cfilter_combo_add(gchar *s) {
  * of the combo box GList to the user's recent file */
 void
  cfilter_combo_recent_write_all(FILE *rf) {
-   GList     *filter_list = OBJECT_GET_DATA(top_level, E_CFILTER_FL_KEY);
+   GList     *cfilter_list = OBJECT_GET_DATA(top_level, E_CFILTER_FL_KEY);
    GList     *li;
    guint      max_count = 0;
 
-   /* write all non empty display filter strings to the recent file (until max count) */
-   li = g_list_first(filter_list);
+   /* write all non empty capture filter strings to the recent file (until max count) */
+   li = g_list_first(cfilter_list);
    while ( li && (max_count++ <= cfilter_combo_max_recent) ) {
      if (strlen(li->data)) {
        fprintf (rf, RECENT_KEY_CAPTURE_FILTER ": %s\n", (char *)li->data);
index a20577e..0757b26 100644 (file)
@@ -157,7 +157,7 @@ int color_marked_count(void)
 {
   int count = 0;
 
-  g_slist_foreach(filter_list, count_this_mark, &count);
+  g_slist_foreach(color_filter_list, count_this_mark, &count);
 
   return count;
 }
@@ -342,7 +342,7 @@ colorize_dialog_new (char *filter)
 #endif
 
   num_of_filters = 0;
-  g_slist_foreach(filter_list, add_filter_to_list, color_filters);
+  g_slist_foreach(color_filter_list, add_filter_to_list, color_filters);
 
 #if GTK_MAJOR_VERSION < 2
   gtk_clist_set_selection_mode    (GTK_CLIST (color_filters),GTK_SELECTION_EXTENDED);
@@ -564,8 +564,8 @@ void move_this_row (GtkWidget   *color_filters,
   
 #endif
 
-  filter_list = g_slist_remove(filter_list, colorf);
-  filter_list = g_slist_insert(filter_list, colorf, filter_number + amount);
+  color_filter_list = g_slist_remove(color_filter_list, colorf);
+  color_filter_list = g_slist_insert(color_filter_list, colorf, filter_number + amount);
 }
 
 /* Move the selected filters up in the list */
@@ -733,7 +733,7 @@ remember_selected_row(GtkTreeSelection *sel, gpointer color_filters)
     data.count = 0; 
     data.color_filters = color_filters;
 
-    g_slist_foreach(filter_list, clear_mark, NULL);
+    g_slist_foreach(color_filter_list, clear_mark, NULL);
     gtk_tree_selection_selected_foreach(sel,remember_this_row, &data);
                                       
     if (data.count > 0)
@@ -822,7 +822,7 @@ color_destroy_cb                       (GtkButton       *button _U_,
                                         gpointer         user_data _U_)
 {
   /* Destroy any edit dialogs we have open. */
-  g_slist_foreach(filter_list, destroy_edit_dialog_cb, NULL);
+  g_slist_foreach(color_filter_list, destroy_edit_dialog_cb, NULL);
 
   colorize_win = NULL;
 }
index 151c8a0..d833c87 100644 (file)
@@ -431,27 +431,27 @@ static guint dfilter_combo_max_recent = 10;
 static gboolean
 dfilter_combo_add(GtkWidget *filter_cm, char *s) {
   GList     *li;
-  GList     *filter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
+  GList     *dfilter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
 
 
   /* GtkCombos don't let us get at their list contents easily, so we maintain
      our own filter list, and feed it to gtk_combo_set_popdown_strings when
      a new filter is added. */
-    li = g_list_first(filter_list);
+    li = g_list_first(dfilter_list);
     while (li) {
         /* If the filter is already in the list, remove the old one and 
                 * append the new one at the latest position (at g_list_append() below) */
                if (li->data && strcmp(s, li->data) == 0) {
-          filter_list = g_list_remove(filter_list, li->data);
+          dfilter_list = g_list_remove(dfilter_list, li->data);
                  break;
                }
       li = li->next;
     }
 
-    filter_list = g_list_append(filter_list, s);
-    OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, filter_list);
-    gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), filter_list);
-    gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), g_list_last(filter_list)->data);
+    dfilter_list = g_list_append(dfilter_list, s);
+    OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, dfilter_list);
+    gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), dfilter_list);
+    gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), g_list_last(dfilter_list)->data);
 
     return TRUE;
 }
@@ -462,13 +462,13 @@ dfilter_combo_add(GtkWidget *filter_cm, char *s) {
 void
 dfilter_recent_combo_write_all(FILE *rf) {
   GtkWidget *filter_cm = OBJECT_GET_DATA(top_level, E_DFILTER_CM_KEY);
-  GList     *filter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
+  GList     *dfilter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
   GList     *li;
   guint      max_count = 0;
 
 
   /* write all non empty display filter strings to the recent file (until max count) */
-  li = g_list_first(filter_list);
+  li = g_list_first(dfilter_list);
   while ( li && (max_count++ <= dfilter_combo_max_recent) ) {
     if (strlen(li->data)) {
       fprintf (rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", (char *)li->data);
@@ -507,7 +507,7 @@ gboolean
 main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
 {
   GtkCombo  *filter_cm = OBJECT_GET_DATA(top_level, E_DFILTER_CM_KEY);
-  GList     *filter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
+  GList     *dfilter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
   GList     *li;
   gboolean   add_filter = TRUE;
   gboolean   free_filter = TRUE;
@@ -524,7 +524,7 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
      a new filter is added. */
   cf_status = cf_filter_packets(cf, s, force);
   if (cf_status == CF_OK) {
-    li = g_list_first(filter_list);
+    li = g_list_first(dfilter_list);
     while (li) {
       if (li->data && strcmp(s, li->data) == 0)
         add_filter = FALSE;
@@ -533,15 +533,15 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
 
     if (add_filter) {
       /* trim list size first */
-      while (g_list_length(filter_list) >= dfilter_combo_max_recent) {
-        filter_list = g_list_remove(filter_list, g_list_first(filter_list)->data);
+      while (g_list_length(dfilter_list) >= dfilter_combo_max_recent) {
+        dfilter_list = g_list_remove(dfilter_list, g_list_first(dfilter_list)->data);
       }
 
       free_filter = FALSE;
-      filter_list = g_list_append(filter_list, s);
-      OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, filter_list);
-      gtk_combo_set_popdown_strings(filter_cm, filter_list);
-      gtk_entry_set_text(GTK_ENTRY(filter_cm->entry), g_list_last(filter_list)->data);
+      dfilter_list = g_list_append(dfilter_list, s);
+      OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, dfilter_list);
+      gtk_combo_set_popdown_strings(filter_cm, dfilter_list);
+      gtk_entry_set_text(GTK_ENTRY(filter_cm->entry), g_list_last(dfilter_list)->data);
     }
   }
   if (free_filter)
@@ -2950,7 +2950,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
                   *filter_add_expr_bt,
                   *filter_apply,
                   *filter_reset;
-    GList         *filter_list = NULL;
+    GList         *dfilter_list = NULL;
     GtkTooltips   *tooltips;
     GtkAccelGroup *accel;
        gchar         *title;
@@ -3067,10 +3067,10 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
 
     /* Create the filter combobox */
     filter_cm = gtk_combo_new();
-    filter_list = NULL;
+    dfilter_list = NULL;
     gtk_combo_disable_activate(GTK_COMBO(filter_cm));
     gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
-    OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, filter_list);
+    OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, dfilter_list);
     filter_te = GTK_COMBO(filter_cm)->entry;
     main_display_filter_widget=filter_te;
     OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);