Re-apply r40728 and fix Coverity CID 1371 UNINIT again.
[obnox/wireshark/wip.git] / epan / tvbuff-int.h
1 /* tvbuff-int.h
2  *
3  * Structures that most TVB users should not be accessing directly.
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __TVBUFF_INT_H__
27 #define __TVBUFF_INT_H__
28
29 typedef struct {
30         /** The backing tvbuff_t */
31         struct tvbuff   *tvb;
32
33         /** The offset of 'tvb' to which I'm privy */
34         guint           offset;
35         /** The length of 'tvb' to which I'm privy */
36         guint           length;
37
38 } tvb_backing_t;
39
40 typedef struct {
41         GSList          *tvbs;
42
43         /* Used for quick testing to see if this
44          * is the tvbuff that a COMPOSITE is
45          * interested in. */
46         guint           *start_offsets;
47         guint           *end_offsets;
48
49 } tvb_comp_t;
50
51 struct tvbuff {
52         /* Doubly linked list pointers */
53         tvbuff_t                *next;
54         tvbuff_t                *previous;
55
56         /* Record-keeping */
57         tvbuff_type             type;
58         gboolean                initialized;
59         struct tvbuff           *ds_tvb;  /**< data source top-level tvbuff */
60
61         /** TVBUFF_SUBSET and TVBUFF_COMPOSITE keep track
62          * of the other tvbuff's they use */
63         union {
64                 tvb_backing_t   subset;
65                 tvb_comp_t      composite;
66         } tvbuffs;
67
68         /** We're either a TVBUFF_REAL_DATA or a
69          * TVBUFF_SUBSET that has a backing buffer that
70          * has real_data != NULL, or a TVBUFF_COMPOSITE
71          * which has flattened its data due to a call
72          * to tvb_get_ptr().
73          */
74         const guint8            *real_data;
75
76         /** Length of virtual buffer (and/or real_data). */
77         guint                   length;
78
79         /** Reported length. */
80         guint                   reported_length;
81
82         /* Offset from beginning of first TVBUFF_REAL. */
83         gint                    raw_offset;
84
85         /** Func to call when actually freed */
86         tvbuff_free_cb_t        free_cb;
87 };
88
89 #endif