Move the file utility functions from wiretap to libwsutil so that
[obnox/wireshark/wip.git] / color_filters.c
index 445c36d1cfa6b3ed4b5901e4629d86d7d72e8830..6d72c1928eee162cc7870648b0a1deea0b0e4ec3 100644 (file)
@@ -24,7 +24,7 @@
 /*
  * Updated 1 Dec 10 jjm
  */
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -34,7 +34,7 @@
 #include <string.h>
 
 #include <epan/filesystem.h>
-#include "file_util.h"
+#include <wsutil/file_util.h>
 
 #include <epan/packet.h>
 #include "color.h"
@@ -54,7 +54,7 @@ static gboolean read_users_filters(GSList **cfl);
 /* the currently active filters */
 static GSList *color_filter_list = NULL;
 
-/* keep "old" deleted filters in this list until 
+/* keep "old" deleted filters in this list until
  * the dissection no longer needs them (e.g. file is closed) */
 static GSList *color_filter_deleted_list = NULL;
 static GSList *color_filter_valid_list = NULL;
@@ -157,10 +157,10 @@ color_filters_set_tmp(guint8 filt_nr, gchar *filter, gboolean disabled)
          * If found, clear it so that a filter can be "moved" up and down the list
          */
         for ( i=1 ; i<=10 ; i++ ) {
-                /* If we need to reset the temporary filter (filter==NULL), don't look 
+                /* If we need to reset the temporary filter (filter==NULL), don't look
                  * for other rules with the same filter string
                  */
-                if( i!=filt_nr && filter==NULL ) 
+                if( i!=filt_nr && filter==NULL )
                         continue;
 
                 name = g_strdup_printf("%s%02d",TEMP_COLOR_PREFIX,i);
@@ -380,7 +380,7 @@ color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl)
         /* clone all list entries from tmp/edit to normal list */
         color_filter_valid_list = NULL;
         color_filter_valid_list = color_filter_list_clone(tmp_cfl);
-        color_filter_valid_list = g_slist_concat(color_filter_valid_list, 
+        color_filter_valid_list = g_slist_concat(color_filter_valid_list,
                                                  color_filter_list_clone(edit_cfl) );
 
         /* compile all filter */
@@ -393,13 +393,13 @@ color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl)
         g_slist_foreach(color_filter_list, color_filter_compile_cb, NULL);
 }
 
-gboolean 
+gboolean
 color_filters_used(void)
 {
         return color_filter_list != NULL && filters_enabled;
 }
 
-gboolean 
+gboolean
 tmp_color_filters_used(void)
 {
         return tmp_colors_set;
@@ -505,7 +505,7 @@ read_filters_file(FILE *f, gpointer user_data)
                }
 
                /* skip # comments and invalid lines */
-               if (c != '@') { 
+               if (c != '@') {
                        skip_end_of_line = TRUE;
                        continue;
                }
@@ -526,7 +526,7 @@ read_filters_file(FILE *f, gpointer user_data)
                                name_len *= 2;
                                name = g_realloc(name, name_len + 1);
                        }
-                       name[i++] = c;            
+                       name[i++] = c;
                }
                name[i] = '\0';
 
@@ -630,7 +630,7 @@ read_users_filters(GSList **cfl)
 
        /* decide what file to open (from dfilter code) */
        path = get_persconffile_path("colorfilters", TRUE, FALSE);
-       if ((f = eth_fopen(path, "r")) == NULL) {
+       if ((f = ws_fopen(path, "r")) == NULL) {
                if (errno != ENOENT) {
                        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                            "Could not open filter file\n\"%s\": %s.", path,
@@ -657,7 +657,7 @@ color_filters_read_globals(gpointer user_data)
 
        /* decide what file to open (from dfilter code) */
        path = get_datafile_path("colorfilters");
-       if ((f = eth_fopen(path, "r")) == NULL) {
+       if ((f = ws_fopen(path, "r")) == NULL) {
                if (errno != ENOENT) {
                        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                            "Could not open global filter file\n\"%s\": %s.", path,
@@ -681,7 +681,7 @@ color_filters_import(gchar *path, gpointer user_data)
        FILE *f;
        gboolean ret;
 
-       if ((f = eth_fopen(path, "r")) == NULL) {
+       if ((f = ws_fopen(path, "r")) == NULL) {
                simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                    "Could not open\n%s\nfor reading: %s.",
                    path, strerror(errno));
@@ -730,7 +730,7 @@ write_filters_file(GSList *cfl, FILE *f, gboolean only_selected)
 
        data.f = f;
        data.only_selected = only_selected;
-  
+
        fprintf(f,"# DO NOT EDIT THIS FILE!  It was created by Wireshark\n");
         g_slist_foreach(cfl, write_filter, &data);
        return TRUE;
@@ -755,7 +755,7 @@ color_filters_write(GSList *cfl)
        }
 
        path = get_persconffile_path("colorfilters", TRUE, TRUE);
-       if ((f = eth_fopen(path, "w+")) == NULL) {
+       if ((f = ws_fopen(path, "w+")) == NULL) {
                simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                    "Could not open\n%s\nfor writing: %s.",
                    path, strerror(errno));
@@ -774,7 +774,7 @@ color_filters_export(gchar *path, GSList *cfl, gboolean only_marked)
 {
        FILE *f;
 
-       if ((f = eth_fopen(path, "w+")) == NULL) {
+       if ((f = ws_fopen(path, "w+")) == NULL) {
                simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                    "Could not open\n%s\nfor writing: %s.",
                    path, strerror(errno));