2 * Copyright (C) 2003 Ximian, Inc. 2005 Armin Bauer
4 * Copyright (C) 2003 Ximian, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * Author: Chris Toshok (toshok@ximian.com)
21 * Author: Armin Bauer (armin.bauer@opensync.org)
47 typedef struct b_VFormat
{
55 VF_ENCODING_RAW
, /* no encoding */
56 VF_ENCODING_BASE64
, /* base64 */
57 VF_ENCODING_QP
, /* quoted-printable */
61 typedef struct b_VFormatAttribute
{
62 char *block
; /* "vtimezone/standard", or "vevent", depending on
63 current begin/end location... may be null */
66 GList
*params
; /* b_VFormatParam */
68 GList
*decoded_values
;
69 b_VFormatEncoding encoding
;
70 gboolean encoding_set
;
73 typedef struct b_VFormatParam
{
75 GList
*values
; /* GList of char*'s*/
79 /*b_VFormat *vcard_new(b_VFormatType type);
80 b_VFormat *vcard_new_from_string (const char *str, b_VFormatType type);
81 //char *vcard_to_string(VFormat *card, VFormatType format);
83 VFormat *vnote_new(void);
84 VFormat *vnote_new_from_string(const char *str);
85 //char *vnote_to_string(VFormat *note);
88 VFormat *vevent_new(void);
89 VFormat *vevent_new_from_string(const char *str);
90 //char *vevent_to_string(VFormat *event);
92 VFormat *vtodo_new(void);
93 VFormat *vtodo_new_from_string(const char *str);*/
94 //char *vtodo_to_string(VFormat *todo);
96 /* mostly for debugging */
97 b_VFormat
*b_vformat_new(void);
98 b_VFormat
*b_vformat_new_from_string(const char *str
);
99 void b_vformat_dump_structure(b_VFormat
*format
);
100 char *b_vformat_to_string(b_VFormat
*evc
, b_VFormatType type
);
101 time_t b_vformat_time_to_unix(const char *inptime
);
102 void b_vformat_free(b_VFormat
*format
);
105 b_VFormatAttribute
*b_vformat_attribute_new (const char *attr_group
, const char *attr_name
);
106 void b_vformat_attribute_free (b_VFormatAttribute
*attr
);
107 b_VFormatAttribute
*b_vformat_attribute_copy (b_VFormatAttribute
*attr
);
108 void b_vformat_remove_attributes (b_VFormat
*vformat
, const char *attr_group
, const char *attr_name
);
109 void b_vformat_remove_attribute (b_VFormat
*vformat
, b_VFormatAttribute
*attr
);
110 void b_vformat_add_attribute (b_VFormat
*vformat
, b_VFormatAttribute
*attr
);
111 void b_vformat_add_attribute_with_value (b_VFormat
*vformat
, b_VFormatAttribute
*attr
, const char *value
);
112 void b_vformat_add_attribute_with_values (b_VFormat
*vformat
, b_VFormatAttribute
*attr
, ...);
113 void b_vformat_attribute_add_value (b_VFormatAttribute
*attr
, const char *value
);
114 void b_vformat_attribute_set_value (b_VFormatAttribute
*attr
, int nth
, const char *value
);
115 void b_vformat_attribute_add_value_decoded (b_VFormatAttribute
*attr
, const char *value
, int len
);
116 void b_vformat_attribute_add_values (b_VFormatAttribute
*attr
, ...);
117 void b_vformat_attribute_remove_values (b_VFormatAttribute
*attr
);
118 void b_vformat_attribute_remove_params (b_VFormatAttribute
*attr
);
119 b_VFormatAttribute
*b_vformat_find_attribute (b_VFormat
*evc
, const char *name
, int nth
, const char *block
);
121 /* attribute parameters */
122 b_VFormatParam
* b_vformat_attribute_param_new (const char *param_name
);
123 void b_vformat_attribute_param_free (b_VFormatParam
*param
);
124 b_VFormatParam
* b_vformat_attribute_param_copy (b_VFormatParam
*param
);
125 void b_vformat_attribute_add_param (b_VFormatAttribute
*attr
, b_VFormatParam
*param
);
126 b_VFormatParam
*b_vformat_attribute_find_param(b_VFormatAttribute
*attr
, const char *name
, int level
);
127 void b_vformat_attribute_add_param_with_value (b_VFormatAttribute
*attr
, const char *name
, const char *value
);
128 void b_vformat_attribute_add_param_with_values (b_VFormatAttribute
*attr
,
129 b_VFormatParam
*param
, ...);
131 void b_vformat_attribute_param_add_value (b_VFormatParam
*param
,
133 void b_vformat_attribute_param_add_values (b_VFormatParam
*param
,
135 void b_vformat_attribute_param_remove_values (b_VFormatParam
*param
);
136 gboolean
b_vformat_attribute_has_param(b_VFormatAttribute
*attr
, const char *name
);
138 /* b_VFormat* accessors. nothing returned from these functions should be
139 freed by the caller. */
140 GList
* b_vformat_get_attributes (b_VFormat
*vformat
);
141 const char* b_vformat_attribute_get_group (b_VFormatAttribute
*attr
);
142 const char* b_vformat_attribute_get_name (b_VFormatAttribute
*attr
);
143 const char* b_vformat_attribute_get_block (b_VFormatAttribute
*attr
);
144 GList
* b_vformat_attribute_get_values (b_VFormatAttribute
*attr
); /* GList elements are of type char* */
145 GList
* b_vformat_attribute_get_values_decoded (b_VFormatAttribute
*attr
); /* GList elements are of type GString* */
146 const char *b_vformat_attribute_get_nth_value(b_VFormatAttribute
*attr
, int nth
);
148 /* special accessors for single valued attributes */
149 gboolean
b_vformat_attribute_is_single_valued (b_VFormatAttribute
*attr
);
150 char* b_vformat_attribute_get_value (b_VFormatAttribute
*attr
);
151 GString
* b_vformat_attribute_get_value_decoded (b_VFormatAttribute
*attr
);
153 GList
* b_vformat_attribute_get_params (b_VFormatAttribute
*attr
);
154 const char* b_vformat_attribute_param_get_name (b_VFormatParam
*param
);
155 GList
* b_vformat_attribute_param_get_values (b_VFormatParam
*param
);
156 const char *b_vformat_attribute_param_get_nth_value(b_VFormatParam
*param
, int nth
);
158 /* special TYPE= parameter predicate (checks for TYPE=@typestr */
159 gboolean
b_vformat_attribute_has_type (b_VFormatAttribute
*attr
, const char *typestr
);
161 /* Utility functions. */
162 char* b_vformat_escape_string (const char *str
, b_VFormatType type
);
163 char* b_vformat_unescape_string (const char *str
);
169 #endif /* _VFORMAT_H */