diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-02-01 20:21:25 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-02-01 20:21:25 +0000 |
commit | 8f1fff2e6a5c114c6beafd2983afb55acd3d66ae (patch) | |
tree | e33c08662c708dcfe71591897fe6ffab53bce135 /epan/dfilter/syntax-tree.h | |
parent | 07a925ef8b0568a2c5b8098d5734364a40eeb2f6 (diff) |
Create a more modular type system for the FT_* types. Put them
into epan/ftypes.
Re-write display filter routines using Lemon parser instead of yacc.
Besides using a different tool, the new grammar is much simpler, while
the display filter engine itself is more powerful and more easily extended.
Add dftest executable, to test display filter "bytecode" generation.
Add option to "configure" to build dftest or randpkt, both of which are not
built by default.
Implement Ed Warnicke's ideas about dranges in the new display filter and
ftype code.
Remove type FT_TEXT_ONLY in favor of FT_NONE, and have protocols registered
as FT_PROTOCOL. Thus, FT_NONE is used only for simple labels in the proto tree,
while FT_PROTOCOL is used for protocols. This was necessary for being
able to make byte slices (ranges) out of protocols, like "frame[0:3]"
Win32 Makefile.nmake's will be added tonight.
svn path=/trunk/; revision=2967
Diffstat (limited to 'epan/dfilter/syntax-tree.h')
-rw-r--r-- | epan/dfilter/syntax-tree.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/epan/dfilter/syntax-tree.h b/epan/dfilter/syntax-tree.h new file mode 100644 index 0000000000..3f60c09f1a --- /dev/null +++ b/epan/dfilter/syntax-tree.h @@ -0,0 +1,95 @@ +/* syntax-tree.h + * + * $Id: syntax-tree.h,v 1.1 2001/02/01 20:21:18 gram Exp $ + * + */ +#ifndef SYNTAX_TREE_H +#define SYNTAX_TREE_H + +#include <glib.h> +#include "cppmagic.h" + +typedef enum { + STTYPE_UNINITIALIZED, + STTYPE_TEST, + STTYPE_STRING, + STTYPE_FIELD, + STTYPE_FVALUE, + STTYPE_RANGE, + STTYPE_NUM_TYPES +} sttype_id_t; + +typedef gpointer (*STTypeNewFunc)(gpointer); +typedef void (*STTypeFreeFunc)(gpointer); + + +/* Type information */ +typedef struct { + sttype_id_t id; + const char *name; + STTypeNewFunc func_new; + STTypeFreeFunc func_free; +} sttype_t; + +/* Node (type instance) information */ +typedef struct { + guint32 magic; + sttype_t *type; + gpointer data; + +} stnode_t; + +void +sttype_init(void); + +void +sttype_cleanup(void); + +void +sttype_register(sttype_t *type); + +stnode_t* +stnode_new(sttype_id_t type_id, gpointer data); + +void +stnode_init(stnode_t *node, sttype_id_t type_id, gpointer data); + +void +stnode_free(stnode_t *node); + +const char* +stnode_type_name(stnode_t *node); + +sttype_id_t +stnode_type_id(stnode_t *node); + +gpointer +stnode_data(stnode_t *node); + +#define assert_magic(obj, mnum) \ + g_assert((obj)); \ + if ((obj)->magic != (mnum)) { \ + g_print("\nMagic num is 0x%08x, but should be 0x%08x", \ + (obj)->magic, (mnum)); \ + g_assert((obj)->magic == (mnum)); \ + } + + + + +#define STTYPE_ACCESSOR(ret,type,attr,magicnum) \ + ret \ + CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node) \ +{\ + CONCAT(type,_t) *value; \ + value = stnode_data(node);\ + assert_magic(value, magicnum); \ + return value->attr; \ +} + +#define STTYPE_ACCESSOR_PROTOTYPE(ret,type,attr) \ + ret \ + CONCAT(CONCAT(CONCAT(sttype_,type),_),attr) (stnode_t *node); + + +#endif |