From 0ca67aef30d49bf0d68dd375756d22404b6e98bd Mon Sep 17 00:00:00 2001 From: Sebastien Tandel Date: Fri, 30 Mar 2007 00:21:39 +0000 Subject: - new ptvcursor subtrees management functions : * ptvcursor_push_subtree(), ptvcursor_pop_subtree() for pushing/popping subtrees. Multiple levels of subtrees (256 max.), allocation per 8 levels. * Two new functions creating an item in the tree and pushing a subtree at the same time. These two functions accept an undefined length (SUBTREE_UNDEFINED_LENGTH). The length of the item is set at the next pop. 1) ptvcursor_add_with_subtree 2) ptvcursor_add_text_with_subtree - get rid of potential memory leaks with g_new in ptvcursor_new(). - Documentation of the new ptvcursor functions in README.developer svn path=/trunk/; revision=21276 --- epan/ptvcursor.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'epan/ptvcursor.h') diff --git a/epan/ptvcursor.h b/epan/ptvcursor.h index 8c14e4c21c..9080a8b5be 100644 --- a/epan/ptvcursor.h +++ b/epan/ptvcursor.h @@ -34,6 +34,8 @@ #include #include +#define SUBTREE_UNDEFINED_LENGTH -1 + typedef struct ptvcursor ptvcursor_t; /* Allocates an initializes a ptvcursor_t with 3 variables: @@ -77,4 +79,32 @@ ptvcursor_tree(ptvcursor_t* ptvc); void ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree *tree); +/* push a subtree in the tree stack of the cursor */ +proto_tree* +ptvcursor_push_subtree(ptvcursor_t *ptvc, proto_item *it, gint ett_subtree); + +/* pop a subtree in the tree stack of the cursor */ +void ptvcursor_pop_subtree(ptvcursor_t *ptvc); + +/* Add an item to the tree and create a subtree + * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH. + * In this case, when the subtree will be closed, the parent item length will + * be equal to the advancement of the cursor since the creation of the subtree. + */ +proto_tree* ptvcursor_add_with_subtree(ptvcursor_t * ptvc, int hfindex, gint length, +gboolean little_endian, gint ett_subtree); + +/* Add a text node to the tree and create a subtree + * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH. + * In this case, when the subtree will be closed, the item length will be equal + * to the advancement of the cursor since the creation of the subtree. + */ +proto_tree * ptvcursor_add_text_with_subtree(ptvcursor_t * ptvc, gint length, + gint ett_subtree, const char *format, ...); + +/* Creates a subtree and adds it to the cursor as the working tree but does not + * save the old working tree */ +proto_tree* +ptvcursor_set_subtree(ptvcursor_t *ptvc, proto_item *it, gint ett_subtree); + #endif /* __PTVCURSOR_H__ */ -- cgit v1.2.3