aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-11 06:39:26 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-11 06:39:26 +0000
commit8abb50f71aa923c7bc87ec4a949dce4374466135 (patch)
treedfec8b639fbd755acc879b925ce7a2d2dd8e9302 /file.c
parent974baaf856fcec198fa51f03581d03afe39a7f20 (diff)
When a new display filter is to be applied, don't set "cf.dfilter" or
"cf.dfcode" if the new filter doesn't compile, because the filter currently in effect will be the one that was last applied - just free up the text of the new filter, and whatever memory was allocated for the new filter code. This means we allocate a new dfilter when a new filter is to be applied, rather than recycling stuff from the old filter, as we want the old filter code to remain around if the new filter doesn't compile. This means that "cf.dfilter" and "cf.dfcode" will be null if there's no filter in effect. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@803 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'file.c')
-rw-r--r--file.c54
1 files changed, 43 insertions, 11 deletions
diff --git a/file.c b/file.c
index ccc84f2fba..cadd519754 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.104 1999/10/10 11:50:38 sharpe Exp $
+ * $Id: file.c,v 1.105 1999/10/11 06:39:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -771,25 +771,57 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset,
}
void
-filter_packets(capture_file *cf)
+filter_packets(capture_file *cf, gchar *dftext)
{
- frame_data *fd;
- guint32 progbar_quantum;
- guint32 progbar_nextstep;
+ dfilter *dfcode;
- if (cf->dfilter == NULL) {
- dfilter_clear_filter(cf->dfcode);
- }
- else {
+ if (dftext == NULL) {
+ /* The new filter is an empty filter (i.e., display all packets). */
+ dfcode = NULL;
+ } else {
/*
- * Compile the filter.
+ * We have a filter; try to compile it.
*/
- if (dfilter_compile(cf->dfcode, cf->dfilter) != 0) {
+ dfcode = dfilter_compile(dftext);
+ if (dfcode == NULL) {
simple_dialog(ESD_TYPE_WARN, NULL, dfilter_error_msg);
return;
}
+
+ /* Was it empty? */
+ if (dfcode->dftree == NULL) {
+ /* Yes - free the filter text and filter code, and set them to
+ NULL. */
+ g_free(dftext);
+ dftext = NULL;
+ dfilter_destroy(dfcode);
+ dfcode = NULL;
+ }
}
+ /* We have a valid filter. Replace the current filter. */
+ if (cf->dfilter != NULL)
+ g_free(cf->dfilter);
+ cf->dfilter = dftext;
+ if (cf->dfcode != NULL)
+ dfilter_destroy(cf->dfcode);
+ cf->dfcode = dfcode;
+
+ /* Now go through the list of packets we've read from the capture file,
+ applying the current display filter, and, if the packet passes the
+ display filter, add it to the summary display, appropriately
+ colored. (That's how we colorize the display - it's like filtering
+ the display, only we don't install a new filter.) */
+ colorize_packets(cf);
+}
+
+void
+colorize_packets(capture_file *cf)
+{
+ frame_data *fd;
+ guint32 progbar_quantum;
+ guint32 progbar_nextstep;
+
gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE);
/* Freeze the packet list while we redo it, so we don't get any