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/config.h7
-rw-r--r--libical/src/libicalss/icalcalendar.h67
-rw-r--r--libical/src/libicalss/icalclassify.c792
-rw-r--r--libical/src/libicalss/icalclassify.h77
-rw-r--r--libical/src/libicalss/icalcstp.c122
-rw-r--r--libical/src/libicalss/icalcstp.h79
-rw-r--r--libical/src/libicalss/icalcstpclient.c350
-rw-r--r--libical/src/libicalss/icalcstpclient.h100
-rw-r--r--libical/src/libicalss/icalcstpserver.c285
-rw-r--r--libical/src/libicalss/icalcstpserver.h101
-rw-r--r--libical/src/libicalss/icaldirset.c777
-rw-r--r--libical/src/libicalss/icaldirset.h82
-rw-r--r--libical/src/libicalss/icaldirsetimpl.h47
-rw-r--r--libical/src/libicalss/icalfileset.c659
-rw-r--r--libical/src/libicalss/icalfileset.h107
-rw-r--r--libical/src/libicalss/icalfilesetimpl.h49
-rw-r--r--libical/src/libicalss/icalgauge.c447
-rw-r--r--libical/src/libicalss/icalgauge.h51
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h63
-rw-r--r--libical/src/libicalss/icalmessage.c373
-rw-r--r--libical/src/libicalss/icalmessage.h71
-rw-r--r--libical/src/libicalss/icalset.c367
-rw-r--r--libical/src/libicalss/icalset.h111
-rw-r--r--libical/src/libicalss/icalspanlist.c309
-rw-r--r--libical/src/libicalss/icalspanlist.h54
-rw-r--r--libical/src/libicalss/icalss.h885
-rw-r--r--libical/src/libicalss/icalsslexer.c1713
-rw-r--r--libical/src/libicalss/icalsslexer.l113
-rw-r--r--libical/src/libicalss/icalssyacc.c1381
-rw-r--r--libical/src/libicalss/icalssyacc.h31
-rw-r--r--libical/src/libicalss/icalssyacc.y245
-rw-r--r--libical/src/libicalss/libicalss.pro43
-rw-r--r--libical/src/libicalss/libicalssE.pro45
33 files changed, 10003 insertions, 0 deletions
diff --git a/libical/src/libicalss/config.h b/libical/src/libicalss/config.h
new file mode 100644
index 0000000..fa66c47
--- a/dev/null
+++ b/libical/src/libicalss/config.h
@@ -0,0 +1,7 @@
1#ifndef LIBICALSS_CONFIG_H
2#define LIBICALSS_CONFIG_H
3
4#define PACKAGE "libicalss"
5#define VERSION "0.23"
6
7#endif
diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h
new file mode 100644
index 0000000..f07457c
--- a/dev/null
+++ b/libical/src/libicalss/icalcalendar.h
@@ -0,0 +1,67 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcalendar.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 ICALCALENDAR_H
30#define ICALCALENDAR_H
31
32#include "ical.h"
33#include "icalset.h"
34
35/* icalcalendar
36 * Routines for storing calendar data in a file system. The calendar
37 * has two icaldirsets, one for incoming components and one for booked
38 * components. It also has interfaces to access the free/busy list
39 * and a list of calendar properties */
40
41typedef void icalcalendar;
42
43icalcalendar* icalcalendar_new(char* dir);
44
45void icalcalendar_free(icalcalendar* calendar);
46
47int icalcalendar_lock(icalcalendar* calendar);
48
49int icalcalendar_unlock(icalcalendar* calendar);
50
51int icalcalendar_islocked(icalcalendar* calendar);
52
53int icalcalendar_ownlock(icalcalendar* calendar);
54
55icalset* icalcalendar_get_booked(icalcalendar* calendar);
56
57icalset* icalcalendar_get_incoming(icalcalendar* calendar);
58
59icalset* icalcalendar_get_properties(icalcalendar* calendar);
60
61icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
62
63
64#endif /* !ICALCALENDAR_H */
65
66
67
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c
new file mode 100644
index 0000000..c029309
--- a/dev/null
+++ b/libical/src/libicalss/icalclassify.c
@@ -0,0 +1,792 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalclassify.c
4 CREATOR: ebusboom 23 aug 2000
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "icalerror.h"
30#include "ical.h"
31#include "icalclassify.h"
32#include "icalmemory.h"
33#include <ctype.h> /* For tolower() */
34#include <string.h> /* for index() */
35#include <stdlib.h> /* for malloc and free */
36
37
38
39struct icalclassify_parts {
40 icalcomponent *c;
41 icalcomponent_kind inner_kind;
42 icalproperty_method method;
43 char* organizer;
44 icalparameter_partstat reply_partstat;
45 char* reply_attendee;
46 char* uid;
47 int sequence;
48 struct icaltimetype dtstamp;
49 struct icaltimetype recurrence_id;
50};
51
52
53char* icalclassify_lowercase(const char* str)
54{
55 char* p = 0;
56 char* new = icalmemory_strdup(str);
57
58 if(str ==0){
59 return 0;
60 }
61
62 for(p = new; *p!=0; p++){
63 *p = tolower(*p);
64 }
65
66 return new;
67}
68
69/* Return a set of components that intersect in time with comp. For
70component X and Y to intersect:
71 X.DTSTART < Y.DTEND && X.DTEND > Y.DTSTART
72*/
73
74
75icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp)
76{
77 icalcomponent *return_set;
78 icalcomponent *c;
79 struct icaltime_span span,compspan;
80
81 icalerror_clear_errno();
82 compspan = icalcomponent_get_span(comp);
83
84 if(icalerrno != ICAL_NO_ERROR){
85 return 0;
86 }
87
88
89 return_set = icalcomponent_new(ICAL_XROOT_COMPONENT);
90
91 for(c = icalset_get_first_component(set);
92 c != 0;
93 c = icalset_get_next_component(set)){
94
95 icalerror_clear_errno();
96
97 span = icalcomponent_get_span(c);
98
99 if(icalerrno != ICAL_NO_ERROR){
100 continue;
101 }
102
103 if (compspan.start < span.end &&
104 compspan.end > span.start){
105
106 icalcomponent *clone = icalcomponent_new_clone(c);
107
108 icalcomponent_add_component(return_set,clone);
109 }
110 }
111
112 if(icalcomponent_count_components(return_set,ICAL_ANY_COMPONENT) !=0){
113 return return_set;
114 } else {
115 icalcomponent_free(return_set);
116 return 0;
117 }
118}
119
120
121
122icalproperty* icalclassify_find_attendee(icalcomponent *c,
123 const char* attendee)
124{
125 icalproperty *p;
126 icalcomponent* inner;
127 char* lattendee;
128 char* upn;
129
130 if(attendee == 0){
131 return 0;
132 }
133
134 lattendee = icalclassify_lowercase(attendee);
135 upn = strchr(lattendee,':');
136
137 if (upn== 0){
138 upn = lattendee;
139 } else {
140 upn++; /* skip the ";"*/
141 }
142
143 inner = icalcomponent_get_first_real_component(c);
144
145 for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
146 p != 0;
147 p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY))
148 {
149 const char* this_attendee
150 = icalclassify_lowercase(icalproperty_get_attendee(p));
151 char* this_upn = strchr(this_attendee,':');
152
153 if(this_upn == 0){
154 continue;
155 } else {
156 this_upn++;
157 }
158
159 if(strcmp(this_upn,upn)==0){
160 return p;
161 }
162
163 }
164
165 return 0;
166
167}
168
169void icalssutil_free_parts(struct icalclassify_parts *parts)
170{
171 if(parts == 0){
172 return;
173 }
174
175 if(parts->organizer != 0){
176 free(parts->organizer);
177 }
178
179 if(parts->uid != 0){
180 free(parts->uid);
181 }
182
183 if(parts->reply_attendee){
184 free(parts->reply_attendee);
185 }
186}
187
188void icalssutil_get_parts(icalcomponent* c,
189 struct icalclassify_parts* parts)
190{
191 icalproperty *p;
192 icalcomponent *inner;
193
194 memset(parts,0,sizeof(struct icalclassify_parts));
195
196 parts->method = ICAL_METHOD_NONE;
197 parts->sequence = 0;
198 parts->reply_partstat = ICAL_PARTSTAT_NONE;
199
200 if(c == 0){
201 return;
202 }
203
204 parts->c = c;
205
206 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
207 if(p!=0){
208 parts->method = icalproperty_get_method(p);
209 }
210
211 inner = icalcomponent_get_first_real_component(c);
212
213 parts->inner_kind = icalcomponent_isa(inner);
214
215 p = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY);
216 if(p!=0){
217 parts->organizer = strdup(icalproperty_get_organizer(p));
218 }
219
220 p = icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY);
221 if(p!=0){
222 parts->sequence = icalproperty_get_sequence(p);
223 }
224
225 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
226 if(p!=0){
227 parts->uid = strdup(icalproperty_get_uid(p));
228 }
229
230 p = icalcomponent_get_first_property(inner,ICAL_RECURRENCEID_PROPERTY);
231 if(p!=0){
232 parts->recurrence_id = icalproperty_get_recurrenceid(p);
233 }
234
235 p = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
236 if(p!=0){
237 parts->dtstamp = icalproperty_get_dtstamp(p);
238 }
239
240 if(parts->method==ICAL_METHOD_REPLY){
241 icalparameter *param;
242 p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
243
244 if(p!=0){
245
246 param = icalproperty_get_first_parameter(p,ICAL_PARTSTAT_PARAMETER);
247
248 if(param != 0){
249 parts->reply_partstat =
250 icalparameter_get_partstat(param);
251 }
252
253 parts->reply_attendee = strdup(icalproperty_get_attendee(p));
254 }
255
256 }
257
258
259}
260
261
262int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b)
263{
264 icalproperty *p1,*p2;
265 icalcomponent *i1,*i2;
266 int i;
267
268 icalproperty_kind kind_array[] = {
269 ICAL_DTSTART_PROPERTY,
270 ICAL_DTEND_PROPERTY,
271 ICAL_DURATION_PROPERTY,
272 ICAL_DUE_PROPERTY,
273 ICAL_RRULE_PROPERTY,
274 ICAL_RDATE_PROPERTY,
275 ICAL_EXRULE_PROPERTY,
276 ICAL_EXDATE_PROPERTY,
277 ICAL_NO_PROPERTY
278 };
279
280 i1 = icalcomponent_get_first_real_component(a);
281 i2 = icalcomponent_get_first_real_component(b);
282
283 for(i =0; kind_array[i] != ICAL_NO_PROPERTY; i++){
284 p1 = icalcomponent_get_first_property(i1,kind_array[i]);
285 p2 = icalcomponent_get_first_property(i2,kind_array[i]);
286
287 if( (p1!=0)^(p1!=0) ){
288 /* Return true if the property exists in one component and not
289 the other */
290 return 1;
291 }
292
293 if(p1 && strcmp(icalproperty_as_ical_string(p1),
294 icalproperty_as_ical_string(p2)) != 0){
295 return 1;
296 }
297 }
298
299 return 0;
300
301}
302
303#define icalclassify_pre \
304 int rtrn =0;
305
306#define icalclassify_post \
307 return rtrn;
308
309
310int icalclassify_publish_new(struct icalclassify_parts *comp,
311 struct icalclassify_parts *match,
312 const char* user)
313{
314 icalclassify_pre;
315
316 if(comp->method == ICAL_METHOD_PUBLISH &&
317 match == 0 && comp->inner_kind != ICAL_VFREEBUSY_COMPONENT){
318 rtrn = 1;
319 }
320
321 icalclassify_post;
322
323}
324
325int icalclassify_publish_update(struct icalclassify_parts *comp,
326 struct icalclassify_parts *match,
327 const char* user)
328{
329 icalclassify_pre;
330
331 if(comp->method == ICAL_METHOD_PUBLISH &&
332 match !=0 && comp->inner_kind != ICAL_VFREEBUSY_COMPONENT){
333 rtrn = 1;
334 }
335
336 icalclassify_post;
337
338}
339
340int icalclassify_publish_freebusy(struct icalclassify_parts *comp,
341 struct icalclassify_parts *match,
342 const char* user)
343{
344 icalclassify_pre;
345
346 if(comp->method == ICAL_METHOD_PUBLISH &&
347 comp->inner_kind == ICAL_VFREEBUSY_COMPONENT){
348 rtrn = 1;
349 }
350
351 icalclassify_post;
352
353}
354
355
356int icalclassify_request_new(struct icalclassify_parts *comp,
357 struct icalclassify_parts *match,
358 const char* user)
359{
360 /* Method is REQUEST, and there is no match */
361
362 icalclassify_pre
363
364 if(match->c==0 && comp->method == ICAL_METHOD_REQUEST){
365 rtrn = 1;
366 }
367
368 icalclassify_post
369
370}
371
372int icalclassify_request_update(
373 struct icalclassify_parts *comp,
374 struct icalclassify_parts *match,
375 const char* user)
376{
377 /* REQUEST method, Higher SEQUENCE than match, and all
378 time-related properties are unchanged */
379
380 icalclassify_pre
381
382 if (match != 0 &&
383 comp->sequence >= match->sequence &&
384 !icalssutil_is_rescheduled(comp->c,match->c)){
385 rtrn = 1;
386 }
387
388 icalclassify_post
389
390}
391
392int icalclassify_request_reschedule(
393 struct icalclassify_parts *comp,
394 struct icalclassify_parts *match,
395 const char* user)
396{
397 /* REQUEST method, Higher SEQUENCE than match, and one or more
398 time-related properties are changed */
399 icalclassify_pre
400
401 if (match->c != 0 &&
402 comp->sequence > match->sequence &&
403 icalssutil_is_rescheduled(comp->c,match->c)){
404 rtrn = 1;
405 }
406
407 icalclassify_post
408
409}
410
411int icalclassify_request_delegate(
412 struct icalclassify_parts *comp,
413 struct icalclassify_parts *match,
414 const char* user)
415{
416 icalproperty* attendee;
417 icalparameter* param;
418 icalclassify_pre;
419
420 attendee = icalclassify_find_attendee(comp->c,user);
421
422 if(attendee == 0){
423 return 0;
424 }
425
426 param = icalproperty_get_first_parameter(attendee,ICAL_DELEGATEDFROM_PARAMETER);
427
428 if (param != 0){
429 rtrn = 1;
430 }
431
432 icalclassify_post
433
434}
435
436int icalclassify_request_new_organizer(
437 struct icalclassify_parts *comp,
438 struct icalclassify_parts *match,
439 const char* user)
440{
441 /* Organizer has changed between match and component */
442 icalclassify_pre
443 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
444 icalclassify_post
445
446}
447
448int icalclassify_request_status(
449 struct icalclassify_parts *comp,
450 struct icalclassify_parts *match,
451 const char* user)
452{
453 icalclassify_pre
454 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
455 icalclassify_post
456}
457
458int icalclassify_request_forward(
459 struct icalclassify_parts *comp,
460 struct icalclassify_parts *match,
461 const char* user)
462{
463 icalclassify_pre
464 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
465 icalclassify_post
466}
467
468int icalclassify_request_freebusy(
469 struct icalclassify_parts *comp,
470 struct icalclassify_parts *match,
471 const char* user)
472{
473 icalclassify_pre
474 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
475 icalclassify_post
476}
477
478int icalclassify_reply_accept(
479 struct icalclassify_parts *comp,
480 struct icalclassify_parts *match,
481 const char* user)
482{
483 icalproperty* attendee;
484 icalclassify_pre;
485
486 attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
487
488 if(attendee != 0&&
489 comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){
490 rtrn = 1;
491 }
492
493 icalclassify_post
494}
495int icalclassify_reply_decline(
496 struct icalclassify_parts *comp,
497 struct icalclassify_parts *match,
498 const char* user)
499{
500 icalproperty* attendee;
501 icalclassify_pre;
502
503 attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
504
505
506 if( attendee != 0 &&
507 comp->reply_partstat == ICAL_PARTSTAT_DECLINED){
508 rtrn = 1;
509 }
510 icalclassify_post
511}
512int icalclassify_reply_delegate(
513 struct icalclassify_parts *comp,
514 struct icalclassify_parts *match,
515 const char* user)
516{
517 icalproperty* attendee;
518 icalclassify_pre;
519
520 attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
521
522 if( attendee != 0 &&
523 comp->reply_partstat == ICAL_PARTSTAT_DELEGATED){
524 rtrn = 1;
525 }
526 icalclassify_post
527}
528int icalclassify_reply_crasher_accept(
529 struct icalclassify_parts *comp,
530 struct icalclassify_parts *match,
531 const char* user)
532{
533 icalproperty* attendee;
534 icalclassify_pre;
535
536 attendee= icalclassify_find_attendee(match->c,comp->reply_attendee);
537
538 if(attendee == 0 &&
539 comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){
540 rtrn = 1;
541 }
542 icalclassify_post
543}
544int icalclassify_reply_crasher_decline(
545 struct icalclassify_parts *comp,
546 struct icalclassify_parts *match,
547 const char* user)
548{
549 icalparameter_partstat partstat;
550 icalproperty* attendee;
551 icalclassify_pre;
552
553
554 attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
555
556 if(attendee == 0 &&
557 comp->reply_partstat == ICAL_PARTSTAT_DECLINED){
558 rtrn = 1;
559 }
560 icalclassify_post
561}
562int icalclassify_add_instance(
563 struct icalclassify_parts *comp,
564 struct icalclassify_parts *match,
565 const char* user)
566{
567 icalclassify_pre
568 if(comp->method == ICAL_METHOD_ADD){
569 rtrn = 1;
570 }
571 icalclassify_post
572}
573int icalclassify_cancel_event(
574 struct icalclassify_parts *comp,
575 struct icalclassify_parts *match,
576 const char* user)
577{
578 icalclassify_pre
579 if(comp->method == ICAL_METHOD_CANCEL){
580 rtrn = 1;
581 }
582 icalclassify_post
583}
584int icalclassify_cancel_instance(
585 struct icalclassify_parts *comp,
586 struct icalclassify_parts *match,
587 const char* user)
588{
589 icalclassify_pre
590 if(comp->method == ICAL_METHOD_CANCEL){
591 rtrn = 1;
592 }
593 icalclassify_post
594}
595int icalclassify_cancel_all(
596 struct icalclassify_parts *comp,
597 struct icalclassify_parts *match,
598 const char* user)
599{
600 icalclassify_pre
601 if(comp->method == ICAL_METHOD_CANCEL){
602 rtrn = 1;
603 }
604 icalclassify_post
605}
606int icalclassify_refesh(
607 struct icalclassify_parts *comp,
608 struct icalclassify_parts *match,
609 const char* user)
610{
611 icalclassify_pre
612 if(comp->method == ICAL_METHOD_REFRESH){
613 rtrn = 1;
614 }
615 icalclassify_post
616}
617int icalclassify_counter(
618 struct icalclassify_parts *comp,
619 struct icalclassify_parts *match,
620 const char* user)
621{
622 icalclassify_pre
623 if(comp->method == ICAL_METHOD_COUNTER){
624 rtrn = 1;
625 }
626 icalclassify_post
627}
628int icalclassify_delinecounter(
629 struct icalclassify_parts *comp,
630 struct icalclassify_parts *match,
631 const char* user)
632{
633 icalclassify_pre
634
635 if(comp->method == ICAL_METHOD_DECLINECOUNTER){
636 rtrn = 1;
637 }
638
639 icalclassify_post
640}
641
642struct icalclassify_map {
643 icalproperty_method method;
644 int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user);
645 ical_class class;
646} icalclassify_map[] =
647{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS},
648 {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS},
649 {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS},
650 {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS},
651 {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS},
652 {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS},
653 {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS},
654
655 {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS},
656 {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS},
657 {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS},
658 {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS},
659
660 {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS},
661 {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS},
662 {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_REPLY_DELEGATE_CLASS},
663 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS},
664 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS},
665
666 {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS},
667
668 {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS},
669 {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS},
670 {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS},
671
672 {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS},
673 {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS},
674 {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS},
675 {ICAL_METHOD_NONE,0,ICAL_NO_CLASS}
676};
677
678
679ical_class icalclassify(icalcomponent* c,icalcomponent* match,
680 const char* user)
681{
682 icalcomponent *inner;
683 icalproperty *p;
684 icalproperty_method method;
685 ical_class class = ICAL_UNKNOWN_CLASS;
686
687 int i;
688
689 struct icalclassify_parts comp_parts;
690 struct icalclassify_parts match_parts;
691
692 inner = icalcomponent_get_first_real_component(c);
693
694 if (inner == 0) {
695 return ICAL_NO_CLASS;
696 }
697
698 icalssutil_get_parts(c,&comp_parts);
699 icalssutil_get_parts(match,&match_parts);
700
701 /* Determine if the incoming component is obsoleted by the match */
702 if(match != 0 && (
703 comp_parts.method == ICAL_METHOD_REQUEST
704 )){
705 assert ( ! ((comp_parts.dtstamp.is_utc==1)^
706 (match_parts.dtstamp.is_utc==1)));
707
708 if( comp_parts.sequence<match_parts.sequence &&
709 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
710 {
711 /* comp has a smaller sequence and a later DTSTAMP */
712 return ICAL_MISSEQUENCED_CLASS;
713 }
714
715 if( (comp_parts.sequence<match_parts.sequence )
716 /*&&icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0*/
717 ||
718 ( comp_parts.sequence == match_parts.sequence &&
719 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){
720
721 return ICAL_OBSOLETE_CLASS;
722 }
723
724 }
725
726 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
727 if (p == 0) {
728 return ICAL_UNKNOWN_CLASS;
729 }
730 method = icalproperty_get_method(p);
731
732 for (i =0; icalclassify_map[i].method != ICAL_METHOD_NONE; i++){
733 if(icalclassify_map[i].method == method){
734 if( (*(icalclassify_map[i].fn))(&comp_parts,&match_parts,user)==1){
735 class = icalclassify_map[i].class;
736 break;
737 }
738 }
739 }
740
741 icalssutil_free_parts(&comp_parts);
742 icalssutil_free_parts(&match_parts);
743
744 return class;
745
746}
747
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
new file mode 100644
index 0000000..81188b3
--- a/dev/null
+++ b/libical/src/libicalss/icalclassify.h
@@ -0,0 +1,77 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalclassify.h
4 CREATOR: eric 21 Aug 2000
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
24 =========================================================================*/
25
26#ifndef ICALCLASSIFY_H
27#define ICALCLASSIFY_H
28
29#include "ical.h"
30#include "icalset.h"
31
32
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);
66
67icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
68
69char* icalclassify_class_to_string(ical_class iclass);
70
71
72#endif /* ICALCLASSIFY_H*/
73
74
75
76
77
diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c
new file mode 100644
index 0000000..ed62b40
--- a/dev/null
+++ b/libical/src/libicalss/icalcstp.c
@@ -0,0 +1,122 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalcstps.c
4 CREATOR: ebusboom 23 Jun 2000
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "ical.h"
30#include "icalcstp.h"
31#include "pvl.h"
32
33// Eugen C. <eug@thekompany.com>
34#include <defines.h>
35#ifndef _QTWIN_
36#include <sys/types.h> /* For send(), others */
37#include <sys/socket.h> /* For send(), others. */
38#include <unistd.h>
39#endif
40// Eugen C. <eug@thekompany.com>
41#include <errno.h>
42#include <stdlib.h> /* for malloc */
43#include <string.h>
44
45
46struct command_map {
47 enum icalcstp_command command;
48 char *str;
49} command_map[] =
50{
51 {ICAL_ABORT_COMMAND,"ABORT"},
52 {ICAL_AUTHENTICATE_COMMAND,"AUTHENTICATE"},
53 {ICAL_CAPABILITY_COMMAND,"CAPABILITY"},
54 {ICAL_CONTINUE_COMMAND,"CONTINUE"},
55 {ICAL_CALIDEXPAND_COMMAND,"CALIDEXPAND"},
56 {ICAL_IDENTIFY_COMMAND,"IDENTIFY"},
57 {ICAL_DISCONNECT_COMMAND,"DISCONNECT"},
58 {ICAL_SENDDATA_COMMAND,"SENDDATA"},
59 {ICAL_STARTTLS_COMMAND,"STARTTLS"},
60 {ICAL_UPNEXPAND_COMMAND,"UPNEXPAND"},
61 {ICAL_UNKNOWN_COMMAND,"UNKNOWN"}
62};
63
64
65icalcstp_command icalcstp_line_command(char* line)
66{
67 int i;
68
69 for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){
70 size_t l = strlen(command_map[i].str);
71
72 if(strncmp(line, command_map[i].str, l) == 0){
73 return command_map[i].command;
74 }
75
76 }
77
78 return ICAL_UNKNOWN_COMMAND;
79}
80
81icalrequeststatus icalcstp_line_response_code(char* line)
82{
83 struct icalreqstattype rs;
84
85 rs = icalreqstattype_from_string(line);
86
87 return rs.code;
88}
89
90int icalcstp_line_is_endofdata(char* line)
91{
92 if(line[0] == '.' && line[1] == '\n'){
93 return 1;
94 }
95
96 return 0;
97
98}
99
100int icalcstp_line_is_mime(char* line)
101{
102 return 0;
103}
104
105
106const char* icalcstp_command_to_string(icalcstp_command command){
107
108 int i;
109
110 for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){
111 size_t l = strlen(command_map[i].str);
112
113 if(command_map[i].command == command){
114 return command_map[i].str;
115 }
116
117 }
118
119 return command_map[i].str;
120
121}
122
diff --git a/libical/src/libicalss/icalcstp.h b/libical/src/libicalss/icalcstp.h
new file mode 100644
index 0000000..dfc3618
--- a/dev/null
+++ b/libical/src/libicalss/icalcstp.h
@@ -0,0 +1,79 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcstp.h
4 CREATOR: eric 20 April 1999
5
6 $Id$
7
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 icalcstp.h
23
24======================================================================*/
25
26
27#ifndef ICALCSTP_H
28#define ICALCSTP_H
29
30#include "ical.h"
31
32
33/* Connection state, from the state machine in RFC2445 */
34enum cstps_state {
35 NO_STATE,
36 CONNECTED,
37 AUTHENTICATED,
38 IDENTIFIED,
39 DISCONNECTED,
40 RECEIVE
41};
42
43/* CSTP Commands that a client can issue to a server */
44typedef enum icalcstp_command {
45 ICAL_ABORT_COMMAND,
46 ICAL_AUTHENTICATE_COMMAND,
47 ICAL_CAPABILITY_COMMAND,
48 ICAL_CONTINUE_COMMAND,
49 ICAL_CALIDEXPAND_COMMAND,
50 ICAL_IDENTIFY_COMMAND,
51 ICAL_DISCONNECT_COMMAND,
52 ICAL_SENDDATA_COMMAND,
53 ICAL_STARTTLS_COMMAND,
54 ICAL_UPNEXPAND_COMMAND,
55 ICAL_COMPLETE_COMMAND,
56 ICAL_UNKNOWN_COMMAND
57} icalcstp_command;
58
59
60
61/* A statement is a combination of command or response code and a
62 component that the server and client exchage with each other. */
63struct icalcstp_statement {
64 icalcstp_command command;
65 char* str_data; /* If non-NUll use as arguments to command */
66 int int_data; /* If non-NULL use as arguments to command */
67
68 icalrequeststatus code;
69
70 icalcomponent* data;
71};
72
73const char* icalcstp_command_to_string(icalcstp_command command);
74icalcstp_command icalcstp_string_to_command(const char* str);
75
76#endif /* !ICALCSTP_H */
77
78
79
diff --git a/libical/src/libicalss/icalcstpclient.c b/libical/src/libicalss/icalcstpclient.c
new file mode 100644
index 0000000..03a70dd
--- a/dev/null
+++ b/libical/src/libicalss/icalcstpclient.c
@@ -0,0 +1,350 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalcstps.c
4 CREATOR: ebusboom 23 Jun 2000
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "icalerror.h"
30#include "ical.h"
31#include "icalcstp.h"
32#include "icalcstpclient.h"
33#include "pvl.h"
34
35// Eugen C. <eug@thekompany.com>
36#include <defines.h>
37#ifndef _QTWIN_
38#include <sys/types.h> /* For send(), others */
39#include <sys/socket.h> /* For send(), others. */
40#include<unistd.h>
41#endif
42// Eugen C. <eug@thekompany.com>
43
44#include <errno.h>
45#include <stdlib.h> /* for malloc */
46#include <string.h>
47
48#define EOL "\n"
49
50
51/* Client state machine */
52
53typedef enum icalcstpc_line_type {
54 ICALCSTPC_RESPONSE_CODE_LINE,
55 ICALCSTPC_TERMINATOR_LINE,
56 ICALCSTPC_APPLICATION_DATA_LINE
57} icalcstpc_line_type;
58
59typedef enum icalcstpc_state {
60 ICALCSTPC_SEND_STATE,
61 ICALCSTPC_RESPONSE_CODE_STATE,
62 ICALCSTPC_RESPONSE_DATA_STATE
63} icalcstpc_state;
64
65
66
67struct icalcstpc_impl {
68 int timeout;
69 icalparser *parser;
70 icalcstp_command command;
71 icalcstpc_state state;
72 char* next_output;
73 char* next_input;
74};
75
76icalcstpc* icalcstpc_new()
77{
78 struct icalcstpc_impl *impl;
79
80 impl = malloc(sizeof(struct icalcstpc_impl));
81
82 if(impl == 0){
83 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
84 return 0;
85 }
86
87 memset(impl,0,sizeof(struct icalcstpc_impl));
88
89 return impl;
90}
91
92void icalcstpc_free(icalcstpc* cstpc)
93{
94 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstpc;
95
96 if(impl->next_output != 0){
97 free(impl->next_output);
98 }
99
100 if(impl->next_input != 0){
101 free(impl->next_input);
102 }
103
104
105 if(impl->parser != 0){
106 icalparser_free(impl->parser);
107 }
108}
109
110/* Get the next string to send to the server */
111char* icalcstpc_next_output(icalcstpc* cstp, char * line)
112{
113 char* out;
114 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
115
116 if(impl->next_output == 0){
117 return 0;
118 }
119
120 out = impl->next_output;
121
122 impl->next_output = 0;
123
124 icalmemory_add_tmp_buffer(out);
125
126 return out;
127}
128
129/* process the next string sent by the server */
130int icalcstpc_next_input(icalcstpc* cstp, char* line)
131{
132 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
133 icalcstpc_line_type line_type;
134
135 if(icalcstp_line_is_endofdata(line) || line == 0){
136 return 0;
137 }
138
139 switch (impl->command){
140 case ICAL_ABORT_COMMAND:{
141 break;
142 }
143 case ICAL_AUTHENTICATE_COMMAND:{
144 break;
145 }
146 case ICAL_CAPABILITY_COMMAND:{
147 break;
148 }
149 case ICAL_CONTINUE_COMMAND:{
150 break;
151 }
152 case ICAL_CALIDEXPAND_COMMAND:{
153 break;
154 }
155 case ICAL_IDENTIFY_COMMAND:{
156 break;
157 }
158 case ICAL_DISCONNECT_COMMAND:{
159 break;
160 }
161 case ICAL_SENDDATA_COMMAND:{
162 break;
163 }
164 case ICAL_STARTTLS_COMMAND:{
165 break;
166 }
167 case ICAL_UPNEXPAND_COMMAND:{
168 break;
169 }
170 case ICAL_COMPLETE_COMMAND:{
171 break;
172 }
173 case ICAL_UNKNOWN_COMMAND:{
174 break;
175 }
176 default:
177 break;
178 }
179}
180
181/* After icalcstpc_next_input returns a 0, there are responses
182 ready. use these to get them */
183icalcstpc_response icalcstpc_first_response(icalcstpc* cstp)
184{
185 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
186
187}
188
189
190icalcstpc_response icalcstpc_next_response(icalcstpc* cstp)
191{
192 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
193}
194
195
196int icalcstpc_set_timeout(icalcstpc* cstp, int sec)
197{
198 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
199}
200
201icalerrorenum icalcstpc_abort(icalcstpc* cstp)
202{
203 struct icalcstpc_impl* impl = (struct icalcstpc_impl*)cstp;
204
205 icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR);
206
207 impl->next_output = "ABORT\n";
208
209 return ICAL_NO_ERROR;
210}
211
212icalerrorenum icalcstpclient_setup_output(icalcstpc* cstp, size_t sz)
213{
214 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
215
216 if(impl->next_output != 0){
217 icalerror_set_errno(ICAL_USAGE_ERROR);
218 return ICAL_USAGE_ERROR;
219 }
220
221 impl->next_output = malloc(sz);
222
223 if(impl->next_output == 0){
224 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
225 return ICAL_NEWFAILED_ERROR;
226 }
227
228 return ICAL_NO_ERROR;
229
230}
231
232icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
233 char* data, char* f(char*))
234{
235 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
236 char* command_str;
237 icalerrorenum error;
238 size_t sz;
239
240 icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR);
241 icalerror_check_arg_re(mechanism!=0,"mechanism",ICAL_BADARG_ERROR);
242 icalerror_check_arg_re(data!=0,"data",ICAL_BADARG_ERROR);
243 icalerror_check_arg_re(f!=0,"f",ICAL_BADARG_ERROR);
244
245 impl->command = ICAL_AUTHENTICATE_COMMAND;
246
247 command_str = icalcstp_command_to_string(impl->command);
248
249 sz = strlen(command_str) + strlen(mechanism) + strlen(data) + 4;
250
251 if((error=icalcstpclient_setup_output(cstp,sz)) != ICAL_NO_ERROR){
252 return error;
253 }
254
255 sprintf(impl->next_output,"%s %s %s%s",command_str,mechanism,data,EOL);
256
257 return ICAL_NO_ERROR;
258}
259
260icalerrorenum icalcstpc_capability(icalcstpc* cstp)
261{
262 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
263 char* command_str;
264 icalerrorenum error;
265 size_t sz;
266
267 icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR);
268
269 impl->command = ICAL_CAPABILITY_COMMAND;
270
271 command_str = icalcstp_command_to_string(impl->command);
272
273 sz = strlen(command_str);
274
275 if((error=icalcstpclient_setup_output(cstp,sz)) != ICAL_NO_ERROR){
276 return error;
277 }
278
279 return ICAL_NO_ERROR;
280}
281
282icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid)
283{
284 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
285
286 impl->command = ICAL_CALIDEXPAND_COMMAND;
287 return ICAL_NO_ERROR;
288}
289
290icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time)
291{
292 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
293
294 impl->command = ICAL_CONTINUE_COMMAND;
295 return ICAL_NO_ERROR;
296}
297
298icalerrorenum icalcstpc_disconnect(icalcstpc* cstp)
299{
300 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
301
302
303 impl->command = ICAL_DISCONNECT_COMMAND;
304
305 return ICAL_NO_ERROR;
306}
307
308icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id)
309{
310 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
311
312
313 impl->command = ICAL_IDENTIFY_COMMAND;
314
315 return ICAL_NO_ERROR;
316}
317
318icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
319 char* data, char * f(char*))
320{
321 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
322
323 impl->command = ICAL_STARTTLS_COMMAND;
324
325 return ICAL_NO_ERROR;
326}
327
328icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid)
329{
330 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
331
332
333 impl->command = ICAL_UPNEXPAND_COMMAND;
334
335 return ICAL_NO_ERROR;
336}
337
338icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
339 icalcomponent *comp)
340{
341 struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
342
343 impl->command = ICAL_SENDDATA_COMMAND;
344
345 return ICAL_NO_ERROR;
346}
347
348
349
350
diff --git a/libical/src/libicalss/icalcstpclient.h b/libical/src/libicalss/icalcstpclient.h
new file mode 100644
index 0000000..8d9d0c9
--- a/dev/null
+++ b/libical/src/libicalss/icalcstpclient.h
@@ -0,0 +1,100 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcstpclient.h
4 CREATOR: eric 4 Feb 01
5
6 $Id$
7
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 icalcstp.h
23
24======================================================================*/
25
26
27#ifndef ICALCSTPC_H
28#define ICALCSTPC_H
29
30#include "ical.h"
31#include "icalcstp.h"
32
33/********************** Client (Sender) Interfaces **************************/
34
35/* How to use:
36
37 1) Construct a new icalcstpc
38 2) Issue a command by calling one of the command routines.
39 3) Repeat until both call icalcstpc_next_output and
40 icalcstpc_next_input return 0:
41 3a) Call icalcstpc_next_output. Send string to server.
42 3b) Get string from server, & give to icalcstp_next_input()
43 4) Iterate with icalcstpc_first_response & icalcstp_next_response to
44 get the servers responses
45 5) Repeat at #2
46*/
47
48
49typedef void icalcstpc;
50
51/* Response code sent by the server. */
52 typedef struct icalcstpc_response {
53 icalrequeststatus code;
54 char *arg; /* These strings are owned by libical */
55 char *debug_text;
56 char *more_text;
57 void* result;
58} icalcstpc_response;
59
60
61icalcstpc* icalcstpc_new();
62
63void icalcstpc_free(icalcstpc* cstpc);
64
65int icalcstpc_set_timeout(icalcstpc* cstp, int sec);
66
67
68/* Get the next string to send to the server */
69char* icalcstpc_next_output(icalcstpc* cstp, char* line);
70
71/* process the next string from the server */
72int icalcstpc_next_input(icalcstpc* cstp, char * line);
73
74/* After icalcstpc_next_input returns a 0, there are responses
75 ready. use these to get them */
76icalcstpc_response icalcstpc_first_response(icalcstpc* cstp);
77icalcstpc_response icalcstpc_next_response(icalcstpc* cstp);
78
79/* Issue a command */
80icalerrorenum icalcstpc_abort(icalcstpc* cstp);
81icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
82 char* init_data, char* f(char*) );
83icalerrorenum icalcstpc_capability(icalcstpc* cstp);
84icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid);
85icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time);
86icalerrorenum icalcstpc_disconnect(icalcstpc* cstp);
87icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id);
88icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
89 char* init_data, char* f(char*));
90icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time,
91 icalcomponent *comp);
92icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid);
93icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
94 icalcomponent *comp);
95
96
97#endif /* !ICALCSTPC_H */
98
99
100
diff --git a/libical/src/libicalss/icalcstpserver.c b/libical/src/libicalss/icalcstpserver.c
new file mode 100644
index 0000000..cd8b3bb
--- a/dev/null
+++ b/libical/src/libicalss/icalcstpserver.c
@@ -0,0 +1,285 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalcstpserver.c
4 CREATOR: ebusboom 13 Feb 01
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "icalerror.h"
30#include "ical.h"
31#include "icalcstp.h"
32#include "icalcstpserver.h"
33#include "pvl.h"
34
35// Eugen C. <eug@thekompany.com>
36#include <defines.h>
37#ifndef _QTWIN_
38#include <sys/types.h> /* For send(), others */
39#include <sys/socket.h> /* For send(), others. */
40#include<unistd.h>
41#endif
42// Eugen C. <eug@thekompany.com>
43
44#include <errno.h>
45#include <stdlib.h> /* for malloc */
46#include <string.h>
47
48
49
50struct icalcstps_impl {
51 int timeout;
52 icalparser *parser;
53 enum cstps_state major_state;
54 struct icalcstps_commandfp commandfp;
55};
56
57
58
59
60/* This state machine is a Mealy-type: actions occur on the
61 transitions, not in the states.
62
63 Here is the state machine diagram from the CAP draft:
64
65
66 STARTTLS /
67 CAPABILITY
68 +-------+
69 | | +---------------+
70 | +-----------+ AUTHENTICATE | |
71 +-->| Connected |-------------->| Authenticated |
72 +-----------+ | |
73 | +---------------+
74 | |
75 | |
76 | |
77 | | +-----+ STARTTLS /
78 | V | | CAPABILITY /
79 | +---------------+ | IDENTIFY
80 | | |<-+
81 | | Identified |<----+
82 | +--------| | |
83 | | +---------------+ | command
84 | | | | completes
85 V |DISCONNECT | |
86 +--------------+ | |SENDDATA |
87 | Disconnected |<--+ | |
88 +--------------+ | | ABORT
89 A | |
90 | V |
91 | DISCONNECT +---------------+ |
92 +--------------------| Receive |--+
93 | |<--+
94 +---------------+ |
95 | | CONTINUTE
96 +----+
97
98 In this implmenetation, the transition from CONNECTED to IDENTIFIED
99 is non-standard. The spec specifies that on the ATHENTICATE
100 command, the machine transitions from CONNECTED to AUTHENTICATED,
101 and then immediately goes to IDENTIFIED. This makes AUTHENTICATED a
102 useless state, so I removed it */
103
104struct state_table {
105 enum cstps_state major_state;
106 enum icalcstp_command command;
107 void (*action)();
108 enum cstps_state next_state;
109
110} server_state_table[] =
111{
112 { CONNECTED, ICAL_CAPABILITY_COMMAND , 0, CONNECTED},
113 { CONNECTED, ICAL_AUTHENTICATE_COMMAND , 0, IDENTIFIED}, /* Non-standard */
114 { IDENTIFIED, ICAL_STARTTLS_COMMAND, 0, IDENTIFIED},
115 { IDENTIFIED, ICAL_IDENTIFY_COMMAND, 0, IDENTIFIED},
116 { IDENTIFIED, ICAL_CAPABILITY_COMMAND, 0, IDENTIFIED},
117 { IDENTIFIED, ICAL_SENDDATA_COMMAND, 0, RECEIVE},
118 { IDENTIFIED, ICAL_DISCONNECT_COMMAND, 0, DISCONNECTED},
119 { DISCONNECTED, 0, 0, 0},
120 { RECEIVE, ICAL_DISCONNECT_COMMAND, 0, DISCONNECTED},
121 { RECEIVE, ICAL_CONTINUE_COMMAND, 0, RECEIVE},
122 { RECEIVE, ICAL_ABORT_COMMAND , 0, IDENTIFIED},
123 { RECEIVE, ICAL_COMPLETE_COMMAND , 0, IDENTIFIED}
124};
125
126
127/**********************************************************************/
128
129
130
131icalcstps* icalcstps_new(struct icalcstps_commandfp cfp)
132{
133 struct icalcstps_impl* impl;
134
135 if ( ( impl = (struct icalcstps_impl*)
136 malloc(sizeof(struct icalcstps_impl))) == 0) {
137 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
138 return 0;
139 }
140
141 impl->commandfp = cfp;
142 impl->timeout = 10;
143
144 return (icalcstps*)impl;
145
146}
147
148void icalcstps_free(icalcstps* cstp);
149
150int icalcstps_set_timeout(icalcstps* cstp, int sec)
151{
152 struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp;
153
154 icalerror_check_arg_rz( (cstp!=0), "cstp");
155
156 impl->timeout = sec;
157
158 return sec;
159}
160
161 typedef struct icalcstps_response {
162 icalrequeststatus code;
163 char caluid[1024];
164 void* result;
165} icalcstps_response;
166
167
168icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data)
169{
170 return ICAL_NO_ERROR;
171}
172icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data)
173{ return ICAL_NO_ERROR;
174}
175icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data)
176{ return ICAL_NO_ERROR;
177}
178icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data)
179{
180 return ICAL_NO_ERROR;
181}
182icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data)
183{
184 return ICAL_NO_ERROR;
185}
186icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data)
187{
188 return ICAL_NO_ERROR;
189}
190icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data)
191{
192 return ICAL_NO_ERROR;
193}
194icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data)
195{
196 return ICAL_NO_ERROR;
197}
198icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data)
199{
200 return ICAL_NO_ERROR;
201}
202icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data)
203{ return ICAL_NO_ERROR;
204}
205
206char* icalcstps_process_incoming(icalcstps* cstp, char* input)
207{
208 struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp;
209 char *i;
210 char *cmd_or_resp;
211 char *data;
212 char *input_cpy;
213 icalerrorenum error;
214
215 icalerror_check_arg_rz(cstp !=0,"cstp");
216 icalerror_check_arg_rz(input !=0,"input");
217
218 if ((input_cpy = (char*)strdup(input)) == 0){
219 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
220 return 0;
221 }
222
223 i = (char*)strstr(" ",input_cpy);
224
225 cmd_or_resp = input_cpy;
226
227 if (i != 0){
228 *i = '\0';
229 data = ++i;
230 } else {
231 data = 0;
232 }
233
234 printf("cmd: %s\n",cmd_or_resp);
235 printf("data: %s\n",data);
236
237 /* extract the command, look up in the state table, and dispatch
238 to the proper handler */
239
240 if(strcmp(cmd_or_resp,"ABORT") == 0){
241 error = prep_abort(impl,data);
242 } else if(strcmp(cmd_or_resp,"AUTHENTICATE") == 0){
243 error = prep_authenticate(impl,data);
244 } else if(strcmp(cmd_or_resp,"CAPABILITY") == 0){
245 error = prep_capability(impl,data);
246 } else if(strcmp(cmd_or_resp,"CALIDEXPAND") == 0){
247 error = prep_calidexpand(impl,data);
248 } else if(strcmp(cmd_or_resp,"CONTINUE") == 0){
249 error = prep_continue(impl,data);
250 } else if(strcmp(cmd_or_resp,"DISCONNECT") == 0){
251 error = prep_disconnect(impl,data);
252 } else if(strcmp(cmd_or_resp,"IDENTIFY") == 0){
253 error = prep_identify(impl,data);
254 } else if(strcmp(cmd_or_resp,"STARTTLS") == 0){
255 error = prep_starttls(impl,data);
256 } else if(strcmp(cmd_or_resp,"UPNEXPAND") == 0){
257 error = prep_upnexpand(impl,data);
258 } else if(strcmp(cmd_or_resp,"SENDDATA") == 0){
259 error = prep_sendata(impl,data);
260 }
261
262 return 0;
263}
264
265 /* Read data until we get a end of data marker */
266
267
268
269struct icalcstps_server_stubs {
270 icalerrorenum (*abort)(icalcstps* cstp);
271 icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism,
272 char* data);
273 icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid);
274 icalerrorenum (*capability)(icalcstps* cstp);
275 icalerrorenum (*cont)(icalcstps* cstp, unsigned int time);
276 icalerrorenum (*identify)(icalcstps* cstp, char* id);
277 icalerrorenum (*disconnect)(icalcstps* cstp);
278 icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time,
279 icalcomponent *comp);
280 icalerrorenum (*starttls)(icalcstps* cstp, char* command,
281 char* data);
282 icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn);
283 icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data);
284};
285
diff --git a/libical/src/libicalss/icalcstpserver.h b/libical/src/libicalss/icalcstpserver.h
new file mode 100644
index 0000000..6fa2254
--- a/dev/null
+++ b/libical/src/libicalss/icalcstpserver.h
@@ -0,0 +1,101 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcstpserver.h
4 CREATOR: eric 13 Feb 01
5
6 $Id$
7
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 icalcstp.h
23
24======================================================================*/
25
26
27#ifndef ICALCSTPS_H
28#define ICALCSTPS_H
29
30#include "ical.h"
31
32
33/********************** Server (Reciever) Interfaces *************************/
34
35/* On the server side, the caller will recieve data from the incoming
36 socket and pass it to icalcstps_next_input. The caller then takes
37 the return from icalcstps_next_outpu and sends it out through the
38 socket. This gives the caller a point of control. If the cstp code
39 connected to the socket itself, it would be hard for the caller to
40 do anything else after the cstp code was started.
41
42 All of the server and client command routines will generate
43 response codes. On the server side, these responses will be turned
44 into text and sent to the client. On the client side, the reponse
45 is the one sent from the server.
46
47 Since each command can return multiple responses, the responses are
48 stored in the icalcstps object and are accesses by
49 icalcstps_first_response() and icalcstps_next_response()
50
51 How to use:
52
53 1) Construct a new icalcstps, bound to your code via stubs
54 2) Repeat forever:
55 2a) Get string from client & give to icalcstps_next_input()
56 2b) Repeat until icalcstp_next_output returns 0:
57 2b1) Call icalcstps_next_output.
58 2b2) Send string to client.
59*/
60
61
62
63typedef void icalcstps;
64
65/* Pointers to the rountines that
66 icalcstps_process_incoming will call when it recognizes a CSTP
67 command in the data. BTW, the CONTINUE command is named 'cont'
68 because 'continue' is a C keyword */
69
70struct icalcstps_commandfp {
71 icalerrorenum (*abort)(icalcstps* cstp);
72 icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism,
73 char* data);
74 icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid);
75 icalerrorenum (*capability)(icalcstps* cstp);
76 icalerrorenum (*cont)(icalcstps* cstp, unsigned int time);
77 icalerrorenum (*identify)(icalcstps* cstp, char* id);
78 icalerrorenum (*disconnect)(icalcstps* cstp);
79 icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time,
80 icalcomponent *comp);
81 icalerrorenum (*starttls)(icalcstps* cstp, char* command,
82 char* data);
83 icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn);
84 icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data);
85};
86
87
88
89icalcstps* icalcstps_new(struct icalcstps_commandfp stubs);
90
91void icalcstps_free(icalcstps* cstp);
92
93int icalcstps_set_timeout(icalcstps* cstp, int sec);
94
95/* Get the next string to send to the client */
96char* icalcstps_next_output(icalcstps* cstp);
97
98/* process the next string from the client */
99int icalcstps_next_input(icalcstps* cstp);
100
101#endif /* ICALCSTPS */
diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c
new file mode 100644
index 0000000..b6cb673
--- a/dev/null
+++ b/libical/src/libicalss/icaldirset.c
@@ -0,0 +1,777 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icaldirset.c
4 CREATOR: eric 28 November 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/*
30
31 icaldirset manages a database of ical components and offers
32 interfaces for reading, writting and searching for components.
33
34 icaldirset groups components in to clusters based on their DTSTAMP
35 time -- all components that start in the same month are grouped
36 together in a single file. All files in a sotre are kept in a single
37 directory.
38
39 The primary interfaces are icaldirset_first and icaldirset_next. These
40 routine iterate through all of the components in the store, subject
41 to the current gauge. A gauge is an icalcomponent that is tested
42 against other componets for a match. If a gauge has been set with
43 icaldirset_select, icaldirset_first and icaldirset_next will only
44 return componentes that match the gauge.
45
46 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 &
48 year as MMYYYY) plus a unique serial number. The serial number is
49 stored as a property of the cluster.
50
51*/
52
53#ifdef HAVE_CONFIG_H
54#include "config.h"
55#endif
56
57
58#include "icalerror.h"
59#include "ical.h"
60#include "icaldirset.h"
61#include "pvl.h"
62#include "icalparser.h"
63#include "icaldirset.h"
64#include "icalfileset.h"
65#include "icalfilesetimpl.h"
66#include "icalgauge.h"
67
68#include <limits.h> /* For PATH_MAX */
69#include <errno.h>
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() */
79#include <unistd.h>
80#include <sys/utsname.h> /* for uname */
81#endif
82// Eugen C. <eug@thekompany.com>
83
84#include <time.h> /* for clock() */
85#include <stdlib.h> /* for rand(), srand() */
86#include <string.h> /* for strdup */
87#include "icaldirsetimpl.h"
88
89
90struct icaldirset_impl* icaldirset_new_impl()
91{
92 struct icaldirset_impl* impl;
93
94 if ( ( impl = (struct icaldirset_impl*)
95 malloc(sizeof(struct icaldirset_impl))) == 0) {
96 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
97 return 0;
98 }
99
100 strcpy(impl->id,ICALDIRSET_ID);
101
102 return impl;
103}
104
105const char* icaldirset_path(icaldirset* cluster)
106{
107 struct icaldirset_impl *impl = icaldirset_new_impl();
108
109 return impl->dir;
110
111}
112
113void icaldirset_mark(icaldirset* store)
114{
115 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
116
117 icalfileset_mark(impl->cluster);
118}
119
120
121icalerrorenum icaldirset_commit(icaldirset* store)
122{
123 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
124
125 return icalfileset_commit(impl->cluster);
126
127}
128
129void icaldirset_lock(const char* dir)
130{
131}
132
133
134void icaldirset_unlock(const char* dir)
135{
136}
137
138/* Load the contents of the store directory into the store's internal directory list*/
139icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
140{
141#ifndef _QTWIN_
142 struct dirent *de;
143 DIR* dp;
144 char *str;
145
146 dp = opendir(impl->dir);
147
148 if ( dp == 0) {
149 icalerror_set_errno(ICAL_FILE_ERROR);
150 return ICAL_FILE_ERROR;
151 }
152
153 /* clear contents of directory list */
154 while((str = pvl_pop(impl->directory))){
155 free(str);
156 }
157
158 /* load all of the cluster names in the directory list */
159 for(de = readdir(dp);
160 de != 0;
161 de = readdir(dp)){
162
163 /* Remove known directory names '.' and '..'*/
164 if (strcmp(de->d_name,".") == 0 ||
165 strcmp(de->d_name,"..") == 0 ){
166 continue;
167 }
168
169 pvl_push(impl->directory, (void*)strdup(de->d_name));
170 }
171
172 closedir(dp);
173
174 return ICAL_NO_ERROR;
175#else
176 icalerror_set_errno(ICAL_FILE_ERROR);
177 return ICAL_FILE_ERROR;
178#endif
179}
180
181icaldirset* icaldirset_new(const char* dir)
182{
183 struct icaldirset_impl *impl = icaldirset_new_impl();
184 struct stat sbuf;
185
186 if (impl == 0){
187 return 0;
188 }
189
190 icalerror_check_arg_rz( (dir!=0), "dir");
191
192 if (stat(dir,&sbuf) != 0){
193 icalerror_set_errno(ICAL_FILE_ERROR);
194 return 0;
195 }
196
197#ifndef _QTWIN_
198 /* dir is not the name of a direectory*/
199 if (!S_ISDIR(sbuf.st_mode)){
200 icalerror_set_errno(ICAL_USAGE_ERROR);
201 return 0;
202 }
203#endif
204
205 icaldirset_lock(dir);
206
207 impl = icaldirset_new_impl();
208
209 if (impl ==0){
210 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
211 return 0;
212 }
213
214 impl->directory = pvl_newlist();
215 impl->directory_iterator = 0;
216 impl->dir = (char*)strdup(dir);
217 impl->gauge = 0;
218 impl->first_component = 0;
219 impl->cluster = 0;
220
221 icaldirset_read_directory(impl);
222
223 return (icaldirset*) impl;
224}
225
226void icaldirset_free(icaldirset* s)
227{
228 struct icaldirset_impl *impl = (struct icaldirset_impl*)s;
229 char* str;
230
231 icaldirset_unlock(impl->dir);
232
233 if(impl->dir !=0){
234 free(impl->dir);
235 }
236
237 if(impl->gauge !=0){
238 icalcomponent_free(impl->gauge);
239 }
240
241 if(impl->cluster !=0){
242 icalfileset_free(impl->cluster);
243 }
244
245 while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){
246 free(str);
247 }
248
249 if(impl->directory != 0){
250 pvl_free(impl->directory);
251 }
252
253 impl->directory = 0;
254 impl->directory_iterator = 0;
255 impl->dir = 0;
256 impl->gauge = 0;
257 impl->first_component = 0;
258
259 free(impl);
260
261}
262
263/* icaldirset_next_uid_number updates a serial number in the Store
264 directory in a file called SEQUENCE */
265
266int icaldirset_next_uid_number(icaldirset* store)
267{
268 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
269 char sequence = 0;
270 char temp[128];
271 char filename[ICAL_PATH_MAX];
272 char *r;
273 FILE *f;
274 struct stat sbuf;
275
276 icalerror_check_arg_rz( (store!=0), "store");
277
278 sprintf(filename,"%s/%s",impl->dir,"SEQUENCE");
279
280 /* Create the file if it does not exist.*/
281#ifndef _QTWIN_
282 if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){
283#else
284 if (stat(filename,&sbuf) == -1){
285#endif
286
287 f = fopen(filename,"w");
288 if (f != 0){
289 fprintf(f,"0");
290 fclose(f);
291 } else {
292 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
293 return 0;
294 }
295
296 }
297
298 if ( (f = fopen(filename,"r+")) != 0){
299
300 rewind(f);
301 r = fgets(temp,128,f);
302
303 if (r == 0){
304 sequence = 1;
305 } else {
306 sequence = atoi(temp)+1;
307 }
308
309 rewind(f);
310
311 fprintf(f,"%d",sequence);
312
313 fclose(f);
314
315 return sequence;
316
317 } else {
318 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
319 return 0;
320 }
321
322}
323
324icalerrorenum icaldirset_next_cluster(icaldirset* store)
325{
326 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
327 char path[ICAL_PATH_MAX];
328
329 if (impl->directory_iterator == 0){
330 icalerror_set_errno(ICAL_INTERNAL_ERROR);
331 return ICAL_INTERNAL_ERROR;
332 }
333 impl->directory_iterator = pvl_next(impl->directory_iterator);
334
335 if (impl->directory_iterator == 0){
336 /* There are no more clusters */
337 if(impl->cluster != 0){
338 icalfileset_free(impl->cluster);
339 impl->cluster = 0;
340 }
341 return ICAL_NO_ERROR;
342 }
343
344 sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
345
346 icalfileset_free(impl->cluster);
347
348 impl->cluster = icalfileset_new(path);
349
350 return icalerrno;
351}
352
353void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
354{
355#ifndef _QTWIN_
356
357 char uidstring[ICAL_PATH_MAX];
358 icalproperty *uid;
359 struct utsname unamebuf;
360
361 icalerror_check_arg_rv( (store!=0), "store");
362 icalerror_check_arg_rv( (comp!=0), "comp");
363
364 uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
365
366 if (uid == 0) {
367
368 uname(&unamebuf);
369
370 sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename);
371
372 uid = icalproperty_new_uid(uidstring);
373 icalcomponent_add_property(comp,uid);
374 } else {
375
376 strcpy(uidstring,icalproperty_get_uid(uid));
377 }
378
379#endif
380}
381
382
383/* 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
385 component must have a DTAMP property */
386
387icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
388{
389 struct icaldirset_impl *impl;
390 char clustername[ICAL_PATH_MAX];
391 icalproperty *dt;
392 icalvalue *v;
393 struct icaltimetype tm;
394 icalerrorenum error = ICAL_NO_ERROR;
395 icalcomponent *inner;
396
397 impl = (struct icaldirset_impl*)store;
398 icalerror_check_arg_rz( (store!=0), "store");
399 icalerror_check_arg_rz( (comp!=0), "comp");
400
401 errno = 0;
402
403 icaldirset_add_uid(store,comp);
404
405 /* Determine which cluster this object belongs in. This is a HACK */
406
407 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
408 inner != 0;
409 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
410
411 dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
412
413 if (dt != 0){
414 break;
415 }
416 }
417
418 if (dt == 0){
419
420 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
421 inner != 0;
422 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
423
424 dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
425
426 if (dt != 0){
427 break;
428 }
429 }
430
431 }
432
433 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");
437 icalerror_set_errno(ICAL_BADARG_ERROR);
438 return ICAL_BADARG_ERROR;
439 }
440
441 v = icalproperty_get_value(dt);
442
443 tm = icalvalue_get_datetime(v);
444
445 snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month);
446
447 /* Load the cluster and insert the object */
448
449 if(impl->cluster != 0 &&
450 strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){
451 icalfileset_free(impl->cluster);
452 impl->cluster = 0;
453 }
454
455 if (impl->cluster == 0){
456 impl->cluster = icalfileset_new(clustername);
457
458 if (impl->cluster == 0){
459 error = icalerrno;
460 }
461 }
462
463 if (error != ICAL_NO_ERROR){
464 icalerror_set_errno(error);
465 return error;
466 }
467
468 /* Add the component to the cluster */
469
470 icalfileset_add_component(impl->cluster,comp);
471
472 icalfileset_mark(impl->cluster);
473
474 return ICAL_NO_ERROR;
475}
476
477/* Remove a component in the current cluster. HACK. This routine is a
478 "friend" of icalfileset, and breaks its encapsulation. It was
479 either do it this way, or add several layers of interfaces that had
480 no other use. */
481icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
482{
483 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
484
485 struct icalfileset_impl *filesetimpl =
486 (struct icalfileset_impl*)impl->cluster;
487
488 icalcomponent *filecomp = filesetimpl->cluster;
489
490 icalcompiter i;
491 int found = 0;
492
493 icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR);
494 icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR);
495 icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR);
496
497 for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT);
498 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
499
500 icalcomponent *this = icalcompiter_deref(&i);
501
502 if (this == comp){
503 found = 1;
504 break;
505 }
506 }
507
508 if (found != 1){
509 icalerror_warn("icaldirset_remove_component: component is not part of current cluster");
510 icalerror_set_errno(ICAL_USAGE_ERROR);
511 return ICAL_USAGE_ERROR;
512 }
513
514 icalfileset_remove_component(impl->cluster,comp);
515
516 icalfileset_mark(impl->cluster);
517
518 /* If the removal emptied the fileset, get the next fileset */
519 if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){
520
521 icalerrorenum error = icaldirset_next_cluster(store);
522
523 if(impl->cluster != 0 && error == ICAL_NO_ERROR){
524 icalfileset_get_first_component(impl->cluster);
525 } else {
526 /* HACK. Not strictly correct for impl->cluster==0 */
527 return error;
528 }
529 } else {
530 /* Do nothing */
531 }
532
533 return ICAL_NO_ERROR;
534}
535
536
537
538int icaldirset_count_components(icaldirset* store,
539 icalcomponent_kind kind)
540{
541 /* HACK, not implemented */
542
543 assert(0);
544
545 return 0;
546}
547
548
549icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c)
550{
551 fprintf(stderr," icaldirset_fetch_match is not implemented\n");
552 assert(0);
553}
554
555
556icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid)
557{
558 icalcomponent *gauge;
559 icalcomponent *old_gauge;
560 icalcomponent *c;
561 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
562
563 icalerror_check_arg_rz( (store!=0), "store");
564 icalerror_check_arg_rz( (uid!=0), "uid");
565
566 gauge =
567 icalcomponent_vanew(
568 ICAL_VCALENDAR_COMPONENT,
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
579 old_gauge = impl->gauge;
580 impl->gauge = gauge;
581
582 c= icaldirset_get_first_component(store);
583
584 impl->gauge = old_gauge;
585
586 icalcomponent_free(gauge);
587
588 return c;
589}
590
591
592int icaldirset_has_uid(icaldirset* store, const char* uid)
593{
594 icalcomponent *c;
595
596 icalerror_check_arg_rz( (store!=0), "store");
597 icalerror_check_arg_rz( (uid!=0), "uid");
598
599 /* HACK. This is a temporary implementation. _has_uid should use a
600 database, and _fetch should use _has_uid, not the other way
601 around */
602 c = icaldirset_fetch(store,uid);
603
604 return c!=0;
605
606}
607
608
609icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge)
610 {
611 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
612
613 icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR);
614 icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR);
615
616 if (!icalcomponent_is_valid(gauge)){
617 return ICAL_BADARG_ERROR;
618 }
619
620 impl->gauge = gauge;
621
622 return ICAL_NO_ERROR;
623}
624
625
626icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
627 icalcomponent *new)
628{
629 assert(0);
630 return ICAL_NO_ERROR; /* HACK, not implemented */
631
632}
633
634
635void icaldirset_clear(icaldirset* store)
636{
637
638 assert(0);
639 return;
640 /* HACK, not implemented */
641}
642
643icalcomponent* icaldirset_get_current_component(icaldirset* store)
644{
645 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
646
647 if(impl->cluster == 0){
648 icaldirset_get_first_component(store);
649 }
650
651 return icalfileset_get_current_component(impl->cluster);
652
653}
654
655
656icalcomponent* icaldirset_get_first_component(icaldirset* store)
657{
658 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
659 icalerrorenum error;
660 char path[ICAL_PATH_MAX];
661
662 error = icaldirset_read_directory(impl);
663
664 if (error != ICAL_NO_ERROR){
665 icalerror_set_errno(error);
666 return 0;
667 }
668
669 impl->directory_iterator = pvl_head(impl->directory);
670
671 if (impl->directory_iterator == 0){
672 icalerror_set_errno(error);
673 return 0;
674 }
675
676 snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
677
678 /* If the next cluster we need is different than the current cluster,
679 delete the current one and get a new one */
680
681 if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){
682 icalfileset_free(impl->cluster);
683 impl->cluster = 0;
684 }
685
686 if (impl->cluster == 0){
687 impl->cluster = icalfileset_new(path);
688
689 if (impl->cluster == 0){
690 error = icalerrno;
691 }
692 }
693
694 if (error != ICAL_NO_ERROR){
695 icalerror_set_errno(error);
696 return 0;
697 }
698
699 impl->first_component = 1;
700
701 return icaldirset_get_next_component(store);
702}
703
704icalcomponent* icaldirset_get_next_component(icaldirset* store)
705{
706 struct icaldirset_impl *impl;
707 icalcomponent *c;
708 icalerrorenum error;
709
710 icalerror_check_arg_rz( (store!=0), "store");
711
712 impl = (struct icaldirset_impl*)store;
713
714 if(impl->cluster == 0){
715
716 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);
718 return 0;
719
720 }
721
722 /* Set the component iterator for the following for loop */
723 if (impl->first_component == 1){
724 icalfileset_get_first_component(impl->cluster);
725 impl->first_component = 0;
726 } else {
727 icalfileset_get_next_component(impl->cluster);
728 }
729
730
731 while(1){
732 /* Iterate through all of the objects in the cluster*/
733 for( c = icalfileset_get_current_component(impl->cluster);
734 c != 0;
735 c = icalfileset_get_next_component(impl->cluster)){
736
737 /* If there is a gauge defined and the component does not
738 pass the gauge, skip the rest of the loop */
739
740#if 0 /* HACK */
741 if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){
742 continue;
743 }
744#else
745 assert(0); /* icalgauge_test needs to be fixed */
746#endif
747 /* Either there is no gauge, or the component passed the
748 gauge, so return it*/
749
750 return c;
751 }
752
753 /* Fell through the loop, so the component we want is not
754 in this cluster. Load a new cluster and try again.*/
755
756 error = icaldirset_next_cluster(store);
757
758 if(impl->cluster == 0 || error != ICAL_NO_ERROR){
759 /* No more clusters */
760 return 0;
761 } else {
762 c = icalfileset_get_first_component(impl->cluster);
763
764 return c;
765 }
766
767 }
768
769 return 0; /* Should never get here */
770}
771
772
773
774
775
776
777
diff --git a/libical/src/libicalss/icaldirset.h b/libical/src/libicalss/icaldirset.h
new file mode 100644
index 0000000..7d205ec
--- a/dev/null
+++ b/libical/src/libicalss/icaldirset.h
@@ -0,0 +1,82 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icaldirset.h
4 CREATOR: eric 28 November 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 ICALDIRSET_H
30#define ICALDIRSET_H
31
32#include "ical.h"
33
34/* icaldirset Routines for storing, fetching, and searching for ical
35 * objects in a database */
36
37typedef void icaldirset;
38
39
40icaldirset* icaldirset_new(const char* path);
41
42void icaldirset_free(icaldirset* store);
43
44const char* icaldirset_path(icaldirset* store);
45
46/* Mark the cluster as changed, so it will be written to disk when it
47 is freed. Commit writes to disk immediately*/
48void icaldirset_mark(icaldirset* store);
49icalerrorenum icaldirset_commit(icaldirset* store);
50
51icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp);
52icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp);
53
54int icaldirset_count_components(icaldirset* store,
55 icalcomponent_kind kind);
56
57/* Restrict the component returned by icaldirset_first, _next to those
58 that pass the gauge. _clear removes the gauge. */
59icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge);
60void icaldirset_clear(icaldirset* store);
61
62/* Get a component by uid */
63icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid);
64int icaldirset_has_uid(icaldirset* store, const char* uid);
65icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c);
66
67/* Modify components according to the MODIFY method of CAP. Works on
68 the currently selected components. */
69icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc,
70 icalcomponent *newc);
71
72/* Iterate through the components. If a guage has been defined, these
73 will skip over components that do not pass the gauge */
74
75icalcomponent* icaldirset_get_current_component(icaldirset* store);
76icalcomponent* icaldirset_get_first_component(icaldirset* store);
77icalcomponent* icaldirset_get_next_component(icaldirset* store);
78
79#endif /* !ICALDIRSET_H */
80
81
82
diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h
new file mode 100644
index 0000000..0e69ba2
--- a/dev/null
+++ b/libical/src/libicalss/icaldirsetimpl.h
@@ -0,0 +1,47 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icaldirsetimpl.h
4 CREATOR: eric 21 Aug 2000
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 icalset*/
35
36#define ICALDIRSET_ID "dset"
37
38struct icaldirset_impl
39{
40 char id[5]; /* "dset" */
41 char* dir;
42 icalcomponent* gauge;
43 icaldirset* cluster;
44 int first_component;
45 pvl_list directory;
46 pvl_elem directory_iterator;
47};
diff --git a/libical/src/libicalss/icalfileset.c b/libical/src/libicalss/icalfileset.c
new file mode 100644
index 0000000..943071d
--- a/dev/null
+++ b/libical/src/libicalss/icalfileset.c
@@ -0,0 +1,659 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalfileset.c
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#include <errno.h>
34
35#include <stdlib.h>
36#include <stdio.h>
37#include <string.h>
38
39#include <fcntl.h> /* For open() flags and mode */
40#include <sys/types.h> /* For open() flags and mode */
41#include <sys/stat.h> /* For open() flags and mode */
42
43#include "icalfileset.h"
44#include "icalfilesetimpl.h"
45
46// Eugen C. <eug@thekompany.com>
47#include <defines.h>
48//
49
50int snprintf(char *str, size_t n, char const *fmt, ...);
51
52//extern int errno;
53
54int icalfileset_lock(icalfileset *cluster);
55int icalfileset_unlock(icalfileset *cluster);
56icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode);
57int icalfileset_filesize(icalfileset* cluster);
58
59icalerrorenum icalfileset_create_cluster(const char *path);
60
61icalfileset* icalfileset_new_impl()
62{
63 struct icalfileset_impl* impl;
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}
78
79
80icalfileset* icalfileset_new(const char* path)
81{
82 return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664);
83}
84
85icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
86{
87 struct icalfileset_impl *impl = icalfileset_new_impl();
88 struct icaltimetype tt;
89 off_t cluster_file_size;
90
91 memset(&tt,0,sizeof(struct icaltimetype));
92
93 icalerror_clear_errno();
94 icalerror_check_arg_rz( (path!=0), "path");
95
96 if (impl == 0){
97 return 0;
98 }
99
100 impl->path = strdup(path);
101
102 cluster_file_size = icalfileset_filesize(impl);
103
104 if(cluster_file_size < 0){
105 icalfileset_free(impl);
106 return 0;
107 }
108
109 impl->fd = open(impl->path,flags, mode);
110
111 if (impl->fd < 0){
112 icalerror_set_errno(ICAL_FILE_ERROR);
113 icalfileset_free(impl);
114 return 0;
115 }
116
117 icalfileset_lock(impl);
118
119 if(cluster_file_size > 0 ){
120 icalerrorenum error;
121 if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){
122 icalfileset_free(impl);
123 return 0;
124 }
125 }
126
127 if(impl->cluster == 0){
128 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
129 }
130
131 return impl;
132}
133
134char* icalfileset_read_from_file(char *s, size_t size, void *d)
135{
136
137 char* p = s;
138 int fd = (int)d;
139
140 /* Simulate fgets -- read single characters and stop at '\n' */
141
142 for(p=s; p<s+size-1;p++){
143
144 if(read(fd,p,1) != 1 || *p=='\n'){
145 p++;
146 break;
147 }
148 }
149
150 *p = '\0';
151
152 if(*s == 0){
153 return 0;
154 } else {
155 return s;
156 }
157
158}
159
160
161icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode)
162{
163
164 icalparser *parser;
165
166 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
167
168 parser = icalparser_new();
169 icalparser_set_gen_data(parser,(void*)impl->fd);
170 impl->cluster = icalparser_parse(parser,icalfileset_read_from_file);
171 icalparser_free(parser);
172
173 if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){
174 icalerror_set_errno(ICAL_PARSE_ERROR);
175 return ICAL_PARSE_ERROR;
176 }
177
178 if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){
179 /* The parser got a single component, so it did not put it in
180 an XROOT. */
181 icalcomponent *cl = impl->cluster;
182 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
183 icalcomponent_add_component(impl->cluster,cl);
184 }
185
186 return ICAL_NO_ERROR;
187
188}
189
190int icalfileset_filesize(icalfileset* cluster)
191{
192 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
193 int cluster_file_size;
194 struct stat sbuf;
195
196 if (stat(impl->path,&sbuf) != 0){
197
198 /* A file by the given name does not exist, or there was
199 another error */
200 cluster_file_size = 0;
201 if (errno == ENOENT) {
202 /* It was because the file does not exist */
203 return 0;
204 } else {
205 /* It was because of another error */
206 icalerror_set_errno(ICAL_FILE_ERROR);
207 return -1;
208 }
209 } else {
210 /* A file by the given name exists, but is it a regular file? */
211
212#ifndef _QTWIN_
213 if (!S_ISREG(sbuf.st_mode)){
214 /* Nope, not a regular file */
215 icalerror_set_errno(ICAL_FILE_ERROR);
216 return -1;
217 } else {
218 /* Lets assume that it is a file of the right type */
219 return sbuf.st_size;
220 }
221#else
222 return sbuf.st_size;
223#endif
224
225 }
226
227 /*return -1; not reached*/
228}
229
230void icalfileset_free(icalfileset* cluster)
231{
232 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
233
234 icalerror_check_arg_rv((cluster!=0),"cluster");
235
236 if (impl->cluster != 0){
237 icalfileset_commit(cluster);
238 icalcomponent_free(impl->cluster);
239 impl->cluster=0;
240 }
241
242 if(impl->fd > 0){
243 icalfileset_unlock(impl);
244 close(impl->fd);
245 impl->fd = -1;
246 }
247
248 if(impl->path != 0){
249 free(impl->path);
250 impl->path = 0;
251 }
252
253 free(impl);
254}
255
256const char* icalfileset_path(icalfileset* cluster)
257{
258 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
259 icalerror_check_arg_rz((cluster!=0),"cluster");
260
261 return impl->path;
262}
263
264
265int icalfileset_lock(icalfileset *cluster)
266{
267#ifndef _WIN32
268 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
269 struct flock lock;
270 int rtrn;
271
272 icalerror_check_arg_rz((impl->fd>0),"impl->fd");
273 errno = 0;
274 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
275 lock.l_start = 0; /* byte offset relative to l_whence */
276 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
277 lock.l_len = 0; /* #bytes (0 means to EOF) */
278
279 rtrn = fcntl(impl->fd, F_SETLKW, &lock);
280
281 return rtrn;
282#else
283 return -1;
284#endif
285}
286
287int icalfileset_unlock(icalfileset *cluster)
288{
289#ifndef _WIN32
290 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
291 struct flock lock;
292 icalerror_check_arg_rz((impl->fd>0),"impl->fd");
293
294 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
295 lock.l_start = 0; /* byte offset relative to l_whence */
296 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
297 lock.l_len = 0; /* #bytes (0 means to EOF) */
298
299 return (fcntl(impl->fd, F_UNLCK, &lock));
300#else
301 return -1;
302#endif
303}
304
305#ifdef ICAL_SAFESAVES
306int icalfileset_safe_saves=1;
307#else
308int icalfileset_safe_saves=0;
309#endif
310
311icalerrorenum icalfileset_commit(icalfileset* cluster)
312{
313 char tmp[ICAL_PATH_MAX];
314 char *str;
315 icalcomponent *c;
316 off_t write_size=0;
317
318 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
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) ;
324
325 if (impl->changed == 0 ){
326 return ICAL_NO_ERROR;
327 }
328
329 if(icalfileset_safe_saves == 1){
330 snprintf(tmp,ICAL_PATH_MAX,"cp %s %s.bak",impl->path,impl->path);
331
332 if(system(tmp) < 0){
333 icalerror_set_errno(ICAL_FILE_ERROR);
334 return ICAL_FILE_ERROR;
335 }
336 }
337
338 if(lseek(impl->fd,SEEK_SET,0) < 0){
339 icalerror_set_errno(ICAL_FILE_ERROR);
340 return ICAL_FILE_ERROR;
341 }
342
343 for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT);
344 c != 0;
345 c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){
346 int sz;
347
348 str = icalcomponent_as_ical_string(c);
349
350 sz=write(impl->fd,str,strlen(str));
351
352 if ( sz != strlen(str)){
353 perror("write");
354 icalerror_set_errno(ICAL_FILE_ERROR);
355 return ICAL_FILE_ERROR;
356 }
357
358 write_size += sz;
359 }
360
361 impl->changed = 0;
362
363#ifndef _QTWIN_
364 if(ftruncate(impl->fd,write_size) < 0){
365 return ICAL_FILE_ERROR;
366 }
367#endif
368
369 return ICAL_NO_ERROR;
370
371}
372
373void icalfileset_mark(icalfileset* cluster){
374
375 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
376
377 icalerror_check_arg_rv((impl!=0),"cluster");
378
379 impl->changed = 1;
380
381}
382
383icalcomponent* icalfileset_get_component(icalfileset* cluster){
384 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
385
386 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
387
388 return impl->cluster;
389}
390
391
392/* manipulate the components in the cluster */
393
394icalerrorenum icalfileset_add_component(icalfileset *cluster,
395 icalcomponent* child)
396{
397 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
398
399 icalerror_check_arg_re((cluster!=0),"cluster", ICAL_BADARG_ERROR);
400 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
401
402 icalcomponent_add_component(impl->cluster,child);
403
404 icalfileset_mark(cluster);
405
406 return ICAL_NO_ERROR;
407
408}
409
410icalerrorenum icalfileset_remove_component(icalfileset *cluster,
411 icalcomponent* child)
412{
413 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
414
415 icalerror_check_arg_re((cluster!=0),"cluster",ICAL_BADARG_ERROR);
416 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
417
418 icalcomponent_remove_component(impl->cluster,child);
419
420 icalfileset_mark(cluster);
421
422 return ICAL_NO_ERROR;
423}
424
425int icalfileset_count_components(icalfileset *cluster,
426 icalcomponent_kind kind)
427{
428 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
429
430 if(cluster == 0){
431 icalerror_set_errno(ICAL_BADARG_ERROR);
432 return -1;
433 }
434
435 return icalcomponent_count_components(impl->cluster,kind);
436}
437
438icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge)
439{
440 struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
441
442 icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR);
443
444 impl->gauge = gauge;
445
446 return ICAL_NO_ERROR;
447}
448
449void icalfileset_clear(icalfileset* gauge)
450{
451 struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge;
452
453 impl->gauge = 0;
454
455}
456
457icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid)
458{
459 icalcompiter i;
460 struct icalfileset_impl* impl = (struct icalfileset_impl*)store;
461
462 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT);
463 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
464
465 icalcomponent *this = icalcompiter_deref(&i);
466 icalcomponent *inner = icalcomponent_get_first_real_component(this);
467 icalcomponent *p;
468 const char *this_uid;
469
470 if(inner != 0){
471 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
472 this_uid = icalproperty_get_uid(p);
473
474 if(this_uid==0){
475 icalerror_warn("icalfileset_fetch found a component with no UID");
476 continue;
477 }
478
479 if (strcmp(uid,this_uid)==0){
480 return this;
481 }
482 }
483 }
484
485 return 0;
486}
487
488int icalfileset_has_uid(icalfileset* store,const char* uid)
489{
490 assert(0); /* HACK, not implemented */
491 return 0;
492}
493
494/******* support routines for icalfileset_fetch_match *********/
495
496struct icalfileset_id{
497 char* uid;
498 char* recurrence_id;
499 int sequence;
500};
501
502void icalfileset_id_free(struct icalfileset_id *id)
503{
504 if(id->recurrence_id != 0){
505 free(id->recurrence_id);
506 }
507
508 if(id->uid != 0){
509 free(id->uid);
510 }
511
512}
513
514struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
515{
516
517 icalcomponent *inner;
518 struct icalfileset_id id;
519 icalproperty *p;
520
521 inner = icalcomponent_get_first_real_component(comp);
522
523 p = icalcomponent_get_first_property(inner, ICAL_UID_PROPERTY);
524
525 assert(p!= 0);
526
527 id.uid = strdup(icalproperty_get_uid(p));
528
529 p = icalcomponent_get_first_property(inner, ICAL_SEQUENCE_PROPERTY);
530
531 if(p == 0) {
532 id.sequence = 0;
533 } else {
534 id.sequence = icalproperty_get_sequence(p);
535 }
536
537 p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);
538
539 if (p == 0){
540 id.recurrence_id = 0;
541 } else {
542 icalvalue *v;
543 v = icalproperty_get_value(p);
544 id.recurrence_id = strdup(icalvalue_as_ical_string(v));
545
546 assert(id.recurrence_id != 0);
547 }
548
549 return id;
550}
551
552/* Find the component that is related to the given
553 component. Currently, it just matches based on UID and
554 RECURRENCE-ID */
555icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
556{
557 struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
558 icalcompiter i;
559
560 struct icalfileset_id comp_id, match_id;
561
562 comp_id = icalfileset_get_id(comp);
563
564 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT);
565 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
566
567 icalcomponent *match = icalcompiter_deref(&i);
568
569 match_id = icalfileset_get_id(match);
570
571 if(strcmp(comp_id.uid, match_id.uid) == 0 &&
572 ( comp_id.recurrence_id ==0 ||
573 strcmp(comp_id.recurrence_id, match_id.recurrence_id) ==0 )){
574
575 /* HACK. What to do with SEQUENCE? */
576
577 icalfileset_id_free(&match_id);
578 icalfileset_id_free(&comp_id);
579 return match;
580
581 }
582
583 icalfileset_id_free(&match_id);
584 }
585
586 icalfileset_id_free(&comp_id);
587 return 0;
588
589}
590
591
592icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old,
593 icalcomponent *new)
594{
595 assert(0); /* HACK, not implemented */
596 return ICAL_NO_ERROR;
597}
598
599
600/* Iterate through components */
601icalcomponent* icalfileset_get_current_component (icalfileset* cluster)
602{
603 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
604
605 icalerror_check_arg_rz((cluster!=0),"cluster");
606
607 return icalcomponent_get_current_component(impl->cluster);
608}
609
610
611icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
612{
613 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
614 icalcomponent *c=0;
615
616 icalerror_check_arg_rz((cluster!=0),"cluster");
617
618 do {
619 if (c == 0){
620 c = icalcomponent_get_first_component(impl->cluster,
621 ICAL_ANY_COMPONENT);
622 } else {
623 c = icalcomponent_get_next_component(impl->cluster,
624 ICAL_ANY_COMPONENT);
625 }
626
627 if(c != 0 && (impl->gauge == 0 ||
628 icalgauge_compare(impl->gauge,c) == 1)){
629 return c;
630 }
631
632 } while(c != 0);
633
634
635 return 0;
636}
637
638icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
639{
640 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
641 icalcomponent *c;
642
643 icalerror_check_arg_rz((cluster!=0),"cluster");
644
645 do {
646 c = icalcomponent_get_next_component(impl->cluster,
647 ICAL_ANY_COMPONENT);
648
649 if(c != 0 && (impl->gauge == 0 ||
650 icalgauge_compare(impl->gauge,c) == 1)){
651 return c;
652 }
653
654 } while(c != 0);
655
656
657 return 0;
658}
659
diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h
new file mode 100644
index 0000000..51254d2
--- a/dev/null
+++ b/libical/src/libicalss/icalfileset.h
@@ -0,0 +1,107 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalfileset.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 ICALFILESET_H
30#define ICALFILESET_H
31
32#include "icalerror.h"
33#include "ical.h"
34#include "icalset.h"
35#include "icalgauge.h"
36
37extern int icalfileset_safe_saves;
38
39typedef void icalfileset;
40
41
42/* icalfileset
43 icalfilesetfile
44 icalfilesetdir
45*/
46
47
48icalfileset* icalfileset_new(const char* path);
49
50#ifdef _WIN32
51#define mode_t int
52#endif
53
54/* Like _new, but takes open() flags for opening the file */
55icalfileset* icalfileset_new_open(const char* path,
56 int flags, mode_t mode);
57
58void icalfileset_free(icalfileset* cluster);
59
60const char* icalfileset_path(icalfileset* cluster);
61
62/* Mark the cluster as changed, so it will be written to disk when it
63 is freed. Commit writes to disk immediately. */
64void icalfileset_mark(icalfileset* cluster);
65icalerrorenum icalfileset_commit(icalfileset* cluster);
66
67icalerrorenum icalfileset_add_component(icalfileset* cluster,
68 icalcomponent* child);
69
70icalerrorenum icalfileset_remove_component(icalfileset* cluster,
71 icalcomponent* child);
72
73int icalfileset_count_components(icalfileset* cluster,
74 icalcomponent_kind kind);
75
76/* Restrict the component returned by icalfileset_first, _next to those
77 that pass the gauge. _clear removes the gauge */
78icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge);
79void icalfileset_clear(icalfileset* store);
80
81/* Get and search for a component by uid */
82icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid);
83int icalfileset_has_uid(icalfileset* cluster, const char* uid);
84icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c);
85
86
87/* Modify components according to the MODIFY method of CAP. Works on
88 the currently selected components. */
89icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp,
90 icalcomponent *newcomp);
91
92/* Iterate through components. If a guage has been defined, these
93 will skip over components that do not pass the gauge */
94
95icalcomponent* icalfileset_get_current_component (icalfileset* cluster);
96icalcomponent* icalfileset_get_first_component(icalfileset* cluster);
97icalcomponent* icalfileset_get_next_component(icalfileset* cluster);
98/* Return a reference to the internal component. You probably should
99 not be using this. */
100
101icalcomponent* icalfileset_get_component(icalfileset* cluster);
102
103
104#endif /* !ICALFILESET_H */
105
106
107
diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h
new file mode 100644
index 0000000..fcd3415
--- a/dev/null
+++ b/libical/src/libicalss/icalfilesetimpl.h
@@ -0,0 +1,49 @@
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#include "icalgauge.h"
34
35/* This definition is in its own file so it can be kept out of the
36 main header file, but used by "friend classes" like icaldirset*/
37
38#define ICALFILESET_ID "fset"
39
40struct icalfileset_impl {
41
42 char id[5]; /*fset*/
43 char *path;
44 icalcomponent* cluster;
45 icalgauge* gauge;
46 int changed;
47 int fd; /* file descriptor */
48};
49
diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c
new file mode 100644
index 0000000..b958ecf
--- a/dev/null
+++ b/libical/src/libicalss/icalgauge.c
@@ -0,0 +1,447 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalgauge.c
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#include "ical.h"
30#include "icalgauge.h"
31#include "icalgaugeimpl.h"
32#include <stdlib.h>
33
34extern char* input_buffer;
35extern char* input_buffer_p;
36int ssparse(void);
37
38struct icalgauge_impl *icalss_yy_gauge;
39
40icalgauge* icalgauge_new_from_sql(char* sql)
41{
42 struct icalgauge_impl *impl;
43
44 int r;
45
46 if ( ( impl = (struct icalgauge_impl*)
47 malloc(sizeof(struct icalgauge_impl))) == 0) {
48 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
49 return 0;
50 }
51
52 impl->select = pvl_newlist();
53 impl->from = pvl_newlist();
54 impl->where = pvl_newlist();
55
56 icalss_yy_gauge = impl;
57
58 input_buffer_p = input_buffer = sql;
59 r = ssparse();
60
61 return impl;
62}
63
64
65void icalgauge_free(icalgauge* gauge)
66{
67 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
68 struct icalgauge_where *w;
69
70 assert(impl->select != 0);
71 assert(impl->where != 0);
72 assert(impl->from != 0);
73
74 if(impl->select){
75 while( (w=pvl_pop(impl->select)) != 0){
76 if(w->value != 0){
77 free(w->value);
78 }
79 free(w);
80 }
81 pvl_free(impl->select);
82 }
83
84 if(impl->where){
85 while( (w=pvl_pop(impl->where)) != 0){
86
87 if(w->value != 0){
88 free(w->value);
89 }
90 free(w);
91 }
92 pvl_free(impl->where);
93 }
94
95 if(impl->from){
96 pvl_free(impl->from);
97 }
98
99}
100
101/* Convert a VQUERY component into a gauge */
102icalcomponent* icalgauge_make_gauge(icalcomponent* query);
103
104/* icaldirset_test compares a component against a gauge, and returns
105 true if the component passes the test
106
107 The gauge is a VCALENDAR component that specifies how to test the
108 target components. The guage holds a collection of VEVENT, VTODO or
109 VJOURNAL sub-components. Each of the sub-components has a
110 collection of properties that are compared to corresponding
111 properties in the target component, according to the
112 X-LIC-COMPARETYPE parameters to the gauge's properties.
113
114 When a gauge has several sub-components, the results of testing the
115 target against each of them is ORed together - the target
116 component will pass if it matches any of the sub-components in the
117 gauge. However, the results of matching the properties in a
118 sub-component are ANDed -- the target must match every property in
119 a gauge sub-component to match the sub-component.
120
121 Here is an example:
122
123 BEGIN:XROOT
124 DTSTART;X-LIC-COMPARETYPE=LESS:19981025T020000
125 ORGANIZER;X-LIC-COMPARETYPE=EQUAL:mrbig@host.com
126 END:XROOT
127 BEGIN:XROOT
128 LOCATION;X-LIC-COMPARETYPE=EQUAL:McNary's Pub
129 END:XROOT
130
131 This gauge has two sub-components; one which will match a VEVENT
132 based on start time, and organizer, and another that matches based
133 on LOCATION. A target component will pass the test if it matched
134 either of the sub-components.
135
136 */
137
138
139int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
140{
141 int pass = 1,localpass = 0;
142 icalproperty *p;
143 icalcomponent *child,*subgauge;
144 icalcomponent_kind gaugekind, compkind;
145
146 icalerror_check_arg_rz( (comp!=0), "comp");
147 icalerror_check_arg_rz( (gauge!=0), "gauge");
148
149 gaugekind = icalcomponent_isa(gauge);
150 compkind = icalcomponent_isa(comp);
151
152 if( ! (gaugekind == compkind || gaugekind == ICAL_ANY_COMPONENT) ){
153 return 0;
154 }
155
156 /* Test properties. For each property in the gauge, search through
157 the component for a similar property. If one is found, compare
158 the two properties value with the comparison specified in the
159 gauge with the X-LIC-COMPARETYPE parameter */
160
161 for(p = icalcomponent_get_first_property(gauge,ICAL_ANY_PROPERTY);
162 p != 0;
163 p = icalcomponent_get_next_property(gauge,ICAL_ANY_PROPERTY)){
164
165 icalproperty* targetprop;
166 icalparameter* compareparam;
167 icalparameter_xliccomparetype compare;
168 int rel; /* The relationship between the gauge and target values.*/
169
170 /* Extract the comparison type from the gauge. If there is no
171 comparison type, assume that it is "EQUAL" */
172
173 compareparam = icalproperty_get_first_parameter(
174 p,
175 ICAL_XLICCOMPARETYPE_PARAMETER);
176
177 if (compareparam!=0){
178 compare = icalparameter_get_xliccomparetype(compareparam);
179 } else {
180 compare = ICAL_XLICCOMPARETYPE_EQUAL;
181 }
182
183 /* Find a property in the component that has the same type
184 as the gauge property. HACK -- multiples of a single
185 property type in the gauge will match only the first
186 instance in the component */
187
188 targetprop = icalcomponent_get_first_property(comp,
189 icalproperty_isa(p));
190
191 if(targetprop != 0){
192
193 /* Compare the values of the gauge property and the target
194 property */
195
196 rel = icalvalue_compare(icalproperty_get_value(p),
197 icalproperty_get_value(targetprop));
198
199 /* Now see if the comparison is equavalent to the comparison
200 specified in the gauge */
201
202 if (rel == compare){
203 localpass++;
204 } else if (compare == ICAL_XLICCOMPARETYPE_LESSEQUAL &&
205 ( rel == ICAL_XLICCOMPARETYPE_LESS ||
206 rel == ICAL_XLICCOMPARETYPE_EQUAL)) {
207 localpass++;
208 } else if (compare == ICAL_XLICCOMPARETYPE_GREATEREQUAL &&
209 ( rel == ICAL_XLICCOMPARETYPE_GREATER ||
210 rel == ICAL_XLICCOMPARETYPE_EQUAL)) {
211 localpass++;
212 } else if (compare == ICAL_XLICCOMPARETYPE_NOTEQUAL &&
213 ( rel == ICAL_XLICCOMPARETYPE_GREATER ||
214 rel == ICAL_XLICCOMPARETYPE_LESS)) {
215 localpass++;
216 } else {
217 localpass = 0;
218 }
219
220 pass = pass && (localpass>0);
221 }
222 }
223
224 /* Test subcomponents. Look for a child component that has a
225 counterpart in the gauge. If one is found, recursively call
226 icaldirset_test */
227
228 for(subgauge = icalcomponent_get_first_component(gauge,ICAL_ANY_COMPONENT);
229 subgauge != 0;
230 subgauge = icalcomponent_get_next_component(gauge,ICAL_ANY_COMPONENT)){
231
232 gaugekind = icalcomponent_isa(subgauge);
233
234 if (gaugekind == ICAL_ANY_COMPONENT){
235 child = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
236 } else {
237 child = icalcomponent_get_first_component(comp,gaugekind);
238 }
239
240 if(child !=0){
241 localpass = icalgauge_compare_recurse(child,subgauge);
242 pass = pass && localpass;
243 } else {
244 pass = 0;
245 }
246 }
247
248 return pass;
249}
250
251
252int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
253{
254
255 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
256 icalcomponent *inner;
257 int local_pass = 0;
258 int last_clause = 1, this_clause = 1;
259 pvl_elem e;
260
261 icalerror_check_arg_rz( (comp!=0), "comp");
262 icalerror_check_arg_rz( (gauge!=0), "gauge");
263
264 inner = icalcomponent_get_first_real_component(comp);
265
266 if(inner == 0){
267 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
268 return 0;
269 }
270
271
272 /* Check that this component is one of the FROM types */
273 local_pass = 0;
274 for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){
275 icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
276
277 if(k == icalcomponent_isa(inner)){
278 local_pass=1;
279 }
280 }
281
282 if(local_pass == 0){
283 return 0;
284 }
285
286
287 /* Check each where clause against the component */
288 for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){
289 struct icalgauge_where *w = pvl_data(e);
290 icalcomponent *sub_comp;
291 icalvalue *v;
292 icalproperty *prop;
293 icalvalue_kind vk;
294
295 if(w->prop == ICAL_NO_PROPERTY || w->value == 0){
296 icalerror_set_errno(ICAL_INTERNAL_ERROR);
297 return 0;
298 }
299
300 /* First, create a value from the gauge */
301 vk = icalenum_property_kind_to_value_kind(w->prop);
302
303 if(vk == ICAL_NO_VALUE){
304 icalerror_set_errno(ICAL_INTERNAL_ERROR);
305 return 0;
306 }
307
308 v = icalvalue_new_from_string(vk,w->value);
309
310 if (v == 0){
311 /* Keep error set by icalvalue_from-string*/
312 return 0;
313 }
314
315 /* Now find the corresponding property in the component,
316 descending into a sub-component if necessary */
317
318 if(w->comp == ICAL_NO_COMPONENT){
319 sub_comp = inner;
320 } else {
321 sub_comp = icalcomponent_get_first_component(inner,w->comp);
322 if(sub_comp == 0){
323 return 0;
324 }
325 }
326
327 this_clause = 0;
328 local_pass = 0;
329 for(prop = icalcomponent_get_first_property(sub_comp,w->prop);
330 prop != 0;
331 prop = icalcomponent_get_next_property(sub_comp,w->prop)){
332 icalvalue* prop_value;
333 icalgaugecompare relation;
334
335 prop_value = icalproperty_get_value(prop);
336
337 relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
338
339 if (relation == w->compare){
340 local_pass++;
341 } else if (w->compare == ICALGAUGECOMPARE_LESSEQUAL &&
342 ( relation == ICALGAUGECOMPARE_LESS ||
343 relation == ICALGAUGECOMPARE_EQUAL)) {
344 local_pass++;
345 } else if (w->compare == ICALGAUGECOMPARE_GREATEREQUAL &&
346 ( relation == ICALGAUGECOMPARE_GREATER ||
347 relation == ICALGAUGECOMPARE_EQUAL)) {
348 local_pass++;
349 } else if (w->compare == ICALGAUGECOMPARE_NOTEQUAL &&
350 ( relation == ICALGAUGECOMPARE_GREATER ||
351 relation == ICALGAUGECOMPARE_LESS)) {
352 local_pass++;
353 } else {
354 local_pass = 0;
355 }
356 }
357
358 this_clause = local_pass > 0 ? 1 : 0;
359
360 /* Now look at the logic operator for this clause to see how
361 the value should be merge with the previous clause */
362
363 if(w->logic == ICALGAUGELOGIC_AND){
364 last_clause = this_clause && last_clause;
365 } else if(w->logic == ICALGAUGELOGIC_AND) {
366 last_clause = this_clause || last_clause;
367 } else {
368 last_clause = this_clause;
369 }
370 }
371
372 return last_clause;
373
374}
375
376
377void icalgauge_dump(icalcomponent* gauge)
378{
379
380 pvl_elem *p;
381 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
382
383
384 printf("--- Select ---\n");
385 for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){
386 struct icalgauge_where *w = pvl_data(p);
387
388 if(w->comp != ICAL_NO_COMPONENT){
389 printf("%s ",icalenum_component_kind_to_string(w->comp));
390 }
391
392 if(w->prop != ICAL_NO_PROPERTY){
393 printf("%s ",icalenum_property_kind_to_string(w->prop));
394 }
395
396 if (w->compare != ICALGAUGECOMPARE_NONE){
397 printf("%d ",w->compare);
398 }
399
400
401 if (w->value!=0){
402 printf("%s",w->value);
403 }
404
405
406 printf("\n");
407 }
408
409 printf("--- From ---\n");
410 for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){
411 icalcomponent_kind k = (icalcomponent_kind)pvl_data(p);
412
413 printf("%s\n",icalenum_component_kind_to_string(k));
414 }
415
416 printf("--- Where ---\n");
417 for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){
418 struct icalgauge_where *w = pvl_data(p);
419
420 if(w->logic != ICALGAUGELOGIC_NONE){
421 printf("%d ",w->logic);
422 }
423
424 if(w->comp != ICAL_NO_COMPONENT){
425 printf("%s ",icalenum_component_kind_to_string(w->comp));
426 }
427
428 if(w->prop != ICAL_NO_PROPERTY){
429 printf("%s ",icalenum_property_kind_to_string(w->prop));
430 }
431
432 if (w->compare != ICALGAUGECOMPARE_NONE){
433 printf("%d ",w->compare);
434 }
435
436
437 if (w->value!=0){
438 printf("%s",w->value);
439 }
440
441
442 printf("\n");
443 }
444
445
446}
447
diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h
new file mode 100644
index 0000000..1caf0ac
--- a/dev/null
+++ b/libical/src/libicalss/icalgauge.h
@@ -0,0 +1,51 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalgauge.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 ICALGAUGE_H
30#define ICALGAUGE_H
31
32typedef void icalgauge;
33
34icalgauge* icalgauge_new_from_sql(char* sql);
35
36void icalgauge_free(icalgauge* gauge);
37
38char* icalgauge_as_sql(icalcomponent* gauge);
39
40void icalgauge_dump(icalcomponent* gauge);
41
42/* Return true is comp matches the gauge. The component must be in
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
44 sub component */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46
47/* Clone the component, but only return the properties specified in
48 the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
50
51#endif /* ICALGAUGE_H*/
diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h
new file mode 100644
index 0000000..73a2813
--- a/dev/null
+++ b/libical/src/libicalss/icalgaugeimpl.h
@@ -0,0 +1,63 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalgaugeimpl.h
4 CREATOR: eric 09 Aug 2000
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======================================================================*/
24
25#include "ical.h"
26
27#include "pvl.h"
28
29typedef enum icalgaugecompare {
30 ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
31 ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
32 ICALGAUGECOMPARE_LESSEQUAL=ICAL_XLICCOMPARETYPE_LESSEQUAL,
33 ICALGAUGECOMPARE_GREATER=ICAL_XLICCOMPARETYPE_GREATER,
34 ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
35 ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
36 ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
37 ICALGAUGECOMPARE_NONE=0
38} icalgaugecompare;
39
40typedef enum icalgaugelogic {
41 ICALGAUGELOGIC_NONE,
42 ICALGAUGELOGIC_AND,
43 ICALGAUGELOGIC_OR
44} icalgaugelogic;
45
46
47struct icalgauge_where {
48 icalgaugelogic logic;
49 icalcomponent_kind comp;
50 icalproperty_kind prop;
51 icalgaugecompare compare;
52 char* value;
53};
54
55struct icalgauge_impl
56{
57
58 pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/
59 pvl_list from; /* List of component_kinds, as integers */
60 pvl_list where; /* List of icalgaugecompare */
61};
62
63
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c
new file mode 100644
index 0000000..d5c57c1
--- a/dev/null
+++ b/libical/src/libicalss/icalmessage.c
@@ -0,0 +1,373 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalmessage.c
4 CREATOR: ebusboom 07 Nov 2000
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "icalmessage.h"
30#include "icalenums.h"
31#include <ctype.h> /* for tolower()*/
32#include <string.h> /* for strstr */
33#include <stdlib.h> /* for free(), malloc() */
34icalcomponent* icalmessage_get_inner(icalcomponent* comp)
35{
36 if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
37 return icalcomponent_get_first_real_component(comp);
38 } else {
39 return comp;
40 }
41}
42
43char* lowercase(const char* str)
44{
45 char* p = 0;
46 char* n = icalmemory_strdup(str);
47
48 if(str ==0){
49 return 0;
50 }
51
52 for(p = n; *p!=0; p++){
53 *p = tolower(*p);
54 }
55
56 return n;
57}
58
59icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user)
60{
61 icalcomponent *inner = icalmessage_get_inner(comp);
62 icalproperty *p,*attendee = 0;
63 char* luser = lowercase(user);
64
65 for(p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY);
66 p != 0;
67 p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY)
68 ){
69
70 char* lattendee;
71
72 lattendee = lowercase(icalproperty_get_attendee(p));
73
74 if (strstr(lattendee,user) != 0){
75 attendee = p;
76 break;
77 }
78
79 free(lattendee);
80
81 }
82
83 free(luser);
84
85 return attendee;
86
87}
88
89void icalmessage_copy_properties(icalcomponent* to, icalcomponent* from,
90 icalproperty_kind kind)
91{
92 icalcomponent *to_inner = icalmessage_get_inner(to);
93 icalcomponent *from_inner = icalmessage_get_inner(from);
94
95 if (to_inner == 0 && from_inner == 0){
96 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
97 return;
98 }
99
100 if(!icalcomponent_get_first_property(from_inner,kind)){
101 return;
102 }
103
104 icalcomponent_add_property(to_inner,
105 icalproperty_new_clone(
106 icalcomponent_get_first_property(
107 from_inner,
108 kind)
109 )
110 );
111}
112
113icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
114 const char* user,
115 const char* msg)
116{
117 icalproperty *attendee;
118 char tmp[45];
119
120 icalcomponent *reply = icalcomponent_vanew(
121 ICAL_VCALENDAR_COMPONENT,
122 icalproperty_new_method(ICAL_METHOD_REPLY),
123 icalcomponent_vanew(
124 ICAL_VEVENT_COMPONENT,
125 icalproperty_new_dtstamp(icaltime_from_timet(time(0),0)),
126 0),
127 0);
128
129 icalcomponent *inner = icalmessage_get_inner(reply);
130
131 icalerror_check_arg_rz(c,"c");
132
133 icalmessage_copy_properties(reply,c,ICAL_UID_PROPERTY);
134 icalmessage_copy_properties(reply,c,ICAL_ORGANIZER_PROPERTY);
135 icalmessage_copy_properties(reply,c,ICAL_RECURRENCEID_PROPERTY);
136 icalmessage_copy_properties(reply,c,ICAL_SUMMARY_PROPERTY);
137 icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY);
138
139 icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0));
140
141 if(msg != 0){
142 icalcomponent_add_property(inner,icalproperty_new_comment(msg));
143 }
144
145 /* Copy this user's attendee property */
146
147 attendee = icalmessage_find_attendee(c,user);
148
149 if (attendee == 0){
150 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
151 icalcomponent_free(reply);
152 return 0;
153 }
154
155 icalcomponent_add_property(inner,icalproperty_new_clone(attendee));
156
157 /* Add PRODID and VERSION */
158
159 icalcomponent_add_property(reply,icalproperty_new_version("2.0"));
160
161 sprintf(tmp,
162 "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION);
163 icalcomponent_add_property(reply,icalproperty_new_prodid(tmp));
164
165 return reply;
166
167}
168
169icalcomponent* icalmessage_new_accept_reply(icalcomponent* c,
170 const char* user,
171 const char* msg)
172{
173
174 icalcomponent *reply;
175 icalproperty *attendee;
176 icalcomponent *inner;
177
178 icalerror_check_arg_rz(c,"c");
179
180 reply = icalmessage_new_reply_base(c,user,msg);
181
182 if(reply == 0){
183 return 0;
184 }
185
186 inner = icalmessage_get_inner(reply);
187
188 attendee = icalcomponent_get_first_property(inner,
189 ICAL_ATTENDEE_PROPERTY);
190
191 icalproperty_set_parameter(attendee,
192 icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED));
193
194 return reply;
195}
196
197icalcomponent* icalmessage_new_decline_reply(icalcomponent* c,
198 const char* user,
199 const char* msg)
200{
201 icalcomponent *reply;
202 icalproperty *attendee;
203 icalcomponent *inner;
204
205 icalerror_check_arg_rz(c,"c");
206
207 reply = icalmessage_new_reply_base(c,user,msg);
208 inner = icalmessage_get_inner(reply);
209 if(reply == 0){
210 return 0;
211 }
212
213 attendee = icalcomponent_get_first_property(inner,
214 ICAL_ATTENDEE_PROPERTY);
215
216 icalproperty_set_parameter(attendee,
217 icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED));
218
219 return reply;
220}
221
222/* New is modified version of old */
223icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
224 icalcomponent* newc,
225 const char* user,
226 const char* msg)
227{
228 icalcomponent *reply;
229
230 icalerror_check_arg_rz(oldc,"oldc");
231 icalerror_check_arg_rz(newc,"newc");
232
233 reply = icalcomponent_new_clone(newc);
234
235 icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
236
237 return newc;
238
239}
240
241
242icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c,
243 const char* user,
244 const char* delegatee,
245 const char* msg)
246{
247
248 icalcomponent *reply;
249 icalproperty *attendee;
250 icalcomponent *inner;
251
252 icalerror_check_arg_rz(c,"c");
253
254 reply = icalmessage_new_reply_base(c,user,msg);
255 inner = icalmessage_get_inner(reply);
256 if(reply == 0){
257 return 0;
258 }
259
260 attendee = icalcomponent_get_first_property(inner,
261 ICAL_ATTENDEE_PROPERTY);
262
263 icalproperty_set_parameter(attendee,
264 icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED));
265
266 icalproperty_set_parameter(attendee,
267 icalparameter_new_delegatedto(delegatee));
268
269 return reply;
270
271}
272
273icalcomponent* icalmessage_new_delegate_request(icalcomponent* c,
274 const char* user,
275 const char* delegatee,
276 const char* msg)
277{
278
279 icalcomponent *reply;
280 icalproperty *attendee;
281 icalcomponent *inner;
282
283 icalerror_check_arg_rz(c,"c");
284
285 reply = icalmessage_new_reply_base(c,user,msg);
286 inner = icalmessage_get_inner(reply);
287
288 if(reply == 0){
289 return 0;
290 }
291
292 icalcomponent_set_method(reply,ICAL_METHOD_REQUEST);
293
294 attendee = icalcomponent_get_first_property(inner,
295 ICAL_ATTENDEE_PROPERTY);
296
297 icalproperty_set_parameter(attendee,
298 icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED));
299
300 icalproperty_set_parameter(attendee,
301 icalparameter_new_delegatedto(delegatee));
302
303 icalcomponent_add_property(
304 inner,
305 icalproperty_vanew_attendee(
306 delegatee,
307 icalparameter_new_delegatedfrom(
308 icalproperty_get_attendee(attendee)
309 ),
310 0
311 )
312 );
313
314
315 return reply;
316
317}
318
319
320icalcomponent* icalmessage_new_cancel_event(icalcomponent* c,
321 const char* user,
322 const char* msg);
323icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c,
324 const char* user,
325 const char* msg);
326icalcomponent* icalmessage_new_cancel_all(icalcomponent* c,
327 const char* user,
328 const char* msg);
329
330
331
332icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
333 const char* user,
334 const char* msg,
335 const char* debug,
336 icalrequeststatus code)
337{
338 icalcomponent *reply;
339 icalcomponent *inner, *cinner;
340 struct icalreqstattype rs;
341
342 icalerror_check_arg_rz(c,"c");
343
344 reply = icalmessage_new_reply_base(c,user,msg);
345 inner = icalmessage_get_inner(reply);
346 cinner = icalmessage_get_inner(c);
347 if(reply == 0){
348 return 0;
349 }
350
351 if( code != ICAL_UNKNOWN_STATUS){
352 rs.code = code;
353 rs.debug = debug;
354
355 icalcomponent_add_property(inner,
356 icalproperty_new_requeststatus(rs));
357 } else { /* code == ICAL_UNKNOWN_STATUS */
358
359 /* Copy all of the request status properties */
360 icalproperty *p;
361 for(p = icalcomponent_get_first_property(cinner,
362 ICAL_REQUESTSTATUS_PROPERTY);
363 p != 0;
364 p = icalcomponent_get_next_property(cinner,
365 ICAL_REQUESTSTATUS_PROPERTY)){
366
367
368 icalcomponent_add_property(inner,icalproperty_new_clone(p));
369 }
370 }
371
372 return reply;
373}
diff --git a/libical/src/libicalss/icalmessage.h b/libical/src/libicalss/icalmessage.h
new file mode 100644
index 0000000..24f1c9f
--- a/dev/null
+++ b/libical/src/libicalss/icalmessage.h
@@ -0,0 +1,71 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalmessage.h
4 CREATOR: eric 07 Nov 2000
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
24 =========================================================================*/
25
26#include "ical.h"
27
28#ifndef ICALMESSAGE_H
29#define ICALMESSAGE_H
30
31
32icalcomponent* icalmessage_new_accept_reply(icalcomponent* c,
33 const char* user,
34 const char* msg);
35
36icalcomponent* icalmessage_new_decline_reply(icalcomponent* c,
37 const char* user,
38 const char* msg);
39
40/* New is modified version of old */
41icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
42 icalcomponent* newc,
43 const char* user,
44 const char* msg);
45
46
47icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c,
48 const char* user,
49 const char* delegatee,
50 const char* msg);
51
52
53icalcomponent* icalmessage_new_cancel_event(icalcomponent* c,
54 const char* user,
55 const char* msg);
56icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c,
57 const char* user,
58 const char* msg);
59icalcomponent* icalmessage_new_cancel_all(icalcomponent* c,
60 const char* user,
61 const char* msg);
62
63
64icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
65 const char* user,
66 const char* msg,
67 const char* debug,
68 icalrequeststatus rs);
69
70
71#endif /* ICALMESSAGE_H*/
diff --git a/libical/src/libicalss/icalset.c b/libical/src/libicalss/icalset.c
new file mode 100644
index 0000000..2120609
--- a/dev/null
+++ b/libical/src/libicalss/icalset.c
@@ -0,0 +1,367 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalset.c
4 CREATOR: eric 17 Jul 2000
5
6
7 Icalset is the "base class" for representations of a collection of
8 iCal components. Derived classes (actually delegates) include:
9
10 icalfileset Store components in a single file
11 icaldirset Store components in multiple files in a directory
12 icalheapset Store components on the heap
13 icalmysqlset Store components in a mysql database.
14
15 $Id$
16 $Locker$
17
18 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
19
20 This program is free software; you can redistribute it and/or modify
21 it under the terms of either:
22
23 The LGPL as published by the Free Software Foundation, version
24 2.1, available at: http://www.fsf.org/copyleft/lesser.html
25
26 Or:
27
28 The Mozilla Public License Version 1.0. You may obtain a copy of
29 the License at http://www.mozilla.org/MPL/
30
31 The Original Code is eric. The Initial Developer of the Original
32 Code is Eric Busboom
33
34
35======================================================================*/
36
37#include "ical.h"
38#include "icalset.h"
39#include "icalfileset.h"
40#include "icalfilesetimpl.h"
41#include "icaldirset.h"
42#include "icaldirsetimpl.h"
43#include <stdlib.h>
44/*#include "icalheapset.h"*/
45/*#include "icalmysqlset.h"*/
46
47#define ICALSET_ID "set "
48
49struct icalset_fp {
50 void (*free)(icalset* set);
51 const char* (*path)(icalset* set);
52 void (*mark)(icalset* set);
53 icalerrorenum (*commit)(icalset* set);
54 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
55 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
56 int (*count_components)(icalset* set,
57 icalcomponent_kind kind);
58 icalerrorenum (*select)(icalset* set, icalcomponent* gauge);
59 void (*clear)(icalset* set);
60 icalcomponent* (*fetch)(icalset* set, const char* uid);
61 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
62 int (*has_uid)(icalset* set, const char* uid);
63 icalerrorenum (*modify)(icalset* set, icalcomponent *old,
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,
72 icaldirset_path,
73 icaldirset_mark,
74 icaldirset_commit,
75 icaldirset_add_component,
76 icaldirset_remove_component,
77 icaldirset_count_components,
78 icaldirset_select,
79 icaldirset_clear,
80 icaldirset_fetch,
81 icaldirset_fetch_match,
82 icaldirset_has_uid,
83 icaldirset_modify,
84 icaldirset_get_current_component,
85 icaldirset_get_first_component,
86 icaldirset_get_next_component
87};
88
89
90struct icalset_fp icalset_fileset_fp = {
91 icalfileset_free,
92 icalfileset_path,
93 icalfileset_mark,
94 icalfileset_commit,
95 icalfileset_add_component,
96 icalfileset_remove_component,
97 icalfileset_count_components,
98 icalfileset_select,
99 icalfileset_clear,
100 icalfileset_fetch,
101 icalfileset_fetch_match,
102 icalfileset_has_uid,
103 icalfileset_modify,
104 icalfileset_get_current_component,
105 icalfileset_get_first_component,
106 icalfileset_get_next_component
107};
108
109struct icalset_impl {
110
111 char id[5]; /* "set " */
112
113 void *derived_impl;
114 struct icalset_fp *fp;
115};
116
117/* Figure out what was actually passed in as the set. This could be a
118 set or and of the derived types such as dirset or fileset. Note
119 this routine returns a value, not a reference, to avoid memory
120 leaks in the methods */
121struct icalset_impl icalset_get_impl(icalset* set)
122{
123 struct icalset_impl impl;
124
125 memset(&impl,0,sizeof(impl));
126 icalerror_check_arg_re( (set!=0),"set",impl);
127
128 if(strcmp((char*)set,ICALSET_ID)==0) {
129 /* It is actually a set, so just sent the reference back out. */
130 return *(struct icalset_impl*)set;
131 } else if(strcmp((char*)set,ICALFILESET_ID)==0) {
132 /* Make a new set from the fileset */
133 impl.fp = &icalset_fileset_fp;
134 impl.derived_impl = set;
135 strcpy(impl.id,ICALFILESET_ID);/* HACK. Is this necessary? */
136 return impl;
137 } else if(strcmp((char*)set,ICALDIRSET_ID)==0) {
138 /* Make a new set from the dirset */
139 impl.fp = &icalset_dirset_fp;
140 impl.derived_impl = set;
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}
149
150
151struct icalset_impl* icalset_new_impl()
152{
153
154 struct icalset_impl* impl;
155
156 if ( ( impl = (struct icalset_impl*)
157 malloc(sizeof(struct icalset_impl))) == 0) {
158 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
159 return 0;
160 }
161
162 strcpy(impl->id,ICALSET_ID);
163
164 impl->derived_impl = 0;
165 impl->fp = 0;
166
167 return impl;
168}
169
170struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset)
171{
172 struct icalset_impl *impl = icalset_new_impl();
173
174 icalerror_check_arg_rz( (fset!=0),"fset");
175
176 if(impl == 0){
177 free(impl);
178 return 0;
179 }
180
181 impl->derived_impl = fset;
182
183 if (impl->derived_impl == 0){
184 free(impl);
185 return 0;
186 }
187
188 impl->fp = &icalset_fileset_fp;
189
190 return (struct icalset_impl*)impl;
191}
192
193icalset* icalset_new_file(const char* path)
194{
195 icalfileset *fset = icalfileset_new(path);
196
197 if(fset == 0){
198 return 0;
199 }
200
201 return (icalset*)icalset_new_file_from_ref(fset);
202}
203
204icalset* icalset_new_dir_from_ref(icaldirset *dset)
205{
206
207 struct icalset_impl *impl = icalset_new_impl();
208
209 icalerror_check_arg_rz( (dset!=0),"dset");
210
211 if(impl == 0){
212 return 0;
213 }
214
215 impl->derived_impl = dset;
216
217 if (impl->derived_impl == 0){
218 free(impl);
219 return 0;
220 }
221
222 impl->fp = &icalset_dirset_fp;
223
224 return impl;
225}
226
227icalset* icalset_new_dir(const char* path)
228{
229 icaldirset *dset = icaldirset_new(path);
230
231 if(dset == 0){
232 return 0;
233 }
234
235 return icalset_new_dir_from_ref(dset);
236}
237
238icalset* icalset_new_heap(void)
239{
240 struct icalset_impl *impl = icalset_new_impl();
241
242
243 if(impl == 0){
244 free(impl);
245 return 0;
246 }
247
248 return 0;
249}
250
251icalset* icalset_new_mysql(const char* path)
252{
253 struct icalset_impl *impl = icalset_new_impl();
254
255 if(impl == 0){
256 free(impl);
257 return 0;
258 }
259
260 return 0;
261}
262
263void icalset_free(icalset* set)
264{
265 struct icalset_impl impl = icalset_get_impl(set);
266 (*(impl.fp->free))(impl.derived_impl);
267
268 if(strcmp((char*)set,ICALSET_ID)) {
269 free(set);
270 }
271}
272
273const char* icalset_path(icalset* set)
274{
275 struct icalset_impl impl = icalset_get_impl(set);
276 return (*(impl.fp->path))(impl.derived_impl);
277}
278
279void icalset_mark(icalset* set)
280{
281 struct icalset_impl impl = icalset_get_impl(set);
282 (*(impl.fp->mark))(impl.derived_impl);
283}
284
285icalerrorenum icalset_commit(icalset* set)
286{
287 struct icalset_impl impl = icalset_get_impl(set);
288 return (*(impl.fp->commit))(impl.derived_impl);
289}
290
291icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp)
292{
293 struct icalset_impl impl = icalset_get_impl(set);
294 return (*(impl.fp->add_component))(impl.derived_impl,comp);
295}
296
297icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp)
298{
299 struct icalset_impl impl = icalset_get_impl(set);
300 return (*(impl.fp->remove_component))(impl.derived_impl,comp);
301}
302
303int icalset_count_components(icalset* set,icalcomponent_kind kind)
304{
305 struct icalset_impl impl = icalset_get_impl(set);
306 return (*(impl.fp->count_components))(impl.derived_impl,kind);
307}
308
309icalerrorenum icalset_select(icalset* set, icalcomponent* gauge)
310{
311 struct icalset_impl impl = icalset_get_impl(set);
312 return (*(impl.fp->select))(impl.derived_impl,gauge);
313}
314
315void icalset_clear(icalset* set)
316{
317 struct icalset_impl impl = icalset_get_impl(set);
318 (*(impl.fp->clear))(impl.derived_impl);
319}
320
321icalcomponent* icalset_fetch(icalset* set, const char* uid)
322{
323 struct icalset_impl impl = icalset_get_impl(set);
324 return (*(impl.fp->fetch))(impl.derived_impl,uid);
325}
326
327icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp)
328{
329 struct icalset_impl impl = icalset_get_impl(set);
330 return (*(impl.fp->fetch_match))(impl.derived_impl,comp);
331}
332
333
334int icalset_has_uid(icalset* set, const char* uid)
335{
336 struct icalset_impl impl = icalset_get_impl(set);
337 return (*(impl.fp->has_uid))(impl.derived_impl,uid);
338}
339
340icalerrorenum icalset_modify(icalset* set, icalcomponent *old,
341 icalcomponent *new)
342{
343 struct icalset_impl impl = icalset_get_impl(set);
344 return (*(impl.fp->modify))(impl.derived_impl,old,new);
345}
346
347icalcomponent* icalset_get_current_component(icalset* set)
348{
349 struct icalset_impl impl = icalset_get_impl(set);
350 return (*(impl.fp->get_current_component))(impl.derived_impl);
351}
352
353icalcomponent* icalset_get_first_component(icalset* set)
354{
355 struct icalset_impl impl = icalset_get_impl(set);
356 return (*(impl.fp->get_first_component))(impl.derived_impl);
357}
358
359icalcomponent* icalset_get_next_component(icalset* set)
360{
361 struct icalset_impl impl = icalset_get_impl(set);
362 return (*(impl.fp->get_next_component))(impl.derived_impl);
363}
364
365
366
367
diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h
new file mode 100644
index 0000000..7b083da
--- a/dev/null
+++ b/libical/src/libicalss/icalset.h
@@ -0,0 +1,111 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalset.h
4 CREATOR: eric 28 November 1999
5
6
7 Icalset is the "base class" for representations of a collection of
8 iCal components. Derived classes (actually delegatees) include:
9
10 icalfileset Store componetns in a single file
11 icaldirset Store components in multiple files in a directory
12 icalheapset Store components on the heap
13 icalmysqlset Store components in a mysql database.
14
15 $Id$
16 $Locker$
17
18 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
19
20 This program is free software; you can redistribute it and/or modify
21 it under the terms of either:
22
23 The LGPL as published by the Free Software Foundation, version
24 2.1, available at: http://www.fsf.org/copyleft/lesser.html
25
26 Or:
27
28 The Mozilla Public License Version 1.0. You may obtain a copy of
29 the License at http://www.mozilla.org/MPL/
30
31 The Original Code is eric. The Initial Developer of the Original
32 Code is Eric Busboom
33
34
35======================================================================*/
36
37#ifndef ICALSET_H
38#define ICALSET_H
39
40#include <limits.h> /* For PATH_MAX */
41#include "ical.h"
42#include "icalerror.h"
43
44#ifdef PATH_MAX
45#define ICAL_PATH_MAX PATH_MAX
46#else
47#define ICAL_PATH_MAX 1024
48#endif
49
50
51
52
53typedef void icalset;
54
55typedef enum icalset_kind {
56 ICAL_FILE_SET,
57 ICAL_DIR_SET,
58 ICAL_HEAP_SET,
59 ICAL_MYSQL_SET,
60 ICAL_CAP_SET
61} icalset_kind;
62
63
64/* Create a specific derived type of set */
65icalset* icalset_new_file(const char* path);
66icalset* icalset_new_dir(const char* path);
67icalset* icalset_new_heap(void);
68icalset* icalset_new_mysql(const char* path);
69/*icalset* icalset_new_cap(icalcstp* cstp);*/
70
71void icalset_free(icalset* set);
72
73const char* icalset_path(icalset* set);
74
75/* Mark the cluster as changed, so it will be written to disk when it
76 is freed. Commit writes to disk immediately*/
77void icalset_mark(icalset* set);
78icalerrorenum icalset_commit(icalset* set);
79
80icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
81icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
82
83int icalset_count_components(icalset* set,
84 icalcomponent_kind kind);
85
86/* Restrict the component returned by icalset_first, _next to those
87 that pass the gauge. _clear removes the gauge. */
88icalerrorenum icalset_select(icalset* set, icalcomponent* gauge);
89void icalset_clear_select(icalset* set);
90
91/* Get a component by uid */
92icalcomponent* icalset_fetch(icalset* set, const char* uid);
93int icalset_has_uid(icalset* set, const char* uid);
94icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
95
96/* Modify components according to the MODIFY method of CAP. Works on
97 the currently selected components. */
98icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
99 icalcomponent *newc);
100
101/* Iterate through the components. If a guage has been defined, these
102 will skip over components that do not pass the gauge */
103
104icalcomponent* icalset_get_current_component(icalset* set);
105icalcomponent* icalset_get_first_component(icalset* set);
106icalcomponent* icalset_get_next_component(icalset* set);
107
108#endif /* !ICALSET_H */
109
110
111
diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c
new file mode 100644
index 0000000..cab6a81
--- a/dev/null
+++ b/libical/src/libicalss/icalspanlist.c
@@ -0,0 +1,309 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalspanlist.c
4 CREATOR: ebusboom 23 aug 2000
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
23 ======================================================================*/
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "ical.h"
30#include "icalspanlist.h"
31#include "pvl.h"
32#include <stdlib.h> /* for free and malloc */
33
34struct icalspanlist_impl {
35 pvl_list spans;
36};
37
38int compare_span(void* a, void* b)
39{
40 struct icaltime_span *span_a = (struct icaltime_span *)a ;
41 struct icaltime_span *span_b = (struct icaltime_span *)b ;
42
43 if(span_a->start == span_b->start){
44 return 0;
45 } else if(span_a->start < span_b->start){
46 return -1;
47 } else { /*if(span_a->start > span->b.start)*/
48 return 1;
49 }
50}
51
52icalcomponent* icalspanlist_get_inner(icalcomponent* comp)
53{
54 if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
55 return icalcomponent_get_first_real_component(comp);
56 } else {
57 return comp;
58 }
59}
60
61
62void print_span(int c, struct icaltime_span span );
63
64
65/* Make a free list from a set of component */
66icalspanlist* icalspanlist_new(icalset *set,
67 struct icaltimetype start,
68 struct icaltimetype end)
69{
70 struct icaltime_span range;
71 pvl_elem itr;
72 icalcomponent *c,*inner;
73 icalcomponent_kind kind, inner_kind;
74 struct icalspanlist_impl *sl;
75 struct icaltime_span *freetime;
76
77 if ( ( sl = (struct icalspanlist_impl*)
78 malloc(sizeof(struct icalspanlist_impl))) == 0) {
79 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
80 return 0;
81 }
82
83 sl->spans = pvl_newlist();
84
85 range.start = icaltime_as_timet(start);
86 range.end = icaltime_as_timet(end);
87
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
93 and order the spans based on the start time */
94
95 for(c = icalset_get_first_component(set);
96 c != 0;
97 c = icalset_get_next_component(set)){
98
99 struct icaltime_span span;
100
101 kind = icalcomponent_isa(c);
102 inner = icalcomponent_get_inner(c);
103
104 if(!inner){
105 continue;
106 }
107
108 inner_kind = icalcomponent_isa(inner);
109
110 if( kind != ICAL_VEVENT_COMPONENT &&
111 inner_kind != ICAL_VEVENT_COMPONENT){
112 continue;
113 }
114
115 icalerror_clear_errno();
116
117 span = icalcomponent_get_span(c);
118 span.is_busy = 1;
119
120 if(icalerrno != ICAL_NO_ERROR){
121 continue;
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
142 /* 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
144 that runs from the start of the range to the start of the
145 span. */
146
147 for( itr = pvl_head(sl->spans);
148 itr != 0;
149 itr = pvl_next(itr))
150 {
151 struct icaltime_span *s = (icalproperty*)pvl_data(itr);
152
153 if ((freetime=(struct icaltime_span *)
154 malloc(sizeof(struct icaltime_span))) == 0){
155 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
156 return 0;
157 }
158
159 if(range.start < s->start){
160 freetime->start = range.start;
161 freetime->end = s->start;
162
163 freetime->is_busy = 0;
164
165
166 pvl_insert_ordered(sl->spans,compare_span,(void*)freetime);
167 } else {
168 free(freetime);
169 }
170
171 range.start = s->end;
172 }
173
174 /* If the end of the range is null, then assume that everything
175 after the last item in the calendar is open and add a span
176 that indicates this */
177
178 if( icaltime_is_null_time(end)){
179 struct icaltime_span* last_span;
180
181 last_span = pvl_data(pvl_tail(sl->spans));
182
183 if (last_span != 0){
184
185 if ((freetime=(struct icaltime_span *)
186 malloc(sizeof(struct icaltime_span))) == 0){
187 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
188 return 0;
189 }
190
191 freetime->is_busy = 0;
192 freetime->start = last_span->end;
193 freetime->end = freetime->start;
194 pvl_insert_ordered(sl->spans,compare_span,(void*)freetime);
195 }
196 }
197
198
199 return sl;
200
201}
202
203void icalspanlist_free(icalspanlist* s)
204{
205 struct icaltime_span *span;
206 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s;
207
208 while( (span=pvl_pop(impl->spans)) != 0){
209 free(span);
210 }
211
212 pvl_free(impl->spans);
213
214 impl->spans = 0;
215}
216
217
218void icalspanlist_dump(icalspanlist* s){
219
220 int i = 0;
221 struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s;
222 pvl_elem itr;
223
224 for( itr = pvl_head(sl->spans);
225 itr != 0;
226 itr = pvl_next(itr))
227 {
228 struct icaltime_span *s = (icalproperty*)pvl_data(itr);
229
230 printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start));
231 printf(" end : %s",ctime(&s->end));
232
233 }
234}
235
236icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
237icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
238
239struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
240 struct icaltimetype t)
241{
242 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl;
243 pvl_elem itr;
244 struct icalperiodtype period;
245 struct icaltime_span *s;
246
247 time_t rangett= icaltime_as_timet(t);
248
249 period.start = icaltime_null_time();
250 period.end = icaltime_null_time();
251
252 /* Is the reference time before the first span? If so, assume
253 that the reference time is free */
254 itr = pvl_head(impl->spans);
255 s = (icalproperty*)pvl_data(itr);
256
257 if (s == 0){
258 /* No elements in span */
259 return period;
260 }
261
262 if(rangett <s->start ){
263 /* End of period is start of first span if span is busy, end
264 of the span if it is free */
265 period.start = t;
266
267 if (s->is_busy == 0){
268 period.end = icaltime_from_timet(s->start,0);
269 } else {
270 period.end = icaltime_from_timet(s->end,0);
271 }
272
273 return period;
274 }
275
276 /* Otherwise, find the first free span that contains the
277 reference time. */
278
279 for( itr = pvl_head(impl->spans);
280 itr != 0;
281 itr = pvl_next(itr))
282 {
283 s = (icalproperty*)pvl_data(itr);
284
285 if(s->is_busy == 0 && s->start >= rangett &&
286 ( rangett < s->end || s->end == s->start)){
287
288 if (rangett < s->start){
289 period.start = icaltime_from_timet(s->start,0);
290 } else {
291 period.start = icaltime_from_timet(rangett,0);
292 }
293
294 period.end = icaltime_from_timet(s->end,0);
295
296 return period;
297 }
298
299 }
300
301 period.start = icaltime_null_time();
302 period.end = icaltime_null_time();
303
304 return period;
305}
306
307struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
308 struct icaltimetype t);
309
diff --git a/libical/src/libicalss/icalspanlist.h b/libical/src/libicalss/icalspanlist.h
new file mode 100644
index 0000000..83cb1c8
--- a/dev/null
+++ b/libical/src/libicalss/icalspanlist.h
@@ -0,0 +1,54 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalspanlist.h
4 CREATOR: eric 21 Aug 2000
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
24 =========================================================================*/
25#ifndef ICALSPANLIST_H
26#define ICALSPANLIST_H
27
28#include "ical.h"
29#include "icalset.h"
30
31typedef void icalspanlist;
32
33/* Make a free list from a set of component. Start and end should be in UTC */
34icalspanlist* icalspanlist_new(icalset *set,
35 struct icaltimetype start,
36 struct icaltimetype end);
37
38void icalspanlist_free(icalspanlist* spl);
39
40icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
41icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
42
43/* Get first free or busy time after time t. all times are in UTC */
44struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
45 struct icaltimetype t);
46struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
47 struct icaltimetype t);
48
49void icalspanlist_dump(icalspanlist* s);
50
51#endif
52
53
54
diff --git a/libical/src/libicalss/icalss.h b/libical/src/libicalss/icalss.h
new file mode 100644
index 0000000..cd07919
--- a/dev/null
+++ b/libical/src/libicalss/icalss.h
@@ -0,0 +1,885 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalgauge.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 ICALGAUGE_H
30#define ICALGAUGE_H
31
32typedef void icalgauge;
33
34icalgauge* icalgauge_new_from_sql(char* sql);
35
36void icalgauge_free(icalgauge* gauge);
37
38char* icalgauge_as_sql(icalcomponent* gauge);
39
40void icalgauge_dump(icalcomponent* gauge);
41
42/* Return true is comp matches the gauge. The component must be in
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
44 sub component */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46
47/* Clone the component, but only return the properties specified in
48 the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
50
51#endif /* ICALGAUGE_H*/
52/* -*- Mode: C -*- */
53/*======================================================================
54 FILE: icalset.h
55 CREATOR: eric 28 November 1999
56
57
58 Icalset is the "base class" for representations of a collection of
59 iCal components. Derived classes (actually delegatees) include:
60
61 icalfileset Store componetns in a single file
62 icaldirset Store components in multiple files in a directory
63 icalheapset Store components on the heap
64 icalmysqlset Store components in a mysql database.
65
66 $Id$
67 $Locker$
68
69 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
70
71 This program is free software; you can redistribute it and/or modify
72 it under the terms of either:
73
74 The LGPL as published by the Free Software Foundation, version
75 2.1, available at: http://www.fsf.org/copyleft/lesser.html
76
77 Or:
78
79 The Mozilla Public License Version 1.0. You may obtain a copy of
80 the License at http://www.mozilla.org/MPL/
81
82 The Original Code is eric. The Initial Developer of the Original
83 Code is Eric Busboom
84
85
86======================================================================*/
87
88#ifndef ICALSET_H
89#define ICALSET_H
90
91#include <limits.h> /* For PATH_MAX */
92
93#ifdef PATH_MAX
94#define ICAL_PATH_MAX PATH_MAX
95#else
96#define ICAL_PATH_MAX 1024
97#endif
98
99
100#ifdef _WIN32
101#define mode_t int
102#endif
103
104
105
106typedef void icalset;
107
108typedef enum icalset_kind {
109 ICAL_FILE_SET,
110 ICAL_DIR_SET,
111 ICAL_HEAP_SET,
112 ICAL_MYSQL_SET,
113 ICAL_CAP_SET
114} icalset_kind;
115
116
117/* Create a specific derived type of set */
118icalset* icalset_new_file(const char* path);
119icalset* icalset_new_dir(const char* path);
120icalset* icalset_new_heap(void);
121icalset* icalset_new_mysql(const char* path);
122/*icalset* icalset_new_cap(icalcstp* cstp);*/
123
124void icalset_free(icalset* set);
125
126const char* icalset_path(icalset* set);
127
128/* Mark the cluster as changed, so it will be written to disk when it
129 is freed. Commit writes to disk immediately*/
130void icalset_mark(icalset* set);
131icalerrorenum icalset_commit(icalset* set);
132
133icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
134icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
135
136int icalset_count_components(icalset* set,
137 icalcomponent_kind kind);
138
139/* Restrict the component returned by icalset_first, _next to those
140 that pass the gauge. _clear removes the gauge. */
141icalerrorenum icalset_select(icalset* set, icalcomponent* gauge);
142void icalset_clear_select(icalset* set);
143
144/* Get a component by uid */
145icalcomponent* icalset_fetch(icalset* set, const char* uid);
146int icalset_has_uid(icalset* set, const char* uid);
147icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
148
149/* Modify components according to the MODIFY method of CAP. Works on
150 the currently selected components. */
151icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
152 icalcomponent *newc);
153
154/* Iterate through the components. If a guage has been defined, these
155 will skip over components that do not pass the gauge */
156
157icalcomponent* icalset_get_current_component(icalset* set);
158icalcomponent* icalset_get_first_component(icalset* set);
159icalcomponent* icalset_get_next_component(icalset* set);
160
161#endif /* !ICALSET_H */
162
163
164
165/* -*- Mode: C -*- */
166/*======================================================================
167 FILE: icalfileset.h
168 CREATOR: eric 23 December 1999
169
170
171 $Id$
172 $Locker$
173
174 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
175
176 This program is free software; you can redistribute it and/or modify
177 it under the terms of either:
178
179 The LGPL as published by the Free Software Foundation, version
180 2.1, available at: http://www.fsf.org/copyleft/lesser.html
181
182 Or:
183
184 The Mozilla Public License Version 1.0. You may obtain a copy of
185 the License at http://www.mozilla.org/MPL/
186
187 The Original Code is eric. The Initial Developer of the Original
188 Code is Eric Busboom
189
190
191======================================================================*/
192
193#ifndef ICALFILESET_H
194#define ICALFILESET_H
195
196#include <sys/types.h> /* For open() flags and mode */
197#include <sys/stat.h> /* For open() flags and mode */
198#include <fcntl.h> /* For open() flags and mode */
199
200extern int icalfileset_safe_saves;
201
202typedef void icalfileset;
203
204
205/* icalfileset
206 icalfilesetfile
207 icalfilesetdir
208*/
209
210
211icalfileset* icalfileset_new(const char* path);
212
213/* Like _new, but takes open() flags for opening the file */
214icalfileset* icalfileset_new_open(const char* path,
215 int flags, mode_t mode);
216
217void icalfileset_free(icalfileset* cluster);
218
219const char* icalfileset_path(icalfileset* cluster);
220
221/* Mark the cluster as changed, so it will be written to disk when it
222 is freed. Commit writes to disk immediately. */
223void icalfileset_mark(icalfileset* cluster);
224icalerrorenum icalfileset_commit(icalfileset* cluster);
225
226icalerrorenum icalfileset_add_component(icalfileset* cluster,
227 icalcomponent* child);
228
229icalerrorenum icalfileset_remove_component(icalfileset* cluster,
230 icalcomponent* child);
231
232int icalfileset_count_components(icalfileset* cluster,
233 icalcomponent_kind kind);
234
235/* Restrict the component returned by icalfileset_first, _next to those
236 that pass the gauge. _clear removes the gauge */
237icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge);
238void icalfileset_clear(icalfileset* store);
239
240/* Get and search for a component by uid */
241icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid);
242int icalfileset_has_uid(icalfileset* cluster, const char* uid);
243icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c);
244
245
246/* Modify components according to the MODIFY method of CAP. Works on
247 the currently selected components. */
248icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp,
249 icalcomponent *newcomp);
250
251/* Iterate through components. If a guage has been defined, these
252 will skip over components that do not pass the gauge */
253
254icalcomponent* icalfileset_get_current_component (icalfileset* cluster);
255icalcomponent* icalfileset_get_first_component(icalfileset* cluster);
256icalcomponent* icalfileset_get_next_component(icalfileset* cluster);
257/* Return a reference to the internal component. You probably should
258 not be using this. */
259
260icalcomponent* icalfileset_get_component(icalfileset* cluster);
261
262
263#endif /* !ICALFILESET_H */
264
265
266
267/* -*- Mode: C -*- */
268/*======================================================================
269 FILE: icaldirset.h
270 CREATOR: eric 28 November 1999
271
272
273 $Id$
274 $Locker$
275
276 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
277
278 This program is free software; you can redistribute it and/or modify
279 it under the terms of either:
280
281 The LGPL as published by the Free Software Foundation, version
282 2.1, available at: http://www.fsf.org/copyleft/lesser.html
283
284 Or:
285
286 The Mozilla Public License Version 1.0. You may obtain a copy of
287 the License at http://www.mozilla.org/MPL/
288
289 The Original Code is eric. The Initial Developer of the Original
290 Code is Eric Busboom
291
292
293======================================================================*/
294
295#ifndef ICALDIRSET_H
296#define ICALDIRSET_H
297
298
299/* icaldirset Routines for storing, fetching, and searching for ical
300 * objects in a database */
301
302typedef void icaldirset;
303
304
305icaldirset* icaldirset_new(const char* path);
306
307void icaldirset_free(icaldirset* store);
308
309const char* icaldirset_path(icaldirset* store);
310
311/* Mark the cluster as changed, so it will be written to disk when it
312 is freed. Commit writes to disk immediately*/
313void icaldirset_mark(icaldirset* store);
314icalerrorenum icaldirset_commit(icaldirset* store);
315
316icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp);
317icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp);
318
319int icaldirset_count_components(icaldirset* store,
320 icalcomponent_kind kind);
321
322/* Restrict the component returned by icaldirset_first, _next to those
323 that pass the gauge. _clear removes the gauge. */
324icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge);
325void icaldirset_clear(icaldirset* store);
326
327/* Get a component by uid */
328icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid);
329int icaldirset_has_uid(icaldirset* store, const char* uid);
330icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c);
331
332/* Modify components according to the MODIFY method of CAP. Works on
333 the currently selected components. */
334icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc,
335 icalcomponent *newc);
336
337/* Iterate through the components. If a guage has been defined, these
338 will skip over components that do not pass the gauge */
339
340icalcomponent* icaldirset_get_current_component(icaldirset* store);
341icalcomponent* icaldirset_get_first_component(icaldirset* store);
342icalcomponent* icaldirset_get_next_component(icaldirset* store);
343
344#endif /* !ICALDIRSET_H */
345
346
347
348/* -*- Mode: C -*- */
349/*======================================================================
350 FILE: icalcalendar.h
351 CREATOR: eric 23 December 1999
352
353
354 $Id$
355 $Locker$
356
357 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
358
359 This program is free software; you can redistribute it and/or modify
360 it under the terms of either:
361
362 The LGPL as published by the Free Software Foundation, version
363 2.1, available at: http://www.fsf.org/copyleft/lesser.html
364
365 Or:
366
367 The Mozilla Public License Version 1.0. You may obtain a copy of
368 the License at http://www.mozilla.org/MPL/
369
370 The Original Code is eric. The Initial Developer of the Original
371 Code is Eric Busboom
372
373
374======================================================================*/
375
376#ifndef ICALCALENDAR_H
377#define ICALCALENDAR_H
378
379
380/* icalcalendar
381 * Routines for storing calendar data in a file system. The calendar
382 * has two icaldirsets, one for incoming components and one for booked
383 * components. It also has interfaces to access the free/busy list
384 * and a list of calendar properties */
385
386typedef void icalcalendar;
387
388icalcalendar* icalcalendar_new(char* dir);
389
390void icalcalendar_free(icalcalendar* calendar);
391
392int icalcalendar_lock(icalcalendar* calendar);
393
394int icalcalendar_unlock(icalcalendar* calendar);
395
396int icalcalendar_islocked(icalcalendar* calendar);
397
398int icalcalendar_ownlock(icalcalendar* calendar);
399
400icalset* icalcalendar_get_booked(icalcalendar* calendar);
401
402icalset* icalcalendar_get_incoming(icalcalendar* calendar);
403
404icalset* icalcalendar_get_properties(icalcalendar* calendar);
405
406icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
407
408
409#endif /* !ICALCALENDAR_H */
410
411
412
413/* -*- Mode: C -*- */
414/*======================================================================
415 FILE: icalclassify.h
416 CREATOR: eric 21 Aug 2000
417
418
419 $Id$
420 $Locker$
421
422 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
423
424 This program is free software; you can redistribute it and/or modify
425 it under the terms of either:
426
427 The LGPL as published by the Free Software Foundation, version
428 2.1, available at: http://www.fsf.org/copyleft/lesser.html
429
430 Or:
431
432 The Mozilla Public License Version 1.0. You may obtain a copy of
433 the License at http://www.mozilla.org/MPL/
434
435
436 =========================================================================*/
437
438#ifndef ICALCLASSIFY_H
439#define ICALCLASSIFY_H
440
441
442
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);
476
477icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
478
479char* icalclassify_class_to_string(ical_class iclass);
480
481
482#endif /* ICALCLASSIFY_H*/
483
484
485
486
487
488/* -*- Mode: C -*- */
489/*======================================================================
490 FILE: icalspanlist.h
491 CREATOR: eric 21 Aug 2000
492
493
494 $Id$
495 $Locker$
496
497 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
498
499 This program is free software; you can redistribute it and/or modify
500 it under the terms of either:
501
502 The LGPL as published by the Free Software Foundation, version
503 2.1, available at: http://www.fsf.org/copyleft/lesser.html
504
505 Or:
506
507 The Mozilla Public License Version 1.0. You may obtain a copy of
508 the License at http://www.mozilla.org/MPL/
509
510
511 =========================================================================*/
512#ifndef ICALSPANLIST_H
513#define ICALSPANLIST_H
514
515
516typedef void icalspanlist;
517
518/* Make a free list from a set of component. Start and end should be in UTC */
519icalspanlist* icalspanlist_new(icalset *set,
520 struct icaltimetype start,
521 struct icaltimetype end);
522
523void icalspanlist_free(icalspanlist* spl);
524
525icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
526icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
527
528/* Get first free or busy time after time t. all times are in UTC */
529struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
530 struct icaltimetype t);
531struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
532 struct icaltimetype t);
533
534void icalspanlist_dump(icalspanlist* s);
535
536#endif
537
538
539
540/* -*- Mode: C -*- */
541/*======================================================================
542 FILE: icalmessage.h
543 CREATOR: eric 07 Nov 2000
544
545
546 $Id$
547 $Locker$
548
549 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
550
551 This program is free software; you can redistribute it and/or modify
552 it under the terms of either:
553
554 The LGPL as published by the Free Software Foundation, version
555 2.1, available at: http://www.fsf.org/copyleft/lesser.html
556
557 Or:
558
559 The Mozilla Public License Version 1.0. You may obtain a copy of
560 the License at http://www.mozilla.org/MPL/
561
562
563 =========================================================================*/
564
565
566#ifndef ICALMESSAGE_H
567#define ICALMESSAGE_H
568
569
570icalcomponent* icalmessage_new_accept_reply(icalcomponent* c,
571 const char* user,
572 const char* msg);
573
574icalcomponent* icalmessage_new_decline_reply(icalcomponent* c,
575 const char* user,
576 const char* msg);
577
578/* New is modified version of old */
579icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
580 icalcomponent* newc,
581 const char* user,
582 const char* msg);
583
584
585icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c,
586 const char* user,
587 const char* delegatee,
588 const char* msg);
589
590
591icalcomponent* icalmessage_new_cancel_event(icalcomponent* c,
592 const char* user,
593 const char* msg);
594icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c,
595 const char* user,
596 const char* msg);
597icalcomponent* icalmessage_new_cancel_all(icalcomponent* c,
598 const char* user,
599 const char* msg);
600
601
602icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
603 const char* user,
604 const char* msg,
605 const char* debug,
606 icalrequeststatus rs);
607
608
609#endif /* ICALMESSAGE_H*/
610/* -*- Mode: C -*- */
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};
680
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
new file mode 100644
index 0000000..e10bcd3
--- a/dev/null
+++ b/libical/src/libicalss/icalsslexer.c
@@ -0,0 +1,1713 @@
1#define yy_create_buffer ss_create_buffer
2#define yy_delete_buffer ss_delete_buffer
3#define yy_scan_buffer ss_scan_buffer
4#define yy_scan_string ss_scan_string
5#define yy_scan_bytes ss_scan_bytes
6#define yy_flex_debug ss_flex_debug
7#define yy_init_buffer ss_init_buffer
8#define yy_flush_buffer ss_flush_buffer
9#define yy_load_buffer_state ss_load_buffer_state
10#define yy_switch_to_buffer ss_switch_to_buffer
11#define yyin ssin
12#define yyleng ssleng
13#define yylex sslex
14#define yyout ssout
15#define yyrestart ssrestart
16#define yytext sstext
17#define yywrap sswrap
18
19/* A lexical scanner generated by flex */
20
21/* Scanner skeleton version:
22 * $Header$
23 */
24
25#define FLEX_SCANNER
26#define YY_FLEX_MAJOR_VERSION 2
27#define YY_FLEX_MINOR_VERSION 5
28
29#include <stdio.h>
30// Eugen C. <eug@thekompany.com>
31#include <defines.h>
32#ifndef _QTWIN_
33#include <unistd.h>
34#else
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
48#ifdef __cplusplus
49
50#include <stdlib.h>
51
52/* Use prototypes in function declarations. */
53#define YY_USE_PROTOS
54
55/* The "const" storage-class-modifier is valid. */
56#define YY_USE_CONST
57
58 #else/* ! __cplusplus */
59
60#if __STDC__
61
62#define YY_USE_PROTOS
63#define YY_USE_CONST
64
65 #endif/* __STDC__ */
66 #endif/* ! __cplusplus */
67
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
78#define yyconst const
79#else
80#define yyconst
81#endif
82
83
84#ifdef YY_USE_PROTOS
85#define YY_PROTO(proto) proto
86#else
87#define YY_PROTO(proto) ()
88#endif
89
90/* Returned upon end-of-file. */
91#define YY_NULL 0
92
93/* Promotes a possibly negative, possibly signed char to an unsigned
94 * integer for use as an array index. If the signed char is negative,
95 * we want to instead treat it as an 8-bit unsigned char, hence the
96 * double cast.
97 */
98#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
99
100/* 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
102 * definition of BEGIN.
103 */
104#define BEGIN yy_start = 1 + 2 *
105
106/* 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
108 * compatibility.
109 */
110#define YY_START ((yy_start - 1) / 2)
111#define YYSTATE YY_START
112
113/* Action number for EOF rule of a given start state. */
114#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
115
116/* Special action meaning "start processing a new file". */
117#define YY_NEW_FILE yyrestart( yyin )
118
119#define YY_END_OF_BUFFER_CHAR 0
120
121/* Size of default input buffer. */
122#define YY_BUF_SIZE 16384
123
124typedef struct yy_buffer_state *YY_BUFFER_STATE;
125
126extern int yyleng;
127extern FILE *yyin, *yyout;
128
129#define EOB_ACT_CONTINUE_SCAN 0
130#define EOB_ACT_END_OF_FILE 1
131#define EOB_ACT_LAST_MATCH 2
132
133/* The funky do-while in the following #define is used to turn the definition
134 * int a single C statement (which needs a semi-colon terminator). This
135 * avoids problems with code like:
136 *
137 * if ( condition_holds )
138 * yyless( 5 );
139 *else
140 * do_something_else();
141 *
142 * Prior to using the do-while the compiler would get upset at the
143 * "else" because it interpreted the "if" statement as being all
144 * done when it reached the ';' after the yyless() call.
145 */
146
147/* Return all but the first 'n' matched characters back to the input stream. */
148
149#define yyless(n) \
150 do \
151 { \
152 /* Undo effects of setting up yytext. */ \
153 *yy_cp = yy_hold_char; \
154 YY_RESTORE_YY_MORE_OFFSET \
155 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
156 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
157 } \
158 while ( 0 )
159
160#define unput(c) yyunput( c, yytext_ptr )
161
162/* 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
164 * flex-generated scanners to compile on their own).
165 */
166typedef unsigned int yy_size_t;
167
168
169struct yy_buffer_state
170 {
171 FILE *yy_input_file;
172
173 char *yy_ch_buf; /* input buffer */
174 char *yy_buf_pos; /* current position in input buffer */
175
176 /* Size of input buffer in bytes, not including room for EOB
177 * characters.
178 */
179 yy_size_t yy_buf_size;
180
181 /* Number of characters read into yy_ch_buf, not including EOB
182 * characters.
183 */
184 int yy_n_chars;
185
186 /* Whether we "own" the buffer - i.e., we know we created it,
187 * and can realloc() it to grow it, and should free() it to
188 * delete it.
189 */
190 int yy_is_our_buffer;
191
192 /* Whether this is an "interactive" input source; if so, and
193 * if we're using stdio for input, then we want to use getc()
194 * instead of fread(), to make sure we stop fetching input after
195 * each newline.
196 */
197 int yy_is_interactive;
198
199 /* Whether we're considered to be at the beginning of a line.
200 * If so, '^' rules will be active on the next match, otherwise
201 * not.
202 */
203 int yy_at_bol;
204
205 /* Whether to try to fill the input buffer when we reach the
206 * end of it.
207 */
208 int yy_fill_buffer;
209
210 int yy_buffer_status;
211#define YY_BUFFER_NEW 0
212#define YY_BUFFER_NORMAL 1
213 /* When an EOF's been seen but there's still some text to process
214 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
215 * shouldn't try reading from the input source any more. We might
216 * still have a bunch of tokens to match, though, because of
217 * possible backing-up.
218 *
219 * When we actually see the EOF, we change the status to "new"
220 * (via yyrestart()), so that the user can continue scanning by
221 * just pointing yyin at a new input file.
222 */
223#define YY_BUFFER_EOF_PENDING 2
224 };
225
226static YY_BUFFER_STATE yy_current_buffer = 0;
227
228/* We provide macros for accessing buffer states in case in the
229 * future we want to put the buffer states in a more general
230 * "scanner state".
231 */
232#define YY_CURRENT_BUFFER yy_current_buffer
233
234
235/* yy_hold_char holds the character lost when yytext is formed. */
236static char yy_hold_char;
237
238 static int yy_n_chars; /* number of characters read into yy_ch_buf */
239
240
241int yyleng;
242
243/* Points to current character in buffer. */
244static char *yy_c_buf_p = (char *) 0;
245 static int yy_init = 1; /* whether we need to initialize */
246 static int yy_start = 0;/* start state number */
247
248/* Flag which is used to allow yywrap()'s to do buffer switches
249 * instead of setting up a fresh yyin. A bit of a hack ...
250 */
251static int yy_did_buffer_switch_on_eof;
252
253void yyrestart YY_PROTO(( FILE *input_file ));
254
255void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
256void yy_load_buffer_state YY_PROTO(( void ));
257YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
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
263YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
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
267static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
268static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
269static void yy_flex_free YY_PROTO(( void * ));
270
271#define yy_new_buffer yy_create_buffer
272
273#define yy_set_interactive(is_interactive) \
274 { \
275 if ( ! yy_current_buffer ) \
276 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
277 yy_current_buffer->yy_is_interactive = is_interactive; \
278 }
279
280#define yy_set_bol(at_bol) \
281 { \
282 if ( ! yy_current_buffer ) \
283 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
284 yy_current_buffer->yy_at_bol = at_bol; \
285 }
286
287#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
288
289typedef unsigned char YY_CHAR;
290FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
291typedef int yy_state_type;
292extern char yytext[];
293
294
295static yy_state_type yy_get_previous_state YY_PROTO(( void ));
296static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
297static int yy_get_next_buffer YY_PROTO(( void ));
298static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
299
300/* Done after the current pattern has been matched and before the
301 * corresponding action - sets up yytext.
302 */
303#define YY_DO_BEFORE_ACTION \
304 yytext_ptr = yy_bp; \
305 yyleng = (int) (yy_cp - yy_bp); \
306 yy_hold_char = *yy_cp; \
307 *yy_cp = '\0'; \
308 if ( yyleng >= YYLMAX ) \
309 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
310 yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \
311 yy_c_buf_p = yy_cp;
312
313#define YY_NUM_RULES 19
314#define YY_END_OF_BUFFER 20
315static yyconst short int yy_accept[47] =
316 { 0,
317 0, 0, 0, 0, 0, 0, 20, 18, 14, 14,
318 18, 13, 17, 4, 15, 7, 5, 8, 17, 17,
319 17, 17, 17, 14, 6, 0, 17, 9, 10, 17,
320 17, 12, 17, 17, 16, 11, 17, 17, 17, 2,
321 17, 17, 17, 3, 1, 0
322 } ;
323
324static yyconst int yy_ec[256] =
325 { 0,
326 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
327 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 2, 4, 1, 1, 1, 1, 1, 5, 1,
330 1, 6, 1, 7, 6, 6, 1, 6, 6, 6,
331 6, 6, 6, 6, 6, 6, 6, 1, 8, 9,
332 10, 11, 1, 1, 12, 6, 13, 14, 15, 16,
333 6, 17, 6, 6, 6, 18, 19, 20, 21, 6,
334 6, 22, 23, 24, 6, 6, 25, 6, 6, 6,
335 1, 1, 1, 1, 1, 1, 12, 6, 13, 14,
336
337 15, 16, 6, 17, 6, 6, 6, 18, 19, 20,
338 21, 6, 6, 22, 23, 24, 6, 6, 25, 6,
339 6, 6, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
343 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
347
348 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
349 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
350 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
351 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
352 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
353 1, 1, 1, 1, 1
354 } ;
355
356static yyconst int yy_meta[26] =
357 { 0,
358 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
359 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
360 2, 2, 2, 2, 2
361 } ;
362
363static yyconst short int yy_base[49] =
364 { 0,
365 0, 0, 0, 0, 0, 0, 53, 54, 24, 26,
366 42, 0, 0, 54, 54, 41, 54, 40, 29, 26,
367 25, 31, 28, 28, 54, 39, 0, 54, 54, 29,
368 21, 0, 23, 25, 54, 0, 20, 23, 15, 0,
369 23, 20, 10, 0, 0, 54, 31, 30
370 } ;
371
372static yyconst short int yy_def[49] =
373 { 0,
374 46, 1, 1, 1, 1, 1, 46, 46, 46, 46,
375 46, 47, 48, 46, 46, 46, 46, 46, 48, 48,
376 48, 48, 48, 46, 46, 47, 48, 46, 46, 48,
377 48, 48, 48, 48, 46, 48, 48, 48, 48, 48,
378 48, 48, 48, 48, 48, 0, 46, 46
379 } ;
380
381static yyconst short int yy_nxt[80] =
382 { 0,
383 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
384 18, 19, 13, 13, 13, 20, 13, 13, 13, 13,
385 21, 13, 22, 13, 23, 24, 24, 24, 24, 24,
386 24, 27, 26, 45, 44, 43, 42, 41, 40, 39,
387 38, 37, 36, 35, 34, 33, 32, 31, 30, 29,
388 28, 25, 46, 7, 46, 46, 46, 46, 46, 46,
389 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
390 46, 46, 46, 46, 46, 46, 46, 46, 46
391 } ;
392
393static yyconst short int yy_chk[80] =
394 { 0,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 9, 9, 10, 10, 24,
398 24, 48, 47, 43, 42, 41, 39, 38, 37, 34,
399 33, 31, 30, 26, 23, 22, 21, 20, 19, 18,
400 16, 11, 7, 46, 46, 46, 46, 46, 46, 46,
401 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
402 46, 46, 46, 46, 46, 46, 46, 46, 46
403 } ;
404
405static yy_state_type yy_last_accepting_state;
406static char *yy_last_accepting_cpos;
407
408/* The intent behind this definition is that it'll catch
409 * any uses of REJECT which flex missed.
410 */
411#define REJECT reject_used_but_not_detected
412#define yymore() yymore_used_but_not_detected
413#define YY_MORE_ADJ 0
414#define YY_RESTORE_YY_MORE_OFFSET
415#ifndef YYLMAX
416#define YYLMAX 8192
417#endif
418
419char yytext[YYLMAX];
420char *yytext_ptr;
421#line 1 "icalsslexer.l"
422#define INITIAL 0
423#line 2 "icalsslexer.l"
424/* -*- Mode: C -*-
425 ======================================================================
426 FILE: icalsslexer.l
427 CREATOR: eric 8 Aug 2000
428
429 DESCRIPTION:
430
431 $Id$
432 $Locker$
433
434(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
435
436 This program is free software; you can redistribute it and/or modify
437 it under the terms of either:
438
439 The LGPL as published by the Free Software Foundation, version
440 2.1, available at: http://www.fsf.org/copyleft/lesser.html
441
442 Or:
443
444 The Mozilla Public License Version 1.0. You may obtain a copy of
445 the License at http://www.mozilla.org/MPL/
446
447 The Original Code is eric. The Initial Developer of the Original
448 Code is Eric Busboom
449
450 ======================================================================*/
451
452#include "icalssyacc.h"
453#include "icalgaugeimpl.h"
454#include "assert.h"
455
456#include <string.h> /* For strdup() */
457
458int icalparser_flex_input(char* buf, int max_size);
459void icalparser_clear_flex_input();
460
461#undef YY_INPUT
462#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
463
464#undef SS_FATAL_ERROR
465#define SS_FATAL_ERROR(msg) sserror(msg)
466
467
468#define sql 1
469#define string_value 2
470
471#line 465 "icalsslexer.c"
472
473/* Macros after this point can all be overridden by user definitions in
474 * section 1.
475 */
476
477#ifndef YY_SKIP_YYWRAP
478#ifdef __cplusplus
479extern "C" int yywrap YY_PROTO(( void ));
480#else
481extern int yywrap YY_PROTO(( void ));
482#endif
483#endif
484
485#ifndef YY_NO_UNPUT
486static void yyunput YY_PROTO(( int c, char *buf_ptr ));
487#endif
488
489#ifndef yytext_ptr
490static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
491#endif
492
493#ifdef YY_NEED_STRLEN
494static int yy_flex_strlen YY_PROTO(( yyconst char * ));
495#endif
496
497#ifndef YY_NO_INPUT
498#ifdef __cplusplus
499static int yyinput YY_PROTO(( void ));
500#else
501static int input YY_PROTO(( void ));
502#endif
503#endif
504
505#if YY_STACK_USED
506static int yy_start_stack_ptr = 0;
507static int yy_start_stack_depth = 0;
508static int *yy_start_stack = 0;
509#ifndef YY_NO_PUSH_STATE
510static void yy_push_state YY_PROTO(( int new_state ));
511#endif
512#ifndef YY_NO_POP_STATE
513static void yy_pop_state YY_PROTO(( void ));
514#endif
515#ifndef YY_NO_TOP_STATE
516static int yy_top_state YY_PROTO(( void ));
517#endif
518
519#else
520#define YY_NO_PUSH_STATE 1
521#define YY_NO_POP_STATE 1
522#define YY_NO_TOP_STATE 1
523#endif
524
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. */
541#ifndef YY_READ_BUF_SIZE
542#define YY_READ_BUF_SIZE 8192
543#endif
544
545/* Copy whatever the last rule matched to the standard output. */
546
547#ifndef ECHO
548/* This used to be an fputs(), but since the string might contain NUL's,
549 * we now use fwrite().
550 */
551#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
552#endif
553
554/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
555 * is returned in "result".
556 */
557#ifndef YY_INPUT
558#define YY_INPUT(buf,result,max_size) \
559 if ( yy_current_buffer->yy_is_interactive ) \
560 { \
561 int c = '*', n; \
562 for ( n = 0; n < max_size && \
563 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
564 buf[n] = (char) c; \
565 if ( c == '\n' ) \
566 buf[n++] = (char) c; \
567 if ( c == EOF && ferror( yyin ) ) \
568 YY_FATAL_ERROR( "input in flex scanner failed" ); \
569 result = n; \
570 } \
571 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
572 && ferror( yyin ) ) \
573 YY_FATAL_ERROR( "input in flex scanner failed" );
574#endif
575
576/* No semi-colon after return; correct usage is to write "yyterminate();" -
577 * we don't want an extra ';' after the "return" because that will cause
578 * some compilers to complain about unreachable statements.
579 */
580#ifndef yyterminate
581#define yyterminate() return YY_NULL
582#endif
583
584/* Number of entries by which start-condition stack grows. */
585#ifndef YY_START_STACK_INCR
586#define YY_START_STACK_INCR 25
587#endif
588
589/* Report a fatal error. */
590#ifndef YY_FATAL_ERROR
591#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
592#endif
593
594/* Default declaration of generated scanner - a define so the user can
595 * easily add parameters.
596 */
597#ifndef YY_DECL
598#define YY_DECL int yylex YY_PROTO(( void ))
599#endif
600
601/* Code executed at the beginning of each rule, after yytext and yyleng
602 * have been set up.
603 */
604#ifndef YY_USER_ACTION
605#define YY_USER_ACTION
606#endif
607
608/* Code executed at the end of each rule. */
609#ifndef YY_BREAK
610#define YY_BREAK break;
611#endif
612
613#define YY_RULE_SETUP \
614 YY_USER_ACTION
615
616YY_DECL
617 {
618 register yy_state_type yy_current_state;
619 register char *yy_cp = NULL, *yy_bp = NULL;
620 register int yy_act;
621
622#line 69 "icalsslexer.l"
623
624
625
626
627
628
629#line 623 "icalsslexer.c"
630
631 if ( yy_init )
632 {
633 yy_init = 0;
634
635#ifdef YY_USER_INIT
636 YY_USER_INIT;
637#endif
638
639 if ( ! yy_start )
640 yy_start = 1;/* first start state */
641
642 if ( ! yyin )
643 yyin = stdin;
644
645 if ( ! yyout )
646 yyout = stdout;
647
648 if ( ! yy_current_buffer )
649 yy_current_buffer =
650 yy_create_buffer( yyin, YY_BUF_SIZE );
651
652 yy_load_buffer_state();
653 }
654
655 while ( 1 ) /* loops until end-of-file is reached */
656 {
657 yy_cp = yy_c_buf_p;
658
659 /* Support of yytext. */
660 *yy_cp = yy_hold_char;
661
662 /* yy_bp points to the position in yy_ch_buf of the start of
663 * the current run.
664 */
665 yy_bp = yy_cp;
666
667 yy_current_state = yy_start;
668yy_match:
669 do
670 {
671 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
672 if ( yy_accept[yy_current_state] )
673 {
674 yy_last_accepting_state = yy_current_state;
675 yy_last_accepting_cpos = yy_cp;
676 }
677 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
678 {
679 yy_current_state = (int) yy_def[yy_current_state];
680 if ( yy_current_state >= 47 )
681 yy_c = yy_meta[(unsigned int) yy_c];
682 }
683 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
684 ++yy_cp;
685 }
686 while ( yy_base[yy_current_state] != 54 );
687
688yy_find_action:
689 yy_act = yy_accept[yy_current_state];
690 if ( yy_act == 0 )
691 { /* have to back up */
692 yy_cp = yy_last_accepting_cpos;
693 yy_current_state = yy_last_accepting_state;
694 yy_act = yy_accept[yy_current_state];
695 }
696
697 YY_DO_BEFORE_ACTION;
698
699
700 do_action:/* This label is used only to access EOF actions. */
701
702
703 switch ( yy_act )
704 { /* beginning of action switch */
705 case 0: /* must back up */
706 /* undo the effects of YY_DO_BEFORE_ACTION */
707 *yy_cp = yy_hold_char;
708 yy_cp = yy_last_accepting_cpos;
709 yy_current_state = yy_last_accepting_state;
710 goto yy_find_action;
711
712case 1:
713YY_RULE_SETUP
714#line 75 "icalsslexer.l"
715{ return SELECT; }
716 YY_BREAK
717case 2:
718YY_RULE_SETUP
719#line 76 "icalsslexer.l"
720{ return FROM; }
721 YY_BREAK
722case 3:
723YY_RULE_SETUP
724#line 77 "icalsslexer.l"
725{ return WHERE; }
726 YY_BREAK
727case 4:
728YY_RULE_SETUP
729#line 78 "icalsslexer.l"
730{ return COMMA; }
731 YY_BREAK
732case 5:
733YY_RULE_SETUP
734#line 79 "icalsslexer.l"
735{ return EQUALS; }
736 YY_BREAK
737case 6:
738YY_RULE_SETUP
739#line 80 "icalsslexer.l"
740{ return NOTEQUALS; }
741 YY_BREAK
742case 7:
743YY_RULE_SETUP
744#line 81 "icalsslexer.l"
745{ return LESS; }
746 YY_BREAK
747case 8:
748YY_RULE_SETUP
749#line 82 "icalsslexer.l"
750{ return GREATER; }
751 YY_BREAK
752case 9:
753YY_RULE_SETUP
754#line 83 "icalsslexer.l"
755{ return LESSEQUALS; }
756 YY_BREAK
757case 10:
758YY_RULE_SETUP
759#line 84 "icalsslexer.l"
760{ return GREATEREQUALS; }
761 YY_BREAK
762case 11:
763YY_RULE_SETUP
764#line 85 "icalsslexer.l"
765{ return AND; }
766 YY_BREAK
767case 12:
768YY_RULE_SETUP
769#line 86 "icalsslexer.l"
770{ return OR; }
771 YY_BREAK
772case 13:
773YY_RULE_SETUP
774#line 87 "icalsslexer.l"
775{ return QUOTE; }
776 YY_BREAK
777case 14:
778YY_RULE_SETUP
779#line 88 "icalsslexer.l"
780 ;
781 YY_BREAK
782case 15:
783YY_RULE_SETUP
784#line 89 "icalsslexer.l"
785{ return EOL; }
786 YY_BREAK
787case 16:
788YY_RULE_SETUP
789#line 90 "icalsslexer.l"
790{
791 int c = input();
792 unput(c);
793 if(c!='\''){
794 sslval.v_string= icalmemory_tmp_copy(sstext);
795 return STRING;
796 } else {
797 /*ssmore();*/
798 }
799}
800 YY_BREAK
801case 17:
802YY_RULE_SETUP
803#line 101 "icalsslexer.l"
804{ sslval.v_string= icalmemory_tmp_copy(sstext);
805 return STRING; }
806 YY_BREAK
807case 18:
808YY_RULE_SETUP
809#line 105 "icalsslexer.l"
810{ return yytext[0]; }
811 YY_BREAK
812case 19:
813YY_RULE_SETUP
814#line 107 "icalsslexer.l"
815ECHO;
816 YY_BREAK
817#line 811 "icalsslexer.c"
818case YY_STATE_EOF(INITIAL):
819case YY_STATE_EOF(sql):
820case YY_STATE_EOF(string_value):
821 yyterminate();
822
823 case YY_END_OF_BUFFER:
824 {
825 /* Amount of text matched not including the EOB char. */
826 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
827
828 /* Undo the effects of YY_DO_BEFORE_ACTION. */
829 *yy_cp = yy_hold_char;
830 YY_RESTORE_YY_MORE_OFFSET
831
832 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
833 {
834 /* We're scanning a new file or input source. It's
835 * possible that this happened because the user
836 * just pointed yyin at a new source and called
837 * yylex(). If so, then we have to assure
838 * consistency between yy_current_buffer and our
839 * globals. Here is the right place to do so, because
840 * this is the first action (other than possibly a
841 * back-up) that will match for the new input source.
842 */
843 yy_n_chars = yy_current_buffer->yy_n_chars;
844 yy_current_buffer->yy_input_file = yyin;
845 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
846 }
847
848 /* Note that here we test for yy_c_buf_p "<=" to the position
849 * of the first EOB in the buffer, since yy_c_buf_p will
850 * already have been incremented past the NUL character
851 * (since all states make transitions on EOB to the
852 * end-of-buffer state). Contrast this with the test
853 * in input().
854 */
855 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
856 { /* This was really a NUL. */
857 yy_state_type yy_next_state;
858
859 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
860
861 yy_current_state = yy_get_previous_state();
862
863 /* Okay, we're now positioned to make the NUL
864 * transition. We couldn't have
865 * yy_get_previous_state() go ahead and do it
866 * for us because it doesn't know how to deal
867 * with the possibility of jamming (and we don't
868 * want to build jamming into it because then it
869 * will run more slowly).
870 */
871
872 yy_next_state = yy_try_NUL_trans( yy_current_state );
873
874 yy_bp = yytext_ptr + YY_MORE_ADJ;
875
876 if ( yy_next_state )
877 {
878 /* Consume the NUL. */
879 yy_cp = ++yy_c_buf_p;
880 yy_current_state = yy_next_state;
881 goto yy_match;
882 }
883
884 else
885 {
886 yy_cp = yy_c_buf_p;
887 goto yy_find_action;
888 }
889 }
890
891 else switch ( yy_get_next_buffer() )
892 {
893 case EOB_ACT_END_OF_FILE:
894 {
895 yy_did_buffer_switch_on_eof = 0;
896
897 if ( yywrap() )
898 {
899 /* Note: because we've taken care in
900 * yy_get_next_buffer() to have set up
901 * yytext, we can now set up
902 * yy_c_buf_p so that if some total
903 * hoser (like flex itself) wants to
904 * call the scanner after we return the
905 * YY_NULL, it'll still work - another
906 * YY_NULL will get returned.
907 */
908 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
909
910 yy_act = YY_STATE_EOF(YY_START);
911 goto do_action;
912 }
913
914 else
915 {
916 if ( ! yy_did_buffer_switch_on_eof )
917 YY_NEW_FILE;
918 }
919 break;
920 }
921
922 case EOB_ACT_CONTINUE_SCAN:
923 yy_c_buf_p =
924 yytext_ptr + yy_amount_of_matched_text;
925
926 yy_current_state = yy_get_previous_state();
927
928 yy_cp = yy_c_buf_p;
929 yy_bp = yytext_ptr + YY_MORE_ADJ;
930 goto yy_match;
931
932 case EOB_ACT_LAST_MATCH:
933 yy_c_buf_p =
934 &yy_current_buffer->yy_ch_buf[yy_n_chars];
935
936 yy_current_state = yy_get_previous_state();
937
938 yy_cp = yy_c_buf_p;
939 yy_bp = yytext_ptr + YY_MORE_ADJ;
940 goto yy_find_action;
941 }
942 break;
943 }
944
945 default:
946 YY_FATAL_ERROR(
947 "fatal flex scanner internal error--no action found" );
948 } /* end of action switch */
949 } /* end of scanning one token */
950 } /* end of yylex */
951
952
953/* yy_get_next_buffer - try to read in a new buffer
954 *
955 * Returns a code representing an action:
956 *EOB_ACT_LAST_MATCH -
957 *EOB_ACT_CONTINUE_SCAN - continue scanning from current position
958 *EOB_ACT_END_OF_FILE - end of file
959 */
960
961static int yy_get_next_buffer()
962 {
963 register char *dest = yy_current_buffer->yy_ch_buf;
964 register char *source = yytext_ptr;
965 register int number_to_move, i;
966 int ret_val;
967
968 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
969 YY_FATAL_ERROR(
970 "fatal flex scanner internal error--end of buffer missed" );
971
972 if ( yy_current_buffer->yy_fill_buffer == 0 )
973 { /* Don't try to fill the buffer, so this is an EOF. */
974 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
975 {
976 /* We matched a single character, the EOB, so
977 * treat this as a final EOF.
978 */
979 return EOB_ACT_END_OF_FILE;
980 }
981
982 else
983 {
984 /* We matched some text prior to the EOB, first
985 * process it.
986 */
987 return EOB_ACT_LAST_MATCH;
988 }
989 }
990
991 /* Try to read more data. */
992
993 /* First move last chars to start of buffer. */
994 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
995
996 for ( i = 0; i < number_to_move; ++i )
997 *(dest++) = *(source++);
998
999 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1000 /* don't do the read, it's not guaranteed to return an EOF,
1001 * just force an EOF
1002 */
1003 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1004
1005 else
1006 {
1007 int num_to_read =
1008 yy_current_buffer->yy_buf_size - number_to_move - 1;
1009
1010 while ( num_to_read <= 0 )
1011 { /* Not enough room in the buffer - grow it. */
1012#ifdef YY_USES_REJECT
1013 YY_FATAL_ERROR(
1014"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1015#else
1016
1017 /* just a shorter name for the current buffer */
1018 YY_BUFFER_STATE b = yy_current_buffer;
1019
1020 int yy_c_buf_p_offset =
1021 (int) (yy_c_buf_p - b->yy_ch_buf);
1022
1023 if ( b->yy_is_our_buffer )
1024 {
1025 int new_size = b->yy_buf_size * 2;
1026
1027 if ( new_size <= 0 )
1028 b->yy_buf_size += b->yy_buf_size / 8;
1029 else
1030 b->yy_buf_size *= 2;
1031
1032 b->yy_ch_buf = (char *)
1033 /* Include room in for 2 EOB chars. */
1034 yy_flex_realloc( (void *) b->yy_ch_buf,
1035 b->yy_buf_size + 2 );
1036 }
1037 else
1038 /* Can't grow it, we don't own it. */
1039 b->yy_ch_buf = 0;
1040
1041 if ( ! b->yy_ch_buf )
1042 YY_FATAL_ERROR(
1043 "fatal error - scanner input buffer overflow" );
1044
1045 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1046
1047 num_to_read = yy_current_buffer->yy_buf_size -
1048 number_to_move - 1;
1049#endif
1050 }
1051
1052 if ( num_to_read > YY_READ_BUF_SIZE )
1053 num_to_read = YY_READ_BUF_SIZE;
1054
1055 /* Read in more data. */
1056 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1057 yy_n_chars, num_to_read );
1058
1059 yy_current_buffer->yy_n_chars = yy_n_chars;
1060 }
1061
1062 if ( yy_n_chars == 0 )
1063 {
1064 if ( number_to_move == YY_MORE_ADJ )
1065 {
1066 ret_val = EOB_ACT_END_OF_FILE;
1067 yyrestart( yyin );
1068 }
1069
1070 else
1071 {
1072 ret_val = EOB_ACT_LAST_MATCH;
1073 yy_current_buffer->yy_buffer_status =
1074 YY_BUFFER_EOF_PENDING;
1075 }
1076 }
1077
1078 else
1079 ret_val = EOB_ACT_CONTINUE_SCAN;
1080
1081 yy_n_chars += number_to_move;
1082 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1083 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1084
1085 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1086
1087 return ret_val;
1088 }
1089
1090
1091/* yy_get_previous_state - get the state just before the EOB char was reached */
1092
1093static yy_state_type yy_get_previous_state()
1094 {
1095 register yy_state_type yy_current_state;
1096 register char *yy_cp;
1097
1098 yy_current_state = yy_start;
1099
1100 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1101 {
1102 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1103 if ( yy_accept[yy_current_state] )
1104 {
1105 yy_last_accepting_state = yy_current_state;
1106 yy_last_accepting_cpos = yy_cp;
1107 }
1108 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1109 {
1110 yy_current_state = (int) yy_def[yy_current_state];
1111 if ( yy_current_state >= 47 )
1112 yy_c = yy_meta[(unsigned int) yy_c];
1113 }
1114 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1115 }
1116
1117 return yy_current_state;
1118 }
1119
1120
1121/* yy_try_NUL_trans - try to make a transition on the NUL character
1122 *
1123 * synopsis
1124 *next_state = yy_try_NUL_trans( current_state );
1125 */
1126
1127#ifdef YY_USE_PROTOS
1128static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1129#else
1130static yy_state_type yy_try_NUL_trans( yy_current_state )
1131yy_state_type yy_current_state;
1132#endif
1133 {
1134 register int yy_is_jam;
1135 register char *yy_cp = yy_c_buf_p;
1136
1137 register YY_CHAR yy_c = 1;
1138 if ( yy_accept[yy_current_state] )
1139 {
1140 yy_last_accepting_state = yy_current_state;
1141 yy_last_accepting_cpos = yy_cp;
1142 }
1143 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1144 {
1145 yy_current_state = (int) yy_def[yy_current_state];
1146 if ( yy_current_state >= 47 )
1147 yy_c = yy_meta[(unsigned int) yy_c];
1148 }
1149 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1150 yy_is_jam = (yy_current_state == 46);
1151
1152 return yy_is_jam ? 0 : yy_current_state;
1153 }
1154
1155
1156#ifndef YY_NO_UNPUT
1157#ifdef YY_USE_PROTOS
1158static void yyunput( int c, register char *yy_bp )
1159#else
1160static void yyunput( c, yy_bp )
1161int c;
1162register char *yy_bp;
1163#endif
1164 {
1165 register char *yy_cp = yy_c_buf_p;
1166
1167 /* undo effects of setting up yytext */
1168 *yy_cp = yy_hold_char;
1169
1170 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1171 { /* need to shift things up to make room */
1172 /* +2 for EOB chars. */
1173 register int number_to_move = yy_n_chars + 2;
1174 register char *dest = &yy_current_buffer->yy_ch_buf[
1175 yy_current_buffer->yy_buf_size + 2];
1176 register char *source =
1177 &yy_current_buffer->yy_ch_buf[number_to_move];
1178
1179 while ( source > yy_current_buffer->yy_ch_buf )
1180 *--dest = *--source;
1181
1182 yy_cp += (int) (dest - source);
1183 yy_bp += (int) (dest - source);
1184 yy_current_buffer->yy_n_chars =
1185 yy_n_chars = yy_current_buffer->yy_buf_size;
1186
1187 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1188 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1189 }
1190
1191 *--yy_cp = (char) c;
1192
1193
1194 yytext_ptr = yy_bp;
1195 yy_hold_char = *yy_cp;
1196 yy_c_buf_p = yy_cp;
1197 }
1198 #endif/* ifndef YY_NO_UNPUT */
1199
1200
1201#ifdef __cplusplus
1202static int yyinput()
1203#else
1204static int input()
1205#endif
1206 {
1207 int c;
1208
1209 *yy_c_buf_p = yy_hold_char;
1210
1211 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1212 {
1213 /* 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
1215 * valid NUL; if not, then we've hit the end of the buffer.
1216 */
1217 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1218 /* This was really a NUL. */
1219 *yy_c_buf_p = '\0';
1220
1221 else
1222 { /* need more input */
1223 int offset = yy_c_buf_p - yytext_ptr;
1224 ++yy_c_buf_p;
1225
1226 switch ( yy_get_next_buffer() )
1227 {
1228 case EOB_ACT_LAST_MATCH:
1229 /* This happens because yy_g_n_b()
1230 * sees that we've accumulated a
1231 * token and flags that we need to
1232 * try matching the token before
1233 * proceeding. But for input(),
1234 * there's no matching to consider.
1235 * So convert the EOB_ACT_LAST_MATCH
1236 * to EOB_ACT_END_OF_FILE.
1237 */
1238
1239 /* Reset buffer status. */
1240 yyrestart( yyin );
1241
1242 /* fall through */
1243
1244 case EOB_ACT_END_OF_FILE:
1245 {
1246 if ( yywrap() )
1247 return EOF;
1248
1249 if ( ! yy_did_buffer_switch_on_eof )
1250 YY_NEW_FILE;
1251#ifdef __cplusplus
1252 return yyinput();
1253#else
1254 return input();
1255#endif
1256 }
1257
1258 case EOB_ACT_CONTINUE_SCAN:
1259 yy_c_buf_p = yytext_ptr + offset;
1260 break;
1261 }
1262 }
1263 }
1264
1265 c = *(unsigned char *) yy_c_buf_p;/* cast for 8-bit char's */
1266 *yy_c_buf_p = '\0';/* preserve yytext */
1267 yy_hold_char = *++yy_c_buf_p;
1268
1269
1270 return c;
1271 }
1272
1273
1274#ifdef YY_USE_PROTOS
1275void yyrestart( FILE *input_file )
1276#else
1277void yyrestart( input_file )
1278FILE *input_file;
1279#endif
1280 {
1281 if ( ! yy_current_buffer )
1282 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1283
1284 yy_init_buffer( yy_current_buffer, input_file );
1285 yy_load_buffer_state();
1286 }
1287
1288
1289#ifdef YY_USE_PROTOS
1290void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1291#else
1292void yy_switch_to_buffer( new_buffer )
1293YY_BUFFER_STATE new_buffer;
1294#endif
1295 {
1296 if ( yy_current_buffer == new_buffer )
1297 return;
1298
1299 if ( yy_current_buffer )
1300 {
1301 /* Flush out information for old buffer. */
1302 *yy_c_buf_p = yy_hold_char;
1303 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1304 yy_current_buffer->yy_n_chars = yy_n_chars;
1305 }
1306
1307 yy_current_buffer = new_buffer;
1308 yy_load_buffer_state();
1309
1310 /* We don't actually know whether we did this switch during
1311 * EOF (yywrap()) processing, but the only time this flag
1312 * is looked at is after yywrap() is called, so it's safe
1313 * to go ahead and always set it.
1314 */
1315 yy_did_buffer_switch_on_eof = 1;
1316 }
1317
1318
1319#ifdef YY_USE_PROTOS
1320void yy_load_buffer_state( void )
1321#else
1322void yy_load_buffer_state()
1323#endif
1324 {
1325 yy_n_chars = yy_current_buffer->yy_n_chars;
1326 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1327 yyin = yy_current_buffer->yy_input_file;
1328 yy_hold_char = *yy_c_buf_p;
1329 }
1330
1331
1332#ifdef YY_USE_PROTOS
1333YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1334#else
1335YY_BUFFER_STATE yy_create_buffer( file, size )
1336FILE *file;
1337int size;
1338#endif
1339 {
1340 YY_BUFFER_STATE b;
1341
1342 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1343 if ( ! b )
1344 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1345
1346 b->yy_buf_size = size;
1347
1348 /* 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.
1350 */
1351 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1352 if ( ! b->yy_ch_buf )
1353 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1354
1355 b->yy_is_our_buffer = 1;
1356
1357 yy_init_buffer( b, file );
1358
1359 return b;
1360 }
1361
1362
1363#ifdef YY_USE_PROTOS
1364void yy_delete_buffer( YY_BUFFER_STATE b )
1365#else
1366void yy_delete_buffer( b )
1367YY_BUFFER_STATE b;
1368#endif
1369 {
1370 if ( ! b )
1371 return;
1372
1373 if ( b == yy_current_buffer )
1374 yy_current_buffer = (YY_BUFFER_STATE) 0;
1375
1376 if ( b->yy_is_our_buffer )
1377 yy_flex_free( (void *) b->yy_ch_buf );
1378
1379 yy_flex_free( (void *) b );
1380 }
1381
1382
1383
1384#ifdef YY_USE_PROTOS
1385void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1386#else
1387void yy_init_buffer( b, file )
1388YY_BUFFER_STATE b;
1389FILE *file;
1390#endif
1391
1392
1393 {
1394 yy_flush_buffer( b );
1395
1396 b->yy_input_file = file;
1397 b->yy_fill_buffer = 1;
1398
1399#if YY_ALWAYS_INTERACTIVE
1400 b->yy_is_interactive = 1;
1401#else
1402#if YY_NEVER_INTERACTIVE
1403 b->yy_is_interactive = 0;
1404#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;
1410#endif
1411
1412#endif
1413#endif
1414 }
1415
1416
1417#ifdef YY_USE_PROTOS
1418void yy_flush_buffer( YY_BUFFER_STATE b )
1419#else
1420void yy_flush_buffer( b )
1421YY_BUFFER_STATE b;
1422#endif
1423
1424 {
1425 if ( ! b )
1426 return;
1427
1428 b->yy_n_chars = 0;
1429
1430 /* We always need two end-of-buffer characters. The first causes
1431 * a transition to the end-of-buffer state. The second causes
1432 * a jam in that state.
1433 */
1434 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1435 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1436
1437 b->yy_buf_pos = &b->yy_ch_buf[0];
1438
1439 b->yy_at_bol = 1;
1440 b->yy_buffer_status = YY_BUFFER_NEW;
1441
1442 if ( b == yy_current_buffer )
1443 yy_load_buffer_state();
1444 }
1445
1446
1447#ifndef YY_NO_SCAN_BUFFER
1448#ifdef YY_USE_PROTOS
1449YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1450#else
1451YY_BUFFER_STATE yy_scan_buffer( base, size )
1452char *base;
1453yy_size_t size;
1454#endif
1455 {
1456 YY_BUFFER_STATE b;
1457
1458 if ( size < 2 ||
1459 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1460 base[size-1] != YY_END_OF_BUFFER_CHAR )
1461 /* They forgot to leave room for the EOB's. */
1462 return 0;
1463
1464 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1465 if ( ! b )
1466 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1467
1468 b->yy_buf_size = size - 2;/* "- 2" to take care of EOB's */
1469 b->yy_buf_pos = b->yy_ch_buf = base;
1470 b->yy_is_our_buffer = 0;
1471 b->yy_input_file = 0;
1472 b->yy_n_chars = b->yy_buf_size;
1473 b->yy_is_interactive = 0;
1474 b->yy_at_bol = 1;
1475 b->yy_fill_buffer = 0;
1476 b->yy_buffer_status = YY_BUFFER_NEW;
1477
1478 yy_switch_to_buffer( b );
1479
1480 return b;
1481 }
1482#endif
1483
1484
1485#ifndef YY_NO_SCAN_STRING
1486#ifdef YY_USE_PROTOS
1487YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1488#else
1489YY_BUFFER_STATE yy_scan_string( yy_str )
1490yyconst char *yy_str;
1491#endif
1492 {
1493 int len;
1494 for ( len = 0; yy_str[len]; ++len )
1495 ;
1496
1497 return yy_scan_bytes( yy_str, len );
1498 }
1499#endif
1500
1501
1502#ifndef YY_NO_SCAN_BYTES
1503#ifdef YY_USE_PROTOS
1504YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1505#else
1506YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1507yyconst char *bytes;
1508int len;
1509#endif
1510 {
1511 YY_BUFFER_STATE b;
1512 char *buf;
1513 yy_size_t n;
1514 int i;
1515
1516 /* Get memory for full buffer, including space for trailing EOB's. */
1517 n = len + 2;
1518 buf = (char *) yy_flex_alloc( n );
1519 if ( ! buf )
1520 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1521
1522 for ( i = 0; i < len; ++i )
1523 buf[i] = bytes[i];
1524
1525 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1526
1527 b = yy_scan_buffer( buf, n );
1528 if ( ! b )
1529 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1530
1531 /* It's okay to grow etc. this buffer, and we should throw it
1532 * away when we're done.
1533 */
1534 b->yy_is_our_buffer = 1;
1535
1536 return b;
1537 }
1538#endif
1539
1540
1541#ifndef YY_NO_PUSH_STATE
1542#ifdef YY_USE_PROTOS
1543static void yy_push_state( int new_state )
1544#else
1545static void yy_push_state( new_state )
1546int new_state;
1547#endif
1548 {
1549 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1550 {
1551 yy_size_t new_size;
1552
1553 yy_start_stack_depth += YY_START_STACK_INCR;
1554 new_size = yy_start_stack_depth * sizeof( int );
1555
1556 if ( ! yy_start_stack )
1557 yy_start_stack = (int *) yy_flex_alloc( new_size );
1558
1559 else
1560 yy_start_stack = (int *) yy_flex_realloc(
1561 (void *) yy_start_stack, new_size );
1562
1563 if ( ! yy_start_stack )
1564 YY_FATAL_ERROR(
1565 "out of memory expanding start-condition stack" );
1566 }
1567
1568 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1569
1570 BEGIN(new_state);
1571 }
1572#endif
1573
1574
1575#ifndef YY_NO_POP_STATE
1576static void yy_pop_state()
1577 {
1578 if ( --yy_start_stack_ptr < 0 )
1579 YY_FATAL_ERROR( "start-condition stack underflow" );
1580
1581 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1582 }
1583#endif
1584
1585
1586#ifndef YY_NO_TOP_STATE
1587static int yy_top_state()
1588 {
1589 return yy_start_stack[yy_start_stack_ptr - 1];
1590 }
1591#endif
1592
1593#ifndef YY_EXIT_FAILURE
1594#define YY_EXIT_FAILURE 2
1595#endif
1596
1597#ifdef YY_USE_PROTOS
1598static void yy_fatal_error( yyconst char msg[] )
1599#else
1600static void yy_fatal_error( msg )
1601char msg[];
1602#endif
1603 {
1604 (void) fprintf( stderr, "%s\n", msg );
1605 exit( YY_EXIT_FAILURE );
1606 }
1607
1608
1609
1610/* Redefine yyless() so it works in section 3 code. */
1611
1612#undef yyless
1613#define yyless(n) \
1614 do \
1615 { \
1616 /* Undo effects of setting up yytext. */ \
1617 yytext[yyleng] = yy_hold_char; \
1618 yy_c_buf_p = yytext + n; \
1619 yy_hold_char = *yy_c_buf_p; \
1620 *yy_c_buf_p = '\0'; \
1621 yyleng = n; \
1622 } \
1623 while ( 0 )
1624
1625
1626/* Internal utility routines. */
1627
1628#ifndef yytext_ptr
1629#ifdef YY_USE_PROTOS
1630static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1631#else
1632static void yy_flex_strncpy( s1, s2, n )
1633char *s1;
1634yyconst char *s2;
1635int n;
1636#endif
1637 {
1638 register int i;
1639 for ( i = 0; i < n; ++i )
1640 s1[i] = s2[i];
1641 }
1642#endif
1643
1644#ifdef YY_NEED_STRLEN
1645#ifdef YY_USE_PROTOS
1646static int yy_flex_strlen( yyconst char *s )
1647#else
1648static int yy_flex_strlen( s )
1649yyconst char *s;
1650#endif
1651 {
1652 register int n;
1653 for ( n = 0; s[n]; ++n )
1654 ;
1655
1656 return n;
1657 }
1658#endif
1659
1660
1661#ifdef YY_USE_PROTOS
1662static void *yy_flex_alloc( yy_size_t size )
1663#else
1664static void *yy_flex_alloc( size )
1665yy_size_t size;
1666#endif
1667 {
1668 return (void *) malloc( size );
1669 }
1670
1671#ifdef YY_USE_PROTOS
1672static void *yy_flex_realloc( void *ptr, yy_size_t size )
1673#else
1674static void *yy_flex_realloc( ptr, size )
1675void *ptr;
1676yy_size_t size;
1677#endif
1678 {
1679 /* The cast to (char *) in the following accommodates both
1680 * implementations that use char* generic pointers, and those
1681 * that use void* generic pointers. It works with the latter
1682 * because both ANSI C and C++ allow castless assignment from
1683 * any pointer type to void*, and deal with argument conversions
1684 * as though doing an assignment.
1685 */
1686 return (void *) realloc( (char *) ptr, size );
1687 }
1688
1689#ifdef YY_USE_PROTOS
1690static void yy_flex_free( void *ptr )
1691#else
1692static void yy_flex_free( ptr )
1693void *ptr;
1694#endif
1695 {
1696 free( ptr );
1697 }
1698
1699#if YY_MAIN
1700int main()
1701 {
1702 yylex();
1703 return 0;
1704 }
1705#endif
1706#line 107 "icalsslexer.l"
1707
1708
1709int sswrap()
1710{
1711 return 1;
1712}
1713
diff --git a/libical/src/libicalss/icalsslexer.l b/libical/src/libicalss/icalsslexer.l
new file mode 100644
index 0000000..58aa162
--- a/dev/null
+++ b/libical/src/libicalss/icalsslexer.l
@@ -0,0 +1,113 @@
1%{
2/* -*- Mode: C -*-
3 ======================================================================
4 FILE: icalsslexer.l
5 CREATOR: eric 8 Aug 2000
6
7 DESCRIPTION:
8
9 $Id$
10 $Locker$
11
12(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of either:
16
17 The LGPL as published by the Free Software Foundation, version
18 2.1, available at: http://www.fsf.org/copyleft/lesser.html
19
20 Or:
21
22 The Mozilla Public License Version 1.0. You may obtain a copy of
23 the License at http://www.mozilla.org/MPL/
24
25 The Original Code is eric. The Initial Developer of the Original
26 Code is Eric Busboom
27
28 ======================================================================*/
29
30#include "icalssyacc.h"
31#include "icalgaugeimpl.h"
32#include "assert.h"
33
34#include <string.h> /* For strdup() */
35
36int icalparser_flex_input(char* buf, int max_size);
37void icalparser_clear_flex_input();
38
39#undef YY_INPUT
40#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
41
42#undef SS_FATAL_ERROR
43#define SS_FATAL_ERROR(msg) sserror(msg)
44
45
46%}
47
48 crlf \x0D?\x0A
49 space [ ]
50 qsafechar[^\x00-\x1F\"]
51 safechar[^\x00-\x1F\"\:\;\,]
52 tsafechar[\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E]
53 valuechar[^\x00-\x08\x10-\x1F]
54 xname X-[a-zA-Z0-9\-]+
55xname2 [a-zA-Z0-9\-\ ]
56 paramtext{safechar}+
57 value {valuechar}+
58 quotedstring\"{qsafechar}+\"
59 digit [0-9]
60
61%array /* Make yytext an array. Slow, but handy. HACK */
62
63%option caseless
64
65%s sql string_value
66
67
68
69%%
70
71%{
72%}
73
74
75 SELECT { return SELECT; }
76 FROM { return FROM; }
77 WHERE { return WHERE; }
78 , { return COMMA; }
79 "=" { return EQUALS; }
80 "!=" { return NOTEQUALS; }
81 "<" { return LESS; }
82 ">" { return GREATER; }
83 "<=" { return LESSEQUALS; }
84 ">=" { return GREATEREQUALS; }
85 AND { return AND; }
86 OR { return OR; }
87\' { return QUOTE; }
88 [ \t\n\r]+ ;
89 ; { return EOL; }
90\'[\*A-Za-z0-9\-\.]+\' {
91 int c = input();
92 unput(c);
93 if(c!='\''){
94 sslval.v_string= icalmemory_tmp_copy(sstext);
95 return STRING;
96 } else {
97 /*ssmore();*/
98 }
99}
100
101 [\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext);
102 return STRING; }
103
104
105 . { return yytext[0]; }
106
107%%
108
109int sswrap()
110{
111 return 1;
112}
113
diff --git a/libical/src/libicalss/icalssyacc.c b/libical/src/libicalss/icalssyacc.c
new file mode 100644
index 0000000..943123e
--- a/dev/null
+++ b/libical/src/libicalss/icalssyacc.c
@@ -0,0 +1,1381 @@
1/* A Bison parser, made from icalssyacc.y
2 by GNU bison 1.35. */
3
4#define YYBISON 1 /* Identify Bison output. */
5
6#define yyparse ssparse
7#define yylex sslex
8#define yyerror sserror
9#define yylval sslval
10#define yychar sschar
11#define yydebug ssdebug
12#define yynerrs ssnerrs
13 # define STRING257
14 # define SELECT258
15 # define FROM259
16 # define WHERE260
17 # define COMMA261
18 # define QUOTE262
19 # define EQUALS263
20 # define NOTEQUALS264
21 # define LESS265
22 # define GREATER266
23 # define LESSEQUALS267
24 # define GREATEREQUALS268
25 # define AND269
26 # define OR270
27 # define EOL271
28 # define END272
29
30#line 1 "icalssyacc.y"
31
32/* -*- Mode: C -*-
33 ======================================================================
34 FILE: icalssyacc.y
35 CREATOR: eric 08 Aug 2000
36
37 DESCRIPTION:
38
39 $Id$
40 $Locker$
41
42(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
43
44 This program is free software; you can redistribute it and/or modify
45 it under the terms of either:
46
47 The LGPL as published by the Free Software Foundation, version
48 2.1, available at: http://www.fsf.org/copyleft/lesser.html
49
50 Or:
51
52 The Mozilla Public License Version 1.0. You may obtain a copy of
53 the License at http://www.mozilla.org/MPL/
54
55 The Original Code is eric. The Initial Developer of the Original
56 Code is Eric Busboom
57
58 ======================================================================*/
59
60#include <stdlib.h>
61#include <string.h> /* for strdup() */
62#include <limits.h> /* for SHRT_MAX*/
63#include "ical.h"
64#include "pvl.h"
65#include "icalgauge.h"
66#include "icalgaugeimpl.h"
67
68
69extern struct icalgauge_impl *icalss_yy_gauge;
70
71void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
72 icalgaugecompare compare , char* value);
73void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
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
78
79
80
81#line 52 "icalssyacc.y"
82#ifndef YYSTYPE
83typedef union {
84 char* v_string;
85} yystype;
86# define YYSTYPE yystype
87# define YYSTYPE_IS_TRIVIAL 1
88#endif
89#ifndef YYDEBUG
90# define YYDEBUG 0
91#endif
92
93
94
95 #define YYFINAL 34
96 #define YYFLAG -32768
97 #define YYNTBASE19
98
99/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
100#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 24)
101
102/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
103static const char yytranslate[] =
104{
105 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
106 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
107 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
110 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
111 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
112 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
113 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
114 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
117 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
131 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
132 16, 17, 18
133};
134
135#if YYDEBUG
136static const short yyprhs[] =
137{
138 0, 0, 7, 9, 11, 15, 17, 21, 22, 26,
139 30, 34, 38, 42, 46, 48, 52
140};
141static const short yyrhs[] =
142{
143 4, 20, 5, 21, 6, 23, 0, 1, 0, 3,
144 0, 20, 7, 3, 0, 3, 0, 21, 7, 3,
145 0, 0, 3, 9, 3, 0, 3, 10, 3, 0,
146 3, 11, 3, 0, 3, 12, 3, 0, 3, 13,
147 3, 0, 3, 14, 3, 0, 22, 0, 23, 15,
148 22, 0, 23, 16, 22, 0
149};
150
151#endif
152
153#if YYDEBUG
154/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
155static const short yyrline[] =
156{
157 0, 63, 64, 70, 72, 76, 78, 81, 83, 85,
158 86, 87, 88, 89, 92, 94, 95
159};
160#endif
161
162
163#if (YYDEBUG) || defined YYERROR_VERBOSE
164
165/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
166static const char *const yytname[] =
167{
168 "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA",
169 "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS",
170 "GREATEREQUALS", "AND", "OR", "EOL", "END", "query_min", "select_list",
171 "from_list", "where_clause", "where_list", 0
172};
173#endif
174
175/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
176static const short yyr1[] =
177{
178 0, 19, 19, 20, 20, 21, 21, 22, 22, 22,
179 22, 22, 22, 22, 23, 23, 23
180};
181
182/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
183static const short yyr2[] =
184{
185 0, 6, 1, 1, 3, 1, 3, 0, 3, 3,
186 3, 3, 3, 3, 1, 3, 3
187};
188
189/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
190 doesn't specify something else to do. Zero means the default is an
191 error. */
192static const short yydefact[] =
193{
194 0, 2, 0, 3, 0, 0, 0, 5, 0, 4,
195 7, 0, 0, 14, 1, 6, 0, 0, 0, 0,
196 0, 0, 7, 7, 8, 9, 10, 11, 12, 13,
197 15, 16, 0, 0, 0
198};
199
200static const short yydefgoto[] =
201{
202 32, 4, 8, 13, 14
203};
204
205static const short yypact[] =
206{
207 5,-32768, 4,-32768, 3, 8, 15,-32768, 6,-32768,
208 16, 17, -9,-32768, -1,-32768, 18, 19, 20, 21,
209 22, 23, 16, 16,-32768,-32768,-32768,-32768,-32768,-32768,
210 -32768,-32768, 27, 28,-32768
211};
212
213static const short yypgoto[] =
214{
215 -32768,-32768,-32768, -6,-32768
216};
217
218
219 #define YYLAST 28
220
221
222static const short yytable[] =
223{
224 16, 17, 18, 19, 20, 21, 1, 3, 5, 2,
225 6, 7, 10, 11, 22, 23, 30, 31, 9, 12,
226 15, 24, 25, 26, 27, 28, 29, 33, 34
227};
228
229static const short yycheck[] =
230{
231 9, 10, 11, 12, 13, 14, 1, 3, 5, 4,
232 7, 3, 6, 7, 15, 16, 22, 23, 3, 3,
233 3, 3, 3, 3, 3, 3, 3, 0, 0
234};
235/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
236#line 3 "/usr/share/bison/bison.simple"
237
238/* Skeleton output parser for bison,
239
240 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
241 Foundation, Inc.
242
243 This program is free software; you can redistribute it and/or modify
244 it under the terms of the GNU General Public License as published by
245 the Free Software Foundation; either version 2, or (at your option)
246 any later version.
247
248 This program is distributed in the hope that it will be useful,
249 but WITHOUT ANY WARRANTY; without even the implied warranty of
250 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
251 GNU General Public License for more details.
252
253 You should have received a copy of the GNU General Public License
254 along with this program; if not, write to the Free Software
255 Foundation, Inc., 59 Temple Place - Suite 330,
256 Boston, MA 02111-1307, USA. */
257
258/* As a special exception, when this file is copied by Bison into a
259 Bison output file, you may use that output file without restriction.
260 This special exception was added by the Free Software Foundation
261 in version 1.24 of Bison. */
262
263/* This is the parser code that is written into each bison parser when
264 the %semantic_parser declaration is not specified in the grammar.
265 It was written by Richard Stallman by simplifying the hairy parser
266 used when %semantic_parser is specified. */
267
268/* All symbols defined below should begin with yy or YY, to avoid
269 infringing on user name space. This should be done even for local
270 variables, as they might otherwise be expanded by user macros.
271 There are some unavoidable exceptions within include files to
272 define necessary library symbols; they are noted "INFRINGES ON
273 USER NAME SPACE" below. */
274
275#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
276
277/* The parser invokes alloca or malloc; define the necessary symbols. */
278
279# if YYSTACK_USE_ALLOCA
280# define YYSTACK_ALLOC alloca
281# else
282# ifndef YYSTACK_USE_ALLOCA
283# if defined (alloca) || defined (_ALLOCA_H)
284# define YYSTACK_ALLOC alloca
285# else
286# ifdef __GNUC__
287# define YYSTACK_ALLOC __builtin_alloca
288# endif
289# endif
290# endif
291# endif
292
293# ifdef YYSTACK_ALLOC
294 /* Pacify GCC's `empty if-body' warning. */
295# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
296# else
297# if defined (__STDC__) || defined (__cplusplus)
298# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
299# define YYSIZE_T size_t
300# endif
301# define YYSTACK_ALLOC malloc
302# define YYSTACK_FREE free
303# 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
311/* A type that is properly aligned for any stack member. */
312union yyalloc
313{
314 short yyss;
315 YYSTYPE yyvs;
316# if YYLSP_NEEDED
317 YYLTYPE yyls;
318# endif
319};
320
321/* The size of the maximum gap between one aligned stack and the next. */
322# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
323
324/* The size of an array large to enough to hold all stacks, each with
325 N elements. */
326# if YYLSP_NEEDED
327# define YYSTACK_BYTES(N) \
328 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))\
329 + 2 * YYSTACK_GAP_MAX)
330# else
331# define YYSTACK_BYTES(N) \
332 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
333 + YYSTACK_GAP_MAX)
334# endif
335
336/* Copy COUNT objects from FROM to TO. The source and destination do
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
356 elements in the stack, and YYPTR gives the new location of the
357 stack. Advance YYPTR to a properly aligned location for the next
358 stack. */
359 # define YYSTACK_RELOCATE(Stack) \
360 do \
361 { \
362 YYSIZE_T yynewbytes; \
363 YYCOPY (&yyptr->Stack, Stack, yysize); \
364 Stack = &yyptr->Stack; \
365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;\
366 yyptr += yynewbytes / sizeof (*yyptr); \
367 } \
368 while (0)
369
370#endif
371
372
373#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
374# define YYSIZE_T __SIZE_TYPE__
375#endif
376#if ! defined (YYSIZE_T) && defined (size_t)
377# define YYSIZE_T size_t
378#endif
379#if ! defined (YYSIZE_T)
380# if defined (__STDC__) || defined (__cplusplus)
381# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
382# define YYSIZE_T size_t
383# endif
384#endif
385#if ! defined (YYSIZE_T)
386# define YYSIZE_T unsigned int
387#endif
388
389 #define yyerrok (yyerrstatus = 0)
390 #define yyclearin(yychar = YYEMPTY)
391 #define YYEMPTY -2
392 #define YYEOF 0
393 #define YYACCEPTgoto yyacceptlab
394 #define YYABORT goto yyabortlab
395 #define YYERROR goto yyerrlab1
396/* Like YYERROR except do call yyerror. This remains here temporarily
397 to ease the transition to the new meaning of YYERROR, for GCC.
398 Once GCC version 2 has supplanted version 1, this can go. */
399 #define YYFAIL goto yyerrlab
400#define YYRECOVERING() (!!yyerrstatus)
401 #define YYBACKUP(Token, Value) \
402 do \
403 if (yychar == YYEMPTY && yylen == 1) \
404 { \
405 yychar = (Token); \
406 yylval = (Value); \
407 yychar1 = YYTRANSLATE (yychar); \
408 YYPOPSTACK; \
409 goto yybackup; \
410 } \
411 else \
412 { \
413 yyerror ("syntax error: cannot back up"); \
414 YYERROR; \
415 } \
416while (0)
417
418 #define YYTERROR1
419 #define YYERRCODE256
420
421
422/* YYLLOC_DEFAULT -- Compute the default location (before the actions
423 are run).
424
425 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
426 first token. By default, to implement support for ranges, extend
427 its range to the last symbol. */
428
429#ifndef YYLLOC_DEFAULT
430 # define YYLLOC_DEFAULT(Current, Rhs, N) \
431 Current.last_line = Rhs[N].last_line;\
432 Current.last_column = Rhs[N].last_column;
433#endif
434
435
436/* YYLEX -- calling `yylex' with the right arguments. */
437
438#if YYPURE
439# if YYLSP_NEEDED
440# ifdef YYLEX_PARAM
441 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
442# else
443 # define YYLEX yylex (&yylval, &yylloc)
444# endif
445# else /* !YYLSP_NEEDED */
446# ifdef YYLEX_PARAM
447 # define YYLEX yylex (&yylval, YYLEX_PARAM)
448# else
449 # define YYLEX yylex (&yylval)
450# endif
451# endif /* !YYLSP_NEEDED */
452#else /* !YYPURE */
453 # define YYLEX yylex ()
454#endif /* !YYPURE */
455
456
457/* Enable debugging if requested. */
458#if YYDEBUG
459
460# ifndef YYFPRINTF
461# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
462# define YYFPRINTF fprintf
463# endif
464
465 # define YYDPRINTF(Args) \
466 do { \
467 if (yydebug) \
468 YYFPRINTF Args; \
469} while (0)
470/* Nonzero means print parse trace. It is left uninitialized so that
471 multiple parsers can coexist. */
472int yydebug;
473#else /* !YYDEBUG */
474# define YYDPRINTF(Args)
475#endif /* !YYDEBUG */
476
477/* YYINITDEPTH -- initial size of the parser's stacks. */
478 #ifndefYYINITDEPTH
479# define YYINITDEPTH 200
480#endif
481
482/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
483 if the built-in stack extension method is used).
484
485 Do not make this value too large; the results are undefined if
486 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
487 evaluated with infinite-precision integer arithmetic. */
488
489#if YYMAXDEPTH == 0
490# undef YYMAXDEPTH
491#endif
492
493#ifndef YYMAXDEPTH
494# define YYMAXDEPTH 10000
495#endif
496
497#ifdef YYERROR_VERBOSE
498
499# ifndef yystrlen
500# if defined (__GLIBC__) && defined (_STRING_H)
501# define yystrlen strlen
502# else
503/* Return the length of YYSTR. */
504static YYSIZE_T
505# if defined (__STDC__) || defined (__cplusplus)
506yystrlen (const char *yystr)
507# else
508yystrlen (yystr)
509 const char *yystr;
510# endif
511{
512 register const char *yys = yystr;
513
514 while (*yys++ != '\0')
515 continue;
516
517 return yys - yystr - 1;
518}
519# endif
520# endif
521
522# ifndef yystpcpy
523# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
524# define yystpcpy stpcpy
525# else
526/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
527 YYDEST. */
528static char *
529# if defined (__STDC__) || defined (__cplusplus)
530yystpcpy (char *yydest, const char *yysrc)
531# else
532yystpcpy (yydest, yysrc)
533 char *yydest;
534 const char *yysrc;
535# endif
536{
537 register char *yyd = yydest;
538 register const char *yys = yysrc;
539
540 while ((*yyd++ = *yys++) != '\0')
541 continue;
542
543 return yyd - 1;
544}
545# endif
546# endif
547#endif
548
549#line 315 "/usr/share/bison/bison.simple"
550
551
552/* The user can define YYPARSE_PARAM as the name of an argument to be passed
553 into yyparse. The argument should have type void *.
554 It should actually point to an object.
555 Grammar actions can access the variable by casting it
556 to the proper pointer type. */
557
558#ifdef YYPARSE_PARAM
559# if defined (__STDC__) || defined (__cplusplus)
560# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
561# define YYPARSE_PARAM_DECL
562# else
563# define YYPARSE_PARAM_ARG YYPARSE_PARAM
564# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
565# endif
566#else /* !YYPARSE_PARAM */
567# define YYPARSE_PARAM_ARG
568# define YYPARSE_PARAM_DECL
569#endif /* !YYPARSE_PARAM */
570
571/* Prevent warning if -Wstrict-prototypes. */
572#ifdef __GNUC__
573# ifdef YYPARSE_PARAM
574int yyparse (void *);
575# else
576int yyparse (void);
577# endif
578#endif
579
580/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
581 variables are global, or local to YYPARSE. */
582
583 #define YY_DECL_NON_LSP_VARIABLES \
584 /* The lookahead symbol. */ \
585 int yychar; \
586 \
587 /* The semantic value of the lookahead symbol. */\
588 YYSTYPE yylval; \
589 \
590 /* Number of parse errors so far. */ \
591int yynerrs;
592
593#if YYLSP_NEEDED
594 # define YY_DECL_VARIABLES \
595 YY_DECL_NON_LSP_VARIABLES \
596 \
597 /* Location data for the lookahead symbol. */\
598YYLTYPE yylloc;
599#else
600 # define YY_DECL_VARIABLES \
601YY_DECL_NON_LSP_VARIABLES
602#endif
603
604
605/* If nonreentrant, generate the variables here. */
606
607#if !YYPURE
608YY_DECL_VARIABLES
609#endif /* !YYPURE */
610
611int
612yyparse (YYPARSE_PARAM_ARG)
613 YYPARSE_PARAM_DECL
614{
615 /* If reentrant, generate the variables here. */
616#if YYPURE
617 YY_DECL_VARIABLES
618#endif /* !YYPURE */
619
620 register int yystate;
621 register int yyn;
622 int yyresult;
623 /* Number of tokens to shift before error messages enabled. */
624 int yyerrstatus;
625 /* Lookahead token as an internal (translated) token number. */
626 int yychar1 = 0;
627
628 /* Three stacks and their tools:
629 `yyss': related to states,
630 `yyvs': related to semantic values,
631 `yyls': related to locations.
632
633 Refer to the stacks thru separate pointers, to allow yyoverflow
634 to reallocate them elsewhere. */
635
636 /* The state stack. */
637 shortyyssa[YYINITDEPTH];
638 short *yyss = yyssa;
639 register short *yyssp;
640
641 /* The semantic value stack. */
642 YYSTYPE yyvsa[YYINITDEPTH];
643 YYSTYPE *yyvs = yyvsa;
644 register YYSTYPE *yyvsp;
645
646#if YYLSP_NEEDED
647 /* The location stack. */
648 YYLTYPE yylsa[YYINITDEPTH];
649 YYLTYPE *yyls = yylsa;
650 YYLTYPE *yylsp;
651#endif
652
653#if YYLSP_NEEDED
654# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
655#else
656# define YYPOPSTACK (yyvsp--, yyssp--)
657#endif
658
659 YYSIZE_T yystacksize = YYINITDEPTH;
660
661
662 /* The variables used to return semantic value and location from the
663 action routines. */
664 YYSTYPE yyval;
665#if YYLSP_NEEDED
666 YYLTYPE yyloc;
667#endif
668
669 /* When reducing, the number of symbols on the RHS of the reduced
670 rule. */
671 int yylen;
672
673 YYDPRINTF ((stderr, "Starting parse\n"));
674
675 yystate = 0;
676 yyerrstatus = 0;
677 yynerrs = 0;
678 yychar = YYEMPTY; /* Cause a token to be read. */
679
680 /* Initialize stack pointers.
681 Waste one element of value and location stack
682 so that they stay on the same level as the state stack.
683 The wasted elements are never initialized. */
684
685 yyssp = yyss;
686 yyvsp = yyvs;
687#if YYLSP_NEEDED
688 yylsp = yyls;
689#endif
690 goto yysetstate;
691
692/*------------------------------------------------------------.
693| yynewstate -- Push a new state, which is found in yystate. |
694`------------------------------------------------------------*/
695 yynewstate:
696 /* In all cases, when you get here, the value and location stacks
697 have just been pushed. so pushing a state here evens the stacks.
698 */
699 yyssp++;
700
701 yysetstate:
702 *yyssp = yystate;
703
704 if (yyssp >= yyss + yystacksize - 1)
705 {
706 /* Get the current used size of the three stacks, in elements. */
707 YYSIZE_T yysize = yyssp - yyss + 1;
708
709#ifdef yyoverflow
710 {
711 /* Give user a chance to reallocate the stack. Use copies of
712 these so that the &'s don't force the real ones into
713 memory. */
714 YYSTYPE *yyvs1 = yyvs;
715 short *yyss1 = yyss;
716
717 /* Each stack pointer address is followed by the size of the
718 data in use in that stack, in bytes. */
719# if YYLSP_NEEDED
720 YYLTYPE *yyls1 = yyls;
721 /* This used to be a conditional around just the two extra args,
722 but that might be undefined if yyoverflow is a macro. */
723 yyoverflow ("parser stack overflow",
724 &yyss1, yysize * sizeof (*yyssp),
725 &yyvs1, yysize * sizeof (*yyvsp),
726 &yyls1, yysize * sizeof (*yylsp),
727 &yystacksize);
728 yyls = yyls1;
729# else
730 yyoverflow ("parser stack overflow",
731 &yyss1, yysize * sizeof (*yyssp),
732 &yyvs1, yysize * sizeof (*yyvsp),
733 &yystacksize);
734# endif
735 yyss = yyss1;
736 yyvs = yyvs1;
737 }
738#else /* no yyoverflow */
739# ifndef YYSTACK_RELOCATE
740 goto yyoverflowlab;
741# else
742 /* Extend the stack our own way. */
743 if (yystacksize >= YYMAXDEPTH)
744 goto yyoverflowlab;
745 yystacksize *= 2;
746 if (yystacksize > YYMAXDEPTH)
747 yystacksize = YYMAXDEPTH;
748
749 {
750 short *yyss1 = yyss;
751 union yyalloc *yyptr =
752 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
753 if (! yyptr)
754 goto yyoverflowlab;
755 YYSTACK_RELOCATE (yyss);
756 YYSTACK_RELOCATE (yyvs);
757# if YYLSP_NEEDED
758 YYSTACK_RELOCATE (yyls);
759# endif
760# undef YYSTACK_RELOCATE
761 if (yyss1 != yyssa)
762 YYSTACK_FREE (yyss1);
763 }
764# endif
765#endif /* no yyoverflow */
766
767 yyssp = yyss + yysize - 1;
768 yyvsp = yyvs + yysize - 1;
769#if YYLSP_NEEDED
770 yylsp = yyls + yysize - 1;
771#endif
772
773 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
774 (unsigned long int) yystacksize));
775
776 if (yyssp >= yyss + yystacksize - 1)
777 YYABORT;
778 }
779
780 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
781
782 goto yybackup;
783
784
785/*-----------.
786| yybackup. |
787`-----------*/
788yybackup:
789
790/* Do appropriate processing given the current state. */
791/* Read a lookahead token if we need one and don't already have one. */
792/* yyresume: */
793
794 /* First try to decide what to do without reference to lookahead token. */
795
796 yyn = yypact[yystate];
797 if (yyn == YYFLAG)
798 goto yydefault;
799
800 /* Not known => get a lookahead token if don't already have one. */
801
802 /* yychar is either YYEMPTY or YYEOF
803 or a valid token in external form. */
804
805 if (yychar == YYEMPTY)
806 {
807 YYDPRINTF ((stderr, "Reading a token: "));
808 yychar = YYLEX;
809 }
810
811 /* Convert token to internal form (in yychar1) for indexing tables with */
812
813 if (yychar <= 0) /* This means end of input. */
814 {
815 yychar1 = 0;
816 yychar = YYEOF; /* Don't call YYLEX any more */
817
818 YYDPRINTF ((stderr, "Now at end of input.\n"));
819 }
820 else
821 {
822 yychar1 = YYTRANSLATE (yychar);
823
824#if YYDEBUG
825 /* We have to keep this `#if YYDEBUG', since we use variables
826 which are defined only if `YYDEBUG' is set. */
827 if (yydebug)
828 {
829 YYFPRINTF (stderr, "Next token is %d (%s",
830 yychar, yytname[yychar1]);
831 /* Give the individual parser a way to print the precise
832 meaning of a token, for further debugging info. */
833# ifdef YYPRINT
834 YYPRINT (stderr, yychar, yylval);
835# endif
836 YYFPRINTF (stderr, ")\n");
837 }
838#endif
839 }
840
841 yyn += yychar1;
842 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
843 goto yydefault;
844
845 yyn = yytable[yyn];
846
847 /* yyn is what to do for this token type in this state.
848 Negative => reduce, -yyn is rule number.
849 Positive => shift, yyn is new state.
850 New state is final state => don't bother to shift,
851 just return success.
852 0, or most negative number => error. */
853
854 if (yyn < 0)
855 {
856 if (yyn == YYFLAG)
857 goto yyerrlab;
858 yyn = -yyn;
859 goto yyreduce;
860 }
861 else if (yyn == 0)
862 goto yyerrlab;
863
864 if (yyn == YYFINAL)
865 YYACCEPT;
866
867 /* Shift the lookahead token. */
868 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
869 yychar, yytname[yychar1]));
870
871 /* Discard the token being shifted unless it is eof. */
872 if (yychar != YYEOF)
873 yychar = YYEMPTY;
874
875 *++yyvsp = yylval;
876#if YYLSP_NEEDED
877 *++yylsp = yylloc;
878#endif
879
880 /* Count tokens shifted since error; after three, turn off error
881 status. */
882 if (yyerrstatus)
883 yyerrstatus--;
884
885 yystate = yyn;
886 goto yynewstate;
887
888
889/*-----------------------------------------------------------.
890| yydefault -- do the default action for the current state. |
891`-----------------------------------------------------------*/
892yydefault:
893 yyn = yydefact[yystate];
894 if (yyn == 0)
895 goto yyerrlab;
896 goto yyreduce;
897
898
899/*-----------------------------.
900| yyreduce -- Do a reduction. |
901`-----------------------------*/
902yyreduce:
903 /* yyn is the number of a rule to reduce with. */
904 yylen = yyr2[yyn];
905
906 /* If YYLEN is nonzero, implement the default value of the action:
907 `$$ = $1'.
908
909 Otherwise, the following line sets YYVAL to the semantic value of
910 the lookahead token. This behavior is undocumented and Bison
911 users should not rely upon it. Assigning to YYVAL
912 unconditionally makes the parser a bit smaller, and it avoids a
913 GCC warning that YYVAL may be used uninitialized. */
914 yyval = yyvsp[1-yylen];
915
916#if YYLSP_NEEDED
917 /* Similarly for the default location. Let the user run additional
918 commands if for instance locations are ranges. */
919 yyloc = yylsp[1-yylen];
920 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
921#endif
922
923#if YYDEBUG
924 /* We have to keep this `#if YYDEBUG', since we use variables which
925 are defined only if `YYDEBUG' is set. */
926 if (yydebug)
927 {
928 int yyi;
929
930 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
931 yyn, yyrline[yyn]);
932
933 /* Print the symbols being reduced, and their result. */
934 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
935 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
936 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
937 }
938#endif
939
940 switch (yyn) {
941
942case 2:
943#line 64 "icalssyacc.y"
944{
945 icalparser_clear_flex_input();
946 yyclearin;
947 }
948 break;
949case 3:
950#line 71 "icalssyacc.y"
951{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
952 break;
953case 4:
954#line 72 "icalssyacc.y"
955{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
956 break;
957case 5:
958#line 77 "icalssyacc.y"
959{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);}
960 break;
961case 6:
962#line 78 "icalssyacc.y"
963{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);}
964 break;
965case 8:
966#line 83 "icalssyacc.y"
967{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); }
968 break;
969case 9:
970#line 85 "icalssyacc.y"
971{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); }
972 break;
973case 10:
974#line 86 "icalssyacc.y"
975{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); }
976 break;
977case 11:
978#line 87 "icalssyacc.y"
979{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); }
980 break;
981case 12:
982#line 88 "icalssyacc.y"
983{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); }
984 break;
985case 13:
986#line 89 "icalssyacc.y"
987{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); }
988 break;
989case 14:
990#line 93 "icalssyacc.y"
991{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
992 break;
993case 15:
994#line 94 "icalssyacc.y"
995{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
996 break;
997case 16:
998#line 95 "icalssyacc.y"
999{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
1000 break;
1001}
1002
1003#line 705 "/usr/share/bison/bison.simple"
1004
1005
1006 yyvsp -= yylen;
1007 yyssp -= yylen;
1008#if YYLSP_NEEDED
1009 yylsp -= yylen;
1010#endif
1011
1012#if YYDEBUG
1013 if (yydebug)
1014 {
1015 short *yyssp1 = yyss - 1;
1016 YYFPRINTF (stderr, "state stack now");
1017 while (yyssp1 != yyssp)
1018 YYFPRINTF (stderr, " %d", *++yyssp1);
1019 YYFPRINTF (stderr, "\n");
1020 }
1021#endif
1022
1023 *++yyvsp = yyval;
1024#if YYLSP_NEEDED
1025 *++yylsp = yyloc;
1026#endif
1027
1028 /* Now `shift' the result of the reduction. Determine what state
1029 that goes to, based on the state we popped back to and the rule
1030 number reduced by. */
1031
1032 yyn = yyr1[yyn];
1033
1034 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1035 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1036 yystate = yytable[yystate];
1037 else
1038 yystate = yydefgoto[yyn - YYNTBASE];
1039
1040 goto yynewstate;
1041
1042
1043/*------------------------------------.
1044| yyerrlab -- here on detecting error |
1045`------------------------------------*/
1046yyerrlab:
1047 /* If not already recovering from an error, report this error. */
1048 if (!yyerrstatus)
1049 {
1050 ++yynerrs;
1051
1052#ifdef YYERROR_VERBOSE
1053 yyn = yypact[yystate];
1054
1055 if (yyn > YYFLAG && yyn < YYLAST)
1056 {
1057 YYSIZE_T yysize = 0;
1058 char *yymsg;
1059 int yyx, yycount;
1060
1061 yycount = 0;
1062 /* Start YYX at -YYN if negative to avoid negative indexes in
1063 YYCHECK. */
1064 for (yyx = yyn < 0 ? -yyn : 0;
1065 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1066 if (yycheck[yyx + yyn] == yyx)
1067 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1068 yysize += yystrlen ("parse error, unexpected ") + 1;
1069 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1070 yymsg = (char *) YYSTACK_ALLOC (yysize);
1071 if (yymsg != 0)
1072 {
1073 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1074 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1075
1076 if (yycount < 5)
1077 {
1078 yycount = 0;
1079 for (yyx = yyn < 0 ? -yyn : 0;
1080 yyx < (int) (sizeof (yytname) / sizeof (char *));
1081 yyx++)
1082 if (yycheck[yyx + yyn] == yyx)
1083 {
1084 const char *yyq = ! yycount ? ", expecting " : " or ";
1085 yyp = yystpcpy (yyp, yyq);
1086 yyp = yystpcpy (yyp, yytname[yyx]);
1087 yycount++;
1088 }
1089 }
1090 yyerror (yymsg);
1091 YYSTACK_FREE (yymsg);
1092 }
1093 else
1094 yyerror ("parse error; also virtual memory exhausted");
1095 }
1096 else
1097#endif /* defined (YYERROR_VERBOSE) */
1098 yyerror ("parse error");
1099 }
1100 goto yyerrlab1;
1101
1102
1103/*--------------------------------------------------.
1104| yyerrlab1 -- error raised explicitly by an action |
1105`--------------------------------------------------*/
1106yyerrlab1:
1107 if (yyerrstatus == 3)
1108 {
1109 /* If just tried and failed to reuse lookahead token after an
1110 error, discard it. */
1111
1112 /* return failure if at end of input */
1113 if (yychar == YYEOF)
1114 YYABORT;
1115 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1116 yychar, yytname[yychar1]));
1117 yychar = YYEMPTY;
1118 }
1119
1120 /* Else will try to reuse lookahead token after shifting the error
1121 token. */
1122
1123 yyerrstatus = 3; /* Each real token shifted decrements this */
1124
1125 goto yyerrhandle;
1126
1127
1128/*-------------------------------------------------------------------.
1129| yyerrdefault -- current state does not do anything special for the |
1130| error token. |
1131`-------------------------------------------------------------------*/
1132yyerrdefault:
1133#if 0
1134 /* This is wrong; only states that explicitly want error tokens
1135 should shift them. */
1136
1137 /* If its default is to accept any token, ok. Otherwise pop it. */
1138 yyn = yydefact[yystate];
1139 if (yyn)
1140 goto yydefault;
1141#endif
1142
1143
1144/*---------------------------------------------------------------.
1145| yyerrpop -- pop the current state because it cannot handle the |
1146| error token |
1147`---------------------------------------------------------------*/
1148yyerrpop:
1149 if (yyssp == yyss)
1150 YYABORT;
1151 yyvsp--;
1152 yystate = *--yyssp;
1153#if YYLSP_NEEDED
1154 yylsp--;
1155#endif
1156
1157#if YYDEBUG
1158 if (yydebug)
1159 {
1160 short *yyssp1 = yyss - 1;
1161 YYFPRINTF (stderr, "Error: state stack now");
1162 while (yyssp1 != yyssp)
1163 YYFPRINTF (stderr, " %d", *++yyssp1);
1164 YYFPRINTF (stderr, "\n");
1165 }
1166#endif
1167
1168/*--------------.
1169| yyerrhandle. |
1170`--------------*/
1171yyerrhandle:
1172 yyn = yypact[yystate];
1173 if (yyn == YYFLAG)
1174 goto yyerrdefault;
1175
1176 yyn += YYTERROR;
1177 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1178 goto yyerrdefault;
1179
1180 yyn = yytable[yyn];
1181 if (yyn < 0)
1182 {
1183 if (yyn == YYFLAG)
1184 goto yyerrpop;
1185 yyn = -yyn;
1186 goto yyreduce;
1187 }
1188 else if (yyn == 0)
1189 goto yyerrpop;
1190
1191 if (yyn == YYFINAL)
1192 YYACCEPT;
1193
1194 YYDPRINTF ((stderr, "Shifting error token, "));
1195
1196 *++yyvsp = yylval;
1197#if YYLSP_NEEDED
1198 *++yylsp = yylloc;
1199#endif
1200
1201 yystate = yyn;
1202 goto yynewstate;
1203
1204
1205/*-------------------------------------.
1206| yyacceptlab -- YYACCEPT comes here. |
1207`-------------------------------------*/
1208yyacceptlab:
1209 yyresult = 0;
1210 goto yyreturn;
1211
1212/*-----------------------------------.
1213| yyabortlab -- YYABORT comes here. |
1214`-----------------------------------*/
1215yyabortlab:
1216 yyresult = 1;
1217 goto yyreturn;
1218
1219/*---------------------------------------------.
1220| yyoverflowab -- parser overflow comes here. |
1221`---------------------------------------------*/
1222yyoverflowlab:
1223 yyerror ("parser stack overflow");
1224 yyresult = 2;
1225 /* Fall through. */
1226
1227yyreturn:
1228#ifndef yyoverflow
1229 if (yyss != yyssa)
1230 YYSTACK_FREE (yyss);
1231#endif
1232 return yyresult;
1233}
1234#line 99 "icalssyacc.y"
1235
1236
1237void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1238 icalgaugecompare compare , char* value_str)
1239{
1240
1241 struct icalgauge_where *where;
1242 char *compstr, *propstr, *c, *s,*l;
1243
1244 if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
1245 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1246 return;
1247 }
1248
1249 memset(where,0,sizeof(struct icalgauge_where));
1250 where->logic = ICALGAUGELOGIC_NONE;
1251 where->compare = ICALGAUGECOMPARE_NONE;
1252 where->comp = ICAL_NO_COMPONENT;
1253 where->prop = ICAL_NO_PROPERTY;
1254
1255 /* remove enclosing quotes */
1256 s = value_str;
1257 if(*s == '\''){
1258 s++;
1259 }
1260 l = s+strlen(s)-1;
1261 if(*l == '\''){
1262 *l=0;
1263 }
1264
1265 where->value = strdup(s);
1266
1267 /* Is there a period in str1 ? If so, the string specified both a
1268 component and a property*/
1269 if( (c = strrchr(str1,'.')) != 0){
1270 compstr = str1;
1271 propstr = c+1;
1272 *c = '\0';
1273 } else {
1274 compstr = 0;
1275 propstr = str1;
1276 }
1277
1278
1279 /* Handle the case where a component was specified */
1280 if(compstr != 0){
1281 where->comp = icalenum_string_to_component_kind(compstr);
1282 } else {
1283 where->comp = ICAL_NO_COMPONENT;
1284 }
1285
1286 where->prop = icalenum_string_to_property_kind(propstr);
1287
1288 where->compare = compare;
1289
1290 if(where->value == 0){
1291 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1292 free(where->value);
1293 return;
1294 }
1295
1296 pvl_push(impl->where,where);
1297}
1298
1299void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1300{
1301 pvl_elem e = pvl_tail(impl->where);
1302 struct icalgauge_where *where = pvl_data(e);
1303
1304 where->logic = l;
1305
1306}
1307
1308
1309
1310void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1311{
1312 char *c, *compstr, *propstr;
1313 struct icalgauge_where *where;
1314
1315 /* Uses only the prop and comp fields of the where structure */
1316 if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
1317 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1318 return;
1319 }
1320
1321 memset(where,0,sizeof(struct icalgauge_where));
1322 where->logic = ICALGAUGELOGIC_NONE;
1323 where->compare = ICALGAUGECOMPARE_NONE;
1324 where->comp = ICAL_NO_COMPONENT;
1325 where->prop = ICAL_NO_PROPERTY;
1326
1327 /* Is there a period in str1 ? If so, the string specified both a
1328 component and a property*/
1329 if( (c = strrchr(str1,'.')) != 0){
1330 compstr = str1;
1331 propstr = c+1;
1332 *c = '\0';
1333 } else {
1334 compstr = 0;
1335 propstr = str1;
1336 }
1337
1338
1339 /* Handle the case where a component was specified */
1340 if(compstr != 0){
1341 where->comp = icalenum_string_to_component_kind(compstr);
1342 } else {
1343 where->comp = ICAL_NO_COMPONENT;
1344 }
1345
1346
1347 /* If the property was '*', then accept all properties */
1348 if(strcmp("*",propstr) == 0) {
1349 where->prop = ICAL_ANY_PROPERTY;
1350 } else {
1351 where->prop = icalenum_string_to_property_kind(propstr);
1352 }
1353
1354
1355 if(where->prop == ICAL_NO_PROPERTY){
1356 icalgauge_free(where);
1357 icalerror_set_errno(ICAL_BADARG_ERROR);
1358 return;
1359 }
1360
1361 pvl_push(impl->select,where);
1362}
1363
1364void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1365{
1366 icalcomponent_kind ckind;
1367
1368 ckind = icalenum_string_to_component_kind(str1);
1369
1370 if(ckind == ICAL_NO_COMPONENT){
1371 assert(0);
1372 }
1373
1374 pvl_push(impl->from,(void*)ckind);
1375
1376}
1377
1378
1379void sserror(char *s){
1380 fprintf(stderr,"Parse error \'%s\'\n", s);
1381}
diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h
new file mode 100644
index 0000000..7d42f3c
--- a/dev/null
+++ b/libical/src/libicalss/icalssyacc.h
@@ -0,0 +1,31 @@
1#ifndef BISON_ICALSSYACC_H
2# define BISON_ICALSSYACC_H
3
4#ifndef YYSTYPE
5typedef union {
6 char* v_string;
7} yystype;
8# define YYSTYPE yystype
9# define YYSTYPE_IS_TRIVIAL 1
10#endif
11 # define STRING257
12 # define SELECT258
13 # define FROM259
14 # define WHERE260
15 # define COMMA261
16 # define QUOTE262
17 # define EQUALS263
18 # define NOTEQUALS264
19 # define LESS265
20 # define GREATER266
21 # define LESSEQUALS267
22 # define GREATEREQUALS268
23 # define AND269
24 # define OR270
25 # define EOL271
26 # define END272
27
28
29extern YYSTYPE sslval;
30
31#endif /* not BISON_ICALSSYACC_H */
diff --git a/libical/src/libicalss/icalssyacc.y b/libical/src/libicalss/icalssyacc.y
new file mode 100644
index 0000000..6482b58
--- a/dev/null
+++ b/libical/src/libicalss/icalssyacc.y
@@ -0,0 +1,245 @@
1%{
2/* -*- Mode: C -*-
3 ======================================================================
4 FILE: icalssyacc.y
5 CREATOR: eric 08 Aug 2000
6
7 DESCRIPTION:
8
9 $Id$
10 $Locker$
11
12(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of either:
16
17 The LGPL as published by the Free Software Foundation, version
18 2.1, available at: http://www.fsf.org/copyleft/lesser.html
19
20 Or:
21
22 The Mozilla Public License Version 1.0. You may obtain a copy of
23 the License at http://www.mozilla.org/MPL/
24
25 The Original Code is eric. The Initial Developer of the Original
26 Code is Eric Busboom
27
28 ======================================================================*/
29
30#include <stdlib.h>
31#include <string.h> /* for strdup() */
32#include <limits.h> /* for SHRT_MAX*/
33#include "ical.h"
34#include "pvl.h"
35#include "icalgauge.h"
36#include "icalgaugeimpl.h"
37
38
39extern struct icalgauge_impl *icalss_yy_gauge;
40
41void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
42 icalgaugecompare compare , char* value);
43void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
44void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
45void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
46void sserror(char *s); /* Don't know why I need this.... */
47
48
49
50%}
51
52%union {
53 char* v_string;
54}
55
56
57%token <v_string> STRING
58%token SELECT FROM WHERE COMMA QUOTE EQUALS NOTEQUALS LESS GREATER LESSEQUALS
59%token GREATEREQUALS AND OR EOL END
60
61%%
62
63query_min: SELECT select_list FROM from_list WHERE where_list
64 | error {
65 icalparser_clear_flex_input();
66 yyclearin;
67 }
68 ;
69
70select_list:
71 STRING {ssyacc_add_select(icalss_yy_gauge,$1);}
72 | select_list COMMA STRING {ssyacc_add_select(icalss_yy_gauge,$3);}
73 ;
74
75
76from_list:
77 STRING {ssyacc_add_from(icalss_yy_gauge,$1);}
78 | from_list COMMA STRING {ssyacc_add_from(icalss_yy_gauge,$3);}
79 ;
80
81where_clause:
82 /* Empty */
83 | STRING EQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_EQUAL,$3); }
84
85 | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_NOTEQUAL,$3); }
86 | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESS,$3); }
87 | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATER,$3); }
88 | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESSEQUAL,$3); }
89 | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATEREQUAL,$3); }
90 ;
91
92where_list:
93 where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
94 | where_list AND where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
95 | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
96 ;
97
98
99%%
100
101void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
102 icalgaugecompare compare , char* value_str)
103{
104
105 struct icalgauge_where *where;
106 char *compstr, *propstr, *c, *s,*l;
107
108 if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
109 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
110 return;
111 }
112
113 memset(where,0,sizeof(struct icalgauge_where));
114 where->logic = ICALGAUGELOGIC_NONE;
115 where->compare = ICALGAUGECOMPARE_NONE;
116 where->comp = ICAL_NO_COMPONENT;
117 where->prop = ICAL_NO_PROPERTY;
118
119 /* remove enclosing quotes */
120 s = value_str;
121 if(*s == '\''){
122 s++;
123 }
124 l = s+strlen(s)-1;
125 if(*l == '\''){
126 *l=0;
127 }
128
129 where->value = strdup(s);
130
131 /* Is there a period in str1 ? If so, the string specified both a
132 component and a property*/
133 if( (c = strrchr(str1,'.')) != 0){
134 compstr = str1;
135 propstr = c+1;
136 *c = '\0';
137 } else {
138 compstr = 0;
139 propstr = str1;
140 }
141
142
143 /* Handle the case where a component was specified */
144 if(compstr != 0){
145 where->comp = icalenum_string_to_component_kind(compstr);
146 } else {
147 where->comp = ICAL_NO_COMPONENT;
148 }
149
150 where->prop = icalenum_string_to_property_kind(propstr);
151
152 where->compare = compare;
153
154 if(where->value == 0){
155 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
156 free(where->value);
157 return;
158 }
159
160 pvl_push(impl->where,where);
161}
162
163void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
164{
165 pvl_elem e = pvl_tail(impl->where);
166 struct icalgauge_where *where = pvl_data(e);
167
168 where->logic = l;
169
170}
171
172
173
174void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
175{
176 char *c, *compstr, *propstr;
177 struct icalgauge_where *where;
178
179 /* Uses only the prop and comp fields of the where structure */
180 if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
181 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
182 return;
183 }
184
185 memset(where,0,sizeof(struct icalgauge_where));
186 where->logic = ICALGAUGELOGIC_NONE;
187 where->compare = ICALGAUGECOMPARE_NONE;
188 where->comp = ICAL_NO_COMPONENT;
189 where->prop = ICAL_NO_PROPERTY;
190
191 /* Is there a period in str1 ? If so, the string specified both a
192 component and a property*/
193 if( (c = strrchr(str1,'.')) != 0){
194 compstr = str1;
195 propstr = c+1;
196 *c = '\0';
197 } else {
198 compstr = 0;
199 propstr = str1;
200 }
201
202
203 /* Handle the case where a component was specified */
204 if(compstr != 0){
205 where->comp = icalenum_string_to_component_kind(compstr);
206 } else {
207 where->comp = ICAL_NO_COMPONENT;
208 }
209
210
211 /* If the property was '*', then accept all properties */
212 if(strcmp("*",propstr) == 0) {
213 where->prop = ICAL_ANY_PROPERTY;
214 } else {
215 where->prop = icalenum_string_to_property_kind(propstr);
216 }
217
218
219 if(where->prop == ICAL_NO_PROPERTY){
220 icalgauge_free(where);
221 icalerror_set_errno(ICAL_BADARG_ERROR);
222 return;
223 }
224
225 pvl_push(impl->select,where);
226}
227
228void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
229{
230 icalcomponent_kind ckind;
231
232 ckind = icalenum_string_to_component_kind(str1);
233
234 if(ckind == ICAL_NO_COMPONENT){
235 assert(0);
236 }
237
238 pvl_push(impl->from,(void*)ckind);
239
240}
241
242
243void sserror(char *s){
244 fprintf(stderr,"Parse error \'%s\'\n", s);
245}
diff --git a/libical/src/libicalss/libicalss.pro b/libical/src/libicalss/libicalss.pro
new file mode 100644
index 0000000..a5cc80c
--- a/dev/null
+++ b/libical/src/libicalss/libicalss.pro
@@ -0,0 +1,43 @@
1include(../../../variables.pri)
2
3 TEMPLATE= lib
4
5TARGET = icalss
6DESTDIR = ../../lib
7 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
41INCLUDEPATH += ../libical
42
43DEFINES += HAVE_CONFIG_H
diff --git a/libical/src/libicalss/libicalssE.pro b/libical/src/libicalss/libicalssE.pro
new file mode 100644
index 0000000..57d60bd
--- a/dev/null
+++ b/libical/src/libicalss/libicalssE.pro
@@ -0,0 +1,45 @@
1 TEMPLATE= lib
2 CONFIG += warn_on staticlib
3INCLUDEPATH += ../libical
4INCLUDEPATH += .
5DEFINES += HAVE_CONFIG_H
6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=../../lib/$(PLATFORM)
9TARGET = icalss
10
11INTERFACES = \
12
13HEADERS = \
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
32SOURCES = \
33 icalclassify.c \
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