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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Author: Chris Toshok (toshok@ximian.com)
21 * Author: Armin Bauer (armin.bauer@opensync.org)
45 typedef struct VFormat
{
53 VF_ENCODING_RAW
, /* no encoding */
54 VF_ENCODING_BASE64
, /* base64 */
55 VF_ENCODING_QP
, /* quoted-printable */
59 typedef struct VFormatAttribute
{
60 char *block
; /* "vtimezone/standard", or "vevent", depending on
61 current begin/end location... may be null */
64 GList
*params
; /* VFormatParam */
66 GList
*decoded_values
;
67 VFormatEncoding encoding
;
68 gboolean encoding_set
;
71 typedef struct VFormatParam
{
73 GList
*values
; /* GList of char*'s*/
77 /*VFormat *vcard_new(VFormatType type);
78 VFormat *vcard_new_from_string (const char *str, VFormatType type);
79 //char *vcard_to_string(VFormat *card, VFormatType format);
81 VFormat *vnote_new(void);
82 VFormat *vnote_new_from_string(const char *str);
83 //char *vnote_to_string(VFormat *note);
86 VFormat *vevent_new(void);
87 VFormat *vevent_new_from_string(const char *str);
88 //char *vevent_to_string(VFormat *event);
90 VFormat *vtodo_new(void);
91 VFormat *vtodo_new_from_string(const char *str);*/
92 //char *vtodo_to_string(VFormat *todo);
94 /* mostly for debugging */
95 VFormat
*vformat_new(void);
96 VFormat
*vformat_new_from_string(const char *str
);
97 void vformat_dump_structure(VFormat
*format
);
98 char *vformat_to_string(VFormat
*evc
, VFormatType type
);
99 time_t vformat_time_to_unix(const char *inptime
);
100 void vformat_free(VFormat
*format
);
103 VFormatAttribute
*vformat_attribute_new (const char *attr_group
, const char *attr_name
);
104 void vformat_attribute_free (VFormatAttribute
*attr
);
105 VFormatAttribute
*vformat_attribute_copy (VFormatAttribute
*attr
);
106 void vformat_remove_attributes (VFormat
*vformat
, const char *attr_group
, const char *attr_name
);
107 void vformat_remove_attribute (VFormat
*vformat
, VFormatAttribute
*attr
);
108 void vformat_add_attribute (VFormat
*vformat
, VFormatAttribute
*attr
);
109 void vformat_add_attribute_with_value (VFormat
*vformat
, VFormatAttribute
*attr
, const char *value
);
110 void vformat_add_attribute_with_values (VFormat
*vformat
, VFormatAttribute
*attr
, ...);
111 void vformat_attribute_add_value (VFormatAttribute
*attr
, const char *value
);
112 void vformat_attribute_set_value (VFormatAttribute
*attr
, int nth
, const char *value
);
113 void vformat_attribute_add_value_decoded (VFormatAttribute
*attr
, const char *value
, int len
);
114 void vformat_attribute_add_values (VFormatAttribute
*attr
, ...);
115 void vformat_attribute_remove_values (VFormatAttribute
*attr
);
116 void vformat_attribute_remove_params (VFormatAttribute
*attr
);
117 VFormatAttribute
*vformat_find_attribute (VFormat
*evc
, const char *name
, int nth
, const char *block
);
119 /* attribute parameters */
120 VFormatParam
* vformat_attribute_param_new (const char *param_name
);
121 void vformat_attribute_param_free (VFormatParam
*param
);
122 VFormatParam
* vformat_attribute_param_copy (VFormatParam
*param
);
123 void vformat_attribute_add_param (VFormatAttribute
*attr
, VFormatParam
*param
);
124 VFormatParam
*vformat_attribute_find_param(VFormatAttribute
*attr
, const char *name
);
125 void vformat_attribute_add_param_with_value (VFormatAttribute
*attr
, const char *name
, const char *value
);
126 void vformat_attribute_add_param_with_values (VFormatAttribute
*attr
,
127 VFormatParam
*param
, ...);
129 void vformat_attribute_param_add_value (VFormatParam
*param
,
131 void vformat_attribute_param_add_values (VFormatParam
*param
,
133 void vformat_attribute_param_remove_values (VFormatParam
*param
);
134 gboolean
vformat_attribute_has_param(VFormatAttribute
*attr
, const char *name
);
136 /* VFormat* accessors. nothing returned from these functions should be
137 freed by the caller. */
138 GList
* vformat_get_attributes (VFormat
*vformat
);
139 const char* vformat_attribute_get_group (VFormatAttribute
*attr
);
140 const char* vformat_attribute_get_name (VFormatAttribute
*attr
);
141 const char* vformat_attribute_get_block (VFormatAttribute
*attr
);
142 GList
* vformat_attribute_get_values (VFormatAttribute
*attr
); /* GList elements are of type char* */
143 GList
* vformat_attribute_get_values_decoded (VFormatAttribute
*attr
); /* GList elements are of type GString* */
144 const char *vformat_attribute_get_nth_value(VFormatAttribute
*attr
, int nth
);
146 /* special accessors for single valued attributes */
147 gboolean
vformat_attribute_is_single_valued (VFormatAttribute
*attr
);
148 char* vformat_attribute_get_value (VFormatAttribute
*attr
);
149 GString
* vformat_attribute_get_value_decoded (VFormatAttribute
*attr
);
151 GList
* vformat_attribute_get_params (VFormatAttribute
*attr
);
152 const char* vformat_attribute_param_get_name (VFormatParam
*param
);
153 GList
* vformat_attribute_param_get_values (VFormatParam
*param
);
154 const char *vformat_attribute_param_get_nth_value(VFormatParam
*param
, int nth
);
156 /* special TYPE= parameter predicate (checks for TYPE=@typestr */
157 gboolean
vformat_attribute_has_type (VFormatAttribute
*attr
, const char *typestr
);
159 /* Utility functions. */
160 char* vformat_escape_string (const char *str
, VFormatType type
);
161 char* vformat_unescape_string (const char *str
);
167 #endif /* _VFORMAT_H */