aa6ef4321ec7bdc58296acb88b5d668b046da5cf
[obnox/wireshark/wip.git] / epan / dfilter / dfilter.h
1 /*
2  * $Id: dfilter.h,v 1.4 2002/01/21 07:37:37 guy Exp $
3  *
4  * Ethereal - Network traffic analyzer
5  * By Gerald Combs <gerald@ethereal.com>
6  * Copyright 2001 Gerald Combs
7  * 
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  */
22
23 #ifndef DFILTER_H
24 #define DFILTER_H
25
26 #include <glib.h>
27
28 /* Passed back to user */
29 typedef struct _dfilter_t dfilter_t;
30
31 #include <epan/epan.h>
32 #include <epan/proto.h>
33
34
35 /* Module-level initialization */
36 void
37 dfilter_init(void);
38
39 /* Module-level cleanup */
40 void
41 dfilter_cleanup(void);
42
43 /* Compiles a string to a dfilter_t.
44  * On success, sets the dfilter* pointed to by dfp
45  * to either a NULL pointer (if the filter is a null
46  * filter, as generated by an all-blank string) or to
47  * a pointer to the newly-allocated dfilter_t
48  * structure.
49  *
50  * On failure, dfilter_error_msg points to an
51  * appropriate error message. This error message is
52  * a global string, so another invocation of
53  * dfilter_compile() will clear it. The dfilter*
54  * will be set to NULL after a failure.
55  *
56  * Returns TRUE on success, FALSE on failure.
57  */
58 gboolean
59 dfilter_compile(gchar *text, dfilter_t **dfp);
60
61 /* Frees all memory used by dfilter, and frees
62  * the dfilter itself. */
63 void
64 dfilter_free(dfilter_t *df);
65
66
67 /* dfilter_error_msg is NULL if there was no error during dfilter_compile,
68  * otherwise it points to a displayable error message. */
69 extern gchar *dfilter_error_msg;
70
71 /* Apply compiled dfilter */
72 gboolean
73 dfilter_apply_edt(dfilter_t *df, epan_dissect_t* edt);
74
75 /* Apply compiled dfilter */
76 gboolean
77 dfilter_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree);
78
79 /* Run a callback for each interesting field in the dfilter. */
80 void
81 dfilter_foreach_interesting_field(dfilter_t *df, GFunc func,
82         gpointer user_data);
83
84 /* Print bytecode of dfilter to stdout */
85 void
86 dfilter_dump(dfilter_t *df);
87
88 #endif