rerun pidl
[metze/wireshark/wip.git] / epan / ptvcursor.h
1 /* ptvcursor.h
2  *
3  * Proto Tree TVBuff cursor
4  * Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 2000 Gerald Combs
11  *
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.
16  *
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.
21  *
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.
25  */
26
27 #ifndef __PTVCURSOR_H__
28 #define __PTVCURSOR_H__
29
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include "ws_symbol_export.h"
33
34 #define SUBTREE_UNDEFINED_LENGTH -1
35
36 typedef struct ptvcursor ptvcursor_t;
37
38 /* Allocates an initializes a ptvcursor_t with 3 variables:
39  * proto_tree, tvbuff, and offset. */
40 WS_DLL_PUBLIC
41 ptvcursor_t*
42 ptvcursor_new(proto_tree* tree, tvbuff_t* tvb, gint offset);
43
44 /* Gets data from tvbuff, adds it to proto_tree, increments offset,
45  * and returns proto_item* */
46 WS_DLL_PUBLIC
47 proto_item*
48 ptvcursor_add(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
49
50
51 /* Gets data from tvbuff, adds it to proto_tree, *DOES NOT* increment
52  * offset, and returns proto_item* */
53 WS_DLL_PUBLIC
54 proto_item*
55 ptvcursor_add_no_advance(ptvcursor_t* ptvc, int hf, gint length, const guint encoding);
56
57 /* Advance the ptvcursor's offset within its tvbuff without
58  * adding anything to the proto_tree. */
59 WS_DLL_PUBLIC
60 void
61 ptvcursor_advance(ptvcursor_t* ptvc, gint length);
62
63 /* Frees memory for ptvcursor_t, but nothing deeper than that. */
64 WS_DLL_PUBLIC
65 void
66 ptvcursor_free(ptvcursor_t* ptvc);
67
68 /* Returns tvbuff. */
69 WS_DLL_PUBLIC
70 tvbuff_t*
71 ptvcursor_tvbuff(ptvcursor_t* ptvc);
72
73 /* Returns current offset. */
74 WS_DLL_PUBLIC
75 gint
76 ptvcursor_current_offset(ptvcursor_t* ptvc);
77
78 /* Returns the proto_tree* */
79 WS_DLL_PUBLIC
80 proto_tree*
81 ptvcursor_tree(ptvcursor_t* ptvc);
82
83 /* Sets a new proto_tree* for the ptvcursor_t */
84 WS_DLL_PUBLIC
85 void
86 ptvcursor_set_tree(ptvcursor_t* ptvc, proto_tree* tree);
87
88 /* push a subtree in the tree stack of the cursor */
89 WS_DLL_PUBLIC
90 proto_tree*
91 ptvcursor_push_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
92
93 /* pop a subtree in the tree stack of the cursor */
94 WS_DLL_PUBLIC
95 void
96 ptvcursor_pop_subtree(ptvcursor_t* ptvc);
97
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.
102  */
103 WS_DLL_PUBLIC
104 proto_tree*
105 ptvcursor_add_with_subtree(ptvcursor_t* ptvc, int hfindex, gint length,
106     const guint encoding, gint ett_subtree);
107
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.
112  */
113 WS_DLL_PUBLIC
114 proto_tree*
115 ptvcursor_add_text_with_subtree(ptvcursor_t* ptvc, gint length,
116     gint ett_subtree, const char* format, ...);
117
118 /* Creates a subtree and adds it to the cursor as the working tree but does not
119  * save the old working tree */
120 WS_DLL_PUBLIC
121 proto_tree*
122 ptvcursor_set_subtree(ptvcursor_t* ptvc, proto_item* it, gint ett_subtree);
123
124 #endif /* __PTVCURSOR_H__ */