3 * Proto Tree TVBuff cursor
4 * Gilbert Ramirez <gram@alumni.rice.edu>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 2000 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef __PTVCURSOR_H__
28 #define __PTVCURSOR_H__
31 #include <epan/packet.h>
32 #include "ws_symbol_export.h"
34 #define SUBTREE_UNDEFINED_LENGTH -1
36 typedef struct ptvcursor ptvcursor_t
;
38 /* Allocates an initializes a ptvcursor_t with 3 variables:
39 * proto_tree, tvbuff, and offset. */
42 ptvcursor_new(proto_tree
* tree
, tvbuff_t
* tvb
, gint offset
);
44 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
45 * and returns proto_item* */
48 ptvcursor_add(ptvcursor_t
* ptvc
, int hf
, gint length
, const guint encoding
);
51 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
52 * offset, and returns proto_item* */
55 ptvcursor_add_no_advance(ptvcursor_t
* ptvc
, int hf
, gint length
, const guint encoding
);
57 /* Advance the ptvcursor's offset within its tvbuff without
58 * adding anything to the proto_tree. */
61 ptvcursor_advance(ptvcursor_t
* ptvc
, gint length
);
63 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
66 ptvcursor_free(ptvcursor_t
* ptvc
);
71 ptvcursor_tvbuff(ptvcursor_t
* ptvc
);
73 /* Returns current offset. */
76 ptvcursor_current_offset(ptvcursor_t
* ptvc
);
78 /* Returns the proto_tree* */
81 ptvcursor_tree(ptvcursor_t
* ptvc
);
83 /* Sets a new proto_tree* for the ptvcursor_t */
86 ptvcursor_set_tree(ptvcursor_t
* ptvc
, proto_tree
* tree
);
88 /* push a subtree in the tree stack of the cursor */
91 ptvcursor_push_subtree(ptvcursor_t
* ptvc
, proto_item
* it
, gint ett_subtree
);
93 /* pop a subtree in the tree stack of the cursor */
96 ptvcursor_pop_subtree(ptvcursor_t
* ptvc
);
98 /* Add an item to the tree and create a subtree
99 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
100 * In this case, when the subtree will be closed, the parent item length will
101 * be equal to the advancement of the cursor since the creation of the subtree.
105 ptvcursor_add_with_subtree(ptvcursor_t
* ptvc
, int hfindex
, gint length
,
106 const guint encoding
, gint ett_subtree
);
108 /* Add a text node to the tree and create a subtree
109 * If the length is unknown, length may be defined as SUBTREE_UNDEFINED_LENGTH.
110 * In this case, when the subtree will be closed, the item length will be equal
111 * to the advancement of the cursor since the creation of the subtree.
115 ptvcursor_add_text_with_subtree(ptvcursor_t
* ptvc
, gint length
,
116 gint ett_subtree
, const char* format
, ...);
118 /* Creates a subtree and adds it to the cursor as the working tree but does not
119 * save the old working tree */
122 ptvcursor_set_subtree(ptvcursor_t
* ptvc
, proto_item
* it
, gint ett_subtree
);
124 #endif /* __PTVCURSOR_H__ */