Diffstat (limited to 'libical/src/libical/icaltypes.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icaltypes.c | 140 |
1 files changed, 23 insertions, 117 deletions
diff --git a/libical/src/libical/icaltypes.c b/libical/src/libical/icaltypes.c index 8c67deb..19719f8 100644 --- a/libical/src/libical/icaltypes.c +++ b/libical/src/libical/icaltypes.c @@ -37,3 +37,6 @@ -int snprintf(char *str, size_t n, char const *fmt, ...); +#ifdef WIN32 +#define snprintf _snprintf +#define strcasecmp stricmp +#endif @@ -41,129 +44,32 @@ int snprintf(char *str, size_t n, char const *fmt, ...); -void* -icalattachtype_get_data (struct icalattachtype* type); -struct icalattachtype* -icalattachtype_new() +int icaltriggertype_is_null_trigger(struct icaltriggertype tr) { - struct icalattachtype* v; - - if ( ( v = (struct icalattachtype*) - malloc(sizeof(struct icalattachtype))) == 0) { - errno = ENOMEM; - return 0; + if(icaltime_is_null_time(tr.time) && + icaldurationtype_is_null_duration(tr.duration)){ + return 1; } - v->refcount = 1; - - v->binary = 0; - v->owns_binary = 0; - v->base64 = 0; - //fprintf(stderr,"setting base 64 to 0 \n"); - - v->owns_base64 = 0; - - v->url = 0; - - return v; + return 0; } - - -void -icalattachtype_free(struct icalattachtype* v) -{ - icalerror_check_arg( (v!=0),"v"); - v->refcount--; - - if (v->refcount <= 0){ - - if (v->base64 != 0 && v->owns_base64 != 0){ - int val = v->base64 ; - if ( val < 255 ) { - fprintf(stderr,"Possible error in attachment processing (%d)\nPocssible solution: Remove attachment from file.\n",val ); - } - free(v->base64); - } - - if (v->binary != 0 && v->owns_binary != 0){ - free(v->binary); - } - - if (v->url != 0){ - free(v->url); - } - - free(v); - } -} - -void icalattachtype_add_reference(struct icalattachtype* v) -{ - icalerror_check_arg( (v!=0),"v"); - v->refcount++; -} - -void icalattachtype_set_url(struct icalattachtype* v, char* url) +int icaltriggertype_is_bad_trigger(struct icaltriggertype tr) { - icalerror_check_arg( (v!=0),"v"); - - if (v->url != 0){ - free (v->url); + if(icaldurationtype_is_bad_duration(tr.duration)){ + return 1; } - v->url = icalmemory_strdup(url); - - /* HACK This routine should do something if icalmemory_strdup returns NULL */ - -} - -char* icalattachtype_get_url(struct icalattachtype* v) -{ - icalerror_check_arg( (v!=0),"v"); - return v->url; -} - -void icalattachtype_set_base64(struct icalattachtype* v, char* base64, - int owns) -{ - //fprintf(stderr,"1setbase64 %d \n", base64 ); - icalerror_check_arg( (v!=0),"v"); - //fprintf(stderr,"setbase64 %d \n", base64 ); - v->base64 = base64; - v->owns_base64 = !(owns != 0 ); - -} - -char* icalattachtype_get_base64(struct icalattachtype* v) -{ - icalerror_check_arg( (v!=0),"v"); - return v->base64; + return 0; } -void icalattachtype_set_binary(struct icalattachtype* v, char* binary, - int owns) +struct icaltriggertype icaltriggertype_from_int(const int reltime) { - icalerror_check_arg( (v!=0),"v"); + struct icaltriggertype tr; - v->binary = binary; - v->owns_binary = !(owns != 0 ); + tr.time = icaltime_null_time(); + tr.duration = icaldurationtype_from_int(reltime); + return tr; } -void* icalattachtype_get_binary(struct icalattachtype* v) -{ - icalerror_check_arg( (v!=0),"v"); - return v->binary; -} - -int icaltriggertype_is_null_trigger(struct icaltriggertype tr) -{ - if(icaltime_is_null_time(tr.time) && - icaldurationtype_is_null_duration(tr.duration)){ - return 1; - } - - return 0; -} - struct icaltriggertype icaltriggertype_from_string(const char* str) @@ -183,3 +89,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str) - /* Surpress errors so a failure in icaltime_from_string() does not cause an abort */ + /* Suppress errors so a failure in icaltime_from_string() does not cause an abort */ es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); @@ -195,3 +101,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str) - if(icaldurationtype_as_int(tr.duration) == 0) goto error; + if (icaldurationtype_is_bad_duration(tr.duration)) goto error; } @@ -205,3 +111,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str) icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return null_tr; + return tr; @@ -214,3 +120,3 @@ struct icalreqstattype icalreqstattype_from_string(const char* str) struct icalreqstattype stat; - int major, minor; + short major=0, minor=0; @@ -224,3 +130,3 @@ struct icalreqstattype icalreqstattype_from_string(const char* str) - sscanf(str, "%d.%d",&major, &minor); + sscanf(str, "%hd.%hd",&major, &minor); |