Diffstat (limited to 'libical/src/libical/icalderivedvalue.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icalderivedvalue.c | 892 |
1 files changed, 459 insertions, 433 deletions
diff --git a/libical/src/libical/icalderivedvalue.c b/libical/src/libical/icalderivedvalue.c index db762ea..8dbbe9e 100644 --- a/libical/src/libical/icalderivedvalue.c +++ b/libical/src/libical/icalderivedvalue.c | |||
@@ -44,345 +44,209 @@ | |||
44 | #include <stddef.h> /* For offsetof() macro */ | 44 | #include <stddef.h> /* For offsetof() macro */ |
45 | #include <errno.h> | 45 | #include <errno.h> |
46 | #include <time.h> /* for mktime */ | 46 | #include <time.h> /* for mktime */ |
47 | #include <stdlib.h> /* for atoi and atof */ | 47 | #include <stdlib.h> /* for atoi and atof */ |
48 | #include <limits.h> /* for SHRT_MAX */ | 48 | #include <limits.h> /* for SHRT_MAX */ |
49 | 49 | ||
50 | |||
51 | |||
52 | #define TMP_BUF_SIZE 1024 | ||
53 | |||
54 | struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind); | 50 | struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind); |
55 | 51 | ||
56 | /* This map associates each of the value types with its string | 52 | /* This map associates each of the value types with its string |
57 | representation */ | 53 | representation */ |
58 | struct icalvalue_kind_map { | 54 | struct icalvalue_kind_map { |
59 | icalvalue_kind kind; | 55 | icalvalue_kind kind; |
60 | char name[20]; | 56 | char name[20]; |
61 | }; | 57 | }; |
62 | 58 | ||
63 | extern struct icalvalue_kind_map value_map[]; | 59 | static struct icalvalue_kind_map value_map[28]={ |
64 | 60 | {ICAL_QUERY_VALUE,"QUERY"}, | |
65 | const char* icalvalue_kind_to_string(icalvalue_kind kind) | 61 | {ICAL_DATE_VALUE,"DATE"}, |
66 | { | 62 | {ICAL_ATTACH_VALUE,"ATTACH"}, |
67 | int i; | 63 | {ICAL_GEO_VALUE,"GEO"}, |
68 | 64 | {ICAL_STATUS_VALUE,"STATUS"}, | |
69 | for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { | 65 | {ICAL_TRANSP_VALUE,"TRANSP"}, |
70 | if (value_map[i].kind == kind) { | 66 | {ICAL_STRING_VALUE,"STRING"}, |
71 | return value_map[i].name; | 67 | {ICAL_TEXT_VALUE,"TEXT"}, |
72 | } | 68 | {ICAL_REQUESTSTATUS_VALUE,"REQUEST-STATUS"}, |
73 | } | 69 | {ICAL_BINARY_VALUE,"BINARY"}, |
74 | 70 | {ICAL_PERIOD_VALUE,"PERIOD"}, | |
75 | return 0; | 71 | {ICAL_FLOAT_VALUE,"FLOAT"}, |
76 | } | 72 | {ICAL_DATETIMEPERIOD_VALUE,"DATE-TIME-PERIOD"}, |
77 | 73 | {ICAL_INTEGER_VALUE,"INTEGER"}, | |
78 | icalvalue_kind icalvalue_string_to_kind(const char* str) | 74 | {ICAL_CLASS_VALUE,"CLASS"}, |
79 | { | 75 | {ICAL_URI_VALUE,"URI"}, |
80 | int i; | 76 | {ICAL_DURATION_VALUE,"DURATION"}, |
81 | 77 | {ICAL_BOOLEAN_VALUE,"BOOLEAN"}, | |
82 | for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { | 78 | {ICAL_X_VALUE,"X"}, |
83 | if (strcmp(value_map[i].name,str) == 0) { | 79 | {ICAL_CALADDRESS_VALUE,"CAL-ADDRESS"}, |
84 | return value_map[i].kind; | 80 | {ICAL_TRIGGER_VALUE,"TRIGGER"}, |
85 | } | 81 | {ICAL_XLICCLASS_VALUE,"X-LIC-CLASS"}, |
86 | } | 82 | {ICAL_RECUR_VALUE,"RECUR"}, |
87 | 83 | {ICAL_ACTION_VALUE,"ACTION"}, | |
88 | return value_map[i].kind; | 84 | {ICAL_DATETIME_VALUE,"DATE-TIME"}, |
85 | {ICAL_UTCOFFSET_VALUE,"UTC-OFFSET"}, | ||
86 | {ICAL_METHOD_VALUE,"METHOD"}, | ||
87 | {ICAL_NO_VALUE,""} | ||
88 | }; | ||
89 | 89 | ||
90 | } | ||
91 | 90 | ||
92 | icalvalue* icalvalue_new_x (const char* v){ | 91 | icalvalue* icalvalue_new_query (const char* v){ |
93 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE); | 92 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_QUERY_VALUE); |
94 | icalerror_check_arg_rz( (v!=0),"v"); | 93 | icalerror_check_arg_rz( (v!=0),"v"); |
95 | 94 | ||
96 | icalvalue_set_x((icalvalue*)impl,v); | 95 | icalvalue_set_query((icalvalue*)impl,v); |
97 | return (icalvalue*)impl; | 96 | return (icalvalue*)impl; |
98 | } | 97 | } |
99 | void icalvalue_set_x(icalvalue* value, const char* v) { | 98 | void icalvalue_set_query(icalvalue* value, const char* v) { |
100 | struct icalvalue_impl* impl; | 99 | struct icalvalue_impl* impl; |
101 | icalerror_check_arg_rv( (value!=0),"value"); | 100 | icalerror_check_arg_rv( (value!=0),"value"); |
102 | icalerror_check_arg_rv( (v!=0),"v"); | 101 | icalerror_check_arg_rv( (v!=0),"v"); |
103 | 102 | ||
103 | icalerror_check_value_type(value, ICAL_QUERY_VALUE); | ||
104 | impl = (struct icalvalue_impl*)value; | 104 | impl = (struct icalvalue_impl*)value; |
105 | if(impl->x_value!=0) {free((void*)impl->x_value);} | 105 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} |
106 | 106 | ||
107 | impl->x_value = icalmemory_strdup(v); | ||
108 | 107 | ||
109 | if (impl->x_value == 0){ | 108 | impl->data.v_string = icalmemory_strdup(v); |
109 | |||
110 | if (impl->data.v_string == 0){ | ||
110 | errno = ENOMEM; | 111 | errno = ENOMEM; |
111 | } | 112 | } |
112 | 113 | ||
113 | } | 114 | |
114 | const char* icalvalue_get_x(icalvalue* value) { | 115 | icalvalue_reset_kind(impl); |
116 | } | ||
117 | const char* icalvalue_get_query(const icalvalue* value) { | ||
115 | 118 | ||
116 | icalerror_check_arg( (value!=0),"value"); | 119 | icalerror_check_arg( (value!=0),"value"); |
117 | icalerror_check_value_type(value, ICAL_X_VALUE); | 120 | icalerror_check_value_type(value, ICAL_QUERY_VALUE); |
118 | return ((struct icalvalue_impl*)value)->x_value; | 121 | return ((struct icalvalue_impl*)value)->data.v_string; |
119 | } | 122 | } |
120 | 123 | ||
121 | /* Attachment is a special case, so it is not auto generated. */ | ||
122 | icalvalue* | ||
123 | icalvalue_new_attach (struct icalattachtype *v) | ||
124 | { | ||
125 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ATTACH_VALUE); | ||
126 | |||
127 | icalvalue_set_attach((icalvalue*)impl,v); | ||
128 | 124 | ||
125 | |||
126 | icalvalue* icalvalue_new_date (struct icaltimetype v){ | ||
127 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATE_VALUE); | ||
128 | |||
129 | icalvalue_set_date((icalvalue*)impl,v); | ||
129 | return (icalvalue*)impl; | 130 | return (icalvalue*)impl; |
130 | } | 131 | } |
131 | 132 | void icalvalue_set_date(icalvalue* value, struct icaltimetype v) { | |
132 | void | ||
133 | icalvalue_set_attach(icalvalue* value, struct icalattachtype *v) | ||
134 | { | ||
135 | struct icalvalue_impl* impl; | 133 | struct icalvalue_impl* impl; |
136 | |||
137 | icalerror_check_arg_rv( (value!=0),"value"); | 134 | icalerror_check_arg_rv( (value!=0),"value"); |
138 | icalerror_check_value_type(value, ICAL_ATTACH_VALUE); | 135 | |
139 | 136 | icalerror_check_value_type(value, ICAL_DATE_VALUE); | |
140 | impl = (struct icalvalue_impl*)value; | 137 | impl = (struct icalvalue_impl*)value; |
141 | 138 | ||
142 | if (impl->data.v_attach != 0){ | ||
143 | icalattachtype_free(impl->data.v_attach); | ||
144 | } | ||
145 | 139 | ||
146 | impl->data.v_attach = v; | 140 | impl->data.v_time = v; |
147 | icalattachtype_add_reference(v); | 141 | |
142 | icalvalue_reset_kind(impl); | ||
148 | } | 143 | } |
144 | struct icaltimetype icalvalue_get_date(const icalvalue* value) { | ||
149 | 145 | ||
150 | struct icalattachtype* | ||
151 | icalvalue_get_attach(icalvalue* value) | ||
152 | { | ||
153 | icalerror_check_arg( (value!=0),"value"); | 146 | icalerror_check_arg( (value!=0),"value"); |
154 | icalerror_check_value_type(value, ICAL_ATTACH_VALUE); | 147 | icalerror_check_value_type(value, ICAL_DATE_VALUE); |
155 | 148 | return ((struct icalvalue_impl*)value)->data.v_time; | |
156 | return ((struct icalvalue_impl*)value)->data.v_attach; | ||
157 | } | 149 | } |
158 | 150 | ||
159 | 151 | ||
160 | /* Recur is a special case, so it is not auto generated. */ | ||
161 | icalvalue* | ||
162 | icalvalue_new_recur (struct icalrecurrencetype v) | ||
163 | { | ||
164 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE); | ||
165 | |||
166 | icalvalue_set_recur((icalvalue*)impl,v); | ||
167 | 152 | ||
153 | icalvalue* icalvalue_new_geo (struct icalgeotype v){ | ||
154 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE); | ||
155 | |||
156 | icalvalue_set_geo((icalvalue*)impl,v); | ||
168 | return (icalvalue*)impl; | 157 | return (icalvalue*)impl; |
169 | } | 158 | } |
170 | 159 | void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) { | |
171 | void | ||
172 | icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v) | ||
173 | { | ||
174 | struct icalvalue_impl* impl; | 160 | struct icalvalue_impl* impl; |
175 | |||
176 | icalerror_check_arg_rv( (value!=0),"value"); | 161 | icalerror_check_arg_rv( (value!=0),"value"); |
177 | icalerror_check_value_type(value, ICAL_RECUR_VALUE); | 162 | |
178 | 163 | icalerror_check_value_type(value, ICAL_GEO_VALUE); | |
179 | impl = (struct icalvalue_impl*)value; | 164 | impl = (struct icalvalue_impl*)value; |
180 | 165 | ||
181 | if (impl->data.v_recur != 0){ | ||
182 | free(impl->data.v_recur); | ||
183 | impl->data.v_recur = 0; | ||
184 | } | ||
185 | 166 | ||
186 | impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); | 167 | impl->data.v_geo = v; |
187 | 168 | ||
188 | if (impl->data.v_recur == 0){ | 169 | icalvalue_reset_kind(impl); |
189 | icalerror_set_errno(ICAL_NEWFAILED_ERROR); | ||
190 | return; | ||
191 | } else { | ||
192 | memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype)); | ||
193 | } | ||
194 | |||
195 | } | 170 | } |
171 | struct icalgeotype icalvalue_get_geo(const icalvalue* value) { | ||
196 | 172 | ||
197 | struct icalrecurrencetype | ||
198 | icalvalue_get_recur(icalvalue* value) | ||
199 | { | ||
200 | icalerror_check_arg( (value!=0),"value"); | 173 | icalerror_check_arg( (value!=0),"value"); |
201 | icalerror_check_value_type(value, ICAL_RECUR_VALUE); | 174 | icalerror_check_value_type(value, ICAL_GEO_VALUE); |
202 | 175 | return ((struct icalvalue_impl*)value)->data.v_geo; | |
203 | return *(((struct icalvalue_impl*)value)->data.v_recur); | ||
204 | } | 176 | } |
205 | 177 | ||
206 | 178 | ||
207 | 179 | ||
208 | 180 | icalvalue* icalvalue_new_status (enum icalproperty_status v){ | |
209 | icalvalue* | 181 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STATUS_VALUE); |
210 | icalvalue_new_trigger (struct icaltriggertype v) | 182 | |
211 | { | 183 | icalvalue_set_status((icalvalue*)impl,v); |
212 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE); | ||
213 | |||
214 | icalvalue_set_trigger((icalvalue*)impl,v); | ||
215 | |||
216 | return (icalvalue*)impl; | 184 | return (icalvalue*)impl; |
217 | } | 185 | } |
218 | 186 | void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) { | |
219 | void | ||
220 | icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v) | ||
221 | { | ||
222 | struct icalvalue_impl* impl; | 187 | struct icalvalue_impl* impl; |
223 | |||
224 | icalerror_check_arg_rv( (value!=0),"value"); | 188 | icalerror_check_arg_rv( (value!=0),"value"); |
225 | 189 | ||
190 | icalerror_check_value_type(value, ICAL_STATUS_VALUE); | ||
226 | impl = (struct icalvalue_impl*)value; | 191 | impl = (struct icalvalue_impl*)value; |
227 | 192 | ||
228 | if(!icaltime_is_null_time(v.time)){ | ||
229 | icalvalue_set_datetime((icalvalue*)impl,v.time); | ||
230 | impl->kind = ICAL_DATETIME_VALUE; | ||
231 | } else { | ||
232 | icalvalue_set_duration((icalvalue*)impl,v.duration); | ||
233 | impl->kind = ICAL_DURATION_VALUE; | ||
234 | } | ||
235 | 193 | ||
236 | } | 194 | impl->data.v_enum = v; |
237 | 195 | ||
238 | struct icaltriggertype | 196 | icalvalue_reset_kind(impl); |
239 | icalvalue_get_trigger(icalvalue* value) | 197 | } |
240 | { | 198 | enum icalproperty_status icalvalue_get_status(const icalvalue* value) { |
241 | struct icalvalue_impl *impl = (struct icalvalue_impl*)value; | ||
242 | struct icaltriggertype tr; | ||
243 | 199 | ||
244 | icalerror_check_arg( (value!=0),"value"); | 200 | icalerror_check_arg( (value!=0),"value"); |
245 | icalerror_check_arg( (value!=0),"value"); | 201 | icalerror_check_value_type(value, ICAL_STATUS_VALUE); |
246 | 202 | return ((struct icalvalue_impl*)value)->data.v_enum; | |
247 | if(impl->kind == ICAL_DATETIME_VALUE){ | ||
248 | tr.duration = icaldurationtype_from_int(0); | ||
249 | tr.time = impl->data.v_time; | ||
250 | } else if(impl->kind == ICAL_DURATION_VALUE){ | ||
251 | tr.time = icaltime_null_time(); | ||
252 | tr.duration = impl->data.v_duration; | ||
253 | } else { | ||
254 | tr.duration = icaldurationtype_from_int(0); | ||
255 | tr.time = icaltime_null_time(); | ||
256 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
257 | } | ||
258 | |||
259 | return tr; | ||
260 | } | 203 | } |
261 | 204 | ||
262 | /* DATE-TIME-PERIOD is a special case, and is not auto generated */ | ||
263 | |||
264 | icalvalue* | ||
265 | icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v) | ||
266 | { | ||
267 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE); | ||
268 | 205 | ||
269 | icalvalue_set_datetimeperiod((icalvalue*)impl,v); | ||
270 | 206 | ||
207 | icalvalue* icalvalue_new_transp (enum icalproperty_transp v){ | ||
208 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRANSP_VALUE); | ||
209 | |||
210 | icalvalue_set_transp((icalvalue*)impl,v); | ||
271 | return (icalvalue*)impl; | 211 | return (icalvalue*)impl; |
272 | } | 212 | } |
273 | 213 | void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) { | |
274 | void | 214 | struct icalvalue_impl* impl; |
275 | icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v) | ||
276 | { | ||
277 | struct icalvalue_impl* impl = (struct icalvalue_impl*)value; | ||
278 | |||
279 | icalerror_check_arg_rv( (value!=0),"value"); | 215 | icalerror_check_arg_rv( (value!=0),"value"); |
280 | 216 | ||
281 | icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); | 217 | icalerror_check_value_type(value, ICAL_TRANSP_VALUE); |
218 | impl = (struct icalvalue_impl*)value; | ||
282 | 219 | ||
283 | if(!icaltime_is_null_time(v.time)){ | ||
284 | if(!icaltime_is_valid_time(v.time)){ | ||
285 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
286 | return; | ||
287 | } | ||
288 | impl->kind = ICAL_DATETIME_VALUE; | ||
289 | icalvalue_set_datetime(impl,v.time); | ||
290 | } else if (!icalperiodtype_is_null_period(v.period)) { | ||
291 | if(!icalperiodtype_is_valid_period(v.period)){ | ||
292 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
293 | return; | ||
294 | } | ||
295 | impl->kind = ICAL_PERIOD_VALUE; | ||
296 | icalvalue_set_period(impl,v.period); | ||
297 | } else { | ||
298 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
299 | } | ||
300 | } | ||
301 | 220 | ||
302 | struct icaldatetimeperiodtype | 221 | impl->data.v_enum = v; |
303 | icalvalue_get_datetimeperiod(icalvalue* value) | ||
304 | { | ||
305 | struct icaldatetimeperiodtype dtp; | ||
306 | |||
307 | struct icalvalue_impl* impl = (struct icalvalue_impl*)value; | ||
308 | icalerror_check_arg( (value!=0),"value"); | ||
309 | icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); | ||
310 | |||
311 | if(impl->kind == ICAL_DATETIME_VALUE){ | ||
312 | dtp.period = icalperiodtype_null_period(); | ||
313 | dtp.time = impl->data.v_time; | ||
314 | } else if(impl->kind == ICAL_PERIOD_VALUE) { | ||
315 | dtp.period = impl->data.v_period; | ||
316 | dtp.time = icaltime_null_time(); | ||
317 | } else { | ||
318 | dtp.period = icalperiodtype_null_period(); | ||
319 | dtp.time = icaltime_null_time(); | ||
320 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
321 | } | ||
322 | 222 | ||
323 | return dtp; | 223 | icalvalue_reset_kind(impl); |
324 | } | 224 | } |
225 | enum icalproperty_transp icalvalue_get_transp(const icalvalue* value) { | ||
325 | 226 | ||
227 | icalerror_check_arg( (value!=0),"value"); | ||
228 | icalerror_check_value_type(value, ICAL_TRANSP_VALUE); | ||
229 | return ((struct icalvalue_impl*)value)->data.v_enum; | ||
230 | } | ||
326 | 231 | ||
327 | 232 | ||
328 | 233 | ||
329 | 234 | icalvalue* icalvalue_new_string (const char* v){ | |
330 | 235 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STRING_VALUE); | |
331 | |||
332 | |||
333 | |||
334 | /* The remaining interfaces are 'new', 'set' and 'get' for each of the value | ||
335 | types */ | ||
336 | |||
337 | |||
338 | /* Everything below this line is machine generated. Do not edit. */ | ||
339 | static struct icalvalue_kind_map value_map[]={ | ||
340 | {ICAL_QUERY_VALUE,"QUERY"}, | ||
341 | {ICAL_TRIGGER_VALUE,"TRIGGER"}, | ||
342 | {ICAL_STATUS_VALUE,"STATUS"}, | ||
343 | {ICAL_TRANSP_VALUE,"TRANSP"}, | ||
344 | {ICAL_CLASS_VALUE,"CLASS"}, | ||
345 | {ICAL_DATE_VALUE,"DATE"}, | ||
346 | {ICAL_STRING_VALUE,"STRING"}, | ||
347 | {ICAL_INTEGER_VALUE,"INTEGER"}, | ||
348 | {ICAL_PERIOD_VALUE,"PERIOD"}, | ||
349 | {ICAL_TEXT_VALUE,"TEXT"}, | ||
350 | {ICAL_DURATION_VALUE,"DURATION"}, | ||
351 | {ICAL_BOOLEAN_VALUE,"BOOLEAN"}, | ||
352 | {ICAL_URI_VALUE,"URI"}, | ||
353 | {ICAL_DATETIMEPERIOD_VALUE,"DATE-TIME-PERIOD"}, | ||
354 | {ICAL_GEO_VALUE,"GEO"}, | ||
355 | {ICAL_DATETIME_VALUE,"DATE-TIME"}, | ||
356 | {ICAL_UTCOFFSET_VALUE,"UTC-OFFSET"}, | ||
357 | {ICAL_ATTACH_VALUE,"ATTACH"}, | ||
358 | {ICAL_ACTION_VALUE,"ACTION"}, | ||
359 | {ICAL_CALADDRESS_VALUE,"CAL-ADDRESS"}, | ||
360 | {ICAL_X_VALUE,"X"}, | ||
361 | {ICAL_FLOAT_VALUE,"FLOAT"}, | ||
362 | {ICAL_REQUESTSTATUS_VALUE,"REQUEST-STATUS"}, | ||
363 | {ICAL_METHOD_VALUE,"METHOD"}, | ||
364 | {ICAL_BINARY_VALUE,"BINARY"}, | ||
365 | {ICAL_RECUR_VALUE,"RECUR"}, | ||
366 | {ICAL_NO_VALUE,""} | ||
367 | }; | ||
368 | |||
369 | |||
370 | icalvalue* icalvalue_new_query (const char* v){ | ||
371 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_QUERY_VALUE); | ||
372 | icalerror_check_arg_rz( (v!=0),"v"); | 236 | icalerror_check_arg_rz( (v!=0),"v"); |
373 | 237 | ||
374 | icalvalue_set_query((icalvalue*)impl,v); | 238 | icalvalue_set_string((icalvalue*)impl,v); |
375 | return (icalvalue*)impl; | 239 | return (icalvalue*)impl; |
376 | } | 240 | } |
377 | void icalvalue_set_query(icalvalue* value, const char* v) { | 241 | void icalvalue_set_string(icalvalue* value, const char* v) { |
378 | struct icalvalue_impl* impl; | 242 | struct icalvalue_impl* impl; |
379 | icalerror_check_arg_rv( (value!=0),"value"); | 243 | icalerror_check_arg_rv( (value!=0),"value"); |
380 | icalerror_check_arg_rv( (v!=0),"v"); | 244 | icalerror_check_arg_rv( (v!=0),"v"); |
381 | 245 | ||
382 | icalerror_check_value_type(value, ICAL_QUERY_VALUE); | 246 | icalerror_check_value_type(value, ICAL_STRING_VALUE); |
383 | impl = (struct icalvalue_impl*)value; | 247 | impl = (struct icalvalue_impl*)value; |
384 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | 248 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} |
385 | 249 | ||
386 | 250 | ||
387 | impl->data.v_string = icalmemory_strdup(v); | 251 | impl->data.v_string = icalmemory_strdup(v); |
388 | 252 | ||
@@ -390,160 +254,168 @@ void icalvalue_set_query(icalvalue* value, const char* v) { | |||
390 | errno = ENOMEM; | 254 | errno = ENOMEM; |
391 | } | 255 | } |
392 | 256 | ||
393 | 257 | ||
394 | icalvalue_reset_kind(impl); | 258 | icalvalue_reset_kind(impl); |
395 | } | 259 | } |
396 | const char* icalvalue_get_query(icalvalue* value) { | 260 | const char* icalvalue_get_string(const icalvalue* value) { |
397 | 261 | ||
398 | icalerror_check_arg( (value!=0),"value"); | 262 | icalerror_check_arg( (value!=0),"value"); |
399 | icalerror_check_value_type(value, ICAL_QUERY_VALUE); | 263 | icalerror_check_value_type(value, ICAL_STRING_VALUE); |
400 | return ((struct icalvalue_impl*)value)->data.v_string; | 264 | return ((struct icalvalue_impl*)value)->data.v_string; |
401 | } | 265 | } |
402 | 266 | ||
403 | 267 | ||
404 | 268 | ||
405 | icalvalue* icalvalue_new_status (enum icalproperty_status v){ | 269 | icalvalue* icalvalue_new_text (const char* v){ |
406 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STATUS_VALUE); | 270 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TEXT_VALUE); |
407 | 271 | icalerror_check_arg_rz( (v!=0),"v"); | |
408 | icalvalue_set_status((icalvalue*)impl,v); | 272 | |
273 | icalvalue_set_text((icalvalue*)impl,v); | ||
409 | return (icalvalue*)impl; | 274 | return (icalvalue*)impl; |
410 | } | 275 | } |
411 | void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) { | 276 | void icalvalue_set_text(icalvalue* value, const char* v) { |
412 | struct icalvalue_impl* impl; | 277 | struct icalvalue_impl* impl; |
413 | icalerror_check_arg_rv( (value!=0),"value"); | 278 | icalerror_check_arg_rv( (value!=0),"value"); |
414 | 279 | icalerror_check_arg_rv( (v!=0),"v"); | |
415 | icalerror_check_value_type(value, ICAL_STATUS_VALUE); | 280 | |
281 | icalerror_check_value_type(value, ICAL_TEXT_VALUE); | ||
416 | impl = (struct icalvalue_impl*)value; | 282 | impl = (struct icalvalue_impl*)value; |
283 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | ||
417 | 284 | ||
418 | 285 | ||
419 | impl->data.v_enum = v; | 286 | impl->data.v_string = icalmemory_strdup(v); |
287 | |||
288 | if (impl->data.v_string == 0){ | ||
289 | errno = ENOMEM; | ||
290 | } | ||
291 | |||
420 | 292 | ||
421 | icalvalue_reset_kind(impl); | 293 | icalvalue_reset_kind(impl); |
422 | } | 294 | } |
423 | enum icalproperty_status icalvalue_get_status(icalvalue* value) { | 295 | const char* icalvalue_get_text(const icalvalue* value) { |
424 | 296 | ||
425 | icalerror_check_arg( (value!=0),"value"); | 297 | icalerror_check_arg( (value!=0),"value"); |
426 | icalerror_check_value_type(value, ICAL_STATUS_VALUE); | 298 | icalerror_check_value_type(value, ICAL_TEXT_VALUE); |
427 | return ((struct icalvalue_impl*)value)->data.v_enum; | 299 | return ((struct icalvalue_impl*)value)->data.v_string; |
428 | } | 300 | } |
429 | 301 | ||
430 | 302 | ||
431 | 303 | ||
432 | icalvalue* icalvalue_new_transp (enum icalproperty_transp v){ | 304 | icalvalue* icalvalue_new_requeststatus (struct icalreqstattype v){ |
433 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRANSP_VALUE); | 305 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_REQUESTSTATUS_VALUE); |
434 | 306 | ||
435 | icalvalue_set_transp((icalvalue*)impl,v); | 307 | icalvalue_set_requeststatus((icalvalue*)impl,v); |
436 | return (icalvalue*)impl; | 308 | return (icalvalue*)impl; |
437 | } | 309 | } |
438 | void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) { | 310 | void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) { |
439 | struct icalvalue_impl* impl; | 311 | struct icalvalue_impl* impl; |
440 | icalerror_check_arg_rv( (value!=0),"value"); | 312 | icalerror_check_arg_rv( (value!=0),"value"); |
441 | 313 | ||
442 | icalerror_check_value_type(value, ICAL_TRANSP_VALUE); | 314 | icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE); |
443 | impl = (struct icalvalue_impl*)value; | 315 | impl = (struct icalvalue_impl*)value; |
444 | 316 | ||
445 | 317 | ||
446 | impl->data.v_enum = v; | 318 | impl->data.v_requeststatus = v; |
447 | 319 | ||
448 | icalvalue_reset_kind(impl); | 320 | icalvalue_reset_kind(impl); |
449 | } | 321 | } |
450 | enum icalproperty_transp icalvalue_get_transp(icalvalue* value) { | 322 | struct icalreqstattype icalvalue_get_requeststatus(const icalvalue* value) { |
451 | 323 | ||
452 | icalerror_check_arg( (value!=0),"value"); | 324 | icalerror_check_arg( (value!=0),"value"); |
453 | icalerror_check_value_type(value, ICAL_TRANSP_VALUE); | 325 | icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE); |
454 | return ((struct icalvalue_impl*)value)->data.v_enum; | 326 | return ((struct icalvalue_impl*)value)->data.v_requeststatus; |
455 | } | 327 | } |
456 | 328 | ||
457 | 329 | ||
458 | 330 | ||
459 | icalvalue* icalvalue_new_class (enum icalproperty_class v){ | 331 | icalvalue* icalvalue_new_binary (const char* v){ |
460 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE); | 332 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_BINARY_VALUE); |
461 | 333 | icalerror_check_arg_rz( (v!=0),"v"); | |
462 | icalvalue_set_class((icalvalue*)impl,v); | 334 | |
335 | icalvalue_set_binary((icalvalue*)impl,v); | ||
463 | return (icalvalue*)impl; | 336 | return (icalvalue*)impl; |
464 | } | 337 | } |
465 | void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) { | 338 | void icalvalue_set_binary(icalvalue* value, const char* v) { |
466 | struct icalvalue_impl* impl; | 339 | struct icalvalue_impl* impl; |
467 | icalerror_check_arg_rv( (value!=0),"value"); | 340 | icalerror_check_arg_rv( (value!=0),"value"); |
468 | 341 | icalerror_check_arg_rv( (v!=0),"v"); | |
469 | icalerror_check_value_type(value, ICAL_CLASS_VALUE); | 342 | |
343 | icalerror_check_value_type(value, ICAL_BINARY_VALUE); | ||
470 | impl = (struct icalvalue_impl*)value; | 344 | impl = (struct icalvalue_impl*)value; |
345 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | ||
471 | 346 | ||
472 | 347 | ||
473 | impl->data.v_enum = v; | 348 | impl->data.v_string = icalmemory_strdup(v); |
349 | |||
350 | if (impl->data.v_string == 0){ | ||
351 | errno = ENOMEM; | ||
352 | } | ||
353 | |||
474 | 354 | ||
475 | icalvalue_reset_kind(impl); | 355 | icalvalue_reset_kind(impl); |
476 | } | 356 | } |
477 | enum icalproperty_class icalvalue_get_class(icalvalue* value) { | 357 | const char* icalvalue_get_binary(const icalvalue* value) { |
478 | 358 | ||
479 | icalerror_check_arg( (value!=0),"value"); | 359 | icalerror_check_arg( (value!=0),"value"); |
480 | icalerror_check_value_type(value, ICAL_CLASS_VALUE); | 360 | icalerror_check_value_type(value, ICAL_BINARY_VALUE); |
481 | return ((struct icalvalue_impl*)value)->data.v_enum; | 361 | return ((struct icalvalue_impl*)value)->data.v_string; |
482 | } | 362 | } |
483 | 363 | ||
484 | 364 | ||
485 | 365 | ||
486 | icalvalue* icalvalue_new_date (struct icaltimetype v){ | 366 | icalvalue* icalvalue_new_period (struct icalperiodtype v){ |
487 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATE_VALUE); | 367 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_PERIOD_VALUE); |
488 | 368 | ||
489 | icalvalue_set_date((icalvalue*)impl,v); | 369 | icalvalue_set_period((icalvalue*)impl,v); |
490 | return (icalvalue*)impl; | 370 | return (icalvalue*)impl; |
491 | } | 371 | } |
492 | void icalvalue_set_date(icalvalue* value, struct icaltimetype v) { | 372 | void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) { |
493 | struct icalvalue_impl* impl; | 373 | struct icalvalue_impl* impl; |
494 | icalerror_check_arg_rv( (value!=0),"value"); | 374 | icalerror_check_arg_rv( (value!=0),"value"); |
495 | 375 | ||
496 | icalerror_check_value_type(value, ICAL_DATE_VALUE); | 376 | icalerror_check_value_type(value, ICAL_PERIOD_VALUE); |
497 | impl = (struct icalvalue_impl*)value; | 377 | impl = (struct icalvalue_impl*)value; |
498 | 378 | ||
499 | 379 | ||
500 | impl->data.v_time = v; | 380 | impl->data.v_period = v; |
501 | 381 | ||
502 | icalvalue_reset_kind(impl); | 382 | icalvalue_reset_kind(impl); |
503 | } | 383 | } |
504 | struct icaltimetype icalvalue_get_date(icalvalue* value) { | 384 | struct icalperiodtype icalvalue_get_period(const icalvalue* value) { |
505 | 385 | ||
506 | icalerror_check_arg( (value!=0),"value"); | 386 | icalerror_check_arg( (value!=0),"value"); |
507 | icalerror_check_value_type(value, ICAL_DATE_VALUE); | 387 | icalerror_check_value_type(value, ICAL_PERIOD_VALUE); |
508 | return ((struct icalvalue_impl*)value)->data.v_time; | 388 | return ((struct icalvalue_impl*)value)->data.v_period; |
509 | } | 389 | } |
510 | 390 | ||
511 | 391 | ||
512 | 392 | ||
513 | icalvalue* icalvalue_new_string (const char* v){ | 393 | icalvalue* icalvalue_new_float (float v){ |
514 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STRING_VALUE); | 394 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_FLOAT_VALUE); |
515 | icalerror_check_arg_rz( (v!=0),"v"); | 395 | |
516 | 396 | icalvalue_set_float((icalvalue*)impl,v); | |
517 | icalvalue_set_string((icalvalue*)impl,v); | ||
518 | return (icalvalue*)impl; | 397 | return (icalvalue*)impl; |
519 | } | 398 | } |
520 | void icalvalue_set_string(icalvalue* value, const char* v) { | 399 | void icalvalue_set_float(icalvalue* value, float v) { |
521 | struct icalvalue_impl* impl; | 400 | struct icalvalue_impl* impl; |
522 | icalerror_check_arg_rv( (value!=0),"value"); | 401 | icalerror_check_arg_rv( (value!=0),"value"); |
523 | icalerror_check_arg_rv( (v!=0),"v"); | 402 | |
524 | 403 | icalerror_check_value_type(value, ICAL_FLOAT_VALUE); | |
525 | icalerror_check_value_type(value, ICAL_STRING_VALUE); | ||
526 | impl = (struct icalvalue_impl*)value; | 404 | impl = (struct icalvalue_impl*)value; |
527 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | ||
528 | 405 | ||
529 | 406 | ||
530 | impl->data.v_string = icalmemory_strdup(v); | 407 | impl->data.v_float = v; |
531 | |||
532 | if (impl->data.v_string == 0){ | ||
533 | errno = ENOMEM; | ||
534 | } | ||
535 | |||
536 | 408 | ||
537 | icalvalue_reset_kind(impl); | 409 | icalvalue_reset_kind(impl); |
538 | } | 410 | } |
539 | const char* icalvalue_get_string(icalvalue* value) { | 411 | float icalvalue_get_float(const icalvalue* value) { |
540 | 412 | ||
541 | icalerror_check_arg( (value!=0),"value"); | 413 | icalerror_check_arg( (value!=0),"value"); |
542 | icalerror_check_value_type(value, ICAL_STRING_VALUE); | 414 | icalerror_check_value_type(value, ICAL_FLOAT_VALUE); |
543 | return ((struct icalvalue_impl*)value)->data.v_string; | 415 | return ((struct icalvalue_impl*)value)->data.v_float; |
544 | } | 416 | } |
545 | 417 | ||
546 | 418 | ||
547 | 419 | ||
548 | icalvalue* icalvalue_new_integer (int v){ | 420 | icalvalue* icalvalue_new_integer (int v){ |
549 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_INTEGER_VALUE); | 421 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_INTEGER_VALUE); |
@@ -560,61 +432,61 @@ void icalvalue_set_integer(icalvalue* value, int v) { | |||
560 | 432 | ||
561 | 433 | ||
562 | impl->data.v_int = v; | 434 | impl->data.v_int = v; |
563 | 435 | ||
564 | icalvalue_reset_kind(impl); | 436 | icalvalue_reset_kind(impl); |
565 | } | 437 | } |
566 | int icalvalue_get_integer(icalvalue* value) { | 438 | int icalvalue_get_integer(const icalvalue* value) { |
567 | 439 | ||
568 | icalerror_check_arg( (value!=0),"value"); | 440 | icalerror_check_arg( (value!=0),"value"); |
569 | icalerror_check_value_type(value, ICAL_INTEGER_VALUE); | 441 | icalerror_check_value_type(value, ICAL_INTEGER_VALUE); |
570 | return ((struct icalvalue_impl*)value)->data.v_int; | 442 | return ((struct icalvalue_impl*)value)->data.v_int; |
571 | } | 443 | } |
572 | 444 | ||
573 | 445 | ||
574 | 446 | ||
575 | icalvalue* icalvalue_new_period (struct icalperiodtype v){ | 447 | icalvalue* icalvalue_new_class (enum icalproperty_class v){ |
576 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_PERIOD_VALUE); | 448 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE); |
577 | 449 | ||
578 | icalvalue_set_period((icalvalue*)impl,v); | 450 | icalvalue_set_class((icalvalue*)impl,v); |
579 | return (icalvalue*)impl; | 451 | return (icalvalue*)impl; |
580 | } | 452 | } |
581 | void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) { | 453 | void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) { |
582 | struct icalvalue_impl* impl; | 454 | struct icalvalue_impl* impl; |
583 | icalerror_check_arg_rv( (value!=0),"value"); | 455 | icalerror_check_arg_rv( (value!=0),"value"); |
584 | 456 | ||
585 | icalerror_check_value_type(value, ICAL_PERIOD_VALUE); | 457 | icalerror_check_value_type(value, ICAL_CLASS_VALUE); |
586 | impl = (struct icalvalue_impl*)value; | 458 | impl = (struct icalvalue_impl*)value; |
587 | 459 | ||
588 | 460 | ||
589 | impl->data.v_period = v; | 461 | impl->data.v_enum = v; |
590 | 462 | ||
591 | icalvalue_reset_kind(impl); | 463 | icalvalue_reset_kind(impl); |
592 | } | 464 | } |
593 | struct icalperiodtype icalvalue_get_period(icalvalue* value) { | 465 | enum icalproperty_class icalvalue_get_class(const icalvalue* value) { |
594 | 466 | ||
595 | icalerror_check_arg( (value!=0),"value"); | 467 | icalerror_check_arg( (value!=0),"value"); |
596 | icalerror_check_value_type(value, ICAL_PERIOD_VALUE); | 468 | icalerror_check_value_type(value, ICAL_CLASS_VALUE); |
597 | return ((struct icalvalue_impl*)value)->data.v_period; | 469 | return ((struct icalvalue_impl*)value)->data.v_enum; |
598 | } | 470 | } |
599 | 471 | ||
600 | 472 | ||
601 | 473 | ||
602 | icalvalue* icalvalue_new_text (const char* v){ | 474 | icalvalue* icalvalue_new_uri (const char* v){ |
603 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TEXT_VALUE); | 475 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_URI_VALUE); |
604 | icalerror_check_arg_rz( (v!=0),"v"); | 476 | icalerror_check_arg_rz( (v!=0),"v"); |
605 | 477 | ||
606 | icalvalue_set_text((icalvalue*)impl,v); | 478 | icalvalue_set_uri((icalvalue*)impl,v); |
607 | return (icalvalue*)impl; | 479 | return (icalvalue*)impl; |
608 | } | 480 | } |
609 | void icalvalue_set_text(icalvalue* value, const char* v) { | 481 | void icalvalue_set_uri(icalvalue* value, const char* v) { |
610 | struct icalvalue_impl* impl; | 482 | struct icalvalue_impl* impl; |
611 | icalerror_check_arg_rv( (value!=0),"value"); | 483 | icalerror_check_arg_rv( (value!=0),"value"); |
612 | icalerror_check_arg_rv( (v!=0),"v"); | 484 | icalerror_check_arg_rv( (v!=0),"v"); |
613 | 485 | ||
614 | icalerror_check_value_type(value, ICAL_TEXT_VALUE); | 486 | icalerror_check_value_type(value, ICAL_URI_VALUE); |
615 | impl = (struct icalvalue_impl*)value; | 487 | impl = (struct icalvalue_impl*)value; |
616 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | 488 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} |
617 | 489 | ||
618 | 490 | ||
619 | impl->data.v_string = icalmemory_strdup(v); | 491 | impl->data.v_string = icalmemory_strdup(v); |
620 | 492 | ||
@@ -622,16 +494,16 @@ void icalvalue_set_text(icalvalue* value, const char* v) { | |||
622 | errno = ENOMEM; | 494 | errno = ENOMEM; |
623 | } | 495 | } |
624 | 496 | ||
625 | 497 | ||
626 | icalvalue_reset_kind(impl); | 498 | icalvalue_reset_kind(impl); |
627 | } | 499 | } |
628 | const char* icalvalue_get_text(icalvalue* value) { | 500 | const char* icalvalue_get_uri(const icalvalue* value) { |
629 | 501 | ||
630 | icalerror_check_arg( (value!=0),"value"); | 502 | icalerror_check_arg( (value!=0),"value"); |
631 | icalerror_check_value_type(value, ICAL_TEXT_VALUE); | 503 | icalerror_check_value_type(value, ICAL_URI_VALUE); |
632 | return ((struct icalvalue_impl*)value)->data.v_string; | 504 | return ((struct icalvalue_impl*)value)->data.v_string; |
633 | } | 505 | } |
634 | 506 | ||
635 | 507 | ||
636 | 508 | ||
637 | icalvalue* icalvalue_new_duration (struct icaldurationtype v){ | 509 | icalvalue* icalvalue_new_duration (struct icaldurationtype v){ |
@@ -649,13 +521,13 @@ void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) { | |||
649 | 521 | ||
650 | 522 | ||
651 | impl->data.v_duration = v; | 523 | impl->data.v_duration = v; |
652 | 524 | ||
653 | icalvalue_reset_kind(impl); | 525 | icalvalue_reset_kind(impl); |
654 | } | 526 | } |
655 | struct icaldurationtype icalvalue_get_duration(icalvalue* value) { | 527 | struct icaldurationtype icalvalue_get_duration(const icalvalue* value) { |
656 | 528 | ||
657 | icalerror_check_arg( (value!=0),"value"); | 529 | icalerror_check_arg( (value!=0),"value"); |
658 | icalerror_check_value_type(value, ICAL_DURATION_VALUE); | 530 | icalerror_check_value_type(value, ICAL_DURATION_VALUE); |
659 | return ((struct icalvalue_impl*)value)->data.v_duration; | 531 | return ((struct icalvalue_impl*)value)->data.v_duration; |
660 | } | 532 | } |
661 | 533 | ||
@@ -676,34 +548,34 @@ void icalvalue_set_boolean(icalvalue* value, int v) { | |||
676 | 548 | ||
677 | 549 | ||
678 | impl->data.v_int = v; | 550 | impl->data.v_int = v; |
679 | 551 | ||
680 | icalvalue_reset_kind(impl); | 552 | icalvalue_reset_kind(impl); |
681 | } | 553 | } |
682 | int icalvalue_get_boolean(icalvalue* value) { | 554 | int icalvalue_get_boolean(const icalvalue* value) { |
683 | 555 | ||
684 | icalerror_check_arg( (value!=0),"value"); | 556 | icalerror_check_arg( (value!=0),"value"); |
685 | icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE); | 557 | icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE); |
686 | return ((struct icalvalue_impl*)value)->data.v_int; | 558 | return ((struct icalvalue_impl*)value)->data.v_int; |
687 | } | 559 | } |
688 | 560 | ||
689 | 561 | ||
690 | 562 | ||
691 | icalvalue* icalvalue_new_uri (const char* v){ | 563 | icalvalue* icalvalue_new_caladdress (const char* v){ |
692 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_URI_VALUE); | 564 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE); |
693 | icalerror_check_arg_rz( (v!=0),"v"); | 565 | icalerror_check_arg_rz( (v!=0),"v"); |
694 | 566 | ||
695 | icalvalue_set_uri((icalvalue*)impl,v); | 567 | icalvalue_set_caladdress((icalvalue*)impl,v); |
696 | return (icalvalue*)impl; | 568 | return (icalvalue*)impl; |
697 | } | 569 | } |
698 | void icalvalue_set_uri(icalvalue* value, const char* v) { | 570 | void icalvalue_set_caladdress(icalvalue* value, const char* v) { |
699 | struct icalvalue_impl* impl; | 571 | struct icalvalue_impl* impl; |
700 | icalerror_check_arg_rv( (value!=0),"value"); | 572 | icalerror_check_arg_rv( (value!=0),"value"); |
701 | icalerror_check_arg_rv( (v!=0),"v"); | 573 | icalerror_check_arg_rv( (v!=0),"v"); |
702 | 574 | ||
703 | icalerror_check_value_type(value, ICAL_URI_VALUE); | 575 | icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); |
704 | impl = (struct icalvalue_impl*)value; | 576 | impl = (struct icalvalue_impl*)value; |
705 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | 577 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} |
706 | 578 | ||
707 | 579 | ||
708 | impl->data.v_string = icalmemory_strdup(v); | 580 | impl->data.v_string = icalmemory_strdup(v); |
709 | 581 | ||
@@ -711,44 +583,71 @@ void icalvalue_set_uri(icalvalue* value, const char* v) { | |||
711 | errno = ENOMEM; | 583 | errno = ENOMEM; |
712 | } | 584 | } |
713 | 585 | ||
714 | 586 | ||
715 | icalvalue_reset_kind(impl); | 587 | icalvalue_reset_kind(impl); |
716 | } | 588 | } |
717 | const char* icalvalue_get_uri(icalvalue* value) { | 589 | const char* icalvalue_get_caladdress(const icalvalue* value) { |
718 | 590 | ||
719 | icalerror_check_arg( (value!=0),"value"); | 591 | icalerror_check_arg( (value!=0),"value"); |
720 | icalerror_check_value_type(value, ICAL_URI_VALUE); | 592 | icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); |
721 | return ((struct icalvalue_impl*)value)->data.v_string; | 593 | return ((struct icalvalue_impl*)value)->data.v_string; |
722 | } | 594 | } |
723 | 595 | ||
724 | 596 | ||
725 | 597 | ||
726 | icalvalue* icalvalue_new_geo (struct icalgeotype v){ | 598 | icalvalue* icalvalue_new_xlicclass (enum icalproperty_xlicclass v){ |
727 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE); | 599 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_XLICCLASS_VALUE); |
728 | 600 | ||
729 | icalvalue_set_geo((icalvalue*)impl,v); | 601 | icalvalue_set_xlicclass((icalvalue*)impl,v); |
730 | return (icalvalue*)impl; | 602 | return (icalvalue*)impl; |
731 | } | 603 | } |
732 | void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) { | 604 | void icalvalue_set_xlicclass(icalvalue* value, enum icalproperty_xlicclass v) { |
733 | struct icalvalue_impl* impl; | 605 | struct icalvalue_impl* impl; |
734 | icalerror_check_arg_rv( (value!=0),"value"); | 606 | icalerror_check_arg_rv( (value!=0),"value"); |
735 | 607 | ||
736 | icalerror_check_value_type(value, ICAL_GEO_VALUE); | 608 | icalerror_check_value_type(value, ICAL_XLICCLASS_VALUE); |
737 | impl = (struct icalvalue_impl*)value; | 609 | impl = (struct icalvalue_impl*)value; |
738 | 610 | ||
739 | 611 | ||
740 | impl->data.v_geo = v; | 612 | impl->data.v_enum = v; |
741 | 613 | ||
742 | icalvalue_reset_kind(impl); | 614 | icalvalue_reset_kind(impl); |
743 | } | 615 | } |
744 | struct icalgeotype icalvalue_get_geo(icalvalue* value) { | 616 | enum icalproperty_xlicclass icalvalue_get_xlicclass(const icalvalue* value) { |
745 | 617 | ||
746 | icalerror_check_arg( (value!=0),"value"); | 618 | icalerror_check_arg( (value!=0),"value"); |
747 | icalerror_check_value_type(value, ICAL_GEO_VALUE); | 619 | icalerror_check_value_type(value, ICAL_XLICCLASS_VALUE); |
748 | return ((struct icalvalue_impl*)value)->data.v_geo; | 620 | return ((struct icalvalue_impl*)value)->data.v_enum; |
621 | } | ||
622 | |||
623 | |||
624 | |||
625 | icalvalue* icalvalue_new_action (enum icalproperty_action v){ | ||
626 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ACTION_VALUE); | ||
627 | |||
628 | icalvalue_set_action((icalvalue*)impl,v); | ||
629 | return (icalvalue*)impl; | ||
630 | } | ||
631 | void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) { | ||
632 | struct icalvalue_impl* impl; | ||
633 | icalerror_check_arg_rv( (value!=0),"value"); | ||
634 | |||
635 | icalerror_check_value_type(value, ICAL_ACTION_VALUE); | ||
636 | impl = (struct icalvalue_impl*)value; | ||
637 | |||
638 | |||
639 | impl->data.v_enum = v; | ||
640 | |||
641 | icalvalue_reset_kind(impl); | ||
642 | } | ||
643 | enum icalproperty_action icalvalue_get_action(const icalvalue* value) { | ||
644 | |||
645 | icalerror_check_arg( (value!=0),"value"); | ||
646 | icalerror_check_value_type(value, ICAL_ACTION_VALUE); | ||
647 | return ((struct icalvalue_impl*)value)->data.v_enum; | ||
749 | } | 648 | } |
750 | 649 | ||
751 | 650 | ||
752 | 651 | ||
753 | icalvalue* icalvalue_new_datetime (struct icaltimetype v){ | 652 | icalvalue* icalvalue_new_datetime (struct icaltimetype v){ |
754 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIME_VALUE); | 653 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIME_VALUE); |
@@ -765,13 +664,13 @@ void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) { | |||
765 | 664 | ||
766 | 665 | ||
767 | impl->data.v_time = v; | 666 | impl->data.v_time = v; |
768 | 667 | ||
769 | icalvalue_reset_kind(impl); | 668 | icalvalue_reset_kind(impl); |
770 | } | 669 | } |
771 | struct icaltimetype icalvalue_get_datetime(icalvalue* value) { | 670 | struct icaltimetype icalvalue_get_datetime(const icalvalue* value) { |
772 | 671 | ||
773 | icalerror_check_arg( (value!=0),"value"); | 672 | icalerror_check_arg( (value!=0),"value"); |
774 | icalerror_check_value_type(value, ICAL_DATETIME_VALUE); | 673 | icalerror_check_value_type(value, ICAL_DATETIME_VALUE); |
775 | return ((struct icalvalue_impl*)value)->data.v_time; | 674 | return ((struct icalvalue_impl*)value)->data.v_time; |
776 | } | 675 | } |
777 | 676 | ||
@@ -792,190 +691,317 @@ void icalvalue_set_utcoffset(icalvalue* value, int v) { | |||
792 | 691 | ||
793 | 692 | ||
794 | impl->data.v_int = v; | 693 | impl->data.v_int = v; |
795 | 694 | ||
796 | icalvalue_reset_kind(impl); | 695 | icalvalue_reset_kind(impl); |
797 | } | 696 | } |
798 | int icalvalue_get_utcoffset(icalvalue* value) { | 697 | int icalvalue_get_utcoffset(const icalvalue* value) { |
799 | 698 | ||
800 | icalerror_check_arg( (value!=0),"value"); | 699 | icalerror_check_arg( (value!=0),"value"); |
801 | icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE); | 700 | icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE); |
802 | return ((struct icalvalue_impl*)value)->data.v_int; | 701 | return ((struct icalvalue_impl*)value)->data.v_int; |
803 | } | 702 | } |
804 | 703 | ||
805 | 704 | ||
806 | 705 | ||
807 | icalvalue* icalvalue_new_action (enum icalproperty_action v){ | 706 | icalvalue* icalvalue_new_method (enum icalproperty_method v){ |
808 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ACTION_VALUE); | 707 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_METHOD_VALUE); |
809 | 708 | ||
810 | icalvalue_set_action((icalvalue*)impl,v); | 709 | icalvalue_set_method((icalvalue*)impl,v); |
811 | return (icalvalue*)impl; | 710 | return (icalvalue*)impl; |
812 | } | 711 | } |
813 | void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) { | 712 | void icalvalue_set_method(icalvalue* value, enum icalproperty_method v) { |
814 | struct icalvalue_impl* impl; | 713 | struct icalvalue_impl* impl; |
815 | icalerror_check_arg_rv( (value!=0),"value"); | 714 | icalerror_check_arg_rv( (value!=0),"value"); |
816 | 715 | ||
817 | icalerror_check_value_type(value, ICAL_ACTION_VALUE); | 716 | icalerror_check_value_type(value, ICAL_METHOD_VALUE); |
818 | impl = (struct icalvalue_impl*)value; | 717 | impl = (struct icalvalue_impl*)value; |
819 | 718 | ||
820 | 719 | ||
821 | impl->data.v_enum = v; | 720 | impl->data.v_enum = v; |
822 | 721 | ||
823 | icalvalue_reset_kind(impl); | 722 | icalvalue_reset_kind(impl); |
824 | } | 723 | } |
825 | enum icalproperty_action icalvalue_get_action(icalvalue* value) { | 724 | enum icalproperty_method icalvalue_get_method(const icalvalue* value) { |
826 | 725 | ||
827 | icalerror_check_arg( (value!=0),"value"); | 726 | icalerror_check_arg( (value!=0),"value"); |
828 | icalerror_check_value_type(value, ICAL_ACTION_VALUE); | 727 | icalerror_check_value_type(value, ICAL_METHOD_VALUE); |
829 | return ((struct icalvalue_impl*)value)->data.v_enum; | 728 | return ((struct icalvalue_impl*)value)->data.v_enum; |
830 | } | 729 | } |
831 | 730 | ||
832 | 731 | ||
732 | int icalvalue_kind_is_valid(const icalvalue_kind kind) | ||
733 | { | ||
734 | int i = 0; | ||
735 | do { | ||
736 | if (value_map[i].kind == kind) | ||
737 | return 1; | ||
738 | } while (value_map[i++].kind != ICAL_NO_VALUE); | ||
833 | 739 | ||
834 | icalvalue* icalvalue_new_caladdress (const char* v){ | 740 | return 0; |
835 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE); | 741 | } |
742 | |||
743 | const char* icalvalue_kind_to_string(const icalvalue_kind kind) | ||
744 | { | ||
745 | int i; | ||
746 | |||
747 | for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { | ||
748 | if (value_map[i].kind == kind) { | ||
749 | return value_map[i].name; | ||
750 | } | ||
751 | } | ||
752 | |||
753 | return 0; | ||
754 | } | ||
755 | |||
756 | icalvalue_kind icalvalue_string_to_kind(const char* str) | ||
757 | { | ||
758 | int i; | ||
759 | |||
760 | for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { | ||
761 | if (strcmp(value_map[i].name,str) == 0) { | ||
762 | return value_map[i].kind; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | return value_map[i].kind; | ||
767 | |||
768 | } | ||
769 | |||
770 | icalvalue* icalvalue_new_x (const char* v){ | ||
771 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE); | ||
836 | icalerror_check_arg_rz( (v!=0),"v"); | 772 | icalerror_check_arg_rz( (v!=0),"v"); |
837 | 773 | ||
838 | icalvalue_set_caladdress((icalvalue*)impl,v); | 774 | icalvalue_set_x((icalvalue*)impl,v); |
839 | return (icalvalue*)impl; | 775 | return (icalvalue*)impl; |
840 | } | 776 | } |
841 | void icalvalue_set_caladdress(icalvalue* value, const char* v) { | 777 | void icalvalue_set_x(icalvalue* impl, const char* v) { |
842 | struct icalvalue_impl* impl; | 778 | icalerror_check_arg_rv( (impl!=0),"value"); |
843 | icalerror_check_arg_rv( (value!=0),"value"); | ||
844 | icalerror_check_arg_rv( (v!=0),"v"); | 779 | icalerror_check_arg_rv( (v!=0),"v"); |
845 | 780 | ||
846 | icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); | 781 | if(impl->x_value!=0) {free((void*)impl->x_value);} |
847 | impl = (struct icalvalue_impl*)value; | ||
848 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | ||
849 | |||
850 | 782 | ||
851 | impl->data.v_string = icalmemory_strdup(v); | 783 | impl->x_value = icalmemory_strdup(v); |
852 | 784 | ||
853 | if (impl->data.v_string == 0){ | 785 | if (impl->x_value == 0){ |
854 | errno = ENOMEM; | 786 | errno = ENOMEM; |
855 | } | 787 | } |
856 | 788 | ||
857 | 789 | } | |
858 | icalvalue_reset_kind(impl); | 790 | const char* icalvalue_get_x(const icalvalue* value) { |
859 | } | ||
860 | const char* icalvalue_get_caladdress(icalvalue* value) { | ||
861 | 791 | ||
862 | icalerror_check_arg( (value!=0),"value"); | 792 | icalerror_check_arg( (value!=0),"value"); |
863 | icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); | 793 | icalerror_check_value_type(value, ICAL_X_VALUE); |
864 | return ((struct icalvalue_impl*)value)->data.v_string; | 794 | return value->x_value; |
865 | } | 795 | } |
866 | 796 | ||
797 | /* Recur is a special case, so it is not auto generated. */ | ||
798 | icalvalue* | ||
799 | icalvalue_new_recur (struct icalrecurrencetype v) | ||
800 | { | ||
801 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE); | ||
802 | |||
803 | icalvalue_set_recur((icalvalue*)impl,v); | ||
867 | 804 | ||
868 | |||
869 | icalvalue* icalvalue_new_float (float v){ | ||
870 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_FLOAT_VALUE); | ||
871 | |||
872 | icalvalue_set_float((icalvalue*)impl,v); | ||
873 | return (icalvalue*)impl; | 805 | return (icalvalue*)impl; |
874 | } | 806 | } |
875 | void icalvalue_set_float(icalvalue* value, float v) { | ||
876 | struct icalvalue_impl* impl; | ||
877 | icalerror_check_arg_rv( (value!=0),"value"); | ||
878 | |||
879 | icalerror_check_value_type(value, ICAL_FLOAT_VALUE); | ||
880 | impl = (struct icalvalue_impl*)value; | ||
881 | 807 | ||
808 | void | ||
809 | icalvalue_set_recur(icalvalue* impl, struct icalrecurrencetype v) | ||
810 | { | ||
811 | icalerror_check_arg_rv( (impl!=0),"value"); | ||
812 | icalerror_check_value_type(value, ICAL_RECUR_VALUE); | ||
882 | 813 | ||
883 | impl->data.v_float = v; | 814 | if (impl->data.v_recur != 0){ |
815 | free(impl->data.v_recur); | ||
816 | impl->data.v_recur = 0; | ||
817 | } | ||
884 | 818 | ||
885 | icalvalue_reset_kind(impl); | 819 | impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); |
820 | |||
821 | if (impl->data.v_recur == 0){ | ||
822 | icalerror_set_errno(ICAL_NEWFAILED_ERROR); | ||
823 | return; | ||
824 | } else { | ||
825 | memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype)); | ||
826 | } | ||
827 | |||
886 | } | 828 | } |
887 | float icalvalue_get_float(icalvalue* value) { | ||
888 | 829 | ||
830 | struct icalrecurrencetype | ||
831 | icalvalue_get_recur(const icalvalue* value) | ||
832 | { | ||
889 | icalerror_check_arg( (value!=0),"value"); | 833 | icalerror_check_arg( (value!=0),"value"); |
890 | icalerror_check_value_type(value, ICAL_FLOAT_VALUE); | 834 | icalerror_check_value_type(value, ICAL_RECUR_VALUE); |
891 | return ((struct icalvalue_impl*)value)->data.v_float; | 835 | |
836 | return *(value->data.v_recur); | ||
892 | } | 837 | } |
893 | 838 | ||
894 | 839 | ||
895 | 840 | ||
896 | icalvalue* icalvalue_new_requeststatus (struct icalreqstattype v){ | 841 | |
897 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_REQUESTSTATUS_VALUE); | 842 | icalvalue* |
898 | 843 | icalvalue_new_trigger (struct icaltriggertype v) | |
899 | icalvalue_set_requeststatus((icalvalue*)impl,v); | 844 | { |
845 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE); | ||
846 | |||
847 | icalvalue_set_trigger((icalvalue*)impl,v); | ||
848 | |||
900 | return (icalvalue*)impl; | 849 | return (icalvalue*)impl; |
901 | } | 850 | } |
902 | void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) { | 851 | |
903 | struct icalvalue_impl* impl; | 852 | void |
853 | icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v) | ||
854 | { | ||
904 | icalerror_check_arg_rv( (value!=0),"value"); | 855 | icalerror_check_arg_rv( (value!=0),"value"); |
905 | 856 | ||
906 | icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE); | 857 | if(!icaltime_is_null_time(v.time)){ |
907 | impl = (struct icalvalue_impl*)value; | 858 | icalvalue_set_datetime(value,v.time); |
859 | value->kind = ICAL_DATETIME_VALUE; | ||
860 | } else { | ||
861 | icalvalue_set_duration(value,v.duration); | ||
862 | value->kind = ICAL_DURATION_VALUE; | ||
863 | } | ||
864 | } | ||
908 | 865 | ||
866 | struct icaltriggertype | ||
867 | icalvalue_get_trigger(const icalvalue* impl) | ||
868 | { | ||
869 | struct icaltriggertype tr; | ||
909 | 870 | ||
910 | impl->data.v_requeststatus = v; | 871 | icalerror_check_arg( (impl!=0),"value"); |
872 | icalerror_check_arg( (impl!=0),"value"); | ||
911 | 873 | ||
912 | icalvalue_reset_kind(impl); | 874 | if(impl->kind == ICAL_DATETIME_VALUE){ |
913 | } | 875 | tr.duration = icaldurationtype_from_int(0); |
914 | struct icalreqstattype icalvalue_get_requeststatus(icalvalue* value) { | 876 | tr.time = impl->data.v_time; |
877 | } else if(impl->kind == ICAL_DURATION_VALUE){ | ||
878 | tr.time = icaltime_null_time(); | ||
879 | tr.duration = impl->data.v_duration; | ||
880 | } else { | ||
881 | tr.duration = icaldurationtype_from_int(0); | ||
882 | tr.time = icaltime_null_time(); | ||
883 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
884 | } | ||
915 | 885 | ||
916 | icalerror_check_arg( (value!=0),"value"); | 886 | return tr; |
917 | icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE); | ||
918 | return ((struct icalvalue_impl*)value)->data.v_requeststatus; | ||
919 | } | 887 | } |
920 | 888 | ||
889 | /* DATE-TIME-PERIOD is a special case, and is not auto generated */ | ||
921 | 890 | ||
891 | icalvalue* | ||
892 | icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v) | ||
893 | { | ||
894 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE); | ||
895 | |||
896 | icalvalue_set_datetimeperiod(impl,v); | ||
922 | 897 | ||
923 | icalvalue* icalvalue_new_method (enum icalproperty_method v){ | ||
924 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_METHOD_VALUE); | ||
925 | |||
926 | icalvalue_set_method((icalvalue*)impl,v); | ||
927 | return (icalvalue*)impl; | 898 | return (icalvalue*)impl; |
928 | } | 899 | } |
929 | void icalvalue_set_method(icalvalue* value, enum icalproperty_method v) { | ||
930 | struct icalvalue_impl* impl; | ||
931 | icalerror_check_arg_rv( (value!=0),"value"); | ||
932 | |||
933 | icalerror_check_value_type(value, ICAL_METHOD_VALUE); | ||
934 | impl = (struct icalvalue_impl*)value; | ||
935 | |||
936 | 900 | ||
937 | impl->data.v_enum = v; | 901 | void |
902 | icalvalue_set_datetimeperiod(icalvalue* impl, struct icaldatetimeperiodtype v) | ||
903 | { | ||
904 | icalerror_check_arg_rv( (impl!=0),"value"); | ||
905 | |||
906 | icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); | ||
938 | 907 | ||
939 | icalvalue_reset_kind(impl); | 908 | if(!icaltime_is_null_time(v.time)){ |
909 | if(!icaltime_is_valid_time(v.time)){ | ||
910 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
911 | return; | ||
912 | } | ||
913 | impl->kind = ICAL_DATETIME_VALUE; | ||
914 | icalvalue_set_datetime(impl,v.time); | ||
915 | } else if (!icalperiodtype_is_null_period(v.period)) { | ||
916 | if(!icalperiodtype_is_valid_period(v.period)){ | ||
917 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
918 | return; | ||
919 | } | ||
920 | impl->kind = ICAL_PERIOD_VALUE; | ||
921 | icalvalue_set_period(impl,v.period); | ||
922 | } else { | ||
923 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
924 | } | ||
940 | } | 925 | } |
941 | enum icalproperty_method icalvalue_get_method(icalvalue* value) { | ||
942 | 926 | ||
943 | icalerror_check_arg( (value!=0),"value"); | 927 | struct icaldatetimeperiodtype |
944 | icalerror_check_value_type(value, ICAL_METHOD_VALUE); | 928 | icalvalue_get_datetimeperiod(const icalvalue* impl) |
945 | return ((struct icalvalue_impl*)value)->data.v_enum; | 929 | { |
946 | } | 930 | struct icaldatetimeperiodtype dtp; |
931 | |||
932 | icalerror_check_arg( (impl!=0),"value"); | ||
933 | icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); | ||
934 | |||
935 | if(impl->kind == ICAL_DATETIME_VALUE){ | ||
936 | dtp.period = icalperiodtype_null_period(); | ||
937 | dtp.time = impl->data.v_time; | ||
938 | } else if(impl->kind == ICAL_PERIOD_VALUE) { | ||
939 | dtp.period = impl->data.v_period; | ||
940 | dtp.time = icaltime_null_time(); | ||
941 | } else { | ||
942 | dtp.period = icalperiodtype_null_period(); | ||
943 | dtp.time = icaltime_null_time(); | ||
944 | icalerror_set_errno(ICAL_BADARG_ERROR); | ||
945 | } | ||
947 | 946 | ||
947 | return dtp; | ||
948 | } | ||
948 | 949 | ||
949 | 950 | ||
950 | icalvalue* icalvalue_new_binary (const char* v){ | ||
951 | struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_BINARY_VALUE); | ||
952 | icalerror_check_arg_rz( (v!=0),"v"); | ||
953 | 951 | ||
954 | icalvalue_set_binary((icalvalue*)impl,v); | 952 | icalvalue * |
955 | return (icalvalue*)impl; | 953 | icalvalue_new_attach (icalattach *attach) |
956 | } | 954 | { |
957 | void icalvalue_set_binary(icalvalue* value, const char* v) { | 955 | struct icalvalue_impl *impl; |
958 | struct icalvalue_impl* impl; | ||
959 | icalerror_check_arg_rv( (value!=0),"value"); | ||
960 | icalerror_check_arg_rv( (v!=0),"v"); | ||
961 | 956 | ||
962 | icalerror_check_value_type(value, ICAL_BINARY_VALUE); | 957 | icalerror_check_arg_rz ((attach != NULL), "attach"); |
963 | impl = (struct icalvalue_impl*)value; | ||
964 | if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} | ||
965 | 958 | ||
959 | impl = icalvalue_new_impl (ICAL_ATTACH_VALUE); | ||
960 | if (!impl) { | ||
961 | errno = ENOMEM; | ||
962 | return NULL; | ||
963 | } | ||
966 | 964 | ||
967 | impl->data.v_string = icalmemory_strdup(v); | 965 | icalvalue_set_attach ((icalvalue *) impl, attach); |
966 | return (icalvalue *) impl; | ||
967 | } | ||
968 | 968 | ||
969 | if (impl->data.v_string == 0){ | 969 | void |
970 | errno = ENOMEM; | 970 | icalvalue_set_attach (icalvalue *value, icalattach *attach) |
971 | } | 971 | { |
972 | struct icalvalue_impl *impl; | ||
973 | |||
974 | icalerror_check_arg_rv ((value != NULL), "value"); | ||
975 | icalerror_check_value_type (value, ICAL_ATTACH_VALUE); | ||
976 | icalerror_check_arg_rv ((attach != NULL), "attach"); | ||
977 | |||
978 | impl = (struct icalvalue_impl *) value; | ||
972 | 979 | ||
980 | icalattach_ref (attach); | ||
973 | 981 | ||
974 | icalvalue_reset_kind(impl); | 982 | if (impl->data.v_attach) |
983 | icalattach_unref (impl->data.v_attach); | ||
984 | |||
985 | impl->data.v_attach = attach; | ||
975 | } | 986 | } |
976 | const char* icalvalue_get_binary(icalvalue* value) { | ||
977 | 987 | ||
978 | icalerror_check_arg( (value!=0),"value"); | 988 | icalattach * |
979 | icalerror_check_value_type(value, ICAL_BINARY_VALUE); | 989 | icalvalue_get_attach (const icalvalue *value) |
980 | return ((struct icalvalue_impl*)value)->data.v_string; | 990 | { |
991 | icalerror_check_arg_rz ((value != NULL), "value"); | ||
992 | icalerror_check_value_type (value, ICAL_ATTACH_VALUE); | ||
993 | |||
994 | return value->data.v_attach; | ||
981 | } | 995 | } |
996 | |||
997 | |||
998 | |||
999 | |||
1000 | |||
1001 | |||
1002 | |||
1003 | /* The remaining interfaces are 'new', 'set' and 'get' for each of the value | ||
1004 | types */ | ||
1005 | |||
1006 | |||
1007 | /* Everything below this line is machine generated. Do not edit. */ | ||