aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-10-12 05:01:07 +0000
committerGuy Harris <guy@alum.mit.edu>1999-10-12 05:01:07 +0000
commitf3da72ef2fd7486be06c6bb69418d4416fdaf3e6 (patch)
tree745d48db7c24775225b32326c4721af356973484 /file.c
parent1efcb7b2cfc60043e672d5cc4c78aabbe50f5416 (diff)
Have "dfilter_compile()" return 0 on success and 1 on failure, and
return the pointer to the compiled filter through a pointer argument. Have it check whether the filter is a null filter and, if so, free up the filter and supply a filter pointer, rather than obliging its callers to check whether the filter actually has any code. (Well, they may want to check if the filter is null, so that they don't save a pointer to the filter text, e.g. so that the display filter displays as "none" rather than as a blank string in the summary box.) In the process, fix the check in "gtk/file_dlg.c" that tests whether the read filter compiled successfully. svn path=/trunk/; revision=812
Diffstat (limited to 'file.c')
-rw-r--r--file.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/file.c b/file.c
index 1b7abe7e2a..1d58ff96ff 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.107 1999/10/12 04:21:11 gram Exp $
+ * $Id: file.c,v 1.108 1999/10/12 05:00:47 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -622,11 +622,11 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
}
/* Apply the filters */
- if (DFILTER_CONTAINS_FILTER(cf->dfcode) ||
+ if (cf->dfcode != NULL ||
CFILTERS_CONTAINS_FILTER(cf)) {
protocol_tree = proto_tree_create_root();
dissect_packet(buf, fdata, protocol_tree);
- if( DFILTER_CONTAINS_FILTER(cf->dfcode) )
+ if (cf->dfcode != NULL)
fdata->passed_dfilter = dfilter_apply(cf->dfcode, protocol_tree, cf->pd);
else
fdata->passed_dfilter = TRUE;
@@ -749,12 +749,10 @@ wtap_dispatch_cb(u_char *user, const struct wtap_pkthdr *phdr, int offset,
passed = TRUE;
if (cf->rfcode) {
- if (DFILTER_CONTAINS_FILTER(cf->rfcode)) {
- protocol_tree = proto_tree_create_root();
- dissect_packet(buf, fdata, protocol_tree);
- passed = dfilter_apply(cf->rfcode, protocol_tree, cf->pd);
- proto_tree_free(protocol_tree);
- }
+ protocol_tree = proto_tree_create_root();
+ dissect_packet(buf, fdata, protocol_tree);
+ passed = dfilter_apply(cf->rfcode, protocol_tree, cf->pd);
+ proto_tree_free(protocol_tree);
}
if (passed) {
plist_end = cf->plist_end;
@@ -782,20 +780,17 @@ filter_packets(capture_file *cf, gchar *dftext)
/*
* We have a filter; try to compile it.
*/
- dfcode = dfilter_compile(dftext);
- if (dfcode == NULL) {
+ if (dfilter_compile(dftext, &dfcode) != 0) {
+ /* The attempt failed; report an error. */
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. */
+ if (dfcode == NULL) {
+ /* Yes - free the filter text, and set it to null. */
g_free(dftext);
dftext = NULL;
- dfilter_destroy(dfcode);
- dfcode = NULL;
}
}