summaryrefslogtreecommitdiffstats
path: root/src/vf_internals.h
blob: 98ddacce61134db791f46750ffd56beded0c9208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*******************************************************************************

    (C) Nick Marley, 2001 -

    This software is distributed under the GNU Lesser General Public Licence.
    Please read and understand the comments at the top of vf_iface.h before use!

FILE
    $Workfile: vf_internals.h $
    $Revision: 1.15 $
    $Author: tilda $

ORIGINAL AUTHOR
    Nick Marley

DESCRIPTION
    Definition of the internal representation used for VOBJECTs.

REFERENCES
    (none)

MODIFICATION HISTORY
 *  $Log: vf_internals.h,v $
 *  Revision 1.15  2002/11/02 18:29:26  tilda
 *  IID485157 - UI does character conversion based on CHARSET property.
 *
 *  Revision 1.14  2002/11/02 08:56:17  tilda
 *  Start of internationalisation changes.
 *
 *  Revision 1.13  2002/10/26 16:09:24  tilda
 *  IID629125 - Ensure string functions used are portable.
 *
 *  Revision 1.12  2002/10/08 21:45:07  tilda
 *  IID620473 - reduce c-runtime dependencies.
 *
 *  Revision 1.11  2002/02/24 17:10:34  tilda
 *  Add API for "is modified" functionality.
 *
 *  Revision 1.10  2001/10/24 18:36:06  tilda
 *  BASE64 bugfixes.  Split reader/writer code. Start create/modify work.
 *
 *  Revision 1.9  2001/10/14 19:53:36  tilda
 *  Group handling.  NO group searching functions.
 *
 *  Revision 1.8  2001/10/14 16:40:04  tilda
 *  Initial testing of access functions.
 *
 *  Revision 1.7  2001/10/13 16:22:08  tilda
 *  Introduce VBINDATA_T and VOBJDATA_T to tidy up internals.
 *
 *  Revision 1.6  2001/10/13 14:58:56  tilda
 *  Tidy up version headers, add vf_strings.h where needed.
 *
 *  Revision 1.5  2001/10/13 14:49:30  tilda
 *  Add string array code to unify handling of names / values.
 *  
 *  Revision 1.4  2001/10/12 16:20:03  tilda
 *  Correctly parse compound quoted printable properties.
 *  
 *  Revision 1.3  2001/10/10 20:53:56  tilda
 *  Various minor tidy ups.
 *  
 *  Revision 1.2  2001/10/09 22:01:59  tilda
 *  Remove older version control comments.
 * 
 *******************************************************************************/

#ifndef _VF_INTERNALS_H_
#define _VF_INTERNALS_H_

#ifndef NORCSID
static const char vf_internals_h_vss_id[] = "$Header: /cvsroot/vformat/src/vformat/src/vf_internals.h,v 1.15 2002/11/02 18:29:26 tilda Exp $";
#endif

/*=============================================================================*
 Public Includes
 *============================================================================*/
/* None */

/*=============================================================================*
 Public Defines
 *============================================================================*/

#define VFP_BEGIN       "BEGIN"
#define VFP_END         "END"

/*=============================================================================*
 Public Types
 *============================================================================*/


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VSTRARRAY_T encapsulates an array of strings.
 *----------------------------------------------------------------------------*/

typedef struct VSTRARRAY_T
{
    uint32_t            n_strings;          /* Then number of strings */
    char                **pp_strings;       /* The strings */
}
VSTRARRAY_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VBINDATA_T encapsulates a chunk of binary data.  Yes, you could encode
 *      any and all vformat attributes in BASE64 but custom is to use BASE64
 *      for images etc.
 *----------------------------------------------------------------------------*/

typedef struct VBINDATA_T
{
    char                *p_buffer;          /* Binary data */
    uint32_t            n_bufsize;
}
VBINDATA_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VOBJDATA_T 
 *----------------------------------------------------------------------------*/

typedef struct VOBJDATA_T
{
    struct VOBJECT_T    *p_object;          /* Another vformat object */
}
VOBJDATA_T;



/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VPROPVALUE_T encapsulates the "value" half of a property.
 *----------------------------------------------------------------------------*/

typedef struct VPROPVALUE_T
{
    vf_encoding_t   encoding;

    struct
    {
        VSTRARRAY_T s;
        VBINDATA_T  b;
        VOBJDATA_T  o;
    }
    v;
}
VPROPVALUE_T;



/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VPROP_T defines a single property.  It's an association of a name
 *      and value pair.  A vformat object is simply a list of properties.
 *      Associated with a property is (possibly) a group name.
 *----------------------------------------------------------------------------*/

typedef struct VPROP_T
{
    char                *p_group;       /* Group - we keep the A.B.C format */
    VSTRARRAY_T         name;           /* Name fields */
    VPROPVALUE_T        value;          /* Value fields */

    struct VPROP_T      *p_next;        /* Next property */
    struct VPROP_T      *p_next_srch;   /* Next in current search */

    bool_t              modified;       /* Property modified? */

    struct VOBJECT_T    *p_parent;      /* Owning object (if any) */
}
VPROP_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      VOBJECT_T defines a single vformat object.
 *----------------------------------------------------------------------------*/

typedef struct VOBJECT_T
{
    char                *p_type;        /* "VCARD" or "VCALENDAR" etc. */
    VPROP_T             *p_props;       /* List of properties */

    bool_t              modified;       /* Object modified? */

    struct VOBJECT_T    *p_parent;      /* Owning object (if any) */
    struct VOBJECT_T    *p_next;        /* Next object (if any) */
}
VOBJECT_T;


/*=============================================================================*
 Public Functions
 *============================================================================*/


/*---------------------------------------------------------------------------*
 * NAME
 *      delete_prop_contents()
 * 
 * DESCRIPTION
 *      Cleans up the memory used by the value associated with the property.
 *      The property is not deleted => can be a statically allocated variable.
 *
 * RETURNS
 *      (none)
 *---------------------------------------------------------------------------*/

extern void delete_prop_contents(
    VF_PROP_T *p_vprop,         /* The VF_PROP_T to clean */
    bool_t delname              /* Delete the name as well? */
    );


/*=============================================================================*
 End of file
 *============================================================================*/

#endif /*_VF_INTERNALS_H_*/