Set "v120len" regardless of whether "tree" is null or not; we use it
[obnox/wireshark/wip.git] / dfilter.h
1 /* dfilter.h
2  * Definitions for display filters
3  *
4  * $Id: dfilter.h,v 1.14 1999/10/12 05:00:47 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __DFILTER_H__
27 #define __DFILTER_H__
28
29 /* dfilter_error_msg is NULL if there was no error during dfilter_compile,
30  * otherwise it points to a displayable error message. */
31 extern gchar *dfilter_error_msg;
32 extern gchar dfilter_error_msg_buf[1024];
33
34 typedef struct {
35
36         GNode *dftree;
37
38         /* space for dfilter_nodes */
39         GMemChunk *node_memchunk;
40
41         /* list of byte arrays we allocate during parse. We can traverse this list
42          * faster than the tree when we go back and free the byte arrays */
43         GSList *list_of_byte_arrays;
44 } dfilter;
45
46 /* Initialization of the symbol table. Called once during program startup */
47 void dfilter_init(void);
48
49 /* Free the memory used by the symbol table. Called at program shutdown */
50 void dfilter_cleanup(void);
51
52 /* Allocate and initialize new dfilter struct. Returns pointer to new dfilter */
53 dfilter* dfilter_new(void);
54
55 /* Frees all memory used by dfilter, and frees dfilter itself */
56 void dfilter_destroy(dfilter *df);
57
58 /* Compile display filter text */
59 int dfilter_compile(gchar* dfilter_text, dfilter** dfp);
60
61 /* Apply compiled dfilter to a proto_tree */
62 gboolean dfilter_apply(dfilter *df, proto_tree *ptree, const guint8* pd);
63
64 #endif /* ! __DFILTER_H__ */