summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalproperty.c
Unidiff
Diffstat (limited to 'libical/src/libical/icalproperty.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalproperty.c509
1 files changed, 348 insertions, 161 deletions
diff --git a/libical/src/libical/icalproperty.c b/libical/src/libical/icalproperty.c
index 7f2cfa5..45d7a75 100644
--- a/libical/src/libical/icalproperty.c
+++ b/libical/src/libical/icalproperty.c
@@ -25,3 +25,2 @@
25======================================================================*/ 25======================================================================*/
26/*#line 27 "icalproperty.c.in"*/
27 26
@@ -47,5 +46,6 @@
47 46
48int snprintf(char *str, size_t n, char const *fmt, ...); 47#ifdef WIN32
49 48#define snprintf _snprintf
50#define TMP_BUF_SIZE 1024 49#define strcasecmp stricmp
50#endif
51 51
@@ -74,9 +74,6 @@ struct icalproperty_impl
74 74
75void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args) 75void icalproperty_add_parameters(icalproperty* prop, va_list args)
76{ 76{
77
78 void* vp; 77 void* vp;
79 78
80 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
81
82 while((vp = va_arg(args, void*)) != 0) { 79 while((vp = va_arg(args, void*)) != 0) {
@@ -86,6 +83,6 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
86 83
87 icalproperty_add_parameter((icalproperty*)impl, 84 icalproperty_add_parameter((icalproperty*)prop,
88 (icalparameter*)vp); 85 (icalparameter*)vp);
89 } else { 86 } else {
90 assert(0); 87 icalerror_set_errno(ICAL_BADARG_ERROR);
91 } 88 }
@@ -93,4 +90,2 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
93 } 90 }
94
95
96} 91}
@@ -98,9 +93,11 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
98 93
99struct icalproperty_impl* 94icalproperty*
100icalproperty_new_impl (icalproperty_kind kind) 95icalproperty_new_impl(icalproperty_kind kind)
101{ 96{
102 struct icalproperty_impl* prop; 97 icalproperty* prop;
98
99 if (!icalproperty_kind_is_valid(kind))
100 return NULL;
103 101
104 if ( ( prop = (struct icalproperty_impl*) 102 if ( ( prop = (icalproperty*) malloc(sizeof(icalproperty))) == 0) {
105 malloc(sizeof(struct icalproperty_impl))) == 0) {
106 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 103 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -125,3 +122,3 @@ icalproperty_new (icalproperty_kind kind)
125{ 122{
126 if(kind == ICAL_NO_PROPERTY){ 123 if (kind == ICAL_NO_PROPERTY){
127 return 0; 124 return 0;
@@ -134,9 +131,7 @@ icalproperty_new (icalproperty_kind kind)
134icalproperty* 131icalproperty*
135icalproperty_new_clone(icalproperty* prop) 132icalproperty_new_clone(icalproperty* old)
136{ 133{
137 struct icalproperty_impl *old = (struct icalproperty_impl*)prop; 134 icalproperty *new = icalproperty_new_impl(old->kind);
138 struct icalproperty_impl *new = icalproperty_new_impl(old->kind);
139 pvl_elem p; 135 pvl_elem p;
140 136
141 icalerror_check_arg_rz((prop!=0),"Prop");
142 icalerror_check_arg_rz((old!=0),"old"); 137 icalerror_check_arg_rz((old!=0),"old");
@@ -221,11 +216,7 @@ icalproperty* icalproperty_new_from_string(const char* str)
221void 216void
222icalproperty_free (icalproperty* prop) 217icalproperty_free (icalproperty* p)
223{ 218{
224 struct icalproperty_impl *p;
225
226 icalparameter* param; 219 icalparameter* param;
227 220
228 icalerror_check_arg_rv((prop!=0),"prop"); 221 icalerror_check_arg_rv((p!=0),"prop");
229
230 p = (struct icalproperty_impl*)prop;
231 222
@@ -267,52 +258,118 @@ icalproperty_free (icalproperty* prop)
267 258
268const char* 259/* This returns where the start of the next line should be. chars_left does
269icalproperty_as_ical_string (icalproperty* prop) 260 not include the trailing '\0'. */
270{ 261#define MAX_LINE_LEN 75
271 icalparameter *param; 262/*#define MAX_LINE_LEN 120*/
272 263
273 /* Create new buffer that we can append names, parameters and a 264static char*
274 value to, and reallocate as needed. Later, this buffer will be 265get_next_line_start (char *line_start, int chars_left)
275 copied to a icalmemory_tmp_buffer, which is managed internally 266{
276 by libical, so it can be given to the caller without fear of 267 char *pos;
277 the caller forgetting to free it */
278
279 const char* property_name = 0;
280 size_t buf_size = 1024;
281 char* buf = icalmemory_new_buffer(buf_size);
282 char* buf_ptr = buf;
283 icalvalue* value;
284 char *out_buf;
285 268
286 char newline[] = "\n"; 269 /* If we have 74 chars or less left, we can output all of them.
270 we return a pointer to the '\0' at the end of the string. */
271 if (chars_left < MAX_LINE_LEN) {
272 return line_start + chars_left;
273 }
287 274
288 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop; 275 /* Now we jump to the last possible character of the line, and step back
289 276 trying to find a ';' ':' or ' '. If we find one, we return the character
290 icalerror_check_arg_rz( (prop!=0),"prop"); 277 after it. */
278 pos = line_start + MAX_LINE_LEN - 2;
279 while (pos > line_start) {
280 if (*pos == ';' || *pos == ':' || *pos == ' ') {
281 return pos + 1;
282 }
283 pos--;
284 }
285 /* Now try to split on a UTF-8 boundary defined as a 7-bit
286 value or as a byte with the two high-most bits set:
287 11xxxxxx. See http://czyborra.com/utf/ */
291 288
289 pos = line_start + MAX_LINE_LEN - 1;
290 while (pos > line_start) {
291 /* plain ascii */
292 if ((*pos & 128) == 0)
293 return pos;
292 294
293 /* Append property name */ 295 /* utf8 escape byte */
296 if ((*pos & 192) == 192)
297 return pos;
294 298
295 if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){ 299 pos--;
296 property_name = impl->x_name;
297 } else {
298 property_name = icalproperty_kind_to_string(impl->kind);
299 } 300 }
300 301
301 if (property_name == 0 ) { 302 /* Give up, just break at 74 chars (the 75th char is the space at
302 icalerror_warn("Got a property of an unknown kind."); 303 the start of the line). */
303 icalmemory_free_buffer(buf); 304
304 return 0; 305 return line_start + MAX_LINE_LEN - 1;
305 306}
306 }
307 307
308 308
309 icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name); 309/** This splits the property into lines less than 75 octects long (as
310 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); 310 * specified in RFC2445). It tries to split after a ';' if it can.
311 * It returns a tmp buffer. NOTE: I'm not sure if it matters if we
312 * split a line in the middle of a UTF-8 character. It probably won't
313 * look nice in a text editor.
314 */
315static char*
316fold_property_line (char *text)
317{
318 size_t buf_size;
319 char *buf, *buf_ptr, *line_start, *next_line_start, *out_buf;
320 int len, chars_left, first_line;
321 char ch;
322
323 /* Start with a buffer twice the size of our property line, so we almost
324 certainly won't overflow it. */
325 len = strlen (text);
326 buf_size = len * 2;
327 buf = icalmemory_new_buffer (buf_size);
328 buf_ptr = buf;
329
330 /* Step through the text, finding each line to add to the output. */
331 line_start = text;
332 chars_left = len;
333 first_line = 1;
334 for (;;) {
335 if (chars_left <= 0)
336 break;
337
338 /* This returns the first character for the next line. */
339 next_line_start = get_next_line_start (line_start, chars_left);
340
341 /* If this isn't the first line, we need to output a newline and space
342 first. */
343 if (!first_line) {
344 icalmemory_append_string (&buf, &buf_ptr, &buf_size, "\n ");
345 }
346 first_line = 0;
347
348 /* This adds the line to our tmp buffer. We temporarily place a '\0'
349 in text, so we can copy the line in one go. */
350 ch = *next_line_start;
351 *next_line_start = '\0';
352 icalmemory_append_string (&buf, &buf_ptr, &buf_size, line_start);
353 *next_line_start = ch;
311 354
355 /* Now we move on to the next line. */
356 chars_left -= (next_line_start - line_start);
357 line_start = next_line_start;
358 }
359
360 /* Copy it to a temporary buffer, and then free it. */
361 out_buf = icalmemory_tmp_buffer (strlen (buf) + 1);
362 strcpy (out_buf, buf);
363 icalmemory_free_buffer (buf);
364
365 return out_buf;
366}
312 367
313 368
314 /* Determine what VALUE parameter to include. The VALUE parameters 369/* Determine what VALUE parameter to include. The VALUE parameters
315 are ignored in the normal parameter printing ( the block after 370 are ignored in the normal parameter printing ( the block after
316 this one, so we need to do it here */ 371 this one, so we need to do it here */
317 { 372static const char *
373icalproperty_get_value_kind(icalproperty *prop)
374{
318 const char* kind_string = 0; 375 const char* kind_string = 0;
@@ -322,3 +379,3 @@ icalproperty_as_ical_string (icalproperty* prop)
322 379
323 icalvalue *value = icalproperty_get_value(impl); 380 icalvalue *value = icalproperty_get_value(prop);
324 381
@@ -329,3 +386,3 @@ icalproperty_as_ical_string (icalproperty* prop)
329 icalvalue_kind default_kind 386 icalvalue_kind default_kind
330 = icalproperty_kind_to_value_kind(impl->kind); 387 = icalproperty_kind_to_value_kind(prop->kind);
331 388
@@ -356,10 +413,51 @@ icalproperty_as_ical_string (icalproperty* prop)
356 413
357 if(kind_string!=0){ 414 return kind_string;
358 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;"); 415}
359 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "VALUE="); 416
360 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); 417const char*
361 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); 418icalproperty_as_ical_string (icalproperty* prop)
362 } 419{
420 icalparameter *param;
421
422 /* Create new buffer that we can append names, parameters and a
423 value to, and reallocate as needed. Later, this buffer will be
424 copied to a icalmemory_tmp_buffer, which is managed internally
425 by libical, so it can be given to the caller without fear of
426 the caller forgetting to free it */
427
428 const char* property_name = 0;
429 size_t buf_size = 1024;
430 char* buf = icalmemory_new_buffer(buf_size);
431 char* buf_ptr = buf;
432 icalvalue* value;
433 char *out_buf;
434 const char* kind_string = 0;
435
436 char newline[] = "\n";
437
438
439 icalerror_check_arg_rz( (prop!=0),"prop");
440
441
442 /* Append property name */
443
444 if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){
445 property_name = prop->x_name;
446 } else {
447 property_name = icalproperty_kind_to_string(prop->kind);
448 }
449
450 if (property_name == 0 ) {
451 icalerror_warn("Got a property of an unknown kind.");
452 icalmemory_free_buffer(buf);
453 return 0;
363 454
455 }
364 456
457 icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name);
458
459 kind_string = icalproperty_get_value_kind(prop);
460 if(kind_string!=0){
461 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";VALUE=");
462 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
365 } 463 }
@@ -371,4 +469,4 @@ icalproperty_as_ical_string (icalproperty* prop)
371 469
372 char* kind_string = icalparameter_as_ical_string(param);
373 icalparameter_kind kind = icalparameter_isa(param); 470 icalparameter_kind kind = icalparameter_isa(param);
471 kind_string = icalparameter_as_ical_string(param);
374 472
@@ -379,5 +477,5 @@ icalproperty_as_ical_string (icalproperty* prop)
379 if (kind_string == 0 ) { 477 if (kind_string == 0 ) {
380 char temp[TMP_BUF_SIZE]; 478 icalerror_warn("Got a parameter of unknown kind for the following property");
381 snprintf(temp, TMP_BUF_SIZE,"Got a parameter of unknown kind in %s property",property_name); 479
382 icalerror_warn(temp); 480 icalerror_warn((property_name) ? property_name : "(NULL)");
383 continue; 481 continue;
@@ -385,6 +483,4 @@ icalproperty_as_ical_string (icalproperty* prop)
385 483
386 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;"); 484 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";");
387 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); 485 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
388 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
389
390 } 486 }
@@ -393,3 +489,3 @@ icalproperty_as_ical_string (icalproperty* prop)
393 489
394 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " :"); 490 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ":");
395 491
@@ -411,5 +507,4 @@ icalproperty_as_ical_string (icalproperty* prop)
411 507
412 508 /* We now use a function to fold the line properly every 75 characters. */
413 out_buf = icalmemory_tmp_buffer(strlen(buf)+1); 509 out_buf = fold_property_line (buf);
414 strcpy(out_buf, buf);
415 510
@@ -423,7 +518,5 @@ icalproperty_as_ical_string (icalproperty* prop)
423icalproperty_kind 518icalproperty_kind
424icalproperty_isa (icalproperty* property) 519icalproperty_isa (icalproperty* p)
425{ 520{
426 struct icalproperty_impl *p = (struct icalproperty_impl*)property; 521 if(p != 0){
427
428 if(property != 0){
429 return p->kind; 522 return p->kind;
@@ -437,6 +530,5 @@ icalproperty_isa_property (void* property)
437{ 530{
438 struct icalproperty_impl *impl = (struct icalproperty_impl*)property; 531 icalproperty *impl = (icalproperty *) property;
439 532
440 icalerror_check_arg_rz( (property!=0), "property"); 533 icalerror_check_arg_rz( (property!=0), "property");
441
442 if (strcmp(impl->id,"prop") == 0) { 534 if (strcmp(impl->id,"prop") == 0) {
@@ -450,7 +542,5 @@ icalproperty_isa_property (void* property)
450void 542void
451icalproperty_add_parameter (icalproperty* prop,icalparameter* parameter) 543icalproperty_add_parameter (icalproperty* p,icalparameter* parameter)
452{ 544{
453 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 545 icalerror_check_arg_rv( (p!=0),"prop");
454
455 icalerror_check_arg_rv( (prop!=0),"prop");
456 icalerror_check_arg_rv( (parameter!=0),"parameter"); 546 icalerror_check_arg_rv( (parameter!=0),"parameter");
@@ -470,4 +560,7 @@ icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter)
470 kind = icalparameter_isa(parameter); 560 kind = icalparameter_isa(parameter);
471 561 if (kind != ICAL_X_PARAMETER)
472 icalproperty_remove_parameter(prop,kind); 562 icalproperty_remove_parameter_by_kind(prop,kind);
563 else
564 icalproperty_remove_parameter_by_name(prop,
565 icalparameter_get_xname(parameter));
473 566
@@ -493,3 +586,3 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
493 } 586 }
494 587
495 param = icalparameter_new_from_value_string(kind,value); 588 param = icalparameter_new_from_value_string(kind,value);
@@ -501,2 +594,6 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
501 594
595 if(kind == ICAL_X_PARAMETER){
596 icalparameter_set_xname(param, name);
597 }
598
502 icalproperty_set_parameter(prop,param); 599 icalproperty_set_parameter(prop,param);
@@ -518,3 +615,3 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
518 615
519 if(kind == ICAL_NO_PROPERTY){ 616 if(kind == ICAL_NO_PARAMETER){
520 /* icalenum_string_to_parameter_kind will set icalerrno */ 617 /* icalenum_string_to_parameter_kind will set icalerrno */
@@ -522,4 +619,14 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
522 } 619 }
620
621 for(param = icalproperty_get_first_parameter(prop,kind);
622 param != 0;
623 param = icalproperty_get_next_parameter(prop,kind)) {
624 if (kind != ICAL_X_PARAMETER) {
625 break;
626 }
523 627
524 param = icalproperty_get_first_parameter(prop,kind); 628 if (strcmp(icalparameter_get_xname(param),name)==0) {
629 break;
630 }
631 }
525 632
@@ -529,2 +636,3 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
529 636
637
530 str = icalparameter_as_ical_string(param); 638 str = icalparameter_as_ical_string(param);
@@ -542,7 +650,29 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
542 650
651/** @see icalproperty_remove_parameter_by_kind()
652 *
653 * @deprecated Please use icalproperty_remove_parameter_by_kind()
654 * instead.
655 */
656
543void 657void
544icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind) 658icalproperty_remove_parameter(icalproperty* prop, icalparameter_kind kind)
659{
660 icalproperty_remove_parameter_by_kind(prop, kind);
661}
662
663
664/** @brief Remove all parameters with the specified kind.
665 *
666 * @param prop A valid icalproperty.
667 * @param kind The kind to remove (ex. ICAL_TZID_PARAMETER)
668 *
669 * See icalproperty_remove_parameter_by_name() and
670 * icalproperty_remove_parameter_by_ref() for alternate ways of
671 * removing parameters
672 */
673
674void
675icalproperty_remove_parameter_by_kind(icalproperty* prop, icalparameter_kind kind)
545{ 676{
546 pvl_elem p; 677 pvl_elem p;
547 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
548 678
@@ -550,7 +680,7 @@ icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind)
550 680
551 for(p=pvl_head(impl->parameters);p != 0; p = pvl_next(p)){ 681 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
552 icalparameter* param = (icalparameter *)pvl_data (p); 682 icalparameter* param = (icalparameter *)pvl_data (p);
553 if (icalparameter_isa(param) == kind) { 683 if (icalparameter_isa(param) == kind) {
554 pvl_remove (impl->parameters, p); 684 pvl_remove (prop->parameters, p);
555 icalparameter_free (param); 685 icalparameter_free(param);
556 break; 686 break;
@@ -561,9 +691,88 @@ icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind)
561 691
562int 692/** @brief Remove all parameters with the specified name.
563icalproperty_count_parameters (icalproperty* prop) 693 *
694 * @param prop A valid icalproperty.
695 * @param name The name of the parameter to remove
696 *
697 * This function removes paramters with the given name. The name
698 * corresponds to either a built-in name (TZID, etc.) or the name of
699 * an extended parameter (X-FOO)
700 *
701 * See icalproperty_remove_parameter_by_kind() and
702 * icalproperty_remove_parameter_by_ref() for alternate ways of removing
703 * parameters
704 */
705
706
707void
708icalproperty_remove_parameter_by_name(icalproperty* prop, const char *name)
564{ 709{
565 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 710 pvl_elem p;
711
712 icalerror_check_arg_rv((prop!=0),"prop");
713
714 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
715 icalparameter* param = (icalparameter *)pvl_data (p);
716 const char * kind_string;
717
718 if (icalparameter_isa(param) == ICAL_X_PARAMETER)
719 kind_string = icalparameter_get_xname(param);
720 else
721 kind_string = icalparameter_kind_to_string(icalparameter_isa(param));
722
723 if (!kind_string)
724 continue;
566 725
726 if (0 == strcmp(kind_string, name)) {
727 pvl_remove (prop->parameters, p);
728 break;
729 }
730 }
731}
732
733
734/** @brief Remove the specified parameter reference from the property.
735 *
736 * @param prop A valid icalproperty.
737 * @param parameter A reference to a specific icalparameter.
738 *
739 * This function removes the specified parameter reference from the
740 * property.
741 */
742
743void
744icalproperty_remove_parameter_by_ref(icalproperty* prop, icalparameter* parameter)
745{
746 pvl_elem p;
747 icalparameter_kind kind;
748 const char *name;
749
750 icalerror_check_arg_rv((prop!=0),"prop");
751 icalerror_check_arg_rv((parameter!=0),"parameter");
752
753 kind = icalparameter_isa(parameter);
754 name = icalparameter_get_xname(parameter);
755
756 /*
757 * FIXME If it's an X- parameter, also compare the names. It would be nice
758 * to have a better abstraction like icalparameter_equals()
759 */
760 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
761 icalparameter* p_param = (icalparameter *)pvl_data (p);
762 if (icalparameter_isa(p_param) == kind &&
763 (kind != ICAL_X_PARAMETER ||
764 !strcmp(icalparameter_get_xname(p_param), name))) {
765 pvl_remove (prop->parameters, p);
766 icalparameter_free(p_param);
767 break;
768 }
769 }
770}
771
772
773int
774icalproperty_count_parameters (const icalproperty* prop)
775{
567 if(prop != 0){ 776 if(prop != 0){
568 return pvl_count(p->parameters); 777 return pvl_count(prop->parameters);
569 } 778 }
@@ -576,7 +785,5 @@ icalproperty_count_parameters (icalproperty* prop)
576icalparameter* 785icalparameter*
577icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind) 786icalproperty_get_first_parameter(icalproperty* p, icalparameter_kind kind)
578{ 787{
579 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 788 icalerror_check_arg_rz( (p!=0),"prop");
580
581 icalerror_check_arg_rz( (prop!=0),"prop");
582 789
@@ -604,7 +811,5 @@ icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind)
604icalparameter* 811icalparameter*
605icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind) 812icalproperty_get_next_parameter (icalproperty* p, icalparameter_kind kind)
606{ 813{
607 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 814 icalerror_check_arg_rz( (p!=0),"prop");
608
609 icalerror_check_arg_rz( (prop!=0),"prop");
610 815
@@ -630,7 +835,5 @@ icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind)
630void 835void
631icalproperty_set_value (icalproperty* prop, icalvalue* value) 836icalproperty_set_value (icalproperty* p, icalvalue* value)
632{ 837{
633 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 838 icalerror_check_arg_rv((p !=0),"prop");
634
635 icalerror_check_arg_rv((prop !=0),"prop");
636 icalerror_check_arg_rv((value !=0),"value"); 839 icalerror_check_arg_rv((value !=0),"value");
@@ -645,3 +848,3 @@ icalproperty_set_value (icalproperty* prop, icalvalue* value)
645 848
646 icalvalue_set_parent(value,prop); 849 icalvalue_set_parent(value,p);
647} 850}
@@ -693,12 +896,10 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* str,
693icalvalue* 896icalvalue*
694icalproperty_get_value (icalproperty* prop) 897icalproperty_get_value(const icalproperty* prop)
695{ 898{
696 struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
697
698 icalerror_check_arg_rz( (prop!=0),"prop"); 899 icalerror_check_arg_rz( (prop!=0),"prop");
699 900
700 return p->value; 901 return prop->value;
701} 902}
702 903
703const char* icalproperty_get_value_as_string(icalproperty* prop) 904const char* icalproperty_get_value_as_string(const icalproperty* prop)
704{ 905{
@@ -706,7 +907,5 @@ const char* icalproperty_get_value_as_string(icalproperty* prop)
706 907
707 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
708
709 icalerror_check_arg_rz( (prop!=0),"prop"); 908 icalerror_check_arg_rz( (prop!=0),"prop");
710 909
711 value = impl->value; 910 value = prop->value;
712 911
@@ -718,4 +917,2 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
718{ 917{
719 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
720
721 icalerror_check_arg_rv( (name!=0),"name"); 918 icalerror_check_arg_rv( (name!=0),"name");
@@ -723,9 +920,9 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
723 920
724 if (impl->x_name != 0) { 921 if (prop->x_name != 0) {
725 free(impl->x_name); 922 free(prop->x_name);
726 } 923 }
727 924
728 impl->x_name = icalmemory_strdup(name); 925 prop->x_name = icalmemory_strdup(name);
729 926
730 if(impl->x_name == 0){ 927 if(prop->x_name == 0){
731 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 928 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -736,8 +933,5 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
736const char* icalproperty_get_x_name(icalproperty* prop){ 933const char* icalproperty_get_x_name(icalproperty* prop){
737
738 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
739
740 icalerror_check_arg_rz( (prop!=0),"prop"); 934 icalerror_check_arg_rz( (prop!=0),"prop");
741 935
742 return impl->x_name; 936 return prop->x_name;
743} 937}
@@ -745,4 +939,11 @@ const char* icalproperty_get_x_name(icalproperty* prop){
745 939
746/* From Jonathan Yue <jonathan.yue@cp.net> */ 940const char* icalproperty_get_name(const icalproperty* prop)
747const char* icalproperty_get_name (icalproperty* prop) 941{
942#ifndef NO_WARN_DEPRECATED
943 icalerror_warn("icalproperty_get_name() is DEPRECATED, please use icalproperty_get_property_name() instead.");
944#endif
945 return icalproperty_get_property_name(prop);
946}
947
948const char* icalproperty_get_property_name(const icalproperty* prop)
748{ 949{
@@ -754,10 +955,8 @@ const char* icalproperty_get_name (icalproperty* prop)
754 955
755 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
756
757 icalerror_check_arg_rz( (prop!=0),"prop"); 956 icalerror_check_arg_rz( (prop!=0),"prop");
758 957
759 if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){ 958 if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){
760 property_name = impl->x_name; 959 property_name = prop->x_name;
761 } else { 960 } else {
762 property_name = icalproperty_kind_to_string(impl->kind); 961 property_name = icalproperty_kind_to_string(prop->kind);
763 } 962 }
@@ -787,24 +986,12 @@ void icalproperty_set_parent(icalproperty* property,
787{ 986{
788 struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
789
790 icalerror_check_arg_rv( (property!=0),"property"); 987 icalerror_check_arg_rv( (property!=0),"property");
791 988
792 impl->parent = component; 989 property->parent = component;
793} 990}
794 991
795icalcomponent* icalproperty_get_parent(icalproperty* property) 992icalcomponent* icalproperty_get_parent(const icalproperty* property)
796{ 993{
797 struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
798
799 icalerror_check_arg_rz( (property!=0),"property"); 994 icalerror_check_arg_rz( (property!=0),"property");
800 995
801 return impl->parent; 996 return property->parent;
802} 997}
803
804
805
806
807
808
809
810/* Everything below this line is machine generated. Do not edit. */