Add infrastructure for display filter functions.
[obnox/wireshark/wip.git] / epan / dfilter / dfunctions.h
1 /*
2  * $Id$
3  *
4  * Ethereal - Network traffic analyzer
5  * 
6  * Copyright 2006 Gilbert Ramirez <gram@alumni.rice.edu>
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 DFUNCTIONS_H
24 #define DFUNCTIONS_H
25
26 #include <glib.h>
27 #include <ftypes/ftypes.h>
28 #include "syntax-tree.h"
29
30 /* The run-time logic of the dfilter function */
31 typedef gboolean (*DFFuncType)(GList *arg1list, GList *arg2list, GList **retval);
32
33 /* The semantic check for the dfilter function */
34 typedef void (*DFSemCheckType)(int param_num, stnode_t *st_node);
35
36 /* If a function needs more args than this, increase
37  * this macro and add more arg members to the dfvm_insn_t
38  * struct in dfvm.h, and add some logic to dfw_append_function()
39  * and dfvm_apply() */
40 #define DFUNCTION_MAX_NARGS 2
41
42 /* This is a "function definition" record, holding everything
43  * we need to know about a function */
44 typedef struct {
45     char            *name;
46     DFFuncType      function;
47     ftenum_t        retval_ftype;
48     guint           min_nargs;
49     guint           max_nargs;
50     DFSemCheckType  semcheck_param_function;
51 } df_func_def_t;
52
53 /* Return the function definition record for a function of named "name" */
54 df_func_def_t* df_func_lookup(char *name);
55
56 #endif