summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalderivedvalue.c
Unidiff
Diffstat (limited to 'libical/src/libical/icalderivedvalue.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalderivedvalue.c981
1 files changed, 981 insertions, 0 deletions
diff --git a/libical/src/libical/icalderivedvalue.c b/libical/src/libical/icalderivedvalue.c
new file mode 100644
index 0000000..db762ea
--- a/dev/null
+++ b/libical/src/libical/icalderivedvalue.c
@@ -0,0 +1,981 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalvalue.c
4 CREATOR: eric 02 May 1999
5
6 $Id$
7
8
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The original code is icalvalue.c
23
24 Contributions from:
25 Graham Davison (g.m.davison@computer.org)
26
27
28======================================================================*/
29
30#ifdef HAVE_CONFIG_H
31#include <config.h>
32#endif
33
34#include "icalerror.h"
35#include "icalmemory.h"
36#include "icalparser.h"
37#include "icalenums.h"
38
39#include "icalvalueimpl.h"
40
41#include <stdlib.h> /* for malloc */
42#include <stdio.h> /* for sprintf */
43#include <string.h> /* For memset, others */
44#include <stddef.h> /* For offsetof() macro */
45#include <errno.h>
46#include <time.h> /* for mktime */
47#include <stdlib.h> /* for atoi and atof */
48#include <limits.h> /* for SHRT_MAX */
49
50
51
52#define TMP_BUF_SIZE 1024
53
54struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind);
55
56/* This map associates each of the value types with its string
57 representation */
58struct icalvalue_kind_map {
59 icalvalue_kind kind;
60 char name[20];
61};
62
63extern struct icalvalue_kind_map value_map[];
64
65const char* icalvalue_kind_to_string(icalvalue_kind kind)
66{
67 int i;
68
69 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
70 if (value_map[i].kind == kind) {
71 return value_map[i].name;
72 }
73 }
74
75 return 0;
76}
77
78icalvalue_kind icalvalue_string_to_kind(const char* str)
79{
80 int i;
81
82 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
83 if (strcmp(value_map[i].name,str) == 0) {
84 return value_map[i].kind;
85 }
86 }
87
88 return value_map[i].kind;
89
90}
91
92icalvalue* icalvalue_new_x (const char* v){
93 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE);
94 icalerror_check_arg_rz( (v!=0),"v");
95
96 icalvalue_set_x((icalvalue*)impl,v);
97 return (icalvalue*)impl;
98}
99void icalvalue_set_x(icalvalue* value, const char* v) {
100 struct icalvalue_impl* impl;
101 icalerror_check_arg_rv( (value!=0),"value");
102 icalerror_check_arg_rv( (v!=0),"v");
103
104 impl = (struct icalvalue_impl*)value;
105 if(impl->x_value!=0) {free((void*)impl->x_value);}
106
107 impl->x_value = icalmemory_strdup(v);
108
109 if (impl->x_value == 0){
110 errno = ENOMEM;
111 }
112
113 }
114const char* icalvalue_get_x(icalvalue* value) {
115
116 icalerror_check_arg( (value!=0),"value");
117 icalerror_check_value_type(value, ICAL_X_VALUE);
118 return ((struct icalvalue_impl*)value)->x_value;
119}
120
121/* Attachment is a special case, so it is not auto generated. */
122icalvalue*
123icalvalue_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
129 return (icalvalue*)impl;
130}
131
132void
133icalvalue_set_attach(icalvalue* value, struct icalattachtype *v)
134{
135 struct icalvalue_impl* impl;
136
137 icalerror_check_arg_rv( (value!=0),"value");
138 icalerror_check_value_type(value, ICAL_ATTACH_VALUE);
139
140 impl = (struct icalvalue_impl*)value;
141
142 if (impl->data.v_attach != 0){
143 icalattachtype_free(impl->data.v_attach);
144 }
145
146 impl->data.v_attach = v;
147 icalattachtype_add_reference(v);
148}
149
150struct icalattachtype*
151icalvalue_get_attach(icalvalue* value)
152{
153 icalerror_check_arg( (value!=0),"value");
154 icalerror_check_value_type(value, ICAL_ATTACH_VALUE);
155
156 return ((struct icalvalue_impl*)value)->data.v_attach;
157}
158
159
160/* Recur is a special case, so it is not auto generated. */
161icalvalue*
162icalvalue_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
168 return (icalvalue*)impl;
169}
170
171void
172icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v)
173{
174 struct icalvalue_impl* impl;
175
176 icalerror_check_arg_rv( (value!=0),"value");
177 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
178
179 impl = (struct icalvalue_impl*)value;
180
181 if (impl->data.v_recur != 0){
182 free(impl->data.v_recur);
183 impl->data.v_recur = 0;
184 }
185
186 impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
187
188 if (impl->data.v_recur == 0){
189 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
190 return;
191 } else {
192 memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
193 }
194
195}
196
197struct icalrecurrencetype
198icalvalue_get_recur(icalvalue* value)
199{
200 icalerror_check_arg( (value!=0),"value");
201 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
202
203 return *(((struct icalvalue_impl*)value)->data.v_recur);
204}
205
206
207
208
209icalvalue*
210icalvalue_new_trigger (struct icaltriggertype v)
211{
212 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
213
214 icalvalue_set_trigger((icalvalue*)impl,v);
215
216 return (icalvalue*)impl;
217}
218
219void
220icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
221{
222 struct icalvalue_impl* impl;
223
224 icalerror_check_arg_rv( (value!=0),"value");
225
226 impl = (struct icalvalue_impl*)value;
227
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
236}
237
238struct icaltriggertype
239icalvalue_get_trigger(icalvalue* value)
240{
241 struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
242 struct icaltriggertype tr;
243
244 icalerror_check_arg( (value!=0),"value");
245 icalerror_check_arg( (value!=0),"value");
246
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}
261
262/* DATE-TIME-PERIOD is a special case, and is not auto generated */
263
264icalvalue*
265icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
266{
267 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);
268
269 icalvalue_set_datetimeperiod((icalvalue*)impl,v);
270
271 return (icalvalue*)impl;
272}
273
274void
275icalvalue_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");
280
281 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
282
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
302struct icaldatetimeperiodtype
303icalvalue_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
323 return dtp;
324}
325
326
327
328
329
330
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. */
339static 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
370icalvalue* 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");
373
374 icalvalue_set_query((icalvalue*)impl,v);
375 return (icalvalue*)impl;
376}
377void icalvalue_set_query(icalvalue* value, const char* v) {
378 struct icalvalue_impl* impl;
379 icalerror_check_arg_rv( (value!=0),"value");
380 icalerror_check_arg_rv( (v!=0),"v");
381
382 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
383 impl = (struct icalvalue_impl*)value;
384 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
385
386
387 impl->data.v_string = icalmemory_strdup(v);
388
389 if (impl->data.v_string == 0){
390 errno = ENOMEM;
391 }
392
393
394 icalvalue_reset_kind(impl);
395}
396const char* icalvalue_get_query(icalvalue* value) {
397
398 icalerror_check_arg( (value!=0),"value");
399 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
400 return ((struct icalvalue_impl*)value)->data.v_string;
401}
402
403
404
405icalvalue* icalvalue_new_status (enum icalproperty_status v){
406 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STATUS_VALUE);
407
408 icalvalue_set_status((icalvalue*)impl,v);
409 return (icalvalue*)impl;
410}
411void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) {
412 struct icalvalue_impl* impl;
413 icalerror_check_arg_rv( (value!=0),"value");
414
415 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
416 impl = (struct icalvalue_impl*)value;
417
418
419 impl->data.v_enum = v;
420
421 icalvalue_reset_kind(impl);
422}
423enum icalproperty_status icalvalue_get_status(icalvalue* value) {
424
425 icalerror_check_arg( (value!=0),"value");
426 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
427 return ((struct icalvalue_impl*)value)->data.v_enum;
428}
429
430
431
432icalvalue* icalvalue_new_transp (enum icalproperty_transp v){
433 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRANSP_VALUE);
434
435 icalvalue_set_transp((icalvalue*)impl,v);
436 return (icalvalue*)impl;
437}
438void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
439 struct icalvalue_impl* impl;
440 icalerror_check_arg_rv( (value!=0),"value");
441
442 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
443 impl = (struct icalvalue_impl*)value;
444
445
446 impl->data.v_enum = v;
447
448 icalvalue_reset_kind(impl);
449}
450enum icalproperty_transp icalvalue_get_transp(icalvalue* value) {
451
452 icalerror_check_arg( (value!=0),"value");
453 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
454 return ((struct icalvalue_impl*)value)->data.v_enum;
455}
456
457
458
459icalvalue* icalvalue_new_class (enum icalproperty_class v){
460 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE);
461
462 icalvalue_set_class((icalvalue*)impl,v);
463 return (icalvalue*)impl;
464}
465void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) {
466 struct icalvalue_impl* impl;
467 icalerror_check_arg_rv( (value!=0),"value");
468
469 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
470 impl = (struct icalvalue_impl*)value;
471
472
473 impl->data.v_enum = v;
474
475 icalvalue_reset_kind(impl);
476}
477enum icalproperty_class icalvalue_get_class(icalvalue* value) {
478
479 icalerror_check_arg( (value!=0),"value");
480 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
481 return ((struct icalvalue_impl*)value)->data.v_enum;
482}
483
484
485
486icalvalue* icalvalue_new_date (struct icaltimetype v){
487 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATE_VALUE);
488
489 icalvalue_set_date((icalvalue*)impl,v);
490 return (icalvalue*)impl;
491}
492void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
493 struct icalvalue_impl* impl;
494 icalerror_check_arg_rv( (value!=0),"value");
495
496 icalerror_check_value_type(value, ICAL_DATE_VALUE);
497 impl = (struct icalvalue_impl*)value;
498
499
500 impl->data.v_time = v;
501
502 icalvalue_reset_kind(impl);
503}
504struct icaltimetype icalvalue_get_date(icalvalue* value) {
505
506 icalerror_check_arg( (value!=0),"value");
507 icalerror_check_value_type(value, ICAL_DATE_VALUE);
508 return ((struct icalvalue_impl*)value)->data.v_time;
509}
510
511
512
513icalvalue* icalvalue_new_string (const char* v){
514 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STRING_VALUE);
515 icalerror_check_arg_rz( (v!=0),"v");
516
517 icalvalue_set_string((icalvalue*)impl,v);
518 return (icalvalue*)impl;
519}
520void icalvalue_set_string(icalvalue* value, const char* v) {
521 struct icalvalue_impl* impl;
522 icalerror_check_arg_rv( (value!=0),"value");
523 icalerror_check_arg_rv( (v!=0),"v");
524
525 icalerror_check_value_type(value, ICAL_STRING_VALUE);
526 impl = (struct icalvalue_impl*)value;
527 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
528
529
530 impl->data.v_string = icalmemory_strdup(v);
531
532 if (impl->data.v_string == 0){
533 errno = ENOMEM;
534 }
535
536
537 icalvalue_reset_kind(impl);
538}
539const char* icalvalue_get_string(icalvalue* value) {
540
541 icalerror_check_arg( (value!=0),"value");
542 icalerror_check_value_type(value, ICAL_STRING_VALUE);
543 return ((struct icalvalue_impl*)value)->data.v_string;
544}
545
546
547
548icalvalue* icalvalue_new_integer (int v){
549 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_INTEGER_VALUE);
550
551 icalvalue_set_integer((icalvalue*)impl,v);
552 return (icalvalue*)impl;
553}
554void icalvalue_set_integer(icalvalue* value, int v) {
555 struct icalvalue_impl* impl;
556 icalerror_check_arg_rv( (value!=0),"value");
557
558 icalerror_check_value_type(value, ICAL_INTEGER_VALUE);
559 impl = (struct icalvalue_impl*)value;
560
561
562 impl->data.v_int = v;
563
564 icalvalue_reset_kind(impl);
565}
566int icalvalue_get_integer(icalvalue* value) {
567
568 icalerror_check_arg( (value!=0),"value");
569 icalerror_check_value_type(value, ICAL_INTEGER_VALUE);
570 return ((struct icalvalue_impl*)value)->data.v_int;
571}
572
573
574
575icalvalue* icalvalue_new_period (struct icalperiodtype v){
576 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_PERIOD_VALUE);
577
578 icalvalue_set_period((icalvalue*)impl,v);
579 return (icalvalue*)impl;
580}
581void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
582 struct icalvalue_impl* impl;
583 icalerror_check_arg_rv( (value!=0),"value");
584
585 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
586 impl = (struct icalvalue_impl*)value;
587
588
589 impl->data.v_period = v;
590
591 icalvalue_reset_kind(impl);
592}
593struct icalperiodtype icalvalue_get_period(icalvalue* value) {
594
595 icalerror_check_arg( (value!=0),"value");
596 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
597 return ((struct icalvalue_impl*)value)->data.v_period;
598}
599
600
601
602icalvalue* icalvalue_new_text (const char* v){
603 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TEXT_VALUE);
604 icalerror_check_arg_rz( (v!=0),"v");
605
606 icalvalue_set_text((icalvalue*)impl,v);
607 return (icalvalue*)impl;
608}
609void icalvalue_set_text(icalvalue* value, const char* v) {
610 struct icalvalue_impl* impl;
611 icalerror_check_arg_rv( (value!=0),"value");
612 icalerror_check_arg_rv( (v!=0),"v");
613
614 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
615 impl = (struct icalvalue_impl*)value;
616 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
617
618
619 impl->data.v_string = icalmemory_strdup(v);
620
621 if (impl->data.v_string == 0){
622 errno = ENOMEM;
623 }
624
625
626 icalvalue_reset_kind(impl);
627}
628const char* icalvalue_get_text(icalvalue* value) {
629
630 icalerror_check_arg( (value!=0),"value");
631 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
632 return ((struct icalvalue_impl*)value)->data.v_string;
633}
634
635
636
637icalvalue* icalvalue_new_duration (struct icaldurationtype v){
638 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DURATION_VALUE);
639
640 icalvalue_set_duration((icalvalue*)impl,v);
641 return (icalvalue*)impl;
642}
643void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) {
644 struct icalvalue_impl* impl;
645 icalerror_check_arg_rv( (value!=0),"value");
646
647 icalerror_check_value_type(value, ICAL_DURATION_VALUE);
648 impl = (struct icalvalue_impl*)value;
649
650
651 impl->data.v_duration = v;
652
653 icalvalue_reset_kind(impl);
654}
655struct icaldurationtype icalvalue_get_duration(icalvalue* value) {
656
657 icalerror_check_arg( (value!=0),"value");
658 icalerror_check_value_type(value, ICAL_DURATION_VALUE);
659 return ((struct icalvalue_impl*)value)->data.v_duration;
660}
661
662
663
664icalvalue* icalvalue_new_boolean (int v){
665 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_BOOLEAN_VALUE);
666
667 icalvalue_set_boolean((icalvalue*)impl,v);
668 return (icalvalue*)impl;
669}
670void icalvalue_set_boolean(icalvalue* value, int v) {
671 struct icalvalue_impl* impl;
672 icalerror_check_arg_rv( (value!=0),"value");
673
674 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
675 impl = (struct icalvalue_impl*)value;
676
677
678 impl->data.v_int = v;
679
680 icalvalue_reset_kind(impl);
681}
682int icalvalue_get_boolean(icalvalue* value) {
683
684 icalerror_check_arg( (value!=0),"value");
685 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
686 return ((struct icalvalue_impl*)value)->data.v_int;
687}
688
689
690
691icalvalue* icalvalue_new_uri (const char* v){
692 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_URI_VALUE);
693 icalerror_check_arg_rz( (v!=0),"v");
694
695 icalvalue_set_uri((icalvalue*)impl,v);
696 return (icalvalue*)impl;
697}
698void icalvalue_set_uri(icalvalue* value, const char* v) {
699 struct icalvalue_impl* impl;
700 icalerror_check_arg_rv( (value!=0),"value");
701 icalerror_check_arg_rv( (v!=0),"v");
702
703 icalerror_check_value_type(value, ICAL_URI_VALUE);
704 impl = (struct icalvalue_impl*)value;
705 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
706
707
708 impl->data.v_string = icalmemory_strdup(v);
709
710 if (impl->data.v_string == 0){
711 errno = ENOMEM;
712 }
713
714
715 icalvalue_reset_kind(impl);
716}
717const char* icalvalue_get_uri(icalvalue* value) {
718
719 icalerror_check_arg( (value!=0),"value");
720 icalerror_check_value_type(value, ICAL_URI_VALUE);
721 return ((struct icalvalue_impl*)value)->data.v_string;
722}
723
724
725
726icalvalue* icalvalue_new_geo (struct icalgeotype v){
727 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE);
728
729 icalvalue_set_geo((icalvalue*)impl,v);
730 return (icalvalue*)impl;
731}
732void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
733 struct icalvalue_impl* impl;
734 icalerror_check_arg_rv( (value!=0),"value");
735
736 icalerror_check_value_type(value, ICAL_GEO_VALUE);
737 impl = (struct icalvalue_impl*)value;
738
739
740 impl->data.v_geo = v;
741
742 icalvalue_reset_kind(impl);
743}
744struct icalgeotype icalvalue_get_geo(icalvalue* value) {
745
746 icalerror_check_arg( (value!=0),"value");
747 icalerror_check_value_type(value, ICAL_GEO_VALUE);
748 return ((struct icalvalue_impl*)value)->data.v_geo;
749}
750
751
752
753icalvalue* icalvalue_new_datetime (struct icaltimetype v){
754 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIME_VALUE);
755
756 icalvalue_set_datetime((icalvalue*)impl,v);
757 return (icalvalue*)impl;
758}
759void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) {
760 struct icalvalue_impl* impl;
761 icalerror_check_arg_rv( (value!=0),"value");
762
763 icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
764 impl = (struct icalvalue_impl*)value;
765
766
767 impl->data.v_time = v;
768
769 icalvalue_reset_kind(impl);
770}
771struct icaltimetype icalvalue_get_datetime(icalvalue* value) {
772
773 icalerror_check_arg( (value!=0),"value");
774 icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
775 return ((struct icalvalue_impl*)value)->data.v_time;
776}
777
778
779
780icalvalue* icalvalue_new_utcoffset (int v){
781 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_UTCOFFSET_VALUE);
782
783 icalvalue_set_utcoffset((icalvalue*)impl,v);
784 return (icalvalue*)impl;
785}
786void icalvalue_set_utcoffset(icalvalue* value, int v) {
787 struct icalvalue_impl* impl;
788 icalerror_check_arg_rv( (value!=0),"value");
789
790 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
791 impl = (struct icalvalue_impl*)value;
792
793
794 impl->data.v_int = v;
795
796 icalvalue_reset_kind(impl);
797}
798int icalvalue_get_utcoffset(icalvalue* value) {
799
800 icalerror_check_arg( (value!=0),"value");
801 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
802 return ((struct icalvalue_impl*)value)->data.v_int;
803}
804
805
806
807icalvalue* icalvalue_new_action (enum icalproperty_action v){
808 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ACTION_VALUE);
809
810 icalvalue_set_action((icalvalue*)impl,v);
811 return (icalvalue*)impl;
812}
813void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
814 struct icalvalue_impl* impl;
815 icalerror_check_arg_rv( (value!=0),"value");
816
817 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
818 impl = (struct icalvalue_impl*)value;
819
820
821 impl->data.v_enum = v;
822
823 icalvalue_reset_kind(impl);
824}
825enum icalproperty_action icalvalue_get_action(icalvalue* value) {
826
827 icalerror_check_arg( (value!=0),"value");
828 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
829 return ((struct icalvalue_impl*)value)->data.v_enum;
830}
831
832
833
834icalvalue* icalvalue_new_caladdress (const char* v){
835 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE);
836 icalerror_check_arg_rz( (v!=0),"v");
837
838 icalvalue_set_caladdress((icalvalue*)impl,v);
839 return (icalvalue*)impl;
840}
841void icalvalue_set_caladdress(icalvalue* value, const char* v) {
842 struct icalvalue_impl* impl;
843 icalerror_check_arg_rv( (value!=0),"value");
844 icalerror_check_arg_rv( (v!=0),"v");
845
846 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
847 impl = (struct icalvalue_impl*)value;
848 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
849
850
851 impl->data.v_string = icalmemory_strdup(v);
852
853 if (impl->data.v_string == 0){
854 errno = ENOMEM;
855 }
856
857
858 icalvalue_reset_kind(impl);
859}
860const char* icalvalue_get_caladdress(icalvalue* value) {
861
862 icalerror_check_arg( (value!=0),"value");
863 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
864 return ((struct icalvalue_impl*)value)->data.v_string;
865}
866
867
868
869icalvalue* 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;
874}
875void 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
882
883 impl->data.v_float = v;
884
885 icalvalue_reset_kind(impl);
886}
887float icalvalue_get_float(icalvalue* value) {
888
889 icalerror_check_arg( (value!=0),"value");
890 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
891 return ((struct icalvalue_impl*)value)->data.v_float;
892}
893
894
895
896icalvalue* icalvalue_new_requeststatus (struct icalreqstattype v){
897 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_REQUESTSTATUS_VALUE);
898
899 icalvalue_set_requeststatus((icalvalue*)impl,v);
900 return (icalvalue*)impl;
901}
902void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) {
903 struct icalvalue_impl* impl;
904 icalerror_check_arg_rv( (value!=0),"value");
905
906 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
907 impl = (struct icalvalue_impl*)value;
908
909
910 impl->data.v_requeststatus = v;
911
912 icalvalue_reset_kind(impl);
913}
914struct icalreqstattype icalvalue_get_requeststatus(icalvalue* value) {
915
916 icalerror_check_arg( (value!=0),"value");
917 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
918 return ((struct icalvalue_impl*)value)->data.v_requeststatus;
919}
920
921
922
923icalvalue* 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;
928}
929void 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
937 impl->data.v_enum = v;
938
939 icalvalue_reset_kind(impl);
940}
941enum icalproperty_method icalvalue_get_method(icalvalue* value) {
942
943 icalerror_check_arg( (value!=0),"value");
944 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
945 return ((struct icalvalue_impl*)value)->data.v_enum;
946}
947
948
949
950icalvalue* 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
954 icalvalue_set_binary((icalvalue*)impl,v);
955 return (icalvalue*)impl;
956}
957void icalvalue_set_binary(icalvalue* value, const char* v) {
958 struct icalvalue_impl* impl;
959 icalerror_check_arg_rv( (value!=0),"value");
960 icalerror_check_arg_rv( (v!=0),"v");
961
962 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
963 impl = (struct icalvalue_impl*)value;
964 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
965
966
967 impl->data.v_string = icalmemory_strdup(v);
968
969 if (impl->data.v_string == 0){
970 errno = ENOMEM;
971 }
972
973
974 icalvalue_reset_kind(impl);
975}
976const char* icalvalue_get_binary(icalvalue* value) {
977
978 icalerror_check_arg( (value!=0),"value");
979 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
980 return ((struct icalvalue_impl*)value)->data.v_string;
981}