summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-01-28 04:52:29 +0000
committerGuy Harris <guy@alum.mit.edu>2001-01-28 04:52:29 +0000
commit3c596f5d718465872676cdf4330d6174bc68342d (patch)
tree12aa5a3eabe16f061bdfdc2f8e56f87f7aa98b94
parentc8639c08ee832fc44651bb08091021e3579bf8ba (diff)
downloadwireshark-3c596f5d718465872676cdf4330d6174bc68342d.tar.gz
Call "get_filter_list()" when Ethereal starts up.
Have it free up any list of filters we already have before reading in new filters. svn path=/trunk/; revision=2947
-rw-r--r--filters.c29
-rw-r--r--gtk/filter_prefs.c3
-rw-r--r--gtk/main.c7
3 files changed, 28 insertions, 11 deletions
diff --git a/filters.c b/filters.c
index f59b44fa02..682a37c9c7 100644
--- a/filters.c
+++ b/filters.c
@@ -1,7 +1,7 @@
/* filters.c
* Code for reading and writing the filters file.
*
- * $Id: filters.c,v 1.1 2001/01/28 04:43:24 guy Exp $
+ * $Id: filters.c,v 1.2 2001/01/28 04:52:28 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -56,14 +56,27 @@ GList *fl = NULL;
void
get_filter_list(void)
{
+ GList *flp;
filter_def *filt;
FILE *ff;
gchar *ff_path, *ff_name = PF_DIR "/filters", f_buf[FILTER_LINE_SIZE];
gchar *name_begin, *name_end, *filt_begin;
int len, line = 0;
- if (fl) return;
-
+ /* If we already have a list of filters, discard it. */
+ if (fl != NULL) {
+ flp = g_list_first(fl);
+ while (flp) {
+ filt = (filter_def *) flp->data;
+ g_free(filt->name);
+ g_free(filt->strval);
+ g_free(filt);
+ flp = flp->next;
+ }
+ g_list_free(fl);
+ fl = NULL;
+ }
+
/* To do: generalize this */
ff_path = (gchar *) g_malloc(strlen(get_home_dir()) + strlen(ff_name) + 4);
sprintf(ff_path, "%s/%s", get_home_dir(), ff_name);
@@ -111,11 +124,11 @@ get_filter_list(void)
void
save_filter_list(void)
{
- GList *flp;
- filter_def *filt;
- gchar *ff_path, *ff_dir = PF_DIR, *ff_name = "filters";
- FILE *ff;
- struct stat s_buf;
+ GList *flp;
+ filter_def *filt;
+ gchar *ff_path, *ff_dir = PF_DIR, *ff_name = "filters";
+ FILE *ff;
+ struct stat s_buf;
ff_path = (gchar *) g_malloc(strlen(get_home_dir()) + strlen(ff_dir) +
strlen(ff_name) + 4);
diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c
index 8d387d720d..6a78c809cb 100644
--- a/gtk/filter_prefs.c
+++ b/gtk/filter_prefs.c
@@ -3,7 +3,7 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
- * $Id: filter_prefs.c,v 1.24 2001/01/28 04:43:26 guy Exp $
+ * $Id: filter_prefs.c,v 1.25 2001/01/28 04:52:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -296,7 +296,6 @@ filter_dialog_new(GtkWidget *caller, GtkWidget *parent_filter_te,
gtk_widget_show(main_vb);
/* Make sure everything is set up */
- get_filter_list();
if (parent_filter_te)
filter_te_str = gtk_entry_get_text(GTK_ENTRY(parent_filter_te));
diff --git a/gtk/main.c b/gtk/main.c
index 6c5529ebbe..67a6c348bf 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.173 2001/01/21 02:27:24 guy Exp $
+ * $Id: main.c,v 1.174 2001/01/28 04:52:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -103,6 +103,7 @@
#include "capture.h"
#include "summary.h"
#include "file.h"
+#include "filters.h"
#include "menu.h"
#include "../menu.h"
#include "color.h"
@@ -924,8 +925,12 @@ main(int argc, char *argv[])
/* Let GTK get its args */
gtk_init (&argc, &argv);
+ /* Read the preference files. */
prefs = read_prefs(&gpf_open_errno, &gpf_path, &pf_open_errno, &pf_path);
+ /* Read the filter file. */
+ get_filter_list();
+
/* Initialize the capture file struct */
cfile.plist = NULL;
cfile.plist_end = NULL;