summaryrefslogtreecommitdiffabout
path: root/libical/src/libicalss
Unidiff
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 @@
1/*======================================================================
2 FILE: icalcalendar.c
3 CREATOR: eric 23 December 1999
4
5 $Id$
6 $Locker$
7
8 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
12
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
15
16 Or:
17
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
20
21 ======================================================================*/
22
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28
29#include "icalcalendar.h"
30#include "icalset.h"
31#include "icalfileset.h"
32#include "icaldirset.h"
33#include <limits.h>
34#include <sys/stat.h> /* For mkdir, stat */
35#include <sys/types.h> /* For mkdir */
36#include <fcntl.h> /* For mkdir */
37
38#ifndef WIN32
39#include <unistd.h> /* For mkdir, stat */
40#endif
41
42#ifndef PATH_MAX
43#define PATH_MAX 512
44#endif
45
46
47#include <stdlib.h> /* for malloc */
48#include <string.h> /* for strcat */
49#include <errno.h>
50
51#define BOOKED_DIR "booked"
52#define INCOMING_FILE "incoming.ics"
53#define PROP_FILE "properties.ics"
54#define FBLIST_FILE "freebusy.ics"
55
56struct icalcalendar_impl
57{
58 char* dir;
59 icalset* freebusy;
60 icalset* properties;
61 icalset* booked;
62 icalset* incoming;
63};
64
65struct icalcalendar_impl* icalcalendar_new_impl(void)
66{
67 struct icalcalendar_impl* impl;
68
69 if ( ( impl = (struct icalcalendar_impl*)
70 malloc(sizeof(struct icalcalendar_impl))) == 0) {
71 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
72 return 0;
73 }
74
75 return impl;
76}
77
78
79icalerrorenum icalcalendar_create(struct icalcalendar_impl* impl)
80{
81 char path[PATH_MAX];
82 struct stat sbuf;
83 int r;
84
85 icalerror_check_arg_re((impl != 0),"impl",ICAL_BADARG_ERROR);
86
87 path[0] = '\0';
88 strcpy(path,impl->dir);
89 strcat(path,"/");
90 strcat(path,BOOKED_DIR);
91
92 r = stat(path,&sbuf);
93
94 if( r != 0 && errno == ENOENT){
95
96 if(mkdir(path,0777)!=0){
97 icalerror_set_errno(ICAL_FILE_ERROR);
98 return ICAL_FILE_ERROR;
99 }
100 }
101
102 return ICAL_NO_ERROR;
103}
104
105icalcalendar* icalcalendar_new(char* dir)
106{
107 struct icalcalendar_impl* impl;
108
109 icalerror_check_arg_rz((dir != 0),"dir");
110
111 impl = icalcalendar_new_impl();
112
113 if (impl == 0){
114 return 0;
115 }
116
117 impl->dir = (char*)strdup(dir);
118 impl->freebusy = 0;
119 impl->properties = 0;
120 impl->booked = 0;
121 impl->incoming = 0;
122
123 if (icalcalendar_create(impl) != ICAL_NO_ERROR){
124 free(impl);
125 return 0;
126 }
127
128 return impl;
129}
130
131void icalcalendar_free(icalcalendar* impl)
132{
133 if (impl->dir !=0){
134 free(impl->dir);
135 }
136
137 if (impl->freebusy !=0){
138 icalset_free(impl->booked);
139 }
140
141 if (impl->properties !=0){
142 icalset_free(impl->properties);
143 }
144
145 if (impl->booked !=0){
146 icalset_free(impl->booked);
147 }
148
149 if (impl->incoming !=0){
150 icalset_free(impl->incoming);
151 }
152
153 impl->dir = 0;
154 impl->freebusy = 0;
155 impl->properties = 0;
156 impl->booked = 0;
157 impl->incoming = 0;
158
159
160 free(impl);
161}
162
163
164int icalcalendar_lock(icalcalendar* impl)
165{
166 icalerror_check_arg_rz((impl != 0),"impl");
167 return 0;
168}
169
170int icalcalendar_unlock(icalcalendar* impl)
171{
172 icalerror_check_arg_rz((impl != 0),"impl");
173 return 0;
174}
175
176int icalcalendar_islocked(icalcalendar* impl)
177{
178 icalerror_check_arg_rz((impl != 0),"impl");
179 return 0;
180}
181
182int icalcalendar_ownlock(icalcalendar* impl)
183{
184 icalerror_check_arg_rz((impl != 0),"impl");
185 return 0;
186}
187
188icalset* icalcalendar_get_booked(icalcalendar* impl)
189{
190 char dir[PATH_MAX];
191
192 icalerror_check_arg_rz((impl != 0),"impl");
193
194 dir[0] = '\0';
195 strcpy(dir,impl->dir);
196 strcat(dir,"/");
197 strcat(dir,BOOKED_DIR);
198
199 if (impl->booked == 0){
200 icalerror_clear_errno();
201 impl->booked = icaldirset_new(dir);
202 assert(icalerrno == ICAL_NO_ERROR);
203 }
204
205 return impl->booked;
206
207}
208
209icalset* icalcalendar_get_incoming(icalcalendar* impl)
210{
211 char path[PATH_MAX];
212 icalerror_check_arg_rz((impl != 0),"impl");
213
214 path[0] = '\0';
215 strcpy(path,impl->dir);
216 strcat(path,"/");
217 strcat(path,INCOMING_FILE);
218
219 if (impl->properties == 0){
220 impl->properties = icalfileset_new(path);
221 }
222
223 return impl->properties;
224}
225
226icalset* icalcalendar_get_properties(icalcalendar* impl)
227{
228 char path[PATH_MAX];
229 icalerror_check_arg_rz((impl != 0),"impl");
230
231 path[0] = '\0';
232 strcpy(path,impl->dir);
233 strcat(path,"/");
234 strcat(path,PROP_FILE);
235
236 if (impl->properties == 0){
237 impl->properties = icalfileset_new(path);
238 }
239
240 return impl->properties;
241}
242
243icalset* icalcalendar_get_freebusy(icalcalendar* impl)
244{
245 char path[PATH_MAX];
246 icalerror_check_arg_rz((impl != 0),"impl");
247
248 path[0] = '\0';
249 strcpy(path,impl->dir);
250 strcat(path,"/");
251 strcat(path,FBLIST_FILE);
252
253
254 if (impl->freebusy == 0){
255 impl->freebusy = icalfileset_new(path);
256 }
257
258 return impl->freebusy;
259}
260
261
262
263
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 @@
38 * components. It also has interfaces to access the free/busy list 38 * components. It also has interfaces to access the free/busy list
39 * and a list of calendar properties */ 39 * and a list of calendar properties */
40 40
41typedef void icalcalendar; 41typedef struct icalcalendar_impl icalcalendar;
42 42
43icalcalendar* icalcalendar_new(char* dir); 43icalcalendar* icalcalendar_new(char* dir);
44 44
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 @@
26#include "config.h" 26#include "config.h"
27#endif 27#endif
28 28
29#include "icalerror.h"
30#include "ical.h" 29#include "ical.h"
31#include "icalclassify.h" 30#include "icalclassify.h"
32#include "icalmemory.h" 31#include "icalmemory.h"
32
33#include <ctype.h> /* For tolower() */ 33#include <ctype.h> /* For tolower() */
34#include <string.h> /* for index() */ 34#include <string.h> /* for index() */
35#include <stdlib.h> /* for malloc and free */ 35#include <stdlib.h> /* for malloc and free */
@@ -146,7 +146,7 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
146 p != 0; 146 p != 0;
147 p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) 147 p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY))
148 { 148 {
149 const char* this_attendee 149 char* this_attendee
150 = icalclassify_lowercase(icalproperty_get_attendee(p)); 150 = icalclassify_lowercase(icalproperty_get_attendee(p));
151 char* this_upn = strchr(this_attendee,':'); 151 char* this_upn = strchr(this_attendee,':');
152 152
@@ -157,10 +157,14 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
157 } 157 }
158 158
159 if(strcmp(this_upn,upn)==0){ 159 if(strcmp(this_upn,upn)==0){
160 free(lattendee);
161 free(this_attendee);
160 return p; 162 return p;
161 } 163 }
162 164
165 free(this_attendee);
163 } 166 }
167 free(lattendee);
164 168
165 return 0; 169 return 0;
166 170
@@ -284,7 +288,7 @@ int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b)
284 p1 = icalcomponent_get_first_property(i1,kind_array[i]); 288 p1 = icalcomponent_get_first_property(i1,kind_array[i]);
285 p2 = icalcomponent_get_first_property(i2,kind_array[i]); 289 p2 = icalcomponent_get_first_property(i2,kind_array[i]);
286 290
287 if( (p1!=0)^(p1!=0) ){ 291 if( (p1!=0)^(p2!=0) ){
288 /* Return true if the property exists in one component and not 292 /* Return true if the property exists in one component and not
289 the other */ 293 the other */
290 return 1; 294 return 1;
@@ -546,7 +550,6 @@ int icalclassify_reply_crasher_decline(
546 struct icalclassify_parts *match, 550 struct icalclassify_parts *match,
547 const char* user) 551 const char* user)
548{ 552{
549 icalparameter_partstat partstat;
550 icalproperty* attendee; 553 icalproperty* attendee;
551 icalclassify_pre; 554 icalclassify_pre;
552 555
@@ -642,47 +645,47 @@ int icalclassify_delinecounter(
642struct icalclassify_map { 645struct icalclassify_map {
643 icalproperty_method method; 646 icalproperty_method method;
644 int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); 647 int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user);
645 ical_class class; 648 icalproperty_xlicclass class;
646} icalclassify_map[] = 649} icalclassify_map[] =
647{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS}, 650{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_XLICCLASS_PUBLISHNEW},
648 {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS}, 651 {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_XLICCLASS_PUBLISHUPDATE},
649 {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS}, 652 {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_XLICCLASS_PUBLISHFREEBUSY},
650 {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS}, 653 {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_XLICCLASS_REQUESTDELEGATE},
651 {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS}, 654 {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_XLICCLASS_REQUESTNEW},
652 {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS}, 655 {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_XLICCLASS_REQUESTUPDATE},
653 {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS}, 656 {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_XLICCLASS_REQUESTRESCHEDULE},
654 657
655 {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS}, 658 {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_XLICCLASS_REQUESTNEWORGANIZER},
656 {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS}, 659 {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_XLICCLASS_REQUESTFORWARD},
657 {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS}, 660 {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_XLICCLASS_REQUESTSTATUS},
658 {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS}, 661 {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_XLICCLASS_REQUESTFREEBUSY},
659 662
660 {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS}, 663 {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_XLICCLASS_REPLYACCEPT},
661 {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS}, 664 {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_XLICCLASS_REPLYDECLINE},
662 {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_REPLY_DELEGATE_CLASS}, 665 {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_XLICCLASS_REPLYDELEGATE},
663 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS}, 666 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_XLICCLASS_REPLYCRASHERACCEPT},
664 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS}, 667 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_XLICCLASS_REPLYCRASHERDECLINE},
665 668
666 {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS}, 669 {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_XLICCLASS_ADDINSTANCE},
667 670
668 {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS}, 671 {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_XLICCLASS_CANCELEVENT},
669 {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS}, 672 {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_XLICCLASS_CANCELINSTANCE},
670 {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS}, 673 {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_XLICCLASS_CANCELALL},
671 674
672 {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS}, 675 {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_XLICCLASS_REFRESH},
673 {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS}, 676 {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_XLICCLASS_COUNTER},
674 {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS}, 677 {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_XLICCLASS_DECLINECOUNTER},
675 {ICAL_METHOD_NONE,0,ICAL_NO_CLASS} 678 {ICAL_METHOD_NONE,0,ICAL_XLICCLASS_NONE}
676}; 679};
677 680
678 681
679ical_class icalclassify(icalcomponent* c,icalcomponent* match, 682icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
680 const char* user) 683 const char* user)
681{ 684{
682 icalcomponent *inner; 685 icalcomponent *inner;
683 icalproperty *p; 686 icalproperty *p;
684 icalproperty_method method; 687 icalproperty_method method;
685 ical_class class = ICAL_UNKNOWN_CLASS; 688 icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN;
686 689
687 int i; 690 int i;
688 691
@@ -692,7 +695,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
692 inner = icalcomponent_get_first_real_component(c); 695 inner = icalcomponent_get_first_real_component(c);
693 696
694 if (inner == 0) { 697 if (inner == 0) {
695 return ICAL_NO_CLASS; 698 return ICAL_XLICCLASS_NONE;
696 } 699 }
697 700
698 icalssutil_get_parts(c,&comp_parts); 701 icalssutil_get_parts(c,&comp_parts);
@@ -709,7 +712,8 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
709 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0) 712 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
710 { 713 {
711 /* comp has a smaller sequence and a later DTSTAMP */ 714 /* comp has a smaller sequence and a later DTSTAMP */
712 return ICAL_MISSEQUENCED_CLASS; 715 class = ICAL_XLICCLASS_MISSEQUENCED;
716 goto CLEANUP;
713 } 717 }
714 718
715 if( (comp_parts.sequence<match_parts.sequence ) 719 if( (comp_parts.sequence<match_parts.sequence )
@@ -718,14 +722,16 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
718 ( comp_parts.sequence == match_parts.sequence && 722 ( comp_parts.sequence == match_parts.sequence &&
719 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){ 723 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){
720 724
721 return ICAL_OBSOLETE_CLASS; 725 class = ICAL_XLICCLASS_OBSOLETE;
726 goto CLEANUP;
722 } 727 }
723 728
724 } 729 }
725 730
726 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); 731 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
727 if (p == 0) { 732 if (p == 0) {
728 return ICAL_UNKNOWN_CLASS; 733 class = ICAL_XLICCLASS_UNKNOWN;
734 goto CLEANUP;
729 } 735 }
730 method = icalproperty_get_method(p); 736 method = icalproperty_get_method(p);
731 737
@@ -738,6 +744,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
738 } 744 }
739 } 745 }
740 746
747CLEANUP:
741 icalssutil_free_parts(&comp_parts); 748 icalssutil_free_parts(&comp_parts);
742 icalssutil_free_parts(&match_parts); 749 icalssutil_free_parts(&match_parts);
743 750
@@ -745,48 +752,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
745 752
746} 753}
747 754
748struct class_map {
749 ical_class class;
750 char *str;
751} class_map[] = {
752 {ICAL_NO_CLASS,"No class"},
753 {ICAL_PUBLISH_NEW_CLASS,"New Publish"},
754 {ICAL_PUBLISH_UPDATE_CLASS,"Publish Update"},
755 {ICAL_PUBLISH_FREEBUSY_CLASS,"Publish freebusy"},
756 {ICAL_REQUEST_NEW_CLASS,"New request"},
757 {ICAL_REQUEST_UPDATE_CLASS,"Update"},
758 {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"},
759 {ICAL_REQUEST_DELEGATE_CLASS,"Delegate request"},
760 {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"},
761 {ICAL_REQUEST_FORWARD_CLASS,"Forward"},
762 {ICAL_REQUEST_STATUS_CLASS,"Status request"},
763 {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"},
764 {ICAL_REPLY_DECLINE_CLASS,"Decline reply"},
765 {ICAL_REPLY_DELEGATE_CLASS,"Delegation reply"},
766 {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"},
767 {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"},
768 {ICAL_ADD_INSTANCE_CLASS,"Add instance"},
769 {ICAL_CANCEL_EVENT_CLASS,"Cancel event"},
770 {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"},
771 {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"},
772 {ICAL_REFRESH_CLASS,"Refresh"},
773 {ICAL_COUNTER_CLASS,"Counter"},
774 {ICAL_DECLINECOUNTER_CLASS,"Decline counter"},
775 {ICAL_MALFORMED_CLASS,"Malformed"},
776 {ICAL_OBSOLETE_CLASS,"Obsolete"},
777 {ICAL_MISSEQUENCED_CLASS,"Missequenced"},
778 {ICAL_UNKNOWN_CLASS,"Unknown"}
779};
780
781char* icalclassify_class_to_string(ical_class class)
782{
783 int i;
784
785 for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){
786 if (class_map[i].class == class){
787 return class_map[i].str;
788 }
789 }
790
791 return "Unknown";
792}
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 @@
29#include "ical.h" 29#include "ical.h"
30#include "icalset.h" 30#include "icalset.h"
31 31
32 32icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
33typedef enum icalclass {
34 ICAL_NO_CLASS,
35 ICAL_PUBLISH_NEW_CLASS,
36 ICAL_PUBLISH_UPDATE_CLASS,
37 ICAL_PUBLISH_FREEBUSY_CLASS,
38 ICAL_REQUEST_NEW_CLASS,
39 ICAL_REQUEST_UPDATE_CLASS,
40 ICAL_REQUEST_RESCHEDULE_CLASS,
41 ICAL_REQUEST_DELEGATE_CLASS,
42 ICAL_REQUEST_NEW_ORGANIZER_CLASS,
43 ICAL_REQUEST_FORWARD_CLASS,
44 ICAL_REQUEST_STATUS_CLASS,
45 ICAL_REQUEST_FREEBUSY_CLASS,
46 ICAL_REPLY_ACCEPT_CLASS,
47 ICAL_REPLY_DECLINE_CLASS,
48 ICAL_REPLY_DELEGATE_CLASS,
49 ICAL_REPLY_CRASHER_ACCEPT_CLASS,
50 ICAL_REPLY_CRASHER_DECLINE_CLASS,
51 ICAL_ADD_INSTANCE_CLASS,
52 ICAL_CANCEL_EVENT_CLASS,
53 ICAL_CANCEL_INSTANCE_CLASS,
54 ICAL_CANCEL_ALL_CLASS,
55 ICAL_REFRESH_CLASS,
56 ICAL_COUNTER_CLASS,
57 ICAL_DECLINECOUNTER_CLASS,
58 ICAL_MALFORMED_CLASS,
59 ICAL_OBSOLETE_CLASS, /* 21 */
60 ICAL_MISSEQUENCED_CLASS, /* 22 */
61 ICAL_UNKNOWN_CLASS /* 23 */
62} ical_class;
63
64ical_class icalclassify(icalcomponent* c,icalcomponent* match,
65 const char* user); 33 const char* user);
66 34
67icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); 35icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
68 36
69char* icalclassify_class_to_string(ical_class iclass); 37char* icalclassify_class_to_string(icalproperty_xlicclass c);
70 38
71 39
72#endif /* ICALCLASSIFY_H*/ 40#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 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalcluster.c
4 CREATOR: acampi 13 March 2002
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2002, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The Original Code is eric. The Initial Developer of the Original
23 Code is Eric Busboom
24
25
26 ======================================================================*/
27
28
29/**
30 *
31 * icalcluster is an utility class design to manage clusters of
32 * icalcomponents on behalf of an implementation of icalset. This is
33 * done in order to split out common behavior different classes might
34 * need.
35 * The definition of what exactly a cluster will contain depends on the
36 * icalset subclass. At the basic level, an icluster is just a tuple,
37 * with anything as key and an icalcomponent as value.
38 */
39
40
41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
45#include <stdlib.h>
46#include <string.h>
47
48#if 0
49#include <errno.h>
50#include <sys/stat.h> /* for stat */
51#ifndef WIN32
52#include <unistd.h> /* for stat, getpid */
53#else
54#include <io.h>
55#include <share.h>
56#endif
57#include <fcntl.h> /* for fcntl */
58#endif
59
60#include "icalcluster.h"
61#include "icalclusterimpl.h"
62#include "icalgauge.h"
63
64#ifdef WIN32
65 #define snprintf_snprintf
66 #define strcasecmpstricmp
67#endif
68
69
70icalcluster * icalcluster_new_impl(void) {
71
72 struct icalcluster_impl* impl;
73
74 if ((impl = (struct icalcluster_impl*)malloc(
75 sizeof(struct icalcluster_impl))) == 0) {
76 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
77 return 0;
78 }
79
80 memset(impl, 0, sizeof(struct icalcluster_impl));
81 strcpy(impl->id,ICALCLUSTER_ID);
82
83 return impl;
84}
85
86/**
87 * Create a cluster with a key/value pair.
88 *
89 * @todo Always do a deep copy.
90 */
91
92icalcluster * icalcluster_new(const char* key, icalcomponent *data) {
93 struct icalcluster_impl *impl = icalcluster_new_impl();
94 assert(impl->data == 0);
95
96 impl->key= strdup(key);
97 impl->changed= 0;
98 impl->data= 0;
99
100 if (data != NULL) {
101 if (icalcomponent_isa(data) != ICAL_XROOT_COMPONENT) {
102 impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
103 icalcomponent_add_component(impl->data, data);
104 } else {
105 impl->data = icalcomponent_new_clone(data);
106 }
107 } else {
108 impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
109 }
110
111 return impl;
112}
113
114/**
115 * Deep clone an icalcluster to a new one
116 */
117
118icalcluster *icalcluster_new_clone(const icalcluster *data) {
119 struct icalcluster_impl *old = (struct icalcluster_impl *)data;
120 struct icalcluster_impl *impl = icalcluster_new_impl();
121
122 impl->key= strdup(old->key);
123 impl->data= icalcomponent_new_clone(old->data);
124 impl->changed= 0;
125
126 return impl;
127}
128
129
130void icalcluster_free(icalcluster *impl) {
131 icalerror_check_arg_rv((impl!=0),"cluster");
132
133 if (impl->key != 0){
134 free(impl->key);
135 impl->key = 0;
136 }
137
138 if (impl->data != 0){
139 icalcomponent_free(impl->data);
140 impl->data = 0;
141 }
142
143 free(impl);
144}
145
146
147const char *icalcluster_key(icalcluster *impl) {
148 icalerror_check_arg_rz((impl!=0),"cluster");
149
150 return impl->key;
151}
152
153
154int icalcluster_is_changed(icalcluster *impl) {
155 icalerror_check_arg_rz((impl!=0),"cluster");
156
157 return impl->changed;
158}
159
160
161void icalcluster_mark(icalcluster *impl) {
162 icalerror_check_arg_rv((impl!=0),"cluster");
163
164 impl->changed = 1;
165}
166
167
168void icalcluster_commit(icalcluster *impl) {
169 icalerror_check_arg_rv((impl!=0),"cluster");
170
171 impl->changed = 0;
172}
173
174
175icalcomponent *icalcluster_get_component(icalcluster *impl) {
176
177 icalerror_check_arg_rz((impl!=0),"cluster");
178
179 if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) {
180 icalerror_warn("The top component is not an XROOT");
181 fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data));
182 abort();
183 }
184
185 return impl->data;
186}
187
188
189icalerrorenum icalcluster_add_component(icalcluster *impl, icalcomponent* child) {
190
191 icalerror_check_arg_re((impl!=0),"cluster", ICAL_BADARG_ERROR);
192 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
193
194 icalcomponent_add_component(impl->data, child);
195 icalcluster_mark(impl);
196
197 return ICAL_NO_ERROR;
198}
199
200
201icalerrorenum icalcluster_remove_component(icalcluster *impl, icalcomponent* child) {
202
203 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
204 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
205
206 icalcomponent_remove_component(impl->data,child);
207 icalcluster_mark(impl);
208
209 return ICAL_NO_ERROR;
210}
211
212
213int icalcluster_count_components(icalcluster *impl, icalcomponent_kind kind) {
214
215 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
216
217 return icalcomponent_count_components(impl->data, kind);
218}
219
220
221/** Iterate through components **/
222icalcomponent *icalcluster_get_current_component(icalcluster* impl) {
223
224 icalerror_check_arg_rz((impl!=0),"cluster");
225
226 return icalcomponent_get_current_component(impl->data);
227}
228
229
230icalcomponent *icalcluster_get_first_component(icalcluster* impl) {
231
232 icalerror_check_arg_rz((impl!=0),"cluster");
233
234 return icalcomponent_get_first_component(impl->data,
235 ICAL_ANY_COMPONENT);
236}
237
238
239icalcomponent *icalcluster_get_next_component(icalcluster* impl) {
240
241 icalerror_check_arg_rz((impl!=0),"cluster");
242
243 return icalcomponent_get_next_component(impl->data,
244 ICAL_ANY_COMPONENT);
245}
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 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcluster.h
4 CREATOR: eric 23 December 1999
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23 The Original Code is eric. The Initial Developer of the Original
24 Code is Eric Busboom
25
26
27======================================================================*/
28
29#ifndef ICALCLUSTER_H
30#define ICALCLUSTER_H
31
32#include "ical.h"
33#include "icalset.h"
34
35typedef struct icalcluster_impl icalcluster;
36
37icalcluster* icalcluster_new(const char *key, icalcomponent *data);
38icalcluster* icalcluster_new_clone(const icalcluster *cluster);
39
40void icalcluster_free(icalcluster *cluster);
41
42const char* icalcluster_key(icalcluster *cluster);
43int icalcluster_is_changed(icalcluster *cluster);
44void icalcluster_mark(icalcluster *cluster);
45void icalcluster_commit(icalcluster *cluster);
46
47icalcomponent* icalcluster_get_component(icalcluster* cluster);
48int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
49icalerrorenum icalcluster_add_component(icalcluster* cluster,
50 icalcomponent* child);
51icalerrorenum icalcluster_remove_component(icalcluster* cluster,
52 icalcomponent* child);
53
54icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
55icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
56icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
57
58#endif /* !ICALCLUSTER_H */
59
60
61
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 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalfilesetimpl.h
4 CREATOR: eric 23 December 1999
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The Original Code is eric. The Initial Developer of the Original
23 Code is Eric Busboom
24
25
26 ======================================================================*/
27
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33/* This definition is in its own file so it can be kept out of the
34 main header file, but used by "friend classes" like icaldirset*/
35
36#define ICALCLUSTER_ID "clus"
37
38struct icalcluster_impl {
39
40 char id[5]; /* clus */
41
42 char *key;
43 icalcomponent *data;
44 int changed;
45};
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 @@
26 ======================================================================*/ 26 ======================================================================*/
27 27
28 28
29/* 29/**
30 @file icaldirset.c
30 31
31 icaldirset manages a database of ical components and offers 32 @brief icaldirset manages a database of ical components and offers
32 interfaces for reading, writting and searching for components. 33 interfaces for reading, writting and searching for components.
33 34
34 icaldirset groups components in to clusters based on their DTSTAMP 35 icaldirset groups components in to clusters based on their DTSTAMP
@@ -36,12 +37,13 @@
36 together in a single file. All files in a sotre are kept in a single 37 together in a single file. All files in a sotre are kept in a single
37 directory. 38 directory.
38 39
39 The primary interfaces are icaldirset_first and icaldirset_next. These 40 The primary interfaces are icaldirset__get_first_component and
40 routine iterate through all of the components in the store, subject 41 icaldirset_get_next_component. These routine iterate through all of
41 to the current gauge. A gauge is an icalcomponent that is tested 42 the components in the store, subject to the current gauge. A gauge
42 against other componets for a match. If a gauge has been set with 43 is an icalcomponent that is tested against other componets for a
43 icaldirset_select, icaldirset_first and icaldirset_next will only 44 match. If a gauge has been set with icaldirset_select,
44 return componentes that match the gauge. 45 icaldirset_first and icaldirset_next will only return componentes
46 that match the gauge.
45 47
46 The Store generated UIDs for all objects that are stored if they do 48 The Store generated UIDs for all objects that are stored if they do
47 not already have a UID. The UID is the name of the cluster (month & 49 not already have a UID. The UID is the name of the cluster (month &
@@ -55,75 +57,76 @@
55#endif 57#endif
56 58
57 59
58#include "icalerror.h"
59#include "ical.h" 60#include "ical.h"
60#include "icaldirset.h" 61#include "icaldirset.h"
61#include "pvl.h"
62#include "icalparser.h"
63#include "icaldirset.h" 62#include "icaldirset.h"
64#include "icalfileset.h" 63#include "icalfileset.h"
65#include "icalfilesetimpl.h" 64#include "icalfilesetimpl.h"
65#include "icalcluster.h"
66#include "icalgauge.h" 66#include "icalgauge.h"
67 67
68#include <limits.h> /* For PATH_MAX */ 68#include <limits.h> /* For PATH_MAX */
69#include <errno.h> 69#ifndef WIN32
70#include <sys/types.h> /* for opendir() */
71#include <sys/stat.h> /* for stat */
72
73int snprintf(char *str, size_t n, char const *fmt, ...);
74
75// Eugen C. <eug@thekompany.com>
76#include <defines.h>
77#ifndef _QTWIN_
78#include <dirent.h> /* for opendir() */ 70#include <dirent.h> /* for opendir() */
79#include <unistd.h> 71#include <unistd.h> /* for stat, getpid */
80#include <sys/utsname.h> /* for uname */ 72#include <sys/utsname.h> /* for uname */
73#else
74#include <io.h>
75#include <process.h>
81#endif 76#endif
82// Eugen C. <eug@thekompany.com> 77#include <errno.h>
83 78#include <sys/types.h> /* for opendir() */
79#include <sys/stat.h> /* for stat */
84#include <time.h> /* for clock() */ 80#include <time.h> /* for clock() */
85#include <stdlib.h> /* for rand(), srand() */ 81#include <stdlib.h> /* for rand(), srand() */
86#include <string.h> /* for strdup */ 82#include <string.h> /* for strdup */
87#include "icaldirsetimpl.h" 83#include "icaldirsetimpl.h"
88 84
89 85
90struct icaldirset_impl* icaldirset_new_impl() 86#ifdef WIN32
91{ 87 #define snprintf_snprintf
92 struct icaldirset_impl* impl; 88 #define strcasecmpstricmp
93 89
94 if ( ( impl = (struct icaldirset_impl*) 90#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
95 malloc(sizeof(struct icaldirset_impl))) == 0) { 91
96 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 92#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
97 return 0; 93#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
98 } 94#endif
99 95
100 strcpy(impl->id,ICALDIRSET_ID); 96/** Default options used when NULL is passed to icalset_new() **/
97icaldirset_options icaldirset_options_default = {O_RDWR|O_CREAT};
101 98
102 return impl;
103}
104 99
105const char* icaldirset_path(icaldirset* cluster) 100const char* icaldirset_path(icalset* set)
106{ 101{
107 struct icaldirset_impl *impl = icaldirset_new_impl(); 102 icaldirset *dset = (icaldirset*)set;
108
109 return impl->dir;
110 103
104 return dset->dir;
111} 105}
112 106
113void icaldirset_mark(icaldirset* store) 107
108void icaldirset_mark(icalset* set)
114{ 109{
115 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 110 icaldirset *dset = (icaldirset*)set;
116 111
117 icalfileset_mark(impl->cluster); 112 icalcluster_mark(dset->cluster);
118} 113}
119 114
120 115
121icalerrorenum icaldirset_commit(icaldirset* store) 116icalerrorenum icaldirset_commit(icalset* set)
122{ 117{
123 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 118 icaldirset *dset = (icaldirset*)set;
119 icalset *fileset;
120 icalfileset_options options = icalfileset_options_default;
124 121
125 return icalfileset_commit(impl->cluster); 122 options.cluster = dset->cluster;
126 123
124 fileset = icalset_new(ICAL_FILE_SET, icalcluster_key(dset->cluster), &options);
125
126 fileset->commit(fileset);
127 fileset->free(fileset);
128
129 return ICAL_NO_ERROR;
127} 130}
128 131
129void icaldirset_lock(const char* dir) 132void icaldirset_lock(const char* dir)
@@ -136,22 +139,22 @@ void icaldirset_unlock(const char* dir)
136} 139}
137 140
138/* Load the contents of the store directory into the store's internal directory list*/ 141/* Load the contents of the store directory into the store's internal directory list*/
139icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl) 142icalerrorenum icaldirset_read_directory(icaldirset *dset)
140{ 143{
141#ifndef _QTWIN_ 144 char *str;
145#ifndef WIN32
142 struct dirent *de; 146 struct dirent *de;
143 DIR* dp; 147 DIR* dp;
144 char *str;
145 148
146 dp = opendir(impl->dir); 149 dp = opendir(dset->dir);
147 150
148 if ( dp == 0) { 151 if (dp == 0) {
149 icalerror_set_errno(ICAL_FILE_ERROR); 152 icalerror_set_errno(ICAL_FILE_ERROR);
150 return ICAL_FILE_ERROR; 153 return ICAL_FILE_ERROR;
151 } 154 }
152 155
153 /* clear contents of directory list */ 156 /* clear contents of directory list */
154 while((str = pvl_pop(impl->directory))){ 157 while((str = pvl_pop(dset->directory))){
155 free(str); 158 free(str);
156 } 159 }
157 160
@@ -166,106 +169,143 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
166 continue; 169 continue;
167 } 170 }
168 171
169 pvl_push(impl->directory, (void*)strdup(de->d_name)); 172 pvl_push(dset->directory, (void*)strdup(de->d_name));
170 } 173 }
171 174
172 closedir(dp); 175 closedir(dp);
173
174 return ICAL_NO_ERROR;
175#else 176#else
176 icalerror_set_errno(ICAL_FILE_ERROR); 177 struct _finddata_t c_file;
177 return ICAL_FILE_ERROR; 178 long hFile;
179
180 /* Find first .c file in current directory */
181 if( (hFile = _findfirst( "*", &c_file )) == -1L ) {
182 icalerror_set_errno(ICAL_FILE_ERROR);
183 return ICAL_FILE_ERROR;
184 } else {
185 while((str = pvl_pop(dset->directory))){
186 free(str);
187 }
188
189 /* load all of the cluster names in the directory list */
190 do {
191 /* Remove known directory names '.' and '..'*/
192 if (strcmp(c_file.name,".") == 0 ||
193 strcmp(c_file.name,"..") == 0 ){
194 continue;
195 }
196
197 pvl_push(dset->directory, (void*)strdup(c_file.name));
198 }
199 while ( _findnext( hFile, &c_file ) == 0 );
200
201 _findclose( hFile );
202 }
203
178#endif 204#endif
205
206 return ICAL_NO_ERROR;
179} 207}
180 208
181icaldirset* icaldirset_new(const char* dir) 209
210icalset* icaldirset_init(icalset* set, const char* dir, void* options_in)
182{ 211{
183 struct icaldirset_impl *impl = icaldirset_new_impl(); 212 icaldirset *dset = (icaldirset*)set;
213 icaldirset_options *options = options_in;
184 struct stat sbuf; 214 struct stat sbuf;
185 215
186 if (impl == 0){
187 return 0;
188 }
189
190 icalerror_check_arg_rz( (dir!=0), "dir"); 216 icalerror_check_arg_rz( (dir!=0), "dir");
217 icalerror_check_arg_rz( (set!=0), "set");
191 218
192 if (stat(dir,&sbuf) != 0){ 219 if (stat(dir,&sbuf) != 0){
193 icalerror_set_errno(ICAL_FILE_ERROR); 220 icalerror_set_errno(ICAL_FILE_ERROR);
194 return 0; 221 return 0;
195 } 222 }
196 223
197#ifndef _QTWIN_
198 /* dir is not the name of a direectory*/ 224 /* dir is not the name of a direectory*/
199 if (!S_ISDIR(sbuf.st_mode)){ 225 if (!S_ISDIR(sbuf.st_mode)){
200 icalerror_set_errno(ICAL_USAGE_ERROR); 226 icalerror_set_errno(ICAL_USAGE_ERROR);
201 return 0; 227 return 0;
202 } 228 }
203#endif
204 229
205 icaldirset_lock(dir); 230 icaldirset_lock(dir);
206 231
207 impl = icaldirset_new_impl(); 232 dset->dir = (char*)strdup(dir);
233 dset->options = *options;
234 dset->directory = pvl_newlist();
235 dset->directory_iterator = 0;
236 dset->gauge = 0;
237 dset->first_component = 0;
238 dset->cluster = 0;
239
240 return set;
241}
242
243icalset* icaldirset_new(const char* dir)
244{
245 return icalset_new(ICAL_DIR_SET, dir, &icaldirset_options_default);
246}
208 247
209 if (impl ==0){
210 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
211 return 0;
212 }
213 248
214 impl->directory = pvl_newlist(); 249icalset* icaldirset_new_reader(const char* dir)
215 impl->directory_iterator = 0; 250{
216 impl->dir = (char*)strdup(dir); 251 icaldirset_options reader_options = icaldirset_options_default;
217 impl->gauge = 0;
218 impl->first_component = 0;
219 impl->cluster = 0;
220 252
221 icaldirset_read_directory(impl); 253 reader_options.flags = O_RDONLY;
222 254
223 return (icaldirset*) impl; 255 return icalset_new(ICAL_DIR_SET, dir, &reader_options);
224} 256}
225 257
226void icaldirset_free(icaldirset* s) 258
259icalset* icaldirset_new_writer(const char* dir)
227{ 260{
228 struct icaldirset_impl *impl = (struct icaldirset_impl*)s; 261 icaldirset_options writer_options = icaldirset_options_default;
262
263 writer_options.flags = O_RDWR|O_CREAT;
264
265 return icalset_new(ICAL_DIR_SET, dir, &writer_options);
266}
267
268
269void icaldirset_free(icalset* s)
270{
271 icaldirset *dset = (icaldirset*)s;
229 char* str; 272 char* str;
230 273
231 icaldirset_unlock(impl->dir); 274 icaldirset_unlock(dset->dir);
232 275
233 if(impl->dir !=0){ 276 if(dset->dir !=0){
234 free(impl->dir); 277 free(dset->dir);
278 dset->dir = 0;
235 } 279 }
236 280
237 if(impl->gauge !=0){ 281 if(dset->gauge !=0){
238 icalcomponent_free(impl->gauge); 282 icalgauge_free(dset->gauge);
283 dset->gauge = 0;
239 } 284 }
240 285
241 if(impl->cluster !=0){ 286 if(dset->cluster !=0){
242 icalfileset_free(impl->cluster); 287 icalcluster_free(dset->cluster);
243 } 288 }
244 289
245 while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){ 290 while(dset->directory !=0 && (str=pvl_pop(dset->directory)) != 0){
246 free(str); 291 free(str);
247 } 292 }
248 293
249 if(impl->directory != 0){ 294 if(dset->directory != 0){
250 pvl_free(impl->directory); 295 pvl_free(dset->directory);
296 dset->directory = 0;
251 } 297 }
252 298
253 impl->directory = 0; 299 dset->directory_iterator = 0;
254 impl->directory_iterator = 0; 300 dset->first_component = 0;
255 impl->dir = 0;
256 impl->gauge = 0;
257 impl->first_component = 0;
258
259 free(impl);
260
261} 301}
262 302
303
263/* icaldirset_next_uid_number updates a serial number in the Store 304/* icaldirset_next_uid_number updates a serial number in the Store
264 directory in a file called SEQUENCE */ 305 directory in a file called SEQUENCE */
265 306
266int icaldirset_next_uid_number(icaldirset* store) 307int icaldirset_next_uid_number(icaldirset* dset)
267{ 308{
268 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
269 char sequence = 0; 309 char sequence = 0;
270 char temp[128]; 310 char temp[128];
271 char filename[ICAL_PATH_MAX]; 311 char filename[ICAL_PATH_MAX];
@@ -273,16 +313,12 @@ int icaldirset_next_uid_number(icaldirset* store)
273 FILE *f; 313 FILE *f;
274 struct stat sbuf; 314 struct stat sbuf;
275 315
276 icalerror_check_arg_rz( (store!=0), "store"); 316 icalerror_check_arg_rz( (dset!=0), "dset");
277 317
278 sprintf(filename,"%s/%s",impl->dir,"SEQUENCE"); 318 sprintf(filename,"%s/%s",dset->dir,"SEQUENCE");
279 319
280 /* Create the file if it does not exist.*/ 320 /* Create the file if it does not exist.*/
281#ifndef _QTWIN_
282 if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){ 321 if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){
283#else
284 if (stat(filename,&sbuf) == -1){
285#endif
286 322
287 f = fopen(filename,"w"); 323 f = fopen(filename,"w");
288 if (f != 0){ 324 if (f != 0){
@@ -292,7 +328,6 @@ int icaldirset_next_uid_number(icaldirset* store)
292 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); 328 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
293 return 0; 329 return 0;
294 } 330 }
295
296 } 331 }
297 332
298 if ( (f = fopen(filename,"r+")) != 0){ 333 if ( (f = fopen(filename,"r+")) != 0){
@@ -318,89 +353,85 @@ int icaldirset_next_uid_number(icaldirset* store)
318 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); 353 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
319 return 0; 354 return 0;
320 } 355 }
321
322} 356}
323 357
324icalerrorenum icaldirset_next_cluster(icaldirset* store) 358icalerrorenum icaldirset_next_cluster(icaldirset* dset)
325{ 359{
326 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
327 char path[ICAL_PATH_MAX]; 360 char path[ICAL_PATH_MAX];
328 361
329 if (impl->directory_iterator == 0){ 362 if (dset->directory_iterator == 0){
330 icalerror_set_errno(ICAL_INTERNAL_ERROR); 363 icalerror_set_errno(ICAL_INTERNAL_ERROR);
331 return ICAL_INTERNAL_ERROR; 364 return ICAL_INTERNAL_ERROR;
332 } 365 }
333 impl->directory_iterator = pvl_next(impl->directory_iterator); 366 dset->directory_iterator = pvl_next(dset->directory_iterator);
334 367
335 if (impl->directory_iterator == 0){ 368 if (dset->directory_iterator == 0){
336 /* There are no more clusters */ 369 /* There are no more clusters */
337 if(impl->cluster != 0){ 370 if(dset->cluster != 0){
338 icalfileset_free(impl->cluster); 371 icalcluster_free(dset->cluster);
339 impl->cluster = 0; 372 dset->cluster = 0;
340 } 373 }
341 return ICAL_NO_ERROR; 374 return ICAL_NO_ERROR;
342 } 375 }
343 376
344 sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); 377 sprintf(path,"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator));
345 378
346 icalfileset_free(impl->cluster); 379 icalcluster_free(dset->cluster);
347 380 dset->cluster = icalfileset_produce_icalcluster(path);
348 impl->cluster = icalfileset_new(path);
349 381
350 return icalerrno; 382 return icalerrno;
351} 383}
352 384
353void icaldirset_add_uid(icaldirset* store, icaldirset* comp) 385static void icaldirset_add_uid(icalcomponent* comp)
354{ 386{
355#ifndef _QTWIN_
356
357 char uidstring[ICAL_PATH_MAX]; 387 char uidstring[ICAL_PATH_MAX];
358 icalproperty *uid; 388 icalproperty *uid;
389#ifndef WIN32
359 struct utsname unamebuf; 390 struct utsname unamebuf;
391#endif
360 392
361 icalerror_check_arg_rv( (store!=0), "store");
362 icalerror_check_arg_rv( (comp!=0), "comp"); 393 icalerror_check_arg_rv( (comp!=0), "comp");
363 394
364 uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY); 395 uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
365 396
366 if (uid == 0) { 397 if (uid == 0) {
367 398
399#ifndef WIN32
368 uname(&unamebuf); 400 uname(&unamebuf);
369 401
370 sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename); 402 sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename);
403#else
404 sprintf(uidstring,"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */
405#endif
371 406
372 uid = icalproperty_new_uid(uidstring); 407 uid = icalproperty_new_uid(uidstring);
373 icalcomponent_add_property(comp,uid); 408 icalcomponent_add_property(comp,uid);
374 } else { 409 } else {
375
376 strcpy(uidstring,icalproperty_get_uid(uid)); 410 strcpy(uidstring,icalproperty_get_uid(uid));
377 } 411 }
378
379#endif
380} 412}
381 413
382 414
383/* This assumes that the top level component is a VCALENDAR, and there 415/**
416 This assumes that the top level component is a VCALENDAR, and there
384 is an inner component of type VEVENT, VTODO or VJOURNAL. The inner 417 is an inner component of type VEVENT, VTODO or VJOURNAL. The inner
385 component must have a DTAMP property */ 418 component must have a DSTAMP property
419*/
386 420
387icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp) 421icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp)
388{ 422{
389 struct icaldirset_impl *impl;
390 char clustername[ICAL_PATH_MAX]; 423 char clustername[ICAL_PATH_MAX];
391 icalproperty *dt; 424 icalproperty *dt = 0;
392 icalvalue *v; 425 icalvalue *v;
393 struct icaltimetype tm; 426 struct icaltimetype tm;
394 icalerrorenum error = ICAL_NO_ERROR; 427 icalerrorenum error = ICAL_NO_ERROR;
395 icalcomponent *inner; 428 icalcomponent *inner;
429 icaldirset *dset = (icaldirset*) set;
396 430
397 impl = (struct icaldirset_impl*)store; 431 icalerror_check_arg_rz( (dset!=0), "dset");
398 icalerror_check_arg_rz( (store!=0), "store");
399 icalerror_check_arg_rz( (comp!=0), "comp"); 432 icalerror_check_arg_rz( (comp!=0), "comp");
400 433
401 errno = 0; 434 icaldirset_add_uid(comp);
402
403 icaldirset_add_uid(store,comp);
404 435
405 /* Determine which cluster this object belongs in. This is a HACK */ 436 /* Determine which cluster this object belongs in. This is a HACK */
406 437
@@ -410,52 +441,44 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
410 441
411 dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); 442 dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
412 443
413 if (dt != 0){ 444 if (dt != 0)
414 break; 445 break;
415 } 446 }
416 }
417
418 if (dt == 0){
419 447
448 if (dt == 0) {
420 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); 449 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
421 inner != 0; 450 inner != 0;
422 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ 451 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
423 452
424 dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); 453 dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
425 454
426 if (dt != 0){ 455 if (dt != 0)
427 break; 456 break;
428 } 457 }
429 } 458 }
430 459
431 }
432
433 if (dt == 0){ 460 if (dt == 0){
434
435
436 icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store"); 461 icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store");
437 icalerror_set_errno(ICAL_BADARG_ERROR); 462 icalerror_set_errno(ICAL_BADARG_ERROR);
438 return ICAL_BADARG_ERROR; 463 return ICAL_BADARG_ERROR;
439 } 464 }
440 465
441 v = icalproperty_get_value(dt); 466 v = icalproperty_get_value(dt);
442
443 tm = icalvalue_get_datetime(v); 467 tm = icalvalue_get_datetime(v);
444 468
445 snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month); 469 snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",dset->dir, tm.year, tm.month);
446 470
447 /* Load the cluster and insert the object */ 471 /* Load the cluster and insert the object */
448 472 if(dset->cluster != 0 &&
449 if(impl->cluster != 0 && 473 strcmp(clustername,icalcluster_key(dset->cluster)) != 0 ){
450 strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){ 474 icalcluster_free(dset->cluster);
451 icalfileset_free(impl->cluster); 475 dset->cluster = 0;
452 impl->cluster = 0;
453 } 476 }
454 477
455 if (impl->cluster == 0){ 478 if (dset->cluster == 0){
456 impl->cluster = icalfileset_new(clustername); 479 dset->cluster = icalfileset_produce_icalcluster(clustername);
457 480
458 if (impl->cluster == 0){ 481 if (dset->cluster == 0){
459 error = icalerrno; 482 error = icalerrno;
460 } 483 }
461 } 484 }
@@ -466,33 +489,31 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
466 } 489 }
467 490
468 /* Add the component to the cluster */ 491 /* Add the component to the cluster */
469 492 icalcluster_add_component(dset->cluster,comp);
470 icalfileset_add_component(impl->cluster,comp);
471 493
472 icalfileset_mark(impl->cluster); 494 /* icalcluster_mark(impl->cluster); */
473 495
474 return ICAL_NO_ERROR; 496 return ICAL_NO_ERROR;
475} 497}
476 498
477/* Remove a component in the current cluster. HACK. This routine is a 499/**
500 Remove a component in the current cluster. HACK. This routine is a
478 "friend" of icalfileset, and breaks its encapsulation. It was 501 "friend" of icalfileset, and breaks its encapsulation. It was
479 either do it this way, or add several layers of interfaces that had 502 either do it this way, or add several layers of interfaces that had
480 no other use. */ 503 no other use.
481icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp) 504 */
482{
483 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
484
485 struct icalfileset_impl *filesetimpl =
486 (struct icalfileset_impl*)impl->cluster;
487 505
488 icalcomponent *filecomp = filesetimpl->cluster; 506icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp)
507{
508 icaldirset *dset = (icaldirset*)set;
509 icalcomponent *filecomp = icalcluster_get_component(dset->cluster);
489 510
490 icalcompiter i; 511 icalcompiter i;
491 int found = 0; 512 int found = 0;
492 513
493 icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR); 514 icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR);
494 icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR); 515 icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR);
495 icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR); 516 icalerror_check_arg_re((dset->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR);
496 517
497 for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT); 518 for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT);
498 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 519 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
@@ -511,17 +532,16 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
511 return ICAL_USAGE_ERROR; 532 return ICAL_USAGE_ERROR;
512 } 533 }
513 534
514 icalfileset_remove_component(impl->cluster,comp); 535 icalcluster_remove_component(dset->cluster,comp);
515 536
516 icalfileset_mark(impl->cluster); 537 /* icalcluster_mark(impl->cluster); */
517 538
518 /* If the removal emptied the fileset, get the next fileset */ 539 /* If the removal emptied the fileset, get the next fileset */
519 if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){ 540 if( icalcluster_count_components(dset->cluster,ICAL_ANY_COMPONENT)==0){
520 541 icalerrorenum error = icaldirset_next_cluster(dset);
521 icalerrorenum error = icaldirset_next_cluster(store);
522 542
523 if(impl->cluster != 0 && error == ICAL_NO_ERROR){ 543 if(dset->cluster != 0 && error == ICAL_NO_ERROR){
524 icalfileset_get_first_component(impl->cluster); 544 icalcluster_get_first_component(dset->cluster);
525 } else { 545 } else {
526 /* HACK. Not strictly correct for impl->cluster==0 */ 546 /* HACK. Not strictly correct for impl->cluster==0 */
527 return error; 547 return error;
@@ -535,95 +555,84 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
535 555
536 556
537 557
538int icaldirset_count_components(icaldirset* store, 558int icaldirset_count_components(icalset* store,
539 icalcomponent_kind kind) 559 icalcomponent_kind kind)
540{ 560{
541 /* HACK, not implemented */ 561 /* HACK, not implemented */
542
543 assert(0); 562 assert(0);
544 563
545 return 0; 564 return 0;
546} 565}
547 566
548 567
549icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c) 568icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c)
550{ 569{
551 fprintf(stderr," icaldirset_fetch_match is not implemented\n"); 570 fprintf(stderr," icaldirset_fetch_match is not implemented\n");
552 assert(0); 571 assert(0);
572 return 0;
553} 573}
554 574
555 575
556icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid) 576icalcomponent* icaldirset_fetch(icalset* set, const char* uid)
557{ 577{
558 icalcomponent *gauge; 578 icaldirset *dset = (icaldirset*)set;
559 icalcomponent *old_gauge; 579 icalgauge *gauge;
580 icalgauge *old_gauge;
560 icalcomponent *c; 581 icalcomponent *c;
561 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 582 char sql[256];
562 583
563 icalerror_check_arg_rz( (store!=0), "store"); 584 icalerror_check_arg_rz( (set!=0), "set");
564 icalerror_check_arg_rz( (uid!=0), "uid"); 585 icalerror_check_arg_rz( (uid!=0), "uid");
565 586
566 gauge = 587 snprintf(sql, 256, "SELECT * FROM VEVENT WHERE UID = \"%s\"", uid);
567 icalcomponent_vanew( 588
568 ICAL_VCALENDAR_COMPONENT, 589 gauge = icalgauge_new_from_sql(sql, 0);
569 icalcomponent_vanew(
570 ICAL_VEVENT_COMPONENT,
571 icalproperty_vanew_uid(
572 uid,
573 icalparameter_new_xliccomparetype(
574 ICAL_XLICCOMPARETYPE_EQUAL),
575 0),
576 0),
577 0);
578 590
579 old_gauge = impl->gauge; 591 old_gauge = dset->gauge;
580 impl->gauge = gauge; 592 dset->gauge = gauge;
581 593
582 c= icaldirset_get_first_component(store); 594 c= icaldirset_get_first_component(set);
583 595
584 impl->gauge = old_gauge; 596 dset->gauge = old_gauge;
585 597
586 icalcomponent_free(gauge); 598 icalgauge_free(gauge);
587 599
588 return c; 600 return c;
589} 601}
590 602
591 603
592int icaldirset_has_uid(icaldirset* store, const char* uid) 604int icaldirset_has_uid(icalset* set, const char* uid)
593{ 605{
594 icalcomponent *c; 606 icalcomponent *c;
595 607
596 icalerror_check_arg_rz( (store!=0), "store"); 608 icalerror_check_arg_rz( (set!=0), "set");
597 icalerror_check_arg_rz( (uid!=0), "uid"); 609 icalerror_check_arg_rz( (uid!=0), "uid");
598 610
599 /* HACK. This is a temporary implementation. _has_uid should use a 611 /* HACK. This is a temporary implementation. _has_uid should use a
600 database, and _fetch should use _has_uid, not the other way 612 database, and _fetch should use _has_uid, not the other way
601 around */ 613 around */
602 c = icaldirset_fetch(store,uid); 614 c = icaldirset_fetch(set,uid);
603 615
604 return c!=0; 616 return c!=0;
605 617
606} 618}
607 619
608 620
609icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge) 621icalerrorenum icaldirset_select(icalset* set, icalgauge* gauge)
610 { 622{
611 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 623 icaldirset *dset = (icaldirset*)set;
612 624
613 icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR); 625 icalerror_check_arg_re( (set!=0), "set",ICAL_BADARG_ERROR);
614 icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR); 626 icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR);
615 627
616 if (!icalcomponent_is_valid(gauge)){ 628 dset->gauge = gauge;
617 return ICAL_BADARG_ERROR;
618 }
619
620 impl->gauge = gauge;
621 629
622 return ICAL_NO_ERROR; 630 return ICAL_NO_ERROR;
623} 631}
624 632
625 633
626icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old, 634icalerrorenum icaldirset_modify(icalset* set,
635 icalcomponent *old,
627 icalcomponent *new) 636 icalcomponent *new)
628{ 637{
629 assert(0); 638 assert(0);
@@ -632,7 +641,7 @@ icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
632} 641}
633 642
634 643
635void icaldirset_clear(icaldirset* store) 644void icaldirset_clear(icalset* set)
636{ 645{
637 646
638 assert(0); 647 assert(0);
@@ -640,53 +649,58 @@ void icaldirset_clear(icaldirset* store)
640 /* HACK, not implemented */ 649 /* HACK, not implemented */
641} 650}
642 651
643icalcomponent* icaldirset_get_current_component(icaldirset* store) 652icalcomponent* icaldirset_get_current_component(icalset* set)
644{ 653{
645 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 654 icaldirset *dset = (icaldirset*)set;
646 655
647 if(impl->cluster == 0){ 656 if (dset->cluster == 0){
648 icaldirset_get_first_component(store); 657 icaldirset_get_first_component(set);
658 }
659 if(dset->cluster == 0){
660 return 0;
649 } 661 }
650 662
651 return icalfileset_get_current_component(impl->cluster); 663 return icalcluster_get_current_component(dset->cluster);
652
653} 664}
654 665
655 666
656icalcomponent* icaldirset_get_first_component(icaldirset* store) 667icalcomponent* icaldirset_get_first_component(icalset* set)
657{ 668{
658 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 669 icaldirset *dset = (icaldirset*)set;
670
659 icalerrorenum error; 671 icalerrorenum error;
660 char path[ICAL_PATH_MAX]; 672 char path[ICAL_PATH_MAX];
661 673
662 error = icaldirset_read_directory(impl); 674 error = icaldirset_read_directory(dset);
663 675
664 if (error != ICAL_NO_ERROR){ 676 if (error != ICAL_NO_ERROR){
665 icalerror_set_errno(error); 677 icalerror_set_errno(error);
666 return 0; 678 return 0;
667 } 679 }
668 680
669 impl->directory_iterator = pvl_head(impl->directory); 681 dset->directory_iterator = pvl_head(dset->directory);
670 682
671 if (impl->directory_iterator == 0){ 683 if (dset->directory_iterator == 0){
672 icalerror_set_errno(error); 684 icalerror_set_errno(error);
673 return 0; 685 return 0;
674 } 686 }
675 687
676 snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); 688 snprintf(path,ICAL_PATH_MAX,"%s/%s",
689 dset->dir,
690 (char*)pvl_data(dset->directory_iterator));
677 691
678 /* If the next cluster we need is different than the current cluster, 692 /* If the next cluster we need is different than the current cluster,
679 delete the current one and get a new one */ 693 delete the current one and get a new one */
680 694
681 if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){ 695 if(dset->cluster != 0 && strcmp(path,icalcluster_key(dset->cluster)) != 0 ){
682 icalfileset_free(impl->cluster); 696 icalcluster_free(dset->cluster);
683 impl->cluster = 0; 697 dset->cluster = 0;
684 } 698 }
685 699
686 if (impl->cluster == 0){ 700 if (dset->cluster == 0){
687 impl->cluster = icalfileset_new(path); 701 dset->cluster = icalfileset_produce_icalcluster(path);
688 702
689 if (impl->cluster == 0){ 703 if (dset->cluster == 0){
690 error = icalerrno; 704 error = icalerrno;
691 } 705 }
692 } 706 }
@@ -696,23 +710,22 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
696 return 0; 710 return 0;
697 } 711 }
698 712
699 impl->first_component = 1; 713 dset->first_component = 1;
700 714
701 return icaldirset_get_next_component(store); 715 return icaldirset_get_next_component(set);
702} 716}
703 717
704icalcomponent* icaldirset_get_next_component(icaldirset* store) 718
719icalcomponent* icaldirset_get_next_component(icalset* set)
705{ 720{
706 struct icaldirset_impl *impl; 721 icaldirset *dset = (icaldirset*)set;
707 icalcomponent *c; 722 icalcomponent *c;
708 icalerrorenum error; 723 icalerrorenum error;
709 724
710 icalerror_check_arg_rz( (store!=0), "store"); 725 icalerror_check_arg_rz( (set!=0), "set");
711
712 impl = (struct icaldirset_impl*)store;
713 726
714 if(impl->cluster == 0){
715 727
728 if(dset->cluster == 0){
716 icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first"); 729 icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first");
717 icalerror_set_errno(ICAL_USAGE_ERROR); 730 icalerror_set_errno(ICAL_USAGE_ERROR);
718 return 0; 731 return 0;
@@ -720,30 +733,26 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
720 } 733 }
721 734
722 /* Set the component iterator for the following for loop */ 735 /* Set the component iterator for the following for loop */
723 if (impl->first_component == 1){ 736 if (dset->first_component == 1){
724 icalfileset_get_first_component(impl->cluster); 737 icalcluster_get_first_component(dset->cluster);
725 impl->first_component = 0; 738 dset->first_component = 0;
726 } else { 739 } else {
727 icalfileset_get_next_component(impl->cluster); 740 icalcluster_get_next_component(dset->cluster);
728 } 741 }
729 742
730
731 while(1){ 743 while(1){
732 /* Iterate through all of the objects in the cluster*/ 744 /* Iterate through all of the objects in the cluster*/
733 for( c = icalfileset_get_current_component(impl->cluster); 745 for( c = icalcluster_get_current_component(dset->cluster);
734 c != 0; 746 c != 0;
735 c = icalfileset_get_next_component(impl->cluster)){ 747 c = icalcluster_get_next_component(dset->cluster)){
736 748
737 /* If there is a gauge defined and the component does not 749 /* If there is a gauge defined and the component does not
738 pass the gauge, skip the rest of the loop */ 750 pass the gauge, skip the rest of the loop */
739 751
740#if 0 /* HACK */ 752 if (dset->gauge != 0 && icalgauge_compare(dset->gauge,c) == 0){
741 if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){
742 continue; 753 continue;
743 } 754 }
744#else 755
745 assert(0); /* icalgauge_test needs to be fixed */
746#endif
747 /* Either there is no gauge, or the component passed the 756 /* Either there is no gauge, or the component passed the
748 gauge, so return it*/ 757 gauge, so return it*/
749 758
@@ -753,13 +762,13 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
753 /* Fell through the loop, so the component we want is not 762 /* Fell through the loop, so the component we want is not
754 in this cluster. Load a new cluster and try again.*/ 763 in this cluster. Load a new cluster and try again.*/
755 764
756 error = icaldirset_next_cluster(store); 765 error = icaldirset_next_cluster(dset);
757 766
758 if(impl->cluster == 0 || error != ICAL_NO_ERROR){ 767 if(dset->cluster == 0 || error != ICAL_NO_ERROR){
759 /* No more clusters */ 768 /* No more clusters */
760 return 0; 769 return 0;
761 } else { 770 } else {
762 c = icalfileset_get_first_component(impl->cluster); 771 c = icalcluster_get_first_component(dset->cluster);
763 772
764 return c; 773 return c;
765 } 774 }
@@ -769,9 +778,28 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
769 return 0; /* Should never get here */ 778 return 0; /* Should never get here */
770} 779}
771 780
772 781icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
782{
783 icalsetiter itr = icalsetiter_null;
784 icaldirset *fset = (icaldirset*) set;
773 785
786 icalerror_check_arg_re((fset!=0), "set", icalsetiter_null);
774 787
788 itr.iter.kind = kind;
789 itr.gauge = gauge;
775 790
791 /* TO BE IMPLEMENTED */
792 return icalsetiter_null;
793}
776 794
777 795icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i)
796{
797 /* TO BE IMPLEMENTED */
798 return NULL;
799}
800
801icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i)
802{
803 /* TO BE IMPLEMENTED */
804 return NULL;
805}
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 @@
30#define ICALDIRSET_H 30#define ICALDIRSET_H
31 31
32#include "ical.h" 32#include "ical.h"
33#include "icalset.h"
34#include "icalcluster.h"
35#include "icalgauge.h"
33 36
34/* icaldirset Routines for storing, fetching, and searching for ical 37/* icaldirset Routines for storing, fetching, and searching for ical
35 * objects in a database */ 38 * objects in a database */
36 39
37typedef void icaldirset; 40typedef struct icaldirset_impl icaldirset;
38 41
42icalset* icaldirset_new(const char* path);
39 43
40icaldirset* icaldirset_new(const char* path); 44icalset* icaldirset_new_reader(const char* path);
45icalset* icaldirset_new_writer(const char* path);
41 46
42void icaldirset_free(icaldirset* store);
43 47
44const char* icaldirset_path(icaldirset* store); 48icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
49void icaldirset_free(icalset* set);
50
51const char* icaldirset_path(icalset* set);
45 52
46/* Mark the cluster as changed, so it will be written to disk when it 53/* Mark the cluster as changed, so it will be written to disk when it
47 is freed. Commit writes to disk immediately*/ 54 is freed. Commit writes to disk immediately*/
48void icaldirset_mark(icaldirset* store); 55void icaldirset_mark(icalset* set);
49icalerrorenum icaldirset_commit(icaldirset* store); 56icalerrorenum icaldirset_commit(icalset* set);
50 57
51icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); 58icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
52icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); 59icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
53 60
54int icaldirset_count_components(icaldirset* store, 61int icaldirset_count_components(icalset* store,
55 icalcomponent_kind kind); 62 icalcomponent_kind kind);
56 63
57/* Restrict the component returned by icaldirset_first, _next to those 64/* Restrict the component returned by icaldirset_first, _next to those
58 that pass the gauge. _clear removes the gauge. */ 65 that pass the gauge. _clear removes the gauge. */
59icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); 66icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
60void icaldirset_clear(icaldirset* store); 67void icaldirset_clear(icalset* store);
61 68
62/* Get a component by uid */ 69/* Get a component by uid */
63icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); 70icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
64int icaldirset_has_uid(icaldirset* store, const char* uid); 71int icaldirset_has_uid(icalset* store, const char* uid);
65icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); 72icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c);
66 73
67/* Modify components according to the MODIFY method of CAP. Works on 74/* Modify components according to the MODIFY method of CAP. Works on
68 the currently selected components. */ 75 the currently selected components. */
69icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, 76icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
70 icalcomponent *newc); 77 icalcomponent *newc);
71 78
72/* Iterate through the components. If a guage has been defined, these 79/* Iterate through the components. If a gauge has been defined, these
73 will skip over components that do not pass the gauge */ 80 will skip over components that do not pass the gauge */
74 81
75icalcomponent* icaldirset_get_current_component(icaldirset* store); 82icalcomponent* icaldirset_get_current_component(icalset* store);
76icalcomponent* icaldirset_get_first_component(icaldirset* store); 83icalcomponent* icaldirset_get_first_component(icalset* store);
77icalcomponent* icaldirset_get_next_component(icaldirset* store); 84icalcomponent* icaldirset_get_next_component(icalset* store);
85
86/* External iterator for thread safety */
87icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
88icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
89icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
90
91typedef struct icaldirset_options {
92 int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
93} icaldirset_options;
78 94
79#endif /* !ICALDIRSET_H */ 95#endif /* !ICALDIRSET_H */
80 96
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 @@
30#include "config.h" 30#include "config.h"
31#endif 31#endif
32 32
33#include "icalcluster.h"
34
33/* This definition is in its own file so it can be kept out of the 35/* This definition is in its own file so it can be kept out of the
34 main header file, but used by "friend classes" like icalset*/ 36 main header file, but used by "friend classes" like icalset*/
35 37
36#define ICALDIRSET_ID "dset"
37
38struct icaldirset_impl 38struct icaldirset_impl
39{ 39{
40 char id[5]; /* "dset" */ 40 icalset super; /**< parent class */
41 char* dir; 41 char* dir; /**< directory containing ics files */
42 icalcomponent* gauge; 42 icaldirset_options options;/**< copy of options passed to icalset_new() */
43 icaldirset* cluster; 43 icalcluster* cluster; /**< cluster containing data */
44 int first_component; 44 icalgauge* gauge; /**< gauge for filtering out data */
45 pvl_list directory; 45 int first_component; /**< ??? */
46 pvl_elem directory_iterator; 46 pvl_list directory; /**< ??? */
47 pvl_elem directory_iterator;/**< ??? */
47}; 48};
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 @@
30#include "config.h" 30#include "config.h"
31#endif 31#endif
32 32
33#include "icalfileset.h"
34#include "icalgauge.h"
33#include <errno.h> 35#include <errno.h>
34 36#include <sys/stat.h> /* for stat */
37#ifndef WIN32
38#include <unistd.h> /* for stat, getpid */
39#else
40#include <io.h>
41#include <share.h>
42#endif
35#include <stdlib.h> 43#include <stdlib.h>
36#include <stdio.h>
37#include <string.h> 44#include <string.h>
45#include <fcntl.h> /* for fcntl */
46#include "icalfilesetimpl.h"
47#include "icalclusterimpl.h"
38 48
39#include <fcntl.h> /* For open() flags and mode */ 49#ifdef WIN32
40#include <sys/types.h> /* For open() flags and mode */ 50 #define snprintf_snprintf
41#include <sys/stat.h> /* For open() flags and mode */ 51 #define strcasecmpstricmp
42 52
43#include "icalfileset.h" 53#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
44#include "icalfilesetimpl.h"
45 54
46// Eugen C. <eug@thekompany.com> 55#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
47#include <defines.h> 56#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
48// 57#endif
49 58
50int snprintf(char *str, size_t n, char const *fmt, ...); 59extern int errno;
51 60
52//extern int errno; 61/** Default options used when NULL is passed to icalset_new() **/
62icalfileset_options icalfileset_options_default = {O_RDWR|O_CREAT, 0644, 0, 0};
53 63
54int icalfileset_lock(icalfileset *cluster); 64int icalfileset_lock(icalfileset *set);
55int icalfileset_unlock(icalfileset *cluster); 65int icalfileset_unlock(icalfileset *set);
56icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode); 66icalerrorenum icalfileset_read_file(icalfileset* set, mode_t mode);
57int icalfileset_filesize(icalfileset* cluster); 67int icalfileset_filesize(icalfileset* set);
58 68
59icalerrorenum icalfileset_create_cluster(const char *path); 69icalerrorenum icalfileset_create_cluster(const char *path);
60 70
61icalfileset* icalfileset_new_impl() 71icalset* icalfileset_new(const char* path)
62{ 72{
63 struct icalfileset_impl* impl; 73 return icalset_new(ICAL_FILE_SET, path, &icalfileset_options_default);
64
65 if ( ( impl = (struct icalfileset_impl*)
66 malloc(sizeof(struct icalfileset_impl))) == 0) {
67 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
68 errno = ENOMEM;
69 return 0;
70 }
71
72 memset(impl,0,sizeof(struct icalfileset_impl));
73
74 strcpy(impl->id,ICALFILESET_ID);
75
76 return impl;
77} 74}
78 75
79 76icalset* icalfileset_new_reader(const char* path)
80icalfileset* icalfileset_new(const char* path)
81{ 77{
82 return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664); 78 icalfileset_options reader_options = icalfileset_options_default;
79 reader_options.flags = O_RDONLY;
80
81 return icalset_new(ICAL_FILE_SET, path, &reader_options);
83} 82}
84 83
85icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode) 84icalset* icalfileset_new_writer(const char* path)
86{ 85{
87 struct icalfileset_impl *impl = icalfileset_new_impl(); 86 icalfileset_options writer_options = icalfileset_options_default;
88 struct icaltimetype tt; 87 writer_options.flags = O_RDONLY;
89 off_t cluster_file_size;
90 88
91 memset(&tt,0,sizeof(struct icaltimetype)); 89 return icalset_new(ICAL_FILE_SET, path, &writer_options);
90}
92 91
93 icalerror_clear_errno(); 92icalset* icalfileset_init(icalset *set, const char* path, void* options_in)
94 icalerror_check_arg_rz( (path!=0), "path"); 93{
94 icalfileset_options *options = (options_in) ? options_in : &icalfileset_options_default;
95 icalfileset *fset = (icalfileset*) set;
96 int flags;
97 mode_t mode;
98 off_t cluster_file_size;
95 99
96 if (impl == 0){ 100 icalerror_clear_errno();
97 return 0; 101 icalerror_check_arg_rz( (path!=0), "path");
98 } 102 icalerror_check_arg_rz( (fset!=0), "fset");
99 103
100 impl->path = strdup(path); 104 fset->path = strdup(path);
105 fset->options = *options;
101 106
102 cluster_file_size = icalfileset_filesize(impl); 107 flags = options->flags;
103 108 mode = options->mode;
104 if(cluster_file_size < 0){ 109
105 icalfileset_free(impl); 110 cluster_file_size = icalfileset_filesize(fset);
106 return 0; 111
107 } 112 if(cluster_file_size < 0){
113 icalfileset_free(set);
114 return 0;
115 }
108 116
109 impl->fd = open(impl->path,flags, mode); 117#ifndef WIN32
118 fset->fd = open(fset->path, flags, mode);
119#else
120 fset->fd = open(fset->path, flags, mode);
121 /* fset->fd = sopen(fset->path,flags, _SH_DENYWR, _S_IREAD | _S_IWRITE); */
122#endif
110 123
111 if (impl->fd < 0){ 124 if (fset->fd < 0){
112 icalerror_set_errno(ICAL_FILE_ERROR); 125 icalerror_set_errno(ICAL_FILE_ERROR);
113 icalfileset_free(impl); 126 icalfileset_free(set);
114 return 0; 127 return 0;
115 } 128 }
116 129
117 icalfileset_lock(impl); 130#ifndef WIN32
131 icalfileset_lock(fset);
132#endif
118 133
119 if(cluster_file_size > 0 ){ 134 if(cluster_file_size > 0 ){
120 icalerrorenum error; 135 icalerrorenum error;
121 if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){ 136 if((error = icalfileset_read_file(fset,mode))!= ICAL_NO_ERROR){
122 icalfileset_free(impl); 137 icalfileset_free(set);
123 return 0; 138 return 0;
124 } 139 }
125 } 140 }
126 141
127 if(impl->cluster == 0){ 142 if (options->cluster) {
128 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); 143 fset->cluster = icalcomponent_new_clone(icalcluster_get_component(options->cluster));
129 } 144 fset->changed = 1;
145 }
146
147 if (fset->cluster == 0) {
148 fset->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
149 }
150
151 return set;
152}
153
154
155icalcluster* icalfileset_produce_icalcluster(const char *path) {
156 icalset *fileset;
157 icalcluster *ret;
158
159 int errstate = icalerror_errors_are_fatal;
160 icalerror_errors_are_fatal = 0;
130 161
131 return impl; 162 fileset = icalfileset_new_reader(path);
163
164
165 if (fileset == 0 && icalerrno == ICAL_FILE_ERROR) {
166 /* file does not exist */
167 ret = icalcluster_new(path, NULL);
168 } else {
169 ret = icalcluster_new(path, ((icalfileset*)fileset)->cluster);
170 icalfileset_free(fileset);
171 }
172
173 icalerror_errors_are_fatal = errstate;
174 icalerror_set_errno(ICAL_NO_ERROR);
175 return ret;
132} 176}
133 177
178
179
134char* icalfileset_read_from_file(char *s, size_t size, void *d) 180char* icalfileset_read_from_file(char *s, size_t size, void *d)
135{ 181{
136
137 char* p = s; 182 char* p = s;
138 int fd = (int)d; 183 int fd = (int)d;
139 184
@@ -158,42 +203,38 @@ char* icalfileset_read_from_file(char *s, size_t size, void *d)
158} 203}
159 204
160 205
161icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode) 206icalerrorenum icalfileset_read_file(icalfileset* set,mode_t mode)
162{ 207{
163
164 icalparser *parser; 208 icalparser *parser;
165 209
166 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
167
168 parser = icalparser_new(); 210 parser = icalparser_new();
169 icalparser_set_gen_data(parser,(void*)impl->fd); 211
170 impl->cluster = icalparser_parse(parser,icalfileset_read_from_file); 212 icalparser_set_gen_data(parser,(void*)set->fd);
213 set->cluster = icalparser_parse(parser,icalfileset_read_from_file);
171 icalparser_free(parser); 214 icalparser_free(parser);
172 215
173 if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){ 216 if (set->cluster == 0 || icalerrno != ICAL_NO_ERROR){
174 icalerror_set_errno(ICAL_PARSE_ERROR); 217 icalerror_set_errno(ICAL_PARSE_ERROR);
175 return ICAL_PARSE_ERROR; 218 /*return ICAL_PARSE_ERROR;*/
176 } 219 }
177 220
178 if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){ 221 if (icalcomponent_isa(set->cluster) != ICAL_XROOT_COMPONENT){
179 /* The parser got a single component, so it did not put it in 222 /* The parser got a single component, so it did not put it in
180 an XROOT. */ 223 an XROOT. */
181 icalcomponent *cl = impl->cluster; 224 icalcomponent *cl = set->cluster;
182 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); 225 set->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
183 icalcomponent_add_component(impl->cluster,cl); 226 icalcomponent_add_component(set->cluster,cl);
184 } 227 }
185 228
186 return ICAL_NO_ERROR; 229 return ICAL_NO_ERROR;
187
188} 230}
189 231
190int icalfileset_filesize(icalfileset* cluster) 232int icalfileset_filesize(icalfileset* fset)
191{ 233{
192 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
193 int cluster_file_size; 234 int cluster_file_size;
194 struct stat sbuf; 235 struct stat sbuf;
195 236
196 if (stat(impl->path,&sbuf) != 0){ 237 if (stat(fset->path,&sbuf) != 0){
197 238
198 /* A file by the given name does not exist, or there was 239 /* A file by the given name does not exist, or there was
199 another error */ 240 another error */
@@ -209,7 +250,6 @@ int icalfileset_filesize(icalfileset* cluster)
209 } else { 250 } else {
210 /* A file by the given name exists, but is it a regular file? */ 251 /* A file by the given name exists, but is it a regular file? */
211 252
212#ifndef _QTWIN_
213 if (!S_ISREG(sbuf.st_mode)){ 253 if (!S_ISREG(sbuf.st_mode)){
214 /* Nope, not a regular file */ 254 /* Nope, not a regular file */
215 icalerror_set_errno(ICAL_FILE_ERROR); 255 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -217,117 +257,109 @@ int icalfileset_filesize(icalfileset* cluster)
217 } else { 257 } else {
218 /* Lets assume that it is a file of the right type */ 258 /* Lets assume that it is a file of the right type */
219 return sbuf.st_size; 259 return sbuf.st_size;
220 } 260 }
221#else
222 return sbuf.st_size;
223#endif
224
225 } 261 }
226 262
227 /*return -1; not reached*/ 263 /*return -1; not reached*/
228} 264}
229 265
230void icalfileset_free(icalfileset* cluster) 266void icalfileset_free(icalset* set)
231{ 267{
232 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 268 icalfileset *fset = (icalfileset*) set;
233 269
234 icalerror_check_arg_rv((cluster!=0),"cluster"); 270 icalerror_check_arg_rv((set!=0),"set");
235 271
236 if (impl->cluster != 0){ 272 if (fset->cluster != 0){
237 icalfileset_commit(cluster); 273 icalfileset_commit(set);
238 icalcomponent_free(impl->cluster); 274 icalcomponent_free(fset->cluster);
239 impl->cluster=0; 275 fset->cluster=0;
240 } 276 }
241 277
242 if(impl->fd > 0){ 278 if (fset->gauge != 0){
243 icalfileset_unlock(impl); 279 icalgauge_free(fset->gauge);
244 close(impl->fd); 280 fset->gauge=0;
245 impl->fd = -1;
246 } 281 }
247 282
248 if(impl->path != 0){ 283 if(fset->fd > 0){
249 free(impl->path); 284 icalfileset_unlock(fset);
250 impl->path = 0; 285 close(fset->fd);
286 fset->fd = -1;
251 } 287 }
252 288
253 free(impl); 289 if(fset->path != 0){
290 free(fset->path);
291 fset->path = 0;
292 }
254} 293}
255 294
256const char* icalfileset_path(icalfileset* cluster) 295const char* icalfileset_path(icalset* set) {
257{ 296 icalerror_check_arg_rz((set!=0),"set");
258 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
259 icalerror_check_arg_rz((cluster!=0),"cluster");
260 297
261 return impl->path; 298 return ((icalfileset*)set)->path;
262} 299}
263 300
264 301
265int icalfileset_lock(icalfileset *cluster) 302int icalfileset_lock(icalfileset *set)
266{ 303{
267#ifndef _WIN32 304#ifndef WIN32
268 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
269 struct flock lock; 305 struct flock lock;
270 int rtrn; 306 int rtrn;
271 307
272 icalerror_check_arg_rz((impl->fd>0),"impl->fd"); 308 icalerror_check_arg_rz((set->fd>0),"set->fd");
273 errno = 0; 309 errno = 0;
274 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ 310 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
275 lock.l_start = 0; /* byte offset relative to l_whence */ 311 lock.l_start = 0; /* byte offset relative to l_whence */
276 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ 312 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
277 lock.l_len = 0; /* #bytes (0 means to EOF) */ 313 lock.l_len = 0; /* #bytes (0 means to EOF) */
278 314
279 rtrn = fcntl(impl->fd, F_SETLKW, &lock); 315 rtrn = fcntl(set->fd, F_SETLKW, &lock);
280 316
281 return rtrn; 317 return rtrn;
282#else 318#else
283 return -1; 319 return 0;
284#endif 320#endif
285} 321}
286 322
287int icalfileset_unlock(icalfileset *cluster) 323int icalfileset_unlock(icalfileset *set)
288{ 324{
289#ifndef _WIN32 325#ifndef WIN32
290 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
291 struct flock lock; 326 struct flock lock;
292 icalerror_check_arg_rz((impl->fd>0),"impl->fd"); 327 icalerror_check_arg_rz((set->fd>0),"set->fd");
293 328
294 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ 329 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
295 lock.l_start = 0; /* byte offset relative to l_whence */ 330 lock.l_start = 0; /* byte offset relative to l_whence */
296 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ 331 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
297 lock.l_len = 0; /* #bytes (0 means to EOF) */ 332 lock.l_len = 0; /* #bytes (0 means to EOF) */
298 333
299 return (fcntl(impl->fd, F_UNLCK, &lock)); 334 return (fcntl(set->fd, F_UNLCK, &lock));
300#else 335#else
301 return -1; 336 return 0;
302#endif 337#endif
303} 338}
304 339
305#ifdef ICAL_SAFESAVES 340icalerrorenum icalfileset_commit(icalset* set)
306int icalfileset_safe_saves=1;
307#else
308int icalfileset_safe_saves=0;
309#endif
310
311icalerrorenum icalfileset_commit(icalfileset* cluster)
312{ 341{
313 char tmp[ICAL_PATH_MAX]; 342 char tmp[ICAL_PATH_MAX];
314 char *str; 343 char *str;
315 icalcomponent *c; 344 icalcomponent *c;
316 off_t write_size=0; 345 off_t write_size=0;
346 icalfileset *fset = (icalfileset*) set;
347
348 icalerror_check_arg_re((fset!=0),"set",ICAL_BADARG_ERROR);
317 349
318 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 350 icalerror_check_arg_re((fset->fd>0),"set->fd is invalid",
319
320 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
321
322 icalerror_check_arg_re((impl->fd>0),"impl->fd is invalid",
323 ICAL_INTERNAL_ERROR) ; 351 ICAL_INTERNAL_ERROR) ;
324 352
325 if (impl->changed == 0 ){ 353 if (fset->changed == 0 ){
326 return ICAL_NO_ERROR; 354 return ICAL_NO_ERROR;
327 } 355 }
328 356
329 if(icalfileset_safe_saves == 1){ 357 if (fset->options.safe_saves == 1) {
330 snprintf(tmp,ICAL_PATH_MAX,"cp %s %s.bak",impl->path,impl->path); 358#ifndef WIN32
359 snprintf(tmp,ICAL_PATH_MAX,"cp '%s' '%s.bak'",fset->path, fset->path);
360#else
361 snprintf(tmp,ICAL_PATH_MAX,"copy %s %s.bak", fset->path, fset->path);
362#endif
331 363
332 if(system(tmp) < 0){ 364 if(system(tmp) < 0){
333 icalerror_set_errno(ICAL_FILE_ERROR); 365 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -335,19 +367,19 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
335 } 367 }
336 } 368 }
337 369
338 if(lseek(impl->fd,SEEK_SET,0) < 0){ 370 if(lseek(fset->fd, 0, SEEK_SET) < 0){
339 icalerror_set_errno(ICAL_FILE_ERROR); 371 icalerror_set_errno(ICAL_FILE_ERROR);
340 return ICAL_FILE_ERROR; 372 return ICAL_FILE_ERROR;
341 } 373 }
342 374
343 for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT); 375 for(c = icalcomponent_get_first_component(fset->cluster,ICAL_ANY_COMPONENT);
344 c != 0; 376 c != 0;
345 c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){ 377 c = icalcomponent_get_next_component(fset->cluster,ICAL_ANY_COMPONENT)){
346 int sz; 378 int sz;
347 379
348 str = icalcomponent_as_ical_string(c); 380 str = icalcomponent_as_ical_string(c);
349 381
350 sz=write(impl->fd,str,strlen(str)); 382 sz=write(fset->fd,str,strlen(str));
351 383
352 if ( sz != strlen(str)){ 384 if ( sz != strlen(str)){
353 perror("write"); 385 perror("write");
@@ -358,134 +390,138 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
358 write_size += sz; 390 write_size += sz;
359 } 391 }
360 392
361 impl->changed = 0; 393 fset->changed = 0;
362 394
363#ifndef _QTWIN_ 395#ifndef WIN32
364 if(ftruncate(impl->fd,write_size) < 0){ 396 if(ftruncate(fset->fd,write_size) < 0){
365 return ICAL_FILE_ERROR; 397 return ICAL_FILE_ERROR;
366 } 398 }
399#else
400 chsize( fset->fd, tell( fset->fd ) );
367#endif 401#endif
368 402
369 return ICAL_NO_ERROR; 403 return ICAL_NO_ERROR;
370
371} 404}
372 405
373void icalfileset_mark(icalfileset* cluster){ 406void icalfileset_mark(icalset* set) {
374 407 icalerror_check_arg_rv((set!=0),"set");
375 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
376
377 icalerror_check_arg_rv((impl!=0),"cluster");
378
379 impl->changed = 1;
380 408
409 ((icalfileset*)set)->changed = 1;
381} 410}
382 411
383icalcomponent* icalfileset_get_component(icalfileset* cluster){ 412icalcomponent* icalfileset_get_component(icalset* set){
384 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 413 icalfileset *fset = (icalfileset*) set;
414 icalerror_check_arg_rz((set!=0),"set");
385 415
386 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); 416 return fset->cluster;
387
388 return impl->cluster;
389} 417}
390 418
391 419
392/* manipulate the components in the cluster */ 420/* manipulate the components in the set */
393 421
394icalerrorenum icalfileset_add_component(icalfileset *cluster, 422icalerrorenum icalfileset_add_component(icalset *set,
395 icalcomponent* child) 423 icalcomponent* child)
396{ 424{
397 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 425 icalfileset *fset = (icalfileset*) set;
398 426
399 icalerror_check_arg_re((cluster!=0),"cluster", ICAL_BADARG_ERROR); 427 icalerror_check_arg_re((set!=0),"set", ICAL_BADARG_ERROR);
400 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); 428 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
401 429
402 icalcomponent_add_component(impl->cluster,child); 430 icalcomponent_add_component(fset->cluster,child);
403 431
404 icalfileset_mark(cluster); 432 icalfileset_mark(set);
405 433
406 return ICAL_NO_ERROR; 434 return ICAL_NO_ERROR;
407
408} 435}
409 436
410icalerrorenum icalfileset_remove_component(icalfileset *cluster, 437icalerrorenum icalfileset_remove_component(icalset *set,
411 icalcomponent* child) 438 icalcomponent* child)
412{ 439{
413 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 440 icalfileset *fset = (icalfileset*) set;
414 441
415 icalerror_check_arg_re((cluster!=0),"cluster",ICAL_BADARG_ERROR); 442 icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR);
416 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); 443 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
417 444
418 icalcomponent_remove_component(impl->cluster,child); 445 icalcomponent_remove_component(fset->cluster,child);
419 446
420 icalfileset_mark(cluster); 447 icalfileset_mark(set);
421 448
422 return ICAL_NO_ERROR; 449 return ICAL_NO_ERROR;
423} 450}
424 451
425int icalfileset_count_components(icalfileset *cluster, 452int icalfileset_count_components(icalset *set,
426 icalcomponent_kind kind) 453 icalcomponent_kind kind)
427{ 454{
428 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 455 icalfileset *fset = (icalfileset*) set;
429 456
430 if(cluster == 0){ 457 if (set == 0){
431 icalerror_set_errno(ICAL_BADARG_ERROR); 458 icalerror_set_errno(ICAL_BADARG_ERROR);
432 return -1; 459 return -1;
433 } 460 }
434 461
435 return icalcomponent_count_components(impl->cluster,kind); 462 return icalcomponent_count_components(fset->cluster,kind);
436} 463}
437 464
438icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge) 465icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge)
439{ 466{
440 struct icalfileset_impl* impl = (struct icalfileset_impl*)set; 467 icalfileset *fset = (icalfileset*) set;
441 468
442 icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR); 469 icalerror_check_arg_re(gauge!=0,"gauge",ICAL_BADARG_ERROR);
443 470
444 impl->gauge = gauge; 471 fset->gauge = gauge;
445 472
446 return ICAL_NO_ERROR; 473 return ICAL_NO_ERROR;
447} 474}
448 475
449void icalfileset_clear(icalfileset* gauge) 476void icalfileset_clear(icalset* set)
450{ 477{
451 struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge; 478 icalfileset *fset = (icalfileset*) set;
452 479
453 impl->gauge = 0; 480 icalerror_check_arg_rv(set!=0,"set");
454 481
482 fset->gauge = 0;
455} 483}
456 484
457icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid) 485icalcomponent* icalfileset_fetch(icalset* set,const char* uid)
458{ 486{
487 icalfileset *fset = (icalfileset*) set;
459 icalcompiter i; 488 icalcompiter i;
460 struct icalfileset_impl* impl = (struct icalfileset_impl*)store; 489
490 icalerror_check_arg_rz(set!=0,"set");
461 491
462 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); 492 for(i = icalcomponent_begin_component(fset->cluster,ICAL_ANY_COMPONENT);
463 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 493 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
464 494
465 icalcomponent *this = icalcompiter_deref(&i); 495 icalcomponent *this = icalcompiter_deref(&i);
466 icalcomponent *inner = icalcomponent_get_first_real_component(this); 496 icalcomponent *inner;
467 icalcomponent *p; 497 icalproperty *p;
468 const char *this_uid; 498 const char *this_uid;
469 499
470 if(inner != 0){ 500 for(inner = icalcomponent_get_first_component(this,ICAL_ANY_COMPONENT);
471 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); 501 inner != 0;
472 this_uid = icalproperty_get_uid(p); 502 inner = icalcomponent_get_next_component(this,ICAL_ANY_COMPONENT)){
473 503
474 if(this_uid==0){ 504 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
475 icalerror_warn("icalfileset_fetch found a component with no UID"); 505 if ( p )
476 continue; 506 {
477 } 507 this_uid = icalproperty_get_uid(p);
478 508
479 if (strcmp(uid,this_uid)==0){ 509 if(this_uid==0){
480 return this; 510 icalerror_warn("icalfileset_fetch found a component with no UID");
481 } 511 continue;
512 }
513
514 if (strcmp(uid,this_uid)==0){
515 return this;
516 }
517 }
518 }
482 } 519 }
483 }
484 520
485 return 0; 521 return 0;
486} 522}
487 523
488int icalfileset_has_uid(icalfileset* store,const char* uid) 524int icalfileset_has_uid(icalset* set,const char* uid)
489{ 525{
490 assert(0); /* HACK, not implemented */ 526 assert(0); /* HACK, not implemented */
491 return 0; 527 return 0;
@@ -508,12 +544,11 @@ void icalfileset_id_free(struct icalfileset_id *id)
508 if(id->uid != 0){ 544 if(id->uid != 0){
509 free(id->uid); 545 free(id->uid);
510 } 546 }
511
512} 547}
513 548
549
514struct icalfileset_id icalfileset_get_id(icalcomponent* comp) 550struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
515{ 551{
516
517 icalcomponent *inner; 552 icalcomponent *inner;
518 struct icalfileset_id id; 553 struct icalfileset_id id;
519 icalproperty *p; 554 icalproperty *p;
@@ -549,19 +584,20 @@ struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
549 return id; 584 return id;
550} 585}
551 586
587
552/* Find the component that is related to the given 588/* Find the component that is related to the given
553 component. Currently, it just matches based on UID and 589 component. Currently, it just matches based on UID and
554 RECURRENCE-ID */ 590 RECURRENCE-ID */
555icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp) 591icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *comp)
556{ 592{
557 struct icalfileset_impl* impl = (struct icalfileset_impl*)set; 593 icalfileset *fset = (icalfileset*) set;
558 icalcompiter i; 594 icalcompiter i;
559 595
560 struct icalfileset_id comp_id, match_id; 596 struct icalfileset_id comp_id, match_id;
561 597
562 comp_id = icalfileset_get_id(comp); 598 comp_id = icalfileset_get_id(comp);
563 599
564 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); 600 for(i = icalcomponent_begin_component(fset->cluster,ICAL_ANY_COMPONENT);
565 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 601 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
566 602
567 icalcomponent *match = icalcompiter_deref(&i); 603 icalcomponent *match = icalcompiter_deref(&i);
@@ -589,43 +625,45 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
589} 625}
590 626
591 627
592icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old, 628icalerrorenum icalfileset_modify(icalset* set, icalcomponent *old,
593 icalcomponent *new) 629 icalcomponent *new)
594{ 630{
631 icalfileset *fset = (icalfileset*) set;
632
595 assert(0); /* HACK, not implemented */ 633 assert(0); /* HACK, not implemented */
596 return ICAL_NO_ERROR; 634 return ICAL_NO_ERROR;
597} 635}
598 636
599 637
600/* Iterate through components */ 638/* Iterate through components */
601icalcomponent* icalfileset_get_current_component (icalfileset* cluster) 639icalcomponent* icalfileset_get_current_component (icalset* set)
602{ 640{
603 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 641 icalfileset *fset = (icalfileset*) set;
604 642
605 icalerror_check_arg_rz((cluster!=0),"cluster"); 643 icalerror_check_arg_rz((set!=0),"set");
606 644
607 return icalcomponent_get_current_component(impl->cluster); 645 return icalcomponent_get_current_component(fset->cluster);
608} 646}
609 647
610 648
611icalcomponent* icalfileset_get_first_component(icalfileset* cluster) 649icalcomponent* icalfileset_get_first_component(icalset* set)
612{ 650{
613 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
614 icalcomponent *c=0; 651 icalcomponent *c=0;
652 icalfileset *fset = (icalfileset*) set;
615 653
616 icalerror_check_arg_rz((cluster!=0),"cluster"); 654 icalerror_check_arg_rz((set!=0),"set");
617 655
618 do { 656 do {
619 if (c == 0){ 657 if (c == 0){
620 c = icalcomponent_get_first_component(impl->cluster, 658 c = icalcomponent_get_first_component(fset->cluster,
621 ICAL_ANY_COMPONENT); 659 ICAL_ANY_COMPONENT);
622 } else { 660 } else {
623 c = icalcomponent_get_next_component(impl->cluster, 661 c = icalcomponent_get_next_component(fset->cluster,
624 ICAL_ANY_COMPONENT); 662 ICAL_ANY_COMPONENT);
625 } 663 }
626 664
627 if(c != 0 && (impl->gauge == 0 || 665 if(c != 0 && (fset->gauge == 0 ||
628 icalgauge_compare(impl->gauge,c) == 1)){ 666 icalgauge_compare(fset->gauge, c) == 1)){
629 return c; 667 return c;
630 } 668 }
631 669
@@ -635,19 +673,19 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
635 return 0; 673 return 0;
636} 674}
637 675
638icalcomponent* icalfileset_get_next_component(icalfileset* cluster) 676icalcomponent* icalfileset_get_next_component(icalset* set)
639{ 677{
640 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 678 icalfileset *fset = (icalfileset*) set;
641 icalcomponent *c; 679 icalcomponent *c;
642 680
643 icalerror_check_arg_rz((cluster!=0),"cluster"); 681 icalerror_check_arg_rz((set!=0),"set");
644 682
645 do { 683 do {
646 c = icalcomponent_get_next_component(impl->cluster, 684 c = icalcomponent_get_next_component(fset->cluster,
647 ICAL_ANY_COMPONENT); 685 ICAL_ANY_COMPONENT);
648 686
649 if(c != 0 && (impl->gauge == 0 || 687 if(c != 0 && (fset->gauge == 0 ||
650 icalgauge_compare(impl->gauge,c) == 1)){ 688 icalgauge_compare(fset->gauge,c) == 1)){
651 return c; 689 return c;
652 } 690 }
653 691
@@ -656,4 +694,241 @@ icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
656 694
657 return 0; 695 return 0;
658} 696}
697/*
698icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
699{
700 icalsetiter itr = icalsetiter_null;
701 icalcomponent* comp = NULL;
702 icalcompiter citr;
703 icalfileset *fset = (icalfileset*) set;
704
705 icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
706
707 itr.gauge = gauge;
708
709 citr = icalcomponent_begin_component(fset->cluster, kind);
710 comp = icalcompiter_deref(&citr);
711
712 while (comp != 0) {
713 comp = icalcompiter_deref(&citr);
714 if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
715 itr.iter = citr;
716 return itr;
717 }
718 comp = icalcompiter_next(&citr);
719 }
720
721 return icalsetiter_null;
722}
723*/
724
725icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
726{
727 icalsetiter itr = icalsetiter_null;
728 icalcomponent* comp = NULL;
729 icalcompiter citr;
730 icalfileset *fset = (icalfileset*) set;
731 struct icaltimetype start, next;
732 icalproperty *dtstart, *rrule, *prop, *due;
733 struct icalrecurrencetype recur;
734 int g = 0;
735
736 icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
737
738 itr.gauge = gauge;
739
740 citr = icalcomponent_begin_component(fset->cluster, kind);
741 comp = icalcompiter_deref(&citr);
742
743 if (gauge == 0) {
744 itr.iter = citr;
745 return itr;
746 }
747
748 while (comp != 0) {
749
750 /* check if it is a recurring component and with guage expand, if so
751 we need to add recurrence-id property to the given component */
752 rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
753 g = icalgauge_get_expand(gauge);
754
755 if (rrule != 0
756 && g == 1) {
757
758 recur = icalproperty_get_rrule(rrule);
759 if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
760 dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
761 if (dtstart)
762 start = icalproperty_get_dtstart(dtstart);
763 } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
764 due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
765 if (due)
766 start = icalproperty_get_due(due);
767 }
768
769 if (itr.last_component == NULL) {
770 itr.ritr = icalrecur_iterator_new(recur, start);
771 next = icalrecur_iterator_next(itr.ritr);
772 itr.last_component = comp;
773 }
774 else {
775 next = icalrecur_iterator_next(itr.ritr);
776 if (icaltime_is_null_time(next)){
777 itr.last_component = NULL;
778 icalrecur_iterator_free(itr.ritr);
779 itr.ritr = NULL;
780 return icalsetiter_null;
781 } else {
782 itr.last_component = comp;
783 }
784 }
785
786 /* add recurrence-id to the component
787 if there is a recurrence-id already, remove it, then add the new one */
788 if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
789 icalcomponent_remove_property(comp, prop);
790 icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
791
792 }
793
794 if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
795 /* matches and returns */
796 itr.iter = citr;
797 return itr;
798 }
799
800 /* if there is no previous component pending, then get the next component */
801 if (itr.last_component == NULL)
802 comp = icalcompiter_next(&citr);
803 }
804
805 return icalsetiter_null;
806}
807icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr)
808{
809 icalcomponent* comp = NULL;
810 struct icaltimetype start, next;
811 icalproperty *dtstart, *rrule, *prop, *due;
812 struct icalrecurrencetype recur;
813
814 comp = itr->last_component;
815
816 if (comp == NULL || itr->gauge == NULL) {
817 return NULL;
818 }
819
820 rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
821
822 recur = icalproperty_get_rrule(rrule);
823
824 if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
825 dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
826 if (dtstart)
827 start = icalproperty_get_dtstart(dtstart);
828 } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
829 due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
830 if (due)
831 start = icalproperty_get_due(due);
832 }
833
834 if (itr->ritr == NULL) {
835 itr->ritr = icalrecur_iterator_new(recur, start);
836 next = icalrecur_iterator_next(itr->ritr);
837 itr->last_component = comp;
838 } else {
839 next = icalrecur_iterator_next(itr->ritr);
840 if (icaltime_is_null_time(next)){
841 /* no more recurrence, returns */
842 itr->last_component = NULL;
843 icalrecur_iterator_free(itr->ritr);
844 itr->ritr = NULL;
845 return NULL;
846 } else {
847 itr->last_component = comp;
848 }
849 }
850
851 /* add recurrence-id to the component
852 * if there is a recurrence-id already, remove it, then add the new one */
853 if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
854 icalcomponent_remove_property(comp, prop);
855 icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
856
857 if (itr->gauge == 0 || icalgauge_compare(itr->gauge, comp) == 1) {
858 /* matches and returns */
859 return comp;
860 }
861 /* not matched */
862 return NULL;
863
864}
865icalcomponent* icalfilesetiter_to_next(icalset* set, icalsetiter* i)
866{
867
868 icalcomponent* c = NULL;
869 icalfileset *fset = (icalfileset*) set;
870 struct icaltimetype start, next;
871 icalproperty *dtstart, *rrule, *prop, *due;
872 struct icalrecurrencetype recur;
873 int g = 0;
874
875
876 do {
877 c = icalcompiter_next(&(i->iter));
878
879 if (c == 0) continue;
880 if (i->gauge == 0) return c;
881
882
883 rrule = icalcomponent_get_first_property(c, ICAL_RRULE_PROPERTY);
884 g = icalgauge_get_expand(i->gauge);
885
886 /* a recurring component with expand query */
887 if (rrule != 0
888 && g == 1) {
889
890 recur = icalproperty_get_rrule(rrule);
891
892 if (icalcomponent_isa(c) == ICAL_VEVENT_COMPONENT) {
893 dtstart = icalcomponent_get_first_property(c, ICAL_DTSTART_PROPERTY);
894 if (dtstart)
895 start = icalproperty_get_dtstart(dtstart);
896 } else if (icalcomponent_isa(c) == ICAL_VTODO_COMPONENT) {
897 due = icalcomponent_get_first_property(c, ICAL_DUE_PROPERTY);
898 if (due)
899 start = icalproperty_get_due(due);
900 }
901
902 if (i->ritr == NULL) {
903 i->ritr = icalrecur_iterator_new(recur, start);
904 next = icalrecur_iterator_next(i->ritr);
905 i->last_component = c;
906 } else {
907 next = icalrecur_iterator_next(i->ritr);
908 if (icaltime_is_null_time(next)) {
909 /* no more recurrence, returns */
910 i->last_component = NULL;
911 icalrecur_iterator_free(i->ritr);
912 i->ritr = NULL;
913 return NULL;
914 } else {
915 i->last_component = c;
916 }
917 }
918 }
919
920 /* add recurrence-id to the component
921 * if there is a recurrence-id already, remove it, then add the new one */
922 if (prop = icalcomponent_get_first_property(c, ICAL_RECURRENCEID_PROPERTY))
923 icalcomponent_remove_property(c, prop);
924 icalcomponent_add_property(c, icalproperty_new_recurrenceid(next));
925
926 if(c != 0 && (i->gauge == 0 ||
927 icalgauge_compare(i->gauge, c) == 1)){
928 return c;
929 }
930 } while (c != 0);
931
932 return 0;
659 933
934}
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 @@
29#ifndef ICALFILESET_H 29#ifndef ICALFILESET_H
30#define ICALFILESET_H 30#define ICALFILESET_H
31 31
32#include "icalerror.h"
33#include "ical.h" 32#include "ical.h"
34#include "icalset.h" 33#include "icalset.h"
34#include "icalcluster.h"
35#include "icalgauge.h" 35#include "icalgauge.h"
36#include <sys/types.h> /* For open() flags and mode */
37#include <sys/stat.h> /* For open() flags and mode */
38#include <fcntl.h> /* For open() flags and mode */
36 39
37extern int icalfileset_safe_saves; 40#ifdef WIN32
38 41#define mode_t int
39typedef void icalfileset; 42#endif
40 43
44extern int icalfileset_safe_saves;
41 45
42/* icalfileset 46typedef struct icalfileset_impl icalfileset;
43 icalfilesetfile
44 icalfilesetdir
45*/
46 47
48icalset* icalfileset_new(const char* path);
49icalset* icalfileset_new_reader(const char* path);
50icalset* icalfileset_new_writer(const char* path);
47 51
48icalfileset* icalfileset_new(const char* path); 52icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
49 53
50#ifdef _WIN32 54icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
51#define mode_t int
52#endif
53 55
54/* Like _new, but takes open() flags for opening the file */ 56icalcluster* icalfileset_produce_icalcluster(const char *path);
55icalfileset* icalfileset_new_open(const char* path,
56 int flags, mode_t mode);
57 57
58void icalfileset_free(icalfileset* cluster); 58void icalfileset_free(icalset* cluster);
59 59
60const char* icalfileset_path(icalfileset* cluster); 60const char* icalfileset_path(icalset* cluster);
61 61
62/* Mark the cluster as changed, so it will be written to disk when it 62/* Mark the cluster as changed, so it will be written to disk when it
63 is freed. Commit writes to disk immediately. */ 63 is freed. Commit writes to disk immediately. */
64void icalfileset_mark(icalfileset* cluster); 64void icalfileset_mark(icalset* set);
65icalerrorenum icalfileset_commit(icalfileset* cluster); 65icalerrorenum icalfileset_commit(icalset* set);
66 66
67icalerrorenum icalfileset_add_component(icalfileset* cluster, 67icalerrorenum icalfileset_add_component(icalset* set,
68 icalcomponent* child); 68 icalcomponent* child);
69 69
70icalerrorenum icalfileset_remove_component(icalfileset* cluster, 70icalerrorenum icalfileset_remove_component(icalset* set,
71 icalcomponent* child); 71 icalcomponent* child);
72 72
73int icalfileset_count_components(icalfileset* cluster, 73int icalfileset_count_components(icalset* set,
74 icalcomponent_kind kind); 74 icalcomponent_kind kind);
75 75
76/* Restrict the component returned by icalfileset_first, _next to those 76/**
77 that pass the gauge. _clear removes the gauge */ 77 * Restrict the component returned by icalfileset_first, _next to those
78icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge); 78 * that pass the gauge. _clear removes the gauge
79void icalfileset_clear(icalfileset* store); 79 */
80icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
81
82/** clear the gauge **/
83void icalfileset_clear(icalset* set);
80 84
81/* Get and search for a component by uid */ 85/** Get and search for a component by uid **/
82icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); 86icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
83int icalfileset_has_uid(icalfileset* cluster, const char* uid); 87int icalfileset_has_uid(icalset* set, const char* uid);
84icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c); 88icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
85 89
86 90
87/* Modify components according to the MODIFY method of CAP. Works on 91/**
88 the currently selected components. */ 92 * Modify components according to the MODIFY method of CAP. Works on the
89icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, 93 * currently selected components.
94 */
95icalerrorenum icalfileset_modify(icalset* set,
96 icalcomponent *oldcomp,
90 icalcomponent *newcomp); 97 icalcomponent *newcomp);
91 98
92/* Iterate through components. If a guage has been defined, these 99/* Iterate through components. If a gauge has been defined, these
93 will skip over components that do not pass the gauge */ 100 will skip over components that do not pass the gauge */
94 101
95icalcomponent* icalfileset_get_current_component (icalfileset* cluster); 102icalcomponent* icalfileset_get_current_component (icalset* cluster);
96icalcomponent* icalfileset_get_first_component(icalfileset* cluster); 103icalcomponent* icalfileset_get_first_component(icalset* cluster);
97icalcomponent* icalfileset_get_next_component(icalfileset* cluster); 104icalcomponent* icalfileset_get_next_component(icalset* cluster);
98/* Return a reference to the internal component. You probably should 105
106/* External iterator for thread safety */
107icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
108icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
109icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
110
111/** Return a reference to the internal component. You probably should
99 not be using this. */ 112 not be using this. */
100 113
101icalcomponent* icalfileset_get_component(icalfileset* cluster); 114icalcomponent* icalfileset_get_component(icalset* cluster);
115
116/**
117 * @brief options for opening an icalfileset.
118 *
119 * These options should be passed to the icalset_new() function
120 */
121
122typedef struct icalfileset_options {
123 int flags; /**< flags for open() O_RDONLY, etc */
124 mode_t mode; /**< file mode */
125 int safe_saves;/**< to lock or not */
126 icalcluster *cluster;/**< use this cluster to initialize data */
127} icalfileset_options;
102 128
129extern icalfileset_options icalfileset_options_default;
103 130
104#endif /* !ICALFILESET_H */ 131#endif /* !ICALFILESET_H */
105 132
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 @@
25 25
26 ======================================================================*/ 26 ======================================================================*/
27 27
28#ifndef ICALFILESETIMPL_H
29#define ICALFILESETIMPL_H
28 30
29#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
30#include "config.h" 32#include "config.h"
@@ -38,12 +40,14 @@
38#define ICALFILESET_ID "fset" 40#define ICALFILESET_ID "fset"
39 41
40struct icalfileset_impl { 42struct icalfileset_impl {
41 43 icalset super; /**< parent class */
42 char id[5]; /*fset*/ 44 char *path; /**< pathname of file */
43 char *path; 45 icalfileset_options options; /**< copy of options passed to icalset_new() */
44 icalcomponent* cluster; 46
45 icalgauge* gauge; 47 icalcomponent* cluster;/**< cluster containing data */
46 int changed; 48 icalgauge* gauge; /**< gauge for filtering out data */
47 int fd; /* file descriptor */ 49 int changed; /**< boolean flag, 1 if data has changed */
50 int fd; /**< file descriptor */
48}; 51};
49 52
53#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 @@
31#include "icalgaugeimpl.h" 31#include "icalgaugeimpl.h"
32#include <stdlib.h> 32#include <stdlib.h>
33 33
34extern char* input_buffer; 34#include "icalssyacc.h"
35extern char* input_buffer_p;
36int ssparse(void);
37 35
38struct icalgauge_impl *icalss_yy_gauge; 36typedef void* yyscan_t;
39 37
40icalgauge* icalgauge_new_from_sql(char* sql) 38int ssparse(yyscan_t );
39
40
41icalgauge* icalgauge_new_from_sql(char* sql, int expand)
41{ 42{
42 struct icalgauge_impl *impl; 43 struct icalgauge_impl *impl;
44 yyscan_t yy_globals = NULL;
43 45
44 int r; 46 int r;
45 47
@@ -52,60 +54,82 @@ icalgauge* icalgauge_new_from_sql(char* sql)
52 impl->select = pvl_newlist(); 54 impl->select = pvl_newlist();
53 impl->from = pvl_newlist(); 55 impl->from = pvl_newlist();
54 impl->where = pvl_newlist(); 56 impl->where = pvl_newlist();
57 impl->expand = expand;
58
59 sslex_init(&yy_globals);
60
61 ssset_extra(impl, yy_globals);
55 62
56 icalss_yy_gauge = impl; 63 ss_scan_string(sql, yy_globals);
57 64
58 input_buffer_p = input_buffer = sql; 65 r = ssparse(yy_globals);
59 r = ssparse(); 66 sslex_destroy(yy_globals);
60 67
61 return impl; 68 if (r == 0) {
69 return impl;
70 }
71 else {
72 icalgauge_free(impl);
73 return NULL;
74 }
62} 75}
63 76
77int icalgauge_get_expand(icalgauge* gauge)
78{
79return (gauge->expand);
80
81}
64 82
65void icalgauge_free(icalgauge* gauge) 83void icalgauge_free(icalgauge* gauge)
66{ 84{
67 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
68 struct icalgauge_where *w; 85 struct icalgauge_where *w;
69 86
70 assert(impl->select != 0); 87 assert(gauge->select != 0);
71 assert(impl->where != 0); 88 assert(gauge->where != 0);
72 assert(impl->from != 0); 89 assert(gauge->from != 0);
73 90
74 if(impl->select){ 91 if(gauge->select){
75 while( (w=pvl_pop(impl->select)) != 0){ 92 while( (w=pvl_pop(gauge->select)) != 0){
76 if(w->value != 0){ 93 if(w->value != 0){
77 free(w->value); 94 free(w->value);
78 } 95 }
79 free(w); 96 free(w);
80 } 97 }
81 pvl_free(impl->select); 98 pvl_free(gauge->select);
99 gauge->select = 0;
82 } 100 }
83 101
84 if(impl->where){ 102 if(gauge->where){
85 while( (w=pvl_pop(impl->where)) != 0){ 103 while( (w=pvl_pop(gauge->where)) != 0){
86 104
87 if(w->value != 0){ 105 if(w->value != 0){
88 free(w->value); 106 free(w->value);
89 } 107 }
90 free(w); 108 free(w);
91 } 109 }
92 pvl_free(impl->where); 110 pvl_free(gauge->where);
111 gauge->where = 0;
93 } 112 }
94 113
95 if(impl->from){ 114 if(gauge->from){
96 pvl_free(impl->from); 115 pvl_free(gauge->from);
116 gauge->from = 0;
97 } 117 }
118
119 free(gauge);
98 120
99} 121}
100 122
101/* Convert a VQUERY component into a gauge */ 123
124/** Convert a VQUERY component into a gauge */
102icalcomponent* icalgauge_make_gauge(icalcomponent* query); 125icalcomponent* icalgauge_make_gauge(icalcomponent* query);
103 126
104/* icaldirset_test compares a component against a gauge, and returns 127/**
128 icaldirset_test compares a component against a gauge, and returns
105 true if the component passes the test 129 true if the component passes the test
106 130
107 The gauge is a VCALENDAR component that specifies how to test the 131 The gauge is a VCALENDAR component that specifies how to test the
108 target components. The guage holds a collection of VEVENT, VTODO or 132 target components. The gauge holds a collection of VEVENT, VTODO or
109 VJOURNAL sub-components. Each of the sub-components has a 133 VJOURNAL sub-components. Each of the sub-components has a
110 collection of properties that are compared to corresponding 134 collection of properties that are compared to corresponding
111 properties in the target component, according to the 135 properties in the target component, according to the
@@ -252,26 +276,45 @@ int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
252int icalgauge_compare(icalgauge* gauge,icalcomponent* comp) 276int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
253{ 277{
254 278
255 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
256 icalcomponent *inner; 279 icalcomponent *inner;
257 int local_pass = 0; 280 int local_pass = 0;
258 int last_clause = 1, this_clause = 1; 281 int last_clause = 1, this_clause = 1;
259 pvl_elem e; 282 pvl_elem e;
283 icalcomponent_kind kind;
284 icalproperty *rrule;
285 int compare_recur = 0;
286
260 287
261 icalerror_check_arg_rz( (comp!=0), "comp"); 288 icalerror_check_arg_rz( (comp!=0), "comp");
262 icalerror_check_arg_rz( (gauge!=0), "gauge"); 289 icalerror_check_arg_rz( (gauge!=0), "gauge");
263 290
291 if (gauge == 0 || comp == 0) return 0;
292
264 inner = icalcomponent_get_first_real_component(comp); 293 inner = icalcomponent_get_first_real_component(comp);
265 294
266 if(inner == 0){ 295 if(inner == 0){
267 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 296 /* Wally Yau: our component is not always wrapped with
268 return 0; 297 * a <VCALENDAR>. It's not an error.
298 * icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
299 * return 0; */
300 kind = icalcomponent_isa(comp);
301 if(kind == ICAL_VEVENT_COMPONENT ||
302 kind == ICAL_VTODO_COMPONENT ||
303 kind == ICAL_VJOURNAL_COMPONENT ||
304 kind == ICAL_VQUERY_COMPONENT ||
305 kind == ICAL_VAGENDA_COMPONENT){
306 inner = comp;
307 }
308 else {
309 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
310 return 0;
311 }
312 inner = comp;
269 } 313 }
270 314
271
272 /* Check that this component is one of the FROM types */ 315 /* Check that this component is one of the FROM types */
273 local_pass = 0; 316 local_pass = 0;
274 for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){ 317 for(e = pvl_head(gauge->from);e!=0;e=pvl_next(e)){
275 icalcomponent_kind k = (icalcomponent_kind)pvl_data(e); 318 icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
276 319
277 if(k == icalcomponent_isa(inner)){ 320 if(k == icalcomponent_isa(inner)){
@@ -284,8 +327,8 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
284 } 327 }
285 328
286 329
287 /* Check each where clause against the component */ 330 /**** Check each where clause against the component ****/
288 for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){ 331 for(e = pvl_head(gauge->where);e!=0;e=pvl_next(e)){
289 struct icalgauge_where *w = pvl_data(e); 332 struct icalgauge_where *w = pvl_data(e);
290 icalcomponent *sub_comp; 333 icalcomponent *sub_comp;
291 icalvalue *v; 334 icalvalue *v;
@@ -301,11 +344,14 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
301 vk = icalenum_property_kind_to_value_kind(w->prop); 344 vk = icalenum_property_kind_to_value_kind(w->prop);
302 345
303 if(vk == ICAL_NO_VALUE){ 346 if(vk == ICAL_NO_VALUE){
304 icalerror_set_errno(ICAL_INTERNAL_ERROR); 347 icalerror_set_errno(ICAL_INTERNAL_ERROR);
305 return 0; 348 return 0;
306 } 349 }
307 350
308 v = icalvalue_new_from_string(vk,w->value); 351 if (w->compare == ICALGAUGECOMPARE_ISNULL || w->compare == ICALGAUGECOMPARE_ISNOTNULL)
352 v = icalvalue_new(vk);
353 else
354 v = icalvalue_new_from_string(vk,w->value);
309 355
310 if (v == 0){ 356 if (v == 0){
311 /* Keep error set by icalvalue_from-string*/ 357 /* Keep error set by icalvalue_from-string*/
@@ -324,14 +370,46 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
324 } 370 }
325 } 371 }
326 372
373 /* check if it is a recurring */
374 rrule = icalcomponent_get_first_property(sub_comp,ICAL_RRULE_PROPERTY);
375
376 if (gauge->expand
377 && rrule) {
378
379 if (w->prop == ICAL_DTSTART_PROPERTY ||
380 w->prop == ICAL_DTEND_PROPERTY ||
381 w->prop == ICAL_DUE_PROPERTY){
382 /** needs to use recurrence-id to do comparison */
383 compare_recur = 1;
384 }
385
386 }
387
388
327 this_clause = 0; 389 this_clause = 0;
328 local_pass = 0; 390 local_pass = (w->compare == ICALGAUGECOMPARE_ISNULL) ? 1 : 0;
391
329 for(prop = icalcomponent_get_first_property(sub_comp,w->prop); 392 for(prop = icalcomponent_get_first_property(sub_comp,w->prop);
330 prop != 0; 393 prop != 0;
331 prop = icalcomponent_get_next_property(sub_comp,w->prop)){ 394 prop = icalcomponent_get_next_property(sub_comp,w->prop)){
332 icalvalue* prop_value; 395 icalvalue* prop_value;
333 icalgaugecompare relation; 396 icalgaugecompare relation;
334 397
398 if (w->compare == ICALGAUGECOMPARE_ISNULL) {
399 local_pass = 0;
400 break;
401 }
402
403 if (w->compare == ICALGAUGECOMPARE_ISNOTNULL) {
404 local_pass = 1;
405 break;
406 }
407
408 if (compare_recur) {
409 icalproperty *p = icalcomponent_get_first_property(sub_comp, ICAL_RECURRENCEID_PROPERTY);
410 prop_value = icalproperty_get_value(p);
411 }
412 else /* prop value from this component */
335 prop_value = icalproperty_get_value(prop); 413 prop_value = icalproperty_get_value(prop);
336 414
337 relation = (icalgaugecompare)icalvalue_compare(prop_value,v); 415 relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
@@ -355,34 +433,40 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
355 } 433 }
356 } 434 }
357 435
436
358 this_clause = local_pass > 0 ? 1 : 0; 437 this_clause = local_pass > 0 ? 1 : 0;
359 438
439
360 /* Now look at the logic operator for this clause to see how 440 /* Now look at the logic operator for this clause to see how
361 the value should be merge with the previous clause */ 441 the value should be merge with the previous clause */
362 442
363 if(w->logic == ICALGAUGELOGIC_AND){ 443 if(w->logic == ICALGAUGELOGIC_AND){
364 last_clause = this_clause && last_clause; 444 last_clause = this_clause && last_clause;
365 } else if(w->logic == ICALGAUGELOGIC_AND) { 445 } else if(w->logic == ICALGAUGELOGIC_OR) {
366 last_clause = this_clause || last_clause; 446 last_clause = this_clause || last_clause;
367 } else { 447 } else {
368 last_clause = this_clause; 448 last_clause = this_clause;
369 } 449 }
370 } 450
451 icalvalue_free(v);
452
453 }/**** check next one in where clause ****/
371 454
372 return last_clause; 455 return last_clause;
373 456
374} 457}
375 458
459/** @brief Debug
460 * Print gauge information to stdout.
461 */
376 462
377void icalgauge_dump(icalcomponent* gauge) 463void icalgauge_dump(icalgauge* gauge)
378{ 464{
379 465
380 pvl_elem *p; 466 pvl_elem p;
381 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
382
383 467
384 printf("--- Select ---\n"); 468 printf("--- Select ---\n");
385 for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){ 469 for(p = pvl_head(gauge->select);p!=0;p=pvl_next(p)){
386 struct icalgauge_where *w = pvl_data(p); 470 struct icalgauge_where *w = pvl_data(p);
387 471
388 if(w->comp != ICAL_NO_COMPONENT){ 472 if(w->comp != ICAL_NO_COMPONENT){
@@ -407,14 +491,14 @@ void icalgauge_dump(icalcomponent* gauge)
407 } 491 }
408 492
409 printf("--- From ---\n"); 493 printf("--- From ---\n");
410 for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){ 494 for(p = pvl_head(gauge->from);p!=0;p=pvl_next(p)){
411 icalcomponent_kind k = (icalcomponent_kind)pvl_data(p); 495 icalcomponent_kind k = (icalcomponent_kind)pvl_data(p);
412 496
413 printf("%s\n",icalenum_component_kind_to_string(k)); 497 printf("%s\n",icalenum_component_kind_to_string(k));
414 } 498 }
415 499
416 printf("--- Where ---\n"); 500 printf("--- Where ---\n");
417 for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){ 501 for(p = pvl_head(gauge->where);p!=0;p=pvl_next(p)){
418 struct icalgauge_where *w = pvl_data(p); 502 struct icalgauge_where *w = pvl_data(p);
419 503
420 if(w->logic != ICALGAUGELOGIC_NONE){ 504 if(w->logic != ICALGAUGELOGIC_NONE){
@@ -441,7 +525,5 @@ void icalgauge_dump(icalcomponent* gauge)
441 525
442 printf("\n"); 526 printf("\n");
443 } 527 }
444
445
446} 528}
447 529
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 @@
29#ifndef ICALGAUGE_H 29#ifndef ICALGAUGE_H
30#define ICALGAUGE_H 30#define ICALGAUGE_H
31 31
32typedef void icalgauge; 32/** @file icalgauge.h
33 * @brief Routines implementing a filter for ical components
34 */
33 35
34icalgauge* icalgauge_new_from_sql(char* sql); 36typedef struct icalgauge_impl icalgauge;
37
38icalgauge* icalgauge_new_from_sql(char* sql, int expand);
39
40int icalgauge_get_expand(icalgauge* gauge);
35 41
36void icalgauge_free(icalgauge* gauge); 42void icalgauge_free(icalgauge* gauge);
37 43
38char* icalgauge_as_sql(icalcomponent* gauge); 44char* icalgauge_as_sql(icalcomponent* gauge);
39 45
40void icalgauge_dump(icalcomponent* gauge); 46void icalgauge_dump(icalgauge* gauge);
47
41 48
42/* Return true is comp matches the gauge. The component must be in 49/** @brief Return true if comp matches the gauge.
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL 50 *
44 sub component */ 51 * The component must be in
52 * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
53 * sub component
54 */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp); 55int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46 56
47/* Clone the component, but only return the properties specified in 57/** Clone the component, but only return the properties
48 the gauge */ 58 * specified in the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); 59icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
50 60
51#endif /* ICALGAUGE_H*/ 61#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 @@
24 24
25#include "ical.h" 25#include "ical.h"
26 26
27#include "pvl.h"
28
29typedef enum icalgaugecompare { 27typedef enum icalgaugecompare {
30 ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL, 28 ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
31 ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS, 29 ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
@@ -34,6 +32,8 @@ typedef enum icalgaugecompare {
34 ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL, 32 ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
35 ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL, 33 ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
36 ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX, 34 ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
35 ICALGAUGECOMPARE_ISNULL=ICAL_XLICCOMPARETYPE_ISNULL,
36 ICALGAUGECOMPARE_ISNOTNULL=ICAL_XLICCOMPARETYPE_ISNOTNULL,
37 ICALGAUGECOMPARE_NONE=0 37 ICALGAUGECOMPARE_NONE=0
38} icalgaugecompare; 38} icalgaugecompare;
39 39
@@ -54,10 +54,10 @@ struct icalgauge_where {
54 54
55struct icalgauge_impl 55struct icalgauge_impl
56{ 56{
57 57 pvl_list select; /**< Of icalgaugecompare, using only prop and comp fields*/
58 pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/ 58 pvl_list from; /**< List of component_kinds, as integers */
59 pvl_list from; /* List of component_kinds, as integers */ 59 pvl_list where; /**< List of icalgaugecompare */
60 pvl_list where; /* List of icalgaugecompare */ 60 int expand;
61}; 61};
62 62
63 63
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)
40 } 40 }
41} 41}
42 42
43char* lowercase(const char* str) 43static char* lowercase(const char* str)
44{ 44{
45 char* p = 0; 45 char* p = 0;
46 char* n = icalmemory_strdup(str); 46 char* n = icalmemory_strdup(str);
@@ -158,8 +158,13 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
158 158
159 icalcomponent_add_property(reply,icalproperty_new_version("2.0")); 159 icalcomponent_add_property(reply,icalproperty_new_version("2.0"));
160 160
161#ifndef WIN32
161 sprintf(tmp, 162 sprintf(tmp,
162 "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); 163 "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION);
164#else
165 sprintf(tmp,
166 "-//SoftwareStudio//NONSGML %s %s //EN",ICAL_PACKAGE,ICAL_VERSION);
167#endif
163 icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); 168 icalcomponent_add_property(reply,icalproperty_new_prodid(tmp));
164 169
165 return reply; 170 return reply;
@@ -230,11 +235,11 @@ icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
230 icalerror_check_arg_rz(oldc,"oldc"); 235 icalerror_check_arg_rz(oldc,"oldc");
231 icalerror_check_arg_rz(newc,"newc"); 236 icalerror_check_arg_rz(newc,"newc");
232 237
233 reply = icalcomponent_new_clone(newc); 238 reply = icalmessage_new_reply_base(newc,user,msg);
234 239
235 icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); 240 icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
236 241
237 return newc; 242 return reply;
238 243
239} 244}
240 245
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 @@
41#include "icaldirset.h" 41#include "icaldirset.h"
42#include "icaldirsetimpl.h" 42#include "icaldirsetimpl.h"
43#include <stdlib.h> 43#include <stdlib.h>
44/*#include "icalheapset.h"*/ 44#include <string.h>
45/*#include "icalmysqlset.h"*/ 45#include <errno.h>
46 46
47#define ICALSET_ID "set " 47#ifdef WITH_BDB4
48 48#include "icalbdbset.h"
49struct icalset_fp { 49#include "icalbdbsetimpl.h"
50 void (*free)(icalset* set); 50#endif
51 const char* (*path)(icalset* set); 51
52 void (*mark)(icalset* set); 52/* #define _DLOPEN_TEST */
53 icalerrorenum (*commit)(icalset* set); 53#ifdef _DLOPEN_TEST
54 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp); 54#include <sys/types.h>
55 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp); 55#include <dlfcn.h>
56 int (*count_components)(icalset* set, 56#include <dirent.h>
57 icalcomponent_kind kind); 57#endif
58 icalerrorenum (*select)(icalset* set, icalcomponent* gauge); 58
59 void (*clear)(icalset* set); 59static icalset icalset_dirset_init = {
60 icalcomponent* (*fetch)(icalset* set, const char* uid); 60 ICAL_DIR_SET,
61 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp); 61 sizeof(icaldirset),
62 int (*has_uid)(icalset* set, const char* uid); 62 NULL,
63 icalerrorenum (*modify)(icalset* set, icalcomponent *old, 63 icaldirset_init,
64 icalcomponent *new);
65 icalcomponent* (*get_current_component)(icalset* set);
66 icalcomponent* (*get_first_component)(icalset* set);
67 icalcomponent* (*get_next_component)(icalset* set);
68};
69
70struct icalset_fp icalset_dirset_fp = {
71 icaldirset_free, 64 icaldirset_free,
72 icaldirset_path, 65 icaldirset_path,
73 icaldirset_mark, 66 icaldirset_mark,
@@ -83,11 +76,18 @@ struct icalset_fp icalset_dirset_fp = {
83 icaldirset_modify, 76 icaldirset_modify,
84 icaldirset_get_current_component, 77 icaldirset_get_current_component,
85 icaldirset_get_first_component, 78 icaldirset_get_first_component,
86 icaldirset_get_next_component 79 icaldirset_get_next_component,
80 icaldirset_begin_component,
81 icaldirsetiter_to_next,
82 icaldirsetiter_to_prior
87}; 83};
88 84
89 85
90struct icalset_fp icalset_fileset_fp = { 86static icalset icalset_fileset_init = {
87 ICAL_FILE_SET,
88 sizeof(icalfileset),
89 NULL,
90 icalfileset_init,
91 icalfileset_free, 91 icalfileset_free,
92 icalfileset_path, 92 icalfileset_path,
93 icalfileset_mark, 93 icalfileset_mark,
@@ -103,265 +103,391 @@ struct icalset_fp icalset_fileset_fp = {
103 icalfileset_modify, 103 icalfileset_modify,
104 icalfileset_get_current_component, 104 icalfileset_get_current_component,
105 icalfileset_get_first_component, 105 icalfileset_get_first_component,
106 icalfileset_get_next_component 106 icalfileset_get_next_component,
107 icalfileset_begin_component,
108 icalfilesetiter_to_next,
109 NULL
107}; 110};
108 111
109struct icalset_impl { 112#ifdef WITH_BDB4
113static icalset icalset_bdbset_init = {
114 ICAL_BDB_SET,
115 sizeof(icalbdbset),
116 NULL,
117 icalbdbset_init,
118 icalbdbset_free,
119 icalbdbset_path,
120 icalbdbset_mark,
121 icalbdbset_commit,
122 icalbdbset_add_component,
123 icalbdbset_remove_component,
124 icalbdbset_count_components,
125 icalbdbset_select,
126 icalbdbset_clear,
127 icalbdbset_fetch,
128 icalbdbset_fetch_match,
129 icalbdbset_has_uid,
130 icalbdbset_modify,
131 icalbdbset_get_current_component,
132 icalbdbset_get_first_component,
133 icalbdbset_get_next_component,
134 icalbdbset_begin_component,
135 icalbdbsetiter_to_next,
136 NULL
137};
138#endif
110 139
111 char id[5]; /* "set " */ 140#ifdef _DLOPEN_TEST
141 static inticalset_init_done = 0;
142static pvl_list icalset_kinds = 0;
112 143
113 void *derived_impl; 144typedef icalset *(*fptr)(void);
114 struct icalset_fp *fp;
115};
116 145
117/* Figure out what was actually passed in as the set. This could be a 146/**
118 set or and of the derived types such as dirset or fileset. Note 147 * Try to load the file and register any icalset found within.
119 this routine returns a value, not a reference, to avoid memory 148 */
120 leaks in the methods */ 149static int load(const char *file) {
121struct icalset_impl icalset_get_impl(icalset* set) 150
122{ 151 void *modh;
123 struct icalset_impl impl; 152 fptr inith;
124 153 icalset *icalset_init_ptr;
125 memset(&impl,0,sizeof(impl)); 154
126 icalerror_check_arg_re( (set!=0),"set",impl); 155 if ((modh = dlopen(file, RTLD_NOW)) == 0) {
127 156 perror("dlopen");
128 if(strcmp((char*)set,ICALSET_ID)==0) { 157 return 0;
129 /* It is actually a set, so just sent the reference back out. */ 158 }
130 return *(struct icalset_impl*)set; 159
131 } else if(strcmp((char*)set,ICALFILESET_ID)==0) { 160 if ((inith = (fptr)dlsym(modh, "InitModule")) == 0) {
132 /* Make a new set from the fileset */ 161 perror("dlsym");
133 impl.fp = &icalset_fileset_fp; 162 return 0;
134 impl.derived_impl = set; 163 }
135 strcpy(impl.id,ICALFILESET_ID);/* HACK. Is this necessary? */ 164
136 return impl; 165 while ((icalset_init_ptr = ((inith)())) != 0) {
137 } else if(strcmp((char*)set,ICALDIRSET_ID)==0) { 166 pvl_push(icalset_kinds, &icalset_init_ptr);
138 /* Make a new set from the dirset */ 167 }
139 impl.fp = &icalset_dirset_fp; 168
140 impl.derived_impl = set; 169 return 1;
141 strcpy(impl.id,ICALDIRSET_ID);/* HACK. Is this necessary? */
142 return impl;
143 } else {
144 /* The type of set is unknown, so throw an error */
145 icalerror_assert((0),"Unknown set type");
146 return impl;
147 }
148} 170}
149 171
172/**
173 * Look in the given directory for files called mod_*.o and try to
174 * load them.
175 */
176int icalset_loaddir(const char *path) {
177 DIR *d;
178 struct dirent *dp;
179 char buf[PATH_MAX],
180 *bufptr;
181 int tot = 0;
150 182
151struct icalset_impl* icalset_new_impl() 183 strcpy(buf, path);
152{ 184 bufptr = buf + strlen(buf);
153
154 struct icalset_impl* impl;
155 185
156 if ( ( impl = (struct icalset_impl*) 186 if (*(bufptr-1) != '/')
157 malloc(sizeof(struct icalset_impl))) == 0) { 187 *bufptr++ = '/';
158 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
159 return 0;
160 }
161 188
162 strcpy(impl->id,ICALSET_ID); 189 if ((d = opendir(path)) == 0) {
190 perror("opendir");
191 return 0;
192 }
163 193
164 impl->derived_impl = 0; 194 while ((dp = readdir(d)) != 0) {
165 impl->fp = 0; 195 if (strncmp(dp->d_name, "mod_", 4)) continue;
166 196
167 return impl; 197 strcpy(bufptr, dp->d_name);
168}
169 198
170struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset) 199 load(buf);
171{ 200 tot++;
172 struct icalset_impl *impl = icalset_new_impl(); 201 }
202 (void)closedir(d);
173 203
174 icalerror_check_arg_rz( (fset!=0),"fset"); 204 return 1;
205}
175 206
176 if(impl == 0){ 207int icalset_register_class(icalset *set);
177 free(impl);
178 return 0;
179 }
180 208
181 impl->derived_impl = fset; 209static void icalset_init(void) {
210 assert(icalset_kinds == 0);
211 icalset_kinds = pvl_newlist();
182 212
183 if (impl->derived_impl == 0){ 213 pvl_push(icalset_kinds, &icalset_fileset_init);
184 free(impl); 214 pvl_push(icalset_kinds, &icalset_dirset_init);
185 return 0; 215#ifdef WITH_BDB4
186 } 216 pvl_push(icalset_kinds, &icalset_bdb4set_init);
217#endif
187 218
188 impl->fp = &icalset_fileset_fp; 219#ifdef EXT_PATH
220 icalset_loaddir(EXT_PATH);
221#endif
189 222
190 return (struct icalset_impl*)impl; 223 icalset_init_done++;
191} 224}
192 225
193icalset* icalset_new_file(const char* path) 226int icalset_register_class(icalset *set) {
194{
195 icalfileset *fset = icalfileset_new(path);
196 227
197 if(fset == 0){ 228 if (!icalset_init_done)
198 return 0; 229 icalset_init();
199 }
200 230
201 return (icalset*)icalset_new_file_from_ref(fset); 231 pvl_push(icalset_kinds, set);
232 return 1;
202} 233}
203 234
204icalset* icalset_new_dir_from_ref(icaldirset *dset) 235#endif
205{
206 236
207 struct icalset_impl *impl = icalset_new_impl(); 237icalset* icalset_new(icalset_kind kind, const char* dsn, void* options) {
238 icalset *data = NULL;
239 icalset *ret = NULL;
208 240
209 icalerror_check_arg_rz( (dset!=0),"dset"); 241#ifdef _DLOPEN_TEST
242 pvl_eleme;
243 icalset *impl;
210 244
211 if(impl == 0){ 245 if (!icalset_init_done)
212 return 0; 246 icalset_init();
247
248 for(e = pvl_head(icalset_kinds); e!=0; e = pvl_next(e)) {
249 impl = (icalset*)pvl_data(e);
250 if (impl->kind == kind)
251 break;
252 }
253 if (e == 0) {
254 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
255 return(NULL);
213 } 256 }
214 257
215 impl->derived_impl = dset; 258 data = (icalset*)malloc(impl->size);
259 if (data == 0) {
260 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
261 errno = ENOMEM;
262 return 0;
263 }
216 264
217 if (impl->derived_impl == 0){ 265 /* The first member of the derived class must be an icalset. */
218 free(impl); 266 memset(data,0,impl->size);
267 /* *data = *impl; */
268 memcpy(data, impl, sizeof(icalset));
269
270 data->dsn = strdup(dsn);
271#else
272 switch(kind) {
273 case ICAL_FILE_SET:
274 data = (icalset*) malloc(sizeof(icalfileset));
275 if (data == 0) {
276 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
277 errno = ENOMEM;
278 return 0;
279 }
280 memset(data,0,sizeof(icalfileset));
281 *data = icalset_fileset_init;
282 break;
283 case ICAL_DIR_SET:
284 data = (icalset*) malloc(sizeof(icaldirset));
285 if (data == 0) {
286 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
287 errno = ENOMEM;
288 return 0;
289 }
290 memset(data,0,sizeof(icaldirset));
291 *data = icalset_dirset_init;
292 break;
293#ifdef WITH_BDB4
294 case ICAL_BDB_SET:
295 data = (icalset*) malloc(sizeof(icalbdbset));
296 if (data == 0) {
297 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
298 errno = ENOMEM;
219 return 0; 299 return 0;
220 } 300 }
301 memset(data,0,sizeof(icalbdbset));
302 *data = icalset_bdbset_init;
303 break;
304#endif
305
306 default:
307 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
308 /** unimplemented **/
309 return(NULL);
310 }
311
312 if ( data == 0) {
313 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
314 return 0;
315 }
316 data->kind = kind;
317 data->dsn = strdup(dsn);
318#endif
221 319
222 impl->fp = &icalset_dirset_fp; 320 /** call the implementation specific initializer **/
321 if ((ret = data->init(data, dsn, options)) == NULL)
322 icalset_free(data);
223 323
224 return impl; 324 return ret;
225} 325}
226 326
227icalset* icalset_new_dir(const char* path) 327icalset* icalset_new_file(const char* path)
228{ 328{
229 icaldirset *dset = icaldirset_new(path); 329 return icalset_new(ICAL_FILE_SET, path, NULL);
230 330}
231 if(dset == 0){
232 return 0;
233 }
234 331
235 return icalset_new_dir_from_ref(dset); 332icalset* icalset_new_file_writer(const char* path)
333{
334 return icalfileset_new_writer(path);
236} 335}
237 336
238icalset* icalset_new_heap(void) 337icalset* icalset_new_file_reader(const char* path)
239{ 338{
240 struct icalset_impl *impl = icalset_new_impl(); 339 return icalfileset_new_reader(path);
340}
241 341
242 342
243 if(impl == 0){ 343icalset* icalset_new_dir(const char* path)
244 free(impl); 344{
245 return 0; 345 return icalset_new(ICAL_DIR_SET, path, NULL);
246 } 346}
247 347
248 return 0; 348icalset* icalset_new_dir_writer(const char* path)
349{
350 return icaldirset_new_writer(path);
249} 351}
250 352
251icalset* icalset_new_mysql(const char* path) 353icalset* icalset_new_dir_reader(const char* path)
252{ 354{
253 struct icalset_impl *impl = icalset_new_impl(); 355 return icaldirset_new_reader(path);
356}
254 357
255 if(impl == 0){
256 free(impl);
257 return 0;
258 }
259 358
260 return 0; 359
261} 360/* Functions for built-in methods */
361
362/**
363 * free memory associated with this icalset
364 * automatically calls the implementation specific free routine
365 */
262 366
263void icalset_free(icalset* set) 367void icalset_free(icalset* set)
264{ 368{
265 struct icalset_impl impl = icalset_get_impl(set); 369 if (set->free)
266 (*(impl.fp->free))(impl.derived_impl); 370 set->free(set);
267 371
268 if(strcmp((char*)set,ICALSET_ID)) { 372 if (set->dsn)
269 free(set); 373 free(set->dsn);
270 }
271}
272 374
273const char* icalset_path(icalset* set) 375 free(set);
274{
275 struct icalset_impl impl = icalset_get_impl(set);
276 return (*(impl.fp->path))(impl.derived_impl);
277} 376}
278 377
279void icalset_mark(icalset* set) 378
280{ 379const char* icalset_path(icalset* set) {
281 struct icalset_impl impl = icalset_get_impl(set); 380 return set->path(set);
282 (*(impl.fp->mark))(impl.derived_impl);
283} 381}
284 382
285icalerrorenum icalset_commit(icalset* set) 383void icalset_mark(icalset* set) {
286{ 384 set->mark(set);
287 struct icalset_impl impl = icalset_get_impl(set);
288 return (*(impl.fp->commit))(impl.derived_impl);
289} 385}
290 386
291icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) 387icalerrorenum icalset_commit(icalset* set) {
292{ 388 return set->commit(set);
293 struct icalset_impl impl = icalset_get_impl(set);
294 return (*(impl.fp->add_component))(impl.derived_impl,comp);
295} 389}
296 390
297icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp) 391icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) {
298{ 392 return set->add_component(set,comp);
299 struct icalset_impl impl = icalset_get_impl(set);
300 return (*(impl.fp->remove_component))(impl.derived_impl,comp);
301} 393}
302 394
303int icalset_count_components(icalset* set,icalcomponent_kind kind) 395icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp) {
304{ 396 return set->remove_component(set,comp);
305 struct icalset_impl impl = icalset_get_impl(set);
306 return (*(impl.fp->count_components))(impl.derived_impl,kind);
307} 397}
308 398
309icalerrorenum icalset_select(icalset* set, icalcomponent* gauge) 399int icalset_count_components(icalset* set,icalcomponent_kind kind) {
310{ 400 return set->count_components(set,kind);
311 struct icalset_impl impl = icalset_get_impl(set);
312 return (*(impl.fp->select))(impl.derived_impl,gauge);
313} 401}
314 402
315void icalset_clear(icalset* set) 403icalerrorenum icalset_select(icalset* set, icalgauge* gauge) {
316{ 404 return set->select(set, gauge);
317 struct icalset_impl impl = icalset_get_impl(set);
318 (*(impl.fp->clear))(impl.derived_impl);
319} 405}
320 406
321icalcomponent* icalset_fetch(icalset* set, const char* uid) 407void icalset_clear(icalset* set) {
322{ 408 set->clear(set);
323 struct icalset_impl impl = icalset_get_impl(set);
324 return (*(impl.fp->fetch))(impl.derived_impl,uid);
325} 409}
326 410
327icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) 411icalcomponent* icalset_fetch(icalset* set, const char* uid) {
328{ 412 return set->fetch(set, uid);
329 struct icalset_impl impl = icalset_get_impl(set);
330 return (*(impl.fp->fetch_match))(impl.derived_impl,comp);
331} 413}
332 414
415icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) {
416 return set->fetch_match(set, comp);
417}
333 418
334int icalset_has_uid(icalset* set, const char* uid) 419int icalset_has_uid(icalset* set, const char* uid) {
335{ 420 return set->has_uid(set, uid);
336 struct icalset_impl impl = icalset_get_impl(set);
337 return (*(impl.fp->has_uid))(impl.derived_impl,uid);
338} 421}
339 422
340icalerrorenum icalset_modify(icalset* set, icalcomponent *old, 423icalerrorenum icalset_modify(icalset* set, icalcomponent *old,
341 icalcomponent *new) 424 icalcomponent *new) {
342{ 425 return set->modify(set, old, new);
343 struct icalset_impl impl = icalset_get_impl(set);
344 return (*(impl.fp->modify))(impl.derived_impl,old,new);
345} 426}
346 427
347icalcomponent* icalset_get_current_component(icalset* set) 428icalcomponent* icalset_get_current_component(icalset* set) {
348{ 429 return set->get_current_component(set);
349 struct icalset_impl impl = icalset_get_impl(set);
350 return (*(impl.fp->get_current_component))(impl.derived_impl);
351} 430}
352 431
353icalcomponent* icalset_get_first_component(icalset* set) 432icalcomponent* icalset_get_first_component(icalset* set) {
354{ 433 return set->get_first_component(set);
355 struct icalset_impl impl = icalset_get_impl(set);
356 return (*(impl.fp->get_first_component))(impl.derived_impl);
357} 434}
358 435
359icalcomponent* icalset_get_next_component(icalset* set) 436icalcomponent* icalset_get_next_component(icalset* set) {
360{ 437 return set->get_next_component(set);
361 struct icalset_impl impl = icalset_get_impl(set); 438}
362 return (*(impl.fp->get_next_component))(impl.derived_impl); 439
440icalsetiter icalsetiter_null = {{ICAL_NO_COMPONENT, 0}, 0};
441
442icalsetiter icalset_begin_component(icalset* set,
443 icalcomponent_kind kind, icalgauge* gauge) {
444 return set->icalset_begin_component(set, kind, gauge);
445}
446
447icalcomponent* icalsetiter_next(icalsetiter* itr) {
448
449 icalcomponent* c = 0;
450 icalerror_check_arg_rz( (itr != NULL), "i");
451
452 do {
453 c = icalcompiter_next(&(itr->iter));
454 if(c != 0 && (itr->gauge == 0 ||
455 icalgauge_compare(itr->gauge, c) == 1)){
456 return c;
457 }
458 } while (c != 0);
459
460 return 0;
363} 461}
364 462
463icalcomponent* icalsetiter_prior(icalsetiter* i) {
464
465 icalcomponent* c = 0;
466 icalerror_check_arg_rz( (i != NULL), "i" );
467
468 do {
469 c = icalcompiter_prior(&(i->iter));
470 if(c != 0 && (i->gauge == 0 ||
471 icalgauge_compare(i->gauge, c) == 1)){
472 return c;
473 }
474 } while (c != 0);
475
476 return 0;
477}
365 478
479icalcomponent* icalsetiter_deref(icalsetiter* i) {
480 icalerror_check_arg_rz( (i != NULL), "i" );
481 return (icalcompiter_deref(&(i->iter)));
482}
366 483
484/* for subclasses that use multiple clusters that require specialized cluster traversal */
485icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i)
486{
487 return set->icalsetiter_to_next(set, i);
488}
367 489
490icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i)
491{
492 return set->icalsetiter_to_prior(set, i);
493}
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 @@
1/* -*- Mode: C -*- */ 1/* -*- Mode: C -*- */
2/*====================================================================== 2/**
3 FILE: icalset.h 3 @file icalset.h
4 CREATOR: eric 28 November 1999 4 @author eric 28 November 1999
5
6 5
7 Icalset is the "base class" for representations of a collection of 6 Icalset is the "base class" for representations of a collection of
8 iCal components. Derived classes (actually delegatees) include: 7 iCal components. Derived classes (actually delegatees) include:
9 8
10 icalfileset Store componetns in a single file 9 icalfileset Store components in a single file
11 icaldirset Store components in multiple files in a directory 10 icaldirset Store components in multiple files in a directory
11 icalbdbset Store components in a Berkeley DB File
12 icalheapset Store components on the heap 12 icalheapset Store components on the heap
13 icalmysqlset Store components in a mysql database. 13 icalmysqlset Store components in a mysql database.
14**/
14 15
16/*
15 $Id$ 17 $Id$
16 $Locker$ 18 $Locker$
17 19
@@ -39,7 +41,7 @@
39 41
40#include <limits.h> /* For PATH_MAX */ 42#include <limits.h> /* For PATH_MAX */
41#include "ical.h" 43#include "ical.h"
42#include "icalerror.h" 44#include "icalgauge.h"
43 45
44#ifdef PATH_MAX 46#ifdef PATH_MAX
45#define ICAL_PATH_MAX PATH_MAX 47#define ICAL_PATH_MAX PATH_MAX
@@ -48,33 +50,86 @@
48#endif 50#endif
49 51
50 52
51 53typedef struct icalset_impl icalset;
52
53typedef void icalset;
54 54
55typedef enum icalset_kind { 55typedef enum icalset_kind {
56 ICAL_FILE_SET, 56 ICAL_FILE_SET,
57 ICAL_DIR_SET, 57 ICAL_DIR_SET,
58 ICAL_HEAP_SET, 58 ICAL_BDB_SET
59 ICAL_MYSQL_SET,
60 ICAL_CAP_SET
61} icalset_kind; 59} icalset_kind;
62 60
61typedef struct icalsetiter
62{
63 icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
64 icalgauge* gauge;
65 icalrecur_iterator* ritr; /*the last iterator*/
66 icalcomponent* last_component; /*the pending recurring component to be processed */
67 const char* tzid; /* the calendar's timezone id */
68} icalsetiter;
69
70struct icalset_impl {
71 icalset_kind kind;
72 int size;
73 char *dsn;
74 icalset* (*init)(icalset* set, const char *dsn, void *options);
75 void (*free)(icalset* set);
76 const char* (*path)(icalset* set);
77 void (*mark)(icalset* set);
78 icalerrorenum (*commit)(icalset* set);
79 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
80 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
81 int (*count_components)(icalset* set,
82 icalcomponent_kind kind);
83 icalerrorenum (*select)(icalset* set, icalgauge* gauge);
84 void (*clear)(icalset* set);
85 icalcomponent* (*fetch)(icalset* set, const char* uid);
86 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
87 int (*has_uid)(icalset* set, const char* uid);
88 icalerrorenum (*modify)(icalset* set, icalcomponent *old,
89 icalcomponent *newc);
90 icalcomponent* (*get_current_component)(icalset* set);
91 icalcomponent* (*get_first_component)(icalset* set);
92 icalcomponent* (*get_next_component)(icalset* set);
93 icalsetiter (*icalset_begin_component)(icalset* set,
94 icalcomponent_kind kind, icalgauge* gauge);
95 icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
96 icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
97};
98
99/** @brief Register a new derived class */
100int icalset_register_class(icalset *set);
101
102
103/** @brief Generic icalset constructor
104 *
105 * @param kind The type of icalset to create
106 * @param dsn Data Source Name - usually a pathname or DB handle
107 * @param options Any implementation specific options
108 *
109 * @return A valid icalset reference or NULL if error.
110 *
111 * This creates any of the icalset types available.
112 */
113
114icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
63 115
64/* Create a specific derived type of set */
65icalset* icalset_new_file(const char* path); 116icalset* icalset_new_file(const char* path);
117icalset* icalset_new_file_reader(const char* path);
118icalset* icalset_new_file_writer(const char* path);
119
66icalset* icalset_new_dir(const char* path); 120icalset* icalset_new_dir(const char* path);
67icalset* icalset_new_heap(void); 121icalset* icalset_new_file_reader(const char* path);
68icalset* icalset_new_mysql(const char* path); 122icalset* icalset_new_file_writer(const char* path);
69/*icalset* icalset_new_cap(icalcstp* cstp);*/
70 123
71void icalset_free(icalset* set); 124void icalset_free(icalset* set);
72 125
73const char* icalset_path(icalset* set); 126const char* icalset_path(icalset* set);
74 127
75/* Mark the cluster as changed, so it will be written to disk when it 128/** Mark the cluster as changed, so it will be written to disk when it
76 is freed. Commit writes to disk immediately*/ 129 is freed. **/
77void icalset_mark(icalset* set); 130void icalset_mark(icalset* set);
131
132/** Write changes to disk immediately */
78icalerrorenum icalset_commit(icalset* set); 133icalerrorenum icalset_commit(icalset* set);
79 134
80icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); 135icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -83,28 +138,46 @@ icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
83int icalset_count_components(icalset* set, 138int icalset_count_components(icalset* set,
84 icalcomponent_kind kind); 139 icalcomponent_kind kind);
85 140
86/* Restrict the component returned by icalset_first, _next to those 141/** Restrict the component returned by icalset_first, _next to those
87 that pass the gauge. _clear removes the gauge. */ 142 that pass the gauge. */
88icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); 143icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
144
145/** Clears the gauge defined by icalset_select() */
89void icalset_clear_select(icalset* set); 146void icalset_clear_select(icalset* set);
90 147
91/* Get a component by uid */ 148/** Get a component by uid */
92icalcomponent* icalset_fetch(icalset* set, const char* uid); 149icalcomponent* icalset_fetch(icalset* set, const char* uid);
150
93int icalset_has_uid(icalset* set, const char* uid); 151int icalset_has_uid(icalset* set, const char* uid);
94icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); 152icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
95 153
96/* Modify components according to the MODIFY method of CAP. Works on 154/** Modify components according to the MODIFY method of CAP. Works on
97 the currently selected components. */ 155 the currently selected components. */
98icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, 156icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
99 icalcomponent *newc); 157 icalcomponent *newc);
100 158
101/* Iterate through the components. If a guage has been defined, these 159/** Iterate through the components. If a guage has been defined, these
102 will skip over components that do not pass the gauge */ 160 will skip over components that do not pass the gauge */
103 161
104icalcomponent* icalset_get_current_component(icalset* set); 162icalcomponent* icalset_get_current_component(icalset* set);
105icalcomponent* icalset_get_first_component(icalset* set); 163icalcomponent* icalset_get_first_component(icalset* set);
106icalcomponent* icalset_get_next_component(icalset* set); 164icalcomponent* icalset_get_next_component(icalset* set);
107 165
166/** External Iterator with gauge - for thread safety */
167extern icalsetiter icalsetiter_null;
168
169icalsetiter icalset_begin_component(icalset* set,
170 icalcomponent_kind kind, icalgauge* gauge);
171
172/** Default _next, _prior, _deref for subclasses that use single cluster */
173icalcomponent* icalsetiter_next(icalsetiter* i);
174icalcomponent* icalsetiter_prior(icalsetiter* i);
175icalcomponent* icalsetiter_deref(icalsetiter* i);
176
177/** for subclasses that use multiple clusters that require specialized cluster traversal */
178icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
179icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
180
108#endif /* !ICALSET_H */ 181#endif /* !ICALSET_H */
109 182
110 183
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 @@
28 28
29#include "ical.h" 29#include "ical.h"
30#include "icalspanlist.h" 30#include "icalspanlist.h"
31#include "pvl.h" 31
32#include <stdlib.h> /* for free and malloc */ 32#include <stdlib.h> /* for free and malloc */
33#include <string.h>
33 34
34struct icalspanlist_impl { 35struct icalspanlist_impl {
35 pvl_list spans; 36 pvl_list spans; /**< list of icaltime_span data **/
37 struct icaltimetype start; /**< start time of span **/
38 struct icaltimetype end;/**< end time of span **/
36}; 39};
37 40
38int compare_span(void* a, void* b) 41/** @brief Internal comparison function for two spans
42 *
43 * @param a a spanlist.
44 * @param b another spanlist.
45 *
46 * @return -1, 0, 1 depending on the comparison of the start times.
47 *
48 * Used to insert spans into the tree in sorted order.
49 */
50
51static int compare_span(void* a, void* b)
39{ 52{
40 struct icaltime_span *span_a = (struct icaltime_span *)a ; 53 struct icaltime_span *span_a = (struct icaltime_span *)a ;
41 struct icaltime_span *span_b = (struct icaltime_span *)b ; 54 struct icaltime_span *span_b = (struct icaltime_span *)b ;
@@ -49,20 +62,52 @@ int compare_span(void* a, void* b)
49 } 62 }
50} 63}
51 64
52icalcomponent* icalspanlist_get_inner(icalcomponent* comp) 65
66/** @brief callback function for collecting spanlists of a
67 * series of events.
68 *
69 * @param comp A valid icalcomponent.
70 * @param span The span to insert into data.
71 * @param data The actual spanlist to insert into
72 *
73 * This callback is used by icalcomponent_foreach_recurrence()
74 * to build up a spanlist.
75 */
76
77static void icalspanlist_new_callback(icalcomponent *comp,
78 struct icaltime_span *span,
79 void *data)
53{ 80{
54 if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ 81 icaltime_span *s;
55 return icalcomponent_get_first_real_component(comp); 82 icalspanlist *sl = (icalspanlist*) data;
56 } else { 83
57 return comp; 84 if (span->is_busy == 0)
58 } 85 return;
86
87 if ((s=(icaltime_span *) malloc(sizeof(icaltime_span))) == 0) {
88 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
89 return;
90 }
91
92 /** copy span data into allocated memory.. **/
93 *s = *span;
94 pvl_insert_ordered(sl->spans, compare_span, (void*)s);
59} 95}
96
60 97
61 98
62void print_span(int c, struct icaltime_span span ); 99/** @brief Make a free list from a set of VEVENT components.
100 *
101 * @param set A valid icalset containing VEVENTS
102 * @param start The free list starts at this date/time
103 * @param end The free list ends at this date/time
104 *
105 * @return A spanlist corresponding to the VEVENTS
106 *
107 * Given a set of components, a start time and an end time
108 * return a spanlist that contains the free/busy times.
109 */
63 110
64
65/* Make a free list from a set of component */
66icalspanlist* icalspanlist_new(icalset *set, 111icalspanlist* icalspanlist_new(icalset *set,
67 struct icaltimetype start, 112 struct icaltimetype start,
68 struct icaltimetype end) 113 struct icaltimetype end)
@@ -71,7 +116,7 @@ icalspanlist* icalspanlist_new(icalset *set,
71 pvl_elem itr; 116 pvl_elem itr;
72 icalcomponent *c,*inner; 117 icalcomponent *c,*inner;
73 icalcomponent_kind kind, inner_kind; 118 icalcomponent_kind kind, inner_kind;
74 struct icalspanlist_impl *sl; 119 icalspanlist *sl;
75 struct icaltime_span *freetime; 120 struct icaltime_span *freetime;
76 121
77 if ( ( sl = (struct icalspanlist_impl*) 122 if ( ( sl = (struct icalspanlist_impl*)
@@ -81,14 +126,12 @@ icalspanlist* icalspanlist_new(icalset *set,
81 } 126 }
82 127
83 sl->spans = pvl_newlist(); 128 sl->spans = pvl_newlist();
129 sl->start = start;
130 sl->end = end;
84 131
85 range.start = icaltime_as_timet(start); 132 range.start = icaltime_as_timet(start);
86 range.end = icaltime_as_timet(end); 133 range.end = icaltime_as_timet(end);
87 134
88 printf("Range start: %s",ctime(&range.start));
89 printf("Range end : %s",ctime(&range.end));
90
91
92 /* Get a list of spans of busy time from the events in the set 135 /* Get a list of spans of busy time from the events in the set
93 and order the spans based on the start time */ 136 and order the spans based on the start time */
94 137
@@ -96,8 +139,6 @@ icalspanlist* icalspanlist_new(icalset *set,
96 c != 0; 139 c != 0;
97 c = icalset_get_next_component(set)){ 140 c = icalset_get_next_component(set)){
98 141
99 struct icaltime_span span;
100
101 kind = icalcomponent_isa(c); 142 kind = icalcomponent_isa(c);
102 inner = icalcomponent_get_inner(c); 143 inner = icalcomponent_get_inner(c);
103 144
@@ -113,31 +154,12 @@ icalspanlist* icalspanlist_new(icalset *set,
113 } 154 }
114 155
115 icalerror_clear_errno(); 156 icalerror_clear_errno();
116 157
117 span = icalcomponent_get_span(c); 158 icalcomponent_foreach_recurrence(c, start, end,
118 span.is_busy = 1; 159 icalspanlist_new_callback,
119 160 (void*)sl);
120 if(icalerrno != ICAL_NO_ERROR){ 161
121 continue; 162 }
122 }
123
124 if ((range.start < span.end && icaltime_is_null_time(end)) ||
125 (range.start < span.end && range.end > span.start )){
126
127 struct icaltime_span *s;
128
129 if ((s=(struct icaltime_span *)
130 malloc(sizeof(struct icaltime_span))) == 0){
131 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
132 return 0;
133 }
134
135 memcpy(s,&span,sizeof(span));
136
137 pvl_insert_ordered(sl->spans,compare_span,(void*)s);
138
139 }
140 }
141 163
142 /* Now Fill in the free time spans. loop through the spans. if the 164 /* Now Fill in the free time spans. loop through the spans. if the
143 start of the range is not within the span, create a free entry 165 start of the range is not within the span, create a free entry
@@ -148,7 +170,7 @@ icalspanlist* icalspanlist_new(icalset *set,
148 itr != 0; 170 itr != 0;
149 itr = pvl_next(itr)) 171 itr = pvl_next(itr))
150 { 172 {
151 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 173 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
152 174
153 if ((freetime=(struct icaltime_span *) 175 if ((freetime=(struct icaltime_span *)
154 malloc(sizeof(struct icaltime_span))) == 0){ 176 malloc(sizeof(struct icaltime_span))) == 0){
@@ -178,7 +200,7 @@ icalspanlist* icalspanlist_new(icalset *set,
178 if( icaltime_is_null_time(end)){ 200 if( icaltime_is_null_time(end)){
179 struct icaltime_span* last_span; 201 struct icaltime_span* last_span;
180 202
181 last_span = pvl_data(pvl_tail(sl->spans)); 203 last_span = (struct icaltime_span*)pvl_data(pvl_tail(sl->spans));
182 204
183 if (last_span != 0){ 205 if (last_span != 0){
184 206
@@ -197,35 +219,46 @@ icalspanlist* icalspanlist_new(icalset *set,
197 219
198 220
199 return sl; 221 return sl;
200
201} 222}
202 223
224/** @brief Destructor.
225 * @param s A valid icalspanlist
226 *
227 * Free memory associated with the spanlist
228 */
229
203void icalspanlist_free(icalspanlist* s) 230void icalspanlist_free(icalspanlist* s)
204{ 231{
205 struct icaltime_span *span; 232 struct icaltime_span *span;
206 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s; 233
207 234 if (s == NULL)
208 while( (span=pvl_pop(impl->spans)) != 0){ 235 return;
236
237 while( (span=pvl_pop(s->spans)) != 0){
209 free(span); 238 free(span);
210 } 239 }
211 240
212 pvl_free(impl->spans); 241 pvl_free(s->spans);
213 242
214 impl->spans = 0; 243 s->spans = 0;
244
245 free(s);
215} 246}
216 247
217 248
218void icalspanlist_dump(icalspanlist* s){ 249/** @brief (Debug) print out spanlist to stdout.
250 * @param sl A valid icalspanlist.
251 */
219 252
253void icalspanlist_dump(icalspanlist* sl){
220 int i = 0; 254 int i = 0;
221 struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s;
222 pvl_elem itr; 255 pvl_elem itr;
223 256
224 for( itr = pvl_head(sl->spans); 257 for( itr = pvl_head(sl->spans);
225 itr != 0; 258 itr != 0;
226 itr = pvl_next(itr)) 259 itr = pvl_next(itr))
227 { 260 {
228 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 261 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
229 262
230 printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start)); 263 printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start));
231 printf(" end : %s",ctime(&s->end)); 264 printf(" end : %s",ctime(&s->end));
@@ -236,10 +269,19 @@ void icalspanlist_dump(icalspanlist* s){
236icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 269icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
237icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 270icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
238 271
272
273/** @brief Find next free time span in a spanlist.
274 *
275 * @param sl The spanlist to search.
276 * @param t The time to start looking.
277 *
278 * Given a spanlist and a time, find the next period of time
279 * that is free
280 */
281
239struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 282struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
240 struct icaltimetype t) 283 struct icaltimetype t)
241{ 284{
242 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl;
243 pvl_elem itr; 285 pvl_elem itr;
244 struct icalperiodtype period; 286 struct icalperiodtype period;
245 struct icaltime_span *s; 287 struct icaltime_span *s;
@@ -249,22 +291,22 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
249 period.start = icaltime_null_time(); 291 period.start = icaltime_null_time();
250 period.end = icaltime_null_time(); 292 period.end = icaltime_null_time();
251 293
252 /* Is the reference time before the first span? If so, assume 294 itr = pvl_head(sl->spans);
253 that the reference time is free */ 295 s = (struct icaltime_span *)pvl_data(itr);
254 itr = pvl_head(impl->spans);
255 s = (icalproperty*)pvl_data(itr);
256 296
257 if (s == 0){ 297 if (s == 0){
258 /* No elements in span */ 298 /* No elements in span */
259 return period; 299 return period;
260 } 300 }
261 301
302 /* Is the reference time before the first span? If so, assume
303 that the reference time is free */
262 if(rangett <s->start ){ 304 if(rangett <s->start ){
263 /* End of period is start of first span if span is busy, end 305 /* End of period is start of first span if span is busy, end
264 of the span if it is free */ 306 of the span if it is free */
265 period.start = t; 307 period.start = t;
266 308
267 if (s->is_busy == 0){ 309 if (s->is_busy == 1){
268 period.end = icaltime_from_timet(s->start,0); 310 period.end = icaltime_from_timet(s->start,0);
269 } else { 311 } else {
270 period.end = icaltime_from_timet(s->end,0); 312 period.end = icaltime_from_timet(s->end,0);
@@ -275,12 +317,11 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
275 317
276 /* Otherwise, find the first free span that contains the 318 /* Otherwise, find the first free span that contains the
277 reference time. */ 319 reference time. */
278 320 for( itr = pvl_head(sl->spans);
279 for( itr = pvl_head(impl->spans);
280 itr != 0; 321 itr != 0;
281 itr = pvl_next(itr)) 322 itr = pvl_next(itr))
282 { 323 {
283 s = (icalproperty*)pvl_data(itr); 324 s = (struct icaltime_span *)pvl_data(itr);
284 325
285 if(s->is_busy == 0 && s->start >= rangett && 326 if(s->is_busy == 0 && s->start >= rangett &&
286 ( rangett < s->end || s->end == s->start)){ 327 ( rangett < s->end || s->end == s->start)){
@@ -307,3 +348,220 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
307struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 348struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
308 struct icaltimetype t); 349 struct icaltimetype t);
309 350
351
352/** @brief Returns an hour-by-hour array of free/busy times over a
353 * given period.
354 *
355 * @param sl A valid icalspanlist
356 * @param delta_t The time slice to divide by, in seconds. Default 3600.
357 *
358 * @return A pointer to an array of integers containing the number of
359 * busy events in each delta_t time period. The final entry
360 * contains the value -1.
361 *
362 * This calculation is somewhat tricky. This is due to the fact that
363 * the time range contains the start time, but does not contain the
364 * end time. To perform a proper calculation we subtract one second
365 * off the end times to get a true containing time.
366 *
367 * Also note that if you supplying a spanlist that does not start or
368 * end on a time boundary divisible by delta_t you may get results
369 * that are not quite what you expect.
370 */
371
372int* icalspanlist_as_freebusy_matrix(icalspanlist* sl, int delta_t) {
373 pvl_elem itr;
374 int spanduration_secs;
375 int *matrix;
376 int matrix_slots;
377 time_t sl_start, sl_end;
378
379 icalerror_check_arg_rz( (sl!=0), "spanlist");
380
381 if (!delta_t)
382 delta_t = 3600;
383
384 /** calculate the start and end time as time_t **/
385 sl_start = icaltime_as_timet_with_zone(sl->start, icaltimezone_get_utc_timezone());
386 sl_end = icaltime_as_timet_with_zone(sl->end, icaltimezone_get_utc_timezone());
387
388
389 /** insure that the time period falls on a time boundary divisable
390 by delta_t */
391
392 sl_start /= delta_t;
393 sl_start *= delta_t;
394
395 sl_end /= delta_t;
396 sl_end *= delta_t;
397
398
399 /** find the duration of this spanlist **/
400 spanduration_secs = sl_end - sl_start;
401
402
403 /** malloc our matrix, add one extra slot for a final -1 **/
404 matrix_slots = spanduration_secs/delta_t + 1;
405
406 matrix = (int*) malloc(sizeof(int) * matrix_slots);
407 if (matrix == NULL) {
408 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
409 return NULL;
410 }
411 memset(matrix, 0, sizeof(int) * matrix_slots);
412 matrix[matrix_slots-1] = -1;
413
414 /* loop through each span and mark the slots in the array */
415
416 for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
417 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
418
419 if (s->is_busy == 1) {
420 int offset_start = s->start/delta_t - sl_start/delta_t;
421 int offset_end = (s->end - 1) /delta_t - sl_start/delta_t + 1;
422 int i;
423
424 if (offset_end >= matrix_slots)
425 offset_end = matrix_slots - 1;
426
427 i = offset_start;
428 for (i=offset_start; i < offset_end; i++) {
429 matrix[i]++;
430 }
431 }
432 }
433 return matrix;
434}
435
436
437/** @brief Return a VFREEBUSY component for the corresponding spanlist
438 *
439 * @param sl A valid icalspanlist, from icalspanlist_new()
440 * @param organizer The organizer specified as MAILTO:user@domain
441 * @param attendee The attendee specified as MAILTO:user@domain
442 *
443 * @return A valid icalcomponent or NULL.
444 *
445 * This function returns a VFREEBUSY component for the given spanlist.
446 * The start time is mapped to DTSTART, the end time to DTEND.
447 * Each busy span is represented as a separate FREEBUSY entry.
448 * An attendee parameter is required, and organizer parameter is
449 * optional.
450 */
451
452icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* sl,
453 const char* organizer,
454 const char* attendee) {
455 icalcomponent *comp;
456 icalproperty *p;
457 struct icaltimetype atime = icaltime_from_timet( time(0),0);
458 pvl_elem itr;
459 icaltimezone *utc_zone;
460 icalparameter *param;
461
462 if (!attendee) {
463 icalerror_set_errno(ICAL_USAGE_ERROR);
464 return 0;
465 }
466
467 utc_zone = icaltimezone_get_utc_timezone ();
468
469 comp = icalcomponent_new_vfreebusy();
470
471 icalcomponent_add_property(comp, icalproperty_new_dtstart(sl->start));
472 icalcomponent_add_property(comp, icalproperty_new_dtend(sl->end));
473 icalcomponent_add_property(comp, icalproperty_new_dtstamp(atime));
474
475 if (organizer) {
476 icalcomponent_add_property(comp, icalproperty_new_organizer(organizer));
477 }
478 icalcomponent_add_property(comp, icalproperty_new_attendee(attendee));
479
480 /* now add the freebusy sections.. */
481
482 for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
483 struct icalperiodtype period;
484 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
485
486 if (s->is_busy == 1) {
487
488 period.start = icaltime_from_timet_with_zone (s->start, 0, utc_zone);
489 period.end = icaltime_from_timet_with_zone (s->end, 0, utc_zone);
490 period.duration = icaldurationtype_null_duration();
491
492
493 p = icalproperty_new_freebusy(period);
494 param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSY);
495 icalproperty_add_parameter(p, param);
496
497 icalcomponent_add_property(comp, p);
498 }
499
500 }
501
502 return comp;
503}
504
505
506/** @brief Return a spanlist corresponding to the VFREEBUSY portion of
507 * an icalcomponent.
508 *
509 * @param c A valid icalcomponent.
510 *
511 * @return A valid icalspanlist or NULL if no VFREEBUSY section.
512 *
513 */
514
515
516icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* comp)
517{
518 icalcomponent *inner;
519 icalproperty *prop;
520 icalspanlist *sl;
521
522 icalerror_check_arg_rz((comp != NULL), "comp");
523
524 inner = icalcomponent_get_inner(comp);
525 if (!inner) return NULL;
526
527 if ( ( sl = (icalspanlist*) malloc(sizeof(icalspanlist))) == 0) {
528 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
529 return 0;
530 }
531 sl->spans = pvl_newlist();
532
533 /* cycle through each FREEBUSY property, adding to the spanlist */
534 for (prop = icalcomponent_get_first_property(inner, ICAL_FREEBUSY_PROPERTY);
535 prop != NULL;
536 prop = icalcomponent_get_next_property(inner, ICAL_FREEBUSY_PROPERTY)) {
537 icaltime_span *s = (icaltime_span *) malloc(sizeof(icaltime_span));
538 icalparameter *param;
539 struct icalperiodtype period;
540 icalparameter_fbtype fbtype;
541
542 if (s == 0) {
543 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
544 return 0;
545 }
546
547 param = icalproperty_get_first_parameter(prop, ICAL_FBTYPE_PARAMETER);
548 fbtype = (param) ? icalparameter_get_fbtype(param) : ICAL_FBTYPE_BUSY;
549
550 switch (fbtype) {
551 case ICAL_FBTYPE_FREE:
552 case ICAL_FBTYPE_NONE:
553 case ICAL_FBTYPE_X:
554 s->is_busy = 1;
555 default:
556 s->is_busy = 0;
557 }
558
559 period = icalproperty_get_freebusy(prop);
560 s->start = icaltime_as_timet_with_zone(period.start, icaltimezone_get_utc_timezone());
561 s->end = icaltime_as_timet_with_zone(period.end, icaltimezone_get_utc_timezone());
562;
563 pvl_insert_ordered(sl->spans, compare_span, (void*)s);
564 }
565 /** @todo calculate start/end limits.. fill in holes? **/
566 return sl;
567}
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 @@
28#include "ical.h" 28#include "ical.h"
29#include "icalset.h" 29#include "icalset.h"
30 30
31typedef void icalspanlist; 31/** @file icalspanlist.h
32 * @brief Code that supports collections of free/busy spans of time
33 */
34
35typedef struct icalspanlist_impl icalspanlist;
36
37
38/** @brief Constructor
39 * Make a free list from a set of component. Start and end should be in UTC
40 */
32 41
33/* Make a free list from a set of component. Start and end should be in UTC */
34icalspanlist* icalspanlist_new(icalset *set, 42icalspanlist* icalspanlist_new(icalset *set,
35 struct icaltimetype start, 43 struct icaltimetype start,
36 struct icaltimetype end); 44 struct icaltimetype end);
37 45
46/** @brief Destructor
47 */
38void icalspanlist_free(icalspanlist* spl); 48void icalspanlist_free(icalspanlist* spl);
39 49
50/* Unimplemented functions */
40icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 51icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
41icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 52icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
42 53
43/* Get first free or busy time after time t. all times are in UTC */ 54/** Get first next free time after time t. all times are in UTC. */
44struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 55struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
45 struct icaltimetype t); 56 struct icaltimetype t);
57/** Get first next busy time after time t. all times are in UTC. */
46struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 58struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
47 struct icaltimetype t); 59 struct icaltimetype t);
48 60
49void icalspanlist_dump(icalspanlist* s); 61void icalspanlist_dump(icalspanlist* s);
50 62
63/** @brief Return a valid VFREEBUSY component for this span */
64icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
65 const char* organizer,
66 const char* attendee);
67
68/** @brief Return an integer matrix of total events per delta_t timespan */
69int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
70
71/** @brief Construct an icalspanlist from a VFREEBUSY component */
72icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
73
51#endif 74#endif
52 75
53 76
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 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4/*
5 $Id$
6*/
1/* -*- Mode: C -*- */ 7/* -*- Mode: C -*- */
2/*====================================================================== 8/*======================================================================
3 FILE: icalgauge.h 9 FILE: icalgauge.h
4 CREATOR: eric 23 December 1999 10 CREATOR: eric 23 December 1999
5 11
6 12
7 $Id$
8 $Locker$
9 13
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 14 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11 15
@@ -29,42 +33,52 @@
29#ifndef ICALGAUGE_H 33#ifndef ICALGAUGE_H
30#define ICALGAUGE_H 34#define ICALGAUGE_H
31 35
32typedef void icalgauge; 36/** @file icalgauge.h
37 * @brief Routines implementing a filter for ical components
38 */
33 39
34icalgauge* icalgauge_new_from_sql(char* sql); 40typedef struct icalgauge_impl icalgauge;
41
42icalgauge* icalgauge_new_from_sql(char* sql, int expand);
43
44int icalgauge_get_expand(icalgauge* gauge);
35 45
36void icalgauge_free(icalgauge* gauge); 46void icalgauge_free(icalgauge* gauge);
37 47
38char* icalgauge_as_sql(icalcomponent* gauge); 48char* icalgauge_as_sql(icalcomponent* gauge);
39 49
40void icalgauge_dump(icalcomponent* gauge); 50void icalgauge_dump(icalgauge* gauge);
51
41 52
42/* Return true is comp matches the gauge. The component must be in 53/** @brief Return true if comp matches the gauge.
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL 54 *
44 sub component */ 55 * The component must be in
56 * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
57 * sub component
58 */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp); 59int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46 60
47/* Clone the component, but only return the properties specified in 61/** Clone the component, but only return the properties
48 the gauge */ 62 * specified in the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); 63icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
50 64
51#endif /* ICALGAUGE_H*/ 65#endif /* ICALGAUGE_H*/
52/* -*- Mode: C -*- */ 66/* -*- Mode: C -*- */
53/*====================================================================== 67/**
54 FILE: icalset.h 68 @file icalset.h
55 CREATOR: eric 28 November 1999 69 @author eric 28 November 1999
56
57 70
58 Icalset is the "base class" for representations of a collection of 71 Icalset is the "base class" for representations of a collection of
59 iCal components. Derived classes (actually delegatees) include: 72 iCal components. Derived classes (actually delegatees) include:
60 73
61 icalfileset Store componetns in a single file 74 icalfileset Store components in a single file
62 icaldirset Store components in multiple files in a directory 75 icaldirset Store components in multiple files in a directory
76 icalbdbset Store components in a Berkeley DB File
63 icalheapset Store components on the heap 77 icalheapset Store components on the heap
64 icalmysqlset Store components in a mysql database. 78 icalmysqlset Store components in a mysql database.
79**/
65 80
66 $Id$ 81/*
67 $Locker$
68 82
69 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 83 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
70 84
@@ -97,37 +111,86 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
97#endif 111#endif
98 112
99 113
100#ifdef _WIN32 114typedef struct icalset_impl icalset;
101#define mode_t int
102#endif
103
104
105
106typedef void icalset;
107 115
108typedef enum icalset_kind { 116typedef enum icalset_kind {
109 ICAL_FILE_SET, 117 ICAL_FILE_SET,
110 ICAL_DIR_SET, 118 ICAL_DIR_SET,
111 ICAL_HEAP_SET, 119 ICAL_BDB_SET
112 ICAL_MYSQL_SET,
113 ICAL_CAP_SET
114} icalset_kind; 120} icalset_kind;
115 121
122typedef struct icalsetiter
123{
124 icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
125 icalgauge* gauge;
126 icalrecur_iterator* ritr; /*the last iterator*/
127 icalcomponent* last_component; /*the pending recurring component to be processed */
128 const char* tzid; /* the calendar's timezone id */
129} icalsetiter;
130
131struct icalset_impl {
132 icalset_kind kind;
133 int size;
134 char *dsn;
135 icalset* (*init)(icalset* set, const char *dsn, void *options);
136 void (*free)(icalset* set);
137 const char* (*path)(icalset* set);
138 void (*mark)(icalset* set);
139 icalerrorenum (*commit)(icalset* set);
140 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
141 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
142 int (*count_components)(icalset* set,
143 icalcomponent_kind kind);
144 icalerrorenum (*select)(icalset* set, icalgauge* gauge);
145 void (*clear)(icalset* set);
146 icalcomponent* (*fetch)(icalset* set, const char* uid);
147 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
148 int (*has_uid)(icalset* set, const char* uid);
149 icalerrorenum (*modify)(icalset* set, icalcomponent *old,
150 icalcomponent *newc);
151 icalcomponent* (*get_current_component)(icalset* set);
152 icalcomponent* (*get_first_component)(icalset* set);
153 icalcomponent* (*get_next_component)(icalset* set);
154 icalsetiter (*icalset_begin_component)(icalset* set,
155 icalcomponent_kind kind, icalgauge* gauge);
156 icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
157 icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
158};
159
160/** @brief Register a new derived class */
161int icalset_register_class(icalset *set);
162
163
164/** @brief Generic icalset constructor
165 *
166 * @param kind The type of icalset to create
167 * @param dsn Data Source Name - usually a pathname or DB handle
168 * @param options Any implementation specific options
169 *
170 * @return A valid icalset reference or NULL if error.
171 *
172 * This creates any of the icalset types available.
173 */
174
175icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
116 176
117/* Create a specific derived type of set */
118icalset* icalset_new_file(const char* path); 177icalset* icalset_new_file(const char* path);
178icalset* icalset_new_file_reader(const char* path);
179icalset* icalset_new_file_writer(const char* path);
180
119icalset* icalset_new_dir(const char* path); 181icalset* icalset_new_dir(const char* path);
120icalset* icalset_new_heap(void); 182icalset* icalset_new_file_reader(const char* path);
121icalset* icalset_new_mysql(const char* path); 183icalset* icalset_new_file_writer(const char* path);
122/*icalset* icalset_new_cap(icalcstp* cstp);*/
123 184
124void icalset_free(icalset* set); 185void icalset_free(icalset* set);
125 186
126const char* icalset_path(icalset* set); 187const char* icalset_path(icalset* set);
127 188
128/* Mark the cluster as changed, so it will be written to disk when it 189/** Mark the cluster as changed, so it will be written to disk when it
129 is freed. Commit writes to disk immediately*/ 190 is freed. **/
130void icalset_mark(icalset* set); 191void icalset_mark(icalset* set);
192
193/** Write changes to disk immediately */
131icalerrorenum icalset_commit(icalset* set); 194icalerrorenum icalset_commit(icalset* set);
132 195
133icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); 196icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -136,40 +199,113 @@ icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
136int icalset_count_components(icalset* set, 199int icalset_count_components(icalset* set,
137 icalcomponent_kind kind); 200 icalcomponent_kind kind);
138 201
139/* Restrict the component returned by icalset_first, _next to those 202/** Restrict the component returned by icalset_first, _next to those
140 that pass the gauge. _clear removes the gauge. */ 203 that pass the gauge. */
141icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); 204icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
205
206/** Clears the gauge defined by icalset_select() */
142void icalset_clear_select(icalset* set); 207void icalset_clear_select(icalset* set);
143 208
144/* Get a component by uid */ 209/** Get a component by uid */
145icalcomponent* icalset_fetch(icalset* set, const char* uid); 210icalcomponent* icalset_fetch(icalset* set, const char* uid);
211
146int icalset_has_uid(icalset* set, const char* uid); 212int icalset_has_uid(icalset* set, const char* uid);
147icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); 213icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
148 214
149/* Modify components according to the MODIFY method of CAP. Works on 215/** Modify components according to the MODIFY method of CAP. Works on
150 the currently selected components. */ 216 the currently selected components. */
151icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, 217icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
152 icalcomponent *newc); 218 icalcomponent *newc);
153 219
154/* Iterate through the components. If a guage has been defined, these 220/** Iterate through the components. If a guage has been defined, these
155 will skip over components that do not pass the gauge */ 221 will skip over components that do not pass the gauge */
156 222
157icalcomponent* icalset_get_current_component(icalset* set); 223icalcomponent* icalset_get_current_component(icalset* set);
158icalcomponent* icalset_get_first_component(icalset* set); 224icalcomponent* icalset_get_first_component(icalset* set);
159icalcomponent* icalset_get_next_component(icalset* set); 225icalcomponent* icalset_get_next_component(icalset* set);
160 226
227/** External Iterator with gauge - for thread safety */
228extern icalsetiter icalsetiter_null;
229
230icalsetiter icalset_begin_component(icalset* set,
231 icalcomponent_kind kind, icalgauge* gauge);
232
233/** Default _next, _prior, _deref for subclasses that use single cluster */
234icalcomponent* icalsetiter_next(icalsetiter* i);
235icalcomponent* icalsetiter_prior(icalsetiter* i);
236icalcomponent* icalsetiter_deref(icalsetiter* i);
237
238/** for subclasses that use multiple clusters that require specialized cluster traversal */
239icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
240icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
241
161#endif /* !ICALSET_H */ 242#endif /* !ICALSET_H */
162 243
163 244
164 245
165/* -*- Mode: C -*- */ 246/* -*- Mode: C -*- */
166/*====================================================================== 247/*======================================================================
248 FILE: icalcluster.h
249 CREATOR: eric 23 December 1999
250
251
252
253 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
254
255 This program is free software; you can redistribute it and/or modify
256 it under the terms of either:
257
258 The LGPL as published by the Free Software Foundation, version
259 2.1, available at: http://www.fsf.org/copyleft/lesser.html
260
261 Or:
262
263 The Mozilla Public License Version 1.0. You may obtain a copy of
264 the License at http://www.mozilla.org/MPL/
265
266 The Original Code is eric. The Initial Developer of the Original
267 Code is Eric Busboom
268
269
270======================================================================*/
271
272#ifndef ICALCLUSTER_H
273#define ICALCLUSTER_H
274
275
276typedef struct icalcluster_impl icalcluster;
277
278icalcluster* icalcluster_new(const char *key, icalcomponent *data);
279icalcluster* icalcluster_new_clone(const icalcluster *cluster);
280
281void icalcluster_free(icalcluster *cluster);
282
283const char* icalcluster_key(icalcluster *cluster);
284int icalcluster_is_changed(icalcluster *cluster);
285void icalcluster_mark(icalcluster *cluster);
286void icalcluster_commit(icalcluster *cluster);
287
288icalcomponent* icalcluster_get_component(icalcluster* cluster);
289int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
290icalerrorenum icalcluster_add_component(icalcluster* cluster,
291 icalcomponent* child);
292icalerrorenum icalcluster_remove_component(icalcluster* cluster,
293 icalcomponent* child);
294
295icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
296icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
297icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
298
299#endif /* !ICALCLUSTER_H */
300
301
302
303/* -*- Mode: C -*- */
304/*======================================================================
167 FILE: icalfileset.h 305 FILE: icalfileset.h
168 CREATOR: eric 23 December 1999 306 CREATOR: eric 23 December 1999
169 307
170 308
171 $Id$
172 $Locker$
173 309
174 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 310 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
175 311
@@ -197,68 +333,96 @@ icalcomponent* icalset_get_next_component(icalset* set);
197#include <sys/stat.h> /* For open() flags and mode */ 333#include <sys/stat.h> /* For open() flags and mode */
198#include <fcntl.h> /* For open() flags and mode */ 334#include <fcntl.h> /* For open() flags and mode */
199 335
200extern int icalfileset_safe_saves; 336#ifdef WIN32
337#define mode_t int
338#endif
201 339
202typedef void icalfileset; 340extern int icalfileset_safe_saves;
203 341
342typedef struct icalfileset_impl icalfileset;
204 343
205/* icalfileset 344icalset* icalfileset_new(const char* path);
206 icalfilesetfile 345icalset* icalfileset_new_reader(const char* path);
207 icalfilesetdir 346icalset* icalfileset_new_writer(const char* path);
208*/
209 347
348icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
210 349
211icalfileset* icalfileset_new(const char* path); 350icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
212 351
213/* Like _new, but takes open() flags for opening the file */ 352icalcluster* icalfileset_produce_icalcluster(const char *path);
214icalfileset* icalfileset_new_open(const char* path,
215 int flags, mode_t mode);
216 353
217void icalfileset_free(icalfileset* cluster); 354void icalfileset_free(icalset* cluster);
218 355
219const char* icalfileset_path(icalfileset* cluster); 356const char* icalfileset_path(icalset* cluster);
220 357
221/* Mark the cluster as changed, so it will be written to disk when it 358/* Mark the cluster as changed, so it will be written to disk when it
222 is freed. Commit writes to disk immediately. */ 359 is freed. Commit writes to disk immediately. */
223void icalfileset_mark(icalfileset* cluster); 360void icalfileset_mark(icalset* set);
224icalerrorenum icalfileset_commit(icalfileset* cluster); 361icalerrorenum icalfileset_commit(icalset* set);
225 362
226icalerrorenum icalfileset_add_component(icalfileset* cluster, 363icalerrorenum icalfileset_add_component(icalset* set,
227 icalcomponent* child); 364 icalcomponent* child);
228 365
229icalerrorenum icalfileset_remove_component(icalfileset* cluster, 366icalerrorenum icalfileset_remove_component(icalset* set,
230 icalcomponent* child); 367 icalcomponent* child);
231 368
232int icalfileset_count_components(icalfileset* cluster, 369int icalfileset_count_components(icalset* set,
233 icalcomponent_kind kind); 370 icalcomponent_kind kind);
234 371
235/* Restrict the component returned by icalfileset_first, _next to those 372/**
236 that pass the gauge. _clear removes the gauge */ 373 * Restrict the component returned by icalfileset_first, _next to those
237icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge); 374 * that pass the gauge. _clear removes the gauge
238void icalfileset_clear(icalfileset* store); 375 */
376icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
239 377
240/* Get and search for a component by uid */ 378/** clear the gauge **/
241icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); 379void icalfileset_clear(icalset* set);
242int icalfileset_has_uid(icalfileset* cluster, const char* uid);
243icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c);
244 380
381/** Get and search for a component by uid **/
382icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
383int icalfileset_has_uid(icalset* set, const char* uid);
384icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
245 385
246/* Modify components according to the MODIFY method of CAP. Works on 386
247 the currently selected components. */ 387/**
248icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, 388 * Modify components according to the MODIFY method of CAP. Works on the
389 * currently selected components.
390 */
391icalerrorenum icalfileset_modify(icalset* set,
392 icalcomponent *oldcomp,
249 icalcomponent *newcomp); 393 icalcomponent *newcomp);
250 394
251/* Iterate through components. If a guage has been defined, these 395/* Iterate through components. If a gauge has been defined, these
252 will skip over components that do not pass the gauge */ 396 will skip over components that do not pass the gauge */
253 397
254icalcomponent* icalfileset_get_current_component (icalfileset* cluster); 398icalcomponent* icalfileset_get_current_component (icalset* cluster);
255icalcomponent* icalfileset_get_first_component(icalfileset* cluster); 399icalcomponent* icalfileset_get_first_component(icalset* cluster);
256icalcomponent* icalfileset_get_next_component(icalfileset* cluster); 400icalcomponent* icalfileset_get_next_component(icalset* cluster);
257/* Return a reference to the internal component. You probably should 401
402/* External iterator for thread safety */
403icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
404icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
405icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
406
407/** Return a reference to the internal component. You probably should
258 not be using this. */ 408 not be using this. */
259 409
260icalcomponent* icalfileset_get_component(icalfileset* cluster); 410icalcomponent* icalfileset_get_component(icalset* cluster);
411
412/**
413 * @brief options for opening an icalfileset.
414 *
415 * These options should be passed to the icalset_new() function
416 */
261 417
418typedef struct icalfileset_options {
419 int flags; /**< flags for open() O_RDONLY, etc */
420 mode_t mode; /**< file mode */
421 int safe_saves;/**< to lock or not */
422 icalcluster *cluster;/**< use this cluster to initialize data */
423} icalfileset_options;
424
425extern icalfileset_options icalfileset_options_default;
262 426
263#endif /* !ICALFILESET_H */ 427#endif /* !ICALFILESET_H */
264 428
@@ -270,8 +434,6 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
270 CREATOR: eric 28 November 1999 434 CREATOR: eric 28 November 1999
271 435
272 436
273 $Id$
274 $Locker$
275 437
276 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 438 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
277 439
@@ -299,47 +461,60 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
299/* icaldirset Routines for storing, fetching, and searching for ical 461/* icaldirset Routines for storing, fetching, and searching for ical
300 * objects in a database */ 462 * objects in a database */
301 463
302typedef void icaldirset; 464typedef struct icaldirset_impl icaldirset;
303 465
466icalset* icaldirset_new(const char* path);
304 467
305icaldirset* icaldirset_new(const char* path); 468icalset* icaldirset_new_reader(const char* path);
469icalset* icaldirset_new_writer(const char* path);
306 470
307void icaldirset_free(icaldirset* store);
308 471
309const char* icaldirset_path(icaldirset* store); 472icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
473void icaldirset_free(icalset* set);
474
475const char* icaldirset_path(icalset* set);
310 476
311/* Mark the cluster as changed, so it will be written to disk when it 477/* Mark the cluster as changed, so it will be written to disk when it
312 is freed. Commit writes to disk immediately*/ 478 is freed. Commit writes to disk immediately*/
313void icaldirset_mark(icaldirset* store); 479void icaldirset_mark(icalset* set);
314icalerrorenum icaldirset_commit(icaldirset* store); 480icalerrorenum icaldirset_commit(icalset* set);
315 481
316icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); 482icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
317icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); 483icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
318 484
319int icaldirset_count_components(icaldirset* store, 485int icaldirset_count_components(icalset* store,
320 icalcomponent_kind kind); 486 icalcomponent_kind kind);
321 487
322/* Restrict the component returned by icaldirset_first, _next to those 488/* Restrict the component returned by icaldirset_first, _next to those
323 that pass the gauge. _clear removes the gauge. */ 489 that pass the gauge. _clear removes the gauge. */
324icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); 490icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
325void icaldirset_clear(icaldirset* store); 491void icaldirset_clear(icalset* store);
326 492
327/* Get a component by uid */ 493/* Get a component by uid */
328icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); 494icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
329int icaldirset_has_uid(icaldirset* store, const char* uid); 495int icaldirset_has_uid(icalset* store, const char* uid);
330icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); 496icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c);
331 497
332/* Modify components according to the MODIFY method of CAP. Works on 498/* Modify components according to the MODIFY method of CAP. Works on
333 the currently selected components. */ 499 the currently selected components. */
334icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, 500icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
335 icalcomponent *newc); 501 icalcomponent *newc);
336 502
337/* Iterate through the components. If a guage has been defined, these 503/* Iterate through the components. If a gauge has been defined, these
338 will skip over components that do not pass the gauge */ 504 will skip over components that do not pass the gauge */
339 505
340icalcomponent* icaldirset_get_current_component(icaldirset* store); 506icalcomponent* icaldirset_get_current_component(icalset* store);
341icalcomponent* icaldirset_get_first_component(icaldirset* store); 507icalcomponent* icaldirset_get_first_component(icalset* store);
342icalcomponent* icaldirset_get_next_component(icaldirset* store); 508icalcomponent* icaldirset_get_next_component(icalset* store);
509
510/* External iterator for thread safety */
511icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
512icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
513icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
514
515typedef struct icaldirset_options {
516 int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
517} icaldirset_options;
343 518
344#endif /* !ICALDIRSET_H */ 519#endif /* !ICALDIRSET_H */
345 520
@@ -351,8 +526,6 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
351 CREATOR: eric 23 December 1999 526 CREATOR: eric 23 December 1999
352 527
353 528
354 $Id$
355 $Locker$
356 529
357 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 530 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
358 531
@@ -383,7 +556,7 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
383 * components. It also has interfaces to access the free/busy list 556 * components. It also has interfaces to access the free/busy list
384 * and a list of calendar properties */ 557 * and a list of calendar properties */
385 558
386typedef void icalcalendar; 559typedef struct icalcalendar_impl icalcalendar;
387 560
388icalcalendar* icalcalendar_new(char* dir); 561icalcalendar* icalcalendar_new(char* dir);
389 562
@@ -416,8 +589,6 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
416 CREATOR: eric 21 Aug 2000 589 CREATOR: eric 21 Aug 2000
417 590
418 591
419 $Id$
420 $Locker$
421 592
422 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 593 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
423 594
@@ -439,44 +610,12 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
439#define ICALCLASSIFY_H 610#define ICALCLASSIFY_H
440 611
441 612
442 613icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
443typedef enum icalclass {
444 ICAL_NO_CLASS,
445 ICAL_PUBLISH_NEW_CLASS,
446 ICAL_PUBLISH_UPDATE_CLASS,
447 ICAL_PUBLISH_FREEBUSY_CLASS,
448 ICAL_REQUEST_NEW_CLASS,
449 ICAL_REQUEST_UPDATE_CLASS,
450 ICAL_REQUEST_RESCHEDULE_CLASS,
451 ICAL_REQUEST_DELEGATE_CLASS,
452 ICAL_REQUEST_NEW_ORGANIZER_CLASS,
453 ICAL_REQUEST_FORWARD_CLASS,
454 ICAL_REQUEST_STATUS_CLASS,
455 ICAL_REQUEST_FREEBUSY_CLASS,
456 ICAL_REPLY_ACCEPT_CLASS,
457 ICAL_REPLY_DECLINE_CLASS,
458 ICAL_REPLY_DELEGATE_CLASS,
459 ICAL_REPLY_CRASHER_ACCEPT_CLASS,
460 ICAL_REPLY_CRASHER_DECLINE_CLASS,
461 ICAL_ADD_INSTANCE_CLASS,
462 ICAL_CANCEL_EVENT_CLASS,
463 ICAL_CANCEL_INSTANCE_CLASS,
464 ICAL_CANCEL_ALL_CLASS,
465 ICAL_REFRESH_CLASS,
466 ICAL_COUNTER_CLASS,
467 ICAL_DECLINECOUNTER_CLASS,
468 ICAL_MALFORMED_CLASS,
469 ICAL_OBSOLETE_CLASS, /* 21 */
470 ICAL_MISSEQUENCED_CLASS, /* 22 */
471 ICAL_UNKNOWN_CLASS /* 23 */
472} ical_class;
473
474ical_class icalclassify(icalcomponent* c,icalcomponent* match,
475 const char* user); 614 const char* user);
476 615
477icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); 616icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
478 617
479char* icalclassify_class_to_string(ical_class iclass); 618char* icalclassify_class_to_string(icalproperty_xlicclass c);
480 619
481 620
482#endif /* ICALCLASSIFY_H*/ 621#endif /* ICALCLASSIFY_H*/
@@ -491,8 +630,6 @@ char* icalclassify_class_to_string(ical_class iclass);
491 CREATOR: eric 21 Aug 2000 630 CREATOR: eric 21 Aug 2000
492 631
493 632
494 $Id$
495 $Locker$
496 633
497 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 634 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
498 635
@@ -513,26 +650,49 @@ char* icalclassify_class_to_string(ical_class iclass);
513#define ICALSPANLIST_H 650#define ICALSPANLIST_H
514 651
515 652
516typedef void icalspanlist; 653/** @file icalspanlist.h
654 * @brief Code that supports collections of free/busy spans of time
655 */
656
657typedef struct icalspanlist_impl icalspanlist;
658
659
660/** @brief Constructor
661 * Make a free list from a set of component. Start and end should be in UTC
662 */
517 663
518/* Make a free list from a set of component. Start and end should be in UTC */
519icalspanlist* icalspanlist_new(icalset *set, 664icalspanlist* icalspanlist_new(icalset *set,
520 struct icaltimetype start, 665 struct icaltimetype start,
521 struct icaltimetype end); 666 struct icaltimetype end);
522 667
668/** @brief Destructor
669 */
523void icalspanlist_free(icalspanlist* spl); 670void icalspanlist_free(icalspanlist* spl);
524 671
672/* Unimplemented functions */
525icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 673icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
526icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 674icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
527 675
528/* Get first free or busy time after time t. all times are in UTC */ 676/** Get first next free time after time t. all times are in UTC. */
529struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 677struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
530 struct icaltimetype t); 678 struct icaltimetype t);
679/** Get first next busy time after time t. all times are in UTC. */
531struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 680struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
532 struct icaltimetype t); 681 struct icaltimetype t);
533 682
534void icalspanlist_dump(icalspanlist* s); 683void icalspanlist_dump(icalspanlist* s);
535 684
685/** @brief Return a valid VFREEBUSY component for this span */
686icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
687 const char* organizer,
688 const char* attendee);
689
690/** @brief Return an integer matrix of total events per delta_t timespan */
691int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
692
693/** @brief Construct an icalspanlist from a VFREEBUSY component */
694icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
695
536#endif 696#endif
537 697
538 698
@@ -543,8 +703,6 @@ void icalspanlist_dump(icalspanlist* s);
543 CREATOR: eric 07 Nov 2000 703 CREATOR: eric 07 Nov 2000
544 704
545 705
546 $Id$
547 $Locker$
548 706
549 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 707 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
550 708
@@ -607,279 +765,6 @@ icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
607 765
608 766
609#endif /* ICALMESSAGE_H*/ 767#endif /* ICALMESSAGE_H*/
610/* -*- Mode: C -*- */ 768#ifdef __cplusplus
611/*======================================================================
612 FILE: icalcstp.h
613 CREATOR: eric 20 April 1999
614
615 $Id$
616
617
618 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
619
620 This program is free software; you can redistribute it and/or modify
621 it under the terms of either:
622
623 The LGPL as published by the Free Software Foundation, version
624 2.1, available at: http://www.fsf.org/copyleft/lesser.html
625
626 Or:
627
628 The Mozilla Public License Version 1.0. You may obtain a copy of
629 the License at http://www.mozilla.org/MPL/
630
631 The original code is icalcstp.h
632
633======================================================================*/
634
635
636#ifndef ICALCSTP_H
637#define ICALCSTP_H
638
639
640
641/* Connection state, from the state machine in RFC2445 */
642enum cstps_state {
643 NO_STATE,
644 CONNECTED,
645 AUTHENTICATED,
646 IDENTIFIED,
647 DISCONNECTED,
648 RECEIVE
649};
650
651/* CSTP Commands that a client can issue to a server */
652typedef enum icalcstp_command {
653 ICAL_ABORT_COMMAND,
654 ICAL_AUTHENTICATE_COMMAND,
655 ICAL_CAPABILITY_COMMAND,
656 ICAL_CONTINUE_COMMAND,
657 ICAL_CALIDEXPAND_COMMAND,
658 ICAL_IDENTIFY_COMMAND,
659 ICAL_DISCONNECT_COMMAND,
660 ICAL_SENDDATA_COMMAND,
661 ICAL_STARTTLS_COMMAND,
662 ICAL_UPNEXPAND_COMMAND,
663 ICAL_COMPLETE_COMMAND,
664 ICAL_UNKNOWN_COMMAND
665} icalcstp_command;
666
667
668
669/* A statement is a combination of command or response code and a
670 component that the server and client exchage with each other. */
671struct icalcstp_statement {
672 icalcstp_command command;
673 char* str_data; /* If non-NUll use as arguments to command */
674 int int_data; /* If non-NULL use as arguments to command */
675
676 icalrequeststatus code;
677
678 icalcomponent* data;
679}; 769};
680 770#endif
681const char* icalcstp_command_to_string(icalcstp_command command);
682icalcstp_command icalcstp_string_to_command(const char* str);
683
684#endif /* !ICALCSTP_H */
685
686
687
688/* -*- Mode: C -*- */
689/*======================================================================
690 FILE: icalcstpclient.h
691 CREATOR: eric 4 Feb 01
692
693 $Id$
694
695
696 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
697
698 This program is free software; you can redistribute it and/or modify
699 it under the terms of either:
700
701 The LGPL as published by the Free Software Foundation, version
702 2.1, available at: http://www.fsf.org/copyleft/lesser.html
703
704 Or:
705
706 The Mozilla Public License Version 1.0. You may obtain a copy of
707 the License at http://www.mozilla.org/MPL/
708
709 The original code is icalcstp.h
710
711======================================================================*/
712
713
714#ifndef ICALCSTPC_H
715#define ICALCSTPC_H
716
717
718/********************** Client (Sender) Interfaces **************************/
719
720/* How to use:
721
722 1) Construct a new icalcstpc
723 2) Issue a command by calling one of the command routines.
724 3) Repeat until both call icalcstpc_next_output and
725 icalcstpc_next_input return 0:
726 3a) Call icalcstpc_next_output. Send string to server.
727 3b) Get string from server, & give to icalcstp_next_input()
728 4) Iterate with icalcstpc_first_response & icalcstp_next_response to
729 get the servers responses
730 5) Repeat at #2
731*/
732
733
734typedef void icalcstpc;
735
736/* Response code sent by the server. */
737 typedef struct icalcstpc_response {
738 icalrequeststatus code;
739 char *arg; /* These strings are owned by libical */
740 char *debug_text;
741 char *more_text;
742 void* result;
743} icalcstpc_response;
744
745
746icalcstpc* icalcstpc_new();
747
748void icalcstpc_free(icalcstpc* cstpc);
749
750int icalcstpc_set_timeout(icalcstpc* cstp, int sec);
751
752
753/* Get the next string to send to the server */
754char* icalcstpc_next_output(icalcstpc* cstp, char* line);
755
756/* process the next string from the server */
757int icalcstpc_next_input(icalcstpc* cstp, char * line);
758
759/* After icalcstpc_next_input returns a 0, there are responses
760 ready. use these to get them */
761icalcstpc_response icalcstpc_first_response(icalcstpc* cstp);
762icalcstpc_response icalcstpc_next_response(icalcstpc* cstp);
763
764/* Issue a command */
765icalerrorenum icalcstpc_abort(icalcstpc* cstp);
766icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
767 char* init_data, char* f(char*) );
768icalerrorenum icalcstpc_capability(icalcstpc* cstp);
769icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid);
770icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time);
771icalerrorenum icalcstpc_disconnect(icalcstpc* cstp);
772icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id);
773icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
774 char* init_data, char* f(char*));
775icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time,
776 icalcomponent *comp);
777icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid);
778icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
779 icalcomponent *comp);
780
781
782#endif /* !ICALCSTPC_H */
783
784
785
786/* -*- Mode: C -*- */
787/*======================================================================
788 FILE: icalcstpserver.h
789 CREATOR: eric 13 Feb 01
790
791 $Id$
792
793
794 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
795
796 This program is free software; you can redistribute it and/or modify
797 it under the terms of either:
798
799 The LGPL as published by the Free Software Foundation, version
800 2.1, available at: http://www.fsf.org/copyleft/lesser.html
801
802 Or:
803
804 The Mozilla Public License Version 1.0. You may obtain a copy of
805 the License at http://www.mozilla.org/MPL/
806
807 The original code is icalcstp.h
808
809======================================================================*/
810
811
812#ifndef ICALCSTPS_H
813#define ICALCSTPS_H
814
815
816
817/********************** Server (Reciever) Interfaces *************************/
818
819/* On the server side, the caller will recieve data from the incoming
820 socket and pass it to icalcstps_next_input. The caller then takes
821 the return from icalcstps_next_outpu and sends it out through the
822 socket. This gives the caller a point of control. If the cstp code
823 connected to the socket itself, it would be hard for the caller to
824 do anything else after the cstp code was started.
825
826 All of the server and client command routines will generate
827 response codes. On the server side, these responses will be turned
828 into text and sent to the client. On the client side, the reponse
829 is the one sent from the server.
830
831 Since each command can return multiple responses, the responses are
832 stored in the icalcstps object and are accesses by
833 icalcstps_first_response() and icalcstps_next_response()
834
835 How to use:
836
837 1) Construct a new icalcstps, bound to your code via stubs
838 2) Repeat forever:
839 2a) Get string from client & give to icalcstps_next_input()
840 2b) Repeat until icalcstp_next_output returns 0:
841 2b1) Call icalcstps_next_output.
842 2b2) Send string to client.
843*/
844
845
846
847typedef void icalcstps;
848
849/* Pointers to the rountines that
850 icalcstps_process_incoming will call when it recognizes a CSTP
851 command in the data. BTW, the CONTINUE command is named 'cont'
852 because 'continue' is a C keyword */
853
854struct icalcstps_commandfp {
855 icalerrorenum (*abort)(icalcstps* cstp);
856 icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism,
857 char* data);
858 icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid);
859 icalerrorenum (*capability)(icalcstps* cstp);
860 icalerrorenum (*cont)(icalcstps* cstp, unsigned int time);
861 icalerrorenum (*identify)(icalcstps* cstp, char* id);
862 icalerrorenum (*disconnect)(icalcstps* cstp);
863 icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time,
864 icalcomponent *comp);
865 icalerrorenum (*starttls)(icalcstps* cstp, char* command,
866 char* data);
867 icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn);
868 icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data);
869};
870
871
872
873icalcstps* icalcstps_new(struct icalcstps_commandfp stubs);
874
875void icalcstps_free(icalcstps* cstp);
876
877int icalcstps_set_timeout(icalcstps* cstp, int sec);
878
879/* Get the next string to send to the client */
880char* icalcstps_next_output(icalcstps* cstp);
881
882/* process the next string from the client */
883int icalcstps_next_input(icalcstps* cstp);
884
885#endif /* ICALCSTPS */
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 @@
1#define YY_REENTRANT 1
2#define YY_TEXT_IS_ARRAY
3#define YY_REENTRANT_BISON_PURE 1
4#ifndef YY_REENTRANT
5#define yytext sstext
6#define yyleng ssleng
7#define yyin ssin
8#define yyout ssout
9#endif
1#define yy_create_buffer ss_create_buffer 10#define yy_create_buffer ss_create_buffer
2#define yy_delete_buffer ss_delete_buffer 11#define yy_delete_buffer ss_delete_buffer
3#define yy_scan_buffer ss_scan_buffer 12#define yy_scan_buffer ss_scan_buffer
@@ -8,46 +17,50 @@
8#define yy_flush_buffer ss_flush_buffer 17#define yy_flush_buffer ss_flush_buffer
9#define yy_load_buffer_state ss_load_buffer_state 18#define yy_load_buffer_state ss_load_buffer_state
10#define yy_switch_to_buffer ss_switch_to_buffer 19#define yy_switch_to_buffer ss_switch_to_buffer
11#define yyin ssin
12#define yyleng ssleng
13#define yylex sslex 20#define yylex sslex
14#define yyout ssout
15#define yyrestart ssrestart 21#define yyrestart ssrestart
16#define yytext sstext 22#define yylex_init sslex_init
23#define yylex_destroy sslex_destroy
24#define yyget_extra ssget_extra
25#define yyset_extra ssset_extra
26#define yyget_in ssget_in
27#define yyset_in ssset_in
28#define yyget_out ssget_out
29#define yyset_out ssset_out
30#define yyget_leng ssget_leng
31#define yyget_text ssget_text
32#define yyget_lineno ssget_lineno
33#define yyset_lineno ssset_lineno
34#ifdef YY_REENTRANT_BISON_PURE
35#define yyget_lval ssget_lval
36#define yyset_lval ssset_lval
37#ifdef YYLTYPE
38#define yyget_lloc ssget_lloc
39#define yyset_lloc ssset_lloc
40#endif
41#endif
17#define yywrap sswrap 42#define yywrap sswrap
18 43
44/* -*-C-*- */
19/* A lexical scanner generated by flex */ 45/* A lexical scanner generated by flex */
20 46
21/* Scanner skeleton version:
22 * $Header$
23 */
24
25#define FLEX_SCANNER 47#define FLEX_SCANNER
26#define YY_FLEX_MAJOR_VERSION 2 48#define YY_FLEX_MAJOR_VERSION 2
27#define YY_FLEX_MINOR_VERSION 5 49#define YY_FLEX_MINOR_VERSION 5
28 50
51/* %- */
52/* begin standard C headers. */
29#include <stdio.h> 53#include <stdio.h>
30// Eugen C. <eug@thekompany.com> 54#include <errno.h>
31#include <defines.h> 55#include <stdlib.h>
32#ifndef _QTWIN_ 56/* end standard C headers. */
33#include <unistd.h> 57/* %+ */
34#else 58/* %* */
35#include <io.h>
36#endif
37// Eugen C. <eug@thekompany.com>
38
39
40/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
41#ifdef c_plusplus
42#ifndef __cplusplus
43#define __cplusplus
44#endif
45#endif
46
47 59
48#ifdef __cplusplus 60#ifdef __cplusplus
49 61
50#include <stdlib.h> 62/* %+ */
63/* %* */
51 64
52/* Use prototypes in function declarations. */ 65/* Use prototypes in function declarations. */
53#define YY_USE_PROTOS 66#define YY_USE_PROTOS
@@ -65,15 +78,6 @@
65 #endif/* __STDC__ */ 78 #endif/* __STDC__ */
66 #endif/* ! __cplusplus */ 79 #endif/* ! __cplusplus */
67 80
68#ifdef __TURBOC__
69 #pragma warn -rch
70 #pragma warn -use
71#include <io.h>
72#include <stdlib.h>
73#define YY_USE_CONST
74#define YY_USE_PROTOS
75#endif
76
77#ifdef YY_USE_CONST 81#ifdef YY_USE_CONST
78#define yyconst const 82#define yyconst const
79#else 83#else
@@ -97,34 +101,94 @@
97 */ 101 */
98#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 102#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
99 103
104
105#ifdef YY_REENTRANT
106
107/* An opaque pointer. */
108#ifndef YY_TYPEDEF_YY_SCANNER_T
109#define YY_TYPEDEF_YY_SCANNER_T
110typedef void* yyscan_t;
111#endif
112
113/* For use wherever a Global is accessed or assigned. */
114#define YY_G(var) (((struct yy_globals_t*)yy_globals)->var)
115
116/* For use in function prototypes to append the additional argument. */
117#ifdef YY_USE_PROTOS
118#define YY_LAST_ARG , yyscan_t yy_globals
119#define YY_ONLY_ARG yyscan_t yy_globals
120#else
121#define YY_LAST_ARG , yy_globals
122#define YY_ONLY_ARG yy_globals
123#define YY_DECL_LAST_ARG yyscan_t yy_globals;
124#endif
125
126/* For use in function calls to pass the additional argument. */
127#define YY_CALL_LAST_ARG , yy_globals
128#define YY_CALL_ONLY_ARG yy_globals
129
130/* For convenience, these vars (plus the bison vars far below)
131 are macros in the reentrant scanner. */
132#define yyin YY_G(yyin_r)
133#define yyout YY_G(yyout_r)
134#define yyextra YY_G(yyextra_r)
135#define yyleng YY_G(yyleng_r)
136#define yytext YY_G(yytext_r)
137#define yylineno YY_G(yylineno_r)
138
139int yylex_init YY_PROTO((yyscan_t* scanner));
140int yylex_destroy YY_PROTO((yyscan_t scanner));
141
142#else /* not YY_REENTRANT */
143
144 /* Define these macros to be no-ops. */
145#define YY_G(var) (var)
146#define YY_LAST_ARG
147#define YY_ONLY_ARG void
148#define YY_CALL_LAST_ARG
149#define YY_CALL_ONLY_ARG
150#define YY_DECL_LAST_ARG
151#endif
152
100/* Enter a start condition. This macro really ought to take a parameter, 153/* Enter a start condition. This macro really ought to take a parameter,
101 * but we do it the disgusting crufty way forced on us by the ()-less 154 * but we do it the disgusting crufty way forced on us by the ()-less
102 * definition of BEGIN. 155 * definition of BEGIN.
103 */ 156 */
104#define BEGIN yy_start = 1 + 2 * 157#define BEGIN YY_G(yy_start) = 1 + 2 *
105 158
106/* Translate the current start state into a value that can be later handed 159/* Translate the current start state into a value that can be later handed
107 * to BEGIN to return to the state. The YYSTATE alias is for lex 160 * to BEGIN to return to the state. The YYSTATE alias is for lex
108 * compatibility. 161 * compatibility.
109 */ 162 */
110#define YY_START ((yy_start - 1) / 2) 163#define YY_START ((YY_G(yy_start) - 1) / 2)
111#define YYSTATE YY_START 164#define YYSTATE YY_START
112 165
113/* Action number for EOF rule of a given start state. */ 166/* Action number for EOF rule of a given start state. */
114#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 167#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
115 168
116/* Special action meaning "start processing a new file". */ 169/* Special action meaning "start processing a new file". */
117#define YY_NEW_FILE yyrestart( yyin ) 170#define YY_NEW_FILE yyrestart( yyin YY_CALL_LAST_ARG )
118 171
119#define YY_END_OF_BUFFER_CHAR 0 172#define YY_END_OF_BUFFER_CHAR 0
120 173
121/* Size of default input buffer. */ 174/* Size of default input buffer. */
122#define YY_BUF_SIZE 16384 175#define YY_BUF_SIZE 16384
123 176
177
178#ifndef YY_TYPEDEF_YY_BUFFER_STATE
179#define YY_TYPEDEF_YY_BUFFER_STATE
124typedef struct yy_buffer_state *YY_BUFFER_STATE; 180typedef struct yy_buffer_state *YY_BUFFER_STATE;
181#endif
182
183#ifndef YY_REENTRANT
184extern size_t yyleng;
185#endif
125 186
126extern int yyleng; 187/* %- */
188#ifndef YY_REENTRANT
127extern FILE *yyin, *yyout; 189extern FILE *yyin, *yyout;
190#endif
191/* %* */
128 192
129#define EOB_ACT_CONTINUE_SCAN 0 193#define EOB_ACT_CONTINUE_SCAN 0
130#define EOB_ACT_END_OF_FILE 1 194#define EOB_ACT_END_OF_FILE 1
@@ -150,25 +214,33 @@ extern FILE *yyin, *yyout;
150 do \ 214 do \
151 { \ 215 { \
152 /* Undo effects of setting up yytext. */ \ 216 /* Undo effects of setting up yytext. */ \
153 *yy_cp = yy_hold_char; \ 217 *yy_cp = YY_G(yy_hold_char); \
154 YY_RESTORE_YY_MORE_OFFSET \ 218 YY_RESTORE_YY_MORE_OFFSET \
155 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ 219 YY_G(yy_c_buf_p) = yy_cp = yy_bp + n - YY_MORE_ADJ; \
156 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 220 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
157 } \ 221 } \
158 while ( 0 ) 222 while ( 0 )
159 223
160#define unput(c) yyunput( c, yytext_ptr ) 224#define unput(c) yyunput( c, YY_G(yytext_ptr) YY_CALL_LAST_ARG )
161 225
162/* The following is because we cannot portably get our hands on size_t 226/* The following is because we cannot portably get our hands on size_t
163 * (without autoconf's help, which isn't available because we want 227 * (without autoconf's help, which isn't available because we want
164 * flex-generated scanners to compile on their own). 228 * flex-generated scanners to compile on their own).
165 */ 229 */
166typedef unsigned int yy_size_t;
167 230
231#ifndef YY_TYPEDEF_YY_SIZE_T
232#define YY_TYPEDEF_YY_SIZE_T
233typedef unsigned int yy_size_t;
234#endif
168 235
236#ifndef YY_STRUCT_YY_BUFFER_STATE
237#define YY_STRUCT_YY_BUFFER_STATE
169struct yy_buffer_state 238struct yy_buffer_state
170 { 239 {
240/* %- */
171 FILE *yy_input_file; 241 FILE *yy_input_file;
242/* %+ */
243/* %* */
172 244
173 char *yy_ch_buf; /* input buffer */ 245 char *yy_ch_buf; /* input buffer */
174 char *yy_buf_pos; /* current position in input buffer */ 246 char *yy_buf_pos; /* current position in input buffer */
@@ -222,8 +294,17 @@ struct yy_buffer_state
222 */ 294 */
223#define YY_BUFFER_EOF_PENDING 2 295#define YY_BUFFER_EOF_PENDING 2
224 }; 296 };
297#endif /* !YY_STRUCT_YY_BUFFER_STATE */
225 298
299/* %- Standard (non-C++) definition */
300/* %c */
301#ifndef ssIN_HEADER
302#ifndef YY_REENTRANT
226static YY_BUFFER_STATE yy_current_buffer = 0; 303static YY_BUFFER_STATE yy_current_buffer = 0;
304#endif
305/* %e */
306#endif /* !ssIN_HEADER */
307/* %* */
227 308
228/* We provide macros for accessing buffer states in case in the 309/* We provide macros for accessing buffer states in case in the
229 * future we want to put the buffer states in a more general 310 * future we want to put the buffer states in a more general
@@ -232,13 +313,18 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
232#define YY_CURRENT_BUFFER yy_current_buffer 313#define YY_CURRENT_BUFFER yy_current_buffer
233 314
234 315
316/* %- Standard (non-C++) definition */
317
318#ifndef YY_REENTRANT
319/* %c */
320#ifndef ssIN_HEADER
235/* yy_hold_char holds the character lost when yytext is formed. */ 321/* yy_hold_char holds the character lost when yytext is formed. */
236static char yy_hold_char; 322static char yy_hold_char;
237 323
238 static int yy_n_chars; /* number of characters read into yy_ch_buf */ 324 static int yy_n_chars; /* number of characters read into yy_ch_buf */
239 325
240 326
241int yyleng; 327size_t yyleng;
242 328
243/* Points to current character in buffer. */ 329/* Points to current character in buffer. */
244static char *yy_c_buf_p = (char *) 0; 330static char *yy_c_buf_p = (char *) 0;
@@ -249,76 +335,111 @@ static int yy_start = 0; /* start state number */
249 * instead of setting up a fresh yyin. A bit of a hack ... 335 * instead of setting up a fresh yyin. A bit of a hack ...
250 */ 336 */
251static int yy_did_buffer_switch_on_eof; 337static int yy_did_buffer_switch_on_eof;
338/* %e */
339#endif /* !ssIN_HEADER */
340#endif /* end !YY_REENTRANT */
341
342void yyrestart YY_PROTO(( FILE *input_file YY_LAST_ARG ));
343
344
345void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer YY_LAST_ARG ));
346void yy_load_buffer_state YY_PROTO(( YY_ONLY_ARG ));
347YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size YY_LAST_ARG ));
348void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
349void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG ));
350void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
252 351
253void yyrestart YY_PROTO(( FILE *input_file )); 352#define YY_FLUSH_BUFFER yy_flush_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG)
254 353
255void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); 354YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size YY_LAST_ARG ));
256void yy_load_buffer_state YY_PROTO(( void )); 355YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str YY_LAST_ARG ));
257YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); 356YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len YY_LAST_ARG ));
258void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
259void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
260void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
261#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
262 357
263YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); 358/* %* */
264YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
265YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
266 359
267static void *yy_flex_alloc YY_PROTO(( yy_size_t )); 360/* %c */
268static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); 361#ifndef ssIN_HEADER
269static void yy_flex_free YY_PROTO(( void * )); 362static void *yy_flex_alloc YY_PROTO(( yy_size_t YY_LAST_ARG ));
363static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t YY_LAST_ARG ));
364static void yy_flex_free YY_PROTO(( void * YY_LAST_ARG ));
365/* %e */
366#endif /* !ssIN_HEADER */
270 367
271#define yy_new_buffer yy_create_buffer 368#define yy_new_buffer yy_create_buffer
272 369
273#define yy_set_interactive(is_interactive) \ 370#define yy_set_interactive(is_interactive) \
274 { \ 371 { \
275 if ( ! yy_current_buffer ) \ 372 if ( ! YY_G(yy_current_buffer) ) \
276 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ 373 YY_G(yy_current_buffer) = \
277 yy_current_buffer->yy_is_interactive = is_interactive; \ 374 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
375 YY_G(yy_current_buffer)->yy_is_interactive = is_interactive; \
278 } 376 }
279 377
280#define yy_set_bol(at_bol) \ 378#define yy_set_bol(at_bol) \
281 { \ 379 { \
282 if ( ! yy_current_buffer ) \ 380 if ( ! YY_G(yy_current_buffer) ) \
283 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ 381 YY_G(yy_current_buffer) = \
284 yy_current_buffer->yy_at_bol = at_bol; \ 382 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
383 YY_G(yy_current_buffer)->yy_at_bol = at_bol; \
285 } 384 }
286 385
287#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) 386#define YY_AT_BOL() (YY_G(yy_current_buffer)->yy_at_bol)
288 387
388/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
389/* Begin user sect3 */
390#ifndef ssIN_HEADER
289typedef unsigned char YY_CHAR; 391typedef unsigned char YY_CHAR;
392#endif /* !ssIN_HEADER */
393#ifndef ssIN_HEADER
394#ifndef YY_REENTRANT
290FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; 395FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
396#endif
397#endif /* !ssIN_HEADER */
398#ifndef ssIN_HEADER
291typedef int yy_state_type; 399typedef int yy_state_type;
292extern char yytext[]; 400#endif /* !ssIN_HEADER */
293 401
294 402/* %- Standard (non-C++) definition */
295static yy_state_type yy_get_previous_state YY_PROTO(( void )); 403/* %c */
296static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); 404#ifndef ssIN_HEADER
297static int yy_get_next_buffer YY_PROTO(( void )); 405static yy_state_type yy_get_previous_state YY_PROTO(( YY_ONLY_ARG ));
406static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state YY_LAST_ARG));
407static int yy_get_next_buffer YY_PROTO(( YY_ONLY_ARG ));
298static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); 408static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
409/* %e */
410#endif /* !ssIN_HEADER */
411/* %* */
299 412
300/* Done after the current pattern has been matched and before the 413/* Done after the current pattern has been matched and before the
301 * corresponding action - sets up yytext. 414 * corresponding action - sets up yytext.
302 */ 415 */
303#define YY_DO_BEFORE_ACTION \ 416#define YY_DO_BEFORE_ACTION \
304 yytext_ptr = yy_bp; \ 417 YY_G(yytext_ptr) = yy_bp; \
305 yyleng = (int) (yy_cp - yy_bp); \ 418/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
306 yy_hold_char = *yy_cp; \ 419 yyleng = (size_t) (yy_cp - yy_bp); \
420 YY_G(yy_hold_char) = *yy_cp; \
307 *yy_cp = '\0'; \ 421 *yy_cp = '\0'; \
422/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
308 if ( yyleng >= YYLMAX ) \ 423 if ( yyleng >= YYLMAX ) \
309 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ 424 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
310 yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \ 425 yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \
311 yy_c_buf_p = yy_cp; 426 YY_G(yy_c_buf_p) = yy_cp;
312 427
313#define YY_NUM_RULES 19 428/* %* */
314#define YY_END_OF_BUFFER 20 429
315static yyconst short int yy_accept[47] = 430/* %c */
431#ifndef ssIN_HEADER
432/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
433#define YY_NUM_RULES 23
434#define YY_END_OF_BUFFER 24
435static yyconst short int yy_accept[56] =
316 { 0, 436 { 0,
317 0, 0, 0, 0, 0, 0, 20, 18, 14, 14, 437 0, 0, 0, 0, 0, 0, 24, 22, 18, 18,
318 18, 13, 17, 4, 15, 7, 5, 8, 17, 17, 438 22, 17, 21, 4, 19, 8, 5, 9, 21, 21,
319 17, 17, 17, 14, 6, 0, 17, 9, 10, 17, 439 21, 21, 21, 21, 21, 18, 7, 0, 21, 10,
320 17, 12, 17, 17, 16, 11, 17, 17, 17, 2, 440 6, 11, 21, 21, 14, 21, 21, 13, 21, 21,
321 17, 17, 17, 3, 1, 0 441 20, 12, 21, 15, 21, 21, 21, 2, 16, 21,
442 21, 21, 3, 1, 0
322 } ; 443 } ;
323 444
324static yyconst int yy_ec[256] = 445static yyconst int yy_ec[256] =
@@ -326,17 +447,17 @@ static yyconst int yy_ec[256] =
326 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 447 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
327 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 448 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 449 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 2, 4, 1, 1, 1, 1, 1, 5, 1, 450 1, 4, 5, 1, 1, 1, 1, 1, 6, 1,
330 1, 6, 1, 7, 6, 6, 1, 6, 6, 6, 451 1, 7, 1, 8, 7, 7, 1, 7, 7, 7,
331 6, 6, 6, 6, 6, 6, 6, 1, 8, 9, 452 7, 7, 7, 7, 7, 7, 7, 9, 10, 11,
332 10, 11, 1, 1, 12, 6, 13, 14, 15, 16, 453 12, 13, 1, 7, 14, 7, 15, 16, 17, 18,
333 6, 17, 6, 6, 6, 18, 19, 20, 21, 6, 454 7, 19, 20, 7, 7, 21, 22, 23, 24, 7,
334 6, 22, 23, 24, 6, 6, 25, 6, 6, 6, 455 7, 25, 26, 27, 28, 7, 29, 7, 7, 7,
335 1, 1, 1, 1, 1, 1, 12, 6, 13, 14, 456 1, 1, 1, 1, 1, 1, 14, 7, 15, 16,
336 457
337 15, 16, 6, 17, 6, 6, 6, 18, 19, 20, 458 17, 18, 7, 19, 20, 7, 7, 21, 22, 23,
338 21, 6, 6, 22, 23, 24, 6, 6, 25, 6, 459 24, 7, 7, 25, 26, 27, 28, 7, 29, 7,
339 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 460 7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 462 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -353,57 +474,62 @@ static yyconst int yy_ec[256] =
353 1, 1, 1, 1, 1 474 1, 1, 1, 1, 1
354 } ; 475 } ;
355 476
356static yyconst int yy_meta[26] = 477static yyconst int yy_meta[30] =
357 { 0, 478 { 0,
358 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 479 1, 1, 1, 2, 1, 1, 3, 1, 2, 1,
359 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 480 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
360 2, 2, 2, 2, 2 481 3, 3, 3, 3, 3, 3, 3, 3, 3
361 } ; 482 } ;
362 483
363static yyconst short int yy_base[49] = 484static yyconst short int yy_base[58] =
364 { 0, 485 { 0,
365 0, 0, 0, 0, 0, 0, 53, 54, 24, 26, 486 0, 0, 0, 0, 0, 0, 68, 69, 28, 31,
366 42, 0, 0, 54, 54, 41, 54, 40, 29, 26, 487 55, 0, 0, 69, 69, 54, 53, 52, 40, 37,
367 25, 31, 28, 28, 54, 39, 0, 54, 54, 29, 488 35, 12, 35, 42, 39, 35, 69, 51, 0, 69,
368 21, 0, 23, 25, 54, 0, 20, 23, 15, 0, 489 69, 69, 40, 31, 0, 27, 32, 0, 31, 34,
369 23, 20, 10, 0, 0, 54, 31, 30 490 69, 0, 28, 0, 28, 31, 22, 0, 0, 31,
491 28, 17, 0, 0, 69, 39, 40
370 } ; 492 } ;
371 493
372static yyconst short int yy_def[49] = 494static yyconst short int yy_def[58] =
373 { 0, 495 { 0,
374 46, 1, 1, 1, 1, 1, 46, 46, 46, 46, 496 55, 1, 1, 1, 1, 1, 55, 55, 55, 55,
375 46, 47, 48, 46, 46, 46, 46, 46, 48, 48, 497 55, 56, 57, 55, 55, 55, 55, 55, 57, 57,
376 48, 48, 48, 46, 46, 47, 48, 46, 46, 48, 498 57, 57, 57, 57, 57, 55, 55, 56, 57, 55,
377 48, 48, 48, 48, 46, 48, 48, 48, 48, 48, 499 55, 55, 57, 57, 57, 57, 57, 57, 57, 57,
378 48, 48, 48, 48, 48, 0, 46, 46 500 55, 57, 57, 57, 57, 57, 57, 57, 57, 57,
501 57, 57, 57, 57, 0, 55, 55
379 } ; 502 } ;
380 503
381static yyconst short int yy_nxt[80] = 504static yyconst short int yy_nxt[99] =
382 { 0, 505 { 0,
383 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 506 8, 9, 10, 9, 11, 12, 13, 14, 8, 15,
384 18, 19, 13, 13, 13, 20, 13, 13, 13, 13, 507 16, 17, 18, 19, 13, 13, 13, 20, 13, 21,
385 21, 13, 22, 13, 23, 24, 24, 24, 24, 24, 508 13, 13, 22, 23, 13, 24, 13, 13, 25, 26,
386 24, 27, 26, 45, 44, 43, 42, 41, 40, 39, 509 26, 26, 26, 26, 26, 36, 26, 26, 26, 37,
387 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 510 28, 28, 29, 54, 53, 52, 51, 50, 49, 48,
388 28, 25, 46, 7, 46, 46, 46, 46, 46, 46, 511 47, 46, 45, 44, 43, 42, 41, 40, 39, 38,
389 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 512 35, 34, 33, 32, 31, 30, 27, 55, 7, 55,
390 46, 46, 46, 46, 46, 46, 46, 46, 46 513 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
514 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
515 55, 55, 55, 55, 55, 55, 55, 55
516
391 } ; 517 } ;
392 518
393static yyconst short int yy_chk[80] = 519static yyconst short int yy_chk[99] =
394 { 0, 520 { 0,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 521 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 522 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 9, 9, 10, 10, 24, 523 1, 1, 1, 1, 1, 1, 1, 1, 1, 9,
398 24, 48, 47, 43, 42, 41, 39, 38, 37, 34, 524 9, 9, 10, 10, 10, 22, 26, 26, 26, 22,
399 33, 31, 30, 26, 23, 22, 21, 20, 19, 18, 525 56, 56, 57, 52, 51, 50, 47, 46, 45, 43,
400 16, 11, 7, 46, 46, 46, 46, 46, 46, 46, 526 40, 39, 37, 36, 34, 33, 28, 25, 24, 23,
401 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 527 21, 20, 19, 18, 17, 16, 11, 7, 55, 55,
402 46, 46, 46, 46, 46, 46, 46, 46, 46 528 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
403 } ; 529 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
530 55, 55, 55, 55, 55, 55, 55, 55
404 531
405static yy_state_type yy_last_accepting_state; 532 } ;
406static char *yy_last_accepting_cpos;
407 533
408/* The intent behind this definition is that it'll catch 534/* The intent behind this definition is that it'll catch
409 * any uses of REJECT which flex missed. 535 * any uses of REJECT which flex missed.
@@ -416,8 +542,10 @@ static char *yy_last_accepting_cpos;
416#define YYLMAX 8192 542#define YYLMAX 8192
417#endif 543#endif
418 544
545#ifndef YY_REENTRANT
419char yytext[YYLMAX]; 546char yytext[YYLMAX];
420char *yytext_ptr; 547char *yytext_ptr;
548#endif
421#line 1 "icalsslexer.l" 549#line 1 "icalsslexer.l"
422#define INITIAL 0 550#define INITIAL 0
423#line 2 "icalsslexer.l" 551#line 2 "icalsslexer.l"
@@ -455,20 +583,159 @@ char *yytext_ptr;
455 583
456#include <string.h> /* For strdup() */ 584#include <string.h> /* For strdup() */
457 585
458int icalparser_flex_input(char* buf, int max_size); 586#undef YYPURE
459void icalparser_clear_flex_input(); 587#define YYPURE
460
461#undef YY_INPUT
462#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
463 588
464#undef SS_FATAL_ERROR 589#undef SS_FATAL_ERROR
465#define SS_FATAL_ERROR(msg) sserror(msg) 590#define SS_FATAL_ERROR(msg) sserror(msg)
466 591
467
468#define sql 1 592#define sql 1
469#define string_value 2 593#define string_value 2
470 594
471#line 465 "icalsslexer.c" 595#line 596 "lex.ss.c"
596/* %e */
597#endif /* !ssIN_HEADER */
598
599/* Special case for "unistd.h", since it is non-ANSI. We include it way
600 * down here because we want the user's section 1 to have been scanned first.
601 * The user has a chance to override it with an option.
602 */
603#ifndef YY_NO_UNISTD_H
604/* %- */
605#include <unistd.h>
606/* %+ */
607/* %* */
608#endif /* !YY_NO_UNISTD_H */
609
610
611#ifndef YY_EXTRA_TYPE
612#define YY_EXTRA_TYPE void *
613#endif
614
615/* %- Reentrant structure and macros (non-C++). */
616#ifdef YY_REENTRANT
617
618/* %c */
619#ifndef ssIN_HEADER
620struct yy_globals_t
621 {
622
623 /* User-defined. Not touched by flex. */
624 YY_EXTRA_TYPE yyextra_r;
625
626 /* The rest are the same as the globals declared in the non-reentrant scanner. */
627 FILE *yyin_r, *yyout_r;
628 YY_BUFFER_STATE yy_current_buffer;
629 char yy_hold_char;
630 int yy_n_chars;
631 int yyleng_r;
632 char *yy_c_buf_p;
633 int yy_init;
634 int yy_start;
635 int yy_did_buffer_switch_on_eof;
636 int yy_start_stack_ptr;
637 int yy_start_stack_depth;
638 int *yy_start_stack;
639 yy_state_type yy_last_accepting_state;
640 char* yy_last_accepting_cpos;
641
642 int yylineno_r;
643
644#ifdef YY_TEXT_IS_ARRAY
645 char yytext_r[YYLMAX];
646 char *yytext_ptr;
647 int yy_more_offset;
648 int yy_prev_more_offset;
649#else
650 char *yytext_r;
651 int yy_more_flag;
652 int yy_more_len;
653#endif
654
655#ifdef YY_REENTRANT_BISON_PURE
656 YYSTYPE * yylval_r;
657#ifdef YYLTYPE
658 YYLTYPE * yylloc_r;
659#endif
660#endif
661
662 };
663/* %e */
664#endif /* !ssIN_HEADER */
665
666/* %c */
667#ifndef ssIN_HEADER
668static int yy_init_globals YY_PROTO(( yyscan_t ));
669/* %e */
670#endif /* !ssIN_HEADER */
671
672/* This must go here because YYSTYPE and YYLSTYPE are included
673 * from bison output in section 1.*/
674#ifdef YY_REENTRANT_BISON_PURE
675# define yylval YY_G(yylval_r)
676# ifdef YYLTYPE
677# define yylloc YY_G(yylloc_r)
678# endif
679#endif /* YY_REENTRANT_BISON_PURE */
680
681#endif /* end if YY_REENTRANT */
682
683/* Accessor methods to globals.
684 These are made visible to non-reentrant scanners for convenience. */
685#ifndef YY_NO_GET_EXTRA
686YY_EXTRA_TYPE yyget_extra YY_PROTO(( YY_ONLY_ARG ));
687#endif
688
689#ifndef YY_NO_SET_EXTRA
690void yyset_extra YY_PROTO(( YY_EXTRA_TYPE user_defined YY_LAST_ARG ));
691#endif
692
693#ifndef YY_NO_GET_IN
694FILE *yyget_in YY_PROTO(( YY_ONLY_ARG ));
695#endif
696
697#ifndef YY_NO_SET_IN
698void yyset_in YY_PROTO(( FILE * in_str YY_LAST_ARG ));
699#endif
700
701#ifndef YY_NO_GET_OUT
702FILE *yyget_out YY_PROTO(( YY_ONLY_ARG ));
703#endif
704
705#ifndef YY_NO_SET_OUT
706void yyset_out YY_PROTO(( FILE * out_str YY_LAST_ARG ));
707#endif
708
709#ifndef YY_NO_GET_LENG
710int yyget_leng YY_PROTO(( YY_ONLY_ARG ));
711#endif
712
713#ifndef YY_NO_GET_TEXT
714char *yyget_text YY_PROTO(( YY_ONLY_ARG ));
715#endif
716
717#ifndef YY_NO_GET_LINENO
718int yyget_lineno YY_PROTO(( YY_ONLY_ARG ));
719#endif
720
721#ifndef YY_NO_SET_LINENO
722void yyset_lineno YY_PROTO(( int line_number YY_LAST_ARG ));
723#endif
724
725#ifdef YY_REENTRANT_BISON_PURE
726#ifndef YY_NO_GET_LVAL
727YYSTYPE * yyget_lval YY_PROTO(( YY_ONLY_ARG ));
728#endif
729void yyset_lval YY_PROTO(( YYSTYPE * yylvalp YY_LAST_ARG ));
730#ifdef YYLTYPE
731#ifndef YY_NO_GET_LLOC
732 YYLTYPE *yyget_lloc YY_PROTO(( YY_ONLY_ARG ));
733#endif
734#ifndef YY_NO_SET_LLOC
735 void yyset_lloc YY_PROTO(( YYLTYPE * yyllocp YY_LAST_ARG ));
736#endif
737#endif /* YYLTYPE */
738#endif /* YY_REENTRANT_BISON_PURE */
472 739
473/* Macros after this point can all be overridden by user definitions in 740/* Macros after this point can all be overridden by user definitions in
474 * section 1. 741 * section 1.
@@ -476,44 +743,62 @@ void icalparser_clear_flex_input();
476 743
477#ifndef YY_SKIP_YYWRAP 744#ifndef YY_SKIP_YYWRAP
478#ifdef __cplusplus 745#ifdef __cplusplus
479extern "C" int yywrap YY_PROTO(( void )); 746extern "C" int yywrap YY_PROTO(( YY_ONLY_ARG ));
480#else 747#else
481extern int yywrap YY_PROTO(( void )); 748extern int yywrap YY_PROTO(( YY_ONLY_ARG ));
482#endif 749#endif
483#endif 750#endif
484 751
752/* %- */
753/* %c */
754#ifndef ssIN_HEADER
485#ifndef YY_NO_UNPUT 755#ifndef YY_NO_UNPUT
486static void yyunput YY_PROTO(( int c, char *buf_ptr )); 756static void yyunput YY_PROTO(( int c, char *buf_ptr YY_LAST_ARG));
487#endif 757#endif
758/* %e */
759#endif /* !ssIN_HEADER */
760/* %* */
488 761
489#ifndef yytext_ptr 762#ifndef yytext_ptr
490static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); 763static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int YY_LAST_ARG));
491#endif 764#endif
492 765
493#ifdef YY_NEED_STRLEN 766#ifdef YY_NEED_STRLEN
494static int yy_flex_strlen YY_PROTO(( yyconst char * )); 767static int yy_flex_strlen YY_PROTO(( yyconst char * YY_LAST_ARG));
495#endif 768#endif
496 769
497#ifndef YY_NO_INPUT 770#ifndef YY_NO_INPUT
771/* %- Standard (non-C++) definition */
772/* %c */
773#ifndef ssIN_HEADER
498#ifdef __cplusplus 774#ifdef __cplusplus
499static int yyinput YY_PROTO(( void )); 775static int yyinput YY_PROTO(( YY_ONLY_ARG ));
500#else 776#else
501static int input YY_PROTO(( void )); 777static int input YY_PROTO(( YY_ONLY_ARG ));
502#endif 778#endif
779/* %e */
780#endif /* !ssIN_HEADER */
781/* %* */
503#endif 782#endif
504 783
505#if YY_STACK_USED 784#if YY_STACK_USED
785#ifndef YY_REENTRANT
786/* %c */
787#ifndef ssIN_HEADER
506static int yy_start_stack_ptr = 0; 788static int yy_start_stack_ptr = 0;
507static int yy_start_stack_depth = 0; 789static int yy_start_stack_depth = 0;
508static int *yy_start_stack = 0; 790static int *yy_start_stack = 0;
791/* %e */
792#endif /* !ssIN_HEADER */
793#endif
509#ifndef YY_NO_PUSH_STATE 794#ifndef YY_NO_PUSH_STATE
510static void yy_push_state YY_PROTO(( int new_state )); 795static void yy_push_state YY_PROTO(( int new_state YY_LAST_ARG));
511#endif 796#endif
512#ifndef YY_NO_POP_STATE 797#ifndef YY_NO_POP_STATE
513static void yy_pop_state YY_PROTO(( void )); 798static void yy_pop_state YY_PROTO(( YY_ONLY_ARG ));
514#endif 799#endif
515#ifndef YY_NO_TOP_STATE 800#ifndef YY_NO_TOP_STATE
516static int yy_top_state YY_PROTO(( void )); 801static int yy_top_state YY_PROTO(( YY_ONLY_ARG ));
517#endif 802#endif
518 803
519#else 804#else
@@ -522,21 +807,6 @@ static int yy_top_state YY_PROTO(( void ));
522#define YY_NO_TOP_STATE 1 807#define YY_NO_TOP_STATE 1
523#endif 808#endif
524 809
525#ifdef YY_MALLOC_DECL
526YY_MALLOC_DECL
527#else
528#if __STDC__
529#ifndef __cplusplus
530#include <stdlib.h>
531#endif
532#else
533/* Just try to get by without declaring the routines. This will fail
534 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
535 * or sizeof(void*) != sizeof(int).
536 */
537#endif
538#endif
539
540/* Amount of stuff to slurp up with each read. */ 810/* Amount of stuff to slurp up with each read. */
541#ifndef YY_READ_BUF_SIZE 811#ifndef YY_READ_BUF_SIZE
542#define YY_READ_BUF_SIZE 8192 812#define YY_READ_BUF_SIZE 8192
@@ -545,10 +815,13 @@ YY_MALLOC_DECL
545/* Copy whatever the last rule matched to the standard output. */ 815/* Copy whatever the last rule matched to the standard output. */
546 816
547#ifndef ECHO 817#ifndef ECHO
818/* %- Standard (non-C++) definition */
548/* This used to be an fputs(), but since the string might contain NUL's, 819/* This used to be an fputs(), but since the string might contain NUL's,
549 * we now use fwrite(). 820 * we now use fwrite().
550 */ 821 */
551#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) 822#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
823/* %+ C++ definition */
824/* %* */
552#endif 825#endif
553 826
554/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 827/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -556,9 +829,11 @@ YY_MALLOC_DECL
556 */ 829 */
557#ifndef YY_INPUT 830#ifndef YY_INPUT
558#define YY_INPUT(buf,result,max_size) \ 831#define YY_INPUT(buf,result,max_size) \
559 if ( yy_current_buffer->yy_is_interactive ) \ 832/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
833 if ( YY_G(yy_current_buffer)->yy_is_interactive ) \
560 { \ 834 { \
561 int c = '*', n; \ 835 int c = '*'; \
836 size_t n; \
562 for ( n = 0; n < max_size && \ 837 for ( n = 0; n < max_size && \
563 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 838 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
564 buf[n] = (char) c; \ 839 buf[n] = (char) c; \
@@ -568,9 +843,22 @@ YY_MALLOC_DECL
568 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 843 YY_FATAL_ERROR( "input in flex scanner failed" ); \
569 result = n; \ 844 result = n; \
570 } \ 845 } \
571 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ 846 else \
572 && ferror( yyin ) ) \ 847 { \
573 YY_FATAL_ERROR( "input in flex scanner failed" ); 848 errno=0; \
849 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
850 { \
851 if( errno != EINTR) \
852 { \
853 YY_FATAL_ERROR( "input in flex scanner failed" ); \
854 break; \
855 } \
856 errno=0; \
857 clearerr(yyin); \
858 } \
859 }
860/* %+ C++ definition \ */\
861/* %* */
574#endif 862#endif
575 863
576/* No semi-colon after return; correct usage is to write "yyterminate();" - 864/* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -588,14 +876,51 @@ YY_MALLOC_DECL
588 876
589/* Report a fatal error. */ 877/* Report a fatal error. */
590#ifndef YY_FATAL_ERROR 878#ifndef YY_FATAL_ERROR
879/* %- */
591#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 880#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
881/* %+ */
882/* %* */
592#endif 883#endif
593 884
594/* Default declaration of generated scanner - a define so the user can 885/* Default declaration of generated scanner - a define so the user can
595 * easily add parameters. 886 * easily add parameters.
596 */ 887 */
597#ifndef YY_DECL 888#ifndef YY_DECL
598#define YY_DECL int yylex YY_PROTO(( void )) 889/* %- Standard (non-C++) definition */
890
891/* If the bison pure parser is used, then bison will provide
892 one or two additional arguments. */
893
894#ifdef YY_REENTRANT_BISON_PURE
895# ifdef YYLTYPE
896# ifdef YY_USE_PROTOS
897# define YY_LEX_ARGS (YYSTYPE * yylvalp, YYLTYPE * yyllocp YY_LAST_ARG)
898# else
899# define YY_LEX_ARGS (yylvalp, yyllocp YY_LAST_ARG) \
900 YYSTYPE * yylvalp; YYLTYPE * yyllocp; YY_DECL_LAST_ARG
901# endif
902# else
903# ifdef YY_USE_PROTOS
904# define YY_LEX_ARGS (YYSTYPE * yylvalp YY_LAST_ARG)
905# else
906# define YY_LEX_ARGS (yylvalp YY_LAST_ARG) \
907 YYSTYPE * yylvalp; YY_DECL_LAST_ARG
908# endif
909# endif
910#else
911# ifdef YY_USE_PROTOS
912# define YY_LEX_ARGS (YY_ONLY_ARG)
913# else
914# define YY_LEX_ARGS (YY_ONLY_ARG) YY_DECL_LAST_ARG
915# endif
916#endif
917
918
919extern int yylex YY_PROTO( YY_LEX_ARGS );
920
921#define YY_DECL int yylex YY_LEX_ARGS
922/* %+ C++ definition */
923/* %* */
599#endif 924#endif
600 925
601/* Code executed at the beginning of each rule, after yytext and yyleng 926/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -610,211 +935,256 @@ YY_MALLOC_DECL
610#define YY_BREAK break; 935#define YY_BREAK break;
611#endif 936#endif
612 937
938/* %% [6.0] YY_RULE_SETUP definition goes here */
613#define YY_RULE_SETUP \ 939#define YY_RULE_SETUP \
614 YY_USER_ACTION 940 YY_USER_ACTION
615 941
942/* %c */
943#ifndef ssIN_HEADER
616YY_DECL 944YY_DECL
617 { 945 {
618 register yy_state_type yy_current_state; 946 register yy_state_type yy_current_state;
619 register char *yy_cp = NULL, *yy_bp = NULL; 947 register char *yy_cp, *yy_bp;
620 register int yy_act; 948 register int yy_act;
621 949
622#line 69 "icalsslexer.l" 950/* %% [7.0] user's declarations go here */
951#line 66 "icalsslexer.l"
952
623 953
624 954
625 955
626 956
627 957
958#line 959 "lex.ss.c"
628 959
629#line 623 "icalsslexer.c" 960#ifdef YY_REENTRANT_BISON_PURE
961 yylval = yylvalp;
962#ifdef YYLTYPE
963 yylloc = yyllocp;
964#endif
965#endif
630 966
631 if ( yy_init ) 967 if ( YY_G(yy_init) )
632 { 968 {
633 yy_init = 0; 969 YY_G(yy_init) = 0;
634 970
635#ifdef YY_USER_INIT 971#ifdef YY_USER_INIT
636 YY_USER_INIT; 972 YY_USER_INIT;
637#endif 973#endif
638 974
639 if ( ! yy_start ) 975 if ( ! YY_G(yy_start) )
640 yy_start = 1;/* first start state */ 976 YY_G(yy_start) = 1;/* first start state */
641 977
642 if ( ! yyin ) 978 if ( ! yyin )
979/* %- */
643 yyin = stdin; 980 yyin = stdin;
981/* %+ */
982/* %* */
644 983
645 if ( ! yyout ) 984 if ( ! yyout )
985/* %- */
646 yyout = stdout; 986 yyout = stdout;
987/* %+ */
988/* %* */
647 989
648 if ( ! yy_current_buffer ) 990 if ( ! YY_G(yy_current_buffer) )
649 yy_current_buffer = 991 YY_G(yy_current_buffer) =
650 yy_create_buffer( yyin, YY_BUF_SIZE ); 992 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
651 993
652 yy_load_buffer_state(); 994 yy_load_buffer_state( YY_CALL_ONLY_ARG );
653 } 995 }
654 996
655 while ( 1 ) /* loops until end-of-file is reached */ 997 while ( 1 ) /* loops until end-of-file is reached */
656 { 998 {
657 yy_cp = yy_c_buf_p; 999/* %% [8.0] yymore()-related code goes here */
1000 yy_cp = YY_G(yy_c_buf_p);
658 1001
659 /* Support of yytext. */ 1002 /* Support of yytext. */
660 *yy_cp = yy_hold_char; 1003 *yy_cp = YY_G(yy_hold_char);
661 1004
662 /* yy_bp points to the position in yy_ch_buf of the start of 1005 /* yy_bp points to the position in yy_ch_buf of the start of
663 * the current run. 1006 * the current run.
664 */ 1007 */
665 yy_bp = yy_cp; 1008 yy_bp = yy_cp;
666 1009
667 yy_current_state = yy_start; 1010/* %% [9.0] code to set up and find next match goes here */
1011 yy_current_state = YY_G(yy_start);
668yy_match: 1012yy_match:
669 do 1013 do
670 { 1014 {
671 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 1015 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
672 if ( yy_accept[yy_current_state] ) 1016 if ( yy_accept[yy_current_state] )
673 { 1017 {
674 yy_last_accepting_state = yy_current_state; 1018 YY_G(yy_last_accepting_state) = yy_current_state;
675 yy_last_accepting_cpos = yy_cp; 1019 YY_G(yy_last_accepting_cpos) = yy_cp;
676 } 1020 }
677 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1021 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
678 { 1022 {
679 yy_current_state = (int) yy_def[yy_current_state]; 1023 yy_current_state = (int) yy_def[yy_current_state];
680 if ( yy_current_state >= 47 ) 1024 if ( yy_current_state >= 56 )
681 yy_c = yy_meta[(unsigned int) yy_c]; 1025 yy_c = yy_meta[(unsigned int) yy_c];
682 } 1026 }
683 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1027 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
684 ++yy_cp; 1028 ++yy_cp;
685 } 1029 }
686 while ( yy_base[yy_current_state] != 54 ); 1030 while ( yy_base[yy_current_state] != 69 );
687 1031
688yy_find_action: 1032yy_find_action:
1033/* %% [10.0] code to find the action number goes here */
689 yy_act = yy_accept[yy_current_state]; 1034 yy_act = yy_accept[yy_current_state];
690 if ( yy_act == 0 ) 1035 if ( yy_act == 0 )
691 { /* have to back up */ 1036 { /* have to back up */
692 yy_cp = yy_last_accepting_cpos; 1037 yy_cp = YY_G(yy_last_accepting_cpos);
693 yy_current_state = yy_last_accepting_state; 1038 yy_current_state = YY_G(yy_last_accepting_state);
694 yy_act = yy_accept[yy_current_state]; 1039 yy_act = yy_accept[yy_current_state];
695 } 1040 }
696 1041
697 YY_DO_BEFORE_ACTION; 1042 YY_DO_BEFORE_ACTION;
698 1043
1044/* %% [11.0] code for yylineno update goes here */
699 1045
700 do_action:/* This label is used only to access EOF actions. */ 1046 do_action:/* This label is used only to access EOF actions. */
701 1047
1048/* %% [12.0] debug code goes here */
702 1049
703 switch ( yy_act ) 1050 switch ( yy_act )
704 { /* beginning of action switch */ 1051 { /* beginning of action switch */
1052/* %% [13.0] actions go here */
705 case 0: /* must back up */ 1053 case 0: /* must back up */
706 /* undo the effects of YY_DO_BEFORE_ACTION */ 1054 /* undo the effects of YY_DO_BEFORE_ACTION */
707 *yy_cp = yy_hold_char; 1055 *yy_cp = YY_G(yy_hold_char);
708 yy_cp = yy_last_accepting_cpos; 1056 yy_cp = YY_G(yy_last_accepting_cpos);
709 yy_current_state = yy_last_accepting_state; 1057 yy_current_state = YY_G(yy_last_accepting_state);
710 goto yy_find_action; 1058 goto yy_find_action;
711 1059
712case 1: 1060case 1:
713YY_RULE_SETUP 1061YY_RULE_SETUP
714#line 75 "icalsslexer.l" 1062#line 72 "icalsslexer.l"
715{ return SELECT; } 1063{ return SELECT; }
716 YY_BREAK 1064 YY_BREAK
717case 2: 1065case 2:
718YY_RULE_SETUP 1066YY_RULE_SETUP
719#line 76 "icalsslexer.l" 1067#line 73 "icalsslexer.l"
720{ return FROM; } 1068{ return FROM; }
721 YY_BREAK 1069 YY_BREAK
722case 3: 1070case 3:
723YY_RULE_SETUP 1071YY_RULE_SETUP
724#line 77 "icalsslexer.l" 1072#line 74 "icalsslexer.l"
725{ return WHERE; } 1073{ return WHERE; }
726 YY_BREAK 1074 YY_BREAK
727case 4: 1075case 4:
728YY_RULE_SETUP 1076YY_RULE_SETUP
729#line 78 "icalsslexer.l" 1077#line 75 "icalsslexer.l"
730{ return COMMA; } 1078{ return COMMA; }
731 YY_BREAK 1079 YY_BREAK
732case 5: 1080case 5:
733YY_RULE_SETUP 1081YY_RULE_SETUP
734#line 79 "icalsslexer.l" 1082#line 76 "icalsslexer.l"
735{ return EQUALS; } 1083{ return EQUALS; }
736 YY_BREAK 1084 YY_BREAK
737case 6: 1085case 6:
738YY_RULE_SETUP 1086YY_RULE_SETUP
739#line 80 "icalsslexer.l" 1087#line 77 "icalsslexer.l"
740{ return NOTEQUALS; } 1088{ return EQUALS; }
741 YY_BREAK 1089 YY_BREAK
742case 7: 1090case 7:
743YY_RULE_SETUP 1091YY_RULE_SETUP
744#line 81 "icalsslexer.l" 1092#line 78 "icalsslexer.l"
745{ return LESS; } 1093{ return NOTEQUALS; }
746 YY_BREAK 1094 YY_BREAK
747case 8: 1095case 8:
748YY_RULE_SETUP 1096YY_RULE_SETUP
749#line 82 "icalsslexer.l" 1097#line 79 "icalsslexer.l"
750{ return GREATER; } 1098{ return LESS; }
751 YY_BREAK 1099 YY_BREAK
752case 9: 1100case 9:
753YY_RULE_SETUP 1101YY_RULE_SETUP
754#line 83 "icalsslexer.l" 1102#line 80 "icalsslexer.l"
755{ return LESSEQUALS; } 1103{ return GREATER; }
756 YY_BREAK 1104 YY_BREAK
757case 10: 1105case 10:
758YY_RULE_SETUP 1106YY_RULE_SETUP
759#line 84 "icalsslexer.l" 1107#line 81 "icalsslexer.l"
760{ return GREATEREQUALS; } 1108{ return LESSEQUALS; }
761 YY_BREAK 1109 YY_BREAK
762case 11: 1110case 11:
763YY_RULE_SETUP 1111YY_RULE_SETUP
764#line 85 "icalsslexer.l" 1112#line 82 "icalsslexer.l"
765{ return AND; } 1113{ return GREATEREQUALS; }
766 YY_BREAK 1114 YY_BREAK
767case 12: 1115case 12:
768YY_RULE_SETUP 1116YY_RULE_SETUP
769#line 86 "icalsslexer.l" 1117#line 83 "icalsslexer.l"
770{ return OR; } 1118{ return AND; }
771 YY_BREAK 1119 YY_BREAK
772case 13: 1120case 13:
773YY_RULE_SETUP 1121YY_RULE_SETUP
774#line 87 "icalsslexer.l" 1122#line 84 "icalsslexer.l"
775{ return QUOTE; } 1123{ return OR; }
776 YY_BREAK 1124 YY_BREAK
777case 14: 1125case 14:
778YY_RULE_SETUP 1126YY_RULE_SETUP
779#line 88 "icalsslexer.l" 1127#line 85 "icalsslexer.l"
780 ; 1128{ return IS; }
781 YY_BREAK 1129 YY_BREAK
782case 15: 1130case 15:
783YY_RULE_SETUP 1131YY_RULE_SETUP
784#line 89 "icalsslexer.l" 1132#line 86 "icalsslexer.l"
785{ return EOL; } 1133{ return NOT; }
786 YY_BREAK 1134 YY_BREAK
787case 16: 1135case 16:
788YY_RULE_SETUP 1136YY_RULE_SETUP
1137#line 87 "icalsslexer.l"
1138{ return SQLNULL; }
1139 YY_BREAK
1140case 17:
1141YY_RULE_SETUP
1142#line 88 "icalsslexer.l"
1143{ return QUOTE; }
1144 YY_BREAK
1145case 18:
1146YY_RULE_SETUP
1147#line 89 "icalsslexer.l"
1148 ;
1149 YY_BREAK
1150case 19:
1151YY_RULE_SETUP
789#line 90 "icalsslexer.l" 1152#line 90 "icalsslexer.l"
1153{ return EOL; }
1154 YY_BREAK
1155case 20:
1156YY_RULE_SETUP
1157#line 92 "icalsslexer.l"
790{ 1158{
791 int c = input(); 1159 int c = input(yy_globals);
792 unput(c); 1160 unput(c);
793 if(c!='\''){ 1161 if(c!='\''){
794 sslval.v_string= icalmemory_tmp_copy(sstext); 1162 yylvalp->v_string= icalmemory_tmp_copy(yytext);
795 return STRING; 1163 return STRING;
796 } else { 1164 } else {
797 /*ssmore();*/ 1165 /*ssmore();*/
798 } 1166 }
799} 1167}
800 YY_BREAK 1168 YY_BREAK
801case 17: 1169case 21:
802YY_RULE_SETUP 1170YY_RULE_SETUP
803#line 101 "icalsslexer.l" 1171#line 103 "icalsslexer.l"
804{ sslval.v_string= icalmemory_tmp_copy(sstext); 1172{
805 return STRING; } 1173 yylval->v_string= icalmemory_tmp_copy(yytext);
1174 return STRING;
1175}
806 YY_BREAK 1176 YY_BREAK
807case 18: 1177case 22:
808YY_RULE_SETUP 1178YY_RULE_SETUP
809#line 105 "icalsslexer.l" 1179#line 109 "icalsslexer.l"
810{ return yytext[0]; } 1180{ return yytext[0]; }
811 YY_BREAK 1181 YY_BREAK
812case 19: 1182case 23:
813YY_RULE_SETUP 1183YY_RULE_SETUP
814#line 107 "icalsslexer.l" 1184#line 111 "icalsslexer.l"
815ECHO; 1185ECHO;
816 YY_BREAK 1186 YY_BREAK
817#line 811 "icalsslexer.c" 1187#line 1188 "lex.ss.c"
818case YY_STATE_EOF(INITIAL): 1188case YY_STATE_EOF(INITIAL):
819case YY_STATE_EOF(sql): 1189case YY_STATE_EOF(sql):
820case YY_STATE_EOF(string_value): 1190case YY_STATE_EOF(string_value):
@@ -823,13 +1193,13 @@ case YY_STATE_EOF(string_value):
823 case YY_END_OF_BUFFER: 1193 case YY_END_OF_BUFFER:
824 { 1194 {
825 /* Amount of text matched not including the EOB char. */ 1195 /* Amount of text matched not including the EOB char. */
826 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; 1196 int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1;
827 1197
828 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1198 /* Undo the effects of YY_DO_BEFORE_ACTION. */
829 *yy_cp = yy_hold_char; 1199 *yy_cp = YY_G(yy_hold_char);
830 YY_RESTORE_YY_MORE_OFFSET 1200 YY_RESTORE_YY_MORE_OFFSET
831 1201
832 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) 1202 if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_NEW )
833 { 1203 {
834 /* We're scanning a new file or input source. It's 1204 /* We're scanning a new file or input source. It's
835 * possible that this happened because the user 1205 * possible that this happened because the user
@@ -840,9 +1210,9 @@ case YY_STATE_EOF(string_value):
840 * this is the first action (other than possibly a 1210 * this is the first action (other than possibly a
841 * back-up) that will match for the new input source. 1211 * back-up) that will match for the new input source.
842 */ 1212 */
843 yy_n_chars = yy_current_buffer->yy_n_chars; 1213 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
844 yy_current_buffer->yy_input_file = yyin; 1214 YY_G(yy_current_buffer)->yy_input_file = yyin;
845 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; 1215 YY_G(yy_current_buffer)->yy_buffer_status = YY_BUFFER_NORMAL;
846 } 1216 }
847 1217
848 /* Note that here we test for yy_c_buf_p "<=" to the position 1218 /* Note that here we test for yy_c_buf_p "<=" to the position
@@ -852,13 +1222,13 @@ case YY_STATE_EOF(string_value):
852 * end-of-buffer state). Contrast this with the test 1222 * end-of-buffer state). Contrast this with the test
853 * in input(). 1223 * in input().
854 */ 1224 */
855 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1225 if ( YY_G(yy_c_buf_p) <= &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
856 { /* This was really a NUL. */ 1226 { /* This was really a NUL. */
857 yy_state_type yy_next_state; 1227 yy_state_type yy_next_state;
858 1228
859 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; 1229 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text;
860 1230
861 yy_current_state = yy_get_previous_state(); 1231 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
862 1232
863 /* Okay, we're now positioned to make the NUL 1233 /* Okay, we're now positioned to make the NUL
864 * transition. We couldn't have 1234 * transition. We couldn't have
@@ -869,32 +1239,33 @@ case YY_STATE_EOF(string_value):
869 * will run more slowly). 1239 * will run more slowly).
870 */ 1240 */
871 1241
872 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1242 yy_next_state = yy_try_NUL_trans( yy_current_state YY_CALL_LAST_ARG);
873 1243
874 yy_bp = yytext_ptr + YY_MORE_ADJ; 1244 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
875 1245
876 if ( yy_next_state ) 1246 if ( yy_next_state )
877 { 1247 {
878 /* Consume the NUL. */ 1248 /* Consume the NUL. */
879 yy_cp = ++yy_c_buf_p; 1249 yy_cp = ++YY_G(yy_c_buf_p);
880 yy_current_state = yy_next_state; 1250 yy_current_state = yy_next_state;
881 goto yy_match; 1251 goto yy_match;
882 } 1252 }
883 1253
884 else 1254 else
885 { 1255 {
886 yy_cp = yy_c_buf_p; 1256/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
1257 yy_cp = YY_G(yy_c_buf_p);
887 goto yy_find_action; 1258 goto yy_find_action;
888 } 1259 }
889 } 1260 }
890 1261
891 else switch ( yy_get_next_buffer() ) 1262 else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
892 { 1263 {
893 case EOB_ACT_END_OF_FILE: 1264 case EOB_ACT_END_OF_FILE:
894 { 1265 {
895 yy_did_buffer_switch_on_eof = 0; 1266 YY_G(yy_did_buffer_switch_on_eof) = 0;
896 1267
897 if ( yywrap() ) 1268 if ( yywrap( YY_CALL_ONLY_ARG ) )
898 { 1269 {
899 /* Note: because we've taken care in 1270 /* Note: because we've taken care in
900 * yy_get_next_buffer() to have set up 1271 * yy_get_next_buffer() to have set up
@@ -905,7 +1276,7 @@ case YY_STATE_EOF(string_value):
905 * YY_NULL, it'll still work - another 1276 * YY_NULL, it'll still work - another
906 * YY_NULL will get returned. 1277 * YY_NULL will get returned.
907 */ 1278 */
908 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; 1279 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ;
909 1280
910 yy_act = YY_STATE_EOF(YY_START); 1281 yy_act = YY_STATE_EOF(YY_START);
911 goto do_action; 1282 goto do_action;
@@ -913,30 +1284,30 @@ case YY_STATE_EOF(string_value):
913 1284
914 else 1285 else
915 { 1286 {
916 if ( ! yy_did_buffer_switch_on_eof ) 1287 if ( ! YY_G(yy_did_buffer_switch_on_eof) )
917 YY_NEW_FILE; 1288 YY_NEW_FILE;
918 } 1289 }
919 break; 1290 break;
920 } 1291 }
921 1292
922 case EOB_ACT_CONTINUE_SCAN: 1293 case EOB_ACT_CONTINUE_SCAN:
923 yy_c_buf_p = 1294 YY_G(yy_c_buf_p) =
924 yytext_ptr + yy_amount_of_matched_text; 1295 YY_G(yytext_ptr) + yy_amount_of_matched_text;
925 1296
926 yy_current_state = yy_get_previous_state(); 1297 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
927 1298
928 yy_cp = yy_c_buf_p; 1299 yy_cp = YY_G(yy_c_buf_p);
929 yy_bp = yytext_ptr + YY_MORE_ADJ; 1300 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
930 goto yy_match; 1301 goto yy_match;
931 1302
932 case EOB_ACT_LAST_MATCH: 1303 case EOB_ACT_LAST_MATCH:
933 yy_c_buf_p = 1304 YY_G(yy_c_buf_p) =
934 &yy_current_buffer->yy_ch_buf[yy_n_chars]; 1305 &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)];
935 1306
936 yy_current_state = yy_get_previous_state(); 1307 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
937 1308
938 yy_cp = yy_c_buf_p; 1309 yy_cp = YY_G(yy_c_buf_p);
939 yy_bp = yytext_ptr + YY_MORE_ADJ; 1310 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
940 goto yy_find_action; 1311 goto yy_find_action;
941 } 1312 }
942 break; 1313 break;
@@ -948,7 +1319,14 @@ case YY_STATE_EOF(string_value):
948 } /* end of action switch */ 1319 } /* end of action switch */
949 } /* end of scanning one token */ 1320 } /* end of scanning one token */
950 } /* end of yylex */ 1321 } /* end of yylex */
951 1322/* %e */
1323#endif /* !ssIN_HEADER */
1324/* %+ */
1325/* %c */
1326#ifndef ssIN_HEADER
1327/* %e */
1328#endif /* !ssIN_HEADER */
1329/* %* */
952 1330
953/* yy_get_next_buffer - try to read in a new buffer 1331/* yy_get_next_buffer - try to read in a new buffer
954 * 1332 *
@@ -958,20 +1336,30 @@ case YY_STATE_EOF(string_value):
958 *EOB_ACT_END_OF_FILE - end of file 1336 *EOB_ACT_END_OF_FILE - end of file
959 */ 1337 */
960 1338
961static int yy_get_next_buffer() 1339/* %- */
1340/* %c */
1341#ifndef ssIN_HEADER
1342#ifdef YY_USE_PROTOS
1343static int yy_get_next_buffer(YY_ONLY_ARG)
1344#else
1345static int yy_get_next_buffer(YY_ONLY_ARG)
1346YY_DECL_LAST_ARG
1347#endif
1348/* %+ */
1349/* %* */
962 { 1350 {
963 register char *dest = yy_current_buffer->yy_ch_buf; 1351 register char *dest = YY_G(yy_current_buffer)->yy_ch_buf;
964 register char *source = yytext_ptr; 1352 register char *source = YY_G(yytext_ptr);
965 register int number_to_move, i; 1353 register int number_to_move, i;
966 int ret_val; 1354 int ret_val;
967 1355
968 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) 1356 if ( YY_G(yy_c_buf_p) > &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] )
969 YY_FATAL_ERROR( 1357 YY_FATAL_ERROR(
970 "fatal flex scanner internal error--end of buffer missed" ); 1358 "fatal flex scanner internal error--end of buffer missed" );
971 1359
972 if ( yy_current_buffer->yy_fill_buffer == 0 ) 1360 if ( YY_G(yy_current_buffer)->yy_fill_buffer == 0 )
973 { /* Don't try to fill the buffer, so this is an EOF. */ 1361 { /* Don't try to fill the buffer, so this is an EOF. */
974 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) 1362 if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 )
975 { 1363 {
976 /* We matched a single character, the EOB, so 1364 /* We matched a single character, the EOB, so
977 * treat this as a final EOF. 1365 * treat this as a final EOF.
@@ -991,21 +1379,21 @@ static int yy_get_next_buffer()
991 /* Try to read more data. */ 1379 /* Try to read more data. */
992 1380
993 /* First move last chars to start of buffer. */ 1381 /* First move last chars to start of buffer. */
994 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; 1382 number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
995 1383
996 for ( i = 0; i < number_to_move; ++i ) 1384 for ( i = 0; i < number_to_move; ++i )
997 *(dest++) = *(source++); 1385 *(dest++) = *(source++);
998 1386
999 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1387 if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1000 /* don't do the read, it's not guaranteed to return an EOF, 1388 /* don't do the read, it's not guaranteed to return an EOF,
1001 * just force an EOF 1389 * just force an EOF
1002 */ 1390 */
1003 yy_current_buffer->yy_n_chars = yy_n_chars = 0; 1391 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars) = 0;
1004 1392
1005 else 1393 else
1006 { 1394 {
1007 int num_to_read = 1395 size_t num_to_read =
1008 yy_current_buffer->yy_buf_size - number_to_move - 1; 1396 YY_G(yy_current_buffer)->yy_buf_size - number_to_move - 1;
1009 1397
1010 while ( num_to_read <= 0 ) 1398 while ( num_to_read <= 0 )
1011 { /* Not enough room in the buffer - grow it. */ 1399 { /* Not enough room in the buffer - grow it. */
@@ -1015,10 +1403,10 @@ static int yy_get_next_buffer()
1015#else 1403#else
1016 1404
1017 /* just a shorter name for the current buffer */ 1405 /* just a shorter name for the current buffer */
1018 YY_BUFFER_STATE b = yy_current_buffer; 1406 YY_BUFFER_STATE b = YY_G(yy_current_buffer);
1019 1407
1020 int yy_c_buf_p_offset = 1408 int yy_c_buf_p_offset =
1021 (int) (yy_c_buf_p - b->yy_ch_buf); 1409 (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf);
1022 1410
1023 if ( b->yy_is_our_buffer ) 1411 if ( b->yy_is_our_buffer )
1024 { 1412 {
@@ -1032,7 +1420,7 @@ static int yy_get_next_buffer()
1032 b->yy_ch_buf = (char *) 1420 b->yy_ch_buf = (char *)
1033 /* Include room in for 2 EOB chars. */ 1421 /* Include room in for 2 EOB chars. */
1034 yy_flex_realloc( (void *) b->yy_ch_buf, 1422 yy_flex_realloc( (void *) b->yy_ch_buf,
1035 b->yy_buf_size + 2 ); 1423 b->yy_buf_size + 2 YY_CALL_LAST_ARG );
1036 } 1424 }
1037 else 1425 else
1038 /* Can't grow it, we don't own it. */ 1426 /* Can't grow it, we don't own it. */
@@ -1042,9 +1430,9 @@ static int yy_get_next_buffer()
1042 YY_FATAL_ERROR( 1430 YY_FATAL_ERROR(
1043 "fatal error - scanner input buffer overflow" ); 1431 "fatal error - scanner input buffer overflow" );
1044 1432
1045 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; 1433 YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1046 1434
1047 num_to_read = yy_current_buffer->yy_buf_size - 1435 num_to_read = YY_G(yy_current_buffer)->yy_buf_size -
1048 number_to_move - 1; 1436 number_to_move - 1;
1049#endif 1437#endif
1050 } 1438 }
@@ -1053,24 +1441,24 @@ static int yy_get_next_buffer()
1053 num_to_read = YY_READ_BUF_SIZE; 1441 num_to_read = YY_READ_BUF_SIZE;
1054 1442
1055 /* Read in more data. */ 1443 /* Read in more data. */
1056 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), 1444 YY_INPUT( (&YY_G(yy_current_buffer)->yy_ch_buf[number_to_move]),
1057 yy_n_chars, num_to_read ); 1445 YY_G(yy_n_chars), num_to_read );
1058 1446
1059 yy_current_buffer->yy_n_chars = yy_n_chars; 1447 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
1060 } 1448 }
1061 1449
1062 if ( yy_n_chars == 0 ) 1450 if ( YY_G(yy_n_chars) == 0 )
1063 { 1451 {
1064 if ( number_to_move == YY_MORE_ADJ ) 1452 if ( number_to_move == YY_MORE_ADJ )
1065 { 1453 {
1066 ret_val = EOB_ACT_END_OF_FILE; 1454 ret_val = EOB_ACT_END_OF_FILE;
1067 yyrestart( yyin ); 1455 yyrestart( yyin YY_CALL_LAST_ARG);
1068 } 1456 }
1069 1457
1070 else 1458 else
1071 { 1459 {
1072 ret_val = EOB_ACT_LAST_MATCH; 1460 ret_val = EOB_ACT_LAST_MATCH;
1073 yy_current_buffer->yy_buffer_status = 1461 YY_G(yy_current_buffer)->yy_buffer_status =
1074 YY_BUFFER_EOF_PENDING; 1462 YY_BUFFER_EOF_PENDING;
1075 } 1463 }
1076 } 1464 }
@@ -1078,37 +1466,50 @@ static int yy_get_next_buffer()
1078 else 1466 else
1079 ret_val = EOB_ACT_CONTINUE_SCAN; 1467 ret_val = EOB_ACT_CONTINUE_SCAN;
1080 1468
1081 yy_n_chars += number_to_move; 1469 YY_G(yy_n_chars) += number_to_move;
1082 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; 1470 YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1083 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; 1471 YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1084 1472
1085 yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; 1473 YY_G(yytext_ptr) = &YY_G(yy_current_buffer)->yy_ch_buf[0];
1086 1474
1087 return ret_val; 1475 return ret_val;
1088 } 1476 }
1089 1477/* %e */
1478#endif /* !ssIN_HEADER */
1090 1479
1091/* yy_get_previous_state - get the state just before the EOB char was reached */ 1480/* yy_get_previous_state - get the state just before the EOB char was reached */
1092 1481
1093static yy_state_type yy_get_previous_state() 1482/* %- */
1483/* %c */
1484#ifndef ssIN_HEADER
1485#ifdef YY_USE_PROTOS
1486static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
1487#else
1488static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
1489YY_DECL_LAST_ARG
1490#endif
1491/* %+ */
1492/* %* */
1094 { 1493 {
1095 register yy_state_type yy_current_state; 1494 register yy_state_type yy_current_state;
1096 register char *yy_cp; 1495 register char *yy_cp;
1097 1496
1098 yy_current_state = yy_start; 1497/* %% [15.0] code to get the start state into yy_current_state goes here */
1498 yy_current_state = YY_G(yy_start);
1099 1499
1100 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) 1500 for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp )
1101 { 1501 {
1502/* %% [16.0] code to find the next state goes here */
1102 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1503 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1103 if ( yy_accept[yy_current_state] ) 1504 if ( yy_accept[yy_current_state] )
1104 { 1505 {
1105 yy_last_accepting_state = yy_current_state; 1506 YY_G(yy_last_accepting_state) = yy_current_state;
1106 yy_last_accepting_cpos = yy_cp; 1507 YY_G(yy_last_accepting_cpos) = yy_cp;
1107 } 1508 }
1108 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1509 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1109 { 1510 {
1110 yy_current_state = (int) yy_def[yy_current_state]; 1511 yy_current_state = (int) yy_def[yy_current_state];
1111 if ( yy_current_state >= 47 ) 1512 if ( yy_current_state >= 56 )
1112 yy_c = yy_meta[(unsigned int) yy_c]; 1513 yy_c = yy_meta[(unsigned int) yy_c];
1113 } 1514 }
1114 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1515 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()
1124 *next_state = yy_try_NUL_trans( current_state ); 1525 *next_state = yy_try_NUL_trans( current_state );
1125 */ 1526 */
1126 1527
1528/* %- */
1127#ifdef YY_USE_PROTOS 1529#ifdef YY_USE_PROTOS
1128static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) 1530static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state YY_LAST_ARG )
1129#else 1531#else
1130static yy_state_type yy_try_NUL_trans( yy_current_state ) 1532static yy_state_type yy_try_NUL_trans( yy_current_state YY_LAST_ARG )
1131yy_state_type yy_current_state; 1533yy_state_type yy_current_state;
1534YY_DECL_LAST_ARG
1132#endif 1535#endif
1536/* %+ */
1537/* %* */
1133 { 1538 {
1134 register int yy_is_jam; 1539 register int yy_is_jam;
1135 register char *yy_cp = yy_c_buf_p; 1540/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1541 register char *yy_cp = YY_G(yy_c_buf_p);
1136 1542
1137 register YY_CHAR yy_c = 1; 1543 register YY_CHAR yy_c = 1;
1138 if ( yy_accept[yy_current_state] ) 1544 if ( yy_accept[yy_current_state] )
1139 { 1545 {
1140 yy_last_accepting_state = yy_current_state; 1546 YY_G(yy_last_accepting_state) = yy_current_state;
1141 yy_last_accepting_cpos = yy_cp; 1547 YY_G(yy_last_accepting_cpos) = yy_cp;
1142 } 1548 }
1143 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1549 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1144 { 1550 {
1145 yy_current_state = (int) yy_def[yy_current_state]; 1551 yy_current_state = (int) yy_def[yy_current_state];
1146 if ( yy_current_state >= 47 ) 1552 if ( yy_current_state >= 56 )
1147 yy_c = yy_meta[(unsigned int) yy_c]; 1553 yy_c = yy_meta[(unsigned int) yy_c];
1148 } 1554 }
1149 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1555 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1150 yy_is_jam = (yy_current_state == 46); 1556 yy_is_jam = (yy_current_state == 55);
1151 1557
1152 return yy_is_jam ? 0 : yy_current_state; 1558 return yy_is_jam ? 0 : yy_current_state;
1153 } 1559 }
1154 1560
1155 1561
1562/* %- */
1156#ifndef YY_NO_UNPUT 1563#ifndef YY_NO_UNPUT
1157#ifdef YY_USE_PROTOS 1564#ifdef YY_USE_PROTOS
1158static void yyunput( int c, register char *yy_bp ) 1565static void yyunput( int c, register char *yy_bp YY_LAST_ARG )
1159#else 1566#else
1160static void yyunput( c, yy_bp ) 1567static void yyunput( c, yy_bp YY_LAST_ARG)
1161int c; 1568int c;
1162register char *yy_bp; 1569register char *yy_bp;
1570YY_DECL_LAST_ARG
1163#endif 1571#endif
1572/* %+ */
1573/* %* */
1164 { 1574 {
1165 register char *yy_cp = yy_c_buf_p; 1575 register char *yy_cp = YY_G(yy_c_buf_p);
1166 1576
1167 /* undo effects of setting up yytext */ 1577 /* undo effects of setting up yytext */
1168 *yy_cp = yy_hold_char; 1578 *yy_cp = YY_G(yy_hold_char);
1169 1579
1170 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1580 if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
1171 { /* need to shift things up to make room */ 1581 { /* need to shift things up to make room */
1172 /* +2 for EOB chars. */ 1582 /* +2 for EOB chars. */
1173 register int number_to_move = yy_n_chars + 2; 1583 register int number_to_move = YY_G(yy_n_chars) + 2;
1174 register char *dest = &yy_current_buffer->yy_ch_buf[ 1584 register char *dest = &YY_G(yy_current_buffer)->yy_ch_buf[
1175 yy_current_buffer->yy_buf_size + 2]; 1585 YY_G(yy_current_buffer)->yy_buf_size + 2];
1176 register char *source = 1586 register char *source =
1177 &yy_current_buffer->yy_ch_buf[number_to_move]; 1587 &YY_G(yy_current_buffer)->yy_ch_buf[number_to_move];
1178 1588
1179 while ( source > yy_current_buffer->yy_ch_buf ) 1589 while ( source > YY_G(yy_current_buffer)->yy_ch_buf )
1180 *--dest = *--source; 1590 *--dest = *--source;
1181 1591
1182 yy_cp += (int) (dest - source); 1592 yy_cp += (int) (dest - source);
1183 yy_bp += (int) (dest - source); 1593 yy_bp += (int) (dest - source);
1184 yy_current_buffer->yy_n_chars = 1594 YY_G(yy_current_buffer)->yy_n_chars =
1185 yy_n_chars = yy_current_buffer->yy_buf_size; 1595 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_buf_size;
1186 1596
1187 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1597 if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
1188 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1598 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1189 } 1599 }
1190 1600
1191 *--yy_cp = (char) c; 1601 *--yy_cp = (char) c;
1192 1602
1603/* %% [18.0] update yylineno here */
1193 1604
1194 yytext_ptr = yy_bp; 1605 YY_G(yytext_ptr) = yy_bp;
1195 yy_hold_char = *yy_cp; 1606 YY_G(yy_hold_char) = *yy_cp;
1196 yy_c_buf_p = yy_cp; 1607 YY_G(yy_c_buf_p) = yy_cp;
1197 } 1608 }
1609/* %- */
1198 #endif/* ifndef YY_NO_UNPUT */ 1610 #endif/* ifndef YY_NO_UNPUT */
1611/* %* */
1199 1612
1200 1613
1614/* %- */
1615#ifndef YY_NO_INPUT
1201#ifdef __cplusplus 1616#ifdef __cplusplus
1202static int yyinput() 1617static int yyinput(YY_ONLY_ARG)
1203#else 1618#else
1204static int input() 1619#ifdef YY_USE_PROTOS
1620static int input(YY_ONLY_ARG)
1621#else
1622static int input(YY_ONLY_ARG)
1623 YY_DECL_LAST_ARG
1624#endif
1205#endif 1625#endif
1626/* %+ */
1627/* %* */
1206 { 1628 {
1207 int c; 1629 int c;
1208 1630
1209 *yy_c_buf_p = yy_hold_char; 1631 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
1210 1632
1211 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) 1633 if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1212 { 1634 {
1213 /* yy_c_buf_p now points to the character we want to return. 1635 /* yy_c_buf_p now points to the character we want to return.
1214 * If this occurs *before* the EOB characters, then it's a 1636 * If this occurs *before* the EOB characters, then it's a
1215 * valid NUL; if not, then we've hit the end of the buffer. 1637 * valid NUL; if not, then we've hit the end of the buffer.
1216 */ 1638 */
1217 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1639 if ( YY_G(yy_c_buf_p) < &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
1218 /* This was really a NUL. */ 1640 /* This was really a NUL. */
1219 *yy_c_buf_p = '\0'; 1641 *YY_G(yy_c_buf_p) = '\0';
1220 1642
1221 else 1643 else
1222 { /* need more input */ 1644 { /* need more input */
1223 int offset = yy_c_buf_p - yytext_ptr; 1645 int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);
1224 ++yy_c_buf_p; 1646 ++YY_G(yy_c_buf_p);
1225 1647
1226 switch ( yy_get_next_buffer() ) 1648 switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
1227 { 1649 {
1228 case EOB_ACT_LAST_MATCH: 1650 case EOB_ACT_LAST_MATCH:
1229 /* This happens because yy_g_n_b() 1651 /* This happens because yy_g_n_b()
@@ -1237,109 +1659,129 @@ static int input()
1237 */ 1659 */
1238 1660
1239 /* Reset buffer status. */ 1661 /* Reset buffer status. */
1240 yyrestart( yyin ); 1662 yyrestart( yyin YY_CALL_LAST_ARG);
1241 1663
1242 /* fall through */ 1664 /* fall through */
1243 1665
1244 case EOB_ACT_END_OF_FILE: 1666 case EOB_ACT_END_OF_FILE:
1245 { 1667 {
1246 if ( yywrap() ) 1668 if ( yywrap( YY_CALL_ONLY_ARG ) )
1247 return EOF; 1669 return EOF;
1248 1670
1249 if ( ! yy_did_buffer_switch_on_eof ) 1671 if ( ! YY_G(yy_did_buffer_switch_on_eof) )
1250 YY_NEW_FILE; 1672 YY_NEW_FILE;
1251#ifdef __cplusplus 1673#ifdef __cplusplus
1252 return yyinput(); 1674 return yyinput(YY_CALL_ONLY_ARG);
1253#else 1675#else
1254 return input(); 1676 return input(YY_CALL_ONLY_ARG);
1255#endif 1677#endif
1256 } 1678 }
1257 1679
1258 case EOB_ACT_CONTINUE_SCAN: 1680 case EOB_ACT_CONTINUE_SCAN:
1259 yy_c_buf_p = yytext_ptr + offset; 1681 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset;
1260 break; 1682 break;
1261 } 1683 }
1262 } 1684 }
1263 } 1685 }
1264 1686
1265 c = *(unsigned char *) yy_c_buf_p;/* cast for 8-bit char's */ 1687 c = *(unsigned char *) YY_G(yy_c_buf_p);/* cast for 8-bit char's */
1266 *yy_c_buf_p = '\0';/* preserve yytext */ 1688 *YY_G(yy_c_buf_p) = '\0';/* preserve yytext */
1267 yy_hold_char = *++yy_c_buf_p; 1689 YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p);
1268 1690
1691/* %% [19.0] update BOL and yylineno */
1269 1692
1270 return c; 1693 return c;
1271 } 1694 }
1695/* %- */
1696 #endif/* ifndef YY_NO_INPUT */
1697/* %* */
1272 1698
1273 1699/* %- */
1274#ifdef YY_USE_PROTOS 1700#ifdef YY_USE_PROTOS
1275void yyrestart( FILE *input_file ) 1701void yyrestart( FILE *input_file YY_LAST_ARG)
1276#else 1702#else
1277void yyrestart( input_file ) 1703void yyrestart( input_file YY_LAST_ARG)
1278FILE *input_file; 1704FILE *input_file;
1705YY_DECL_LAST_ARG
1279#endif 1706#endif
1707/* %+ */
1708/* %* */
1280 { 1709 {
1281 if ( ! yy_current_buffer ) 1710 if ( ! YY_G(yy_current_buffer) )
1282 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); 1711 YY_G(yy_current_buffer) =
1712 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
1283 1713
1284 yy_init_buffer( yy_current_buffer, input_file ); 1714 yy_init_buffer( YY_G(yy_current_buffer), input_file YY_CALL_LAST_ARG);
1285 yy_load_buffer_state(); 1715 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1286 } 1716 }
1287 1717
1288 1718
1719/* %- */
1289#ifdef YY_USE_PROTOS 1720#ifdef YY_USE_PROTOS
1290void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 1721void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer YY_LAST_ARG )
1291#else 1722#else
1292void yy_switch_to_buffer( new_buffer ) 1723void yy_switch_to_buffer( new_buffer YY_LAST_ARG )
1293YY_BUFFER_STATE new_buffer; 1724YY_BUFFER_STATE new_buffer;
1725YY_DECL_LAST_ARG
1294#endif 1726#endif
1727/* %+ */
1728/* %* */
1295 { 1729 {
1296 if ( yy_current_buffer == new_buffer ) 1730 if ( YY_G(yy_current_buffer) == new_buffer )
1297 return; 1731 return;
1298 1732
1299 if ( yy_current_buffer ) 1733 if ( YY_G(yy_current_buffer) )
1300 { 1734 {
1301 /* Flush out information for old buffer. */ 1735 /* Flush out information for old buffer. */
1302 *yy_c_buf_p = yy_hold_char; 1736 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
1303 yy_current_buffer->yy_buf_pos = yy_c_buf_p; 1737 YY_G(yy_current_buffer)->yy_buf_pos = YY_G(yy_c_buf_p);
1304 yy_current_buffer->yy_n_chars = yy_n_chars; 1738 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
1305 } 1739 }
1306 1740
1307 yy_current_buffer = new_buffer; 1741 YY_G(yy_current_buffer) = new_buffer;
1308 yy_load_buffer_state(); 1742 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1309 1743
1310 /* We don't actually know whether we did this switch during 1744 /* We don't actually know whether we did this switch during
1311 * EOF (yywrap()) processing, but the only time this flag 1745 * EOF (yywrap()) processing, but the only time this flag
1312 * is looked at is after yywrap() is called, so it's safe 1746 * is looked at is after yywrap() is called, so it's safe
1313 * to go ahead and always set it. 1747 * to go ahead and always set it.
1314 */ 1748 */
1315 yy_did_buffer_switch_on_eof = 1; 1749 YY_G(yy_did_buffer_switch_on_eof) = 1;
1316 } 1750 }
1317 1751
1318 1752
1753/* %- */
1319#ifdef YY_USE_PROTOS 1754#ifdef YY_USE_PROTOS
1320void yy_load_buffer_state( void ) 1755void yy_load_buffer_state( YY_ONLY_ARG )
1321#else 1756#else
1322void yy_load_buffer_state() 1757void yy_load_buffer_state(YY_ONLY_ARG )
1758YY_DECL_LAST_ARG
1323#endif 1759#endif
1760/* %+ */
1761/* %* */
1324 { 1762 {
1325 yy_n_chars = yy_current_buffer->yy_n_chars; 1763 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
1326 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; 1764 YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_G(yy_current_buffer)->yy_buf_pos;
1327 yyin = yy_current_buffer->yy_input_file; 1765 yyin = YY_G(yy_current_buffer)->yy_input_file;
1328 yy_hold_char = *yy_c_buf_p; 1766 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
1329 } 1767 }
1330 1768
1331 1769
1770/* %- */
1332#ifdef YY_USE_PROTOS 1771#ifdef YY_USE_PROTOS
1333YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) 1772YY_BUFFER_STATE yy_create_buffer( FILE *file, int size YY_LAST_ARG)
1334#else 1773#else
1335YY_BUFFER_STATE yy_create_buffer( file, size ) 1774YY_BUFFER_STATE yy_create_buffer( file, size YY_LAST_ARG)
1336FILE *file; 1775FILE *file;
1337int size; 1776int size;
1777YY_DECL_LAST_ARG
1338#endif 1778#endif
1779/* %+ */
1780/* %* */
1339 { 1781 {
1340 YY_BUFFER_STATE b; 1782 YY_BUFFER_STATE b;
1341 1783
1342 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1784 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
1343 if ( ! b ) 1785 if ( ! b )
1344 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1786 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1345 1787
@@ -1348,79 +1790,100 @@ int size;
1348 /* yy_ch_buf has to be 2 characters longer than the size given because 1790 /* yy_ch_buf has to be 2 characters longer than the size given because
1349 * we need to put in 2 end-of-buffer characters. 1791 * we need to put in 2 end-of-buffer characters.
1350 */ 1792 */
1351 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); 1793 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
1352 if ( ! b->yy_ch_buf ) 1794 if ( ! b->yy_ch_buf )
1353 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1795 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1354 1796
1355 b->yy_is_our_buffer = 1; 1797 b->yy_is_our_buffer = 1;
1356 1798
1357 yy_init_buffer( b, file ); 1799 yy_init_buffer( b, file YY_CALL_LAST_ARG);
1358 1800
1359 return b; 1801 return b;
1360 } 1802 }
1361 1803
1362 1804
1805/* %- */
1363#ifdef YY_USE_PROTOS 1806#ifdef YY_USE_PROTOS
1364void yy_delete_buffer( YY_BUFFER_STATE b ) 1807void yy_delete_buffer( YY_BUFFER_STATE b YY_LAST_ARG)
1365#else 1808#else
1366void yy_delete_buffer( b ) 1809void yy_delete_buffer( b YY_LAST_ARG)
1367YY_BUFFER_STATE b; 1810YY_BUFFER_STATE b;
1811YY_DECL_LAST_ARG
1368#endif 1812#endif
1813/* %+ */
1814/* %* */
1369 { 1815 {
1370 if ( ! b ) 1816 if ( ! b )
1371 return; 1817 return;
1372 1818
1373 if ( b == yy_current_buffer ) 1819 if ( b == YY_G(yy_current_buffer) )
1374 yy_current_buffer = (YY_BUFFER_STATE) 0; 1820 YY_G(yy_current_buffer) = (YY_BUFFER_STATE) 0;
1375 1821
1376 if ( b->yy_is_our_buffer ) 1822 if ( b->yy_is_our_buffer )
1377 yy_flex_free( (void *) b->yy_ch_buf ); 1823 yy_flex_free( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
1378 1824
1379 yy_flex_free( (void *) b ); 1825 yy_flex_free( (void *) b YY_CALL_LAST_ARG );
1380 } 1826 }
1381 1827
1382 1828
1829/* %- */
1830#ifndef YY_ALWAYS_INTERACTIVE
1831#ifndef YY_NEVER_INTERACTIVE
1832#ifdef __cplusplus
1833extern "C" int isatty YY_PROTO(( int ));
1834#else
1835extern int isatty YY_PROTO(( int ));
1836#endif /* __cplusplus */
1837#endif /* !YY_NEVER_INTERACTIVE */
1838#endif /* !YY_ALWAYS_INTERACTIVE */
1383 1839
1384#ifdef YY_USE_PROTOS 1840#ifdef YY_USE_PROTOS
1385void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) 1841void yy_init_buffer( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG)
1386#else 1842#else
1387void yy_init_buffer( b, file ) 1843void yy_init_buffer( b, file YY_LAST_ARG)
1388YY_BUFFER_STATE b; 1844YY_BUFFER_STATE b;
1389FILE *file; 1845FILE *file;
1846YY_DECL_LAST_ARG
1390#endif 1847#endif
1391 1848
1849/* %+ */
1850/* %* */
1392 1851
1393 { 1852 {
1394 yy_flush_buffer( b ); 1853 int oerrno = errno;
1854
1855 yy_flush_buffer( b YY_CALL_LAST_ARG);
1395 1856
1396 b->yy_input_file = file; 1857 b->yy_input_file = file;
1397 b->yy_fill_buffer = 1; 1858 b->yy_fill_buffer = 1;
1398 1859
1860/* %- */
1399#if YY_ALWAYS_INTERACTIVE 1861#if YY_ALWAYS_INTERACTIVE
1400 b->yy_is_interactive = 1; 1862 b->yy_is_interactive = 1;
1401#else 1863#else
1402#if YY_NEVER_INTERACTIVE 1864#if YY_NEVER_INTERACTIVE
1403 b->yy_is_interactive = 0; 1865 b->yy_is_interactive = 0;
1404#else 1866#else
1405
1406#ifdef _QTWIN_
1407 b->yy_is_interactive = file ? (_isatty( fileno(file) ) > 0) : 0;
1408#else
1409 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1867 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1410#endif 1868#endif
1411
1412#endif
1413#endif 1869#endif
1870/* %+ */
1871/* %* */
1872 errno = oerrno;
1414 } 1873 }
1415 1874
1416 1875
1876/* %- */
1417#ifdef YY_USE_PROTOS 1877#ifdef YY_USE_PROTOS
1418void yy_flush_buffer( YY_BUFFER_STATE b ) 1878void yy_flush_buffer( YY_BUFFER_STATE b YY_LAST_ARG )
1419#else 1879#else
1420void yy_flush_buffer( b ) 1880void yy_flush_buffer( b YY_LAST_ARG )
1421YY_BUFFER_STATE b; 1881YY_BUFFER_STATE b;
1882YY_DECL_LAST_ARG
1422#endif 1883#endif
1423 1884
1885/* %+ */
1886/* %* */
1424 { 1887 {
1425 if ( ! b ) 1888 if ( ! b )
1426 return; 1889 return;
@@ -1439,18 +1902,21 @@ YY_BUFFER_STATE b;
1439 b->yy_at_bol = 1; 1902 b->yy_at_bol = 1;
1440 b->yy_buffer_status = YY_BUFFER_NEW; 1903 b->yy_buffer_status = YY_BUFFER_NEW;
1441 1904
1442 if ( b == yy_current_buffer ) 1905 if ( b == YY_G(yy_current_buffer) )
1443 yy_load_buffer_state(); 1906 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1444 } 1907 }
1908/* %* */
1445 1909
1446 1910
1447#ifndef YY_NO_SCAN_BUFFER 1911#ifndef YY_NO_SCAN_BUFFER
1912/* %- */
1448#ifdef YY_USE_PROTOS 1913#ifdef YY_USE_PROTOS
1449YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) 1914YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size YY_LAST_ARG )
1450#else 1915#else
1451YY_BUFFER_STATE yy_scan_buffer( base, size ) 1916YY_BUFFER_STATE yy_scan_buffer( base, size YY_LAST_ARG )
1452char *base; 1917char *base;
1453yy_size_t size; 1918yy_size_t size;
1919YY_DECL_LAST_ARG
1454#endif 1920#endif
1455 { 1921 {
1456 YY_BUFFER_STATE b; 1922 YY_BUFFER_STATE b;
@@ -1461,7 +1927,7 @@ yy_size_t size;
1461 /* They forgot to leave room for the EOB's. */ 1927 /* They forgot to leave room for the EOB's. */
1462 return 0; 1928 return 0;
1463 1929
1464 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1930 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
1465 if ( ! b ) 1931 if ( ! b )
1466 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 1932 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1467 1933
@@ -1475,36 +1941,42 @@ yy_size_t size;
1475 b->yy_fill_buffer = 0; 1941 b->yy_fill_buffer = 0;
1476 b->yy_buffer_status = YY_BUFFER_NEW; 1942 b->yy_buffer_status = YY_BUFFER_NEW;
1477 1943
1478 yy_switch_to_buffer( b ); 1944 yy_switch_to_buffer( b YY_CALL_LAST_ARG );
1479 1945
1480 return b; 1946 return b;
1481 } 1947 }
1948/* %* */
1482#endif 1949#endif
1483 1950
1484 1951
1485#ifndef YY_NO_SCAN_STRING 1952#ifndef YY_NO_SCAN_STRING
1953/* %- */
1486#ifdef YY_USE_PROTOS 1954#ifdef YY_USE_PROTOS
1487YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) 1955YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str YY_LAST_ARG )
1488#else 1956#else
1489YY_BUFFER_STATE yy_scan_string( yy_str ) 1957YY_BUFFER_STATE yy_scan_string( yy_str YY_LAST_ARG)
1490yyconst char *yy_str; 1958yyconst char *yy_str;
1959YY_DECL_LAST_ARG
1491#endif 1960#endif
1492 { 1961 {
1493 int len; 1962 int len;
1494 for ( len = 0; yy_str[len]; ++len ) 1963 for ( len = 0; yy_str[len]; ++len )
1495 ; 1964 ;
1496 1965
1497 return yy_scan_bytes( yy_str, len ); 1966 return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG);
1498 } 1967 }
1968/* %* */
1499#endif 1969#endif
1500 1970
1501 1971
1502#ifndef YY_NO_SCAN_BYTES 1972#ifndef YY_NO_SCAN_BYTES
1973/* %- */
1503#ifdef YY_USE_PROTOS 1974#ifdef YY_USE_PROTOS
1504YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) 1975YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len YY_LAST_ARG)
1505#else 1976#else
1506YY_BUFFER_STATE yy_scan_bytes( bytes, len ) 1977YY_BUFFER_STATE yy_scan_bytes( bytes, len YY_LAST_ARG)
1507yyconst char *bytes; 1978yyconst char *bytes;
1979YY_DECL_LAST_ARG
1508int len; 1980int len;
1509#endif 1981#endif
1510 { 1982 {
@@ -1515,7 +1987,7 @@ int len;
1515 1987
1516 /* Get memory for full buffer, including space for trailing EOB's. */ 1988 /* Get memory for full buffer, including space for trailing EOB's. */
1517 n = len + 2; 1989 n = len + 2;
1518 buf = (char *) yy_flex_alloc( n ); 1990 buf = (char *) yy_flex_alloc( n YY_CALL_LAST_ARG );
1519 if ( ! buf ) 1991 if ( ! buf )
1520 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 1992 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1521 1993
@@ -1524,7 +1996,7 @@ int len;
1524 1996
1525 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; 1997 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1526 1998
1527 b = yy_scan_buffer( buf, n ); 1999 b = yy_scan_buffer( buf, n YY_CALL_LAST_ARG);
1528 if ( ! b ) 2000 if ( ! b )
1529 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2001 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1530 2002
@@ -1535,37 +2007,42 @@ int len;
1535 2007
1536 return b; 2008 return b;
1537 } 2009 }
2010/* %* */
1538#endif 2011#endif
1539 2012
1540 2013
1541#ifndef YY_NO_PUSH_STATE 2014#ifndef YY_NO_PUSH_STATE
2015/* %- */
1542#ifdef YY_USE_PROTOS 2016#ifdef YY_USE_PROTOS
1543static void yy_push_state( int new_state ) 2017static void yy_push_state( int new_state YY_LAST_ARG)
1544#else 2018#else
1545static void yy_push_state( new_state ) 2019static void yy_push_state( new_state YY_LAST_ARG)
1546int new_state; 2020int new_state;
2021YY_DECL_LAST_ARG
1547#endif 2022#endif
2023/* %+ */
2024/* %* */
1548 { 2025 {
1549 if ( yy_start_stack_ptr >= yy_start_stack_depth ) 2026 if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
1550 { 2027 {
1551 yy_size_t new_size; 2028 yy_size_t new_size;
1552 2029
1553 yy_start_stack_depth += YY_START_STACK_INCR; 2030 YY_G(yy_start_stack_depth) += YY_START_STACK_INCR;
1554 new_size = yy_start_stack_depth * sizeof( int ); 2031 new_size = YY_G(yy_start_stack_depth) * sizeof( int );
1555 2032
1556 if ( ! yy_start_stack ) 2033 if ( ! YY_G(yy_start_stack) )
1557 yy_start_stack = (int *) yy_flex_alloc( new_size ); 2034 YY_G(yy_start_stack) = (int *) yy_flex_alloc( new_size YY_CALL_LAST_ARG );
1558 2035
1559 else 2036 else
1560 yy_start_stack = (int *) yy_flex_realloc( 2037 YY_G(yy_start_stack) = (int *) yy_flex_realloc(
1561 (void *) yy_start_stack, new_size ); 2038 (void *) YY_G(yy_start_stack), new_size YY_CALL_LAST_ARG );
1562 2039
1563 if ( ! yy_start_stack ) 2040 if ( ! YY_G(yy_start_stack) )
1564 YY_FATAL_ERROR( 2041 YY_FATAL_ERROR(
1565 "out of memory expanding start-condition stack" ); 2042 "out of memory expanding start-condition stack" );
1566 } 2043 }
1567 2044
1568 yy_start_stack[yy_start_stack_ptr++] = YY_START; 2045 YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
1569 2046
1570 BEGIN(new_state); 2047 BEGIN(new_state);
1571 } 2048 }
@@ -1573,20 +2050,36 @@ int new_state;
1573 2050
1574 2051
1575#ifndef YY_NO_POP_STATE 2052#ifndef YY_NO_POP_STATE
1576static void yy_pop_state() 2053/* %- */
2054#ifdef YY_USE_PROTOS
2055static void yy_pop_state( YY_ONLY_ARG )
2056#else
2057static void yy_pop_state( YY_ONLY_ARG )
2058YY_DECL_LAST_ARG
2059#endif
2060/* %+ */
2061/* %* */
1577 { 2062 {
1578 if ( --yy_start_stack_ptr < 0 ) 2063 if ( --YY_G(yy_start_stack_ptr) < 0 )
1579 YY_FATAL_ERROR( "start-condition stack underflow" ); 2064 YY_FATAL_ERROR( "start-condition stack underflow" );
1580 2065
1581 BEGIN(yy_start_stack[yy_start_stack_ptr]); 2066 BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
1582 } 2067 }
1583#endif 2068#endif
1584 2069
1585 2070
1586#ifndef YY_NO_TOP_STATE 2071#ifndef YY_NO_TOP_STATE
1587static int yy_top_state() 2072/* %- */
2073#ifdef YY_USE_PROTOS
2074static int yy_top_state( YY_ONLY_ARG )
2075#else
2076static int yy_top_state( YY_ONLY_ARG )
2077YY_DECL_LAST_ARG
2078#endif
2079/* %+ */
2080/* %* */
1588 { 2081 {
1589 return yy_start_stack[yy_start_stack_ptr - 1]; 2082 return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
1590 } 2083 }
1591#endif 2084#endif
1592 2085
@@ -1594,17 +2087,15 @@ static int yy_top_state()
1594#define YY_EXIT_FAILURE 2 2087#define YY_EXIT_FAILURE 2
1595#endif 2088#endif
1596 2089
1597#ifdef YY_USE_PROTOS 2090/* %- */
1598static void yy_fatal_error( yyconst char msg[] ) 2091static void yy_fatal_error( yyconst char msg[] )
1599#else
1600static void yy_fatal_error( msg )
1601char msg[];
1602#endif
1603 { 2092 {
1604 (void) fprintf( stderr, "%s\n", msg ); 2093 (void) fprintf( stderr, "%s\n", msg );
1605 exit( YY_EXIT_FAILURE ); 2094 exit( YY_EXIT_FAILURE );
1606 } 2095 }
1607 2096
2097/* %+ */
2098/* %* */
1608 2099
1609 2100
1610/* Redefine yyless() so it works in section 3 code. */ 2101/* Redefine yyless() so it works in section 3 code. */
@@ -1614,25 +2105,288 @@ char msg[];
1614 do \ 2105 do \
1615 { \ 2106 { \
1616 /* Undo effects of setting up yytext. */ \ 2107 /* Undo effects of setting up yytext. */ \
1617 yytext[yyleng] = yy_hold_char; \ 2108 yytext[yyleng] = YY_G(yy_hold_char); \
1618 yy_c_buf_p = yytext + n; \ 2109 YY_G(yy_c_buf_p) = yytext + n; \
1619 yy_hold_char = *yy_c_buf_p; \ 2110 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
1620 *yy_c_buf_p = '\0'; \ 2111 *YY_G(yy_c_buf_p) = '\0'; \
1621 yyleng = n; \ 2112 yyleng = n; \
1622 } \ 2113 } \
1623 while ( 0 ) 2114 while ( 0 )
1624 2115
1625 2116
2117
2118#ifdef YY_REENTRANT
2119
2120/* Accessor methods (get/set functions) to struct members. */
2121
2122#ifndef YY_NO_GET_EXTRA
2123#ifdef YY_USE_PROTOS
2124YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
2125#else
2126YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
2127 YY_DECL_LAST_ARG
2128#endif
2129{
2130 return yyextra;
2131}
2132#endif /* !YY_NO_GET_EXTRA */
2133
2134#ifndef YY_NO_GET_LINENO
2135# ifdef YY_USE_PROTOS
2136int yyget_lineno( YY_ONLY_ARG )
2137# else
2138int yyget_lineno( YY_ONLY_ARG )
2139 YY_DECL_LAST_ARG
2140# endif
2141{
2142 return yylineno;
2143}
2144#endif /* !YY_NO_GET_LINENO */
2145
2146#ifndef YY_NO_GET_IN
2147#ifdef YY_USE_PROTOS
2148FILE *yyget_in( YY_ONLY_ARG )
2149#else
2150FILE *yyget_in( YY_ONLY_ARG )
2151 YY_DECL_LAST_ARG
2152#endif
2153{
2154 return yyin;
2155}
2156#endif /* !YY_NO_GET_IN */
2157
2158#ifndef YY_NO_GET_OUT
2159#ifdef YY_USE_PROTOS
2160FILE *yyget_out( YY_ONLY_ARG )
2161#else
2162FILE *yyget_out( YY_ONLY_ARG )
2163 YY_DECL_LAST_ARG
2164#endif
2165{
2166 return yyout;
2167}
2168#endif /* !YY_NO_GET_OUT */
2169
2170#ifndef YY_NO_GET_LENG
2171#ifdef YY_USE_PROTOS
2172int yyget_leng( YY_ONLY_ARG )
2173#else
2174int yyget_leng( YY_ONLY_ARG )
2175 YY_DECL_LAST_ARG
2176#endif
2177{
2178 return yyleng;
2179}
2180#endif /* !YY_NO_GET_LENG */
2181
2182#ifndef YY_NO_GET_TEXT
2183#ifdef YY_USE_PROTOS
2184char *yyget_text( YY_ONLY_ARG )
2185#else
2186char *yyget_text( YY_ONLY_ARG )
2187 YY_DECL_LAST_ARG
2188#endif
2189{
2190 return yytext;
2191}
2192#endif /* !YY_NO_GET_TEXT */
2193
2194#ifndef YY_NO_SET_EXTRA
2195#ifdef YY_USE_PROTOS
2196void yyset_extra( YY_EXTRA_TYPE user_defined YY_LAST_ARG )
2197#else
2198void yyset_extra( user_defined YY_LAST_ARG )
2199 YY_EXTRA_TYPE user_defined;
2200 YY_DECL_LAST_ARG
2201#endif
2202{
2203 yyextra = user_defined ;
2204}
2205#endif /* !YY_NO_SET_EXTRA */
2206
2207#ifndef YY_NO_SET_LINENO
2208# ifdef YY_USE_PROTOS
2209void yyset_lineno( int line_number YY_LAST_ARG )
2210# else
2211void yyset_lineno( line_number YY_LAST_ARG )
2212 int line_number;
2213 YY_DECL_LAST_ARG
2214# endif
2215{
2216 yylineno = line_number;
2217}
2218#endif /* !YY_NO_SET_LINENO */
2219
2220
2221#ifndef YY_NO_SET_IN
2222#ifdef YY_USE_PROTOS
2223void yyset_in( FILE * in_str YY_LAST_ARG )
2224#else
2225void yyset_in( in_str YY_LAST_ARG )
2226 FILE * in_str;
2227 YY_DECL_LAST_ARG
2228#endif
2229{
2230 yyin = in_str ;
2231}
2232#endif /* !YY_NO_SET_IN */
2233
2234#ifndef YY_NO_SET_OUT
2235#ifdef YY_USE_PROTOS
2236void yyset_out( FILE * out_str YY_LAST_ARG )
2237#else
2238void yyset_out( out_str YY_LAST_ARG )
2239 FILE * out_str;
2240 YY_DECL_LAST_ARG
2241#endif
2242{
2243 yyout = out_str ;
2244}
2245#endif /* !YY_NO_SET_OUT */
2246
2247/* Accessor methods for yylval and yylloc */
2248
2249#ifdef YY_REENTRANT_BISON_PURE
2250#ifndef YY_NO_GET_LVAL
2251#ifdef YY_USE_PROTOS
2252YYSTYPE * yyget_lval( YY_ONLY_ARG )
2253#else
2254YYSTYPE * yyget_lval( YY_ONLY_ARG )
2255 YY_DECL_LAST_ARG
2256#endif
2257{
2258 return yylval;
2259}
2260#endif /* !YY_NO_GET_LVAL */
2261
2262#ifndef YY_NO_SET_LVAL
2263#ifdef YY_USE_PROTOS
2264void yyset_lval( YYSTYPE * yylvalp YY_LAST_ARG )
2265#else
2266void yyset_lval( yylvalp YY_LAST_ARG )
2267 YYSTYPE * yylvalp;
2268 YY_DECL_LAST_ARG
2269#endif
2270{
2271 yylval = yylvalp;
2272}
2273#endif /* !YY_NO_SET_LVAL */
2274
2275#ifdef YYLTYPE
2276#ifndef YY_NO_GET_LLOC
2277#ifdef YY_USE_PROTOS
2278YYLTYPE *yyget_lloc( YY_ONLY_ARG )
2279#else
2280YYLTYPE *yyget_lloc( YY_ONLY_ARG )
2281 YY_DECL_LAST_ARG
2282#endif
2283{
2284 return yylloc;
2285}
2286#endif /* !YY_NO_GET_LLOC */
2287
2288#ifndef YY_NO_SET_LLOC
2289#ifdef YY_USE_PROTOS
2290void yyset_lloc( YYLTYPE * yyllocp YY_LAST_ARG )
2291#else
2292void yyset_lloc( yyllocp YY_LAST_ARG )
2293 YYLTYPE * yyllocp;
2294 YY_DECL_LAST_ARG
2295#endif
2296{
2297 yylloc = yyllocp;
2298}
2299#endif /* !YY_NO_SET_LLOC */
2300
2301#endif /* YYLTYPE */
2302#endif /* YY_REENTRANT_BISON_PURE */
2303
2304
2305#ifdef YY_USE_PROTOS
2306static int yy_init_globals( yyscan_t yy_globals)
2307#else
2308static int yy_init_globals( yy_globals )
2309 yyscan_t yy_globals;
2310#endif
2311 {
2312 /* Initialization is the same as for the non-reentrant scanner.
2313 This function is called once per scanner lifetime. */
2314
2315 /* We do not touch yylineno unless the option is enabled. */
2316#ifdef YY_USE_LINENO
2317 yylineno = 1;
2318#endif
2319 YY_G(yy_current_buffer) = 0;
2320 YY_G(yy_c_buf_p) = (char *) 0;
2321 YY_G(yy_init) = 1;
2322 YY_G(yy_start) = 0;
2323 YY_G(yy_start_stack_ptr) = 0;
2324 YY_G(yy_start_stack_depth) = 0;
2325 YY_G(yy_start_stack) = (int *) 0;
2326
2327/* Defined in main.c */
2328#ifdef YY_STDINIT
2329 yyin = stdin;
2330 yyout = stdout;
2331#else
2332 yyin = (FILE *) 0;
2333 yyout = (FILE *) 0;
2334#endif
2335 return 0;
2336 }
2337
2338/* User-visible API */
2339#ifdef YY_USE_PROTOS
2340int yylex_init( yyscan_t* ptr_yy_globals)
2341#else
2342int yylex_init( ptr_yy_globals )
2343 yyscan_t* ptr_yy_globals;
2344#endif
2345 {
2346 *ptr_yy_globals = (yyscan_t) yy_flex_alloc ( sizeof( struct yy_globals_t ), NULL );
2347 yy_init_globals ( *ptr_yy_globals );
2348 return 0;
2349 }
2350
2351#ifdef YY_USE_PROTOS
2352int yylex_destroy( yyscan_t yy_globals )
2353#else
2354int yylex_destroy( yy_globals )
2355 yyscan_t yy_globals;
2356#endif
2357 {
2358 if( yy_globals )
2359 {
2360
2361 /* Destroy the current (main) buffer. */
2362 yy_delete_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG );
2363 YY_G(yy_current_buffer) = NULL;
2364
2365 /* Destroy the start condition stack. */
2366 if( YY_G(yy_start_stack) ) {
2367 yy_flex_free( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
2368 YY_G(yy_start_stack) = NULL;
2369 }
2370
2371 /* Destroy the main struct. */
2372 yy_flex_free ( yy_globals YY_CALL_LAST_ARG );
2373 }
2374 return 0;
2375 }
2376
2377#endif /* End YY_REENTRANT */
2378
1626/* Internal utility routines. */ 2379/* Internal utility routines. */
1627 2380
1628#ifndef yytext_ptr 2381#ifndef yytext_ptr
1629#ifdef YY_USE_PROTOS 2382#ifdef YY_USE_PROTOS
1630static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) 2383static void yy_flex_strncpy( char *s1, yyconst char *s2, int n YY_LAST_ARG)
1631#else 2384#else
1632static void yy_flex_strncpy( s1, s2, n ) 2385static void yy_flex_strncpy( s1, s2, n YY_LAST_ARG)
1633char *s1; 2386char *s1;
1634yyconst char *s2; 2387yyconst char *s2;
1635int n; 2388int n;
2389YY_DECL_LAST_ARG
1636#endif 2390#endif
1637 { 2391 {
1638 register int i; 2392 register int i;
@@ -1643,10 +2397,11 @@ int n;
1643 2397
1644#ifdef YY_NEED_STRLEN 2398#ifdef YY_NEED_STRLEN
1645#ifdef YY_USE_PROTOS 2399#ifdef YY_USE_PROTOS
1646static int yy_flex_strlen( yyconst char *s ) 2400static int yy_flex_strlen( yyconst char *s YY_LAST_ARG)
1647#else 2401#else
1648static int yy_flex_strlen( s ) 2402static int yy_flex_strlen( s YY_LAST_ARG)
1649yyconst char *s; 2403yyconst char *s;
2404YY_DECL_LAST_ARG
1650#endif 2405#endif
1651 { 2406 {
1652 register int n; 2407 register int n;
@@ -1659,21 +2414,23 @@ yyconst char *s;
1659 2414
1660 2415
1661#ifdef YY_USE_PROTOS 2416#ifdef YY_USE_PROTOS
1662static void *yy_flex_alloc( yy_size_t size ) 2417static void *yy_flex_alloc( yy_size_t size YY_LAST_ARG )
1663#else 2418#else
1664static void *yy_flex_alloc( size ) 2419static void *yy_flex_alloc( size YY_LAST_ARG )
1665yy_size_t size; 2420yy_size_t size;
2421YY_DECL_LAST_ARG
1666#endif 2422#endif
1667 { 2423 {
1668 return (void *) malloc( size ); 2424 return (void *) malloc( size );
1669 } 2425 }
1670 2426
1671#ifdef YY_USE_PROTOS 2427#ifdef YY_USE_PROTOS
1672static void *yy_flex_realloc( void *ptr, yy_size_t size ) 2428static void *yy_flex_realloc( void *ptr, yy_size_t size YY_LAST_ARG )
1673#else 2429#else
1674static void *yy_flex_realloc( ptr, size ) 2430static void *yy_flex_realloc( ptr, size YY_LAST_ARG )
1675void *ptr; 2431void *ptr;
1676yy_size_t size; 2432yy_size_t size;
2433YY_DECL_LAST_ARG
1677#endif 2434#endif
1678 { 2435 {
1679 /* The cast to (char *) in the following accommodates both 2436 /* The cast to (char *) in the following accommodates both
@@ -1687,27 +2444,42 @@ yy_size_t size;
1687 } 2444 }
1688 2445
1689#ifdef YY_USE_PROTOS 2446#ifdef YY_USE_PROTOS
1690static void yy_flex_free( void *ptr ) 2447static void yy_flex_free( void *ptr YY_LAST_ARG )
1691#else 2448#else
1692static void yy_flex_free( ptr ) 2449static void yy_flex_free( ptr YY_LAST_ARG )
1693void *ptr; 2450void *ptr;
2451YY_DECL_LAST_ARG
1694#endif 2452#endif
1695 { 2453 {
1696 free( ptr ); 2454 free( (char *) ptr );/* see yy_flex_realloc() for (char *) cast */
1697 } 2455 }
1698 2456
1699#if YY_MAIN 2457#if YY_MAIN
1700int main() 2458int main()
1701 { 2459 {
2460
2461#ifdef YY_REENTRANT
2462 yyscan_t lexer;
2463 yylex_init(&lexer);
2464 yylex( lexer );
2465 yylex_destroy( lexer);
2466
2467#else
1702 yylex(); 2468 yylex();
2469#endif
2470
1703 return 0; 2471 return 0;
1704 } 2472 }
1705#endif 2473#endif
1706#line 107 "icalsslexer.l" 2474/* %e */
2475#endif /* !ssIN_HEADER */
2476#line 111 "icalsslexer.l"
2477#ifndef ssIN_HEADER
1707 2478
1708 2479
1709int sswrap() 2480int yywrap(yyscan_t yy_globals)
1710{ 2481{
1711 return 1; 2482 return 1;
1712} 2483}
1713 2484
2485#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 @@
1/* A Bison parser, made from icalssyacc.y 1/* A Bison parser, made from icalssyacc.y
2 by GNU bison 1.35. */ 2 by GNU bison 1.34. */
3 3
4#define YYBISON 1 /* Identify Bison output. */ 4#define YYBISON 1 /* Identify Bison output. */
5 5
@@ -26,8 +26,11 @@
26 # define OR270 26 # define OR270
27 # define EOL271 27 # define EOL271
28 # define END272 28 # define END272
29 # define IS273
30 # define NOT274
31 # define SQLNULL275
29 32
30#line 1 "icalssyacc.y" 33#line 3 "icalssyacc.y"
31 34
32/* -*- Mode: C -*- 35/* -*- Mode: C -*-
33 ====================================================================== 36 ======================================================================
@@ -56,35 +59,36 @@
56 Code is Eric Busboom 59 Code is Eric Busboom
57 60
58 ======================================================================*/ 61 ======================================================================*/
59 62/*#define YYDEBUG 1*/
60#include <stdlib.h> 63#include <stdlib.h>
61#include <string.h> /* for strdup() */ 64#include <string.h> /* for strdup() */
62#include <limits.h> /* for SHRT_MAX*/ 65#include <limits.h> /* for SHRT_MAX*/
63#include "ical.h" 66#include "ical.h"
64#include "pvl.h"
65#include "icalgauge.h" 67#include "icalgauge.h"
66#include "icalgaugeimpl.h" 68#include "icalgaugeimpl.h"
67 69
68 70
69extern struct icalgauge_impl *icalss_yy_gauge; 71#define YYPARSE_PARAM yy_globals
70 72#define YYLEX_PARAM yy_globals
71void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, 73#define YY_EXTRA_TYPE icalgauge_impl*
72 icalgaugecompare compare , char* value); 74 /* ick...*/
73void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); 75#define yyextra ((struct icalgauge_impl*)ssget_extra(yy_globals))
74void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
75void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
76void sserror(char *s); /* Don't know why I need this.... */
77 76
78 77
78static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
79 icalgaugecompare compare , char* value);
80static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
81static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
82static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
83void sserror(char *s); /* Don't know why I need this.... */
79 84
80 85
81#line 52 "icalssyacc.y" 86#line 56 "icalssyacc.y"
82#ifndef YYSTYPE 87#ifndef YYSTYPE
83typedef union { 88typedef union {
84 char* v_string; 89 char* v_string;
85} yystype; 90} yystype;
86# define YYSTYPE yystype 91# define YYSTYPE yystype
87# define YYSTYPE_IS_TRIVIAL 1
88#endif 92#endif
89#ifndef YYDEBUG 93#ifndef YYDEBUG
90# define YYDEBUG 0 94# define YYDEBUG 0
@@ -92,12 +96,12 @@ typedef union {
92 96
93 97
94 98
95 #define YYFINAL 34 99 #define YYFINAL 38
96 #define YYFLAG -32768 100 #define YYFLAG -32768
97 #define YYNTBASE19 101 #define YYNTBASE22
98 102
99/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ 103/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
100#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 24) 104#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 27)
101 105
102/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ 106/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
103static const char yytranslate[] = 107static const char yytranslate[] =
@@ -129,23 +133,24 @@ static const char yytranslate[] =
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 134 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
131 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 135 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
132 16, 17, 18 136 16, 17, 18, 19, 20, 21
133}; 137};
134 138
135#if YYDEBUG 139#if YYDEBUG
136static const short yyprhs[] = 140static const short yyprhs[] =
137{ 141{
138 0, 0, 7, 9, 11, 15, 17, 21, 22, 26, 142 0, 0, 7, 12, 14, 16, 20, 22, 26, 27,
139 30, 34, 38, 42, 46, 48, 52 143 31, 35, 40, 44, 48, 52, 56, 60, 62, 66
140}; 144};
141static const short yyrhs[] = 145static const short yyrhs[] =
142{ 146{
143 4, 20, 5, 21, 6, 23, 0, 1, 0, 3, 147 4, 23, 5, 24, 6, 26, 0, 4, 23, 5,
144 0, 20, 7, 3, 0, 3, 0, 21, 7, 3, 148 24, 0, 1, 0, 3, 0, 23, 7, 3, 0,
145 0, 0, 3, 9, 3, 0, 3, 10, 3, 0, 149 3, 0, 24, 7, 3, 0, 0, 3, 9, 3,
146 3, 11, 3, 0, 3, 12, 3, 0, 3, 13, 150 0, 3, 19, 21, 0, 3, 19, 20, 21, 0,
147 3, 0, 3, 14, 3, 0, 22, 0, 23, 15, 151 3, 10, 3, 0, 3, 11, 3, 0, 3, 12,
148 22, 0, 23, 16, 22, 0 152 3, 0, 3, 13, 3, 0, 3, 14, 3, 0,
153 25, 0, 26, 15, 25, 0, 26, 16, 25, 0
149}; 154};
150 155
151#endif 156#endif
@@ -154,8 +159,8 @@ static const short yyrhs[] =
154/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 159/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
155static const short yyrline[] = 160static const short yyrline[] =
156{ 161{
157 0, 63, 64, 70, 72, 76, 78, 81, 83, 85, 162 0, 67, 68, 69, 75, 77, 81, 83, 86, 88,
158 86, 87, 88, 89, 92, 94, 95 163 89, 90, 91, 92, 93, 94, 95, 98, 100, 101
159}; 164};
160#endif 165#endif
161 166
@@ -167,23 +172,23 @@ static const char *const yytname[] =
167{ 172{
168 "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA", 173 "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA",
169 "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS", 174 "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS",
170 "GREATEREQUALS", "AND", "OR", "EOL", "END", "query_min", "select_list", 175 "GREATEREQUALS", "AND", "OR", "EOL", "END", "IS", "NOT", "SQLNULL",
171 "from_list", "where_clause", "where_list", 0 176 "query_min", "select_list", "from_list", "where_clause", "where_list", 0
172}; 177};
173#endif 178#endif
174 179
175/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 180/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
176static const short yyr1[] = 181static const short yyr1[] =
177{ 182{
178 0, 19, 19, 20, 20, 21, 21, 22, 22, 22, 183 0, 22, 22, 22, 23, 23, 24, 24, 25, 25,
179 22, 22, 22, 22, 23, 23, 23 184 25, 25, 25, 25, 25, 25, 25, 26, 26, 26
180}; 185};
181 186
182/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 187/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
183static const short yyr2[] = 188static const short yyr2[] =
184{ 189{
185 0, 6, 1, 1, 3, 1, 3, 0, 3, 3, 190 0, 6, 4, 1, 1, 3, 1, 3, 0, 3,
186 3, 3, 3, 3, 1, 3, 3 191 3, 4, 3, 3, 3, 3, 3, 1, 3, 3
187}; 192};
188 193
189/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE 194/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -191,49 +196,53 @@ static const short yyr2[] =
191 error. */ 196 error. */
192static const short yydefact[] = 197static const short yydefact[] =
193{ 198{
194 0, 2, 0, 3, 0, 0, 0, 5, 0, 4, 199 0, 3, 0, 4, 0, 0, 0, 6, 2, 5,
195 7, 0, 0, 14, 1, 6, 0, 0, 0, 0, 200 8, 0, 0, 17, 1, 7, 0, 0, 0, 0,
196 0, 0, 7, 7, 8, 9, 10, 11, 12, 13, 201 0, 0, 0, 8, 8, 9, 12, 13, 14, 15,
197 15, 16, 0, 0, 0 202 16, 0, 10, 18, 19, 11, 0, 0, 0
198}; 203};
199 204
200static const short yydefgoto[] = 205static const short yydefgoto[] =
201{ 206{
202 32, 4, 8, 13, 14 207 36, 4, 8, 13, 14
203}; 208};
204 209
205static const short yypact[] = 210static const short yypact[] =
206{ 211{
207 5,-32768, 4,-32768, 3, 8, 15,-32768, 6,-32768, 212 5,-32768, 9,-32768, 6, 17, 18,-32768, 1,-32768,
208 16, 17, -9,-32768, -1,-32768, 18, 19, 20, 21, 213 19, 20, -9,-32768, -1,-32768, 21, 22, 23, 24,
209 22, 23, 16, 16,-32768,-32768,-32768,-32768,-32768,-32768, 214 25, 26, -4, 19, 19,-32768,-32768,-32768,-32768,-32768,
210 -32768,-32768, 27, 28,-32768 215 -32768, 10,-32768,-32768,-32768,-32768, 30, 32,-32768
211}; 216};
212 217
213static const short yypgoto[] = 218static const short yypgoto[] =
214{ 219{
215 -32768,-32768,-32768, -6,-32768 220 -32768,-32768,-32768, -5,-32768
216}; 221};
217 222
218 223
219 #define YYLAST 28 224 #define YYLAST 32
220 225
221 226
222static const short yytable[] = 227static const short yytable[] =
223{ 228{
224 16, 17, 18, 19, 20, 21, 1, 3, 5, 2, 229 16, 17, 18, 19, 20, 21, 1, 10, 11, 2,
225 6, 7, 10, 11, 22, 23, 30, 31, 9, 12, 230 22, 5, 3, 6, 23, 24, 31, 32, 33, 34,
226 15, 24, 25, 26, 27, 28, 29, 33, 34 231 7, 9, 12, 15, 25, 26, 27, 28, 29, 30,
232 37, 35, 38
227}; 233};
228 234
229static const short yycheck[] = 235static const short yycheck[] =
230{ 236{
231 9, 10, 11, 12, 13, 14, 1, 3, 5, 4, 237 9, 10, 11, 12, 13, 14, 1, 6, 7, 4,
232 7, 3, 6, 7, 15, 16, 22, 23, 3, 3, 238 19, 5, 3, 7, 15, 16, 20, 21, 23, 24,
233 3, 3, 3, 3, 3, 3, 3, 0, 0 239 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
240 0, 21, 0
234}; 241};
242#define YYPURE 1
243
235/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 244/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
236#line 3 "/usr/share/bison/bison.simple" 245#line 3 "/usr/local/share/bison/bison.simple"
237 246
238/* Skeleton output parser for bison, 247/* Skeleton output parser for bison,
239 248
@@ -301,12 +310,6 @@ static const short yycheck[] =
301# define YYSTACK_ALLOC malloc 310# define YYSTACK_ALLOC malloc
302# define YYSTACK_FREE free 311# define YYSTACK_FREE free
303# endif 312# endif
304#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
305
306
307#if (! defined (yyoverflow) \
308 && (! defined (__cplusplus) \
309 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
310 313
311/* A type that is properly aligned for any stack member. */ 314/* A type that is properly aligned for any stack member. */
312union yyalloc 315union yyalloc
@@ -333,41 +336,24 @@ union yyalloc
333 + YYSTACK_GAP_MAX) 336 + YYSTACK_GAP_MAX)
334# endif 337# endif
335 338
336/* Copy COUNT objects from FROM to TO. The source and destination do 339/* Relocate the TYPE STACK from its old location to the new one. The
337 not overlap. */
338# ifndef YYCOPY
339# if 1 < __GNUC__
340# define YYCOPY(To, From, Count) \
341 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
342# else
343 # define YYCOPY(To, From, Count) \
344 do \
345 { \
346 register YYSIZE_T yyi; \
347 for (yyi = 0; yyi < (Count); yyi++)\
348 (To)[yyi] = (From)[yyi]; \
349 } \
350 while (0)
351# endif
352# endif
353
354/* Relocate STACK from its old location to the new one. The
355 local variables YYSIZE and YYSTACKSIZE give the old and new number of 340 local variables YYSIZE and YYSTACKSIZE give the old and new number of
356 elements in the stack, and YYPTR gives the new location of the 341 elements in the stack, and YYPTR gives the new location of the
357 stack. Advance YYPTR to a properly aligned location for the next 342 stack. Advance YYPTR to a properly aligned location for the next
358 stack. */ 343 stack. */
359 # define YYSTACK_RELOCATE(Stack) \ 344 # define YYSTACK_RELOCATE(Type, Stack) \
360 do \ 345 do \
361 { \ 346 { \
362 YYSIZE_T yynewbytes; \ 347 YYSIZE_T yynewbytes; \
363 YYCOPY (&yyptr->Stack, Stack, yysize); \ 348 yymemcpy ((char *) yyptr, (char *) (Stack), \
349 yysize * (YYSIZE_T) sizeof (Type)); \
364 Stack = &yyptr->Stack; \ 350 Stack = &yyptr->Stack; \
365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;\ 351 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;\
366 yyptr += yynewbytes / sizeof (*yyptr); \ 352 yyptr += yynewbytes / sizeof (*yyptr); \
367 } \ 353 } \
368 while (0) 354 while (0)
369 355
370#endif 356#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
371 357
372 358
373#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 359#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -494,6 +480,33 @@ int yydebug;
494# define YYMAXDEPTH 10000 480# define YYMAXDEPTH 10000
495#endif 481#endif
496 482
483#if ! defined (yyoverflow) && ! defined (yymemcpy)
484 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
485# define yymemcpy __builtin_memcpy
486 # else /* not GNU C or C++ */
487
488/* This is the most reliable way to avoid incompatibilities
489 in available built-in functions on various systems. */
490static void
491# if defined (__STDC__) || defined (__cplusplus)
492yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
493# else
494yymemcpy (yyto, yyfrom, yycount)
495 char *yyto;
496 const char *yyfrom;
497 YYSIZE_T yycount;
498# endif
499{
500 register const char *yyf = yyfrom;
501 register char *yyt = yyto;
502 register YYSIZE_T yyi = yycount;
503
504 while (yyi-- != 0)
505 *yyt++ = *yyf++;
506}
507# endif
508#endif
509
497#ifdef YYERROR_VERBOSE 510#ifdef YYERROR_VERBOSE
498 511
499# ifndef yystrlen 512# ifndef yystrlen
@@ -546,7 +559,7 @@ yystpcpy (yydest, yysrc)
546# endif 559# endif
547#endif 560#endif
548 561
549#line 315 "/usr/share/bison/bison.simple" 562#line 319 "/usr/local/share/bison/bison.simple"
550 563
551 564
552/* The user can define YYPARSE_PARAM as the name of an argument to be passed 565/* The user can define YYPARSE_PARAM as the name of an argument to be passed
@@ -736,9 +749,6 @@ yyparse (YYPARSE_PARAM_ARG)
736 yyvs = yyvs1; 749 yyvs = yyvs1;
737 } 750 }
738#else /* no yyoverflow */ 751#else /* no yyoverflow */
739# ifndef YYSTACK_RELOCATE
740 goto yyoverflowlab;
741# else
742 /* Extend the stack our own way. */ 752 /* Extend the stack our own way. */
743 if (yystacksize >= YYMAXDEPTH) 753 if (yystacksize >= YYMAXDEPTH)
744 goto yyoverflowlab; 754 goto yyoverflowlab;
@@ -752,16 +762,15 @@ yyparse (YYPARSE_PARAM_ARG)
752 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 762 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
753 if (! yyptr) 763 if (! yyptr)
754 goto yyoverflowlab; 764 goto yyoverflowlab;
755 YYSTACK_RELOCATE (yyss); 765 YYSTACK_RELOCATE (short, yyss);
756 YYSTACK_RELOCATE (yyvs); 766 YYSTACK_RELOCATE (YYSTYPE, yyvs);
757# if YYLSP_NEEDED 767# if YYLSP_NEEDED
758 YYSTACK_RELOCATE (yyls); 768 YYSTACK_RELOCATE (YYLTYPE, yyls);
759# endif 769# endif
760# undef YYSTACK_RELOCATE 770# undef YYSTACK_RELOCATE
761 if (yyss1 != yyssa) 771 if (yyss1 != yyssa)
762 YYSTACK_FREE (yyss1); 772 YYSTACK_FREE (yyss1);
763 } 773 }
764# endif
765#endif /* no yyoverflow */ 774#endif /* no yyoverflow */
766 775
767 yyssp = yyss + yysize - 1; 776 yyssp = yyss + yysize - 1;
@@ -939,68 +948,76 @@ yyreduce:
939 948
940 switch (yyn) { 949 switch (yyn) {
941 950
942case 2: 951case 3:
943#line 64 "icalssyacc.y" 952#line 69 "icalssyacc.y"
944{ 953{
945 icalparser_clear_flex_input();
946 yyclearin; 954 yyclearin;
955 YYABORT;
947 } 956 }
948 break; 957 break;
949case 3:
950#line 71 "icalssyacc.y"
951{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
952 break;
953case 4: 958case 4:
954#line 72 "icalssyacc.y" 959#line 76 "icalssyacc.y"
955{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);} 960{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
956 break; 961 break;
957case 5: 962case 5:
958#line 77 "icalssyacc.y" 963#line 77 "icalssyacc.y"
959{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} 964{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
960 break; 965 break;
961case 6: 966case 6:
962#line 78 "icalssyacc.y" 967#line 82 "icalssyacc.y"
963{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} 968{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
964 break; 969 break;
965case 8: 970case 7:
966#line 83 "icalssyacc.y" 971#line 83 "icalssyacc.y"
967{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); } 972{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
968 break; 973 break;
969case 9: 974case 9:
970#line 85 "icalssyacc.y" 975#line 88 "icalssyacc.y"
971{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); } 976{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); }
972 break; 977 break;
973case 10: 978case 10:
974#line 86 "icalssyacc.y" 979#line 89 "icalssyacc.y"
975{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); } 980{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_ISNULL,""); }
976 break; 981 break;
977case 11: 982case 11:
978#line 87 "icalssyacc.y" 983#line 90 "icalssyacc.y"
979{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); } 984{ssyacc_add_where(yyextra,yyvsp[-3].v_string,ICALGAUGECOMPARE_ISNOTNULL,""); }
980 break; 985 break;
981case 12: 986case 12:
982#line 88 "icalssyacc.y" 987#line 91 "icalssyacc.y"
983{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); } 988{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); }
984 break; 989 break;
985case 13: 990case 13:
986#line 89 "icalssyacc.y" 991#line 92 "icalssyacc.y"
987{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); } 992{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); }
988 break; 993 break;
989case 14: 994case 14:
990#line 93 "icalssyacc.y" 995#line 93 "icalssyacc.y"
991{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);} 996{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); }
992 break; 997 break;
993case 15: 998case 15:
994#line 94 "icalssyacc.y" 999#line 94 "icalssyacc.y"
995{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);} 1000{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); }
996 break; 1001 break;
997case 16: 1002case 16:
998#line 95 "icalssyacc.y" 1003#line 95 "icalssyacc.y"
999{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} 1004{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); }
1005 break;
1006case 17:
1007#line 99 "icalssyacc.y"
1008{set_logic(yyextra,ICALGAUGELOGIC_NONE);}
1009 break;
1010case 18:
1011#line 100 "icalssyacc.y"
1012{set_logic(yyextra,ICALGAUGELOGIC_AND);}
1013 break;
1014case 19:
1015#line 101 "icalssyacc.y"
1016{set_logic(yyextra,ICALGAUGELOGIC_OR);}
1000 break; 1017 break;
1001} 1018}
1002 1019
1003#line 705 "/usr/share/bison/bison.simple" 1020#line 705 "/usr/local/share/bison/bison.simple"
1004 1021
1005 1022
1006 yyvsp -= yylen; 1023 yyvsp -= yylen;
@@ -1231,10 +1248,10 @@ yyreturn:
1231#endif 1248#endif
1232 return yyresult; 1249 return yyresult;
1233} 1250}
1234#line 99 "icalssyacc.y" 1251#line 105 "icalssyacc.y"
1235 1252
1236 1253
1237void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, 1254static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1238 icalgaugecompare compare , char* value_str) 1255 icalgaugecompare compare , char* value_str)
1239{ 1256{
1240 1257
@@ -1296,7 +1313,7 @@ void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1296 pvl_push(impl->where,where); 1313 pvl_push(impl->where,where);
1297} 1314}
1298 1315
1299void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) 1316static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1300{ 1317{
1301 pvl_elem e = pvl_tail(impl->where); 1318 pvl_elem e = pvl_tail(impl->where);
1302 struct icalgauge_where *where = pvl_data(e); 1319 struct icalgauge_where *where = pvl_data(e);
@@ -1307,7 +1324,7 @@ void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1307 1324
1308 1325
1309 1326
1310void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) 1327static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1311{ 1328{
1312 char *c, *compstr, *propstr; 1329 char *c, *compstr, *propstr;
1313 struct icalgauge_where *where; 1330 struct icalgauge_where *where;
@@ -1353,15 +1370,15 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1353 1370
1354 1371
1355 if(where->prop == ICAL_NO_PROPERTY){ 1372 if(where->prop == ICAL_NO_PROPERTY){
1356 icalgauge_free(where); 1373 free(where);
1357 icalerror_set_errno(ICAL_BADARG_ERROR); 1374 icalerror_set_errno(ICAL_BADARG_ERROR);
1358 return; 1375 return;
1359 } 1376 }
1360 1377
1361 pvl_push(impl->select,where); 1378 pvl_push(impl->select,where);
1362} 1379}
1363 1380
1364void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) 1381static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1365{ 1382{
1366 icalcomponent_kind ckind; 1383 icalcomponent_kind ckind;
1367 1384
@@ -1377,5 +1394,6 @@ void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1377 1394
1378 1395
1379void sserror(char *s){ 1396void sserror(char *s){
1380 fprintf(stderr,"Parse error \'%s\'\n", s); 1397 fprintf(stderr,"Parse error \'%s\'\n", s);
1398 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1381} 1399}
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 @@
1#ifndef BISON_ICALSSYACC_H 1#ifndef BISON_Y_TAB_H
2# define BISON_ICALSSYACC_H 2# define BISON_Y_TAB_H
3 3
4#ifndef YYSTYPE 4#ifndef YYSTYPE
5typedef union { 5typedef union {
6 char* v_string; 6 char* v_string;
7} yystype; 7} yystype;
8# define YYSTYPE yystype 8# define YYSTYPE yystype
9# define YYSTYPE_IS_TRIVIAL 1
10#endif 9#endif
11 # define STRING257 10 # define STRING257
12 # define SELECT258 11 # define SELECT258
@@ -24,8 +23,9 @@ typedef union {
24 # define OR270 23 # define OR270
25 # define EOL271 24 # define EOL271
26 # define END272 25 # define END272
26 # define IS273
27 # define NOT274
28 # define SQLNULL275
27 29
28 30
29extern YYSTYPE sslval; 31#endif /* not BISON_Y_TAB_H */
30
31#endif /* not BISON_ICALSSYACC_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 @@
1include(../../../variables.pri) 1######################################################################
2# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
3######################################################################
4
2 5
3 TEMPLATE= lib 6 TEMPLATE= lib
4 7
5TARGET = icalss 8TARGET = icalss
6DESTDIR = ../../lib 9DESTDIR = ../../lib
7 CONFIG += staticlib 10 CONFIG += staticlib
8win32: DEFINES += _WIN32 _QTWIN_
9 HEADERS = icalcalendar.h \
10 icalclassify.h \
11 icalcstp.h \
12 icalcstpclient.h \
13 icalcstpserver.h \
14 icaldirset.h \
15 icaldirsetimpl.h \
16 icalfileset.h \
17 icalfilesetimpl.h \
18 icalgauge.h \
19 icalgaugeimpl.h \
20 icalmessage.h \
21 icalset.h \
22 icalspanlist.h \
23 icalssyacc.h \
24 config.h
25
26 SOURCES = icalclassify.c \
27 icalcstp.c \
28 icalcstpclient.c \
29 icalcstpserver.c \
30 icaldirset.c \
31 icalfileset.c \
32 icalgauge.c \
33 icalmessage.c \
34 icalset.c \
35 icalspanlist.c \
36 icalsslexer.c \
37 icalssyacc.c
38
39 INTERFACES=
40 11
41INCLUDEPATH += ../libical 12INCLUDEPATH += . ../libical
13# Input
14win32 {
15DEFINES += YY_NO_UNISTD_H
42 16
43DEFINES += HAVE_CONFIG_H 17}
18HEADERS += icalcalendar.h \
19 icalclassify.h \
20 icalcluster.h \
21 icalclusterimpl.h \
22 icaldirset.h \
23 icaldirsetimpl.h \
24 icalfileset.h \
25 icalfilesetimpl.h \
26 icalgauge.h \
27 icalgaugeimpl.h \
28 icalmessage.h \
29 icalset.h \
30 icalspanlist.h \
31 icalss.h \
32 icalssyacc.h
33SOURCES += icalcalendar.c \
34 icalclassify.c \
35 icalcluster.c \
36 icaldirset.c \
37 icalfileset.c \
38 icalgauge.c \
39 icalmessage.c \
40 icalset.c \
41 icalspanlist.c \
42 icalsslexer.c \
43 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 @@
1 TEMPLATE= lib 1######################################################################
2 CONFIG += warn_on staticlib 2# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
3INCLUDEPATH += ../libical 3######################################################################
4INCLUDEPATH += .
5DEFINES += HAVE_CONFIG_H
6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=../../lib/$(PLATFORM)
9TARGET = icalss
10 4
11INTERFACES = \
12 5
13HEADERS = \ 6 TEMPLATE= lib
14 config.h \
15 icalcalendar.h \
16 icalclassify.h \
17 icalcstp.h \
18 icalcstpclient.h \
19 icalcstpserver.h \
20 icaldirset.h \
21 icaldirsetimpl.h \
22 icalfileset.h \
23 icalfilesetimpl.h \
24 icalgauge.h \
25 icalgaugeimpl.h \
26 icalmessage.h \
27 icalset.h \
28 icalspanlist.h \
29 icalss.h \
30 icalssyacc.h \
31 7
32SOURCES = \ 8TARGET = icalss
33 icalclassify.c \ 9 CONFIG += staticlib
34 icalcstp.c \
35 icalcstpclient.c \
36 icalcstpserver.c \
37 icaldirset.c \
38 icalfileset.c \
39 icalgauge.c \
40 icalmessage.c \
41 icalset.c \
42 icalspanlist.c \
43 icalsslexer.c \
44 icalssyacc.c \
45 10
11OBJECTS_DIR = obj/$(PLATFORM)
12MOC_DIR = moc/$(PLATFORM)
13DESTDIR=../../lib/$(PLATFORM)
14INCLUDEPATH += . ../libical
15# Input
16HEADERS += icalcalendar.h \
17 icalclassify.h \
18 icalcluster.h \
19 icalclusterimpl.h \
20 icaldirset.h \
21 icaldirsetimpl.h \
22 icalfileset.h \
23 icalfilesetimpl.h \
24 icalgauge.h \
25 icalgaugeimpl.h \
26 icalmessage.h \
27 icalset.h \
28 icalspanlist.h \
29 icalss.h \
30 icalssyacc.h
31SOURCES += icalcalendar.c \
32 icalclassify.c \
33 icalcluster.c \
34 icaldirset.c \
35 icalfileset.c \
36 icalgauge.c \
37 icalmessage.c \
38 icalset.c \
39 icalspanlist.c \
40 icalsslexer.c \
41 icalssyacc.c