From e00d6a24cbe2a1c3b89de362af7a8b7d1902d57c Mon Sep 17 00:00:00 2001 From: siboud Date: Fri, 1 Apr 2005 20:40:20 +0000 Subject: [PATCH] filter tree: - finally found my bug -- joy oh joy ! - added prototypes for structures,enum and union of filter.h git-svn-id: http://ltt.polymtl.ca/svn@911 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/filter.c | 14 ++++---- ltt/branches/poly/lttv/lttv/filter.h | 52 ++++++++++++++++++---------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index 85939858..f7d2c613 100644 --- a/ltt/branches/poly/lttv/lttv/filter.c +++ b/ltt/branches/poly/lttv/lttv/filter.c @@ -102,7 +102,7 @@ lttv_filter_tree_add_node(GPtrArray* stack, LttvFilterTree* subtree, LttvLogical t2->node = op; if(subtree != NULL) { t2->left = LTTV_TREE_NODE; - t2->l_child.t = (LttvFilterTree*)subtree; + t2->l_child.t = subtree; subtree = NULL; t1->right = LTTV_TREE_NODE; t1->r_child.t = t2; @@ -133,7 +133,7 @@ lttv_simple_expression_new() { se->field = LTTV_FILTER_UNDEFINED; se->op = NULL; se->offset = 0; - se->value.v_uint64 = NULL; + se->value.v_uint64 = 0; return se; } @@ -1074,7 +1074,7 @@ lttv_filter_update(LttvFilter* filter) { case '|': /* or */ - t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1); + t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); while(t1->right != LTTV_TREE_IDLE) { g_assert(t1->right == LTTV_TREE_NODE); t1 = t1->r_child.t; @@ -1101,7 +1101,7 @@ lttv_filter_update(LttvFilter* filter) { case '^': /* xor */ - t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1); + t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); while(t1->right != LTTV_TREE_IDLE) { g_assert(t1->right == LTTV_TREE_NODE); t1 = t1->r_child.t; @@ -1135,7 +1135,7 @@ lttv_filter_update(LttvFilter* filter) { lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_NE); i++; } else { /* ! */ - t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1); + t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1); while(t1->right != LTTV_TREE_IDLE) { g_assert(t1->right == LTTV_TREE_NODE); t1 = t1->r_child.t; @@ -1346,7 +1346,7 @@ LttvFilterTree* lttv_filter_tree_new() { LttvFilterTree* tree; - tree = g_new(LttvFilter,1); + tree = g_new(LttvFilterTree,1); tree->node = 0; //g_new(lttv_expression,1); tree->left = LTTV_TREE_IDLE; tree->right = LTTV_TREE_IDLE; @@ -1414,7 +1414,7 @@ lttv_filter_tree_destroy(LttvFilterTree* tree) { if(tree->right == LTTV_TREE_LEAF) lttv_simple_expression_destroy(tree->r_child.leaf); else if(tree->right == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->r_child.t); - g_free(tree->node); +// g_free(tree->node); g_free(tree); } diff --git a/ltt/branches/poly/lttv/lttv/filter.h b/ltt/branches/poly/lttv/lttv/filter.h index 827974cc..7abfb216 100644 --- a/ltt/branches/poly/lttv/lttv/filter.h +++ b/ltt/branches/poly/lttv/lttv/filter.h @@ -51,6 +51,20 @@ value = integer | double | string */ +/* structures prototypes */ +typedef enum _LttvStructType LttvStructType; +typedef enum _LttvFieldType LttvFieldType; +typedef enum _LttvExpressionOp LttvExpressionOp; +typedef enum _LttvTreeElement LttvTreeElement; +typedef enum _LttvLogicalOp LttvLogicalOp; + +typedef union _LttvFieldValue LttvFieldValue; + +typedef struct _LttvSimpleExpression LttvSimpleExpression; +typedef struct _LttvFilterTree LttvFilterTree; +typedef struct _LttvFilter LttvFilter; + + /** * @enum LttvStructType * @brief The lttv structures @@ -65,7 +79,7 @@ enum _LttvStructType { LTTV_FILTER_TRACEFILE, LTTV_FILTER_EVENT, LTTV_FILTER_STATE -} LttvStructType; +}; /** * @enum LttvFieldType @@ -94,7 +108,7 @@ enum _LttvFieldType { LTTV_FILTER_EVENT_TSC, /** event.tsc (double) */ LTTV_FILTER_EVENT_FIELD, LTTV_FILTER_UNDEFINED /** undefined field */ -} LttvFieldType; +}; /** * @enum LttvExpressionOp @@ -105,7 +119,7 @@ enum _LttvFieldType { * right and left member in simple * expression */ -typedef enum _LttvExpressionOp +enum _LttvExpressionOp { LTTV_FIELD_EQ, /** equal */ LTTV_FIELD_NE, /** not equal */ @@ -113,7 +127,7 @@ typedef enum _LttvExpressionOp LTTV_FIELD_LE, /** lower or equal */ LTTV_FIELD_GT, /** greater than */ LTTV_FIELD_GE /** greater or equal */ -} LttvExpressionOp; +}; /** * @union LttvFieldValue @@ -125,13 +139,13 @@ typedef enum _LttvExpressionOp * It is used for comparison whithin the * 'operators' functions */ -typedef union _LttvFieldValue { +union _LttvFieldValue { guint64 v_uint64; guint32 v_uint32; guint16 v_uint16; double v_double; char* v_string; -} LttvFieldValue; +}; /** * @enum LttvTreeElement @@ -140,15 +154,15 @@ typedef union _LttvFieldValue { * LttvTreeElement defines the possible * types of nodes which build the LttvFilterTree. */ -typedef enum _LttvTreeElement { +enum _LttvTreeElement { LTTV_TREE_IDLE, /** this node does nothing */ LTTV_TREE_NODE, /** this node contains a logical operator */ LTTV_TREE_LEAF /** this node is a leaf and contains a simple expression */ -} LttvTreeElement; +}; /** - * @enum LttvSimpleExpression + * @struct LttvSimpleExpression * @brief simple expression structure * * An LttvSimpleExpression is the base @@ -159,14 +173,14 @@ typedef enum _LttvTreeElement { * field, an operator and a specific * value. */ -typedef struct _LttvSimpleExpression +struct _LttvSimpleExpression { gint field; /** left member of simple expression */ gint offset; /** offset used for dynamic fields */ gboolean (*op)(gpointer,LttvFieldValue); /** operator of simple expression */ // char *value; LttvFieldValue value; /** right member of simple expression */ -} LttvSimpleExpression; +}; /** * @enum LttvLogicalOp @@ -177,12 +191,12 @@ typedef struct _LttvSimpleExpression * simple expression. Values are * AND, OR, XOR or NOT */ -typedef enum _LttvLogicalOp { +enum _LttvLogicalOp { LTTV_LOGICAL_OR = 1, /** OR (1) */ LTTV_LOGICAL_AND = 1<<1, /** AND (2) */ LTTV_LOGICAL_NOT = 1<<2, /** NOT (4) */ LTTV_LOGICAL_XOR = 1<<3 /** XOR (8) */ -} LttvLogicalOp; +}; /** * @struct LttvFilterTree @@ -191,29 +205,29 @@ typedef enum _LttvLogicalOp { * composed of simple expressions and logical * operators */ -typedef struct _LttvFilterTree { +struct _LttvFilterTree { int node; /** value of LttvLogicalOp */ LttvTreeElement left; LttvTreeElement right; union { - struct LttvFilterTree* t; + LttvFilterTree* t; LttvSimpleExpression* leaf; } l_child; union { - struct LttvFilterTree* t; + LttvFilterTree* t; LttvSimpleExpression* leaf; } r_child; -} LttvFilterTree; +}; /** * @struct lttv_filter * Contains a binary tree of filtering options along * with the expression itself. */ -typedef struct _LttvFilter { +struct _LttvFilter { char *expression; LttvFilterTree *head; -} LttvFilter; +}; /* * General Data Handling functions -- 2.34.1