3 * Proto Tree TVBuff cursor
4 * Gilbert Ramirez <gram@alumni.rice.edu>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 2000 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __PTVCURSOR_H__
26 #define __PTVCURSOR_H__
29 #include <epan/packet.h>
30 #include "ws_symbol_export.h"
32 #define SUBTREE_UNDEFINED_LENGTH -1
34 typedef struct ptvcursor ptvcursor_t;
36 /* Allocates an initializes a ptvcursor_t with 3 variables:
37 * proto_tree, tvbuff, and offset. */
40 ptvcursor_new(proto_tree* tree, tvbuff_t* tvb, gint offset);
42 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
43 * and returns proto_item* */
46 ptvcursor_add(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
49 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
50 * offset, and returns proto_item* */
53 ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
55 /* Advance the ptvcursor's offset within its tvbuff without
56 * adding anything to the proto_tree. */
59 ptvcursor_advance(ptvcursor_t* ptvc, gint length);
61 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
64 ptvcursor_free(ptvcursor_t* ptvc);
69 ptvcursor_tvbuff(ptvcursor_t* ptvc);
71 /* Returns current offset. */
74 ptvcursor_current_offset(ptvcursor_t* ptvc);
76 /* Returns the proto_tree* */
79 ptvcursor_tree(ptvcursor_t* ptvc);
81 /* Sets a new proto_tree* for the ptvcursor_t */
84 ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
86 /* push a subtree in the tree stack of the cursor */
89 ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
91 /* pop a subtree in the tree stack of the cursor */
94 ptvcursor_pop_subtree(ptvcursor_t* ptvc);
96 /* Add an item to the tree and create a subtree
97 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
98 * In this case, when the subtree will be closed, the parent item length will
99 * be equal to the advancement of the cursor since the creation of the subtree.
103 ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, gint length,
104 const guint encoding, gint ett_subtree);
106 /* Add a text node to the tree and create a subtree
107 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
108 * In this case, when the subtree will be closed, the item length will be equal
109 * to the advancement of the cursor since the creation of the subtree.
113 ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, gint length,
114 gint ett_subtree, const char* format, ...);
116 /* Creates a subtree and adds it to the cursor as the working tree but does not
117 * save the old working tree */
120 ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
122 #endif /* __PTVCURSOR_H__ */