Fix bug 637064 - reference libical - Update to libical 0.46. r=pmartinak

--HG--
extra : rebase_source : be9f1447779baaaca178cd523a73d53037aaa81f
This commit is contained in:
Philipp Kewisch 2011-05-24 17:13:45 +02:00
Родитель 6fbb8d3bca
Коммит ec31579702
46 изменённых файлов: 1328 добавлений и 540 удалений

Просмотреть файл

@ -1,39 +1,39 @@
"#Name ","C Type","Enumeration Values"
"ALTREP","const char*",
"CHARSET","const char*",
"CN","const char*",
"CUTYPE","icalparameter_cutype","INDIVIDUAL;GROUP;RESOURCE;ROOM;UNKNOWN"
"DELEGATED-FROM","const char*",
"DELEGATED-TO","const char*",
"DIR","const char*",
"ENCODING","icalparameter_encoding","8BIT;BASE64"
"FBTYPE","icalparameter_fbtype","FREE;BUSY;BUSY-UNAVAILABLE;BUSY-TENTATIVE"
"FMTTYPE","const char*",
"LANGUAGE","const char*",
"MEMBER","const char*",
"PARTSTAT","icalparameter_partstat","NEEDS-ACTION;ACCEPTED;DECLINED;TENTATIVE;DELEGATED;COMPLETED;INPROCESS"
"RANGE","icalparameter_range","THISANDPRIOR;THISANDFUTURE"
"RELATED","icalparameter_related","START;END"
"RELTYPE","icalparameter_reltype","PARENT;CHILD;SIBLING"
"ROLE","icalparameter_role","CHAIR;REQ-PARTICIPANT;OPT-PARTICIPANT;NON-PARTICIPANT"
"RSVP","icalparameter_rsvp","TRUE;FALSE"
"SENT-BY","const char*",
"RECEIVED-SEQUENCE","const char*",
"RECEIVED-DTSTAMP","const char*",
"TZID","const char*",
"VALUE","icalparameter_value","BINARY;BOOLEAN;DATE;DURATION;FLOAT;INTEGER;PERIOD;RECUR;TEXT;URI;ERROR;DATE-TIME;UTC-OFFSET;CAL-ADDRESS"
"X","const char*",
"X-LIC-ERRORTYPE","icalparameter_xlicerrortype","COMPONENT-PARSE-ERROR;PROPERTY-PARSE-ERROR;PARAMETER-NAME-PARSE-ERROR;PARAMETER-VALUE-PARSE-ERROR;VALUE-PARSE-ERROR;INVALID-ITIP;UNKNOWN-VCAL-PROP-ERROR;MIME-PARSE-ERROR;VCAL-PROP-PARSE-ERROR"
"X-LIC-COMPARETYPE","icalparameter_xliccomparetype","EQUAL;NOTEQUAL;LESS;GREATER;LESSEQUAL;GREATEREQUAL;REGEX;ISNULL;ISNOTNULL"
"#Name ","C icalparameter_kind Enum","C Type","Enumeration Values"
"ALTREP","2","const char*",
"CHARSET","3","const char*",
"CN","4","const char*",
"CUTYPE","5","icalparameter_cutype","INDIVIDUAL;GROUP;RESOURCE;ROOM;UNKNOWN"
"DELEGATED-FROM","6","const char*",
"DELEGATED-TO","7","const char*",
"DIR","8","const char*",
"ENCODING","10","icalparameter_encoding","8BIT;BASE64"
"FBTYPE","11","icalparameter_fbtype","FREE;BUSY;BUSY-UNAVAILABLE;BUSY-TENTATIVE"
"FMTTYPE","12","const char*",
"LANGUAGE","14","const char*",
"MEMBER","18","const char*",
"PARTSTAT","20","icalparameter_partstat","NEEDS-ACTION;ACCEPTED;DECLINED;TENTATIVE;DELEGATED;COMPLETED;INPROCESS"
"RANGE","21","icalparameter_range","THISANDPRIOR;THISANDFUTURE"
"RELATED","22","icalparameter_related","START;END"
"RELTYPE","23","icalparameter_reltype","PARENT;CHILD;SIBLING"
"ROLE","24","icalparameter_role","CHAIR;REQ-PARTICIPANT;OPT-PARTICIPANT;NON-PARTICIPANT"
"RSVP","25","icalparameter_rsvp","TRUE;FALSE"
"SENT-BY","26","const char*",
"TZID","27","const char*",
"VALUE","28","icalparameter_value","BINARY;BOOLEAN;DATE;DURATION;FLOAT;INTEGER;PERIOD;RECUR;TEXT;URI;ERROR;DATE-TIME;UTC-OFFSET;CAL-ADDRESS"
"X","29","const char*",
"X-LIC-ERRORTYPE","31","icalparameter_xlicerrortype","COMPONENT-PARSE-ERROR;PROPERTY-PARSE-ERROR;PARAMETER-NAME-PARSE-ERROR;PARAMETER-VALUE-PARSE-ERROR;VALUE-PARSE-ERROR;INVALID-ITIP;UNKNOWN-VCAL-PROP-ERROR;MIME-PARSE-ERROR;VCAL-PROP-PARSE-ERROR"
"X-LIC-COMPARETYPE","30","icalparameter_xliccomparetype","EQUAL;NOTEQUAL;LESS;GREATER;LESSEQUAL;GREATEREQUAL;REGEX;ISNULL;ISNOTNULL"
"#CAP Parameters","Draft 8",
"#this parameter should really be called ACTION, but this conflicts with the ACTION property"
"ACTIONPARAM","icalparameter_action","ASK;ABORT"
"ID","const char*",
"ENABLE","icalparameter_enable","TRUE;FALSE"
"LATENCY","const char*",
"LOCAL","icalparameter_local","TRUE;FALSE"
"LOCALIZE","const char*",
"OPTIONS","const char*",
"SCHEDULE-AGENT","const char*",
"SCHEDULE-STATUS","const char*",
"SCHEDULE-FORCE-SEND","const char*",
"ACTIONPARAM","1","icalparameter_action","ASK;ABORT"
"ID","13","const char*",
"ENABLE","9","icalparameter_enable","TRUE;FALSE"
"LATENCY","15","const char*",
"LOCAL","16","icalparameter_local","TRUE;FALSE"
"LOCALIZE","17","const char*",
"OPTIONS","19","const char*",
"NO","32",,
"#In practice any unknown paramater that is not an xparam is treated as an ianaparam"
"IANA","33","const char*",
"ANY","0",,
"#NOTE for updaters. Preserve the icalparameter_kind Enum values to aid forward compatibility"

Не удается отобразить этот файл, потому что он имеет неправильное количество полей в строке 26.

Просмотреть файл

@ -3,7 +3,7 @@
"BOOLEAN","(a)int","integer","unitary",
"CAL-ADDRESS","(a)const char*","string","unitary",
"DATE","(a)struct icaltimetype","Time","unitary",
"DATE-TIME","(a)struct icaltimetype","Time","unitary",
"DATE-TIME","(m)struct icaltimetype","Time","unitary",
"DURATION","(a)struct icaldurationtype","Duration","unitary",
"FLOAT","(a)float","float","unitary",
"INTEGER","(a)int","integer","unitary",
@ -23,10 +23,10 @@
"ACTION","(a)enum icalproperty_action","string","unitary","AUDIO;DISPLAY;EMAIL;PROCEDURE"
"STATUS","(a)enum icalproperty_status","string","unitary","TENTATIVE;CONFIRMED;COMPLETED;NEEDS-ACTION;CANCELLED;IN-PROCESS;DRAFT;FINAL"
"TRANSP","(a)enum icalproperty_transp","string","unitary","OPAQUE;OPAQUE-NOCONFLICT;TRANSPARENT;TRANSPARENT-NOCONFLICT"
"CLASS","(a)enum icalproperty_class","string","unitary","PUBLIC;PRIVATE;CONFIDENTIAL"
"CLASS","(m)enum icalproperty_class","string","unitary","PUBLIC;PRIVATE;CONFIDENTIAL"
"#Other non-standard",,,,
"REQUEST-STATUS","(a)struct icalreqstattype","string","unitary"
"GEO","(a)struct icalgeotype","tuple","unitary",
"GEO","(m)struct icalgeotype","tuple","unitary",
"STRING","(a)const char*","string","unitary",
"X","(m)const char*","string","unitary",
"#CAP enumeration types",,,,

Не удается отобразить этот файл, потому что он имеет неправильное количество полей в строке 28.

Просмотреть файл

@ -19,19 +19,25 @@ if ($opt_i) {
while(<IN>){
if (/<insert_code_here>/){
$autogenMsg = "of section of machine generated code (mkderivedparameters.pl). Do not edit.";
if($opt_p){
$startComment = "#";
$endComment = "";
} else {
$startComment = "/*";
$endComment = " */";
}
print $startComment." START ".$autogenMsg.$endComment."\n\n";
insert_code();
print $startComment." END ".$autogenMsg.$endComment."\n\n";
} else {
print;
}
}
if($opt_p){
print "# Everything below this line is machine generated. Do not edit. \n";
} else {
print "/* Everything below this line is machine generated. Do not edit. */\n";
}
}
sub insert_code
@ -40,7 +46,9 @@ sub insert_code
# Write parameter enumerations and datatypes
if($opt_h){
print "typedef enum icalparameter_kind {\n ICAL_ANY_PARAMETER = 0,\n";
my $enumConst = $params{'ANY'}->{"kindEnum"};
print "typedef enum icalparameter_kind {\n ICAL_ANY_PARAMETER = ".$enumConst.",\n";
$enumVal = 1;
foreach $param (sort keys %params) {
next if !$param;
@ -49,12 +57,13 @@ if($opt_h){
my $uc = join("",map {uc($_);} split(/-/,$param));
my @enums = @{$params{$param}->{'enums'}};
$enumConst = $params{$param}->{"kindEnum"};
print " ICAL_${uc}_PARAMETER, \n";
print " ICAL_${uc}_PARAMETER = ".$enumConst.", \n";
}
print " ICAL_NO_PARAMETER\n} icalparameter_kind;\n\n";
$enumConst = $params{'NO'}->{"kindEnum"};
print " ICAL_NO_PARAMETER = ".$enumConst."\n} icalparameter_kind;\n\n";
# Now create enumerations for parameter values
$idx = 20000;
@ -65,7 +74,7 @@ if($opt_h){
next if !$param;
next if $param eq 'NO' or $prop eq 'ANY';
next if $param eq 'NO' or $param eq 'ANY';
my $type = $params{$param}->{"C"};
my $ucv = join("",map {uc(lc($_));} split(/-/,$param));
@ -131,7 +140,7 @@ if ($opt_c){
next if !$param;
next if $param eq 'NO' or $prop eq 'ANY';
next if $param eq 'NO' or $param eq 'ANY';
my $lc = join("",map {lc($_);} split(/-/,$param));
my $uc = join("",map {uc(lc($_));} split(/-/,$param));
@ -152,7 +161,7 @@ if ($opt_c){
next if !$param;
next if $param eq 'NO' or $prop eq 'ANY';
next if $param eq 'NO' or $param eq 'ANY';
my $type = $params{$param}->{"C"};
my $uc = join("",map {uc(lc($_));} split(/-/,$param));
@ -178,7 +187,9 @@ if ($opt_c){
}
foreach $param (keys %params){
foreach $param (sort keys %params){
next if $param eq 'NO' or $param eq 'ANY';
my $type = $params{$param}->{'C'};

Просмотреть файл

@ -179,7 +179,9 @@ foreach $prop (sort keys %propmap) {
print<<EOM;
icalproperty* icalproperty_vanew_${lc}($type v, ...){
va_list args;
struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); $pointer_check
struct icalproperty_impl *impl;
$pointer_check
impl= icalproperty_new_impl(ICAL_${uc}_PROPERTY);
icalproperty_set_${lc}((icalproperty*)impl,v);
va_start(args,v);
icalproperty_add_parameters(impl, args);
@ -192,7 +194,9 @@ EOM
/* $prop */
icalproperty* icalproperty_new_${lc}($type v) {
struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY); $pointer_check
struct icalproperty_impl *impl;
$pointer_check
impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY);
icalproperty_set_${lc}((icalproperty*)impl,v);
return (icalproperty*)impl;
}

Просмотреть файл

@ -184,8 +184,9 @@ foreach $value (keys %h) {
print "\n\n\
icalvalue* icalvalue_new_${lc} ($type v){\
struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_${uc}_VALUE);\
struct icalvalue_impl* impl;\
$pointer_check\
impl = icalvalue_new_impl(ICAL_${uc}_VALUE);\
icalvalue_set_${lc}((icalvalue*)impl,v);\
return (icalvalue*)impl;\
}\

Просмотреть файл

@ -110,8 +110,9 @@ sub read_parameters_file {
my $parameter_name = $column[0];
my $data_type = $column[1];
my $enum_string = $column[2];
my $enumConst = $column[1];
my $data_type = $column[2];
my $enum_string = $column[3];
my @enums;
if($enum_string){
@ -119,6 +120,7 @@ sub read_parameters_file {
}
$h{$parameter_name} = { C => $data_type,
kindEnum => $enumConst,
enums => [@enums]
};
}

Просмотреть файл

@ -108,31 +108,32 @@ ICALSCRIPTS = $(srcdir)/../../scripts
# is required to make the combined header ical.h properly
COMBINEDHEADERS = \
$(srcdir)/../../config.h \
$(srcdir)/icalversion.h \
$(srcdir)/icaltime.h \
$(srcdir)/icalduration.h \
$(srcdir)/icalperiod.h \
$(srcdir)/icalenums.h \
$(srcdir)/icaltypes.h \
$(srcdir)/icalrecur.h \
$(srcdir)/icalattach.h \
icalderivedvalue.h \
icalderivedparameter.h \
$(srcdir)/icalvalue.h \
$(srcdir)/icalparameter.h \
icalderivedproperty.h \
$(srcdir)/icalproperty.h \
$(srcdir)/pvl.h \
$(srcdir)/icalarray.h \
$(srcdir)/icalcomponent.h \
$(srcdir)/icaltimezone.h \
$(srcdir)/icalparser.h \
$(srcdir)/icalmemory.h \
$(srcdir)/icalerror.h \
$(srcdir)/icalrestriction.h \
$(srcdir)/sspm.h \
$(srcdir)/icalmime.h \
$(srcdir)/icallangbind.h
$(srcdir)/icalversion.h \
$(srcdir)/icaltime.h \
$(srcdir)/icalduration.h \
$(srcdir)/icalperiod.h \
$(srcdir)/icalenums.h \
$(srcdir)/icaltypes.h \
$(srcdir)/icalrecur.h \
$(srcdir)/icalattach.h \
icalderivedvalue.h \
icalderivedparameter.h \
$(srcdir)/icalvalue.h \
$(srcdir)/icalparameter.h \
icalderivedproperty.h \
$(srcdir)/icalproperty.h \
$(srcdir)/pvl.h \
$(srcdir)/icalarray.h \
$(srcdir)/icalcomponent.h \
$(srcdir)/icaltimezone.h \
$(srcdir)/icalparser.h \
$(srcdir)/icalmemory.h \
$(srcdir)/icalerror.h \
$(srcdir)/icalrestriction.h \
$(srcdir)/sspm.h \
$(srcdir)/icalmime.h \
$(srcdir)/icallangbind.h \
$(NULL)
BUILT_COMBINEDHEADERS = \
icalderivedparameter.h \

Просмотреть файл

@ -72,13 +72,13 @@ struct ut_instant * date;
ka = (long) jd;
if ( jd >= 2299161L )
{
ialp = ( (double) jd - 1867216.25 ) / ( 36524.25 );
ialp = (long) (((double) jd) - 1867216.25 ) / 36524.25;
ka = jd + 1L + ialp - ( ialp >> 2 );
}
kb = ka + 1524L;
kc = ( (double) kb - 122.1 ) / 365.25;
kd = (double) kc * 365.25;
ke = (double) ( kb - kd ) / 30.6001;
kc = (long) ((double) kb - 122.1 ) / 365.25;
kd = (long) (double) kc * 365.25;
ke = (long) (double) ( kb - kd ) / 30.6001;
date->day = kb - kd - ((long) ( (double) ke * 30.6001 ));
if ( ke > 13L )
date->month = ke - 13L;
@ -93,9 +93,9 @@ struct ut_instant * date;
else
date->year = kc - 4715L;
date->i_hour = date->d_hour = frac * 24.0; /* hour */
date->i_minute = date->d_minute =
date->i_minute = date->d_minute = (long)
( date->d_hour - (double) date->i_hour ) * 60.0; /* minute */
date->i_second = date->d_second =
date->i_second = date->d_second = (long)
( date->d_minute - (double) date->i_minute ) * 60.0;/* second */
date->weekday = (jd + 1L) % 7L; /* day of week */
if ( date->year == ((date->year >> 2) << 2) )

Просмотреть файл

@ -66,15 +66,42 @@ icalarray_new (int element_size,
return array;
}
icalarray *icalarray_copy (icalarray *originalarray)
{
icalarray *array = icalarray_new(originalarray->element_size, originalarray->increment_size);
if (!array)
return NULL;
array->num_elements = originalarray->num_elements;
array->space_allocated = originalarray->space_allocated;
array->data = malloc(array->space_allocated * array->element_size);
if (array->data) {
memcpy(array->data, originalarray->data,
array->element_size*array->space_allocated);
} else {
icalerror_set_errno(ICAL_ALLOCATION_ERROR);
}
return array;
}
/** @brief Destructor
*/
void
icalarray_free (icalarray *array)
{
if (array->data)
if (array->data) {
free (array->data);
array->data = 0;
}
free (array);
array = 0;
}
@ -152,7 +179,10 @@ icalarray_expand (icalarray *array,
if (new_data) {
memcpy(new_data,array->data,array->element_size*array->space_allocated);
free(array->data);
if (array->data) {
free(array->data);
array->data = 0;
}
array->data = new_data;
array->space_allocated = new_space_allocated;
} else {

Просмотреть файл

@ -46,6 +46,7 @@ struct _icalarray {
icalarray *icalarray_new (int element_size,
int increment_size);
icalarray *icalarray_copy (icalarray *array);
void icalarray_free (icalarray *array);
void icalarray_append (icalarray *array,

Просмотреть файл

@ -63,10 +63,11 @@ icalattach_new_from_url (const char *url)
}
icalattach *
icalattach_new_from_data (unsigned char *data, icalattach_free_fn_t free_fn,
icalattach_new_from_data (const char *data, icalattach_free_fn_t free_fn,
void *free_fn_data)
{
icalattach *attach;
char *data_copy;
icalerror_check_arg_rz ((data != NULL), "data");
@ -75,9 +76,15 @@ icalattach_new_from_data (unsigned char *data, icalattach_free_fn_t free_fn,
return NULL;
}
if ((data_copy = strdup (data)) == NULL) {
free (attach);
errno = ENOMEM;
return NULL;
}
attach->refcount = 1;
attach->is_url = 0;
attach->u.data.data = data;
attach->u.data.data = data_copy;
attach->u.data.free_fn = free_fn;
attach->u.data.free_fn_data = free_fn_data;
@ -104,10 +111,15 @@ icalattach_unref (icalattach *attach)
if (attach->refcount != 0)
return;
if (attach->is_url)
if (attach->is_url) {
free (attach->u.url.url);
else if (attach->u.data.free_fn)
(* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data);
} else {
free (attach->u.data.data);
/* unused for now
if (attach->u.data.free_fn)
(* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data);
*/
}
free (attach);
}

Просмотреть файл

@ -30,7 +30,7 @@ typedef struct icalattach_impl icalattach;
typedef void (* icalattach_free_fn_t) (unsigned char *data, void *user_data);
icalattach *icalattach_new_from_url (const char *url);
icalattach *icalattach_new_from_data (unsigned char *data,
icalattach *icalattach_new_from_data (const char *data,
icalattach_free_fn_t free_fn, void *free_fn_data);
void icalattach_ref (icalattach *attach);

Просмотреть файл

@ -46,7 +46,7 @@ struct icalattach_impl {
/* Inline data */
struct {
unsigned char *data;
char *data;
icalattach_free_fn_t free_fn;
void *free_fn_data;
} data;

Просмотреть файл

@ -46,9 +46,12 @@
#include <stdio.h> /* for fprintf */
#include <string.h> /* for strdup */
#include <limits.h> /* for INT_MAX */
#ifdef WIN32
#define snprintf _snprintf
#define strncasecmp strnicmp
#define strncasecmp strnicmp
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif
struct icalcomponent_impl
@ -94,6 +97,8 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1,
icalcomponent *vtimezone2);
static int icalcomponent_compare_timezone_fn (const void *elem1,
const void *elem2);
static struct icaltimetype
icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop);
void icalcomponent_add_children(icalcomponent *impl, va_list args)
@ -316,9 +321,6 @@ icalcomponent_as_ical_string_r (icalcomponent* impl)
const char* kind_string;
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
icalerror_check_arg_rz( (impl!=0), "component");
icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT");
@ -330,6 +332,9 @@ icalcomponent_as_ical_string_r (icalcomponent* impl)
icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component");
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:");
icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
@ -394,7 +399,6 @@ icalcomponent_isa (const icalcomponent* component)
{
return component->kind;
}
return ICAL_NO_COMPONENT;
}
@ -851,21 +855,23 @@ int icalproperty_recurrence_is_excluded(icalcomponent *comp,
struct icaltimetype *dtstart,
struct icaltimetype *recurtime) {
icalproperty *exdate, *exrule;
pvl_elem property_iterator = comp->property_iterator;
pvl_elem property_iterator;
if (comp == NULL ||
dtstart == NULL ||
recurtime == NULL ||
icaltime_is_null_time(*recurtime))
/* BAD DATA */
return 1;
return 1;
property_iterator = comp->property_iterator;
/** first test against the exdate values **/
for (exdate = icalcomponent_get_first_property(comp,ICAL_EXDATE_PROPERTY);
exdate != NULL;
exdate = icalcomponent_get_next_property(comp,ICAL_EXDATE_PROPERTY)) {
struct icaltimetype exdatetime = icalproperty_get_exdate(exdate);
struct icaltimetype exdatetime = icalcomponent_get_datetime(comp, exdate);
if (icaltime_compare(*recurtime, exdatetime) == 0) {
/** MATCHED **/
@ -884,7 +890,7 @@ int icalproperty_recurrence_is_excluded(icalcomponent *comp,
icalrecur_iterator *exrule_itr = icalrecur_iterator_new(recur, *dtstart);
struct icaltimetype exrule_time;
while (1) {
while (exrule_itr) {
int result;
exrule_time = icalrecur_iterator_next(exrule_itr);
@ -1046,11 +1052,13 @@ void icalcomponent_foreach_recurrence(icalcomponent* comp,
struct icalrecurrencetype recur = icalproperty_get_rrule(rrule);
icalrecur_iterator *rrule_itr = icalrecur_iterator_new(recur, dtstart);
struct icaltimetype rrule_time = icalrecur_iterator_next(rrule_itr);
struct icaltimetype rrule_time;
if(rrule_itr)
rrule_time = icalrecur_iterator_next(rrule_itr);
/** note that icalrecur_iterator_next always returns dtstart
the first time.. **/
while (1) {
while (rrule_itr) {
rrule_time = icalrecur_iterator_next(rrule_itr);
if (icaltime_is_null_time(rrule_time))
@ -2031,51 +2039,51 @@ enum icalproperty_status icalcomponent_get_status(icalcomponent* comp){
return icalproperty_get_status(prop);
}
icalcomponent* icalcomponent_new_vcalendar()
icalcomponent* icalcomponent_new_vcalendar(void)
{
return icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
}
icalcomponent* icalcomponent_new_vevent()
icalcomponent* icalcomponent_new_vevent(void)
{
return icalcomponent_new(ICAL_VEVENT_COMPONENT);
}
icalcomponent* icalcomponent_new_vtodo()
icalcomponent* icalcomponent_new_vtodo(void)
{
return icalcomponent_new(ICAL_VTODO_COMPONENT);
}
icalcomponent* icalcomponent_new_vjournal()
icalcomponent* icalcomponent_new_vjournal(void)
{
return icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
}
icalcomponent* icalcomponent_new_valarm()
icalcomponent* icalcomponent_new_valarm(void)
{
return icalcomponent_new(ICAL_VALARM_COMPONENT);
}
icalcomponent* icalcomponent_new_vfreebusy()
icalcomponent* icalcomponent_new_vfreebusy(void)
{
return icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
}
icalcomponent* icalcomponent_new_vtimezone()
icalcomponent* icalcomponent_new_vtimezone(void)
{
return icalcomponent_new(ICAL_VTIMEZONE_COMPONENT);
}
icalcomponent* icalcomponent_new_xstandard()
icalcomponent* icalcomponent_new_xstandard(void)
{
return icalcomponent_new(ICAL_XSTANDARD_COMPONENT);
}
icalcomponent* icalcomponent_new_xdaylight()
icalcomponent* icalcomponent_new_xdaylight(void)
{
return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT);
}
icalcomponent* icalcomponent_new_vagenda()
icalcomponent* icalcomponent_new_vagenda(void)
{
return icalcomponent_new(ICAL_VAGENDA_COMPONENT);
}
icalcomponent* icalcomponent_new_vquery()
icalcomponent* icalcomponent_new_vquery(void)
{
return icalcomponent_new(ICAL_VQUERY_COMPONENT);
}
icalcomponent* icalcomponent_new_vreply()
icalcomponent* icalcomponent_new_vreply(void)
{
return icalcomponent_new(ICAL_VREPLY_COMPONENT);
}
@ -2126,9 +2134,8 @@ void icalcomponent_merge_component(icalcomponent* comp,
for (i = 0; i < tzids_to_rename->num_elements; i++) {
free (icalarray_element_at (tzids_to_rename, i));
}
icalarray_free (tzids_to_rename);
}
icalarray_free (tzids_to_rename);
/* Now move all the components from comp_to_merge to comp, excluding
VTIMEZONE components. */
subcomp = icalcomponent_get_first_component (comp_to_merge,
@ -2249,11 +2256,17 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
/* The VTIMEZONEs match, so we can use the existing VTIMEZONE. But
we have to rename TZIDs to this TZID. */
tzid_copy = strdup (tzid);
if(!tzid_copy) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
return;
}
existing_tzid_copy = strdup (existing_tzid);
if (!tzid_copy || !existing_tzid_copy) {
if (!existing_tzid_copy) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
free(tzid_copy);
} else {
icalarray_append (tzids_to_rename, tzid_copy);
free(tzid_copy);
icalarray_append (tzids_to_rename, existing_tzid_copy);
}
return;
@ -2272,10 +2285,16 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
/* We didn't find a VTIMEZONE that matched, so we have to rename the TZID,
using the maximum numerical suffix found + 1. */
tzid_copy = strdup (tzid);
if(!tzid_copy) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
return;
}
snprintf (suffix_buf, sizeof(suffix_buf), "%i", max_suffix + 1);
new_tzid = malloc (tzid_len + strlen (suffix_buf) + 1);
if (!new_tzid || !tzid_copy) {
if (!new_tzid) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
free(tzid_copy);
return;
}
@ -2283,6 +2302,8 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
strcpy (new_tzid + tzid_len, suffix_buf);
icalarray_append (tzids_to_rename, tzid_copy);
icalarray_append (tzids_to_rename, new_tzid);
free(tzid_copy);
free(new_tzid);
}
@ -2404,13 +2425,15 @@ icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid)
middle = (lower + upper) >> 1;
zone = icalarray_element_at (comp->timezones, middle);
zone_tzid = icaltimezone_get_tzid (zone);
cmp = strcmp (tzid, zone_tzid);
if (cmp == 0)
return zone;
else if (cmp < 0)
upper = middle;
else
lower = middle + 1;
if (zone_tzid != NULL) {
cmp = strcmp (tzid, zone_tzid);
if (cmp == 0)
return zone;
else if (cmp < 0)
upper = middle;
else
lower = middle + 1;
}
}
return NULL;
@ -2573,9 +2596,7 @@ struct icaltimetype icalcomponent_get_due(icalcomponent* comp)
icalproperty *dur_prop
= icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
if( due_prop == 0 && dur_prop == 0){
return icaltime_null_time();
} else if ( due_prop != 0) {
if ( due_prop != 0) {
return icalproperty_get_due(due_prop);
} else if ( dur_prop != 0) {
@ -2588,13 +2609,8 @@ struct icaltimetype icalcomponent_get_due(icalcomponent* comp)
return due;
} else {
/* Error, both duration and due have been specified */
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return icaltime_null_time();
}
return icaltime_null_time();
}
/** @brief Set the due date of a VTODO task.
@ -2636,8 +2652,5 @@ void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v)
icalproperty_set_duration(dur_prop,dur);
} else {
/* Error, both duration and due have been specified */
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
}
}

Просмотреть файл

@ -270,16 +270,16 @@ void icalcomponent_foreach_recurrence(icalcomponent* comp,
/*************** Type Specific routines ***************/
icalcomponent* icalcomponent_new_vcalendar();
icalcomponent* icalcomponent_new_vevent();
icalcomponent* icalcomponent_new_vtodo();
icalcomponent* icalcomponent_new_vjournal();
icalcomponent* icalcomponent_new_valarm();
icalcomponent* icalcomponent_new_vfreebusy();
icalcomponent* icalcomponent_new_vtimezone();
icalcomponent* icalcomponent_new_xstandard();
icalcomponent* icalcomponent_new_xdaylight();
icalcomponent* icalcomponent_new_vagenda();
icalcomponent* icalcomponent_new_vquery();
icalcomponent* icalcomponent_new_vcalendar(void);
icalcomponent* icalcomponent_new_vevent(void);
icalcomponent* icalcomponent_new_vtodo(void);
icalcomponent* icalcomponent_new_vjournal(void);
icalcomponent* icalcomponent_new_valarm(void);
icalcomponent* icalcomponent_new_vfreebusy(void);
icalcomponent* icalcomponent_new_vtimezone(void);
icalcomponent* icalcomponent_new_xstandard(void);
icalcomponent* icalcomponent_new_xdaylight(void);
icalcomponent* icalcomponent_new_vagenda(void);
icalcomponent* icalcomponent_new_vquery(void);
#endif /* !ICALCOMPONENT_H */

Просмотреть файл

@ -38,6 +38,7 @@
#include "icalproperty.h"
#include "icalerror.h"
#include "icalmemory.h"
#include "icaltypes.h"
#include <stdlib.h> /* for malloc() */
#include <errno.h>
@ -98,21 +99,25 @@ icalparameter_kind icalparameter_string_to_kind(const char* string)
int i;
if (string ==0 ) {
return ICAL_NO_PARAMETER;
return ICAL_NO_PARAMETER;
}
for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
if (strcasecmp(parameter_map[i].name, string) == 0) {
return parameter_map[i].kind;
}
if (strcasecmp(parameter_map[i].name, string) == 0) {
return parameter_map[i].kind;
}
}
if(strncmp(string,"X-",2)==0){
return ICAL_X_PARAMETER;
return ICAL_X_PARAMETER;
}
return ICAL_NO_PARAMETER;
if (ical_get_unknown_token_handling_setting() == ICAL_TREAT_AS_ERROR) {
return ICAL_NO_PARAMETER;
} else {
return ICAL_IANA_PARAMETER;
}
}

Просмотреть файл

@ -192,7 +192,8 @@ int icalproperty_kind_and_string_to_enum(const int kind, const char* str)
return 0;
for (; i != ICALPROPERTY_LAST_ENUM; i++) {
if ( strcasecmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == pkind &&
strcasecmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum;
}
}

Просмотреть файл

@ -4,7 +4,18 @@
CREATOR: eric 09 May 1999
$Id: icalderivedproperty.h.in,v 1.7 2007-04-30 13:57:48 artcancro Exp $
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
======================================================================*/

Просмотреть файл

@ -102,9 +102,11 @@ icalvalue_kind icalvalue_string_to_kind(const char* str)
}
icalvalue* icalvalue_new_x (const char* v){
struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE);
struct icalvalue_impl* impl;
icalerror_check_arg_rz( (v!=0),"v");
impl = icalvalue_new_impl(ICAL_X_VALUE);
icalvalue_set_x((icalvalue*)impl,v);
return (icalvalue*)impl;
}
@ -123,7 +125,7 @@ void icalvalue_set_x(icalvalue* impl, const char* v) {
}
const char* icalvalue_get_x(const icalvalue* value) {
icalerror_check_arg( (value!=0),"value");
icalerror_check_arg_rz( (value!=0),"value");
icalerror_check_value_type(value, ICAL_X_VALUE);
return value->x_value;
}
@ -164,7 +166,10 @@ icalvalue_set_recur(icalvalue* impl, struct icalrecurrencetype v)
struct icalrecurrencetype
icalvalue_get_recur(const icalvalue* value)
{
icalerror_check_arg( (value!=0),"value");
struct icalrecurrencetype rt;
icalrecurrencetype_clear(&rt);
icalerror_check_arg_rx( (value!=0),"value", rt);
icalerror_check_value_type(value, ICAL_RECUR_VALUE);
return *(value->data.v_recur);
@ -202,24 +207,64 @@ icalvalue_get_trigger(const icalvalue* impl)
{
struct icaltriggertype tr;
icalerror_check_arg( (impl!=0),"value");
icalerror_check_arg( (impl!=0),"value");
tr.duration = icaldurationtype_from_int(0);
tr.time = icaltime_null_time();
if(impl->kind == ICAL_DATETIME_VALUE){
tr.duration = icaldurationtype_from_int(0);
tr.time = impl->data.v_time;
} else if(impl->kind == ICAL_DURATION_VALUE){
icalerror_check_arg_rx( (impl!=0),"value", tr);
if(impl) {
if(impl->kind == ICAL_DATETIME_VALUE){
tr.duration = icaldurationtype_from_int(0);
tr.time = impl->data.v_time;
} else if(impl->kind == ICAL_DURATION_VALUE){
tr.time = icaltime_null_time();
tr.duration = impl->data.v_duration;
} else {
} else {
tr.duration = icaldurationtype_from_int(0);
tr.time = icaltime_null_time();
icalerror_set_errno(ICAL_BADARG_ERROR);
}
} else {
tr.duration = icaldurationtype_from_int(0);
tr.time = icaltime_null_time();
icalerror_set_errno(ICAL_BADARG_ERROR);
}
return tr;
}
icalvalue*
icalvalue_new_datetime (struct icaltimetype v){
struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIME_VALUE);
icalvalue_set_datetime((icalvalue*)impl,v);
return (icalvalue*)impl;
}
void
icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) {
struct icalvalue_impl* impl;
icalerror_check_arg_rv( (value!=0),"value");
icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
impl = (struct icalvalue_impl*)value;
impl->data.v_time = v;
icalvalue_reset_kind(impl);
}
struct icaltimetype
icalvalue_get_datetime (const icalvalue* value) {
struct icaltimetype dt;
dt = icaltime_null_time();
icalerror_check_arg_rx((value!=0),"value", dt);
icalerror_check_value_type (value, ICAL_DATETIME_VALUE);
return ((struct icalvalue_impl*)value)->data.v_time;
}
/* DATE-TIME-PERIOD is a special case, and is not auto generated */
icalvalue*
@ -262,25 +307,98 @@ struct icaldatetimeperiodtype
icalvalue_get_datetimeperiod(const icalvalue* impl)
{
struct icaldatetimeperiodtype dtp;
icalerror_check_arg( (impl!=0),"value");
dtp.period = icalperiodtype_null_period();
dtp.time = icaltime_null_time();
icalerror_check_arg_rx( (impl!=0),"value", dtp);
icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
if( impl->kind == ICAL_DATETIME_VALUE || impl->kind == ICAL_DATE_VALUE ){
if(impl) {
if( impl->kind == ICAL_DATETIME_VALUE || impl->kind == ICAL_DATE_VALUE ){
dtp.period = icalperiodtype_null_period();
dtp.time = impl->data.v_time;
} else if(impl->kind == ICAL_PERIOD_VALUE) {
} else if(impl->kind == ICAL_PERIOD_VALUE) {
dtp.period = impl->data.v_period;
dtp.time = icaltime_null_time();
} else {
} else {
dtp.period = icalperiodtype_null_period();
dtp.time = icaltime_null_time();
icalerror_set_errno(ICAL_BADARG_ERROR);
}
} else {
dtp.period = icalperiodtype_null_period();
dtp.time = icaltime_null_time();
icalerror_set_errno(ICAL_BADARG_ERROR);
}
return dtp;
}
icalvalue*
icalvalue_new_class (enum icalproperty_class v){
struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE);
icalvalue_set_class((icalvalue*)impl,v);
return (icalvalue*)impl;
}
void
icalvalue_set_class(icalvalue* value, enum icalproperty_class v) {
struct icalvalue_impl* impl;
icalerror_check_arg_rv( (value!=0),"value");
icalerror_check_value_type(value, ICAL_CLASS_VALUE);
impl = (struct icalvalue_impl*)value;
impl->data.v_enum = v;
icalvalue_reset_kind(impl);
}
enum icalproperty_class
icalvalue_get_class (const icalvalue* value) {
icalproperty_class pr;
pr = ICAL_CLASS_NONE;
icalerror_check_arg_rx ((value!=NULL),"value", pr);
icalerror_check_arg ((value!=0),"value");
icalerror_check_value_type (value, ICAL_CLASS_VALUE);
return ((struct icalvalue_impl*)value)->data.v_enum;
}
icalvalue*
icalvalue_new_geo (struct icalgeotype v){
struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE);
icalvalue_set_geo((icalvalue*)impl,v);
return (icalvalue*)impl;
}
void
icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
struct icalvalue_impl* impl;
icalerror_check_arg_rv( (value!=0),"value");
icalerror_check_value_type(value, ICAL_GEO_VALUE);
impl = (struct icalvalue_impl*)value;
impl->data.v_geo = v;
icalvalue_reset_kind(impl);
}
struct icalgeotype
icalvalue_get_geo (const icalvalue* value) {
struct icalgeotype gt;
gt.lat = 255.0;
gt.lon = 255.0;
icalerror_check_arg_rx((value!=0),"value", gt);
icalerror_check_value_type (value, ICAL_GEO_VALUE);
return ((struct icalvalue_impl*)value)->data.v_geo;
}
icalvalue *

Просмотреть файл

@ -38,8 +38,6 @@
typedef struct icalvalue_impl icalvalue;
void icalvalue_set_x(icalvalue* value, const char* v);
icalvalue* icalvalue_new_x(const char* v);
const char* icalvalue_get_x(const icalvalue* value);
@ -52,10 +50,19 @@ icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
icalvalue* icalvalue_new_datetime(struct icaltimetype v);
struct icaltimetype icalvalue_get_datetime(const icalvalue* value);
void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v);
icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v);
struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
/* GEO */
icalvalue* icalvalue_new_geo(struct icalgeotype v);
struct icalgeotype icalvalue_get_geo(const icalvalue* value);
void icalvalue_set_geo(icalvalue* value, struct icalgeotype v);
icalvalue *icalvalue_new_attach (icalattach *attach);
void icalvalue_set_attach (icalvalue *value, icalattach *attach);
icalattach *icalvalue_get_attach (const icalvalue *value);
@ -63,3 +70,8 @@ icalattach *icalvalue_get_attach (const icalvalue *value);
void icalvalue_reset_kind(icalvalue* value);
<insert_code_here>
icalvalue* icalvalue_new_class(enum icalproperty_class v);
enum icalproperty_class icalvalue_get_class(const icalvalue* value);
void icalvalue_set_class(icalvalue* value, enum icalproperty_class v);

Просмотреть файл

@ -35,14 +35,16 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef WIN32
#define snprintf _snprintf
#endif
#include "icalerror.h"
#include "icalmemory.h"
#include "icalvalue.h"
#ifdef WIN32
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif

Просмотреть файл

@ -35,11 +35,15 @@
#include <stdio.h> /* For stderr */
#include <string.h> /* For strncmp */
#include <assert.h>
#ifdef WIN32
#define snprintf _snprintf
#endif
#include "icalmemory.h"
#ifdef WIN32
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif
/*** @brief Allowed request status values
*/
static const struct {

Просмотреть файл

@ -189,7 +189,7 @@ icalerrorstate icalerror_supress(const char* error){
return es;
}
const char* icalerror_perror()
const char* icalerror_perror(void)
{
return icalerror_strerror(icalerrno);
}

Просмотреть файл

@ -69,7 +69,17 @@ icalerrorenum * icalerrno_return(void);
* @warning NOT THREAD SAFE -- recommended that you do not change
* this in a multithreaded program.
*/
extern int icalerror_errors_are_fatal;
#ifdef _MSC_VER
#ifdef BUILD_LIBICALDLL
#define LIBICAL_EXPORT __declspec(dllexport)
#else
#define LIBICAL_EXPORT __declspec(dllimport)
#endif
#else
#define LIBICAL_EXPORT extern
#endif
LIBICAL_EXPORT int icalerror_errors_are_fatal;
/* Warning messages */
@ -92,7 +102,7 @@ typedef enum icalerrorstate {
} icalerrorstate ;
const char* icalerror_strerror(icalerrorenum e);
const char* icalerror_perror();
const char* icalerror_perror(void);
void ical_bt(void);
void icalerror_set_error_state( icalerrorenum error, icalerrorstate);
icalerrorstate icalerror_get_error_state( icalerrorenum error);

Просмотреть файл

@ -160,8 +160,8 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
{
char tmp[25];
size_t buf_size = 1024;
char* buf = icalmemory_new_buffer(buf_size);
char* buf_ptr = buf;
char* buf;
char* buf_ptr;
icalparameter *param;
icalvalue* value;
@ -169,6 +169,9 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
if( prop == 0){
return 0;
}
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
APPENDS("{ ");

Просмотреть файл

@ -53,7 +53,7 @@ struct text_part
size_t buf_size;
};
void* icalmime_text_new_part()
void* icalmime_text_new_part(void)
{
#define BUF_SIZE 2048
@ -125,7 +125,7 @@ void icalmime_text_free_part(void *part)
/* Ignore Attachments for now */
void* icalmime_attachment_new_part()
void* icalmime_attachment_new_part(void)
{
return 0;
}
@ -345,7 +345,8 @@ line between the header and the previous boundary\?";
} else if (parts[i].level < last_level){
parent = icalcomponent_get_parent(parent);
if (parent)
parent = icalcomponent_get_parent(parent);
icalcomponent_add_component(parent,comp);
last_level = parts[i].level;
@ -399,6 +400,7 @@ int icalmime_test(char* (*get_string)(char *s, size_t size, void *d),
sspm_write_mime(parts,NUM_PARTS,&out,"To: bob@bob.org");
printf("%s\n",out);
free(out);
return 0;

Просмотреть файл

@ -27,7 +27,6 @@
Graham Davison <g.m.davison@computer.org>
======================================================================*/
/*#line 29 "icalparameter.c.in"*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@ -43,6 +42,14 @@
#include <errno.h>
#include <string.h> /* for memset() */
#ifdef WIN32
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#define strcasecmp stricmp
#endif
/* In icalderivedparameter */
icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val);
@ -167,6 +174,7 @@ icalparameter* icalparameter_new_from_string(const char *str)
if(eq == 0){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(cpy);
return 0;
}
@ -178,6 +186,7 @@ icalparameter* icalparameter_new_from_string(const char *str)
if(kind == ICAL_NO_PARAMETER){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(cpy);
return 0;
}
@ -185,6 +194,8 @@ icalparameter* icalparameter_new_from_string(const char *str)
if(kind == ICAL_X_PARAMETER){
icalparameter_set_xname(param,cpy);
} else if(kind == ICAL_IANA_PARAMETER) {
icalparameter_set_iana_name(param, cpy);
}
free(cpy);
@ -220,7 +231,6 @@ icalparameter_as_ical_string_r(icalparameter* param)
size_t buf_size = 1024;
char* buf;
char* buf_ptr;
char *out_buf;
const char *kind_string;
icalerror_check_arg_rz( (param!=0), "parameter");
@ -233,10 +243,11 @@ icalparameter_as_ical_string_r(icalparameter* param)
buf_ptr = buf;
if(param->kind == ICAL_X_PARAMETER) {
icalmemory_append_string(&buf, &buf_ptr, &buf_size,
icalparameter_get_xname(param));
icalmemory_append_string(&buf, &buf_ptr, &buf_size,
icalparameter_get_xname(param));
} else if (param->kind == ICAL_IANA_PARAMETER) {
icalmemory_append_string(&buf, &buf_ptr, &buf_size,
icalparameter_get_iana_name(param));
} else {
kind_string = icalparameter_kind_to_string(param->kind);
@ -246,6 +257,7 @@ icalparameter_as_ical_string_r(icalparameter* param)
kind_string == 0)
{
icalerror_set_errno(ICAL_BADARG_ERROR);
free(buf);
return 0;
}
@ -274,6 +286,7 @@ icalparameter_as_ical_string_r(icalparameter* param)
icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
} else {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(buf);
return 0;
}
@ -365,6 +378,26 @@ icalparameter_get_xvalue (icalparameter* param)
return param->string;
}
void icalparameter_set_iana_value (icalparameter* param, const char* v)
{
icalparameter_set_xvalue(param, v);
}
const char* icalparameter_get_iana_value(icalparameter* param)
{
return icalparameter_get_xvalue(param);
}
void icalparameter_set_iana_name (icalparameter* param, const char* v)
{
icalparameter_set_xname(param, v);
}
const char* icalparameter_get_iana_name (icalparameter* param)
{
return icalparameter_get_xname(param);
}
void icalparameter_set_parent(icalparameter* param,
icalproperty* property)
{
@ -380,6 +413,36 @@ icalproperty* icalparameter_get_parent(icalparameter* param)
return param->parent;
}
/* returns 1 if parameters have same name in ICAL, otherwise 0 */
int icalparameter_has_same_name(icalparameter* param1, icalparameter* param2)
{
icalparameter_kind kind1;
icalparameter_kind kind2;
const char *name1;
const char *name2;
icalerror_check_arg_rz( (param1!=0),"param1");
icalerror_check_arg_rz( (param2!=0),"param2");
kind1 = icalparameter_isa(param1);
kind2 = icalparameter_isa(param2);
if (kind1 != kind2)
return 0;
if (kind1 == ICAL_X_PARAMETER) {
name1 = icalparameter_get_xname(param1);
name2 = icalparameter_get_xname(param2);
if (strcasecmp(name1, name2) != 0)
return 0;
} else if (kind1 == ICAL_IANA_PARAMETER) {
name1 = icalparameter_get_iana_name(param1);
name2 = icalparameter_get_iana_name(param2);
if (strcasecmp(name1, name2) != 0)
return 0;
}
return 1;
}
/* Everything below this line is machine generated. Do not edit. */
/* ALTREP */

Просмотреть файл

@ -55,12 +55,21 @@ icalparameter_kind icalparameter_isa(icalparameter* parameter);
int icalparameter_isa_parameter(void* param);
/* Access the name of an X parameer */
/* Access the name of an X parameter */
void icalparameter_set_xname (icalparameter* param, const char* v);
const char* icalparameter_get_xname(icalparameter* param);
void icalparameter_set_xvalue (icalparameter* param, const char* v);
const char* icalparameter_get_xvalue(icalparameter* param);
/* Access the name of an IANA parameter */
void icalparameter_set_iana_name (icalparameter* param, const char* v);
const char* icalparameter_get_iana_name(icalparameter* param);
void icalparameter_set_iana_value (icalparameter* param, const char* v);
const char* icalparameter_get_iana_value(icalparameter* param);
/* returns 1 if parameters have same name in ICAL, otherwise 0 */
int icalparameter_has_same_name(icalparameter* param1, icalparameter* param2);
/* Convert enumerations */
const char* icalparameter_kind_to_string(icalparameter_kind kind);

Просмотреть файл

@ -55,11 +55,6 @@
#include "icalmemory.h"
#include "icalparser.h"
#ifdef WIN32
#define HAVE_CTYPE_H
#define HAVE_ISWSPACE
#endif
#ifdef HAVE_WCTYPE_H
# include <wctype.h>
/* Some systems have an imcomplete implementation on wctype (FreeBSD,
@ -284,6 +279,7 @@ char* parser_get_param_name(char* line, char **end, char **buf)
*end = *end+1;
next = parser_get_next_char('"',*end,0);
if (next == 0) {
free(str);
return 0;
}
@ -746,11 +742,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
}
if (comp_kind != ICAL_X_COMPONENT) {
c = icalcomponent_new(comp_kind);
} else {
c = icalcomponent_new_x(str);
}
c = icalcomponent_new(comp_kind);
if (c == 0){
c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
@ -906,13 +898,25 @@ icalcomponent* icalparser_add_line(icalparser* parser,
if(kind == ICAL_X_PARAMETER){
param = icalparameter_new(ICAL_X_PARAMETER);
if(param != 0){
icalparameter_set_xname(param,name);
icalparameter_set_xvalue(param,pvalue);
}
icalmemory_free_buffer(buf_value);
buf_value = NULL;
if(param != 0){
icalparameter_set_xname(param,name);
icalparameter_set_xvalue(param,pvalue);
}
icalmemory_free_buffer(buf_value);
buf_value = NULL;
} else if (kind == ICAL_IANA_PARAMETER){
ical_unknown_token_handling tokHandlingSetting =
ical_get_unknown_token_handling_setting();
if (tokHandlingSetting == ICAL_DISCARD_TOKEN)
continue;
param = icalparameter_new(ICAL_IANA_PARAMETER);
if(param != 0){
icalparameter_set_xname(param,name);
icalparameter_set_xvalue(param,pvalue);
}
icalmemory_free_buffer(buf_value);
buf_value = NULL;
} else if (kind != ICAL_NO_PARAMETER){
param = icalparameter_new_from_value_string(kind,pvalue);
@ -990,7 +994,6 @@ icalcomponent* icalparser_add_line(icalparser* parser,
tail, str,
"Got a VALUE parameter with an unknown type",
ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
icalparameter_free(param);
value_kind =
icalproperty_kind_to_value_kind(
@ -1112,21 +1115,29 @@ icalcomponent* icalparser_add_line(icalparser* parser,
str = NULL;
} else {
if (str != NULL) {
icalmemory_free_buffer(str);
str = NULL;
}
if (vcount == 0){
char temp[200]; /* HACK */
icalproperty_kind prop_kind = icalproperty_isa(prop);
icalcomponent *tail = pvl_data(pvl_tail(parser->components));
/* Remove the empty property */
snprintf(temp,sizeof(temp),"No value for %s property. Removing entire property",
icalproperty_kind_to_string(prop_kind));
insert_error(tail, str, temp,
ICAL_XLICERRORTYPE_VALUEPARSEERROR);
/* Remove the troublesome property */
icalcomponent_remove_property(tail,prop);
icalproperty_free(prop);
prop = NULL;
}
prop = 0;
tail = 0;
parser->state = ICALPARSER_ERROR;
return 0;
} else {
break;
break;
}
}
}

Просмотреть файл

@ -117,8 +117,8 @@ const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
char* icalperiodtype_as_ical_string_r(struct icalperiodtype p)
{
const char* start;
const char* end;
char* start;
char* end;
char *buf;
size_t buf_size = 40;

Просмотреть файл

@ -174,14 +174,17 @@ icalproperty* icalproperty_new_from_string(const char* str)
{
size_t buf_size = 1024;
char* buf = icalmemory_new_buffer(buf_size);
char* buf_ptr = buf;
char* buf;
char* buf_ptr;
icalproperty *prop;
icalcomponent *comp;
int errors = 0;
icalerror_check_arg_rz( (str!=0),"str");
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
/* Is this a HACK or a crafty reuse of code? */
icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:VCALENDAR\r\n");
@ -193,6 +196,7 @@ icalproperty* icalproperty_new_from_string(const char* str)
if(comp == 0){
icalerror_set_errno(ICAL_PARSE_ERROR);
free(buf);
return 0;
}
@ -273,6 +277,16 @@ get_next_line_start (char *line_start, int chars_left)
return line_start + chars_left;
}
/* Now we jump to the last possible character of the line, and step back
trying to find a ';' ':' or ' '. If we find one, we return the character
after it. */
pos = line_start + MAX_LINE_LEN - 2;
while (pos > line_start) {
if (*pos == ';' || *pos == ':' || *pos == ' ') {
return pos + 1;
}
pos--;
}
/* Now try to split on a UTF-8 boundary defined as a 7-bit
value or as a byte with the two high-most bits set:
11xxxxxx. See http://czyborra.com/utf/ */
@ -307,7 +321,7 @@ static char*
fold_property_line (char *text)
{
size_t buf_size;
char *buf, *buf_ptr, *line_start, *next_line_start, *out_buf;
char *buf, *buf_ptr, *line_start, *next_line_start;
int len, chars_left, first_line;
char ch;
@ -422,8 +436,8 @@ icalproperty_as_ical_string_r(icalproperty* prop)
const char* property_name = 0;
size_t buf_size = 1024;
char* buf = icalmemory_new_buffer(buf_size);
char* buf_ptr = buf;
char* buf;
char* buf_ptr;
icalvalue* value;
char *out_buf;
const char* kind_string = 0;
@ -432,6 +446,8 @@ icalproperty_as_ical_string_r(icalproperty* prop)
icalerror_check_arg_rz( (prop!=0),"prop");
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
/* Append property name */
@ -489,8 +505,10 @@ icalproperty_as_ical_string_r(icalproperty* prop)
if (value != 0){
char *str = icalvalue_as_ical_string_r(value);
icalerror_assert((str !=0),"Could not get string representation of a value");
icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
if (str != 0)
icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
else
icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value");
free(str);
} else {
icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value");
@ -553,11 +571,15 @@ icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter)
icalerror_check_arg_rv( (parameter!=0),"parameter");
kind = icalparameter_isa(parameter);
if (kind != ICAL_X_PARAMETER)
icalproperty_remove_parameter_by_kind(prop,kind);
else
if (kind == ICAL_X_PARAMETER) {
icalproperty_remove_parameter_by_name(prop,
icalparameter_get_xname(parameter));
} else if (kind == ICAL_IANA_PARAMETER) {
icalproperty_remove_parameter_by_name(prop,
icalparameter_get_iana_name(parameter));
}
else
icalproperty_remove_parameter_by_kind(prop,kind);
icalproperty_add_parameter(prop,parameter);
}
@ -587,8 +609,10 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
return;
}
if(kind == ICAL_X_PARAMETER){
icalparameter_set_xname(param, name);
if (kind == ICAL_X_PARAMETER) {
icalparameter_set_xname(param, name);
} else if (kind == ICAL_IANA_PARAMETER) {
icalparameter_set_iana_name(param, name);
}
icalproperty_set_parameter(prop,param);
@ -628,13 +652,19 @@ char* icalproperty_get_parameter_as_string_r(icalproperty* prop,
for(param = icalproperty_get_first_parameter(prop,kind);
param != 0;
param = icalproperty_get_next_parameter(prop,kind)) {
if (kind != ICAL_X_PARAMETER) {
break;
}
if (strcmp(icalparameter_get_xname(param),name)==0) {
if (kind == ICAL_X_PARAMETER) {
if (strcmp(icalparameter_get_xname(param),name)==0) {
break;
}
} else if (kind == ICAL_IANA_PARAMETER) {
if (strcmp(icalparameter_get_iana_name(param),name)==0) {
break;
}
} else {
break;
}
}
}
if (param == 0){
@ -747,6 +777,8 @@ icalproperty_remove_parameter_by_name(icalproperty* prop, const char *name)
if (icalparameter_isa(param) == ICAL_X_PARAMETER)
kind_string = icalparameter_get_xname(param);
else if (icalparameter_isa(param) == ICAL_IANA_PARAMETER)
kind_string = icalparameter_get_iana_name(param);
else
kind_string = icalparameter_kind_to_string(icalparameter_isa(param));
@ -781,21 +813,15 @@ icalproperty_remove_parameter_by_ref(icalproperty* prop, icalparameter* paramete
icalerror_check_arg_rv((parameter!=0),"parameter");
kind = icalparameter_isa(parameter);
name = icalparameter_get_xname(parameter);
/*
* FIXME If it's an X- parameter, also compare the names. It would be nice
* to have a better abstraction like icalparameter_equals()
*/
for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
icalparameter* p_param = (icalparameter *)pvl_data (p);
if (icalparameter_isa(p_param) == kind &&
(kind != ICAL_X_PARAMETER ||
!strcmp(icalparameter_get_xname(p_param), name))) {
for (p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)) {
icalparameter* p_param = (icalparameter *)pvl_data (p);
if (icalparameter_has_same_name(parameter, p_param)) {
pvl_remove (prop->parameters, p);
icalparameter_free(p_param);
break;
}
}
}
}
@ -910,6 +936,7 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* str,
return;
}
icalerror_clear_errno();
nval = icalvalue_new_from_string(kind, str);
if(nval == 0){
@ -989,10 +1016,13 @@ char* icalproperty_get_property_name_r(const icalproperty* prop)
const char* property_name = 0;
size_t buf_size = 256;
char* buf = icalmemory_new_buffer(buf_size);
char* buf_ptr = buf;
char* buf;
char* buf_ptr;
icalerror_check_arg_rz( (prop!=0),"prop");
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){
property_name = prop->x_name;
@ -1002,6 +1032,7 @@ char* icalproperty_get_property_name_r(const icalproperty* prop)
if (property_name == 0 ) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
icalmemory_free_buffer(buf);
return 0;
} else {

Просмотреть файл

@ -139,17 +139,23 @@
#include <stdint.h>
#endif
#ifdef WIN32
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif
#include <limits.h>
#ifndef HAVE_INTPTR_T
#if defined (WIN32) || defined (XP_BEOS)
#if (defined (WIN32) && !defined (__MINGW32__)) || defined (XP_BEOS)
typedef long intptr_t;
#endif
#endif
#ifdef WIN32
#define snprintf _snprintf
#define strcasecmp stricmp
#define strcasecmp stricmp
#endif
#include "icalrecur.h"
@ -323,9 +329,13 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
* function sorts the days taking into account the first day of week.
*/
static void
sort_bydayrules(short * array, int week_start)
sort_bydayrules(struct icalrecur_parser *parser)
{
int one, two, i, j;
short *array;
int week_start, one, two, i, j;
array = parser->rt.by_day;
week_start = parser->rt.week_start;
for (i=0;
i<ICAL_BY_DAY_SIZE && array[i] != ICAL_RECURRENCE_ARRAY_MAX;
@ -362,8 +372,6 @@ void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
end = (char*)vals_copy+strlen(vals_copy);
n = vals_copy;
array[0] = ICAL_RECURRENCE_ARRAY_MAX;
while(n != 0){
@ -398,15 +406,14 @@ void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
wd = icalrecur_string_to_weekday(t);
if (wd != ICAL_NO_WEEKDAY) {
array[i++] = (short) (sign * (wd + 8 * weekno));
array[i] = ICAL_RECURRENCE_ARRAY_MAX;
}
array[i++] = (short)(sign* (wd + 8*weekno));
array[i] = ICAL_RECURRENCE_ARRAY_MAX;
}
free(vals_copy);
sort_bydayrules(parser->rt.by_day, parser->rt.week_start);
sort_bydayrules(parser);
}
@ -448,20 +455,14 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
if (strcasecmp(name,"FREQ") == 0){
parser.rt.freq = icalrecur_string_to_freq(value);
} else if (strcasecmp(name,"COUNT") == 0){
int v = atoi(value);
if (v >= 0) {
parser.rt.count = v;
}
parser.rt.count = atoi(value);
} else if (strcasecmp(name,"UNTIL") == 0){
parser.rt.until = icaltime_from_string(value);
} else if (strcasecmp(name,"INTERVAL") == 0){
int v = atoi(value);
if (v > 0 && v <= SHRT_MAX) {
parser.rt.interval = (short) v;
}
parser.rt.interval = (short)atoi(value);
} else if (strcasecmp(name,"WKST") == 0){
parser.rt.week_start = icalrecur_string_to_weekday(value);
sort_bydayrules(parser.rt.by_day, parser.rt.week_start);
sort_bydayrules(&parser);
} else if (strcasecmp(name,"BYSECOND") == 0){
icalrecur_add_byrules(&parser,parser.rt.by_second,
ICAL_BY_SECOND_SIZE,value);
@ -816,6 +817,8 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
icalrecur_iterator* impl;
icalrecurrencetype_frequency freq;
icalerror_clear_errno();
if ( ( impl = (icalrecur_iterator*)
malloc(sizeof(icalrecur_iterator))) == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@ -881,26 +884,18 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_DAY) ){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(impl);
return 0;
}
/* BYWEEKNO and BYMONTH rule parts may not both appear.*/
if(icalrecur_two_byrule(impl,BY_WEEK_NO,BY_MONTH)){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
}
/* BYWEEKNO and BYMONTHDAY rule parts may not both appear.*/
if(icalrecur_two_byrule(impl,BY_WEEK_NO,BY_MONTH_DAY)){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
free(impl);
return 0;
}
@ -910,7 +905,8 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
if(freq == ICAL_MONTHLY_RECURRENCE &&
icalrecur_one_byrule(impl,BY_WEEK_NO)){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
free(impl);
return 0;
}
@ -920,13 +916,15 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
if(freq == ICAL_WEEKLY_RECURRENCE &&
icalrecur_one_byrule(impl,BY_MONTH_DAY )) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
free(impl);
return 0;
}
/* BYYEARDAY may only appear in YEARLY rules */
if(freq != ICAL_YEARLY_RECURRENCE &&
icalrecur_one_byrule(impl,BY_YEAR_DAY )) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(impl);
return 0;
}
@ -996,9 +994,15 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
if(impl->rule.freq == ICAL_YEARLY_RECURRENCE){
struct icaltimetype next;
icalerror_clear_errno();
for (;;) {
expand_year_days(impl, impl->last.year);
if( icalerrno != ICAL_NO_ERROR) {
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
free(impl);
return 0;
}
if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX)
break; /* break when no days are expanded */
increment_year(impl,impl->rule.interval);
@ -1060,7 +1064,8 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
if(impl->last.day > days_in_month || impl->last.day == 0){
icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
return 0;
free(impl);
return 0;
}
} else if (has_by_data(impl,BY_MONTH_DAY)) {
@ -1164,7 +1169,7 @@ static void increment_hour(icalrecur_iterator* impl, int inc)
days = impl->last.hour / 24;
impl->last.hour = impl->last.hour % 24;
if (impl->days != 0){
if (days != 0){
increment_monthday(impl,days);
}
}
@ -1500,6 +1505,20 @@ static int is_day_in_byday(icalrecur_iterator* impl,struct icaltimetype tt){
return 0;
}
int check_set_position(icalrecur_iterator* impl, int set_pos)
{
int i;
int found = 0;
for (i = 0; impl->rule.by_set_pos[i] != ICAL_RECURRENCE_ARRAY_MAX &&
i != ICAL_BY_SETPOS_SIZE; i++){
if (impl->rule.by_set_pos[i] == set_pos) {
found = 1;
break;
}
}
return found;
}
static int next_month(icalrecur_iterator* impl)
{
int data_valid = 1;
@ -1559,7 +1578,6 @@ static int next_month(icalrecur_iterator* impl)
if ( day > days_in_month){
impl->last.day = 1;
increment_month(impl);
impl->last.day--; /* Go back one day, so searches next month start at day 1 */
data_valid = 0; /* signal that impl->last is invalid */
}
@ -1582,15 +1600,43 @@ static int next_month(icalrecur_iterator* impl)
int day;
int days_in_month = icaltime_days_in_month(impl->last.month,
impl->last.year);
int set_pos_counter = 0;
int set_pos_total = 0;
int found = 0;
assert( BYDAYPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
/* Count the past positions for the BYSETPOS calculation */
if(has_by_data(impl,BY_SET_POS)){
int last_day = impl->last.day;
for(day = 1; day <= days_in_month; day++){
impl->last.day = day;
if(is_day_in_byday(impl,impl->last)){
set_pos_total++;
if(day <= last_day)
set_pos_counter++;
}
}
impl->last.day = last_day;
}
for(day = impl->last.day+1; day <= days_in_month; day++){
impl->last.day = day;
if(is_day_in_byday(impl,impl->last)){
data_valid = 1;
break;
}
/* If there is no BYSETPOS rule, calculate only by BYDAY
If there is BYSETPOS rule, take into account the occurence
matches with BYDAY */
if(!has_by_data(impl,BY_SET_POS) || check_set_position(impl, ++set_pos_counter)
|| check_set_position(impl, set_pos_counter-set_pos_total-1)) {
found = 1;
break;
}
}
}
data_valid = found;
if ( day > days_in_month){
impl->last.day = 1;
@ -1601,7 +1647,9 @@ static int next_month(icalrecur_iterator* impl)
invalid */
if(is_day_in_byday(impl,impl->last)){
data_valid = 1;
/* If there is no BYSETPOS rule or BYSETPOS=1, new data is valid */
if(!has_by_data(impl,BY_SET_POS) || check_set_position(impl,1))
data_valid = 1;
} else {
data_valid = 0; /* signal that impl->last is invalid */
}
@ -1654,12 +1702,15 @@ static int next_month(icalrecur_iterator* impl)
} else {
int days_in_month;
assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
impl->last.day = BYMDPTR[0];
increment_month(impl);
days_in_month = icaltime_days_in_month(impl->last.month,
impl->last.year);
if (impl->last.day > days_in_month){
data_valid = 0; /* signal that impl->last is invalid */
impl->last.day = days_in_month;
}
}
@ -1682,10 +1733,6 @@ static int next_weekday_by_week(icalrecur_iterator* impl)
return 1;
}
/* this call to 'sort_bydayrules' assures that the occurrences for
weekly recurrences will be generated in a strict linear order. */
sort_bydayrules(BYDAYPTR, impl->rule.week_start);
/* If we get here, we need to step to tne next day */
for (;;) {
@ -1861,7 +1908,7 @@ static pvl_list expand_by_day(icalrecur_iterator* impl, int year)
static int expand_year_days(icalrecur_iterator* impl, int year)
{
int j,k;
int i,j,k;
int days_index=0;
struct icaltimetype t;
int flags;
@ -1883,6 +1930,46 @@ static int expand_year_days(icalrecur_iterator* impl, int year)
(HBD(BY_YEAR_DAY) ? 1<<BY_YEAR_DAY : 0);
/* BY_WEEK_NO together with BY_MONTH - may conflict, in this case BY_MONTH wins */
if( (flags & 1<<BY_MONTH) && (flags & 1<<BY_WEEK_NO) ){
int valid_weeks[ICAL_BY_WEEKNO_SIZE];
int valid = 1;
memset(valid_weeks, 0, sizeof(valid_weeks));
t.year = year;
t.is_date = 1;
/* calculate valid week numbers */
for(j=0; impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
int month = impl->by_ptrs[BY_MONTH][j];
int first_week, last_week;
t.month = month;
t.day = 1;
first_week = icaltime_week_number(t);
t.day = icaltime_days_in_month(month,year);
last_week = icaltime_week_number(t);
for(j=first_week; j<last_week; j++) {
valid_weeks[j] = 1;
}
}
/* check valid weeks */
for(i = 0; BYWEEKPTR[i] != ICAL_RECURRENCE_ARRAY_MAX && valid; i++){
int weekno = BYWEEKPTR[i];
if(weekno < ICAL_BY_WEEKNO_SIZE)
valid &= valid_weeks[i]; /* check if the week number is valid */
else
valid = 0; /* invalid week number */
}
/* let us make the decision which rule to keep */
if(valid) { /* BYWEEKNO wins */
flags -= 1<<BY_MONTH;
}
else { /* BYMONTH vins */
flags -= 1<<BY_WEEK_NO;
}
}
switch(flags) {
case 0: {
@ -2022,7 +2109,24 @@ static int expand_year_days(icalrecur_iterator* impl, int year)
t.day = days_in_month;
last_dow = icaltime_day_of_week(t);
for(k=0;impl->by_ptrs[BY_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++){
if(has_by_data(impl,BY_SET_POS)) {
/*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTH = 12; BYSETPOS=1*/
int day;
int set_pos_counter = 0;
int set_pos_total = 0;
int by_month_day[ICAL_BY_MONTHDAY_SIZE];
for(day = 1; day <= days_in_month; day++){
t.day = day;
if(is_day_in_byday(impl,t))
by_month_day[set_pos_total++] = day;
}
for(set_pos_counter = 0; set_pos_counter < set_pos_total; set_pos_counter++){
if(check_set_position(impl, set_pos_counter+1) ||
check_set_position(impl, set_pos_counter-set_pos_total))
impl->days[days_index++] = doy_offset + by_month_day[set_pos_counter];
}
}
else for(k=0;impl->by_ptrs[BY_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++){
short day_coded = impl->by_ptrs[BY_DAY][k];
enum icalrecurrencetype_weekday dow =
icalrecurrencetype_day_day_of_week(day_coded);
@ -2263,8 +2367,8 @@ static int check_contracting_rules(icalrecur_iterator* impl)
struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *impl)
{
int valid = 1;
if( (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) ||
if( !impl || (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) ||
(!icaltime_is_null_time(impl->rule.until) &&
icaltime_compare(impl->last,impl->rule.until) > 0)) {
return icaltime_null_time();
@ -2315,6 +2419,11 @@ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *impl)
}
}
if(impl->last.year >= 2038 ){
/* HACK */
return icaltime_null_time();
}
} while(!check_contracting_rules(impl)
|| icaltime_compare(impl->last,impl->dtstart) < 0
|| valid == 0);
@ -2476,21 +2585,21 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
icstart = icaltime_from_timet_with_zone(start,0,0);
recur = icalrecurrencetype_from_string(rule);
ritr = icalrecur_iterator_new(recur,icstart);
if(ritr) {
for(next = icalrecur_iterator_next(ritr);
!icaltime_is_null_time(next) && i < count;
next = icalrecur_iterator_next(ritr)){
for(ritr = icalrecur_iterator_new(recur,icstart),
next = icalrecur_iterator_next(ritr);
!icaltime_is_null_time(next) && i < count;
next = icalrecur_iterator_next(ritr)){
tt = icaltime_as_timet(next);
tt = icaltime_as_timet(next);
if (tt >= start ){
array[i++] = tt;
}
if (tt >= start ){
array[i++] = tt;
}
}
icalrecur_iterator_free(ritr);
}
icalrecur_iterator_free(ritr);
return 1;
}

Просмотреть файл

@ -1,7 +1,18 @@
/* -*- Mode: C -*- */
/* ======================================================================
File: icalrestriction.c
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
======================================================================*/
/*#line 7 "icalrestriction.c.in"*/
@ -16,9 +27,13 @@
#include <assert.h>
#include <stdio.h> /* For snprintf */
#ifdef WIN32
#define snprintf _snprintf
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif
#define TMP_BUF_SIZE 1024
@ -284,7 +299,7 @@ const char* icalrestriction_no_dtend(
(void)rec;
(void)prop;
if( !icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){
if(icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){
return "Failed iTIP restrictions for DTEND property. The component must not have both DURATION and DTEND";

Просмотреть файл

@ -329,6 +329,7 @@ char* set_tz(const char* tzid)
if(new_tz == 0){
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
free(old_tz_copy);
return 0;
}

Просмотреть файл

@ -40,9 +40,8 @@
#include "icalerror.h"
#include "icalparser.h"
#include "icaltimezone.h"
#ifndef NO_ZONES_TAB
#include "icaltimezoneimpl.h"
#include "icaltz-util.h"
#endif
#include <sys/stat.h>
@ -57,16 +56,24 @@
/* The gmtime() in Microsoft's C library is MT-safe */
#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
#define snprintf _snprintf
#define strcasecmp stricmp
// MSVC lacks the POSIX macro S_ISDIR, however it's a trivial one:
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#ifndef HAVE_SNPRINTF
#include "vsnprintf.h"
#endif
#endif
#define strcasecmp stricmp
#endif
/** This is the toplevel directory where the timezone data is installed in. */
#define ZONEINFO_DIRECTORY PACKAGE_DATA_DIR "/zoneinfo"
/** The prefix we use to uniquely identify TZIDs. */
#define TZID_PREFIX "/citadel.org/"
#define TZID_PREFIX_LEN 13
/** The prefix we use to uniquely identify TZIDs.
It must begin and end with forward slashes.
*/
const char *ical_tzid_prefix = "/freeassociation.sourceforge.net/";
/** This is the filename of the file containing the city names and
coordinates of all the builtin timezones. */
@ -80,54 +87,6 @@
somewhere around 2037. */
#define ICALTIMEZONE_MAX_YEAR 2035
struct _icaltimezone {
char *tzid;
/**< The unique ID of this timezone,
e.g. "/citadel.org/Olson_20010601_1/Africa/Banjul".
This should only be used to identify a VTIMEZONE. It is not
meant to be displayed to the user in any form. */
char *location;
/**< The location for the timezone, e.g. "Africa/Accra" for the
Olson database. We look for this in the "LOCATION" or
"X-LIC-LOCATION" properties of the VTIMEZONE component. It
isn't a standard property yet. This will be NULL if no location
is found in the VTIMEZONE. */
char *tznames;
/**< This will be set to a combination of the TZNAME properties
from the last STANDARD and DAYLIGHT components in the
VTIMEZONE, e.g. "EST/EDT". If they both use the same TZNAME,
or only one type of component is found, then only one TZNAME
will appear, e.g. "AZOT". If no TZNAME is found this will be
NULL. */
double latitude;
double longitude;
/**< The coordinates of the city, in degrees. */
icalcomponent *component;
/**< The toplevel VTIMEZONE component loaded from the .ics file for this
timezone. If we need to regenerate the changes data we need this. */
icaltimezone *builtin_timezone;
/**< If this is not NULL it points to the builtin icaltimezone
that the above TZID refers to. This icaltimezone should be used
instead when accessing the timezone changes data, so that the
expanded timezone changes data is shared between calendar
components. */
int end_year;
/**< This is the last year for which we have expanded the data to.
If we need to calculate a date past this we need to expand the
timezone component data from scratch. */
icalarray *changes;
/**< A dynamically-allocated array of time zone changes, sorted by the
time of the change in local time. So we can do fast binary-searches
to convert from local time to UTC. */
};
typedef struct _icaltimezonechange icaltimezonechange;
struct _icaltimezonechange {
@ -153,10 +112,10 @@ struct _icaltimezonechange {
/** An array of icaltimezones for the builtin timezones. */
static icalarray *s_builtin_timezones = NULL;
static icalarray *builtin_timezones = NULL;
/** This is the special UTC timezone, which isn't in s_builtin_timezones. */
static icaltimezone utc_timezone = { (char *) "UTC", NULL, NULL, 0.0, 0.0, NULL, NULL, 0, NULL };
/** This is the special UTC timezone, which isn't in builtin_timezones. */
static icaltimezone utc_timezone = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static char* zone_files_directory = NULL;
@ -195,6 +154,8 @@ static void icaltimezone_ensure_coverage (icaltimezone *zone,
int end_year);
static void icaltimezone_init_builtin_timezones(void);
static void icaltimezone_parse_zone_tab (void);
#ifdef USE_BUILTIN_TZDATA
@ -236,10 +197,18 @@ icaltimezone_copy (icaltimezone *originalzone)
}
memcpy (zone, originalzone, sizeof (icaltimezone));
if (zone->tzid != NULL)
zone->tzid = strdup (zone->tzid);
if (zone->location != NULL)
zone->location = strdup (zone->location);
if (zone->tznames != NULL)
zone->tznames = strdup (zone->tznames);
if (zone->changes != NULL)
zone->changes = icalarray_copy(zone->changes);
/* Let the caller set the component because then they will
know to be careful not to free this reference twice. */
zone->component = NULL;
return zone;
}
@ -691,7 +660,7 @@ icaltimezone_expand_vtimezone (icalcomponent *comp,
}
rrule_iterator = icalrecur_iterator_new (rrule, dtstart);
for (;;) {
for (;rrule_iterator;) {
occ = icalrecur_iterator_next (rrule_iterator);
if (occ.year > end_year || icaltime_is_null_time (occ))
break;
@ -1279,7 +1248,7 @@ icaltimezone_get_display_name (icaltimezone *zone)
this is one of our TZIDs and if so we jump to the city name
at the end of it. */
if (display_name
&& !strncmp (display_name, TZID_PREFIX, TZID_PREFIX_LEN)) {
&& !strncmp (display_name, ical_tzid_prefix, strlen(ical_tzid_prefix))) {
/* Get the location, which is after the 3rd '/' char. */
const char *p;
int num_slashes = 0;
@ -1296,7 +1265,6 @@ icaltimezone_get_display_name (icaltimezone *zone)
return display_name;
}
icalarray*
icaltimezone_array_new (void)
{
@ -1346,19 +1314,18 @@ icaltimezone_array_free (icalarray *timezones)
icalarray*
icaltimezone_get_builtin_timezones (void)
{
#ifndef NO_ZONES_TAB
if (!s_builtin_timezones) {
icaltimezone_parse_zone_tab ();
}
#endif
return s_builtin_timezones;
if (!builtin_timezones)
icaltimezone_init_builtin_timezones ();
return builtin_timezones;
}
/** Release builtin timezone memory */
void
icaltimezone_free_builtin_timezones(void)
{
icaltimezone_array_free(s_builtin_timezones);
icaltimezone_array_free(builtin_timezones);
builtin_timezones = 0;
}
@ -1366,22 +1333,20 @@ icaltimezone_free_builtin_timezones(void)
icaltimezone*
icaltimezone_get_builtin_timezone (const char *location)
{
icalcomponent *comp;
icaltimezone *zone;
unsigned int lower;
int lower;
const char *zone_location;
icalarray * builtin_timezones;
if (!location || !location[0])
return NULL;
if (!builtin_timezones)
icaltimezone_init_builtin_timezones ();
if (!strcmp (location, "UTC"))
return &utc_timezone;
builtin_timezones = icaltimezone_get_builtin_timezones();
if (!builtin_timezones) {
return NULL;
}
#if 0
/* Do a simple binary search. */
lower = middle = 0;
@ -1410,6 +1375,20 @@ icaltimezone_get_builtin_timezone (const char *location)
return zone;
}
/* Check whether file exists, but is not mentioned in zone.tab.
It means it's a deprecated timezone, but still available. */
comp = icaltzutil_fetch_timezone (location);
if (comp) {
icaltimezone tz;
icaltimezone_init (&tz);
if (icaltimezone_set_component (&tz, comp)) {
icalarray_append (builtin_timezones, &tz);
return icalarray_element_at (builtin_timezones, builtin_timezones->num_elements - 1);
} else {
icalcomponent_free (comp);
}
}
return NULL;
}
@ -1455,7 +1434,9 @@ icaltimezone_get_builtin_timezone_from_offset (int offset, const char *tzname)
{
icaltimezone *zone=NULL;
int count, i;
icalarray * builtin_timezones;
if (!builtin_timezones)
icaltimezone_init_builtin_timezones ();
if (offset==0)
return &utc_timezone;
@ -1463,11 +1444,6 @@ icaltimezone_get_builtin_timezone_from_offset (int offset, const char *tzname)
if (!tzname)
return NULL;
builtin_timezones = icaltimezone_get_builtin_timezones();
if (!builtin_timezones) {
return NULL;
}
count = builtin_timezones->num_elements;
for (i=0; i<count; i++) {
@ -1497,7 +1473,7 @@ icaltimezone_get_builtin_timezone_from_tzid (const char *tzid)
return NULL;
/* Check that the TZID starts with our unique prefix. */
if (strncmp (tzid, TZID_PREFIX, TZID_PREFIX_LEN))
if (strncmp (tzid, ical_tzid_prefix, strlen(ical_tzid_prefix)))
return NULL;
/* Get the location, which is after the 3rd '/' character. */
@ -1535,11 +1511,26 @@ icaltimezone_get_builtin_timezone_from_tzid (const char *tzid)
icaltimezone*
icaltimezone_get_utc_timezone (void)
{
if (!builtin_timezones)
icaltimezone_init_builtin_timezones ();
return &utc_timezone;
}
/** This initializes the builtin timezone data, i.e. the
builtin_timezones array and the special UTC timezone. It should be
called before any code that uses the timezone functions. */
static void
icaltimezone_init_builtin_timezones (void)
{
/* Initialize the special UTC timezone. */
utc_timezone.tzid = (char *)"UTC";
icaltimezone_parse_zone_tab ();
}
static int
parse_coord (char *coord,
int len,
@ -1591,15 +1582,31 @@ fetch_lat_long_from_string (const char *str, int *latitude_degrees, int *latitu
len = sptr - loc;
location = strncpy (location, loc, len);
location [len] = '\0';
#if defined(sun) && defined(__SVR4)
/* Handle EET, MET and WET in zone_sun.tab. */
if (!strcmp (location, "Europe/")) {
while (*sptr != '\t')
sptr++;
loc = ++sptr;
while (!isspace (*sptr))
sptr++;
len = sptr - loc;
location = strncpy (location, loc, len);
location [len] = '\0';
}
#endif
lon = lat + 1;
while (*lon != '+' && *lon != '-')
lon++;
if (parse_coord (lat, lon - lat, latitude_degrees, latitude_minutes, latitude_seconds) == 1 ||
parse_coord (lon, strlen (lon), longitude_degrees, longitude_minutes, longitude_seconds)
== 1)
return 1;
== 1) {
free(lat);
return 1;
}
free (lat);
@ -1616,7 +1623,6 @@ fetch_lat_long_from_string (const char *str, int *latitude_degrees, int *latitu
static void
icaltimezone_parse_zone_tab (void)
{
#ifndef NO_ZONES_TAB
char *filename;
FILE *fp;
char buf[1024]; /* Used to store each line of zones.tab as it is read. */
@ -1626,10 +1632,10 @@ icaltimezone_parse_zone_tab (void)
int longitude_degrees = 0, longitude_minutes = 0, longitude_seconds = 0;
icaltimezone zone;
icalerror_assert (s_builtin_timezones == NULL,
icalerror_assert (builtin_timezones == NULL,
"Parsing zones.tab file multiple times");
s_builtin_timezones = icalarray_new (sizeof (icaltimezone), 32);
builtin_timezones = icalarray_new (sizeof (icaltimezone), 32);
#ifndef USE_BUILTIN_TZDATA
filename_len = strlen ((char *) icaltzutil_get_zone_directory()) + strlen (ZONES_TAB_SYSTEM_FILENAME)
@ -1704,7 +1710,7 @@ icaltimezone_parse_zone_tab (void)
- (double) longitude_minutes / 60
- (double) longitude_seconds / 3600;
icalarray_append (s_builtin_timezones, &zone);
icalarray_append (builtin_timezones, &zone);
#if 0
printf ("Found zone: %s %f %f\n",
@ -1713,17 +1719,17 @@ icaltimezone_parse_zone_tab (void)
}
fclose (fp);
#endif /* NO_ZONES_TAB */
}
void
icaltimezone_release_zone_tab (void)
{
unsigned int i;
icalarray *mybuiltin_timezones = s_builtin_timezones;
if (s_builtin_timezones == NULL)
int i;
icalarray *mybuiltin_timezones = builtin_timezones;
if (builtin_timezones == NULL)
return;
s_builtin_timezones = NULL;
builtin_timezones = NULL;
for (i = 0; i < mybuiltin_timezones->num_elements; i++)
free ( ((icaltimezone*)icalarray_element_at(mybuiltin_timezones, i))->location);
icalarray_free (mybuiltin_timezones);
@ -1733,7 +1739,6 @@ icaltimezone_release_zone_tab (void)
static void
icaltimezone_load_builtin_timezone (icaltimezone *zone)
{
#ifndef NO_ZONES_TAB
icalcomponent *subcomp;
/* If the location isn't set, it isn't a builtin timezone. */
@ -1797,7 +1802,7 @@ icaltimezone_load_builtin_timezone (icaltimezone *zone)
icalcomponent_free(comp);
}
#endif
#endif /* NO_ZONES_TAB */
}
@ -2003,6 +2008,8 @@ static const char* get_zone_directory(void)
void set_zone_directory(char *path)
{
if (zone_files_directory)
free_zone_directory();
zone_files_directory = malloc(strlen(path)+1);
if ( zone_files_directory != NULL )
{
@ -2015,5 +2022,13 @@ void free_zone_directory(void)
if ( zone_files_directory != NULL )
{
free(zone_files_directory);
zone_files_directory = NULL;
}
}
void icaltimezone_set_tzid_prefix(const char *new_prefix)
{
if (new_prefix) {
ical_tzid_prefix = new_prefix;
}
}

Просмотреть файл

@ -57,6 +57,12 @@ icaltimezone *icaltimezone_copy (icaltimezone *originalzone);
void icaltimezone_free (icaltimezone *zone,
int free_struct);
/** Sets the prefix to be used for tzid's generated from system tzdata.
Must be globally unique (such as a domain name owned by the developer
of the calling application), and begin and end with forward slashes.
Do not change or de-allocate the string buffer after calling this.
*/
void icaltimezone_set_tzid_prefix(const char *new_prefix);
/**
* @par Accessing timezones.

Просмотреть файл

@ -43,6 +43,12 @@
#define TEMP_MAX 1024
#ifdef HAVE_PTHREAD
#include <pthread.h>
static pthread_mutex_t unk_token_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static ical_unknown_token_handling unknownTokenHandling = ICAL_TREAT_AS_ERROR;
int icaltriggertype_is_null_trigger(struct icaltriggertype tr)
{
@ -178,9 +184,9 @@ char* icalreqstattype_as_string_r(struct icalreqstattype stat)
{
char *temp;
temp = (char*)icalmemory_new_buffer(TEMP_MAX);
icalerror_check_arg_rz((stat.code != ICAL_UNKNOWN_STATUS),"Status");
temp = (char*)icalmemory_new_buffer(TEMP_MAX);
if (stat.desc == 0){
stat.desc = icalenum_reqstat_desc(stat.code);
@ -199,3 +205,35 @@ char* icalreqstattype_as_string_r(struct icalreqstattype stat)
return temp;
}
ical_unknown_token_handling ical_get_unknown_token_handling_setting(void)
{
ical_unknown_token_handling myHandling;
#ifdef HAVE_PTHREAD
pthread_mutex_lock (&unk_token_mutex);
#endif
myHandling = unknownTokenHandling;
#ifdef HAVE_PTHREAD
pthread_mutex_unlock (&unk_token_mutex);
#endif
return myHandling;
}
void ical_set_unknown_token_handling_setting(ical_unknown_token_handling newSetting)
{
#ifdef HAVE_PTHREAD
pthread_mutex_lock (&unk_token_mutex);
#endif
unknownTokenHandling = newSetting;
#ifdef HAVE_PTHREAD
pthread_mutex_unlock (&unk_token_mutex);
#endif
}

Просмотреть файл

@ -34,8 +34,8 @@
struct icalgeotype
{
float lat;
float lon;
double lat;
double lon;
};
@ -105,5 +105,18 @@ struct icaltimezonetype {
void icaltimezonetype_free(struct icaltimezonetype tzt);
/* ical_unknown_token_handling :
* How should the ICAL library handle components, properties and parameters with
* unknown names?
* FIXME: Currently only affects parameters. Extend to components and properties.
*/
typedef enum ical_unknown_token_handling {
ICAL_ASSUME_IANA_TOKEN = 1,
ICAL_DISCARD_TOKEN = 2,
ICAL_TREAT_AS_ERROR = 3
} ical_unknown_token_handling;
ical_unknown_token_handling ical_get_unknown_token_handling_setting(void);
void ical_set_unknown_token_handling_setting(ical_unknown_token_handling newSetting);
#endif /* !ICALTYPES_H */

Просмотреть файл

@ -136,6 +136,7 @@ icalvalue* icalvalue_new_clone(const icalvalue* old) {
new->data.v_string=icalmemory_strdup(old->data.v_string);
if ( new->data.v_string == 0 ) {
icalvalue_free(new);
return 0;
}
@ -148,6 +149,7 @@ icalvalue* icalvalue_new_clone(const icalvalue* old) {
new->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
if(new->data.v_recur == 0){
icalvalue_free(new);
return 0;
}
@ -163,6 +165,7 @@ icalvalue* icalvalue_new_clone(const icalvalue* old) {
new->x_value=icalmemory_strdup(old->x_value);
if (new->x_value == 0) {
icalvalue_free(new);
return 0;
}
}
@ -262,72 +265,6 @@ static char* icalmemory_strdup_and_dequote(const char* str)
return out;
}
/*
* Returns a quoted copy of a string
*/
static char* icalmemory_strdup_and_quote(const char* unquoted_str)
{
char *str;
char *str_p;
const char *p;
size_t buf_sz;
buf_sz = strlen(unquoted_str)+1;
str_p = str = (char*)icalmemory_new_buffer(buf_sz);
if (str_p == 0){
return 0;
}
for(p=unquoted_str; *p!=0; p++){
switch(*p){
case '\n': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\n");
break;
}
case '\t': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\t");
break;
}
case '\r': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\r");
break;
}
case '\b': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\b");
break;
}
case '\f': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\f");
break;
}
case ';':
case ',':
case '"':
case '\\':{
icalmemory_append_char(&str,&str_p,&buf_sz,'\\');
icalmemory_append_char(&str,&str_p,&buf_sz,*p);
break;
}
default: {
icalmemory_append_char(&str,&str_p,&buf_sz,*p);
}
}
}
/* Assume the last character is not a '\0' and add one. We could
check *str_p != 0, but that would be an uninitialized memory
read. */
icalmemory_append_char(&str,&str_p,&buf_sz,'\0');
return str;
}
/*
* FIXME
*
@ -363,9 +300,9 @@ icalvalue* icalvalue_new_enum(icalvalue_kind kind, int x_type, const char* str)
* If you want a code that that does the same job with a decimal separator
* dependant on the current locale, then use strtof() from libc.
*/
int simple_str_to_float(const char* from,
float *result,
char** to)
int simple_str_to_double(const char* from,
double *result,
char** to)
{
#define TMP_NUM_SIZE 100
char *start=NULL, *end=NULL, *cur=(char*)from ;
@ -454,7 +391,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
case ICAL_BINARY_VALUE:
{
icalattach *attach;
attach = icalattach_new_from_data ((unsigned char*)str, 0, 0);
attach = icalattach_new_from_data (str, 0, 0);
if ( !attach )
break;
value = icalvalue_new_attach (attach);
@ -561,7 +498,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
char *cur=NULL ;
struct icalgeotype geo = {0.0, 0.0};
if (simple_str_to_float (str, &geo.lat, &cur)) {
if (simple_str_to_double (str, &geo.lat, &cur)) {
goto geo_parsing_error ;
}
@ -584,7 +521,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
++cur ;
}
if (simple_str_to_float (cur, &geo.lon, &cur)) {
if (simple_str_to_double (cur, &geo.lon, &cur)) {
goto geo_parsing_error ;
}
value = icalvalue_new_geo (geo) ;
@ -772,6 +709,7 @@ icalvalue_free (icalvalue* v)
case ICAL_TEXT_VALUE:
case ICAL_CALADDRESS_VALUE:
case ICAL_URI_VALUE:
case ICAL_STRING_VALUE:
case ICAL_QUERY_VALUE:
{
if (v->data.v_string != 0) {
@ -832,9 +770,10 @@ static char* icalvalue_binary_as_ical_string_r(const icalvalue* value) {
static char* icalvalue_int_as_ical_string_r(const icalvalue* value) {
int data;
char* str = (char*)icalmemory_new_buffer(MAX_INT_DIGITS);
char* str;
icalerror_check_arg_rz( (value!=0),"value");
str = (char*)icalmemory_new_buffer(MAX_INT_DIGITS);
data = icalvalue_get_integer(value);
@ -848,10 +787,11 @@ static char* icalvalue_utcoffset_as_ical_string_r(const icalvalue* value)
{
int data,h,m,s;
char sign;
char* str = (char*)icalmemory_new_buffer(9);
char* str;
icalerror_check_arg_rz( (value!=0),"value");
str = (char*)icalmemory_new_buffer(9);
data = icalvalue_get_utcoffset(value);
if (abs(data) == data){
@ -900,16 +840,66 @@ static char* icalvalue_recur_as_ical_string_r(const icalvalue* value)
*/
static char* icalvalue_text_as_ical_string_r(const icalvalue* value) {
return icalmemory_strdup_and_quote(value->data.v_string);
char *str;
char *str_p;
const char *p;
size_t buf_sz;
}
buf_sz = strlen(value->data.v_string)+1;
str_p = str = (char*)icalmemory_new_buffer(buf_sz);
if (str_p == 0){
return 0;
}
for(p=value->data.v_string; *p!=0; p++){
switch(*p){
case '\n': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\n");
break;
}
case '\t': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\t");
break;
}
case '\r': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\r");
break;
}
case '\b': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\b");
break;
}
case '\f': {
icalmemory_append_string(&str,&str_p,&buf_sz,"\\f");
break;
}
case ';':
case ',':
case '"':
case '\\':{
icalmemory_append_char(&str,&str_p,&buf_sz,'\\');
icalmemory_append_char(&str,&str_p,&buf_sz,*p);
break;
}
default: {
icalmemory_append_char(&str,&str_p,&buf_sz,*p);
}
}
}
/* Assume the last character is not a '\0' and add one. We could
check *str_p != 0, but that would be an uninitialized memory
read. */
static char* icalvalue_text_as_ical_string(const icalvalue* value) {
char *buf;
buf = icalvalue_text_as_ical_string_r(value);
icalmemory_add_tmp_buffer(buf);
return buf;
icalmemory_append_char(&str,&str_p,&buf_sz,'\0');
return str;
}
@ -956,24 +946,29 @@ static char* icalvalue_duration_as_ical_string_r(const icalvalue* value) {
void print_time_to_string(char* str, const struct icaltimetype *data)
{
char temp[20];
str[0] = '\0';
if (icaltime_is_utc(*data)){
snprintf(temp,sizeof(temp),"%02d%02d%02dZ",data->hour,data->minute,data->second);
} else {
snprintf(temp,sizeof(temp),"%02d%02d%02d",data->hour,data->minute,data->second);
}
strcat(str,temp);
if (data != 0) {
if (icaltime_is_utc(*data)){
snprintf(temp,sizeof(temp),"%02d%02d%02dZ",data->hour,data->minute,data->second);
strncat(str,temp,7);
} else {
snprintf(temp,sizeof(temp),"%02d%02d%02d",data->hour,data->minute,data->second);
strncat(str,temp,6);
}
}
}
void print_date_to_string(char* str, const struct icaltimetype *data)
{
char temp[20];
str[0] = '\0';
snprintf(temp,sizeof(temp),"%04d%02d%02d",data->year,data->month,data->day);
strcat(str,temp);
if (data != 0) {
snprintf(temp,sizeof(temp),"%04d%02d%02d",data->year,data->month,data->day);
strncat(str,temp,8);
}
}
static char* icalvalue_date_as_ical_string_r(const icalvalue* value) {
@ -985,7 +980,7 @@ static char* icalvalue_date_as_ical_string_r(const icalvalue* value) {
str = (char*)icalmemory_new_buffer(9);
str[0] = 0;
str[0] = '\0';
print_date_to_string(str,&data);
return str;
@ -993,10 +988,17 @@ static char* icalvalue_date_as_ical_string_r(const icalvalue* value) {
void print_datetime_to_string(char* str, const struct icaltimetype *data)
{
print_date_to_string(str,data);
if ( !data->is_date ) {
strcat(str,"T");
print_time_to_string(str,data);
char temp[20];
str[0] = '\0';
if (data != 0) {
print_date_to_string(str,data);
if ( !data->is_date ) {
strncat(str,"T",19);
temp[0] = '\0';
print_time_to_string(temp,data);
strncat(str,temp,19);
}
}
}
@ -1021,7 +1023,6 @@ static char* icalvalue_datetime_as_ical_string_r(const icalvalue* value) {
str = (char*)icalmemory_new_buffer(20);
str[0] = 0;
print_datetime_to_string(str,&data);
return str;
@ -1183,7 +1184,7 @@ icalvalue_as_ical_string_r(const icalvalue* value)
case ICAL_X_VALUE:
if (value->x_value != 0)
return icalmemory_strdup_and_quote(value->x_value);
return icalmemory_strdup(value->x_value);
/* FALLTHRU */

Просмотреть файл

@ -63,18 +63,19 @@ icalparameter_xliccomparetype icalvalue_compare(const icalvalue* a, const icalva
/* Special, non autogenerated value accessors */
icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
/* Defined in icalderivedvalue.h */
/* icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); */
/* void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); */
/* struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value); */
icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
/* icalvalue* icalvalue_new_trigger (struct icaltriggertype v); */
/* void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); */
/* struct icaltriggertype icalvalue_get_trigger(const icalvalue* value); */
icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
void icalvalue_set_datetimeperiod(icalvalue* value,
struct icaldatetimeperiodtype v);
struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
/* icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); */
/* void icalvalue_set_datetimeperiod(icalvalue* value, */
/* struct icaldatetimeperiodtype v); */
/* struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value); */
/* Convert enumerations */

Просмотреть файл

@ -0,0 +1,173 @@
#ifdef WIN32
#include "config.h"
#ifndef HAVE_SNPRINTF
#error DO NOT USE libical version of vsnprintf.
#endif
/*
* Revision 12: http://theos.com/~deraadt/snprintf.c
*
* Copyright (c) 1997 Theo de Raadt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WIN32
#include <sys/param.h>
#include <sys/mman.h>
#include <unistd.h>
#endif
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#if __STDC__
#include <stdarg.h>
#include <stdlib.h>
#else
#include <varargs.h>
#endif
#include <setjmp.h>
#ifndef roundup
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
#endif
static int pgsize;
static char *curobj;
static sigjmp_buf bail;
#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */
static char *
msetup(str, n)
char *str;
size_t n;
{
char *e;
if (n == 0)
return NULL;
if (pgsize == 0)
pgsize = getpagesize();
curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
if (curobj == NULL)
return NULL;
e = curobj + n + EXTRABYTES;
e = (char *)roundup((unsigned long)e, pgsize);
if (mprotect(e, pgsize, PROT_NONE) == -1) {
free(curobj);
curobj = NULL;
return NULL;
}
e = e - n - EXTRABYTES;
*e = '\0';
return (e);
}
static void
mcatch(int i)
{
siglongjmp(bail, 1);
}
static void
mcleanup(str, n, p)
char *str;
size_t n;
char *p;
{
strncpy(str, p, n-1);
str[n-1] = '\0';
if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
PROT_READ|PROT_WRITE|PROT_EXEC) == -1)
mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
PROT_READ|PROT_WRITE);
free(curobj);
}
int
#if __STDC__
vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
#else
vsnprintf(str, n, fmt, ap)
char *str;
size_t n;
char *fmt;
char *ap;
#endif
{
struct sigaction osa, nsa;
char *p;
int ret = n + 1; /* if we bail, indicated we overflowed */
memset(&nsa, 0, sizeof nsa);
nsa.sa_handler = mcatch;
sigemptyset(&nsa.sa_mask);
p = msetup(str, n);
if (p == NULL) {
*str = '\0';
return 0;
}
if (sigsetjmp(bail, 1) == 0) {
if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
mcleanup(str, n, p);
return (0);
}
ret = vsprintf(p, fmt, ap);
}
mcleanup(str, n, p);
(void) sigaction(SIGSEGV, &osa, NULL);
return (ret);
}
int
#if __STDC__
snprintf(char *str, size_t n, char const *fmt, ...)
#else
snprintf(str, n, fmt, va_alist)
char *str;
size_t n;
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
return (vsnprintf(str, n, fmt, ap));
va_end(ap);
}
#else
/* ANSI C forbids an empty source file... */
static void vsnprintf_dummy_func() {
vsnprintf_dummy_func();
}
#endif

Просмотреть файл

@ -5,6 +5,18 @@
(C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
======================================================================*/
#ifdef HAVE_CONFIG_H

Просмотреть файл

@ -5,6 +5,18 @@
(C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
http://www.softwarestudio.org
This program is free software; you can redistribute it and/or modify
it under the terms of either:
The LGPL as published by the Free Software Foundation, version
2.1, available at: http://www.fsf.org/copyleft/lesser.html
Or:
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
======================================================================*/

Просмотреть файл

@ -181,7 +181,8 @@ char* sspm_get_parameter(const char* line, const char* parameter)
if(s != 0){
strncpy(name,p,(size_t)s-(size_t)p);
} else {
strcpy(name,p);
strncpy(name,p,sizeof(name)-1);
name[sizeof(name)-1]='\0';
}
/* Strip off trailing quote, if it exists */
@ -252,7 +253,7 @@ static const char *mime_headers[] = {
};
void* sspm_default_new_part()
void* sspm_default_new_part(void)
{
return 0;
}
@ -472,6 +473,7 @@ enum sspm_minor_type sspm_find_minor_content_type(char* type)
char *p = strchr(ltype,'/');
if (p==0){
free(ltype);
return SSPM_UNKNOWN_MINOR_TYPE;
}

Просмотреть файл

@ -111,7 +111,7 @@ struct sspm_part {
struct sspm_action_map {
enum sspm_major_type major;
enum sspm_minor_type minor;
void* (*new_part)();
void* (*new_part)(void);
void (*add_line)(void *part, struct sspm_header *header,
const char* line, size_t size);
void* (*end_part)(void* part);

Просмотреть файл

@ -0,0 +1,33 @@
#ifdef WIN32
#ifndef roundup
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
#endif
#include <stdlib.h>
#include <stdarg.h>
int
#if __STDC__
vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
#else
vsnprintf(str, n, fmt, ap);
char *str;
size_t n;
char *fmt;
char *ap;
#endif
int
#if __STDC__
snprintf(char *str, size_t n, char const *fmt, ...);
#else
snprintf(str, n, fmt, va_alist);
char *str;
size_t n;
char *fmt;
va_dcl
#endif
#endif