From 1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 11 Dec 2000 22:07:10 +0000 Subject: Initial revision svn path=/trunk/; revision=6915 --- libical/src/libicalss/icalclassify.c | 701 +++++++++++++ libical/src/libicalss/icalclassify.h | 73 ++ libical/src/libicalss/icalcstp.c | 376 +++++++ libical/src/libicalss/icaldirsetimpl.h | 47 + libical/src/libicalss/icalgaugeimpl.h | 39 + libical/src/libicalss/icalmessage.c | 376 +++++++ libical/src/libicalss/icalmessage.h | 72 ++ libical/src/libicalss/icalspanlist.c | 309 ++++++ libical/src/libicalss/icalspanlist.h | 54 + libical/src/libicalss/icalss.h | 763 ++++++++++++++ libical/src/libicalss/icalsslexer.c | 1702 ++++++++++++++++++++++++++++++++ libical/src/libicalss/icalsslexer.l | 111 +++ libical/src/libicalss/icalssutil.c | 29 + libical/src/libicalss/icalssutil.h | 27 + libical/src/libicalss/icalssyacc.c | 1154 ++++++++++++++++++++++ libical/src/libicalss/icalssyacc.h | 21 + libical/src/libicalss/icalssyacc.y | 215 ++++ 17 files changed, 6069 insertions(+) create mode 100644 libical/src/libicalss/icalclassify.c create mode 100644 libical/src/libicalss/icalclassify.h create mode 100644 libical/src/libicalss/icalcstp.c create mode 100644 libical/src/libicalss/icaldirsetimpl.h create mode 100644 libical/src/libicalss/icalgaugeimpl.h create mode 100644 libical/src/libicalss/icalmessage.c create mode 100644 libical/src/libicalss/icalmessage.h create mode 100644 libical/src/libicalss/icalspanlist.c create mode 100644 libical/src/libicalss/icalspanlist.h create mode 100644 libical/src/libicalss/icalss.h create mode 100644 libical/src/libicalss/icalsslexer.c create mode 100644 libical/src/libicalss/icalsslexer.l create mode 100644 libical/src/libicalss/icalssutil.c create mode 100644 libical/src/libicalss/icalssutil.h create mode 100644 libical/src/libicalss/icalssyacc.c create mode 100644 libical/src/libicalss/icalssyacc.h create mode 100644 libical/src/libicalss/icalssyacc.y (limited to 'libical/src/libicalss') diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c new file mode 100644 index 0000000000..e0ee710544 --- /dev/null +++ b/libical/src/libicalss/icalclassify.c @@ -0,0 +1,701 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalclassify.c + CREATOR: ebusboom 23 aug 2000 + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + ======================================================================*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ical.h" +#include "icalclassify.h" +#include "icalmemory.h" +#include /* For tolower() */ +#include /* for index() */ +#include /* for malloc and free */ + + + +struct icalclassify_parts { + icalcomponent *c; + icalproperty_method method; + char* organizer; + icalparameter_partstat reply_partstat; + char* reply_attendee; + char* uid; + int sequence; + struct icaltimetype dtstamp; + struct icaltimetype recurrence_id; +}; + + +char* icalclassify_lowercase(const char* str) +{ + char* p = 0; + char* new = icalmemory_strdup(str); + + if(str ==0){ + return 0; + } + + for(p = new; *p!=0; p++){ + *p = tolower(*p); + } + + return new; +} + +/* Return a set of components that intersect in time with comp. For +component X and Y to intersect: + X.DTSTART < Y.DTEND && X.DTEND > Y.DTSTART +*/ + + +icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp) +{ + icalcomponent *return_set; + icalcomponent *c; + struct icaltime_span span,compspan; + + icalerror_clear_errno(); + compspan = icalcomponent_get_span(comp); + + if(icalerrno != ICAL_NO_ERROR){ + return 0; + } + + + return_set = icalcomponent_new(ICAL_XROOT_COMPONENT); + + for(c = icalset_get_first_component(set); + c != 0; + c = icalset_get_next_component(set)){ + + icalerror_clear_errno(); + + span = icalcomponent_get_span(c); + + if(icalerrno != ICAL_NO_ERROR){ + continue; + } + + if (compspan.start < span.end && + compspan.end > span.start){ + + icalcomponent *clone = icalcomponent_new_clone(c); + + icalcomponent_add_component(return_set,clone); + } + } + + if(icalcomponent_count_components(return_set,ICAL_ANY_COMPONENT) !=0){ + return return_set; + } else { + icalcomponent_free(return_set); + return 0; + } +} + + + +icalparameter_partstat icalclassify_find_attendee(icalcomponent *c, + const char* attendee) +{ + icalproperty *p; + char* lattendee = icalclassify_lowercase(attendee); + char* upn = index(lattendee,':'); + icalcomponent *inner = icalcomponent_get_first_real_component(c); + + for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) + { + const char* this_attendee + = icalclassify_lowercase(icalproperty_get_attendee(p)); + char* this_upn = index(this_attendee,':'); + + if(strcmp(this_upn,upn)==0){ + + icalparameter *param = icalproperty_get_first_parameter(p, + ICAL_PARTSTAT_PARAMETER); + if (param != 0){ + free(lattendee); + free((void*)this_attendee); + return icalparameter_get_partstat(param); + } + + } + + } + + free(lattendee); + return ICAL_PARTSTAT_NONE; + +} + +void icalssutil_free_parts(struct icalclassify_parts *parts) +{ + if(parts == 0){ + return; + } + + if(parts->organizer != 0){ + free(parts->organizer); + } + + if(parts->uid != 0){ + free(parts->uid); + } + + if(parts->reply_attendee){ + free(parts->reply_attendee); + } +} + +void icalssutil_get_parts(icalcomponent* c, + struct icalclassify_parts* parts) +{ + icalproperty *p; + icalcomponent *inner; + + memset(parts,0,sizeof(struct icalclassify_parts)); + + parts->method = ICAL_METHOD_NONE; + parts->sequence = 0; + parts->reply_partstat = ICAL_PARTSTAT_NONE; + + if(c == 0){ + return; + } + + parts->c = c; + + p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); + if(p!=0){ + parts->method = icalproperty_get_method(p); + } + + inner = icalcomponent_get_first_real_component(c); + + p = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY); + if(p!=0){ + parts->organizer = strdup(icalproperty_get_organizer(p)); + } + + p = icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY); + if(p!=0){ + parts->sequence = icalproperty_get_sequence(p); + } + + p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); + if(p!=0){ + parts->uid = strdup(icalproperty_get_uid(p)); + } + + p = icalcomponent_get_first_property(inner,ICAL_RECURRENCEID_PROPERTY); + if(p!=0){ + parts->recurrence_id = icalproperty_get_recurrenceid(p); + } + + p = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); + if(p!=0){ + parts->dtstamp = icalproperty_get_dtstamp(p); + } + + if(parts->method==ICAL_METHOD_REPLY){ + icalparameter *param; + p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY); + + if(p!=0){ + + param = icalproperty_get_first_parameter(p,ICAL_PARTSTAT_PARAMETER); + + if(param != 0){ + parts->reply_partstat = + icalparameter_get_partstat(param); + } + + parts->reply_attendee = strdup(icalproperty_get_attendee(p)); + } + + } + + +} + + +int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b) +{ + icalproperty *p1,*p2; + icalcomponent *i1,*i2; + int i; + + icalproperty_kind kind_array[] = { + ICAL_DTSTART_PROPERTY, + ICAL_DTEND_PROPERTY, + ICAL_DURATION_PROPERTY, + ICAL_DUE_PROPERTY, + ICAL_RRULE_PROPERTY, + ICAL_RDATE_PROPERTY, + ICAL_EXRULE_PROPERTY, + ICAL_EXDATE_PROPERTY, + ICAL_NO_PROPERTY + }; + + i1 = icalcomponent_get_first_real_component(a); + i2 = icalcomponent_get_first_real_component(b); + + for(i =0; kind_array[i] != ICAL_NO_PROPERTY; i++){ + p1 = icalcomponent_get_first_property(i1,kind_array[i]); + p2 = icalcomponent_get_first_property(i2,kind_array[i]); + + if( (p1!=0)^(p1!=0) ){ + /* Return true if the property exists in one component and not + the other */ + return 1; + } + + if(p1 && strcmp(icalproperty_as_ical_string(p1), + icalproperty_as_ical_string(p2)) != 0){ + return 1; + } + } + + return 0; + +} + +#define icalclassify_pre \ + int rtrn =0; + +#define icalclassify_post \ + return rtrn; + + +int icalclassify_publish_new(struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre; + + if(comp->method == ICAL_METHOD_PUBLISH && + match == 0){ + rtrn = 1; + } + + icalclassify_post; + +} + +int icalclassify_publish_update(struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre; + + if(comp->method == ICAL_METHOD_PUBLISH && + match !=0 ){ + rtrn = 1; + } + + icalclassify_post; + +} + +int icalclassify_publish_freebusy(struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre; + + if(comp->method == ICAL_METHOD_PUBLISH && + match == 0){ + rtrn = 1; + } + + icalclassify_post; + +} + + +int icalclassify_request_new(struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + /* Method is REQUEST, and there is no match */ + + icalclassify_pre + + if(match->c==0 && comp->method == ICAL_METHOD_REQUEST){ + rtrn = 1; + } + + icalclassify_post + +} + +int icalclassify_request_update( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + /* REQUEST method, Higher SEQUENCE than match, and all + time-related properties are unchanged */ + + icalclassify_pre + + if (match != 0 && + comp->sequence >= match->sequence && + !icalssutil_is_rescheduled(comp->c,match->c)){ + rtrn = 1; + } + + icalclassify_post + +} + +int icalclassify_request_reschedule( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + /* REQUEST method, Higher SEQUENCE than match, and one or more + time-related properties are changed */ + icalclassify_pre + + if (match->c != 0 && + comp->sequence > match->sequence && + icalssutil_is_rescheduled(comp->c,match->c)){ + rtrn = 1; + } + + icalclassify_post + +} + +int icalclassify_request_delegate( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + + if (match->c != 0 && + comp->sequence > match->sequence && + icalssutil_is_rescheduled(comp->c,match->c)){ + rtrn = 1; + } + + icalclassify_post + +} + +int icalclassify_request_new_organizer( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + /* Organizer has changed between match and component */ + icalclassify_pre + + icalclassify_post + +} + +int icalclassify_request_status( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + icalclassify_post +} + +int icalclassify_request_forward( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + icalclassify_post +} + +int icalclassify_request_freebusy( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + icalclassify_post +} + +int icalclassify_reply_accept( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalparameter_partstat partstat; + icalclassify_pre; + + partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); + + if(partstat != ICAL_PARTSTAT_NONE && + comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){ + rtrn = 1; + } + + icalclassify_post +} +int icalclassify_reply_decline( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalparameter_partstat partstat; + icalclassify_pre; + + + partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); + + if(partstat != ICAL_PARTSTAT_NONE && + comp->reply_partstat == ICAL_PARTSTAT_DECLINED){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_reply_crasher_accept( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalparameter_partstat partstat; + icalclassify_pre; + + + partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); + + if(partstat == ICAL_PARTSTAT_NONE && + comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_reply_crasher_decline( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalparameter_partstat partstat; + icalclassify_pre; + + + partstat = icalclassify_find_attendee(match->c,comp->reply_attendee); + + if(partstat == ICAL_PARTSTAT_NONE && + comp->reply_partstat == ICAL_PARTSTAT_DECLINED){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_add_instance( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_ADD){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_cancel_event( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_CANCEL){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_cancel_instance( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_CANCEL){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_cancel_all( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_CANCEL){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_refesh( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_REFRESH){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_counter( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + if(comp->method == ICAL_METHOD_COUNTER){ + rtrn = 1; + } + icalclassify_post +} +int icalclassify_delinecounter( + struct icalclassify_parts *comp, + struct icalclassify_parts *match, + const char* user) +{ + icalclassify_pre + + if(comp->method == ICAL_METHOD_DECLINECOUNTER){ + rtrn = 1; + } + + icalclassify_post +} + +struct icalclassify_map { + icalproperty_method method; + int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); + ical_class class; +} icalclassify_map[] = +{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS}, + {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS}, + {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS}, + {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS}, + + {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS}, + {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS}, + {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS}, + {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS}, + + {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS}, + + {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS}, + {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS}, + {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS}, + + {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS}, + {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS}, + {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS}, + {ICAL_METHOD_NONE,0,ICAL_NO_CLASS} +}; + + +ical_class icalclassify(icalcomponent* c,icalcomponent* match, + const char* user) +{ + icalcomponent *inner; + icalproperty *p; + icalproperty_method method; + ical_class class = ICAL_UNKNOWN_CLASS; + + int i; + + struct icalclassify_parts comp_parts; + struct icalclassify_parts match_parts; + + inner = icalcomponent_get_first_real_component(c); + + if (inner == 0) { + return ICAL_NO_CLASS; + } + + icalssutil_get_parts(c,&comp_parts); + icalssutil_get_parts(match,&match_parts); + + /* Determine if the incoming component is obsoleted by the match */ + if(match != 0 && ( + comp_parts.method == ICAL_METHOD_REQUEST + )){ + assert ( ! ((comp_parts.dtstamp.is_utc==1)^ + (match_parts.dtstamp.is_utc==1))); + + if( comp_parts.sequence0) + { + /* comp has a smaller sequence and a later DTSTAMP */ + return ICAL_MISSEQUENCED_CLASS; + } + + if( (comp_parts.sequence /* For send(), others */ +#include /* For send(), others. */ +#include /* For alarm */ +#include + +enum cstps_state { + NO_STATE, + CONNECTED, + AUTHENTICATED, + IDENTIFIED, + DISCONNECTED, + RECEIVE, +}; + +struct icalcstps_impl { + int timeout; + icalparser *parser; + enum cstps_state major_state; + struct icalcstps_stubs stubs; +}; + + +enum cstp_command { + ABORT, + AUTHENTICATE, + CAPABILITY, + CONTINUE, + EXPANDCALID, + IDENTIFY, + DISCONNECT, + SENDDATA, + STARTTLS, + EXPANDUPN, + COMMAND_COMPLETE, + UNKNOWN +}; + +struct command_map { + enum cstp_command command; + char *str; +} command_map[] = +{ + {ABORT,"ABORT"}, + {AUTHENTICATE,"AUTHENTICATE"}, + {CAPABILITY,"CAPABILITY"}, + {CONTINUE,"CONTINUE"}, + {EXPANDCALID,"EXPANDCALID"}, + {IDENTIFY,"IDENTIFY"}, + {DISCONNECT,"DISCONNECT"}, + {SENDDATA,"SENDDATA"}, + {STARTTLS,"STARTTLS"}, + {EXPANDUPN,"EXPANDUPN"}, + {UNKNOWN,"UNKNOWN"} +}; + + + +/* This state machine is a Mealy-type: actions occur on the + transitions, not in the states. + + Here is the state machine diagram from the CAP draft: + + + STARTTLS / + CAPABILITY + +-------+ + | | +---------------+ + | +-----------+ AUTHENTICATE | | + +-->| Connected |-------------->| Authenticated | + +-----------+ | | + | +---------------+ + | | + | | + | | + | | +-----+ STARTTLS / + | V | | CAPABILITY / + | +---------------+ | IDENTIFY + | | |<-+ + | | Identified |<----+ + | +--------| | | + | | +---------------+ | command + | | | | completes + V |DISCONNECT | | + +--------------+ | |SENDDATA | + | Disconnected |<--+ | | + +--------------+ | | ABORT + A | | + | V | + | DISCONNECT +---------------+ | + +--------------------| Receive |--+ + | |<--+ + +---------------+ | + | | CONTINUTE + +----+ + + In this implmenetation, the transition from CONNECTED to IDENTIFIED + is non-standard. The spec specifies that on the ATHENTICATE + command, the machine transitions from CONNECTED to AUTHENTICATED, + and then immediately goes to IDENTIFIED. This makes AUTHENTICATED a + useless state, so I removed it */ + +struct state_table { + enum cstps_state major_state; + enum cstp_command command; + void (*action)(); + enum cstps_state next_state; + +} server_state_table[] = +{ + { CONNECTED, CAPABILITY , 0, CONNECTED}, + { CONNECTED, AUTHENTICATE , 0, IDENTIFIED}, /* Non-standard */ + { IDENTIFIED, STARTTLS, 0, IDENTIFIED}, + { IDENTIFIED, IDENTIFY, 0, IDENTIFIED}, + { IDENTIFIED, CAPABILITY, 0, IDENTIFIED}, + { IDENTIFIED, SENDDATA, 0, RECEIVE}, + { IDENTIFIED, DISCONNECT, 0, DISCONNECTED}, + { DISCONNECTED, 0, 0, 0}, + { RECEIVE, DISCONNECT, 0, DISCONNECTED}, + { RECEIVE, CONTINUE, 0, RECEIVE}, + { RECEIVE, ABORT , 0, IDENTIFIED}, + { RECEIVE, COMMAND_COMPLETE , 0, IDENTIFIED} +}; + + +/**********************************************************************/ + + + +icalcstps* icalcstps_new(struct icalcstps_stubs stubs) +{ + struct icalcstps_impl* impl; + + if ( ( impl = (struct icalcstps_impl*) + malloc(sizeof(struct icalcstps_impl))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + impl->stubs = stubs; + impl->timeout = 10; + + return (icalcstps*)impl; + +} + +void icalcstps_free(icalcstps* cstp); + +int icalcstps_set_timeout(icalcstps* cstp, int sec) +{ + struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp; + + icalerror_check_arg_rz( (cstp!=0), "cstp"); + + impl->timeout = sec; + + return sec; +} + +typedef struct icalcstps_response { + icalrequeststatus code; + char caluid[1024]; + void* result; +} icalcstps_response; + +int line_is_command(char* line); +int line_is_response(char* line); +int line_is_endofdata(char* line); +int line_is_mime(char* line); + +icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data); +icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data); + +char* icalcstps_process_incoming(icalcstps* cstp, char* input) +{ + struct icalcstps_impl *impl = (struct icalcstps_impl *) cstp; + char *i; + char *cmd_or_resp; + char *data; + char *input_cpy; + icalerrorenum error; + + icalerror_check_arg_rz(cstp !=0,"cstp"); + icalerror_check_arg_rz(input !=0,"input"); + + if ((input_cpy = (char*)strdup(input)) == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + i = (char*)index(" ",input_cpy); + + cmd_or_resp = input_cpy; + + if (i != 0){ + *i = '\0'; + data = ++i; + } else { + data = 0; + } + + printf("cmd: %s\n",cmd_or_resp); + printf("data: %s\n",data); + + /* extract the command, look up in the state table, and dispatch + to the proper handler */ + + if(strcmp(cmd_or_resp,"ABORT") == 0){ + error = prep_abort(impl,data); + } else if(strcmp(cmd_or_resp,"AUTHENTICATE") == 0){ + error = prep_authenticate(impl,data); + } else if(strcmp(cmd_or_resp,"CAPABILITY") == 0){ + error = prep_capability(impl,data); + } else if(strcmp(cmd_or_resp,"CALIDEXPAND") == 0){ + error = prep_calidexpand(impl,data); + } else if(strcmp(cmd_or_resp,"CONTINUE") == 0){ + error = prep_continue(impl,data); + } else if(strcmp(cmd_or_resp,"DISCONNECT") == 0){ + error = prep_disconnect(impl,data); + } else if(strcmp(cmd_or_resp,"IDENTIFY") == 0){ + error = prep_identify(impl,data); + } else if(strcmp(cmd_or_resp,"STARTTLS") == 0){ + error = prep_starttls(impl,data); + } else if(strcmp(cmd_or_resp,"UPNEXPAND") == 0){ + error = prep_upnexpand(impl,data); + } else if(strcmp(cmd_or_resp,"SENDDATA") == 0){ + error = prep_sendata(impl,data); + } + + +} + + /* Read data until we get a end of data marker */ + + + +struct icalcstps_server_stubs { + icalerrorenum (*abort)(icalcstps* cstp); + icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism, + char* data); + icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid); + icalerrorenum (*capability)(icalcstps* cstp); + icalerrorenum (*cont)(icalcstps* cstp, unsigned int time); + icalerrorenum (*identify)(icalcstps* cstp, char* id); + icalerrorenum (*disconnect)(icalcstps* cstp); + icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time, + icalcomponent *comp); + icalerrorenum (*starttls)(icalcstps* cstp, char* command, + char* data); + icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn); + icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data); +}; + + +/********************** Client (Sender) Interfaces **************************/ + +struct icalcstpc_impl { + int timeout; + icalparser *parser; + enum cstp_command command; + char* next_output; + char* next_input; +}; + +icalcstps* icalcstpc_new(); + +void* icalcstpc_free(icalcstpc* cstpc); + +/* Get the next string to send to the server */ +char* icalcstpc_next_output(icalcstpc* cstp) +{ +} + +/* process the next string to send to the server */ +int icalcstpc_next_input(icalcstpc* cstp) +{ +} + +/* After icalcstpc_next_input returns a 0, there are responses + ready. use these to get them */ +icalcstpc_response icalcstpc_first_response(icalcstpc* cstp); +icalcstpc_response icalcstpc_next_response(icalcstpc* cstp); + +int icalcstpc_set_timeout(icalcstpc* cstp, int sec); + +icalerrorenum icalcstpc_abort(icalcstpc* cstp) +{ + struct icalcstpc_impl* impl = (struct icalcstpc_impl*)cstp; + + icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR); + + impl->next_output = "ABORT"; + +} + +icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism, + char* data, char* f(char*)) +{ +} + +icalerrorenum icalcstpc_capability(icalcstpc* cstp) +{ +} + +icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid) +{ +} + +icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time) +{ +} + +icalerrorenum icalcstpc_disconnect(icalcstpc* cstp) +{ +} + +icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id) +{ +} + +icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command, + char* data, char * f(char*)) +{ +} + +icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid) +{ +} + +icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time, + icalcomponent *comp) +{ +} + + + + diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h new file mode 100644 index 0000000000..0e69ba2f2e --- /dev/null +++ b/libical/src/libicalss/icaldirsetimpl.h @@ -0,0 +1,47 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: icaldirsetimpl.h + CREATOR: eric 21 Aug 2000 + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + + ======================================================================*/ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* This definition is in its own file so it can be kept out of the + main header file, but used by "friend classes" like icalset*/ + +#define ICALDIRSET_ID "dset" + +struct icaldirset_impl +{ + char id[5]; /* "dset" */ + char* dir; + icalcomponent* gauge; + icaldirset* cluster; + int first_component; + pvl_list directory; + pvl_elem directory_iterator; +}; diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h new file mode 100644 index 0000000000..927d46ef0a --- /dev/null +++ b/libical/src/libicalss/icalgaugeimpl.h @@ -0,0 +1,39 @@ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalgaugeimpl.h + CREATOR: eric 09 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#include "ical.h" + +struct icalgauge_impl +{ + icalcomponent* select; + icalcomponent* from; + icalcomponent* where; + +}; + + diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c new file mode 100644 index 0000000000..4f075ed6bb --- /dev/null +++ b/libical/src/libicalss/icalmessage.c @@ -0,0 +1,376 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalmessage.c + CREATOR: ebusboom 07 Nov 2000 + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + ======================================================================*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "icalmessage.h" +#include "icalenums.h" +#include /* for tolower()*/ +#include /* for strstr */ +#include /* for free(), malloc() */ +icalcomponent* icalmessage_get_inner(icalcomponent* comp) +{ + if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ + return icalcomponent_get_first_real_component(comp); + } else { + return comp; + } +} + +char* lowercase(const char* str) +{ + char* p = 0; + char* new = icalmemory_strdup(str); + + if(str ==0){ + return 0; + } + + for(p = new; *p!=0; p++){ + *p = tolower(*p); + } + + return new; +} + +icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user) +{ + icalcomponent *inner = icalmessage_get_inner(comp); + icalproperty *p,*attendee = 0; + char* luser = lowercase(user); + + for(p = icalcomponent_get_first_property(inner, ICAL_ATTENDEE_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(inner, ICAL_ATTENDEE_PROPERTY) + ){ + + char* lattendee; + + lattendee = lowercase(icalproperty_get_attendee(p)); + + if (strstr(lattendee,user) != 0){ + attendee = p; + break; + } + + free(lattendee); + + } + + free(luser); + + return attendee; + +} + +void icalmessage_copy_properties(icalcomponent* to, icalcomponent* from, + icalproperty_kind kind) +{ + icalcomponent *to_inner = icalmessage_get_inner(to); + icalcomponent *from_inner = icalmessage_get_inner(from); + + if (to_inner == 0 && from_inner == 0){ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + return; + } + + if(!icalcomponent_get_first_property(from_inner,kind)){ + return; + } + + icalcomponent_add_property(to_inner, + icalproperty_new_clone( + icalcomponent_get_first_property( + from_inner, + kind) + ) + ); +} + +icalcomponent *icalmessage_new_reply_base(icalcomponent* c, + const char* user, + const char* msg) +{ + icalproperty *attendee; + char tmp[45]; + + icalcomponent *reply = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalproperty_new_method(ICAL_METHOD_REPLY), + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_dtstamp(icaltime_from_timet(time(0),0,1)), + 0), + 0); + + icalcomponent *inner = icalmessage_get_inner(reply); + + icalerror_check_arg_rz(c,"c"); + + icalmessage_copy_properties(reply,c,ICAL_UID_PROPERTY); + icalmessage_copy_properties(reply,c,ICAL_ORGANIZER_PROPERTY); + icalmessage_copy_properties(reply,c,ICAL_RECURRENCEID_PROPERTY); + icalmessage_copy_properties(reply,c,ICAL_SUMMARY_PROPERTY); + icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY); + + icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0,1)); + + if(msg != 0){ + icalcomponent_add_property(inner,icalproperty_new_comment(msg)); + } + + /* Copy this user's attendee property */ + + attendee = icalmessage_find_attendee(c,user); + + if (attendee == 0){ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + icalcomponent_free(reply); + return 0; + } + + icalcomponent_add_property(inner,icalproperty_new_clone(attendee)); + + /* Add PRODID and VERSION */ + + icalcomponent_add_property(reply,icalproperty_new_version("2.0")); + + sprintf(tmp, + "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); + icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); + + return reply; + +} + +icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, + const char* user, + const char* msg) +{ + + icalcomponent *reply; + icalproperty *attendee; + icalcomponent *inner; + + icalerror_check_arg_rz(c,"c"); + + reply = icalmessage_new_reply_base(c,user,msg); + + if(reply == 0){ + return 0; + } + + inner = icalmessage_get_inner(reply); + + attendee = icalcomponent_get_first_property(inner, + ICAL_ATTENDEE_PROPERTY); + + icalproperty_set_parameter(attendee, + icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED)); + + return reply; +} + +icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, + const char* user, + const char* msg) +{ + icalcomponent *reply; + icalproperty *attendee; + icalcomponent *inner; + + icalerror_check_arg_rz(c,"c"); + + reply = icalmessage_new_reply_base(c,user,msg); + inner = icalmessage_get_inner(reply); + if(reply == 0){ + return 0; + } + + attendee = icalcomponent_get_first_property(inner, + ICAL_ATTENDEE_PROPERTY); + + icalproperty_set_parameter(attendee, + icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED)); + + return reply; +} + +/* New is modified version of old */ +icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* old, + icalcomponent* new, + const char* user, + const char* msg) +{ + icalcomponent *reply; + + icalerror_check_arg_rz(old,"old"); + icalerror_check_arg_rz(new,"new"); + + reply = icalcomponent_new_clone(new); + + icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); + + return new; + +} + + +icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, + const char* user, + const char* delegatee, + const char* msg) +{ + + icalcomponent *reply; + icalproperty *attendee; + icalcomponent *inner; + + icalerror_check_arg_rz(c,"c"); + + reply = icalmessage_new_reply_base(c,user,msg); + inner = icalmessage_get_inner(reply); + if(reply == 0){ + return 0; + } + + attendee = icalcomponent_get_first_property(inner, + ICAL_ATTENDEE_PROPERTY); + + icalproperty_set_parameter(attendee, + icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED)); + + icalproperty_set_parameter(attendee, + icalparameter_new_delegatedto(delegatee)); + + return reply; + +} + +icalcomponent* icalmessage_new_delegate_request(icalcomponent* c, + const char* user, + const char* delegatee, + const char* msg) +{ + + icalcomponent *reply; + icalproperty *attendee; + icalcomponent *inner; + + icalerror_check_arg_rz(c,"c"); + + reply = icalmessage_new_reply_base(c,user,msg); + inner = icalmessage_get_inner(reply); + + if(reply == 0){ + return 0; + } + + icalcomponent_set_method(reply,ICAL_METHOD_REQUEST); + + attendee = icalcomponent_get_first_property(inner, + ICAL_ATTENDEE_PROPERTY); + + icalproperty_set_parameter(attendee, + icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED)); + + icalproperty_set_parameter(attendee, + icalparameter_new_delegatedto(delegatee)); + + icalcomponent_add_property( + inner, + icalproperty_vanew_attendee( + delegatee, + icalparameter_new_delegatedfrom( + icalproperty_get_attendee(attendee) + ), + 0 + ) + ); + + + return reply; + +} + + +icalcomponent* icalmessage_new_cancel_event(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_all(icalcomponent* c, + const char* user, + const char* msg); + + + +icalcomponent* icalmessage_new_error_reply(icalcomponent* c, + const char* user, + const char* msg, + const char* debug, + icalrequeststatus code) +{ + icalcomponent *reply; + icalcomponent *inner, *cinner; + struct icalreqstattype rs; + + icalerror_check_arg_rz(c,"c"); + + reply = icalmessage_new_reply_base(c,user,msg); + inner = icalmessage_get_inner(reply); + cinner = icalmessage_get_inner(c); + if(reply == 0){ + return 0; + } + + if( code != ICAL_UNKNOWN_STATUS){ + rs.code = code; + rs.debug = debug; + + icalcomponent_add_property(inner, + icalproperty_new_requeststatus( + icalreqstattype_as_string(rs) + ) + ); + } else { /* code == ICAL_UNKNOWN_STATUS */ + + /* Copy all of the request status properties */ + icalproperty *p; + for(p = icalcomponent_get_first_property(cinner, + ICAL_REQUESTSTATUS_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(cinner, + ICAL_REQUESTSTATUS_PROPERTY)){ + + + icalcomponent_add_property(inner,icalproperty_new_clone(p)); + } + } + + return reply; +} diff --git a/libical/src/libicalss/icalmessage.h b/libical/src/libicalss/icalmessage.h new file mode 100644 index 0000000000..7687db681e --- /dev/null +++ b/libical/src/libicalss/icalmessage.h @@ -0,0 +1,72 @@ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalmessage.h + CREATOR: eric 07 Nov 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ + +#include "ical.h" + +#ifndef ICALMESSAGE_H +#define ICALMESSAGE_H + + +icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, + const char* user, + const char* msg); + +icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, + const char* user, + const char* msg); + +/* New is modified version of old */ +icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* old, + icalcomponent* new, + const char* user, + const char* msg); + + +icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, + const char* user, + const char* delegatee, + const char* msg); + + + +icalcomponent* icalmessage_new_cancel_event(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_all(icalcomponent* c, + const char* user, + const char* msg); + + +icalcomponent* icalmessage_new_error_reply(icalcomponent* c, + const char* user, + const char* msg, + const char* debug, + icalrequeststatus rs); + + +#endif /* ICALMESSAGE_H*/ diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c new file mode 100644 index 0000000000..effab3dca2 --- /dev/null +++ b/libical/src/libicalss/icalspanlist.c @@ -0,0 +1,309 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalspanlist.c + CREATOR: ebusboom 23 aug 2000 + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + ======================================================================*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ical.h" +#include "icalspanlist.h" +#include "pvl.h" +#include /* for free and malloc */ + +struct icalspanlist_impl { + pvl_list spans; +}; + +int compare_span(void* a, void* b) +{ + struct icaltime_span *span_a = (struct icaltime_span *)a ; + struct icaltime_span *span_b = (struct icaltime_span *)b ; + + if(span_a->start == span_b->start){ + return 0; + } else if(span_a->start < span_b->start){ + return -1; + } else { /*if(span_a->start > span->b.start)*/ + return 1; + } +} + +icalcomponent* icalspanlist_get_inner(icalcomponent* comp) +{ + if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ + return icalcomponent_get_first_real_component(comp); + } else { + return comp; + } +} + + +void print_span(int c, struct icaltime_span span ); + + +/* Make a free list from a set of component */ +icalspanlist* icalspanlist_new(icalset *set, + struct icaltimetype start, + struct icaltimetype end) +{ + struct icaltime_span range; + pvl_elem itr; + icalcomponent *c,*inner; + icalcomponent_kind kind, inner_kind; + struct icalspanlist_impl *sl; + struct icaltime_span *freetime; + + if ( ( sl = (struct icalspanlist_impl*) + malloc(sizeof(struct icalspanlist_impl))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + sl->spans = pvl_newlist(); + + range.start = icaltime_as_timet(start); + range.end = icaltime_as_timet(end); + + printf("Range start: %s",ctime(&range.start)); + printf("Range end : %s",ctime(&range.end)); + + + /* Get a list of spans of busy time from the events in the set + and order the spans based on the start time */ + + for(c = icalset_get_first_component(set); + c != 0; + c = icalset_get_next_component(set)){ + + struct icaltime_span span; + + kind = icalcomponent_isa(c); + inner = icalcomponent_get_inner(c); + + if(!inner){ + continue; + } + + inner_kind = icalcomponent_isa(inner); + + if( kind != ICAL_VEVENT_COMPONENT && + inner_kind != ICAL_VEVENT_COMPONENT){ + continue; + } + + icalerror_clear_errno(); + + span = icalcomponent_get_span(c); + span.is_busy = 1; + + if(icalerrno != ICAL_NO_ERROR){ + continue; + } + + if ((range.start < span.end && icaltime_is_null_time(end)) || + (range.start < span.end && range.end > span.start )){ + + struct icaltime_span *s; + + if ((s=(struct icaltime_span *) + malloc(sizeof(struct icaltime_span))) == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + memcpy(s,&span,sizeof(span)); + + pvl_insert_ordered(sl->spans,compare_span,(void*)s); + + } + } + + /* Now Fill in the free time spans. loop through the spans. if the + start of the range is not within the span, create a free entry + that runs from the start of the range to the start of the + span. */ + + for( itr = pvl_head(sl->spans); + itr != 0; + itr = pvl_next(itr)) + { + struct icaltime_span *s = (icalproperty*)pvl_data(itr); + + if ((freetime=(struct icaltime_span *) + malloc(sizeof(struct icaltime_span))) == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + if(range.start < s->start){ + freetime->start = range.start; + freetime->end = s->start; + + freetime->is_busy = 0; + + + pvl_insert_ordered(sl->spans,compare_span,(void*)freetime); + } else { + free(freetime); + } + + range.start = s->end; + } + + /* If the end of the range is null, then assume that everything + after the last item in the calendar is open and add a span + that indicates this */ + + if( icaltime_is_null_time(end)){ + struct icaltime_span* last_span; + + last_span = pvl_data(pvl_tail(sl->spans)); + + if (last_span != 0){ + + if ((freetime=(struct icaltime_span *) + malloc(sizeof(struct icaltime_span))) == 0){ + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + freetime->is_busy = 0; + freetime->start = last_span->end; + freetime->end = freetime->start; + pvl_insert_ordered(sl->spans,compare_span,(void*)freetime); + } + } + + + return sl; + +} + +void icalspanlist_free(icalspanlist* s) +{ + struct icaltime_span *span; + struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s; + + while( (span=pvl_pop(impl->spans)) != 0){ + free(span); + } + + pvl_free(impl->spans); + + impl->spans = 0; +} + + +void icalspanlist_dump(icalspanlist* s){ + + int i = 0; + struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s; + pvl_elem itr; + + for( itr = pvl_head(sl->spans); + itr != 0; + itr = pvl_next(itr)) + { + struct icaltime_span *s = (icalproperty*)pvl_data(itr); + + printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start)); + printf(" end : %s",ctime(&s->end)); + + } +} + +icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); +icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); + +struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, + struct icaltimetype t) +{ + struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl; + pvl_elem itr; + struct icalperiodtype period; + struct icaltime_span *s; + + time_t rangett= icaltime_as_timet(t); + + period.start = icaltime_null_time(); + period.end = icaltime_null_time(); + + /* Is the reference time before the first span? If so, assume + that the reference time is free */ + itr = pvl_head(impl->spans); + s = (icalproperty*)pvl_data(itr); + + if (s == 0){ + /* No elements in span */ + return period; + } + + if(rangett start ){ + /* End of period is start of first span if span is busy, end + of the span if it is free */ + period.start = t; + + if (s->is_busy == 0){ + period.end = icaltime_from_timet(s->start,0,0); + } else { + period.end = icaltime_from_timet(s->end,0,0); + } + + return period; + } + + /* Otherwise, find the first free span that contains the + reference time. */ + + for( itr = pvl_head(impl->spans); + itr != 0; + itr = pvl_next(itr)) + { + s = (icalproperty*)pvl_data(itr); + + if(s->is_busy == 0 && s->start >= rangett && + ( rangett < s->end || s->end == s->start)){ + + if (rangett < s->start){ + period.start = icaltime_from_timet(s->start,0,0); + } else { + period.start = icaltime_from_timet(rangett,0,0); + } + + period.end = icaltime_from_timet(s->end,0,0); + + return period; + } + + } + + period.start = icaltime_null_time(); + period.end = icaltime_null_time(); + + return period; +} + +struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, + struct icaltimetype t); + diff --git a/libical/src/libicalss/icalspanlist.h b/libical/src/libicalss/icalspanlist.h new file mode 100644 index 0000000000..83cb1c8a6d --- /dev/null +++ b/libical/src/libicalss/icalspanlist.h @@ -0,0 +1,54 @@ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalspanlist.h + CREATOR: eric 21 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ +#ifndef ICALSPANLIST_H +#define ICALSPANLIST_H + +#include "ical.h" +#include "icalset.h" + +typedef void icalspanlist; + +/* Make a free list from a set of component. Start and end should be in UTC */ +icalspanlist* icalspanlist_new(icalset *set, + struct icaltimetype start, + struct icaltimetype end); + +void icalspanlist_free(icalspanlist* spl); + +icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); +icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); + +/* Get first free or busy time after time t. all times are in UTC */ +struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, + struct icaltimetype t); +struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, + struct icaltimetype t); + +void icalspanlist_dump(icalspanlist* s); + +#endif + + + diff --git a/libical/src/libicalss/icalss.h b/libical/src/libicalss/icalss.h new file mode 100644 index 0000000000..df87bc2f6c --- /dev/null +++ b/libical/src/libicalss/icalss.h @@ -0,0 +1,763 @@ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalset.h + CREATOR: eric 28 November 1999 + + + Icalset is the "base class" for representations of a collection of + iCal components. Derived classes (actually delegatees) include: + + icalfileset Store componetns in a single file + icaldirset Store components in multiple files in a directory + icalheapset Store components on the heap + icalmysqlset Store components in a mysql database. + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#ifndef ICALSET_H +#define ICALSET_H + + +typedef void icalset; + +typedef enum icalset_kind { + ICAL_FILE_SET, + ICAL_DIR_SET, + ICAL_HEAP_SET, + ICAL_MYSQL_SET, + ICAL_CAP_SET +} icalset_kind; + + +/* Create a specific derived type of set */ +icalset* icalset_new_file(const char* path); +icalset* icalset_new_dir(const char* path); +icalset* icalset_new_heap(void); +icalset* icalset_new_mysql(const char* path); +/*icalset* icalset_new_cap(icalcstp* cstp);*/ + +void icalset_free(icalset* set); + +const char* icalset_path(icalset* set); + +/* Mark the cluster as changed, so it will be written to disk when it + is freed. Commit writes to disk immediately*/ +void icalset_mark(icalset* set); +icalerrorenum icalset_commit(icalset* set); + +icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); +icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp); + +int icalset_count_components(icalset* set, + icalcomponent_kind kind); + +/* Restrict the component returned by icalset_first, _next to those + that pass the gauge. _clear removes the gauge. */ +icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); +void icalset_clear_select(icalset* set); + +/* Get a component by uid */ +icalcomponent* icalset_fetch(icalset* set, const char* uid); +int icalset_has_uid(icalset* set, const char* uid); +icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); + +/* Modify components according to the MODIFY method of CAP. Works on + the currently selected components. */ +icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, + icalcomponent *newc); + +/* Iterate through the components. If a guage has been defined, these + will skip over components that do not pass the gauge */ + +icalcomponent* icalset_get_current_component(icalset* set); +icalcomponent* icalset_get_first_component(icalset* set); +icalcomponent* icalset_get_next_component(icalset* set); + +#endif /* !ICALSET_H */ + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalfileset.h + CREATOR: eric 23 December 1999 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#ifndef ICALFILESET_H +#define ICALFILESET_H + + +typedef void icalfileset; + + +/* icalfileset + icalfilesetfile + icalfilesetdir +*/ + + +icalfileset* icalfileset_new(const char* path); +void icalfileset_free(icalfileset* cluster); + +const char* icalfileset_path(icalfileset* cluster); + +/* Mark the cluster as changed, so it will be written to disk when it + is freed. Commit writes to disk immediately. */ +void icalfileset_mark(icalfileset* cluster); +icalerrorenum icalfileset_commit(icalfileset* cluster); + +icalerrorenum icalfileset_add_component(icalfileset* cluster, + icalcomponent* child); + +icalerrorenum icalfileset_remove_component(icalfileset* cluster, + icalcomponent* child); + +int icalfileset_count_components(icalfileset* cluster, + icalcomponent_kind kind); + +/* Restrict the component returned by icalfileset_first, _next to those + that pass the gauge. _clear removes the gauge */ +icalerrorenum icalfileset_select(icalfileset* store, icalcomponent* gauge); +void icalfileset_clear(icalfileset* store); + +/* Get and search for a component by uid */ +icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); +int icalfileset_has_uid(icalfileset* cluster, const char* uid); +icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c); + + +/* Modify components according to the MODIFY method of CAP. Works on + the currently selected components. */ +icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, + icalcomponent *newcomp); + +/* Iterate through components. If a guage has been defined, these + will skip over components that do not pass the gauge */ + +icalcomponent* icalfileset_get_current_component (icalfileset* cluster); +icalcomponent* icalfileset_get_first_component(icalfileset* cluster); +icalcomponent* icalfileset_get_next_component(icalfileset* cluster); +/* Return a reference to the internal component. You probably should + not be using this. */ + +icalcomponent* icalfileset_get_component(icalfileset* cluster); + + +#endif /* !ICALFILESET_H */ + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icaldirset.h + CREATOR: eric 28 November 1999 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#ifndef ICALDIRSET_H +#define ICALDIRSET_H + + +/* icaldirset Routines for storing, fetching, and searching for ical + * objects in a database */ + +typedef void icaldirset; + + +icaldirset* icaldirset_new(const char* path); + +void icaldirset_free(icaldirset* store); + +const char* icaldirset_path(icaldirset* store); + +/* Mark the cluster as changed, so it will be written to disk when it + is freed. Commit writes to disk immediately*/ +void icaldirset_mark(icaldirset* store); +icalerrorenum icaldirset_commit(icaldirset* store); + +icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); +icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); + +int icaldirset_count_components(icaldirset* store, + icalcomponent_kind kind); + +/* Restrict the component returned by icaldirset_first, _next to those + that pass the gauge. _clear removes the gauge. */ +icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); +void icaldirset_clear(icaldirset* store); + +/* Get a component by uid */ +icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); +int icaldirset_has_uid(icaldirset* store, const char* uid); +icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); + +/* Modify components according to the MODIFY method of CAP. Works on + the currently selected components. */ +icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, + icalcomponent *newc); + +/* Iterate through the components. If a guage has been defined, these + will skip over components that do not pass the gauge */ + +icalcomponent* icaldirset_get_current_component(icaldirset* store); +icalcomponent* icaldirset_get_first_component(icaldirset* store); +icalcomponent* icaldirset_get_next_component(icaldirset* store); + +#endif /* !ICALDIRSET_H */ + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalcalendar.h + CREATOR: eric 23 December 1999 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#ifndef ICALCALENDAR_H +#define ICALCALENDAR_H + + +/* icalcalendar + * Routines for storing calendar data in a file system. The calendar + * has two icaldirsets, one for incoming components and one for booked + * components. It also has interfaces to access the free/busy list + * and a list of calendar properties */ + +typedef void icalcalendar; + +icalcalendar* icalcalendar_new(char* dir); + +void icalcalendar_free(icalcalendar* calendar); + +int icalcalendar_lock(icalcalendar* calendar); + +int icalcalendar_unlock(icalcalendar* calendar); + +int icalcalendar_islocked(icalcalendar* calendar); + +int icalcalendar_ownlock(icalcalendar* calendar); + +icalset* icalcalendar_get_booked(icalcalendar* calendar); + +icalset* icalcalendar_get_incoming(icalcalendar* calendar); + +icalset* icalcalendar_get_properties(icalcalendar* calendar); + +icalset* icalcalendar_get_freebusy(icalcalendar* calendar); + + +#endif /* !ICALCALENDAR_H */ + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalgauge.h + CREATOR: eric 23 December 1999 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + +======================================================================*/ + +#ifndef ICALGAUGE_H +#define ICALGAUGE_H + +typedef void icalgauge; + +icalgauge* icalgauge_new_from_sql(char* sql); + +void icalgauge_free(icalgauge* gauge); + +char* icalgauge_as_sql(icalcomponent* gauge); + +int icalgauge_test(icalcomponent* comp, icalcomponent* gaugecontainer); + + +#endif /* ICALGAUGE_H*/ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalssutil.h + CREATOR: eric 21 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalclassify.h + CREATOR: eric 21 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ + +#ifndef ICALCLASSIFY_H +#define ICALCLASSIFY_H + + + +typedef enum icalclass { + ICAL_NO_CLASS, + ICAL_PUBLISH_NEW_CLASS, + ICAL_PUBLISH_UPDATE_CLASS, + ICAL_PUBLISH_FREEBUSY_CLASS, + ICAL_REQUEST_NEW_CLASS, + ICAL_REQUEST_UPDATE_CLASS, + ICAL_REQUEST_RESCHEDULE_CLASS, + ICAL_REQUEST_DELEGATE_CLASS, + ICAL_REQUEST_NEW_ORGANIZER_CLASS, + ICAL_REQUEST_FORWARD_CLASS, + ICAL_REQUEST_STATUS_CLASS, + ICAL_REQUEST_FREEBUSY_CLASS, + ICAL_REPLY_ACCEPT_CLASS, + ICAL_REPLY_DECLINE_CLASS, + ICAL_REPLY_CRASHER_ACCEPT_CLASS, + ICAL_REPLY_CRASHER_DECLINE_CLASS, + ICAL_ADD_INSTANCE_CLASS, + ICAL_CANCEL_EVENT_CLASS, + ICAL_CANCEL_INSTANCE_CLASS, + ICAL_CANCEL_ALL_CLASS, + ICAL_REFRESH_CLASS, + ICAL_COUNTER_CLASS, + ICAL_DECLINECOUNTER_CLASS, + ICAL_MALFORMED_CLASS, + ICAL_OBSOLETE_CLASS, /* 21 */ + ICAL_MISSEQUENCED_CLASS, /* 22 */ + ICAL_UNKNOWN_CLASS /* 23 */ +} ical_class; + +ical_class icalclassify(icalcomponent* c,icalcomponent* match, + const char* user); + +icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); + +#endif /* ICALCLASSIFY_H*/ + + + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalspanlist.h + CREATOR: eric 21 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ +#ifndef ICALSPANLIST_H +#define ICALSPANLIST_H + + +typedef void icalspanlist; + +/* Make a free list from a set of component. Start and end should be in UTC */ +icalspanlist* icalspanlist_new(icalset *set, + struct icaltimetype start, + struct icaltimetype end); + +void icalspanlist_free(icalspanlist* spl); + +icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); +icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); + +/* Get first free or busy time after time t. all times are in UTC */ +struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, + struct icaltimetype t); +struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, + struct icaltimetype t); + +void icalspanlist_dump(icalspanlist* s); + +#endif + + + +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalmessage.h + CREATOR: eric 07 Nov 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ + + +#ifndef ICALMESSAGE_H +#define ICALMESSAGE_H + + +icalcomponent* icalmessage_new_accept_reply(icalcomponent* c, + const char* user, + const char* msg); + +icalcomponent* icalmessage_new_decline_reply(icalcomponent* c, + const char* user, + const char* msg); + +/* New is modified version of old */ +icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* old, + icalcomponent* new, + const char* user, + const char* msg); + + +icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c, + const char* user, + const char* delegatee, + const char* msg); + + + +icalcomponent* icalmessage_new_cancel_event(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_instance(icalcomponent* c, + const char* user, + const char* msg); +icalcomponent* icalmessage_new_cancel_all(icalcomponent* c, + const char* user, + const char* msg); + + +icalcomponent* icalmessage_new_error_reply(icalcomponent* c, + const char* user, + const char* msg, + const char* debug, + icalrequeststatus rs); + + +#endif /* ICALMESSAGE_H*/ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalcstp.h + CREATOR: eric 20 April 1999 + + $Id$ + + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The original code is icalcstp.h + +======================================================================*/ + + +#ifndef ICALCSTP_H +#define ICALCSTP_H + + + +/********************** Server (Reciever) Interfaces *************************/ + +/* On the server side, the caller will recieve data from the incoming + socket and pass it to icalcstps_next_input. The caller then takes + the return from icalcstps_next_outpu and sends it out through the + socket. This gives the caller a point of control. If the cstp code + connected to the socket itself, it would be hard for the caller to + do anything else after the cstp code was started. + + All of the server abd client command routines will generate + response codes. On the server side, these responses will be turned + into text and sent to the client. On the client side, the reponse + is the one sent from the server. + + Since each command can return multiple responses, the responses are + stored in the icalcstps object and are accesses by + icalcstps_first_response() and icalcstps_next_response() + + How to use: + + 1) Construct a new icalcstps, bound to your code via stubs + 2) Repeat forever: + 2a) Get string from client & give to icalcstps_next_input() + 2b) Call icalcstps_next_output. Send string to client. + +*/ + + + +typedef void icalcstps; + +/* Er, they aren't really stubs, but pointers to the rountines that + icalcstps_process_incoming will call when it recognizes a CSTP + command in the data. BTW, the CONTINUE command is named 'cont' + because 'continue' is a C keyword */ +struct icalcstps_stubs { + icalerrorenum (*abort)(icalcstps* cstp); + icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism, + char* data); + icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid); + icalerrorenum (*capability)(icalcstps* cstp); + icalerrorenum (*cont)(icalcstps* cstp, unsigned int time); + icalerrorenum (*identify)(icalcstps* cstp, char* id); + icalerrorenum (*disconnect)(icalcstps* cstp); + icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time, + icalcomponent *comp); + icalerrorenum (*starttls)(icalcstps* cstp, char* command, + char* data); + icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn); + icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data); +}; + + +icalcstps* icalcstps_new(struct icalcstps_stubs stubs); + +void icalcstps_free(icalcstps* cstp); + +int icalcstps_set_timeout(icalcstps* cstp, int sec); + +/* Get the next string to send to the client */ +char* icalcstps_next_output(icalcstps* cstp); + +/* process the next string from the client */ +int icalcstps_next_input(icalcstps* cstp); + + +/********************** Client (Sender) Interfaces **************************/ + +/* How to use: + + 1) Construct a new icalcstpc + 2) Issue a command + 3) Repeat until both call icalcstpc_next_output and + icalcstpc_next_input return 0: + 3a) Call icalcstpc_next_output. Send string to server. + 3b) Get string from server, & give to icalcstp_next_input() + 4) Iterate with icalcstpc_first_response & icalcstp_next_response to + get the servers responses + 5) Repeat at #2 +*/ + +typedef void* icalcstpc; + +/* Response code sent by the server. */ +typedef struct icalcstpc_response { + icalrequeststatus code; + char *arg; /* These strings are owned by libical */ + char *debug_text; + char *more_text; + void* result; +} icalcstpc_response; + +icalcstps* icalcstpc_new(); + +void* icalcstpc_free(icalcstpc* cstpc); + +int icalcstpc_set_timeout(icalcstpc* cstp, int sec); + + +/* Get the next string to send to the server */ +char* icalcstpc_next_output(icalcstpc* cstp); + +/* process the next string from the server */ +int icalcstpc_next_input(icalcstpc* cstp); + +/* After icalcstpc_next_input returns a 0, there are responses + ready. use these to get them */ +icalcstpc_response icalcstpc_first_response(icalcstpc* cstp); +icalcstpc_response icalcstpc_next_response(icalcstpc* cstp); + +/* Issue a command */ +icalerrorenum icalcstpc_abort(icalcstpc* cstp); +icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism, + char* init_data, char* f(char*) ); +icalerrorenum icalcstpc_capability(icalcstpc* cstp); +icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid); +icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time); +icalerrorenum icalcstpc_disconnect(icalcstpc* cstp); +icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id); +icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command, + char* init_data, char* f(char*)); +icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time, + icalcomponent *comp); +icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid); +icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time, + icalcomponent *comp); + + +#endif /* !ICALCSTP_H */ + + + diff --git a/libical/src/libicalss/icalsslexer.c b/libical/src/libicalss/icalsslexer.c new file mode 100644 index 0000000000..9deced3aca --- /dev/null +++ b/libical/src/libicalss/icalsslexer.c @@ -0,0 +1,1702 @@ +#define yy_create_buffer ss_create_buffer +#define yy_delete_buffer ss_delete_buffer +#define yy_scan_buffer ss_scan_buffer +#define yy_scan_string ss_scan_string +#define yy_scan_bytes ss_scan_bytes +#define yy_flex_debug ss_flex_debug +#define yy_init_buffer ss_init_buffer +#define yy_flush_buffer ss_flush_buffer +#define yy_load_buffer_state ss_load_buffer_state +#define yy_switch_to_buffer ss_switch_to_buffer +#define yyin ssin +#define yyleng ssleng +#define yylex sslex +#define yyout ssout +#define yyrestart ssrestart +#define yytext sstext +#define yywrap sswrap + +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header$ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char yytext[]; + + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + if ( yyleng >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ + yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 18 +#define YY_END_OF_BUFFER 19 +static yyconst short int yy_accept[47] = + { 0, + 0, 0, 0, 0, 0, 0, 19, 17, 13, 13, + 17, 17, 15, 4, 14, 7, 5, 8, 15, 15, + 15, 15, 15, 13, 6, 0, 16, 15, 9, 10, + 15, 15, 12, 15, 15, 11, 15, 15, 15, 2, + 15, 15, 15, 3, 1, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 7, 6, 6, 1, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 1, 8, 9, + 10, 11, 1, 1, 12, 6, 13, 14, 15, 16, + 6, 17, 6, 6, 6, 18, 19, 20, 21, 6, + 6, 22, 23, 24, 6, 6, 25, 6, 6, 6, + 1, 1, 1, 1, 1, 1, 12, 6, 13, 14, + + 15, 16, 6, 17, 6, 6, 6, 18, 19, 20, + 21, 6, 6, 22, 23, 24, 6, 6, 25, 6, + 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[26] = + { 0, + 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3 + } ; + +static yyconst short int yy_base[49] = + { 0, + 0, 0, 0, 0, 0, 0, 55, 56, 24, 26, + 44, 48, 0, 56, 56, 42, 56, 41, 30, 27, + 26, 32, 29, 28, 56, 40, 56, 0, 56, 56, + 30, 22, 0, 24, 26, 0, 21, 24, 16, 0, + 24, 21, 11, 0, 0, 56, 31, 30 + } ; + +static yyconst short int yy_def[49] = + { 0, + 46, 1, 1, 1, 1, 1, 46, 46, 46, 46, + 46, 47, 48, 46, 46, 46, 46, 46, 48, 48, + 48, 48, 48, 46, 46, 47, 46, 48, 46, 46, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 0, 46, 46 + } ; + +static yyconst short int yy_nxt[82] = + { 0, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 13, 13, 13, 20, 13, 13, 13, 13, + 21, 13, 22, 13, 23, 24, 24, 24, 24, 24, + 24, 26, 28, 26, 45, 44, 43, 42, 41, 40, + 39, 38, 37, 36, 27, 35, 34, 33, 32, 31, + 30, 29, 27, 25, 46, 7, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 + } ; + +static yyconst short int yy_chk[82] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 9, 9, 10, 10, 24, + 24, 47, 48, 47, 43, 42, 41, 39, 38, 37, + 35, 34, 32, 31, 26, 23, 22, 21, 20, 19, + 18, 16, 12, 11, 7, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#ifndef YYLMAX +#define YYLMAX 8192 +#endif + +char yytext[YYLMAX]; +char *yytext_ptr; +#line 1 "icalsslexer.l" +#define INITIAL 0 +#line 2 "icalsslexer.l" +/* -*- Mode: C -*- + ====================================================================== + FILE: icalsslexer.l + CREATOR: eric 8 Aug 2000 + + DESCRIPTION: + + $Id$ + $Locker$ + +(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + ======================================================================*/ + +#include "icalssyacc.h" +#include "icalgaugeimpl.h" +#include "assert.h" + +#include /* For strdup() */ + +int icalparser_flex_input(char* buf, int max_size); +void icalparser_clear_flex_input(); + +#undef YY_INPUT +#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) + +#undef SS_FATAL_ERROR +#define SS_FATAL_ERROR(msg) sserror(msg) + + +#define sql 1 +#define string_value 2 + +#line 467 "lex.ss.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 69 "icalsslexer.l" + + + + + + +#line 625 "lex.ss.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 56 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 75 "icalsslexer.l" +{ return SELECT; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 76 "icalsslexer.l" +{ return FROM; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 77 "icalsslexer.l" +{ return WHERE; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 78 "icalsslexer.l" +{ return COMMA; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 79 "icalsslexer.l" +{ return EQUALS; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 80 "icalsslexer.l" +{ return NOTEQUALS; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 81 "icalsslexer.l" +{ return LESS; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 82 "icalsslexer.l" +{ return GREATER; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 83 "icalsslexer.l" +{ return LESSEQUALS; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 84 "icalsslexer.l" +{ return GREATEREQUALS; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 85 "icalsslexer.l" +{ return AND; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 86 "icalsslexer.l" +{ return OR; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 87 "icalsslexer.l" +; + YY_BREAK +case 14: +YY_RULE_SETUP +#line 88 "icalsslexer.l" +{ return EOL; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 89 "icalsslexer.l" +{ sslval.v_string= icalmemory_tmp_copy(sstext); + return STRING; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 92 "icalsslexer.l" +{ + int c = input(); + unput(c); + if(c!='\''){ + sslval.v_string= icalmemory_tmp_copy(sstext); + return STRING; + } else { + /*ssmore();*/ + } +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 103 "icalsslexer.l" +{ return yytext[0]; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 105 "icalsslexer.l" +ECHO; + YY_BREAK +#line 808 "lex.ss.c" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(sql): +case YY_STATE_EOF(string_value): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 47 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 46); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 105 "icalsslexer.l" + + +int sswrap() +{ + return 1; +} + diff --git a/libical/src/libicalss/icalsslexer.l b/libical/src/libicalss/icalsslexer.l new file mode 100644 index 0000000000..0054984c6d --- /dev/null +++ b/libical/src/libicalss/icalsslexer.l @@ -0,0 +1,111 @@ +%{ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalsslexer.l + CREATOR: eric 8 Aug 2000 + + DESCRIPTION: + + $Id: icalsslexer.l,v 1.1 2000/12/11 22:06:17 federico Exp $ + $Locker: $ + +(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + ======================================================================*/ + +#include "icalssyacc.h" +#include "icalgaugeimpl.h" +#include "assert.h" + +#include /* For strdup() */ + +int icalparser_flex_input(char* buf, int max_size); +void icalparser_clear_flex_input(); + +#undef YY_INPUT +#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms)) + +#undef SS_FATAL_ERROR +#define SS_FATAL_ERROR(msg) sserror(msg) + + +%} + +crlf \x0D?\x0A +space [ ] +qsafechar [^\x00-\x1F\"] +safechar [^\x00-\x1F\"\:\;\,] +tsafechar [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E] +valuechar [^\x00-\x08\x10-\x1F] +xname X-[a-zA-Z0-9\-]+ +xname2 [a-zA-Z0-9\-\ ] +paramtext {safechar}+ +value {valuechar}+ +quotedstring \"{qsafechar}+\" +digit [0-9] + +%array /* Make yytext an array. Slow, but handy. HACK */ + +%option caseless + +%s sql string_value + + + +%% + +%{ +%} + + +SELECT { return SELECT; } +FROM { return FROM; } +WHERE { return WHERE; } +, { return COMMA; } +"=" { return EQUALS; } +"!=" { return NOTEQUALS; } +"<" { return LESS; } +">" { return GREATER; } +"<=" { return LESSEQUALS; } +">=" { return GREATEREQUALS; } +AND { return AND; } +OR { return OR; } +[ \t\n\r]+ ; +; { return EOL; } +[\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext); + return STRING; } + +'[^'\n]*' { + int c = input(); + unput(c); + if(c!='\''){ + sslval.v_string= icalmemory_tmp_copy(sstext); + return STRING; + } else { + /*ssmore();*/ + } +} + +. { return yytext[0]; } + +%% + +int sswrap() +{ + return 1; +} + diff --git a/libical/src/libicalss/icalssutil.c b/libical/src/libicalss/icalssutil.c new file mode 100644 index 0000000000..8db141d41d --- /dev/null +++ b/libical/src/libicalss/icalssutil.c @@ -0,0 +1,29 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalssutil.c + CREATOR: ebusboom 23 aug 2000 + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + ======================================================================*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + diff --git a/libical/src/libicalss/icalssutil.h b/libical/src/libicalss/icalssutil.h new file mode 100644 index 0000000000..3890da6a11 --- /dev/null +++ b/libical/src/libicalss/icalssutil.h @@ -0,0 +1,27 @@ +/* -*- Mode: C -*- */ +/*====================================================================== + FILE: icalssutil.h + CREATOR: eric 21 Aug 2000 + + + $Id$ + $Locker$ + + (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + + =========================================================================*/ + +#include "ical.h" + diff --git a/libical/src/libicalss/icalssyacc.c b/libical/src/libicalss/icalssyacc.c new file mode 100644 index 0000000000..38a872942d --- /dev/null +++ b/libical/src/libicalss/icalssyacc.c @@ -0,0 +1,1154 @@ + +/* A Bison parser, made from icalssyacc.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define yyparse ssparse +#define yylex sslex +#define yyerror sserror +#define yylval sslval +#define yychar sschar +#define yydebug ssdebug +#define yynerrs ssnerrs +#define STRING 257 +#define SELECT 258 +#define FROM 259 +#define WHERE 260 +#define COMMA 261 +#define EQUALS 262 +#define NOTEQUALS 263 +#define LESS 264 +#define GREATER 265 +#define LESSEQUALS 266 +#define GREATEREQUALS 267 +#define AND 268 +#define OR 269 +#define EOL 270 +#define END 271 + +#line 1 "icalssyacc.y" + +/* -*- Mode: C -*- + ====================================================================== + FILE: icalssyacc.y + CREATOR: eric 08 Aug 2000 + + DESCRIPTION: + + $Id$ + $Locker$ + +(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + ======================================================================*/ + +#include +#include /* for strdup() */ +#include /* for SHRT_MAX*/ +#include "ical.h" +#include "pvl.h" +#include "icalgaugeimpl.h" + + +extern struct icalgauge_impl *icalss_yy_gauge; + +void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, + enum icalparameter_xliccomparetype compare , char* str2); +void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); +void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); +void move_where(int w); +void sserror(char *s); /* Don't know why I need this.... */ + + + + +#line 51 "icalssyacc.y" +typedef union { + char* v_string; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 34 +#define YYFLAG -32768 +#define YYNTBASE 18 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 271 ? yytranslate[x] : 23) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 7, 9, 11, 15, 17, 21, 22, 26, 30, + 34, 38, 42, 46, 48, 52 +}; + +static const short yyrhs[] = { 4, + 19, 5, 20, 6, 22, 0, 1, 0, 3, 0, + 19, 7, 3, 0, 3, 0, 20, 7, 3, 0, + 0, 3, 8, 3, 0, 3, 9, 3, 0, 3, + 10, 3, 0, 3, 11, 3, 0, 3, 12, 3, + 0, 3, 13, 3, 0, 21, 0, 22, 14, 21, + 0, 22, 15, 21, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 62, 63, 69, 71, 75, 77, 80, 82, 84, 85, + 86, 87, 88, 91, 93, 94 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","STRING", +"SELECT","FROM","WHERE","COMMA","EQUALS","NOTEQUALS","LESS","GREATER","LESSEQUALS", +"GREATEREQUALS","AND","OR","EOL","END","query_min","select_list","from_list", +"where_clause","where_list", NULL +}; +#endif + +static const short yyr1[] = { 0, + 18, 18, 19, 19, 20, 20, 21, 21, 21, 21, + 21, 21, 21, 22, 22, 22 +}; + +static const short yyr2[] = { 0, + 6, 1, 1, 3, 1, 3, 0, 3, 3, 3, + 3, 3, 3, 1, 3, 3 +}; + +static const short yydefact[] = { 0, + 2, 0, 3, 0, 0, 0, 5, 0, 4, 7, + 0, 0, 14, 1, 6, 0, 0, 0, 0, 0, + 0, 7, 7, 8, 9, 10, 11, 12, 13, 15, + 16, 0, 0, 0 +}; + +static const short yydefgoto[] = { 32, + 4, 8, 13, 14 +}; + +static const short yypact[] = { 5, +-32768, 4,-32768, 3, 8, 15,-32768, 6,-32768, 16, + 17, -8,-32768, 0,-32768, 18, 19, 20, 21, 22, + 23, 16, 16,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 27, 28,-32768 +}; + +static const short yypgoto[] = {-32768, +-32768,-32768, -6,-32768 +}; + + +#define YYLAST 28 + + +static const short yytable[] = { 16, + 17, 18, 19, 20, 21, 1, 3, 5, 2, 6, + 7, 10, 11, 22, 23, 30, 31, 9, 12, 15, + 24, 25, 26, 27, 28, 29, 33, 34 +}; + +static const short yycheck[] = { 8, + 9, 10, 11, 12, 13, 1, 3, 5, 4, 7, + 3, 6, 7, 14, 15, 22, 23, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 0, 0 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/lib/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 2: +#line 63 "icalssyacc.y" +{ + icalparser_clear_flex_input(); + yyclearin; + ; + break;} +case 3: +#line 70 "icalssyacc.y" +{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);; + break;} +case 4: +#line 71 "icalssyacc.y" +{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);; + break;} +case 5: +#line 76 "icalssyacc.y" +{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);; + break;} +case 6: +#line 77 "icalssyacc.y" +{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);; + break;} +case 8: +#line 82 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_EQUAL,yyvsp[0].v_string); ; + break;} +case 9: +#line 84 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_NOTEQUAL,yyvsp[0].v_string); ; + break;} +case 10: +#line 85 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_LESS,yyvsp[0].v_string); ; + break;} +case 11: +#line 86 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_GREATER,yyvsp[0].v_string); ; + break;} +case 12: +#line 87 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_LESSEQUAL,yyvsp[0].v_string); ; + break;} +case 13: +#line 88 "icalssyacc.y" +{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICAL_XLICCOMPARETYPE_GREATEREQUAL,yyvsp[0].v_string); ; + break;} +case 14: +#line 92 "icalssyacc.y" +{move_where(1);; + break;} +case 15: +#line 93 "icalssyacc.y" +{move_where(2);; + break;} +case 16: +#line 94 "icalssyacc.y" +{move_where(3);; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/lib/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 98 "icalssyacc.y" + + +void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, + enum icalparameter_xliccomparetype compare , char* str2) +{ + icalproperty *p; + icalvalue *v; + icalproperty_kind kind; + + kind = icalenum_string_to_property_kind(str1); + + if(kind == ICAL_NO_PROPERTY){ + assert(0); + } + + p = icalproperty_new(kind); + + v = icalvalue_new_text(str2); + + if(v == 0){ + assert(0); + } + + icalproperty_set_value(p,v); + + icalproperty_add_parameter(p,icalparameter_new_xliccomparetype(compare)); + + icalcomponent_add_property(impl->where,p); +} + +void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) +{ + icalproperty *p; + icalproperty_kind pkind; + icalcomponent_kind ckind = ICAL_NO_COMPONENT; + char* c; + char* compstr; + char* propstr; + + /* Is there a period in str1 ? If so, the string specified both a + component and a property*/ + if( (c = strrchr(str1,'.')) != 0){ + compstr = str1; + propstr = c+1; + *c = '\0'; + } else { + compstr = 0; + propstr = str1; + } + + + /* Handle the case where a component was specified */ + if(compstr != 0){ + ckind = icalenum_string_to_component_kind(compstr); + + if(ckind == ICAL_NO_COMPONENT){ + assert(0); + } + } else { + ckind = ICAL_NO_COMPONENT; + } + + + /* If the property was '*', then accept all properties */ + if(strcmp("*",propstr) == 0) { + pkind = ICAL_ANY_PROPERTY; + } else { + pkind = icalenum_string_to_property_kind(str1); + } + + + if(pkind == ICAL_NO_PROPERTY){ + assert(0); + } + + + if(ckind == ICAL_NO_COMPONENT){ + p = icalproperty_new(pkind); + assert(p!=0); + icalcomponent_add_property(impl->select,p); + + } else { + icalcomponent *comp = + icalcomponent_new(ckind); + p = icalproperty_new(pkind); + + assert(p!=0); + + icalcomponent_add_property(comp,p); + icalcomponent_add_component(impl->select,comp); + + } +} + +void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) +{ + icalcomponent *c; + icalcomponent_kind ckind; + + ckind = icalenum_string_to_component_kind(str1); + + if(ckind == ICAL_NO_COMPONENT){ + assert(0); + } + + c = icalcomponent_new(ckind); + + icalcomponent_add_component(impl->from,c); + +} + +void move_where(int w) +{ +} + +void sserror(char *s){ + fprintf(stderr,"Parse error \'%s\'\n", s); +} diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h new file mode 100644 index 0000000000..43423f0d50 --- /dev/null +++ b/libical/src/libicalss/icalssyacc.h @@ -0,0 +1,21 @@ +typedef union { + char* v_string; +} YYSTYPE; +#define STRING 257 +#define SELECT 258 +#define FROM 259 +#define WHERE 260 +#define COMMA 261 +#define EQUALS 262 +#define NOTEQUALS 263 +#define LESS 264 +#define GREATER 265 +#define LESSEQUALS 266 +#define GREATEREQUALS 267 +#define AND 268 +#define OR 269 +#define EOL 270 +#define END 271 + + +extern YYSTYPE sslval; diff --git a/libical/src/libicalss/icalssyacc.y b/libical/src/libicalss/icalssyacc.y new file mode 100644 index 0000000000..e6efe5da1f --- /dev/null +++ b/libical/src/libicalss/icalssyacc.y @@ -0,0 +1,215 @@ +%{ +/* -*- Mode: C -*- + ====================================================================== + FILE: icalssyacc.y + CREATOR: eric 08 Aug 2000 + + DESCRIPTION: + + $Id: icalssyacc.y,v 1.1 2000/12/11 22:06:18 federico Exp $ + $Locker: $ + +(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org + + This program is free software; you can redistribute it and/or modify + it under the terms of either: + + The LGPL as published by the Free Software Foundation, version + 2.1, available at: http://www.fsf.org/copyleft/lesser.html + + Or: + + The Mozilla Public License Version 1.0. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + The Original Code is eric. The Initial Developer of the Original + Code is Eric Busboom + + ======================================================================*/ + +#include +#include /* for strdup() */ +#include /* for SHRT_MAX*/ +#include "ical.h" +#include "pvl.h" +#include "icalgaugeimpl.h" + + +extern struct icalgauge_impl *icalss_yy_gauge; + +void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, + enum icalparameter_xliccomparetype compare , char* str2); +void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); +void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); +void move_where(int w); +void sserror(char *s); /* Don't know why I need this.... */ + + + +%} + +%union { + char* v_string; +} + + +%token STRING +%token SELECT FROM WHERE COMMA EQUALS NOTEQUALS LESS GREATER LESSEQUALS +%token GREATEREQUALS AND OR EOL END + +%% + +query_min: SELECT select_list FROM from_list WHERE where_list + | error { + icalparser_clear_flex_input(); + yyclearin; + } + ; + +select_list: + STRING {ssyacc_add_select(icalss_yy_gauge,$1);} + | select_list COMMA STRING {ssyacc_add_select(icalss_yy_gauge,$3);} + ; + + +from_list: + STRING {ssyacc_add_from(icalss_yy_gauge,$1);} + | from_list COMMA STRING {ssyacc_add_from(icalss_yy_gauge,$3);} + ; + +where_clause: + /* Empty */ + | STRING EQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_EQUAL,$3); } + + | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_NOTEQUAL,$3); } + | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_LESS,$3); } + | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_GREATER,$3); } + | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_LESSEQUAL,$3); } + | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_GREATEREQUAL,$3); } + ; + +where_list: + where_clause {move_where(1);} + | where_list AND where_clause {move_where(2);} + | where_list OR where_clause {move_where(3);} + ; + + +%% + +void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, + enum icalparameter_xliccomparetype compare , char* str2) +{ + icalproperty *p; + icalvalue *v; + icalproperty_kind kind; + + kind = icalenum_string_to_property_kind(str1); + + if(kind == ICAL_NO_PROPERTY){ + assert(0); + } + + p = icalproperty_new(kind); + + v = icalvalue_new_text(str2); + + if(v == 0){ + assert(0); + } + + icalproperty_set_value(p,v); + + icalproperty_add_parameter(p,icalparameter_new_xliccomparetype(compare)); + + icalcomponent_add_property(impl->where,p); +} + +void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) +{ + icalproperty *p; + icalproperty_kind pkind; + icalcomponent_kind ckind = ICAL_NO_COMPONENT; + char* c; + char* compstr; + char* propstr; + + /* Is there a period in str1 ? If so, the string specified both a + component and a property*/ + if( (c = strrchr(str1,'.')) != 0){ + compstr = str1; + propstr = c+1; + *c = '\0'; + } else { + compstr = 0; + propstr = str1; + } + + + /* Handle the case where a component was specified */ + if(compstr != 0){ + ckind = icalenum_string_to_component_kind(compstr); + + if(ckind == ICAL_NO_COMPONENT){ + assert(0); + } + } else { + ckind = ICAL_NO_COMPONENT; + } + + + /* If the property was '*', then accept all properties */ + if(strcmp("*",propstr) == 0) { + pkind = ICAL_ANY_PROPERTY; + } else { + pkind = icalenum_string_to_property_kind(str1); + } + + + if(pkind == ICAL_NO_PROPERTY){ + assert(0); + } + + + if(ckind == ICAL_NO_COMPONENT){ + p = icalproperty_new(pkind); + assert(p!=0); + icalcomponent_add_property(impl->select,p); + + } else { + icalcomponent *comp = + icalcomponent_new(ckind); + p = icalproperty_new(pkind); + + assert(p!=0); + + icalcomponent_add_property(comp,p); + icalcomponent_add_component(impl->select,comp); + + } +} + +void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) +{ + icalcomponent *c; + icalcomponent_kind ckind; + + ckind = icalenum_string_to_component_kind(str1); + + if(ckind == ICAL_NO_COMPONENT){ + assert(0); + } + + c = icalcomponent_new(ckind); + + icalcomponent_add_component(impl->from,c); + +} + +void move_where(int w) +{ +} + +void sserror(char *s){ + fprintf(stderr,"Parse error \'%s\'\n", s); +} -- cgit v1.2.3