summaryrefslogtreecommitdiffabout
path: root/libical/src/libicalss
authorzautrix <zautrix>2004-06-29 11:59:46 (UTC)
committer zautrix <zautrix>2004-06-29 11:59:46 (UTC)
commitda43dbdc6c82453228f34766fc74585615cba938 (patch) (side-by-side diff)
tree16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libicalss
parent627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff)
downloadkdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libicalss') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libicalss/icalcalendar.c263
-rw-r--r--libical/src/libicalss/icalcalendar.h2
-rw-r--r--libical/src/libicalss/icalclassify.c132
-rw-r--r--libical/src/libicalss/icalclassify.h36
-rw-r--r--libical/src/libicalss/icalcluster.c245
-rw-r--r--libical/src/libicalss/icalcluster.h61
-rw-r--r--libical/src/libicalss/icalclusterimpl.h45
-rw-r--r--libical/src/libicalss/icaldirset.c542
-rw-r--r--libical/src/libicalss/icaldirset.h54
-rw-r--r--libical/src/libicalss/icaldirsetimpl.h19
-rw-r--r--libical/src/libicalss/icalfileset.c725
-rw-r--r--libical/src/libicalss/icalfileset.h105
-rw-r--r--libical/src/libicalss/icalfilesetimpl.h18
-rw-r--r--libical/src/libicalss/icalgauge.c172
-rw-r--r--libical/src/libicalss/icalgauge.h26
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h12
-rw-r--r--libical/src/libicalss/icalmessage.c11
-rw-r--r--libical/src/libicalss/icalset.c528
-rw-r--r--libical/src/libicalss/icalset.h121
-rw-r--r--libical/src/libicalss/icalspanlist.c386
-rw-r--r--libical/src/libicalss/icalspanlist.h29
-rw-r--r--libical/src/libicalss/icalss.h719
-rw-r--r--libical/src/libicalss/icalsslexer.c1624
-rw-r--r--libical/src/libicalss/icalssyacc.c270
-rw-r--r--libical/src/libicalss/icalssyacc.h12
-rw-r--r--libical/src/libicalss/libicalss.pro70
-rw-r--r--libical/src/libicalss/libicalssE.pro78
27 files changed, 4224 insertions, 2081 deletions
diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c
new file mode 100644
index 0000000..1f24f88
--- a/dev/null
+++ b/libical/src/libicalss/icalcalendar.c
@@ -0,0 +1,263 @@
+/*======================================================================
+ 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 */
+
+#ifndef WIN32
+#include <unistd.h> /* For mkdir, stat */
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 512
+#endif
+
+
+#include <stdlib.h> /* for malloc */
+#include <string.h> /* for strcat */
+#include <errno.h>
+
+#define BOOKED_DIR "booked"
+#define INCOMING_FILE "incoming.ics"
+#define PROP_FILE "properties.ics"
+#define FBLIST_FILE "freebusy.ics"
+
+struct icalcalendar_impl
+{
+ char* dir;
+ icalset* freebusy;
+ icalset* properties;
+ icalset* booked;
+ icalset* incoming;
+};
+
+struct icalcalendar_impl* icalcalendar_new_impl(void)
+{
+ 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* impl)
+{
+ if (impl->dir !=0){
+ free(impl->dir);
+ }
+
+ if (impl->freebusy !=0){
+ icalset_free(impl->booked);
+ }
+
+ if (impl->properties !=0){
+ icalset_free(impl->properties);
+ }
+
+ if (impl->booked !=0){
+ icalset_free(impl->booked);
+ }
+
+ if (impl->incoming !=0){
+ icalset_free(impl->incoming);
+ }
+
+ impl->dir = 0;
+ impl->freebusy = 0;
+ impl->properties = 0;
+ impl->booked = 0;
+ impl->incoming = 0;
+
+
+ free(impl);
+}
+
+
+int icalcalendar_lock(icalcalendar* impl)
+{
+ icalerror_check_arg_rz((impl != 0),"impl");
+ return 0;
+}
+
+int icalcalendar_unlock(icalcalendar* impl)
+{
+ icalerror_check_arg_rz((impl != 0),"impl");
+ return 0;
+}
+
+int icalcalendar_islocked(icalcalendar* impl)
+{
+ icalerror_check_arg_rz((impl != 0),"impl");
+ return 0;
+}
+
+int icalcalendar_ownlock(icalcalendar* impl)
+{
+ icalerror_check_arg_rz((impl != 0),"impl");
+ return 0;
+}
+
+icalset* icalcalendar_get_booked(icalcalendar* impl)
+{
+ 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* impl)
+{
+ char path[PATH_MAX];
+ 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* impl)
+{
+ char path[PATH_MAX];
+ 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* impl)
+{
+ char path[PATH_MAX];
+ 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
index f07457c..2a0c151 100644
--- a/libical/src/libicalss/icalcalendar.h
+++ b/libical/src/libicalss/icalcalendar.h
@@ -38,7 +38,7 @@
* components. It also has interfaces to access the free/busy list
* and a list of calendar properties */
-typedef void icalcalendar;
+typedef struct icalcalendar_impl icalcalendar;
icalcalendar* icalcalendar_new(char* dir);
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c
index c029309..61ddbd3 100644
--- a/libical/src/libicalss/icalclassify.c
+++ b/libical/src/libicalss/icalclassify.c
@@ -26,10 +26,10 @@
#include "config.h"
#endif
-#include "icalerror.h"
#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 */
@@ -146,7 +146,7 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
p != 0;
p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY))
{
- const char* this_attendee
+ char* this_attendee
= icalclassify_lowercase(icalproperty_get_attendee(p));
char* this_upn = strchr(this_attendee,':');
@@ -157,10 +157,14 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
}
if(strcmp(this_upn,upn)==0){
+ free(lattendee);
+ free(this_attendee);
return p;
}
+ free(this_attendee);
}
+ free(lattendee);
return 0;
@@ -284,7 +288,7 @@ int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b)
p1 = icalcomponent_get_first_property(i1,kind_array[i]);
p2 = icalcomponent_get_first_property(i2,kind_array[i]);
- if( (p1!=0)^(p1!=0) ){
+ if( (p1!=0)^(p2!=0) ){
/* Return true if the property exists in one component and not
the other */
return 1;
@@ -546,7 +550,6 @@ int icalclassify_reply_crasher_decline(
struct icalclassify_parts *match,
const char* user)
{
- icalparameter_partstat partstat;
icalproperty* attendee;
icalclassify_pre;
@@ -642,47 +645,47 @@ int icalclassify_delinecounter(
struct icalclassify_map {
icalproperty_method method;
int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user);
- ical_class class;
+ icalproperty_xlicclass 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_delegate,ICAL_REQUEST_DELEGATE_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_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_delegate,ICAL_REPLY_DELEGATE_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_METHOD_PUBLISH,icalclassify_publish_new,ICAL_XLICCLASS_PUBLISHNEW},
+ {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_XLICCLASS_PUBLISHUPDATE},
+ {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_XLICCLASS_PUBLISHFREEBUSY},
+ {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_XLICCLASS_REQUESTDELEGATE},
+ {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_XLICCLASS_REQUESTNEW},
+ {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_XLICCLASS_REQUESTUPDATE},
+ {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_XLICCLASS_REQUESTRESCHEDULE},
+
+ {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_XLICCLASS_REQUESTNEWORGANIZER},
+ {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_XLICCLASS_REQUESTFORWARD},
+ {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_XLICCLASS_REQUESTSTATUS},
+ {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_XLICCLASS_REQUESTFREEBUSY},
+
+ {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_XLICCLASS_REPLYACCEPT},
+ {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_XLICCLASS_REPLYDECLINE},
+ {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_XLICCLASS_REPLYDELEGATE},
+ {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_XLICCLASS_REPLYCRASHERACCEPT},
+ {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_XLICCLASS_REPLYCRASHERDECLINE},
+
+ {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_XLICCLASS_ADDINSTANCE},
+
+ {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_XLICCLASS_CANCELEVENT},
+ {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_XLICCLASS_CANCELINSTANCE},
+ {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_XLICCLASS_CANCELALL},
+
+ {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_XLICCLASS_REFRESH},
+ {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_XLICCLASS_COUNTER},
+ {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_XLICCLASS_DECLINECOUNTER},
+ {ICAL_METHOD_NONE,0,ICAL_XLICCLASS_NONE}
};
-ical_class icalclassify(icalcomponent* c,icalcomponent* match,
+icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
const char* user)
{
icalcomponent *inner;
icalproperty *p;
icalproperty_method method;
- ical_class class = ICAL_UNKNOWN_CLASS;
+ icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN;
int i;
@@ -692,7 +695,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
inner = icalcomponent_get_first_real_component(c);
if (inner == 0) {
- return ICAL_NO_CLASS;
+ return ICAL_XLICCLASS_NONE;
}
icalssutil_get_parts(c,&comp_parts);
@@ -709,7 +712,8 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
{
/* comp has a smaller sequence and a later DTSTAMP */
- return ICAL_MISSEQUENCED_CLASS;
+ class = ICAL_XLICCLASS_MISSEQUENCED;
+ goto CLEANUP;
}
if( (comp_parts.sequence<match_parts.sequence )
@@ -718,14 +722,16 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
( comp_parts.sequence == match_parts.sequence &&
icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){
- return ICAL_OBSOLETE_CLASS;
+ class = ICAL_XLICCLASS_OBSOLETE;
+ goto CLEANUP;
}
}
p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
if (p == 0) {
- return ICAL_UNKNOWN_CLASS;
+ class = ICAL_XLICCLASS_UNKNOWN;
+ goto CLEANUP;
}
method = icalproperty_get_method(p);
@@ -738,6 +744,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
}
}
+CLEANUP:
icalssutil_free_parts(&comp_parts);
icalssutil_free_parts(&match_parts);
@@ -745,48 +752,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
}
-struct class_map {
- ical_class class;
- char *str;
-} class_map[] = {
- {ICAL_NO_CLASS,"No class"},
- {ICAL_PUBLISH_NEW_CLASS,"New Publish"},
- {ICAL_PUBLISH_UPDATE_CLASS,"Publish Update"},
- {ICAL_PUBLISH_FREEBUSY_CLASS,"Publish freebusy"},
- {ICAL_REQUEST_NEW_CLASS,"New request"},
- {ICAL_REQUEST_UPDATE_CLASS,"Update"},
- {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"},
- {ICAL_REQUEST_DELEGATE_CLASS,"Delegate request"},
- {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"},
- {ICAL_REQUEST_FORWARD_CLASS,"Forward"},
- {ICAL_REQUEST_STATUS_CLASS,"Status request"},
- {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"},
- {ICAL_REPLY_DECLINE_CLASS,"Decline reply"},
- {ICAL_REPLY_DELEGATE_CLASS,"Delegation reply"},
- {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"},
- {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"},
- {ICAL_ADD_INSTANCE_CLASS,"Add instance"},
- {ICAL_CANCEL_EVENT_CLASS,"Cancel event"},
- {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"},
- {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"},
- {ICAL_REFRESH_CLASS,"Refresh"},
- {ICAL_COUNTER_CLASS,"Counter"},
- {ICAL_DECLINECOUNTER_CLASS,"Decline counter"},
- {ICAL_MALFORMED_CLASS,"Malformed"},
- {ICAL_OBSOLETE_CLASS,"Obsolete"},
- {ICAL_MISSEQUENCED_CLASS,"Missequenced"},
- {ICAL_UNKNOWN_CLASS,"Unknown"}
-};
-
-char* icalclassify_class_to_string(ical_class class)
-{
- int i;
-
- for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){
- if (class_map[i].class == class){
- return class_map[i].str;
- }
- }
-
- return "Unknown";
-}
diff --git a/libical/src/libicalss/icalclassify.h b/libical/src/libicalss/icalclassify.h
index 81188b3..aceabc0 100644
--- a/libical/src/libicalss/icalclassify.h
+++ b/libical/src/libicalss/icalclassify.h
@@ -29,44 +29,12 @@
#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_DELEGATE_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,
+icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
const char* user);
icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
-char* icalclassify_class_to_string(ical_class iclass);
+char* icalclassify_class_to_string(icalproperty_xlicclass c);
#endif /* ICALCLASSIFY_H*/
diff --git a/libical/src/libicalss/icalcluster.c b/libical/src/libicalss/icalcluster.c
new file mode 100644
index 0000000..6d11078
--- a/dev/null
+++ b/libical/src/libicalss/icalcluster.c
@@ -0,0 +1,245 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: icalcluster.c
+ CREATOR: acampi 13 March 2002
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2002, Eric Busboom, http://www.softwarestudio.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of either:
+
+ The LGPL as published by the Free Software Foundation, version
+ 2.1, available at: http://www.fsf.org/copyleft/lesser.html
+
+ Or:
+
+ The Mozilla Public License Version 1.0. You may obtain a copy of
+ the License at http://www.mozilla.org/MPL/
+
+ The Original Code is eric. The Initial Developer of the Original
+ Code is Eric Busboom
+
+
+ ======================================================================*/
+
+
+/**
+ *
+ * icalcluster is an utility class design to manage clusters of
+ * icalcomponents on behalf of an implementation of icalset. This is
+ * done in order to split out common behavior different classes might
+ * need.
+ * The definition of what exactly a cluster will contain depends on the
+ * icalset subclass. At the basic level, an icluster is just a tuple,
+ * with anything as key and an icalcomponent as value.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#if 0
+#include <errno.h>
+#include <sys/stat.h> /* for stat */
+#ifndef WIN32
+#include <unistd.h> /* for stat, getpid */
+#else
+#include <io.h>
+#include <share.h>
+#endif
+#include <fcntl.h> /* for fcntl */
+#endif
+
+#include "icalcluster.h"
+#include "icalclusterimpl.h"
+#include "icalgauge.h"
+
+#ifdef WIN32
+#define snprintf _snprintf
+#define strcasecmp stricmp
+#endif
+
+
+icalcluster * icalcluster_new_impl(void) {
+
+ struct icalcluster_impl* impl;
+
+ if ((impl = (struct icalcluster_impl*)malloc(
+ sizeof(struct icalcluster_impl))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ memset(impl, 0, sizeof(struct icalcluster_impl));
+ strcpy(impl->id,ICALCLUSTER_ID);
+
+ return impl;
+}
+
+/**
+ * Create a cluster with a key/value pair.
+ *
+ * @todo Always do a deep copy.
+ */
+
+icalcluster * icalcluster_new(const char* key, icalcomponent *data) {
+ struct icalcluster_impl *impl = icalcluster_new_impl();
+ assert(impl->data == 0);
+
+ impl->key = strdup(key);
+ impl->changed = 0;
+ impl->data = 0;
+
+ if (data != NULL) {
+ if (icalcomponent_isa(data) != ICAL_XROOT_COMPONENT) {
+ impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ icalcomponent_add_component(impl->data, data);
+ } else {
+ impl->data = icalcomponent_new_clone(data);
+ }
+ } else {
+ impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ }
+
+ return impl;
+}
+
+/**
+ * Deep clone an icalcluster to a new one
+ */
+
+icalcluster *icalcluster_new_clone(const icalcluster *data) {
+ struct icalcluster_impl *old = (struct icalcluster_impl *)data;
+ struct icalcluster_impl *impl = icalcluster_new_impl();
+
+ impl->key = strdup(old->key);
+ impl->data = icalcomponent_new_clone(old->data);
+ impl->changed = 0;
+
+ return impl;
+}
+
+
+void icalcluster_free(icalcluster *impl) {
+ icalerror_check_arg_rv((impl!=0),"cluster");
+
+ if (impl->key != 0){
+ free(impl->key);
+ impl->key = 0;
+ }
+
+ if (impl->data != 0){
+ icalcomponent_free(impl->data);
+ impl->data = 0;
+ }
+
+ free(impl);
+}
+
+
+const char *icalcluster_key(icalcluster *impl) {
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ return impl->key;
+}
+
+
+int icalcluster_is_changed(icalcluster *impl) {
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ return impl->changed;
+}
+
+
+void icalcluster_mark(icalcluster *impl) {
+ icalerror_check_arg_rv((impl!=0),"cluster");
+
+ impl->changed = 1;
+}
+
+
+void icalcluster_commit(icalcluster *impl) {
+ icalerror_check_arg_rv((impl!=0),"cluster");
+
+ impl->changed = 0;
+}
+
+
+icalcomponent *icalcluster_get_component(icalcluster *impl) {
+
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) {
+ icalerror_warn("The top component is not an XROOT");
+ fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data));
+ abort();
+ }
+
+ return impl->data;
+}
+
+
+icalerrorenum icalcluster_add_component(icalcluster *impl, icalcomponent* child) {
+
+ icalerror_check_arg_re((impl!=0),"cluster", ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
+
+ icalcomponent_add_component(impl->data, child);
+ icalcluster_mark(impl);
+
+ return ICAL_NO_ERROR;
+}
+
+
+icalerrorenum icalcluster_remove_component(icalcluster *impl, icalcomponent* child) {
+
+ icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
+
+ icalcomponent_remove_component(impl->data,child);
+ icalcluster_mark(impl);
+
+ return ICAL_NO_ERROR;
+}
+
+
+int icalcluster_count_components(icalcluster *impl, icalcomponent_kind kind) {
+
+ icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
+
+ return icalcomponent_count_components(impl->data, kind);
+}
+
+
+/** Iterate through components **/
+icalcomponent *icalcluster_get_current_component(icalcluster* impl) {
+
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ return icalcomponent_get_current_component(impl->data);
+}
+
+
+icalcomponent *icalcluster_get_first_component(icalcluster* impl) {
+
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ return icalcomponent_get_first_component(impl->data,
+ ICAL_ANY_COMPONENT);
+}
+
+
+icalcomponent *icalcluster_get_next_component(icalcluster* impl) {
+
+ icalerror_check_arg_rz((impl!=0),"cluster");
+
+ return icalcomponent_get_next_component(impl->data,
+ ICAL_ANY_COMPONENT);
+}
diff --git a/libical/src/libicalss/icalcluster.h b/libical/src/libicalss/icalcluster.h
new file mode 100644
index 0000000..f4eb041
--- a/dev/null
+++ b/libical/src/libicalss/icalcluster.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C -*- */
+/*======================================================================
+ FILE: icalcluster.h
+ CREATOR: eric 23 December 1999
+
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of either:
+
+ The LGPL as published by the Free Software Foundation, version
+ 2.1, available at: http://www.fsf.org/copyleft/lesser.html
+
+ Or:
+
+ The Mozilla Public License Version 1.0. You may obtain a copy of
+ the License at http://www.mozilla.org/MPL/
+
+ The Original Code is eric. The Initial Developer of the Original
+ Code is Eric Busboom
+
+
+======================================================================*/
+
+#ifndef ICALCLUSTER_H
+#define ICALCLUSTER_H
+
+#include "ical.h"
+#include "icalset.h"
+
+typedef struct icalcluster_impl icalcluster;
+
+icalcluster* icalcluster_new(const char *key, icalcomponent *data);
+icalcluster* icalcluster_new_clone(const icalcluster *cluster);
+
+void icalcluster_free(icalcluster *cluster);
+
+const char* icalcluster_key(icalcluster *cluster);
+int icalcluster_is_changed(icalcluster *cluster);
+void icalcluster_mark(icalcluster *cluster);
+void icalcluster_commit(icalcluster *cluster);
+
+icalcomponent* icalcluster_get_component(icalcluster* cluster);
+int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
+icalerrorenum icalcluster_add_component(icalcluster* cluster,
+ icalcomponent* child);
+icalerrorenum icalcluster_remove_component(icalcluster* cluster,
+ icalcomponent* child);
+
+icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
+icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
+icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
+
+#endif /* !ICALCLUSTER_H */
+
+
+
diff --git a/libical/src/libicalss/icalclusterimpl.h b/libical/src/libicalss/icalclusterimpl.h
new file mode 100644
index 0000000..ef80e1a
--- a/dev/null
+++ b/libical/src/libicalss/icalclusterimpl.h
@@ -0,0 +1,45 @@
+/* -*- 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
+
+/* 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 ICALCLUSTER_ID "clus"
+
+struct icalcluster_impl {
+
+ char id[5]; /* clus */
+
+ char *key;
+ icalcomponent *data;
+ int changed;
+};
diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c
index b6cb673..4a20fe1 100644
--- a/libical/src/libicalss/icaldirset.c
+++ b/libical/src/libicalss/icaldirset.c
@@ -26,9 +26,10 @@
======================================================================*/
-/*
+/**
+ @file icaldirset.c
- icaldirset manages a database of ical components and offers
+ @brief 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
@@ -36,12 +37,13 @@
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 primary interfaces are icaldirset__get_first_component and
+ icaldirset_get_next_component. These routine iterate through all of
+ the components in the store, subject to the current gauge. A gauge
+ is an icalcomponent that is tested against other componets for a
+ match. If a gauge has been set with icaldirset_select,
+ icaldirset_first and icaldirset_next will only return componentes
+ that match the gauge.
The 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 &
@@ -55,75 +57,76 @@
#endif
-#include "icalerror.h"
#include "ical.h"
#include "icaldirset.h"
-#include "pvl.h"
-#include "icalparser.h"
#include "icaldirset.h"
#include "icalfileset.h"
#include "icalfilesetimpl.h"
+#include "icalcluster.h"
#include "icalgauge.h"
#include <limits.h> /* For PATH_MAX */
-#include <errno.h>
-#include <sys/types.h> /* for opendir() */
-#include <sys/stat.h> /* for stat */
-
-int snprintf(char *str, size_t n, char const *fmt, ...);
-
-// Eugen C. <eug@thekompany.com>
-#include <defines.h>
-#ifndef _QTWIN_
+#ifndef WIN32
#include <dirent.h> /* for opendir() */
-#include <unistd.h>
+#include <unistd.h> /* for stat, getpid */
#include <sys/utsname.h> /* for uname */
+#else
+#include <io.h>
+#include <process.h>
#endif
-// Eugen C. <eug@thekompany.com>
-
+#include <errno.h>
+#include <sys/types.h> /* for opendir() */
+#include <sys/stat.h> /* for stat */
#include <time.h> /* for clock() */
#include <stdlib.h> /* for rand(), srand() */
#include <string.h> /* for strdup */
#include "icaldirsetimpl.h"
-struct icaldirset_impl* icaldirset_new_impl()
-{
- struct icaldirset_impl* impl;
+#ifdef WIN32
+#define snprintf _snprintf
+#define strcasecmp stricmp
- if ( ( impl = (struct icaldirset_impl*)
- malloc(sizeof(struct icaldirset_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
+#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
+
+#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
+#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
+#endif
- strcpy(impl->id,ICALDIRSET_ID);
+/** Default options used when NULL is passed to icalset_new() **/
+icaldirset_options icaldirset_options_default = {O_RDWR|O_CREAT};
- return impl;
-}
-const char* icaldirset_path(icaldirset* cluster)
+const char* icaldirset_path(icalset* set)
{
- struct icaldirset_impl *impl = icaldirset_new_impl();
-
- return impl->dir;
+ icaldirset *dset = (icaldirset*)set;
+ return dset->dir;
}
-void icaldirset_mark(icaldirset* store)
+
+void icaldirset_mark(icalset* set)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+ icaldirset *dset = (icaldirset*)set;
- icalfileset_mark(impl->cluster);
+ icalcluster_mark(dset->cluster);
}
-icalerrorenum icaldirset_commit(icaldirset* store)
+icalerrorenum icaldirset_commit(icalset* set)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+ icaldirset *dset = (icaldirset*)set;
+ icalset *fileset;
+ icalfileset_options options = icalfileset_options_default;
- return icalfileset_commit(impl->cluster);
+ options.cluster = dset->cluster;
+ fileset = icalset_new(ICAL_FILE_SET, icalcluster_key(dset->cluster), &options);
+
+ fileset->commit(fileset);
+ fileset->free(fileset);
+
+ return ICAL_NO_ERROR;
}
void icaldirset_lock(const char* dir)
@@ -136,22 +139,22 @@ 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)
+icalerrorenum icaldirset_read_directory(icaldirset *dset)
{
-#ifndef _QTWIN_
+ char *str;
+#ifndef WIN32
struct dirent *de;
DIR* dp;
- char *str;
- dp = opendir(impl->dir);
+ dp = opendir(dset->dir);
- if ( dp == 0) {
+ if (dp == 0) {
icalerror_set_errno(ICAL_FILE_ERROR);
return ICAL_FILE_ERROR;
}
/* clear contents of directory list */
- while((str = pvl_pop(impl->directory))){
+ while((str = pvl_pop(dset->directory))){
free(str);
}
@@ -166,106 +169,143 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
continue;
}
- pvl_push(impl->directory, (void*)strdup(de->d_name));
+ pvl_push(dset->directory, (void*)strdup(de->d_name));
}
closedir(dp);
-
- return ICAL_NO_ERROR;
#else
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
+ struct _finddata_t c_file;
+ long hFile;
+
+ /* Find first .c file in current directory */
+ if( (hFile = _findfirst( "*", &c_file )) == -1L ) {
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ return ICAL_FILE_ERROR;
+ } else {
+ while((str = pvl_pop(dset->directory))){
+ free(str);
+ }
+
+ /* load all of the cluster names in the directory list */
+ do {
+ /* Remove known directory names '.' and '..'*/
+ if (strcmp(c_file.name,".") == 0 ||
+ strcmp(c_file.name,"..") == 0 ){
+ continue;
+ }
+
+ pvl_push(dset->directory, (void*)strdup(c_file.name));
+ }
+ while ( _findnext( hFile, &c_file ) == 0 );
+
+ _findclose( hFile );
+ }
+
#endif
+
+ return ICAL_NO_ERROR;
}
-icaldirset* icaldirset_new(const char* dir)
+
+icalset* icaldirset_init(icalset* set, const char* dir, void* options_in)
{
- struct icaldirset_impl *impl = icaldirset_new_impl();
+ icaldirset *dset = (icaldirset*)set;
+ icaldirset_options *options = options_in;
struct stat sbuf;
- if (impl == 0){
- return 0;
- }
-
icalerror_check_arg_rz( (dir!=0), "dir");
+ icalerror_check_arg_rz( (set!=0), "set");
if (stat(dir,&sbuf) != 0){
icalerror_set_errno(ICAL_FILE_ERROR);
return 0;
}
-#ifndef _QTWIN_
/* dir is not the name of a direectory*/
if (!S_ISDIR(sbuf.st_mode)){
icalerror_set_errno(ICAL_USAGE_ERROR);
return 0;
}
-#endif
icaldirset_lock(dir);
- impl = icaldirset_new_impl();
+ dset->dir = (char*)strdup(dir);
+ dset->options = *options;
+ dset->directory = pvl_newlist();
+ dset->directory_iterator = 0;
+ dset->gauge = 0;
+ dset->first_component = 0;
+ dset->cluster = 0;
+
+ return set;
+}
+
+icalset* icaldirset_new(const char* dir)
+{
+ return icalset_new(ICAL_DIR_SET, dir, &icaldirset_options_default);
+}
- if (impl ==0){
- icalerror_set_errno(ICAL_NEWFAILED_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;
+icalset* icaldirset_new_reader(const char* dir)
+{
+ icaldirset_options reader_options = icaldirset_options_default;
- icaldirset_read_directory(impl);
+ reader_options.flags = O_RDONLY;
- return (icaldirset*) impl;
+ return icalset_new(ICAL_DIR_SET, dir, &reader_options);
}
-void icaldirset_free(icaldirset* s)
+
+icalset* icaldirset_new_writer(const char* dir)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)s;
+ icaldirset_options writer_options = icaldirset_options_default;
+
+ writer_options.flags = O_RDWR|O_CREAT;
+
+ return icalset_new(ICAL_DIR_SET, dir, &writer_options);
+}
+
+
+void icaldirset_free(icalset* s)
+{
+ icaldirset *dset = (icaldirset*)s;
char* str;
- icaldirset_unlock(impl->dir);
+ icaldirset_unlock(dset->dir);
- if(impl->dir !=0){
- free(impl->dir);
+ if(dset->dir !=0){
+ free(dset->dir);
+ dset->dir = 0;
}
- if(impl->gauge !=0){
- icalcomponent_free(impl->gauge);
+ if(dset->gauge !=0){
+ icalgauge_free(dset->gauge);
+ dset->gauge = 0;
}
- if(impl->cluster !=0){
- icalfileset_free(impl->cluster);
+ if(dset->cluster !=0){
+ icalcluster_free(dset->cluster);
}
- while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){
+ while(dset->directory !=0 && (str=pvl_pop(dset->directory)) != 0){
free(str);
}
- if(impl->directory != 0){
- pvl_free(impl->directory);
+ if(dset->directory != 0){
+ pvl_free(dset->directory);
+ dset->directory = 0;
}
- impl->directory = 0;
- impl->directory_iterator = 0;
- impl->dir = 0;
- impl->gauge = 0;
- impl->first_component = 0;
-
- free(impl);
-
+ dset->directory_iterator = 0;
+ dset->first_component = 0;
}
+
/* icaldirset_next_uid_number updates a serial number in the Store
directory in a file called SEQUENCE */
-int icaldirset_next_uid_number(icaldirset* store)
+int icaldirset_next_uid_number(icaldirset* dset)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
char sequence = 0;
char temp[128];
char filename[ICAL_PATH_MAX];
@@ -273,16 +313,12 @@ int icaldirset_next_uid_number(icaldirset* store)
FILE *f;
struct stat sbuf;
- icalerror_check_arg_rz( (store!=0), "store");
+ icalerror_check_arg_rz( (dset!=0), "dset");
- sprintf(filename,"%s/%s",impl->dir,"SEQUENCE");
+ sprintf(filename,"%s/%s",dset->dir,"SEQUENCE");
/* Create the file if it does not exist.*/
-#ifndef _QTWIN_
if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){
-#else
- if (stat(filename,&sbuf) == -1){
-#endif
f = fopen(filename,"w");
if (f != 0){
@@ -292,7 +328,6 @@ int icaldirset_next_uid_number(icaldirset* store)
icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
return 0;
}
-
}
if ( (f = fopen(filename,"r+")) != 0){
@@ -318,89 +353,85 @@ int icaldirset_next_uid_number(icaldirset* store)
icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
return 0;
}
-
}
-icalerrorenum icaldirset_next_cluster(icaldirset* store)
+icalerrorenum icaldirset_next_cluster(icaldirset* dset)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
char path[ICAL_PATH_MAX];
- if (impl->directory_iterator == 0){
+ if (dset->directory_iterator == 0){
icalerror_set_errno(ICAL_INTERNAL_ERROR);
return ICAL_INTERNAL_ERROR;
}
- impl->directory_iterator = pvl_next(impl->directory_iterator);
+ dset->directory_iterator = pvl_next(dset->directory_iterator);
- if (impl->directory_iterator == 0){
+ if (dset->directory_iterator == 0){
/* There are no more clusters */
- if(impl->cluster != 0){
- icalfileset_free(impl->cluster);
- impl->cluster = 0;
+ if(dset->cluster != 0){
+ icalcluster_free(dset->cluster);
+ dset->cluster = 0;
}
return ICAL_NO_ERROR;
}
- sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
+ sprintf(path,"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator));
- icalfileset_free(impl->cluster);
-
- impl->cluster = icalfileset_new(path);
+ icalcluster_free(dset->cluster);
+ dset->cluster = icalfileset_produce_icalcluster(path);
return icalerrno;
}
-void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
+static void icaldirset_add_uid(icalcomponent* comp)
{
-#ifndef _QTWIN_
-
char uidstring[ICAL_PATH_MAX];
icalproperty *uid;
+#ifndef WIN32
struct utsname unamebuf;
+#endif
- icalerror_check_arg_rv( (store!=0), "store");
icalerror_check_arg_rv( (comp!=0), "comp");
uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
if (uid == 0) {
+#ifndef WIN32
uname(&unamebuf);
sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename);
+#else
+ sprintf(uidstring,"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */
+#endif
uid = icalproperty_new_uid(uidstring);
icalcomponent_add_property(comp,uid);
} else {
-
strcpy(uidstring,icalproperty_get_uid(uid));
}
-
-#endif
}
-/* This assumes that the top level component is a VCALENDAR, and there
+/**
+ This assumes that the top level component is a VCALENDAR, and there
is an inner component of type VEVENT, VTODO or VJOURNAL. The inner
- component must have a DTAMP property */
+ component must have a DSTAMP property
+*/
-icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
+icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp)
{
- struct icaldirset_impl *impl;
char clustername[ICAL_PATH_MAX];
- icalproperty *dt;
+ icalproperty *dt = 0;
icalvalue *v;
struct icaltimetype tm;
icalerrorenum error = ICAL_NO_ERROR;
icalcomponent *inner;
+ icaldirset *dset = (icaldirset*) set;
- impl = (struct icaldirset_impl*)store;
- icalerror_check_arg_rz( (store!=0), "store");
+ icalerror_check_arg_rz( (dset!=0), "dset");
icalerror_check_arg_rz( (comp!=0), "comp");
- errno = 0;
-
- icaldirset_add_uid(store,comp);
+ icaldirset_add_uid(comp);
/* Determine which cluster this object belongs in. This is a HACK */
@@ -410,52 +441,44 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
- if (dt != 0){
+ if (dt != 0)
break;
}
- }
-
- if (dt == 0){
+ if (dt == 0) {
for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
inner != 0;
inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
- if (dt != 0){
+ if (dt != 0)
break;
}
}
- }
-
if (dt == 0){
-
-
icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store");
icalerror_set_errno(ICAL_BADARG_ERROR);
return ICAL_BADARG_ERROR;
}
v = icalproperty_get_value(dt);
-
tm = icalvalue_get_datetime(v);
- snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month);
+ snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",dset->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(dset->cluster != 0 &&
+ strcmp(clustername,icalcluster_key(dset->cluster)) != 0 ){
+ icalcluster_free(dset->cluster);
+ dset->cluster = 0;
}
- if (impl->cluster == 0){
- impl->cluster = icalfileset_new(clustername);
+ if (dset->cluster == 0){
+ dset->cluster = icalfileset_produce_icalcluster(clustername);
- if (impl->cluster == 0){
+ if (dset->cluster == 0){
error = icalerrno;
}
}
@@ -466,33 +489,31 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
}
/* Add the component to the cluster */
-
- icalfileset_add_component(impl->cluster,comp);
+ icalcluster_add_component(dset->cluster,comp);
- icalfileset_mark(impl->cluster);
+ /* icalcluster_mark(impl->cluster); */
return ICAL_NO_ERROR;
}
-/* Remove a component in the current cluster. HACK. This routine is a
+/**
+ Remove a component in the current cluster. HACK. This routine is a
"friend" of icalfileset, and breaks its encapsulation. It was
either do it this way, or add several layers of interfaces that had
- no other use. */
-icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- struct icalfileset_impl *filesetimpl =
- (struct icalfileset_impl*)impl->cluster;
+ no other use.
+ */
- icalcomponent *filecomp = filesetimpl->cluster;
+icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp)
+{
+ icaldirset *dset = (icaldirset*)set;
+ icalcomponent *filecomp = icalcluster_get_component(dset->cluster);
icalcompiter i;
int found = 0;
- icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((set!=0),"set",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);
+ icalerror_check_arg_re((dset->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR);
for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT);
icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
@@ -511,17 +532,16 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
return ICAL_USAGE_ERROR;
}
- icalfileset_remove_component(impl->cluster,comp);
+ icalcluster_remove_component(dset->cluster,comp);
- icalfileset_mark(impl->cluster);
+ /* icalcluster_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( icalcluster_count_components(dset->cluster,ICAL_ANY_COMPONENT)==0){
+ icalerrorenum error = icaldirset_next_cluster(dset);
- if(impl->cluster != 0 && error == ICAL_NO_ERROR){
- icalfileset_get_first_component(impl->cluster);
+ if(dset->cluster != 0 && error == ICAL_NO_ERROR){
+ icalcluster_get_first_component(dset->cluster);
} else {
/* HACK. Not strictly correct for impl->cluster==0 */
return error;
@@ -535,95 +555,84 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
-int icaldirset_count_components(icaldirset* store,
+int icaldirset_count_components(icalset* store,
icalcomponent_kind kind)
{
/* HACK, not implemented */
-
assert(0);
return 0;
}
-icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c)
+icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c)
{
fprintf(stderr," icaldirset_fetch_match is not implemented\n");
assert(0);
+ return 0;
}
-icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid)
+icalcomponent* icaldirset_fetch(icalset* set, const char* uid)
{
- icalcomponent *gauge;
- icalcomponent *old_gauge;
+ icaldirset *dset = (icaldirset*)set;
+ icalgauge *gauge;
+ icalgauge *old_gauge;
icalcomponent *c;
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+ char sql[256];
- icalerror_check_arg_rz( (store!=0), "store");
+ icalerror_check_arg_rz( (set!=0), "set");
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);
+ snprintf(sql, 256, "SELECT * FROM VEVENT WHERE UID = \"%s\"", uid);
+
+ gauge = icalgauge_new_from_sql(sql, 0);
- old_gauge = impl->gauge;
- impl->gauge = gauge;
+ old_gauge = dset->gauge;
+ dset->gauge = gauge;
- c= icaldirset_get_first_component(store);
+ c= icaldirset_get_first_component(set);
- impl->gauge = old_gauge;
+ dset->gauge = old_gauge;
- icalcomponent_free(gauge);
+ icalgauge_free(gauge);
return c;
}
-int icaldirset_has_uid(icaldirset* store, const char* uid)
+int icaldirset_has_uid(icalset* set, const char* uid)
{
icalcomponent *c;
- icalerror_check_arg_rz( (store!=0), "store");
+ icalerror_check_arg_rz( (set!=0), "set");
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);
+ c = icaldirset_fetch(set,uid);
return c!=0;
}
-icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge)
- {
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+icalerrorenum icaldirset_select(icalset* set, icalgauge* gauge)
+{
+ icaldirset *dset = (icaldirset*)set;
- icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re( (set!=0), "set",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;
+ dset->gauge = gauge;
return ICAL_NO_ERROR;
}
-icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
+icalerrorenum icaldirset_modify(icalset* set,
+ icalcomponent *old,
icalcomponent *new)
{
assert(0);
@@ -632,7 +641,7 @@ icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
}
-void icaldirset_clear(icaldirset* store)
+void icaldirset_clear(icalset* set)
{
assert(0);
@@ -640,53 +649,58 @@ void icaldirset_clear(icaldirset* store)
/* HACK, not implemented */
}
-icalcomponent* icaldirset_get_current_component(icaldirset* store)
+icalcomponent* icaldirset_get_current_component(icalset* set)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+ icaldirset *dset = (icaldirset*)set;
- if(impl->cluster == 0){
- icaldirset_get_first_component(store);
+ if (dset->cluster == 0){
+ icaldirset_get_first_component(set);
+ }
+ if(dset->cluster == 0){
+ return 0;
}
- return icalfileset_get_current_component(impl->cluster);
-
+ return icalcluster_get_current_component(dset->cluster);
}
-icalcomponent* icaldirset_get_first_component(icaldirset* store)
+icalcomponent* icaldirset_get_first_component(icalset* set)
{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
+ icaldirset *dset = (icaldirset*)set;
+
icalerrorenum error;
char path[ICAL_PATH_MAX];
- error = icaldirset_read_directory(impl);
+ error = icaldirset_read_directory(dset);
if (error != ICAL_NO_ERROR){
icalerror_set_errno(error);
return 0;
}
- impl->directory_iterator = pvl_head(impl->directory);
+ dset->directory_iterator = pvl_head(dset->directory);
- if (impl->directory_iterator == 0){
+ if (dset->directory_iterator == 0){
icalerror_set_errno(error);
return 0;
}
- snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
+ snprintf(path,ICAL_PATH_MAX,"%s/%s",
+ dset->dir,
+ (char*)pvl_data(dset->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(dset->cluster != 0 && strcmp(path,icalcluster_key(dset->cluster)) != 0 ){
+ icalcluster_free(dset->cluster);
+ dset->cluster = 0;
}
- if (impl->cluster == 0){
- impl->cluster = icalfileset_new(path);
+ if (dset->cluster == 0){
+ dset->cluster = icalfileset_produce_icalcluster(path);
- if (impl->cluster == 0){
+ if (dset->cluster == 0){
error = icalerrno;
}
}
@@ -696,23 +710,22 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
return 0;
}
- impl->first_component = 1;
+ dset->first_component = 1;
- return icaldirset_get_next_component(store);
+ return icaldirset_get_next_component(set);
}
-icalcomponent* icaldirset_get_next_component(icaldirset* store)
+
+icalcomponent* icaldirset_get_next_component(icalset* set)
{
- struct icaldirset_impl *impl;
+ icaldirset *dset = (icaldirset*)set;
icalcomponent *c;
icalerrorenum error;
- icalerror_check_arg_rz( (store!=0), "store");
-
- impl = (struct icaldirset_impl*)store;
+ icalerror_check_arg_rz( (set!=0), "set");
- if(impl->cluster == 0){
+ if(dset->cluster == 0){
icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first");
icalerror_set_errno(ICAL_USAGE_ERROR);
return 0;
@@ -720,30 +733,26 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
}
/* Set the component iterator for the following for loop */
- if (impl->first_component == 1){
- icalfileset_get_first_component(impl->cluster);
- impl->first_component = 0;
+ if (dset->first_component == 1){
+ icalcluster_get_first_component(dset->cluster);
+ dset->first_component = 0;
} else {
- icalfileset_get_next_component(impl->cluster);
+ icalcluster_get_next_component(dset->cluster);
}
-
while(1){
/* Iterate through all of the objects in the cluster*/
- for( c = icalfileset_get_current_component(impl->cluster);
+ for( c = icalcluster_get_current_component(dset->cluster);
c != 0;
- c = icalfileset_get_next_component(impl->cluster)){
+ c = icalcluster_get_next_component(dset->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){
+ if (dset->gauge != 0 && icalgauge_compare(dset->gauge,c) == 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*/
@@ -753,13 +762,13 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
/* 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);
+ error = icaldirset_next_cluster(dset);
- if(impl->cluster == 0 || error != ICAL_NO_ERROR){
+ if(dset->cluster == 0 || error != ICAL_NO_ERROR){
/* No more clusters */
return 0;
} else {
- c = icalfileset_get_first_component(impl->cluster);
+ c = icalcluster_get_first_component(dset->cluster);
return c;
}
@@ -769,9 +778,28 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
return 0; /* Should never get here */
}
-
+icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
+{
+ icalsetiter itr = icalsetiter_null;
+ icaldirset *fset = (icaldirset*) set;
+ icalerror_check_arg_re((fset!=0), "set", icalsetiter_null);
+ itr.iter.kind = kind;
+ itr.gauge = gauge;
+ /* TO BE IMPLEMENTED */
+ return icalsetiter_null;
+}
-
+icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i)
+{
+ /* TO BE IMPLEMENTED */
+ return NULL;
+}
+
+icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i)
+{
+ /* TO BE IMPLEMENTED */
+ return NULL;
+}
diff --git a/libical/src/libicalss/icaldirset.h b/libical/src/libicalss/icaldirset.h
index 7d205ec..a2d577d 100644
--- a/libical/src/libicalss/icaldirset.h
+++ b/libical/src/libicalss/icaldirset.h
@@ -30,51 +30,67 @@
#define ICALDIRSET_H
#include "ical.h"
+#include "icalset.h"
+#include "icalcluster.h"
+#include "icalgauge.h"
/* icaldirset Routines for storing, fetching, and searching for ical
* objects in a database */
-typedef void icaldirset;
+typedef struct icaldirset_impl icaldirset;
+icalset* icaldirset_new(const char* path);
-icaldirset* icaldirset_new(const char* path);
+icalset* icaldirset_new_reader(const char* path);
+icalset* icaldirset_new_writer(const char* path);
-void icaldirset_free(icaldirset* store);
-const char* icaldirset_path(icaldirset* store);
+icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
+void icaldirset_free(icalset* set);
+
+const char* icaldirset_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 icaldirset_mark(icaldirset* store);
-icalerrorenum icaldirset_commit(icaldirset* store);
+void icaldirset_mark(icalset* set);
+icalerrorenum icaldirset_commit(icalset* set);
-icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp);
-icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp);
+icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
+icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
-int icaldirset_count_components(icaldirset* store,
+int icaldirset_count_components(icalset* 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);
+icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
+void icaldirset_clear(icalset* 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);
+icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
+int icaldirset_has_uid(icalset* store, const char* uid);
+icalcomponent* icaldirset_fetch_match(icalset* 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,
+icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
icalcomponent *newc);
-/* Iterate through the components. If a guage has been defined, these
+/* Iterate through the components. If a gauge 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);
+icalcomponent* icaldirset_get_current_component(icalset* store);
+icalcomponent* icaldirset_get_first_component(icalset* store);
+icalcomponent* icaldirset_get_next_component(icalset* store);
+
+/* External iterator for thread safety */
+icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
+icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
+icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
+
+typedef struct icaldirset_options {
+ int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
+} icaldirset_options;
#endif /* !ICALDIRSET_H */
diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h
index 0e69ba2..332a369 100644
--- a/libical/src/libicalss/icaldirsetimpl.h
+++ b/libical/src/libicalss/icaldirsetimpl.h
@@ -30,18 +30,19 @@
#include "config.h"
#endif
+#include "icalcluster.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 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;
+ icalset super; /**< parent class */
+ char* dir; /**< directory containing ics files */
+ icaldirset_options options; /**< copy of options passed to icalset_new() */
+ icalcluster* cluster; /**< cluster containing data */
+ icalgauge* gauge; /**< gauge for filtering out data */
+ int first_component; /**< ??? */
+ pvl_list directory; /**< ??? */
+ pvl_elem directory_iterator; /**< ??? */
};
diff --git a/libical/src/libicalss/icalfileset.c b/libical/src/libicalss/icalfileset.c
index 943071d..3ae6c54 100644
--- a/libical/src/libicalss/icalfileset.c
+++ b/libical/src/libicalss/icalfileset.c
@@ -30,110 +30,155 @@
#include "config.h"
#endif
+#include "icalfileset.h"
+#include "icalgauge.h"
#include <errno.h>
-
+#include <sys/stat.h> /* for stat */
+#ifndef WIN32
+#include <unistd.h> /* for stat, getpid */
+#else
+#include <io.h>
+#include <share.h>
+#endif
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
+#include <fcntl.h> /* for fcntl */
+#include "icalfilesetimpl.h"
+#include "icalclusterimpl.h"
-#include <fcntl.h> /* For open() flags and mode */
-#include <sys/types.h> /* For open() flags and mode */
-#include <sys/stat.h> /* For open() flags and mode */
+#ifdef WIN32
+#define snprintf _snprintf
+#define strcasecmp stricmp
-#include "icalfileset.h"
-#include "icalfilesetimpl.h"
+#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
-// Eugen C. <eug@thekompany.com>
-#include <defines.h>
-//
+#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
+#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
+#endif
-int snprintf(char *str, size_t n, char const *fmt, ...);
+extern int errno;
-//extern int errno;
+/** Default options used when NULL is passed to icalset_new() **/
+icalfileset_options icalfileset_options_default = {O_RDWR|O_CREAT, 0644, 0, 0};
-int icalfileset_lock(icalfileset *cluster);
-int icalfileset_unlock(icalfileset *cluster);
-icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode);
-int icalfileset_filesize(icalfileset* cluster);
+int icalfileset_lock(icalfileset *set);
+int icalfileset_unlock(icalfileset *set);
+icalerrorenum icalfileset_read_file(icalfileset* set, mode_t mode);
+int icalfileset_filesize(icalfileset* set);
icalerrorenum icalfileset_create_cluster(const char *path);
-icalfileset* icalfileset_new_impl()
+icalset* icalfileset_new(const char* path)
{
- 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;
+ return icalset_new(ICAL_FILE_SET, path, &icalfileset_options_default);
}
-
-icalfileset* icalfileset_new(const char* path)
+icalset* icalfileset_new_reader(const char* path)
{
- return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664);
+ icalfileset_options reader_options = icalfileset_options_default;
+ reader_options.flags = O_RDONLY;
+
+ return icalset_new(ICAL_FILE_SET, path, &reader_options);
}
-icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
+icalset* icalfileset_new_writer(const char* path)
{
- struct icalfileset_impl *impl = icalfileset_new_impl();
- struct icaltimetype tt;
- off_t cluster_file_size;
+ icalfileset_options writer_options = icalfileset_options_default;
+ writer_options.flags = O_RDONLY;
- memset(&tt,0,sizeof(struct icaltimetype));
+ return icalset_new(ICAL_FILE_SET, path, &writer_options);
+}
- icalerror_clear_errno();
- icalerror_check_arg_rz( (path!=0), "path");
+icalset* icalfileset_init(icalset *set, const char* path, void* options_in)
+{
+ icalfileset_options *options = (options_in) ? options_in : &icalfileset_options_default;
+ icalfileset *fset = (icalfileset*) set;
+ int flags;
+ mode_t mode;
+ off_t cluster_file_size;
- if (impl == 0){
- return 0;
- }
+ icalerror_clear_errno();
+ icalerror_check_arg_rz( (path!=0), "path");
+ icalerror_check_arg_rz( (fset!=0), "fset");
- impl->path = strdup(path);
+ fset->path = strdup(path);
+ fset->options = *options;
- cluster_file_size = icalfileset_filesize(impl);
-
- if(cluster_file_size < 0){
- icalfileset_free(impl);
- return 0;
- }
+ flags = options->flags;
+ mode = options->mode;
+
+ cluster_file_size = icalfileset_filesize(fset);
+
+ if(cluster_file_size < 0){
+ icalfileset_free(set);
+ return 0;
+ }
- impl->fd = open(impl->path,flags, mode);
+#ifndef WIN32
+ fset->fd = open(fset->path, flags, mode);
+#else
+ fset->fd = open(fset->path, flags, mode);
+ /* fset->fd = sopen(fset->path,flags, _SH_DENYWR, _S_IREAD | _S_IWRITE); */
+#endif
- if (impl->fd < 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- icalfileset_free(impl);
- return 0;
- }
+ if (fset->fd < 0){
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ icalfileset_free(set);
+ return 0;
+ }
- icalfileset_lock(impl);
+#ifndef WIN32
+ icalfileset_lock(fset);
+#endif
if(cluster_file_size > 0 ){
icalerrorenum error;
- if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){
- icalfileset_free(impl);
- return 0;
+ if((error = icalfileset_read_file(fset,mode))!= ICAL_NO_ERROR){
+ icalfileset_free(set);
+ return 0;
}
}
- if(impl->cluster == 0){
- impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
- }
+ if (options->cluster) {
+ fset->cluster = icalcomponent_new_clone(icalcluster_get_component(options->cluster));
+ fset->changed = 1;
+ }
+
+ if (fset->cluster == 0) {
+ fset->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ }
+
+ return set;
+}
+
+
+icalcluster* icalfileset_produce_icalcluster(const char *path) {
+ icalset *fileset;
+ icalcluster *ret;
+
+ int errstate = icalerror_errors_are_fatal;
+ icalerror_errors_are_fatal = 0;
- return impl;
+ fileset = icalfileset_new_reader(path);
+
+
+ if (fileset == 0 && icalerrno == ICAL_FILE_ERROR) {
+ /* file does not exist */
+ ret = icalcluster_new(path, NULL);
+ } else {
+ ret = icalcluster_new(path, ((icalfileset*)fileset)->cluster);
+ icalfileset_free(fileset);
+ }
+
+ icalerror_errors_are_fatal = errstate;
+ icalerror_set_errno(ICAL_NO_ERROR);
+ return ret;
}
+
+
char* icalfileset_read_from_file(char *s, size_t size, void *d)
{
-
char* p = s;
int fd = (int)d;
@@ -158,42 +203,38 @@ char* icalfileset_read_from_file(char *s, size_t size, void *d)
}
-icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode)
+icalerrorenum icalfileset_read_file(icalfileset* set,mode_t mode)
{
-
icalparser *parser;
- 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_set_gen_data(parser,(void*)set->fd);
+ set->cluster = icalparser_parse(parser,icalfileset_read_from_file);
icalparser_free(parser);
- if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){
+ if (set->cluster == 0 || icalerrno != ICAL_NO_ERROR){
icalerror_set_errno(ICAL_PARSE_ERROR);
- return ICAL_PARSE_ERROR;
+ /*return ICAL_PARSE_ERROR;*/
}
- if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){
+ if (icalcomponent_isa(set->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);
+ icalcomponent *cl = set->cluster;
+ set->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ icalcomponent_add_component(set->cluster,cl);
}
return ICAL_NO_ERROR;
-
}
-int icalfileset_filesize(icalfileset* cluster)
+int icalfileset_filesize(icalfileset* fset)
{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
int cluster_file_size;
struct stat sbuf;
-
- if (stat(impl->path,&sbuf) != 0){
+
+ if (stat(fset->path,&sbuf) != 0){
/* A file by the given name does not exist, or there was
another error */
@@ -209,7 +250,6 @@ int icalfileset_filesize(icalfileset* cluster)
} else {
/* A file by the given name exists, but is it a regular file? */
-#ifndef _QTWIN_
if (!S_ISREG(sbuf.st_mode)){
/* Nope, not a regular file */
icalerror_set_errno(ICAL_FILE_ERROR);
@@ -217,117 +257,109 @@ int icalfileset_filesize(icalfileset* cluster)
} else {
/* Lets assume that it is a file of the right type */
return sbuf.st_size;
- }
-#else
- return sbuf.st_size;
-#endif
-
+ }
}
/*return -1; not reached*/
}
-void icalfileset_free(icalfileset* cluster)
+void icalfileset_free(icalset* set)
{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_rv((cluster!=0),"cluster");
+ icalerror_check_arg_rv((set!=0),"set");
- if (impl->cluster != 0){
- icalfileset_commit(cluster);
- icalcomponent_free(impl->cluster);
- impl->cluster=0;
+ if (fset->cluster != 0){
+ icalfileset_commit(set);
+ icalcomponent_free(fset->cluster);
+ fset->cluster=0;
}
- if(impl->fd > 0){
- icalfileset_unlock(impl);
- close(impl->fd);
- impl->fd = -1;
+ if (fset->gauge != 0){
+ icalgauge_free(fset->gauge);
+ fset->gauge=0;
}
- if(impl->path != 0){
- free(impl->path);
- impl->path = 0;
+ if(fset->fd > 0){
+ icalfileset_unlock(fset);
+ close(fset->fd);
+ fset->fd = -1;
}
- free(impl);
+ if(fset->path != 0){
+ free(fset->path);
+ fset->path = 0;
+ }
}
-const char* icalfileset_path(icalfileset* cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- icalerror_check_arg_rz((cluster!=0),"cluster");
+const char* icalfileset_path(icalset* set) {
+ icalerror_check_arg_rz((set!=0),"set");
- return impl->path;
+ return ((icalfileset*)set)->path;
}
-int icalfileset_lock(icalfileset *cluster)
+int icalfileset_lock(icalfileset *set)
{
-#ifndef _WIN32
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+#ifndef WIN32
struct flock lock;
int rtrn;
- icalerror_check_arg_rz((impl->fd>0),"impl->fd");
+ icalerror_check_arg_rz((set->fd>0),"set->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);
+ rtrn = fcntl(set->fd, F_SETLKW, &lock);
return rtrn;
#else
- return -1;
+ return 0;
#endif
}
-int icalfileset_unlock(icalfileset *cluster)
+int icalfileset_unlock(icalfileset *set)
{
-#ifndef _WIN32
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+#ifndef WIN32
struct flock lock;
- icalerror_check_arg_rz((impl->fd>0),"impl->fd");
+ icalerror_check_arg_rz((set->fd>0),"set->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));
+ return (fcntl(set->fd, F_UNLCK, &lock));
#else
- return -1;
+ return 0;
#endif
}
-#ifdef ICAL_SAFESAVES
-int icalfileset_safe_saves=1;
-#else
-int icalfileset_safe_saves=0;
-#endif
-
-icalerrorenum icalfileset_commit(icalfileset* cluster)
+icalerrorenum icalfileset_commit(icalset* set)
{
char tmp[ICAL_PATH_MAX];
char *str;
icalcomponent *c;
off_t write_size=0;
+ icalfileset *fset = (icalfileset*) set;
+
+ icalerror_check_arg_re((fset!=0),"set",ICAL_BADARG_ERROR);
- 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",
+ icalerror_check_arg_re((fset->fd>0),"set->fd is invalid",
ICAL_INTERNAL_ERROR) ;
- if (impl->changed == 0 ){
+ if (fset->changed == 0 ){
return ICAL_NO_ERROR;
}
- if(icalfileset_safe_saves == 1){
- snprintf(tmp,ICAL_PATH_MAX,"cp %s %s.bak",impl->path,impl->path);
+ if (fset->options.safe_saves == 1) {
+#ifndef WIN32
+ snprintf(tmp,ICAL_PATH_MAX,"cp '%s' '%s.bak'",fset->path, fset->path);
+#else
+ snprintf(tmp,ICAL_PATH_MAX,"copy %s %s.bak", fset->path, fset->path);
+#endif
if(system(tmp) < 0){
icalerror_set_errno(ICAL_FILE_ERROR);
@@ -335,19 +367,19 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
}
}
- if(lseek(impl->fd,SEEK_SET,0) < 0){
+ if(lseek(fset->fd, 0, SEEK_SET) < 0){
icalerror_set_errno(ICAL_FILE_ERROR);
return ICAL_FILE_ERROR;
}
- for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT);
+ for(c = icalcomponent_get_first_component(fset->cluster,ICAL_ANY_COMPONENT);
c != 0;
- c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){
+ c = icalcomponent_get_next_component(fset->cluster,ICAL_ANY_COMPONENT)){
int sz;
str = icalcomponent_as_ical_string(c);
- sz=write(impl->fd,str,strlen(str));
+ sz=write(fset->fd,str,strlen(str));
if ( sz != strlen(str)){
perror("write");
@@ -358,134 +390,138 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
write_size += sz;
}
- impl->changed = 0;
+ fset->changed = 0;
-#ifndef _QTWIN_
- if(ftruncate(impl->fd,write_size) < 0){
+#ifndef WIN32
+ if(ftruncate(fset->fd,write_size) < 0){
return ICAL_FILE_ERROR;
}
+#else
+ chsize( fset->fd, tell( fset->fd ) );
#endif
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;
+void icalfileset_mark(icalset* set) {
+ icalerror_check_arg_rv((set!=0),"set");
+ ((icalfileset*)set)->changed = 1;
}
-icalcomponent* icalfileset_get_component(icalfileset* cluster){
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+icalcomponent* icalfileset_get_component(icalset* set){
+ icalfileset *fset = (icalfileset*) set;
+ icalerror_check_arg_rz((set!=0),"set");
- icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
-
- return impl->cluster;
+ return fset->cluster;
}
-/* manipulate the components in the cluster */
+/* manipulate the components in the set */
-icalerrorenum icalfileset_add_component(icalfileset *cluster,
+icalerrorenum icalfileset_add_component(icalset *set,
icalcomponent* child)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_re((cluster!=0),"cluster", ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((set!=0),"set", ICAL_BADARG_ERROR);
icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
- icalcomponent_add_component(impl->cluster,child);
+ icalcomponent_add_component(fset->cluster,child);
- icalfileset_mark(cluster);
+ icalfileset_mark(set);
return ICAL_NO_ERROR;
-
}
-icalerrorenum icalfileset_remove_component(icalfileset *cluster,
+icalerrorenum icalfileset_remove_component(icalset *set,
icalcomponent* child)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_re((cluster!=0),"cluster",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR);
icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
- icalcomponent_remove_component(impl->cluster,child);
+ icalcomponent_remove_component(fset->cluster,child);
- icalfileset_mark(cluster);
+ icalfileset_mark(set);
return ICAL_NO_ERROR;
}
-int icalfileset_count_components(icalfileset *cluster,
+int icalfileset_count_components(icalset *set,
icalcomponent_kind kind)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
- if(cluster == 0){
+ if (set == 0){
icalerror_set_errno(ICAL_BADARG_ERROR);
return -1;
}
- return icalcomponent_count_components(impl->cluster,kind);
+ return icalcomponent_count_components(fset->cluster,kind);
}
-icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge)
+icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re(gauge!=0,"gauge",ICAL_BADARG_ERROR);
- impl->gauge = gauge;
+ fset->gauge = gauge;
return ICAL_NO_ERROR;
}
-void icalfileset_clear(icalfileset* gauge)
+void icalfileset_clear(icalset* set)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge;
-
- impl->gauge = 0;
+ icalfileset *fset = (icalfileset*) set;
+
+ icalerror_check_arg_rv(set!=0,"set");
+ fset->gauge = 0;
}
-icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid)
+icalcomponent* icalfileset_fetch(icalset* set,const char* uid)
{
+ icalfileset *fset = (icalfileset*) set;
icalcompiter i;
- struct icalfileset_impl* impl = (struct icalfileset_impl*)store;
+
+ icalerror_check_arg_rz(set!=0,"set");
- for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT);
+ for(i = icalcomponent_begin_component(fset->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;
- }
+ icalcomponent *this = icalcompiter_deref(&i);
+ icalcomponent *inner;
+ icalproperty *p;
+ const char *this_uid;
+
+ for(inner = icalcomponent_get_first_component(this,ICAL_ANY_COMPONENT);
+ inner != 0;
+ inner = icalcomponent_get_next_component(this,ICAL_ANY_COMPONENT)){
+
+ p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
+ if ( p )
+ {
+ 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)
+int icalfileset_has_uid(icalset* set,const char* uid)
{
assert(0); /* HACK, not implemented */
return 0;
@@ -508,12 +544,11 @@ void icalfileset_id_free(struct icalfileset_id *id)
if(id->uid != 0){
free(id->uid);
}
-
}
+
struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
{
-
icalcomponent *inner;
struct icalfileset_id id;
icalproperty *p;
@@ -549,19 +584,20 @@ struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
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)
+icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *comp)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
+ icalfileset *fset = (icalfileset*) 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);
+ for(i = icalcomponent_begin_component(fset->cluster,ICAL_ANY_COMPONENT);
icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
icalcomponent *match = icalcompiter_deref(&i);
@@ -589,43 +625,45 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
}
-icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old,
+icalerrorenum icalfileset_modify(icalset* set, icalcomponent *old,
icalcomponent *new)
{
+ icalfileset *fset = (icalfileset*) set;
+
assert(0); /* HACK, not implemented */
return ICAL_NO_ERROR;
}
/* Iterate through components */
-icalcomponent* icalfileset_get_current_component (icalfileset* cluster)
+icalcomponent* icalfileset_get_current_component (icalset* set)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_rz((cluster!=0),"cluster");
+ icalerror_check_arg_rz((set!=0),"set");
- return icalcomponent_get_current_component(impl->cluster);
+ return icalcomponent_get_current_component(fset->cluster);
}
-icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
+icalcomponent* icalfileset_get_first_component(icalset* set)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
icalcomponent *c=0;
+ icalfileset *fset = (icalfileset*) set;
- icalerror_check_arg_rz((cluster!=0),"cluster");
+ icalerror_check_arg_rz((set!=0),"set");
do {
if (c == 0){
- c = icalcomponent_get_first_component(impl->cluster,
+ c = icalcomponent_get_first_component(fset->cluster,
ICAL_ANY_COMPONENT);
} else {
- c = icalcomponent_get_next_component(impl->cluster,
+ c = icalcomponent_get_next_component(fset->cluster,
ICAL_ANY_COMPONENT);
}
- if(c != 0 && (impl->gauge == 0 ||
- icalgauge_compare(impl->gauge,c) == 1)){
+ if(c != 0 && (fset->gauge == 0 ||
+ icalgauge_compare(fset->gauge, c) == 1)){
return c;
}
@@ -635,19 +673,19 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
return 0;
}
-icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
+icalcomponent* icalfileset_get_next_component(icalset* set)
{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalfileset *fset = (icalfileset*) set;
icalcomponent *c;
- icalerror_check_arg_rz((cluster!=0),"cluster");
+ icalerror_check_arg_rz((set!=0),"set");
do {
- c = icalcomponent_get_next_component(impl->cluster,
+ c = icalcomponent_get_next_component(fset->cluster,
ICAL_ANY_COMPONENT);
- if(c != 0 && (impl->gauge == 0 ||
- icalgauge_compare(impl->gauge,c) == 1)){
+ if(c != 0 && (fset->gauge == 0 ||
+ icalgauge_compare(fset->gauge,c) == 1)){
return c;
}
@@ -656,4 +694,241 @@ icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
return 0;
}
+/*
+icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
+{
+ icalsetiter itr = icalsetiter_null;
+ icalcomponent* comp = NULL;
+ icalcompiter citr;
+ icalfileset *fset = (icalfileset*) set;
+
+ icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
+
+ itr.gauge = gauge;
+
+ citr = icalcomponent_begin_component(fset->cluster, kind);
+ comp = icalcompiter_deref(&citr);
+
+ while (comp != 0) {
+ comp = icalcompiter_deref(&citr);
+ if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
+ itr.iter = citr;
+ return itr;
+ }
+ comp = icalcompiter_next(&citr);
+ }
+
+ return icalsetiter_null;
+}
+*/
+
+icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
+{
+ icalsetiter itr = icalsetiter_null;
+ icalcomponent* comp = NULL;
+ icalcompiter citr;
+ icalfileset *fset = (icalfileset*) set;
+ struct icaltimetype start, next;
+ icalproperty *dtstart, *rrule, *prop, *due;
+ struct icalrecurrencetype recur;
+ int g = 0;
+
+ icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
+
+ itr.gauge = gauge;
+
+ citr = icalcomponent_begin_component(fset->cluster, kind);
+ comp = icalcompiter_deref(&citr);
+
+ if (gauge == 0) {
+ itr.iter = citr;
+ return itr;
+ }
+
+ while (comp != 0) {
+
+ /* check if it is a recurring component and with guage expand, if so
+ we need to add recurrence-id property to the given component */
+ rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
+ g = icalgauge_get_expand(gauge);
+
+ if (rrule != 0
+ && g == 1) {
+
+ recur = icalproperty_get_rrule(rrule);
+ if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
+ dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
+ if (dtstart)
+ start = icalproperty_get_dtstart(dtstart);
+ } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
+ due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
+ if (due)
+ start = icalproperty_get_due(due);
+ }
+
+ if (itr.last_component == NULL) {
+ itr.ritr = icalrecur_iterator_new(recur, start);
+ next = icalrecur_iterator_next(itr.ritr);
+ itr.last_component = comp;
+ }
+ else {
+ next = icalrecur_iterator_next(itr.ritr);
+ if (icaltime_is_null_time(next)){
+ itr.last_component = NULL;
+ icalrecur_iterator_free(itr.ritr);
+ itr.ritr = NULL;
+ return icalsetiter_null;
+ } else {
+ itr.last_component = comp;
+ }
+ }
+
+ /* add recurrence-id to the component
+ if there is a recurrence-id already, remove it, then add the new one */
+ if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
+ icalcomponent_remove_property(comp, prop);
+ icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
+
+ }
+
+ if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
+ /* matches and returns */
+ itr.iter = citr;
+ return itr;
+ }
+
+ /* if there is no previous component pending, then get the next component */
+ if (itr.last_component == NULL)
+ comp = icalcompiter_next(&citr);
+ }
+
+ return icalsetiter_null;
+}
+icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr)
+{
+ icalcomponent* comp = NULL;
+ struct icaltimetype start, next;
+ icalproperty *dtstart, *rrule, *prop, *due;
+ struct icalrecurrencetype recur;
+
+ comp = itr->last_component;
+
+ if (comp == NULL || itr->gauge == NULL) {
+ return NULL;
+ }
+
+ rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
+
+ recur = icalproperty_get_rrule(rrule);
+
+ if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
+ dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
+ if (dtstart)
+ start = icalproperty_get_dtstart(dtstart);
+ } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
+ due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
+ if (due)
+ start = icalproperty_get_due(due);
+ }
+
+ if (itr->ritr == NULL) {
+ itr->ritr = icalrecur_iterator_new(recur, start);
+ next = icalrecur_iterator_next(itr->ritr);
+ itr->last_component = comp;
+ } else {
+ next = icalrecur_iterator_next(itr->ritr);
+ if (icaltime_is_null_time(next)){
+ /* no more recurrence, returns */
+ itr->last_component = NULL;
+ icalrecur_iterator_free(itr->ritr);
+ itr->ritr = NULL;
+ return NULL;
+ } else {
+ itr->last_component = comp;
+ }
+ }
+
+ /* add recurrence-id to the component
+ * if there is a recurrence-id already, remove it, then add the new one */
+ if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
+ icalcomponent_remove_property(comp, prop);
+ icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
+
+ if (itr->gauge == 0 || icalgauge_compare(itr->gauge, comp) == 1) {
+ /* matches and returns */
+ return comp;
+ }
+ /* not matched */
+ return NULL;
+
+}
+icalcomponent* icalfilesetiter_to_next(icalset* set, icalsetiter* i)
+{
+
+ icalcomponent* c = NULL;
+ icalfileset *fset = (icalfileset*) set;
+ struct icaltimetype start, next;
+ icalproperty *dtstart, *rrule, *prop, *due;
+ struct icalrecurrencetype recur;
+ int g = 0;
+
+
+ do {
+ c = icalcompiter_next(&(i->iter));
+
+ if (c == 0) continue;
+ if (i->gauge == 0) return c;
+
+
+ rrule = icalcomponent_get_first_property(c, ICAL_RRULE_PROPERTY);
+ g = icalgauge_get_expand(i->gauge);
+
+ /* a recurring component with expand query */
+ if (rrule != 0
+ && g == 1) {
+
+ recur = icalproperty_get_rrule(rrule);
+
+ if (icalcomponent_isa(c) == ICAL_VEVENT_COMPONENT) {
+ dtstart = icalcomponent_get_first_property(c, ICAL_DTSTART_PROPERTY);
+ if (dtstart)
+ start = icalproperty_get_dtstart(dtstart);
+ } else if (icalcomponent_isa(c) == ICAL_VTODO_COMPONENT) {
+ due = icalcomponent_get_first_property(c, ICAL_DUE_PROPERTY);
+ if (due)
+ start = icalproperty_get_due(due);
+ }
+
+ if (i->ritr == NULL) {
+ i->ritr = icalrecur_iterator_new(recur, start);
+ next = icalrecur_iterator_next(i->ritr);
+ i->last_component = c;
+ } else {
+ next = icalrecur_iterator_next(i->ritr);
+ if (icaltime_is_null_time(next)) {
+ /* no more recurrence, returns */
+ i->last_component = NULL;
+ icalrecur_iterator_free(i->ritr);
+ i->ritr = NULL;
+ return NULL;
+ } else {
+ i->last_component = c;
+ }
+ }
+ }
+
+ /* add recurrence-id to the component
+ * if there is a recurrence-id already, remove it, then add the new one */
+ if (prop = icalcomponent_get_first_property(c, ICAL_RECURRENCEID_PROPERTY))
+ icalcomponent_remove_property(c, prop);
+ icalcomponent_add_property(c, icalproperty_new_recurrenceid(next));
+
+ if(c != 0 && (i->gauge == 0 ||
+ icalgauge_compare(i->gauge, c) == 1)){
+ return c;
+ }
+ } while (c != 0);
+
+ return 0;
+}
diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h
index 51254d2..dc044ea 100644
--- a/libical/src/libicalss/icalfileset.h
+++ b/libical/src/libicalss/icalfileset.h
@@ -29,77 +29,104 @@
#ifndef ICALFILESET_H
#define ICALFILESET_H
-#include "icalerror.h"
#include "ical.h"
#include "icalset.h"
+#include "icalcluster.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;
+#ifdef WIN32
+#define mode_t int
+#endif
+extern int icalfileset_safe_saves;
-/* icalfileset
- icalfilesetfile
- icalfilesetdir
-*/
+typedef struct icalfileset_impl icalfileset;
+icalset* icalfileset_new(const char* path);
+icalset* icalfileset_new_reader(const char* path);
+icalset* icalfileset_new_writer(const char* path);
-icalfileset* icalfileset_new(const char* path);
+icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
-#ifdef _WIN32
-#define mode_t int
-#endif
+icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
-/* Like _new, but takes open() flags for opening the file */
-icalfileset* icalfileset_new_open(const char* path,
- int flags, mode_t mode);
+icalcluster* icalfileset_produce_icalcluster(const char *path);
-void icalfileset_free(icalfileset* cluster);
+void icalfileset_free(icalset* cluster);
-const char* icalfileset_path(icalfileset* cluster);
+const char* icalfileset_path(icalset* 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);
+void icalfileset_mark(icalset* set);
+icalerrorenum icalfileset_commit(icalset* set);
-icalerrorenum icalfileset_add_component(icalfileset* cluster,
+icalerrorenum icalfileset_add_component(icalset* set,
icalcomponent* child);
-icalerrorenum icalfileset_remove_component(icalfileset* cluster,
+icalerrorenum icalfileset_remove_component(icalset* set,
icalcomponent* child);
-int icalfileset_count_components(icalfileset* cluster,
+int icalfileset_count_components(icalset* set,
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);
+/**
+ * Restrict the component returned by icalfileset_first, _next to those
+ * that pass the gauge. _clear removes the gauge
+ */
+icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
+
+/** clear the gauge **/
+void icalfileset_clear(icalset* set);
-/* 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);
+/** Get and search for a component by uid **/
+icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
+int icalfileset_has_uid(icalset* set, const char* uid);
+icalcomponent* icalfileset_fetch_match(icalset* 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,
+/**
+ * Modify components according to the MODIFY method of CAP. Works on the
+ * currently selected components.
+ */
+icalerrorenum icalfileset_modify(icalset* set,
+ icalcomponent *oldcomp,
icalcomponent *newcomp);
-/* Iterate through components. If a guage has been defined, these
+/* Iterate through components. If a gauge 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
+icalcomponent* icalfileset_get_current_component (icalset* cluster);
+icalcomponent* icalfileset_get_first_component(icalset* cluster);
+icalcomponent* icalfileset_get_next_component(icalset* cluster);
+
+/* External iterator for thread safety */
+icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
+icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
+icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
+
+/** Return a reference to the internal component. You probably should
not be using this. */
-icalcomponent* icalfileset_get_component(icalfileset* cluster);
+icalcomponent* icalfileset_get_component(icalset* cluster);
+
+/**
+ * @brief options for opening an icalfileset.
+ *
+ * These options should be passed to the icalset_new() function
+ */
+
+typedef struct icalfileset_options {
+ int flags; /**< flags for open() O_RDONLY, etc */
+ mode_t mode; /**< file mode */
+ int safe_saves; /**< to lock or not */
+ icalcluster *cluster; /**< use this cluster to initialize data */
+} icalfileset_options;
+extern icalfileset_options icalfileset_options_default;
#endif /* !ICALFILESET_H */
diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h
index fcd3415..fe39604 100644
--- a/libical/src/libicalss/icalfilesetimpl.h
+++ b/libical/src/libicalss/icalfilesetimpl.h
@@ -25,6 +25,8 @@
======================================================================*/
+#ifndef ICALFILESETIMPL_H
+#define ICALFILESETIMPL_H
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -38,12 +40,14 @@
#define ICALFILESET_ID "fset"
struct icalfileset_impl {
-
- char id[5]; /*fset*/
- char *path;
- icalcomponent* cluster;
- icalgauge* gauge;
- int changed;
- int fd; /* file descriptor */
+ icalset super; /**< parent class */
+ char *path; /**< pathname of file */
+ icalfileset_options options; /**< copy of options passed to icalset_new() */
+
+ icalcomponent* cluster; /**< cluster containing data */
+ icalgauge* gauge; /**< gauge for filtering out data */
+ int changed; /**< boolean flag, 1 if data has changed */
+ int fd; /**< file descriptor */
};
+#endif
diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c
index b958ecf..f4854c7 100644
--- a/libical/src/libicalss/icalgauge.c
+++ b/libical/src/libicalss/icalgauge.c
@@ -31,15 +31,17 @@
#include "icalgaugeimpl.h"
#include <stdlib.h>
-extern char* input_buffer;
-extern char* input_buffer_p;
-int ssparse(void);
+#include "icalssyacc.h"
-struct icalgauge_impl *icalss_yy_gauge;
+typedef void* yyscan_t;
-icalgauge* icalgauge_new_from_sql(char* sql)
+int ssparse(yyscan_t );
+
+
+icalgauge* icalgauge_new_from_sql(char* sql, int expand)
{
struct icalgauge_impl *impl;
+ yyscan_t yy_globals = NULL;
int r;
@@ -52,60 +54,82 @@ icalgauge* icalgauge_new_from_sql(char* sql)
impl->select = pvl_newlist();
impl->from = pvl_newlist();
impl->where = pvl_newlist();
+ impl->expand = expand;
+
+ sslex_init(&yy_globals);
+
+ ssset_extra(impl, yy_globals);
- icalss_yy_gauge = impl;
+ ss_scan_string(sql, yy_globals);
- input_buffer_p = input_buffer = sql;
- r = ssparse();
+ r = ssparse(yy_globals);
+ sslex_destroy(yy_globals);
- return impl;
+ if (r == 0) {
+ return impl;
+ }
+ else {
+ icalgauge_free(impl);
+ return NULL;
+ }
}
+int icalgauge_get_expand(icalgauge* gauge)
+{
+return (gauge->expand);
+
+}
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);
+ assert(gauge->select != 0);
+ assert(gauge->where != 0);
+ assert(gauge->from != 0);
- if(impl->select){
- while( (w=pvl_pop(impl->select)) != 0){
+ if(gauge->select){
+ while( (w=pvl_pop(gauge->select)) != 0){
if(w->value != 0){
free(w->value);
}
free(w);
}
- pvl_free(impl->select);
+ pvl_free(gauge->select);
+ gauge->select = 0;
}
- if(impl->where){
- while( (w=pvl_pop(impl->where)) != 0){
+ if(gauge->where){
+ while( (w=pvl_pop(gauge->where)) != 0){
if(w->value != 0){
free(w->value);
}
free(w);
}
- pvl_free(impl->where);
+ pvl_free(gauge->where);
+ gauge->where = 0;
}
- if(impl->from){
- pvl_free(impl->from);
+ if(gauge->from){
+ pvl_free(gauge->from);
+ gauge->from = 0;
}
+
+ free(gauge);
}
-/* Convert a VQUERY component into a gauge */
+
+/** Convert a VQUERY component into a gauge */
icalcomponent* icalgauge_make_gauge(icalcomponent* query);
-/* icaldirset_test compares a component against a gauge, and returns
+/**
+ 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
+ target components. The gauge 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
@@ -252,26 +276,45 @@ int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
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;
+ icalcomponent_kind kind;
+ icalproperty *rrule;
+ int compare_recur = 0;
+
icalerror_check_arg_rz( (comp!=0), "comp");
icalerror_check_arg_rz( (gauge!=0), "gauge");
+ if (gauge == 0 || comp == 0) return 0;
+
inner = icalcomponent_get_first_real_component(comp);
if(inner == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
+ /* Wally Yau: our component is not always wrapped with
+ * a <VCALENDAR>. It's not an error.
+ * icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
+ * return 0; */
+ kind = icalcomponent_isa(comp);
+ if(kind == ICAL_VEVENT_COMPONENT ||
+ kind == ICAL_VTODO_COMPONENT ||
+ kind == ICAL_VJOURNAL_COMPONENT ||
+ kind == ICAL_VQUERY_COMPONENT ||
+ kind == ICAL_VAGENDA_COMPONENT){
+ inner = comp;
+ }
+ else {
+ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
+ return 0;
+ }
+ inner = comp;
}
-
/* 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)){
+ for(e = pvl_head(gauge->from);e!=0;e=pvl_next(e)){
icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
if(k == icalcomponent_isa(inner)){
@@ -284,8 +327,8 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
}
- /* Check each where clause against the component */
- for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){
+ /**** Check each where clause against the component ****/
+ for(e = pvl_head(gauge->where);e!=0;e=pvl_next(e)){
struct icalgauge_where *w = pvl_data(e);
icalcomponent *sub_comp;
icalvalue *v;
@@ -301,11 +344,14 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
vk = icalenum_property_kind_to_value_kind(w->prop);
if(vk == ICAL_NO_VALUE){
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
+ icalerror_set_errno(ICAL_INTERNAL_ERROR);
return 0;
}
- v = icalvalue_new_from_string(vk,w->value);
+ if (w->compare == ICALGAUGECOMPARE_ISNULL || w->compare == ICALGAUGECOMPARE_ISNOTNULL)
+ v = icalvalue_new(vk);
+ else
+ v = icalvalue_new_from_string(vk,w->value);
if (v == 0){
/* Keep error set by icalvalue_from-string*/
@@ -324,14 +370,46 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
}
}
+ /* check if it is a recurring */
+ rrule = icalcomponent_get_first_property(sub_comp,ICAL_RRULE_PROPERTY);
+
+ if (gauge->expand
+ && rrule) {
+
+ if (w->prop == ICAL_DTSTART_PROPERTY ||
+ w->prop == ICAL_DTEND_PROPERTY ||
+ w->prop == ICAL_DUE_PROPERTY){
+ /** needs to use recurrence-id to do comparison */
+ compare_recur = 1;
+ }
+
+ }
+
+
this_clause = 0;
- local_pass = 0;
+ local_pass = (w->compare == ICALGAUGECOMPARE_ISNULL) ? 1 : 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;
+ if (w->compare == ICALGAUGECOMPARE_ISNULL) {
+ local_pass = 0;
+ break;
+ }
+
+ if (w->compare == ICALGAUGECOMPARE_ISNOTNULL) {
+ local_pass = 1;
+ break;
+ }
+
+ if (compare_recur) {
+ icalproperty *p = icalcomponent_get_first_property(sub_comp, ICAL_RECURRENCEID_PROPERTY);
+ prop_value = icalproperty_get_value(p);
+ }
+ else /* prop value from this component */
prop_value = icalproperty_get_value(prop);
relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
@@ -355,34 +433,40 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
}
}
+
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) {
+ } else if(w->logic == ICALGAUGELOGIC_OR) {
last_clause = this_clause || last_clause;
} else {
last_clause = this_clause;
}
- }
+
+ icalvalue_free(v);
+
+ }/**** check next one in where clause ****/
return last_clause;
}
+/** @brief Debug
+ * Print gauge information to stdout.
+ */
-void icalgauge_dump(icalcomponent* gauge)
+void icalgauge_dump(icalgauge* gauge)
{
- pvl_elem *p;
- struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
-
+ pvl_elem p;
printf("--- Select ---\n");
- for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){
+ for(p = pvl_head(gauge->select);p!=0;p=pvl_next(p)){
struct icalgauge_where *w = pvl_data(p);
if(w->comp != ICAL_NO_COMPONENT){
@@ -407,14 +491,14 @@ void icalgauge_dump(icalcomponent* gauge)
}
printf("--- From ---\n");
- for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){
+ for(p = pvl_head(gauge->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)){
+ for(p = pvl_head(gauge->where);p!=0;p=pvl_next(p)){
struct icalgauge_where *w = pvl_data(p);
if(w->logic != ICALGAUGELOGIC_NONE){
@@ -441,7 +525,5 @@ void icalgauge_dump(icalcomponent* gauge)
printf("\n");
}
-
-
}
diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h
index 1caf0ac..c35b4f7 100644
--- a/libical/src/libicalss/icalgauge.h
+++ b/libical/src/libicalss/icalgauge.h
@@ -29,23 +29,33 @@
#ifndef ICALGAUGE_H
#define ICALGAUGE_H
-typedef void icalgauge;
+/** @file icalgauge.h
+ * @brief Routines implementing a filter for ical components
+ */
-icalgauge* icalgauge_new_from_sql(char* sql);
+typedef struct icalgauge_impl icalgauge;
+
+icalgauge* icalgauge_new_from_sql(char* sql, int expand);
+
+int icalgauge_get_expand(icalgauge* gauge);
void icalgauge_free(icalgauge* gauge);
char* icalgauge_as_sql(icalcomponent* gauge);
-void icalgauge_dump(icalcomponent* gauge);
+void icalgauge_dump(icalgauge* 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 */
+/** @brief Return true if 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 */
+/** 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
index 73a2813..e56b1c0 100644
--- a/libical/src/libicalss/icalgaugeimpl.h
+++ b/libical/src/libicalss/icalgaugeimpl.h
@@ -24,8 +24,6 @@
#include "ical.h"
-#include "pvl.h"
-
typedef enum icalgaugecompare {
ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
@@ -34,6 +32,8 @@ typedef enum icalgaugecompare {
ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
+ ICALGAUGECOMPARE_ISNULL=ICAL_XLICCOMPARETYPE_ISNULL,
+ ICALGAUGECOMPARE_ISNOTNULL=ICAL_XLICCOMPARETYPE_ISNOTNULL,
ICALGAUGECOMPARE_NONE=0
} icalgaugecompare;
@@ -54,10 +54,10 @@ struct icalgauge_where {
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 */
+ 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 */
+ int expand;
};
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c
index d5c57c1..731a2c7 100644
--- a/libical/src/libicalss/icalmessage.c
+++ b/libical/src/libicalss/icalmessage.c
@@ -40,7 +40,7 @@ icalcomponent* icalmessage_get_inner(icalcomponent* comp)
}
}
-char* lowercase(const char* str)
+static char* lowercase(const char* str)
{
char* p = 0;
char* n = icalmemory_strdup(str);
@@ -158,8 +158,13 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
icalcomponent_add_property(reply,icalproperty_new_version("2.0"));
+#ifndef WIN32
sprintf(tmp,
"-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION);
+#else
+ sprintf(tmp,
+ "-//SoftwareStudio//NONSGML %s %s //EN",ICAL_PACKAGE,ICAL_VERSION);
+#endif
icalcomponent_add_property(reply,icalproperty_new_prodid(tmp));
return reply;
@@ -230,11 +235,11 @@ icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
icalerror_check_arg_rz(oldc,"oldc");
icalerror_check_arg_rz(newc,"newc");
- reply = icalcomponent_new_clone(newc);
+ reply = icalmessage_new_reply_base(newc,user,msg);
icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
- return newc;
+ return reply;
}
diff --git a/libical/src/libicalss/icalset.c b/libical/src/libicalss/icalset.c
index 2120609..0ad2269 100644
--- a/libical/src/libicalss/icalset.c
+++ b/libical/src/libicalss/icalset.c
@@ -41,33 +41,26 @@
#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 = {
+#include <string.h>
+#include <errno.h>
+
+#ifdef WITH_BDB4
+#include "icalbdbset.h"
+#include "icalbdbsetimpl.h"
+#endif
+
+/* #define _DLOPEN_TEST */
+#ifdef _DLOPEN_TEST
+#include <sys/types.h>
+#include <dlfcn.h>
+#include <dirent.h>
+#endif
+
+static icalset icalset_dirset_init = {
+ ICAL_DIR_SET,
+ sizeof(icaldirset),
+ NULL,
+ icaldirset_init,
icaldirset_free,
icaldirset_path,
icaldirset_mark,
@@ -83,11 +76,18 @@ struct icalset_fp icalset_dirset_fp = {
icaldirset_modify,
icaldirset_get_current_component,
icaldirset_get_first_component,
- icaldirset_get_next_component
+ icaldirset_get_next_component,
+ icaldirset_begin_component,
+ icaldirsetiter_to_next,
+ icaldirsetiter_to_prior
};
-struct icalset_fp icalset_fileset_fp = {
+static icalset icalset_fileset_init = {
+ ICAL_FILE_SET,
+ sizeof(icalfileset),
+ NULL,
+ icalfileset_init,
icalfileset_free,
icalfileset_path,
icalfileset_mark,
@@ -103,265 +103,391 @@ struct icalset_fp icalset_fileset_fp = {
icalfileset_modify,
icalfileset_get_current_component,
icalfileset_get_first_component,
- icalfileset_get_next_component
+ icalfileset_get_next_component,
+ icalfileset_begin_component,
+ icalfilesetiter_to_next,
+ NULL
};
-struct icalset_impl {
+#ifdef WITH_BDB4
+static icalset icalset_bdbset_init = {
+ ICAL_BDB_SET,
+ sizeof(icalbdbset),
+ NULL,
+ icalbdbset_init,
+ icalbdbset_free,
+ icalbdbset_path,
+ icalbdbset_mark,
+ icalbdbset_commit,
+ icalbdbset_add_component,
+ icalbdbset_remove_component,
+ icalbdbset_count_components,
+ icalbdbset_select,
+ icalbdbset_clear,
+ icalbdbset_fetch,
+ icalbdbset_fetch_match,
+ icalbdbset_has_uid,
+ icalbdbset_modify,
+ icalbdbset_get_current_component,
+ icalbdbset_get_first_component,
+ icalbdbset_get_next_component,
+ icalbdbset_begin_component,
+ icalbdbsetiter_to_next,
+ NULL
+};
+#endif
- char id[5]; /* "set " */
+#ifdef _DLOPEN_TEST
+static int icalset_init_done = 0;
+static pvl_list icalset_kinds = 0;
- void *derived_impl;
- struct icalset_fp *fp;
-};
+typedef icalset *(*fptr)(void);
-/* 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_re( (set!=0),"set",impl);
-
- 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;
- }
+/**
+ * Try to load the file and register any icalset found within.
+ */
+static int load(const char *file) {
+
+ void *modh;
+ fptr inith;
+ icalset *icalset_init_ptr;
+
+ if ((modh = dlopen(file, RTLD_NOW)) == 0) {
+ perror("dlopen");
+ return 0;
+ }
+
+ if ((inith = (fptr)dlsym(modh, "InitModule")) == 0) {
+ perror("dlsym");
+ return 0;
+ }
+
+ while ((icalset_init_ptr = ((inith)())) != 0) {
+ pvl_push(icalset_kinds, &icalset_init_ptr);
+ }
+
+ return 1;
}
+/**
+ * Look in the given directory for files called mod_*.o and try to
+ * load them.
+ */
+int icalset_loaddir(const char *path) {
+ DIR *d;
+ struct dirent *dp;
+ char buf[PATH_MAX],
+ *bufptr;
+ int tot = 0;
-struct icalset_impl* icalset_new_impl()
-{
-
- struct icalset_impl* impl;
+ strcpy(buf, path);
+ bufptr = buf + strlen(buf);
- if ( ( impl = (struct icalset_impl*)
- malloc(sizeof(struct icalset_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
+ if (*(bufptr-1) != '/')
+ *bufptr++ = '/';
- strcpy(impl->id,ICALSET_ID);
+ if ((d = opendir(path)) == 0) {
+ perror("opendir");
+ return 0;
+ }
- impl->derived_impl = 0;
- impl->fp = 0;
+ while ((dp = readdir(d)) != 0) {
+ if (strncmp(dp->d_name, "mod_", 4)) continue;
- return impl;
-}
+ strcpy(bufptr, dp->d_name);
-struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset)
-{
- struct icalset_impl *impl = icalset_new_impl();
+ load(buf);
+ tot++;
+ }
+ (void)closedir(d);
- icalerror_check_arg_rz( (fset!=0),"fset");
+ return 1;
+}
- if(impl == 0){
- free(impl);
- return 0;
- }
+int icalset_register_class(icalset *set);
- impl->derived_impl = fset;
+static void icalset_init(void) {
+ assert(icalset_kinds == 0);
+ icalset_kinds = pvl_newlist();
- if (impl->derived_impl == 0){
- free(impl);
- return 0;
- }
+ pvl_push(icalset_kinds, &icalset_fileset_init);
+ pvl_push(icalset_kinds, &icalset_dirset_init);
+#ifdef WITH_BDB4
+ pvl_push(icalset_kinds, &icalset_bdb4set_init);
+#endif
- impl->fp = &icalset_fileset_fp;
+#ifdef EXT_PATH
+ icalset_loaddir(EXT_PATH);
+#endif
- return (struct icalset_impl*)impl;
+ icalset_init_done++;
}
-icalset* icalset_new_file(const char* path)
-{
- icalfileset *fset = icalfileset_new(path);
+int icalset_register_class(icalset *set) {
- if(fset == 0){
- return 0;
- }
+ if (!icalset_init_done)
+ icalset_init();
- return (icalset*)icalset_new_file_from_ref(fset);
+ pvl_push(icalset_kinds, set);
+ return 1;
}
-icalset* icalset_new_dir_from_ref(icaldirset *dset)
-{
+#endif
- struct icalset_impl *impl = icalset_new_impl();
+icalset* icalset_new(icalset_kind kind, const char* dsn, void* options) {
+ icalset *data = NULL;
+ icalset *ret = NULL;
- icalerror_check_arg_rz( (dset!=0),"dset");
+#ifdef _DLOPEN_TEST
+ pvl_elem e;
+ icalset *impl;
- if(impl == 0){
- return 0;
+ if (!icalset_init_done)
+ icalset_init();
+
+ for(e = pvl_head(icalset_kinds); e!=0; e = pvl_next(e)) {
+ impl = (icalset*)pvl_data(e);
+ if (impl->kind == kind)
+ break;
+ }
+ if (e == 0) {
+ icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
+ return(NULL);
}
- impl->derived_impl = dset;
+ data = (icalset*)malloc(impl->size);
+ if (data == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ errno = ENOMEM;
+ return 0;
+ }
- if (impl->derived_impl == 0){
- free(impl);
+ /* The first member of the derived class must be an icalset. */
+ memset(data,0,impl->size);
+ /* *data = *impl; */
+ memcpy(data, impl, sizeof(icalset));
+
+ data->dsn = strdup(dsn);
+#else
+ switch(kind) {
+ case ICAL_FILE_SET:
+ data = (icalset*) malloc(sizeof(icalfileset));
+ if (data == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ errno = ENOMEM;
+ return 0;
+ }
+ memset(data,0,sizeof(icalfileset));
+ *data = icalset_fileset_init;
+ break;
+ case ICAL_DIR_SET:
+ data = (icalset*) malloc(sizeof(icaldirset));
+ if (data == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ errno = ENOMEM;
+ return 0;
+ }
+ memset(data,0,sizeof(icaldirset));
+ *data = icalset_dirset_init;
+ break;
+#ifdef WITH_BDB4
+ case ICAL_BDB_SET:
+ data = (icalset*) malloc(sizeof(icalbdbset));
+ if (data == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ errno = ENOMEM;
return 0;
}
+ memset(data,0,sizeof(icalbdbset));
+ *data = icalset_bdbset_init;
+ break;
+#endif
+
+ default:
+ icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
+ /** unimplemented **/
+ return(NULL);
+ }
+
+ if ( data == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+ data->kind = kind;
+ data->dsn = strdup(dsn);
+#endif
- impl->fp = &icalset_dirset_fp;
+ /** call the implementation specific initializer **/
+ if ((ret = data->init(data, dsn, options)) == NULL)
+ icalset_free(data);
- return impl;
+ return ret;
}
-icalset* icalset_new_dir(const char* path)
+icalset* icalset_new_file(const char* path)
{
- icaldirset *dset = icaldirset_new(path);
-
- if(dset == 0){
- return 0;
- }
+ return icalset_new(ICAL_FILE_SET, path, NULL);
+}
- return icalset_new_dir_from_ref(dset);
+icalset* icalset_new_file_writer(const char* path)
+{
+ return icalfileset_new_writer(path);
}
-icalset* icalset_new_heap(void)
+icalset* icalset_new_file_reader(const char* path)
{
- struct icalset_impl *impl = icalset_new_impl();
+ return icalfileset_new_reader(path);
+}
- if(impl == 0){
- free(impl);
- return 0;
- }
+icalset* icalset_new_dir(const char* path)
+{
+ return icalset_new(ICAL_DIR_SET, path, NULL);
+}
- return 0;
+icalset* icalset_new_dir_writer(const char* path)
+{
+ return icaldirset_new_writer(path);
}
-icalset* icalset_new_mysql(const char* path)
+icalset* icalset_new_dir_reader(const char* path)
{
- struct icalset_impl *impl = icalset_new_impl();
+ return icaldirset_new_reader(path);
+}
- if(impl == 0){
- free(impl);
- return 0;
- }
- return 0;
-}
+
+/* Functions for built-in methods */
+
+/**
+ * free memory associated with this icalset
+ * automatically calls the implementation specific free routine
+ */
void icalset_free(icalset* set)
{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->free))(impl.derived_impl);
+ if (set->free)
+ set->free(set);
- if(strcmp((char*)set,ICALSET_ID)) {
- free(set);
- }
-}
+ if (set->dsn)
+ free(set->dsn);
-const char* icalset_path(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->path))(impl.derived_impl);
+ free(set);
}
-void icalset_mark(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->mark))(impl.derived_impl);
+
+const char* icalset_path(icalset* set) {
+ return set->path(set);
}
-icalerrorenum icalset_commit(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->commit))(impl.derived_impl);
+void icalset_mark(icalset* set) {
+ set->mark(set);
}
-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_commit(icalset* set) {
+ return set->commit(set);
}
-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);
+icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) {
+ return set->add_component(set,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_remove_component(icalset* set, icalcomponent* comp) {
+ return set->remove_component(set,comp);
}
-icalerrorenum icalset_select(icalset* set, icalcomponent* gauge)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->select))(impl.derived_impl,gauge);
+int icalset_count_components(icalset* set,icalcomponent_kind kind) {
+ return set->count_components(set,kind);
}
-void icalset_clear(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->clear))(impl.derived_impl);
+icalerrorenum icalset_select(icalset* set, icalgauge* gauge) {
+ return set->select(set, gauge);
}
-icalcomponent* icalset_fetch(icalset* set, const char* uid)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->fetch))(impl.derived_impl,uid);
+void icalset_clear(icalset* set) {
+ set->clear(set);
}
-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);
+icalcomponent* icalset_fetch(icalset* set, const char* uid) {
+ return set->fetch(set, uid);
}
+icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) {
+ return set->fetch_match(set, 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);
+int icalset_has_uid(icalset* set, const char* uid) {
+ return set->has_uid(set, 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 *new) {
+ return set->modify(set, 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_current_component(icalset* set) {
+ return set->get_current_component(set);
}
-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_first_component(icalset* set) {
+ return set->get_first_component(set);
}
-icalcomponent* icalset_get_next_component(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->get_next_component))(impl.derived_impl);
+icalcomponent* icalset_get_next_component(icalset* set) {
+ return set->get_next_component(set);
+}
+
+icalsetiter icalsetiter_null = {{ICAL_NO_COMPONENT, 0}, 0};
+
+icalsetiter icalset_begin_component(icalset* set,
+ icalcomponent_kind kind, icalgauge* gauge) {
+ return set->icalset_begin_component(set, kind, gauge);
+}
+
+icalcomponent* icalsetiter_next(icalsetiter* itr) {
+
+ icalcomponent* c = 0;
+ icalerror_check_arg_rz( (itr != NULL), "i");
+
+ do {
+ c = icalcompiter_next(&(itr->iter));
+ if(c != 0 && (itr->gauge == 0 ||
+ icalgauge_compare(itr->gauge, c) == 1)){
+ return c;
+ }
+ } while (c != 0);
+
+ return 0;
}
+icalcomponent* icalsetiter_prior(icalsetiter* i) {
+
+ icalcomponent* c = 0;
+ icalerror_check_arg_rz( (i != NULL), "i" );
+
+ do {
+ c = icalcompiter_prior(&(i->iter));
+ if(c != 0 && (i->gauge == 0 ||
+ icalgauge_compare(i->gauge, c) == 1)){
+ return c;
+ }
+ } while (c != 0);
+
+ return 0;
+}
+icalcomponent* icalsetiter_deref(icalsetiter* i) {
+ icalerror_check_arg_rz( (i != NULL), "i" );
+ return (icalcompiter_deref(&(i->iter)));
+}
+/* for subclasses that use multiple clusters that require specialized cluster traversal */
+icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i)
+{
+ return set->icalsetiter_to_next(set, i);
+}
+icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i)
+{
+ return set->icalsetiter_to_prior(set, i);
+}
diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h
index 7b083da..4008c62 100644
--- a/libical/src/libicalss/icalset.h
+++ b/libical/src/libicalss/icalset.h
@@ -1,17 +1,19 @@
/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalset.h
- CREATOR: eric 28 November 1999
-
+/**
+ @file icalset.h
+ @author 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
+ icalfileset Store components in a single file
icaldirset Store components in multiple files in a directory
+ icalbdbset Store components in a Berkeley DB File
icalheapset Store components on the heap
icalmysqlset Store components in a mysql database.
+**/
+/*
$Id$
$Locker$
@@ -39,7 +41,7 @@
#include <limits.h> /* For PATH_MAX */
#include "ical.h"
-#include "icalerror.h"
+#include "icalgauge.h"
#ifdef PATH_MAX
#define ICAL_PATH_MAX PATH_MAX
@@ -48,33 +50,86 @@
#endif
-
-
-typedef void icalset;
+typedef struct icalset_impl icalset;
typedef enum icalset_kind {
ICAL_FILE_SET,
ICAL_DIR_SET,
- ICAL_HEAP_SET,
- ICAL_MYSQL_SET,
- ICAL_CAP_SET
+ ICAL_BDB_SET
} icalset_kind;
+typedef struct icalsetiter
+{
+ icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
+ icalgauge* gauge;
+ icalrecur_iterator* ritr; /*the last iterator*/
+ icalcomponent* last_component; /*the pending recurring component to be processed */
+ const char* tzid; /* the calendar's timezone id */
+} icalsetiter;
+
+struct icalset_impl {
+ icalset_kind kind;
+ int size;
+ char *dsn;
+ icalset* (*init)(icalset* set, const char *dsn, void *options);
+ 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, icalgauge* 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 *newc);
+ icalcomponent* (*get_current_component)(icalset* set);
+ icalcomponent* (*get_first_component)(icalset* set);
+ icalcomponent* (*get_next_component)(icalset* set);
+ icalsetiter (*icalset_begin_component)(icalset* set,
+ icalcomponent_kind kind, icalgauge* gauge);
+ icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
+ icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
+};
+
+/** @brief Register a new derived class */
+int icalset_register_class(icalset *set);
+
+
+/** @brief Generic icalset constructor
+ *
+ * @param kind The type of icalset to create
+ * @param dsn Data Source Name - usually a pathname or DB handle
+ * @param options Any implementation specific options
+ *
+ * @return A valid icalset reference or NULL if error.
+ *
+ * This creates any of the icalset types available.
+ */
+
+icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
-/* Create a specific derived type of set */
icalset* icalset_new_file(const char* path);
+icalset* icalset_new_file_reader(const char* path);
+icalset* icalset_new_file_writer(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);*/
+icalset* icalset_new_file_reader(const char* path);
+icalset* icalset_new_file_writer(const char* path);
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*/
+/** Mark the cluster as changed, so it will be written to disk when it
+ is freed. **/
void icalset_mark(icalset* set);
+
+/** Write changes to disk immediately */
icalerrorenum icalset_commit(icalset* set);
icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -83,28 +138,46 @@ 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);
+/** Restrict the component returned by icalset_first, _next to those
+ that pass the gauge. */
+icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
+
+/** Clears the gauge defined by icalset_select() */
void icalset_clear_select(icalset* set);
-/* Get a component by uid */
+/** 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
+/** 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
+/** 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);
+/** External Iterator with gauge - for thread safety */
+extern icalsetiter icalsetiter_null;
+
+icalsetiter icalset_begin_component(icalset* set,
+ icalcomponent_kind kind, icalgauge* gauge);
+
+/** Default _next, _prior, _deref for subclasses that use single cluster */
+icalcomponent* icalsetiter_next(icalsetiter* i);
+icalcomponent* icalsetiter_prior(icalsetiter* i);
+icalcomponent* icalsetiter_deref(icalsetiter* i);
+
+/** for subclasses that use multiple clusters that require specialized cluster traversal */
+icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
+icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
+
#endif /* !ICALSET_H */
diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c
index cab6a81..f42ff41 100644
--- a/libical/src/libicalss/icalspanlist.c
+++ b/libical/src/libicalss/icalspanlist.c
@@ -28,14 +28,27 @@
#include "ical.h"
#include "icalspanlist.h"
-#include "pvl.h"
+
#include <stdlib.h> /* for free and malloc */
+#include <string.h>
struct icalspanlist_impl {
- pvl_list spans;
+ pvl_list spans; /**< list of icaltime_span data **/
+ struct icaltimetype start; /**< start time of span **/
+ struct icaltimetype end; /**< end time of span **/
};
-int compare_span(void* a, void* b)
+/** @brief Internal comparison function for two spans
+ *
+ * @param a a spanlist.
+ * @param b another spanlist.
+ *
+ * @return -1, 0, 1 depending on the comparison of the start times.
+ *
+ * Used to insert spans into the tree in sorted order.
+ */
+
+static 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 ;
@@ -49,20 +62,52 @@ int compare_span(void* a, void* b)
}
}
-icalcomponent* icalspanlist_get_inner(icalcomponent* comp)
+
+/** @brief callback function for collecting spanlists of a
+ * series of events.
+ *
+ * @param comp A valid icalcomponent.
+ * @param span The span to insert into data.
+ * @param data The actual spanlist to insert into
+ *
+ * This callback is used by icalcomponent_foreach_recurrence()
+ * to build up a spanlist.
+ */
+
+static void icalspanlist_new_callback(icalcomponent *comp,
+ struct icaltime_span *span,
+ void *data)
{
- if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
- return icalcomponent_get_first_real_component(comp);
- } else {
- return comp;
- }
+ icaltime_span *s;
+ icalspanlist *sl = (icalspanlist*) data;
+
+ if (span->is_busy == 0)
+ return;
+
+ if ((s=(icaltime_span *) malloc(sizeof(icaltime_span))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return;
+ }
+
+ /** copy span data into allocated memory.. **/
+ *s = *span;
+ pvl_insert_ordered(sl->spans, compare_span, (void*)s);
}
+
-void print_span(int c, struct icaltime_span span );
+/** @brief Make a free list from a set of VEVENT components.
+ *
+ * @param set A valid icalset containing VEVENTS
+ * @param start The free list starts at this date/time
+ * @param end The free list ends at this date/time
+ *
+ * @return A spanlist corresponding to the VEVENTS
+ *
+ * Given a set of components, a start time and an end time
+ * return a spanlist that contains the free/busy times.
+ */
-
-/* Make a free list from a set of component */
icalspanlist* icalspanlist_new(icalset *set,
struct icaltimetype start,
struct icaltimetype end)
@@ -71,7 +116,7 @@ icalspanlist* icalspanlist_new(icalset *set,
pvl_elem itr;
icalcomponent *c,*inner;
icalcomponent_kind kind, inner_kind;
- struct icalspanlist_impl *sl;
+ icalspanlist *sl;
struct icaltime_span *freetime;
if ( ( sl = (struct icalspanlist_impl*)
@@ -81,14 +126,12 @@ icalspanlist* icalspanlist_new(icalset *set,
}
sl->spans = pvl_newlist();
+ sl->start = start;
+ sl->end = end;
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 */
@@ -96,8 +139,6 @@ icalspanlist* icalspanlist_new(icalset *set,
c != 0;
c = icalset_get_next_component(set)){
- struct icaltime_span span;
-
kind = icalcomponent_isa(c);
inner = icalcomponent_get_inner(c);
@@ -113,31 +154,12 @@ icalspanlist* icalspanlist_new(icalset *set,
}
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);
-
- }
- }
+
+ icalcomponent_foreach_recurrence(c, start, end,
+ icalspanlist_new_callback,
+ (void*)sl);
+
+ }
/* 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
@@ -148,7 +170,7 @@ icalspanlist* icalspanlist_new(icalset *set,
itr != 0;
itr = pvl_next(itr))
{
- struct icaltime_span *s = (icalproperty*)pvl_data(itr);
+ struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
if ((freetime=(struct icaltime_span *)
malloc(sizeof(struct icaltime_span))) == 0){
@@ -178,7 +200,7 @@ icalspanlist* icalspanlist_new(icalset *set,
if( icaltime_is_null_time(end)){
struct icaltime_span* last_span;
- last_span = pvl_data(pvl_tail(sl->spans));
+ last_span = (struct icaltime_span*)pvl_data(pvl_tail(sl->spans));
if (last_span != 0){
@@ -197,35 +219,46 @@ icalspanlist* icalspanlist_new(icalset *set,
return sl;
-
}
+/** @brief Destructor.
+ * @param s A valid icalspanlist
+ *
+ * Free memory associated with the spanlist
+ */
+
void icalspanlist_free(icalspanlist* s)
{
struct icaltime_span *span;
- struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s;
-
- while( (span=pvl_pop(impl->spans)) != 0){
+
+ if (s == NULL)
+ return;
+
+ while( (span=pvl_pop(s->spans)) != 0){
free(span);
}
- pvl_free(impl->spans);
+ pvl_free(s->spans);
- impl->spans = 0;
+ s->spans = 0;
+
+ free(s);
}
-void icalspanlist_dump(icalspanlist* s){
+/** @brief (Debug) print out spanlist to stdout.
+ * @param sl A valid icalspanlist.
+ */
+void icalspanlist_dump(icalspanlist* sl){
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);
+ struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start));
printf(" end : %s",ctime(&s->end));
@@ -236,10 +269,19 @@ void icalspanlist_dump(icalspanlist* s){
icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
+
+/** @brief Find next free time span in a spanlist.
+ *
+ * @param sl The spanlist to search.
+ * @param t The time to start looking.
+ *
+ * Given a spanlist and a time, find the next period of time
+ * that is free
+ */
+
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;
@@ -249,22 +291,22 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
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);
+ itr = pvl_head(sl->spans);
+ s = (struct icaltime_span *)pvl_data(itr);
if (s == 0){
/* No elements in span */
return period;
}
+ /* Is the reference time before the first span? If so, assume
+ that the reference time is free */
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){
+ if (s->is_busy == 1){
period.end = icaltime_from_timet(s->start,0);
} else {
period.end = icaltime_from_timet(s->end,0);
@@ -275,12 +317,11 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
/* Otherwise, find the first free span that contains the
reference time. */
-
- for( itr = pvl_head(impl->spans);
+ for( itr = pvl_head(sl->spans);
itr != 0;
itr = pvl_next(itr))
{
- s = (icalproperty*)pvl_data(itr);
+ s = (struct icaltime_span *)pvl_data(itr);
if(s->is_busy == 0 && s->start >= rangett &&
( rangett < s->end || s->end == s->start)){
@@ -307,3 +348,220 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
struct icaltimetype t);
+
+/** @brief Returns an hour-by-hour array of free/busy times over a
+ * given period.
+ *
+ * @param sl A valid icalspanlist
+ * @param delta_t The time slice to divide by, in seconds. Default 3600.
+ *
+ * @return A pointer to an array of integers containing the number of
+ * busy events in each delta_t time period. The final entry
+ * contains the value -1.
+ *
+ * This calculation is somewhat tricky. This is due to the fact that
+ * the time range contains the start time, but does not contain the
+ * end time. To perform a proper calculation we subtract one second
+ * off the end times to get a true containing time.
+ *
+ * Also note that if you supplying a spanlist that does not start or
+ * end on a time boundary divisible by delta_t you may get results
+ * that are not quite what you expect.
+ */
+
+int* icalspanlist_as_freebusy_matrix(icalspanlist* sl, int delta_t) {
+ pvl_elem itr;
+ int spanduration_secs;
+ int *matrix;
+ int matrix_slots;
+ time_t sl_start, sl_end;
+
+ icalerror_check_arg_rz( (sl!=0), "spanlist");
+
+ if (!delta_t)
+ delta_t = 3600;
+
+ /** calculate the start and end time as time_t **/
+ sl_start = icaltime_as_timet_with_zone(sl->start, icaltimezone_get_utc_timezone());
+ sl_end = icaltime_as_timet_with_zone(sl->end, icaltimezone_get_utc_timezone());
+
+
+ /** insure that the time period falls on a time boundary divisable
+ by delta_t */
+
+ sl_start /= delta_t;
+ sl_start *= delta_t;
+
+ sl_end /= delta_t;
+ sl_end *= delta_t;
+
+
+ /** find the duration of this spanlist **/
+ spanduration_secs = sl_end - sl_start;
+
+
+ /** malloc our matrix, add one extra slot for a final -1 **/
+ matrix_slots = spanduration_secs/delta_t + 1;
+
+ matrix = (int*) malloc(sizeof(int) * matrix_slots);
+ if (matrix == NULL) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return NULL;
+ }
+ memset(matrix, 0, sizeof(int) * matrix_slots);
+ matrix[matrix_slots-1] = -1;
+
+ /* loop through each span and mark the slots in the array */
+
+ for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
+ struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
+
+ if (s->is_busy == 1) {
+ int offset_start = s->start/delta_t - sl_start/delta_t;
+ int offset_end = (s->end - 1) /delta_t - sl_start/delta_t + 1;
+ int i;
+
+ if (offset_end >= matrix_slots)
+ offset_end = matrix_slots - 1;
+
+ i = offset_start;
+ for (i=offset_start; i < offset_end; i++) {
+ matrix[i]++;
+ }
+ }
+ }
+ return matrix;
+}
+
+
+/** @brief Return a VFREEBUSY component for the corresponding spanlist
+ *
+ * @param sl A valid icalspanlist, from icalspanlist_new()
+ * @param organizer The organizer specified as MAILTO:user@domain
+ * @param attendee The attendee specified as MAILTO:user@domain
+ *
+ * @return A valid icalcomponent or NULL.
+ *
+ * This function returns a VFREEBUSY component for the given spanlist.
+ * The start time is mapped to DTSTART, the end time to DTEND.
+ * Each busy span is represented as a separate FREEBUSY entry.
+ * An attendee parameter is required, and organizer parameter is
+ * optional.
+ */
+
+icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* sl,
+ const char* organizer,
+ const char* attendee) {
+ icalcomponent *comp;
+ icalproperty *p;
+ struct icaltimetype atime = icaltime_from_timet( time(0),0);
+ pvl_elem itr;
+ icaltimezone *utc_zone;
+ icalparameter *param;
+
+ if (!attendee) {
+ icalerror_set_errno(ICAL_USAGE_ERROR);
+ return 0;
+ }
+
+ utc_zone = icaltimezone_get_utc_timezone ();
+
+ comp = icalcomponent_new_vfreebusy();
+
+ icalcomponent_add_property(comp, icalproperty_new_dtstart(sl->start));
+ icalcomponent_add_property(comp, icalproperty_new_dtend(sl->end));
+ icalcomponent_add_property(comp, icalproperty_new_dtstamp(atime));
+
+ if (organizer) {
+ icalcomponent_add_property(comp, icalproperty_new_organizer(organizer));
+ }
+ icalcomponent_add_property(comp, icalproperty_new_attendee(attendee));
+
+ /* now add the freebusy sections.. */
+
+ for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
+ struct icalperiodtype period;
+ struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
+
+ if (s->is_busy == 1) {
+
+ period.start = icaltime_from_timet_with_zone (s->start, 0, utc_zone);
+ period.end = icaltime_from_timet_with_zone (s->end, 0, utc_zone);
+ period.duration = icaldurationtype_null_duration();
+
+
+ p = icalproperty_new_freebusy(period);
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSY);
+ icalproperty_add_parameter(p, param);
+
+ icalcomponent_add_property(comp, p);
+ }
+
+ }
+
+ return comp;
+}
+
+
+/** @brief Return a spanlist corresponding to the VFREEBUSY portion of
+ * an icalcomponent.
+ *
+ * @param c A valid icalcomponent.
+ *
+ * @return A valid icalspanlist or NULL if no VFREEBUSY section.
+ *
+ */
+
+
+icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* comp)
+{
+ icalcomponent *inner;
+ icalproperty *prop;
+ icalspanlist *sl;
+
+ icalerror_check_arg_rz((comp != NULL), "comp");
+
+ inner = icalcomponent_get_inner(comp);
+ if (!inner) return NULL;
+
+ if ( ( sl = (icalspanlist*) malloc(sizeof(icalspanlist))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+ sl->spans = pvl_newlist();
+
+ /* cycle through each FREEBUSY property, adding to the spanlist */
+ for (prop = icalcomponent_get_first_property(inner, ICAL_FREEBUSY_PROPERTY);
+ prop != NULL;
+ prop = icalcomponent_get_next_property(inner, ICAL_FREEBUSY_PROPERTY)) {
+ icaltime_span *s = (icaltime_span *) malloc(sizeof(icaltime_span));
+ icalparameter *param;
+ struct icalperiodtype period;
+ icalparameter_fbtype fbtype;
+
+ if (s == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ param = icalproperty_get_first_parameter(prop, ICAL_FBTYPE_PARAMETER);
+ fbtype = (param) ? icalparameter_get_fbtype(param) : ICAL_FBTYPE_BUSY;
+
+ switch (fbtype) {
+ case ICAL_FBTYPE_FREE:
+ case ICAL_FBTYPE_NONE:
+ case ICAL_FBTYPE_X:
+ s->is_busy = 1;
+ default:
+ s->is_busy = 0;
+ }
+
+ period = icalproperty_get_freebusy(prop);
+ s->start = icaltime_as_timet_with_zone(period.start, icaltimezone_get_utc_timezone());
+ s->end = icaltime_as_timet_with_zone(period.end, icaltimezone_get_utc_timezone());
+;
+ pvl_insert_ordered(sl->spans, compare_span, (void*)s);
+ }
+ /** @todo calculate start/end limits.. fill in holes? **/
+ return sl;
+}
diff --git a/libical/src/libicalss/icalspanlist.h b/libical/src/libicalss/icalspanlist.h
index 83cb1c8..91f0acb 100644
--- a/libical/src/libicalss/icalspanlist.h
+++ b/libical/src/libicalss/icalspanlist.h
@@ -28,26 +28,49 @@
#include "ical.h"
#include "icalset.h"
-typedef void icalspanlist;
+/** @file icalspanlist.h
+ * @brief Code that supports collections of free/busy spans of time
+ */
+
+typedef struct icalspanlist_impl icalspanlist;
+
+
+/** @brief Constructor
+ * Make a free list from a set of component. Start and end should be in UTC
+ */
-/* 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);
+/** @brief Destructor
+ */
void icalspanlist_free(icalspanlist* spl);
+/* Unimplemented functions */
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 */
+/** Get first next free time after time t. all times are in UTC. */
struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
struct icaltimetype t);
+/** Get first next busy time after time t. all times are in UTC. */
struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
struct icaltimetype t);
void icalspanlist_dump(icalspanlist* s);
+/** @brief Return a valid VFREEBUSY component for this span */
+icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
+ const char* organizer,
+ const char* attendee);
+
+/** @brief Return an integer matrix of total events per delta_t timespan */
+int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
+
+/** @brief Construct an icalspanlist from a VFREEBUSY component */
+icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
+
#endif
diff --git a/libical/src/libicalss/icalss.h b/libical/src/libicalss/icalss.h
index cd07919..8930e11 100644
--- a/libical/src/libicalss/icalss.h
+++ b/libical/src/libicalss/icalss.h
@@ -1,11 +1,15 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ $Id$
+*/
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalgauge.h
CREATOR: eric 23 December 1999
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -29,42 +33,52 @@
#ifndef ICALGAUGE_H
#define ICALGAUGE_H
-typedef void icalgauge;
+/** @file icalgauge.h
+ * @brief Routines implementing a filter for ical components
+ */
-icalgauge* icalgauge_new_from_sql(char* sql);
+typedef struct icalgauge_impl icalgauge;
+
+icalgauge* icalgauge_new_from_sql(char* sql, int expand);
+
+int icalgauge_get_expand(icalgauge* gauge);
void icalgauge_free(icalgauge* gauge);
char* icalgauge_as_sql(icalcomponent* gauge);
-void icalgauge_dump(icalcomponent* gauge);
+void icalgauge_dump(icalgauge* 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 */
+/** @brief Return true if 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 */
+/** Clone the component, but only return the properties
+ * specified in the gauge */
icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
#endif /* ICALGAUGE_H*/
/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalset.h
- CREATOR: eric 28 November 1999
-
+/**
+ @file icalset.h
+ @author 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
+ icalfileset Store components in a single file
icaldirset Store components in multiple files in a directory
+ icalbdbset Store components in a Berkeley DB File
icalheapset Store components on the heap
icalmysqlset Store components in a mysql database.
+**/
- $Id$
- $Locker$
+/*
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -97,37 +111,86 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
#endif
-#ifdef _WIN32
-#define mode_t int
-#endif
-
-
-
-typedef void icalset;
+typedef struct icalset_impl icalset;
typedef enum icalset_kind {
ICAL_FILE_SET,
ICAL_DIR_SET,
- ICAL_HEAP_SET,
- ICAL_MYSQL_SET,
- ICAL_CAP_SET
+ ICAL_BDB_SET
} icalset_kind;
+typedef struct icalsetiter
+{
+ icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
+ icalgauge* gauge;
+ icalrecur_iterator* ritr; /*the last iterator*/
+ icalcomponent* last_component; /*the pending recurring component to be processed */
+ const char* tzid; /* the calendar's timezone id */
+} icalsetiter;
+
+struct icalset_impl {
+ icalset_kind kind;
+ int size;
+ char *dsn;
+ icalset* (*init)(icalset* set, const char *dsn, void *options);
+ 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, icalgauge* 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 *newc);
+ icalcomponent* (*get_current_component)(icalset* set);
+ icalcomponent* (*get_first_component)(icalset* set);
+ icalcomponent* (*get_next_component)(icalset* set);
+ icalsetiter (*icalset_begin_component)(icalset* set,
+ icalcomponent_kind kind, icalgauge* gauge);
+ icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
+ icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
+};
+
+/** @brief Register a new derived class */
+int icalset_register_class(icalset *set);
+
+
+/** @brief Generic icalset constructor
+ *
+ * @param kind The type of icalset to create
+ * @param dsn Data Source Name - usually a pathname or DB handle
+ * @param options Any implementation specific options
+ *
+ * @return A valid icalset reference or NULL if error.
+ *
+ * This creates any of the icalset types available.
+ */
+
+icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
-/* Create a specific derived type of set */
icalset* icalset_new_file(const char* path);
+icalset* icalset_new_file_reader(const char* path);
+icalset* icalset_new_file_writer(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);*/
+icalset* icalset_new_file_reader(const char* path);
+icalset* icalset_new_file_writer(const char* path);
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*/
+/** Mark the cluster as changed, so it will be written to disk when it
+ is freed. **/
void icalset_mark(icalset* set);
+
+/** Write changes to disk immediately */
icalerrorenum icalset_commit(icalset* set);
icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -136,40 +199,113 @@ 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);
+/** Restrict the component returned by icalset_first, _next to those
+ that pass the gauge. */
+icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
+
+/** Clears the gauge defined by icalset_select() */
void icalset_clear_select(icalset* set);
-/* Get a component by uid */
+/** 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
+/** 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
+/** 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);
+/** External Iterator with gauge - for thread safety */
+extern icalsetiter icalsetiter_null;
+
+icalsetiter icalset_begin_component(icalset* set,
+ icalcomponent_kind kind, icalgauge* gauge);
+
+/** Default _next, _prior, _deref for subclasses that use single cluster */
+icalcomponent* icalsetiter_next(icalsetiter* i);
+icalcomponent* icalsetiter_prior(icalsetiter* i);
+icalcomponent* icalsetiter_deref(icalsetiter* i);
+
+/** for subclasses that use multiple clusters that require specialized cluster traversal */
+icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
+icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
+
#endif /* !ICALSET_H */
/* -*- Mode: C -*- */
/*======================================================================
+ FILE: icalcluster.h
+ CREATOR: eric 23 December 1999
+
+
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of either:
+
+ The LGPL as published by the Free Software Foundation, version
+ 2.1, available at: http://www.fsf.org/copyleft/lesser.html
+
+ Or:
+
+ The Mozilla Public License Version 1.0. You may obtain a copy of
+ the License at http://www.mozilla.org/MPL/
+
+ The Original Code is eric. The Initial Developer of the Original
+ Code is Eric Busboom
+
+
+======================================================================*/
+
+#ifndef ICALCLUSTER_H
+#define ICALCLUSTER_H
+
+
+typedef struct icalcluster_impl icalcluster;
+
+icalcluster* icalcluster_new(const char *key, icalcomponent *data);
+icalcluster* icalcluster_new_clone(const icalcluster *cluster);
+
+void icalcluster_free(icalcluster *cluster);
+
+const char* icalcluster_key(icalcluster *cluster);
+int icalcluster_is_changed(icalcluster *cluster);
+void icalcluster_mark(icalcluster *cluster);
+void icalcluster_commit(icalcluster *cluster);
+
+icalcomponent* icalcluster_get_component(icalcluster* cluster);
+int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
+icalerrorenum icalcluster_add_component(icalcluster* cluster,
+ icalcomponent* child);
+icalerrorenum icalcluster_remove_component(icalcluster* cluster,
+ icalcomponent* child);
+
+icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
+icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
+icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
+
+#endif /* !ICALCLUSTER_H */
+
+
+
+/* -*- Mode: C -*- */
+/*======================================================================
FILE: icalfileset.h
CREATOR: eric 23 December 1999
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -197,68 +333,96 @@ icalcomponent* icalset_get_next_component(icalset* set);
#include <sys/stat.h> /* For open() flags and mode */
#include <fcntl.h> /* For open() flags and mode */
-extern int icalfileset_safe_saves;
+#ifdef WIN32
+#define mode_t int
+#endif
-typedef void icalfileset;
+extern int icalfileset_safe_saves;
+typedef struct icalfileset_impl icalfileset;
-/* icalfileset
- icalfilesetfile
- icalfilesetdir
-*/
+icalset* icalfileset_new(const char* path);
+icalset* icalfileset_new_reader(const char* path);
+icalset* icalfileset_new_writer(const char* path);
+icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
-icalfileset* icalfileset_new(const char* path);
+icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
-/* Like _new, but takes open() flags for opening the file */
-icalfileset* icalfileset_new_open(const char* path,
- int flags, mode_t mode);
+icalcluster* icalfileset_produce_icalcluster(const char *path);
-void icalfileset_free(icalfileset* cluster);
+void icalfileset_free(icalset* cluster);
-const char* icalfileset_path(icalfileset* cluster);
+const char* icalfileset_path(icalset* 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);
+void icalfileset_mark(icalset* set);
+icalerrorenum icalfileset_commit(icalset* set);
-icalerrorenum icalfileset_add_component(icalfileset* cluster,
+icalerrorenum icalfileset_add_component(icalset* set,
icalcomponent* child);
-icalerrorenum icalfileset_remove_component(icalfileset* cluster,
+icalerrorenum icalfileset_remove_component(icalset* set,
icalcomponent* child);
-int icalfileset_count_components(icalfileset* cluster,
+int icalfileset_count_components(icalset* set,
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);
+/**
+ * Restrict the component returned by icalfileset_first, _next to those
+ * that pass the gauge. _clear removes the gauge
+ */
+icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
-/* 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);
+/** clear the gauge **/
+void icalfileset_clear(icalset* set);
+/** Get and search for a component by uid **/
+icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
+int icalfileset_has_uid(icalset* set, const char* uid);
+icalcomponent* icalfileset_fetch_match(icalset* 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,
+
+/**
+ * Modify components according to the MODIFY method of CAP. Works on the
+ * currently selected components.
+ */
+icalerrorenum icalfileset_modify(icalset* set,
+ icalcomponent *oldcomp,
icalcomponent *newcomp);
-/* Iterate through components. If a guage has been defined, these
+/* Iterate through components. If a gauge 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
+icalcomponent* icalfileset_get_current_component (icalset* cluster);
+icalcomponent* icalfileset_get_first_component(icalset* cluster);
+icalcomponent* icalfileset_get_next_component(icalset* cluster);
+
+/* External iterator for thread safety */
+icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
+icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
+icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
+
+/** Return a reference to the internal component. You probably should
not be using this. */
-icalcomponent* icalfileset_get_component(icalfileset* cluster);
+icalcomponent* icalfileset_get_component(icalset* cluster);
+
+/**
+ * @brief options for opening an icalfileset.
+ *
+ * These options should be passed to the icalset_new() function
+ */
+typedef struct icalfileset_options {
+ int flags; /**< flags for open() O_RDONLY, etc */
+ mode_t mode; /**< file mode */
+ int safe_saves; /**< to lock or not */
+ icalcluster *cluster; /**< use this cluster to initialize data */
+} icalfileset_options;
+
+extern icalfileset_options icalfileset_options_default;
#endif /* !ICALFILESET_H */
@@ -270,8 +434,6 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
CREATOR: eric 28 November 1999
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -299,47 +461,60 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
/* icaldirset Routines for storing, fetching, and searching for ical
* objects in a database */
-typedef void icaldirset;
+typedef struct icaldirset_impl icaldirset;
+icalset* icaldirset_new(const char* path);
-icaldirset* icaldirset_new(const char* path);
+icalset* icaldirset_new_reader(const char* path);
+icalset* icaldirset_new_writer(const char* path);
-void icaldirset_free(icaldirset* store);
-const char* icaldirset_path(icaldirset* store);
+icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
+void icaldirset_free(icalset* set);
+
+const char* icaldirset_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 icaldirset_mark(icaldirset* store);
-icalerrorenum icaldirset_commit(icaldirset* store);
+void icaldirset_mark(icalset* set);
+icalerrorenum icaldirset_commit(icalset* set);
-icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp);
-icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp);
+icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
+icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
-int icaldirset_count_components(icaldirset* store,
+int icaldirset_count_components(icalset* 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);
+icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
+void icaldirset_clear(icalset* 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);
+icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
+int icaldirset_has_uid(icalset* store, const char* uid);
+icalcomponent* icaldirset_fetch_match(icalset* 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,
+icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
icalcomponent *newc);
-/* Iterate through the components. If a guage has been defined, these
+/* Iterate through the components. If a gauge 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);
+icalcomponent* icaldirset_get_current_component(icalset* store);
+icalcomponent* icaldirset_get_first_component(icalset* store);
+icalcomponent* icaldirset_get_next_component(icalset* store);
+
+/* External iterator for thread safety */
+icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
+icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
+icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
+
+typedef struct icaldirset_options {
+ int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
+} icaldirset_options;
#endif /* !ICALDIRSET_H */
@@ -351,8 +526,6 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
CREATOR: eric 23 December 1999
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -383,7 +556,7 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
* components. It also has interfaces to access the free/busy list
* and a list of calendar properties */
-typedef void icalcalendar;
+typedef struct icalcalendar_impl icalcalendar;
icalcalendar* icalcalendar_new(char* dir);
@@ -416,8 +589,6 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
CREATOR: eric 21 Aug 2000
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -439,44 +610,12 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
#define ICALCLASSIFY_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_DELEGATE_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,
+icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
const char* user);
icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
-char* icalclassify_class_to_string(ical_class iclass);
+char* icalclassify_class_to_string(icalproperty_xlicclass c);
#endif /* ICALCLASSIFY_H*/
@@ -491,8 +630,6 @@ char* icalclassify_class_to_string(ical_class iclass);
CREATOR: eric 21 Aug 2000
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -513,26 +650,49 @@ char* icalclassify_class_to_string(ical_class iclass);
#define ICALSPANLIST_H
-typedef void icalspanlist;
+/** @file icalspanlist.h
+ * @brief Code that supports collections of free/busy spans of time
+ */
+
+typedef struct icalspanlist_impl icalspanlist;
+
+
+/** @brief Constructor
+ * Make a free list from a set of component. Start and end should be in UTC
+ */
-/* 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);
+/** @brief Destructor
+ */
void icalspanlist_free(icalspanlist* spl);
+/* Unimplemented functions */
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 */
+/** Get first next free time after time t. all times are in UTC. */
struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
struct icaltimetype t);
+/** Get first next busy time after time t. all times are in UTC. */
struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
struct icaltimetype t);
void icalspanlist_dump(icalspanlist* s);
+/** @brief Return a valid VFREEBUSY component for this span */
+icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
+ const char* organizer,
+ const char* attendee);
+
+/** @brief Return an integer matrix of total events per delta_t timespan */
+int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
+
+/** @brief Construct an icalspanlist from a VFREEBUSY component */
+icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
+
#endif
@@ -543,8 +703,6 @@ void icalspanlist_dump(icalspanlist* s);
CREATOR: eric 07 Nov 2000
- $Id$
- $Locker$
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -607,279 +765,6 @@ icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
#endif /* ICALMESSAGE_H*/
-/* -*- 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
-
-
-
-/* Connection state, from the state machine in RFC2445 */
-enum cstps_state {
- NO_STATE,
- CONNECTED,
- AUTHENTICATED,
- IDENTIFIED,
- DISCONNECTED,
- RECEIVE
-};
-
-/* CSTP Commands that a client can issue to a server */
-typedef enum icalcstp_command {
- ICAL_ABORT_COMMAND,
- ICAL_AUTHENTICATE_COMMAND,
- ICAL_CAPABILITY_COMMAND,
- ICAL_CONTINUE_COMMAND,
- ICAL_CALIDEXPAND_COMMAND,
- ICAL_IDENTIFY_COMMAND,
- ICAL_DISCONNECT_COMMAND,
- ICAL_SENDDATA_COMMAND,
- ICAL_STARTTLS_COMMAND,
- ICAL_UPNEXPAND_COMMAND,
- ICAL_COMPLETE_COMMAND,
- ICAL_UNKNOWN_COMMAND
-} icalcstp_command;
-
-
-
-/* A statement is a combination of command or response code and a
- component that the server and client exchage with each other. */
-struct icalcstp_statement {
- icalcstp_command command;
- char* str_data; /* If non-NUll use as arguments to command */
- int int_data; /* If non-NULL use as arguments to command */
-
- icalrequeststatus code;
-
- icalcomponent* data;
+#ifdef __cplusplus
};
-
-const char* icalcstp_command_to_string(icalcstp_command command);
-icalcstp_command icalcstp_string_to_command(const char* str);
-
-#endif /* !ICALCSTP_H */
-
-
-
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcstpclient.h
- CREATOR: eric 4 Feb 01
-
- $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 ICALCSTPC_H
-#define ICALCSTPC_H
-
-
-/********************** 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;
-
-
-icalcstpc* 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, char* line);
-
-/* process the next string from the server */
-int icalcstpc_next_input(icalcstpc* cstp, char * line);
-
-/* 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 /* !ICALCSTPC_H */
-
-
-
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcstpserver.h
- CREATOR: eric 13 Feb 01
-
- $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 ICALCSTPS_H
-#define ICALCSTPS_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 and 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;
-
-/* 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_commandfp {
- 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_commandfp 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);
-
-#endif /* ICALCSTPS */
+#endif
diff --git a/libical/src/libicalss/icalsslexer.c b/libical/src/libicalss/icalsslexer.c
index e10bcd3..28d1b66 100644
--- a/libical/src/libicalss/icalsslexer.c
+++ b/libical/src/libicalss/icalsslexer.c
@@ -1,3 +1,12 @@
+#define YY_REENTRANT 1
+#define YY_TEXT_IS_ARRAY
+#define YY_REENTRANT_BISON_PURE 1
+#ifndef YY_REENTRANT
+#define yytext sstext
+#define yyleng ssleng
+#define yyin ssin
+#define yyout ssout
+#endif
#define yy_create_buffer ss_create_buffer
#define yy_delete_buffer ss_delete_buffer
#define yy_scan_buffer ss_scan_buffer
@@ -8,46 +17,50 @@
#define yy_flush_buffer ss_flush_buffer
#define yy_load_buffer_state ss_load_buffer_state
#define yy_switch_to_buffer ss_switch_to_buffer
-#define yyin ssin
-#define yyleng ssleng
#define yylex sslex
-#define yyout ssout
#define yyrestart ssrestart
-#define yytext sstext
+#define yylex_init sslex_init
+#define yylex_destroy sslex_destroy
+#define yyget_extra ssget_extra
+#define yyset_extra ssset_extra
+#define yyget_in ssget_in
+#define yyset_in ssset_in
+#define yyget_out ssget_out
+#define yyset_out ssset_out
+#define yyget_leng ssget_leng
+#define yyget_text ssget_text
+#define yyget_lineno ssget_lineno
+#define yyset_lineno ssset_lineno
+#ifdef YY_REENTRANT_BISON_PURE
+#define yyget_lval ssget_lval
+#define yyset_lval ssset_lval
+#ifdef YYLTYPE
+#define yyget_lloc ssget_lloc
+#define yyset_lloc ssset_lloc
+#endif
+#endif
#define yywrap sswrap
+/* -*-C-*- */
/* A lexical scanner generated by flex */
-/* Scanner skeleton version:
- * $Header$
- */
-
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
+/* %- */
+/* begin standard C headers. */
#include <stdio.h>
-// Eugen C. <eug@thekompany.com>
-#include <defines.h>
-#ifndef _QTWIN_
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-// Eugen C. <eug@thekompany.com>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
+#include <errno.h>
+#include <stdlib.h>
+/* end standard C headers. */
+/* %+ */
+/* %* */
#ifdef __cplusplus
-#include <stdlib.h>
+/* %+ */
+/* %* */
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
@@ -65,15 +78,6 @@
#endif /* __STDC__ */
#endif /* ! __cplusplus */
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
#ifdef YY_USE_CONST
#define yyconst const
#else
@@ -97,34 +101,94 @@
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+#ifdef YY_REENTRANT
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For use wherever a Global is accessed or assigned. */
+#define YY_G(var) (((struct yy_globals_t*)yy_globals)->var)
+
+/* For use in function prototypes to append the additional argument. */
+#ifdef YY_USE_PROTOS
+#define YY_LAST_ARG , yyscan_t yy_globals
+#define YY_ONLY_ARG yyscan_t yy_globals
+#else
+#define YY_LAST_ARG , yy_globals
+#define YY_ONLY_ARG yy_globals
+#define YY_DECL_LAST_ARG yyscan_t yy_globals;
+#endif
+
+/* For use in function calls to pass the additional argument. */
+#define YY_CALL_LAST_ARG , yy_globals
+#define YY_CALL_ONLY_ARG yy_globals
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin YY_G(yyin_r)
+#define yyout YY_G(yyout_r)
+#define yyextra YY_G(yyextra_r)
+#define yyleng YY_G(yyleng_r)
+#define yytext YY_G(yytext_r)
+#define yylineno YY_G(yylineno_r)
+
+int yylex_init YY_PROTO((yyscan_t* scanner));
+int yylex_destroy YY_PROTO((yyscan_t scanner));
+
+#else /* not YY_REENTRANT */
+
+ /* Define these macros to be no-ops. */
+#define YY_G(var) (var)
+#define YY_LAST_ARG
+#define YY_ONLY_ARG void
+#define YY_CALL_LAST_ARG
+#define YY_CALL_ONLY_ARG
+#define YY_DECL_LAST_ARG
+#endif
+
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
-#define BEGIN yy_start = 1 + 2 *
+#define BEGIN YY_G(yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
-#define YY_START ((yy_start - 1) / 2)
+#define YY_START ((YY_G(yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
+#define YY_NEW_FILE yyrestart( yyin YY_CALL_LAST_ARG )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#define YY_BUF_SIZE 16384
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#ifndef YY_REENTRANT
+extern size_t yyleng;
+#endif
-extern int yyleng;
+/* %- */
+#ifndef YY_REENTRANT
extern FILE *yyin, *yyout;
+#endif
+/* %* */
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
@@ -150,25 +214,33 @@ extern FILE *yyin, *yyout;
do \
{ \
/* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
+ *yy_cp = YY_G(yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ YY_G(yy_c_buf_p) = yy_cp = yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-#define unput(c) yyunput( c, yytext_ptr )
+#define unput(c) yyunput( c, YY_G(yytext_ptr) YY_CALL_LAST_ARG )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
*/
-typedef unsigned int yy_size_t;
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
+/* %- */
FILE *yy_input_file;
+/* %+ */
+/* %* */
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
@@ -222,8 +294,17 @@ struct yy_buffer_state
*/
#define YY_BUFFER_EOF_PENDING 2
};
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+/* %- Standard (non-C++) definition */
+/* %c */
+#ifndef ssIN_HEADER
+#ifndef YY_REENTRANT
static YY_BUFFER_STATE yy_current_buffer = 0;
+#endif
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %* */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
@@ -232,13 +313,18 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
#define YY_CURRENT_BUFFER yy_current_buffer
+/* %- Standard (non-C++) definition */
+
+#ifndef YY_REENTRANT
+/* %c */
+#ifndef ssIN_HEADER
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int yyleng;
+size_t yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@@ -249,76 +335,111 @@ static int yy_start = 0; /* start state number */
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
+/* %e */
+#endif /* !ssIN_HEADER */
+#endif /* end !YY_REENTRANT */
+
+void yyrestart YY_PROTO(( FILE *input_file YY_LAST_ARG ));
+
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer YY_LAST_ARG ));
+void yy_load_buffer_state YY_PROTO(( YY_ONLY_ARG ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size YY_LAST_ARG ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
-void yyrestart YY_PROTO(( FILE *input_file ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG)
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size YY_LAST_ARG ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str YY_LAST_ARG ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len YY_LAST_ARG ));
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+/* %* */
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
+/* %c */
+#ifndef ssIN_HEADER
+static void *yy_flex_alloc YY_PROTO(( yy_size_t YY_LAST_ARG ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t YY_LAST_ARG ));
+static void yy_flex_free YY_PROTO(( void * YY_LAST_ARG ));
+/* %e */
+#endif /* !ssIN_HEADER */
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
+ if ( ! YY_G(yy_current_buffer) ) \
+ YY_G(yy_current_buffer) = \
+ yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ YY_G(yy_current_buffer)->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
+ if ( ! YY_G(yy_current_buffer) ) \
+ YY_G(yy_current_buffer) = \
+ yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ YY_G(yy_current_buffer)->yy_at_bol = at_bol; \
}
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+#define YY_AT_BOL() (YY_G(yy_current_buffer)->yy_at_bol)
+/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
+/* Begin user sect3 */
+#ifndef ssIN_HEADER
typedef unsigned char YY_CHAR;
+#endif /* !ssIN_HEADER */
+#ifndef ssIN_HEADER
+#ifndef YY_REENTRANT
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+#endif
+#endif /* !ssIN_HEADER */
+#ifndef ssIN_HEADER
typedef int yy_state_type;
-extern char yytext[];
-
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
+#endif /* !ssIN_HEADER */
+
+/* %- Standard (non-C++) definition */
+/* %c */
+#ifndef ssIN_HEADER
+static yy_state_type yy_get_previous_state YY_PROTO(( YY_ONLY_ARG ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state YY_LAST_ARG));
+static int yy_get_next_buffer YY_PROTO(( YY_ONLY_ARG ));
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %* */
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
+ YY_G(yytext_ptr) = yy_bp; \
+/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ YY_G(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
+/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
if ( yyleng >= YYLMAX ) \
YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
- yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \
- yy_c_buf_p = yy_cp;
+ yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \
+ YY_G(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 19
-#define YY_END_OF_BUFFER 20
-static yyconst short int yy_accept[47] =
+/* %* */
+
+/* %c */
+#ifndef ssIN_HEADER
+/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
+#define YY_NUM_RULES 23
+#define YY_END_OF_BUFFER 24
+static yyconst short int yy_accept[56] =
{ 0,
- 0, 0, 0, 0, 0, 0, 20, 18, 14, 14,
- 18, 13, 17, 4, 15, 7, 5, 8, 17, 17,
- 17, 17, 17, 14, 6, 0, 17, 9, 10, 17,
- 17, 12, 17, 17, 16, 11, 17, 17, 17, 2,
- 17, 17, 17, 3, 1, 0
+ 0, 0, 0, 0, 0, 0, 24, 22, 18, 18,
+ 22, 17, 21, 4, 19, 8, 5, 9, 21, 21,
+ 21, 21, 21, 21, 21, 18, 7, 0, 21, 10,
+ 6, 11, 21, 21, 14, 21, 21, 13, 21, 21,
+ 20, 12, 21, 15, 21, 21, 21, 2, 16, 21,
+ 21, 21, 3, 1, 0
} ;
static yyconst int yy_ec[256] =
@@ -326,17 +447,17 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 1, 1, 1, 1, 1, 5, 1,
- 1, 6, 1, 7, 6, 6, 1, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 1, 8, 9,
- 10, 11, 1, 1, 12, 6, 13, 14, 15, 16,
- 6, 17, 6, 6, 6, 18, 19, 20, 21, 6,
- 6, 22, 23, 24, 6, 6, 25, 6, 6, 6,
- 1, 1, 1, 1, 1, 1, 12, 6, 13, 14,
-
- 15, 16, 6, 17, 6, 6, 6, 18, 19, 20,
- 21, 6, 6, 22, 23, 24, 6, 6, 25, 6,
- 6, 6, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 4, 5, 1, 1, 1, 1, 1, 6, 1,
+ 1, 7, 1, 8, 7, 7, 1, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 9, 10, 11,
+ 12, 13, 1, 7, 14, 7, 15, 16, 17, 18,
+ 7, 19, 20, 7, 7, 21, 22, 23, 24, 7,
+ 7, 25, 26, 27, 28, 7, 29, 7, 7, 7,
+ 1, 1, 1, 1, 1, 1, 14, 7, 15, 16,
+
+ 17, 18, 7, 19, 20, 7, 7, 21, 22, 23,
+ 24, 7, 7, 25, 26, 27, 28, 7, 29, 7,
+ 7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -353,57 +474,62 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst int yy_meta[26] =
+static yyconst int yy_meta[30] =
{ 0,
- 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2
+ 1, 1, 1, 2, 1, 1, 3, 1, 2, 1,
+ 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3
} ;
-static yyconst short int yy_base[49] =
+static yyconst short int yy_base[58] =
{ 0,
- 0, 0, 0, 0, 0, 0, 53, 54, 24, 26,
- 42, 0, 0, 54, 54, 41, 54, 40, 29, 26,
- 25, 31, 28, 28, 54, 39, 0, 54, 54, 29,
- 21, 0, 23, 25, 54, 0, 20, 23, 15, 0,
- 23, 20, 10, 0, 0, 54, 31, 30
+ 0, 0, 0, 0, 0, 0, 68, 69, 28, 31,
+ 55, 0, 0, 69, 69, 54, 53, 52, 40, 37,
+ 35, 12, 35, 42, 39, 35, 69, 51, 0, 69,
+ 69, 69, 40, 31, 0, 27, 32, 0, 31, 34,
+ 69, 0, 28, 0, 28, 31, 22, 0, 0, 31,
+ 28, 17, 0, 0, 69, 39, 40
} ;
-static yyconst short int yy_def[49] =
+static yyconst short int yy_def[58] =
{ 0,
- 46, 1, 1, 1, 1, 1, 46, 46, 46, 46,
- 46, 47, 48, 46, 46, 46, 46, 46, 48, 48,
- 48, 48, 48, 46, 46, 47, 48, 46, 46, 48,
- 48, 48, 48, 48, 46, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 0, 46, 46
+ 55, 1, 1, 1, 1, 1, 55, 55, 55, 55,
+ 55, 56, 57, 55, 55, 55, 55, 55, 57, 57,
+ 57, 57, 57, 57, 57, 55, 55, 56, 57, 55,
+ 55, 55, 57, 57, 57, 57, 57, 57, 57, 57,
+ 55, 57, 57, 57, 57, 57, 57, 57, 57, 57,
+ 57, 57, 57, 57, 0, 55, 55
} ;
-static yyconst short int yy_nxt[80] =
+static yyconst short int yy_nxt[99] =
{ 0,
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 13, 13, 13, 20, 13, 13, 13, 13,
- 21, 13, 22, 13, 23, 24, 24, 24, 24, 24,
- 24, 27, 26, 45, 44, 43, 42, 41, 40, 39,
- 38, 37, 36, 35, 34, 33, 32, 31, 30, 29,
- 28, 25, 46, 7, 46, 46, 46, 46, 46, 46,
- 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
- 46, 46, 46, 46, 46, 46, 46, 46, 46
+ 8, 9, 10, 9, 11, 12, 13, 14, 8, 15,
+ 16, 17, 18, 19, 13, 13, 13, 20, 13, 21,
+ 13, 13, 22, 23, 13, 24, 13, 13, 25, 26,
+ 26, 26, 26, 26, 26, 36, 26, 26, 26, 37,
+ 28, 28, 29, 54, 53, 52, 51, 50, 49, 48,
+ 47, 46, 45, 44, 43, 42, 41, 40, 39, 38,
+ 35, 34, 33, 32, 31, 30, 27, 55, 7, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55
+
} ;
-static yyconst short int yy_chk[80] =
+static yyconst short int yy_chk[99] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 9, 9, 10, 10, 24,
- 24, 48, 47, 43, 42, 41, 39, 38, 37, 34,
- 33, 31, 30, 26, 23, 22, 21, 20, 19, 18,
- 16, 11, 7, 46, 46, 46, 46, 46, 46, 46,
- 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
- 46, 46, 46, 46, 46, 46, 46, 46, 46
- } ;
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 9,
+ 9, 9, 10, 10, 10, 22, 26, 26, 26, 22,
+ 56, 56, 57, 52, 51, 50, 47, 46, 45, 43,
+ 40, 39, 37, 36, 34, 33, 28, 25, 24, 23,
+ 21, 20, 19, 18, 17, 16, 11, 7, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
+ } ;
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@@ -416,8 +542,10 @@ static char *yy_last_accepting_cpos;
#define YYLMAX 8192
#endif
+#ifndef YY_REENTRANT
char yytext[YYLMAX];
char *yytext_ptr;
+#endif
#line 1 "icalsslexer.l"
#define INITIAL 0
#line 2 "icalsslexer.l"
@@ -455,20 +583,159 @@ char *yytext_ptr;
#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 YYPURE
+#define YYPURE
#undef SS_FATAL_ERROR
#define SS_FATAL_ERROR(msg) sserror(msg)
-
#define sql 1
#define string_value 2
-#line 465 "icalsslexer.c"
+#line 596 "lex.ss.c"
+/* %e */
+#endif /* !ssIN_HEADER */
+
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#ifndef YY_NO_UNISTD_H
+/* %- */
+#include <unistd.h>
+/* %+ */
+/* %* */
+#endif /* !YY_NO_UNISTD_H */
+
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* %- Reentrant structure and macros (non-C++). */
+#ifdef YY_REENTRANT
+
+/* %c */
+#ifndef ssIN_HEADER
+struct yy_globals_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra_r;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin_r, *yyout_r;
+ YY_BUFFER_STATE yy_current_buffer;
+ char yy_hold_char;
+ int yy_n_chars;
+ int yyleng_r;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno_r;
+
+#ifdef YY_TEXT_IS_ARRAY
+ char yytext_r[YYLMAX];
+ char *yytext_ptr;
+ int yy_more_offset;
+ int yy_prev_more_offset;
+#else
+ char *yytext_r;
+ int yy_more_flag;
+ int yy_more_len;
+#endif
+
+#ifdef YY_REENTRANT_BISON_PURE
+ YYSTYPE * yylval_r;
+#ifdef YYLTYPE
+ YYLTYPE * yylloc_r;
+#endif
+#endif
+
+ };
+/* %e */
+#endif /* !ssIN_HEADER */
+
+/* %c */
+#ifndef ssIN_HEADER
+static int yy_init_globals YY_PROTO(( yyscan_t ));
+/* %e */
+#endif /* !ssIN_HEADER */
+
+/* This must go here because YYSTYPE and YYLSTYPE are included
+ * from bison output in section 1.*/
+#ifdef YY_REENTRANT_BISON_PURE
+# define yylval YY_G(yylval_r)
+# ifdef YYLTYPE
+# define yylloc YY_G(yylloc_r)
+# endif
+#endif /* YY_REENTRANT_BISON_PURE */
+
+#endif /* end if YY_REENTRANT */
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+#ifndef YY_NO_GET_EXTRA
+YY_EXTRA_TYPE yyget_extra YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_EXTRA
+void yyset_extra YY_PROTO(( YY_EXTRA_TYPE user_defined YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_IN
+FILE *yyget_in YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_IN
+void yyset_in YY_PROTO(( FILE * in_str YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_OUT
+FILE *yyget_out YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_OUT
+void yyset_out YY_PROTO(( FILE * out_str YY_LAST_ARG ));
+#endif
+
+#ifndef YY_NO_GET_LENG
+int yyget_leng YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_GET_TEXT
+char *yyget_text YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_GET_LINENO
+int yyget_lineno YY_PROTO(( YY_ONLY_ARG ));
+#endif
+
+#ifndef YY_NO_SET_LINENO
+void yyset_lineno YY_PROTO(( int line_number YY_LAST_ARG ));
+#endif
+
+#ifdef YY_REENTRANT_BISON_PURE
+#ifndef YY_NO_GET_LVAL
+YYSTYPE * yyget_lval YY_PROTO(( YY_ONLY_ARG ));
+#endif
+void yyset_lval YY_PROTO(( YYSTYPE * yylvalp YY_LAST_ARG ));
+#ifdef YYLTYPE
+#ifndef YY_NO_GET_LLOC
+ YYLTYPE *yyget_lloc YY_PROTO(( YY_ONLY_ARG ));
+#endif
+#ifndef YY_NO_SET_LLOC
+ void yyset_lloc YY_PROTO(( YYLTYPE * yyllocp YY_LAST_ARG ));
+#endif
+#endif /* YYLTYPE */
+#endif /* YY_REENTRANT_BISON_PURE */
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -476,44 +743,62 @@ void icalparser_clear_flex_input();
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
+extern "C" int yywrap YY_PROTO(( YY_ONLY_ARG ));
#else
-extern int yywrap YY_PROTO(( void ));
+extern int yywrap YY_PROTO(( YY_ONLY_ARG ));
#endif
#endif
+/* %- */
+/* %c */
+#ifndef ssIN_HEADER
#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+static void yyunput YY_PROTO(( int c, char *buf_ptr YY_LAST_ARG));
#endif
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %* */
#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int YY_LAST_ARG));
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+static int yy_flex_strlen YY_PROTO(( yyconst char * YY_LAST_ARG));
#endif
#ifndef YY_NO_INPUT
+/* %- Standard (non-C++) definition */
+/* %c */
+#ifndef ssIN_HEADER
#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
+static int yyinput YY_PROTO(( YY_ONLY_ARG ));
#else
-static int input YY_PROTO(( void ));
+static int input YY_PROTO(( YY_ONLY_ARG ));
#endif
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %* */
#endif
#if YY_STACK_USED
+#ifndef YY_REENTRANT
+/* %c */
+#ifndef ssIN_HEADER
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
+/* %e */
+#endif /* !ssIN_HEADER */
+#endif
#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
+static void yy_push_state YY_PROTO(( int new_state YY_LAST_ARG));
#endif
#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
+static void yy_pop_state YY_PROTO(( YY_ONLY_ARG ));
#endif
#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
+static int yy_top_state YY_PROTO(( YY_ONLY_ARG ));
#endif
#else
@@ -522,21 +807,6 @@ static int yy_top_state YY_PROTO(( void ));
#define YY_NO_TOP_STATE 1
#endif
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
@@ -545,10 +815,13 @@ YY_MALLOC_DECL
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
+/* %- Standard (non-C++) definition */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+/* %+ C++ definition */
+/* %* */
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -556,9 +829,11 @@ YY_MALLOC_DECL
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
+/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
+ if ( YY_G(yy_current_buffer)->yy_is_interactive ) \
{ \
- int c = '*', n; \
+ int c = '*'; \
+ size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -568,9 +843,22 @@ YY_MALLOC_DECL
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }
+/* %+ C++ definition \ */\
+/* %* */
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -588,14 +876,51 @@ YY_MALLOC_DECL
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
+/* %- */
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+/* %+ */
+/* %* */
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
+/* %- Standard (non-C++) definition */
+
+/* If the bison pure parser is used, then bison will provide
+ one or two additional arguments. */
+
+#ifdef YY_REENTRANT_BISON_PURE
+# ifdef YYLTYPE
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YYSTYPE * yylvalp, YYLTYPE * yyllocp YY_LAST_ARG)
+# else
+# define YY_LEX_ARGS (yylvalp, yyllocp YY_LAST_ARG) \
+ YYSTYPE * yylvalp; YYLTYPE * yyllocp; YY_DECL_LAST_ARG
+# endif
+# else
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YYSTYPE * yylvalp YY_LAST_ARG)
+# else
+# define YY_LEX_ARGS (yylvalp YY_LAST_ARG) \
+ YYSTYPE * yylvalp; YY_DECL_LAST_ARG
+# endif
+# endif
+#else
+# ifdef YY_USE_PROTOS
+# define YY_LEX_ARGS (YY_ONLY_ARG)
+# else
+# define YY_LEX_ARGS (YY_ONLY_ARG) YY_DECL_LAST_ARG
+# endif
+#endif
+
+
+extern int yylex YY_PROTO( YY_LEX_ARGS );
+
+#define YY_DECL int yylex YY_LEX_ARGS
+/* %+ C++ definition */
+/* %* */
#endif
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -610,211 +935,256 @@ YY_MALLOC_DECL
#define YY_BREAK break;
#endif
+/* %% [6.0] YY_RULE_SETUP definition goes here */
#define YY_RULE_SETUP \
YY_USER_ACTION
+/* %c */
+#ifndef ssIN_HEADER
YY_DECL
{
register yy_state_type yy_current_state;
- register char *yy_cp = NULL, *yy_bp = NULL;
+ register char *yy_cp, *yy_bp;
register int yy_act;
-#line 69 "icalsslexer.l"
+/* %% [7.0] user's declarations go here */
+#line 66 "icalsslexer.l"
+
+#line 959 "lex.ss.c"
-#line 623 "icalsslexer.c"
+#ifdef YY_REENTRANT_BISON_PURE
+ yylval = yylvalp;
+#ifdef YYLTYPE
+ yylloc = yyllocp;
+#endif
+#endif
- if ( yy_init )
+ if ( YY_G(yy_init) )
{
- yy_init = 0;
+ YY_G(yy_init) = 0;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
- if ( ! yy_start )
- yy_start = 1; /* first start state */
+ if ( ! YY_G(yy_start) )
+ YY_G(yy_start) = 1; /* first start state */
if ( ! yyin )
+/* %- */
yyin = stdin;
+/* %+ */
+/* %* */
if ( ! yyout )
+/* %- */
yyout = stdout;
+/* %+ */
+/* %* */
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
+ if ( ! YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) =
+ yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
- yy_load_buffer_state();
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
while ( 1 ) /* loops until end-of-file is reached */
{
- yy_cp = yy_c_buf_p;
+/* %% [8.0] yymore()-related code goes here */
+ yy_cp = YY_G(yy_c_buf_p);
/* Support of yytext. */
- *yy_cp = yy_hold_char;
+ *yy_cp = YY_G(yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
- yy_current_state = yy_start;
+/* %% [9.0] code to set up and find next match goes here */
+ yy_current_state = YY_G(yy_start);
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ YY_G(yy_last_accepting_state) = yy_current_state;
+ YY_G(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 47 )
+ if ( yy_current_state >= 56 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 54 );
+ while ( yy_base[yy_current_state] != 69 );
yy_find_action:
+/* %% [10.0] code to find the action number goes here */
yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 )
{ /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
+ yy_cp = YY_G(yy_last_accepting_cpos);
+ yy_current_state = YY_G(yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
YY_DO_BEFORE_ACTION;
+/* %% [11.0] code for yylineno update goes here */
do_action: /* This label is used only to access EOF actions. */
+/* %% [12.0] debug code goes here */
switch ( yy_act )
{ /* beginning of action switch */
+/* %% [13.0] actions go here */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
+ *yy_cp = YY_G(yy_hold_char);
+ yy_cp = YY_G(yy_last_accepting_cpos);
+ yy_current_state = YY_G(yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
-#line 75 "icalsslexer.l"
+#line 72 "icalsslexer.l"
{ return SELECT; }
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 76 "icalsslexer.l"
+#line 73 "icalsslexer.l"
{ return FROM; }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 77 "icalsslexer.l"
+#line 74 "icalsslexer.l"
{ return WHERE; }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 78 "icalsslexer.l"
+#line 75 "icalsslexer.l"
{ return COMMA; }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 79 "icalsslexer.l"
+#line 76 "icalsslexer.l"
{ return EQUALS; }
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 80 "icalsslexer.l"
-{ return NOTEQUALS; }
+#line 77 "icalsslexer.l"
+{ return EQUALS; }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 81 "icalsslexer.l"
-{ return LESS; }
+#line 78 "icalsslexer.l"
+{ return NOTEQUALS; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 82 "icalsslexer.l"
-{ return GREATER; }
+#line 79 "icalsslexer.l"
+{ return LESS; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 83 "icalsslexer.l"
-{ return LESSEQUALS; }
+#line 80 "icalsslexer.l"
+{ return GREATER; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 84 "icalsslexer.l"
-{ return GREATEREQUALS; }
+#line 81 "icalsslexer.l"
+{ return LESSEQUALS; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 85 "icalsslexer.l"
-{ return AND; }
+#line 82 "icalsslexer.l"
+{ return GREATEREQUALS; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 86 "icalsslexer.l"
-{ return OR; }
+#line 83 "icalsslexer.l"
+{ return AND; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 87 "icalsslexer.l"
-{ return QUOTE; }
+#line 84 "icalsslexer.l"
+{ return OR; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 88 "icalsslexer.l"
-;
+#line 85 "icalsslexer.l"
+{ return IS; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 89 "icalsslexer.l"
-{ return EOL; }
+#line 86 "icalsslexer.l"
+{ return NOT; }
YY_BREAK
case 16:
YY_RULE_SETUP
+#line 87 "icalsslexer.l"
+{ return SQLNULL; }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 88 "icalsslexer.l"
+{ return QUOTE; }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 89 "icalsslexer.l"
+;
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
#line 90 "icalsslexer.l"
+{ return EOL; }
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 92 "icalsslexer.l"
{
- int c = input();
+ int c = input(yy_globals);
unput(c);
if(c!='\''){
- sslval.v_string= icalmemory_tmp_copy(sstext);
+ yylvalp->v_string= icalmemory_tmp_copy(yytext);
return STRING;
} else {
/*ssmore();*/
}
}
YY_BREAK
-case 17:
+case 21:
YY_RULE_SETUP
-#line 101 "icalsslexer.l"
-{ sslval.v_string= icalmemory_tmp_copy(sstext);
- return STRING; }
+#line 103 "icalsslexer.l"
+{
+ yylval->v_string= icalmemory_tmp_copy(yytext);
+ return STRING;
+}
YY_BREAK
-case 18:
+case 22:
YY_RULE_SETUP
-#line 105 "icalsslexer.l"
+#line 109 "icalsslexer.l"
{ return yytext[0]; }
YY_BREAK
-case 19:
+case 23:
YY_RULE_SETUP
-#line 107 "icalsslexer.l"
+#line 111 "icalsslexer.l"
ECHO;
YY_BREAK
-#line 811 "icalsslexer.c"
+#line 1188 "lex.ss.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(sql):
case YY_STATE_EOF(string_value):
@@ -823,13 +1193,13 @@ case YY_STATE_EOF(string_value):
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+ int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
+ *yy_cp = YY_G(yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
@@ -840,9 +1210,9 @@ case YY_STATE_EOF(string_value):
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
+ YY_G(yy_current_buffer)->yy_input_file = yyin;
+ YY_G(yy_current_buffer)->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
@@ -852,13 +1222,13 @@ case YY_STATE_EOF(string_value):
* end-of-buffer state). Contrast this with the test
* in input().
*/
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( YY_G(yy_c_buf_p) <= &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -869,32 +1239,33 @@ case YY_STATE_EOF(string_value):
* will run more slowly).
*/
- yy_next_state = yy_try_NUL_trans( yy_current_state );
+ yy_next_state = yy_try_NUL_trans( yy_current_state YY_CALL_LAST_ARG);
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
+ yy_cp = ++YY_G(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
- yy_cp = yy_c_buf_p;
+/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
+ yy_cp = YY_G(yy_c_buf_p);
goto yy_find_action;
}
}
- else switch ( yy_get_next_buffer() )
+ else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_END_OF_FILE:
{
- yy_did_buffer_switch_on_eof = 0;
+ YY_G(yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap() )
+ if ( yywrap( YY_CALL_ONLY_ARG ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -905,7 +1276,7 @@ case YY_STATE_EOF(string_value):
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
@@ -913,30 +1284,30 @@ case YY_STATE_EOF(string_value):
else
{
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
+ YY_G(yy_c_buf_p) =
+ YY_G(yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_cp = YY_G(yy_c_buf_p);
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
+ YY_G(yy_c_buf_p) =
+ &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)];
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_cp = YY_G(yy_c_buf_p);
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
goto yy_find_action;
}
break;
@@ -948,7 +1319,14 @@ case YY_STATE_EOF(string_value):
} /* end of action switch */
} /* end of scanning one token */
} /* end of yylex */
-
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %+ */
+/* %c */
+#ifndef ssIN_HEADER
+/* %e */
+#endif /* !ssIN_HEADER */
+/* %* */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -958,20 +1336,30 @@ case YY_STATE_EOF(string_value):
* EOB_ACT_END_OF_FILE - end of file
*/
-static int yy_get_next_buffer()
+/* %- */
+/* %c */
+#ifndef ssIN_HEADER
+#ifdef YY_USE_PROTOS
+static int yy_get_next_buffer(YY_ONLY_ARG)
+#else
+static int yy_get_next_buffer(YY_ONLY_ARG)
+YY_DECL_LAST_ARG
+#endif
+/* %+ */
+/* %* */
{
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
+ register char *dest = YY_G(yy_current_buffer)->yy_ch_buf;
+ register char *source = YY_G(yytext_ptr);
register int number_to_move, i;
int ret_val;
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ if ( YY_G(yy_c_buf_p) > &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
- if ( yy_current_buffer->yy_fill_buffer == 0 )
+ if ( YY_G(yy_current_buffer)->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
@@ -991,21 +1379,21 @@ static int yy_get_next_buffer()
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+ number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars) = 0;
else
{
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
+ size_t num_to_read =
+ YY_G(yy_current_buffer)->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
@@ -1015,10 +1403,10 @@ static int yy_get_next_buffer()
#else
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
+ YY_BUFFER_STATE b = YY_G(yy_current_buffer);
int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
+ (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
@@ -1032,7 +1420,7 @@ static int yy_get_next_buffer()
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
+ b->yy_buf_size + 2 YY_CALL_LAST_ARG );
}
else
/* Can't grow it, we don't own it. */
@@ -1042,9 +1430,9 @@ static int yy_get_next_buffer()
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+ YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
- num_to_read = yy_current_buffer->yy_buf_size -
+ num_to_read = YY_G(yy_current_buffer)->yy_buf_size -
number_to_move - 1;
#endif
}
@@ -1053,24 +1441,24 @@ static int yy_get_next_buffer()
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
+ YY_INPUT( (&YY_G(yy_current_buffer)->yy_ch_buf[number_to_move]),
+ YY_G(yy_n_chars), num_to_read );
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
}
- if ( yy_n_chars == 0 )
+ if ( YY_G(yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
+ yyrestart( yyin YY_CALL_LAST_ARG);
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
+ YY_G(yy_current_buffer)->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
@@ -1078,37 +1466,50 @@ static int yy_get_next_buffer()
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+ YY_G(yy_n_chars) += number_to_move;
+ YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+ YY_G(yytext_ptr) = &YY_G(yy_current_buffer)->yy_ch_buf[0];
return ret_val;
}
-
+/* %e */
+#endif /* !ssIN_HEADER */
/* yy_get_previous_state - get the state just before the EOB char was reached */
-static yy_state_type yy_get_previous_state()
+/* %- */
+/* %c */
+#ifndef ssIN_HEADER
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
+#else
+static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
+YY_DECL_LAST_ARG
+#endif
+/* %+ */
+/* %* */
{
register yy_state_type yy_current_state;
register char *yy_cp;
- yy_current_state = yy_start;
+/* %% [15.0] code to get the start state into yy_current_state goes here */
+ yy_current_state = YY_G(yy_start);
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp )
{
+/* %% [16.0] code to find the next state goes here */
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ YY_G(yy_last_accepting_state) = yy_current_state;
+ YY_G(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 47 )
+ if ( yy_current_state >= 56 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1124,106 +1525,127 @@ static yy_state_type yy_get_previous_state()
* next_state = yy_try_NUL_trans( current_state );
*/
+/* %- */
#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state YY_LAST_ARG )
#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
+static yy_state_type yy_try_NUL_trans( yy_current_state YY_LAST_ARG )
yy_state_type yy_current_state;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
+/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
+ register char *yy_cp = YY_G(yy_c_buf_p);
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ YY_G(yy_last_accepting_state) = yy_current_state;
+ YY_G(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 47 )
+ if ( yy_current_state >= 56 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 46);
+ yy_is_jam = (yy_current_state == 55);
return yy_is_jam ? 0 : yy_current_state;
}
+/* %- */
#ifndef YY_NO_UNPUT
#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
+static void yyunput( int c, register char *yy_bp YY_LAST_ARG )
#else
-static void yyunput( c, yy_bp )
+static void yyunput( c, yy_bp YY_LAST_ARG)
int c;
register char *yy_bp;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- register char *yy_cp = yy_c_buf_p;
+ register char *yy_cp = YY_G(yy_c_buf_p);
/* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
+ *yy_cp = YY_G(yy_hold_char);
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
+ register int number_to_move = YY_G(yy_n_chars) + 2;
+ register char *dest = &YY_G(yy_current_buffer)->yy_ch_buf[
+ YY_G(yy_current_buffer)->yy_buf_size + 2];
register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
+ &YY_G(yy_current_buffer)->yy_ch_buf[number_to_move];
- while ( source > yy_current_buffer->yy_ch_buf )
+ while ( source > YY_G(yy_current_buffer)->yy_ch_buf )
*--dest = *--source;
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
+ YY_G(yy_current_buffer)->yy_n_chars =
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_buf_size;
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
*--yy_cp = (char) c;
+/* %% [18.0] update yylineno here */
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
+ YY_G(yytext_ptr) = yy_bp;
+ YY_G(yy_hold_char) = *yy_cp;
+ YY_G(yy_c_buf_p) = yy_cp;
}
+/* %- */
#endif /* ifndef YY_NO_UNPUT */
+/* %* */
+/* %- */
+#ifndef YY_NO_INPUT
#ifdef __cplusplus
-static int yyinput()
+static int yyinput(YY_ONLY_ARG)
#else
-static int input()
+#ifdef YY_USE_PROTOS
+static int input(YY_ONLY_ARG)
+#else
+static int input(YY_ONLY_ARG)
+ YY_DECL_LAST_ARG
+#endif
#endif
+/* %+ */
+/* %* */
{
int c;
- *yy_c_buf_p = yy_hold_char;
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( YY_G(yy_c_buf_p) < &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
/* This was really a NUL. */
- *yy_c_buf_p = '\0';
+ *YY_G(yy_c_buf_p) = '\0';
else
{ /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
+ int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);
+ ++YY_G(yy_c_buf_p);
- switch ( yy_get_next_buffer() )
+ switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -1237,109 +1659,129 @@ static int input()
*/
/* Reset buffer status. */
- yyrestart( yyin );
+ yyrestart( yyin YY_CALL_LAST_ARG);
/* fall through */
case EOB_ACT_END_OF_FILE:
{
- if ( yywrap() )
+ if ( yywrap( YY_CALL_ONLY_ARG ) )
return EOF;
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
- return yyinput();
+ return yyinput(YY_CALL_ONLY_ARG);
#else
- return input();
+ return input(YY_CALL_ONLY_ARG);
#endif
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset;
break;
}
}
}
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
+ c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */
+ *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */
+ YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p);
+/* %% [19.0] update BOL and yylineno */
return c;
}
+/* %- */
+#endif /* ifndef YY_NO_INPUT */
+/* %* */
-
+/* %- */
#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
+void yyrestart( FILE *input_file YY_LAST_ARG)
#else
-void yyrestart( input_file )
+void yyrestart( input_file YY_LAST_ARG)
FILE *input_file;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+ if ( ! YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) =
+ yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
+ yy_init_buffer( YY_G(yy_current_buffer), input_file YY_CALL_LAST_ARG);
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
+/* %- */
#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer YY_LAST_ARG )
#else
-void yy_switch_to_buffer( new_buffer )
+void yy_switch_to_buffer( new_buffer YY_LAST_ARG )
YY_BUFFER_STATE new_buffer;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- if ( yy_current_buffer == new_buffer )
+ if ( YY_G(yy_current_buffer) == new_buffer )
return;
- if ( yy_current_buffer )
+ if ( YY_G(yy_current_buffer) )
{
/* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
+ YY_G(yy_current_buffer)->yy_buf_pos = YY_G(yy_c_buf_p);
+ YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
}
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
+ YY_G(yy_current_buffer) = new_buffer;
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
- yy_did_buffer_switch_on_eof = 1;
+ YY_G(yy_did_buffer_switch_on_eof) = 1;
}
+/* %- */
#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
+void yy_load_buffer_state( YY_ONLY_ARG )
#else
-void yy_load_buffer_state()
+void yy_load_buffer_state(YY_ONLY_ARG )
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
+ YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
+ YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_G(yy_current_buffer)->yy_buf_pos;
+ yyin = YY_G(yy_current_buffer)->yy_input_file;
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
}
+/* %- */
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size YY_LAST_ARG)
#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
+YY_BUFFER_STATE yy_create_buffer( file, size YY_LAST_ARG)
FILE *file;
int size;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -1348,79 +1790,100 @@ int size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer( b, file );
+ yy_init_buffer( b, file YY_CALL_LAST_ARG);
return b;
}
+/* %- */
#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
+void yy_delete_buffer( YY_BUFFER_STATE b YY_LAST_ARG)
#else
-void yy_delete_buffer( b )
+void yy_delete_buffer( b YY_LAST_ARG)
YY_BUFFER_STATE b;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
if ( ! b )
return;
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
+ if ( b == YY_G(yy_current_buffer) )
+ YY_G(yy_current_buffer) = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
+ yy_flex_free( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
- yy_flex_free( (void *) b );
+ yy_flex_free( (void *) b YY_CALL_LAST_ARG );
}
+/* %- */
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+#ifdef __cplusplus
+extern "C" int isatty YY_PROTO(( int ));
+#else
+extern int isatty YY_PROTO(( int ));
+#endif /* __cplusplus */
+#endif /* !YY_NEVER_INTERACTIVE */
+#endif /* !YY_ALWAYS_INTERACTIVE */
#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG)
#else
-void yy_init_buffer( b, file )
+void yy_init_buffer( b, file YY_LAST_ARG)
YY_BUFFER_STATE b;
FILE *file;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- yy_flush_buffer( b );
+ int oerrno = errno;
+
+ yy_flush_buffer( b YY_CALL_LAST_ARG);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
+/* %- */
#if YY_ALWAYS_INTERACTIVE
b->yy_is_interactive = 1;
#else
#if YY_NEVER_INTERACTIVE
b->yy_is_interactive = 0;
#else
-
-#ifdef _QTWIN_
- b->yy_is_interactive = file ? (_isatty( fileno(file) ) > 0) : 0;
-#else
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
#endif
-
-#endif
#endif
+/* %+ */
+/* %* */
+ errno = oerrno;
}
+/* %- */
#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
+void yy_flush_buffer( YY_BUFFER_STATE b YY_LAST_ARG )
#else
-void yy_flush_buffer( b )
+void yy_flush_buffer( b YY_LAST_ARG )
YY_BUFFER_STATE b;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
if ( ! b )
return;
@@ -1439,18 +1902,21 @@ YY_BUFFER_STATE b;
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
+ if ( b == YY_G(yy_current_buffer) )
+ yy_load_buffer_state( YY_CALL_ONLY_ARG );
}
+/* %* */
#ifndef YY_NO_SCAN_BUFFER
+/* %- */
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size YY_LAST_ARG )
#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
+YY_BUFFER_STATE yy_scan_buffer( base, size YY_LAST_ARG )
char *base;
yy_size_t size;
+YY_DECL_LAST_ARG
#endif
{
YY_BUFFER_STATE b;
@@ -1461,7 +1927,7 @@ yy_size_t size;
/* They forgot to leave room for the EOB's. */
return 0;
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
@@ -1475,36 +1941,42 @@ yy_size_t size;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer( b );
+ yy_switch_to_buffer( b YY_CALL_LAST_ARG );
return b;
}
+/* %* */
#endif
#ifndef YY_NO_SCAN_STRING
+/* %- */
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str YY_LAST_ARG )
#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
+YY_BUFFER_STATE yy_scan_string( yy_str YY_LAST_ARG)
yyconst char *yy_str;
+YY_DECL_LAST_ARG
#endif
{
int len;
for ( len = 0; yy_str[len]; ++len )
;
- return yy_scan_bytes( yy_str, len );
+ return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG);
}
+/* %* */
#endif
#ifndef YY_NO_SCAN_BYTES
+/* %- */
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len YY_LAST_ARG)
#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+YY_BUFFER_STATE yy_scan_bytes( bytes, len YY_LAST_ARG)
yyconst char *bytes;
+YY_DECL_LAST_ARG
int len;
#endif
{
@@ -1515,7 +1987,7 @@ int len;
/* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2;
- buf = (char *) yy_flex_alloc( n );
+ buf = (char *) yy_flex_alloc( n YY_CALL_LAST_ARG );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1524,7 +1996,7 @@ int len;
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer( buf, n );
+ b = yy_scan_buffer( buf, n YY_CALL_LAST_ARG);
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1535,37 +2007,42 @@ int len;
return b;
}
+/* %* */
#endif
#ifndef YY_NO_PUSH_STATE
+/* %- */
#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
+static void yy_push_state( int new_state YY_LAST_ARG)
#else
-static void yy_push_state( new_state )
+static void yy_push_state( new_state YY_LAST_ARG)
int new_state;
+YY_DECL_LAST_ARG
#endif
+/* %+ */
+/* %* */
{
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
+ if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
{
yy_size_t new_size;
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
+ YY_G(yy_start_stack_depth) += YY_START_STACK_INCR;
+ new_size = YY_G(yy_start_stack_depth) * sizeof( int );
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
+ if ( ! YY_G(yy_start_stack) )
+ YY_G(yy_start_stack) = (int *) yy_flex_alloc( new_size YY_CALL_LAST_ARG );
else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
+ YY_G(yy_start_stack) = (int *) yy_flex_realloc(
+ (void *) YY_G(yy_start_stack), new_size YY_CALL_LAST_ARG );
- if ( ! yy_start_stack )
+ if ( ! YY_G(yy_start_stack) )
YY_FATAL_ERROR(
"out of memory expanding start-condition stack" );
}
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
+ YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
BEGIN(new_state);
}
@@ -1573,20 +2050,36 @@ int new_state;
#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
+/* %- */
+#ifdef YY_USE_PROTOS
+static void yy_pop_state( YY_ONLY_ARG )
+#else
+static void yy_pop_state( YY_ONLY_ARG )
+YY_DECL_LAST_ARG
+#endif
+/* %+ */
+/* %* */
{
- if ( --yy_start_stack_ptr < 0 )
+ if ( --YY_G(yy_start_stack_ptr) < 0 )
YY_FATAL_ERROR( "start-condition stack underflow" );
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
+ BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
}
#endif
#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
+/* %- */
+#ifdef YY_USE_PROTOS
+static int yy_top_state( YY_ONLY_ARG )
+#else
+static int yy_top_state( YY_ONLY_ARG )
+YY_DECL_LAST_ARG
+#endif
+/* %+ */
+/* %* */
{
- return yy_start_stack[yy_start_stack_ptr - 1];
+ return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
}
#endif
@@ -1594,17 +2087,15 @@ static int yy_top_state()
#define YY_EXIT_FAILURE 2
#endif
-#ifdef YY_USE_PROTOS
+/* %- */
static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
+/* %+ */
+/* %* */
/* Redefine yyless() so it works in section 3 code. */
@@ -1614,25 +2105,288 @@ char msg[];
do \
{ \
/* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
+ yytext[yyleng] = YY_G(yy_hold_char); \
+ YY_G(yy_c_buf_p) = yytext + n; \
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
+ *YY_G(yy_c_buf_p) = '\0'; \
yyleng = n; \
} \
while ( 0 )
+
+#ifdef YY_REENTRANT
+
+/* Accessor methods (get/set functions) to struct members. */
+
+#ifndef YY_NO_GET_EXTRA
+#ifdef YY_USE_PROTOS
+YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
+#else
+YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yyextra;
+}
+#endif /* !YY_NO_GET_EXTRA */
+
+#ifndef YY_NO_GET_LINENO
+# ifdef YY_USE_PROTOS
+int yyget_lineno( YY_ONLY_ARG )
+# else
+int yyget_lineno( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+# endif
+{
+ return yylineno;
+}
+#endif /* !YY_NO_GET_LINENO */
+
+#ifndef YY_NO_GET_IN
+#ifdef YY_USE_PROTOS
+FILE *yyget_in( YY_ONLY_ARG )
+#else
+FILE *yyget_in( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yyin;
+}
+#endif /* !YY_NO_GET_IN */
+
+#ifndef YY_NO_GET_OUT
+#ifdef YY_USE_PROTOS
+FILE *yyget_out( YY_ONLY_ARG )
+#else
+FILE *yyget_out( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yyout;
+}
+#endif /* !YY_NO_GET_OUT */
+
+#ifndef YY_NO_GET_LENG
+#ifdef YY_USE_PROTOS
+int yyget_leng( YY_ONLY_ARG )
+#else
+int yyget_leng( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yyleng;
+}
+#endif /* !YY_NO_GET_LENG */
+
+#ifndef YY_NO_GET_TEXT
+#ifdef YY_USE_PROTOS
+char *yyget_text( YY_ONLY_ARG )
+#else
+char *yyget_text( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yytext;
+}
+#endif /* !YY_NO_GET_TEXT */
+
+#ifndef YY_NO_SET_EXTRA
+#ifdef YY_USE_PROTOS
+void yyset_extra( YY_EXTRA_TYPE user_defined YY_LAST_ARG )
+#else
+void yyset_extra( user_defined YY_LAST_ARG )
+ YY_EXTRA_TYPE user_defined;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yyextra = user_defined ;
+}
+#endif /* !YY_NO_SET_EXTRA */
+
+#ifndef YY_NO_SET_LINENO
+# ifdef YY_USE_PROTOS
+void yyset_lineno( int line_number YY_LAST_ARG )
+# else
+void yyset_lineno( line_number YY_LAST_ARG )
+ int line_number;
+ YY_DECL_LAST_ARG
+# endif
+{
+ yylineno = line_number;
+}
+#endif /* !YY_NO_SET_LINENO */
+
+
+#ifndef YY_NO_SET_IN
+#ifdef YY_USE_PROTOS
+void yyset_in( FILE * in_str YY_LAST_ARG )
+#else
+void yyset_in( in_str YY_LAST_ARG )
+ FILE * in_str;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yyin = in_str ;
+}
+#endif /* !YY_NO_SET_IN */
+
+#ifndef YY_NO_SET_OUT
+#ifdef YY_USE_PROTOS
+void yyset_out( FILE * out_str YY_LAST_ARG )
+#else
+void yyset_out( out_str YY_LAST_ARG )
+ FILE * out_str;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yyout = out_str ;
+}
+#endif /* !YY_NO_SET_OUT */
+
+/* Accessor methods for yylval and yylloc */
+
+#ifdef YY_REENTRANT_BISON_PURE
+#ifndef YY_NO_GET_LVAL
+#ifdef YY_USE_PROTOS
+YYSTYPE * yyget_lval( YY_ONLY_ARG )
+#else
+YYSTYPE * yyget_lval( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yylval;
+}
+#endif /* !YY_NO_GET_LVAL */
+
+#ifndef YY_NO_SET_LVAL
+#ifdef YY_USE_PROTOS
+void yyset_lval( YYSTYPE * yylvalp YY_LAST_ARG )
+#else
+void yyset_lval( yylvalp YY_LAST_ARG )
+ YYSTYPE * yylvalp;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yylval = yylvalp;
+}
+#endif /* !YY_NO_SET_LVAL */
+
+#ifdef YYLTYPE
+#ifndef YY_NO_GET_LLOC
+#ifdef YY_USE_PROTOS
+YYLTYPE *yyget_lloc( YY_ONLY_ARG )
+#else
+YYLTYPE *yyget_lloc( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yylloc;
+}
+#endif /* !YY_NO_GET_LLOC */
+
+#ifndef YY_NO_SET_LLOC
+#ifdef YY_USE_PROTOS
+void yyset_lloc( YYLTYPE * yyllocp YY_LAST_ARG )
+#else
+void yyset_lloc( yyllocp YY_LAST_ARG )
+ YYLTYPE * yyllocp;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yylloc = yyllocp;
+}
+#endif /* !YY_NO_SET_LLOC */
+
+#endif /* YYLTYPE */
+#endif /* YY_REENTRANT_BISON_PURE */
+
+
+#ifdef YY_USE_PROTOS
+static int yy_init_globals( yyscan_t yy_globals)
+#else
+static int yy_init_globals( yy_globals )
+ yyscan_t yy_globals;
+#endif
+ {
+ /* Initialization is the same as for the non-reentrant scanner.
+ This function is called once per scanner lifetime. */
+
+ /* We do not touch yylineno unless the option is enabled. */
+#ifdef YY_USE_LINENO
+ yylineno = 1;
+#endif
+ YY_G(yy_current_buffer) = 0;
+ YY_G(yy_c_buf_p) = (char *) 0;
+ YY_G(yy_init) = 1;
+ YY_G(yy_start) = 0;
+ YY_G(yy_start_stack_ptr) = 0;
+ YY_G(yy_start_stack_depth) = 0;
+ YY_G(yy_start_stack) = (int *) 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
+#endif
+ return 0;
+ }
+
+/* User-visible API */
+#ifdef YY_USE_PROTOS
+int yylex_init( yyscan_t* ptr_yy_globals)
+#else
+int yylex_init( ptr_yy_globals )
+ yyscan_t* ptr_yy_globals;
+#endif
+ {
+ *ptr_yy_globals = (yyscan_t) yy_flex_alloc ( sizeof( struct yy_globals_t ), NULL );
+ yy_init_globals ( *ptr_yy_globals );
+ return 0;
+ }
+
+#ifdef YY_USE_PROTOS
+int yylex_destroy( yyscan_t yy_globals )
+#else
+int yylex_destroy( yy_globals )
+ yyscan_t yy_globals;
+#endif
+ {
+ if( yy_globals )
+ {
+
+ /* Destroy the current (main) buffer. */
+ yy_delete_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG );
+ YY_G(yy_current_buffer) = NULL;
+
+ /* Destroy the start condition stack. */
+ if( YY_G(yy_start_stack) ) {
+ yy_flex_free( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
+ YY_G(yy_start_stack) = NULL;
+ }
+
+ /* Destroy the main struct. */
+ yy_flex_free ( yy_globals YY_CALL_LAST_ARG );
+ }
+ return 0;
+ }
+
+#endif /* End YY_REENTRANT */
+
/* Internal utility routines. */
#ifndef yytext_ptr
#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n YY_LAST_ARG)
#else
-static void yy_flex_strncpy( s1, s2, n )
+static void yy_flex_strncpy( s1, s2, n YY_LAST_ARG)
char *s1;
yyconst char *s2;
int n;
+YY_DECL_LAST_ARG
#endif
{
register int i;
@@ -1643,10 +2397,11 @@ int n;
#ifdef YY_NEED_STRLEN
#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
+static int yy_flex_strlen( yyconst char *s YY_LAST_ARG)
#else
-static int yy_flex_strlen( s )
+static int yy_flex_strlen( s YY_LAST_ARG)
yyconst char *s;
+YY_DECL_LAST_ARG
#endif
{
register int n;
@@ -1659,21 +2414,23 @@ yyconst char *s;
#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
+static void *yy_flex_alloc( yy_size_t size YY_LAST_ARG )
#else
-static void *yy_flex_alloc( size )
+static void *yy_flex_alloc( size YY_LAST_ARG )
yy_size_t size;
+YY_DECL_LAST_ARG
#endif
{
return (void *) malloc( size );
}
#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
+static void *yy_flex_realloc( void *ptr, yy_size_t size YY_LAST_ARG )
#else
-static void *yy_flex_realloc( ptr, size )
+static void *yy_flex_realloc( ptr, size YY_LAST_ARG )
void *ptr;
yy_size_t size;
+YY_DECL_LAST_ARG
#endif
{
/* The cast to (char *) in the following accommodates both
@@ -1687,27 +2444,42 @@ yy_size_t size;
}
#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
+static void yy_flex_free( void *ptr YY_LAST_ARG )
#else
-static void yy_flex_free( ptr )
+static void yy_flex_free( ptr YY_LAST_ARG )
void *ptr;
+YY_DECL_LAST_ARG
#endif
{
- free( ptr );
+ free( (char *) ptr ); /* see yy_flex_realloc() for (char *) cast */
}
#if YY_MAIN
int main()
{
+
+#ifdef YY_REENTRANT
+ yyscan_t lexer;
+ yylex_init(&lexer);
+ yylex( lexer );
+ yylex_destroy( lexer);
+
+#else
yylex();
+#endif
+
return 0;
}
#endif
-#line 107 "icalsslexer.l"
+/* %e */
+#endif /* !ssIN_HEADER */
+#line 111 "icalsslexer.l"
+#ifndef ssIN_HEADER
-int sswrap()
+int yywrap(yyscan_t yy_globals)
{
return 1;
}
+#endif /* !ssIN_HEADER */
diff --git a/libical/src/libicalss/icalssyacc.c b/libical/src/libicalss/icalssyacc.c
index 943123e..3d8cdc1 100644
--- a/libical/src/libicalss/icalssyacc.c
+++ b/libical/src/libicalss/icalssyacc.c
@@ -1,5 +1,5 @@
/* A Bison parser, made from icalssyacc.y
- by GNU bison 1.35. */
+ by GNU bison 1.34. */
#define YYBISON 1 /* Identify Bison output. */
@@ -26,8 +26,11 @@
# define OR 270
# define EOL 271
# define END 272
+# define IS 273
+# define NOT 274
+# define SQLNULL 275
-#line 1 "icalssyacc.y"
+#line 3 "icalssyacc.y"
/* -*- Mode: C -*-
======================================================================
@@ -56,35 +59,36 @@
Code is Eric Busboom
======================================================================*/
-
+/*#define YYDEBUG 1*/
#include <stdlib.h>
#include <string.h> /* for strdup() */
#include <limits.h> /* for SHRT_MAX*/
#include "ical.h"
-#include "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.... */
+#define YYPARSE_PARAM yy_globals
+#define YYLEX_PARAM yy_globals
+#define YY_EXTRA_TYPE icalgauge_impl*
+ /* ick...*/
+#define yyextra ((struct icalgauge_impl*)ssget_extra(yy_globals))
+static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
+ icalgaugecompare compare , char* value);
+static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
+static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
+static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
+void sserror(char *s); /* Don't know why I need this.... */
-#line 52 "icalssyacc.y"
+#line 56 "icalssyacc.y"
#ifndef YYSTYPE
typedef union {
char* v_string;
} yystype;
# define YYSTYPE yystype
-# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -92,12 +96,12 @@ typedef union {
-#define YYFINAL 34
+#define YYFINAL 38
#define YYFLAG -32768
-#define YYNTBASE 19
+#define YYNTBASE 22
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
-#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 24)
+#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 27)
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
static const char yytranslate[] =
@@ -129,23 +133,24 @@ static const char yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18
+ 16, 17, 18, 19, 20, 21
};
#if YYDEBUG
static const short yyprhs[] =
{
- 0, 0, 7, 9, 11, 15, 17, 21, 22, 26,
- 30, 34, 38, 42, 46, 48, 52
+ 0, 0, 7, 12, 14, 16, 20, 22, 26, 27,
+ 31, 35, 40, 44, 48, 52, 56, 60, 62, 66
};
static const short yyrhs[] =
{
- 4, 20, 5, 21, 6, 23, 0, 1, 0, 3,
- 0, 20, 7, 3, 0, 3, 0, 21, 7, 3,
- 0, 0, 3, 9, 3, 0, 3, 10, 3, 0,
- 3, 11, 3, 0, 3, 12, 3, 0, 3, 13,
- 3, 0, 3, 14, 3, 0, 22, 0, 23, 15,
- 22, 0, 23, 16, 22, 0
+ 4, 23, 5, 24, 6, 26, 0, 4, 23, 5,
+ 24, 0, 1, 0, 3, 0, 23, 7, 3, 0,
+ 3, 0, 24, 7, 3, 0, 0, 3, 9, 3,
+ 0, 3, 19, 21, 0, 3, 19, 20, 21, 0,
+ 3, 10, 3, 0, 3, 11, 3, 0, 3, 12,
+ 3, 0, 3, 13, 3, 0, 3, 14, 3, 0,
+ 25, 0, 26, 15, 25, 0, 26, 16, 25, 0
};
#endif
@@ -154,8 +159,8 @@ static const short yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
- 0, 63, 64, 70, 72, 76, 78, 81, 83, 85,
- 86, 87, 88, 89, 92, 94, 95
+ 0, 67, 68, 69, 75, 77, 81, 83, 86, 88,
+ 89, 90, 91, 92, 93, 94, 95, 98, 100, 101
};
#endif
@@ -167,23 +172,23 @@ static const char *const yytname[] =
{
"$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA",
"QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS",
- "GREATEREQUALS", "AND", "OR", "EOL", "END", "query_min", "select_list",
- "from_list", "where_clause", "where_list", 0
+ "GREATEREQUALS", "AND", "OR", "EOL", "END", "IS", "NOT", "SQLNULL",
+ "query_min", "select_list", "from_list", "where_clause", "where_list", 0
};
#endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
- 0, 19, 19, 20, 20, 21, 21, 22, 22, 22,
- 22, 22, 22, 22, 23, 23, 23
+ 0, 22, 22, 22, 23, 23, 24, 24, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 26, 26, 26
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
- 0, 6, 1, 1, 3, 1, 3, 0, 3, 3,
- 3, 3, 3, 3, 1, 3, 3
+ 0, 6, 4, 1, 1, 3, 1, 3, 0, 3,
+ 3, 4, 3, 3, 3, 3, 3, 1, 3, 3
};
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -191,49 +196,53 @@ static const short yyr2[] =
error. */
static const short yydefact[] =
{
- 0, 2, 0, 3, 0, 0, 0, 5, 0, 4,
- 7, 0, 0, 14, 1, 6, 0, 0, 0, 0,
- 0, 0, 7, 7, 8, 9, 10, 11, 12, 13,
- 15, 16, 0, 0, 0
+ 0, 3, 0, 4, 0, 0, 0, 6, 2, 5,
+ 8, 0, 0, 17, 1, 7, 0, 0, 0, 0,
+ 0, 0, 0, 8, 8, 9, 12, 13, 14, 15,
+ 16, 0, 10, 18, 19, 11, 0, 0, 0
};
static const short yydefgoto[] =
{
- 32, 4, 8, 13, 14
+ 36, 4, 8, 13, 14
};
static const short yypact[] =
{
- 5,-32768, 4,-32768, 3, 8, 15,-32768, 6,-32768,
- 16, 17, -9,-32768, -1,-32768, 18, 19, 20, 21,
- 22, 23, 16, 16,-32768,-32768,-32768,-32768,-32768,-32768,
- -32768,-32768, 27, 28,-32768
+ 5,-32768, 9,-32768, 6, 17, 18,-32768, 1,-32768,
+ 19, 20, -9,-32768, -1,-32768, 21, 22, 23, 24,
+ 25, 26, -4, 19, 19,-32768,-32768,-32768,-32768,-32768,
+ -32768, 10,-32768,-32768,-32768,-32768, 30, 32,-32768
};
static const short yypgoto[] =
{
- -32768,-32768,-32768, -6,-32768
+ -32768,-32768,-32768, -5,-32768
};
-#define YYLAST 28
+#define YYLAST 32
static const short yytable[] =
{
- 16, 17, 18, 19, 20, 21, 1, 3, 5, 2,
- 6, 7, 10, 11, 22, 23, 30, 31, 9, 12,
- 15, 24, 25, 26, 27, 28, 29, 33, 34
+ 16, 17, 18, 19, 20, 21, 1, 10, 11, 2,
+ 22, 5, 3, 6, 23, 24, 31, 32, 33, 34,
+ 7, 9, 12, 15, 25, 26, 27, 28, 29, 30,
+ 37, 35, 38
};
static const short yycheck[] =
{
- 9, 10, 11, 12, 13, 14, 1, 3, 5, 4,
- 7, 3, 6, 7, 15, 16, 22, 23, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 0, 0
+ 9, 10, 11, 12, 13, 14, 1, 6, 7, 4,
+ 19, 5, 3, 7, 15, 16, 20, 21, 23, 24,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 0, 21, 0
};
+#define YYPURE 1
+
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/share/bison/bison.simple"
+#line 3 "/usr/local/share/bison/bison.simple"
/* Skeleton output parser for bison,
@@ -301,12 +310,6 @@ static const short yycheck[] =
# define YYSTACK_ALLOC malloc
# define YYSTACK_FREE free
# endif
-#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
-
-
-#if (! defined (yyoverflow) \
- && (! defined (__cplusplus) \
- || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -333,41 +336,24 @@ union yyalloc
+ YYSTACK_GAP_MAX)
# endif
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- register YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
+/* Relocate the TYPE STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Type, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
+ yymemcpy ((char *) yyptr, (char *) (Stack), \
+ yysize * (YYSIZE_T) sizeof (Type)); \
Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
+ yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
-#endif
+#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -494,6 +480,33 @@ int yydebug;
# define YYMAXDEPTH 10000
#endif
+#if ! defined (yyoverflow) && ! defined (yymemcpy)
+# if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
+# define yymemcpy __builtin_memcpy
+# else /* not GNU C or C++ */
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+# if defined (__STDC__) || defined (__cplusplus)
+yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
+# else
+yymemcpy (yyto, yyfrom, yycount)
+ char *yyto;
+ const char *yyfrom;
+ YYSIZE_T yycount;
+# endif
+{
+ register const char *yyf = yyfrom;
+ register char *yyt = yyto;
+ register YYSIZE_T yyi = yycount;
+
+ while (yyi-- != 0)
+ *yyt++ = *yyf++;
+}
+# endif
+#endif
+
#ifdef YYERROR_VERBOSE
# ifndef yystrlen
@@ -546,7 +559,7 @@ yystpcpy (yydest, yysrc)
# endif
#endif
-#line 315 "/usr/share/bison/bison.simple"
+#line 319 "/usr/local/share/bison/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
@@ -736,9 +749,6 @@ yyparse (YYPARSE_PARAM_ARG)
yyvs = yyvs1;
}
#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyoverflowlab;
-# else
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
goto yyoverflowlab;
@@ -752,16 +762,15 @@ yyparse (YYPARSE_PARAM_ARG)
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyoverflowlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
+ YYSTACK_RELOCATE (short, yyss);
+ YYSTACK_RELOCATE (YYSTYPE, yyvs);
# if YYLSP_NEEDED
- YYSTACK_RELOCATE (yyls);
+ YYSTACK_RELOCATE (YYLTYPE, yyls);
# endif
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
-# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
@@ -939,68 +948,76 @@ yyreduce:
switch (yyn) {
-case 2:
-#line 64 "icalssyacc.y"
+case 3:
+#line 69 "icalssyacc.y"
{
- icalparser_clear_flex_input();
yyclearin;
+ YYABORT;
}
break;
-case 3:
-#line 71 "icalssyacc.y"
-{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
- break;
case 4:
-#line 72 "icalssyacc.y"
-{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
+#line 76 "icalssyacc.y"
+{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
break;
case 5:
#line 77 "icalssyacc.y"
-{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);}
+{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
break;
case 6:
-#line 78 "icalssyacc.y"
-{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);}
+#line 82 "icalssyacc.y"
+{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
break;
-case 8:
+case 7:
#line 83 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); }
+{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
break;
case 9:
-#line 85 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); }
+#line 88 "icalssyacc.y"
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); }
break;
case 10:
-#line 86 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); }
+#line 89 "icalssyacc.y"
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_ISNULL,""); }
break;
case 11:
-#line 87 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); }
+#line 90 "icalssyacc.y"
+{ssyacc_add_where(yyextra,yyvsp[-3].v_string,ICALGAUGECOMPARE_ISNOTNULL,""); }
break;
case 12:
-#line 88 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); }
+#line 91 "icalssyacc.y"
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); }
break;
case 13:
-#line 89 "icalssyacc.y"
-{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); }
+#line 92 "icalssyacc.y"
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); }
break;
case 14:
#line 93 "icalssyacc.y"
-{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); }
break;
case 15:
#line 94 "icalssyacc.y"
-{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); }
break;
case 16:
#line 95 "icalssyacc.y"
-{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
+{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); }
+ break;
+case 17:
+#line 99 "icalssyacc.y"
+{set_logic(yyextra,ICALGAUGELOGIC_NONE);}
+ break;
+case 18:
+#line 100 "icalssyacc.y"
+{set_logic(yyextra,ICALGAUGELOGIC_AND);}
+ break;
+case 19:
+#line 101 "icalssyacc.y"
+{set_logic(yyextra,ICALGAUGELOGIC_OR);}
break;
}
-#line 705 "/usr/share/bison/bison.simple"
+#line 705 "/usr/local/share/bison/bison.simple"
yyvsp -= yylen;
@@ -1231,10 +1248,10 @@ yyreturn:
#endif
return yyresult;
}
-#line 99 "icalssyacc.y"
+#line 105 "icalssyacc.y"
-void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
+static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
icalgaugecompare compare , char* value_str)
{
@@ -1296,7 +1313,7 @@ void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
pvl_push(impl->where,where);
}
-void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
+static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
{
pvl_elem e = pvl_tail(impl->where);
struct icalgauge_where *where = pvl_data(e);
@@ -1307,7 +1324,7 @@ void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
-void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
+static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
{
char *c, *compstr, *propstr;
struct icalgauge_where *where;
@@ -1353,15 +1370,15 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
if(where->prop == ICAL_NO_PROPERTY){
- icalgauge_free(where);
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
+ free(where);
+ icalerror_set_errno(ICAL_BADARG_ERROR);
+ return;
}
pvl_push(impl->select,where);
}
-void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
+static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
{
icalcomponent_kind ckind;
@@ -1377,5 +1394,6 @@ void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
void sserror(char *s){
- fprintf(stderr,"Parse error \'%s\'\n", s);
+ fprintf(stderr,"Parse error \'%s\'\n", s);
+ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
}
diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h
index 7d42f3c..6d03a0f 100644
--- a/libical/src/libicalss/icalssyacc.h
+++ b/libical/src/libicalss/icalssyacc.h
@@ -1,12 +1,11 @@
-#ifndef BISON_ICALSSYACC_H
-# define BISON_ICALSSYACC_H
+#ifndef BISON_Y_TAB_H
+# define BISON_Y_TAB_H
#ifndef YYSTYPE
typedef union {
char* v_string;
} yystype;
# define YYSTYPE yystype
-# define YYSTYPE_IS_TRIVIAL 1
#endif
# define STRING 257
# define SELECT 258
@@ -24,8 +23,9 @@ typedef union {
# define OR 270
# define EOL 271
# define END 272
+# define IS 273
+# define NOT 274
+# define SQLNULL 275
-extern YYSTYPE sslval;
-
-#endif /* not BISON_ICALSSYACC_H */
+#endif /* not BISON_Y_TAB_H */
diff --git a/libical/src/libicalss/libicalss.pro b/libical/src/libicalss/libicalss.pro
index a5cc80c..64b7094 100644
--- a/libical/src/libicalss/libicalss.pro
+++ b/libical/src/libicalss/libicalss.pro
@@ -1,43 +1,43 @@
-include(../../../variables.pri)
+######################################################################
+# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
+######################################################################
+
TEMPLATE = lib
TARGET = icalss
DESTDIR = ../../lib
CONFIG += staticlib
-win32: DEFINES += _WIN32 _QTWIN_
-HEADERS = icalcalendar.h \
- icalclassify.h \
- icalcstp.h \
- icalcstpclient.h \
- icalcstpserver.h \
- icaldirset.h \
- icaldirsetimpl.h \
- icalfileset.h \
- icalfilesetimpl.h \
- icalgauge.h \
- icalgaugeimpl.h \
- icalmessage.h \
- icalset.h \
- icalspanlist.h \
- icalssyacc.h \
- config.h
-
-SOURCES = icalclassify.c \
- icalcstp.c \
- icalcstpclient.c \
- icalcstpserver.c \
- icaldirset.c \
- icalfileset.c \
- icalgauge.c \
- icalmessage.c \
- icalset.c \
- icalspanlist.c \
- icalsslexer.c \
- icalssyacc.c
-
-INTERFACES =
-INCLUDEPATH += ../libical
+INCLUDEPATH += . ../libical
+# Input
+win32 {
+DEFINES += YY_NO_UNISTD_H
-DEFINES += HAVE_CONFIG_H
+}
+HEADERS += icalcalendar.h \
+ icalclassify.h \
+ icalcluster.h \
+ icalclusterimpl.h \
+ icaldirset.h \
+ icaldirsetimpl.h \
+ icalfileset.h \
+ icalfilesetimpl.h \
+ icalgauge.h \
+ icalgaugeimpl.h \
+ icalmessage.h \
+ icalset.h \
+ icalspanlist.h \
+ icalss.h \
+ icalssyacc.h
+SOURCES += icalcalendar.c \
+ icalclassify.c \
+ icalcluster.c \
+ icaldirset.c \
+ icalfileset.c \
+ icalgauge.c \
+ icalmessage.c \
+ icalset.c \
+ icalspanlist.c \
+ icalsslexer.c \
+ icalssyacc.c
diff --git a/libical/src/libicalss/libicalssE.pro b/libical/src/libicalss/libicalssE.pro
index 57d60bd..84ccf47 100644
--- a/libical/src/libicalss/libicalssE.pro
+++ b/libical/src/libicalss/libicalssE.pro
@@ -1,45 +1,41 @@
-TEMPLATE = lib
-CONFIG += warn_on staticlib
-INCLUDEPATH += ../libical
-INCLUDEPATH += .
-DEFINES += HAVE_CONFIG_H
-OBJECTS_DIR = obj/$(PLATFORM)
-MOC_DIR = moc/$(PLATFORM)
-DESTDIR=../../lib/$(PLATFORM)
-TARGET = icalss
+######################################################################
+# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
+######################################################################
-INTERFACES = \
-HEADERS = \
- config.h \
- icalcalendar.h \
- icalclassify.h \
- icalcstp.h \
- icalcstpclient.h \
- icalcstpserver.h \
- icaldirset.h \
- icaldirsetimpl.h \
- icalfileset.h \
- icalfilesetimpl.h \
- icalgauge.h \
- icalgaugeimpl.h \
- icalmessage.h \
- icalset.h \
- icalspanlist.h \
- icalss.h \
- icalssyacc.h \
+TEMPLATE = lib
-SOURCES = \
- icalclassify.c \
- icalcstp.c \
- icalcstpclient.c \
- icalcstpserver.c \
- icaldirset.c \
- icalfileset.c \
- icalgauge.c \
- icalmessage.c \
- icalset.c \
- icalspanlist.c \
- icalsslexer.c \
- icalssyacc.c \
+TARGET = icalss
+CONFIG += staticlib
+OBJECTS_DIR = obj/$(PLATFORM)
+MOC_DIR = moc/$(PLATFORM)
+DESTDIR=../../lib/$(PLATFORM)
+INCLUDEPATH += . ../libical
+# Input
+HEADERS += icalcalendar.h \
+ icalclassify.h \
+ icalcluster.h \
+ icalclusterimpl.h \
+ icaldirset.h \
+ icaldirsetimpl.h \
+ icalfileset.h \
+ icalfilesetimpl.h \
+ icalgauge.h \
+ icalgaugeimpl.h \
+ icalmessage.h \
+ icalset.h \
+ icalspanlist.h \
+ icalss.h \
+ icalssyacc.h
+SOURCES += icalcalendar.c \
+ icalclassify.c \
+ icalcluster.c \
+ icaldirset.c \
+ icalfileset.c \
+ icalgauge.c \
+ icalmessage.c \
+ icalset.c \
+ icalspanlist.c \
+ icalsslexer.c \
+ icalssyacc.c