diff options
author | JP Rosevear <jpr@src.gnome.org> | 2000-08-25 04:12:06 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-08-25 04:12:06 +0800 |
commit | 73a6d43a66a828b09e2c1b5a483405e6e0b5fa6a (patch) | |
tree | 5be6b34646e168f530ae5cf818a19d5b4be1bd73 /libical/src | |
parent | 37471a4d5261636aea1a330ed2c42db9e665a9f9 (diff) | |
download | gsoc2013-evolution-73a6d43a66a828b09e2c1b5a483405e6e0b5fa6a.tar.gz gsoc2013-evolution-73a6d43a66a828b09e2c1b5a483405e6e0b5fa6a.tar.zst gsoc2013-evolution-73a6d43a66a828b09e2c1b5a483405e6e0b5fa6a.zip |
Fix minor conflicts.
svn path=/trunk/; revision=5017
Diffstat (limited to 'libical/src')
38 files changed, 2539 insertions, 1519 deletions
diff --git a/libical/src/Makefile.am b/libical/src/Makefile.am index 37dc5e39cb..4edf2a1d14 100644 --- a/libical/src/Makefile.am +++ b/libical/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = libical libicalss test +SUBDIRS = libical libicalss libicalvcal test diff --git a/libical/src/libical/Makefile.am b/libical/src/libical/Makefile.am index d9af51bccd..35a08effc7 100644 --- a/libical/src/libical/Makefile.am +++ b/libical/src/libical/Makefile.am @@ -30,9 +30,16 @@ libical_a_SOURCES = \ icaltypes.h \ icalvalue.c \ icalvalue.h \ - icalvcal.h \ + icalrecur.c \ + icalrecur.h \ + icaltime.h \ + icaltime.c \ pvl.c \ - pvl.h + pvl.h \ + sspm.c \ + sspm.h \ + icalmime.c \ + icalmime.h include_HEADERS=\ ical.h \ @@ -46,9 +53,12 @@ include_HEADERS=\ icalrestriction.h \ icaltypes.h \ icalvalue.h \ - icalvcal.h \ + icalrecur.h \ icalversion.h \ - pvl.h + icaltime.h \ + pvl.h \ + sspm.h \ + icalmime.h # diff --git a/libical/src/libical/ical.h b/libical/src/libical/ical.h index d0f33cd1a1..05e7ca82bc 100644 --- a/libical/src/libical/ical.h +++ b/libical/src/libical/ical.h @@ -4,20 +4,19 @@ CREATOR: eric 20 March 1999 - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 ical.h ======================================================================*/ @@ -36,6 +35,14 @@ #include "icalmemory.h" #include "icalerror.h" #include "icalrestriction.h" +#include "icaltime.h" +#include "icalrecur.h" + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + + #endif /* !ICAL_H */ diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c index bd2b13189c..52c2088140 100644 --- a/libical/src/libical/icalcomponent.c +++ b/libical/src/libical/icalcomponent.c @@ -1,25 +1,22 @@ -/* -*- Mode: C -*- */ /*====================================================================== FILE: icalcomponent.c CREATOR: eric 28 April 1999 $Id$ + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - (C) COPYRIGHT 1999 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 contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icalcomponent.c ======================================================================*/ @@ -154,6 +151,7 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* component) struct icalcomponent_impl *new; icalproperty *p; icalcomponent *c; + pvl_elem itr; icalerror_check_arg_rv( (component!=0), "component"); @@ -164,20 +162,22 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* component) } - for(p = icalcomponent_get_first_property(old,ICAL_ANY_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(old,ICAL_ANY_PROPERTY)){ - - icalcomponent_add_property(new,icalproperty_new_clone(p)); - } + for( itr = pvl_head(old->properties); + itr != 0; + itr = pvl_next(itr)) + { + p = (icalproperty*)pvl_data(itr); + icalcomponent_add_property(new,icalproperty_new_clone(p)); + } - for(c = icalcomponent_get_first_component(old,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(old,ICAL_ANY_COMPONENT)){ - - icalcomponent_add_component(new,icalcomponent_new_clone(c)); - } + for( itr = pvl_head(old->components); + itr != 0; + itr = pvl_next(itr)) + { + c = (icalcomponent*)pvl_data(itr); + icalcomponent_add_component(new,icalcomponent_new_clone(c)); + } return new; @@ -242,6 +242,8 @@ icalcomponent_as_ical_string (icalcomponent* component) char* tmp_buf; size_t buf_size = 1024; char* buf_ptr = 0; + pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; #ifdef ICAL_UNIX_NEWLINE char newline[] = "\n"; @@ -270,22 +272,28 @@ icalcomponent_as_ical_string (icalcomponent* component) icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); - for(p = icalcomponent_get_first_property(component,ICAL_ANY_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(component,ICAL_ANY_PROPERTY)){ - tmp_buf = icalproperty_as_ical_string(p); - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); - } + for( itr = pvl_head(impl->properties); + itr != 0; + itr = pvl_next(itr)) + { + p = (icalproperty*)pvl_data(itr); + + icalerror_assert((p!=0),"Got a null property"); + tmp_buf = icalproperty_as_ical_string(p); + + icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); + } - for(c = icalcomponent_get_first_component(component,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(component,ICAL_ANY_COMPONENT)){ + for( itr = pvl_head(impl->components); + itr != 0; + itr = pvl_next(itr)) + { + c = (icalcomponent*)pvl_data(itr); tmp_buf = icalcomponent_as_ical_string(c); - + icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); } @@ -423,17 +431,23 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property) } int -icalcomponent_count_properties (icalcomponent* component, icalproperty_kind kind) +icalcomponent_count_properties (icalcomponent* component, + icalproperty_kind kind) { int count=0; - icalproperty *p; + pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; + icalerror_check_arg_rz( (component!=0), "component"); - for(p = icalcomponent_get_first_property(component,kind); - p != 0; - p = icalcomponent_get_next_property(component,kind)){ - - count++; + for( itr = pvl_head(impl->properties); + itr != 0; + itr = pvl_next(itr)) + { + if(kind == icalproperty_isa((icalproperty*)pvl_data(itr)) || + kind == ICAL_ANY_PROPERTY){ + count++; + } } @@ -545,30 +559,42 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child) if( pvl_data(itr) == (void*)child ){ if (impl->component_iterator == itr){ - /* impl->component_iterator = pvl_next(itr);*/ + /* Don't let the current iterator become invalid */ + + /* HACK. The semantics for this are troubling. */ + impl->component_iterator = + pvl_next(impl->component_iterator); + } pvl_remove( impl->components, itr); cimpl->parent = 0; + break; } } } int -icalcomponent_count_components (icalcomponent* component, icalcomponent_kind kind) +icalcomponent_count_components (icalcomponent* component, + icalcomponent_kind kind) { int count=0; - icalcomponent *c; + pvl_elem itr; + struct icalcomponent_impl *impl = + (struct iccalcomponent_impl*)component; + icalerror_check_arg_rz( (component!=0), "component"); - for(c = icalcomponent_get_first_component(component,kind); - c != 0; - c = icalcomponent_get_next_component(component,kind)){ - - count++; + for( itr = pvl_head(impl->components); + itr != 0; + itr = pvl_next(itr)) + { + if(kind == icalcomponent_isa((icalcomponent*)pvl_data(itr)) || + kind == ICAL_ANY_COMPONENT){ + count++; + } } - return count; } @@ -646,10 +672,14 @@ int icalcomponent_count_errors(icalcomponent* component) int errors = 0; icalproperty *p; icalcomponent *c; + pvl_elem itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; - for(p = icalcomponent_get_first_property(component,ICAL_ANY_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(component,ICAL_ANY_PROPERTY)){ + for( itr = pvl_head(impl->properties); + itr != 0; + itr = pvl_next(itr)) + { + p = (icalproperty*)pvl_data(itr); if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) { @@ -657,9 +687,12 @@ int icalcomponent_count_errors(icalcomponent* component) } } - for(c = icalcomponent_get_first_component(component,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(component,ICAL_ANY_COMPONENT)){ + + for( itr = pvl_head(impl->components); + itr != 0; + itr = pvl_next(itr)) + { + c = (icalcomponent*)pvl_data(itr); errors += icalcomponent_count_errors(c); @@ -671,30 +704,34 @@ int icalcomponent_count_errors(icalcomponent* component) void icalcomponent_strip_errors(icalcomponent* component) { - icalproperty *p, *next_p; + icalproperty *p; icalcomponent *c; + pvl_elem itr, next_itr; + struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; - for(p = icalcomponent_get_first_property(component,ICAL_ANY_PROPERTY); - p != 0; - p = next_p){ - - next_p = icalcomponent_get_next_property(component,ICAL_ANY_PROPERTY); + for( itr = pvl_head(impl->properties); + itr != 0; + itr = next_itr) + { + p = (icalproperty*)pvl_data(itr); + next_itr = pvl_next(itr); if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) { icalcomponent_remove_property(component,p); } } - - for(c = icalcomponent_get_first_component(component,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(component,ICAL_ANY_COMPONENT)){ - + + for( itr = pvl_head(impl->components); + itr != 0; + itr = pvl_next(itr)) + { + c = (icalcomponent*)pvl_data(itr); icalcomponent_strip_errors(c); } } - +/* Hack. This will change the state of the iterators */ void icalcomponent_convert_errors(icalcomponent* component) { icalproperty *p, *next_p; @@ -709,7 +746,6 @@ void icalcomponent_convert_errors(icalcomponent* component) if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) { struct icalreqstattype rst; - char tmp[MAX_TMP]; icalparameter *param = icalproperty_get_first_parameter (p,ICAL_XLICERRORTYPE_PARAMETER); @@ -779,4 +815,111 @@ void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent) c->parent = parent; } +icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0}; + +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; + + icalerror_check_arg_rz( (component!=0),"component"); + + for( i = pvl_head(impl->components); i != 0; i = pvl_next(itr.iter)) { + + icalcomponent *c = (icalcomponent*) pvl_data(i); + + if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) { + + itr.iter = i; + + return itr; + } + } + + return icalcompiter_null;; +} + +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_rz( (component!=0),"component"); + + for( i = pvl_tail(impl->components); i != 0; i = pvl_prior(i)) { + + icalcomponent *c = (icalcomponent*) pvl_data(i); + + if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) { + + itr.iter = pvl_next(i); + + return itr; + } + } + + return icalcompiter_null;; +} + + +icalcomponent* icalcompiter_next(icalcompiter* i) +{ + if (i->iter == 0){ + return 0; + } + + for( i->iter = pvl_next(i->iter); + i->iter != 0; + i->iter = pvl_next(i->iter)) { + + icalcomponent *c = (icalcomponent*) pvl_data(i->iter); + + if (icalcomponent_isa(c) == i->kind + || i->kind == ICAL_ANY_COMPONENT) { + + return icalcompiter_deref(i);; + } + } + + return 0; + +} + +icalcomponent* icalcompiter_prior(icalcompiter* i) +{ + if (i->iter == 0){ + return 0; + } + + for( i->iter = pvl_prior(i->iter); + i->iter != 0; + i->iter = pvl_prior(i->iter)) { + + icalcomponent *c = (icalcomponent*) pvl_data(i->iter); + + if (icalcomponent_isa(c) == i->kind + || i->kind == ICAL_ANY_COMPONENT) { + + return icalcompiter_deref(i);; + } + } + return 0; + +} +icalcomponent* icalcompiter_deref(icalcompiter* i) +{ + if(i->iter ==0){ + return 0; + } + + return pvl_data(i->iter); +} diff --git a/libical/src/libical/icalcomponent.h b/libical/src/libical/icalcomponent.h index 8d9f22ca76..b0d1e33630 100644 --- a/libical/src/libical/icalcomponent.h +++ b/libical/src/libical/icalcomponent.h @@ -4,20 +4,19 @@ CREATOR: eric 20 March 1999 - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalcomponent.h ======================================================================*/ @@ -28,9 +27,19 @@ #include "icalproperty.h" #include "icalvalue.h" #include "icalenums.h" /* defines icalcomponent_kind */ +#include "pvl.h" typedef void icalcomponent; +/* This is exposed so that callers will not have to allocate and + deallocate iterators. Pretend that you can't see it. */ +typedef struct icalcompiter +{ + icalcomponent_kind kind; + pvl_elem iter; + +} icalcompiter; + icalcomponent* icalcomponent_new(icalcomponent_kind kind); icalcomponent* icalcomponent_new_clone(icalcomponent* component); icalcomponent* icalcomponent_new_from_string(char* str); @@ -86,6 +95,20 @@ void icalcomponent_remove_component(icalcomponent* parent, int icalcomponent_count_components(icalcomponent* component, icalcomponent_kind kind); +/* Iteration Routines. There are two forms of iterators, internal and +external. The internal ones came first, and are almost completely +sufficient, but they fail badly when you want to construct a loop that +removes components from the container. + +The internal iterators are deprecated. */ + +/* Using external iterators */ +icalcompiter icalcomponent_begin_component(icalcomponent* component, + icalcomponent_kind kind); + +icalcompiter icalcomponent_end_component(icalcomponent* component, + icalcomponent_kind kind); + /* Iterate through components */ icalcomponent* icalcomponent_get_current_component (icalcomponent* component); @@ -94,6 +117,8 @@ icalcomponent* icalcomponent_get_first_component(icalcomponent* component, icalcomponent* icalcomponent_get_next_component(icalcomponent* component, icalcomponent_kind kind); + + /* Return a null-terminated array of icalproperties*/ icalproperty** icalcomponent_get_component(icalcomponent* component, icalproperty_kind kind); @@ -113,6 +138,14 @@ icalcomponent* icalcomponent_get_parent(icalcomponent* component); void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent); + + +/* External component iterator */ +icalcomponent* icalcompiter_next(icalcompiter* i); +icalcomponent* icalcompiter_prior(icalcompiter* i); +icalcomponent* icalcompiter_deref(icalcompiter* i); + + #endif /* !ICALCOMPONENT_H */ diff --git a/libical/src/libical/icalenums.c b/libical/src/libical/icalenums.c index 7f0aae6a0e..50d23c8d41 100644 --- a/libical/src/libical/icalenums.c +++ b/libical/src/libical/icalenums.c @@ -5,21 +5,19 @@ $Id$ + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - (C) COPYRIGHT 1999 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 contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icalenum.c ======================================================================*/ @@ -33,7 +31,7 @@ struct icalproperty_kind_map { icalproperty_kind kind; - char name[20]; + char *name; }; static struct icalproperty_kind_map property_map[] = @@ -98,6 +96,10 @@ static struct icalproperty_kind_map property_map[] = /* libical private properties */ { ICAL_XLICERROR_PROPERTY,"X-LIC-ERROR"}, + { ICAL_XLICMIMECONTENTTYPE_PROPERTY,"X-LIC-MIME-CONTENT-TYPE"}, + { ICAL_XLICMIMEENCODING_PROPERTY,"X-LIC-MIME-ENCODING"}, + { ICAL_XLICMIMEOPTINFO_PROPERTY,"X-LIC-MIME-OPT-INFO"}, + { ICAL_XLICMIMECHARSET_PROPERTY,"X-LIC-MIME-CHARSET"}, { ICAL_XLICCLUSTERCOUNT_PROPERTY,"X-LIC-CLUSTERCOUNT"}, /* End of the list */ @@ -287,6 +289,7 @@ static struct icalcomponent_kind_map component_map[] = /* libical private components */ { ICAL_XLICINVALID_COMPONENT, "X-LIC-UNKNOWN" }, + { ICAL_XLICMIMEPART_COMPONENT, "X-LIC-MIME-PART" }, { ICAL_ANY_COMPONENT, "ANY" }, { ICAL_XROOT_COMPONENT, "XROOT" }, diff --git a/libical/src/libical/icalenums.h b/libical/src/libical/icalenums.h index ff7cee486e..ba3137803e 100644 --- a/libical/src/libical/icalenums.h +++ b/libical/src/libical/icalenums.h @@ -1,23 +1,23 @@ + /* -*- Mode: C -*-*/ /*====================================================================== FILE: icalenums.h - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icalenums.h Contributions from: @@ -57,7 +57,10 @@ typedef enum icalcomponent_kind { ICAL_VQUERY_COMPONENT, ICAL_VCAR_COMPONENT, ICAL_VCOMMAND_COMPONENT, - ICAL_XLICINVALID_COMPONENT + ICAL_XLICINVALID_COMPONENT, + ICAL_XLICMIMEPART_COMPONENT /* a non-stardard component that mirrors + structure of MIME data */ + } icalcomponent_kind; /*********************************************************************** @@ -126,6 +129,12 @@ typedef enum icalproperty_kind { /* libical private properties */ ICAL_XLICERROR_PROPERTY, ICAL_XLICCLUSTERCOUNT_PROPERTY, + ICAL_XLICMIMECONTENTTYPE_PROPERTY, + ICAL_XLICMIMEENCODING_PROPERTY, + ICAL_XLICMIMECID_PROPERTY, + ICAL_XLICMIMEFILENAME_PROPERTY, + ICAL_XLICMIMECHARSET_PROPERTY, + ICAL_XLICMIMEOPTINFO_PROPERTY, ICAL_NO_PROPERTY /* This must be the last enum, for iteration */ @@ -323,7 +332,9 @@ typedef enum icalparameter_xlicerrortype { ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR, ICAL_XLICERRORTYPE_PROPERTYPARSEERROR, ICAL_XLICERRORTYPE_VALUEPARSEERROR, - ICAL_XLICERRORTYPE_INVALIDITIP + ICAL_XLICERRORTYPE_UNKVCALPROP, + ICAL_XLICERRORTYPE_INVALIDITIP, + ICAL_XLICERRORTYPE_MIMEPARSEERROR, } icalparameter_xlicerrortype; typedef enum icalparameter_xliccomparetype { @@ -359,17 +370,20 @@ typedef enum icalparameter_value { * Recurrances **********************************************************************/ - typedef enum icalrecurrencetype_frequency { - ICAL_NO_RECURRENCE, - ICAL_SECONDLY_RECURRENCE, - ICAL_MINUTELY_RECURRENCE, - ICAL_HOURLY_RECURRENCE, - ICAL_DAILY_RECURRENCE, - ICAL_WEEKLY_RECURRENCE, - ICAL_MONTHLY_RECURRENCE, - ICAL_YEARLY_RECURRENCE + /* These enums are used to index an array, so don't change the + order or the integers */ + + ICAL_SECONDLY_RECURRENCE=0, + ICAL_MINUTELY_RECURRENCE=1, + ICAL_HOURLY_RECURRENCE=2, + ICAL_DAILY_RECURRENCE=3, + ICAL_WEEKLY_RECURRENCE=4, + ICAL_MONTHLY_RECURRENCE=5, + ICAL_YEARLY_RECURRENCE=6, + ICAL_NO_RECURRENCE=7 + } icalrecurrencetype_frequency; typedef enum icalrecurrencetype_weekday diff --git a/libical/src/libical/icalerror.c b/libical/src/libical/icalerror.c index fb9e152b16..c7641da504 100644 --- a/libical/src/libical/icalerror.c +++ b/libical/src/libical/icalerror.c @@ -4,23 +4,23 @@ CREATOR: eric 16 May 1999 $Id$ + $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org + (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 contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ - The original author is Eric Busboom The original code is icalerror.c ======================================================================*/ diff --git a/libical/src/libical/icalerror.h b/libical/src/libical/icalerror.h index 124699c21b..fbf6076dd6 100644 --- a/libical/src/libical/icalerror.h +++ b/libical/src/libical/icalerror.h @@ -6,20 +6,19 @@ $Id$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalerror.h ======================================================================*/ @@ -122,6 +121,7 @@ typedef enum icalerrorenum { ICAL_USAGE_ERROR, ICAL_NO_ERROR, ICAL_MULTIPLEINCLUSION_ERROR, + ICAL_TIMEDOUT_ERROR, ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror()*/ } icalerrorenum; diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c index 35544b14ee..e13c2c42ca 100644 --- a/libical/src/libical/icalmemory.c +++ b/libical/src/libical/icalmemory.c @@ -4,6 +4,7 @@ CREATOR: eric 30 June 1999 $Id$ + $Locker$ The contents of this file are subject to the Mozilla Public License @@ -16,12 +17,34 @@ the License for the specific language governing rights and limitations under the License. + + 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 icalmemory.h - The Initial Developer of the Original Code is Eric Busboom - (C) COPYRIGHT 1999 The Software Studio. - 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 Initial Developer of the Original Code is Eric Busboom + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ /* libical often passes strings back to the caller. To make these @@ -41,6 +64,9 @@ #include "config.h" #endif +#ifdef DMALLOC +#include "dmalloc.h" +#endif #include "icalmemory.h" #include "icalerror.h" @@ -52,18 +78,16 @@ #define BUFFER_RING_SIZE 25 #define MIN_BUFFER_SIZE 200 -void* buffer_ring[BUFFER_RING_SIZE+1]; -int buffer_pos = 0; +/* HACK. Not threadsafe */ +void* buffer_ring[BUFFER_RING_SIZE]; +int buffer_pos = -1; int initialized = 0; -/* Create a new temporary buffer on the ring. Libical owns these and wil deallocate them. */ -void* -icalmemory_tmp_buffer (size_t size) +/* Add an existing buffer to the buffer ring */ +void icalmemory_add_tmp_buffer(void* buf) { - void *rtrn; /* I don't think I need this -- I think static arrays are initialized to 0 as a standard part of C, but I am not sure. */ - if (initialized == 0){ int i; for(i=0; i<BUFFER_RING_SIZE; i++){ @@ -71,30 +95,45 @@ icalmemory_tmp_buffer (size_t size) } initialized = 1; } - - /* Ideally, this routine would re-use an existing buffer if it is - larger than the requested buffer. Maybe later.... */ - if (size < MIN_BUFFER_SIZE){ - size = MIN_BUFFER_SIZE; + /* Wrap around the ring */ + if(++buffer_pos == BUFFER_RING_SIZE){ + buffer_pos = 0; } - + + /* Free buffers as their slots are overwritten */ if ( buffer_ring[buffer_pos] != 0){ - /*sprintf(buffer_ring[buffer_pos], "***DEALLOCATED MEMORY***: %d",buffer_pos);*/ free( buffer_ring[buffer_pos]); buffer_ring[buffer_pos] = 0; } + /* Assign the buffer to a slot */ + buffer_ring[buffer_pos] = buf; +} - rtrn = buffer_ring[buffer_pos] = (void*)malloc(size); +/* Create a new temporary buffer on the ring. Libical owns these and + wil deallocate them. */ +void* +icalmemory_tmp_buffer (size_t size) +{ + char *buf; - memset(rtrn,0,size); + if (size < MIN_BUFFER_SIZE){ + size = MIN_BUFFER_SIZE; + } + + buf = (void*)malloc(size); - if(++buffer_pos > BUFFER_RING_SIZE){ - buffer_pos = 0; + if( buf == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; } - return rtrn; + memset(buf,0,size); + + icalmemory_add_tmp_buffer(buf); + + return buf; } void icalmemory_free_ring() @@ -112,6 +151,8 @@ void icalmemory_free_ring() } + + /* Like strdup, but the buffer is on the ring. */ char* icalmemory_tmp_copy(char* str) @@ -124,6 +165,10 @@ icalmemory_tmp_copy(char* str) } +char* icalmemory_strdup(const char *s) +{ + return strdup(s); +} void icalmemory_free_tmp_buffer (void* buf) @@ -137,13 +182,18 @@ icalmemory_free_tmp_buffer (void* buf) } -/* These buffer routines create memory the old fashioned way -- so the caller will have to delocate the new memory */ +/* These buffer routines create memory the old fashioned way -- so the + caller will have to delocate the new memory */ void* icalmemory_new_buffer(size_t size) { - /* HACK. need to handle out of memory case */ void *b = malloc(size); + if( b == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + memset(b,0,size); return b; @@ -151,9 +201,14 @@ void* icalmemory_new_buffer(size_t size) void* icalmemory_resize_buffer(void* buf, size_t size) { - /* HACK. need to handle out of memory case */ + void *b = realloc(buf, size); - return realloc(buf, size); + if( b == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + return b; } void icalmemory_free_buffer(void* buf) @@ -240,5 +295,5 @@ icalmemory_append_char(char** buf, char** pos, size_t* buf_size, **pos = ch; *pos += 1; - + **pos = 0; } diff --git a/libical/src/libical/icalmemory.h b/libical/src/libical/icalmemory.h index 26d22b7316..6c974cdc95 100644 --- a/libical/src/libical/icalmemory.h +++ b/libical/src/libical/icalmemory.h @@ -17,12 +17,34 @@ the License for the specific language governing rights and limitations under the License. + + 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 icalmemory.h - The Initial Developer of the Original Code is Eric Busboom - (C) COPYRIGHT 1999 The Software Studio. - 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 Initial Developer of the Original Code is Eric Busboom + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ #ifndef ICALMEMORY_H @@ -30,7 +52,8 @@ #include <sys/types.h> /* for size_t */ -/* Tmp buffers are managed by ical. References can be returned to the caller, although the caller will not own the memory. */ +/* Tmp buffers are managed by ical. References can be returned to the + caller, although the caller will not own the memory. */ void* icalmemory_tmp_buffer(size_t size); char* icalmemory_tmp_copy(char* str); @@ -70,6 +93,9 @@ void icalmemory_append_string(char** buf, char** pos, size_t* buf_size, void icalmemory_append_char(char** buf, char** pos, size_t* buf_size, char ch); +/* A wrapper around strdup */ +char* icalmemory_strdup(const char *s); + #endif /* !ICALMEMORY_H */ diff --git a/libical/src/libical/icalparameter.c b/libical/src/libical/icalparameter.c index cf37eb07b2..c77c223f1c 100644 --- a/libical/src/libical/icalparameter.c +++ b/libical/src/libical/icalparameter.c @@ -4,23 +4,23 @@ CREATOR: eric 09 May 1999 $Id$ + $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org + (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 contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ - The original author is Eric Busboom The original code is icalderivedparameters.{c,h} Contributions from: @@ -114,7 +114,7 @@ icalparameter_new_clone(icalparameter* param) memcpy(new,old,sizeof(struct icalparameter_impl)); if (old->string != 0){ - new->string = strdup(old->string); + new->string = icalmemory_strdup(old->string); if (new->string == 0){ icalparameter_free(new); return 0; @@ -122,7 +122,7 @@ icalparameter_new_clone(icalparameter* param) } if (old->x_name != 0){ - new->x_name = strdup(old->x_name); + new->x_name = icalmemory_strdup(old->x_name); if (new->x_name == 0){ icalparameter_free(new); return 0; @@ -132,6 +132,116 @@ icalparameter_new_clone(icalparameter* param) return new; } +#if 0 + +struct param_string_map { + icalparameter_kind kind; + int val; /* Actually, union of several types of enums */ + char* str; +} param_string_map[] = +{ + {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_INDIVIDUAL,"INDIVIDUAL"}, + {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_GROUP,"GROUP"}, + {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_RESOURCE,"RESOURCE"}, + {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_ROOM,"ROOM"}, + {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_UNKNOWN,"UNKNOWN"}, + {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_FREE,"FREE"}, + {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSY,"BUSY"}, + {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSYUNAVAILABLE,"BUSYUNAVAILABLE"}, + {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSYTENTATIVE,"BUSYTENTATIVE"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_NEEDSACTION,"NEEDSACTION"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_ACCEPTED,"ACCEPTED"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_DECLINED,"DECLINED"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_TENTATIVE,"TENTATIVE"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_DELEGATED,"DELEGATED"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_COMPLETED,"COMPLETED"}, + {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_INPROCESS,"INPROCESS"}, + {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDPRIOR,"THISANDPRIOR"}, + {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDFUTURE,"THISANDFUTURE"}, + {ICAL_RELATED_PARAMETER,ICAL_RELATED_START,"START"}, + {ICAL_RELATED_PARAMETER,ICAL_RELATED_END,"END"}, + {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_PARENT,"PARENT"}, + {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_CHILD,"CHILD"}, + {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_SIBLING,"SIBLING"}, + {ICAL_ROLE_PARAMETER,ICAL_ROLE_CHAIR,"CHAIR"}, + {ICAL_RSVP_PARAMETER,ICAL_RSVP_PARAMETER,"TRUE"}, + {ICAL_RSVP_PARAMETER,ICAL_RSVP_PARAMETER,"FALSE"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_BINARY,"BINARY"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_BOOLEAN,"BOOLEAN"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_DATE,"DATE"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_DURATION,"DURATION"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_FLOAT,"FLOAT"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_INTEGER,"INTEGER"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_PERIOD,"PERIOD"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_RECUR,"RECUR"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_TEXT,"TEXT"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_TIME,"TIME"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_URI,"URI"}, + {ICAL_VALUE_PARAMETER,ICAL_VALUE_XNAME,"ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_COMPONENTPARSEERROR,"COMPONENT_PARSE_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PROPERTYPARSEERROR,"PROPERTY_PARSE_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR,"PARAMETER_NAME_PARSE_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR,"PARAMETER_VALUE_PARSE_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_VALUEPARSEERROR,"VALUE_PARSE_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_INVALIDITIP,"INVALID_ITIP"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_UNKVCALPROP,"UNKNOWN_VCAL_PROP_ERROR"}, + {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_MIMEPARSEERROR,"MIME_PARSE_ERROR"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_EQUAL,"EQUAL"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_NOTEQUAL,"NOTEQUAL"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESS,"LESS"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATER,"GREATER"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESSEQUAL,"LESSEQUAL"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATEREQUAL,"GREATEREQUAL"}, + {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_REGEX,"REGEX"}, + {ICAL_NO_PARAMETER,0,""}, + +}; + + +icalparameter* icalparameter_new_from_string(icalparameter_kind kind, char* val) +{ + int i =0; + icalparameter* param=0; + + icalerror_check_arg_rz((val!=0),"val"); + + switch(kind){ + case ICAL_SENTBY_PARAMETER: + case ICAL_TZID_PARAMETER: + case ICAL_X_PARAMETER: + case ICAL_FMTTYPE_PARAMETER: + case ICAL_LANGUAGE_PARAMETER: + case ICAL_MEMBER_PARAMETER: + case ICAL_DELEGATEDFROM_PARAMETER: + case ICAL_DELEGATEDTO_PARAMETER: + case ICAL_DIR_PARAMETER: + case ICAL_ALTREP_PARAMETER: + case ICAL_CN_PARAMETER: + { + if (impl->string == 0){ return no_parameter;} + strcpy(tend,impl->string);break; + break; + } + + case ICAL_NO_PARAMETER: + case ICAL_ANY_PARAMETER: + { + } + + default: { + /* All other types are enumerated */ + for(i = 0; param_string_map[i].kind != ICAL_NO_PARAMETER){ + if(kind == param_string_map[i].kind && + strcmp(val,param_string_map[i].str) == 0){ + + + } + } + } +} + +#endif + icalparameter* icalparameter_new_from_string(icalparameter_kind kind, char* val) { @@ -427,6 +537,12 @@ icalparameter* icalparameter_new_from_string(icalparameter_kind kind, char* val) else if(strcmp(val,"INVALID_ITIP") == 0){ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); } + else if(strcmp(val,"MIME_PARSE_ERROR") == 0){ + param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_MIMEPARSEERROR); + } + else if(strcmp(val,"UNKNOWN_VCAL_PROP_ERROR") == 0){ + param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_UNKVCALPROP); + } break; } @@ -839,6 +955,14 @@ icalparameter_as_ical_string (icalparameter* parameter) { strcpy(tend,"INVALID_ITIP");break; } + case ICAL_XLICERRORTYPE_UNKVCALPROP: + { + strcpy(tend,"UNKNOWN_VCAL_PROP_ERROR");break; + } + case ICAL_XLICERRORTYPE_MIMEPARSEERROR: + { + strcpy(tend,"MIME_PARSE_ERROR");break; + } } break; } @@ -969,7 +1093,7 @@ icalparameter_set_xname (icalparameter* param, char* v) free(impl->x_name); } - impl->x_name = strdup(v); + impl->x_name = icalmemory_strdup(v); if (impl->x_name == 0){ errno = ENOMEM; @@ -998,7 +1122,7 @@ icalparameter_set_xvalue (icalparameter* param, char* v) free(impl->string); } - impl->string = strdup(v); + impl->string = icalmemory_strdup(v); if (impl->string == 0){ errno = ENOMEM; @@ -1071,7 +1195,7 @@ void icalparameter_set_altrep(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* CN */ @@ -1107,7 +1231,7 @@ void icalparameter_set_cn(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* CUTYPE */ @@ -1184,7 +1308,7 @@ void icalparameter_set_delegatedfrom(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* DELEGATED-TO */ @@ -1220,7 +1344,7 @@ void icalparameter_set_delegatedto(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* DIR */ @@ -1256,7 +1380,7 @@ void icalparameter_set_dir(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* ENCODING */ @@ -1374,7 +1498,7 @@ void icalparameter_set_fmttype(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* LANGUAGE */ @@ -1410,7 +1534,7 @@ void icalparameter_set_language(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* MEMBER */ @@ -1446,7 +1570,7 @@ void icalparameter_set_member(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* PARTSTAT */ @@ -1719,7 +1843,7 @@ void icalparameter_set_sentby(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* TZID */ @@ -1755,7 +1879,7 @@ void icalparameter_set_tzid(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* VALUE */ @@ -1832,7 +1956,7 @@ void icalparameter_set_x(icalparameter* param, char* v) icalerror_check_arg_rv( (param!=0), "param"); icalerror_clear_errno(); - ((struct icalparameter_impl*)param)->string = strdup(v); + ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); } /* X-LIC-ERRORTYPE */ diff --git a/libical/src/libical/icalparameter.h b/libical/src/libical/icalparameter.h index 174cae6f3f..ad97f34e58 100644 --- a/libical/src/libical/icalparameter.h +++ b/libical/src/libical/icalparameter.h @@ -9,20 +9,19 @@ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalparam.h ======================================================================*/ diff --git a/libical/src/libical/icalparser.c b/libical/src/libical/icalparser.c index 3be754036a..b4563e23c9 100644 --- a/libical/src/libical/icalparser.c +++ b/libical/src/libical/icalparser.c @@ -4,6 +4,7 @@ CREATOR: eric 04 August 1999 $Id$ + $Locker$ The contents of this file are subject to the Mozilla Public License @@ -16,11 +17,21 @@ the License for the specific language governing rights and limitations under the License. - The Initial Developer of the Original Code is Eric Busboom - (C) COPYRIGHT 1999 The Software Studio. - 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 Initial Developer of the Original Code is Eric Busboom + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -91,6 +102,7 @@ icalparser* icalparser_new() return (icalparser*)impl; } + void icalparser_free(icalparser* parser) { struct icalparser_impl* impl = (struct icalparser_impl*)parser; @@ -105,6 +117,8 @@ void icalparser_free(icalparser* parser) } pvl_free(impl->components); + + free(impl); } void icalparser_set_gen_data(icalparser* parser, void* data) @@ -115,7 +129,7 @@ void icalparser_set_gen_data(icalparser* parser, void* data) } -icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind, +icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind, char* str, icalproperty **error); @@ -313,7 +327,6 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind) ) { /* The COMMA was followed by 'FREQ', is it a real seperator*/ /* Fall through */ - printf("%s\n",next); } else if (next != 0){ /* Not real, get the next COMMA */ p = next+1; @@ -404,7 +417,8 @@ char* icalparser_get_line(icalparser *parser, /* If the last position in the temp buffer is occupied, mark the buffer as full. The means we will do another read later, because the line is not finished */ - if (impl->temp[impl->tmp_buf_size-1] == 0){ + if (impl->temp[impl->tmp_buf_size-1] == 0 && + impl->temp[impl->tmp_buf_size-2] != '\n'){ impl->buffer_full = 1; } else { impl->buffer_full = 0; @@ -515,7 +529,6 @@ icalcomponent* icalparser_parse(icalparser *parser, do{ line = icalparser_get_line(parser, line_gen_func); - if ((c = icalparser_add_line(parser,line)) != 0){ if (root_component == 0){ /* Just one component */ @@ -538,6 +551,9 @@ icalcomponent* icalparser_parse(icalparser *parser, icalparser_claim(parser); } } + if(line != 0){ + free(line); + } } while ( line != 0); return root_component; @@ -568,7 +584,7 @@ icalcomponent* icalparser_add_line(icalparser* parser, /* Begin by getting the property name at the start of the line. The property name may end up being "BEGIN" or "END" in which case it - is not really a property, but the market for the start or end of + is not really a property, but the marker for the start or end of a component */ end = 0; @@ -591,8 +607,6 @@ icalcomponent* icalparser_add_line(icalparser* parser, /********************************************************************** * Handle begin and end of components **********************************************************************/ - - /* If the property name is BEGIN or END, we are actually starting or ending a new component */ diff --git a/libical/src/libical/icalparser.h b/libical/src/libical/icalparser.h index 25c07eca9f..161127379f 100644 --- a/libical/src/libical/icalparser.h +++ b/libical/src/libical/icalparser.h @@ -6,20 +6,19 @@ $Id$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalparser.h ======================================================================*/ @@ -32,6 +31,16 @@ #include <stdio.h> /* For FILE* */ typedef void* icalparser; + + +/*********************************************************************** + * Line-oriented parsing. + * + * Create a new parser via icalparse_new_parser, then add ines one at + * a time with icalparse_add_line(). icalparser_add_line() will return + * non-zero when it has finished with a component. + ***********************************************************************/ + typedef enum icalparser_state { ICALPARSER_ERROR, ICALPARSER_SUCCESS, @@ -40,6 +49,13 @@ typedef enum icalparser_state { ICALPARSER_IN_PROGRESS } icalparser_state; +icalparser* icalparser_new(); +icalcomponent* icalparser_add_line(icalparser* parser, char* str ); +icalcomponent* icalparser_claim(icalparser* parser); +icalcomponent* icalparser_clean(icalparser* parser); +icalparser_state icalparser_get_state(icalparser* parser); +void icalparser_free(icalparser* parser); + /*********************************************************************** * Message oriented parsing. icalparser_parse takes a string that @@ -51,25 +67,13 @@ typedef enum icalparser_state { icalcomponent* icalparser_parse(icalparser *parser, char* (*line_gen_func)(char *s, size_t size, void *d)); -/* A simple, and incorrect interface - can only return one component*/ -icalcomponent* icalparser_parse_string(char* str); +/* Set the data that icalparser_parse will give to the line_gen_func + as the parameter 'd'*/ +void icalparser_set_gen_data(icalparser* parser, void* data); -/*********************************************************************** - * Line-oriented parsing. - * - * Create a new parser via icalparse_new_parser, then add ines one at - * a time with icalparse_add_line(). icalparser_add_line() will return - * non-zero when it has finished with a component. - ***********************************************************************/ +icalcomponent* icalparser_parse_string(char* str); -icalparser* icalparser_new(); -void icalparser_set_gen_data(icalparser* parser, void* data); -icalcomponent* icalparser_add_line(icalparser* parser, char* str ); -icalcomponent* icalparser_claim(icalparser* parser); -icalcomponent* icalparser_clean(icalparser* parser); -icalparser_state icalparser_get_state(icalparser* parser); -void icalparser_free(icalparser* parser); /*********************************************************************** * Parser support functions @@ -81,14 +85,6 @@ icalvalue* icalparser_parse_value(icalvalue_kind kind, char* str, icalcomponent /* Given a line generator function, return a single iCal content line.*/ char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d)); - -/* a line_gen_function that returns lines from a string. To use it, - set string_line_generator_str to point to the input string, and set - string_line_generator_pos to 0. These globals make the routine not - thead-safe. */ - -extern char* string_line_generator_str; -extern char* string_line_generator_pos; char* string_line_generator(char *out, size_t buf_size, void *d); #endif /* !ICALPARSE_H */ diff --git a/libical/src/libical/icalproperty.c b/libical/src/libical/icalproperty.c index c3fe7c9073..1040215108 100644 --- a/libical/src/libical/icalproperty.c +++ b/libical/src/libical/icalproperty.c @@ -7,20 +7,19 @@ $Id$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icalproperty.c ======================================================================*/ @@ -29,7 +28,7 @@ #include "config.h" #endif -#include <string.h> /* For strdup, rindex */ +#include <string.h> /* For icalmemory_strdup, rindex */ #include <assert.h> #include <stdlib.h> #include <errno.h> @@ -80,7 +79,7 @@ void icalproperty_add_parameters(struct icalproperty_impl *impl,va_list args) icalproperty_add_parameter((icalproperty*)impl, (icalparameter*)vp); } else { - abort(); + assert(0); } } @@ -138,7 +137,7 @@ icalproperty_new_clone(icalproperty* prop) if (old->x_name != 0) { - new->x_name = strdup(old->x_name); + new->x_name = icalmemory_strdup(old->x_name); if (new->x_name == 0) { icalproperty_free(new); @@ -269,6 +268,7 @@ icalproperty_as_ical_string (icalproperty* prop) icalerror_check_arg_rz( (prop!=0),"prop"); + /* Append property name */ if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){ @@ -315,8 +315,9 @@ icalproperty_as_ical_string (icalproperty* prop) value = icalproperty_get_value(prop); if (value != 0){ - icalmemory_append_string(&buf, &buf_ptr, &buf_size, - icalvalue_as_ical_string(icalproperty_get_value(prop))); + char *str = icalvalue_as_ical_string(value); + icalerror_assert((str !=0),"Could not get string representation of a value"); + icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); } else { icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value"); @@ -479,7 +480,7 @@ void icalproperty_set_x_name(icalproperty* prop, char* name) free(impl->x_name); } - impl->x_name = strdup(name); + impl->x_name = icalmemory_strdup(name); if(impl->x_name == 0){ icalerror_set_errno(ICAL_ALLOCATION_ERROR); @@ -569,6 +570,59 @@ icalproperty_method icalproperty_get_method(icalproperty* prop) return icalvalue_get_method(value); } +/* X-LIC-MIMECID */ + +icalproperty* icalproperty_new_xlicmimecid(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECID_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecid((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimecid(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECID_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecid((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimecid(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimecid(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + /* LAST-MODIFIED */ icalproperty* icalproperty_new_lastmodified(struct icaltimetype v) @@ -1193,6 +1247,112 @@ char* icalproperty_get_contact(icalproperty* prop) return icalvalue_get_text(value); } +/* X-LIC-MIMECONTENTTYPE */ + +icalproperty* icalproperty_new_xlicmimecontenttype(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECONTENTTYPE_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecontenttype((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimecontenttype(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECONTENTTYPE_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecontenttype((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimecontenttype(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimecontenttype(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + +/* X-LIC-MIMEOPTINFO */ + +icalproperty* icalproperty_new_xlicmimeoptinfo(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEOPTINFO_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimeoptinfo((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimeoptinfo(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEOPTINFO_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimeoptinfo((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + /* RELATED-TO */ icalproperty* icalproperty_new_relatedto(char* v) @@ -1352,6 +1512,59 @@ char* icalproperty_get_comment(icalproperty* prop) return icalvalue_get_text(value); } +/* X-LIC-ERROR */ + +icalproperty* icalproperty_new_xlicerror(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicerror((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicerror(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicerror((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicerror(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_text(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicerror(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_text(value); +} + /* TRIGGER */ icalproperty* icalproperty_new_trigger(union icaltriggertype v) @@ -1402,27 +1615,27 @@ union icaltriggertype icalproperty_get_trigger(icalproperty* prop) return icalvalue_get_trigger(value); } -/* X-LIC-ERROR */ +/* CLASS */ -icalproperty* icalproperty_new_xlicerror(char* v) +icalproperty* icalproperty_new_class(char* v) { - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); - icalproperty_set_xlicerror((icalproperty*)impl,v); + icalproperty_set_class((icalproperty*)impl,v); return (icalproperty*)impl; } -icalproperty* icalproperty_vanew_xlicerror(char* v, ...) +icalproperty* icalproperty_vanew_class(char* v, ...) { va_list args; - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); - icalproperty_set_xlicerror((icalproperty*)impl,v); + icalproperty_set_class((icalproperty*)impl,v); va_start(args,v); icalproperty_add_parameters(impl, args); @@ -1431,7 +1644,7 @@ icalproperty* icalproperty_vanew_xlicerror(char* v, ...) return (icalproperty*)impl; } -void icalproperty_set_xlicerror(icalproperty* prop, char* v) +void icalproperty_set_class(icalproperty* prop, char* v) { icalvalue *value; @@ -1445,7 +1658,7 @@ void icalproperty_set_xlicerror(icalproperty* prop, char* v) } -char* icalproperty_get_xlicerror(icalproperty* prop) +char* icalproperty_get_class(icalproperty* prop) { icalvalue *value; icalerror_check_arg( (prop!=0),"prop"); @@ -1455,27 +1668,27 @@ char* icalproperty_get_xlicerror(icalproperty* prop) return icalvalue_get_text(value); } -/* CLASS */ +/* X */ -icalproperty* icalproperty_new_class(char* v) +icalproperty* icalproperty_new_x(char* v) { - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_X_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); - icalproperty_set_class((icalproperty*)impl,v); + icalproperty_set_x((icalproperty*)impl,v); return (icalproperty*)impl; } -icalproperty* icalproperty_vanew_class(char* v, ...) +icalproperty* icalproperty_vanew_x(char* v, ...) { va_list args; - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_X_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); - icalproperty_set_class((icalproperty*)impl,v); + icalproperty_set_x((icalproperty*)impl,v); va_start(args,v); icalproperty_add_parameters(impl, args); @@ -1484,7 +1697,7 @@ icalproperty* icalproperty_vanew_class(char* v, ...) return (icalproperty*)impl; } -void icalproperty_set_class(icalproperty* prop, char* v) +void icalproperty_set_x(icalproperty* prop, char* v) { icalvalue *value; @@ -1498,7 +1711,7 @@ void icalproperty_set_class(icalproperty* prop, char* v) } -char* icalproperty_get_class(icalproperty* prop) +char* icalproperty_get_x(icalproperty* prop) { icalvalue *value; icalerror_check_arg( (prop!=0),"prop"); @@ -1611,6 +1824,59 @@ char* icalproperty_get_transp(icalproperty* prop) return icalvalue_get_text(value); } +/* X-LIC-MIMEENCODING */ + +icalproperty* icalproperty_new_xlicmimeencoding(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEENCODING_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimeencoding((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimeencoding(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEENCODING_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimeencoding((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimeencoding(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimeencoding(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + /* SEQUENCE */ icalproperty* icalproperty_new_sequence(int v) @@ -2432,6 +2698,59 @@ struct icalperiodtype icalproperty_get_rdate(icalproperty* prop) return icalvalue_get_datetimeperiod(value); } +/* X-LIC-MIMEFILENAME */ + +icalproperty* icalproperty_new_xlicmimefilename(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEFILENAME_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimefilename((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimefilename(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEFILENAME_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimefilename((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimefilename(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimefilename(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + /* URL */ icalproperty* icalproperty_new_url(char* v) @@ -2485,25 +2804,25 @@ char* icalproperty_get_url(icalproperty* prop) return icalvalue_get_uri(value); } -/* ATTACH */ +/* X-LIC-CLUSTERCOUNT */ -icalproperty* icalproperty_new_attach(struct icalattachtype v) +icalproperty* icalproperty_new_xlicclustercount(int v) { - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); - icalproperty_set_attach((icalproperty*)impl,v); + icalproperty_set_xlicclustercount((icalproperty*)impl,v); return (icalproperty*)impl; } -icalproperty* icalproperty_vanew_attach(struct icalattachtype v, ...) +icalproperty* icalproperty_vanew_xlicclustercount(int v, ...) { va_list args; - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); - icalproperty_set_attach((icalproperty*)impl,v); + icalproperty_set_xlicclustercount((icalproperty*)impl,v); va_start(args,v); icalproperty_add_parameters(impl, args); @@ -2512,48 +2831,48 @@ icalproperty* icalproperty_vanew_attach(struct icalattachtype v, ...) return (icalproperty*)impl; } -void icalproperty_set_attach(icalproperty* prop, struct icalattachtype v) +void icalproperty_set_xlicclustercount(icalproperty* prop, int v) { icalvalue *value; icalerror_check_arg_rv( (prop!=0),"prop"); - value = icalvalue_new_attach(v); + value = icalvalue_new_integer(v); icalproperty_set_value(prop,value); } -struct icalattachtype icalproperty_get_attach(icalproperty* prop) +int icalproperty_get_xlicclustercount(icalproperty* prop) { icalvalue *value; icalerror_check_arg( (prop!=0),"prop"); value = icalproperty_get_value(prop); - return icalvalue_get_attach(value); + return icalvalue_get_integer(value); } -/* X-LIC-CLUSTERCOUNT */ +/* ATTACH */ -icalproperty* icalproperty_new_xlicclustercount(int v) +icalproperty* icalproperty_new_attach(struct icalattachtype v) { - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); - icalproperty_set_xlicclustercount((icalproperty*)impl,v); + icalproperty_set_attach((icalproperty*)impl,v); return (icalproperty*)impl; } -icalproperty* icalproperty_vanew_xlicclustercount(int v, ...) +icalproperty* icalproperty_vanew_attach(struct icalattachtype v, ...) { va_list args; - struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); - icalproperty_set_xlicclustercount((icalproperty*)impl,v); + icalproperty_set_attach((icalproperty*)impl,v); va_start(args,v); icalproperty_add_parameters(impl, args); @@ -2562,27 +2881,27 @@ icalproperty* icalproperty_vanew_xlicclustercount(int v, ...) return (icalproperty*)impl; } -void icalproperty_set_xlicclustercount(icalproperty* prop, int v) +void icalproperty_set_attach(icalproperty* prop, struct icalattachtype v) { icalvalue *value; icalerror_check_arg_rv( (prop!=0),"prop"); - value = icalvalue_new_integer(v); + value = icalvalue_new_attach(v); icalproperty_set_value(prop,value); } -int icalproperty_get_xlicclustercount(icalproperty* prop) +struct icalattachtype icalproperty_get_attach(icalproperty* prop) { icalvalue *value; icalerror_check_arg( (prop!=0),"prop"); value = icalproperty_get_value(prop); - return icalvalue_get_integer(value); + return icalvalue_get_attach(value); } /* EXRULE */ @@ -2891,6 +3210,59 @@ struct icalgeotype icalproperty_get_geo(icalproperty* prop) return icalvalue_get_geo(value); } +/* X-LIC-MIMECHARSET */ + +icalproperty* icalproperty_new_xlicmimecharset(char* v) +{ + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECHARSET_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecharset((icalproperty*)impl,v); + + return (icalproperty*)impl; +} + +icalproperty* icalproperty_vanew_xlicmimecharset(char* v, ...) +{ + va_list args; + struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECHARSET_PROPERTY); + icalerror_check_arg_rz( (v!=0),"v"); + + + icalproperty_set_xlicmimecharset((icalproperty*)impl,v); + + va_start(args,v); + icalproperty_add_parameters(impl, args); + va_end(args); + + return (icalproperty*)impl; +} + +void icalproperty_set_xlicmimecharset(icalproperty* prop, char* v) +{ + icalvalue *value; + + icalerror_check_arg_rv( (v!=0),"v"); + + icalerror_check_arg_rv( (prop!=0),"prop"); + + value = icalvalue_new_string(v); + + icalproperty_set_value(prop,value); + +} + +char* icalproperty_get_xlicmimecharset(icalproperty* prop) +{ + icalvalue *value; + icalerror_check_arg( (prop!=0),"prop"); + + value = icalproperty_get_value(prop); + + return icalvalue_get_string(value); +} + /* COMPLETED */ icalproperty* icalproperty_new_completed(struct icaltimetype v) diff --git a/libical/src/libical/icalproperty.h b/libical/src/libical/icalproperty.h index 2cd28fe179..278c4d533f 100644 --- a/libical/src/libical/icalproperty.h +++ b/libical/src/libical/icalproperty.h @@ -5,20 +5,7 @@ $Id$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ @@ -63,7 +50,6 @@ icalvalue* icalproperty_get_value(icalproperty* prop); void icalproperty_set_x_name(icalproperty* prop, char* name); char* icalproperty_get_x_name(icalproperty* prop); - /* Everything below this line is machine generated. Do not edit. */ /* METHOD */ @@ -72,6 +58,12 @@ icalproperty* icalproperty_vanew_method(icalproperty_method v, ...); void icalproperty_set_method(icalproperty* prop, icalproperty_method v); icalproperty_method icalproperty_get_method(icalproperty* prop); +/* X-LIC-MIMECID */ +icalproperty* icalproperty_new_xlicmimecid(char* v); +icalproperty* icalproperty_vanew_xlicmimecid(char* v, ...); +void icalproperty_set_xlicmimecid(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimecid(icalproperty* prop); + /* LAST-MODIFIED */ icalproperty* icalproperty_new_lastmodified(struct icaltimetype v); icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...); @@ -144,6 +136,18 @@ icalproperty* icalproperty_vanew_contact(char* v, ...); void icalproperty_set_contact(icalproperty* prop, char* v); char* icalproperty_get_contact(icalproperty* prop); +/* X-LIC-MIMECONTENTTYPE */ +icalproperty* icalproperty_new_xlicmimecontenttype(char* v); +icalproperty* icalproperty_vanew_xlicmimecontenttype(char* v, ...); +void icalproperty_set_xlicmimecontenttype(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimecontenttype(icalproperty* prop); + +/* X-LIC-MIMEOPTINFO */ +icalproperty* icalproperty_new_xlicmimeoptinfo(char* v); +icalproperty* icalproperty_vanew_xlicmimeoptinfo(char* v, ...); +void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop); + /* RELATED-TO */ icalproperty* icalproperty_new_relatedto(char* v); icalproperty* icalproperty_vanew_relatedto(char* v, ...); @@ -162,24 +166,30 @@ icalproperty* icalproperty_vanew_comment(char* v, ...); void icalproperty_set_comment(icalproperty* prop, char* v); char* icalproperty_get_comment(icalproperty* prop); -/* TRIGGER */ -icalproperty* icalproperty_new_trigger(union icaltriggertype v); -icalproperty* icalproperty_vanew_trigger(union icaltriggertype v, ...); -void icalproperty_set_trigger(icalproperty* prop, union icaltriggertype v); -union icaltriggertype icalproperty_get_trigger(icalproperty* prop); - /* X-LIC-ERROR */ icalproperty* icalproperty_new_xlicerror(char* v); icalproperty* icalproperty_vanew_xlicerror(char* v, ...); void icalproperty_set_xlicerror(icalproperty* prop, char* v); char* icalproperty_get_xlicerror(icalproperty* prop); +/* TRIGGER */ +icalproperty* icalproperty_new_trigger(union icaltriggertype v); +icalproperty* icalproperty_vanew_trigger(union icaltriggertype v, ...); +void icalproperty_set_trigger(icalproperty* prop, union icaltriggertype v); +union icaltriggertype icalproperty_get_trigger(icalproperty* prop); + /* CLASS */ icalproperty* icalproperty_new_class(char* v); icalproperty* icalproperty_vanew_class(char* v, ...); void icalproperty_set_class(icalproperty* prop, char* v); char* icalproperty_get_class(icalproperty* prop); +/* X */ +icalproperty* icalproperty_new_x(char* v); +icalproperty* icalproperty_vanew_x(char* v, ...); +void icalproperty_set_x(icalproperty* prop, char* v); +char* icalproperty_get_x(icalproperty* prop); + /* TZOFFSETTO */ icalproperty* icalproperty_new_tzoffsetto(int v); icalproperty* icalproperty_vanew_tzoffsetto(int v, ...); @@ -192,6 +202,12 @@ icalproperty* icalproperty_vanew_transp(char* v, ...); void icalproperty_set_transp(icalproperty* prop, char* v); char* icalproperty_get_transp(icalproperty* prop); +/* X-LIC-MIMEENCODING */ +icalproperty* icalproperty_new_xlicmimeencoding(char* v); +icalproperty* icalproperty_vanew_xlicmimeencoding(char* v, ...); +void icalproperty_set_xlicmimeencoding(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimeencoding(icalproperty* prop); + /* SEQUENCE */ icalproperty* icalproperty_new_sequence(int v); icalproperty* icalproperty_vanew_sequence(int v, ...); @@ -288,24 +304,30 @@ icalproperty* icalproperty_vanew_rdate(struct icalperiodtype v, ...); void icalproperty_set_rdate(icalproperty* prop, struct icalperiodtype v); struct icalperiodtype icalproperty_get_rdate(icalproperty* prop); +/* X-LIC-MIMEFILENAME */ +icalproperty* icalproperty_new_xlicmimefilename(char* v); +icalproperty* icalproperty_vanew_xlicmimefilename(char* v, ...); +void icalproperty_set_xlicmimefilename(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimefilename(icalproperty* prop); + /* URL */ icalproperty* icalproperty_new_url(char* v); icalproperty* icalproperty_vanew_url(char* v, ...); void icalproperty_set_url(icalproperty* prop, char* v); char* icalproperty_get_url(icalproperty* prop); -/* ATTACH */ -icalproperty* icalproperty_new_attach(struct icalattachtype v); -icalproperty* icalproperty_vanew_attach(struct icalattachtype v, ...); -void icalproperty_set_attach(icalproperty* prop, struct icalattachtype v); -struct icalattachtype icalproperty_get_attach(icalproperty* prop); - /* X-LIC-CLUSTERCOUNT */ icalproperty* icalproperty_new_xlicclustercount(int v); icalproperty* icalproperty_vanew_xlicclustercount(int v, ...); void icalproperty_set_xlicclustercount(icalproperty* prop, int v); int icalproperty_get_xlicclustercount(icalproperty* prop); +/* ATTACH */ +icalproperty* icalproperty_new_attach(struct icalattachtype v); +icalproperty* icalproperty_vanew_attach(struct icalattachtype v, ...); +void icalproperty_set_attach(icalproperty* prop, struct icalattachtype v); +struct icalattachtype icalproperty_get_attach(icalproperty* prop); + /* EXRULE */ icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v); icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...); @@ -342,6 +364,12 @@ icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...); void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v); struct icalgeotype icalproperty_get_geo(icalproperty* prop); +/* X-LIC-MIMECHARSET */ +icalproperty* icalproperty_new_xlicmimecharset(char* v); +icalproperty* icalproperty_vanew_xlicmimecharset(char* v, ...); +void icalproperty_set_xlicmimecharset(icalproperty* prop, char* v); +char* icalproperty_get_xlicmimecharset(icalproperty* prop); + /* COMPLETED */ icalproperty* icalproperty_new_completed(struct icaltimetype v); icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...); diff --git a/libical/src/libical/icalrestriction.c b/libical/src/libical/icalrestriction.c index 8371e87545..be0e292d28 100644 --- a/libical/src/libical/icalrestriction.c +++ b/libical/src/libical/icalrestriction.c @@ -2,20 +2,7 @@ /* ====================================================================== File: icalrestriction.c - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -1466,7 +1453,7 @@ icalrestriction_property_record icalrestriction_property_records[] = { {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, - {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE} + {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE,0} }; icalrestriction_component_record icalrestriction_component_records[] = { {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_VALARM_COMPONENT,ICAL_RESTRICTION_ZEROPLUS,0}, @@ -1596,5 +1583,5 @@ icalrestriction_component_record icalrestriction_component_records[] = { {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VEVENT_COMPONENT,ICAL_RESTRICTION_ZERO,0}, {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VFREEBUSY_COMPONENT,ICAL_RESTRICTION_ZERO,0}, {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VTODO_COMPONENT,ICAL_RESTRICTION_ZERO,0}, - {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE} + {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE,0} }; diff --git a/libical/src/libical/icalrestriction.h b/libical/src/libical/icalrestriction.h index ca4beeea7b..12421d0f32 100644 --- a/libical/src/libical/icalrestriction.h +++ b/libical/src/libical/icalrestriction.h @@ -6,20 +6,19 @@ $Id$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalrestriction.h Contributions from: diff --git a/libical/src/libical/icaltypes.c b/libical/src/libical/icaltypes.c index b60333887e..c7017eb2af 100644 --- a/libical/src/libical/icaltypes.c +++ b/libical/src/libical/icaltypes.c @@ -7,20 +7,19 @@ $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icaltypes.c ======================================================================*/ @@ -31,9 +30,9 @@ #include "icaltypes.h" #include "icalerror.h" #include "icalmemory.h" -#include <stdlib.h> /* for malloc */ +#include <stdlib.h> /* for malloc and abs() */ #include <errno.h> /* for errno */ -#include <string.h> /* for strdup */ +#include <string.h> /* for icalmemory_strdup */ #include <assert.h> #include <limits.h> /* for SHRT_MAX */ @@ -106,9 +105,9 @@ void icalattachtype_set_url(struct icalattachtype* v, char* url) free (v->url); } - v->url = strdup(url); + v->url = icalmemory_strdup(url); - /* HACK This routine should do something if strdup returns NULL */ + /* HACK This routine should do something if icalmemory_strdup returns NULL */ } @@ -159,28 +158,6 @@ icalperiodtype_duration (struct icalperiodtype period); time_t icalperiodtype_end (struct icalperiodtype period); -struct icaltimetype -icaltimetype_from_timet(time_t v, int date) -{ - struct icaltimetype tt; - struct tm t; - time_t tm = time(&v); - -/* HACK Does not properly consider timezone */ - t = *(gmtime(&tm)); - - tt.second = t.tm_sec; - tt.minute = t.tm_min; - tt.hour = t.tm_hour; - tt.day = t.tm_mday; - tt.month = t.tm_mon + 1; - tt.year = t.tm_year+ 1900; - - tt.is_utc = 1; - tt.is_date = date; - - return tt; -} /* From Russel Steinthal */ time_t icaldurationtype_as_timet(struct icaldurationtype dur) @@ -210,7 +187,7 @@ struct icaldurationtype icaldurationtype_from_timet(time_t t) return dur; } - + void icalrecurrencetype_clear(struct icalrecurrencetype *recur) { memset(recur,ICAL_RECURRENCE_ARRAY_MAX_BYTE, @@ -218,16 +195,34 @@ void icalrecurrencetype_clear(struct icalrecurrencetype *recur) recur->week_start = ICAL_NO_WEEKDAY; recur->freq = ICAL_NO_RECURRENCE; - recur->interval = 0; - recur->until.year = 0; + recur->interval = 1; + memset(&(recur->until),0,sizeof(struct icaltimetype)); recur->count = 0; } +/* The 'day' element of icalrecurrencetype_weekday is encoded to allow +reporesentation 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's position in the period ( Nth-ness) and the numerical value +of the day are encoded together as: pos*7 + dow + */ + +enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day) +{ + return abs(day)%8; +} + +short icalrecurrencetype_day_position(short day) +{ + return (day-icalrecurrencetype_day_day_of_week(day))/8; +} + struct icalreqstattype icalreqstattype_from_string(char* str) { char *p1,*p2; - size_t len; struct icalreqstattype stat; int major, minor; @@ -235,7 +230,6 @@ struct icalreqstattype icalreqstattype_from_string(char* str) stat.code = ICAL_UNKNOWN_STATUS; stat.debug = 0; - stat.desc = 0; /* Get the status numbers */ @@ -278,7 +272,6 @@ struct icalreqstattype icalreqstattype_from_string(char* str) char* icalreqstattype_as_string(struct icalreqstattype stat) { - char format[20]; char *temp; temp = (char*)icalmemory_tmp_buffer(TEMP_MAX); diff --git a/libical/src/libical/icaltypes.h b/libical/src/libical/icaltypes.h index 77a67fae80..1130ab2457 100644 --- a/libical/src/libical/icaltypes.h +++ b/libical/src/libical/icaltypes.h @@ -4,20 +4,19 @@ CREATOR: eric 20 March 1999 - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icaltypes.h ======================================================================*/ @@ -27,6 +26,7 @@ #include <time.h> #include "icalenums.h" /* for recurrence enums */ +#include "icaltime.h" /* This type type should probably be an opaque type... */ struct icalattachtype @@ -67,21 +67,6 @@ struct icalgeotype float lon; }; -struct icaltimetype -{ - int year; - int month; - int day; - int hour; - int minute; - int second; - - int is_utc; /* 1-> time is in UTC timezone */ - - int is_date; /* 1 -> interpret this as date. */ -}; - -struct icaltimetype icaltimetype_from_timet(time_t v, int is_date); /* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of @@ -112,7 +97,7 @@ struct icalrecurrencetype short by_second[61]; short by_minute[61]; short by_hour[25]; - short by_day[8]; + short by_day[8]; /* Encoded value, see below */ short by_month_day[32]; short by_year_day[367]; short by_week_no[54]; @@ -123,6 +108,17 @@ struct icalrecurrencetype void icalrecurrencetype_clear(struct icalrecurrencetype *r); +/* The 'day' element of icalrecurrencetype_weekday is encoded to allow +reporesentation 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. */ +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 */ +short icalrecurrencetype_day_position(short day); + struct icaldurationtype { unsigned int days; @@ -171,7 +167,7 @@ operating on a the value of a request_status property. */ struct icalreqstattype { - icalrequeststatus code; + icalrequeststatus code; char* desc; char* debug; }; diff --git a/libical/src/libical/icalvalue.c b/libical/src/libical/icalvalue.c index 79eb8d827a..db0e58efe8 100644 --- a/libical/src/libical/icalvalue.c +++ b/libical/src/libical/icalvalue.c @@ -5,21 +5,19 @@ $Id$ + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - (C) COPYRIGHT 1999 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 contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + 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 author is Eric Busboom The original code is icalvalue.c Contributions from: @@ -49,7 +47,7 @@ #include <limits.h> /* for SHRT_MAX */ #if _MAC_OS_ -#include "strdup.h" +#include "icalmemory_strdup.h" #endif #define TMP_BUF_SIZE 1024 @@ -88,8 +86,10 @@ struct icalvalue_impl { /*struct icaltimetype v_datetime;*/ /*struct icaltimetype v_datetimedate;*/ - /* struct icalrecurrencetype was once a value in this - union, but it contributes 2000 bytes to every*/ + /* struct icalrecurrencetype was once included + directly ( not referenced ) in this union, but it + contributes 2000 bytes to every value, so now it is + a reference*/ struct icalrecurrencetype *v_recur; union icaltriggertype v_trigger; @@ -159,7 +159,7 @@ icalvalue* icalvalue_new_clone(icalvalue* value){ case ICAL_URI_VALUE: { if (old->data.v_string != 0) { - new->data.v_string=strdup(old->data.v_string); + new->data.v_string=icalmemory_strdup(old->data.v_string); if ( new->data.v_string == 0 ) { return 0; @@ -195,7 +195,7 @@ icalvalue* icalvalue_new_clone(icalvalue* value){ return new; } -char* strdup_and_dequote(char* str) +char* icalmemory_strdup_and_dequote(char* str) { char* p; char* out = (char*)malloc(sizeof(char) * strlen(str) +1); @@ -343,7 +343,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,char* str,ic case ICAL_TEXT_VALUE: { - char* dequoted_str = strdup_and_dequote(str); + char* dequoted_str = icalmemory_strdup_and_dequote(str); value = icalvalue_new_text(dequoted_str); free(dequoted_str); break; @@ -663,8 +663,11 @@ char* icalvalue_recur_as_ical_string(icalvalue* value) for(i=0; i< limit && array[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){ if (j == 3) { /* BYDAY */ - icalmemory_append_string(&str,&str_p,&buf_sz, - icalenum_weekday_to_string(array[i])); + short dow = icalrecurrencetype_day_day_of_week(array[i]); + char *daystr = icalenum_weekday_to_string(dow); + + /* HACK, does not correctly handle the integer value */ + icalmemory_append_string(&str,&str_p,&buf_sz,daystr); } else { sprintf(temp,"%d",array[i]); icalmemory_append_string(&str,&str_p,&buf_sz, temp); @@ -1369,6 +1372,7 @@ icalvalue_set_attach(icalvalue* value, struct icalattachtype v) icalerror_check_value_type(value, ICAL_ATTACH_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_attach = v; } @@ -1405,6 +1409,8 @@ icalvalue_set_binary(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_BINARY_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ @@ -1444,6 +1450,7 @@ icalvalue_set_boolean(icalvalue* value, int v) icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_int = v; } @@ -1480,6 +1487,8 @@ icalvalue_set_caladdress(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ @@ -1519,6 +1528,7 @@ icalvalue_set_date(icalvalue* value, struct icaltimetype v) icalerror_check_value_type(value, ICAL_DATE_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_time = v; } @@ -1553,6 +1563,7 @@ icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) icalerror_check_value_type(value, ICAL_DATETIME_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_time = v; } @@ -1587,6 +1598,7 @@ icalvalue_set_datetimedate(icalvalue* value, struct icaltimetype v) icalerror_check_value_type(value, ICAL_DATETIMEDATE_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_time = v; } @@ -1621,6 +1633,7 @@ icalvalue_set_datetimeperiod(icalvalue* value, struct icalperiodtype v) icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_period = v; } @@ -1655,6 +1668,7 @@ icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) icalerror_check_value_type(value, ICAL_DURATION_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_duration = v; } @@ -1689,6 +1703,7 @@ icalvalue_set_float(icalvalue* value, float v) icalerror_check_value_type(value, ICAL_FLOAT_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_float = v; } @@ -1723,6 +1738,7 @@ icalvalue_set_geo(icalvalue* value, struct icalgeotype v) icalerror_check_value_type(value, ICAL_GEO_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_geo = v; } @@ -1757,6 +1773,7 @@ icalvalue_set_integer(icalvalue* value, int v) icalerror_check_value_type(value, ICAL_INTEGER_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_int = v; } @@ -1791,6 +1808,7 @@ icalvalue_set_method(icalvalue* value, icalproperty_method v) icalerror_check_value_type(value, ICAL_METHOD_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_method = v; } @@ -1825,6 +1843,7 @@ icalvalue_set_period(icalvalue* value, struct icalperiodtype v) icalerror_check_value_type(value, ICAL_PERIOD_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_period = v; } @@ -1837,7 +1856,6 @@ icalvalue_get_period(icalvalue* value) return ((struct icalvalue_impl*)value)->data.v_period; } - icalvalue* icalvalue_new_string (char* v) { @@ -1861,6 +1879,8 @@ icalvalue_set_string(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_STRING_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ @@ -1878,6 +1898,7 @@ icalvalue_get_string(icalvalue* value) return ((struct icalvalue_impl*)value)->data.v_string; } + icalvalue* icalvalue_new_text (char* v) { @@ -1901,6 +1922,8 @@ icalvalue_set_text(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_TEXT_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ @@ -1940,6 +1963,7 @@ icalvalue_set_time(icalvalue* value, struct icaltimetype v) icalerror_check_value_type(value, ICAL_TIME_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_time = v; } @@ -1974,6 +1998,7 @@ icalvalue_set_trigger(icalvalue* value, union icaltriggertype v) icalerror_check_value_type(value, ICAL_TRIGGER_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_trigger = v; } @@ -2010,6 +2035,8 @@ icalvalue_set_uri(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_URI_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ @@ -2049,6 +2076,7 @@ icalvalue_set_utcoffset(icalvalue* value, int v) icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE); impl = (struct icalvalue_impl*)value; + impl->data.v_int = v; } @@ -2085,6 +2113,8 @@ icalvalue_set_query(icalvalue* value, char* v) icalerror_check_value_type(value, ICAL_QUERY_VALUE); impl = (struct icalvalue_impl*)value; + if(impl->data.v_string!=0) {free(impl->data.v_string);} + impl->data.v_string = strdup(v); if (impl->data.v_string == 0){ diff --git a/libical/src/libical/icalvalue.h b/libical/src/libical/icalvalue.h index ec7457d6aa..18c15abaf4 100644 --- a/libical/src/libical/icalvalue.h +++ b/libical/src/libical/icalvalue.h @@ -9,20 +9,19 @@ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalvalue.h ======================================================================*/ diff --git a/libical/src/libical/icalyacc.c b/libical/src/libical/icalyacc.c index 46de31370d..04999747db 100644 --- a/libical/src/libical/icalyacc.c +++ b/libical/src/libical/icalyacc.c @@ -145,20 +145,19 @@ $Id$ $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The original author is Eric Busboom + (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 icalitip.y @@ -189,6 +188,7 @@ struct icaldurationtype duration; struct icalrecurrencetype recur; short skiplist[367]; short skippos; +int dow_pos; void copy_list(short* array, size_t size); void clear_recur(); @@ -207,7 +207,7 @@ void ical_yy_error(char *s); /* Don't know why I need this.... */ VALUEs, that is, ) correctly. */ -#line 75 "icalyacc.y" +#line 76 "icalyacc.y" typedef union { float v_float; int v_int; @@ -274,7 +274,7 @@ typedef union { -#define YYFINAL 135 +#define YYFINAL 137 #define YYFLAG -32768 #define YYNTBASE 141 @@ -329,10 +329,10 @@ static const short yyprhs[] = { 0, 42, 45, 48, 51, 54, 57, 61, 64, 68, 71, 74, 75, 77, 79, 83, 87, 91, 101, 108, 112, 116, 120, 124, 128, 132, 136, 138, 140, 142, 144, - 146, 148, 150, 152, 155, 159, 161, 165, 169, 173, - 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, - 217, 221, 225, 229, 233, 237, 241, 245, 246, 250, - 253, 255, 257, 261 + 146, 148, 150, 152, 155, 159, 164, 166, 170, 174, + 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, + 218, 222, 226, 230, 234, 238, 242, 246, 250, 251, + 255, 258, 260, 262, 266 }; static const short yyrhs[] = { 142, @@ -351,33 +351,33 @@ static const short yyrhs[] = { 142, 8, 26, 0, 16, 8, 30, 0, 16, 8, 28, 0, 16, 8, 32, 0, 39, 0, 37, 0, 40, 0, 41, 0, 42, 0, 43, 0, 38, 0, 159, - 0, 3, 159, 0, 160, 11, 159, 0, 3, 0, - 161, 11, 3, 0, 33, 8, 3, 0, 36, 8, - 39, 0, 36, 8, 37, 0, 36, 8, 40, 0, - 36, 8, 41, 0, 36, 8, 42, 0, 36, 8, - 43, 0, 36, 8, 38, 0, 22, 8, 161, 0, - 19, 8, 161, 0, 18, 8, 161, 0, 17, 8, - 160, 0, 20, 8, 161, 0, 21, 8, 161, 0, - 25, 8, 161, 0, 24, 8, 161, 0, 23, 8, - 161, 0, 35, 8, 147, 0, 35, 8, 144, 0, - 34, 8, 3, 0, 0, 163, 12, 162, 0, 158, - 163, 0, 137, 0, 138, 0, 165, 4, 4, 0, - 165, 4, 4, 4, 0 + 0, 3, 159, 0, 160, 11, 159, 0, 160, 11, + 3, 159, 0, 3, 0, 161, 11, 3, 0, 33, + 8, 3, 0, 36, 8, 39, 0, 36, 8, 37, + 0, 36, 8, 40, 0, 36, 8, 41, 0, 36, + 8, 42, 0, 36, 8, 43, 0, 36, 8, 38, + 0, 22, 8, 161, 0, 19, 8, 161, 0, 18, + 8, 161, 0, 17, 8, 160, 0, 20, 8, 161, + 0, 21, 8, 161, 0, 25, 8, 161, 0, 24, + 8, 161, 0, 23, 8, 161, 0, 35, 8, 147, + 0, 35, 8, 144, 0, 34, 8, 3, 0, 0, + 163, 12, 162, 0, 158, 163, 0, 137, 0, 138, + 0, 165, 4, 4, 0, 165, 4, 4, 4, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, - 158, 160, 161, 162, 163, 164, 165, 166, 167, 173, - 175, 178, 181, 196, 198, 201, 203, 205, 221, 222, - 224, 229, 232, 235, 239, 243, 248, 252, 257, 262, - 267, 270, 273, 277, 282, 287, 296, 317, 349, 351, - 352, 353, 354, 355, 356, 360, 362, 363, 364, 365, - 366, 367, 371, 373, 374, 377, 379, 382, 384, 385, - 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, - 396, 397, 398, 399, 400, 403, 406, 410, 412, 414, - 422, 423, 425, 431 + 159, 161, 162, 163, 164, 165, 166, 167, 168, 174, + 176, 179, 182, 197, 199, 202, 204, 206, 222, 223, + 225, 230, 233, 236, 240, 244, 249, 253, 258, 263, + 268, 271, 274, 278, 283, 288, 297, 318, 350, 352, + 353, 354, 355, 356, 357, 361, 364, 366, 368, 370, + 372, 374, 379, 381, 382, 383, 386, 388, 391, 393, + 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, + 404, 405, 406, 407, 408, 409, 412, 415, 419, 421, + 423, 431, 432, 434, 440 }; #endif @@ -415,10 +415,10 @@ static const short yyr1[] = { 0, 149, 150, 150, 150, 151, 151, 152, 152, 153, 154, 155, 155, 155, 156, 156, 156, 157, 157, 158, 158, 158, 158, 158, 158, 158, 159, 159, 159, 159, 159, - 159, 159, 160, 160, 160, 161, 161, 162, 162, 162, + 159, 159, 160, 160, 160, 160, 161, 161, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, - 162, 162, 162, 162, 162, 162, 162, 163, 163, 164, - 165, 165, 166, 166 + 162, 162, 162, 162, 162, 162, 162, 162, 163, 163, + 164, 165, 165, 166, 166 }; static const short yyr2[] = { 0, @@ -427,55 +427,55 @@ static const short yyr2[] = { 0, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 0, 1, 1, 3, 3, 3, 9, 6, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 3, 1, 3, 3, 3, 3, + 1, 1, 1, 2, 3, 4, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 0, 3, 2, - 1, 1, 3, 4 + 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, + 2, 1, 1, 3, 4 }; static const short yydefact[] = { 0, 9, 13, 11, 12, 0, 10, 32, 33, 1, 2, - 3, 4, 0, 5, 6, 78, 7, 0, 8, 0, - 0, 0, 80, 0, 14, 42, 40, 44, 39, 43, - 41, 45, 0, 0, 34, 36, 35, 19, 0, 83, + 3, 4, 0, 5, 6, 79, 7, 0, 8, 0, + 0, 0, 81, 0, 14, 42, 40, 44, 39, 43, + 41, 45, 0, 0, 34, 36, 35, 19, 0, 84, 15, 18, 21, 30, 0, 22, 23, 24, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 79, 84, 31, 25, 27, 29, 0, 0, + 0, 0, 80, 85, 31, 25, 27, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 33, 38, 0, 26, 0, 28, 0, - 47, 52, 46, 48, 49, 50, 51, 53, 69, 56, - 68, 67, 70, 71, 66, 74, 73, 72, 58, 77, - 13, 76, 75, 60, 65, 59, 61, 62, 63, 64, - 0, 54, 0, 0, 0, 16, 55, 57, 14, 17, - 37, 18, 0, 0, 0 + 47, 52, 46, 48, 49, 50, 51, 53, 70, 57, + 69, 68, 71, 72, 67, 75, 74, 73, 59, 78, + 13, 77, 76, 61, 66, 60, 62, 63, 64, 65, + 0, 54, 0, 0, 0, 16, 0, 55, 58, 14, + 17, 37, 56, 18, 0, 0, 0 }; -static const short yydefgoto[] = { 133, - 9, 10, 11, 42, 131, 12, 35, 36, 37, 46, +static const short yydefgoto[] = { 135, + 9, 10, 11, 42, 132, 12, 35, 36, 37, 46, 47, 48, 38, 13, 14, 15, 16, 98, 99, 101, 63, 23, 17, 18, 19 }; static const short yypact[] = { -1, --32768, -123,-32768,-32768, 1,-32768, 3, 6,-32768,-32768, --32768,-32768, -127,-32768,-32768,-32768,-32768, 64,-32768, 66, - -10, -2, 58, 67, -58,-32768,-32768,-32768,-32768,-32768, --32768,-32768, -128, 70,-32768,-32768,-32768, -55, 28, 71, --32768, -64,-32768,-32768, -68,-32768,-32768,-32768,-32768, 69, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83,-32768,-32768, 2, 89, 90,-32768, 0, 91, - 91, 91, 91, 91, 91, 91, 91, 92, 93, 94, - -14, -51,-32768,-32768,-32768, -36,-32768, -56,-32768, -7, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 88,-32768, - 95, 95, 95, 95, 95, 95, 95, 95,-32768,-32768, - -29,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - 98,-32768, -7, 99, 100, -26,-32768,-32768, -58,-32768, --32768,-32768, 105, 107,-32768 +-32768, -123,-32768,-32768, 1,-32768, 3, 8,-32768,-32768, +-32768,-32768, -122,-32768,-32768,-32768,-32768, 12,-32768, 33, + -7, -2, 40, 49, -119,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, -128, 51,-32768,-32768,-32768, -46, 39, 80, +-32768, -55,-32768,-32768, -100,-32768,-32768,-32768,-32768, 78, + 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91,-32768,-32768, 2, 97, 98,-32768, 0, 99, + 99, 99, 99, 99, 99, 99, 99, 100, 101, 102, + -11, -41,-32768,-32768,-32768, -28,-32768, -27,-32768, 28, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 96,-32768, + 103, 103, 103, 103, 103, 103, 103, 103,-32768,-32768, + -20,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 107,-32768, 7, 108, 109, -17, 28,-32768,-32768, -119, +-32768,-32768,-32768,-32768, 115, 116,-32768 }; static const short yypgoto[] = {-32768, --32768,-32768, 29, -21,-32768, 30,-32768,-32768, 84,-32768, - 45, 46,-32768,-32768, 47,-32768,-32768, -79,-32768, -17, +-32768,-32768, 37, -12,-32768, 41,-32768,-32768, 93,-32768, + 53, 55,-32768,-32768, 58,-32768,-32768, -72,-32768, 5, -32768,-32768,-32768,-32768,-32768 }; @@ -484,37 +484,37 @@ static const short yypgoto[] = {-32768, static const short yytable[] = { 1, - 33, 2, 90, 43, 82, 20, -81, 44, 21, -82, - 122, 22, 3, 4, 5, 26, 27, 28, 29, 30, - 31, 32, 114, 115, 116, 117, 118, 119, 120, 91, - 92, 93, 94, 95, 96, 97, 91, 92, 93, 94, - 95, 96, 97, 127, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 102, 103, 104, 105, 106, 107, 108, - 59, 60, 61, 62, 66, 67, 68, 24, 25, 39, - 40, 41, 45, 34, 64, 65, 69, 121, 68, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 86, 88, 100, 109, 110, 111, 67, 123, 125, - 126, 128, 129, 130, 134, 124, 135, 132, 112, 113, - 87, 85, 89, 0, 0, 0, 0, 0, 0, 0, - 0, 49, 0, 0, 0, 0, 34, 0, 0, 6, - 0, 0, 0, 0, 0, 7, 8, -31, 83, 84 + 33, 2, 90, 43, 82, 20, -82, 44, 21, 127, + 41, -83, 3, 4, 5, 24, 22, 122, 26, 27, + 28, 29, 30, 31, 32, 114, 115, 116, 117, 118, + 119, 120, 66, 67, 68, 25, 91, 92, 93, 94, + 95, 96, 97, 91, 92, 93, 94, 95, 96, 97, + 128, 39, 40, 45, 133, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 91, 92, 93, 94, 95, 96, + 97, 59, 60, 61, 62, 102, 103, 104, 105, 106, + 107, 108, 34, 64, 65, 69, 70, 121, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 86, + 88, 100, 109, 110, 111, 67, 123, 68, 125, 126, + 129, 130, 131, 124, 136, 137, 112, 134, 87, 0, + 113, 89, 85, 0, 0, 0, 34, 0, 0, 6, + 49, 0, 0, 0, 0, 7, 8, -31, 83, 84 }; static const short yycheck[] = { 1, - 3, 3, 3, 132, 3, 129, 4, 136, 8, 4, - 90, 139, 14, 15, 16, 26, 27, 28, 29, 30, - 31, 32, 37, 38, 39, 40, 41, 42, 43, 37, - 38, 39, 40, 41, 42, 43, 37, 38, 39, 40, - 41, 42, 43, 123, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 71, 72, 73, 74, 75, 76, 77, - 33, 34, 35, 36, 133, 134, 135, 4, 3, 12, - 4, 130, 3, 129, 4, 140, 8, 129, 135, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 3, 3, 3, 3, 3, 3, 134, 11, 129, - 3, 3, 3, 130, 0, 11, 0, 129, 80, 80, - 66, 65, 67, -1, -1, -1, -1, -1, -1, -1, - -1, 38, -1, -1, -1, -1, 129, -1, -1, 131, - -1, -1, -1, -1, -1, 137, 138, 139, 137, 138 + 3, 3, 3, 132, 3, 129, 4, 136, 8, 3, + 130, 4, 14, 15, 16, 4, 139, 90, 26, 27, + 28, 29, 30, 31, 32, 37, 38, 39, 40, 41, + 42, 43, 133, 134, 135, 3, 37, 38, 39, 40, + 41, 42, 43, 37, 38, 39, 40, 41, 42, 43, + 123, 12, 4, 3, 127, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 37, 38, 39, 40, 41, 42, + 43, 33, 34, 35, 36, 71, 72, 73, 74, 75, + 76, 77, 129, 4, 140, 8, 8, 129, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, + 3, 3, 3, 3, 3, 134, 11, 135, 129, 3, + 3, 3, 130, 11, 0, 0, 80, 130, 66, -1, + 80, 67, 65, -1, -1, -1, 129, -1, -1, 131, + 38, -1, -1, -1, -1, 137, 138, 139, 137, 138 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/lib/bison.simple" @@ -1060,7 +1060,7 @@ yyreduce: switch (yyn) { case 9: -#line 167 "icalyacc.y" +#line 168 "icalyacc.y" { icalparser_yy_value = 0; icalparser_clear_flex_input(); @@ -1068,15 +1068,15 @@ case 9: ; break;} case 11: -#line 177 "icalyacc.y" +#line 178 "icalyacc.y" { icalparser_yy_value = icalvalue_new_boolean(1); ; break;} case 12: -#line 179 "icalyacc.y" +#line 180 "icalyacc.y" { icalparser_yy_value = icalvalue_new_boolean(0); ; break;} case 13: -#line 182 "icalyacc.y" +#line 183 "icalyacc.y" { struct icaltimetype stm; @@ -1092,23 +1092,23 @@ case 13: ; break;} case 14: -#line 197 "icalyacc.y" +#line 198 "icalyacc.y" {utc = 0;; break;} case 15: -#line 198 "icalyacc.y" +#line 199 "icalyacc.y" {utc = 1;; break;} case 16: -#line 202 "icalyacc.y" +#line 203 "icalyacc.y" {utc_b = 0;; break;} case 17: -#line 203 "icalyacc.y" +#line 204 "icalyacc.y" {utc_b = 1;; break;} case 18: -#line 207 "icalyacc.y" +#line 208 "icalyacc.y" { struct icaltimetype stm; stm = fill_datetime(yyvsp[-3].v_string, yyvsp[-1].v_string); @@ -1120,100 +1120,100 @@ case 18: ; break;} case 21: -#line 225 "icalyacc.y" +#line 226 "icalyacc.y" { duration.weeks = atoi(yyvsp[-1].v_string); ; break;} case 22: -#line 230 "icalyacc.y" +#line 231 "icalyacc.y" { ; break;} case 23: -#line 233 "icalyacc.y" +#line 234 "icalyacc.y" { ; break;} case 24: -#line 236 "icalyacc.y" +#line 237 "icalyacc.y" { ; break;} case 25: -#line 240 "icalyacc.y" +#line 241 "icalyacc.y" { duration.hours = atoi(yyvsp[-1].v_string); ; break;} case 26: -#line 244 "icalyacc.y" +#line 245 "icalyacc.y" { duration.hours = atoi(yyvsp[-2].v_string); ; break;} case 27: -#line 249 "icalyacc.y" +#line 250 "icalyacc.y" { duration.minutes = atoi(yyvsp[-1].v_string); ; break;} case 28: -#line 253 "icalyacc.y" +#line 254 "icalyacc.y" { duration.minutes = atoi(yyvsp[-2].v_string); ; break;} case 29: -#line 258 "icalyacc.y" +#line 259 "icalyacc.y" { duration.seconds = atoi(yyvsp[-1].v_string); ; break;} case 30: -#line 263 "icalyacc.y" +#line 264 "icalyacc.y" { duration.days = atoi(yyvsp[-1].v_string); ; break;} case 31: -#line 268 "icalyacc.y" +#line 269 "icalyacc.y" { ; break;} case 32: -#line 271 "icalyacc.y" +#line 272 "icalyacc.y" { ; break;} case 33: -#line 274 "icalyacc.y" +#line 275 "icalyacc.y" { ; break;} case 34: -#line 278 "icalyacc.y" +#line 279 "icalyacc.y" { icalparser_yy_value = icalvalue_new_duration(duration); memset(&duration,0, sizeof(duration)); ; break;} case 35: -#line 283 "icalyacc.y" +#line 284 "icalyacc.y" { icalparser_yy_value = icalvalue_new_duration(duration); memset(&duration,0, sizeof(duration)); ; break;} case 36: -#line 288 "icalyacc.y" +#line 289 "icalyacc.y" { icalparser_yy_value = icalvalue_new_duration(duration); memset(&duration,0, sizeof(duration)); ; break;} case 37: -#line 297 "icalyacc.y" +#line 298 "icalyacc.y" { struct icalperiodtype p; @@ -1236,7 +1236,7 @@ case 37: ; break;} case 38: -#line 318 "icalyacc.y" +#line 319 "icalyacc.y" { struct icalperiodtype p; @@ -1265,175 +1265,194 @@ case 38: ; break;} case 39: -#line 350 "icalyacc.y" +#line 351 "icalyacc.y" {clear_recur();recur.freq = ICAL_SECONDLY_RECURRENCE;; break;} case 40: -#line 351 "icalyacc.y" +#line 352 "icalyacc.y" {clear_recur();recur.freq = ICAL_MINUTELY_RECURRENCE;; break;} case 41: -#line 352 "icalyacc.y" +#line 353 "icalyacc.y" {clear_recur();recur.freq = ICAL_HOURLY_RECURRENCE;; break;} case 42: -#line 353 "icalyacc.y" +#line 354 "icalyacc.y" {clear_recur();recur.freq = ICAL_DAILY_RECURRENCE;; break;} case 43: -#line 354 "icalyacc.y" +#line 355 "icalyacc.y" {clear_recur();recur.freq = ICAL_WEEKLY_RECURRENCE;; break;} case 44: -#line 355 "icalyacc.y" +#line 356 "icalyacc.y" {clear_recur();recur.freq = ICAL_MONTHLY_RECURRENCE;; break;} case 45: -#line 356 "icalyacc.y" +#line 357 "icalyacc.y" {clear_recur();recur.freq = ICAL_YEARLY_RECURRENCE;; break;} case 46: -#line 361 "icalyacc.y" -{ skiplist[skippos]=ICAL_SUNDAY_WEEKDAY; if( skippos<8) skippos++;; +#line 362 "icalyacc.y" +{ skiplist[skippos]=ICAL_SUNDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 47: -#line 362 "icalyacc.y" -{ skiplist[skippos]=ICAL_MONDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 364 "icalyacc.y" +{ skiplist[skippos]=ICAL_MONDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 48: -#line 363 "icalyacc.y" -{ skiplist[skippos]=ICAL_TUESDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 366 "icalyacc.y" +{ skiplist[skippos]=ICAL_TUESDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 49: -#line 364 "icalyacc.y" -{ skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 368 "icalyacc.y" +{ skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 50: -#line 365 "icalyacc.y" -{ skiplist[skippos]=ICAL_THURSDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 370 "icalyacc.y" +{ skiplist[skippos]=ICAL_THURSDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 51: -#line 366 "icalyacc.y" -{ skiplist[skippos]=ICAL_FRIDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 372 "icalyacc.y" +{ skiplist[skippos]=ICAL_FRIDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; break;} case 52: -#line 367 "icalyacc.y" -{ skiplist[skippos]=ICAL_SATURDAY_WEEKDAY;if( skippos<8) skippos++;; +#line 374 "icalyacc.y" +{ skiplist[skippos]=ICAL_SATURDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;; + break;} +case 53: +#line 380 "icalyacc.y" +{dow_pos = 0; break;} case 54: -#line 373 "icalyacc.y" -{ ; +#line 381 "icalyacc.y" +{ dow_pos = atoi(yyvsp[-1].v_string); + break;} +case 55: +#line 382 "icalyacc.y" +{dow_pos = 0; break;} case 56: -#line 378 "icalyacc.y" -{ skiplist[skippos] = atoi(yyvsp[0].v_string); skippos++;; +#line 383 "icalyacc.y" +{ dow_pos = atoi(yyvsp[-1].v_string); break;} case 57: -#line 379 "icalyacc.y" -{ skiplist[skippos] = atoi(yyvsp[0].v_string); if (skippos<367) skippos++;; +#line 387 "icalyacc.y" +{ skiplist[skippos] = atoi(yyvsp[0].v_string); skippos++;; break;} case 58: -#line 383 "icalyacc.y" -{recur.interval = atoi(yyvsp[0].v_string);; +#line 388 "icalyacc.y" +{ skiplist[skippos] = atoi(yyvsp[0].v_string); if (skippos<367) skippos++;; break;} case 59: -#line 384 "icalyacc.y" -{recur.week_start = ICAL_SUNDAY_WEEKDAY;; +#line 392 "icalyacc.y" +{recur.interval = atoi(yyvsp[0].v_string);; break;} case 60: -#line 385 "icalyacc.y" -{recur.week_start = ICAL_MONDAY_WEEKDAY;; +#line 393 "icalyacc.y" +{recur.week_start = ICAL_SUNDAY_WEEKDAY;; break;} case 61: -#line 386 "icalyacc.y" -{recur.week_start = ICAL_TUESDAY_WEEKDAY;; +#line 394 "icalyacc.y" +{recur.week_start = ICAL_MONDAY_WEEKDAY;; break;} case 62: -#line 387 "icalyacc.y" -{recur.week_start = ICAL_WEDNESDAY_WEEKDAY;; +#line 395 "icalyacc.y" +{recur.week_start = ICAL_TUESDAY_WEEKDAY;; break;} case 63: -#line 388 "icalyacc.y" -{recur.week_start = ICAL_THURSDAY_WEEKDAY;; +#line 396 "icalyacc.y" +{recur.week_start = ICAL_WEDNESDAY_WEEKDAY;; break;} case 64: -#line 389 "icalyacc.y" -{recur.week_start = ICAL_FRIDAY_WEEKDAY;; +#line 397 "icalyacc.y" +{recur.week_start = ICAL_THURSDAY_WEEKDAY;; break;} case 65: -#line 390 "icalyacc.y" -{recur.week_start = ICAL_SATURDAY_WEEKDAY;; +#line 398 "icalyacc.y" +{recur.week_start = ICAL_FRIDAY_WEEKDAY;; break;} case 66: -#line 391 "icalyacc.y" -{copy_list(recur.by_second,60);; +#line 399 "icalyacc.y" +{recur.week_start = ICAL_SATURDAY_WEEKDAY;; break;} case 67: -#line 392 "icalyacc.y" -{copy_list(recur.by_minute,60);; +#line 400 "icalyacc.y" +{copy_list(recur.by_second,60);; break;} case 68: -#line 393 "icalyacc.y" -{copy_list(recur.by_hour,24);; +#line 401 "icalyacc.y" +{copy_list(recur.by_minute,60);; break;} case 69: -#line 394 "icalyacc.y" -{copy_list(recur.by_day,7);; +#line 402 "icalyacc.y" +{copy_list(recur.by_hour,24);; break;} case 70: -#line 395 "icalyacc.y" -{copy_list(recur.by_month,12);; +#line 403 "icalyacc.y" +{copy_list(recur.by_day,7);; break;} case 71: -#line 396 "icalyacc.y" -{copy_list(recur.by_month_day,31);; +#line 404 "icalyacc.y" +{copy_list(recur.by_month,12);; break;} case 72: -#line 397 "icalyacc.y" -{copy_list(recur.by_year_day,366);; +#line 405 "icalyacc.y" +{copy_list(recur.by_month_day,31);; break;} case 73: -#line 398 "icalyacc.y" -{copy_list(recur.by_week_no,53);; +#line 406 "icalyacc.y" +{copy_list(recur.by_year_day,366);; break;} case 74: -#line 399 "icalyacc.y" -{copy_list(recur.by_set_pos,366);; +#line 407 "icalyacc.y" +{copy_list(recur.by_week_no,53);; break;} case 75: -#line 401 "icalyacc.y" +#line 408 "icalyacc.y" +{copy_list(recur.by_set_pos,366);; + break;} +case 76: +#line 410 "icalyacc.y" { recur.until = icalvalue_get_datetime(icalparser_yy_value); icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;; break;} -case 76: -#line 404 "icalyacc.y" +case 77: +#line 413 "icalyacc.y" { recur.until = icalvalue_get_date(icalparser_yy_value); icalvalue_free(icalparser_yy_value); icalparser_yy_value=0;; break;} -case 77: -#line 407 "icalyacc.y" +case 78: +#line 416 "icalyacc.y" { recur.count = atoi(yyvsp[0].v_string); ; break;} -case 80: -#line 416 "icalyacc.y" +case 81: +#line 425 "icalyacc.y" { icalparser_yy_value = icalvalue_new_recur(recur); ; break;} -case 81: -#line 422 "icalyacc.y" +case 82: +#line 431 "icalyacc.y" { utcsign = 1; ; break;} -case 82: -#line 423 "icalyacc.y" +case 83: +#line 432 "icalyacc.y" { utcsign = -1; ; break;} -case 83: -#line 427 "icalyacc.y" +case 84: +#line 436 "icalyacc.y" { icalparser_yy_value = icalvalue_new_utcoffset( utcsign * (yyvsp[-1].v_int*3600) + (yyvsp[0].v_int*60) ); ; break;} -case 84: -#line 432 "icalyacc.y" +case 85: +#line 441 "icalyacc.y" { icalparser_yy_value = icalvalue_new_utcoffset(utcsign * (yyvsp[-2].v_int*3600) + (yyvsp[-1].v_int*60) +(yyvsp[0].v_int)); ; @@ -1660,7 +1679,7 @@ yyerrhandle: } return 1; } -#line 438 "icalyacc.y" +#line 447 "icalyacc.y" diff --git a/libical/src/libical/icalyacc.y b/libical/src/libical/icalyacc.y index 1fe2a737e9..0917daf371 100644 --- a/libical/src/libical/icalyacc.y +++ b/libical/src/libical/icalyacc.y @@ -6,7 +6,7 @@ DESCRIPTION: - $Id: icalyacc.y,v 1.4 2000/06/06 22:48:09 alves Exp $ + $Id: icalyacc.y,v 1.5 2000/08/24 20:12:04 jpr Exp $ $Locker: $ (C) COPYRIGHT 1999 Eric Busboom @@ -53,6 +53,7 @@ struct icaldurationtype duration; struct icalrecurrencetype recur; short skiplist[367]; short skippos; +int dow_pos; void copy_list(short* array, size_t size); void clear_recur(); @@ -358,20 +359,28 @@ recur_start: weekday: - SU { skiplist[skippos]=ICAL_SUNDAY_WEEKDAY; if( skippos<8) skippos++;} - | MO { skiplist[skippos]=ICAL_MONDAY_WEEKDAY;if( skippos<8) skippos++;} - | TU { skiplist[skippos]=ICAL_TUESDAY_WEEKDAY;if( skippos<8) skippos++;} - | WE { skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY;if( skippos<8) skippos++;} - | TH { skiplist[skippos]=ICAL_THURSDAY_WEEKDAY;if( skippos<8) skippos++;} - | FR { skiplist[skippos]=ICAL_FRIDAY_WEEKDAY;if( skippos<8) skippos++;} - | SA { skiplist[skippos]=ICAL_SATURDAY_WEEKDAY;if( skippos<8) skippos++;} + SU { skiplist[skippos]=ICAL_SUNDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | MO { skiplist[skippos]=ICAL_MONDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | TU { skiplist[skippos]=ICAL_TUESDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | WE { skiplist[skippos]=ICAL_WEDNESDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | TH { skiplist[skippos]=ICAL_THURSDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | FR { skiplist[skippos]=ICAL_FRIDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} + | SA { skiplist[skippos]=ICAL_SATURDAY_WEEKDAY+8*dow_pos; + if( skippos<8) skippos++;} ; weekday_list: - weekday - | DIGITS weekday { } /* HACK Incorectly handles int in BYDAY */ - | weekday_list COMMA weekday + weekday {dow_pos = 0}; + | DIGITS weekday { dow_pos = atoi($1)} + | weekday_list COMMA weekday {dow_pos = 0}; + | weekday_list COMMA DIGITS weekday { dow_pos = atoi($3)} recur_list: diff --git a/libical/src/libical/pvl.c b/libical/src/libical/pvl.c index d5225a541e..94eaeac874 100644 --- a/libical/src/libical/pvl.c +++ b/libical/src/libical/pvl.c @@ -3,18 +3,7 @@ CREATOR: eric November, 1995 - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -505,6 +494,10 @@ pvl_remove(pvl_list l,pvl_elem e) data = E->d; + E->prior = 0; + E->next = 0; + E->d = 0; + free(E); return data; diff --git a/libical/src/libical/pvl.h b/libical/src/libical/pvl.h index 8113f7495a..40ca516e9f 100644 --- a/libical/src/libical/pvl.h +++ b/libical/src/libical/pvl.h @@ -3,27 +3,9 @@ CREATOR: eric November, 1995 - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org ======================================================================*/ -/* - struct pvl_elem_t - - This type is private. Always use pvl_elem instead - - */ #ifndef __PVL_H__ #define __PVL_H__ @@ -31,6 +13,14 @@ typedef void* pvl_list; typedef void* pvl_elem; +/* + struct pvl_elem_t + + This type is private. Always use pvl_elem instead. The struct would + not even appear in this header except to make code in the USE_MACROS + blocks work + + */ typedef struct pvl_elem_t { int MAGIC; /* Magic Identifier */ diff --git a/libical/src/libicalss/Makefile.am b/libical/src/libicalss/Makefile.am index 01a7fa4d9c..e4431cb492 100644 --- a/libical/src/libicalss/Makefile.am +++ b/libical/src/libicalss/Makefile.am @@ -6,16 +6,27 @@ lib_LIBRARIES = libicalss.a libicalss_a_SOURCES =\ icalcalendar.c \ icalcalendar.h \ - icalcluster.c \ - icalcluster.h \ - icalstore.c \ - icalstore.h + icalset.h \ + icalset.c \ + icalfileset.c \ + icalfileset.h \ + icalfilesetimpl.h \ + icaldirset.c \ + icaldirset.h \ + icalcsdb.h \ + icalcstp.h \ + icalgauge.h \ + icalgauge.c include_HEADERS =\ icalcalendar.h \ - icalcluster.h \ - icalstore.h - + icalset.h + icalfileset.h \ + icalfilesetimpl.h \ + icaldirset.h \ + icalcsdb.h \ + icalcstp.h \ + icalgauge.h INCLUDES = \ -I ../libical/ \ diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c index 0f2231b1d7..e63b5330ad 100644 --- a/libical/src/libicalss/icalcalendar.c +++ b/libical/src/libicalss/icalcalendar.c @@ -1,27 +1,22 @@ -/* -*- Mode: C -*- - ====================================================================== +/*====================================================================== FILE: icalcalendar.c CREATOR: eric 23 December 1999 $Id$ $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom + (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/ ======================================================================*/ @@ -32,7 +27,9 @@ #include "icalcalendar.h" -#include "icalcluster.h" +#include "icalset.h" +#include "icalfileset.h" +#include "icaldirset.h" #include <limits.h> #include <sys/stat.h> /* For mkdir, stat */ #include <sys/types.h> /* For mkdir */ @@ -52,8 +49,8 @@ struct icalcalendar_impl char* dir; icalcomponent* freebusy; icalcomponent* properties; - icalstore* booked; - icalstore* incoming; + icalset* booked; + icalset* incoming; }; struct icalcalendar_impl* icalcalendar_new_impl() @@ -132,19 +129,19 @@ void icalcalendar_free(icalcalendar* calendar) } if (impl->freebusy !=0){ - icalcluster_free(impl->freebusy); + icalfileset_free(impl->freebusy); } if (impl->properties !=0){ - icalcluster_free(impl->properties); + icalfileset_free(impl->properties); } if (impl->booked !=0){ - icalstore_free(impl->booked); + icaldirset_free(impl->booked); } if (impl->incoming !=0){ - icalstore_free(impl->incoming); + icaldirset_free(impl->incoming); } impl->dir = 0; @@ -186,7 +183,7 @@ int icalcalendar_ownlock(icalcalendar* calendar) return 0; } -icalstore* icalcalendar_get_booked(icalcalendar* calendar) +icalset* icalcalendar_get_booked(icalcalendar* calendar) { struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; char dir[PATH_MAX]; @@ -200,7 +197,7 @@ icalstore* icalcalendar_get_booked(icalcalendar* calendar) if (impl->booked == 0){ icalerror_clear_errno(); - impl->booked = icalstore_new(dir); + impl->booked = icaldirset_new(dir); assert(icalerrno == ICAL_NO_ERROR); } @@ -208,7 +205,7 @@ icalstore* icalcalendar_get_booked(icalcalendar* calendar) } -icalcluster* icalcalendar_get_incoming(icalcalendar* calendar) +icalset* icalcalendar_get_incoming(icalcalendar* calendar) { char path[PATH_MAX]; struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; @@ -220,13 +217,13 @@ icalcluster* icalcalendar_get_incoming(icalcalendar* calendar) strcat(path,INCOMING_FILE); if (impl->properties == 0){ - impl->properties = icalcluster_new(path); + impl->properties = icalfileset_new(path); } return impl->properties; } -icalcluster* icalcalendar_get_properties(icalcalendar* calendar) +icalset* icalcalendar_get_properties(icalcalendar* calendar) { char path[PATH_MAX]; struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; @@ -238,13 +235,13 @@ icalcluster* icalcalendar_get_properties(icalcalendar* calendar) strcat(path,PROP_FILE); if (impl->properties == 0){ - impl->properties = icalcluster_new(path); + impl->properties = icalfileset_new(path); } return impl->properties; } -icalcluster* icalcalendar_get_freebusy(icalcalendar* calendar) +icalset* icalcalendar_get_freebusy(icalcalendar* calendar) { char path[PATH_MAX]; struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; @@ -257,7 +254,7 @@ icalcluster* icalcalendar_get_freebusy(icalcalendar* calendar) if (impl->freebusy == 0){ - impl->freebusy = icalcluster_new(path); + impl->freebusy = icalfileset_new(path); } return impl->freebusy; diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h index 90e7b33c22..f07457c60d 100644 --- a/libical/src/libicalss/icalcalendar.h +++ b/libical/src/libicalss/icalcalendar.h @@ -7,19 +7,19 @@ $Id$ $Locker$ - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - + (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 @@ -30,12 +30,11 @@ #define ICALCALENDAR_H #include "ical.h" -#include "icalstore.h" -#include "icalcluster.h" +#include "icalset.h" /* icalcalendar * Routines for storing calendar data in a file system. The calendar - * has two icalstores, one for incoming components and one for booked + * has two icaldirsets, one for incoming components and one for booked * components. It also has interfaces to access the free/busy list * and a list of calendar properties */ @@ -53,13 +52,13 @@ int icalcalendar_islocked(icalcalendar* calendar); int icalcalendar_ownlock(icalcalendar* calendar); -icalstore* icalcalendar_get_booked(icalcalendar* calendar); +icalset* icalcalendar_get_booked(icalcalendar* calendar); -icalcluster* icalcalendar_get_incoming(icalcalendar* calendar); +icalset* icalcalendar_get_incoming(icalcalendar* calendar); -icalcluster* icalcalendar_get_properties(icalcalendar* calendar); +icalset* icalcalendar_get_properties(icalcalendar* calendar); -icalcluster* icalcalendar_get_freebusy(icalcalendar* calendar); +icalset* icalcalendar_get_freebusy(icalcalendar* calendar); #endif /* !ICALCALENDAR_H */ diff --git a/libical/src/test/Makefile.am b/libical/src/test/Makefile.am index 81ffff8c39..bd76fca669 100644 --- a/libical/src/test/Makefile.am +++ b/libical/src/test/Makefile.am @@ -1,7 +1,7 @@ -noinst_PROGRAMS = usecases copycluster regression parser findobj storage stow +noinst_PROGRAMS = copycluster regression parser findobj storage stow testvcal recur testmime -LDADD = ../libical/libical.a ../libicalss/libicalss.a +LDADD = ../libical/libical.a ../libicalss/libicalss.a ../libicalvcal/libicalvcal.a INCLUDES = \ -I . \ -I $(srcdir) \ @@ -9,11 +9,15 @@ INCLUDES = \ -I $(srcdir)/../libical \ -I../libicalss \ -I $(srcdir)/../libicalss + -I../libicalvcal \ + -I $(srcdir)/../libicalvcal findobj_SOURCES = findobj.c -usecases_SOURCES = usecases.c copycluster_SOURCES = copycluster.c regression_SOURCES = regression.c parser_SOURCES = icaltestparser.c storage_SOURCES = storage.c -stow_SOURCES = stow.c
\ No newline at end of file +stow_SOURCES = stow.c +testvcal_SOURCES =testvcal.c +recur_SOURCES = recur.c +test_mime = testmime.c
\ No newline at end of file diff --git a/libical/src/test/Makefile.in b/libical/src/test/Makefile.in deleted file mode 100644 index 8a7cf257c3..0000000000 --- a/libical/src/test/Makefile.in +++ /dev/null @@ -1,385 +0,0 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = ../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ -AR = @AR@ -AS = @AS@ -CC = @CC@ -DLLTOOL = @DLLTOOL@ -LEX = @LEX@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -MAKEINFO = @MAKEINFO@ -OBJDUMP = @OBJDUMP@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ -YACC = @YACC@ - -noinst_PROGRAMS = usecases copycluster regression parser findobj storage stow - -LDADD = ../libical/libical.a ../libicalss/libicalss.a -INCLUDES = -I . -I $(srcdir) -I../libical -I $(srcdir)/../libical -I../libicalss -I $(srcdir)/../libicalss - - -findobj_SOURCES = findobj.c -usecases_SOURCES = usecases.c -copycluster_SOURCES = copycluster.c -regression_SOURCES = regression.c -parser_SOURCES = icaltestparser.c -storage_SOURCES = storage.c -stow_SOURCES = stow.c -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../../config.h -CONFIG_CLEAN_FILES = -PROGRAMS = $(noinst_PROGRAMS) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I../.. -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -usecases_OBJECTS = usecases.o -usecases_LDADD = $(LDADD) -usecases_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -usecases_LDFLAGS = -copycluster_OBJECTS = copycluster.o -copycluster_LDADD = $(LDADD) -copycluster_DEPENDENCIES = ../libical/libical.a \ -../libicalss/libicalss.a -copycluster_LDFLAGS = -regression_OBJECTS = regression.o -regression_LDADD = $(LDADD) -regression_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -regression_LDFLAGS = -parser_OBJECTS = icaltestparser.o -parser_LDADD = $(LDADD) -parser_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -parser_LDFLAGS = -findobj_OBJECTS = findobj.o -findobj_LDADD = $(LDADD) -findobj_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -findobj_LDFLAGS = -storage_OBJECTS = storage.o -storage_LDADD = $(LDADD) -storage_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -storage_LDFLAGS = -stow_OBJECTS = stow.o -stow_LDADD = $(LDADD) -stow_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a -stow_LDFLAGS = -CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = gtar -GZIP_ENV = --best -DEP_FILES = .deps/copycluster.P .deps/findobj.P .deps/icaltestparser.P \ -.deps/regression.P .deps/storage.P .deps/stow.P .deps/usecases.P -SOURCES = $(usecases_SOURCES) $(copycluster_SOURCES) $(regression_SOURCES) $(parser_SOURCES) $(findobj_SOURCES) $(storage_SOURCES) $(stow_SOURCES) -OBJECTS = $(usecases_OBJECTS) $(copycluster_OBJECTS) $(regression_OBJECTS) $(parser_OBJECTS) $(findobj_OBJECTS) $(storage_OBJECTS) $(stow_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu src/test/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-noinstPROGRAMS: - -clean-noinstPROGRAMS: - -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) - -distclean-noinstPROGRAMS: - -maintainer-clean-noinstPROGRAMS: - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -usecases: $(usecases_OBJECTS) $(usecases_DEPENDENCIES) - @rm -f usecases - $(LINK) $(usecases_LDFLAGS) $(usecases_OBJECTS) $(usecases_LDADD) $(LIBS) - -copycluster: $(copycluster_OBJECTS) $(copycluster_DEPENDENCIES) - @rm -f copycluster - $(LINK) $(copycluster_LDFLAGS) $(copycluster_OBJECTS) $(copycluster_LDADD) $(LIBS) - -regression: $(regression_OBJECTS) $(regression_DEPENDENCIES) - @rm -f regression - $(LINK) $(regression_LDFLAGS) $(regression_OBJECTS) $(regression_LDADD) $(LIBS) - -parser: $(parser_OBJECTS) $(parser_DEPENDENCIES) - @rm -f parser - $(LINK) $(parser_LDFLAGS) $(parser_OBJECTS) $(parser_LDADD) $(LIBS) - -findobj: $(findobj_OBJECTS) $(findobj_DEPENDENCIES) - @rm -f findobj - $(LINK) $(findobj_LDFLAGS) $(findobj_OBJECTS) $(findobj_LDADD) $(LIBS) - -storage: $(storage_OBJECTS) $(storage_DEPENDENCIES) - @rm -f storage - $(LINK) $(storage_LDFLAGS) $(storage_OBJECTS) $(storage_LDADD) $(LIBS) - -stow: $(stow_OBJECTS) $(stow_DEPENDENCIES) - @rm -f stow - $(LINK) $(stow_LDFLAGS) $(stow_OBJECTS) $(stow_LDADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = src/test - -distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/test/Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: -uninstall: uninstall-am -all-am: Makefile $(PROGRAMS) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \ - mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ - mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \ - clean-depend clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-noinstPROGRAMS distclean-compile \ - distclean-libtool distclean-tags distclean-depend \ - distclean-generic clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-noinstPROGRAMS \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-tags maintainer-clean-depend \ - maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ -clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ -mostlyclean-compile distclean-compile clean-compile \ -maintainer-clean-compile mostlyclean-libtool distclean-libtool \ -clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ -distclean-tags clean-tags maintainer-clean-tags distdir \ -mostlyclean-depend distclean-depend clean-depend \ -maintainer-clean-depend info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libical/src/test/copycluster.c b/libical/src/test/copycluster.c index b059130c13..11bd94c62d 100644 --- a/libical/src/test/copycluster.c +++ b/libical/src/test/copycluster.c @@ -27,7 +27,7 @@ #include <stdio.h> /* for printf */ #include "ical.h" -#include "icalcluster.h" +#include "icalfileset.h" #include <errno.h> #include <string.h> /* For strerror */ #include "icalrestriction.h" @@ -41,7 +41,7 @@ void usage(char* arg0) { int main(int c, char *argv[]){ - icalcluster *clusterin, *clusterout; + icalfileset *clusterin, *clusterout; icalcomponent *itr; int count=0; int tostdout = 0; @@ -55,7 +55,7 @@ int main(int c, char *argv[]){ tostdout = 1; } - clusterin = icalcluster_new(argv[1]); + clusterin = icalfileset_new(argv[1]); if (clusterin == 0){ printf("Could not open input cluster \"%s\"",argv[1]); @@ -64,7 +64,7 @@ int main(int c, char *argv[]){ } if (!tostdout){ - clusterout = icalcluster_new(argv[2]); + clusterout = icalfileset_new(argv[2]); if (clusterout == 0){ printf("Could not open output cluster \"%s\"\n",argv[2]); exit(1); @@ -72,10 +72,10 @@ int main(int c, char *argv[]){ } - for (itr = icalcluster_get_first_component(clusterin, + for (itr = icalfileset_get_first_component(clusterin, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(clusterin, + itr = icalfileset_get_next_component(clusterin, ICAL_ANY_COMPONENT)){ icalrestriction_check(itr); @@ -87,7 +87,7 @@ int main(int c, char *argv[]){ printf("--------------\n%s\n",icalcomponent_as_ical_string(itr)); } else { - icalcluster_add_component(clusterout, + icalfileset_add_component(clusterout, icalcomponent_new_clone(itr)); } @@ -101,11 +101,11 @@ int main(int c, char *argv[]){ printf("Transfered %d components\n",count); - icalcluster_free(clusterin); + icalfileset_free(clusterin); if (!tostdout){ - icalcluster_mark(clusterout); - icalcluster_free(clusterout); + icalfileset_mark(clusterout); + icalfileset_free(clusterout); } return 0; diff --git a/libical/src/test/findobj.c b/libical/src/test/findobj.c index e7ec59169a..c31101c33d 100644 --- a/libical/src/test/findobj.c +++ b/libical/src/test/findobj.c @@ -28,6 +28,7 @@ #include <stdio.h> /* for printf */ #include "ical.h" #include "icalcalendar.h" +#include "icaldirset.h" #include <errno.h> #include <string.h> /* For strerror */ #include "icalrestriction.h" @@ -41,7 +42,7 @@ void usage(char* arg0) { int main(int c, char *argv[]){ icalcalendar *cal; - icalstore *booked; + icaldirset *booked; icalcomponent *itr; if(c < 2 || c > 3){ @@ -59,7 +60,7 @@ int main(int c, char *argv[]){ booked = icalcalendar_get_booked(cal); - itr = icalstore_fetch(booked,argv[2]); + itr = icaldirset_fetch(booked,argv[2]); if(itr != 0){ diff --git a/libical/src/test/icaltestparser.c b/libical/src/test/icaltestparser.c index 98dbcff94f..71f91b641f 100644 --- a/libical/src/test/icaltestparser.c +++ b/libical/src/test/icaltestparser.c @@ -91,7 +91,6 @@ char* read_stream(char *s, size_t size, void *d) int main(int argc, char* argv[]) { - int lineno = 0; char* line; FILE* stream; icalcomponent *c; @@ -120,5 +119,5 @@ int main(int argc, char* argv[]) } while ( line != 0); - -} + return 0; + } diff --git a/libical/src/test/regression.c b/libical/src/test/regression.c index 7b1606d432..dc6a5301f1 100644 --- a/libical/src/test/regression.c +++ b/libical/src/test/regression.c @@ -34,11 +34,12 @@ #include <stdio.h> /* for printf */ #include <time.h> /* for time() */ #include "icalmemory.h" -#include "icalstore.h" -#include "icalcluster.h" #include "icalerror.h" #include "icalrestriction.h" #include "icalcalendar.h" +#include "icalgauge.h" +#include "icaldirset.h" +#include "icalfileset.h" /* This example creates and minipulates the ical object that appears * in rfc 2445, page 137 */ @@ -92,8 +93,8 @@ icalcomponent* create_simple_component() icalcomponent* calendar; struct icalperiodtype rtime; - rtime.start = icaltimetype_from_timet( time(0),0); - rtime.end = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); + rtime.end = icaltime_from_timet( time(0),0,0); rtime.end.hour++; @@ -122,12 +123,12 @@ icalcomponent* create_new_component() icalcomponent* timezone; icalcomponent* tzc; icalcomponent* event; - struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + struct icaltimetype atime = icaltime_from_timet( time(0),0,0); struct icalperiodtype rtime; icalproperty* property; - rtime.start = icaltimetype_from_timet( time(0),0); - rtime.end = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); + rtime.end = icaltime_from_timet( time(0),0,0); rtime.end.hour++; @@ -331,11 +332,11 @@ icalcomponent* create_new_component_with_va_args() { icalcomponent* calendar; - struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + struct icaltimetype atime = icaltime_from_timet( time(0),0,0); struct icalperiodtype rtime; - rtime.start = icaltimetype_from_timet( time(0),0); - rtime.end = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); + rtime.end = icaltime_from_timet( time(0),0,0); rtime.end.hour++; @@ -524,9 +525,9 @@ void test_values() icalvalue_free(copy); - v = icalvalue_new_date(icaltimetype_from_timet( time(0),0)); + v = icalvalue_new_date(icaltime_from_timet( time(0),0,0)); printf("date 1: %s\n",icalvalue_as_ical_string(v)); - icalvalue_set_date(v,icaltimetype_from_timet( time(0)+3600,0)); + icalvalue_set_date(v,icaltime_from_timet( time(0)+3600,0,0)); printf("date 2: %s\n",icalvalue_as_ical_string(v)); copy = icalvalue_new_clone(v); @@ -662,6 +663,7 @@ void test_components() void test_memory() { size_t bufsize = 256; + int i; char *p; char S1[] = "1) When in the Course of human events, "; @@ -682,8 +684,7 @@ void test_memory() char *f, *b1, *b2, *b3, *b4, *b5, *b6, *b7, *b8; - #define BUFSIZE 1024 - +#define BUFSIZE 1024 f = icalmemory_new_buffer(bufsize); p = f; @@ -737,32 +738,61 @@ void test_memory() free(f); bufsize = 4; + f = icalmemory_new_buffer(bufsize); + + memset(f,0,bufsize); p = f; icalmemory_append_char(&f, &p, &bufsize, 'a'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'b'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'c'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'd'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'e'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'f'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'g'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'h'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'i'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'j'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'a'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'b'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'c'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'd'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'e'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'f'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'g'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'h'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'i'); + printf("Char-by-Char buffer: %s\n", f); icalmemory_append_char(&f, &p, &bufsize, 'j'); - printf("Char-by-Char buffer: %s\n", f); + + for(i=0; i<100; i++){ + f = icalmemory_tmp_buffer(bufsize); + + assert(f!=0); + memset(f,0,bufsize); + sprintf(f,"%d",i); + } } @@ -772,14 +802,14 @@ int test_store() icalcomponent *c, *gauge; icalerrorenum error; icalcomponent *next, *itr; - icalcluster* cluster; + icalfileset* cluster; struct icalperiodtype rtime; - icalstore *s = icalstore_new("store"); + icaldirset *s = icaldirset_new("store"); int i; - rtime.start = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); - cluster = icalcluster_new("clusterin.vcd"); + cluster = icalfileset_new("clusterin.vcd"); if (cluster == 0){ printf("Failed to create cluster: %s\n",icalerror_strerror(icalerrno)); @@ -799,10 +829,10 @@ int test_store() rtime.end = rtime.start; rtime.end.hour++; - for (itr = icalcluster_get_first_component(cluster, + for (itr = icalfileset_get_first_component(cluster, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(cluster, + itr = icalfileset_get_next_component(cluster, ICAL_ANY_COMPONENT)){ icalcomponent *clone; icalproperty *p; @@ -847,7 +877,7 @@ int test_store() printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(clone)); - error = icalstore_add_component(s,clone); + error = icaldirset_add_component(s,clone); assert(icalerrno == ICAL_NO_ERROR); @@ -877,15 +907,15 @@ int test_store() #if 0 - icalstore_select(s,gauge); + icaldirset_select(s,gauge); - for(c = icalstore_first(s); c != 0; c = icalstore_next(s)){ + for(c = icaldirset_first(s); c != 0; c = icaldirset_next(s)){ printf("Got one! (%d)\n", count++); if (c != 0){ printf("%s", icalcomponent_as_ical_string(c));; - if (icalstore_store(s2,c) == 0){ + if (icaldirset_store(s2,c) == 0){ printf("Failed to write!\n"); } icalcomponent_free(c); @@ -895,18 +925,18 @@ int test_store() } - icalstore_free(s2); + icaldirset_free(s2); #endif - for(c = icalstore_get_first_component(s); + for(c = icaldirset_get_first_component(s,ICAL_ANY_COMPONENT); c != 0; c = next){ - next = icalstore_get_next_component(s); + next = icaldirset_get_next_component(s,ICAL_ANY_COMPONENT); if (c != 0){ - /*icalstore_remove_component(s,c);*/ + /*icaldirset_remove_component(s,c);*/ printf("%s", icalcomponent_as_ical_string(c));; } else { printf("Failed to get component\n"); @@ -915,7 +945,7 @@ int test_store() } - icalstore_free(s); + icaldirset_free(s); return 0; } @@ -976,7 +1006,7 @@ int test_compare() printf("%s",icalcomponent_as_ical_string(gauge)); - printf("%d\n",icalstore_test(c,gauge)); + printf("%d\n",icalgauge_test(c,gauge)); return 0; } @@ -984,13 +1014,13 @@ int test_compare() void test_restriction() { icalcomponent *comp; - struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + struct icaltimetype atime = icaltime_from_timet( time(0),0,0); int valid; struct icalperiodtype rtime; - rtime.start = icaltimetype_from_timet( time(0),0); - rtime.end = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); + rtime.end = icaltime_from_timet( time(0),0,0); rtime.end.hour++; @@ -1097,11 +1127,11 @@ void test_restriction() void test_calendar() { icalcomponent *comp; - icalcluster *c; - icalstore *s; + icalfileset *c; + icaldirset *s; icalcalendar* calendar = icalcalendar_new("calendar"); icalerrorenum error; - struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + struct icaltimetype atime = icaltime_from_timet( time(0),0,0); comp = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, @@ -1125,13 +1155,13 @@ void test_calendar() s = icalcalendar_get_booked(calendar); - error = icalstore_add_component(s,comp); + error = icaldirset_add_component(s,comp); assert(error == ICAL_NO_ERROR); c = icalcalendar_get_properties(calendar); - error = icalcluster_add_component(c,icalcomponent_new_clone(comp)); + error = icalfileset_add_component(c,icalcomponent_new_clone(comp)); assert(error == ICAL_NO_ERROR); @@ -1170,6 +1200,19 @@ void test_recur() } +void test_recur_expansion() +{ + + icalvalue *v; + + v = icalvalue_new_from_string(ICAL_RECUR_VALUE, + "FREQ=YEARLY;UNTIL=123456T123456;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30"); + + printf("%s\n",icalvalue_as_ical_string(v)); + + icalrecurrencetype_test(); +} + void test_duration() { @@ -1278,19 +1321,213 @@ void test_requeststat() } +void test_time() +{ + struct icaltimetype ictt; + time_t tt,tt2; + icalvalue *v; + short day_of_week,start_day_of_week, day_of_year; + + + tt = time(0); + + printf("System time is: %s\n",ctime(&tt)); + + ictt = icaltime_from_timet(tt,0,0); + + v = icalvalue_new_datetime(ictt); + + printf("System time from libical: %s\n",icalvalue_as_ical_string(v)); + + tt2 = icaltime_as_timet(ictt); + printf("Converted back to libc: %s\n",ctime(&tt2)); + + + ictt.year++; + tt2 = icaltime_as_timet(ictt); + printf("Add a year: %s\n",ctime(&tt2)); + + ictt.month+=13; + tt2 = icaltime_as_timet(ictt); + printf("Add 13 months: %s\n",ctime(&tt2)); + + ictt.second+=90; + tt2 = icaltime_as_timet(ictt); + printf("Add 90 seconds: %s\n",ctime(&tt2)); + + ictt = icaltime_from_timet(tt,0,0); + + + day_of_week = icaltime_day_of_week(ictt); + start_day_of_week = icaltime_start_doy_of_week(ictt); + day_of_year = icaltime_day_of_year(ictt); + + printf("Today is day of week %d, day of year %d\n",day_of_week,day_of_year); + printf("Week started n doy of %d\n",start_day_of_week); + + +} + +void test_iterators() +{ + icalcomponent *c,*inner,*next; + icalcompiter i; + + c= icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew(ICAL_VEVENT_COMPONENT, + icalproperty_vanew_version("1"),0), + icalcomponent_vanew(ICAL_VEVENT_COMPONENT, + icalproperty_vanew_version("2"),0), + icalcomponent_vanew(ICAL_VEVENT_COMPONENT, + icalproperty_vanew_version("3"),0), + icalcomponent_vanew(ICAL_VEVENT_COMPONENT, + icalproperty_vanew_version("4"),0), + icalcomponent_vanew(ICAL_VTODO_COMPONENT, + icalproperty_vanew_version("5"),0), + icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT, + icalproperty_vanew_version("6"),0), + icalcomponent_vanew(ICAL_VEVENT_COMPONENT, + icalproperty_vanew_version("7"),0), + icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT, + icalproperty_vanew_version("8"),0), + icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT, + icalproperty_vanew_version("9"),0), + icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT, + icalproperty_vanew_version("10"),0), + 0); + + printf("1: "); + + /* List all of the VEVENTS */ + for(i = icalcomponent_begin_component(c,ICAL_VEVENT_COMPONENT); + icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ + + icalcomponent *this = icalcompiter_deref(&i); + + icalproperty *p = + icalcomponent_get_first_property(this, + ICAL_VERSION_PROPERTY); + char* s = icalproperty_get_version(p); + + printf("%s ",s); + + } + + printf("\n2: "); + +#if 0 + for(inner = icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT); + inner != 0; + inner = next){ + + next = icalcomponent_get_next_component(c,ICAL_VEVENT_COMPONENT); + + icalcomponent_remove_component(c,inner); + + icalcomponent_free(inner); + } +#endif + + /* Delete all of the VEVENTS */ + /* reset iterator */ + icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT); + + while((inner=icalcomponent_get_current_component(c)) != 0 ){ + if(icalcomponent_isa(inner) == ICAL_VEVENT_COMPONENT){ + icalcomponent_remove_component(c,inner); + } else { + icalcomponent_get_next_component(c,ICAL_VEVENT_COMPONENT); + } + } + + + + /* List all remaining components */ + for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT); + inner != 0; + inner = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){ + + + icalproperty *p = + icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); + + char* s = icalproperty_get_version(p); + + printf("%s ",s); + } + + printf("\n3: "); + + + /* Remove all remaining components */ + for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT); + inner != 0; + inner = next){ + + icalcomponent *this; + icalproperty *p; + char* s; + next = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT); + + p=icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); + s = icalproperty_get_version(p); + printf("rem:%s ",s); + + icalcomponent_remove_component(c,inner); + + this = icalcomponent_get_current_component(c); + + if(this != 0){ + p=icalcomponent_get_first_property(this,ICAL_VERSION_PROPERTY); + s = icalproperty_get_version(p); + printf("next:%s; ",s); + } + + icalcomponent_free(inner); + } + + printf("\n4: "); + + + /* List all remaining components */ + for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT); + inner != 0; + inner = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){ + + icalproperty *p = + icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); + + char* s = icalproperty_get_version(p); + + printf("%s ",s); + } + + printf("\n"); +} + int main(int argc, char *argv[]) { + printf("\n------------Test Memory---------------\n"); + test_memory(); + +exit(0); + + + printf("\n------------Test Iterators-----------\n"); + test_iterators(); + + + printf("\n------------Test time----------------\n"); + test_time(); printf("\n------------Test Restriction---------------\n"); test_restriction(); - exit(0); - printf("\n------------Test request status-------\n"); test_requeststat(); - printf("\n------------Test strings---------------\n"); test_strings(); @@ -1303,9 +1540,6 @@ int main(int argc, char *argv[]) printf("\n------------Test Compare---------------\n"); test_compare(); - printf("\n------------Test Memory---------------\n"); - test_memory(); - printf("\n------------Test Values---------------\n"); test_values(); diff --git a/libical/src/test/storage.c b/libical/src/test/storage.c index f6d0dd69e5..d53001b574 100644 --- a/libical/src/test/storage.c +++ b/libical/src/test/storage.c @@ -34,14 +34,13 @@ #include <stdio.h> /* for printf */ #include <time.h> /* for time() */ #include "icalmemory.h" -#include "icalstore.h" -#include "icalcluster.h" +#include "icaldirset.h" +#include "icalfileset.h" #include "icalerror.h" #include "icalrestriction.h" #include "icalcalendar.h" -/* This example creates and minipulates the ical object that appears - * in rfc 2445, page 137 */ +#define OUTPUT_FILE "filesetout.ics" char str[] = "BEGIN:VCALENDAR\n\ PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\n\ @@ -106,29 +105,31 @@ END:VCALENDAR\n\ "; -void test_cluster() +void test_fileset() { - icalcluster *cin, *cout; + icalfileset *cout; int month = 0; int count=0; struct icaltimetype start, end; icalcomponent *c,*clone, *itr; - start = icaltimetype_from_timet( time(0),0); + start = icaltime_from_timet( time(0),0,0); end = start; end.hour++; - cout = icalcluster_new("clusterout.ics"); + cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); c = icalparser_parse_string(str2); assert(c != 0); - for(month = 1; month < 2; month++){ + /* Add data to the file */ + + for(month = 1; month < 10; month++){ icalcomponent *event; icalproperty *dtstart, *dtend; - cout = icalcluster_new("clusterout.ics"); + cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); start.month = month; @@ -147,10 +148,10 @@ void test_cluster() assert(dtend!=0); icalproperty_set_dtend(dtend,end); - icalcluster_add_component(cout,clone); - icalcluster_commit(cout); + icalfileset_add_component(cout,clone); + icalfileset_commit(cout); - icalcluster_free(cout); + icalfileset_free(cout); } @@ -158,13 +159,13 @@ void test_cluster() /* Print them out */ - cout = icalcluster_new("clusterout.ics"); + cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); - for (itr = icalcluster_get_first_component(cout, + for (itr = icalfileset_get_first_component(cout, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(cout, + itr = icalfileset_get_next_component(cout, ICAL_ANY_COMPONENT)){ icalcomponent *event; @@ -184,34 +185,34 @@ void test_cluster() /* Remove all of them */ - icalcluster_free(cout); + icalfileset_free(cout); - cout = icalcluster_new("clusterout.ics"); + cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); - for (itr = icalcluster_get_first_component(cout, + for (itr = icalfileset_get_first_component(cout, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(cout, + itr = icalfileset_get_next_component(cout, ICAL_ANY_COMPONENT)){ - icalcluster_remove_component(cout, itr); + icalfileset_remove_component(cout, itr); } - icalcluster_free(cout); + icalfileset_free(cout); /* Print them out again */ - cout = icalcluster_new("clusterout.ics"); + cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); count =0; - for (itr = icalcluster_get_first_component(cout, + for (itr = icalfileset_get_first_component(cout, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(cout, + itr = icalfileset_get_next_component(cout, ICAL_ANY_COMPONENT)){ icalcomponent *event; @@ -229,29 +230,29 @@ void test_cluster() } - icalcluster_free(cout); + icalfileset_free(cout); } -int test_store() +int test_dirset() { icalcomponent *c, *gauge; icalerrorenum error; - icalcomponent *next, *itr; - icalcluster* cluster; + icalcomponent *itr; + icalfileset* cluster; struct icalperiodtype rtime; - icalstore *s = icalstore_new("store"); + icaldirset *s = icaldirset_new("store"); int i; assert(s != 0); - rtime.start = icaltimetype_from_timet( time(0),0); + rtime.start = icaltime_from_timet( time(0),0,0); - cluster = icalcluster_new("clusterout.ics"); + cluster = icalfileset_new(OUTPUT_FILE); assert(cluster != 0); @@ -268,10 +269,10 @@ int test_store() rtime.end = rtime.start; rtime.end.hour++; - for (itr = icalcluster_get_first_component(cluster, + for (itr = icalfileset_get_first_component(cluster, ICAL_ANY_COMPONENT); itr != 0; - itr = icalcluster_get_next_component(cluster, + itr = icalfileset_get_next_component(cluster, ICAL_ANY_COMPONENT)){ icalcomponent *clone, *inner; icalproperty *p; @@ -316,7 +317,8 @@ int test_store() printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner)); - error = icalstore_add_component(s,inner); + error = icaldirset_add_component(s, + icalcomponent_new_clone(itr)); assert(icalerrno == ICAL_NO_ERROR); @@ -346,15 +348,15 @@ int test_store() #if 0 - icalstore_select(s,gauge); + icaldirset_select(s,gauge); - for(c = icalstore_first(s); c != 0; c = icalstore_next(s)){ + for(c = icaldirset_first(s); c != 0; c = icaldirset_next(s)){ printf("Got one! (%d)\n", count++); if (c != 0){ printf("%s", icalcomponent_as_ical_string(c));; - if (icalstore_store(s2,c) == 0){ + if (icaldirset_store(s2,c) == 0){ printf("Failed to write!\n"); } icalcomponent_free(c); @@ -364,38 +366,43 @@ int test_store() } - icalstore_free(s2); + icaldirset_free(s2); #endif - for(c = icalstore_get_first_component(s); + for(c = icaldirset_get_first_component(s,ICAL_ANY_COMPONENT); c != 0; - c = next){ - - next = icalstore_get_next_component(s); + c = icaldirset_get_next_component(s,ICAL_ANY_COMPONENT)){ if (c != 0){ - /*icalstore_remove_component(s,c);*/ printf("%s", icalcomponent_as_ical_string(c));; } else { printf("Failed to get component\n"); } + } + + /* Remove all of the components */ + i=0; + while((c=icaldirset_get_current_component(s)) != 0 ){ + i++; + icaldirset_remove_component(s,c); } + - icalstore_free(s); + icaldirset_free(s); return 0; } void test_calendar() { icalcomponent *comp; - icalcluster *c; - icalstore *s; + icalfileset *c; + icaldirset *s; icalcalendar* calendar = icalcalendar_new("calendar"); icalerrorenum error; - struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + struct icaltimetype atime = icaltime_from_timet( time(0),0,0); comp = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, @@ -419,13 +426,13 @@ void test_calendar() s = icalcalendar_get_booked(calendar); - error = icalstore_add_component(s,comp); + error = icaldirset_add_component(s,comp); assert(error == ICAL_NO_ERROR); c = icalcalendar_get_properties(calendar); - error = icalcluster_add_component(c,icalcomponent_new_clone(comp)); + error = icalfileset_add_component(c,icalcomponent_new_clone(comp)); assert(error == ICAL_NO_ERROR); @@ -437,16 +444,14 @@ void test_calendar() int main(int argc, char *argv[]) { +/* printf("\n------------Test File Set---------------\n"); + test_fileset(); */ - printf("\n------------Test Cluster---------------\n"); - test_cluster(); + printf("\n------------Test Dir Set---------------\n"); + test_dirset(); #if 0 - printf("\n------------Test Store---------------\n"); - test_store(); - - printf("\n------------Test Calendar---------------\n"); test_calendar(); diff --git a/libical/src/test/stow.c b/libical/src/test/stow.c index d7629855c5..f742b417a5 100644 --- a/libical/src/test/stow.c +++ b/libical/src/test/stow.c @@ -33,35 +33,85 @@ #include <stdlib.h> #include <sys/utsname.h> /* for uname */ #include <sys/stat.h> /* for stat */ -#include <unistd.h> /* for stat, getpid */ +#include <unistd.h> /* for stat, getpid, getopt */ +#include <pwd.h> /* For getpwent */ +#include <sys/types.h> /* For getpwent */ +#include <ctype.h> /* for tolower */ #include "ical.h" #include "icalcalendar.h" - +#include "icalfileset.h" +#include "icalmime.h" char* program_name; #define TMPSIZE 2048 +#define SENDMAIL "/usr/lib/sendmail -t" enum options { - STORE_IN_DIR, + STORE_IN_FILE, STORE_IN_DB, - INPUT_IS_EMAIL, + INPUT_IS_MIME, INPUT_IS_ICAL, INPUT_FROM_STDIN, - INPUT_FROM_FILE + INPUT_FROM_FILE, + ERRORS_TO_STDOUT, + ERRORS_TO_ORGANIZER }; struct options_struct { enum options storage; enum options input_type; + enum options input_source; + enum options errors; char* input_file; - char* input_text; char* calid; - char* caldir; + char* output_file; +}; + + +enum file_type +{ + ERROR, + NO_FILE, + DIRECTORY, + REGULAR, + OTHER }; +enum file_type test_file(char *path) +{ + struct stat sbuf; + enum file_type type; + + errno = 0; + + /* Check if the path already exists and if it is a directory*/ + if (stat(path,&sbuf) != 0){ + + /* A file by the given name does not exist, or there was + another error */ + if(errno == ENOENT) + { + type = NO_FILE; + } else { + type = ERROR; + } + + } else { + /* A file by the given name exists, but is it a directory? */ + + if (S_ISDIR(sbuf.st_mode)){ + type = DIRECTORY; + } else if(S_ISREG(sbuf.st_mode)){ + type = REGULAR; + } else { + type = OTHER; + } + } + return type; +} char* lowercase(char* str) { @@ -79,23 +129,33 @@ char* lowercase(char* str) return new; } +#if 0 char* get_local_attendee(struct options_struct *opt) { char attendee[PATH_MAX]; - char* user = getenv("USER"); - struct utsname uts; + if(opt->calid){ - uname(&uts); + strncpy(attendee,opt->calid,PATH_MAX); - /* HACK nodename may not be a fully qualified domain name */ - snprintf(attendee,PATH_MAX,"%s@%s",user,uts.nodename); + } else { + + char* user = getenv("USER"); + struct utsname uts; + uname(&utget_option); + /* HACK nodename may not be a fully qualified domain name */ + snprintf(attendee,PATH_MAX,"%s@%s",user,uts.nodename); + } + return lowercase(attendee); } +#endif void usage(char *message) { + fprintf(stderr,"Usage: %s [-emdcn] [-i inputfile] [-o outputfile] [-u calid]\n",program_name); + } icalcomponent* get_first_real_component(icalcomponent *comp) @@ -140,20 +200,20 @@ char* make_mime(char* to, char* from, char* subject, uname(&uts); srand(time(0)<<getpid()); - sprintf(content_id,"%d-%d@%s",time(0),rand(),uts.nodename); - sprintf(boundary,"%d-%d-%s",time(0),rand(),uts.nodename); + sprintf(content_id,"%d-%d@%s",(int)time(0),rand(),uts.nodename); + sprintf(boundary,"%d-%d-%s",(int)time(0),rand(),uts.nodename); sprintf(mime_part_1,"Content-ID: %s\n\ Content-type: text/plain\n\ Content-Description: Text description of error message\n\n\ -%s\n\n%s", +%s\n\n--%s", content_id,text_message,boundary); if(ical_message != 0 && method != 0){ - sprintf(mime_part_2,"\nContent-ID: %s\n\ + sprintf(mime_part_2,"Content-ID: %s\n\ Content-type: text/calendar; method=%s\n\ -Content-Description: ICal component reply\n\n\ -%s\n\n%s--\n", +Content-Description: iCal component reply\n\n\ +%s\n\n--%s--", content_id,method,ical_message,boundary); } @@ -166,6 +226,7 @@ Content-Type: multipart/mixed; boundary=\"%s\"\n\ \n\ This is a multimedia message in MIME format\n\ \n\ +--%s %s ", to,from,subject,content_id,boundary,boundary, @@ -181,14 +242,39 @@ Content-Type: multipart/mixed; boundary=\"%s\"\n\ } /* The incoming component had fatal errors */ -void return_failure(icalcomponent* comp, char* message, struct options_struct *opt) +void return_failure(icalcomponent* comp, char* message, + struct options_struct *opt) { - + char* local_attendee = opt->calid; + FILE* p; - fputs(make_mime("Dest", "Source", "iMIP error", - message, "reply", - icalcomponent_as_ical_string(comp)),stdout); + icalcomponent *inner = get_first_real_component(comp); + + icalproperty *organizer_prop = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY); + char *organizer = icalproperty_get_organizer(organizer_prop); + + organizer += 7; + if (opt->errors == ERRORS_TO_ORGANIZER){ + p = popen(SENDMAIL,"w"); + } else { + p = stdout; + } + + if(p == 0){ + fprintf(stderr, + "%s: fatal. Could not open pipe to sendmail (\"%s\") \n", + program_name,SENDMAIL); + exit(1); + } + + fputs(make_mime(organizer, local_attendee, "iMIP error", + message, "reply", + icalcomponent_as_ical_string(comp)),p); + + if (opt->errors == ERRORS_TO_ORGANIZER){ + pclose(p); + } } /* The program had a fatal error and could not process the incoming component*/ @@ -201,43 +287,124 @@ void return_error(icalcomponent* comp, char* message, struct options_struct *op } -char* check_component(icalcomponent* comp, struct options_struct *opt) +icalcomponent* make_reply(icalcomponent *comp, icalproperty *return_status, + struct options_struct *opt) + +{ + icalcomponent *reply, *rinner; + icalcomponent *inner = get_first_real_component(comp); + icalproperty *p=0; + char* local_attendee = opt->calid; + char attendee[TMPSIZE]; + + char prodid[TMPSIZE]; + + snprintf(attendee,TMPSIZE,"mailto:%s",local_attendee); + + snprintf(prodid,TMPSIZE,"-//Softwarestudio.org//%s version %s//EN",ICAL_PACKAGE,ICAL_VERSION); + + /* Create the base component */ + reply = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalproperty_new_version(strdup("2.0")), + icalproperty_new_prodid(strdup(prodid)), + icalproperty_new_method(ICAL_METHOD_REPLY), + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_clone( + icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY)), + icalproperty_new_clone( + icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY)), + icalproperty_new_clone( + icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY)), + icalproperty_new_attendee(attendee), + 0), + 0); + + + /* Convert errors into request-status properties and transfers + them to the reply component */ + + icalcomponent_convert_errors(comp); + + rinner = get_first_real_component(reply); + + for(p = icalcomponent_get_first_property(inner, + ICAL_REQUESTSTATUS_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(inner, + ICAL_REQUESTSTATUS_PROPERTY)){ + + icalcomponent_add_property(rinner,icalproperty_new_clone(p)); + } + + if(return_status != 0){ + icalcomponent_add_property(rinner, return_status); + } + + return reply; + +} + +int check_attendee(icalproperty *p, struct options_struct *opt){ + char* s = icalproperty_get_attendee(p); + char* lower_attendee = lowercase(s); + char* local_attendee = opt->calid; + + /* Check that attendee begins with "mailto:" */ + if (strncmp(lower_attendee,"mailto:",7) == 0){ + /* skip over the mailto: part */ + lower_attendee += 7; + + if(strcmp(lower_attendee,local_attendee) == 0){ + return 1; + } + + lower_attendee -= 7; + + free(lower_attendee); + } + + return 0; +} + +char static_component_error_str[PATH_MAX]; +char* check_component(icalcomponent* comp, icalproperty **return_status, + struct options_struct *opt) { - static char static_component_error_str[PATH_MAX]; char* component_error_str=0; icalcomponent* inner; int errors = 0; icalproperty *p; int found_attendee = 0; + *return_status = 0; + /* This do/while loop only executes once because it is being used to fake exceptions */ do { - /* Check that the root component is a VCALENDAR */ - if(icalcomponent_isa(comp) != ICAL_VCALENDAR_COMPONENT){ + /* Check that we actually got a component */ + if(comp == 0){ strcpy(static_component_error_str, - "Root component is not a VCALENDAR"); + "Did not find a component"); component_error_str = static_component_error_str; break; } - /* Check that the component passes iTIP restrictions */ - - errors = icalcomponent_count_errors(comp); - icalrestriction_check(comp); - - if(errors != icalcomponent_count_errors(comp)){ + /* Check that the root component is a VCALENDAR */ + if(icalcomponent_isa(comp) != ICAL_VCALENDAR_COMPONENT){ strcpy(static_component_error_str, - "The component does not conform to iTIP restrictions"); + "Root component is not a VCALENDAR"); component_error_str = static_component_error_str; break; } + /* Check that the component has a METHOD */ - if (!icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY) == 0) + if (icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY) == 0) { strcpy(static_component_error_str, "Component does not have a METHOD property"); @@ -245,208 +412,288 @@ char* check_component(icalcomponent* comp, struct options_struct *opt) break; } - /* Check for this user as an attendee */ + inner = get_first_real_component(comp); - inner = get_first_real_component(comp); + /* Check that the compopnent has an organizer */ + if(icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY) == 0){ + fprintf(stderr,"%s: fatal. Component does not have an ORGANIZER property\n",program_name); + + exit(1); + } + + + /* Check for this user as an attendee or organizer */ for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY); p != 0; p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)){ - - char* s = icalproperty_get_attendee(p); - char* lower_attendee = lowercase(s); - char* local_attendee = get_local_attendee(opt); - - /* Check that attendee begins with "mailto:" */ - if (strncmp(lower_attendee,"mailto:",7) == 0){ - /* skip over the mailto: part */ - lower_attendee += 7; - - if(strcmp(lower_attendee,local_attendee) == 0){ - found_attendee = 1; - } - - lower_attendee -= 7; + + found_attendee += check_attendee(p,opt); + } - free(local_attendee); - free(lower_attendee); - - } + for(p = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(inner,ICAL_ORGANIZER_PROPERTY)){ + + found_attendee += check_attendee(p,opt); } - + if (found_attendee == 0){ - char* local_attendee = get_local_attendee(opt); + struct icalreqstattype rs; + char* rs_string; + memset(static_component_error_str,0,PATH_MAX); + snprintf(static_component_error_str,PATH_MAX, - "This target user (%s) is not listed as an attendee", - local_attendee ); + "This target user (%s) is not listed as an attendee or organizer", + opt->calid ); component_error_str = static_component_error_str; - free(local_attendee); + + rs.code = ICAL_3_7_INVCU_STATUS; + rs.desc = 0; + rs.debug = component_error_str; + rs_string = icalreqstattype_as_string(rs); + + *return_status = icalproperty_new_requeststatus(rs_string); break; } + + + /* Check that the component passes iTIP restrictions */ + + errors = icalcomponent_count_errors(comp); + icalrestriction_check(comp); + + if(errors != icalcomponent_count_errors(comp)){ + snprintf(static_component_error_str,PATH_MAX, + "The component does not conform to iTIP restrictions.\n Here is the original component; look at the X-LIC-ERROR properties\nfor details\n\n%s",icalcomponent_as_ical_string(comp)); + component_error_str = static_component_error_str; + break; + } + + + } while(0); return component_error_str; } + void get_options(int argc, char* argv[], struct options_struct *opt) { - opt->storage = STORE_IN_DIR; - opt->input_type = INPUT_FROM_STDIN; + int c; + extern char *optarg; + extern int optind, optopt; + int errflg=0; + + opt->storage = STORE_IN_FILE; + opt->input_source = INPUT_FROM_STDIN; + opt->input_type = INPUT_IS_ICAL; opt->input_file = 0; - opt->input_text = 0; + opt->errors = ERRORS_TO_ORGANIZER; opt->calid = 0; - opt->caldir = 0; -} - -char* check_options(struct options_struct *opt) -{ - return 0; -} - -void store_component(icalcomponent *comp, icalcalendar* cal, - struct options_struct *opt) -{ - - icalcluster *incoming = 0; - icalerrorenum error; - - incoming = icalcalendar_get_incoming(cal); + opt->output_file = 0; + + + while ((c = getopt(argc, argv, "nemu:o:d:b:c:i:")) != -1) { + switch (c) { + case 'e': { /* Input data is MIME encapsulated */ + opt->input_type = INPUT_IS_MIME; + break; + } + case 'm': { /* Input is iCal. Default*/ + opt->input_type = INPUT_IS_ICAL; + break; + } + case 'i': { /* Input comes from named file */ + opt->input_source = INPUT_FROM_FILE; + opt->input_file = strdup(optarg); + break; + } + case 'o': { /* Output goes to named file. Default*/ + opt->output_file = strdup(optarg); + opt->storage = STORE_IN_FILE; + break; + } + case 'd': { /* Output goes to database */ + fprintf(stderr,"%s: option -d is unimplmented\n",program_name); + opt->storage = STORE_IN_DB; + errflg++; + break; + } + case 'c': { + + break; + } + case 'u': { /* Set the calid for the output database or + file. Default is user name of user running + program */ + opt->calid = strdup(optarg); + break; + } + + case 'n': { /* Dump error to stdout. Default is to + send error to the organizer specified + in the iCal data */ + opt->errors = ERRORS_TO_STDOUT; + break; + } + + case ':': {/* Option given without an operand */ + fprintf(stderr, + "%s: Option -%c requires an operand\n", + program_name,optopt); + errflg++; + break; + } + case '?': { + errflg++; + } + + } + + if (errflg >0){ + usage(""); + exit(1); + } + } - if (incoming == 0){ - fprintf(stderr,"%s: Failed to get incoming component directory: %s\n", - program_name, icalerror_strerror(icalerrno)); - exit(1); - } + if(opt->calid == 0){ + /* If no calid specified, use username */ + char attendee[PATH_MAX]; + char* user = getenv("USER"); + struct utsname uts; + uname(&uts); + /* HACK nodename may not be a fully qualified domain name */ + snprintf(attendee,PATH_MAX,"%s@%s",user,uts.nodename); - error = icalcluster_add_component(incoming,comp); - - if (error != ICAL_NO_ERROR){ - fprintf(stderr,"%s: Failed to write incoming component: %s\n", - program_name, icalerror_strerror(icalerrno)); - exit(1); - } - - error = icalcluster_commit(incoming); - - if (error != ICAL_NO_ERROR){ - fprintf(stderr,"%s: Failed to commit incoming cluster: %s\n", - program_name, icalerror_strerror(icalerrno)); - exit(1); + opt->calid = lowercase(attendee); } - - return; -} - -enum file_type -{ - ERROR, - NO_FILE, - DIRECTORY, - REGULAR, - OTHER -}; -enum file_type test_file(char *path) -{ - struct stat sbuf; - enum file_type type; - - errno = 0; + if(opt->storage == STORE_IN_FILE && + opt->output_file ==0){ + char file[PATH_MAX]; + char* user = getenv("USER"); + struct passwd *pw; - /* Check if the path already exists and if it is a directory*/ - if (stat(path,&sbuf) != 0){ + if(!user){ + fprintf(stderr,"%s: Can't get username. Try explicitly specifing the output file with -o", program_name); + exit(1); + } - /* A file by the given name does not exist, or there was - another error */ - if(errno == ENOENT) - { - type = NO_FILE; - } else { - type = ERROR; + /* Find password entry for user */ + while( (pw = getpwent())!=0){ + if(strcmp(user,pw->pw_name)==0){ + break; + } + } + + if(pw==0){ + fprintf(stderr,"%s: Can't get get password entry for user \"%s\" Try explicitly specifing the output file with -o", + program_name,user); + exit(1); } - } else { - /* A file by the given name exists, but is it a directory? */ - - if (S_ISDIR(sbuf.st_mode)){ - type = DIRECTORY; - } else if(S_ISREG(sbuf.st_mode)){ - type = REGULAR; - } else { - type = OTHER; + if(pw->pw_dir==0){ + fprintf(stderr,"%s: User \"%s\" has no home directory. Try explicitly specifing the output file with -o", + program_name, user); + exit(1); } + + snprintf(file,PATH_MAX,"%s/.facs/%s",pw->pw_dir,opt->calid); + + opt->output_file = strdup(file); } - return type; -} -icalcalendar* get_calendar(icalcomponent* comp, struct options_struct *opt) -{ - - struct stat sbuf; - char calpath[PATH_MAX]; - char facspath[PATH_MAX]; - char* home = getenv("HOME"); - char* user = getenv("USER"); - enum file_type type; - icalcalendar* cal; + /* Now try to create the calendar directory if it does + not exist */ - snprintf(facspath,PATH_MAX,"%s/.facs",home); + if(opt->storage == STORE_IN_FILE ) { + char * p; + char* facspath = strdup(opt->output_file); + enum file_type type; - type = test_file(facspath); + /* Cut off the last slash to make it just a directoy */ - errno = 0; - if (type == NO_FILE){ + p = strrchr(facspath,'/'); - if(mkdir(facspath,0775) != 0){ - fprintf(stderr,"%s: Failed to create calendar store directory %s: %s\n", - program_name,facspath, strerror(errno)); - exit(1); - } else { - printf("%s: Creating calendar store directory %s\n",program_name,facspath); - } + if (p == 0){ + fprintf(stderr,"%s: Invalid calendar filename \"%s\"", + program_name,facspath); + exit(1); + } + + *p='\0'; + + type = test_file(facspath); - } else if(type==REGULAR || type == ERROR){ - fprintf(stderr,"%s: Cannot create calendar store directory %s\n", + errno = 0; + if (type == NO_FILE){ + + if(mkdir(facspath,0775) != 0){ + fprintf(stderr, + "%s: Failed to create calendar directory %s: %s\n", + program_name,facspath, strerror(errno)); + exit(1); + } else { + fprintf(stderr,"%s: Creating calendar directory %s\n", + program_name,facspath); + } + + } else if(type==REGULAR || type == ERROR){ + fprintf(stderr,"%s: Cannot create calendar directory %s\n", program_name,facspath); exit(1); - } + } + } +} +char* check_options(struct options_struct *opt) +{ + return 0; +} +void store_component(icalcomponent *comp, struct options_struct *opt) +{ + icalerrorenum error; - snprintf(calpath,PATH_MAX,"%s/%s",facspath,user); - type = test_file(calpath); + if(opt->storage == STORE_IN_FILE){ + icalfileset *fs = icalfileset_new(opt->output_file); - errno = 0; + if (fs == 0){ + fprintf(stderr, + "%s: Failed to get incoming component directory: %s\n", + program_name, icalerror_strerror(icalerrno)); + exit(1); + } - if (type == NO_FILE){ - if(mkdir(calpath,0775) != 0){ - fprintf(stderr,"%s: Failed to create calendar directory %s: %s\n", - program_name,calpath, strerror(errno)); - } else { - printf("%s: Creating calendar store directory %s\n",program_name,facspath); + error = icalfileset_add_component(fs,comp); + + if (error != ICAL_NO_ERROR){ + fprintf(stderr,"%s: Failed to write incoming component: %s\n", + program_name, icalerror_strerror(icalerrno)); + exit(1); } - } else if(type==REGULAR || type == ERROR){ - fprintf(stderr,"%s: Cannot create calendar directory %s\n", - program_name,calpath); + + error = icalfileset_commit(fs); + + if (error != ICAL_NO_ERROR){ + fprintf(stderr,"%s: Failed to commit incoming cluster: %s\n", + program_name, icalerror_strerror(icalerrno)); exit(1); - } - - cal = icalcalendar_new(calpath); + } + + icalfileset_free(fs); - if(cal == 0){ - fprintf(stderr,"%s: Failed to open calendar at %s: %s", - program_name,calpath,icalerror_strerror(icalerrno)); - exit(1); + return; + } else { + assert(0); } - - return cal; - } char* read_stream(char *s, size_t size, void *d) @@ -456,14 +703,14 @@ char* read_stream(char *s, size_t size, void *d) return c; } -icalcomponent* read_component(struct options_struct *opt) +icalcomponent* read_nonmime_component(struct options_struct *opt) { FILE *stream; icalcomponent *comp; icalparser* parser = icalparser_new(); char* line; - if(opt->input_type == INPUT_FROM_FILE){ + if(opt->input_source == INPUT_FROM_FILE){ stream = fopen(opt->input_file,"r"); if (stream == 0){ @@ -490,22 +737,89 @@ icalcomponent* read_component(struct options_struct *opt) } while ( line != 0); - if(opt->input_type == INPUT_FROM_FILE){ + if(opt->input_source == INPUT_FROM_FILE){ fclose(stream); } + return comp; } +icalcomponent* find_vcalendar(icalcomponent* comp) +{ + icalcomponent *c,*rtrn; + + for(c = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); + c != 0; + c = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ + + if(icalcomponent_isa(c) == ICAL_VCALENDAR_COMPONENT){ + icalcomponent_remove_component(comp,c); + return c; + } + + if((rtrn=find_vcalendar(c)) != 0){ + return rtrn; + } + } + + return 0; +} + +icalcomponent* read_mime_component(struct options_struct *opt) +{ + icalcomponent *comp,*mimecomp; + FILE* stream; + + if(opt->input_source == INPUT_FROM_FILE){ + stream = fopen(opt->input_file,"r"); + + if (stream == 0){ + perror("Can't open input file"); + exit(1); + } + + } else { + stream = stdin; + } + + assert(stream != 0); + + mimecomp = icalmime_parse(read_stream,(void*)stream); + + /* now find the iCal component embedded within the mime component */ + comp = find_vcalendar(mimecomp); + + + if(comp == 0){ + return 0; + } + + return comp; +} + +icalcomponent* read_component(struct options_struct *opt) +{ + if(opt->input_type == INPUT_IS_MIME){ + return read_mime_component(opt); + } else if (opt->input_type == INPUT_IS_ICAL){ + return read_nonmime_component(opt); + } else { + fprintf(stderr,"%s: Internal Error; unknown option for input_type\n", + program_name); + exit(1); + } +} + int main(int argc, char* argv[] ) { char* options_error_str; char* component_error_str; - icalcalendar* cal; icalcomponent* comp, *reply; struct options_struct opt; + icalproperty *return_status; - program_name = argv[0]; + program_name = strrchr(argv[0],'/'); get_options(argc, argv, &opt); @@ -516,17 +830,19 @@ int main(int argc, char* argv[] ) comp = read_component(&opt); - if ( (component_error_str = check_component(comp,&opt)) != 0){ - return_failure(comp, component_error_str, &opt); - exit(1); + if ( (component_error_str = + check_component(comp,&return_status,&opt)) != 0){ + reply = make_reply(comp,return_status,&opt); + return_failure(reply, component_error_str, &opt); + icalcomponent_free(reply); + exit(0); } - cal = get_calendar(comp,&opt); + store_component(comp,&opt); - store_component(comp,cal, &opt); - icalcomponent_free(comp); - icalcalendar_free(cal); + /* Don't free the component comp, since it is now part of the + store, and will be freed there */ exit(0); } |