diff options
Diffstat (limited to 'libical/src/libicalss')
30 files changed, 0 insertions, 5883 deletions
diff --git a/libical/src/libicalss/.cvsignore b/libical/src/libicalss/.cvsignore deleted file mode 100644 index 732c1577b6..0000000000 --- a/libical/src/libicalss/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -.deps -Makefile.in -*.lo -*.la -.libs
\ No newline at end of file diff --git a/libical/src/libicalss/Makefile.am b/libical/src/libicalss/Makefile.am deleted file mode 100644 index 732d970738..0000000000 --- a/libical/src/libicalss/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -lib_LTLIBRARIES = libicalss.la - -YFLAGS =-d -v -p ss -LFLAGS = -Pss -LEX_OUTPUT_ROOT = lex.ss - -all: icalss.h - -INCLUDES = \ - -I$(top_builddir) \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - -I$(top_srcdir)/src/libical \ - -I$(srcdir)/libical - -libicalss_la_LDFLAGS = -version-info 0:0:0 - -libicalss_la_SOURCES = \ - icalclassify.c \ - icalgauge.c \ - icalgaugeimpl.h \ - icaldirset.c \ - icaldirsetimpl.h \ - icalfileset.c \ - icalfilesetimpl.h \ - icalset.c \ - icalsslexer.l \ - icalssutil.c \ - icalssyacc.h \ - icalssyacc.y \ - icalspanlist.c \ - icalmessage.c \ - icalcstp.c - -libicalssincludedir = $(includedir) - -COMBINEDHEADERS = \ - icalgauge.h \ - icalset.h \ - icalfileset.h \ - icaldirset.h \ - icalcalendar.h \ - icalssutil.h \ - icalclassify.h \ - icalspanlist.h \ - icalmessage.h \ - icalcstp.h - -icalss.h: $(COMBINEDHEADERS) - cat $(COMBINEDHEADERS) | egrep -v "#include.*\"ical" \ - | egrep -v "#include.*\"pvl\.h\"" > icalss.h - - -libicalssinclude_HEADERS = icalss.h - -CONFIG_CLEAN_FILES = y.output - -EXTRA_DIST = \ - $(COMBINEDHEADERS) \ diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c deleted file mode 100644 index e63b5330ad..0000000000 --- a/libical/src/libicalss/icalcalendar.c +++ /dev/null @@ -1,265 +0,0 @@ -/*====================================================================== - FILE: icalcalendar.c - CREATOR: eric 23 December 1999 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - - -#include "icalcalendar.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 */ -#include <fcntl.h> /* For mkdir */ -#include <unistd.h> /* For mkdir, stat */ -#include <stdlib.h> /* for malloc */ -#include <string.h> /* for strcat */ -#include <errno.h> - -#define BOOKED_DIR "booked" -#define INCOMING_FILE "incoming.ics" -#define PROP_FILE "properties.ics" -#define FBLIST_FILE "freebusy.ics" - -struct icalcalendar_impl -{ - char* dir; - icalcomponent* freebusy; - icalcomponent* properties; - icalset* booked; - icalset* incoming; -}; - -struct icalcalendar_impl* icalcalendar_new_impl() -{ - struct icalcalendar_impl* impl; - - if ( ( impl = (struct icalcalendar_impl*) - malloc(sizeof(struct icalcalendar_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - return impl; -} - - -icalerrorenum icalcalendar_create(struct icalcalendar_impl* impl) -{ - char path[PATH_MAX]; - struct stat sbuf; - int r; - - icalerror_check_arg_re((impl != 0),"impl",ICAL_BADARG_ERROR); - - path[0] = '\0'; - strcpy(path,impl->dir); - strcat(path,"/"); - strcat(path,BOOKED_DIR); - - r = stat(path,&sbuf); - - if( r != 0 && errno == ENOENT){ - - if(mkdir(path,0777)!=0){ - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } - } - - return ICAL_NO_ERROR; -} - -icalcalendar* icalcalendar_new(char* dir) -{ - struct icalcalendar_impl* impl; - - icalerror_check_arg_rz((dir != 0),"dir"); - - impl = icalcalendar_new_impl(); - - if (impl == 0){ - return 0; - } - - impl->dir = (char*)strdup(dir); - impl->freebusy = 0; - impl->properties = 0; - impl->booked = 0; - impl->incoming = 0; - - if (icalcalendar_create(impl) != ICAL_NO_ERROR){ - free(impl); - return 0; - } - - return impl; -} - -void icalcalendar_free(icalcalendar* calendar) -{ - - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - - if (impl->dir !=0){ - free(impl->dir); - } - - if (impl->freebusy !=0){ - icalfileset_free(impl->freebusy); - } - - if (impl->properties !=0){ - icalfileset_free(impl->properties); - } - - if (impl->booked !=0){ - icaldirset_free(impl->booked); - } - - if (impl->incoming !=0){ - icaldirset_free(impl->incoming); - } - - impl->dir = 0; - impl->freebusy = 0; - impl->properties = 0; - impl->booked = 0; - impl->incoming = 0; - - - free(impl); -} - - -int icalcalendar_lock(icalcalendar* calendar) -{ - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - return 0; -} - -int icalcalendar_unlock(icalcalendar* calendar) -{ - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - return 0; -} - -int icalcalendar_islocked(icalcalendar* calendar) -{ - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - return 0; -} - -int icalcalendar_ownlock(icalcalendar* calendar) -{ - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - return 0; -} - -icalset* icalcalendar_get_booked(icalcalendar* calendar) -{ - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - char dir[PATH_MAX]; - - icalerror_check_arg_rz((impl != 0),"impl"); - - dir[0] = '\0'; - strcpy(dir,impl->dir); - strcat(dir,"/"); - strcat(dir,BOOKED_DIR); - - if (impl->booked == 0){ - icalerror_clear_errno(); - impl->booked = icaldirset_new(dir); - assert(icalerrno == ICAL_NO_ERROR); - } - - return impl->booked; - -} - -icalset* icalcalendar_get_incoming(icalcalendar* calendar) -{ - char path[PATH_MAX]; - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - - path[0] = '\0'; - strcpy(path,impl->dir); - strcat(path,"/"); - strcat(path,INCOMING_FILE); - - if (impl->properties == 0){ - impl->properties = icalfileset_new(path); - } - - return impl->properties; -} - -icalset* icalcalendar_get_properties(icalcalendar* calendar) -{ - char path[PATH_MAX]; - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - - path[0] = '\0'; - strcpy(path,impl->dir); - strcat(path,"/"); - strcat(path,PROP_FILE); - - if (impl->properties == 0){ - impl->properties = icalfileset_new(path); - } - - return impl->properties; -} - -icalset* icalcalendar_get_freebusy(icalcalendar* calendar) -{ - char path[PATH_MAX]; - struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar; - icalerror_check_arg_rz((impl != 0),"impl"); - - path[0] = '\0'; - strcpy(path,impl->dir); - strcat(path,"/"); - strcat(path,FBLIST_FILE); - - - if (impl->freebusy == 0){ - impl->freebusy = icalfileset_new(path); - } - - return impl->freebusy; -} - - - - diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h deleted file mode 100644 index f07457c60d..0000000000 --- a/libical/src/libicalss/icalcalendar.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcalendar.h - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALCALENDAR_H -#define ICALCALENDAR_H - -#include "ical.h" -#include "icalset.h" - -/* icalcalendar - * Routines for storing calendar data in a file system. The calendar - * 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 */ - -typedef void icalcalendar; - -icalcalendar* icalcalendar_new(char* dir); - -void icalcalendar_free(icalcalendar* calendar); - -int icalcalendar_lock(icalcalendar* calendar); - -int icalcalendar_unlock(icalcalendar* calendar); - -int icalcalendar_islocked(icalcalendar* calendar); - -int icalcalendar_ownlock(icalcalendar* calendar); - -icalset* icalcalendar_get_booked(icalcalendar* calendar); - -icalset* icalcalendar_get_incoming(icalcalendar* calendar); - -icalset* icalcalendar_get_properties(icalcalendar* calendar); - -icalset* icalcalendar_get_freebusy(icalcalendar* calendar); - - -#endif /* !ICALCALENDAR_H */ - - - diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c deleted file mode 100644 index 89761d8120..0000000000 --- a/libical/src/libicalss/icalclassify.c +++ /dev/null @@ -1,701 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalclassify.c - CREATOR: ebusboom 23 aug 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "ical.h" -#include "icalclassify.h" -#include "icalmemory.h" -#include <ctype.h> /* For tolower() */ -#include <string.h> /* for index() */ -#include <stdlib.h> /* for malloc and free */ - - - -struct icalclassify_parts { - icalcomponent *c; - icalproperty_method method; - char* organizer; - icalparameter_partstat reply_partstat; - char* reply_attendee; - char* uid; - int sequence; - struct icaltimetype dtstamp; - struct icaltimetype recurrence_id; -}; - - -char* icalclassify_lowercase(const char* str) -{ - char* p = 0; - char* new = icalmemory_strdup(str); - - if(str ==0){ - return 0; - } - - for(p = new; *p!=0; p++){ - *p = tolower(*p); - } - - return new; -} - -/* Return a set of components that intersect in time with comp. For -component X and Y to intersect: - X.DTSTART < Y.DTEND && X.DTEND > Y.DTSTART -*/ - - -icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp) -{ - icalcomponent *return_set; - icalcomponent *c; - struct icaltime_span span,compspan; - - icalerror_clear_errno(); - compspan = icalcomponent_get_span(comp); - - if(icalerrno != ICAL_NO_ERROR){ - return 0; - } - - - return_set = icalcomponent_new(ICAL_XROOT_COMPONENT); - - for(c = icalset_get_first_component(set); - c != 0; - c = icalset_get_next_component(set)){ - - icalerror_clear_errno(); - - span = icalcomponent_get_span(c); - - if(icalerrno != ICAL_NO_ERROR){ - continue; - } - - if (compspan.start < span.end && - compspan.end > span.start){ - - icalcomponent *clone = icalcomponent_new_clone(c); - - icalcomponent_add_component(return_set,clone); - } - } - - if(icalcomponent_count_components(return_set,ICAL_ANY_COMPONENT) !=0){ - return return_set; - } else { - icalcomponent_free(return_set); - return 0; - } -} - - - -icalparameter_partstat icalclassify_find_attendee(icalcomponent *c, - const char* attendee) -{ - icalproperty *p; - char* lattendee = icalclassify_lowercase(attendee); - char* upn = strchr(lattendee,':'); - icalcomponent *inner = icalcomponent_get_first_real_component(c); - - for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) - { - const char* this_attendee - = icalclassify_lowercase(icalproperty_get_attendee(p)); - char* this_upn = strchr(this_attendee,':'); - - if(strcmp(this_upn,upn)==0){ - - icalparameter *param = icalproperty_get_first_parameter(p, - ICAL_PARTSTAT_PARAMETER); - if (param != 0){ - free(lattendee); - free((void*)this_attendee); - return icalparameter_get_partstat(param); - } - - } - - } - - free(lattendee); - return ICAL_PARTSTAT_NONE; - -} - -void icalssutil_free_parts(struct icalclassify_parts *parts) -{ - if(parts == 0){ - return; - } - - if(parts->organizer != 0){ - free(parts->organizer); - } - - if(parts->uid != 0){ - free(parts->uid); - } - - if(parts->reply_attendee){ - free(parts->reply_attendee); - } -} - -void icalssutil_get_parts(icalcomponent* c, - struct icalclassify_parts* parts) -{ - icalproperty *p; - icalcomponent *inner; - - memset(parts,0,sizeof(struct icalclassify_parts)); - - parts->method = ICAL_METHOD_NONE; - parts->sequence = 0; - parts->reply_partstat = ICAL_PARTSTAT_NONE; - - if(c == 0){ - return; - } - - parts->c = c; - - p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); - if(p!=0){ - parts->method = icalproperty_get_method(p); - } - - inner = icalcomponent_get_first_real_component(c); - - p = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY); - if(p!=0){ - parts->organizer = strdup(icalproperty_get_organizer(p)); - } - - p = icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY); - if(p!=0){ - parts->sequence = icalproperty_get_sequence(p); - } - - p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); - if(p!=0){ - parts->uid = strdup(icalproperty_get_uid(p)); - } - - p = icalcomponent_get_first_property(inner,ICAL_RECURRENCEID_PROPERTY); - if(p!=0){ - parts->recurrence_id = icalproperty_get_recurrenceid(p); - } - - p = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); - if(p!=0){ - parts->dtstamp = icalproperty_get_dtstamp(p); - } - - if(parts->method==ICAL_METHOD_REPLY){ - icalparameter *param; - p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY); - - if(p!=0){ - - param = icalproperty_get_first_parameter(p,ICAL_PARTSTAT_PARAMETER); - - if(param != 0){ - parts->reply_partstat = - icalparameter_get_partstat(param); - } - - parts->reply_attendee = strdup(icalproperty_get_attendee(p)); - } - - } - - -} - - -int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b) -{ - icalproperty *p1,*p2; - icalcomponent *i1,*i2; - int i; - - icalproperty_kind kind_array[] = { - ICAL_DTSTART_PROPERTY, - ICAL_DTEND_PROPERTY, - ICAL_DURATION_PROPERTY, - ICAL_DUE_PROPERTY, - ICAL_RRULE_PROPERTY, - ICAL_RDATE_PROPERTY, - ICAL_EXRULE_PROPERTY, - ICAL_EXDATE_PROPERTY, - ICAL_NO_PROPERTY - }; - - i1 = icalcomponent_get_first_real_component(a); - i2 = icalcomponent_get_first_real_component(b); - - for(i =0; kind_array[i] != ICAL_NO_PROPERTY; i++){ - p1 = icalcomponent_get_first_property(i1,kind_array[i]); - p2 = icalcomponent_get_first_property(i2,kind_array[i]); - - if( (p1!=0)^(p1!=0) ){ - /* Return true if the property exists in one component and not - the other */ - return 1; - } - - if(p1 && strcmp(icalproperty_as_ical_string(p1), - icalproperty_as_ical_string(p2)) != 0){ - return 1; - } - } - - return 0; - -} - -#define icalclassify_pre \ - int rtrn =0; - -#define icalclassify_post \ - return rtrn; - - -int icalclassify_publish_new(struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre; - - if(comp->method == ICAL_METHOD_PUBLISH && - match == 0){ - rtrn = 1; - } - - icalclassify_post; - -} - -int icalclassify_publish_update(struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre; - - if(comp->method == ICAL_METHOD_PUBLISH && - match !=0 ){ - rtrn = 1; - } - - icalclassify_post; - -} - -int icalclassify_publish_freebusy(struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre; - - if(comp->method == ICAL_METHOD_PUBLISH && - match == 0){ - rtrn = 1; - } - - icalclassify_post; - -} - - -int icalclassify_request_new(struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - /* Method is REQUEST, and there is no match */ - - icalclassify_pre - - if(match->c==0 && comp->method == ICAL_METHOD_REQUEST){ - rtrn = 1; - } - - icalclassify_post - -} - -int icalclassify_request_update( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - /* REQUEST method, Higher SEQUENCE than match, and all - time-related properties are unchanged */ - - icalclassify_pre - - if (match != 0 && - comp->sequence >= match->sequence && - !icalssutil_is_rescheduled(comp->c,match->c)){ - rtrn = 1; - } - - icalclassify_post - -} - -int icalclassify_request_reschedule( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - /* REQUEST method, Higher SEQUENCE than match, and one or more - time-related properties are changed */ - icalclassify_pre - - if (match->c != 0 && - comp->sequence > match->sequence && - icalssutil_is_rescheduled(comp->c,match->c)){ - rtrn = 1; - } - - icalclassify_post - -} - -int icalclassify_request_delegate( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - - if (match->c != 0 && - comp->sequence > match->sequence && - icalssutil_is_rescheduled(comp->c,match->c)){ - rtrn = 1; - } - - icalclassify_post - -} - -int icalclassify_request_new_organizer( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - /* Organizer has changed between match and component */ - icalclassify_pre - - icalclassify_post - -} - -int icalclassify_request_status( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - icalclassify_post -} - -int icalclassify_request_forward( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - icalclassify_post -} - -int icalclassify_request_freebusy( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - icalclassify_post -} - -int icalclassify_reply_accept( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalparameter_partstat partstat; - icalclassify_pre; - - partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); - - if(partstat != ICAL_PARTSTAT_NONE && - comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){ - rtrn = 1; - } - - icalclassify_post -} -int icalclassify_reply_decline( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalparameter_partstat partstat; - icalclassify_pre; - - - partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); - - if(partstat != ICAL_PARTSTAT_NONE && - comp->reply_partstat == ICAL_PARTSTAT_DECLINED){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_reply_crasher_accept( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalparameter_partstat partstat; - icalclassify_pre; - - - partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); - - if(partstat == ICAL_PARTSTAT_NONE && - comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_reply_crasher_decline( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalparameter_partstat partstat; - icalclassify_pre; - - - partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); - - if(partstat == ICAL_PARTSTAT_NONE && - comp->reply_partstat == ICAL_PARTSTAT_DECLINED){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_add_instance( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_ADD){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_cancel_event( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_CANCEL){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_cancel_instance( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_CANCEL){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_cancel_all( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_CANCEL){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_refesh( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_REFRESH){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_counter( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - if(comp->method == ICAL_METHOD_COUNTER){ - rtrn = 1; - } - icalclassify_post -} -int icalclassify_delinecounter( - struct icalclassify_parts *comp, - struct icalclassify_parts *match, - const char* user) -{ - icalclassify_pre - - if(comp->method == ICAL_METHOD_DECLINECOUNTER){ - rtrn = 1; - } - - icalclassify_post -} - -struct icalclassify_map { - icalproperty_method method; - int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); - ical_class class; -} icalclassify_map[] = -{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS}, - {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS}, - {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS}, - {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS}, - - {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS}, - {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS}, - {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS}, - {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS}, - - {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS}, - - {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS}, - {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS}, - {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS}, - - {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS}, - {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS}, - {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS}, - {ICAL_METHOD_NONE,0,ICAL_NO_CLASS} -}; - - -ical_class icalclassify(icalcomponent* c,icalcomponent* match, - const char* user) -{ - icalcomponent *inner; - icalproperty *p; - icalproperty_method method; - ical_class class = ICAL_UNKNOWN_CLASS; - - int i; - - struct icalclassify_parts comp_parts; - struct icalclassify_parts match_parts; - - inner = icalcomponent_get_first_real_component(c); - - if (inner == 0) { - return ICAL_NO_CLASS; - } - - icalssutil_get_parts(c,&comp_parts); - icalssutil_get_parts(match,&match_parts); - - /* Determine if the incoming component is obsoleted by the match */ - if(match != 0 && ( - comp_parts.method == ICAL_METHOD_REQUEST - )){ - assert ( ! ((comp_parts.dtstamp.is_utc==1)^ - (match_parts.dtstamp.is_utc==1))); - - if( comp_parts.sequence<match_parts.sequence && - icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0) - { - /* comp has a smaller sequence and a later DTSTAMP */ - return ICAL_MISSEQUENCED_CLASS; - } - - if( (comp_parts.sequence<match_parts.sequence ) - /*&&icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0*/ - || - ( comp_parts.sequence == match_parts.sequence && - icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){ - - return ICAL_OBSOLETE_CLASS; - } - - } - - p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); - if (p == 0) { - return ICAL_UNKNOWN_CLASS; - } - method = icalproperty_get_method(p); - - for (i =0; icalclassify_map[i].method != ICAL_METHOD_NONE; i++){ - if(icalclassify_map[i].method == method){ - if( (*(icalclassify_map[i].fn))(&comp_parts,&match_parts,user)==1){ - class = icalclassify_map[i].class; - break; - } - } - } - - icalssutil_free_parts(&comp_parts); - icalssutil_free_parts(&match_parts); - - return class; - -} diff --git a/libical/src/libicalss/icalclassify.h b/libical/src/libicalss/icalclassify.h deleted file mode 100644 index ae76434378..0000000000 --- a/libical/src/libicalss/icalclassify.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalclassify.h - CREATOR: eric 21 Aug 2000 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - =========================================================================*/ - -#ifndef ICALCLASSIFY_H -#define ICALCLASSIFY_H - -#include "ical.h" -#include "icalset.h" - - -typedef enum icalclass { - ICAL_NO_CLASS, - ICAL_PUBLISH_NEW_CLASS, - ICAL_PUBLISH_UPDATE_CLASS, - ICAL_PUBLISH_FREEBUSY_CLASS, - ICAL_REQUEST_NEW_CLASS, - ICAL_REQUEST_UPDATE_CLASS, - ICAL_REQUEST_RESCHEDULE_CLASS, - ICAL_REQUEST_DELEGATE_CLASS, - ICAL_REQUEST_NEW_ORGANIZER_CLASS, - ICAL_REQUEST_FORWARD_CLASS, - ICAL_REQUEST_STATUS_CLASS, - ICAL_REQUEST_FREEBUSY_CLASS, - ICAL_REPLY_ACCEPT_CLASS, - ICAL_REPLY_DECLINE_CLASS, - ICAL_REPLY_CRASHER_ACCEPT_CLASS, - ICAL_REPLY_CRASHER_DECLINE_CLASS, - ICAL_ADD_INSTANCE_CLASS, - ICAL_CANCEL_EVENT_CLASS, - ICAL_CANCEL_INSTANCE_CLASS, - ICAL_CANCEL_ALL_CLASS, - ICAL_REFRESH_CLASS, - ICAL_COUNTER_CLASS, - ICAL_DECLINECOUNTER_CLASS, - ICAL_MALFORMED_CLASS, - ICAL_OBSOLETE_CLASS, /* 21 */ - ICAL_MISSEQUENCED_CLASS, /* 22 */ - ICAL_UNKNOWN_CLASS /* 23 */ -} ical_class; - -ical_class icalclassify(icalcomponent* c,icalcomponent* match, - const char* user); - -icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); - -#endif /* ICALCLASSIFY_H*/ - - - - - diff --git a/libical/src/libicalss/icalcomponent.h b/libical/src/libicalss/icalcomponent.h deleted file mode 100644 index 9e0e9f5a9f..0000000000 --- a/libical/src/libicalss/icalcomponent.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcomponent.h - 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 - The original code is icalcomponent.h - -======================================================================*/ - -#ifndef ICALCOMPONENT_H -#define ICALCOMPONENT_H - -#include "icalproperty.h" -#include "icalvalue.h" -#include "icalenums.h" /* defines icalcomponent_kind */ - -typedef void icalcomponent; - -icalcomponent* icalcomponent_new(icalcomponent_kind kind); -icalcomponent* icalcomponent_new_clone(icalcomponent* component); -icalcomponent* icalcomponent_new_from_string(char* str); -icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...); -void icalcomponent_free(icalcomponent* component); - -char* icalcomponent_as_ical_string(icalcomponent* component); - -int icalcomponent_is_valid(icalcomponent* component); - -icalcomponent_kind icalcomponent_isa(icalcomponent* component); - -int icalcomponent_isa_component (void* component); - -/* - * Working with properties - */ - -void icalcomponent_add_property(icalcomponent* component, - icalproperty* property); - -void icalcomponent_remove_property(icalcomponent* component, - icalproperty* property); - -int icalcomponent_count_properties(icalcomponent* component, - icalproperty_kind kind); - -/* Iterate through the properties */ -icalproperty* icalcomponent_get_current_property(icalcomponent* component); - -icalproperty* icalcomponent_get_first_property(icalcomponent* component, - icalproperty_kind kind); -icalproperty* icalcomponent_get_next_property(icalcomponent* component, - icalproperty_kind kind); - -/* Return a null-terminated array of icalproperties*/ - -icalproperty** icalcomponent_get_properties(icalcomponent* component, - icalproperty_kind kind); - - -/* - * Working with components - */ - - -void icalcomponent_add_component(icalcomponent* parent, - icalcomponent* child); - -void icalcomponent_remove_component(icalcomponent* parent, - icalcomponent* child); - -int icalcomponent_count_components(icalcomponent* component, - icalcomponent_kind kind); - -/* Iterate through components */ -icalcomponent* icalcomponent_get_current_component (icalcomponent* component); - -icalcomponent* icalcomponent_get_first_component(icalcomponent* component, - icalcomponent_kind kind); -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); - -/* Working with embedded error properties */ - -int icalcomponent_count_errors(icalcomponent* component); -void icalcomponent_strip_errors(icalcomponent* component); - - -/* Internal operations. You don't see these... */ -icalcomponent* icalcomponent_get_parent(icalcomponent* component); -void icalcomponent_set_parent(icalcomponent* component, - icalcomponent* parent); - -#endif /* !ICALCOMPONENT_H */ - - - diff --git a/libical/src/libicalss/icalcsdb.h b/libical/src/libicalss/icalcsdb.h deleted file mode 100644 index 4619b94fd0..0000000000 --- a/libical/src/libicalss/icalcsdb.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcsdb.h Calendar Server Database - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - -======================================================================*/ - -#ifndef ICALCSDB_H -#define ICALCSDB_H - -#include "ical.h" - -typedef void icalcsdb; - -icalcsdb* icalcsdb_new(char* path); - -void icalcsdb_free(icalcsdb* csdb); - -icalerrorenum icalcsdb_create(icalcsdb* db, char* calid); - -icalerrorenum icalcsdb_delete(icalcsdb* db, char* calid); - -icalerrorenum icalcsdb_move(icalcsdb* db, char* oldcalid, char* newcalid); - -icalerrorenum icalcsdb_noop(icalcsdb* db); - -char* icalcsdb_generateuid(icalcsdb* db); - -icalcomponent* icalcsdb_expand_upn(icalcsdb* db, char* upn); -icalcomponent* icalcsdb_expand_calid(icalcsdb* db, char* calid); - -icalerrorenum icalcsbd_senddata(icalcsdb* db, icalcomponent* comp); - -icalset* icalcsdb_get_calendar(icalcsdb* db, char* calid, - icalcomponent *gauge); - -icalset* icalcsdb_get_vcars(icalcsdb* db); - -icalset* icalcsdb_get_properties(icalcsdb* db); - -icalset* icalcsdb_get_capabilities(icalcsdb* db); - -icalset* icalcsdb_get_timezones(icalcsdb* db); - - -#endif /* !ICALCSDB_H */ - - - diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c deleted file mode 100644 index 53ee7bdeef..0000000000 --- a/libical/src/libicalss/icalcstp.c +++ /dev/null @@ -1,416 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalcstps.c - CREATOR: ebusboom 23 Jun 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "ical.h" -#include "icalcstp.h" -#include "pvl.h" - -#include <sys/types.h> /* For send(), others */ -#include <sys/socket.h> /* For send(), others. */ -#include <unistd.h> /* For alarm */ -#include <errno.h> -#include <stdlib.h> /* for malloc */ -#include <string.h> - -enum cstps_state { - NO_STATE, - CONNECTED, - AUTHENTICATED, - IDENTIFIED, - DISCONNECTED, - RECEIVE, -}; - -struct icalcstps_impl { - int timeout; - icalparser *parser; - enum cstps_state major_state; - struct icalcstps_stubs stubs; -}; - - -enum cstp_command { - ABORT, - AUTHENTICATE, - CAPABILITY, - CONTINUE, - EXPANDCALID, - IDENTIFY, - DISCONNECT, - SENDDATA, - STARTTLS, - EXPANDUPN, - COMMAND_COMPLETE, - UNKNOWN -}; - -struct command_map { - enum cstp_command command; - char *str; -} command_map[] = -{ - {ABORT,"ABORT"}, - {AUTHENTICATE,"AUTHENTICATE"}, - {CAPABILITY,"CAPABILITY"}, - {CONTINUE,"CONTINUE"}, - {EXPANDCALID,"EXPANDCALID"}, - {IDENTIFY,"IDENTIFY"}, - {DISCONNECT,"DISCONNECT"}, - {SENDDATA,"SENDDATA"}, - {STARTTLS,"STARTTLS"}, - {EXPANDUPN,"EXPANDUPN"}, - {UNKNOWN,"UNKNOWN"} -}; - - - -/* This state machine is a Mealy-type: actions occur on the - transitions, not in the states. - - Here is the state machine diagram from the CAP draft: - - - STARTTLS / - CAPABILITY - +-------+ - | | +---------------+ - | +-----------+ AUTHENTICATE | | - +-->| Connected |-------------->| Authenticated | - +-----------+ | | - | +---------------+ - | | - | | - | | - | | +-----+ STARTTLS / - | V | | CAPABILITY / - | +---------------+ | IDENTIFY - | | |<-+ - | | Identified |<----+ - | +--------| | | - | | +---------------+ | command - | | | | completes - V |DISCONNECT | | - +--------------+ | |SENDDATA | - | Disconnected |<--+ | | - +--------------+ | | ABORT - A | | - | V | - | DISCONNECT +---------------+ | - +--------------------| Receive |--+ - | |<--+ - +---------------+ | - | | CONTINUTE - +----+ - - In this implmenetation, the transition from CONNECTED to IDENTIFIED - is non-standard. The spec specifies that on the ATHENTICATE - command, the machine transitions from CONNECTED to AUTHENTICATED, - and then immediately goes to IDENTIFIED. This makes AUTHENTICATED a - useless state, so I removed it */ - -struct state_table { - enum cstps_state major_state; - enum cstp_command command; - void (*action)(); - enum cstps_state next_state; - -} server_state_table[] = -{ - { CONNECTED, CAPABILITY , 0, CONNECTED}, - { CONNECTED, AUTHENTICATE , 0, IDENTIFIED}, /* Non-standard */ - { IDENTIFIED, STARTTLS, 0, IDENTIFIED}, - { IDENTIFIED, IDENTIFY, 0, IDENTIFIED}, - { IDENTIFIED, CAPABILITY, 0, IDENTIFIED}, - { IDENTIFIED, SENDDATA, 0, RECEIVE}, - { IDENTIFIED, DISCONNECT, 0, DISCONNECTED}, - { DISCONNECTED, 0, 0, 0}, - { RECEIVE, DISCONNECT, 0, DISCONNECTED}, - { RECEIVE, CONTINUE, 0, RECEIVE}, - { RECEIVE, ABORT , 0, IDENTIFIED}, - { RECEIVE, COMMAND_COMPLETE , 0, IDENTIFIED} -}; - - -/**********************************************************************/ - - - -icalcstps* icalcstps_new(struct icalcstps_stubs stubs) -{ - struct icalcstps_impl* impl; - - if ( ( impl = (struct icalcstps_impl*) - malloc(sizeof(struct icalcstps_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - impl->stubs = stubs; - impl->timeout = 10; - - return (icalcstps*)impl; - -} - -void icalcstps_free(icalcstps* cstp); - -int icalcstps_set_timeout(icalcstps* cstp, int sec) -{ - struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp; - - icalerror_check_arg_rz( (cstp!=0), "cstp"); - - impl->timeout = sec; - - return sec; -} - -typedef struct icalcstps_response { - icalrequeststatus code; - char caluid[1024]; - void* result; -} icalcstps_response; - -int line_is_command(char* line); -int line_is_response(char* line); -int line_is_endofdata(char* line); -int line_is_mime(char* line); - -icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data) -{ return ICAL_NO_ERROR; -} -icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data) -{ return ICAL_NO_ERROR; -} -icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data) -{ - return ICAL_NO_ERROR; -} -icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data) -{ return ICAL_NO_ERROR; -} - -char* icalcstps_process_incoming(icalcstps* cstp, char* input) -{ - struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp; - char *i; - char *cmd_or_resp; - char *data; - char *input_cpy; - icalerrorenum error; - - icalerror_check_arg_rz(cstp !=0,"cstp"); - icalerror_check_arg_rz(input !=0,"input"); - - if ((input_cpy = (char*)strdup(input)) == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - i = (char*)strstr(" ",input_cpy); - - cmd_or_resp = input_cpy; - - if (i != 0){ - *i = '\0'; - data = ++i; - } else { - data = 0; - } - - printf("cmd: %s\n",cmd_or_resp); - printf("data: %s\n",data); - - /* extract the command, look up in the state table, and dispatch - to the proper handler */ - - if(strcmp(cmd_or_resp,"ABORT") == 0){ - error = prep_abort(impl,data); - } else if(strcmp(cmd_or_resp,"AUTHENTICATE") == 0){ - error = prep_authenticate(impl,data); - } else if(strcmp(cmd_or_resp,"CAPABILITY") == 0){ - error = prep_capability(impl,data); - } else if(strcmp(cmd_or_resp,"CALIDEXPAND") == 0){ - error = prep_calidexpand(impl,data); - } else if(strcmp(cmd_or_resp,"CONTINUE") == 0){ - error = prep_continue(impl,data); - } else if(strcmp(cmd_or_resp,"DISCONNECT") == 0){ - error = prep_disconnect(impl,data); - } else if(strcmp(cmd_or_resp,"IDENTIFY") == 0){ - error = prep_identify(impl,data); - } else if(strcmp(cmd_or_resp,"STARTTLS") == 0){ - error = prep_starttls(impl,data); - } else if(strcmp(cmd_or_resp,"UPNEXPAND") == 0){ - error = prep_upnexpand(impl,data); - } else if(strcmp(cmd_or_resp,"SENDDATA") == 0){ - error = prep_sendata(impl,data); - } - - return 0; -} - - /* Read data until we get a end of data marker */ - - - -struct icalcstps_server_stubs { - icalerrorenum (*abort)(icalcstps* cstp); - icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism, - char* data); - icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid); - icalerrorenum (*capability)(icalcstps* cstp); - icalerrorenum (*cont)(icalcstps* cstp, unsigned int time); - icalerrorenum (*identify)(icalcstps* cstp, char* id); - icalerrorenum (*disconnect)(icalcstps* cstp); - icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time, - icalcomponent *comp); - icalerrorenum (*starttls)(icalcstps* cstp, char* command, - char* data); - icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn); - icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data); -}; - - -/********************** Client (Sender) Interfaces **************************/ - -struct icalcstpc_impl { - int timeout; - icalparser *parser; - enum cstp_command command; - char* next_output; - char* next_input; -}; - -icalcstps* icalcstpc_new(); - -void* icalcstpc_free(icalcstpc* cstpc); - -/* Get the next string to send to the server */ -char* icalcstpc_next_output(icalcstpc* cstp) -{ - return 0; -} - -/* process the next string to send to the server */ -int icalcstpc_next_input(icalcstpc* cstp) -{ - return 0; -} - -/* After icalcstpc_next_input returns a 0, there are responses - ready. use these to get them */ -icalcstpc_response icalcstpc_first_response(icalcstpc* cstp); -icalcstpc_response icalcstpc_next_response(icalcstpc* cstp); - -int icalcstpc_set_timeout(icalcstpc* cstp, int sec); - -icalerrorenum icalcstpc_abort(icalcstpc* cstp) -{ - struct icalcstpc_impl* impl = (struct icalcstpc_impl*)cstp; - - icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR); - - impl->next_output = "ABORT"; - - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism, - char* data, char* f(char*)) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_capability(icalcstpc* cstp) -{ - return ICAL_NO_ERROR;} - -icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_disconnect(icalcstpc* cstp) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command, - char* data, char * f(char*)) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid) -{ - return ICAL_NO_ERROR; -} - -icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time, - icalcomponent *comp) -{ - return ICAL_NO_ERROR; -} - - - - diff --git a/libical/src/libicalss/icalcstp.h b/libical/src/libicalss/icalcstp.h deleted file mode 100644 index 2ebccd622a..0000000000 --- a/libical/src/libicalss/icalcstp.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcstp.h - CREATOR: eric 20 April 1999 - - $Id$ - - - (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 icalcstp.h - -======================================================================*/ - - -#ifndef ICALCSTP_H -#define ICALCSTP_H - -#include "ical.h" - - -/********************** Server (Reciever) Interfaces *************************/ - -/* On the server side, the caller will recieve data from the incoming - socket and pass it to icalcstps_next_input. The caller then takes - the return from icalcstps_next_outpu and sends it out through the - socket. This gives the caller a point of control. If the cstp code - connected to the socket itself, it would be hard for the caller to - do anything else after the cstp code was started. - - All of the server abd client command routines will generate - response codes. On the server side, these responses will be turned - into text and sent to the client. On the client side, the reponse - is the one sent from the server. - - Since each command can return multiple responses, the responses are - stored in the icalcstps object and are accesses by - icalcstps_first_response() and icalcstps_next_response() - - How to use: - - 1) Construct a new icalcstps, bound to your code via stubs - 2) Repeat forever: - 2a) Get string from client & give to icalcstps_next_input() - 2b) Repeat until icalcstp_next_output returns 0: - 2b1) Call icalcstps_next_output. - 2b2) Send string to client. -*/ - - - -typedef void icalcstps; - -/* Er, they aren't really stubs, but pointers to the rountines that - icalcstps_process_incoming will call when it recognizes a CSTP - command in the data. BTW, the CONTINUE command is named 'cont' - because 'continue' is a C keyword */ -struct icalcstps_stubs { - icalerrorenum (*abort)(icalcstps* cstp); - icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism, - char* data); - icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid); - icalerrorenum (*capability)(icalcstps* cstp); - icalerrorenum (*cont)(icalcstps* cstp, unsigned int time); - icalerrorenum (*identify)(icalcstps* cstp, char* id); - icalerrorenum (*disconnect)(icalcstps* cstp); - icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time, - icalcomponent *comp); - icalerrorenum (*starttls)(icalcstps* cstp, char* command, - char* data); - icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn); - icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data); -}; - - -icalcstps* icalcstps_new(struct icalcstps_stubs stubs); - -void icalcstps_free(icalcstps* cstp); - -int icalcstps_set_timeout(icalcstps* cstp, int sec); - -/* Get the next string to send to the client */ -char* icalcstps_next_output(icalcstps* cstp); - -/* process the next string from the client */ -int icalcstps_next_input(icalcstps* cstp); - - -/********************** Client (Sender) Interfaces **************************/ - -/* How to use: - - 1) Construct a new icalcstpc - 2) Issue a command by calling one of the command routines. - 3) Repeat until both call icalcstpc_next_output and - icalcstpc_next_input return 0: - 3a) Call icalcstpc_next_output. Send string to server. - 3b) Get string from server, & give to icalcstp_next_input() - 4) Iterate with icalcstpc_first_response & icalcstp_next_response to - get the servers responses - 5) Repeat at #2 -*/ - -typedef void* icalcstpc; - -/* Response code sent by the server. */ -typedef struct icalcstpc_response { - icalrequeststatus code; - char *arg; /* These strings are owned by libical */ - char *debug_text; - char *more_text; - void* result; -} icalcstpc_response; - -icalcstps* icalcstpc_new(); - -void* icalcstpc_free(icalcstpc* cstpc); - -int icalcstpc_set_timeout(icalcstpc* cstp, int sec); - - -/* Get the next string to send to the server */ -char* icalcstpc_next_output(icalcstpc* cstp); - -/* process the next string from the server */ -int icalcstpc_next_input(icalcstpc* cstp); - -/* After icalcstpc_next_input returns a 0, there are responses - ready. use these to get them */ -icalcstpc_response icalcstpc_first_response(icalcstpc* cstp); -icalcstpc_response icalcstpc_next_response(icalcstpc* cstp); - -/* Issue a command */ -icalerrorenum icalcstpc_abort(icalcstpc* cstp); -icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism, - char* init_data, char* f(char*) ); -icalerrorenum icalcstpc_capability(icalcstpc* cstp); -icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid); -icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time); -icalerrorenum icalcstpc_disconnect(icalcstpc* cstp); -icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id); -icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command, - char* init_data, char* f(char*)); -icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time, - icalcomponent *comp); -icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid); -icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time, - icalcomponent *comp); - - -#endif /* !ICALCSTP_H */ - - - diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c deleted file mode 100644 index 78b2373219..0000000000 --- a/libical/src/libicalss/icaldirset.c +++ /dev/null @@ -1,753 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaldirset.c - CREATOR: eric 28 November 1999 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - - -/* - - icaldirset manages a database of ical components and offers - interfaces for reading, writting and searching for components. - - icaldirset groups components in to clusters based on their DTSTAMP - time -- all components that start in the same month are grouped - together in a single file. All files in a sotre are kept in a single - directory. - - The primary interfaces are icaldirset_first and icaldirset_next. These - routine iterate through all of the components in the store, subject - to the current gauge. A gauge is an icalcomponent that is tested - against other componets for a match. If a gauge has been set with - icaldirset_select, icaldirset_first and icaldirset_next will only - return componentes that match the gauge. - - The Store generated UIDs for all objects that are stored if they do - not already have a UID. The UID is the name of the cluster (month & - year as MMYYYY) plus a unique serial number. The serial number is - stored as a property of the cluster. - -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - - -#include "ical.h" -#include "icaldirset.h" -#include "pvl.h" -#include "icalerror.h" -#include "icalparser.h" -#include "icaldirset.h" -#include "icalfileset.h" -#include "icalfilesetimpl.h" -#include "icalgauge.h" - -#include <limits.h> -#include <dirent.h> /* for opendir() */ -#include <errno.h> -#include <sys/types.h> /* for opendir() */ -#include <sys/stat.h> /* for stat */ -#include <unistd.h> /* for stat, getpid */ -#include <time.h> /* for clock() */ -#include <stdlib.h> /* for rand(), srand() */ -#include <sys/utsname.h> /* for uname */ -#include <string.h> /* for strdup */ -#include "icaldirsetimpl.h" - - -struct icaldirset_impl* icaldirset_new_impl() -{ - struct icaldirset_impl* impl; - - if ( ( impl = (struct icaldirset_impl*) - malloc(sizeof(struct icaldirset_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(impl->id,ICALDIRSET_ID); - - return impl; -} - -const char* icaldirset_path(icaldirset* cluster) -{ - struct icaldirset_impl *impl = icaldirset_new_impl(); - - return impl->dir; - -} - -void icaldirset_mark(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - icalfileset_mark(impl->cluster); -} - - -icalerrorenum icaldirset_commit(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - return icalfileset_commit(impl->cluster); - -} - -void icaldirset_lock(const char* dir) -{ -} - - -void icaldirset_unlock(const char* dir) -{ -} - -/* Load the contents of the store directory into the store's internal directory list*/ -icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl) -{ - struct dirent *de; - DIR* dp; - char *str; - - dp = opendir(impl->dir); - - if ( dp == 0) { - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } - - /* clear contents of directory list */ - while((str = pvl_pop(impl->directory))){ - free(str); - } - - /* load all of the cluster names in the directory list */ - for(de = readdir(dp); - de != 0; - de = readdir(dp)){ - - /* Remove known directory names '.' and '..'*/ - if (strcmp(de->d_name,".") == 0 || - strcmp(de->d_name,"..") == 0 ){ - continue; - } - - pvl_push(impl->directory, (void*)strdup(de->d_name)); - } - - closedir(dp); - - return ICAL_NO_ERROR; -} - -icaldirset* icaldirset_new(const char* dir) -{ - struct icaldirset_impl *impl = icaldirset_new_impl(); - struct stat sbuf; - - if (impl == 0){ - return 0; - } - - icalerror_check_arg_rz( (dir!=0), "dir"); - - if (stat(dir,&sbuf) != 0){ - icalerror_set_errno(ICAL_FILE_ERROR); - return 0; - } - - /* dir is not the name of a direectory*/ - if (!S_ISDIR(sbuf.st_mode)){ - icalerror_set_errno(ICAL_USAGE_ERROR); - return 0; - } - - icaldirset_lock(dir); - - impl = icaldirset_new_impl(); - - if (impl ==0){ - icalerror_set_errno(ICAL_ALLOCATION_ERROR); - return 0; - } - - impl->directory = pvl_newlist(); - impl->directory_iterator = 0; - impl->dir = (char*)strdup(dir); - impl->gauge = 0; - impl->first_component = 0; - impl->cluster = 0; - - icaldirset_read_directory(impl); - - return (icaldirset*) impl; -} - -void icaldirset_free(icaldirset* s) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)s; - char* str; - - icaldirset_unlock(impl->dir); - - if(impl->dir !=0){ - free(impl->dir); - } - - if(impl->gauge !=0){ - icalcomponent_free(impl->gauge); - } - - if(impl->cluster !=0){ - icalfileset_free(impl->cluster); - } - - while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){ - free(str); - } - - if(impl->directory != 0){ - pvl_free(impl->directory); - } - - impl->directory = 0; - impl->directory_iterator = 0; - impl->dir = 0; - impl->gauge = 0; - impl->first_component = 0; - - free(impl); - -} - -/* icaldirset_next_uid_number updates a serial number in the Store - directory in a file called SEQUENCE */ - -int icaldirset_next_uid_number(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - char sequence = 0; - char temp[128]; - char filename[PATH_MAX]; - char *r; - FILE *f; - struct stat sbuf; - - icalerror_check_arg_rz( (store!=0), "store"); - - sprintf(filename,"%s/%s",impl->dir,"SEQUENCE"); - - /* Create the file if it does not exist.*/ - if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){ - - f = fopen(filename,"w"); - if (f != 0){ - fprintf(f,"0"); - fclose(f); - } else { - icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); - return 0; - } - - } - - if ( (f = fopen(filename,"r+")) != 0){ - - rewind(f); - r = fgets(temp,128,f); - - if (r == 0){ - sequence = 1; - } else { - sequence = atoi(temp)+1; - } - - rewind(f); - - fprintf(f,"%d",sequence); - - fclose(f); - - return sequence; - - } else { - icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); - return 0; - } - -} - -icalerrorenum icaldirset_next_cluster(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - char path[PATH_MAX]; - - if (impl->directory_iterator == 0){ - icalerror_set_errno(ICAL_INTERNAL_ERROR); - return ICAL_INTERNAL_ERROR; - } - impl->directory_iterator = pvl_next(impl->directory_iterator); - - if (impl->directory_iterator == 0){ - /* There are no more clusters */ - if(impl->cluster != 0){ - icalfileset_free(impl->cluster); - impl->cluster = 0; - } - return ICAL_NO_ERROR; - } - - sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); - - icalfileset_free(impl->cluster); - - impl->cluster = icalfileset_new(path); - - return icalerrno; -} - -void icaldirset_add_uid(icaldirset* store, icaldirset* comp) -{ - char uidstring[PATH_MAX]; - icalproperty *uid; - struct utsname unamebuf; - - icalerror_check_arg_rv( (store!=0), "store"); - icalerror_check_arg_rv( (comp!=0), "comp"); - - uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY); - - if (uid == 0) { - - uname(&unamebuf); - - sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename); - - uid = icalproperty_new_uid(uidstring); - icalcomponent_add_property(comp,uid); - } else { - - strcpy(uidstring,icalproperty_get_uid(uid)); - } -} - - -/* This assumes that the top level component is a VCALENDAR, and there - is an inner component of type VEVENT, VTODO or VJOURNAL. The inner - component must have a DTAMP property */ - -icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp) -{ - struct icaldirset_impl *impl; - char clustername[PATH_MAX]; - icalproperty *dt; - icalvalue *v; - struct icaltimetype tm; - icalerrorenum error = ICAL_NO_ERROR; - icalcomponent *inner; - - impl = (struct icaldirset_impl*)store; - icalerror_check_arg_rz( (store!=0), "store"); - icalerror_check_arg_rz( (comp!=0), "comp"); - - errno = 0; - - icaldirset_add_uid(store,comp); - - /* Determine which cluster this object belongs in. This is a HACK */ - - for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); - inner != 0; - inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ - - dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); - - if (dt != 0){ - break; - } - } - - if (dt == 0){ - - for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); - inner != 0; - inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ - - dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); - - if (dt != 0){ - break; - } - } - - } - - if (dt == 0){ - - - icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store"); - icalerror_set_errno(ICAL_BADARG_ERROR); - return ICAL_BADARG_ERROR; - } - - v = icalproperty_get_value(dt); - - tm = icalvalue_get_datetime(v); - - snprintf(clustername,PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month); - - /* Load the cluster and insert the object */ - - if(impl->cluster != 0 && - strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){ - icalfileset_free(impl->cluster); - impl->cluster = 0; - } - - if (impl->cluster == 0){ - impl->cluster = icalfileset_new(clustername); - - if (impl->cluster == 0){ - error = icalerrno; - } - } - - if (error != ICAL_NO_ERROR){ - icalerror_set_errno(error); - return error; - } - - /* Add the component to the cluster */ - - icalfileset_add_component(impl->cluster,comp); - - icalfileset_mark(impl->cluster); - - return ICAL_NO_ERROR; -} - -/* Remove a component in the current cluster. HACK. This routine is a - "friend" of icalfileset, and breaks its encapsulation. It was - either do it this way, or add several layers of interfaces that had - no other use. */ -icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - struct icalfileset_impl *filesetimpl = - (struct icalfileset_impl*)impl->cluster; - - icalcomponent *filecomp = filesetimpl->cluster; - - icalcompiter i; - int found = 0; - - icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR); - icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR); - icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR); - - for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT); - icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ - - icalcomponent *this = icalcompiter_deref(&i); - - if (this == comp){ - found = 1; - break; - } - } - - if (found != 1){ - icalerror_warn("icaldirset_remove_component: component is not part of current cluster"); - icalerror_set_errno(ICAL_USAGE_ERROR); - return ICAL_USAGE_ERROR; - } - - icalfileset_remove_component(impl->cluster,comp); - - icalfileset_mark(impl->cluster); - - /* If the removal emptied the fileset, get the next fileset */ - if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){ - - icalerrorenum error = icaldirset_next_cluster(store); - - if(impl->cluster != 0 && error == ICAL_NO_ERROR){ - icalfileset_get_first_component(impl->cluster); - } else { - /* HACK. Not strictly correct for impl->cluster==0 */ - return error; - } - } else { - /* Do nothing */ - } - - return ICAL_NO_ERROR; -} - - - -int icaldirset_count_components(icaldirset* store, - icalcomponent_kind kind) -{ - /* HACK, not implemented */ - - assert(0); - - return 0; -} - - -icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c) -{ - fprintf(stderr," icaldirset_fetch_match is not implemented\n"); - assert(0); -} - - -icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid) -{ - icalcomponent *gauge; - icalcomponent *old_gauge; - icalcomponent *c; - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - icalerror_check_arg_rz( (store!=0), "store"); - icalerror_check_arg_rz( (uid!=0), "uid"); - - gauge = - icalcomponent_vanew( - ICAL_VCALENDAR_COMPONENT, - icalcomponent_vanew( - ICAL_VEVENT_COMPONENT, - icalproperty_vanew_uid( - uid, - icalparameter_new_xliccomparetype( - ICAL_XLICCOMPARETYPE_EQUAL), - 0), - 0), - 0); - - old_gauge = impl->gauge; - impl->gauge = gauge; - - c= icaldirset_get_first_component(store); - - impl->gauge = old_gauge; - - icalcomponent_free(gauge); - - return c; -} - - -int icaldirset_has_uid(icaldirset* store, const char* uid) -{ - icalcomponent *c; - - icalerror_check_arg_rz( (store!=0), "store"); - icalerror_check_arg_rz( (uid!=0), "uid"); - - /* HACK. This is a temporary implementation. _has_uid should use a - database, and _fetch should use _has_uid, not the other way - around */ - c = icaldirset_fetch(store,uid); - - return c!=0; - -} - - -icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge) - { - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR); - icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR); - - if (!icalcomponent_is_valid(gauge)){ - return ICAL_BADARG_ERROR; - } - - impl->gauge = gauge; - - return ICAL_NO_ERROR; -} - - -icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old, - icalcomponent *new) -{ - assert(0); - return ICAL_NO_ERROR; /* HACK, not implemented */ - -} - - -void icaldirset_clear(icaldirset* store) -{ - - assert(0); - return; - /* HACK, not implemented */ -} - -icalcomponent* icaldirset_get_current_component(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - - if(impl->cluster == 0){ - icaldirset_get_first_component(store); - } - - return icalfileset_get_current_component(impl->cluster); - -} - - -icalcomponent* icaldirset_get_first_component(icaldirset* store) -{ - struct icaldirset_impl *impl = (struct icaldirset_impl*)store; - icalerrorenum error; - char path[PATH_MAX]; - - error = icaldirset_read_directory(impl); - - if (error != ICAL_NO_ERROR){ - icalerror_set_errno(error); - return 0; - } - - impl->directory_iterator = pvl_head(impl->directory); - - if (impl->directory_iterator == 0){ - icalerror_set_errno(error); - return 0; - } - - snprintf(path,PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); - - /* If the next cluster we need is different than the current cluster, - delete the current one and get a new one */ - - if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){ - icalfileset_free(impl->cluster); - impl->cluster = 0; - } - - if (impl->cluster == 0){ - impl->cluster = icalfileset_new(path); - - if (impl->cluster == 0){ - error = icalerrno; - } - } - - if (error != ICAL_NO_ERROR){ - icalerror_set_errno(error); - return 0; - } - - impl->first_component = 1; - - return icaldirset_get_next_component(store); -} - -icalcomponent* icaldirset_get_next_component(icaldirset* store) -{ - struct icaldirset_impl *impl; - icalcomponent *c; - icalerrorenum error; - - icalerror_check_arg_rz( (store!=0), "store"); - - impl = (struct icaldirset_impl*)store; - - if(impl->cluster == 0){ - - icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first"); - icalerror_set_errno(ICAL_USAGE_ERROR); - return 0; - - } - - /* Set the component iterator for the following for loop */ - if (impl->first_component == 1){ - icalfileset_get_first_component(impl->cluster); - impl->first_component = 0; - } else { - icalfileset_get_next_component(impl->cluster); - } - - - while(1){ - /* Iterate through all of the objects in the cluster*/ - for( c = icalfileset_get_current_component(impl->cluster); - c != 0; - c = icalfileset_get_next_component(impl->cluster)){ - - /* If there is a gauge defined and the component does not - pass the gauge, skip the rest of the loop */ - -#if 0 /* HACK */ - if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){ - continue; - } -#else - assert(0); /* icalgauge_test needs to be fixed */ -#endif - /* Either there is no gauge, or the component passed the - gauge, so return it*/ - - return c; - } - - /* Fell through the loop, so the component we want is not - in this cluster. Load a new cluster and try again.*/ - - error = icaldirset_next_cluster(store); - - if(impl->cluster == 0 || error != ICAL_NO_ERROR){ - /* No more clusters */ - return 0; - } else { - c = icalfileset_get_first_component(impl->cluster); - - return c; - } - - } - - return 0; /* Should never get here */ -} - - - - - - - diff --git a/libical/src/libicalss/icaldirset.h b/libical/src/libicalss/icaldirset.h deleted file mode 100644 index 7d205ecf0a..0000000000 --- a/libical/src/libicalss/icaldirset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icaldirset.h - CREATOR: eric 28 November 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALDIRSET_H -#define ICALDIRSET_H - -#include "ical.h" - -/* icaldirset Routines for storing, fetching, and searching for ical - * objects in a database */ - -typedef void icaldirset; - - -icaldirset* icaldirset_new(const char* path); - -void icaldirset_free(icaldirset* store); - -const char* icaldirset_path(icaldirset* store); - -/* Mark the cluster as changed, so it will be written to disk when it - is freed. Commit writes to disk immediately*/ -void icaldirset_mark(icaldirset* store); -icalerrorenum icaldirset_commit(icaldirset* store); - -icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); -icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); - -int icaldirset_count_components(icaldirset* store, - icalcomponent_kind kind); - -/* Restrict the component returned by icaldirset_first, _next to those - that pass the gauge. _clear removes the gauge. */ -icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); -void icaldirset_clear(icaldirset* store); - -/* Get a component by uid */ -icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); -int icaldirset_has_uid(icaldirset* store, const char* uid); -icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); - -/* Modify components according to the MODIFY method of CAP. Works on - the currently selected components. */ -icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, - icalcomponent *newc); - -/* Iterate through the components. If a guage has been defined, these - will skip over components that do not pass the gauge */ - -icalcomponent* icaldirset_get_current_component(icaldirset* store); -icalcomponent* icaldirset_get_first_component(icaldirset* store); -icalcomponent* icaldirset_get_next_component(icaldirset* store); - -#endif /* !ICALDIRSET_H */ - - - diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h deleted file mode 100644 index 0e69ba2f2e..0000000000 --- a/libical/src/libicalss/icaldirsetimpl.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaldirsetimpl.h - CREATOR: eric 21 Aug 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* This definition is in its own file so it can be kept out of the - main header file, but used by "friend classes" like icalset*/ - -#define ICALDIRSET_ID "dset" - -struct icaldirset_impl -{ - char id[5]; /* "dset" */ - char* dir; - icalcomponent* gauge; - icaldirset* cluster; - int first_component; - pvl_list directory; - pvl_elem directory_iterator; -}; diff --git a/libical/src/libicalss/icalfileset.c b/libical/src/libicalss/icalfileset.c deleted file mode 100644 index 2ef38ff876..0000000000 --- a/libical/src/libicalss/icalfileset.c +++ /dev/null @@ -1,639 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalfileset.c - CREATOR: eric 23 December 1999 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalfileset.h" -#include "icalgauge.h" -#include <errno.h> -#include <limits.h> /* For PATH_MAX */ -#include <sys/stat.h> /* for stat */ -#include <unistd.h> /* for stat, getpid */ -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> /* for fcntl */ -#include <unistd.h> /* for fcntl */ -#include "icalfilesetimpl.h" - -extern int errno; - -int icalfileset_lock(icalfileset *cluster); -int icalfileset_unlock(icalfileset *cluster); -icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode); -int icalfileset_filesize(icalfileset* cluster); - -icalerrorenum icalfileset_create_cluster(const char *path); - -icalfileset* icalfileset_new_impl() -{ - struct icalfileset_impl* impl; - - if ( ( impl = (struct icalfileset_impl*) - malloc(sizeof(struct icalfileset_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - errno = ENOMEM; - return 0; - } - - memset(impl,0,sizeof(struct icalfileset_impl)); - - strcpy(impl->id,ICALFILESET_ID); - - return impl; -} - - -icalfileset* icalfileset_new(const char* path) -{ - return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664); -} - -icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode) -{ - struct icalfileset_impl *impl = icalfileset_new_impl(); - struct icaltimetype tt; - off_t cluster_file_size; - - memset(&tt,0,sizeof(struct icaltimetype)); - - icalerror_clear_errno(); - icalerror_check_arg_rz( (path!=0), "path"); - - if (impl == 0){ - return 0; - } - - impl->path = strdup(path); - - cluster_file_size = icalfileset_filesize(impl); - - if(cluster_file_size < 0){ - icalfileset_free(impl); - return 0; - } - - impl->fd = open(impl->path,flags, mode); - - if (impl->fd < 0){ - icalerror_set_errno(ICAL_FILE_ERROR); - icalfileset_free(impl); - return 0; - } - - icalfileset_lock(impl); - - if(cluster_file_size > 0 ){ - icalerrorenum error; - if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){ - icalfileset_free(impl); - return 0; - } - } - - if(impl->cluster == 0){ - impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); - } - - return impl; -} - -char* icalfileset_read_from_file(char *s, size_t size, void *d) -{ - - char* p = s; - int fd = (int)d; - - /* Simulate fgets -- read single characters and stop at '\n' */ - - for(p=s; p<s+size-1;p++){ - - if(read(fd,p,1) != 1 || *p=='\n'){ - p++; - break; - } - } - - *p = '\0'; - - if(*s == 0){ - return 0; - } else { - return s; - } - -} - - -icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode) -{ - - icalparser *parser; - int fd; - - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - - parser = icalparser_new(); - icalparser_set_gen_data(parser,(void*)impl->fd); - impl->cluster = icalparser_parse(parser,icalfileset_read_from_file); - icalparser_free(parser); - - if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){ - icalerror_set_errno(ICAL_PARSE_ERROR); - return ICAL_PARSE_ERROR; - } - - if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){ - /* The parser got a single component, so it did not put it in - an XROOT. */ - icalcomponent *cl = impl->cluster; - impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); - icalcomponent_add_component(impl->cluster,cl); - } - - return ICAL_NO_ERROR; - -} - -int icalfileset_filesize(icalfileset* cluster) -{ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - int cluster_file_size; - struct stat sbuf; - - if (stat(impl->path,&sbuf) != 0){ - - /* A file by the given name does not exist, or there was - another error */ - cluster_file_size = 0; - if (errno == ENOENT) { - /* It was because the file does not exist */ - return 0; - } else { - /* It was because of another error */ - icalerror_set_errno(ICAL_FILE_ERROR); - return -1; - } - } else { - /* A file by the given name exists, but is it a regular file? */ - - if (!S_ISREG(sbuf.st_mode)){ - /* Nope, not a regular file */ - icalerror_set_errno(ICAL_FILE_ERROR); - return -1; - } else { - /* Lets assume that it is a file of the right type */ - return sbuf.st_size; - } - } - - /*return -1; not reached*/ -} - -void icalfileset_free(icalfileset* cluster) -{ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_rv((cluster!=0),"cluster"); - - if (impl->cluster != 0){ - icalfileset_commit(cluster); - icalcomponent_free(impl->cluster); - impl->cluster=0; - } - - if(impl->fd > 0){ - icalfileset_unlock(impl); - close(impl->fd); - impl->fd = -1; - } - - if(impl->path != 0){ - free(impl->path); - impl->path = 0; - } - - free(impl); -} - -const char* icalfileset_path(icalfileset* cluster) -{ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - icalerror_check_arg_rz((cluster!=0),"cluster"); - - return impl->path; -} - - -int icalfileset_lock(icalfileset *cluster) -{ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - struct flock lock; - int rtrn; - - icalerror_check_arg_rz((impl->fd>0),"impl->fd"); - errno = 0; - lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ - lock.l_start = 0; /* byte offset relative to l_whence */ - lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ - lock.l_len = 0; /* #bytes (0 means to EOF) */ - - rtrn = fcntl(impl->fd, F_SETLKW, &lock); - - return rtrn; -} - -int icalfileset_unlock(icalfileset *cluster) -{ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - struct flock lock; - icalerror_check_arg_rz((impl->fd>0),"impl->fd"); - - lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ - lock.l_start = 0; /* byte offset relative to l_whence */ - lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ - lock.l_len = 0; /* #bytes (0 means to EOF) */ - - return (fcntl(impl->fd, F_UNLCK, &lock)); - -} - -#ifdef ICAL_SAFESAVES -int icalfileset_safe_saves=1; -#else -int icalfileset_safe_saves=0; -#endif - -icalerrorenum icalfileset_commit(icalfileset* cluster) -{ - char tmp[PATH_MAX]; - char *str; - icalcomponent *c; - off_t write_size=0; - - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); - - icalerror_check_arg_re((impl->fd>0),"impl->fd is invalid", - ICAL_INTERNAL_ERROR) ; - - if (impl->changed == 0 ){ - return ICAL_NO_ERROR; - } - - if(icalfileset_safe_saves == 1){ - snprintf(tmp,PATH_MAX,"cp %s %s.bak",impl->path,impl->path); - - if(system(tmp) < 0){ - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } - } - - if(lseek(impl->fd,SEEK_SET,0) < 0){ - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } - - for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){ - int sz; - - str = icalcomponent_as_ical_string(c); - - sz=write(impl->fd,str,strlen(str)); - - if ( sz != strlen(str)){ - perror("write"); - icalerror_set_errno(ICAL_FILE_ERROR); - return ICAL_FILE_ERROR; - } - - write_size += sz; - } - - impl->changed = 0; - - if(ftruncate(impl->fd,write_size) < 0){ - return ICAL_FILE_ERROR; - } - - return ICAL_NO_ERROR; - -} - -void icalfileset_mark(icalfileset* cluster){ - - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_rv((impl!=0),"cluster"); - - impl->changed = 1; - -} - -icalcomponent* icalfileset_get_component(icalfileset* cluster){ - struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); - - return impl->cluster; -} - - -/* manipulate the components in the cluster */ - -icalerrorenum icalfileset_add_component(icalfileset *cluster, - icalcomponent* child) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_rv((cluster!=0),"cluster"); - icalerror_check_arg_rv((child!=0),"child"); - - icalcomponent_add_component(impl->cluster,child); - - icalfileset_mark(cluster); - - return ICAL_NO_ERROR; - -} - -icalerrorenum icalfileset_remove_component(icalfileset *cluster, - icalcomponent* child) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_rv((cluster!=0),"cluster"); - icalerror_check_arg_rv((child!=0),"child"); - - icalcomponent_remove_component(impl->cluster,child); - - icalfileset_mark(cluster); - - return ICAL_NO_ERROR; -} - -int icalfileset_count_components(icalfileset *cluster, - icalcomponent_kind kind) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - - if(cluster == 0){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return -1; - } - - return icalcomponent_count_components(impl->cluster,kind); -} - -icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)set; - - icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR); - - impl->gauge = gauge; - - return ICAL_NO_ERROR; -} - -void icalfileset_clear(icalfileset* gauge) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge; - - impl->gauge = 0; - -} - -icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid) -{ - icalcompiter i; - struct icalfileset_impl* impl = (struct icalfileset_impl*)store; - - for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); - icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ - - icalcomponent *this = icalcompiter_deref(&i); - icalcomponent *inner = icalcomponent_get_first_real_component(this); - icalcomponent *p; - const char *this_uid; - - if(inner != 0){ - p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); - this_uid = icalproperty_get_uid(p); - - if(this_uid==0){ - icalerror_warn("icalfileset_fetch found a component with no UID"); - continue; - } - - if (strcmp(uid,this_uid)==0){ - return this; - } - } - } - - return 0; -} - -int icalfileset_has_uid(icalfileset* store,const char* uid) -{ - assert(0); /* HACK, not implemented */ - return 0; -} - -/******* support routines for icalfileset_fetch_match *********/ - -struct icalfileset_id{ - char* uid; - char* recurrence_id; - int sequence; -}; - -void icalfileset_id_free(struct icalfileset_id *id) -{ - if(id->recurrence_id != 0){ - free(id->recurrence_id); - } - - if(id->uid != 0){ - free(id->uid); - } - -} - -struct icalfileset_id icalfileset_get_id(icalcomponent* comp) -{ - - icalcomponent *inner; - struct icalfileset_id id; - icalproperty *p; - - inner = icalcomponent_get_first_real_component(comp); - - p = icalcomponent_get_first_property(inner, ICAL_UID_PROPERTY); - - assert(p!= 0); - - id.uid = strdup(icalproperty_get_uid(p)); - - p = icalcomponent_get_first_property(inner, ICAL_SEQUENCE_PROPERTY); - - if(p == 0) { - id.sequence = 0; - } else { - id.sequence = icalproperty_get_sequence(p); - } - - p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY); - - if (p == 0){ - id.recurrence_id = 0; - } else { - icalvalue *v; - v = icalproperty_get_value(p); - id.recurrence_id = strdup(icalvalue_as_ical_string(v)); - - assert(id.recurrence_id != 0); - } - - return id; -} - -/* Find the component that is related to the given - component. Currently, it just matches based on UID and - RECURRENCE-ID */ -icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)set; - icalcompiter i; - - struct icalfileset_id comp_id, match_id; - - comp_id = icalfileset_get_id(comp); - - for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); - icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ - - icalcomponent *match = icalcompiter_deref(&i); - - match_id = icalfileset_get_id(match); - - if(strcmp(comp_id.uid, match_id.uid) == 0 && - ( comp_id.recurrence_id ==0 || - strcmp(comp_id.recurrence_id, match_id.recurrence_id) ==0 )){ - - /* HACK. What to do with SEQUENCE? */ - - icalfileset_id_free(&match_id); - icalfileset_id_free(&comp_id); - return match; - - } - - icalfileset_id_free(&match_id); - } - - icalfileset_id_free(&comp_id); - return 0; - -} - - -icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old, - icalcomponent *new) -{ - assert(0); /* HACK, not implemented */ - return ICAL_NO_ERROR; -} - - -/* Iterate through components */ -icalcomponent* icalfileset_get_current_component (icalfileset* cluster) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - - icalerror_check_arg_rz((cluster!=0),"cluster"); - - return icalcomponent_get_current_component(impl->cluster); -} - - -icalcomponent* icalfileset_get_first_component(icalfileset* cluster) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - icalcomponent *c=0; - - icalerror_check_arg_rz((cluster!=0),"cluster"); - - do { - if (c == 0){ - c = icalcomponent_get_first_component(impl->cluster, - ICAL_ANY_COMPONENT); - } else { - c = icalcomponent_get_next_component(impl->cluster, - ICAL_ANY_COMPONENT); - } - - if(c != 0 && (impl->gauge == 0 || - icalgauge_compare(impl->gauge,c) == 1)){ - return c; - } - - } while(c != 0); - - - return 0; -} - -icalcomponent* icalfileset_get_next_component(icalfileset* cluster) -{ - struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; - icalcomponent *c; - - icalerror_check_arg_rz((cluster!=0),"cluster"); - - do { - c = icalcomponent_get_next_component(impl->cluster, - ICAL_ANY_COMPONENT); - - if(c != 0 && (impl->gauge == 0 || - icalgauge_compare(impl->gauge,c) == 1)){ - return c; - } - - } while(c != 0); - - - return 0; -} - diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h deleted file mode 100644 index 3b4b87c34d..0000000000 --- a/libical/src/libicalss/icalfileset.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalfileset.h - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALFILESET_H -#define ICALFILESET_H - -#include "ical.h" -#include "icalgauge.h" -#include <sys/types.h> /* For open() flags and mode */ -#include <sys/stat.h> /* For open() flags and mode */ -#include <fcntl.h> /* For open() flags and mode */ - -extern int icalfileset_safe_saves; - -typedef void icalfileset; - - -/* icalfileset - icalfilesetfile - icalfilesetdir -*/ - - -icalfileset* icalfileset_new(const char* path); - -/* Like _new, but takes open() flags for opening the file */ -icalfileset* icalfileset_new_open(const char* path, - int flags, mode_t mode); - -void icalfileset_free(icalfileset* cluster); - -const char* icalfileset_path(icalfileset* cluster); - -/* Mark the cluster as changed, so it will be written to disk when it - is freed. Commit writes to disk immediately. */ -void icalfileset_mark(icalfileset* cluster); -icalerrorenum icalfileset_commit(icalfileset* cluster); - -icalerrorenum icalfileset_add_component(icalfileset* cluster, - icalcomponent* child); - -icalerrorenum icalfileset_remove_component(icalfileset* cluster, - icalcomponent* child); - -int icalfileset_count_components(icalfileset* cluster, - icalcomponent_kind kind); - -/* Restrict the component returned by icalfileset_first, _next to those - that pass the gauge. _clear removes the gauge */ -icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge); -void icalfileset_clear(icalfileset* store); - -/* Get and search for a component by uid */ -icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); -int icalfileset_has_uid(icalfileset* cluster, const char* uid); -icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c); - - -/* Modify components according to the MODIFY method of CAP. Works on - the currently selected components. */ -icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, - icalcomponent *newcomp); - -/* Iterate through components. If a guage has been defined, these - will skip over components that do not pass the gauge */ - -icalcomponent* icalfileset_get_current_component (icalfileset* cluster); -icalcomponent* icalfileset_get_first_component(icalfileset* cluster); -icalcomponent* icalfileset_get_next_component(icalfileset* cluster); -/* Return a reference to the internal component. You probably should - not be using this. */ - -icalcomponent* icalfileset_get_component(icalfileset* cluster); - - -#endif /* !ICALFILESET_H */ - - - diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h deleted file mode 100644 index fcd3415121..0000000000 --- a/libical/src/libicalss/icalfilesetimpl.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalfilesetimpl.h - CREATOR: eric 23 December 1999 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalgauge.h" - -/* This definition is in its own file so it can be kept out of the - main header file, but used by "friend classes" like icaldirset*/ - -#define ICALFILESET_ID "fset" - -struct icalfileset_impl { - - char id[5]; /*fset*/ - char *path; - icalcomponent* cluster; - icalgauge* gauge; - int changed; - int fd; /* file descriptor */ -}; - diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c deleted file mode 100644 index b958ecfc9d..0000000000 --- a/libical/src/libicalss/icalgauge.c +++ /dev/null @@ -1,447 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalgauge.c - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#include "ical.h" -#include "icalgauge.h" -#include "icalgaugeimpl.h" -#include <stdlib.h> - -extern char* input_buffer; -extern char* input_buffer_p; -int ssparse(void); - -struct icalgauge_impl *icalss_yy_gauge; - -icalgauge* icalgauge_new_from_sql(char* sql) -{ - struct icalgauge_impl *impl; - - int r; - - if ( ( impl = (struct icalgauge_impl*) - malloc(sizeof(struct icalgauge_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - impl->select = pvl_newlist(); - impl->from = pvl_newlist(); - impl->where = pvl_newlist(); - - icalss_yy_gauge = impl; - - input_buffer_p = input_buffer = sql; - r = ssparse(); - - return impl; -} - - -void icalgauge_free(icalgauge* gauge) -{ - struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge; - struct icalgauge_where *w; - - assert(impl->select != 0); - assert(impl->where != 0); - assert(impl->from != 0); - - if(impl->select){ - while( (w=pvl_pop(impl->select)) != 0){ - if(w->value != 0){ - free(w->value); - } - free(w); - } - pvl_free(impl->select); - } - - if(impl->where){ - while( (w=pvl_pop(impl->where)) != 0){ - - if(w->value != 0){ - free(w->value); - } - free(w); - } - pvl_free(impl->where); - } - - if(impl->from){ - pvl_free(impl->from); - } - -} - -/* Convert a VQUERY component into a gauge */ -icalcomponent* icalgauge_make_gauge(icalcomponent* query); - -/* icaldirset_test compares a component against a gauge, and returns - true if the component passes the test - - The gauge is a VCALENDAR component that specifies how to test the - target components. The guage holds a collection of VEVENT, VTODO or - VJOURNAL sub-components. Each of the sub-components has a - collection of properties that are compared to corresponding - properties in the target component, according to the - X-LIC-COMPARETYPE parameters to the gauge's properties. - - When a gauge has several sub-components, the results of testing the - target against each of them is ORed together - the target - component will pass if it matches any of the sub-components in the - gauge. However, the results of matching the properties in a - sub-component are ANDed -- the target must match every property in - a gauge sub-component to match the sub-component. - - Here is an example: - - BEGIN:XROOT - DTSTART;X-LIC-COMPARETYPE=LESS:19981025T020000 - ORGANIZER;X-LIC-COMPARETYPE=EQUAL:mrbig@host.com - END:XROOT - BEGIN:XROOT - LOCATION;X-LIC-COMPARETYPE=EQUAL:McNary's Pub - END:XROOT - - This gauge has two sub-components; one which will match a VEVENT - based on start time, and organizer, and another that matches based - on LOCATION. A target component will pass the test if it matched - either of the sub-components. - - */ - - -int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge) -{ - int pass = 1,localpass = 0; - icalproperty *p; - icalcomponent *child,*subgauge; - icalcomponent_kind gaugekind, compkind; - - icalerror_check_arg_rz( (comp!=0), "comp"); - icalerror_check_arg_rz( (gauge!=0), "gauge"); - - gaugekind = icalcomponent_isa(gauge); - compkind = icalcomponent_isa(comp); - - if( ! (gaugekind == compkind || gaugekind == ICAL_ANY_COMPONENT) ){ - return 0; - } - - /* Test properties. For each property in the gauge, search through - the component for a similar property. If one is found, compare - the two properties value with the comparison specified in the - gauge with the X-LIC-COMPARETYPE parameter */ - - for(p = icalcomponent_get_first_property(gauge,ICAL_ANY_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(gauge,ICAL_ANY_PROPERTY)){ - - icalproperty* targetprop; - icalparameter* compareparam; - icalparameter_xliccomparetype compare; - int rel; /* The relationship between the gauge and target values.*/ - - /* Extract the comparison type from the gauge. If there is no - comparison type, assume that it is "EQUAL" */ - - compareparam = icalproperty_get_first_parameter( - p, - ICAL_XLICCOMPARETYPE_PARAMETER); - - if (compareparam!=0){ - compare = icalparameter_get_xliccomparetype(compareparam); - } else { - compare = ICAL_XLICCOMPARETYPE_EQUAL; - } - - /* Find a property in the component that has the same type - as the gauge property. HACK -- multiples of a single - property type in the gauge will match only the first - instance in the component */ - - targetprop = icalcomponent_get_first_property(comp, - icalproperty_isa(p)); - - if(targetprop != 0){ - - /* Compare the values of the gauge property and the target - property */ - - rel = icalvalue_compare(icalproperty_get_value(p), - icalproperty_get_value(targetprop)); - - /* Now see if the comparison is equavalent to the comparison - specified in the gauge */ - - if (rel == compare){ - localpass++; - } else if (compare == ICAL_XLICCOMPARETYPE_LESSEQUAL && - ( rel == ICAL_XLICCOMPARETYPE_LESS || - rel == ICAL_XLICCOMPARETYPE_EQUAL)) { - localpass++; - } else if (compare == ICAL_XLICCOMPARETYPE_GREATEREQUAL && - ( rel == ICAL_XLICCOMPARETYPE_GREATER || - rel == ICAL_XLICCOMPARETYPE_EQUAL)) { - localpass++; - } else if (compare == ICAL_XLICCOMPARETYPE_NOTEQUAL && - ( rel == ICAL_XLICCOMPARETYPE_GREATER || - rel == ICAL_XLICCOMPARETYPE_LESS)) { - localpass++; - } else { - localpass = 0; - } - - pass = pass && (localpass>0); - } - } - - /* Test subcomponents. Look for a child component that has a - counterpart in the gauge. If one is found, recursively call - icaldirset_test */ - - for(subgauge = icalcomponent_get_first_component(gauge,ICAL_ANY_COMPONENT); - subgauge != 0; - subgauge = icalcomponent_get_next_component(gauge,ICAL_ANY_COMPONENT)){ - - gaugekind = icalcomponent_isa(subgauge); - - if (gaugekind == ICAL_ANY_COMPONENT){ - child = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); - } else { - child = icalcomponent_get_first_component(comp,gaugekind); - } - - if(child !=0){ - localpass = icalgauge_compare_recurse(child,subgauge); - pass = pass && localpass; - } else { - pass = 0; - } - } - - return pass; -} - - -int icalgauge_compare(icalgauge* gauge,icalcomponent* comp) -{ - - struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge; - icalcomponent *inner; - int local_pass = 0; - int last_clause = 1, this_clause = 1; - pvl_elem e; - - icalerror_check_arg_rz( (comp!=0), "comp"); - icalerror_check_arg_rz( (gauge!=0), "gauge"); - - inner = icalcomponent_get_first_real_component(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - - /* Check that this component is one of the FROM types */ - local_pass = 0; - for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){ - icalcomponent_kind k = (icalcomponent_kind)pvl_data(e); - - if(k == icalcomponent_isa(inner)){ - local_pass=1; - } - } - - if(local_pass == 0){ - return 0; - } - - - /* Check each where clause against the component */ - for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){ - struct icalgauge_where *w = pvl_data(e); - icalcomponent *sub_comp; - icalvalue *v; - icalproperty *prop; - icalvalue_kind vk; - - if(w->prop == ICAL_NO_PROPERTY || w->value == 0){ - icalerror_set_errno(ICAL_INTERNAL_ERROR); - return 0; - } - - /* First, create a value from the gauge */ - vk = icalenum_property_kind_to_value_kind(w->prop); - - if(vk == ICAL_NO_VALUE){ - icalerror_set_errno(ICAL_INTERNAL_ERROR); - return 0; - } - - v = icalvalue_new_from_string(vk,w->value); - - if (v == 0){ - /* Keep error set by icalvalue_from-string*/ - return 0; - } - - /* Now find the corresponding property in the component, - descending into a sub-component if necessary */ - - if(w->comp == ICAL_NO_COMPONENT){ - sub_comp = inner; - } else { - sub_comp = icalcomponent_get_first_component(inner,w->comp); - if(sub_comp == 0){ - return 0; - } - } - - this_clause = 0; - local_pass = 0; - for(prop = icalcomponent_get_first_property(sub_comp,w->prop); - prop != 0; - prop = icalcomponent_get_next_property(sub_comp,w->prop)){ - icalvalue* prop_value; - icalgaugecompare relation; - - prop_value = icalproperty_get_value(prop); - - relation = (icalgaugecompare)icalvalue_compare(prop_value,v); - - if (relation == w->compare){ - local_pass++; - } else if (w->compare == ICALGAUGECOMPARE_LESSEQUAL && - ( relation == ICALGAUGECOMPARE_LESS || - relation == ICALGAUGECOMPARE_EQUAL)) { - local_pass++; - } else if (w->compare == ICALGAUGECOMPARE_GREATEREQUAL && - ( relation == ICALGAUGECOMPARE_GREATER || - relation == ICALGAUGECOMPARE_EQUAL)) { - local_pass++; - } else if (w->compare == ICALGAUGECOMPARE_NOTEQUAL && - ( relation == ICALGAUGECOMPARE_GREATER || - relation == ICALGAUGECOMPARE_LESS)) { - local_pass++; - } else { - local_pass = 0; - } - } - - this_clause = local_pass > 0 ? 1 : 0; - - /* Now look at the logic operator for this clause to see how - the value should be merge with the previous clause */ - - if(w->logic == ICALGAUGELOGIC_AND){ - last_clause = this_clause && last_clause; - } else if(w->logic == ICALGAUGELOGIC_AND) { - last_clause = this_clause || last_clause; - } else { - last_clause = this_clause; - } - } - - return last_clause; - -} - - -void icalgauge_dump(icalcomponent* gauge) -{ - - pvl_elem *p; - struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge; - - - printf("--- Select ---\n"); - for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){ - struct icalgauge_where *w = pvl_data(p); - - if(w->comp != ICAL_NO_COMPONENT){ - printf("%s ",icalenum_component_kind_to_string(w->comp)); - } - - if(w->prop != ICAL_NO_PROPERTY){ - printf("%s ",icalenum_property_kind_to_string(w->prop)); - } - - if (w->compare != ICALGAUGECOMPARE_NONE){ - printf("%d ",w->compare); - } - - - if (w->value!=0){ - printf("%s",w->value); - } - - - printf("\n"); - } - - printf("--- From ---\n"); - for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){ - icalcomponent_kind k = (icalcomponent_kind)pvl_data(p); - - printf("%s\n",icalenum_component_kind_to_string(k)); - } - - printf("--- Where ---\n"); - for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){ - struct icalgauge_where *w = pvl_data(p); - - if(w->logic != ICALGAUGELOGIC_NONE){ - printf("%d ",w->logic); - } - - if(w->comp != ICAL_NO_COMPONENT){ - printf("%s ",icalenum_component_kind_to_string(w->comp)); - } - - if(w->prop != ICAL_NO_PROPERTY){ - printf("%s ",icalenum_property_kind_to_string(w->prop)); - } - - if (w->compare != ICALGAUGECOMPARE_NONE){ - printf("%d ",w->compare); - } - - - if (w->value!=0){ - printf("%s",w->value); - } - - - printf("\n"); - } - - -} - diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h deleted file mode 100644 index 1caf0ac7d1..0000000000 --- a/libical/src/libicalss/icalgauge.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalgauge.h - CREATOR: eric 23 December 1999 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALGAUGE_H -#define ICALGAUGE_H - -typedef void icalgauge; - -icalgauge* icalgauge_new_from_sql(char* sql); - -void icalgauge_free(icalgauge* gauge); - -char* icalgauge_as_sql(icalcomponent* gauge); - -void icalgauge_dump(icalcomponent* gauge); - -/* Return true is comp matches the gauge. The component must be in - cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL - sub component */ -int icalgauge_compare(icalgauge* g, icalcomponent* comp); - -/* Clone the component, but only return the properties specified in - the gauge */ -icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); - -#endif /* ICALGAUGE_H*/ diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h deleted file mode 100644 index 73a2813242..0000000000 --- a/libical/src/libicalss/icalgaugeimpl.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalgaugeimpl.h - CREATOR: eric 09 Aug 2000 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - -======================================================================*/ - -#include "ical.h" - -#include "pvl.h" - -typedef enum icalgaugecompare { - ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL, - ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS, - ICALGAUGECOMPARE_LESSEQUAL=ICAL_XLICCOMPARETYPE_LESSEQUAL, - ICALGAUGECOMPARE_GREATER=ICAL_XLICCOMPARETYPE_GREATER, - ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL, - ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL, - ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX, - ICALGAUGECOMPARE_NONE=0 -} icalgaugecompare; - -typedef enum icalgaugelogic { - ICALGAUGELOGIC_NONE, - ICALGAUGELOGIC_AND, - ICALGAUGELOGIC_OR -} icalgaugelogic; - - -struct icalgauge_where { - icalgaugelogic logic; - icalcomponent_kind comp; - icalproperty_kind prop; - icalgaugecompare compare; - char* value; -}; - -struct icalgauge_impl -{ - - pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/ - pvl_list from; /* List of component_kinds, as integers */ - pvl_list where; /* List of icalgaugecompare */ -}; - - diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c deleted file mode 100644 index e1e8d8015c..0000000000 --- a/libical/src/libicalss/icalmessage.c +++ /dev/null @@ -1,376 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalmessage.c - CREATOR: ebusboom 07 Nov 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalmessage.h" -#include "icalenums.h" -#include <ctype.h> /* for tolower()*/ -#include <string.h> /* for strstr */ -#include <stdlib.h> /* for free(), malloc() */ -icalcomponent* icalmessage_get_inner(icalcomponent* comp) -{ - if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ - return icalcomponent_get_first_real_component(comp); - } else { - return comp; - } -} - -char* lowercase(const char* str) -{ - char* p = 0; - char* n = icalmemory_strdup(str); - - if(str ==0){ - return 0; - } - - for(p = n; *p!=0; p++){ - *p = tolower(*p); - } - - return n; -} - -icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user) -{ - icalcomponent *inner = icalmessage_get_inner(comp); - icalproperty *p,*attendee = 0; - char* luser = lowercase(user); - - for(p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY) - ){ - - char* lattendee; - - lattendee = lowercase(icalproperty_get_attendee(p)); - - if (strstr(lattendee,user) != 0){ - attendee = p; - break; - } - - free(lattendee); - - } - - free(luser); - - return attendee; - -} - -void icalmessage_copy_properties(icalcomponent* to, icalcomponent* from, - icalproperty_kind kind) -{ - icalcomponent *to_inner = icalmessage_get_inner(to); - icalcomponent *from_inner = icalmessage_get_inner(from); - - if (to_inner == 0 && from_inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } - - if(!icalcomponent_get_first_property(from_inner,kind)){ - return; - } - - icalcomponent_add_property(to_inner, - icalproperty_new_clone( - icalcomponent_get_first_property( - from_inner, - kind) - ) - ); -} - -icalcomponent *icalmessage_new_reply_base(icalcomponent* c, - const char* user, - const char* msg) -{ - icalproperty *attendee; - char tmp[45]; - - icalcomponent *reply = icalcomponent_vanew( - ICAL_VCALENDAR_COMPONENT, - icalproperty_new_method(ICAL_METHOD_REPLY), - icalcomponent_vanew( - ICAL_VEVENT_COMPONENT, - icalproperty_new_dtstamp(icaltime_from_timet(time(0),0)), - 0), - 0); - - icalcomponent *inner = icalmessage_get_inner(reply); - - icalerror_check_arg_rz(c,"c"); - - icalmessage_copy_properties(reply,c,ICAL_UID_PROPERTY); - icalmessage_copy_properties(reply,c,ICAL_ORGANIZER_PROPERTY); - icalmessage_copy_properties(reply,c,ICAL_RECURRENCEID_PROPERTY); - icalmessage_copy_properties(reply,c,ICAL_SUMMARY_PROPERTY); - icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY); - - icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0)); - - if(msg != 0){ - icalcomponent_add_property(inner,icalproperty_new_comment(msg)); - } - - /* Copy this user's attendee property */ - - attendee = icalmessage_find_attendee(c,user); - - if (attendee == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - icalcomponent_free(reply); - return 0; - } - - icalcomponent_add_property(inner,icalproperty_new_clone(attendee)); - - /* Add PRODID and VERSION */ - - icalcomponent_add_property(reply,icalproperty_new_version("2.0")); - - sprintf(tmp, - "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); - icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); - - return reply; - -} - -icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, - const char* user, - const char* msg) -{ - - icalcomponent *reply; - icalproperty *attendee; - icalcomponent *inner; - - icalerror_check_arg_rz(c,"c"); - - reply = icalmessage_new_reply_base(c,user,msg); - - if(reply == 0){ - return 0; - } - - inner = icalmessage_get_inner(reply); - - attendee = icalcomponent_get_first_property(inner, - ICAL_ATTENDEE_PROPERTY); - - icalproperty_set_parameter(attendee, - icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED)); - - return reply; -} - -icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, - const char* user, - const char* msg) -{ - icalcomponent *reply; - icalproperty *attendee; - icalcomponent *inner; - - icalerror_check_arg_rz(c,"c"); - - reply = icalmessage_new_reply_base(c,user,msg); - inner = icalmessage_get_inner(reply); - if(reply == 0){ - return 0; - } - - attendee = icalcomponent_get_first_property(inner, - ICAL_ATTENDEE_PROPERTY); - - icalproperty_set_parameter(attendee, - icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED)); - - return reply; -} - -/* New is modified version of old */ -icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc, - icalcomponent* newc, - const char* user, - const char* msg) -{ - icalcomponent *reply; - - icalerror_check_arg_rz(oldc,"oldc"); - icalerror_check_arg_rz(newc,"newc"); - - reply = icalcomponent_new_clone(newc); - - icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); - - return newc; - -} - - -icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, - const char* user, - const char* delegatee, - const char* msg) -{ - - icalcomponent *reply; - icalproperty *attendee; - icalcomponent *inner; - - icalerror_check_arg_rz(c,"c"); - - reply = icalmessage_new_reply_base(c,user,msg); - inner = icalmessage_get_inner(reply); - if(reply == 0){ - return 0; - } - - attendee = icalcomponent_get_first_property(inner, - ICAL_ATTENDEE_PROPERTY); - - icalproperty_set_parameter(attendee, - icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED)); - - icalproperty_set_parameter(attendee, - icalparameter_new_delegatedto(delegatee)); - - return reply; - -} - -icalcomponent* icalmessage_new_delegate_request(icalcomponent* c, - const char* user, - const char* delegatee, - const char* msg) -{ - - icalcomponent *reply; - icalproperty *attendee; - icalcomponent *inner; - - icalerror_check_arg_rz(c,"c"); - - reply = icalmessage_new_reply_base(c,user,msg); - inner = icalmessage_get_inner(reply); - - if(reply == 0){ - return 0; - } - - icalcomponent_set_method(reply,ICAL_METHOD_REQUEST); - - attendee = icalcomponent_get_first_property(inner, - ICAL_ATTENDEE_PROPERTY); - - icalproperty_set_parameter(attendee, - icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED)); - - icalproperty_set_parameter(attendee, - icalparameter_new_delegatedto(delegatee)); - - icalcomponent_add_property( - inner, - icalproperty_vanew_attendee( - delegatee, - icalparameter_new_delegatedfrom( - icalproperty_get_attendee(attendee) - ), - 0 - ) - ); - - - return reply; - -} - - -icalcomponent* icalmessage_new_cancel_event(icalcomponent* c, - const char* user, - const char* msg); -icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c, - const char* user, - const char* msg); -icalcomponent* icalmessage_new_cancel_all(icalcomponent* c, - const char* user, - const char* msg); - - - -icalcomponent* icalmessage_new_error_reply(icalcomponent* c, - const char* user, - const char* msg, - const char* debug, - icalrequeststatus code) -{ - icalcomponent *reply; - icalcomponent *inner, *cinner; - struct icalreqstattype rs; - - icalerror_check_arg_rz(c,"c"); - - reply = icalmessage_new_reply_base(c,user,msg); - inner = icalmessage_get_inner(reply); - cinner = icalmessage_get_inner(c); - if(reply == 0){ - return 0; - } - - if( code != ICAL_UNKNOWN_STATUS){ - rs.code = code; - rs.debug = debug; - - icalcomponent_add_property(inner, - icalproperty_new_requeststatus( - icalreqstattype_as_string(rs) - ) - ); - } else { /* code == ICAL_UNKNOWN_STATUS */ - - /* Copy all of the request status properties */ - icalproperty *p; - for(p = icalcomponent_get_first_property(cinner, - ICAL_REQUESTSTATUS_PROPERTY); - p != 0; - p = icalcomponent_get_next_property(cinner, - ICAL_REQUESTSTATUS_PROPERTY)){ - - - icalcomponent_add_property(inner,icalproperty_new_clone(p)); - } - } - - return reply; -} diff --git a/libical/src/libicalss/icalmessage.h b/libical/src/libicalss/icalmessage.h deleted file mode 100644 index 24f1c9f243..0000000000 --- a/libical/src/libicalss/icalmessage.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalmessage.h - CREATOR: eric 07 Nov 2000 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - =========================================================================*/ - -#include "ical.h" - -#ifndef ICALMESSAGE_H -#define ICALMESSAGE_H - - -icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, - const char* user, - const char* msg); - -icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, - const char* user, - const char* msg); - -/* New is modified version of old */ -icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc, - icalcomponent* newc, - const char* user, - const char* msg); - - -icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, - const char* user, - const char* delegatee, - const char* msg); - - -icalcomponent* icalmessage_new_cancel_event(icalcomponent* c, - const char* user, - const char* msg); -icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c, - const char* user, - const char* msg); -icalcomponent* icalmessage_new_cancel_all(icalcomponent* c, - const char* user, - const char* msg); - - -icalcomponent* icalmessage_new_error_reply(icalcomponent* c, - const char* user, - const char* msg, - const char* debug, - icalrequeststatus rs); - - -#endif /* ICALMESSAGE_H*/ diff --git a/libical/src/libicalss/icalset.c b/libical/src/libicalss/icalset.c deleted file mode 100644 index 3edbe503c4..0000000000 --- a/libical/src/libicalss/icalset.c +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalset.c - CREATOR: eric 17 Jul 2000 - - - Icalset is the "base class" for representations of a collection of - iCal components. Derived classes (actually delegates) include: - - icalfileset Store components in a single file - icaldirset Store components in multiple files in a directory - icalheapset Store components on the heap - icalmysqlset Store components in a mysql database. - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#include "ical.h" -#include "icalset.h" -#include "icalfileset.h" -#include "icalfilesetimpl.h" -#include "icaldirset.h" -#include "icaldirsetimpl.h" -#include <stdlib.h> -/*#include "icalheapset.h"*/ -/*#include "icalmysqlset.h"*/ - -#define ICALSET_ID "set " - -struct icalset_fp { - void (*free)(icalset* set); - const char* (*path)(icalset* set); - void (*mark)(icalset* set); - icalerrorenum (*commit)(icalset* set); - icalerrorenum (*add_component)(icalset* set, icalcomponent* comp); - icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp); - int (*count_components)(icalset* set, - icalcomponent_kind kind); - icalerrorenum (*select)(icalset* set, icalcomponent* gauge); - void (*clear)(icalset* set); - icalcomponent* (*fetch)(icalset* set, const char* uid); - icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp); - int (*has_uid)(icalset* set, const char* uid); - icalerrorenum (*modify)(icalset* set, icalcomponent *old, - icalcomponent *new); - icalcomponent* (*get_current_component)(icalset* set); - icalcomponent* (*get_first_component)(icalset* set); - icalcomponent* (*get_next_component)(icalset* set); -}; - -struct icalset_fp icalset_dirset_fp = { - icaldirset_free, - icaldirset_path, - icaldirset_mark, - icaldirset_commit, - icaldirset_add_component, - icaldirset_remove_component, - icaldirset_count_components, - icaldirset_select, - icaldirset_clear, - icaldirset_fetch, - icaldirset_fetch_match, - icaldirset_has_uid, - icaldirset_modify, - icaldirset_get_current_component, - icaldirset_get_first_component, - icaldirset_get_next_component -}; - - -struct icalset_fp icalset_fileset_fp = { - icalfileset_free, - icalfileset_path, - icalfileset_mark, - icalfileset_commit, - icalfileset_add_component, - icalfileset_remove_component, - icalfileset_count_components, - icalfileset_select, - icalfileset_clear, - icalfileset_fetch, - icalfileset_fetch_match, - icalfileset_has_uid, - icalfileset_modify, - icalfileset_get_current_component, - icalfileset_get_first_component, - icalfileset_get_next_component -}; - -struct icalset_impl { - - char id[5]; /* "set " */ - - void *derived_impl; - struct icalset_fp *fp; -}; - -/* Figure out what was actually passed in as the set. This could be a - set or and of the derived types such as dirset or fileset. Note - this routine returns a value, not a reference, to avoid memory - leaks in the methods */ -struct icalset_impl icalset_get_impl(icalset* set) -{ - struct icalset_impl impl; - - memset(&impl,0,sizeof(impl)); - icalerror_check_arg_rv( (set!=0),"set"); - - if(strcmp((char*)set,ICALSET_ID)==0) { - /* It is actually a set, so just sent the reference back out. */ - return *(struct icalset_impl*)set; - } else if(strcmp((char*)set,ICALFILESET_ID)==0) { - /* Make a new set from the fileset */ - impl.fp = &icalset_fileset_fp; - impl.derived_impl = set; - strcpy(impl.id,ICALFILESET_ID);/* HACK. Is this necessary? */ - return impl; - } else if(strcmp((char*)set,ICALDIRSET_ID)==0) { - /* Make a new set from the dirset */ - impl.fp = &icalset_dirset_fp; - impl.derived_impl = set; - strcpy(impl.id,ICALDIRSET_ID);/* HACK. Is this necessary? */ - return impl; - } else { - /* The type of set is unknown, so throw an error */ - icalerror_assert((0),"Unknown set type"); - return impl; - } -} - - -struct icalset_impl* icalset_new_impl() -{ - - struct icalset_impl* impl; - - if ( ( impl = (struct icalset_impl*) - malloc(sizeof(struct icalset_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(impl->id,ICALSET_ID); - - impl->derived_impl = 0; - impl->fp = 0; - - return impl; -} - -struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset) -{ - struct icalset_impl *impl = icalset_new_impl(); - - icalerror_check_arg_rz( (fset!=0),"fset"); - - if(impl == 0){ - free(impl); - return 0; - } - - impl->derived_impl = fset; - - if (impl->derived_impl == 0){ - free(impl); - return 0; - } - - impl->fp = &icalset_fileset_fp; - - return (struct icalset_impl*)impl; -} - -icalset* icalset_new_file(const char* path) -{ - icalfileset *fset = icalfileset_new(path); - - if(fset == 0){ - return 0; - } - - return (icalset*)icalset_new_file_from_ref(fset); -} - -icalset* icalset_new_dir_from_ref(icaldirset *dset) -{ - - struct icalset_impl *impl = icalset_new_impl(); - - icalerror_check_arg_rz( (dset!=0),"dset"); - - if(impl == 0){ - return 0; - } - - impl->derived_impl = dset; - - if (impl->derived_impl == 0){ - free(impl); - return 0; - } - - impl->fp = &icalset_dirset_fp; - - return impl; -} - -icalset* icalset_new_dir(const char* path) -{ - icaldirset *dset = icaldirset_new(path); - - if(dset == 0){ - return 0; - } - - return icalset_new_dir_from_ref(dset); -} - -icalset* icalset_new_heap(void) -{ - struct icalset_impl *impl = icalset_new_impl(); - - - if(impl == 0){ - free(impl); - return 0; - } - - return 0; -} - -icalset* icalset_new_mysql(const char* path) -{ - struct icalset_impl *impl = icalset_new_impl(); - - if(impl == 0){ - free(impl); - return 0; - } - - return 0; -} - -void icalset_free(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - (*(impl.fp->free))(impl.derived_impl); - - if(strcmp((char*)set,ICALSET_ID)) { - free(set); - } -} - -const char* icalset_path(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->path))(impl.derived_impl); -} - -void icalset_mark(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - (*(impl.fp->mark))(impl.derived_impl); -} - -icalerrorenum icalset_commit(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->commit))(impl.derived_impl); -} - -icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->add_component))(impl.derived_impl,comp); -} - -icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->remove_component))(impl.derived_impl,comp); -} - -int icalset_count_components(icalset* set,icalcomponent_kind kind) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->count_components))(impl.derived_impl,kind); -} - -icalerrorenum icalset_select(icalset* set, icalcomponent* gauge) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->select))(impl.derived_impl,gauge); -} - -void icalset_clear(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - (*(impl.fp->clear))(impl.derived_impl); -} - -icalcomponent* icalset_fetch(icalset* set, const char* uid) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->fetch))(impl.derived_impl,uid); -} - -icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->fetch_match))(impl.derived_impl,comp); -} - - -int icalset_has_uid(icalset* set, const char* uid) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->has_uid))(impl.derived_impl,uid); -} - -icalerrorenum icalset_modify(icalset* set, icalcomponent *old, - icalcomponent *new) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->modify))(impl.derived_impl,old,new); -} - -icalcomponent* icalset_get_current_component(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->get_current_component))(impl.derived_impl); -} - -icalcomponent* icalset_get_first_component(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->get_first_component))(impl.derived_impl); -} - -icalcomponent* icalset_get_next_component(icalset* set) -{ - struct icalset_impl impl = icalset_get_impl(set); - return (*(impl.fp->get_next_component))(impl.derived_impl); -} - - - - diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h deleted file mode 100644 index d4678e3bed..0000000000 --- a/libical/src/libicalss/icalset.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalset.h - CREATOR: eric 28 November 1999 - - - Icalset is the "base class" for representations of a collection of - iCal components. Derived classes (actually delegatees) include: - - icalfileset Store componetns in a single file - icaldirset Store components in multiple files in a directory - icalheapset Store components on the heap - icalmysqlset Store components in a mysql database. - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALSET_H -#define ICALSET_H - -#include "ical.h" -#include "icalerror.h" - -typedef void icalset; - -typedef enum icalset_kind { - ICAL_FILE_SET, - ICAL_DIR_SET, - ICAL_HEAP_SET, - ICAL_MYSQL_SET, - ICAL_CAP_SET -} icalset_kind; - - -/* Create a specific derived type of set */ -icalset* icalset_new_file(const char* path); -icalset* icalset_new_dir(const char* path); -icalset* icalset_new_heap(void); -icalset* icalset_new_mysql(const char* path); -/*icalset* icalset_new_cap(icalcstp* cstp);*/ - -void icalset_free(icalset* set); - -const char* icalset_path(icalset* set); - -/* Mark the cluster as changed, so it will be written to disk when it - is freed. Commit writes to disk immediately*/ -void icalset_mark(icalset* set); -icalerrorenum icalset_commit(icalset* set); - -icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); -icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp); - -int icalset_count_components(icalset* set, - icalcomponent_kind kind); - -/* Restrict the component returned by icalset_first, _next to those - that pass the gauge. _clear removes the gauge. */ -icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); -void icalset_clear_select(icalset* set); - -/* Get a component by uid */ -icalcomponent* icalset_fetch(icalset* set, const char* uid); -int icalset_has_uid(icalset* set, const char* uid); -icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); - -/* Modify components according to the MODIFY method of CAP. Works on - the currently selected components. */ -icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, - icalcomponent *newc); - -/* Iterate through the components. If a guage has been defined, these - will skip over components that do not pass the gauge */ - -icalcomponent* icalset_get_current_component(icalset* set); -icalcomponent* icalset_get_first_component(icalset* set); -icalcomponent* icalset_get_next_component(icalset* set); - -#endif /* !ICALSET_H */ - - - diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c deleted file mode 100644 index cab6a81c68..0000000000 --- a/libical/src/libicalss/icalspanlist.c +++ /dev/null @@ -1,309 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalspanlist.c - CREATOR: ebusboom 23 aug 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "ical.h" -#include "icalspanlist.h" -#include "pvl.h" -#include <stdlib.h> /* for free and malloc */ - -struct icalspanlist_impl { - pvl_list spans; -}; - -int compare_span(void* a, void* b) -{ - struct icaltime_span *span_a = (struct icaltime_span *)a ; - struct icaltime_span *span_b = (struct icaltime_span *)b ; - - if(span_a->start == span_b->start){ - return 0; - } else if(span_a->start < span_b->start){ - return -1; - } else { /*if(span_a->start > span->b.start)*/ - return 1; - } -} - -icalcomponent* icalspanlist_get_inner(icalcomponent* comp) -{ - if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ - return icalcomponent_get_first_real_component(comp); - } else { - return comp; - } -} - - -void print_span(int c, struct icaltime_span span ); - - -/* Make a free list from a set of component */ -icalspanlist* icalspanlist_new(icalset *set, - struct icaltimetype start, - struct icaltimetype end) -{ - struct icaltime_span range; - pvl_elem itr; - icalcomponent *c,*inner; - icalcomponent_kind kind, inner_kind; - struct icalspanlist_impl *sl; - struct icaltime_span *freetime; - - if ( ( sl = (struct icalspanlist_impl*) - malloc(sizeof(struct icalspanlist_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - sl->spans = pvl_newlist(); - - range.start = icaltime_as_timet(start); - range.end = icaltime_as_timet(end); - - printf("Range start: %s",ctime(&range.start)); - printf("Range end : %s",ctime(&range.end)); - - - /* Get a list of spans of busy time from the events in the set - and order the spans based on the start time */ - - for(c = icalset_get_first_component(set); - c != 0; - c = icalset_get_next_component(set)){ - - struct icaltime_span span; - - kind = icalcomponent_isa(c); - inner = icalcomponent_get_inner(c); - - if(!inner){ - continue; - } - - inner_kind = icalcomponent_isa(inner); - - if( kind != ICAL_VEVENT_COMPONENT && - inner_kind != ICAL_VEVENT_COMPONENT){ - continue; - } - - icalerror_clear_errno(); - - span = icalcomponent_get_span(c); - span.is_busy = 1; - - if(icalerrno != ICAL_NO_ERROR){ - continue; - } - - if ((range.start < span.end && icaltime_is_null_time(end)) || - (range.start < span.end && range.end > span.start )){ - - struct icaltime_span *s; - - if ((s=(struct icaltime_span *) - malloc(sizeof(struct icaltime_span))) == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memcpy(s,&span,sizeof(span)); - - pvl_insert_ordered(sl->spans,compare_span,(void*)s); - - } - } - - /* Now Fill in the free time spans. loop through the spans. if the - start of the range is not within the span, create a free entry - that runs from the start of the range to the start of the - span. */ - - for( itr = pvl_head(sl->spans); - itr != 0; - itr = pvl_next(itr)) - { - struct icaltime_span *s = (icalproperty*)pvl_data(itr); - - if ((freetime=(struct icaltime_span *) - malloc(sizeof(struct icaltime_span))) == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - if(range.start < s->start){ - freetime->start = range.start; - freetime->end = s->start; - - freetime->is_busy = 0; - - - pvl_insert_ordered(sl->spans,compare_span,(void*)freetime); - } else { - free(freetime); - } - - range.start = s->end; - } - - /* If the end of the range is null, then assume that everything - after the last item in the calendar is open and add a span - that indicates this */ - - if( icaltime_is_null_time(end)){ - struct icaltime_span* last_span; - - last_span = pvl_data(pvl_tail(sl->spans)); - - if (last_span != 0){ - - if ((freetime=(struct icaltime_span *) - malloc(sizeof(struct icaltime_span))) == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - freetime->is_busy = 0; - freetime->start = last_span->end; - freetime->end = freetime->start; - pvl_insert_ordered(sl->spans,compare_span,(void*)freetime); - } - } - - - return sl; - -} - -void icalspanlist_free(icalspanlist* s) -{ - struct icaltime_span *span; - struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s; - - while( (span=pvl_pop(impl->spans)) != 0){ - free(span); - } - - pvl_free(impl->spans); - - impl->spans = 0; -} - - -void icalspanlist_dump(icalspanlist* s){ - - int i = 0; - struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s; - pvl_elem itr; - - for( itr = pvl_head(sl->spans); - itr != 0; - itr = pvl_next(itr)) - { - struct icaltime_span *s = (icalproperty*)pvl_data(itr); - - printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start)); - printf(" end : %s",ctime(&s->end)); - - } -} - -icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); -icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); - -struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, - struct icaltimetype t) -{ - struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl; - pvl_elem itr; - struct icalperiodtype period; - struct icaltime_span *s; - - time_t rangett= icaltime_as_timet(t); - - period.start = icaltime_null_time(); - period.end = icaltime_null_time(); - - /* Is the reference time before the first span? If so, assume - that the reference time is free */ - itr = pvl_head(impl->spans); - s = (icalproperty*)pvl_data(itr); - - if (s == 0){ - /* No elements in span */ - return period; - } - - if(rangett <s->start ){ - /* End of period is start of first span if span is busy, end - of the span if it is free */ - period.start = t; - - if (s->is_busy == 0){ - period.end = icaltime_from_timet(s->start,0); - } else { - period.end = icaltime_from_timet(s->end,0); - } - - return period; - } - - /* Otherwise, find the first free span that contains the - reference time. */ - - for( itr = pvl_head(impl->spans); - itr != 0; - itr = pvl_next(itr)) - { - s = (icalproperty*)pvl_data(itr); - - if(s->is_busy == 0 && s->start >= rangett && - ( rangett < s->end || s->end == s->start)){ - - if (rangett < s->start){ - period.start = icaltime_from_timet(s->start,0); - } else { - period.start = icaltime_from_timet(rangett,0); - } - - period.end = icaltime_from_timet(s->end,0); - - return period; - } - - } - - period.start = icaltime_null_time(); - period.end = icaltime_null_time(); - - return period; -} - -struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, - struct icaltimetype t); - diff --git a/libical/src/libicalss/icalspanlist.h b/libical/src/libicalss/icalspanlist.h deleted file mode 100644 index 83cb1c8a6d..0000000000 --- a/libical/src/libicalss/icalspanlist.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalspanlist.h - CREATOR: eric 21 Aug 2000 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - =========================================================================*/ -#ifndef ICALSPANLIST_H -#define ICALSPANLIST_H - -#include "ical.h" -#include "icalset.h" - -typedef void icalspanlist; - -/* Make a free list from a set of component. Start and end should be in UTC */ -icalspanlist* icalspanlist_new(icalset *set, - struct icaltimetype start, - struct icaltimetype end); - -void icalspanlist_free(icalspanlist* spl); - -icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); -icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); - -/* Get first free or busy time after time t. all times are in UTC */ -struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, - struct icaltimetype t); -struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, - struct icaltimetype t); - -void icalspanlist_dump(icalspanlist* s); - -#endif - - - diff --git a/libical/src/libicalss/icalsslexer.l b/libical/src/libicalss/icalsslexer.l deleted file mode 100644 index 848a9bc74f..0000000000 --- a/libical/src/libicalss/icalsslexer.l +++ /dev/null @@ -1,113 +0,0 @@ -%{ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalsslexer.l - CREATOR: eric 8 Aug 2000 - - DESCRIPTION: - - $Id: icalsslexer.l,v 1.1.1.2 2001/01/23 19:20:41 jpr Exp $ - $Locker: $ - -(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - ======================================================================*/ - -#include "icalssyacc.h" -#include "icalgaugeimpl.h" -#include "assert.h" - -#include <string.h> /* For strdup() */ - -int icalparser_flex_input(char* buf, int max_size); -void icalparser_clear_flex_input(); - -#undef YY_INPUT -#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) - -#undef SS_FATAL_ERROR -#define SS_FATAL_ERROR(msg) sserror(msg) - - -%} - -crlf \x0D?\x0A -space [ ] -qsafechar [^\x00-\x1F\"] -safechar [^\x00-\x1F\"\:\;\,] -tsafechar [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E] -valuechar [^\x00-\x08\x10-\x1F] -xname X-[a-zA-Z0-9\-]+ -xname2 [a-zA-Z0-9\-\ ] -paramtext {safechar}+ -value {valuechar}+ -quotedstring \"{qsafechar}+\" -digit [0-9] - -%array /* Make yytext an array. Slow, but handy. HACK */ - -%option caseless - -%s sql string_value - - - -%% - -%{ -%} - - -SELECT { return SELECT; } -FROM { return FROM; } -WHERE { return WHERE; } -, { return COMMA; } -"=" { return EQUALS; } -"!=" { return NOTEQUALS; } -"<" { return LESS; } -">" { return GREATER; } -"<=" { return LESSEQUALS; } -">=" { return GREATEREQUALS; } -AND { return AND; } -OR { return OR; } -\' { return QUOTE; } -[ \t\n\r]+ ; -; { return EOL; } -\'[\*A-Za-z0-9\-\.]+\' { - int c = input(); - unput(c); - if(c!='\''){ - sslval.v_string= icalmemory_tmp_copy(sstext); - return STRING; - } else { - /*ssmore();*/ - } -} - -[\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext); - return STRING; } - - -. { return yytext[0]; } - -%% - -int sswrap() -{ - return 1; -} - diff --git a/libical/src/libicalss/icalssutil.c b/libical/src/libicalss/icalssutil.c deleted file mode 100644 index 8db141d41d..0000000000 --- a/libical/src/libicalss/icalssutil.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalssutil.c - CREATOR: ebusboom 23 aug 2000 - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - - diff --git a/libical/src/libicalss/icalssutil.h b/libical/src/libicalss/icalssutil.h deleted file mode 100644 index 3890da6a11..0000000000 --- a/libical/src/libicalss/icalssutil.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalssutil.h - CREATOR: eric 21 Aug 2000 - - - $Id$ - $Locker$ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - =========================================================================*/ - -#include "ical.h" - diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h deleted file mode 100644 index 9a933dc735..0000000000 --- a/libical/src/libicalss/icalssyacc.h +++ /dev/null @@ -1,22 +0,0 @@ -typedef union { - char* v_string; -} YYSTYPE; -#define STRING 257 -#define SELECT 258 -#define FROM 259 -#define WHERE 260 -#define COMMA 261 -#define QUOTE 262 -#define EQUALS 263 -#define NOTEQUALS 264 -#define LESS 265 -#define GREATER 266 -#define LESSEQUALS 267 -#define GREATEREQUALS 268 -#define AND 269 -#define OR 270 -#define EOL 271 -#define END 272 - - -extern YYSTYPE sslval; diff --git a/libical/src/libicalss/icalssyacc.y b/libical/src/libicalss/icalssyacc.y deleted file mode 100644 index 047b158e93..0000000000 --- a/libical/src/libicalss/icalssyacc.y +++ /dev/null @@ -1,245 +0,0 @@ -%{ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalssyacc.y - CREATOR: eric 08 Aug 2000 - - DESCRIPTION: - - $Id: icalssyacc.y,v 1.1.1.2 2001/01/23 19:20:41 jpr Exp $ - $Locker: $ - -(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - ======================================================================*/ - -#include <stdlib.h> -#include <string.h> /* for strdup() */ -#include <limits.h> /* for SHRT_MAX*/ -#include "ical.h" -#include "pvl.h" -#include "icalgauge.h" -#include "icalgaugeimpl.h" - - -extern struct icalgauge_impl *icalss_yy_gauge; - -void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, - icalgaugecompare compare , char* value); -void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); -void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); -void set_logic(struct icalgauge_impl* impl,icalgaugelogic l); -void sserror(char *s); /* Don't know why I need this.... */ - - - -%} - -%union { - char* v_string; -} - - -%token <v_string> STRING -%token SELECT FROM WHERE COMMA QUOTE EQUALS NOTEQUALS LESS GREATER LESSEQUALS -%token GREATEREQUALS AND OR EOL END - -%% - -query_min: SELECT select_list FROM from_list WHERE where_list - | error { - icalparser_clear_flex_input(); - yyclearin; - } - ; - -select_list: - STRING {ssyacc_add_select(icalss_yy_gauge,$1);} - | select_list COMMA STRING {ssyacc_add_select(icalss_yy_gauge,$3);} - ; - - -from_list: - STRING {ssyacc_add_from(icalss_yy_gauge,$1);} - | from_list COMMA STRING {ssyacc_add_from(icalss_yy_gauge,$3);} - ; - -where_clause: - /* Empty */ - | STRING EQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_EQUAL,$3); } - - | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_NOTEQUAL,$3); } - | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESS,$3); } - | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATER,$3); } - | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESSEQUAL,$3); } - | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATEREQUAL,$3); } - ; - -where_list: - where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);} - | where_list AND where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);} - | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} - ; - - -%% - -void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, - icalgaugecompare compare , char* value_str) -{ - - struct icalgauge_where *where; - char *compstr, *propstr, *c, *s,*l; - - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - memset(where,0,sizeof(struct icalgauge_where)); - where->logic = ICALGAUGELOGIC_NONE; - where->compare = ICALGAUGECOMPARE_NONE; - where->comp = ICAL_NO_COMPONENT; - where->prop = ICAL_NO_PROPERTY; - - /* remove enclosing quotes */ - s = value_str; - if(*s == '\''){ - s++; - } - l = s+strlen(s)-1; - if(*l == '\''){ - *l=0; - } - - where->value = strdup(s); - - /* Is there a period in str1 ? If so, the string specified both a - component and a property*/ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; - } else { - compstr = 0; - propstr = str1; - } - - - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); - } else { - where->comp = ICAL_NO_COMPONENT; - } - - where->prop = icalenum_string_to_property_kind(propstr); - - where->compare = compare; - - if(where->value == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(where->value); - return; - } - - pvl_push(impl->where,where); -} - -void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) -{ - pvl_elem e = pvl_tail(impl->where); - struct icalgauge_where *where = pvl_data(e); - - where->logic = l; - -} - - - -void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) -{ - char *c, *compstr, *propstr; - struct icalgauge_where *where; - - /* Uses only the prop and comp fields of the where structure */ - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - memset(where,0,sizeof(struct icalgauge_where)); - where->logic = ICALGAUGELOGIC_NONE; - where->compare = ICALGAUGECOMPARE_NONE; - where->comp = ICAL_NO_COMPONENT; - where->prop = ICAL_NO_PROPERTY; - - /* Is there a period in str1 ? If so, the string specified both a - component and a property*/ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; - } else { - compstr = 0; - propstr = str1; - } - - - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); - } else { - where->comp = ICAL_NO_COMPONENT; - } - - - /* If the property was '*', then accept all properties */ - if(strcmp("*",propstr) == 0) { - where->prop = ICAL_ANY_PROPERTY; - } else { - where->prop = icalenum_string_to_property_kind(propstr); - } - - - if(where->prop == ICAL_NO_PROPERTY){ - icalgauge_free(where); - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - - pvl_push(impl->select,where); -} - -void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) -{ - icalcomponent_kind ckind; - - ckind = icalenum_string_to_component_kind(str1); - - if(ckind == ICAL_NO_COMPONENT){ - assert(0); - } - - pvl_push(impl->from,(void*)ckind); - -} - - -void sserror(char *s){ - fprintf(stderr,"Parse error \'%s\'\n", s); -} |