Libical API Documentation 4.0 STABLE VERSION [Visit the v3.0 documentation]
Loading...
Searching...
No Matches
icalvalue.c
Go to the documentation of this file.
1/*======================================================================
2 FILE: icalvalue.c
3 CREATOR: eric 02 May 1999
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7
8 Contributions from:
9 Graham Davison <g.m.davison@computer.org>
10======================================================================*/
11
16
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include "icalvalue.h"
22#include "icalvalueimpl.h"
23#include "icalerror_p.h"
24#include "icallimits.h"
25#include "icalmemory.h"
26#include "icaltime.h"
27
28#include <ctype.h>
29#include <errno.h>
30#include <locale.h>
31#include <stdlib.h>
32
34#define TMP_BUF_SIZE 1024
35
36LIBICAL_ICAL_EXPORT struct icalvalue_impl *icalvalue_new_impl(icalvalue_kind kind)
37{
38 struct icalvalue_impl *v;
39
40 if (!icalvalue_kind_is_valid(kind)) {
41 return NULL;
42 }
43
44 if ((v = (struct icalvalue_impl *)icalmemory_new_buffer(sizeof(struct icalvalue_impl))) == 0) {
46 return 0;
47 }
48
49 v->id = ICAL_STRUCTURE_TYPE_VALUE;
50
51 v->kind = kind;
52 v->size = 0;
53 v->parent = 0;
54 v->x_value = 0;
55 memset(&v->data, 0, sizeof(v->data));
56
57 return v;
58}
60
62{
63 return (icalvalue *)icalvalue_new_impl(kind);
64}
65
67{
68 struct icalvalue_impl *clone;
69
70 clone = icalvalue_new_impl(old->kind);
71
72 if (clone == 0) {
73 return 0;
74 }
75 clone->id = old->id;
76 clone->kind = old->kind;
77 clone->size = old->size;
78
79 switch (clone->kind) {
81 case ICAL_BINARY_VALUE: {
82 /* Hmm. We just ref the attach value, which may not be the right
83 * thing to do. We cannot quite copy the data, anyways, since we
84 * don't know how long it is.
85 */
86 clone->data.v_attach = old->data.v_attach;
87 if (clone->data.v_attach) {
88 icalattach_ref(clone->data.v_attach);
89 }
90
91 break;
92 }
96 case ICAL_TEXT_VALUE:
98 case ICAL_UID_VALUE:
100 case ICAL_URI_VALUE: {
101 if (old->data.v_string != 0) {
102 clone->data.v_string = icalmemory_strdup(old->data.v_string);
103
104 if (clone->data.v_string == 0) {
105 clone->parent = 0;
106 icalvalue_free(clone);
107 return 0;
108 }
109 }
110 break;
111 }
112 case ICAL_ACTION_VALUE: {
113 clone->data = old->data;
114
115 if (old->data.v_enum == ICAL_ACTION_X) {
116 //preserve the custom action string
117 if (old->x_value != 0) {
118 clone->x_value = icalmemory_strdup(old->x_value);
119
120 if (clone->x_value == 0) {
121 clone->parent = 0;
122 icalvalue_free(clone);
123 return 0;
124 }
125 }
126 }
127 break;
128 }
129 case ICAL_RECUR_VALUE: {
130 if (old->data.v_recur != 0) {
131 clone->data.v_recur = icalrecurrencetype_clone(old->data.v_recur);
132 if (clone->data.v_recur == 0) {
133 icalvalue_free(clone);
134 return 0;
135 }
136 }
137 break;
138 }
139
140 case ICAL_X_VALUE: {
141 if (old->x_value != 0) {
142 clone->x_value = icalmemory_strdup(old->x_value);
143
144 if (clone->x_value == 0) {
145 clone->parent = 0;
146 icalvalue_free(clone);
147 return 0;
148 }
149 }
150
151 break;
152 }
153
155 clone->data = old->data;
156 if (old->data.v_requeststatus.debug != 0) {
157 clone->data.v_requeststatus.debug = icalmemory_strdup(old->data.v_requeststatus.debug);
158 if (clone->data.v_requeststatus.debug == 0) {
159 clone->parent = 0;
160 icalvalue_free(clone);
161 return 0;
162 }
163 }
164 break;
165 }
166
167 default: {
168 /* all of the other types are stored as values, not
169 pointers, so we can just copy the whole structure. */
170
171 clone->data = old->data;
172 }
173 }
174
175 return clone;
176}
177
178static char *icalmemory_strdup_and_dequote(const char *str)
179{
180 const char *p;
181 char *out = (char *)icalmemory_new_buffer(sizeof(char) * strlen(str) + 1);
182 char *pout;
183 int wroteNull = 0;
184
185 if (out == 0) {
186 return 0;
187 }
188
189 pout = out;
190
191 /* Stop the loop when encountering a terminator in the source string
192 or if a null has been written to the destination. This prevents
193 reading past the end of the source string if the last character
194 is a backslash. */
195 for (p = str; !wroteNull && *p != 0; p++) {
196 if (*p == '\\') {
197 p++;
198 switch (*p) {
199 case 0: {
200 wroteNull = 1; //stops iteration so p isn't incremented past the end of str
201 *pout = '\0';
202 break;
203 }
204 case 'n':
205 case 'N': {
206 *pout = '\n';
207 break;
208 }
209 case 't':
210 case 'T': {
211 *pout = '\t';
212 break;
213 }
214 case 'r':
215 case 'R': {
216 *pout = '\r';
217 break;
218 }
219 case 'b':
220 case 'B': {
221 *pout = '\b';
222 break;
223 }
224 case 'f':
225 case 'F': {
226 *pout = '\f';
227 break;
228 }
229 case ';':
230 case ',':
231 case '"':
232 case '\\': {
233 *pout = *p;
234 break;
235 }
236 default: {
237 *pout = ' ';
238 }
239 }
240 } else {
241 *pout = *p;
242 }
243
244 pout++;
245 }
246
247 *pout = '\0';
248
249 return out;
250}
251
252/*
253 * Returns a quoted copy of a string
254 * @todo This is not RFC5545 compliant.
255 * The RFC only allows:
256 * TSAFE-CHAR = %x20-21 / %x23-2B / %x2D-39 / %x3C-5B / %x5D-7E / NON-US-ASCII
257 * As such, \t\r\b\f are not allowed, not even escaped
258 */
259static char *icalmemory_strdup_and_quote(const icalvalue *value, const char *unquoted_str)
260{
261 char *str;
262 char *str_p;
263 const char *p;
264 size_t buf_sz;
265 size_t cnt = 0; //track iterations
266
267 buf_sz = strlen(unquoted_str) + 1;
268
269 str_p = str = (char *)icalmemory_new_buffer(buf_sz);
270
271 if (str_p == 0) {
272 return 0;
273 }
274
275 const size_t max_value_chars = icallimit_get(ICAL_LIMIT_VALUE_CHARS);
276 for (p = unquoted_str; *p != 0 && cnt < max_value_chars; p++, cnt++) {
277 switch (*p) {
278 case '\n': {
279 icalmemory_append_string(&str, &str_p, &buf_sz, "\\n");
280 break;
281 }
282
283 /*issue74: \t is not escaped, but embedded literally.*/
284 case '\t': {
285 icalmemory_append_string(&str, &str_p, &buf_sz, "\t");
286 break;
287 }
288
289 /*issue74: \r, \b and \f are not whitespace and are trashed.*/
290 case '\r': {
291 /*icalmemory_append_string(&str,&str_p,&buf_sz,"\\r"); */
292 break;
293 }
294 case '\b': {
295 /*icalmemory_append_string(&str,&str_p,&buf_sz,"\\b"); */
296 break;
297 }
298 case '\f': {
299 /*icalmemory_append_string(&str,&str_p,&buf_sz,"\\f"); */
300 break;
301 }
302
303 case ';':
304 case ',':
305 /* unescaped COMMA is allowed in CATEGORIES property as its
306 considered a list delimiter here, see:
307 https://tools.ietf.org/html/rfc5545#section-3.8.1.2 */
308 if ((icalproperty_isa(value->parent) == ICAL_CATEGORIES_PROPERTY) ||
309 (icalproperty_isa(value->parent) == ICAL_RESOURCES_PROPERTY) ||
311 (icalproperty_isa(value->parent) == ICAL_LOCATIONTYPE_PROPERTY) ||
312 ((icalproperty_isa(value->parent) == ICAL_X_PROPERTY ||
313 icalproperty_isa(value->parent) == ICAL_IANA_PROPERTY) &&
314 icalvalue_isa(value) != ICAL_TEXT_VALUE)) {
315 icalmemory_append_char(&str, &str_p, &buf_sz, *p);
316 break;
317 }
318 _fallthrough();
319 /*issue74, we don't escape double quotes
320 case '"':
321*/
322 case '\\': {
323 icalmemory_append_char(&str, &str_p, &buf_sz, '\\');
324 icalmemory_append_char(&str, &str_p, &buf_sz, *p);
325 break;
326 }
327
328 default: {
329 icalmemory_append_char(&str, &str_p, &buf_sz, *p);
330 }
331 }
332 }
333
334 /* Assume the last character is not a '\0' and add one. We could
335 check *str_p != 0, but that would be an uninitialized memory
336 read. */
337
338 icalmemory_append_char(&str, &str_p, &buf_sz, '\0');
339 return str;
340}
341
342/*
343 * Returns a copy of a string that is written out without escaping.
344 * CR and LF are dropped so that an embedded line break cannot end the
345 * content line early and inject another property.
346 */
347static char *icalmemory_strdup_without_line_breaks(const char *str)
348{
349 const size_t str_len = strlen(str) + 1;
350 char *out = (char *)icalmemory_new_buffer(str_len);
351
352 if (out == 0) {
353 return 0;
354 }
355
356 char *pout = out;
357 for (const char *p = str; *p != 0; p++) {
358 if (*p != '\r' && *p != '\n') {
359 *pout++ = *p;
360 }
361 }
362
363 *pout = '\0';
364
365 return out;
366}
367
368/*
369 * FIXME
370 *
371 * This is a bad API, as it forces callers to specify their own X type.
372 * This function should take care of this by itself.
373 */
374static icalvalue *icalvalue_new_enum(icalvalue_kind kind, int x_type, const char *str)
375{
376 int e = icalproperty_kind_and_string_to_enum((int)kind, str);
377 struct icalvalue_impl *value;
378
380 value = icalvalue_new_impl(kind);
381 value->data.v_enum = e;
382 } else {
383 /* Make it an X value */
384 value = icalvalue_new_impl(kind);
385 value->data.v_enum = x_type;
386 icalvalue_set_x(value, str);
387 }
388
389 return value;
390}
391
398static bool simple_str_to_doublestr(const char *from, char *result, int result_len, char **to)
399{
400 const char *start = NULL;
401 char *end = NULL, *cur = (char *)from;
402
403 struct lconv *loc_data = localeconv();
404 int i = 0, len;
405 double dtest;
406
407 /*sanity checks */
408 if (!from || !result) {
409 return true;
410 }
411
412 /*skip the white spaces at the beginning */
413 while (*cur && isspace((int)*cur)) {
414 cur++;
415 }
416
417 start = cur;
418 /* copy the part that looks like a double into result.
419 * during the copy, we give ourselves a chance to convert the '.'
420 * into the decimal separator of the current locale.
421 */
422 while (*cur && (isdigit((int)*cur) || *cur == '.' || *cur == '+' || *cur == '-')) {
423 ++cur;
424 }
425 end = cur;
426 len = (int)(ptrdiff_t)(end - start);
427 if (len + 1 >= result_len) {
428 /* huh hoh, number is too big. truncate it */
429 len = result_len - 1;
430 }
431
432 /* copy the float number string into result, and take
433 * care to have the (optional) decimal separator be the one
434 * of the current locale.
435 */
436 for (i = 0; i < len; ++i) {
437 if (start[i] == '.' &&
438 loc_data && loc_data->decimal_point && loc_data->decimal_point[0] && loc_data->decimal_point[0] != '.') {
439 /*replace '.' by the digit separator of the current locale */
440 result[i] = loc_data->decimal_point[0];
441 } else {
442 result[i] = start[i];
443 }
444 }
445 if (to) {
446 *to = end;
447 }
448
449 /* now try to convert to a floating point number, to check for validity only */
450 if (sscanf(result, "%lf", &dtest) != 1) { //NOLINT(bugprone-unchecked-string-to-number-conversion)
451 return true;
452 }
453 return false;
454}
455
456static void free_icalvalue_attach_data(char *data, void *user_data)
457{
458 _unused(user_data);
459 free(data);
460}
461
462static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind,
463 const char *str, icalproperty **error)
464{
465 char temp[TMP_BUF_SIZE] = {};
466 icalparameter *errParam;
467
468 struct icalvalue_impl *value = 0;
469
470 icalerror_check_arg_rz(str != 0, "str");
471
472 if (error != 0) {
473 *error = 0;
474 }
475
476 switch (kind) {
477 case ICAL_ATTACH_VALUE: {
478 icalattach *attach;
479
480 attach = icalattach_new_from_url(str);
481 if (!attach) {
482 break;
483 }
484
485 value = icalvalue_new_attach(attach);
486 icalattach_unref(attach);
487 break;
488 }
489
490#if defined(__GNUC__) && !defined(__clang__)
491#pragma GCC diagnostic push
492#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
493#endif
494 case ICAL_BINARY_VALUE: {
495 char *dupStr = strdup(str); // will be freed later on during unref
496 if (dupStr) {
497 icalattach *attach = icalattach_new_from_data(dupStr, free_icalvalue_attach_data, 0);
498 if (!attach) {
499 free(dupStr);
500 break;
501 }
502
503 value = icalvalue_new_attach(attach);
504 icalattach_unref(attach);
505 }
506 break;
507 }
508#if defined(__GNUC__) && !defined(__clang__)
509#pragma GCC diagnostic pop
510#endif
511
512 case ICAL_BOOLEAN_VALUE: {
513 if (!strcmp(str, "TRUE")) {
514 value = icalvalue_new_boolean(1);
515 } else if (!strcmp(str, "FALSE")) {
516 value = icalvalue_new_boolean(0);
517 } else {
518 if (error != 0) {
519 snprintf(temp, sizeof(temp),
520 "Could not parse %s as a %s property",
521 str, icalvalue_kind_to_string(kind));
523 *error = icalproperty_vanew_xlicerror(temp, errParam, (void *)0);
524 }
525 snprintf(temp, TMP_BUF_SIZE,
526 "icalvalue_new_from_string cannot parse value string (%s) for \'%s\'",
527 icalvalue_kind_to_string(kind), str);
528 icalerror_warn(temp);
530 }
531 break;
532 }
533
535 value = icalvalue_new_enum(kind, (int)ICAL_TRANSP_X, str);
536 break;
538 value = icalvalue_new_enum(kind, (int)ICAL_METHOD_X, str);
539 break;
541 value = icalvalue_new_enum(kind, (int)ICAL_STATUS_X, str);
542 break;
544 value = icalvalue_new_enum(kind, (int)ICAL_ACTION_X, str);
545 break;
546
547 case ICAL_QUERY_VALUE:
548 value = icalvalue_new_query(str);
549 break;
550
551 case ICAL_CLASS_VALUE:
552 value = icalvalue_new_enum(kind, (int)ICAL_CLASS_X, str);
553 break;
554 case ICAL_CMD_VALUE:
555 value = icalvalue_new_enum(kind, ICAL_CMD_X, str);
556 break;
558 value = icalvalue_new_enum(kind, ICAL_QUERYLEVEL_X, str);
559 break;
561 value = icalvalue_new_enum(kind, ICAL_CARLEVEL_X, str);
562 break;
564 value = icalvalue_new_enum(kind, ICAL_BUSYTYPE_X, str);
565 break;
567 value = icalvalue_new_enum(kind, ICAL_PROXIMITY_X, str);
568 break;
570 value = icalvalue_new_enum(kind, ICAL_POLLMODE_X, str);
571 break;
573 value = icalvalue_new_enum(kind, ICAL_POLLCOMPLETION_X, str);
574 break;
575
577 value = icalvalue_new_enum(kind, ICAL_PARTICIPANTTYPE_X, str);
578 break;
579
581 value = icalvalue_new_enum(kind, ICAL_RESOURCETYPE_X, str);
582 break;
583
584 case ICAL_INTEGER_VALUE: {
585 errno = 0;
586 char *t_end;
587 const long tmpl = strtol(str, &t_end, 10);
588 if (str != t_end && errno != ERANGE) {
589 value = icalvalue_new_integer(tmpl);
590 }
591 break;
592 }
593 case ICAL_FLOAT_VALUE: {
594 char *t_end;
595 const float tmpf = strtof(str, &t_end);
596 if (str != t_end) {
597 value = icalvalue_new_float(tmpf);
598 }
599 break;
600 }
602 int iOffset;
603 long utcoffset, hours, minutes, seconds;
604
605 /* treat the UTCOFFSET string as a decimal number, disassemble its digits
606 and reconstruct it as sections */
607 long t = strtol(str, 0, 10);
608
609 /* add phantom seconds field */
610 if (strlen(str) < 7) {
611 t *= 100;
612 }
613 hours = (t / 10000);
614 minutes = (t - hours * 10000) / 100;
615 seconds = (t - hours * 10000 - minutes * 100);
616 utcoffset = hours * 3600 + minutes * 60 + seconds;
617 if (utcoffset < INT_MIN) {
618 iOffset = INT_MIN;
619 } else if (utcoffset > INT_MAX) {
620 iOffset = INT_MAX;
621 } else {
622 iOffset = utcoffset;
623 }
624 value = icalvalue_new_utcoffset(iOffset);
625
626 break;
627 }
628
629 case ICAL_TEXT_VALUE: {
630 char *dequoted_str = icalmemory_strdup_and_dequote(str);
631
632 value = icalvalue_new_text(dequoted_str);
633 icalmemory_free_buffer(dequoted_str);
634 break;
635 }
636
638 value = icalvalue_new_string(str);
639 break;
640
641 case ICAL_COLOR_VALUE:
642 value = icalvalue_new_color(str);
643 break;
644
646 value = icalvalue_new_caladdress(str);
647 break;
648
649 case ICAL_URI_VALUE:
650 value = icalvalue_new_uri(str);
651 break;
652
653 case ICAL_GEO_VALUE: {
654 char *cur = NULL;
655 struct icalgeotype geo = {0};
656 memset(geo.lat, 0, ICAL_GEO_LEN);
657 memset(geo.lon, 0, ICAL_GEO_LEN);
658
659 if (simple_str_to_doublestr(str, geo.lat, ICAL_GEO_LEN, &cur)) {
660 goto geo_parsing_error;
661 }
662 /* skip white spaces */
663 while (cur && isspace((int)*cur)) {
664 ++cur;
665 }
666
667 /*there is a ';' between the latitude and longitude parts */
668 if (!cur || *cur != ';') {
669 goto geo_parsing_error;
670 }
671
672 ++cur;
673
674 /* skip white spaces */
675 while (cur && isspace((int)*cur)) {
676 ++cur;
677 }
678
679 if (simple_str_to_doublestr(cur, geo.lon, ICAL_GEO_LEN, &cur)) {
680 goto geo_parsing_error;
681 }
682 value = icalvalue_new_geo(geo);
683 break;
684
685 geo_parsing_error:
686 if (error != 0) {
687 snprintf(temp, sizeof(temp),
688 "Could not parse %s as a %s property",
689 str, icalvalue_kind_to_string(kind));
691 *error = icalproperty_vanew_xlicerror(temp, errParam, (void *)0);
692 }
693 snprintf(temp, TMP_BUF_SIZE,
694 "icalvalue_new_from_string cannot parse value string (%s) for \'%s\'",
695 icalvalue_kind_to_string(kind), str);
696 icalerror_warn(temp);
698 } break;
699
700 case ICAL_RECUR_VALUE: {
701 struct icalrecurrencetype *rt;
702
704 if (rt) {
705 value = icalvalue_new_recur(rt);
707 }
708 break;
709 }
710
711 case ICAL_DATE_VALUE:
712 case ICAL_DATETIME_VALUE: {
713 struct icaltimetype tt;
714
715 tt = icaltime_from_string(str);
716 if (!icaltime_is_null_time(tt)) {
717 value = icalvalue_new_impl(kind);
718 value->data.v_time = tt;
719
721 }
722 break;
723 }
724
726 struct icaltimetype tt;
727 struct icalperiodtype p;
728
729 tt = icaltime_from_string(str);
730
731 if (!icaltime_is_null_time(tt)) {
732 value = icalvalue_new_datetime(tt);
733 break;
734 }
735
738 value = icalvalue_new_period(p);
739 }
740
741 break;
742 }
743
744 case ICAL_DURATION_VALUE: {
746
747 if (!icaldurationtype_is_bad_duration(dur)) { /* failed to parse */
748 value = icalvalue_new_duration(dur);
749 }
750
751 break;
752 }
753
754 case ICAL_PERIOD_VALUE: {
755 struct icalperiodtype p;
756
758
760 value = icalvalue_new_period(p);
761 }
762 break;
763 }
764
765 case ICAL_TRIGGER_VALUE: {
767
769 value = icalvalue_new_trigger(tr);
770 }
771 break;
772 }
773
776
777 if (rst.code != ICAL_UNKNOWN_STATUS) {
778 value = icalvalue_new_requeststatus(rst);
779 }
780 break;
781 }
782
783 case ICAL_UID_VALUE: {
784 char *dequoted_str = icalmemory_strdup_and_dequote(str);
785
786 value = icalvalue_new_uid(dequoted_str);
787 icalmemory_free_buffer(dequoted_str);
788 break;
789 }
790
792 value = icalvalue_new_xmlreference(str);
793 break;
794
795 case ICAL_X_VALUE: {
796 char *dequoted_str = icalmemory_strdup_and_dequote(str);
797
798 value = icalvalue_new_x(dequoted_str);
799 icalmemory_free_buffer(dequoted_str);
800 } break;
801
802 default: {
803 if (error != 0) {
804 snprintf(temp, TMP_BUF_SIZE, "Unknown type for \'%s\'", str);
805
807 *error = icalproperty_vanew_xlicerror(temp, errParam, (void *)0);
808 }
809
810 snprintf(temp, TMP_BUF_SIZE,
811 "icalvalue_new_from_string got an unknown value type (%s) for \'%s\'",
812 icalvalue_kind_to_string(kind), str);
813 icalerror_warn(temp);
815 }
816 }
817
818#if defined(__GNUC__) && !defined(__clang__)
819#pragma GCC diagnostic push
820#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
821#endif
822 if (error != 0 && *error == 0 && value == 0) {
823 snprintf(temp, TMP_BUF_SIZE, "Failed to parse value: \'%s\'", str);
824
825 /* coverity[resource_leak] */
827 *error = icalproperty_vanew_xlicerror(temp, errParam, (void *)0);
828 }
829#if defined(__GNUC__) && !defined(__clang__)
830#pragma GCC diagnostic pop
831#endif
832 return value;
833}
834
836{
837 return icalvalue_new_from_string_with_error(kind, str, (icalproperty **)0);
838}
839
841{
842 icalerror_check_arg_rv((v != 0), "value");
843
844 if (v->parent != 0) {
845 return;
846 }
847
848 if (v->x_value != 0) {
849 icalmemory_free_buffer(v->x_value);
850 }
851
852 switch (v->kind) {
854 case ICAL_ATTACH_VALUE: {
855 if (v->data.v_attach) {
856 icalattach_unref(v->data.v_attach);
857 v->data.v_attach = NULL;
858 }
859
860 break;
861 }
862 case ICAL_TEXT_VALUE:
863 _fallthrough();
864
866 _fallthrough();
867
868 case ICAL_URI_VALUE:
869 _fallthrough();
870
872 _fallthrough();
873
874 case ICAL_COLOR_VALUE:
875 _fallthrough();
876
877 case ICAL_QUERY_VALUE: {
878 _fallthrough();
879 case ICAL_UID_VALUE:
880 _fallthrough();
882 if (v->data.v_string != 0) {
883 icalmemory_free_buffer((void *)v->data.v_string);
884 v->data.v_string = 0;
885 }
886 break;
887 }
888 case ICAL_RECUR_VALUE: {
889 if (v->data.v_recur != 0) {
890 icalrecurrencetype_unref(v->data.v_recur);
891 v->data.v_recur = NULL;
892 }
893 break;
894 }
895
897 if (v->data.v_requeststatus.debug != 0) {
898 icalmemory_free_buffer((void *)v->data.v_requeststatus.debug);
899 v->data.v_requeststatus.debug = 0;
900 }
901 break;
902 }
903
904 default: {
905 /* Nothing to do */
906 }
907 }
908
909 v->kind = ICAL_NO_VALUE;
910 v->size = 0;
911 v->parent = 0;
912 memset(&v->data, 0, sizeof(v->data));
913 v->id = ICAL_STRUCTURE_TYPE_VALUE_EMPTY;
915}
916
918{
919 if (value == 0) {
920 return false;
921 }
922
923 return true;
924}
925
926static char *icalvalue_binary_as_ical_string_r(const icalvalue *value)
927{
928 char *str;
929
930 icalerror_check_arg_rz((value != 0), "value");
931
932 str = (char *)icalmemory_new_buffer(60);
933 snprintf(str, 60, "icalvalue_binary_as_ical_string is not implemented yet");
934
935 return str;
936}
937
938static char *icalvalue_boolean_as_ical_string_r(const icalvalue *value)
939{
940 int data;
941 char *str;
942
943 icalerror_check_arg_rz((value != 0), "value");
944 str = (char *)icalmemory_new_buffer(6);
945
946 data = icalvalue_get_integer(value);
947
948 strncpy(str, data ? "TRUE" : "FALSE", 6);
949
950 return str;
951}
952
954#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign */
956
957static char *icalvalue_int_as_ical_string_r(const icalvalue *value)
958{
959 int data;
960 char *str;
961
962 icalerror_check_arg_rz((value != 0), "value");
964
965 data = icalvalue_get_integer(value);
966
967 snprintf(str, MAX_INT_DIGITS, "%d", data);
968
969 return str;
970}
971
972static char *icalvalue_utcoffset_as_ical_string_r(const icalvalue *value)
973{
974 int data, h, m, s;
975 char sign;
976 char *str;
977
978 icalerror_check_arg_rz((value != 0), "value");
979
980 str = (char *)icalmemory_new_buffer(9);
981 data = icalvalue_get_utcoffset(value);
982
983 if (abs(data) == data) {
984 sign = '+';
985 } else {
986 sign = '-';
987 }
988
989 h = data / 3600;
990 m = (data - (h * 3600)) / 60;
991 s = (data - (h * 3600) - (m * 60));
992
993 h = MIN(abs(h), 23);
994 m = MIN(abs(m), 59);
995 s = MIN(abs(s), 59);
996 if (s != 0) {
997 snprintf(str, 9, "%c%02d%02d%02d", sign, h, m, s);
998 } else {
999 snprintf(str, 9, "%c%02d%02d", sign, h, m);
1000 }
1001
1002 return str;
1003}
1004
1005static char *icalvalue_string_as_ical_string_r(const icalvalue *value)
1006{
1007 icalerror_check_arg_rz((value != 0), "value");
1008
1009 return icalmemory_strdup_without_line_breaks(value->data.v_string);
1010}
1011
1012static char *icalvalue_recur_as_ical_string_r(const icalvalue *value)
1013{
1014 struct icalrecurrencetype *recur = value->data.v_recur;
1015
1016 return icalrecurrencetype_as_string_r(recur);
1017}
1018
1019static char *icalvalue_text_as_ical_string_r(const icalvalue *value)
1020{
1021 return icalmemory_strdup_and_quote(value, value->data.v_string);
1022}
1023
1024static char *icalvalue_attach_as_ical_string_r(const icalvalue *value)
1025{
1026 icalattach *a;
1027
1028 icalerror_check_arg_rz((value != 0), "value");
1029
1030 a = icalvalue_get_attach(value);
1031
1032 if (icalattach_get_is_url(a)) {
1033 const char *url;
1034
1035 url = icalattach_get_url(a);
1036 return icalmemory_strdup_without_line_breaks(url);
1037 } else {
1038 const char *data = 0;
1039
1040 data = (const char *)icalattach_get_data(a);
1041 const size_t len_data = strlen(data) + 1;
1042 char *str = icalmemory_new_buffer(len_data);
1043 strncpy(str, data, len_data);
1044 str[len_data - 1] = '\0';
1045 return str;
1046 }
1047}
1048
1049static char *icalvalue_duration_as_ical_string_r(const icalvalue *value)
1050{
1051 struct icaldurationtype data;
1052
1053 icalerror_check_arg_rz((value != 0), "value");
1054 data = icalvalue_get_duration(value);
1055
1057}
1058
1059static void print_time_to_string(char *str, const struct icaltimetype *data)
1060{ /* this function is a candidate for a library-wide external function
1061 except it isn't used any place outside of icalvalue.c.
1062 see print_date_to_string() and print_datetime_to_string in icalvalue.h */
1063#if defined(__GNUC__) && !defined(__clang__)
1064#pragma GCC diagnostic push
1065#pragma GCC diagnostic ignored "-Wstringop-truncation"
1066#endif
1067 char temp[8];
1068
1069 str[0] = '\0';
1070 if (data != 0) {
1071 if (icaltime_is_utc(*data)) {
1072 snprintf(temp, sizeof(temp), "%02d%02d%02dZ", data->hour, data->minute, data->second);
1073 strncat(str, temp, 7);
1074 } else {
1075 snprintf(temp, sizeof(temp), "%02d%02d%02d", data->hour, data->minute, data->second);
1076 strncat(str, temp, 6);
1077 }
1078 }
1079#if defined(__GNUC__) && !defined(__clang__)
1080#pragma GCC diagnostic pop
1081#endif
1082}
1083
1085void print_date_to_string(char *str, const struct icaltimetype *data)
1086{
1087#if defined(__GNUC__) && !defined(__clang__)
1088#pragma GCC diagnostic push
1089#pragma GCC diagnostic ignored "-Wstringop-truncation"
1090#endif
1091 char temp[9];
1092
1093 str[0] = '\0';
1094
1095 if (data != 0) {
1096 snprintf(temp, sizeof(temp), "%04d%02d%02d", data->year, data->month, data->day);
1097 strncat(str, temp, 8);
1098 }
1099#if defined(__GNUC__) && !defined(__clang__)
1100#pragma GCC diagnostic pop
1101#endif
1102}
1104
1105static char *icalvalue_date_as_ical_string_r(const icalvalue *value)
1106{
1107 struct icaltimetype data;
1108 char *str;
1109
1110 icalerror_check_arg_rz((value != 0), "value");
1111 data = icalvalue_get_date(value);
1112
1113 str = (char *)icalmemory_new_buffer(9);
1114
1115 str[0] = '\0';
1116 print_date_to_string(str, &data);
1117
1118 return str;
1119}
1120
1122void print_datetime_to_string(char *str, const struct icaltimetype *data)
1123{
1124#if defined(__GNUC__) && !defined(__clang__)
1125#pragma GCC diagnostic push
1126#pragma GCC diagnostic ignored "-Wstringop-truncation"
1127#endif
1128 char temp[20] = {0};
1129
1130 str[0] = '\0';
1131 if (data != 0) {
1132 print_date_to_string(str, data);
1133 if (!data->is_date) {
1134 strncat(str, "T", 19);
1135 temp[0] = '\0';
1136 print_time_to_string(temp, data);
1137 strncat(str, temp, 19);
1138 }
1139 }
1140#if defined(__GNUC__) && !defined(__clang__)
1141#pragma GCC diagnostic pop
1142#endif
1143}
1145
1146static char *icalvalue_datetime_as_ical_string_r(const icalvalue *value)
1147{
1148 struct icaltimetype data;
1149 char *str;
1150 icalvalue_kind kind = icalvalue_isa(value);
1151
1152 icalerror_check_arg_rz((value != 0), "value");
1153
1154 if (!(kind == ICAL_DATE_VALUE || kind == ICAL_DATETIME_VALUE)) {
1156 return 0;
1157 }
1158
1159 data = icalvalue_get_datetime(value);
1160
1161 str = (char *)icalmemory_new_buffer(20);
1162
1163 str[0] = 0;
1164 print_datetime_to_string(str, &data);
1165
1166 return str;
1167}
1168
1169static char *icalvalue_float_as_ical_string_r(const icalvalue *value)
1170{
1171 float data;
1172 char *str;
1173 char *old_locale;
1174
1175 icalerror_check_arg_rz((value != 0), "value");
1176 data = icalvalue_get_float(value);
1177
1178 /* bypass current locale in order to make
1179 sure snprintf uses a '.' as a separator
1180 set locate to 'C' and keep old locale */
1181 old_locale = icalmemory_strdup(setlocale(LC_NUMERIC, NULL));
1182 (void)setlocale(LC_NUMERIC, "C");
1183
1184 str = (char *)icalmemory_new_buffer(40);
1185
1186 snprintf(str, 40, "%f", data);
1187
1188 /* restore saved locale */
1189 (void)setlocale(LC_NUMERIC, old_locale);
1190 icalmemory_free_buffer(old_locale);
1191
1192 return str;
1193}
1194
1195static char *icalvalue_geo_as_ical_string_r(const icalvalue *value)
1196{
1197 struct icalgeotype data;
1198 char *str;
1199
1200 icalerror_check_arg_rz((value != 0), "value");
1201
1202 data = icalvalue_get_geo(value);
1203 str = (char *)icalmemory_new_buffer(80);
1204 snprintf(str, 80, "%s;%s", data.lat, data.lon);
1205
1206 return str;
1207}
1208
1209static char *icalvalue_datetimeperiod_as_ical_string_r(const icalvalue *value)
1210{
1212
1213 icalerror_check_arg_rz((value != 0), "value");
1214
1215 if (!icaltime_is_null_time(dtp.time)) {
1216 return icaltime_as_ical_string_r(dtp.time);
1217 } else {
1219 }
1220}
1221
1222static char *icalvalue_period_as_ical_string_r(const icalvalue *value)
1223{
1224 struct icalperiodtype data;
1225
1226 icalerror_check_arg_rz((value != 0), "value");
1227 data = icalvalue_get_period(value);
1228
1230}
1231
1232static char *icalvalue_trigger_as_ical_string_r(const icalvalue *value)
1233{
1234 struct icaltriggertype data;
1235
1236 icalerror_check_arg_rz((value != 0), "value");
1237 data = icalvalue_get_trigger(value);
1238
1239 if (!icaltime_is_null_time(data.time)) {
1240 return icaltime_as_ical_string_r(data.time);
1241 } else {
1242 return icaldurationtype_as_ical_string_r(data.duration);
1243 }
1244}
1245
1246const char *icalvalue_as_ical_string(const icalvalue *value)
1247{
1248 char *buf;
1249
1250 buf = icalvalue_as_ical_string_r(value);
1252 return buf;
1253}
1254
1256{
1257 if (value == 0) {
1258 return 0;
1259 }
1260
1261 switch (value->kind) {
1262 case ICAL_ATTACH_VALUE:
1263 return icalvalue_attach_as_ical_string_r(value);
1264
1265 case ICAL_BINARY_VALUE:
1266 return icalvalue_binary_as_ical_string_r(value);
1267
1268 case ICAL_BOOLEAN_VALUE:
1269 return icalvalue_boolean_as_ical_string_r(value);
1270
1271 case ICAL_INTEGER_VALUE:
1272 return icalvalue_int_as_ical_string_r(value);
1273
1275 return icalvalue_utcoffset_as_ical_string_r(value);
1276
1277 case ICAL_TEXT_VALUE:
1278 case ICAL_UID_VALUE:
1279 return icalvalue_text_as_ical_string_r(value);
1280
1281 case ICAL_QUERY_VALUE:
1282 return icalvalue_string_as_ical_string_r(value);
1283
1284 case ICAL_STRING_VALUE:
1285 case ICAL_COLOR_VALUE:
1286 case ICAL_URI_VALUE:
1289 return icalvalue_string_as_ical_string_r(value);
1290
1291 case ICAL_DATE_VALUE:
1292 return icalvalue_date_as_ical_string_r(value);
1294 return icalvalue_datetime_as_ical_string_r(value);
1296 return icalvalue_duration_as_ical_string_r(value);
1297
1298 case ICAL_PERIOD_VALUE:
1299 return icalvalue_period_as_ical_string_r(value);
1301 return icalvalue_datetimeperiod_as_ical_string_r(value);
1302
1303 case ICAL_FLOAT_VALUE:
1304 return icalvalue_float_as_ical_string_r(value);
1305
1306 case ICAL_GEO_VALUE:
1307 return icalvalue_geo_as_ical_string_r(value);
1308
1309 case ICAL_RECUR_VALUE:
1310 return icalvalue_recur_as_ical_string_r(value);
1311
1312 case ICAL_TRIGGER_VALUE:
1313 return icalvalue_trigger_as_ical_string_r(value);
1314
1316 return icalreqstattype_as_string_r(value->data.v_requeststatus);
1317
1318 case ICAL_ACTION_VALUE:
1319 case ICAL_CMD_VALUE:
1322 case ICAL_METHOD_VALUE:
1323 case ICAL_STATUS_VALUE:
1324 case ICAL_TRANSP_VALUE:
1325 case ICAL_CLASS_VALUE:
1332 if (value->x_value != 0) {
1333 return icalmemory_strdup_without_line_breaks(value->x_value);
1334 }
1335
1336 return icalproperty_enum_to_string_r(value->data.v_enum);
1337
1338 case ICAL_X_VALUE:
1339 if (value->x_value != 0) {
1340 return icalmemory_strdup_and_quote(value, value->x_value);
1341 }
1342 _fallthrough();
1343
1344 case ICAL_NO_VALUE:
1345 _fallthrough();
1346
1347 default: {
1349 return icalmemory_strdup("");
1350 }
1351 return 0;
1352 }
1353 }
1354}
1355
1357{
1358 if (value == 0) {
1359 return ICAL_NO_VALUE;
1360 }
1361
1362 return value->kind;
1363}
1364
1365bool icalvalue_isa_value(void *value)
1366{
1367 const struct icalvalue_impl *impl = (struct icalvalue_impl *)value;
1368
1369 icalerror_check_arg_rz((value != 0), "value");
1370
1371 return (impl->id == ICAL_STRUCTURE_TYPE_VALUE);
1372}
1373
1374static bool icalvalue_is_time(const icalvalue *a)
1375{
1376 icalvalue_kind kind = icalvalue_isa(a);
1377
1378 if (kind == ICAL_DATETIME_VALUE || kind == ICAL_DATE_VALUE) {
1379 return true;
1380 }
1381
1382 return false;
1383}
1384
1386{
1387 icalerror_check_arg_rx((a != 0), "a", ICAL_XLICCOMPARETYPE_NONE);
1388 icalerror_check_arg_rx((b != 0), "b", ICAL_XLICCOMPARETYPE_NONE);
1389
1390 /* Not the same type; they can only be unequal */
1391 if (!(icalvalue_is_time(a) && icalvalue_is_time(b)) && icalvalue_isa(a) != icalvalue_isa(b)) {
1393 }
1394
1395 switch (icalvalue_isa(a)) {
1396 case ICAL_ATTACH_VALUE: {
1397 if (icalattach_get_is_url(a->data.v_attach) &&
1398 icalattach_get_is_url(b->data.v_attach)) {
1399 if (strcasecmp(icalattach_get_url(a->data.v_attach),
1400 icalattach_get_url(b->data.v_attach)) == 0) {
1402 } else {
1404 }
1405 } else {
1406 if (a->data.v_attach == b->data.v_attach) {
1408 } else {
1410 }
1411 }
1412 }
1413 case ICAL_BINARY_VALUE: {
1414 if (a->data.v_attach == b->data.v_attach) {
1416 } else {
1418 }
1419 }
1420
1421 case ICAL_BOOLEAN_VALUE: {
1424 } else {
1426 }
1427 }
1428
1429 case ICAL_FLOAT_VALUE: {
1430 if (a->data.v_float > b->data.v_float) {
1432 } else if (a->data.v_float < b->data.v_float) {
1434 } else {
1436 }
1437 }
1438
1439 case ICAL_INTEGER_VALUE:
1440 case ICAL_UTCOFFSET_VALUE: {
1441 if (a->data.v_int > b->data.v_int) {
1443 } else if (a->data.v_int < b->data.v_int) {
1445 } else {
1447 }
1448 }
1449
1450 case ICAL_DURATION_VALUE: {
1451 struct icaldurationtype dur_a = a->data.v_duration,
1452 dur_b = b->data.v_duration;
1453 int a_days = (int)(7 * dur_a.weeks + dur_a.days) * (dur_a.is_neg == 1 ? -1 : 1),
1454 b_days = (int)(7 * dur_b.weeks + dur_b.days) * (dur_a.is_neg == 1 ? -1 : 1);
1455 int a_secs = (int)(dur_a.seconds + 60 * (dur_a.minutes + 60 * dur_a.hours)) *
1456 (dur_a.is_neg == 1 ? -1 : 1),
1457 b_secs = (int)(dur_b.seconds + 60 * (dur_b.minutes + 60 * dur_b.hours)) *
1458 (dur_b.is_neg == 1 ? -1 : 1);
1459
1460 if (a_secs == b_secs) {
1461 if (a_days > b_days) {
1463 } else if (a_days < b_days) {
1465 } else {
1467 }
1468 } else if (a_days == b_days) {
1469 if (a_secs > b_secs) {
1471 } else {
1473 }
1474 } else {
1475 /* We can't compare a mix of nominal and accurate durations */
1477 }
1478 }
1479
1480 case ICAL_TEXT_VALUE:
1481 case ICAL_URI_VALUE:
1483 case ICAL_TRIGGER_VALUE:
1484 case ICAL_DATE_VALUE:
1487 case ICAL_QUERY_VALUE:
1488 case ICAL_UID_VALUE:
1490 case ICAL_RECUR_VALUE: {
1491 int r;
1492 char *temp1, *temp2;
1493
1494 temp1 = icalvalue_as_ical_string_r(a);
1495 if (temp1) {
1496 temp2 = icalvalue_as_ical_string_r(b);
1497 if (temp2) {
1498 r = strcmp(temp1, temp2);
1499 } else {
1502 }
1503 } else {
1505 }
1508
1509 if (r > 0) {
1511 } else if (r < 0) {
1513 } else {
1515 }
1516 }
1517
1518 case ICAL_METHOD_VALUE: {
1521 } else {
1523 }
1524 }
1525
1526 case ICAL_STATUS_VALUE: {
1529 } else {
1531 }
1532 }
1533
1534 case ICAL_TRANSP_VALUE: {
1537 } else {
1539 }
1540 }
1541
1542 case ICAL_ACTION_VALUE: {
1545 } else {
1547 }
1548 }
1549
1550 case ICAL_PERIOD_VALUE:
1551 case ICAL_GEO_VALUE:
1552 case ICAL_NO_VALUE:
1553 default: {
1554 icalerror_warn("Comparison not implemented for value type");
1556 }
1557 }
1558}
1559
1561{
1562 if (value &&
1563 (value->kind == ICAL_DATETIME_VALUE || value->kind == ICAL_DATE_VALUE) &&
1564 !icaltime_is_null_time(value->data.v_time)) {
1565 if (icaltime_is_date(value->data.v_time)) {
1566 value->kind = ICAL_DATE_VALUE;
1567 } else {
1568 value->kind = ICAL_DATETIME_VALUE;
1569 }
1570 }
1571}
1572
1573void icalvalue_set_parent(icalvalue *value, icalproperty *property)
1574{
1575 icalerror_check_arg_rv((value != 0), "value");
1576
1577 value->parent = property;
1578}
1579
1580icalproperty *icalvalue_get_parent(const icalvalue *value)
1581{
1582 return value->parent;
1583}
1584
1585bool icalvalue_encode_ical_string(const char *szText, char *szEncText, int maxBufferLen)
1586{
1587 char *ptr;
1588 icalvalue *value = 0;
1589
1590 if ((szText == 0) || (szEncText == 0)) {
1591 return false;
1592 }
1593
1595
1596 if (value == 0) {
1597 return false;
1598 }
1599
1600 ptr = icalvalue_text_as_ical_string_r(value);
1601 if (ptr == 0) {
1602 return false;
1603 }
1604
1605 if ((int)strlen(ptr) >= maxBufferLen) {
1606 icalvalue_free(value);
1608 return false;
1609 }
1610
1611 strcpy(szEncText, ptr); //NOLINT(clang-analyzer-security.insecureAPI.strcp
1613
1614 icalvalue_free((icalvalue *)value);
1615
1616 return true;
1617}
1618
1619bool icalvalue_decode_ical_string(const char *szText, char *szDecText, int maxBufferLen)
1620{
1621 char *str, *str_p;
1622 const char *p;
1623 size_t buf_sz;
1624
1625 if ((szText == 0) || (szDecText == 0) || (maxBufferLen <= 0)) {
1626 return false;
1627 }
1628
1629 buf_sz = strlen(szText) + 1;
1630 str_p = str = (char *)icalmemory_new_buffer(buf_sz);
1631
1632 if (str_p == 0) {
1633 return false;
1634 }
1635
1636 for (p = szText; *p != 0; p++) {
1637 if (*p == '\\') {
1638 if (*(p + 1) == 0) {
1639 /* a trailing escape character escapes nothing; stop before the terminator */
1640 break;
1641 }
1642 icalmemory_append_char(&str, &str_p, &buf_sz, *(p + 1));
1643 p++;
1644 } else {
1645 icalmemory_append_char(&str, &str_p, &buf_sz, *p);
1646 }
1647
1648 if (str_p - str > maxBufferLen) {
1649 break;
1650 }
1651 }
1652
1653 icalmemory_append_char(&str, &str_p, &buf_sz, '\0');
1654
1655 if ((int)strlen(str) >= maxBufferLen) {
1657 return false;
1658 }
1659
1660 strcpy(szDecText, str); //NOLINT(clang-analyzer-security.insecureAPI.strcpy)
1661
1663 return true;
1664}
1665
1666/* The remaining interfaces are 'new', 'set' and 'get' for each of the value
1667 types */
icalattach * icalattach_new_from_data(const char *data, icalattach_free_fn_t free_fn, void *free_fn_data)
Creates new icalattach object from data.
Definition icalattach.c:56
void icalattach_unref(icalattach *attach)
Decrements reference count of the icalattach.
Definition icalattach.c:95
void icalattach_ref(icalattach *attach)
Increments reference count of the icalattach.
Definition icalattach.c:87
unsigned char * icalattach_get_data(icalattach *attach)
Returns the data of the icalattach object.
Definition icalattach.c:130
const char * icalattach_get_url(icalattach *attach)
Returns the URL of the icalattach object.
Definition icalattach.c:122
icalattach * icalattach_new_from_url(const char *url)
Creates new icalattach object from a URL.
Definition icalattach.c:25
bool icalattach_get_is_url(const icalattach *attach)
Determines if attach is an URL.
Definition icalattach.c:115
struct icalattach_impl icalattach
An iCal attach object representing a link to a document object.
Definition icalattach.h:36
struct icalparameter_impl icalparameter
icalparameter_xliccomparetype
@ ICAL_XLICCOMPARETYPE_NOTEQUAL
@ ICAL_XLICCOMPARETYPE_LESS
@ ICAL_XLICCOMPARETYPE_GREATER
@ ICAL_XLICCOMPARETYPE_EQUAL
@ ICAL_XLICCOMPARETYPE_NONE
@ ICAL_XLICERRORTYPE_VALUEPARSEERROR
icalparameter * icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
icalproperty * icalproperty_vanew_xlicerror(const char *v,...)
@ ICAL_LOCATIONTYPE_PROPERTY
@ ICAL_CATEGORIES_PROPERTY
@ ICAL_IANA_PROPERTY
@ ICAL_POLLPROPERTIES_PROPERTY
@ ICAL_X_PROPERTY
@ ICAL_RESOURCES_PROPERTY
icalvalue * icalvalue_new_query(const char *v)
struct icaltimetype icalvalue_get_datetime(const icalvalue *value)
enum icalproperty_status icalvalue_get_status(const icalvalue *value)
icalvalue * icalvalue_new_trigger(struct icaltriggertype v)
@ ICAL_CMD_X
struct icaltriggertype icalvalue_get_trigger(const icalvalue *value)
float icalvalue_get_float(const icalvalue *value)
@ ICAL_CARLEVEL_X
icalvalue * icalvalue_new_geo(struct icalgeotype v)
@ ICAL_BUSYTYPE_X
@ ICAL_STATUS_X
icalvalue * icalvalue_new_uid(const char *v)
icalvalue * icalvalue_new_x(const char *v)
icalvalue * icalvalue_new_integer(int v)
@ ICAL_ACTION_X
icalvalue * icalvalue_new_utcoffset(int v)
void icalvalue_set_x(icalvalue *value, const char *v)
@ ICAL_QUERYLEVEL_X
struct icaltimetype icalvalue_get_date(const icalvalue *value)
@ ICAL_METHOD_X
icalvalue * icalvalue_new_uri(const char *v)
@ ICAL_RESOURCETYPE_X
icalvalue * icalvalue_new_xmlreference(const char *v)
int icalvalue_get_integer(const icalvalue *value)
enum icalproperty_action icalvalue_get_action(const icalvalue *value)
icalvalue * icalvalue_new_requeststatus(struct icalreqstattype v)
enum icalproperty_transp icalvalue_get_transp(const icalvalue *value)
icalvalue * icalvalue_new_period(struct icalperiodtype v)
int icalvalue_get_utcoffset(const icalvalue *value)
icalattach * icalvalue_get_attach(const icalvalue *value)
icalvalue * icalvalue_new_color(const char *v)
@ ICAL_CLASS_X
icalvalue * icalvalue_new_boolean(int v)
@ ICAL_PARTICIPANTTYPE_X
icalvalue * icalvalue_new_duration(struct icaldurationtype v)
icalvalue * icalvalue_new_attach(icalattach *attach)
icalvalue_kind
@ ICAL_STATUS_VALUE
@ ICAL_RESOURCETYPE_VALUE
@ ICAL_BOOLEAN_VALUE
@ ICAL_PROXIMITY_VALUE
@ ICAL_URI_VALUE
@ ICAL_CMD_VALUE
@ ICAL_RECUR_VALUE
@ ICAL_INTEGER_VALUE
@ ICAL_ACTION_VALUE
@ ICAL_UTCOFFSET_VALUE
@ ICAL_DATETIME_VALUE
@ ICAL_METHOD_VALUE
@ ICAL_XMLREFERENCE_VALUE
@ ICAL_TRIGGER_VALUE
@ ICAL_TRANSP_VALUE
@ ICAL_BINARY_VALUE
@ ICAL_DATETIMEPERIOD_VALUE
@ ICAL_ATTACH_VALUE
@ ICAL_FLOAT_VALUE
@ ICAL_QUERY_VALUE
@ ICAL_QUERYLEVEL_VALUE
@ ICAL_GEO_VALUE
@ ICAL_PERIOD_VALUE
@ ICAL_DATE_VALUE
@ ICAL_CALADDRESS_VALUE
@ ICAL_COLOR_VALUE
@ ICAL_X_VALUE
@ ICAL_POLLCOMPLETION_VALUE
@ ICAL_POLLMODE_VALUE
@ ICAL_TEXT_VALUE
@ ICAL_NO_VALUE
@ ICAL_DURATION_VALUE
@ ICAL_UID_VALUE
@ ICAL_REQUESTSTATUS_VALUE
@ ICAL_PARTICIPANTTYPE_VALUE
@ ICAL_BUSYTYPE_VALUE
@ ICAL_CLASS_VALUE
@ ICAL_STRING_VALUE
@ ICAL_CARLEVEL_VALUE
icalvalue * icalvalue_new_float(float v)
struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue *value)
icalvalue * icalvalue_new_string(const char *v)
enum icalproperty_method icalvalue_get_method(const icalvalue *value)
@ ICAL_PROXIMITY_X
struct icaldurationtype icalvalue_get_duration(const icalvalue *value)
@ ICAL_POLLMODE_X
icalvalue * icalvalue_new_recur(struct icalrecurrencetype *recur)
icalvalue * icalvalue_new_caladdress(const char *v)
icalvalue * icalvalue_new_datetime(struct icaltimetype v)
struct icalperiodtype icalvalue_get_period(const icalvalue *value)
struct icalgeotype icalvalue_get_geo(const icalvalue *value)
icalvalue * icalvalue_new_text(const char *v)
@ ICAL_TRANSP_X
int icalvalue_get_boolean(const icalvalue *value)
struct icalvalue_impl icalvalue
@ ICAL_POLLCOMPLETION_X
bool icaldurationtype_is_bad_duration(struct icaldurationtype d)
Checks if a duration is a bad duration.
char * icaldurationtype_as_ical_string_r(struct icaldurationtype d)
struct icaldurationtype icaldurationtype_from_string(const char *str)
Creates a new icaldurationtype from a duration given as a string.
@ ICAL_UNKNOWN_STATUS
Definition icalenums.h:80
void icalerror_set_errno(icalerrorenum x)
Sets the icalerrno to a given error.
Definition icalerror.c:90
@ ICAL_NEWFAILED_ERROR
Definition icalerror.h:50
@ ICAL_BADARG_ERROR
Definition icalerror.h:47
@ ICAL_PARSE_ERROR
Definition icalerror.h:62
size_t icallimit_get(icallimits_kind kind)
Definition icallimits.c:29
Defines the interface for getting/setting internal library limits.
@ ICAL_LIMIT_VALUE_CHARS
Definition icallimits.h:34
void icalmemory_free_buffer(void *buf)
Releases a buffer.
Definition icalmemory.c:355
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition icalmemory.c:242
void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string)
Appends a string to a buffer.
Definition icalmemory.c:365
void * icalmemory_new_buffer(size_t size)
Creates new buffer with the specified size.
Definition icalmemory.c:315
void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch)
Appends a character to a buffer.
Definition icalmemory.c:406
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition icalmemory.c:158
Common memory management routines.
char * icalperiodtype_as_ical_string_r(struct icalperiodtype p)
Converts an icalperiodtype into an iCal-formatted string.
Definition icalperiod.c:97
bool icalperiodtype_is_null_period(struct icalperiodtype p)
Definition icalperiod.c:138
struct icalperiodtype icalperiodtype_from_string(const char *str)
Constructs a new icalperiodtype from str.
Definition icalperiod.c:25
icalproperty_kind icalproperty_isa(const icalproperty *p)
bool icalproperty_get_allow_empty_properties(void)
icalproperty * icalvalue_get_parent(const icalvalue *value)
Definition icalvalue.c:1580
char * icalproperty_enum_to_string_r(int e)
bool icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e)
void icalvalue_set_parent(icalvalue *value, icalproperty *property)
Definition icalvalue.c:1573
icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind)
int icalproperty_kind_and_string_to_enum(const int kind, const char *str)
struct icalrecurrencetype * icalrecurrencetype_new_from_string(const char *str)
Definition icalrecur.c:869
struct icalrecurrencetype * icalrecurrencetype_clone(struct icalrecurrencetype *recur)
Definition icalrecur.c:832
void icalrecurrencetype_unref(struct icalrecurrencetype *recur)
Definition icalrecur.c:790
char * icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur)
Definition icalrecur.c:1069
bool icaltime_is_date(const struct icaltimetype t)
Definition icaltime.c:634
struct icaltimetype icaltime_from_string(const char *str)
Definition icaltime.c:379
bool icaltime_is_utc(const struct icaltimetype t)
Definition icaltime.c:639
bool icaltime_is_null_time(const struct icaltimetype t)
Definition icaltime.c:644
char * icaltime_as_ical_string_r(const struct icaltimetype tt)
Definition icaltime.c:346
Defines the data structure for representing date-times.
struct icaltriggertype icaltriggertype_from_string(const char *str)
Definition icaltypes.c:61
bool icaltriggertype_is_bad_trigger(struct icaltriggertype tr)
Definition icaltypes.c:42
struct icalreqstattype icalreqstattype_from_string(const char *str)
Definition icaltypes.c:99
char * icalreqstattype_as_string_r(struct icalreqstattype stat)
Definition icaltypes.c:165
#define ICAL_GEO_LEN
Definition icaltypes.h:35
icalvalue_kind icalvalue_isa(const icalvalue *value)
Definition icalvalue.c:1356
bool icalvalue_is_valid(const icalvalue *value)
Definition icalvalue.c:917
bool icalvalue_isa_value(void *value)
Definition icalvalue.c:1365
icalvalue * icalvalue_clone(const icalvalue *old)
Definition icalvalue.c:66
icalvalue * icalvalue_new_from_string(icalvalue_kind kind, const char *str)
Definition icalvalue.c:835
icalparameter_xliccomparetype icalvalue_compare(const icalvalue *a, const icalvalue *b)
Definition icalvalue.c:1385
icalvalue * icalvalue_new(icalvalue_kind kind)
Definition icalvalue.c:61
bool icalvalue_decode_ical_string(const char *szText, char *szDecText, int maxBufferLen)
Definition icalvalue.c:1619
void icalvalue_reset_kind(icalvalue *value)
Definition icalvalue.c:1560
void icalvalue_free(icalvalue *v)
Definition icalvalue.c:840
char * icalvalue_as_ical_string_r(const icalvalue *value)
Definition icalvalue.c:1255
bool icalvalue_encode_ical_string(const char *szText, char *szEncText, int maxBufferLen)
Definition icalvalue.c:1585
const char * icalvalue_as_ical_string(const icalvalue *value)
Definition icalvalue.c:1246
Defines the data structure representing iCalendar parameter values.
bool icalvalue_kind_is_valid(const icalvalue_kind kind)
const char * icalvalue_kind_to_string(const icalvalue_kind kind)
struct icaltimetype time
Definition icaltypes.h:30
struct icalperiodtype period
Definition icaltypes.h:31
unsigned int weeks
unsigned int hours
unsigned int seconds
unsigned int days
unsigned int minutes
char lat[16]
Definition icaltypes.h:40
char lon[16]
Definition icaltypes.h:41
icalrequeststatus code
Definition icaltypes.h:111
#define MAX_INT_DIGITS
Definition vcardvalue.c:686
#define TMP_BUF_SIZE
Definition vcardvalue.c:30