diff options
author | nobody <nobody@localhost> | 2003-09-26 23:53:23 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2003-09-26 23:53:23 +0800 |
commit | 911c3b9d4fe2f40bc34029ef798ed78fdf0fcb42 (patch) | |
tree | e3efa4958cf2cf6bfe50e2a15c729b9014efa5db /libical/src | |
parent | 99c61843f0d1da7f9b3b73b99bab0e918ce99e5b (diff) | |
download | gsoc2013-evolution-new-calendar-branch-merge-end.tar gsoc2013-evolution-new-calendar-branch-merge-end.tar.gz gsoc2013-evolution-new-calendar-branch-merge-end.tar.bz2 gsoc2013-evolution-new-calendar-branch-merge-end.tar.lz gsoc2013-evolution-new-calendar-branch-merge-end.tar.xz gsoc2013-evolution-new-calendar-branch-merge-end.tar.zst gsoc2013-evolution-new-calendar-branch-merge-end.zip |
This commit was manufactured by cvs2svn to create tagnew-calendar-branch-merge-end
'new-calendar-branch-merge-end'.
svn path=/tags/new-calendar-branch-merge-end/; revision=22718
Diffstat (limited to 'libical/src')
34 files changed, 1106 insertions, 5439 deletions
diff --git a/libical/src/.cvsignore b/libical/src/.cvsignore index bbc8ba00d1..c038ed7864 100644 --- a/libical/src/.cvsignore +++ b/libical/src/.cvsignore @@ -1,5 +1,2 @@ Makefile -.deps -.libs -*.lo -*.la +Makefile.in
\ No newline at end of file diff --git a/libical/src/Makefile.am b/libical/src/Makefile.am index 5e5cd331db..7a3f9fcdff 100644 --- a/libical/src/Makefile.am +++ b/libical/src/Makefile.am @@ -4,16 +4,6 @@ else PYTHON_DIR = endif -if WITH_JAVA -JAVA_DIR = java -else -JAVA_DIR = -endif - -if WITH_CAP -LIBICALCAP_DIR = libicalcap -else -LIBICALCAP_DIR = -endif - -SUBDIRS = libical libicalss $(LIBICALCAP_DIR) libicalvcal $(PYTHON_DIR) $(JAVA_DIR) test +# For evolution we only build libical at present. +SUBDIRS = libical libicalvcal +#SUBDIRS = libical libicalss libicalvcal # $(PYTHON_DIR) test diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c index a892128a0e..6c222f01a9 100644 --- a/libical/src/libical/icalcomponent.c +++ b/libical/src/libical/icalcomponent.c @@ -4,6 +4,7 @@ $Id$ + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org This program is free software; you can redistribute it and/or modify @@ -37,7 +38,6 @@ #include "icalduration.h" #include "icalperiod.h" #include "icalparser.h" -#include "icalrestriction.h" #include <stdlib.h> /* for malloc */ #include <stdarg.h> /* for va_list, etc */ @@ -45,7 +45,8 @@ #include <assert.h> #include <stdio.h> /* for fprintf */ #include <string.h> /* for strdup */ -#include <limits.h> /* for INT_MAX */ + +#define MAX_TMP 1024 struct icalcomponent_impl { @@ -58,7 +59,7 @@ struct icalcomponent_impl pvl_elem component_iterator; icalcomponent* parent; - /** An array of icaltimezone structs. We use this so we can do fast + /* An array of icaltimezone structs. We use this so we can do fast lookup of timezones using binary searches. timezones_sorted is set to 0 whenever we add a timezone, so we remember to sort the array before doing a binary search. */ @@ -70,8 +71,9 @@ struct icalcomponent_impl void icalproperty_set_parent(icalproperty* property, icalcomponent* component); icalcomponent* icalproperty_get_parent(icalproperty* property); -void icalcomponent_add_children(icalcomponent *impl,va_list args); -static icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind); +void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args); +icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind); +int icalcomponent_property_sorter(void *a, void *b); static void icalcomponent_merge_vtimezone (icalcomponent *comp, icalcomponent *vtimezone, @@ -81,7 +83,7 @@ static void icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, icalproperty *tzid_prop, const char *tzid, icalarray *tzids_to_rename); -static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid); +static int icalcomponent_get_tzid_prefix_len (const char *tzid); static void icalcomponent_rename_tzids(icalcomponent* comp, icalarray* rename_table); static void icalcomponent_rename_tzids_callback(icalparameter *param, @@ -92,7 +94,7 @@ static int icalcomponent_compare_timezone_fn (const void *elem1, const void *elem2); -void icalcomponent_add_children(icalcomponent *impl, va_list args) +void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args) { void* vp; @@ -102,23 +104,25 @@ void icalcomponent_add_children(icalcomponent *impl, va_list args) icalproperty_isa_property(vp) != 0 ) ; if (icalcomponent_isa_component(vp) != 0 ){ - icalcomponent_add_component(impl, (icalcomponent*)vp); + + icalcomponent_add_component((icalcomponent*)impl, + (icalcomponent*)vp); } else if (icalproperty_isa_property(vp) != 0 ){ - icalcomponent_add_property(impl, (icalproperty*)vp); + + icalcomponent_add_property((icalcomponent*)impl, + (icalproperty*)vp); } } } -static icalcomponent* +icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind) { - icalcomponent* comp; - - if (!icalcomponent_kind_is_valid(kind)) - return NULL; + struct icalcomponent_impl* comp; - if ( ( comp = (icalcomponent*) malloc(sizeof(icalcomponent))) == 0) { + if ( ( comp = (struct icalcomponent_impl*) + malloc(sizeof(struct icalcomponent_impl))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -138,22 +142,18 @@ icalcomponent_new_impl (icalcomponent_kind kind) return comp; } -/** @brief Constructor - */ icalcomponent* icalcomponent_new (icalcomponent_kind kind) { - return icalcomponent_new_impl(kind); + return (icalcomponent*)icalcomponent_new_impl(kind); } -/** @brief Constructor - */ icalcomponent* icalcomponent_vanew (icalcomponent_kind kind, ...) { va_list args; - icalcomponent *impl = icalcomponent_new_impl(kind); + struct icalcomponent_impl *impl = icalcomponent_new_impl(kind); if (impl == 0){ return 0; @@ -163,26 +163,23 @@ icalcomponent_vanew (icalcomponent_kind kind, ...) icalcomponent_add_children(impl, args); va_end(args); - return impl; + return (icalcomponent*) impl; } -/** @brief Constructor - */ icalcomponent* icalcomponent_new_from_string(char* str) { return icalparser_parse_string(str); } -/** @brief Constructor - */ -icalcomponent* icalcomponent_new_clone(icalcomponent* old) +icalcomponent* icalcomponent_new_clone(icalcomponent* component) { - icalcomponent *new; + struct icalcomponent_impl *old = (struct icalcomponent_impl*)component; + struct icalcomponent_impl *new; icalproperty *p; icalcomponent *c; pvl_elem itr; - icalerror_check_arg_rz( (old!=0), "component"); + icalerror_check_arg_rz( (component!=0), "component"); new = icalcomponent_new_impl(old->kind); @@ -196,7 +193,8 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* old) itr = pvl_next(itr)) { p = (icalproperty*)pvl_data(itr); - icalcomponent_add_property(new,icalproperty_new_clone(p)); + if (p != 0) + icalcomponent_add_property(new,icalproperty_new_clone(p)); } @@ -212,15 +210,15 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* old) } -/*** @brief Destructor - */ + void -icalcomponent_free (icalcomponent* c) +icalcomponent_free (icalcomponent* component) { icalproperty* prop; icalcomponent* comp; + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; - icalerror_check_arg_rv( (c!=0), "component"); + icalerror_check_arg_rv( (component!=0), "component"); #ifdef ICAL_FREE_ON_LIST_IS_ERROR icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component"); @@ -230,22 +228,19 @@ icalcomponent_free (icalcomponent* c) } #endif - if(c != 0 ){ + if(component != 0 ){ - if ( c->properties != 0 ) - { - while( (prop=pvl_pop(c->properties)) != 0){ - assert(prop != 0); - icalproperty_set_parent(prop,0); - icalproperty_free(prop); - } - pvl_free(c->properties); - } - + while( (prop=pvl_pop(c->properties)) != 0){ + assert(prop != 0); + icalproperty_set_parent(prop,0); + icalproperty_free(prop); + } + + pvl_free(c->properties); while( (comp=pvl_data(pvl_head(c->components))) != 0){ assert(comp!=0); - icalcomponent_remove_component(c,comp); + icalcomponent_remove_component(component,comp); icalcomponent_free(comp); } @@ -269,40 +264,38 @@ icalcomponent_free (icalcomponent* c) free(c); } + } char* -icalcomponent_as_ical_string (icalcomponent* impl) +icalcomponent_as_ical_string (icalcomponent* component) { char* buf, *out_buf; - const char* tmp_buf; + char* tmp_buf; size_t buf_size = 1024; char* buf_ptr = 0; pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; -/* WIN32 automatically adds the \r, Anybody else need it? #ifdef ICAL_UNIX_NEWLINE -*/ char newline[] = "\n"; -/* #else char newline[] = "\r\n"; #endif -*/ icalcomponent *c; icalproperty *p; - icalcomponent_kind kind = icalcomponent_isa(impl); + icalcomponent_kind kind = icalcomponent_isa(component); const char* kind_string; buf = icalmemory_new_buffer(buf_size); buf_ptr = buf; - icalerror_check_arg_rz( (impl!=0), "component"); + icalerror_check_arg_rz( (component!=0), "component"); icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT"); - kind_string = icalcomponent_kind_to_string(kind); + kind_string = icalenum_component_kind_to_string(kind); icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component"); @@ -339,7 +332,7 @@ icalcomponent_as_ical_string (icalcomponent* impl) icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:"); icalmemory_append_string(&buf, &buf_ptr, &buf_size, - icalcomponent_kind_to_string(kind)); + icalenum_component_kind_to_string(kind)); icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); out_buf = icalmemory_tmp_copy(buf); @@ -352,8 +345,11 @@ icalcomponent_as_ical_string (icalcomponent* impl) int icalcomponent_is_valid (icalcomponent* component) { - if ( (strcmp(component->id,"comp") == 0) && - component->kind != ICAL_NO_COMPONENT){ + struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; + + + if ( (strcmp(impl->id,"comp") == 0) && + impl->kind != ICAL_NO_COMPONENT){ return 1; } else { return 0; @@ -363,13 +359,14 @@ icalcomponent_is_valid (icalcomponent* component) icalcomponent_kind -icalcomponent_isa (const icalcomponent* component) +icalcomponent_isa (icalcomponent* component) { - icalerror_check_arg_rx( (component!=0), "component", ICAL_NO_COMPONENT); + struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; + icalerror_check_arg_rz( (component!=0), "component"); if(component != 0) { - return component->kind; + return impl->kind; } return ICAL_NO_COMPONENT; @@ -379,7 +376,7 @@ icalcomponent_isa (const icalcomponent* component) int icalcomponent_isa_component (void* component) { - icalcomponent *impl = component; + struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; icalerror_check_arg_rz( (component!=0), "component"); @@ -391,32 +388,63 @@ icalcomponent_isa_component (void* component) } +int icalcomponent_property_sorter(void *a, void *b) +{ + icalproperty_kind kinda, kindb; + const char *ksa, *ksb; + + kinda = icalproperty_isa((icalproperty*)a); + kindb = icalproperty_isa((icalproperty*)b); + + ksa = icalenum_property_kind_to_string(kinda); + ksb = icalenum_property_kind_to_string(kindb); + + return strcmp(ksa,ksb); +} + + void icalcomponent_add_property (icalcomponent* component, icalproperty* property) { + struct icalcomponent_impl *impl; + icalerror_check_arg_rv( (component!=0), "component"); icalerror_check_arg_rv( (property!=0), "property"); + impl = (struct icalcomponent_impl*)component; + icalerror_assert( (!icalproperty_get_parent(property)),"The property has already been added to a component. Remove the property with icalcomponent_remove_property before calling icalcomponent_add_property"); icalproperty_set_parent(property,component); - pvl_push(component->properties,property); +#ifdef ICAL_INSERT_ORDERED + pvl_insert_ordered(impl->properties, + icalcomponent_property_sorter,property); +#else + pvl_push(impl->properties,property); +#endif + } void icalcomponent_remove_property (icalcomponent* component, icalproperty* property) { + struct icalcomponent_impl *impl; pvl_elem itr, next_itr; + struct icalproperty_impl *pimpl; icalerror_check_arg_rv( (component!=0), "component"); icalerror_check_arg_rv( (property!=0), "property"); + impl = (struct icalcomponent_impl*)component; + + pimpl = (struct icalproperty_impl*)property; + icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component"); - for( itr = pvl_head(component->properties); + for( itr = pvl_head(impl->properties); itr != 0; itr = next_itr) { @@ -424,11 +452,11 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property) if( pvl_data(itr) == (void*)property ){ - if (component->property_iterator == itr){ - component->property_iterator = pvl_next(itr); + if (impl->property_iterator == itr){ + impl->property_iterator = pvl_next(itr); } - pvl_remove( component->properties, itr); + pvl_remove( impl->properties, itr); icalproperty_set_parent(property,0); } } @@ -440,10 +468,11 @@ icalcomponent_count_properties (icalcomponent* component, { int count=0; pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; icalerror_check_arg_rz( (component!=0), "component"); - for( itr = pvl_head(component->properties); + for( itr = pvl_head(impl->properties); itr != 0; itr = pvl_next(itr)) { @@ -460,19 +489,23 @@ icalcomponent_count_properties (icalcomponent* component, icalproperty* icalcomponent_get_current_property (icalcomponent* component) { + + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; icalerror_check_arg_rz( (component!=0),"component"); - if ((component->property_iterator==0)){ + if ((c->property_iterator==0)){ return 0; } - return (icalproperty*) pvl_data(component->property_iterator); + return (icalproperty*) pvl_data(c->property_iterator); + } icalproperty* -icalcomponent_get_first_property (icalcomponent* c, icalproperty_kind kind) +icalcomponent_get_first_property (icalcomponent* component, icalproperty_kind kind) { - icalerror_check_arg_rz( (c!=0),"component"); + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + icalerror_check_arg_rz( (component!=0),"component"); for( c->property_iterator = pvl_head(c->properties); c->property_iterator != 0; @@ -489,9 +522,10 @@ icalcomponent_get_first_property (icalcomponent* c, icalproperty_kind kind) } icalproperty* -icalcomponent_get_next_property (icalcomponent* c, icalproperty_kind kind) +icalcomponent_get_next_property (icalcomponent* component, icalproperty_kind kind) { - icalerror_check_arg_rz( (c!=0),"component"); + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + icalerror_check_arg_rz( (component!=0),"component"); if (c->property_iterator == 0){ return 0; @@ -520,28 +554,31 @@ icalcomponent_get_properties (icalcomponent* component, icalproperty_kind kind); void icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) { + struct icalcomponent_impl *impl, *cimpl; + icalerror_check_arg_rv( (parent!=0), "parent"); icalerror_check_arg_rv( (child!=0), "child"); - if (child->parent !=0) { - icalerror_set_errno(ICAL_USAGE_ERROR); - } + impl = (struct icalcomponent_impl*)parent; + cimpl = (struct icalcomponent_impl*)child; + + icalerror_assert( (cimpl->parent ==0),"The child component has already been added to a parent component. Remove the component with icalcomponent_remove_component before calling icalcomponent_add_component"); - child->parent = parent; + cimpl->parent = parent; - pvl_push(parent->components,child); + pvl_push(impl->components,child); /* If the new component is a VTIMEZONE, add it to our array. */ - if (child->kind == ICAL_VTIMEZONE_COMPONENT) { + if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) { /* FIXME: Currently we are also creating this array when loading in a builtin VTIMEZONE, when we don't need it. */ - if (!parent->timezones) - parent->timezones = icaltimezone_array_new (); + if (!impl->timezones) + impl->timezones = icaltimezone_array_new (); - icaltimezone_array_append_from_vtimezone (parent->timezones, child); + icaltimezone_array_append_from_vtimezone (impl->timezones, child); /* Flag that we need to sort it before doing any binary searches. */ - parent->timezones_sorted = 0; + impl->timezones_sorted = 0; } } @@ -549,28 +586,32 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) void icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child) { + struct icalcomponent_impl *impl,*cimpl; pvl_elem itr, next_itr; icalerror_check_arg_rv( (parent!=0), "parent"); icalerror_check_arg_rv( (child!=0), "child"); + impl = (struct icalcomponent_impl*)parent; + cimpl = (struct icalcomponent_impl*)child; + /* If the component is a VTIMEZONE, remove it from our array as well. */ - if (child->kind == ICAL_VTIMEZONE_COMPONENT) { + if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; int i, num_elements; - num_elements = parent->timezones ? parent->timezones->num_elements : 0; + num_elements = impl->timezones ? impl->timezones->num_elements : 0; for (i = 0; i < num_elements; i++) { - zone = icalarray_element_at (parent->timezones, i); + zone = icalarray_element_at (impl->timezones, i); if (icaltimezone_get_component (zone) == child) { icaltimezone_free (zone, 0); - icalarray_remove_element_at (parent->timezones, i); + icalarray_remove_element_at (impl->timezones, i); break; } } } - for( itr = pvl_head(parent->components); + for( itr = pvl_head(impl->components); itr != 0; itr = next_itr) { @@ -578,16 +619,16 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child) if( pvl_data(itr) == (void*)child ){ - if (parent->component_iterator == itr){ + if (impl->component_iterator == itr){ /* Don't let the current iterator become invalid */ /* HACK. The semantics for this are troubling. */ - parent->component_iterator = - pvl_next(parent->component_iterator); + impl->component_iterator = + pvl_next(impl->component_iterator); } - pvl_remove( parent->components, itr); - child->parent = 0; + pvl_remove( impl->components, itr); + cimpl->parent = 0; break; } } @@ -600,10 +641,11 @@ icalcomponent_count_components (icalcomponent* component, { int count=0; pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; icalerror_check_arg_rz( (component!=0), "component"); - for( itr = pvl_head(component->components); + for( itr = pvl_head(impl->components); itr != 0; itr = pvl_next(itr)) { @@ -619,20 +661,24 @@ icalcomponent_count_components (icalcomponent* component, icalcomponent* icalcomponent_get_current_component(icalcomponent* component) { + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + icalerror_check_arg_rz( (component!=0),"component"); - if (component->component_iterator == 0){ + if (c->component_iterator == 0){ return 0; } - return (icalcomponent*) pvl_data(component->component_iterator); + return (icalcomponent*) pvl_data(c->component_iterator); } icalcomponent* -icalcomponent_get_first_component (icalcomponent* c, +icalcomponent_get_first_component (icalcomponent* component, icalcomponent_kind kind) { - icalerror_check_arg_rz( (c!=0),"component"); + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + + icalerror_check_arg_rz( (component!=0),"component"); for( c->component_iterator = pvl_head(c->components); c->component_iterator != 0; @@ -651,9 +697,11 @@ icalcomponent_get_first_component (icalcomponent* c, icalcomponent* -icalcomponent_get_next_component (icalcomponent* c, icalcomponent_kind kind) +icalcomponent_get_next_component (icalcomponent* component, icalcomponent_kind kind) { - icalerror_check_arg_rz( (c!=0),"component"); + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + + icalerror_check_arg_rz( (component!=0),"component"); if (c->component_iterator == 0){ return 0; @@ -686,54 +734,31 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c) if(kind == ICAL_VEVENT_COMPONENT || kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VJOURNAL_COMPONENT || - kind == ICAL_VFREEBUSY_COMPONENT || - kind == ICAL_VQUERY_COMPONENT || - kind == ICAL_VREPLY_COMPONENT || - kind == ICAL_VAGENDA_COMPONENT){ + kind == ICAL_VJOURNAL_COMPONENT ){ return comp; } } return 0; } - -/** @brief Get the timespan covered by this component, in UTC - * (deprecated) - * - * see icalcomponent_foreach_recurrence() for a better way to - * extract spans from an component. - * - * This method can be called on either a VCALENDAR or any real - * component. If the VCALENDAR contains no real component, but - * contains a VTIMEZONE, we return that span instead. - * This might not be a desirable behavior; we keep it for now - * for backward compatibility, but it might be deprecated at a - * future time. - * - * FIXME this API needs to be clarified. DTEND is defined as the - * first available time after the end of this event, so the span - * should actually end 1 second before DTEND. - */ - -icaltime_span icalcomponent_get_span(icalcomponent* comp) +struct icaltime_span icalcomponent_get_span(icalcomponent* comp) { icalcomponent *inner; + icalproperty *p, *duration; icalcomponent_kind kind; - icaltime_span span; - struct icaltimetype start, end; + struct icaltime_span span; + struct icaltimetype start; span.start = 0; span.end = 0; span.is_busy= 1; /* initial Error checking */ - if (comp == NULL) { - return span; - } - /* FIXME this might go away */ +/* icalerror_check_arg_rz( (comp!=0),"comp");*/ + kind = icalcomponent_isa(comp); + if(kind == ICAL_VCALENDAR_COMPONENT){ inner = icalcomponent_get_first_real_component(comp); @@ -765,330 +790,73 @@ icaltime_span icalcomponent_get_span(icalcomponent* comp) } - /* Get to work. starting with DTSTART */ - start = icalcomponent_get_dtstart(comp); - if (icaltime_is_null_time(start)) { - return span; - } - span.start = icaltime_as_timet_with_zone(start, - icaltimezone_get_utc_timezone()); - /* The end time could be specified as either a DTEND or a DURATION */ - /* icalcomponent_get_dtend takes care of these cases. */ - end = icalcomponent_get_dtend(comp); - if (icaltime_is_null_time(end)) { - if (!icaltime_is_date(start)) { - /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION - it takes no time */ - span.start = 0; - return span; - } else { - end = start; - } - } - - span.end = icaltime_as_timet_with_zone(end, - icaltimezone_get_utc_timezone()); - if (icaltime_is_date(start)) { - /* Until the end of the day*/ - span.end += 60*60*24 - 1; - } - return span; + /* Get to work. starting with DTSTART */ -} + p = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY); -/** - * Decide if this recurrance is acceptable - * - * @param comp A valid icalcomponent. - * @param dtstart The base dtstart value for this component. - * @param recurtime The time to test against. - * - * @return true if the recurrence value is excluded, false otherwise. - * - * This function decides if a specific recurrence value is - * excluded by EXRULE or EXDATE properties. - * - * It's not the most efficient code. You might get better performance - * if you assume that recurtime is always increasing for each - * call. Then you could: - * - * - sort the EXDATE values - * - save the state of each EXRULE iterator for the next call. - * - * In this case though you don't need to worry how you call this - * function. It will always return the correct result. - */ - -int icalproperty_recurrence_is_excluded(icalcomponent *comp, - struct icaltimetype *dtstart, - struct icaltimetype *recurtime) { - icalproperty *exdate, *exrule; - - if (comp == NULL || - dtstart == NULL || - recurtime == NULL || - icaltime_is_null_time(*recurtime)) - /* BAD DATA */ - return 1; - - /** 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); - - if (icaltime_compare(*recurtime, exdatetime) == 0) { - /** MATCHED **/ - return 1; + if (p ==0 ) { + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + /*icalerror_warn("icalcomponent_get_span: component has no DTSTART time");*/ + return span; } - } - /** Now test against the EXRULEs **/ - for (exrule = icalcomponent_get_first_property(comp,ICAL_EXRULE_PROPERTY); - exdate != NULL; - exdate = icalcomponent_get_next_property(comp,ICAL_EXRULE_PROPERTY)) { - - struct icalrecurrencetype recur = icalproperty_get_exrule(exrule); - icalrecur_iterator *exrule_itr = icalrecur_iterator_new(recur, *dtstart); - struct icaltimetype exrule_time; - - while (1) { - int result; - exrule_time = icalrecur_iterator_next(exrule_itr); - - if (icaltime_is_null_time(exrule_time)) - break; - - result = icaltime_compare(*recurtime, exrule_time); - if (result == 0) { - icalrecur_iterator_free(exrule_itr); - return 1; /** MATCH **/ - } - if (result == 1) - break; /** exrule_time > recurtime **/ - } - icalrecur_iterator_free(exrule_itr); - } + start = icalproperty_get_dtstart(p); - return 0; /** no matches **/ -} + icalerror_clear_errno(); -/** - * @brief Return the busy status based on the TRANSP property. - * - * @param comp A valid icalcomponent. - * - * @return 1 if the event is a busy item, 0 if it is not. - */ - -static int icalcomponent_is_busy(icalcomponent *comp) { - icalproperty *transp; - enum icalproperty_status status; - int ret = 1; + /* FIXME: Needs updating to new icaltimezone functions. */ +#if 0 + span.start = icalcomponent_convert_time(p); +#endif - /** @todo check access control here, converting busy->free if the - permissions do not allow access... */ +#ifdef TEST_CONVERT_TIME + printf("convert time:\n %s %s", + icalproperty_as_ical_string(p), ctime(&span.start)); +#endif - /* Is this a busy time? Check the TRANSP property */ - transp = icalcomponent_get_first_property(comp, ICAL_TRANSP_PROPERTY); - - if (transp) { - icalvalue *transp_val = icalproperty_get_value(transp); - - switch (icalvalue_get_transp(transp_val)) { - case ICAL_TRANSP_OPAQUE: - case ICAL_TRANSP_OPAQUENOCONFLICT: - case ICAL_TRANSP_NONE: - ret = 1; - break; - case ICAL_TRANSP_TRANSPARENT: - case ICAL_TRANSP_TRANSPARENTNOCONFLICT: - ret = 0; - break; - default: - ret = 0; - break; - } - } - status = icalcomponent_get_status(comp); - if (ret && status) { - switch (status) { - case ICAL_STATUS_CANCELLED: - case ICAL_STATUS_TENTATIVE: - ret = 0; - break; - default: - break; + if(icalerrno != ICAL_NO_ERROR){ + span.start = 0; + return span; } - } - return(ret); -} - - - - -/** - * @brief cycle through all recurrances of an event - * - * @param comp A valid VEVENT component - * @param start Ignore timespans before this - * @param end Ignore timespans after this - * @param callback Function called for each timespan within the range - * @param callback_data Pointer passed back to the callback function - * - * This function will call the specified callback function for once - * for the base value of DTSTART, and foreach recurring date/time - * value. - * - * It will filter out events that are specified as an EXDATE or an EXRULE. - * - * @todo We do not filter out duplicate RRULES/RDATES - * @todo We do not handle RDATEs with explicit periods - */ - -void icalcomponent_foreach_recurrence(icalcomponent* comp, - struct icaltimetype start, - struct icaltimetype end, - void (*callback)(icalcomponent *comp, - struct icaltime_span *span, - void *data), - void *callback_data) -{ - struct icaltimetype dtstart, dtend; - icaltime_span recurspan, basespan, limit_span; - time_t limit_start, limit_end; - int dtduration; - icalproperty *rrule, *rdate; - struct icaldurationtype dur; - pvl_elem property_iterator; /* for saving the iterator */ - - if (comp == NULL || callback == NULL) - return; - - dtstart = icalcomponent_get_dtstart(comp); - - if (icaltime_is_null_time(dtstart)) - return; - - - /* The end time could be specified as either a DTEND or a DURATION */ - /* icalcomponent_get_dtend takes care of these cases. */ - dtend = icalcomponent_get_dtend(comp); - - /* Now set up the base span for this item, corresponding to the - base DTSTART and DTEND */ - basespan = icaltime_span_new(dtstart, dtend, 1); - - basespan.is_busy = icalcomponent_is_busy(comp); - - - /** Calculate the ceiling and floor values.. **/ - limit_start = icaltime_as_timet_with_zone(start, icaltimezone_get_utc_timezone()); - if (!icaltime_is_null_time(end)) - limit_end = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone()); - else - limit_end = INT_MAX; /* max 32 bit time_t */ - - limit_span.start = limit_start; - limit_span.end = limit_end; - - - /* Do the callback for the initial DTSTART entry */ - - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &dtstart)) { - /** call callback action **/ - if (icaltime_span_overlaps(&basespan, &limit_span)) - (*callback) (comp, &basespan, callback_data); - } - - recurspan = basespan; - dtduration = basespan.end - basespan.start; - - /* Now cycle through the rrule entries */ - for (rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); - rrule != NULL; - rrule = icalcomponent_get_next_property(comp,ICAL_RRULE_PROPERTY)) { - - struct icalrecurrencetype recur = icalproperty_get_rrule(rrule); - icalrecur_iterator *rrule_itr = icalrecur_iterator_new(recur, dtstart); - struct icaltimetype rrule_time; - - while (1) { - rrule_time = icalrecur_iterator_next(rrule_itr); - - if (icaltime_is_null_time(rrule_time)) - break; - - if (!icaltime_compare(rrule_time, dtstart)) - continue; - - dur = icaltime_subtract(rrule_time, dtstart); - - recurspan.start = basespan.start + icaldurationtype_as_int(dur); - recurspan.end = recurspan.start + dtduration; - - /** save the iterator ICK! **/ - property_iterator = comp->property_iterator; - - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rrule_time)) { - /** call callback action **/ - if (icaltime_span_overlaps(&recurspan, &limit_span)) - (*callback) (comp, &recurspan, callback_data); - } - comp->property_iterator = property_iterator; - } /* end of iteration over a specific RRULE */ - - icalrecur_iterator_free(rrule_itr); - } /* end of RRULE loop */ - - - /** Now process RDATE entries **/ - for (rdate = icalcomponent_get_first_property(comp,ICAL_RDATE_PROPERTY); - rdate != NULL; - rdate = icalcomponent_get_next_property(comp,ICAL_RDATE_PROPERTY)) { - - struct icaldatetimeperiodtype rdate_period = icalproperty_get_rdate(rdate); - - /** RDATES can specify raw datetimes, periods, or dates. - we only support raw datetimes for now.. - @todo Add support for other types **/ - - if (icaltime_is_null_time(rdate_period.time)) - continue; - - dur = icaltime_subtract(rdate_period.time, dtstart); + /* The end time could be specified as either a DTEND or a DURATION */ + p = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); + duration = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - recurspan.start = basespan.start + icaldurationtype_as_int(dur); - recurspan.end = recurspan.start + dtduration; + if (p==0 && duration == 0 && start.is_date != 1) { + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + /*icalerror_warn("icalcomponent_get_span: component has neither DTEND nor DURATION time");*/ + span.start = 0; + return span; + } - /** save the iterator ICK! **/ - property_iterator = comp->property_iterator; + if (p!=0){ + /* FIXME: Needs updating to new icaltimezone functions. */ +#if 0 + span.end = icalcomponent_convert_time(p); +#endif + } else if (start.is_date == 1) { + /* Duration is all day */ + span.end = span.start + 60*60*24; + } else { + /* Use the duration */ + struct icaldurationtype dur; + time_t durt; + + + dur = icalproperty_get_duration(duration); - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rdate_period.time)) { - /** call callback action **/ - (*callback) (comp, &recurspan, callback_data); + durt = icaldurationtype_as_int(dur); + span.end = span.start+durt; } - comp->property_iterator = property_iterator; - } -} - + return span; -int icalcomponent_check_restrictions(icalcomponent* comp){ - icalerror_check_arg_rz(comp!=0,"comp"); - return icalrestriction_check(comp); } -/** @brief returns the number of errors encountered parsing the data - * - * This function counts the number times the X-LIC-ERROR occurs - * in the data structure. - */ int icalcomponent_count_errors(icalcomponent* component) { @@ -1096,8 +864,9 @@ int icalcomponent_count_errors(icalcomponent* component) icalproperty *p; icalcomponent *c; pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; - for( itr = pvl_head(component->properties); + for( itr = pvl_head(impl->properties); itr != 0; itr = pvl_next(itr)) { @@ -1110,7 +879,7 @@ int icalcomponent_count_errors(icalcomponent* component) } - for( itr = pvl_head(component->components); + for( itr = pvl_head(impl->components); itr != 0; itr = pvl_next(itr)) { @@ -1129,8 +898,9 @@ void icalcomponent_strip_errors(icalcomponent* component) icalproperty *p; icalcomponent *c; pvl_elem itr, next_itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; - for( itr = pvl_head(component->properties); + for( itr = pvl_head(impl->properties); itr != 0; itr = next_itr) { @@ -1143,7 +913,7 @@ void icalcomponent_strip_errors(icalcomponent* component) } } - for( itr = pvl_head(component->components); + for( itr = pvl_head(impl->components); itr != 0; itr = pvl_next(itr)) { @@ -1197,14 +967,16 @@ void icalcomponent_convert_errors(icalcomponent* component) } default: { - break; } } if (rst.code != ICAL_UNKNOWN_STATUS){ rst.debug = icalproperty_get_xlicerror(p); icalcomponent_add_property(component, - icalproperty_new_requeststatus(rst)); + icalproperty_new_requeststatus( + icalreqstattype_as_string(rst) + ) + ); icalcomponent_remove_property(component,p); } @@ -1222,12 +994,16 @@ void icalcomponent_convert_errors(icalcomponent* component) icalcomponent* icalcomponent_get_parent(icalcomponent* component) { - return component->parent; + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + + return c->parent; } void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent) { - component->parent = parent; + struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; + + c->parent = parent; } icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0}; @@ -1246,7 +1022,6 @@ static struct icalcomponent_kind_map component_map[] = { ICAL_VTODO_COMPONENT, "VTODO" }, { ICAL_VJOURNAL_COMPONENT, "VJOURNAL" }, { ICAL_VCALENDAR_COMPONENT, "VCALENDAR" }, - { ICAL_VAGENDA_COMPONENT, "VAGENDA" }, { ICAL_VFREEBUSY_COMPONENT, "VFREEBUSY" }, { ICAL_VTIMEZONE_COMPONENT, "VTIMEZONE" }, { ICAL_VALARM_COMPONENT, "VALARM" }, @@ -1256,10 +1031,9 @@ static struct icalcomponent_kind_map component_map[] = { ICAL_VSCHEDULE_COMPONENT, "SCHEDULE" }, /* CAP components */ + { ICAL_VQUERY_COMPONENT, "VQUERY" }, { ICAL_VCAR_COMPONENT, "VCAR" }, { ICAL_VCOMMAND_COMPONENT, "VCOMMAND" }, - { ICAL_VQUERY_COMPONENT, "VQUERY" }, - { ICAL_VREPLY_COMPONENT, "VREPLY" }, /* libical private components */ { ICAL_XLICINVALID_COMPONENT, "X-LIC-UNKNOWN" }, @@ -1272,16 +1046,6 @@ static struct icalcomponent_kind_map component_map[] = }; -int icalcomponent_kind_is_valid(const icalcomponent_kind kind) -{ - int i = 0; - do { - if (component_map[i].kind == kind) - return 1; - } while (component_map[i++].kind != ICAL_NO_COMPONENT); - - return 0; -} const char* icalcomponent_kind_to_string(icalcomponent_kind kind) { @@ -1319,15 +1083,15 @@ icalcomponent_kind icalcomponent_string_to_kind(const char* string) icalcompiter icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind) { + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; icalcompiter itr; pvl_elem i; itr.kind = kind; - itr.iter = NULL; - icalerror_check_arg_re(component!=0,"component",icalcompiter_null); + icalerror_check_arg_re( (component!=0),"component",icalcompiter_null); - for( i = pvl_head(component->components); i != 0; i = pvl_next(i)) { + for( i = pvl_head(impl->components); i != 0; i = pvl_next(i)) { icalcomponent *c = (icalcomponent*) pvl_data(i); @@ -1345,14 +1109,15 @@ icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind) icalcompiter icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind) { + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; icalcompiter itr; pvl_elem i; itr.kind = kind; - icalerror_check_arg_re(component!=0,"component",icalcompiter_null); + icalerror_check_arg_re( (component!=0),"component",icalcompiter_null); - for( i = pvl_tail(component->components); i != 0; i = pvl_prior(i)) { + for( i = pvl_tail(impl->components); i != 0; i = pvl_prior(i)) { icalcomponent *c = (icalcomponent*) pvl_data(i); @@ -1433,240 +1198,140 @@ icalcomponent* icalcomponent_get_inner(icalcomponent* comp) } } -/** @brief sets the METHOD property to the given method - */ -void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method) +void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v) { - icalproperty *prop - = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY); - - - if (prop == 0){ - prop = icalproperty_new_method(method); - icalcomponent_add_property(comp, prop); - } - - icalproperty_set_method(prop,method); - -} - -/** @brief returns the METHOD property - */ -icalproperty_method icalcomponent_get_method(icalcomponent* comp) -{ + icalcomponent *inner = icalcomponent_get_inner(comp); icalproperty *prop - = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY); + = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY); - if (prop == 0){ - return ICAL_METHOD_NONE; - } - - return icalproperty_get_method(prop); -} - -#define ICALSETUPSET(p_kind) \ - icalcomponent *inner; \ - icalproperty *prop; \ - icalerror_check_arg_rv(comp!=0,"comp");\ - inner = icalcomponent_get_inner(comp); \ - if(inner == 0){\ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);\ - return;\ - }\ - prop = icalcomponent_get_first_property(inner, p_kind); - - -/** @brief Set DTSTART property to given icaltime - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - */ -void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v) -{ - char *tzid; - ICALSETUPSET(ICAL_DTSTART_PROPERTY); if (prop == 0){ prop = icalproperty_new_dtstart(v); icalcomponent_add_property(inner, prop); - } else { - icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER); } icalproperty_set_dtstart(prop,v); - if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) { - icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid)); - } } -/** @brief Get a DATE or DATE-TIME property as an icaltime - * - * If the property is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ -static struct icaltimetype -icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop) { - - icalcomponent *c; - icalparameter *param; - struct icaltimetype ret; - - ret = icalvalue_get_datetime(icalproperty_get_value(prop)); - - if ((param = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER)) - != NULL) { - const char *tzid = icalparameter_get_tzid(param); - icaltimezone *tz = NULL; - - for (c = comp; c != NULL; c = icalcomponent_get_parent(c)) { - tz = icalcomponent_get_timezone(c, tzid); - if (tz != NULL) - break; - } - - if (tz == NULL) - tz = icaltimezone_get_builtin_timezone(tzid); - if (tz != NULL) - ret = icaltime_set_timezone(&ret, tz); - } - - return ret; -} - -/** @brief Get DTSTART property as an icaltime - * - * If DTSTART is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp) { icalcomponent *inner = icalcomponent_get_inner(comp); - icalproperty *prop; + icalproperty *prop + = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); - prop = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); if (prop == 0){ return icaltime_null_time(); } - - return icalcomponent_get_datetime(comp, prop); + + return icalproperty_get_dtstart(prop); } -/** @brief Get DTEND property as an icaltime - * - * If a DTEND property is not present but a DURATION is, we use - * that to determine the proper end. - * - * If DTSTART is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ + struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp) { icalcomponent *inner = icalcomponent_get_inner(comp); + icalproperty *end_prop = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); + icalproperty *dur_prop = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - struct icaltimetype ret = icaltime_null_time(); - if ( end_prop != 0) { - ret = icalcomponent_get_datetime(comp, end_prop); - } else if ( dur_prop != 0) { + if( end_prop == 0 && dur_prop == 0){ + return icaltime_null_time(); + } else if ( end_prop != 0) { + return icalproperty_get_dtend(end_prop); + } else if ( dur_prop != 0) { + struct icaltimetype start = icalcomponent_get_dtstart(inner); struct icaldurationtype duration = icalproperty_get_duration(dur_prop); - + struct icaltimetype end = icaltime_add(start,duration); - ret = end; - } + return end; + + } else { + /* Error, both duration and dtend have been specified */ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + return icaltime_null_time(); - return ret; + } + } -/** @brief Set DTEND property to given icaltime - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - * - * This also checks that a DURATION property isn't already there, - * and returns an error if it is. It's the caller's responsibility - * to remove it. - */ + void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v) { - char *tzid; - ICALSETUPSET(ICAL_DTEND_PROPERTY); + icalcomponent *inner = icalcomponent_get_inner(comp); - if (icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY) - != NULL) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } + icalproperty *end_prop + = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); - if (prop == 0) { - prop = icalproperty_new_dtend(v); - icalcomponent_add_property(inner, prop); - } else { - icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER); - } + icalproperty *dur_prop + = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); + + + if( end_prop == 0 && dur_prop == 0){ + end_prop = icalproperty_new_dtend(v); + icalcomponent_add_property(inner,end_prop); + } else if ( end_prop != 0) { + icalproperty_set_dtend(end_prop,v); + } else if ( dur_prop != 0) { + struct icaltimetype start = + icalcomponent_get_dtstart(inner); + + struct icaltimetype end = + icalcomponent_get_dtend(inner); + + struct icaldurationtype dur + = icaltime_subtract(end,start); - icalproperty_set_dtend(prop,v); + icalproperty_set_duration(dur_prop,dur); - if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) { - icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid)); + } else { + /* Error, both duration and dtend have been specified */ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } } -/** @brief Set DURATION property to given icalduration - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - * - * This also checks that a DTEND property isn't already there, - * and returns an error if it is. It's the caller's responsibility - * to remove it. - */ void icalcomponent_set_duration(icalcomponent* comp, struct icaldurationtype v) { - ICALSETUPSET(ICAL_DURATION_PROPERTY); + icalcomponent *inner = icalcomponent_get_inner(comp); - if (icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY) != NULL) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } + icalproperty *end_prop + = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); - if (prop == 0) { - prop = icalproperty_new_duration(v); - icalcomponent_add_property(inner, prop); + icalproperty *dur_prop + = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); + + + if( end_prop == 0 && dur_prop == 0){ + dur_prop = icalproperty_new_duration(v); + icalcomponent_add_property(inner, dur_prop); + } else if ( end_prop != 0) { + struct icaltimetype start = + icalcomponent_get_dtstart(inner); + + struct icaltimetype new_end = icaltime_add(start,v); + + icalproperty_set_dtend(end_prop,new_end); + + } else if ( dur_prop != 0) { + icalproperty_set_duration(dur_prop,v); } else { - icalproperty_set_duration(prop,v); + /* Error, both duration and dtend have been specified */ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } } -/** @brief Get DURATION property as an icalduration - * - * If a DURATION property is not present but a DTEND is, we use - * that to determine the proper end. - */ struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp) { icalcomponent *inner = icalcomponent_get_inner(comp); @@ -1677,329 +1342,154 @@ struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp) icalproperty *dur_prop = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); - struct icaldurationtype ret = icaldurationtype_null_duration(); + struct icaldurationtype null_duration; + memset(&null_duration,0,sizeof(struct icaldurationtype)); - if ( dur_prop != 0 && end_prop == 0) { - ret = icalproperty_get_duration(dur_prop); - } else if ( end_prop != 0 && dur_prop == 0) { - /** - * FIXME - * We assume DTSTART and DTEND are not in different time zones. - * Does the standard actually guarantee this? - */ + if( end_prop == 0 && dur_prop == 0){ + return null_duration; + } else if ( end_prop != 0) { struct icaltimetype start = icalcomponent_get_dtstart(inner); + time_t startt = icaltime_as_timet(start); + struct icaltimetype end = icalcomponent_get_dtend(inner); - - ret = icaltime_subtract(end, start); + time_t endt = icaltime_as_timet(end); + + return icaldurationtype_from_int(endt-startt); + } else if ( dur_prop != 0) { + return icalproperty_get_duration(dur_prop); } else { /* Error, both duration and dtend have been specified */ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + return null_duration; } - return ret; } -void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v) +void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method) { + icalproperty *prop + = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY); - ICALSETUPSET(ICAL_DTSTAMP_PROPERTY); if (prop == 0){ - prop = icalproperty_new_dtstamp(v); - icalcomponent_add_property(inner, prop); + prop = icalproperty_new_method(method); + icalcomponent_add_property(comp, prop); } - icalproperty_set_dtstamp(prop,v); + icalproperty_set_method(prop,method); } - -struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp) +icalproperty_method icalcomponent_get_method(icalcomponent* comp) { - icalcomponent *inner = icalcomponent_get_inner(comp); icalproperty *prop - = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); - - if (prop == 0){ - return icaltime_null_time(); - } - - return icalproperty_get_dtstamp(prop); -} - + = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY); -void icalcomponent_set_summary(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_SUMMARY_PROPERTY) - if (prop == 0){ - prop = icalproperty_new_summary(v); - icalcomponent_add_property(inner, prop); + return ICAL_METHOD_NONE; } - icalproperty_set_summary(prop,v); + return icalproperty_get_method(prop); } - -const char* icalcomponent_get_summary(icalcomponent* comp) +void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v) { - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_summary(prop); - -} + icalcomponent *inner = icalcomponent_get_inner(comp); + icalproperty *prop + = icalcomponent_get_first_property(inner, ICAL_DTSTAMP_PROPERTY); -void icalcomponent_set_comment(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_COMMENT_PROPERTY); if (prop == 0){ - prop = icalproperty_new_comment(v); + prop = icalproperty_new_dtstamp(v); icalcomponent_add_property(inner, prop); } - - icalproperty_set_summary(prop,v); + + icalproperty_set_dtstamp(prop,v); } -const char* icalcomponent_get_comment(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - prop= icalcomponent_get_first_property(inner,ICAL_COMMENT_PROPERTY); +struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp) +{ + icalcomponent *inner = icalcomponent_get_inner(comp); + icalproperty *prop + = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); if (prop == 0){ - return 0; + return icaltime_null_time(); } - return icalproperty_get_comment(prop); + return icalproperty_get_dtstamp(prop); } -void icalcomponent_set_uid(icalcomponent* comp, const char* v) + +void icalcomponent_set_summary(icalcomponent* comp, const char* v) { - ICALSETUPSET(ICAL_UID_PROPERTY); + icalcomponent *inner = icalcomponent_get_inner(comp); + icalproperty *prop + = icalcomponent_get_first_property(inner, ICAL_SUMMARY_PROPERTY); if (prop == 0){ - prop = icalproperty_new_uid(v); + prop = icalproperty_new_summary(v); icalcomponent_add_property(inner, prop); } - + icalproperty_set_summary(prop,v); - } -const char* icalcomponent_get_uid(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - prop= icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); +const char* icalcomponent_get_summary(icalcomponent* comp) +{ + icalcomponent *inner = icalcomponent_get_inner(comp); + icalproperty *prop + = icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY); if (prop == 0){ return 0; } - return icalproperty_get_uid(prop); -} - -void icalcomponent_set_recurrenceid(icalcomponent* comp, struct icaltimetype v) -{ - ICALSETUPSET(ICAL_RECURRENCEID_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_recurrenceid(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_recurrenceid(prop,v); -} -struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - if (comp == 0) { - icalerror_set_errno(ICAL_BADARG_ERROR); - return icaltime_null_time(); - } - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaltime_null_time(); - } - - prop= icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY); - - if (prop == 0){ - return icaltime_null_time(); - } - - return icalproperty_get_recurrenceid(prop); -} - -void icalcomponent_set_description(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_DESCRIPTION_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_description(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_description(prop,v); -} -const char* icalcomponent_get_description(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_DESCRIPTION_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_description(prop); -} - -void icalcomponent_set_location(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_LOCATION_PROPERTY) - - if (prop == 0){ - prop = icalproperty_new_location(v); - icalcomponent_add_property(inner, prop); - } + return icalproperty_get_summary(prop); - icalproperty_set_location(prop,v); } -const char* icalcomponent_get_location(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - prop= icalcomponent_get_first_property(inner,ICAL_LOCATION_PROPERTY); +void icalcomponent_set_comment(icalcomponent* comp, const char* v); +const char* icalcomponent_get_comment(icalcomponent* comp); - if (prop == 0){ - return 0; - } - - return icalproperty_get_location(prop); -} - -void icalcomponent_set_sequence(icalcomponent* comp, int v) +void icalcomponent_set_uid(icalcomponent* comp, const char* v) { - ICALSETUPSET(ICAL_SEQUENCE_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_sequence(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_sequence(prop,v); - -} -int icalcomponent_get_sequence(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); + icalcomponent *inner = icalcomponent_get_inner (comp); + icalproperty *prop + = icalcomponent_get_first_property (inner, ICAL_UID_PROPERTY); - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY); - - if (prop == 0){ - return 0; - } + if (prop == 0) { + prop = icalproperty_new_uid (v); + icalcomponent_add_property (inner, prop); + } - return icalproperty_get_sequence(prop); + icalproperty_set_uid (prop, v); } - -void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v) +const char* icalcomponent_get_uid(icalcomponent* comp) { - ICALSETUPSET(ICAL_STATUS_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_status(v); - icalcomponent_add_property(inner, prop); - } + icalcomponent *inner = icalcomponent_get_inner (comp); + icalproperty *prop = icalcomponent_get_first_property (inner, ICAL_UID_PROPERTY); - icalproperty_set_status(prop,v); + if (prop == 0) { + return 0; + } + return icalproperty_get_uid (prop); } -enum icalproperty_status icalcomponent_get_status(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - inner = icalcomponent_get_inner(comp); +void icalcomponent_set_recurrenceid(icalcomponent* comp, + struct icaltimetype v); +struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp); - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_STATUS_PROPERTY); - if (prop == 0){ - return 0; - } - return icalproperty_get_status(prop); -} icalcomponent* icalcomponent_new_vcalendar() { @@ -2037,29 +1527,15 @@ icalcomponent* icalcomponent_new_xdaylight() { return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT); } -icalcomponent* icalcomponent_new_vagenda() -{ - return icalcomponent_new(ICAL_VAGENDA_COMPONENT); -} -icalcomponent* icalcomponent_new_vquery() -{ - return icalcomponent_new(ICAL_VQUERY_COMPONENT); -} -icalcomponent* icalcomponent_new_vreply() -{ - return icalcomponent_new(ICAL_VREPLY_COMPONENT); -} + /* * Timezone stuff. */ - -/** - * This takes 2 VCALENDAR components and merges the second one into the first, - * resolving any problems with conflicting TZIDs. comp_to_merge will no - * longer exist after calling this function. - */ +/* This takes 2 VCALENDAR components and merges the second one into the first, + resolving any problems with conflicting TZIDs. comp_to_merge will no + longer exist after calling this function. */ void icalcomponent_merge_component(icalcomponent* comp, icalcomponent* comp_to_merge) { @@ -2126,7 +1602,8 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp, icalproperty *tzid_prop; const char *tzid; char *tzid_copy; - icaltimezone *existing_vtimezone; + icaltimezone *existing_zone; + icalcomponent *existing_vtimezone; /* Get the TZID of the VTIMEZONE. */ tzid_prop = icalcomponent_get_first_property (vtimezone, ICAL_TZID_PROPERTY); @@ -2138,11 +1615,11 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp, return; /* See if there is already a VTIMEZONE in comp with the same TZID. */ - existing_vtimezone = icalcomponent_get_timezone (comp, tzid); + existing_zone = icalcomponent_get_timezone (comp, tzid); /* If there is no existing VTIMEZONE with the same TZID, we can just move the VTIMEZONE to comp and return. */ - if (!existing_vtimezone) { + if (!existing_zone) { icalcomponent_remove_component (icalcomponent_get_parent (vtimezone), vtimezone); icalcomponent_add_component (comp, vtimezone); @@ -2164,7 +1641,8 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp, return; } - if (!icalcomponent_compare_vtimezones (comp, vtimezone)) { + existing_vtimezone = icaltimezone_get_component (existing_zone); + if (!icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone)) { /* FIXME: Handle possible NEWFAILED error. */ /* Now we have two different VTIMEZONEs with the same TZID. */ @@ -2182,8 +1660,8 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, const char *tzid, icalarray *tzids_to_rename) { - int i, suffix, max_suffix = 0, num_elements; - unsigned int tzid_len; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)comp; + int tzid_len, i, suffix, max_suffix = 1, num_elements; char *tzid_copy, *new_tzid, suffix_buf[32]; /* Find the length of the TZID without any trailing digits. */ @@ -2196,13 +1674,13 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, same prefix (e.g. 'London'). If it matches any of those, we have to rename the TZIDs to that TZID, else we rename to a new TZID, using the biggest numeric suffix found + 1. */ - num_elements = comp->timezones ? comp->timezones->num_elements : 0; + num_elements = impl->timezones ? impl->timezones->num_elements : 0; for (i = 0; i < num_elements; i++) { icaltimezone *zone; char *existing_tzid, *existing_tzid_copy; - unsigned int existing_tzid_len; + int existing_tzid_len; - zone = icalarray_element_at (comp->timezones, i); + zone = icalarray_element_at (impl->timezones, i); existing_tzid = icaltimezone_get_tzid (zone); /* Find the length of the TZID without any trailing digits. */ @@ -2255,7 +1733,7 @@ icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, /* Returns the length of the TZID, without any trailing digits. */ -static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid) +static int icalcomponent_get_tzid_prefix_len (const char *tzid) { int len; const char *p; @@ -2271,11 +1749,9 @@ static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid) } -/** - * Renames all references to the given TZIDs to a new name. rename_table - * contains pairs of strings - a current TZID, and the new TZID to rename it - * to. - */ +/* Renames all references to the given TZIDs to a new name. rename_table + contains pairs of strings - a current TZID, and the new TZID to rename it + to. */ static void icalcomponent_rename_tzids(icalcomponent* comp, icalarray* rename_table) { @@ -2305,9 +1781,7 @@ static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data } -/** - * Calls the given function for each TZID parameter found in the component. - */ +/* Calls the given function for each TZID parameter found in the component. */ void icalcomponent_foreach_tzid(icalcomponent* comp, void (*callback)(icalparameter *param, void *data), void *callback_data) @@ -2345,32 +1819,33 @@ void icalcomponent_foreach_tzid(icalcomponent* comp, -/** - * Returns the icaltimezone from the component corresponding to the given - * TZID, or NULL if the component does not have a corresponding VTIMEZONE. - */ +/* Returns the icaltimezone from the component corresponding to the given + TZID, or NULL if the component does not have a corresponding VTIMEZONE. */ icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid) { + struct icalcomponent_impl *impl; icaltimezone *zone; int lower, upper, middle, cmp; char *zone_tzid; - if (!comp->timezones) + impl = (struct icalcomponent_impl*)comp; + + if (!impl->timezones) return NULL; /* Sort the array if necessary (by the TZID string). */ - if (!comp->timezones_sorted) { - icalarray_sort (comp->timezones, icalcomponent_compare_timezone_fn); - comp->timezones_sorted = 1; + if (!impl->timezones_sorted) { + icalarray_sort (impl->timezones, icalcomponent_compare_timezone_fn); + impl->timezones_sorted = 1; } /* Do a simple binary search. */ lower = middle = 0; - upper = comp->timezones->num_elements; + upper = impl->timezones->num_elements; while (lower < upper) { middle = (lower + upper) >> 1; - zone = icalarray_element_at (comp->timezones, middle); + zone = icalarray_element_at (impl->timezones, middle); zone_tzid = icaltimezone_get_tzid (zone); cmp = strcmp (tzid, zone_tzid); if (cmp == 0) @@ -2385,14 +1860,13 @@ icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid) } -/** - * A function to compare 2 icaltimezone elements, used for qsort(). - */ +/* A function to compare 2 icaltimezone elements, used for qsort(). */ static int icalcomponent_compare_timezone_fn (const void *elem1, const void *elem2) { icaltimezone *zone1, *zone2; const char *zone1_tzid, *zone2_tzid; + int retval; zone1 = (icaltimezone*) elem1; zone2 = (icaltimezone*) elem2; @@ -2404,16 +1878,14 @@ static int icalcomponent_compare_timezone_fn (const void *elem1, } -/** - * Compares 2 VTIMEZONE components to see if they match, ignoring their TZIDs. - * It returns 1 if they match, 0 if they don't, or -1 on error. - */ +/* Compares 2 VTIMEZONE components to see if they match, ignoring their TZIDs. + It returns 1 if they match, 0 if they don't, or -1 on error. */ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, icalcomponent *vtimezone2) { icalproperty *prop1, *prop2; const char *tzid1, *tzid2; - char *tzid2_copy, *string1, *string2; + char *tzid2_copy, *string1, *string2, *string1_copy; int cmp; /* Get the TZID property of the first VTIMEZONE. */ @@ -2421,6 +1893,7 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, if (!prop1) return -1; + /* This returns the pointer to the actual string in the property. */ tzid1 = icalproperty_get_tzid (prop1); if (!tzid1) return -1; @@ -2430,6 +1903,7 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, if (!prop2) return -1; + /* This returns the pointer to the actual string in the property. */ tzid2 = icalproperty_get_tzid (prop2); if (!tzid2) return -1; @@ -2447,21 +1921,32 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, /* Now convert both VTIMEZONEs to strings and compare them. */ string1 = icalcomponent_as_ical_string (vtimezone1); if (!string1) { + /* Try to reset the property. Though this may not work if we are low + on memory. */ + icalproperty_set_tzid (prop2, tzid2_copy); + free (tzid2_copy); + return -1; + } + + /* Copy the string, since it is in a temporary buffer which may get freed + during the next call. */ + string1_copy = strdup (string1); + if (!string1_copy) { + icalproperty_set_tzid (prop2, tzid2_copy); free (tzid2_copy); return -1; } string2 = icalcomponent_as_ical_string (vtimezone2); if (!string2) { - free (string1); + icalproperty_set_tzid (prop2, tzid2_copy); free (tzid2_copy); return -1; } - cmp = strcmp (string1, string2); + cmp = strcmp (string1_copy, string2); - free (string1); - free (string2); + free (string1_copy); /* Now reset the second TZID. */ icalproperty_set_tzid (prop2, tzid2_copy); @@ -2469,143 +1954,3 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, return (cmp == 0) ? 1 : 0; } - - - - - - -/** - * @brief set the RELCALID property of a component. - * - * @param comp Valid calendar component. - * @param v Relcalid URL value - */ - -void icalcomponent_set_relcalid(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_RELCALID_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_relcalid(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_relcalid(prop,v); - -} - - -/** - * @brief get the RELCALID property of a component. - * - * @param comp Valid calendar component. - */ - -const char* icalcomponent_get_relcalid(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_RELCALID_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_relcalid(prop); -} - - -/** @brief Return the time a TODO task is DUE. - * - * @param comp Valid calendar component. - * - * Uses the DUE: property if it exists, otherwise we calculate the DUE - * value by adding the task's duration to the DTSTART time - */ - -struct icaltimetype icalcomponent_get_due(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - - icalproperty *due_prop - = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY); - - 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) { - return icalproperty_get_due(due_prop); - } else if ( dur_prop != 0) { - - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - struct icaldurationtype duration = - icalproperty_get_duration(dur_prop); - - struct icaltimetype due = icaltime_add(start,duration); - - return due; - - } else { - /* Error, both duration and due have been specified */ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaltime_null_time(); - - } - -} - -/** @brief Set the due date of a VTODO task. - * - * @param comp Valid VTODO component. - * @param v Valid due date time. - * - * - If no duration or due properties then set the DUE property. - * - If a DUE property is already set, then reset it to the value v. - * - If a DURATION property is already set, then calculate the new - * duration based on the supplied value of v. - */ - -void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - - icalproperty *due_prop - = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY); - - icalproperty *dur_prop - = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); - - - if( due_prop == 0 && dur_prop == 0){ - due_prop = icalproperty_new_due(v); - icalcomponent_add_property(inner,due_prop); - } else if ( due_prop != 0) { - icalproperty_set_due(due_prop,v); - } else if ( dur_prop != 0) { - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - - struct icaltimetype due = - icalcomponent_get_due(inner); - - struct icaldurationtype dur - = icaltime_subtract(due,start); - - icalproperty_set_duration(dur_prop,dur); - - } else { - /* Error, both duration and due have been specified */ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - } -} diff --git a/libical/src/libical/icalderivedparameter.c.in b/libical/src/libical/icalderivedparameter.c.in index b41587e0de..4af6e95c0e 100644 --- a/libical/src/libical/icalderivedparameter.c.in +++ b/libical/src/libical/icalderivedparameter.c.in @@ -3,7 +3,7 @@ FILE: icalderivedparameters.{c,h} CREATOR: eric 09 May 1999 - $Id: icalderivedparameter.c.in,v 1.2 2003/09/11 22:04:19 hansp Exp $ + $Id: icalderivedparameter.c.in,v 1.1 2001/04/17 17:23:17 jpr Exp $ $Locker: $ @@ -55,25 +55,8 @@ struct icalparameter_kind_map { }; -/* This map associates the enumerations for the VALUE parameter with - the kinds of VALUEs. */ - -struct icalparameter_value_kind_map { - icalparameter_value value; - icalvalue_kind kind; -}; +extern struct icalparameter_kind_map parameter_map[]; -/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */ - -struct icalparameter_map { - icalparameter_kind kind; - int enumeration; - const char* str; -}; - - - -<insert_code_here> const char* icalparameter_kind_to_string(icalparameter_kind kind) { @@ -111,6 +94,16 @@ icalparameter_kind icalparameter_string_to_kind(const char* string) return ICAL_NO_PARAMETER; } +/* This map associates the enumerations for the VALUE parameter with + the kinds of VALUEs. */ + +struct icalparameter_value_kind_map { + icalparameter_value value; + icalvalue_kind kind; +}; + +extern struct icalparameter_value_kind_map value_kind_map[]; + icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value) { @@ -127,6 +120,18 @@ icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value) } +/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */ + +struct icalparameter_map { + icalparameter_kind kind; + int enumeration; + const char* str; +}; + + +extern struct icalparameter_map icalparameter_map[]; + + const char* icalparameter_enum_to_string(int e) { int i; @@ -203,3 +208,4 @@ icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const +/* Everything below this line is machine generated. Do not edit. */ diff --git a/libical/src/libical/icalderivedparameter.h.in b/libical/src/libical/icalderivedparameter.h.in index a8f3a36085..e9fdd19fa7 100644 --- a/libical/src/libical/icalderivedparameter.h.in +++ b/libical/src/libical/icalderivedparameter.h.in @@ -4,7 +4,7 @@ CREATOR: eric 20 March 1999 - $Id: icalderivedparameter.h.in,v 1.2 2003/09/11 22:04:19 hansp Exp $ + $Id: icalderivedparameter.h.in,v 1.1 2001/04/17 17:23:17 jpr Exp $ $Locker: $ @@ -30,9 +30,8 @@ #define ICALDERIVEDPARAMETER_H -typedef struct icalparameter_impl icalparameter; +typedef void icalparameter; const char* icalparameter_enum_to_string(int e); int icalparameter_string_to_enum(const char* str); -<insert_code_here> diff --git a/libical/src/libical/icalderivedproperty.c.in b/libical/src/libical/icalderivedproperty.c.in index 36ddc846ae..ceec0b797d 100644 --- a/libical/src/libical/icalderivedproperty.c.in +++ b/libical/src/libical/icalderivedproperty.c.in @@ -4,7 +4,7 @@ FILE: icalderivedproperty.c CREATOR: eric 15 Feb 2001 - $Id: icalderivedproperty.c.in,v 1.2 2003/09/11 22:04:19 hansp Exp $ + $Id: icalderivedproperty.c.in,v 1.1 2001/04/17 17:23:17 jpr Exp $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org @@ -43,9 +43,10 @@ #include <stdio.h> /* for printf */ #include <stdarg.h> /* for va_list, va_start, etc. */ +#define TMP_BUF_SIZE 1024 + struct icalproperty_impl* icalproperty_new_impl (icalproperty_kind kind); -void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args); /* This map associates the property kinds with the string representation of the property name and the kind of VALUE that the @@ -58,29 +59,7 @@ struct icalproperty_map { }; -/* This map associates the property enumerations with the king of - property that they are used in and the string representation of the - enumeration */ - -struct icalproperty_enum_map { - icalproperty_kind prop; - int prop_enum; - const char* str; -}; - - -<insert_code_here> - -int icalproperty_kind_is_valid(const icalproperty_kind kind) -{ - int i = 0; - do { - if (property_map[i].kind == kind) - return 1; - } while (property_map[i++].kind != ICAL_NO_PROPERTY); - - return 0; -} +extern struct icalproperty_map property_map[]; const char* icalproperty_kind_to_string(icalproperty_kind kind) { @@ -121,7 +100,7 @@ icalproperty_kind icalproperty_string_to_kind(const char* string) } -icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind) +icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind) { int i; @@ -131,7 +110,7 @@ icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind) } } - return ICAL_NO_PROPERTY; + return ICAL_NO_VALUE; } @@ -150,6 +129,19 @@ icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind) } +/* This map associates the property enumerations with the king of + property that they are used in and the string representation of the + enumeration */ + +struct icalproperty_enum_map { + icalproperty_kind prop; + int prop_enum; + const char* str; +}; + +extern struct icalproperty_enum_map enum_map[]; + + const char* icalproperty_enum_to_string(int e) { icalerror_check_arg_rz(e >= ICALPROPERTY_FIRST_ENUM,"e"); @@ -158,37 +150,6 @@ const char* icalproperty_enum_to_string(int e) return enum_map[e-ICALPROPERTY_FIRST_ENUM].str; } -int icalproperty_kind_and_string_to_enum(const int kind, const char* str) -{ - icalproperty_kind pkind; - int i; - - icalerror_check_arg_rz(str!=0,"str") - - if ((pkind = icalproperty_value_kind_to_kind(kind)) == ICAL_NO_VALUE) - return 0; - - while(*str == ' '){ - str++; - } - - for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) { - if (enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == pkind) - break; - } - if (i == ICALPROPERTY_LAST_ENUM) - return 0; - - for (; i != ICALPROPERTY_LAST_ENUM; i++) { - if ( strcmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) { - return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum; - } - } - - return 0; -} - -/** @deprecated please use icalproperty_kind_and_string_to_enum instead */ int icalproperty_string_to_enum(const char* str) { int i; @@ -276,10 +237,14 @@ icalproperty_status icalenum_string_to_status(const char* str) i != ICAL_STATUS_NONE-ICALPROPERTY_FIRST_ENUM; i++) { if ( strcmp(enum_map[i].str, str) == 0) { - return (icalproperty_status)enum_map[i].prop_enum; + return (icalproperty_method)enum_map[i].prop_enum; } } return ICAL_STATUS_NONE; } + + + +/* Everything below this line is machine generated. Do not edit. */ diff --git a/libical/src/libical/icalderivedproperty.h.in b/libical/src/libical/icalderivedproperty.h.in index eda95ee031..6ce34afafb 100644 --- a/libical/src/libical/icalderivedproperty.h.in +++ b/libical/src/libical/icalderivedproperty.h.in @@ -3,7 +3,7 @@ FILE: icalderivedproperties.{c,h} CREATOR: eric 09 May 1999 - $Id: icalderivedproperty.h.in,v 1.2 2003/09/11 22:04:19 hansp Exp $ + $Id: icalderivedproperty.h.in,v 1.1 2001/04/17 17:23:17 jpr Exp $ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ @@ -17,6 +17,7 @@ #include "icalderivedvalue.h" #include "icalrecur.h" -typedef struct icalproperty_impl icalproperty; +typedef void icalproperty; -<insert_code_here> + +/* Everything below this line is machine generated. Do not edit. */ diff --git a/libical/src/libical/icallangbind.h b/libical/src/libical/icallangbind.h index fed3626c32..2ed50038eb 100644 --- a/libical/src/libical/icallangbind.h +++ b/libical/src/libical/icallangbind.h @@ -41,14 +41,9 @@ icalcomponent* icallangbind_get_first_component(icalcomponent *c, icalcomponent* icallangbind_get_next_component(icalcomponent *c, const char* comp); -icalparameter* icallangbind_get_first_parameter(icalproperty *prop); - -icalparameter* icallangbind_get_next_parameter(icalproperty *prop); const char* icallangbind_property_eval_string(icalproperty* prop, char* sep); int icallangbind_string_to_open_flag(const char* str); - -const char* icallangbind_quote_as_ical(const char* str); #endif /*__ICALLANGBIND_H__*/ diff --git a/libical/src/libical/icalmime.c b/libical/src/libical/icalmime.c index e5d1c90601..6e11e9e326 100644 --- a/libical/src/libical/icalmime.c +++ b/libical/src/libical/icalmime.c @@ -38,10 +38,6 @@ #include "dmalloc.h" #endif -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif /* These *_part routines are called by the MIME parser via the local_action_map */ @@ -209,12 +205,8 @@ icalcomponent* icalmime_parse(char* (*get_string)(char *s, size_t size, } if(parts[i].header.error!=SSPM_NO_ERROR){ - char *str = "Unknown error"; - char temp[256]; - - if(parts[i].header.error==SSPM_MALFORMED_HEADER_ERROR){ - str = "Malformed header, possibly due to input not in MIME format"; - } + char *str; + char* temp[256]; if(parts[i].header.error==SSPM_UNEXPECTED_BOUNDARY_ERROR){ str = "Got an unexpected boundary, possibly due to a MIME header for a MULTIPART part that is missing the Content-Type line"; @@ -235,16 +227,16 @@ line between the header and the previous boundary\?"; } if(parts[i].header.error_text != 0){ - snprintf(temp,sizeof(temp), + snprintf((char*)temp,256, "%s: %s",str,parts[i].header.error_text); } else { - strcpy(temp,str); + strcpy((char*)temp,str); } icalcomponent_add_property (comp, icalproperty_vanew_xlicerror( - temp, + (char*)temp, icalparameter_new_xlicerrortype( ICAL_XLICERRORTYPE_MIMEPARSEERROR), 0)); diff --git a/libical/src/libical/icalperiod.h b/libical/src/libical/icalperiod.h index 5f07dd4a88..64d53237ad 100644 --- a/libical/src/libical/icalperiod.h +++ b/libical/src/libical/icalperiod.h @@ -42,12 +42,12 @@ struct icalperiodtype struct icalperiodtype icalperiodtype_from_string (const char* str); const char* icalperiodtype_as_ical_string(struct icalperiodtype p); +struct icalperiodtype icalperiodtype_null_period(); +int icalperiodtype_is_null_period(struct icalperiodtype p); +int icalperiodtype_is_valid_period(struct icalperiodtype p); -struct icalperiodtype icalperiodtype_null_period(void); -int icalperiodtype_is_null_period(struct icalperiodtype p); -int icalperiodtype_is_valid_period(struct icalperiodtype p); #endif /* !ICALTIME_H */ diff --git a/libical/src/libical/icalrecur.h b/libical/src/libical/icalrecur.h index 45bdd21b65..5fcdc15a8c 100644 --- a/libical/src/libical/icalrecur.h +++ b/libical/src/libical/icalrecur.h @@ -16,17 +16,10 @@ The Mozilla Public License Version 1.0. You may obtain a copy of the License at http://www.mozilla.org/MPL/ -*/ - -/** -@file icalrecur.h -@brief Routines for dealing with recurring time How to use: 1) Get a rule and a start time from a component - -@code icalproperty rrule; struct icalrecurrencetype recur; struct icaltimetype dtstart; @@ -34,36 +27,26 @@ How to use: rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); recur = icalproperty_get_rrule(rrule); start = icalproperty_get_dtstart(dtstart); -@endcode Or, just make them up: - -@code recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); dtstart = icaltime_from_string("19970101T123000") -@endcode 2) Create an iterator - -@code icalrecur_iterator* ritr; ritr = icalrecur_iterator_new(recur,start); -@endcode 3) Iterator over the occurrences - -@code struct icaltimetype next; while (next = icalrecur_iterator_next(ritr) && !icaltime_is_null_time(next){ Do something with next } -@endcode Note that that the time returned by icalrecur_iterator_next is in whatever timezone that dtstart is in. -*/ +======================================================================*/ #ifndef ICALRECUR_H #define ICALRECUR_H @@ -71,9 +54,9 @@ whatever timezone that dtstart is in. #include <time.h> #include "icaltime.h" -/* +/*********************************************************************** * Recurrance enumerations - */ +**********************************************************************/ typedef enum icalrecurrencetype_frequency { @@ -110,9 +93,7 @@ enum { -/** - * Recurrence type routines - */ +/********************** Recurrence type routines **************/ /* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of the values and fields in struct icalrecurrencetype */ @@ -127,7 +108,7 @@ enum { #define ICAL_BY_MONTH_SIZE 13 #define ICAL_BY_SETPOS_SIZE 367 -/** Main struct for holding digested recurrence rules */ +/* Main struct for holding digested recurrence rules */ struct icalrecurrencetype { icalrecurrencetype_frequency freq; @@ -164,50 +145,43 @@ struct icalrecurrencetype void icalrecurrencetype_clear(struct icalrecurrencetype *r); -/** - * Array Encoding - * - * The 'day' element of the by_day array is encoded to allow - * representation of both the day of the week ( Monday, Tueday), but also - * the Nth day of the week ( First tuesday of the month, last thursday of - * the year) These routines decode the day values - */ +/* The 'day' element of the by_day array is encoded to allow +representation of both the day of the week ( Monday, Tueday), but also +the Nth day of the week ( First tuesday of the month, last thursday of +the year) These routines decode the day values */ -/** 1 == Monday, etc. */ +/* 1 == Monday, etc. */ enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); -/** 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ -int icalrecurrencetype_day_position(short day); +/* 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ +short icalrecurrencetype_day_position(short day); -icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str); -/** Recurrance rule parser */ +/*********************************************************************** + * Recurrance rule parser +**********************************************************************/ -/** Convert between strings and recurrencetype structures. */ +/* Convert between strings ans recurrencetype structures. */ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); -/** Recurrence iteration routines */ +/********** recurrence iteration routines ********************/ -typedef struct icalrecur_iterator_impl icalrecur_iterator; +typedef void icalrecur_iterator; -/** Create a new recurrence rule iterator */ +/* Create a new recurrence rule iterator */ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, struct icaltimetype dtstart); -/** Get the next occurrence from an iterator */ +/* Get the next occurrence from an iterator */ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); -void icalrecur_iterator_decrement_count(icalrecur_iterator*); - -/** Free the iterator */ +/* Free the iterator */ void icalrecur_iterator_free(icalrecur_iterator*); -/** - * Fills array up with at most 'count' time_t values, each - * representing an occurrence time in seconds past the POSIX epoch - */ +/* Fills array up with at most 'count' time_t values, each + representing an occurrence time in seconds past the POSIX epoch */ int icalrecur_expand_recurrence(char* rule, time_t start, int count, time_t* array); diff --git a/libical/src/libical/icalrestriction.c.in b/libical/src/libical/icalrestriction.c.in index 05cdc9d413..454442531f 100644 --- a/libical/src/libical/icalrestriction.c.in +++ b/libical/src/libical/icalrestriction.c.in @@ -19,11 +19,6 @@ #define TMP_BUF_SIZE 1024 -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - /* Define the structs for the restrictions. these data are filled out in machine generated code below */ @@ -66,7 +61,7 @@ icalrestriction_property_record null_prop_record = {ICAL_METHOD_NONE,ICAL_NO_C icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0}; -/** The each row gives the result of comparing a restriction against a +/* The each row gives the result of comparing a restriction against a count. The columns in each row represent 0,1,2+. '-1' indicates 'invalid, 'don't care' or 'needs more analysis' So, for ICAL_RESTRICTION_ONE, if there is 1 of a property with that @@ -224,7 +219,7 @@ char* icalrestriction_must_have_duration(icalrestriction_property_record *rec, if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){ - return "Failed iTIP restrictions. This component must have a DURATION property"; + return "Failed iTIP restrictions for STATUS property. This component must have a DURATION property"; } @@ -235,7 +230,7 @@ char* icalrestriction_must_have_repeat(icalrestriction_property_record *rec, icalproperty* prop){ if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){ - return "Failed iTIP restrictions. This component must have a REPEAT property"; + return "Failed iTIP restrictions for STATUS property. This component must have a REPEAT property"; } @@ -252,9 +247,9 @@ char* icalrestriction_no_dtend(icalrestriction_property_record *rec, icalcomponent* comp, icalproperty* prop){ - if( icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){ + if( !icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){ - return "Failed iTIP restrictions. The component must not have both DURATION and DTEND"; + return "Failed iTIP restrictions for STATUS property. The component must not have both DURATION and DTEND"; } @@ -267,21 +262,7 @@ char* icalrestriction_no_duration(icalrestriction_property_record *rec, /* _no_dtend takes care of this one */ return 0; } -char* icalrestriction_must_be_email( - icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_status stat = icalproperty_get_action(prop); - if( !( stat == ICAL_ACTION_EMAIL)){ - - return "Failed iTIP restrictions for ACTION property. Value must be EMAIL."; - - } - - return 0; -} int icalrestriction_check_component(icalproperty_method method, icalcomponent* comp) @@ -290,6 +271,7 @@ int icalrestriction_check_component(icalproperty_method method, icalcomponent_kind comp_kind; icalrestriction_kind restr; icalrestriction_property_record *prop_record; + icalrestriction_component_record *comp_record; char* funcr = 0; icalproperty *prop; diff --git a/libical/src/libical/sspm.c b/libical/src/libical/sspm.c index c6647d37af..311747c8f5 100644 --- a/libical/src/libical/sspm.c +++ b/libical/src/libical/sspm.c @@ -45,11 +45,6 @@ #include "dmalloc.h" #endif -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - #define TMP_BUF_SIZE 1024 @@ -90,7 +85,7 @@ char* sspm_strdup(char* str){ } -static struct major_content_type_map +struct major_content_type_map { enum sspm_major_type type; char* str; @@ -109,7 +104,7 @@ static struct major_content_type_map {SSPM_UNKNOWN_MAJOR_TYPE,"" }, }; -static struct minor_content_type_map +struct minor_content_type_map { enum sspm_minor_type type; char* str; @@ -238,7 +233,7 @@ char* sspm_value(char* line) } -static char *mime_headers[] = { +char *mime_headers[] = { "Content-Type", "Content-Transfer-Encoding", "Content-Disposition", @@ -363,7 +358,7 @@ enum line_type { }; -static enum line_type get_line_type(char* line){ +enum line_type get_line_type(char* line){ if (line == 0){ return EMPTY; @@ -387,7 +382,7 @@ static enum line_type get_line_type(char* line){ } -static struct sspm_action_map get_action(struct mime_impl *impl, +struct sspm_action_map get_action(struct mime_impl *impl, enum sspm_major_type major, enum sspm_minor_type minor) { @@ -953,8 +948,7 @@ void sspm_read_header(struct mime_impl *impl,struct sspm_header *header) assert(strlen(buf) < BUF_SIZE); - strncpy(header_lines[current_line],buf,BUF_SIZE-1); - header_lines[current_line][BUF_SIZE-1] = '\0'; + strcpy(header_lines[current_line],buf); break; } @@ -989,7 +983,7 @@ void sspm_read_header(struct mime_impl *impl,struct sspm_header *header) assert( strlen(buf_start) + strlen(last_line) < BUF_SIZE); - strncat(last_line,buf_start,BUF_SIZE-strlen(last_line)-1); + strcat(last_line,buf_start); break; } @@ -1169,7 +1163,7 @@ char *decode_base64(char *dest, char *src, size_t *size) { - int cc = 0; + int cc; char buf[4] = {0,0,0,0}; int p = 0; int valid_data = 0; diff --git a/libical/src/libical/vsnprintf.c b/libical/src/libical/vsnprintf.c index 982920b21c..6339183dd4 100644 --- a/libical/src/libical/vsnprintf.c +++ b/libical/src/libical/vsnprintf.c @@ -1,7 +1,4 @@ -#ifndef WIN32 -#include "config.h" -#endif -#ifndef HAVE_SNPRINTF +#ifdef __osf__ /* * Revision 12: http://theos.com/~deraadt/snprintf.c * @@ -28,14 +25,12 @@ * 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 <sys/mman.h> #include <signal.h> #include <stdio.h> +#include <unistd.h> #include <string.h> #if __STDC__ #include <stdarg.h> diff --git a/libical/src/libicalss/.cvsignore b/libical/src/libicalss/.cvsignore index 25846dfca6..04a3e1b036 100644 --- a/libical/src/libicalss/.cvsignore +++ b/libical/src/libicalss/.cvsignore @@ -1,6 +1,10 @@ Makefile .deps -.libs +Makefile.in *.lo *.la +.libs +y.output +icalsslexer.c +icalssyacc.c icalss.h diff --git a/libical/src/libicalss/Makefile.am b/libical/src/libicalss/Makefile.am index 359b1f029a..9e11bc3fc8 100644 --- a/libical/src/libicalss/Makefile.am +++ b/libical/src/libicalss/Makefile.am @@ -1,89 +1,26 @@ -#====================================================================== -# FILE: Makefile.am -# CREATOR: eric -# -# $Id: Makefile.am,v 1.20 2003/09/22 07:32:31 hansp Exp $ -# -# -# (C) COPYRIGHT 2000, Eric Busboom, 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/ -# -# -# -#====================================================================== +lib_LTLIBRARIES = libicalss.la - -AM_YFLAGS =-d -v -p ss -AM_LFLAGS = -Pss +YFLAGS =-d -v -p ss +LFLAGS = -Pss LEX_OUTPUT_ROOT = lex.ss all: icalss.h -# just to get it built -$(srcdir)/icalgauge.c: icalssyacc.h -$(srcdir)/icalsslexer.c: icalssyacc.h - - -if WITH_BDB4 -BDB_INCLUDE=-I@BDB_DIR_INCLUDE@ -DWITH_BDB4 -BDB_SOURCEFILES=icalbdbset.c icalbdbset.h icalbdbsetimpl.h -BDB_HEADERFILES=$(srcdir)/icalbdbset.h -libicalssinclude_BDBHEADERS=icalbdbset.h icalbdbsetimpl.h -BDB_LIBFILES=@BDB_DIR_LIB@/@BDB_LIB@ -else -BDB_INCLUDE= -BDB_SOURCEFILES= -BDB_HEADERFILES= -endif - -if WITH_CXX_BINDINGS -cxx_lib=libicalss-evolution_cxx.la -cxx_headers=icalspanlist_cxx.h -else -cxx_lib= -cxx_headers= -endif - -privlib_LTLIBRARIES = libicalss-evolution.la $(cxx_lib) - INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/src \ -I$(top_srcdir)/src/libical \ - -I$(top_builddir)/libical \ - $(BDB_INCLUDE) + -I$(top_builddir)/src/libical -libicalss_evolution_la_LDFLAGS = -version-info 0:0:0 -libicalss_evolution_la_LIBADD = $(BDB_LIBFILES) +libicalss_la_LDFLAGS = -version-info 0:0:0 -if DEV -libicalss_evolution_la_DEVSOURCES = icalsslexer.l icalssyacc.y -else -libicalss_evolution_la_DEVSOURCES = icalsslexer.c icalssyacc.c -endif - -libicalss_evolution_la_SOURCES = \ - icalcalendar.c \ +libicalss_la_SOURCES = \ icalcalendar.h \ icalclassify.c \ icalclassify.h \ - icalcluster.c \ - icalcluster.h \ - icalclusterimpl.h \ icalgauge.c \ icalgauge.h \ icalgaugeimpl.h \ - icaldirset.c \ icaldirset.h \ icaldirsetimpl.h \ icalfileset.c \ @@ -91,58 +28,42 @@ libicalss_evolution_la_SOURCES = \ icalfilesetimpl.h \ icalset.c \ icalset.h \ + icalsslexer.l \ icalssyacc.h \ + icalssyacc.y \ icalspanlist.c \ icalspanlist.h \ icalmessage.c \ icalmessage.h \ - $(BDB_SOURCEFILES) \ - $(libicalss_evolution_la_DEVSOURCES) + icalcstpclient.c \ + icalcstpclient.h \ + icalcstpserver.c \ + icalcstpserver.h \ + icalcstp.c \ + icalcstp.h -libicalssincludedir = $(privincludedir)/libical +libicalssincludedir = $(includedir) COMBINEDHEADERS = \ $(srcdir)/icalgauge.h \ $(srcdir)/icalset.h \ - $(srcdir)/icalcluster.h \ $(srcdir)/icalfileset.h \ $(srcdir)/icaldirset.h \ - $(BDB_HEADERFILES) \ $(srcdir)/icalcalendar.h \ $(srcdir)/icalclassify.h \ $(srcdir)/icalspanlist.h \ - $(srcdir)/icalmessage.h + $(srcdir)/icalmessage.h \ + $(srcdir)/icalcstp.h \ + $(srcdir)/icalcstpclient.h \ + $(srcdir)/icalcstpserver.h icalss.h: $(COMBINEDHEADERS) - echo '#ifdef __cplusplus' > icalss.h - echo 'extern "C" {' >> icalss.h - echo '#endif' >> icalss.h - echo '/*' >> icalss.h - echo ' $$''Id''$$' >> icalss.h - echo '*/' >> icalss.h - cat $(COMBINEDHEADERS) \ - | egrep -v "#include.*\"ical" \ - | egrep -v "#include.*\"pvl\.h\"" \ - | egrep -v '\$$(Id|Locker): .+\$$'>> icalss.h - echo '#ifdef __cplusplus' >> icalss.h - echo '};' >> icalss.h - echo '#endif' >> icalss.h - - -if WITH_CXX_BINDINGS -libicalss_evolution_cxx_la_SOURCES = \ - $(libicalss_evolution_la_SOURCES) \ - icalspanlist_cxx.h \ - icalspanlist_cxx.cpp - -# c++ needs ical.h auto-generated. -icalspanlist_cxx.lo: icalss.h - -endif + cat $(COMBINEDHEADERS) | egrep -v "#include.*\"ical" \ + | egrep -v "#include.*\"pvl\.h\"" > icalss.h -libicalssinclude_HEADERS = icalss.h icalcalendar.h icalclassify.h icalcluster.h icaldirset.h icaldirsetimpl.h icalfileset.h icalfilesetimpl.h icalgauge.h icalgaugeimpl.h icalmessage.h icalset.h icalspanlist.h icalssyacc.h $(libicalssinclude_BDBHEADERS) $(cxx_headers) +libicalssinclude_HEADERS = icalss.h CONFIG_CLEAN_FILES = y.output diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c index 1f24f88db6..e63b5330ad 100644 --- a/libical/src/libicalss/icalcalendar.c +++ b/libical/src/libicalss/icalcalendar.c @@ -34,16 +34,7 @@ #include <sys/stat.h> /* For mkdir, stat */ #include <sys/types.h> /* For mkdir */ #include <fcntl.h> /* For mkdir */ - -#ifndef WIN32 #include <unistd.h> /* For mkdir, stat */ -#endif - -#ifndef PATH_MAX -#define PATH_MAX 512 -#endif - - #include <stdlib.h> /* for malloc */ #include <string.h> /* for strcat */ #include <errno.h> @@ -56,13 +47,13 @@ struct icalcalendar_impl { char* dir; - icalset* freebusy; - icalset* properties; + icalcomponent* freebusy; + icalcomponent* properties; icalset* booked; icalset* incoming; }; -struct icalcalendar_impl* icalcalendar_new_impl(void) +struct icalcalendar_impl* icalcalendar_new_impl() { struct icalcalendar_impl* impl; @@ -128,26 +119,29 @@ icalcalendar* icalcalendar_new(char* dir) return impl; } -void icalcalendar_free(icalcalendar* impl) +void icalcalendar_free(icalcalendar* calendar) { + + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; + if (impl->dir !=0){ free(impl->dir); } if (impl->freebusy !=0){ - icalset_free(impl->booked); + icalfileset_free(impl->freebusy); } if (impl->properties !=0){ - icalset_free(impl->properties); + icalfileset_free(impl->properties); } if (impl->booked !=0){ - icalset_free(impl->booked); + icaldirset_free(impl->booked); } if (impl->incoming !=0){ - icalset_free(impl->incoming); + icaldirset_free(impl->incoming); } impl->dir = 0; @@ -161,32 +155,37 @@ void icalcalendar_free(icalcalendar* impl) } -int icalcalendar_lock(icalcalendar* impl) +int icalcalendar_lock(icalcalendar* calendar) { + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); return 0; } -int icalcalendar_unlock(icalcalendar* impl) +int icalcalendar_unlock(icalcalendar* calendar) { + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); return 0; } -int icalcalendar_islocked(icalcalendar* impl) +int icalcalendar_islocked(icalcalendar* calendar) { + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); return 0; } -int icalcalendar_ownlock(icalcalendar* impl) +int icalcalendar_ownlock(icalcalendar* calendar) { + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); return 0; } -icalset* icalcalendar_get_booked(icalcalendar* impl) +icalset* icalcalendar_get_booked(icalcalendar* calendar) { + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; char dir[PATH_MAX]; icalerror_check_arg_rz((impl != 0),"impl"); @@ -206,9 +205,10 @@ icalset* icalcalendar_get_booked(icalcalendar* impl) } -icalset* icalcalendar_get_incoming(icalcalendar* impl) +icalset* icalcalendar_get_incoming(icalcalendar* calendar) { char path[PATH_MAX]; + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; @@ -223,9 +223,10 @@ icalset* icalcalendar_get_incoming(icalcalendar* impl) return impl->properties; } -icalset* icalcalendar_get_properties(icalcalendar* impl) +icalset* icalcalendar_get_properties(icalcalendar* calendar) { char path[PATH_MAX]; + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; @@ -240,9 +241,10 @@ icalset* icalcalendar_get_properties(icalcalendar* impl) return impl->properties; } -icalset* icalcalendar_get_freebusy(icalcalendar* impl) +icalset* icalcalendar_get_freebusy(icalcalendar* calendar) { char path[PATH_MAX]; + struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; icalerror_check_arg_rz((impl != 0),"impl"); path[0] = '\0'; diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h index 2a0c15196a..f07457c60d 100644 --- a/libical/src/libicalss/icalcalendar.h +++ b/libical/src/libicalss/icalcalendar.h @@ -38,7 +38,7 @@ * components. It also has interfaces to access the free/busy list * and a list of calendar properties */ -typedef struct icalcalendar_impl icalcalendar; +typedef void icalcalendar; icalcalendar* icalcalendar_new(char* dir); diff --git a/libical/src/libicalss/icalcluster.c b/libical/src/libicalss/icalcluster.c deleted file mode 100644 index 6d11078a72..0000000000 --- a/libical/src/libicalss/icalcluster.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalcluster.c - CREATOR: acampi 13 March 2002 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2002, Eric Busboom, 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/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - - -/** - * - * icalcluster is an utility class design to manage clusters of - * icalcomponents on behalf of an implementation of icalset. This is - * done in order to split out common behavior different classes might - * need. - * The definition of what exactly a cluster will contain depends on the - * icalset subclass. At the basic level, an icluster is just a tuple, - * with anything as key and an icalcomponent as value. - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> - -#if 0 -#include <errno.h> -#include <sys/stat.h> /* for stat */ -#ifndef WIN32 -#include <unistd.h> /* for stat, getpid */ -#else -#include <io.h> -#include <share.h> -#endif -#include <fcntl.h> /* for fcntl */ -#endif - -#include "icalcluster.h" -#include "icalclusterimpl.h" -#include "icalgauge.h" - -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - - -icalcluster * icalcluster_new_impl(void) { - - struct icalcluster_impl* impl; - - if ((impl = (struct icalcluster_impl*)malloc( - sizeof(struct icalcluster_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(impl, 0, sizeof(struct icalcluster_impl)); - strcpy(impl->id,ICALCLUSTER_ID); - - return impl; -} - -/** - * Create a cluster with a key/value pair. - * - * @todo Always do a deep copy. - */ - -icalcluster * icalcluster_new(const char* key, icalcomponent *data) { - struct icalcluster_impl *impl = icalcluster_new_impl(); - assert(impl->data == 0); - - impl->key = strdup(key); - impl->changed = 0; - impl->data = 0; - - if (data != NULL) { - if (icalcomponent_isa(data) != ICAL_XROOT_COMPONENT) { - impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT); - icalcomponent_add_component(impl->data, data); - } else { - impl->data = icalcomponent_new_clone(data); - } - } else { - impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT); - } - - return impl; -} - -/** - * Deep clone an icalcluster to a new one - */ - -icalcluster *icalcluster_new_clone(const icalcluster *data) { - struct icalcluster_impl *old = (struct icalcluster_impl *)data; - struct icalcluster_impl *impl = icalcluster_new_impl(); - - impl->key = strdup(old->key); - impl->data = icalcomponent_new_clone(old->data); - impl->changed = 0; - - return impl; -} - - -void icalcluster_free(icalcluster *impl) { - icalerror_check_arg_rv((impl!=0),"cluster"); - - if (impl->key != 0){ - free(impl->key); - impl->key = 0; - } - - if (impl->data != 0){ - icalcomponent_free(impl->data); - impl->data = 0; - } - - free(impl); -} - - -const char *icalcluster_key(icalcluster *impl) { - icalerror_check_arg_rz((impl!=0),"cluster"); - - return impl->key; -} - - -int icalcluster_is_changed(icalcluster *impl) { - icalerror_check_arg_rz((impl!=0),"cluster"); - - return impl->changed; -} - - -void icalcluster_mark(icalcluster *impl) { - icalerror_check_arg_rv((impl!=0),"cluster"); - - impl->changed = 1; -} - - -void icalcluster_commit(icalcluster *impl) { - icalerror_check_arg_rv((impl!=0),"cluster"); - - impl->changed = 0; -} - - -icalcomponent *icalcluster_get_component(icalcluster *impl) { - - icalerror_check_arg_rz((impl!=0),"cluster"); - - if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) { - icalerror_warn("The top component is not an XROOT"); - fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data)); - abort(); - } - - return impl->data; -} - - -icalerrorenum icalcluster_add_component(icalcluster *impl, icalcomponent* child) { - - icalerror_check_arg_re((impl!=0),"cluster", ICAL_BADARG_ERROR); - icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); - - icalcomponent_add_component(impl->data, child); - icalcluster_mark(impl); - - return ICAL_NO_ERROR; -} - - -icalerrorenum icalcluster_remove_component(icalcluster *impl, icalcomponent* child) { - - icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); - icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); - - icalcomponent_remove_component(impl->data,child); - icalcluster_mark(impl); - - return ICAL_NO_ERROR; -} - - -int icalcluster_count_components(icalcluster *impl, icalcomponent_kind kind) { - - icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); - - return icalcomponent_count_components(impl->data, kind); -} - - -/** Iterate through components **/ -icalcomponent *icalcluster_get_current_component(icalcluster* impl) { - - icalerror_check_arg_rz((impl!=0),"cluster"); - - return icalcomponent_get_current_component(impl->data); -} - - -icalcomponent *icalcluster_get_first_component(icalcluster* impl) { - - icalerror_check_arg_rz((impl!=0),"cluster"); - - return icalcomponent_get_first_component(impl->data, - ICAL_ANY_COMPONENT); -} - - -icalcomponent *icalcluster_get_next_component(icalcluster* impl) { - - icalerror_check_arg_rz((impl!=0),"cluster"); - - return icalcomponent_get_next_component(impl->data, - ICAL_ANY_COMPONENT); -} diff --git a/libical/src/libicalss/icalcluster.h b/libical/src/libicalss/icalcluster.h deleted file mode 100644 index f4eb041b04..0000000000 --- a/libical/src/libicalss/icalcluster.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcluster.h - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, 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/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALCLUSTER_H -#define ICALCLUSTER_H - -#include "ical.h" -#include "icalset.h" - -typedef struct icalcluster_impl icalcluster; - -icalcluster* icalcluster_new(const char *key, icalcomponent *data); -icalcluster* icalcluster_new_clone(const icalcluster *cluster); - -void icalcluster_free(icalcluster *cluster); - -const char* icalcluster_key(icalcluster *cluster); -int icalcluster_is_changed(icalcluster *cluster); -void icalcluster_mark(icalcluster *cluster); -void icalcluster_commit(icalcluster *cluster); - -icalcomponent* icalcluster_get_component(icalcluster* cluster); -int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind); -icalerrorenum icalcluster_add_component(icalcluster* cluster, - icalcomponent* child); -icalerrorenum icalcluster_remove_component(icalcluster* cluster, - icalcomponent* child); - -icalcomponent* icalcluster_get_current_component(icalcluster* cluster); -icalcomponent* icalcluster_get_first_component(icalcluster* cluster); -icalcomponent* icalcluster_get_next_component(icalcluster* cluster); - -#endif /* !ICALCLUSTER_H */ - - - diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c index 4a20fe1978..f5da125459 100644 --- a/libical/src/libicalss/icaldirset.c +++ b/libical/src/libicalss/icaldirset.c @@ -26,10 +26,9 @@ ======================================================================*/ -/** - @file icaldirset.c +/* - @brief icaldirset manages a database of ical components and offers + icaldirset manages a database of ical components and offers interfaces for reading, writting and searching for components. icaldirset groups components in to clusters based on their DTSTAMP @@ -37,13 +36,12 @@ together in a single file. All files in a sotre are kept in a single directory. - The primary interfaces are icaldirset__get_first_component and - icaldirset_get_next_component. These routine iterate through all of - the components in the store, subject to the current gauge. A gauge - is an icalcomponent that is tested against other componets for a - match. If a gauge has been set with icaldirset_select, - icaldirset_first and icaldirset_next will only return componentes - that match the gauge. + The primary interfaces are icaldirset_first and icaldirset_next. These + routine iterate through all of the components in the store, subject + to the current gauge. A gauge is an icalcomponent that is tested + against other componets for a match. If a gauge has been set with + icaldirset_select, icaldirset_first and icaldirset_next will only + return componentes that match the gauge. The Store generated UIDs for all objects that are stored if they do not already have a UID. The UID is the name of the cluster (month & @@ -59,74 +57,64 @@ #include "ical.h" #include "icaldirset.h" +#include "pvl.h" +#include "icalerror.h" +#include "icalparser.h" #include "icaldirset.h" #include "icalfileset.h" #include "icalfilesetimpl.h" -#include "icalcluster.h" #include "icalgauge.h" #include <limits.h> /* For PATH_MAX */ -#ifndef WIN32 -#include <dirent.h> /* for opendir() */ -#include <unistd.h> /* for stat, getpid */ -#include <sys/utsname.h> /* for uname */ -#else -#include <io.h> -#include <process.h> -#endif #include <errno.h> #include <sys/types.h> /* for opendir() */ +#include <dirent.h> /* for opendir() */ #include <sys/stat.h> /* for stat */ +#include <unistd.h> /* for stat, getpid */ #include <time.h> /* for clock() */ #include <stdlib.h> /* for rand(), srand() */ +#include <sys/utsname.h> /* for uname */ #include <string.h> /* for strdup */ #include "icaldirsetimpl.h" -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp - -#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask)) +struct icaldirset_impl* icaldirset_new_impl() +{ + struct icaldirset_impl* impl; -#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR) -#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG) -#endif + if ( ( impl = (struct icaldirset_impl*) + malloc(sizeof(struct icaldirset_impl))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } -/** Default options used when NULL is passed to icalset_new() **/ -icaldirset_options icaldirset_options_default = {O_RDWR|O_CREAT}; + strcpy(impl->id,ICALDIRSET_ID); + return impl; +} -const char* icaldirset_path(icalset* set) +const char* icaldirset_path(icaldirset* cluster) { - icaldirset *dset = (icaldirset*)set; + struct icaldirset_impl *impl = icaldirset_new_impl(); - return dset->dir; -} + return impl->dir; +} -void icaldirset_mark(icalset* set) +void icaldirset_mark(icaldirset* store) { - icaldirset *dset = (icaldirset*)set; + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - icalcluster_mark(dset->cluster); + icalfileset_mark(impl->cluster); } -icalerrorenum icaldirset_commit(icalset* set) +icalerrorenum icaldirset_commit(icaldirset* store) { - icaldirset *dset = (icaldirset*)set; - icalset *fileset; - icalfileset_options options = icalfileset_options_default; + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - options.cluster = dset->cluster; + return icalfileset_commit(impl->cluster); - fileset = icalset_new(ICAL_FILE_SET, icalcluster_key(dset->cluster), &options); - - fileset->commit(fileset); - fileset->free(fileset); - - return ICAL_NO_ERROR; } void icaldirset_lock(const char* dir) @@ -139,22 +127,21 @@ void icaldirset_unlock(const char* dir) } /* Load the contents of the store directory into the store's internal directory list*/ -icalerrorenum icaldirset_read_directory(icaldirset *dset) +icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl) { - char *str; -#ifndef WIN32 struct dirent *de; DIR* dp; + char *str; - dp = opendir(dset->dir); + dp = opendir(impl->dir); - if (dp == 0) { + if ( dp == 0) { icalerror_set_errno(ICAL_FILE_ERROR); return ICAL_FILE_ERROR; } /* clear contents of directory list */ - while((str = pvl_pop(dset->directory))){ + while((str = pvl_pop(impl->directory))){ free(str); } @@ -169,52 +156,24 @@ icalerrorenum icaldirset_read_directory(icaldirset *dset) continue; } - pvl_push(dset->directory, (void*)strdup(de->d_name)); + pvl_push(impl->directory, (void*)strdup(de->d_name)); } closedir(dp); -#else - struct _finddata_t c_file; - long hFile; - - /* Find first .c file in current directory */ - if( (hFile = _findfirst( "*", &c_file )) == -1L ) { - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } else { - while((str = pvl_pop(dset->directory))){ - free(str); - } - - /* load all of the cluster names in the directory list */ - do { - /* Remove known directory names '.' and '..'*/ - if (strcmp(c_file.name,".") == 0 || - strcmp(c_file.name,"..") == 0 ){ - continue; - } - - pvl_push(dset->directory, (void*)strdup(c_file.name)); - } - while ( _findnext( hFile, &c_file ) == 0 ); - - _findclose( hFile ); - } - -#endif return ICAL_NO_ERROR; } - -icalset* icaldirset_init(icalset* set, const char* dir, void* options_in) +icaldirset* icaldirset_new(const char* dir) { - icaldirset *dset = (icaldirset*)set; - icaldirset_options *options = options_in; + struct icaldirset_impl *impl = icaldirset_new_impl(); struct stat sbuf; + if (impl == 0){ + return 0; + } + icalerror_check_arg_rz( (dir!=0), "dir"); - icalerror_check_arg_rz( (set!=0), "set"); if (stat(dir,&sbuf) != 0){ icalerror_set_errno(ICAL_FILE_ERROR); @@ -229,83 +188,68 @@ icalset* icaldirset_init(icalset* set, const char* dir, void* options_in) icaldirset_lock(dir); - dset->dir = (char*)strdup(dir); - dset->options = *options; - dset->directory = pvl_newlist(); - dset->directory_iterator = 0; - dset->gauge = 0; - dset->first_component = 0; - dset->cluster = 0; - - return set; -} - -icalset* icaldirset_new(const char* dir) -{ - return icalset_new(ICAL_DIR_SET, dir, &icaldirset_options_default); -} - - -icalset* icaldirset_new_reader(const char* dir) -{ - icaldirset_options reader_options = icaldirset_options_default; - - reader_options.flags = O_RDONLY; - - return icalset_new(ICAL_DIR_SET, dir, &reader_options); -} + impl = icaldirset_new_impl(); + if (impl ==0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } -icalset* icaldirset_new_writer(const char* dir) -{ - icaldirset_options writer_options = icaldirset_options_default; + impl->directory = pvl_newlist(); + impl->directory_iterator = 0; + impl->dir = (char*)strdup(dir); + impl->gauge = 0; + impl->first_component = 0; + impl->cluster = 0; - writer_options.flags = O_RDWR|O_CREAT; + icaldirset_read_directory(impl); - return icalset_new(ICAL_DIR_SET, dir, &writer_options); + return (icaldirset*) impl; } - -void icaldirset_free(icalset* s) +void icaldirset_free(icaldirset* s) { - icaldirset *dset = (icaldirset*)s; + struct icaldirset_impl *impl = (struct icaldirset_impl*)s; char* str; - icaldirset_unlock(dset->dir); + icaldirset_unlock(impl->dir); - if(dset->dir !=0){ - free(dset->dir); - dset->dir = 0; + if(impl->dir !=0){ + free(impl->dir); } - if(dset->gauge !=0){ - icalgauge_free(dset->gauge); - dset->gauge = 0; + if(impl->gauge !=0){ + icalcomponent_free(impl->gauge); } - if(dset->cluster !=0){ - icalcluster_free(dset->cluster); + if(impl->cluster !=0){ + icalfileset_free(impl->cluster); } - while(dset->directory !=0 && (str=pvl_pop(dset->directory)) != 0){ + while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){ free(str); } - if(dset->directory != 0){ - pvl_free(dset->directory); - dset->directory = 0; + if(impl->directory != 0){ + pvl_free(impl->directory); } - dset->directory_iterator = 0; - dset->first_component = 0; -} + impl->directory = 0; + impl->directory_iterator = 0; + impl->dir = 0; + impl->gauge = 0; + impl->first_component = 0; + free(impl); + +} /* icaldirset_next_uid_number updates a serial number in the Store directory in a file called SEQUENCE */ -int icaldirset_next_uid_number(icaldirset* dset) +int icaldirset_next_uid_number(icaldirset* store) { + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; char sequence = 0; char temp[128]; char filename[ICAL_PATH_MAX]; @@ -313,9 +257,9 @@ int icaldirset_next_uid_number(icaldirset* dset) FILE *f; struct stat sbuf; - icalerror_check_arg_rz( (dset!=0), "dset"); + icalerror_check_arg_rz( (store!=0), "store"); - sprintf(filename,"%s/%s",dset->dir,"SEQUENCE"); + sprintf(filename,"%s/%s",impl->dir,"SEQUENCE"); /* Create the file if it does not exist.*/ if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){ @@ -328,6 +272,7 @@ int icaldirset_next_uid_number(icaldirset* dset) icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); return 0; } + } if ( (f = fopen(filename,"r+")) != 0){ @@ -353,85 +298,85 @@ int icaldirset_next_uid_number(icaldirset* dset) icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); return 0; } + } -icalerrorenum icaldirset_next_cluster(icaldirset* dset) +icalerrorenum icaldirset_next_cluster(icaldirset* store) { + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; char path[ICAL_PATH_MAX]; - if (dset->directory_iterator == 0){ + if (impl->directory_iterator == 0){ icalerror_set_errno(ICAL_INTERNAL_ERROR); return ICAL_INTERNAL_ERROR; } - dset->directory_iterator = pvl_next(dset->directory_iterator); + impl->directory_iterator = pvl_next(impl->directory_iterator); - if (dset->directory_iterator == 0){ + if (impl->directory_iterator == 0){ /* There are no more clusters */ - if(dset->cluster != 0){ - icalcluster_free(dset->cluster); - dset->cluster = 0; + if(impl->cluster != 0){ + icalfileset_free(impl->cluster); + impl->cluster = 0; } return ICAL_NO_ERROR; } - sprintf(path,"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator)); + sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); + + icalfileset_free(impl->cluster); - icalcluster_free(dset->cluster); - dset->cluster = icalfileset_produce_icalcluster(path); + impl->cluster = icalfileset_new(path); return icalerrno; } -static void icaldirset_add_uid(icalcomponent* comp) +void icaldirset_add_uid(icaldirset* store, icaldirset* comp) { char uidstring[ICAL_PATH_MAX]; icalproperty *uid; -#ifndef WIN32 struct utsname unamebuf; -#endif + icalerror_check_arg_rv( (store!=0), "store"); icalerror_check_arg_rv( (comp!=0), "comp"); uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY); if (uid == 0) { -#ifndef WIN32 uname(&unamebuf); sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename); -#else - sprintf(uidstring,"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */ -#endif uid = icalproperty_new_uid(uidstring); icalcomponent_add_property(comp,uid); } else { + strcpy(uidstring,icalproperty_get_uid(uid)); } } -/** - This assumes that the top level component is a VCALENDAR, and there +/* This assumes that the top level component is a VCALENDAR, and there is an inner component of type VEVENT, VTODO or VJOURNAL. The inner - component must have a DSTAMP property -*/ + component must have a DTAMP property */ -icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp) +icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp) { + struct icaldirset_impl *impl; char clustername[ICAL_PATH_MAX]; - icalproperty *dt = 0; + icalproperty *dt; icalvalue *v; struct icaltimetype tm; icalerrorenum error = ICAL_NO_ERROR; icalcomponent *inner; - icaldirset *dset = (icaldirset*) set; - icalerror_check_arg_rz( (dset!=0), "dset"); + impl = (struct icaldirset_impl*)store; + icalerror_check_arg_rz( (store!=0), "store"); icalerror_check_arg_rz( (comp!=0), "comp"); - icaldirset_add_uid(comp); + errno = 0; + + icaldirset_add_uid(store,comp); /* Determine which cluster this object belongs in. This is a HACK */ @@ -441,44 +386,52 @@ icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp) dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); - if (dt != 0) + if (dt != 0){ break; } + } + + if (dt == 0){ - if (dt == 0) { for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); inner != 0; inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); - if (dt != 0) + if (dt != 0){ break; } } + } + if (dt == 0){ + + icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store"); icalerror_set_errno(ICAL_BADARG_ERROR); return ICAL_BADARG_ERROR; } v = icalproperty_get_value(dt); + tm = icalvalue_get_datetime(v); - snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",dset->dir, tm.year, tm.month); + snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month); /* Load the cluster and insert the object */ - if(dset->cluster != 0 && - strcmp(clustername,icalcluster_key(dset->cluster)) != 0 ){ - icalcluster_free(dset->cluster); - dset->cluster = 0; + + if(impl->cluster != 0 && + strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){ + icalfileset_free(impl->cluster); + impl->cluster = 0; } - if (dset->cluster == 0){ - dset->cluster = icalfileset_produce_icalcluster(clustername); + if (impl->cluster == 0){ + impl->cluster = icalfileset_new(clustername); - if (dset->cluster == 0){ + if (impl->cluster == 0){ error = icalerrno; } } @@ -489,31 +442,33 @@ icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp) } /* Add the component to the cluster */ - icalcluster_add_component(dset->cluster,comp); + + icalfileset_add_component(impl->cluster,comp); - /* icalcluster_mark(impl->cluster); */ + icalfileset_mark(impl->cluster); return ICAL_NO_ERROR; } -/** - Remove a component in the current cluster. HACK. This routine is a +/* Remove a component in the current cluster. HACK. This routine is a "friend" of icalfileset, and breaks its encapsulation. It was either do it this way, or add several layers of interfaces that had - no other use. - */ - -icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp) + no other use. */ +icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp) { - icaldirset *dset = (icaldirset*)set; - icalcomponent *filecomp = icalcluster_get_component(dset->cluster); + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; + + struct icalfileset_impl *filesetimpl = + (struct icalfileset_impl*)impl->cluster; + + icalcomponent *filecomp = filesetimpl->cluster; icalcompiter i; int found = 0; - icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR); + icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR); icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR); - icalerror_check_arg_re((dset->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR); + icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR); for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT); icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ @@ -532,16 +487,17 @@ icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp) return ICAL_USAGE_ERROR; } - icalcluster_remove_component(dset->cluster,comp); + icalfileset_remove_component(impl->cluster,comp); - /* icalcluster_mark(impl->cluster); */ + icalfileset_mark(impl->cluster); /* If the removal emptied the fileset, get the next fileset */ - if( icalcluster_count_components(dset->cluster,ICAL_ANY_COMPONENT)==0){ - icalerrorenum error = icaldirset_next_cluster(dset); + if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){ + + icalerrorenum error = icaldirset_next_cluster(store); - if(dset->cluster != 0 && error == ICAL_NO_ERROR){ - icalcluster_get_first_component(dset->cluster); + if(impl->cluster != 0 && error == ICAL_NO_ERROR){ + icalfileset_get_first_component(impl->cluster); } else { /* HACK. Not strictly correct for impl->cluster==0 */ return error; @@ -555,84 +511,95 @@ icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp) -int icaldirset_count_components(icalset* store, +int icaldirset_count_components(icaldirset* store, icalcomponent_kind kind) { /* HACK, not implemented */ + assert(0); return 0; } -icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c) +icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c) { fprintf(stderr," icaldirset_fetch_match is not implemented\n"); assert(0); - return 0; } -icalcomponent* icaldirset_fetch(icalset* set, const char* uid) +icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid) { - icaldirset *dset = (icaldirset*)set; - icalgauge *gauge; - icalgauge *old_gauge; + icalcomponent *gauge; + icalcomponent *old_gauge; icalcomponent *c; - char sql[256]; + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - icalerror_check_arg_rz( (set!=0), "set"); + icalerror_check_arg_rz( (store!=0), "store"); icalerror_check_arg_rz( (uid!=0), "uid"); - snprintf(sql, 256, "SELECT * FROM VEVENT WHERE UID = \"%s\"", uid); - - gauge = icalgauge_new_from_sql(sql, 0); + gauge = + icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_uid( + uid, + icalparameter_new_xliccomparetype( + ICAL_XLICCOMPARETYPE_EQUAL), + 0), + 0), + 0); - old_gauge = dset->gauge; - dset->gauge = gauge; + old_gauge = impl->gauge; + impl->gauge = gauge; - c= icaldirset_get_first_component(set); + c= icaldirset_get_first_component(store); - dset->gauge = old_gauge; + impl->gauge = old_gauge; - icalgauge_free(gauge); + icalcomponent_free(gauge); return c; } -int icaldirset_has_uid(icalset* set, const char* uid) +int icaldirset_has_uid(icaldirset* store, const char* uid) { icalcomponent *c; - icalerror_check_arg_rz( (set!=0), "set"); + icalerror_check_arg_rz( (store!=0), "store"); icalerror_check_arg_rz( (uid!=0), "uid"); /* HACK. This is a temporary implementation. _has_uid should use a database, and _fetch should use _has_uid, not the other way around */ - c = icaldirset_fetch(set,uid); + c = icaldirset_fetch(store,uid); return c!=0; } -icalerrorenum icaldirset_select(icalset* set, icalgauge* gauge) -{ - icaldirset *dset = (icaldirset*)set; +icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge) + { + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - icalerror_check_arg_re( (set!=0), "set",ICAL_BADARG_ERROR); + icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR); icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR); - dset->gauge = gauge; + if (!icalcomponent_is_valid(gauge)){ + return ICAL_BADARG_ERROR; + } + + impl->gauge = gauge; return ICAL_NO_ERROR; } -icalerrorenum icaldirset_modify(icalset* set, - icalcomponent *old, +icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old, icalcomponent *new) { assert(0); @@ -641,7 +608,7 @@ icalerrorenum icaldirset_modify(icalset* set, } -void icaldirset_clear(icalset* set) +void icaldirset_clear(icaldirset* store) { assert(0); @@ -649,58 +616,53 @@ void icaldirset_clear(icalset* set) /* HACK, not implemented */ } -icalcomponent* icaldirset_get_current_component(icalset* set) +icalcomponent* icaldirset_get_current_component(icaldirset* store) { - icaldirset *dset = (icaldirset*)set; + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - if (dset->cluster == 0){ - icaldirset_get_first_component(set); - } - if(dset->cluster == 0){ - return 0; + if(impl->cluster == 0){ + icaldirset_get_first_component(store); } - return icalcluster_get_current_component(dset->cluster); + return icalfileset_get_current_component(impl->cluster); + } -icalcomponent* icaldirset_get_first_component(icalset* set) +icalcomponent* icaldirset_get_first_component(icaldirset* store) { - icaldirset *dset = (icaldirset*)set; - + struct icaldirset_impl *impl = (struct icaldirset_impl*)store; icalerrorenum error; char path[ICAL_PATH_MAX]; - error = icaldirset_read_directory(dset); + error = icaldirset_read_directory(impl); if (error != ICAL_NO_ERROR){ icalerror_set_errno(error); return 0; } - dset->directory_iterator = pvl_head(dset->directory); + impl->directory_iterator = pvl_head(impl->directory); - if (dset->directory_iterator == 0){ + if (impl->directory_iterator == 0){ icalerror_set_errno(error); return 0; } - snprintf(path,ICAL_PATH_MAX,"%s/%s", - dset->dir, - (char*)pvl_data(dset->directory_iterator)); + snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); /* If the next cluster we need is different than the current cluster, delete the current one and get a new one */ - if(dset->cluster != 0 && strcmp(path,icalcluster_key(dset->cluster)) != 0 ){ - icalcluster_free(dset->cluster); - dset->cluster = 0; + if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){ + icalfileset_free(impl->cluster); + impl->cluster = 0; } - if (dset->cluster == 0){ - dset->cluster = icalfileset_produce_icalcluster(path); + if (impl->cluster == 0){ + impl->cluster = icalfileset_new(path); - if (dset->cluster == 0){ + if (impl->cluster == 0){ error = icalerrno; } } @@ -710,22 +672,23 @@ icalcomponent* icaldirset_get_first_component(icalset* set) return 0; } - dset->first_component = 1; + impl->first_component = 1; - return icaldirset_get_next_component(set); + return icaldirset_get_next_component(store); } - -icalcomponent* icaldirset_get_next_component(icalset* set) +icalcomponent* icaldirset_get_next_component(icaldirset* store) { - icaldirset *dset = (icaldirset*)set; + struct icaldirset_impl *impl; icalcomponent *c; icalerrorenum error; - icalerror_check_arg_rz( (set!=0), "set"); + icalerror_check_arg_rz( (store!=0), "store"); + + impl = (struct icaldirset_impl*)store; + if(impl->cluster == 0){ - if(dset->cluster == 0){ icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first"); icalerror_set_errno(ICAL_USAGE_ERROR); return 0; @@ -733,26 +696,30 @@ icalcomponent* icaldirset_get_next_component(icalset* set) } /* Set the component iterator for the following for loop */ - if (dset->first_component == 1){ - icalcluster_get_first_component(dset->cluster); - dset->first_component = 0; + if (impl->first_component == 1){ + icalfileset_get_first_component(impl->cluster); + impl->first_component = 0; } else { - icalcluster_get_next_component(dset->cluster); + icalfileset_get_next_component(impl->cluster); } + while(1){ /* Iterate through all of the objects in the cluster*/ - for( c = icalcluster_get_current_component(dset->cluster); + for( c = icalfileset_get_current_component(impl->cluster); c != 0; - c = icalcluster_get_next_component(dset->cluster)){ + c = icalfileset_get_next_component(impl->cluster)){ /* If there is a gauge defined and the component does not pass the gauge, skip the rest of the loop */ - if (dset->gauge != 0 && icalgauge_compare(dset->gauge,c) == 0){ +#if 0 /* HACK */ + if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){ continue; } - +#else + assert(0); /* icalgauge_test needs to be fixed */ +#endif /* Either there is no gauge, or the component passed the gauge, so return it*/ @@ -762,13 +729,13 @@ icalcomponent* icaldirset_get_next_component(icalset* set) /* Fell through the loop, so the component we want is not in this cluster. Load a new cluster and try again.*/ - error = icaldirset_next_cluster(dset); + error = icaldirset_next_cluster(store); - if(dset->cluster == 0 || error != ICAL_NO_ERROR){ + if(impl->cluster == 0 || error != ICAL_NO_ERROR){ /* No more clusters */ return 0; } else { - c = icalcluster_get_first_component(dset->cluster); + c = icalfileset_get_first_component(impl->cluster); return c; } @@ -778,28 +745,9 @@ icalcomponent* icaldirset_get_next_component(icalset* set) return 0; /* Should never get here */ } -icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge) -{ - icalsetiter itr = icalsetiter_null; - icaldirset *fset = (icaldirset*) set; - - icalerror_check_arg_re((fset!=0), "set", icalsetiter_null); + - itr.iter.kind = kind; - itr.gauge = gauge; - /* TO BE IMPLEMENTED */ - return icalsetiter_null; -} -icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i) -{ - /* TO BE IMPLEMENTED */ - return NULL; -} -icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i) -{ - /* TO BE IMPLEMENTED */ - return NULL; -} + diff --git a/libical/src/libicalss/icalsslexer.c b/libical/src/libicalss/icalsslexer.c deleted file mode 100644 index e5afa81f61..0000000000 --- a/libical/src/libicalss/icalsslexer.c +++ /dev/null @@ -1,1746 +0,0 @@ -#define yy_create_buffer ss_create_buffer -#define yy_delete_buffer ss_delete_buffer -#define yy_scan_buffer ss_scan_buffer -#define yy_scan_string ss_scan_string -#define yy_scan_bytes ss_scan_bytes -#define yy_flex_debug ss_flex_debug -#define yy_init_buffer ss_init_buffer -#define yy_flush_buffer ss_flush_buffer -#define yy_load_buffer_state ss_load_buffer_state -#define yy_switch_to_buffer ss_switch_to_buffer -#define yyin ssin -#define yyleng ssleng -#define yylex sslex -#define yyout ssout -#define yyrestart ssrestart -#define yytext sstext -#define yywrap sswrap - -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include <stdio.h> -#include <unistd.h> - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char yytext[]; - - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - if ( yyleng >= YYLMAX ) \ - YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ - yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 23 -#define YY_END_OF_BUFFER 24 -static yyconst short int yy_accept[56] = - { 0, - 0, 0, 0, 0, 0, 0, 24, 22, 18, 18, - 22, 17, 21, 4, 19, 8, 5, 9, 21, 21, - 21, 21, 21, 21, 21, 18, 7, 0, 21, 10, - 6, 11, 21, 21, 14, 21, 21, 13, 21, 21, - 20, 12, 21, 15, 21, 21, 21, 2, 16, 21, - 21, 21, 3, 1, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 5, 1, 1, 1, 1, 1, 6, 1, - 1, 7, 1, 8, 7, 7, 1, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 9, 10, 11, - 12, 13, 1, 7, 14, 7, 15, 16, 17, 18, - 7, 19, 20, 7, 7, 21, 22, 23, 24, 7, - 7, 25, 26, 27, 28, 7, 29, 7, 7, 7, - 1, 1, 1, 1, 1, 1, 14, 7, 15, 16, - - 17, 18, 7, 19, 20, 7, 7, 21, 22, 23, - 24, 7, 7, 25, 26, 27, 28, 7, 29, 7, - 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[30] = - { 0, - 1, 1, 1, 2, 1, 1, 3, 1, 2, 1, - 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3 - } ; - -static yyconst short int yy_base[58] = - { 0, - 0, 0, 0, 0, 0, 0, 68, 69, 28, 31, - 55, 0, 0, 69, 69, 54, 53, 52, 40, 37, - 35, 12, 35, 42, 39, 35, 69, 51, 0, 69, - 69, 69, 40, 31, 0, 27, 32, 0, 31, 34, - 69, 0, 28, 0, 28, 31, 22, 0, 0, 31, - 28, 17, 0, 0, 69, 39, 40 - } ; - -static yyconst short int yy_def[58] = - { 0, - 55, 1, 1, 1, 1, 1, 55, 55, 55, 55, - 55, 56, 57, 55, 55, 55, 55, 55, 57, 57, - 57, 57, 57, 57, 57, 55, 55, 56, 57, 55, - 55, 55, 57, 57, 57, 57, 57, 57, 57, 57, - 55, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 0, 55, 55 - } ; - -static yyconst short int yy_nxt[99] = - { 0, - 8, 9, 10, 9, 11, 12, 13, 14, 8, 15, - 16, 17, 18, 19, 13, 13, 13, 20, 13, 21, - 13, 13, 22, 23, 13, 24, 13, 13, 25, 26, - 26, 26, 26, 26, 26, 36, 26, 26, 26, 37, - 28, 28, 29, 54, 53, 52, 51, 50, 49, 48, - 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, - 35, 34, 33, 32, 31, 30, 27, 55, 7, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55 - - } ; - -static yyconst short int yy_chk[99] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, - 9, 9, 10, 10, 10, 22, 26, 26, 26, 22, - 56, 56, 57, 52, 51, 50, 47, 46, 45, 43, - 40, 39, 37, 36, 34, 33, 28, 25, 24, 23, - 21, 20, 19, 18, 17, 16, 11, 7, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55 - - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#ifndef YYLMAX -#define YYLMAX 8192 -#endif - -char yytext[YYLMAX]; -char *yytext_ptr; -#line 1 "icalsslexer.l" -#define INITIAL 0 -#line 2 "icalsslexer.l" -/* -*- Mode: C -*- - ====================================================================== - FILE: icalsslexer.l - CREATOR: eric 8 Aug 2000 - - DESCRIPTION: - - $Id$ - $Locker$ - -(C) COPYRIGHT 2000, Eric Busboom, 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/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - ======================================================================*/ - -#include "icalssyacc.h" -#include "icalgaugeimpl.h" -#include "assert.h" - -#include <string.h> /* For strdup() */ - -const char* input_buffer; -const char* input_buffer_p; - -#define min(a,b) ((a) < (b) ? (a) : (b)) - -int icalss_input(char* buf, int max_size) -{ - int n = min(max_size,strlen(input_buffer_p)); - - if (n > 0){ - memcpy(buf, input_buffer_p, n); - input_buffer_p += n; - return n; - } else { - return 0; - } -} - -#undef YY_INPUT -#define YY_INPUT(b,r,ms) ( r= icalss_input(b,ms)) - -#undef SS_FATAL_ERROR -#define SS_FATAL_ERROR(msg) sserror(msg) - -#define sql 1 -#define string_value 2 - -#line 488 "icalsslexer.c" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp = NULL, *yy_bp = NULL; - register int yy_act; - -#line 83 "icalsslexer.l" - - - - - - -#line 646 "icalsslexer.c" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 56 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 69 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 89 "icalsslexer.l" -{ return SELECT; } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 90 "icalsslexer.l" -{ return FROM; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 91 "icalsslexer.l" -{ return WHERE; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 92 "icalsslexer.l" -{ return COMMA; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 93 "icalsslexer.l" -{ return EQUALS; } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 94 "icalsslexer.l" -{ return EQUALS; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 95 "icalsslexer.l" -{ return NOTEQUALS; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 96 "icalsslexer.l" -{ return LESS; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 97 "icalsslexer.l" -{ return GREATER; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 98 "icalsslexer.l" -{ return LESSEQUALS; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 99 "icalsslexer.l" -{ return GREATEREQUALS; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 100 "icalsslexer.l" -{ return AND; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 101 "icalsslexer.l" -{ return OR; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 102 "icalsslexer.l" -{ return IS; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 103 "icalsslexer.l" -{ return NOT; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 104 "icalsslexer.l" -{ return SQLNULL; } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 105 "icalsslexer.l" -{ return QUOTE; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 106 "icalsslexer.l" -; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 107 "icalsslexer.l" -{ return EOL; } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 109 "icalsslexer.l" -{ - int c = input(); - unput(c); - if(c!='\''){ - sslval.v_string= icalmemory_tmp_copy(yytext); - return STRING; - } else { - /*ssmore();*/ - } -} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 120 "icalsslexer.l" -{ - sslval.v_string= icalmemory_tmp_copy(yytext); - return STRING; -} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 126 "icalsslexer.l" -{ return yytext[0]; } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 128 "icalsslexer.l" -ECHO; - YY_BREAK -#line 856 "icalsslexer.c" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(sql): -case YY_STATE_EOF(string_value): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 56 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 56 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 55); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } -#endif /* YY_NO_INPUT */ - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 128 "icalsslexer.l" - - -int yywrap() -{ - return 1; -} - diff --git a/libical/src/libicalss/icalssyacc.c b/libical/src/libicalss/icalssyacc.c deleted file mode 100644 index c2dcc47a24..0000000000 --- a/libical/src/libicalss/icalssyacc.c +++ /dev/null @@ -1,1397 +0,0 @@ -/* A Bison parser, made from /home/hpj/work/cvs/cvs.gnome.org/evolution-trunk/libical/src/libicalss/icalssyacc.y - by GNU bison 1.35. */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define yyparse ssparse -#define yylex sslex -#define yyerror sserror -#define yylval sslval -#define yychar sschar -#define yydebug ssdebug -#define yynerrs ssnerrs -# define STRING 257 -# define SELECT 258 -# define FROM 259 -# define WHERE 260 -# define COMMA 261 -# define QUOTE 262 -# define EQUALS 263 -# define NOTEQUALS 264 -# define LESS 265 -# define GREATER 266 -# define LESSEQUALS 267 -# define GREATEREQUALS 268 -# define AND 269 -# define OR 270 -# define EOL 271 -# define END 272 -# define IS 273 -# define NOT 274 -# define SQLNULL 275 - -#line 1 "icalssyacc.y" - -/* -*- Mode: C -*- - ====================================================================== - FILE: icalssyacc.y - CREATOR: eric 08 Aug 2000 - - DESCRIPTION: - - $Id$ - $Locker$ - -(C) COPYRIGHT 2000, Eric Busboom, 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/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - ======================================================================*/ -/*#define YYDEBUG 1*/ -#include <stdlib.h> -#include <string.h> /* for strdup() */ -#include <limits.h> /* for SHRT_MAX*/ -#include "ical.h" -#include "icalgauge.h" -#include "icalgaugeimpl.h" - -extern struct icalgauge_impl *icalss_yy_gauge; - -#define YYPARSE_PARAM yy_globals -#define YYLEX_PARAM yy_globals -#define YY_EXTRA_TYPE icalgauge_impl* - - -static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, - icalgaugecompare compare , char* value); -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l); -void sserror(char *s); /* Don't know why I need this.... */ - - -#line 53 "icalssyacc.y" -#ifndef YYSTYPE -typedef union { - char* v_string; -} yystype; -# define YYSTYPE yystype -# define YYSTYPE_IS_TRIVIAL 1 -#endif -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - - - -#define YYFINAL 38 -#define YYFLAG -32768 -#define YYNTBASE 22 - -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 27) - -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ -static const char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21 -}; - -#if YYDEBUG -static const short yyprhs[] = -{ - 0, 0, 7, 12, 14, 16, 20, 22, 26, 27, - 31, 35, 40, 44, 48, 52, 56, 60, 62, 66 -}; -static const short yyrhs[] = -{ - 4, 23, 5, 24, 6, 26, 0, 4, 23, 5, - 24, 0, 1, 0, 3, 0, 23, 7, 3, 0, - 3, 0, 24, 7, 3, 0, 0, 3, 9, 3, - 0, 3, 19, 21, 0, 3, 19, 20, 21, 0, - 3, 10, 3, 0, 3, 11, 3, 0, 3, 12, - 3, 0, 3, 13, 3, 0, 3, 14, 3, 0, - 25, 0, 26, 15, 25, 0, 26, 16, 25, 0 -}; - -#endif - -#if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const short yyrline[] = -{ - 0, 64, 65, 66, 72, 74, 78, 80, 83, 85, - 86, 87, 88, 89, 90, 91, 92, 95, 97, 98 -}; -#endif - - -#if (YYDEBUG) || defined YYERROR_VERBOSE - -/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ -static const char *const yytname[] = -{ - "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA", - "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS", - "GREATEREQUALS", "AND", "OR", "EOL", "END", "IS", "NOT", "SQLNULL", - "query_min", "select_list", "from_list", "where_clause", "where_list", 0 -}; -#endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const short yyr1[] = -{ - 0, 22, 22, 22, 23, 23, 24, 24, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 26, 26, 26 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const short yyr2[] = -{ - 0, 6, 4, 1, 1, 3, 1, 3, 0, 3, - 3, 4, 3, 3, 3, 3, 3, 1, 3, 3 -}; - -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -static const short yydefact[] = -{ - 0, 3, 0, 4, 0, 0, 0, 6, 2, 5, - 8, 0, 0, 17, 1, 7, 0, 0, 0, 0, - 0, 0, 0, 8, 8, 9, 12, 13, 14, 15, - 16, 0, 10, 18, 19, 11, 0, 0, 0 -}; - -static const short yydefgoto[] = -{ - 36, 4, 8, 13, 14 -}; - -static const short yypact[] = -{ - 5,-32768, 9,-32768, 6, 17, 18,-32768, 1,-32768, - 19, 20, -9,-32768, -1,-32768, 21, 22, 23, 24, - 25, 26, -4, 19, 19,-32768,-32768,-32768,-32768,-32768, - -32768, 10,-32768,-32768,-32768,-32768, 30, 32,-32768 -}; - -static const short yypgoto[] = -{ - -32768,-32768,-32768, -5,-32768 -}; - - -#define YYLAST 32 - - -static const short yytable[] = -{ - 16, 17, 18, 19, 20, 21, 1, 10, 11, 2, - 22, 5, 3, 6, 23, 24, 31, 32, 33, 34, - 7, 9, 12, 15, 25, 26, 27, 28, 29, 30, - 37, 35, 38 -}; - -static const short yycheck[] = -{ - 9, 10, 11, 12, 13, 14, 1, 6, 7, 4, - 19, 5, 3, 7, 15, 16, 20, 21, 23, 24, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 0, 21, 0 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison/bison.simple" - -/* Skeleton output parser for bison, - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser when - the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; -# if YYLSP_NEEDED - YYLTYPE yyls; -# endif -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAX) -# else -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) -# endif - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up"); \ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). - - When YYLLOC_DEFAULT is run, CURRENT is set the location of the - first token. By default, to implement support for ranges, extend - its range to the last symbol. */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#if YYPURE -# if YYLSP_NEEDED -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval, &yylloc) -# endif -# else /* !YYLSP_NEEDED */ -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval) -# endif -# endif /* !YYLSP_NEEDED */ -#else /* !YYPURE */ -# define YYLEX yylex () -#endif /* !YYPURE */ - - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -#endif /* !YYDEBUG */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - -#ifdef YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif -#endif - -#line 315 "/usr/share/bison/bison.simple" - - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL -# else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -# endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else -int yyparse (void); -# endif -#endif - -/* YY_DECL_VARIABLES -- depending whether we use a pure parser, - variables are global, or local to YYPARSE. */ - -#define YY_DECL_NON_LSP_VARIABLES \ -/* The lookahead symbol. */ \ -int yychar; \ - \ -/* The semantic value of the lookahead symbol. */ \ -YYSTYPE yylval; \ - \ -/* Number of parse errors so far. */ \ -int yynerrs; - -#if YYLSP_NEEDED -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES \ - \ -/* Location data for the lookahead symbol. */ \ -YYLTYPE yylloc; -#else -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES -#endif - - -/* If nonreentrant, generate the variables here. */ - -#if !YYPURE -YY_DECL_VARIABLES -#endif /* !YYPURE */ - -int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - /* If reentrant, generate the variables here. */ -#if YYPURE - YY_DECL_VARIABLES -#endif /* !YYPURE */ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - -#if YYLSP_NEEDED - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#endif - -#if YYLSP_NEEDED -# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -# define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - YYSIZE_T yystacksize = YYINITDEPTH; - - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; -#if YYLSP_NEEDED - YYLTYPE yyloc; -#endif - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; -#if YYLSP_NEEDED - yylsp = yyls; -#endif - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ -# if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - yyls = yyls1; -# else - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); -# endif - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - goto yyoverflowlab; - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED - YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; -#if YYLSP_NEEDED - yylsp = yyls + yysize - 1; -#endif - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yychar1 = YYTRANSLATE (yychar); - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - YYFPRINTF (stderr, "Next token is %d (%s", - yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise - meaning of a token, for further debugging info. */ -# ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -# endif - YYFPRINTF (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to the semantic value of - the lookahead token. This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - -#if YYLSP_NEEDED - /* Similarly for the default location. Let the user run additional - commands if for instance locations are ranges. */ - yyloc = yylsp[1-yylen]; - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); -#endif - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - switch (yyn) { - -case 3: -#line 66 "icalssyacc.y" -{ - yyclearin; - YYABORT; - } - break; -case 4: -#line 73 "icalssyacc.y" -{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);} - break; -case 5: -#line 74 "icalssyacc.y" -{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);} - break; -case 6: -#line 79 "icalssyacc.y" -{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} - break; -case 7: -#line 80 "icalssyacc.y" -{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} - break; -case 9: -#line 85 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); } - break; -case 10: -#line 86 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_ISNULL,""); } - break; -case 11: -#line 87 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-3].v_string,ICALGAUGECOMPARE_ISNOTNULL,""); } - break; -case 12: -#line 88 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); } - break; -case 13: -#line 89 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); } - break; -case 14: -#line 90 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); } - break; -case 15: -#line 91 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); } - break; -case 16: -#line 92 "icalssyacc.y" -{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); } - break; -case 17: -#line 96 "icalssyacc.y" -{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);} - break; -case 18: -#line 97 "icalssyacc.y" -{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);} - break; -case 19: -#line 98 "icalssyacc.y" -{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} - break; -} - -#line 705 "/usr/share/bison/bison.simple" - - - yyvsp -= yylen; - yyssp -= yylen; -#if YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; -#if YYLSP_NEEDED - *++yylsp = yyloc; -#endif - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("parse error; also virtual memory exhausted"); - } - else -#endif /* defined (YYERROR_VERBOSE) */ - yyerror ("parse error"); - } - goto yyerrlab1; - - -/*--------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action | -`--------------------------------------------------*/ -yyerrlab1: - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - - -/*-------------------------------------------------------------------. -| yyerrdefault -- current state does not do anything special for the | -| error token. | -`-------------------------------------------------------------------*/ -yyerrdefault: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - - /* If its default is to accept any token, ok. Otherwise pop it. */ - yyn = yydefact[yystate]; - if (yyn) - goto yydefault; -#endif - - -/*---------------------------------------------------------------. -| yyerrpop -- pop the current state because it cannot handle the | -| error token | -`---------------------------------------------------------------*/ -yyerrpop: - if (yyssp == yyss) - YYABORT; - yyvsp--; - yystate = *--yyssp; -#if YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - -/*--------------. -| yyerrhandle. | -`--------------*/ -yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -/*---------------------------------------------. -| yyoverflowab -- parser overflow comes here. | -`---------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} -#line 102 "icalssyacc.y" - - -static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, - icalgaugecompare compare , char* value_str) -{ - - struct icalgauge_where *where; - char *compstr, *propstr, *c, *s,*l; - - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - memset(where,0,sizeof(struct icalgauge_where)); - where->logic = ICALGAUGELOGIC_NONE; - where->compare = ICALGAUGECOMPARE_NONE; - where->comp = ICAL_NO_COMPONENT; - where->prop = ICAL_NO_PROPERTY; - - /* remove enclosing quotes */ - s = value_str; - if(*s == '\''){ - s++; - } - l = s+strlen(s)-1; - if(*l == '\''){ - *l=0; - } - - where->value = strdup(s); - - /* Is there a period in str1 ? If so, the string specified both a - component and a property*/ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; - } else { - compstr = 0; - propstr = str1; - } - - - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); - } else { - where->comp = ICAL_NO_COMPONENT; - } - - where->prop = icalenum_string_to_property_kind(propstr); - - where->compare = compare; - - if(where->value == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(where->value); - return; - } - - pvl_push(impl->where,where); -} - -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) -{ - pvl_elem e = pvl_tail(impl->where); - struct icalgauge_where *where = pvl_data(e); - - where->logic = l; - -} - - - -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) -{ - char *c, *compstr, *propstr; - struct icalgauge_where *where; - - /* Uses only the prop and comp fields of the where structure */ - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - memset(where,0,sizeof(struct icalgauge_where)); - where->logic = ICALGAUGELOGIC_NONE; - where->compare = ICALGAUGECOMPARE_NONE; - where->comp = ICAL_NO_COMPONENT; - where->prop = ICAL_NO_PROPERTY; - - /* Is there a period in str1 ? If so, the string specified both a - component and a property*/ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; - } else { - compstr = 0; - propstr = str1; - } - - - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); - } else { - where->comp = ICAL_NO_COMPONENT; - } - - - /* If the property was '*', then accept all properties */ - if(strcmp("*",propstr) == 0) { - where->prop = ICAL_ANY_PROPERTY; - } else { - where->prop = icalenum_string_to_property_kind(propstr); - } - - - if(where->prop == ICAL_NO_PROPERTY){ - free(where); - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - - pvl_push(impl->select,where); -} - -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) -{ - icalcomponent_kind ckind; - - ckind = icalenum_string_to_component_kind(str1); - - if(ckind == ICAL_NO_COMPONENT){ - assert(0); - } - - pvl_push(impl->from,(void*)ckind); - -} - - -void sserror(char *s){ - fprintf(stderr,"Parse error \'%s\'\n", s); - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); -} diff --git a/libical/src/libicalvcal/.cvsignore b/libical/src/libicalvcal/.cvsignore index bbc8ba00d1..533caa2f3d 100644 --- a/libical/src/libicalvcal/.cvsignore +++ b/libical/src/libicalvcal/.cvsignore @@ -1,5 +1,12 @@ -Makefile -.deps -.libs -*.lo *.la +*.lo +.libs +.deps +Makefile +Makefile.in +libtool +ltconfig +ltmain.sh +stamp-h +stamp-h.in +vcc.c
\ No newline at end of file diff --git a/libical/src/libicalvcal/Makefile.am b/libical/src/libicalvcal/Makefile.am index 414265181c..f9d8dd39d9 100644 --- a/libical/src/libicalvcal/Makefile.am +++ b/libical/src/libicalvcal/Makefile.am @@ -8,27 +8,20 @@ INCLUDES = \ libicalvcal_evolution_la_LDFLAGS = -version-info 0:0:0 -if DEV -libicalvcal_evolution_la_DEVSOURCES = vcc.y -else -libicalvcal_evolution_la_DEVSOURCES = vcc.c -endif - - libicalvcal_evolution_la_SOURCES = \ icalvcal.h \ icalvcal.c \ port.h \ vcc.h \ + vcc.y \ vobject.h \ vobject.c \ vcaltmp.h \ - vcaltmp.c \ - $(libicalvcal_evolution_la_DEVSOURCES) + vcaltmp.c -libicalvcal_evolutionincludedir = $(privincludedir)/libical +#libicalvcalincludedir = $(privincludedir)/libicalvcal -#libicalvcal_evolutioninclude_HEADERS = \ +#libicalvcalinclude_HEADERS = \ # icalvcal.h \ # port.h \ # vcc.h \ diff --git a/libical/src/libicalvcal/icalvcal.c b/libical/src/libicalvcal/icalvcal.c index f5d417cb6d..9ab3fa899e 100644 --- a/libical/src/libicalvcal/icalvcal.c +++ b/libical/src/libicalvcal/icalvcal.c @@ -42,11 +42,6 @@ #include "icalvcal.h" #include <string.h> -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - enum datatype { COMPONENT, PROPERTY, @@ -67,7 +62,6 @@ int weekday_codes[] = { ICAL_SATURDAY_WEEKDAY }; - struct conversion_table_struct { char* vcalname; enum datatype type; @@ -155,10 +149,10 @@ static void convert_floating_time_to_utc (struct icaltimetype *itt) } -static void icalvcal_traverse_objects(VObject *object, - icalcomponent* last_comp, - icalproperty* last_prop, - icalvcal_defaults *defaults) +static int icalvcal_traverse_objects(VObject *object, + icalcomponent* last_comp, + icalproperty* last_prop, + icalvcal_defaults *defaults) { VObjectIterator iterator; char* name = "[No Name]"; @@ -167,8 +161,7 @@ static void icalvcal_traverse_objects(VObject *object, if ( vObjectName(object)== 0){ printf("ERROR, object has no name"); - assert(0); - return; + return 0; } name = (char*)vObjectName(object); @@ -191,8 +184,7 @@ static void icalvcal_traverse_objects(VObject *object, icalproperty_set_x_name(prop,name); icalcomponent_add_property(last_comp,prop); } else { - assert(0); - return; + return 0; } } else { @@ -211,8 +203,9 @@ static void icalvcal_traverse_objects(VObject *object, object, last_comp, defaults)); if (subc) { - icalcomponent_add_component(last_comp,subc); - } + icalcomponent_add_component(last_comp,subc); + } + break; } @@ -227,7 +220,7 @@ static void icalvcal_traverse_objects(VObject *object, object, last_comp, defaults)); if (prop) - icalcomponent_add_property(last_comp,prop); + icalcomponent_add_property(last_comp,prop); last_prop = prop; @@ -267,7 +260,6 @@ static void icalvcal_traverse_objects(VObject *object, /* Do Nothing. */ break; } - } } @@ -282,12 +274,16 @@ static void icalvcal_traverse_objects(VObject *object, should use it as the 'last_comp' */ if(subc!=0){ - icalvcal_traverse_objects(eachProp,subc,last_prop,defaults); + if (!icalvcal_traverse_objects(eachProp,subc,last_prop,defaults)) + return 0; } else { - icalvcal_traverse_objects(eachProp,last_comp,last_prop,defaults); + if (!icalvcal_traverse_objects(eachProp,last_comp,last_prop,defaults)) + return 0; } } + + return 1; } icalcomponent* icalvcal_convert_with_defaults (VObject *object, @@ -313,7 +309,8 @@ icalcomponent* icalvcal_convert_with_defaults (VObject *object, printf ("===========================================\n"); #endif - icalvcal_traverse_objects(object,container,0,defaults); + if (!icalvcal_traverse_objects(object,container,0,defaults)) + return 0; /* HACK. I am using the extra 'container' component because I am lazy. I know there is a way to get rid of it, but I did not care @@ -449,7 +446,7 @@ static int get_alarm_properties (icalcomponent *comp, VObject *object, icalcomponent_add_property (comp, trigger_prop); } - + } else if (!strcmp (name, VCSnoozeTimeProp)) { struct icaldurationtype d; @@ -458,7 +455,7 @@ static int get_alarm_properties (icalcomponent *comp, VObject *object, which we don't handle at present. Though it is unlikely they will be used as a snooze time between repeated alarms! */ d = icaldurationtype_from_string (s); - + duration_prop = icalproperty_new_duration (d); icalcomponent_add_property (comp, duration_prop); @@ -534,7 +531,7 @@ static int get_alarm_properties (icalcomponent *comp, VObject *object, if (!summary_prop) { summary_prop = icalproperty_new_summary (s); icalcomponent_add_property (comp, summary_prop); - } + } } if (free_string) @@ -695,23 +692,23 @@ void* alarm_comp(int icaltype, VObject *o, icalcomponent *comp, int is_valid_alarm; icalcomponent* c = icalcomponent_new(ICAL_VALARM_COMPONENT); - + is_valid_alarm = get_alarm_properties (c, o, icaltype, defaults); if (is_valid_alarm) { - return (void*)c; + return (void*)c; } else { icalcomponent_free (c); return NULL; } } - /* These #defines indicate conversion routines that are not defined yet. */ #define parameter 0 #define rsvp_parameter 0 + void* transp_prop(int icaltype, VObject *object, icalcomponent *comp, icalvcal_defaults *defaults) { @@ -721,12 +718,11 @@ void* transp_prop(int icaltype, VObject *object, icalcomponent *comp, s = get_string_value (object, &free_string); - /* In vCalendar "0" means opaque, "1" means transparent, and >1 is implementation-specific. So we just check for "1" and output TRANSPARENT. For anything else, the default OPAQUE will be used. */ if (!strcmp (s, "1")) { - prop = icalproperty_new_transp (ICAL_TRANSP_TRANSPARENT); + prop = icalproperty_new_transp ("TRANSPARENT"); } if (free_string) @@ -735,6 +731,7 @@ void* transp_prop(int icaltype, VObject *object, icalcomponent *comp, return (void*)prop; } + void* sequence_prop(int icaltype, VObject *object, icalcomponent *comp, icalvcal_defaults *defaults) { @@ -1016,8 +1013,8 @@ static char* rrule_parse_weekly_days (char *s, e = s + 2; if (*e == ' ' || *e == '\t' || *e == '\0') { found_day = day; - break; - } + break; + } } } @@ -1070,8 +1067,8 @@ static char* rrule_parse_monthly_days (char *s, } else if (*e == '-') { e++; month_day = -month_day; + } } - } /* Check the next char is whitespace or the end of the string. */ if (*e != ' ' && *e != '\t' && *e != '\0') @@ -1391,10 +1388,9 @@ void* dc_prop(int icaltype, VObject *object, icalcomponent *comp, icalproperty *prop; icalvalue *value; icalvalue_kind value_kind; - char *s,*t=0; + char *s; int free_string; - prop = icalproperty_new(kind); value_kind = icalenum_property_kind_to_value_kind (icalproperty_isa(prop)); @@ -1422,6 +1418,7 @@ struct conversion_table_struct conversion_table[] = {VCCalProp, COMPONENT, comp, ICAL_VCALENDAR_COMPONENT}, {VCTodoProp, COMPONENT, comp, ICAL_VTODO_COMPONENT}, {VCEventProp, COMPONENT, comp, ICAL_VEVENT_COMPONENT}, + {VCAAlarmProp, COMPONENT, alarm_comp, ICAL_XAUDIOALARM_COMPONENT}, {VCDAlarmProp, COMPONENT, alarm_comp, ICAL_XDISPLAYALARM_COMPONENT}, {VCMAlarmProp, COMPONENT, alarm_comp, ICAL_XEMAILALARM_COMPONENT}, @@ -1481,6 +1478,7 @@ struct conversion_table_struct conversion_table[] = {VCSnoozeTimeProp, IGNORE,0, 0}, {VCRepeatCountProp, IGNORE,0, 0}, {VCValueProp, IGNORE,0, 0}, +{VCAudioContentProp, IGNORE,0, 0}, {VCProcedureNameProp, IGNORE,0, 0}, {VCDisplayStringProp, IGNORE,0, 0}, {VCEmailAddressProp, IGNORE,0, 0}, @@ -1497,7 +1495,6 @@ struct conversion_table_struct conversion_table[] = {VCAppleLinkProp, UNSUPPORTED,0, 0}, {VCAttachProp, UNSUPPORTED,0, 0}, {VCATTMailProp, UNSUPPORTED,0, 0}, -{VCAudioContentProp, UNSUPPORTED,0, 0}, {VCAVIProp, UNSUPPORTED,0, 0}, {VCBase64Prop, UNSUPPORTED,0, 0}, {VCBBSProp, UNSUPPORTED,0, 0}, diff --git a/libical/src/libicalvcal/icalvcal.h b/libical/src/libicalvcal/icalvcal.h index 67119ce042..96e94b9f2e 100644 --- a/libical/src/libicalvcal/icalvcal.h +++ b/libical/src/libicalvcal/icalvcal.h @@ -44,10 +44,10 @@ struct _icalvcal_defaults { icalcomponent* icalvcal_convert(VObject *object); - icalcomponent* icalvcal_convert_with_defaults (VObject *object, icalvcal_defaults *defaults); + #endif /* !ICALVCAL_H */ diff --git a/libical/src/libicalvcal/vcc.y b/libical/src/libicalvcal/vcc.y index 245774f37e..5338f563a6 100644 --- a/libical/src/libicalvcal/vcc.y +++ b/libical/src/libicalvcal/vcc.y @@ -56,11 +56,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #define DBG_(x) #endif -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - /**** External Functions ****/ /* assign local name to parser variables and functions so that @@ -424,7 +419,7 @@ static void enterValues(const char *value) using ';' to separate the values. */ if (vObjectUStringZValue(curProp)) { p1 = fakeCString(vObjectUStringZValue(curProp)); - p2 = malloc((strlen(p1)+strlen(value)+1)); + p2 = malloc((strlen(p1)+strlen(value)+2)); strcpy(p2, p1); deleteStr(p1); @@ -437,7 +432,7 @@ static void enterValues(const char *value) setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); deleteStr(p2); } else { - setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); + setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); } } } diff --git a/libical/src/libicalvcal/vobject.c b/libical/src/libicalvcal/vobject.c index 616581ffa8..b17830eb72 100644 --- a/libical/src/libicalvcal/vobject.c +++ b/libical/src/libicalvcal/vobject.c @@ -42,11 +42,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. * vobject, and convert a vobject into its textual representation. */ -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif - #include "vobject.h" #include <stdlib.h> #include <string.h> @@ -1249,10 +1244,9 @@ static void writeGroup(OFile *fp, VObject *o) char buf2[256]; strcpy(buf1,NAME_OF(o)); while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { - strncpy(buf2,STRINGZ_VALUE_OF(o),sizeof(buf2)); - buf2[sizeof(buf2)-1] = '\0'; - strncat(buf2,".",sizeof(buf2)-strlen(buf2)-1); - strncat(buf2,buf1,sizeof(buf2)-strlen(buf2)-1); + strcpy(buf2,STRINGZ_VALUE_OF(o)); + strcat(buf2,"."); + strcat(buf2,buf1); strcpy(buf1,buf2); } appendsOFile(fp,buf1); diff --git a/libical/src/python/.cvsignore b/libical/src/python/.cvsignore index 801247a12c..3dda72986f 100644 --- a/libical/src/python/.cvsignore +++ b/libical/src/python/.cvsignore @@ -1,9 +1,2 @@ +Makefile.in Makefile -.deps -.libs -*.lo -*.la -*.pyc -LibicalWrap.c -LibicalWrap_wrap.doc -config.c diff --git a/libical/src/test/process.c b/libical/src/test/process.c index 466cf38101..56f1c65fb1 100644 --- a/libical/src/test/process.c +++ b/libical/src/test/process.c @@ -22,12 +22,55 @@ ======================================================================*/ #include <stdio.h> /* for printf */ +#include "ical.h" +#include "icalss.h" #include <errno.h> #include <string.h> /* For strerror */ #include <stdlib.h> /* for free */ -#include "ical.h" -#include "icalss.h" +struct class_map { + ical_class class; + char *str; +} class_map[] = { + {ICAL_NO_CLASS,"No class"}, + {ICAL_PUBLISH_NEW_CLASS,"New Publish"}, + {ICAL_PUBLISH_UPDATE_CLASS,"New Publish"}, + {ICAL_REQUEST_NEW_CLASS,"New request"}, + {ICAL_REQUEST_UPDATE_CLASS,"Update"}, + {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"}, + {ICAL_REQUEST_DELEGATE_CLASS,"Delegate"}, + {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"}, + {ICAL_REQUEST_FORWARD_CLASS,"Forward"}, + {ICAL_REQUEST_STATUS_CLASS,"Status request"}, + {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"}, + {ICAL_REPLY_DECLINE_CLASS,"Decline reply"}, + {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"}, + {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"}, + {ICAL_ADD_INSTANCE_CLASS,"Add instance"}, + {ICAL_CANCEL_EVENT_CLASS,"Cancel event"}, + {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"}, + {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"}, + {ICAL_REFRESH_CLASS,"Refresh"}, + {ICAL_COUNTER_CLASS,"Counter"}, + {ICAL_DECLINECOUNTER_CLASS,"Decline counter"}, + {ICAL_MALFORMED_CLASS,"Malformed"}, + {ICAL_OBSOLETE_CLASS,"Obsolete"}, + {ICAL_MISSEQUENCED_CLASS,"Missequenced"}, + {ICAL_UNKNOWN_CLASS,"Unknown"} +}; + +char* find_class_string(ical_class class) +{ + int i; + + for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){ + if (class_map[i].class == class){ + return class_map[i].str; + } + } + + return "Unknown"; +} void send_message(icalcomponent *reply,const char* this_user) { @@ -41,7 +84,7 @@ int main(int argc, char* argv[]) { icalcomponent *c, *next_c; int i=0; - const char *class_string; + char *class_string; int dont_remove; icalset* f = icalset_new_file("../../test-data/process-incoming.ics"); @@ -60,7 +103,7 @@ int main(int argc, char* argv[]) /* Foreach incoming message */ for(c=icalset_get_first_component(f);c!=0;c = next_c){ - icalproperty_xlicclass class; + ical_class class; icalcomponent *match; icalcomponent *inner; icalcomponent *reply = 0; @@ -87,7 +130,7 @@ int main(int argc, char* argv[]) class = icalclassify(c,match,this_user); - class_string = icalproperty_enum_to_string(class); + class_string = find_class_string(class); /* Print out the notes associated with the incoming component and the matched component in the */ @@ -128,7 +171,7 @@ int main(int argc, char* argv[]) /* Main processing structure */ switch (class){ - case ICAL_XLICCLASS_NONE: { + case ICAL_NO_CLASS: { char temp[1024]; /* Huh? Return an error to sender */ icalrestriction_check(c); @@ -148,15 +191,15 @@ int main(int argc, char* argv[]) break; } - case ICAL_XLICCLASS_PUBLISHNEW: { + case ICAL_PUBLISH_NEW_CLASS: { /* Don't accept published events from anyone but - self. If self, fall through to ICAL_XLICCLASS_REQUESTNEW */ + self. If self, fall through to ICAL_REQUEST_NEW_CLASS */ } - case ICAL_XLICCLASS_REQUESTNEW: { + case ICAL_REQUEST_NEW_CLASS: { /* Book the new component if it does not overlap anything. If the time is busy and the start time is @@ -240,114 +283,110 @@ conflicts with this meeting. I am proposing a time that works better for me."); } break; } - case ICAL_XLICCLASS_PUBLISHFREEBUSY: { + case ICAL_PUBLISH_FREEBUSY_CLASS: { /* Store the busy time information in a file named after the sender */ break; } - case ICAL_XLICCLASS_PUBLISHUPDATE: { + case ICAL_PUBLISH_UPDATE_CLASS: { /* Only accept publish updates from self. If self, fall - throught to ICAL_XLICCLASS_REQUESTUPDATE */ + throught to ICAL_REQUEST_UPDATE_CLASS */ } - case ICAL_XLICCLASS_REQUESTUPDATE: { + case ICAL_REQUEST_UPDATE_CLASS: { /* always accept the changes */ break; } - case ICAL_XLICCLASS_REQUESTRESCHEDULE: { + case ICAL_REQUEST_RESCHEDULE_CLASS: { /* Use same rules as REQUEST_NEW */ icalcomponent *overlaps; overlaps = icalclassify_find_overlaps(cal,c); break; } - case ICAL_XLICCLASS_REQUESTDELEGATE: { + case ICAL_REQUEST_DELEGATE_CLASS: { break; } - case ICAL_XLICCLASS_REQUESTNEWORGANIZER: { + case ICAL_REQUEST_NEW_ORGANIZER_CLASS: { break; } - case ICAL_XLICCLASS_REQUESTFORWARD: { + case ICAL_REQUEST_FORWARD_CLASS: { break; } - case ICAL_XLICCLASS_REQUESTSTATUS: { + case ICAL_REQUEST_STATUS_CLASS: { break; } - case ICAL_XLICCLASS_REQUESTFREEBUSY: { + case ICAL_REQUEST_FREEBUSY_CLASS: { break; } - case ICAL_XLICCLASS_REPLYACCEPT: { + case ICAL_REPLY_ACCEPT_CLASS: { /* Change the PARTSTAT of the sender */ break; } - case ICAL_XLICCLASS_REPLYDECLINE: { + case ICAL_REPLY_DECLINE_CLASS: { /* Change the PARTSTAT of the sender */ break; } - case ICAL_XLICCLASS_REPLYCRASHERACCEPT: { + case ICAL_REPLY_CRASHER_ACCEPT_CLASS: { /* Add the crasher to the ATTENDEE list with the appropriate PARTSTAT */ break; } - case ICAL_XLICCLASS_REPLYCRASHERDECLINE: { + case ICAL_REPLY_CRASHER_DECLINE_CLASS: { /* Add the crasher to the ATTENDEE list with the appropriate PARTSTAT */ break; } - case ICAL_XLICCLASS_ADDINSTANCE: { + case ICAL_ADD_INSTANCE_CLASS: { break; } - case ICAL_XLICCLASS_CANCELEVENT: { + case ICAL_CANCEL_EVENT_CLASS: { /* Remove the component */ break; } - case ICAL_XLICCLASS_CANCELINSTANCE: { + case ICAL_CANCEL_INSTANCE_CLASS: { break; } - case ICAL_XLICCLASS_CANCELALL: { + case ICAL_CANCEL_ALL_CLASS: { /* Remove the component */ break; } - case ICAL_XLICCLASS_REFRESH: { + case ICAL_REFRESH_CLASS: { /* Resend the latest copy of the request */ break; } - case ICAL_XLICCLASS_COUNTER: { + case ICAL_COUNTER_CLASS: { break; } - case ICAL_XLICCLASS_DECLINECOUNTER: { + case ICAL_DECLINECOUNTER_CLASS: { break; } - case ICAL_XLICCLASS_MALFORMED: { + case ICAL_MALFORMED_CLASS: { /* Send back an error */ break; } - case ICAL_XLICCLASS_OBSOLETE: { + case ICAL_OBSOLETE_CLASS: { printf(" ** Got an obsolete component:\n%s", icalcomponent_as_ical_string(c)); /* Send back an error */ break; } - case ICAL_XLICCLASS_MISSEQUENCED: { + case ICAL_MISSEQUENCED_CLASS: { printf(" ** Got a missequenced component:\n%s", icalcomponent_as_ical_string(c)); /* Send back an error */ break; } - case ICAL_XLICCLASS_UNKNOWN: { + case ICAL_UNKNOWN_CLASS: { printf(" ** Don't know what to do with this component:\n%s", icalcomponent_as_ical_string(c)); /* Send back an error */ break; } - case ICAL_XLICCLASS_X: - case ICAL_XLICCLASS_REPLYDELEGATE: - default: { - } } #if(0) diff --git a/libical/src/test/recur.c b/libical/src/test/recur.c index bb23337adb..f4d9a38647 100644 --- a/libical/src/test/recur.c +++ b/libical/src/test/recur.c @@ -25,137 +25,96 @@ ======================================================================*/ +#include "ical.h" #include <assert.h> #include <string.h> /* for strdup */ #include <stdlib.h> /* for malloc */ #include <stdio.h> /* for printf */ #include <time.h> /* for time() */ #include <signal.h> /* for signal */ -#ifndef WIN32 #include <unistd.h> /* for alarm */ -#endif - -#include "ical.h" -#include "icalss.h" - -#ifdef WIN32 -#define snprintf _snprintf -#define strcasecmp stricmp -#endif +#include "icalmemory.h" +#include "icaldirset.h" +#include "icalfileset.h" static void sig_alrm(int i){ fprintf(stderr,"Could not get lock on file\n"); exit(1); } -static void recur_callback(icalcomponent *comp, - struct icaltime_span *span, - void *data) -{ - printf("cb: %s", ctime(&span->start)); - printf(" %s\n", ctime(&span->end)); - -} - int main(int argc, char *argv[]) { - icalset *cin; - struct icaltimetype next; + icalfileset *cin; + struct icaltimetype start, next; icalcomponent *itr; icalproperty *desc, *dtstart, *rrule; struct icalrecurrencetype recur; icalrecur_iterator* ritr; time_t tt; char* file; - + icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL); - -#ifndef WIN32 + signal(SIGALRM,sig_alrm); -#endif - + + if (argc <= 1){ - file = "../../test-data/recur.txt"; + file = "../../test-data/recur.txt"; } else if (argc == 2){ - file = argv[1]; + file = argv[1]; } else { - fprintf(stderr,"usage: recur [input file]\n"); - exit(1); + fprintf(stderr,"usage: recur [input file]\n"); + exit(1); } - -#ifndef WIN32 + alarm(300); /* to get file lock */ -#endif cin = icalfileset_new(file); -#ifndef WIN32 alarm(0); -#endif - + if(cin == 0){ - fprintf(stderr,"recur: can't open file %s\n",file); - exit(1); - } - - - for (itr = icalfileset_get_first_component(cin); - itr != 0; - itr = icalfileset_get_next_component(cin)){ - - struct icaltimetype start = icaltime_from_timet(1,0); - struct icaltimetype end = icaltime_today(); - - - - desc = icalcomponent_get_first_property(itr,ICAL_DESCRIPTION_PROPERTY); - dtstart = icalcomponent_get_first_property(itr,ICAL_DTSTART_PROPERTY); - rrule = icalcomponent_get_first_property(itr,ICAL_RRULE_PROPERTY); - - if (desc == 0 || dtstart == 0 || rrule == 0){ - printf("\n******** Error in input component ********\n"); - printf("The following component is malformed:\n %s\n", - icalcomponent_as_ical_string(itr)); - continue; - } - - printf("\n\n#### %s\n",icalproperty_get_description(desc)); - printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule))); - recur = icalproperty_get_rrule(rrule); - start = icalproperty_get_dtstart(dtstart); - - ritr = icalrecur_iterator_new(recur,start); - - tt = icaltime_as_timet(start); - - printf("#### %s\n",ctime(&tt )); - - icalrecur_iterator_free(ritr); - - for(ritr = icalrecur_iterator_new(recur,start), - next = icalrecur_iterator_next(ritr); - !icaltime_is_null_time(next); - next = icalrecur_iterator_next(ritr)){ - - tt = icaltime_as_timet(next); - - printf(" %s",ctime(&tt )); - - } - icalrecur_iterator_free(ritr); - - icalcomponent_foreach_recurrence(itr, start, end, - recur_callback, NULL); - - - + fprintf(stderr,"recur: can't open file %s\n",file); + exit(1); } - icalset_free(cin); - icaltimezone_free_builtin_timezones(); - - icalmemory_free_ring(); + for (itr = icalfileset_get_first_component(cin); + itr != 0; + itr = icalfileset_get_next_component(cin)){ + + desc = icalcomponent_get_first_property(itr,ICAL_DESCRIPTION_PROPERTY); + dtstart = icalcomponent_get_first_property(itr,ICAL_DTSTART_PROPERTY); + rrule = icalcomponent_get_first_property(itr,ICAL_RRULE_PROPERTY); + + if (desc == 0 || dtstart == 0 || rrule == 0){ + printf("\n******** Error in input component ********\n"); + printf("The following component is malformed:\n %s\n", + icalcomponent_as_ical_string(itr)); + continue; + } + + printf("\n\n#### %s\n",icalproperty_get_description(desc)); + printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule))); + recur = icalproperty_get_rrule(rrule); + start = icalproperty_get_dtstart(dtstart); - free_zone_directory(); + ritr = icalrecur_iterator_new(recur,start); + tt = icaltime_as_timet(start); + + printf("#### %s\n",ctime(&tt )); + + for(ritr = icalrecur_iterator_new(recur,start), + next = icalrecur_iterator_next(ritr); + !icaltime_is_null_time(next); + next = icalrecur_iterator_next(ritr)){ + + tt = icaltime_as_timet(next); + + printf(" %s",ctime(&tt )); + + } + + } + return 0; } diff --git a/libical/src/test/testclassify.c b/libical/src/test/testclassify.c index 649d80cc58..2c6c785dfa 100644 --- a/libical/src/test/testclassify.c +++ b/libical/src/test/testclassify.c @@ -29,29 +29,52 @@ #include "ical.h" #include <errno.h> #include <string.h> /* For strerror */ -#include "icalss.h" - -/* Get a note about the purpose of the property*/ -const char* get_note(icalcomponent *c) +#include "icalset.h" +#include "icalclassify.h" + + +struct class_map { + ical_class class; + char *str; +} class_map[] = { + {ICAL_NO_CLASS,"No class"}, + {ICAL_PUBLISH_NEW_CLASS,"New Publish"}, + {ICAL_PUBLISH_UPDATE_CLASS,"Update Publish"}, + {ICAL_REQUEST_NEW_CLASS,"New request"}, + {ICAL_REQUEST_UPDATE_CLASS,"Update"}, + {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"}, + {ICAL_REQUEST_DELEGATE_CLASS,"Delegate"}, + {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"}, + {ICAL_REQUEST_FORWARD_CLASS,"Forward"}, + {ICAL_REQUEST_STATUS_CLASS,"Status request"}, + {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"}, + {ICAL_REPLY_DECLINE_CLASS,"Decline reply"}, + {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"}, + {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"}, + {ICAL_ADD_INSTANCE_CLASS,"Add instance"}, + {ICAL_CANCEL_EVENT_CLASS,"Cancel event"}, + {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"}, + {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"}, + {ICAL_REFRESH_CLASS,"Refresh"}, + {ICAL_COUNTER_CLASS,"Counter"}, + {ICAL_DECLINECOUNTER_CLASS,"Decline counter"}, + {ICAL_MALFORMED_CLASS,"Malformed"}, + {ICAL_OBSOLETE_CLASS,"Obsolete"}, + {ICAL_MISSEQUENCED_CLASS,"Missequenced"}, + {ICAL_UNKNOWN_CLASS,"Unknown"} +}; + +char* find_class_string(ical_class class) { - icalproperty *p; - const char* note = 0; - - if(c != 0){ - for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY); - p!= 0; - p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){ - if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){ - note = icalproperty_get_x(p); - } - } - } - - if(note == 0){ - note = "None"; + int i; + + for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){ + if (class_map[i].class == class){ + return class_map[i].str; + } } - - return note; + + return "Unknown"; } @@ -60,66 +83,71 @@ int main(int argc, char* argv[]) icalcomponent *c; int i=0; - /* Open up the two storage files, one for the incomming components, - one for the calendar */ - icalset* incoming = icalset_new_file("../../test-data/incoming.ics"); + icalset* f = icalset_new_file("../../test-data/incoming.ics"); icalset* cal = icalset_new_file("../../test-data/calendar.ics"); - assert(incoming!= 0); + assert(f!= 0); assert(cal!=0); + - /* Iterate through all of the incoming components */ - for(c=icalset_get_first_component(incoming);c!=0; - c=icalset_get_next_component(incoming)){ + /* Foreach incoming message */ + for(c=icalset_get_first_component(f);c!=0; + c=icalset_get_next_component(f)){ - icalproperty_xlicclass class; - icalcomponent *match = 0; - const char* this_uid; + ical_class class; + icalcomponent *match; + icalcomponent *inner = icalcomponent_get_first_real_component(c); + icalcomponent *p; + const char *this_uid; + const char *i_x_note=0; + const char *c_x_note=0; i++; - /* Check this component against the restrictions imposed by - iTIP. An errors will be inserted as X-LIC-ERROR properties - in the component. The Parser will also insert errors if it - cannot parse the component */ - icalcomponent_check_restrictions(c); - - /* If there are any errors, print out the component */ - if(icalcomponent_count_errors(c) != 0){ - printf("----- Component has errors ------- \n%s-----------------\n", - icalcomponent_as_ical_string(c)); - } - - /* Use one of the icalcomponent convenience routines to get - the UID. This routine will save you from having to use - icalcomponent_get_inner(), - icalcomponent_get_first_property(), checking the return - value, and then calling icalproperty_get_uid. There are - several other convenience routines for DTSTART, DTEND, - DURATION, SUMMARY, METHOD, and COMMENT */ - this_uid = icalcomponent_get_uid(c); - - if(this_uid != 0){ - /* Look in the calendar for a component with the same UID - as the incomming component. We should reall also be - checking the RECURRENCE-ID. Another way to do this - operation is to us icalset_find_match(), which does use - the RECURRENCE-ID. */ - match = icalset_fetch(cal,this_uid); - } - - - /* Classify the incoming component. The third argument is the - calid of the user who owns the calendar. In a real program, - you would probably switch() on the class.*/ + if(inner == 0){ + continue; + } + + p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); + this_uid = icalproperty_get_uid(p); + + assert(this_uid != 0); + + /* Find a booked component that is matched to the incoming + message, based on the incoming component's UID, SEQUENCE + and RECURRENCE-ID*/ + + match = icalset_fetch(cal,this_uid); + class = icalclassify(c,match,"A@example.com"); - printf("Test %d\n\ -Incoming: %s\n\ -Matched: %s\n\ -Classification: %s\n\n", - i,get_note(c),get_note(match), - icalproperty_enum_to_string(class)); + for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY); + p!= 0; + p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){ + if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){ + i_x_note = icalproperty_get_x(p); + } + } + + + if(i_x_note == 0){ + i_x_note = "None"; + } + + for(p = icalcomponent_get_first_property(match,ICAL_X_PROPERTY); + p!= 0; + p = icalcomponent_get_next_property(match,ICAL_X_PROPERTY)){ + if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){ + c_x_note = icalproperty_get_x(p); + } + } + + if(c_x_note == 0){ + c_x_note = "None"; + } + + + printf("Test %d\nIncoming: %s\nMatched: %s\nClassification: %s\n\n",i,i_x_note,c_x_note,find_class_string(class)); } return 0; diff --git a/libical/src/test/testmime.c b/libical/src/test/testmime.c index cdb47d88dc..5dfc3b7d31 100644 --- a/libical/src/test/testmime.c +++ b/libical/src/test/testmime.c @@ -34,7 +34,8 @@ ======================================================================*/ #include "ical.h" - +#include "sspm.h" +#include "icalmime.h" #include <stdlib.h> /* For rand */ #include <string.h> /* for strrchr, strdup*/ #include <unistd.h> /* for getopt */ @@ -264,7 +265,7 @@ int main(int argc, char* argv[]) { d.pos = 0; d.str = buf; - c = icalmime_parse(icalparser_string_line_generator,&d); + c = icalmime_parse(string_line_generator,&d); printf("%s\n",icalcomponent_as_ical_string(c)); |