aboutsummaryrefslogtreecommitdiffstats
path: root/libical/src
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@src.gnome.org>2000-12-12 06:07:10 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-12-12 06:07:10 +0800
commit1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4 (patch)
treee6bb5fd749b39ef9a0c2f29353986d9e9854c8b6 /libical/src
parent23be726b6025c8e1a656840903da15f7d1f3fb37 (diff)
downloadgsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar.gz
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar.bz2
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar.lz
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar.xz
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.tar.zst
gsoc2013-evolution-1a8645d8b85f46d34ff24f1f7bdc69bfd32282d4.zip
Initial revision
svn path=/trunk/; revision=6915
Diffstat (limited to 'libical/src')
-rw-r--r--libical/src/libical/icalparameter.c.in1234
-rw-r--r--libical/src/libical/icalparameter.h.in57
-rw-r--r--libical/src/libical/icalproperty.c.in560
-rw-r--r--libical/src/libical/icalproperty.h.in57
-rw-r--r--libical/src/libical/icalrestriction.c.in447
-rw-r--r--libical/src/libical/icalvalue.c.in1388
-rw-r--r--libical/src/libical/icalvalue.h.in58
-rw-r--r--libical/src/libicalss/icalclassify.c701
-rw-r--r--libical/src/libicalss/icalclassify.h73
-rw-r--r--libical/src/libicalss/icalcstp.c376
-rw-r--r--libical/src/libicalss/icaldirsetimpl.h47
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h39
-rw-r--r--libical/src/libicalss/icalmessage.c376
-rw-r--r--libical/src/libicalss/icalmessage.h72
-rw-r--r--libical/src/libicalss/icalspanlist.c309
-rw-r--r--libical/src/libicalss/icalspanlist.h54
-rw-r--r--libical/src/libicalss/icalss.h763
-rw-r--r--libical/src/libicalss/icalsslexer.c1702
-rw-r--r--libical/src/libicalss/icalsslexer.l111
-rw-r--r--libical/src/libicalss/icalssutil.c29
-rw-r--r--libical/src/libicalss/icalssutil.h27
-rw-r--r--libical/src/libicalss/icalssyacc.c1154
-rw-r--r--libical/src/libicalss/icalssyacc.h21
-rw-r--r--libical/src/libicalss/icalssyacc.y215
-rw-r--r--libical/src/test/process.c452
-rw-r--r--libical/src/test/testclassify.c157
26 files changed, 10479 insertions, 0 deletions
diff --git a/libical/src/libical/icalparameter.c.in b/libical/src/libical/icalparameter.c.in
new file mode 100644
index 0000000000..0a0efc1332
--- /dev/null
+++ b/libical/src/libical/icalparameter.c.in
@@ -0,0 +1,1234 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: icalderivedparameters.{c,h}
+ CREATOR: eric 09 May 1999
+
+ $Id: icalparameter.c.in,v 1.1 2000/12/11 22:05:59 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 icalderivedparameters.{c,h}
+
+ Contributions from:
+ Graham Davison (g.m.davison@computer.org)
+
+ ======================================================================*/
+#line 29 "icalparameter.c.in"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "icalparameter.h"
+#include "icalproperty.h"
+#include "icalerror.h"
+#include "icalmemory.h"
+
+#include <stdlib.h> /* for malloc() */
+#include <errno.h>
+#include <string.h> /* for memset() */
+
+union icalparameter_impl_data {
+ int v_int;
+ int v_rsvp;
+ icalparameter_cutype v_cutype;
+ icalparameter_encoding v_encoding;
+ icalparameter_fbtype v_fbtype;
+ icalparameter_partstat v_partstat;
+ icalparameter_range v_range;
+ icalparameter_related v_related;
+ icalparameter_reltype v_reltype;
+ icalparameter_role v_role;
+ icalparameter_value v_value;
+ icalparameter_xlicerrortype v_xlicerrortype;
+ icalparameter_xliccomparetype v_xliccomparetype;
+} data;
+
+struct icalparameter_impl
+{
+ icalparameter_kind kind;
+ char id[5];
+ int size;
+ const char* string;
+ const char* x_name;
+ icalproperty* parent;
+
+ union icalparameter_impl_data data;
+};
+
+struct icalparameter_impl* icalparameter_new_impl(icalparameter_kind kind)
+{
+ struct icalparameter_impl* v;
+
+ if ( ( v = (struct icalparameter_impl*)
+ malloc(sizeof(struct icalparameter_impl))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ strcpy(v->id,"para");
+
+ v->kind = kind;
+ v->size = 0;
+ v->string = 0;
+ v->x_name = 0;
+ v->parent = 0;
+ memset(&(v->data),0,sizeof(v->data));
+
+ return v;
+}
+
+icalparameter*
+icalparameter_new (icalparameter_kind kind)
+{
+ struct icalparameter_impl* v = icalparameter_new_impl(kind);
+
+ return (icalparameter*) v;
+
+}
+
+icalparameter*
+icalparameter_new_clone(icalparameter* param)
+{
+ struct icalparameter_impl *old;
+ struct icalparameter_impl *new;
+
+ old = (struct icalparameter_impl *)param;
+ new = icalparameter_new_impl(old->kind);
+
+ icalerror_check_arg_rz((param!=0),"param");
+
+ if (new == 0){
+ return 0;
+ }
+
+ memcpy(new,old,sizeof(struct icalparameter_impl));
+
+ if (old->string != 0){
+ new->string = icalmemory_strdup(old->string);
+ if (new->string == 0){
+ icalparameter_free(new);
+ return 0;
+ }
+ }
+
+ if (old->x_name != 0){
+ new->x_name = icalmemory_strdup(old->x_name);
+ if (new->x_name == 0){
+ icalparameter_free(new);
+ return 0;
+ }
+ }
+
+ return new;
+}
+
+#if 1
+/* The following code is meant to replace most of the case-switch
+ statements, but it is still a work in progress */
+struct param_string_map {
+ icalparameter_kind kind;
+ int val; /* Actually, union of several types of enums */
+ const char* str;
+} param_string_map[] =
+{
+ {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_INDIVIDUAL,"INDIVIDUAL"},
+ {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_GROUP,"GROUP"},
+ {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_RESOURCE,"RESOURCE"},
+ {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_ROOM,"ROOM"},
+ {ICAL_CUTYPE_PARAMETER,ICAL_CUTYPE_UNKNOWN,"UNKNOWN"},
+ {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_FREE,"FREE"},
+ {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSY,"BUSY"},
+ {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSYUNAVAILABLE,"BUSYUNAVAILABLE"},
+ {ICAL_FBTYPE_PARAMETER,ICAL_FBTYPE_BUSYTENTATIVE,"BUSYTENTATIVE"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_NEEDSACTION,"NEEDSACTION"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_ACCEPTED,"ACCEPTED"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_DECLINED,"DECLINED"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_TENTATIVE,"TENTATIVE"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_DELEGATED,"DELEGATED"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_COMPLETED,"COMPLETED"},
+ {ICAL_PARTSTAT_PARAMETER,ICAL_PARTSTAT_INPROCESS,"INPROCESS"},
+ {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDPRIOR,"THISANDPRIOR"},
+ {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDFUTURE,"THISANDFUTURE"},
+ {ICAL_RELATED_PARAMETER,ICAL_RELATED_START,"START"},
+ {ICAL_RELATED_PARAMETER,ICAL_RELATED_END,"END"},
+ {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_PARENT,"PARENT"},
+ {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_CHILD,"CHILD"},
+ {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_SIBLING,"SIBLING"},
+ {ICAL_ROLE_PARAMETER,ICAL_ROLE_CHAIR,"CHAIR"},
+ {ICAL_ROLE_PARAMETER,ICAL_ROLE_REQPARTICIPANT,"REQ-PARTICIPANT"},
+ {ICAL_ROLE_PARAMETER,ICAL_ROLE_OPTPARTICIPANT,"OPT-PARTICIPANT"},
+ {ICAL_ROLE_PARAMETER,ICAL_ROLE_NONPARTICIPANT,"NON-PARTICIPANT"},
+ {ICAL_RSVP_PARAMETER,ICAL_RSVP_PARAMETER,"TRUE"},
+ {ICAL_RSVP_PARAMETER,ICAL_RSVP_PARAMETER,"FALSE"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_BINARY,"BINARY"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_BOOLEAN,"BOOLEAN"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_DATE,"DATE"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_DURATION,"DURATION"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_FLOAT,"FLOAT"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_INTEGER,"INTEGER"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_PERIOD,"PERIOD"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_RECUR,"RECUR"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_TEXT,"TEXT"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_TIME,"TIME"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_URI,"URI"},
+ {ICAL_VALUE_PARAMETER,ICAL_VALUE_XNAME,"ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_COMPONENTPARSEERROR,"COMPONENT_PARSE_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PROPERTYPARSEERROR,"PROPERTY_PARSE_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR,"PARAMETER_NAME_PARSE_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR,"PARAMETER_VALUE_PARSE_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_VALUEPARSEERROR,"VALUE_PARSE_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_INVALIDITIP,"INVALID_ITIP"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_UNKVCALPROP,"UNKNOWN_VCAL_PROP_ERROR"},
+ {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_MIMEPARSEERROR,"MIME_PARSE_ERROR"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_EQUAL,"EQUAL"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_NOTEQUAL,"NOTEQUAL"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESS,"LESS"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATER,"GREATER"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESSEQUAL,"LESSEQUAL"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATEREQUAL,"GREATEREQUAL"},
+ {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_REGEX,"REGEX"},
+ {ICAL_NO_PARAMETER,0,""},
+
+};
+
+void icalparameter_set_impl_data(icalparameter_kind kind,
+ union icalparameter_impl_data *data,
+ int value)
+{
+
+ switch (kind){
+ case ICAL_CUTYPE_PARAMETER:
+ data->v_cutype=value; break;
+ case ICAL_FBTYPE_PARAMETER:
+ data->v_fbtype=value; break;
+ case ICAL_PARTSTAT_PARAMETER:
+ data->v_partstat=value; break;
+ case ICAL_RANGE_PARAMETER:
+ data->v_range=value; break;
+ case ICAL_RELATED_PARAMETER:
+ data->v_related=value; break;
+ case ICAL_RELTYPE_PARAMETER:
+ data->v_reltype=value; break;
+ case ICAL_ROLE_PARAMETER:
+ data->v_role=value; break;
+ case ICAL_RSVP_PARAMETER:
+ data->v_rsvp=value; break;
+ case ICAL_VALUE_PARAMETER:
+ data->v_value=value; break;
+ case ICAL_XLICERRORTYPE_PARAMETER:
+ data->v_xlicerrortype=value; break;
+ case ICAL_XLICCOMPARETYPE_PARAMETER:
+ data->v_xliccomparetype=value; break;
+ default:
+ }
+}
+
+icalparameter* icalparameter_new_from_string_test(icalparameter_kind kind, char* val)
+{
+ int i =0;
+ icalparameter* param=0;
+
+ icalerror_check_arg_rz((val!=0),"val");
+
+ switch(kind){
+
+ /* These are all string values parameters */
+ case ICAL_SENTBY_PARAMETER:
+ case ICAL_TZID_PARAMETER:
+ case ICAL_X_PARAMETER:
+ case ICAL_FMTTYPE_PARAMETER:
+ case ICAL_LANGUAGE_PARAMETER:
+ case ICAL_MEMBER_PARAMETER:
+ case ICAL_DELEGATEDFROM_PARAMETER:
+ case ICAL_DELEGATEDTO_PARAMETER:
+ case ICAL_DIR_PARAMETER:
+ case ICAL_ALTREP_PARAMETER:
+ case ICAL_CN_PARAMETER:
+ {
+ struct icalparameter_impl *impl = icalparameter_new_impl(kind);
+ if (impl == 0) {
+ return 0;
+ }
+ ((struct icalparameter_impl*)param)->string =
+ icalmemory_strdup(val);
+
+ return (icalparameter*) impl;
+
+ }
+
+ case ICAL_NO_PARAMETER:
+ case ICAL_ANY_PARAMETER:
+ {
+ }
+
+ default: {
+ int found = 0;
+ /* All other types are enumerated */
+ for(i = 0; param_string_map[i].kind != ICAL_NO_PARAMETER; i++){
+
+ if(kind == param_string_map[i].kind &&
+ strcmp(val,param_string_map[i].str) == 0){
+
+ struct icalparameter_impl *impl =
+ icalparameter_new_impl(kind);
+ found = 1;
+
+ icalparameter_set_impl_data(kind,&impl->data,
+ param_string_map[i].val);
+
+ return (icalparameter*)impl;
+ }
+ }
+
+ /* Didn't find the standard enumerated type, so it must be
+ an X parameter */
+ if (found ==0) {
+ icalparameter *param = icalparameter_new(kind);
+
+ icalparameter_set_xvalue(param,val);
+
+ return param;
+
+ }
+ }
+ }
+
+ return 0;
+}
+
+#endif
+
+
+icalparameter* icalparameter_new_from_string(icalparameter_kind kind, char* val)
+{
+
+ icalparameter* param=0;
+
+ icalerror_check_arg_rz((val!=0),"val");
+
+ switch (kind) {
+ case ICAL_ALTREP_PARAMETER:
+ {
+ param = icalparameter_new_altrep(val);
+
+ break;
+ }
+ case ICAL_CN_PARAMETER:
+ {
+ param = icalparameter_new_cn(val);
+
+ break;
+ }
+ case ICAL_CUTYPE_PARAMETER:
+ {
+ if(strcmp(val,"INDIVIDUAL") == 0){
+ param = icalparameter_new_cutype(ICAL_CUTYPE_INDIVIDUAL);
+ }
+ else if(strcmp(val,"GROUP") == 0){
+ param = icalparameter_new_cutype(ICAL_CUTYPE_GROUP);
+ }
+ else if(strcmp(val,"RESOURCE") == 0){
+ param = icalparameter_new_cutype(ICAL_CUTYPE_RESOURCE);
+ }
+ else if(strcmp(val,"ROOM") == 0){
+ param = icalparameter_new_cutype(ICAL_CUTYPE_ROOM);
+ }
+ else if(strcmp(val,"UNKNOWN") == 0){
+ param = icalparameter_new_cutype(ICAL_CUTYPE_UNKNOWN);
+ }
+ else {
+ param = icalparameter_new_cutype(ICAL_CUTYPE_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+
+ case ICAL_DELEGATEDFROM_PARAMETER:
+ {
+ param = icalparameter_new_delegatedfrom(val);
+
+ break;
+ }
+ case ICAL_DELEGATEDTO_PARAMETER:
+ {
+ param = icalparameter_new_delegatedto(val);
+
+ break;
+ }
+ case ICAL_DIR_PARAMETER:
+ {
+ param = icalparameter_new_dir(val);
+
+ break;
+ }
+ case ICAL_ENCODING_PARAMETER:
+ {
+ if(strcmp(val,"BIT8") == 0){
+ param = icalparameter_new_encoding(ICAL_ENCODING_8BIT);
+ }
+ else if(strcmp(val,"BASE64") == 0){
+ param = icalparameter_new_encoding(ICAL_ENCODING_BASE64);
+ }
+ else {
+ param = icalparameter_new_encoding(ICAL_ENCODING_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+ case ICAL_FBTYPE_PARAMETER:
+ {
+ if(strcmp(val,"FREE") == 0){
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_FREE);
+ }
+ else if(strcmp(val,"BUSY") == 0){
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSY);
+ }
+ else if(strcmp(val,"BUSYUNAVAILABLE") == 0){
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSYUNAVAILABLE);
+ }
+ else if(strcmp(val,"BUSYTENTATIVE") == 0){
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSYTENTATIVE);
+ }
+ else {
+ param = icalparameter_new_fbtype(ICAL_FBTYPE_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+ case ICAL_FMTTYPE_PARAMETER:
+ {
+ param = icalparameter_new_fmttype(val);
+ break;
+ }
+ case ICAL_LANGUAGE_PARAMETER:
+ {
+ param = icalparameter_new_language(val);
+
+ break;
+ }
+ case ICAL_MEMBER_PARAMETER:
+ {
+ param = icalparameter_new_member(val);
+
+ break;
+ }
+ case ICAL_PARTSTAT_PARAMETER:
+ {
+ if(strcmp(val,"NEEDSACTION") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_NEEDSACTION);
+ }
+ else if(strcmp(val,"ACCEPTED") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_ACCEPTED);
+ }
+ else if(strcmp(val,"DECLINED") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_DECLINED);
+ }
+ else if(strcmp(val,"TENTATIVE") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_TENTATIVE);
+ }
+ else if(strcmp(val,"DELEGATED") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_DELEGATED);
+ }
+ else if(strcmp(val,"COMPLETED") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_COMPLETED);
+ }
+ else if(strcmp(val,"INPROCESS") == 0){
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_INPROCESS);
+ }
+ else {
+ param = icalparameter_new_partstat(ICAL_PARTSTAT_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+ case ICAL_RANGE_PARAMETER:
+ {
+ if(strcmp(val,"THISANDFUTURE") == 0){
+ param = icalparameter_new_range(ICAL_RANGE_THISANDFUTURE);
+ }
+ else if(strcmp(val,"THISANDPRIOR") == 0){
+ param = icalparameter_new_range(ICAL_RANGE_THISANDPRIOR);
+ }
+
+ break;
+ }
+ case ICAL_RELATED_PARAMETER:
+ {
+ if(strcmp(val,"START") == 0){
+ param = icalparameter_new_related(ICAL_RELATED_START);
+ }
+ else if(strcmp(val,"END") == 0){
+ param = icalparameter_new_related(ICAL_RELATED_END);
+ }
+
+ break;
+ }
+ case ICAL_RELTYPE_PARAMETER:
+ {
+ if(strcmp(val,"PARENT") == 0){
+ param = icalparameter_new_reltype(ICAL_RELTYPE_PARENT);
+ }
+ else if(strcmp(val,"CHILD") == 0){
+ param = icalparameter_new_reltype(ICAL_RELTYPE_CHILD);
+ }
+ else if(strcmp(val,"SIBLING") == 0){
+ param = icalparameter_new_reltype(ICAL_RELTYPE_SIBLING);
+ }
+ else {
+ param = icalparameter_new_reltype(ICAL_RELTYPE_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+ case ICAL_ROLE_PARAMETER:
+ {
+ if(strcmp(val,"CHAIR") == 0){
+ param = icalparameter_new_role(ICAL_ROLE_CHAIR);
+ }
+ else if(strcmp(val,"REQ-PARTICIPANT") == 0){
+ param = icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT);
+ }
+ else if(strcmp(val,"OPT-PARTICIPANT") == 0){
+ param = icalparameter_new_role(ICAL_ROLE_OPTPARTICIPANT);
+ }
+ else if(strcmp(val,"NON-PARTICIPANT") == 0){
+ param = icalparameter_new_role(ICAL_ROLE_NONPARTICIPANT);
+ }
+ else {
+ param = icalparameter_new_role(ICAL_ROLE_XNAME);
+ icalparameter_set_xvalue(param,val);
+ }
+ break;
+ }
+ case ICAL_RSVP_PARAMETER:
+ {
+ if(strcmp(val,"TRUE") == 0){
+ param = icalparameter_new_rsvp(1);
+ }
+ else if(strcmp(val,"FALSE") == 0){
+ param = icalparameter_new_rsvp(0);
+ }
+
+ break;
+ }
+ case ICAL_SENTBY_PARAMETER:
+ {
+ param = icalparameter_new_sentby(val);
+
+ break;
+ }
+ case ICAL_TZID_PARAMETER:
+ {
+ param = icalparameter_new_tzid(val);
+
+ break;
+ }
+ case ICAL_VALUE_PARAMETER:
+ {
+ if(strcmp(val,"BINARY") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_BINARY);
+ }
+ else if(strcmp(val,"BOOLEAN") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_BOOLEAN);
+ }
+ else if(strcmp(val,"CAL-ADDRESS") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_CALADDRESS);
+ }
+ else if(strcmp(val,"DATE") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_DATE);
+ }
+ else if(strcmp(val,"DATE-TIME") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_DATETIME);
+ }
+ else if(strcmp(val,"DURATION") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_DURATION);
+ }
+ else if(strcmp(val,"FLOAT") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_FLOAT);
+ }
+ else if(strcmp(val,"INTEGER") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_INTEGER);
+ }
+ else if(strcmp(val,"PERIOD") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_PERIOD);
+ }
+ else if(strcmp(val,"RECUR") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_RECUR);
+ }
+ else if(strcmp(val,"TEXT") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_TEXT);
+ }
+ else if(strcmp(val,"TIME") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_TIME);
+ }
+ else if(strcmp(val,"URI") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_URI);
+ }
+ else if(strcmp(val,"UTC-OFFSET") == 0){
+ param = icalparameter_new_value(ICAL_VALUE_UTCOFFSET);
+ }
+ else {
+ param = 0;
+ }
+ break;
+ }
+ case ICAL_XLICERRORTYPE_PARAMETER:
+ {
+
+ if(strcmp(val,"COMPONENT_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
+ }
+ else if(strcmp(val,"PROPERTY_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);
+ }
+ else if(strcmp(val,"PARAMETER_NAME_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
+ }
+ else if(strcmp(val,"PARAMETER_VALUE_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
+ }
+ else if(strcmp(val,"VALUE_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_VALUEPARSEERROR);
+ }
+ else if(strcmp(val,"INVALID_ITIP") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP);
+ }
+ else if(strcmp(val,"MIME_PARSE_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_MIMEPARSEERROR);
+ }
+ else if(strcmp(val,"UNKNOWN_VCAL_PROP_ERROR") == 0){
+ param = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_UNKVCALPROP);
+ }
+ break;
+ }
+
+ case ICAL_XLICCOMPARETYPE_PARAMETER:
+ {
+
+ if(strcmp(val,"EQUAL") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL);
+ }
+ else if(strcmp(val,"NOTEQUAL") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_NOTEQUAL);
+ }
+ else if(strcmp(val,"LESS") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_LESS);
+ }
+ else if(strcmp(val,"GREATER") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_GREATER);
+ }
+ else if(strcmp(val,"LESSEQUAL") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_LESSEQUAL);
+ }
+ else if(strcmp(val,"GREATEREQUAL") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_GREATEREQUAL);
+ }
+ else if(strcmp(val,"REGEX") == 0){
+ param = icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_REGEX);
+ } else {
+ param = 0;
+ }
+ break;
+ }
+
+
+ case ICAL_X_PARAMETER:
+ {
+ param = icalparameter_new(ICAL_FBTYPE_PARAMETER);
+ icalparameter_set_xvalue(param,val);
+ break;
+ }
+
+ case ICAL_NO_PARAMETER:
+ default:
+ {
+ return 0;
+ }
+
+
+ }
+
+ return param;
+}
+
+void
+icalparameter_free (icalparameter* parameter)
+{
+ struct icalparameter_impl * impl;
+
+ impl = (struct icalparameter_impl*)parameter;
+
+/* HACK. This always triggers, even when parameter is non-zero
+ icalerror_check_arg_rv((parameter==0),"parameter");*/
+
+
+#ifdef ICAL_FREE_ON_LIST_IS_ERROR
+ icalerror_assert( (impl->parent ==0),"Tried to free a parameter that is still attached to a component. ");
+
+#else
+ if(impl->parent !=0){
+ return;
+ }
+#endif
+
+
+ if (impl->string != 0){
+ free ((void*)impl->string);
+ }
+
+ if (impl->x_name != 0){
+ free ((void*)impl->x_name);
+ }
+
+ memset(impl,0,sizeof(impl));
+
+ impl->parent = 0;
+ impl->id[0] = 'X';
+ free(impl);
+}
+
+
+char no_parameter[]="Error: No Parameter";
+char*
+icalparameter_as_ical_string (icalparameter* parameter)
+{
+ struct icalparameter_impl* impl;
+ size_t buf_size = 1024;
+ char* buf;
+ char* buf_ptr;
+ char *out_buf;
+ const char *kind_string;
+
+ char tend[1024]; /* HACK . Should be using memory buffer ring */
+
+ icalerror_check_arg_rz( (parameter!=0), "parameter");
+
+ /* Create new buffer that we can append names, parameters and a
+ value to, and reallocate as needed. Later, this buffer will be
+ copied to a icalmemory_tmp_buffer, which is managed internally
+ by libical, so it can be given to the caller without fear of
+ the caller forgetting to free it */
+
+ buf = icalmemory_new_buffer(buf_size);
+ buf_ptr = buf;
+ impl = (struct icalparameter_impl*)parameter;
+
+ kind_string = icalenum_parameter_kind_to_string(impl->kind);
+
+ if (impl->kind == ICAL_NO_PARAMETER ||
+ impl->kind == ICAL_ANY_PARAMETER ||
+ kind_string == 0)
+ {
+ icalerror_set_errno(ICAL_BADARG_ERROR);
+ return 0;
+ }
+
+ /* Put the parameter name into the string */
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, "=");
+
+ switch (impl->kind) {
+ case ICAL_CUTYPE_PARAMETER:
+ {
+ switch (impl->data.v_cutype) {
+ case ICAL_CUTYPE_INDIVIDUAL: {
+ strcpy(tend,"INDIVIDUAL");break;
+ }
+ case ICAL_CUTYPE_GROUP:{
+ strcpy(tend,"GROUP");break;
+ }
+ case ICAL_CUTYPE_RESOURCE: {
+ strcpy(tend,"RESOURCE");break;
+ }
+ case ICAL_CUTYPE_ROOM:{
+ strcpy(tend,"ROOM");break;
+ }
+ case ICAL_CUTYPE_UNKNOWN:{
+ strcpy(tend,"UNKNOWN");break;
+ }
+ case ICAL_CUTYPE_XNAME:{
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+
+ }
+ case ICAL_ENCODING_PARAMETER:
+ {
+ switch (impl->data.v_encoding) {
+ case ICAL_ENCODING_8BIT: {
+ strcpy(tend,"8BIT");break;
+ }
+ case ICAL_ENCODING_BASE64:{
+ strcpy(tend,"BASE64");break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+
+ case ICAL_FBTYPE_PARAMETER:
+ {
+ switch (impl->data.v_fbtype) {
+ case ICAL_FBTYPE_FREE:{
+ strcpy(tend,"FREE");break;
+ }
+ case ICAL_FBTYPE_BUSY: {
+ strcpy(tend,"BUSY");break;
+ }
+ case ICAL_FBTYPE_BUSYUNAVAILABLE:{
+ strcpy(tend,"BUSYUNAVAILABLE");break;
+ }
+ case ICAL_FBTYPE_BUSYTENTATIVE:{
+ strcpy(tend,"BUSYTENTATIVE");break;
+ }
+ case ICAL_FBTYPE_XNAME:{
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+
+ }
+ case ICAL_PARTSTAT_PARAMETER:
+ {
+ switch (impl->data.v_partstat) {
+ case ICAL_PARTSTAT_NEEDSACTION: {
+ strcpy(tend,"NEEDSACTION");break;
+ }
+ case ICAL_PARTSTAT_ACCEPTED: {
+ strcpy(tend,"ACCEPTED");break;
+ }
+ case ICAL_PARTSTAT_DECLINED:{
+ strcpy(tend,"DECLINED");break;
+ }
+ case ICAL_PARTSTAT_TENTATIVE:{
+ strcpy(tend,"TENTATIVE");break;
+ }
+ case ICAL_PARTSTAT_DELEGATED:{
+ strcpy(tend,"DELEGATED");break;
+ }
+ case ICAL_PARTSTAT_COMPLETED:{
+ strcpy(tend,"COMPLETED");break;
+ }
+ case ICAL_PARTSTAT_INPROCESS:{
+ strcpy(tend,"INPROCESS");break;
+ }
+ case ICAL_PARTSTAT_XNAME:{
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+
+ }
+ case ICAL_RANGE_PARAMETER:
+ {
+ switch (impl->data.v_range) {
+ case ICAL_RANGE_THISANDPRIOR: {
+ strcpy(tend,"THISANDPRIOR");break;
+ }
+ case ICAL_RANGE_THISANDFUTURE: {
+ strcpy(tend,"THISANDFUTURE");break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+ case ICAL_RELATED_PARAMETER:
+ {
+ switch (impl->data.v_related) {
+ case ICAL_RELATED_START: {
+ strcpy(tend,"START");break;
+ }
+ case ICAL_RELATED_END: {
+ strcpy(tend,"END");break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+ case ICAL_RELTYPE_PARAMETER:
+ {
+ switch (impl->data.v_reltype) {
+ case ICAL_RELTYPE_PARENT: {
+ strcpy(tend,"PARENT");break;
+ }
+ case ICAL_RELTYPE_CHILD:{
+ strcpy(tend,"CHILD");break;
+ }
+ case ICAL_RELTYPE_SIBLING:{
+ strcpy(tend,"SIBLING");break;
+ }
+ case ICAL_RELTYPE_XNAME:{
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+ case ICAL_ROLE_PARAMETER:
+ {
+ switch (impl->data.v_role) {
+ case ICAL_ROLE_CHAIR: {
+ strcpy(tend,"CHAIR");break;
+ }
+ case ICAL_ROLE_REQPARTICIPANT: {
+ strcpy(tend,"REQ-PARTICIPANT");break;
+ }
+ case ICAL_ROLE_OPTPARTICIPANT: {
+ strcpy(tend,"OPT-PARTICIPANT");break;
+ }
+ case ICAL_ROLE_NONPARTICIPANT: {
+ strcpy(tend,"NON-PARTICIPANT");break;
+ }
+ case ICAL_ROLE_XNAME:{
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+ case ICAL_RSVP_PARAMETER:
+ {
+ switch (impl->data.v_rsvp) {
+ case 1: {
+ strcpy(tend,"TRUE");break;
+ }
+ case 0: {
+ strcpy(tend,"FALSE");break;
+ }
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+ case ICAL_VALUE_PARAMETER:
+ {
+ switch (impl->data.v_value) {
+ case ICAL_VALUE_BINARY: {
+ strcpy(tend,"BINARY");break;
+ }
+ case ICAL_VALUE_BOOLEAN: {
+ strcpy(tend,"BOOLEAN");break;
+ }
+ case ICAL_VALUE_CALADDRESS: {
+ strcpy(tend,"CAL-ADDRESS");break;
+ }
+ case ICAL_VALUE_DATE: {
+ strcpy(tend,"DATE");break;
+ }
+ case ICAL_VALUE_DATETIME: {
+ strcpy(tend,"DATE-TIME");break;
+ }
+ case ICAL_VALUE_DURATION: {
+ strcpy(tend,"DURATION");break;
+ }
+ case ICAL_VALUE_FLOAT: {
+ strcpy(tend,"FLOAT");break;
+ }
+ case ICAL_VALUE_INTEGER: {
+ strcpy(tend,"INTEGER");break;
+ }
+ case ICAL_VALUE_PERIOD: {
+ strcpy(tend,"PERIOD");break;
+ }
+ case ICAL_VALUE_RECUR: {
+ strcpy(tend,"RECUR");break;
+ }
+ case ICAL_VALUE_TEXT: {
+ strcpy(tend,"TEXT");break;
+ }
+ case ICAL_VALUE_TIME: {
+ strcpy(tend,"TIME");break;
+ }
+ case ICAL_VALUE_URI: {
+ strcpy(tend,"URI");break;
+ }
+ case ICAL_VALUE_UTCOFFSET: {
+ strcpy(tend,"UTC-OFFSET");break;
+ }
+ case ICAL_VALUE_XNAME: {
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ }
+ default:{
+ strcpy(tend,"ERROR");
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ }
+ break;
+ }
+
+
+ case ICAL_XLICERRORTYPE_PARAMETER:
+ {
+ switch (impl->data.v_xlicerrortype) {
+ case ICAL_XLICERRORTYPE_COMPONENTPARSEERROR:
+ {
+ strcpy(tend,"COMPONENT_PARSE_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_PROPERTYPARSEERROR:
+ {
+ strcpy(tend,"PROPERTY_PARSE_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR:
+ {
+ strcpy(tend,"PARAMETER_NAME_PARSE_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR:
+ {
+ strcpy(tend,"PARAMETER_VALUE_PARSE_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_VALUEPARSEERROR:
+ {
+ strcpy(tend,"VALUE_PARSE_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_INVALIDITIP:
+ {
+ strcpy(tend,"INVALID_ITIP");break;
+ }
+ case ICAL_XLICERRORTYPE_UNKVCALPROP:
+ {
+ strcpy(tend,"UNKNOWN_VCAL_PROP_ERROR");break;
+ }
+ case ICAL_XLICERRORTYPE_MIMEPARSEERROR:
+ {
+ strcpy(tend,"MIME_PARSE_ERROR");break;
+ }
+ }
+ break;
+ }
+
+ case ICAL_XLICCOMPARETYPE_PARAMETER:
+ {
+ switch (impl->data.v_xliccomparetype) {
+ case ICAL_XLICCOMPARETYPE_EQUAL:
+ {
+ strcpy(tend,"EQUAL");break;
+ }
+ case ICAL_XLICCOMPARETYPE_NOTEQUAL:
+ {
+ strcpy(tend,"NOTEQUAL");break;
+ }
+ case ICAL_XLICCOMPARETYPE_LESS:
+ {
+ strcpy(tend,"LESS");break;
+ }
+ case ICAL_XLICCOMPARETYPE_GREATER:
+ {
+ strcpy(tend,"GREATER");break;
+ }
+ case ICAL_XLICCOMPARETYPE_LESSEQUAL:
+ {
+ strcpy(tend,"LESSEQUAL");break;
+ }
+ case ICAL_XLICCOMPARETYPE_GREATEREQUAL:
+ {
+ strcpy(tend,"GREATEREQUAL");break;
+ }
+ case ICAL_XLICCOMPARETYPE_REGEX:
+ {
+ strcpy(tend,"REGEX");break;
+ }
+ break;
+ }
+
+ default:{
+ icalerror_set_errno(ICAL_BADARG_ERROR);break;
+ }
+ break;
+ }
+
+
+ case ICAL_SENTBY_PARAMETER:
+ case ICAL_TZID_PARAMETER:
+ case ICAL_X_PARAMETER:
+ case ICAL_FMTTYPE_PARAMETER:
+ case ICAL_LANGUAGE_PARAMETER:
+ case ICAL_MEMBER_PARAMETER:
+ case ICAL_DELEGATEDFROM_PARAMETER:
+ case ICAL_DELEGATEDTO_PARAMETER:
+ case ICAL_DIR_PARAMETER:
+ case ICAL_ALTREP_PARAMETER:
+ case ICAL_CN_PARAMETER:
+ {
+ if (impl->string == 0){ return no_parameter;}
+ strcpy(tend,impl->string);break;
+ break;
+ }
+
+ case ICAL_NO_PARAMETER:
+ case ICAL_ANY_PARAMETER:
+ {
+ /* These are actually handled before the case/switch
+ clause */
+ }
+
+ }
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, tend);
+
+ /* Now, copy the buffer to a tmp_buffer, which is safe to give to
+ the caller without worring about de-allocating it. */
+
+
+ out_buf = icalmemory_tmp_buffer(strlen(buf));
+ strcpy(out_buf, buf);
+
+ icalmemory_free_buffer(buf);
+
+ return out_buf;
+
+}
+
+
+int
+icalparameter_is_valid (icalparameter* parameter);
+
+
+icalparameter_kind
+icalparameter_isa (icalparameter* parameter)
+{
+ if(parameter == 0){
+ return ICAL_NO_PARAMETER;
+ }
+
+ return ((struct icalparameter_impl *)parameter)->kind;
+}
+
+
+int
+icalparameter_isa_parameter (void* parameter)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl *)parameter;
+
+ if (parameter == 0){
+ return 0;
+ }
+
+ if (strcmp(impl->id,"para") == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+void
+icalparameter_set_xname (icalparameter* param, const char* v)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+ icalerror_check_arg_rv( (param!=0),"param");
+ icalerror_check_arg_rv( (v!=0),"v");
+
+ if (impl->x_name != 0){
+ free((void*)impl->x_name);
+ }
+
+ impl->x_name = icalmemory_strdup(v);
+
+ if (impl->x_name == 0){
+ errno = ENOMEM;
+ }
+
+}
+
+const char*
+icalparameter_get_xname (icalparameter* param)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+ icalerror_check_arg_rz( (param!=0),"param");
+
+ return impl->x_name;
+}
+
+void
+icalparameter_set_xvalue (icalparameter* param, const char* v)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+
+ icalerror_check_arg_rv( (param!=0),"param");
+ icalerror_check_arg_rv( (v!=0),"v");
+
+ if (impl->string != 0){
+ free((void*)impl->string);
+ }
+
+ impl->string = icalmemory_strdup(v);
+
+ if (impl->string == 0){
+ errno = ENOMEM;
+ }
+
+}
+
+const char*
+icalparameter_get_xvalue (icalparameter* param)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+
+ icalerror_check_arg_rz( (param!=0),"param");
+
+ return impl->string;
+
+}
+
+void icalparameter_set_parent(icalparameter* param,
+ icalproperty* property)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+
+ icalerror_check_arg_rv( (param!=0),"param");
+
+ impl->parent = property;
+}
+
+icalproperty* icalparameter_get_parent(icalparameter* param)
+{
+ struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
+
+ icalerror_check_arg_rv( (param!=0),"param");
+
+ return impl->parent;
+}
+
+
+/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalparameter.h.in b/libical/src/libical/icalparameter.h.in
new file mode 100644
index 0000000000..d3bd4c963c
--- /dev/null
+++ b/libical/src/libical/icalparameter.h.in
@@ -0,0 +1,57 @@
+/* -*- Mode: C -*- */
+/*======================================================================
+ FILE: icalparam.h
+ CREATOR: eric 20 March 1999
+
+
+ $Id: icalparameter.h.in,v 1.1 2000/12/11 22:05:59 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 icalparam.h
+
+ ======================================================================*/
+
+#ifndef ICALPARAM_H
+#define ICALPARAM_H
+
+#include "icalenums.h"
+
+typedef void icalparameter;
+
+icalparameter* icalparameter_new(icalparameter_kind kind);
+icalparameter* icalparameter_new_clone(icalparameter* p);
+icalparameter* icalparameter_new_from_string(icalparameter_kind kind, char* value);
+
+void icalparameter_free(icalparameter* parameter);
+
+char* icalparameter_as_ical_string(icalparameter* parameter);
+
+int icalparameter_is_valid(icalparameter* parameter);
+
+icalparameter_kind icalparameter_isa(icalparameter* parameter);
+
+int icalparameter_isa_parameter(void* param);
+
+/* Acess the name of an X parameer */
+void icalparameter_set_xname (icalparameter* param, const char* v);
+const char* icalparameter_get_xname(icalparameter* param);
+void icalparameter_set_xvalue (icalparameter* param, const char* v);
+const char* icalparameter_get_xvalue(icalparameter* param);
+
+
+/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalproperty.c.in b/libical/src/libical/icalproperty.c.in
new file mode 100644
index 0000000000..12a9ec4afa
--- /dev/null
+++ b/libical/src/libical/icalproperty.c.in
@@ -0,0 +1,560 @@
+/* -*- Mode: C -*- */
+
+/*======================================================================
+ FILE: icalproperty.c
+ CREATOR: eric 28 April 1999
+
+ $Id: icalproperty.c.in,v 1.1 2000/12/11 22:05:59 federico Exp $
+
+
+ (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 icalproperty.c
+
+======================================================================*/
+#line 27 "icalproperty.c.in"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "icalproperty.h"
+#include "icalcomponent.h"
+#include "pvl.h"
+#include "icalenums.h"
+#include "icalerror.h"
+#include "icalmemory.h"
+
+#include <string.h> /* For icalmemory_strdup, rindex */
+#include <assert.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h> /* for printf */
+#include <stdarg.h> /* for va_list, va_start, etc. */
+
+#define TMP_BUF_SIZE 1024
+
+/* Private routines for icalproperty */
+void icalvalue_set_parent(icalvalue* value,
+ icalproperty* property);
+icalproperty* icalvalue_get_parent(icalvalue* value);
+
+void icalparameter_set_parent(icalparameter* param,
+ icalproperty* property);
+icalproperty* icalparameter_get_parent(icalparameter* value);
+
+
+void icalproperty_set_x_name(icalproperty* prop, char* name);
+
+struct icalproperty_impl
+{
+ char id[5];
+ icalproperty_kind kind;
+ char* x_name;
+ pvl_list parameters;
+ pvl_elem parameter_iterator;
+ icalvalue* value;
+ icalcomponent *parent;
+};
+
+void icalproperty_add_parameters(struct icalproperty_impl *impl,va_list args)
+{
+
+ void* vp;
+
+ while((vp = va_arg(args, void*)) != 0) {
+
+ if (icalvalue_isa_value(vp) != 0 ){
+ } else if (icalparameter_isa_parameter(vp) != 0 ){
+
+ icalproperty_add_parameter((icalproperty*)impl,
+ (icalparameter*)vp);
+ } else {
+ assert(0);
+ }
+
+ }
+
+
+}
+
+
+struct icalproperty_impl*
+icalproperty_new_impl (icalproperty_kind kind)
+{
+ struct icalproperty_impl* prop;
+
+ if ( ( prop = (struct icalproperty_impl*)
+ malloc(sizeof(struct icalproperty_impl))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ strcpy(prop->id,"prop");
+
+ prop->kind = kind;
+ prop->parameters = pvl_newlist();
+ prop->parameter_iterator = 0;
+ prop->value = 0;
+ prop->x_name = 0;
+ prop->parent = 0;
+
+ return prop;
+}
+
+
+icalproperty*
+icalproperty_new (icalproperty_kind kind)
+{
+ icalproperty *prop = (icalproperty*)icalproperty_new_impl(kind);
+
+ return prop;
+}
+
+
+icalproperty*
+icalproperty_new_clone(icalproperty* prop)
+{
+ struct icalproperty_impl *old = (struct icalproperty_impl*)prop;
+ struct icalproperty_impl *new = icalproperty_new_impl(old->kind);
+ pvl_elem p;
+
+ icalerror_check_arg_rz((prop!=0),"Prop");
+ icalerror_check_arg_rz((old!=0),"old");
+ icalerror_check_arg_rz((new!=0),"new");
+
+ if (old->value !=0) {
+ new->value = icalvalue_new_clone(old->value);
+ }
+
+ if (old->x_name != 0) {
+
+ new->x_name = icalmemory_strdup(old->x_name);
+
+ if (new->x_name == 0) {
+ icalproperty_free(new);
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+ }
+
+ for(p=pvl_head(old->parameters);p != 0; p = pvl_next(p)){
+ icalparameter *param = icalparameter_new_clone(pvl_data(p));
+
+ if (param == 0){
+ icalproperty_free(new);
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ pvl_push(new->parameters,param);
+
+ }
+
+ return new;
+
+}
+
+/* This one works a little differently from the other *_from_string
+ routines; the string input is the name of the property, not the
+ data associated with the property, as it is in
+ icalvalue_from_string. All of the parsing associated with
+ properties is driven by routines in icalparse.c */
+
+icalproperty* icalproperty_new_from_string(char* str)
+{
+ icalproperty_kind kind;
+
+ icalerror_check_arg_rz( (str!=0),"str");
+
+ kind = icalenum_string_to_property_kind(str);
+
+ if (kind == ICAL_NO_PROPERTY){
+
+ if( str[0] == 'X' && str[1] == '-'){
+ icalproperty *p = icalproperty_new(ICAL_X_PROPERTY);
+ icalproperty_set_x_name(p,str);
+ return p;
+ } else {
+ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
+ return 0;
+ }
+
+ } else {
+ return icalproperty_new(kind);
+ }
+}
+
+void
+icalproperty_free (icalproperty* prop)
+{
+ struct icalproperty_impl *p;
+
+ icalparameter* param;
+
+ icalerror_check_arg_rv((prop!=0),"prop");
+
+ p = (struct icalproperty_impl*)prop;
+
+#ifdef ICAL_FREE_ON_LIST_IS_ERROR
+ icalerror_assert( (p->parent ==0),"Tried to free a property that is still attached to a component. ");
+
+#else
+ if(p->parent !=0){
+ return;
+ }
+#endif
+
+ if (p->value != 0){
+ icalvalue_set_parent(p->value,0);
+ icalvalue_free(p->value);
+ }
+
+ while( (param = pvl_pop(p->parameters)) != 0){
+ icalparameter_free(param);
+ }
+
+ pvl_free(p->parameters);
+
+ if (p->x_name != 0) {
+ free(p->x_name);
+ }
+
+ p->kind = ICAL_NO_PROPERTY;
+ p->parameters = 0;
+ p->parameter_iterator = 0;
+ p->value = 0;
+ p->x_name = 0;
+ p->id[0] = 'X';
+
+ free(p);
+
+}
+
+
+char*
+icalproperty_as_ical_string (icalproperty* prop)
+{
+ icalparameter *param;
+
+ /* Create new buffer that we can append names, parameters and a
+ value to, and reallocate as needed. Later, this buffer will be
+ copied to a icalmemory_tmp_buffer, which is managed internally
+ by libical, so it can be given to the caller without fear of
+ the caller forgetting to free it */
+
+ const char* property_name = 0;
+ size_t buf_size = 1024;
+ char* buf = icalmemory_new_buffer(buf_size);
+ char* buf_ptr = buf;
+ icalvalue* value;
+ char *out_buf;
+
+ char newline[] = "\n";
+
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rz( (prop!=0),"prop");
+
+
+ /* Append property name */
+
+ if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){
+ property_name = impl->x_name;
+ } else {
+ property_name = icalenum_property_kind_to_string(impl->kind);
+ }
+
+ if (property_name == 0 ) {
+ icalerror_warn("Got a property of an unknown kind.");
+ icalmemory_free_buffer(buf);
+ return 0;
+
+ }
+
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name);
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
+
+ /* Append parameters */
+ for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER);
+ param != 0;
+ param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) {
+
+ char* kind_string = icalparameter_as_ical_string(param);
+
+ if (kind_string == 0 ) {
+ char temp[TMP_BUF_SIZE];
+ snprintf(temp, TMP_BUF_SIZE,"Got a parameter of unknown kind in %s property",property_name);
+ icalerror_warn(temp);
+ continue;
+ }
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;");
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
+
+ }
+
+ /* Append value */
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, " :");
+
+ value = icalproperty_get_value(prop);
+
+ if (value != 0){
+ const char *str = icalvalue_as_ical_string(value);
+ icalerror_assert((str !=0),"Could not get string representation of a value");
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
+ } else {
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value");
+
+ }
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
+
+ /* Now, copy the buffer to a tmp_buffer, which is safe to give to
+ the caller without worring about de-allocating it. */
+
+
+ out_buf = icalmemory_tmp_buffer(strlen(buf)+1);
+ strcpy(out_buf, buf);
+
+ icalmemory_free_buffer(buf);
+
+ return out_buf;
+}
+
+
+
+icalproperty_kind
+icalproperty_isa (icalproperty* property)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)property;
+
+ if(property != 0){
+ return p->kind;
+ }
+
+ return ICAL_NO_PROPERTY;
+}
+
+int
+icalproperty_isa_property (void* property)
+{
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
+
+ icalerror_check_arg_rz( (property!=0), "property");
+
+ if (strcmp(impl->id,"prop") == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+void
+icalproperty_add_parameter (icalproperty* prop,icalparameter* parameter)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rv( (prop!=0),"prop");
+ icalerror_check_arg_rv( (parameter!=0),"parameter");
+
+ pvl_push(p->parameters, parameter);
+
+}
+
+void
+icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter)
+{
+ icalproperty_kind kind;
+
+ kind = icalparameter_isa(parameter);
+
+ icalproperty_remove_parameter(prop,kind);
+
+ icalproperty_add_parameter(prop,parameter);
+}
+
+
+void
+icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind)
+{
+ pvl_elem p;
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rv((prop!=0),"prop");
+
+ for(p=pvl_head(impl->parameters);p != 0; p = pvl_next(p)){
+ icalparameter* param = (icalparameter *)pvl_data (p);
+ if (icalparameter_isa(param) == kind) {
+ pvl_remove (impl->parameters, p);
+ icalparameter_free (param);
+ break;
+ }
+ }
+}
+
+
+int
+icalproperty_count_parameters (icalproperty* prop)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ if(prop != 0){
+ return pvl_count(p->parameters);
+ }
+
+ icalerror_set_errno(ICAL_USAGE_ERROR);
+ return -1;
+}
+
+
+icalparameter*
+icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rz( (prop!=0),"prop");
+
+ p->parameter_iterator = pvl_head(p->parameters);
+
+ if (p->parameter_iterator == 0) {
+ return 0;
+ }
+
+ for( p->parameter_iterator = pvl_head(p->parameters);
+ p->parameter_iterator !=0;
+ p->parameter_iterator = pvl_next(p->parameter_iterator)){
+
+ icalparameter *param = (icalparameter*)pvl_data(p->parameter_iterator);
+
+ if(icalparameter_isa(param) == kind || kind == ICAL_ANY_PARAMETER){
+ return param;
+ }
+ }
+
+ return 0;
+}
+
+
+icalparameter*
+icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rz( (prop!=0),"prop");
+
+ if (p->parameter_iterator == 0) {
+ return 0;
+ }
+
+ for( p->parameter_iterator = pvl_next(p->parameter_iterator);
+ p->parameter_iterator !=0;
+ p->parameter_iterator = pvl_next(p->parameter_iterator)){
+
+ icalparameter *param = (icalparameter*)pvl_data(p->parameter_iterator);
+
+ if(icalparameter_isa(param) == kind || kind == ICAL_ANY_PARAMETER){
+ return param;
+ }
+ }
+
+ return 0;
+
+}
+
+void
+icalproperty_set_value (icalproperty* prop, icalvalue* value)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rv((prop !=0),"prop");
+ icalerror_check_arg_rv((value !=0),"value");
+
+ if (p->value != 0){
+ icalvalue_set_parent(p->value,0);
+ icalvalue_free(p->value);
+ p->value = 0;
+ }
+
+ p->value = value;
+
+ icalvalue_set_parent(value,prop);
+}
+
+
+icalvalue*
+icalproperty_get_value (icalproperty* prop)
+{
+ struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rz( (prop!=0),"prop");
+
+ return p->value;
+}
+
+
+void icalproperty_set_x_name(icalproperty* prop, char* name)
+{
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rv( (name!=0),"name");
+ icalerror_check_arg_rv( (prop!=0),"prop");
+
+ if (impl->x_name != 0) {
+ free(impl->x_name);
+ }
+
+ impl->x_name = icalmemory_strdup(name);
+
+ if(impl->x_name == 0){
+ icalerror_set_errno(ICAL_ALLOCATION_ERROR);
+ }
+
+}
+
+char* icalproperty_get_x_name(icalproperty* prop){
+
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
+
+ icalerror_check_arg_rz( (prop!=0),"prop");
+
+ return impl->x_name;
+}
+
+
+void icalproperty_set_parent(icalproperty* property,
+ icalcomponent* component)
+{
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
+
+ icalerror_check_arg_rv( (property!=0),"property");
+
+ impl->parent = component;
+}
+
+icalcomponent* icalproperty_get_parent(icalproperty* property)
+{
+ struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
+
+ icalerror_check_arg_rv( (property!=0),"property");
+
+ return impl->parent;
+}
+
+
+/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalproperty.h.in b/libical/src/libical/icalproperty.h.in
new file mode 100644
index 0000000000..cfc7704970
--- /dev/null
+++ b/libical/src/libical/icalproperty.h.in
@@ -0,0 +1,57 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: icalderivedproperties.{c,h}
+ CREATOR: eric 09 May 1999
+
+ $Id: icalproperty.h.in,v 1.1 2000/12/11 22:05:59 federico Exp $
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+ ======================================================================*/
+
+
+#ifndef ICALPROPERTY_H
+#define ICALPROPERTY_H
+
+#include <time.h>
+#include "icalparameter.h"
+#include "icalvalue.h"
+#include "icalrecur.h"
+
+typedef void icalproperty;
+
+icalproperty* icalproperty_new(icalproperty_kind kind);
+
+icalproperty* icalproperty_new_clone(icalproperty * prop);
+
+icalproperty* icalproperty_new_from_string(char* str);
+
+char* icalproperty_as_ical_string(icalproperty* prop);
+
+void icalproperty_free(icalproperty* prop);
+
+icalproperty_kind icalproperty_isa(icalproperty* property);
+int icalproperty_isa_property(void* property);
+
+void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter);
+void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter);
+
+void icalproperty_remove_parameter(icalproperty* prop,
+ icalparameter_kind kind);
+
+int icalproperty_count_parameters(icalproperty* prop);
+
+/* Iterate through the parameters */
+icalparameter* icalproperty_get_first_parameter(icalproperty* prop,
+ icalparameter_kind kind);
+icalparameter* icalproperty_get_next_parameter(icalproperty* prop,
+ icalparameter_kind kind);
+/* Access the value of the property */
+void icalproperty_set_value(icalproperty* prop, icalvalue* value);
+icalvalue* icalproperty_get_value(icalproperty* prop);
+
+/* Deal with X properties */
+
+void icalproperty_set_x_name(icalproperty* prop, char* name);
+char* icalproperty_get_x_name(icalproperty* prop);
+
+/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalrestriction.c.in b/libical/src/libical/icalrestriction.c.in
new file mode 100644
index 0000000000..454442531f
--- /dev/null
+++ b/libical/src/libical/icalrestriction.c.in
@@ -0,0 +1,447 @@
+/* -*- Mode: C -*- */
+/* ======================================================================
+ File: icalrestriction.c
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+ ======================================================================*/
+/*#line 7 "icalrestriction.c.in"*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "icalrestriction.h"
+#include "icalenums.h"
+#include "icalerror.h"
+
+#include <assert.h>
+#include <stdio.h> /* For snprintf */
+
+#define TMP_BUF_SIZE 1024
+
+
+/* Define the structs for the restrictions. these data are filled out
+in machine generated code below */
+
+struct icalrestriction_property_record;
+
+typedef char* (*restriction_func)(struct icalrestriction_property_record* rec,icalcomponent* comp,icalproperty* prop);
+
+
+typedef struct icalrestriction_property_record {
+ icalproperty_method method;
+ icalcomponent_kind component;
+ icalproperty_kind property;
+ icalrestriction_kind restriction;
+ restriction_func function;
+} icalrestriction_property_record;
+
+
+typedef struct icalrestriction_component_record {
+ icalproperty_method method;
+ icalcomponent_kind component;
+ icalcomponent_kind subcomponent;
+ icalrestriction_kind restriction;
+ restriction_func function;
+} icalrestriction_component_record;
+
+icalrestriction_property_record*
+icalrestriction_get_property_restriction(icalproperty_method method,
+ icalcomponent_kind component,
+ icalproperty_kind property);
+icalrestriction_component_record*
+icalrestriction_get_component_restriction(icalproperty_method method,
+ icalcomponent_kind component,
+ icalcomponent_kind subcomponent);
+
+icalrestriction_component_record icalrestriction_component_records[];
+icalrestriction_property_record icalrestriction_property_records[];
+
+icalrestriction_property_record null_prop_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_UNKNOWN,0};
+icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0};
+
+
+/* The each row gives the result of comparing a restriction against a
+ count. The columns in each row represent 0,1,2+. '-1' indicates
+ 'invalid, 'don't care' or 'needs more analysis' So, for
+ ICAL_RESTRICTION_ONE, if there is 1 of a property with that
+ restriction, it passes, but if there are 0 or 2+, it fails. */
+
+char compare_map[ICAL_RESTRICTION_UNKNOWN+1][3] = {
+ { 1, 1, 1},/*ICAL_RESTRICTION_NONE*/
+ { 1, 0, 0},/*ICAL_RESTRICTION_ZERO*/
+ { 0, 1, 0},/*ICAL_RESTRICTION_ONE*/
+ { 1, 1, 1},/*ICAL_RESTRICTION_ZEROPLUS*/
+ { 0, 1, 1},/*ICAL_RESTRICTION_ONEPLUS*/
+ { 1, 1, 0},/*ICAL_RESTRICTION_ZEROORONE*/
+ { 1, 1, 0},/*ICAL_RESTRICTION_ONEEXCLUSIVE*/
+ { 1, 1, 0},/*ICAL_RESTRICTION_ONEMUTUAL*/
+ { 1, 1, 1} /*ICAL_RESTRICTION_UNKNOWN*/
+};
+
+char restr_string_map[ICAL_RESTRICTION_UNKNOWN+1][60] = {
+ "unknown number",/*ICAL_RESTRICTION_NONE*/
+ "0",/*ICAL_RESTRICTION_ZERO*/
+ "1",/*ICAL_RESTRICTION_ONE*/
+ "zero or more",/*ICAL_RESTRICTION_ZEROPLUS*/
+ "one or more" ,/*ICAL_RESTRICTION_ONEPLUS*/
+ "zero or one",/*ICAL_RESTRICTION_ZEROORONE*/
+ "zero or one, exclusive with another property",/*ICAL_RESTRICTION_ONEEXCLUSIVE*/
+ "zero or one, mutual with another property",/*ICAL_RESTRICTION_ONEMUTUAL*/
+ "unknown number" /*ICAL_RESTRICTION_UNKNOWN*/
+};
+
+
+int
+icalrestriction_compare(icalrestriction_kind restr, int count){
+
+ if ( restr < ICAL_RESTRICTION_NONE || restr > ICAL_RESTRICTION_UNKNOWN
+ || count < 0){
+ return -1;
+ }
+
+ if (count > 2) {
+ count = 2;
+ }
+
+ return compare_map[restr][count];
+
+}
+
+/* Special case routines */
+
+char* icalrestriction_may_be_draft_final_canceled(
+ icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop)
+{
+
+ icalproperty_status stat = icalproperty_get_status(prop);
+
+ if( !( stat == ICAL_STATUS_DRAFT ||
+ stat == ICAL_STATUS_FINAL ||
+ stat == ICAL_STATUS_CANCELLED )){
+
+ return "Failed iTIP restrictions for STATUS property. Value must be one of DRAFT, FINAL, or CANCELED";
+
+ }
+
+ return 0;
+}
+
+char* icalrestriction_may_be_comp_need_process(
+ icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop)
+{
+ icalproperty_status stat = icalproperty_get_status(prop);
+
+ if( !( stat == ICAL_STATUS_COMPLETED ||
+ stat == ICAL_STATUS_NEEDSACTION ||
+ stat == ICAL_STATUS_INPROCESS )){
+
+ return "Failed iTIP restrictions for STATUS property. Value must be one of COMPLETED, NEEDS-ACTION or IN-PROCESS";
+
+ }
+
+ return 0;
+}
+char* icalrestriction_may_be_tent_conf(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+ icalproperty_status stat = icalproperty_get_status(prop);
+
+ if( !( stat == ICAL_STATUS_TENTATIVE ||
+ stat == ICAL_STATUS_CONFIRMED )){
+
+ return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE or CONFIRMED";
+
+ }
+
+ return 0;
+}
+char* icalrestriction_may_be_tent_conf_cancel(
+ icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop)
+{
+ icalproperty_status stat = icalproperty_get_status(prop);
+
+ if( !( stat == ICAL_STATUS_TENTATIVE ||
+ stat == ICAL_STATUS_CONFIRMED ||
+ stat == ICAL_STATUS_CANCELLED )){
+
+ return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE, CONFIRMED or CANCELED";
+
+ }
+
+ return 0;
+}
+
+char* icalrestriction_must_be_cancel_if_present(
+ icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop)
+{
+ /* This routine will not be called if prop == 0 */
+ icalproperty_status stat = icalproperty_get_status(prop);
+
+ if( stat != ICAL_STATUS_CANCELLED)
+ {
+ return "Failed iTIP restrictions for STATUS property. Value must be CANCELLED";
+
+ }
+
+
+ return 0;
+}
+
+char* icalrestriction_must_be_canceled_no_attendee(
+ icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop)
+{
+
+ /* Hack. see rfc2446, 3.2.5 CANCEL for porperty STATUS. I don't
+ understand the note */
+
+ return 0;
+}
+char* icalrestriction_must_be_recurring(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+ /* Hack */
+ return 0;
+}
+char* icalrestriction_must_have_duration(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+
+ if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){
+
+ return "Failed iTIP restrictions for STATUS property. This component must have a DURATION property";
+
+ }
+
+ return 0;
+}
+char* icalrestriction_must_have_repeat(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+ if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){
+
+ return "Failed iTIP restrictions for STATUS property. This component must have a REPEAT property";
+
+ }
+
+ return 0;
+}
+char* icalrestriction_must_if_tz_ref(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+
+ /* Hack */
+ return 0;
+}
+char* icalrestriction_no_dtend(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+
+ if( !icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){
+
+ return "Failed iTIP restrictions for STATUS property. The component must not have both DURATION and DTEND";
+
+ }
+
+ return 0;
+}
+char* icalrestriction_no_duration(icalrestriction_property_record *rec,
+ icalcomponent* comp,
+ icalproperty* prop){
+
+ /* _no_dtend takes care of this one */
+ return 0;
+}
+
+
+int icalrestriction_check_component(icalproperty_method method,
+ icalcomponent* comp)
+{
+ icalproperty_kind kind;
+ icalcomponent_kind comp_kind;
+ icalrestriction_kind restr;
+ icalrestriction_property_record *prop_record;
+ icalrestriction_component_record *comp_record;
+ char* funcr = 0;
+ icalproperty *prop;
+
+ int count;
+ int compare;
+ int valid = 1;
+
+ comp_kind = icalcomponent_isa(comp);
+
+ /* Check all of the properties in this component */
+
+ for(kind = ICAL_ANY_PROPERTY+1; kind != ICAL_NO_PROPERTY; kind++){
+ count = icalcomponent_count_properties(comp, kind);
+
+ prop_record = icalrestriction_get_property_restriction(method,
+ comp_kind,
+ kind);
+
+ restr = prop_record->restriction;
+
+ if(restr == ICAL_RESTRICTION_ONEEXCLUSIVE ||
+ restr == ICAL_RESTRICTION_ONEMUTUAL) {
+
+ /* First treat is as a 0/1 restriction */
+ restr = ICAL_RESTRICTION_ZEROORONE;
+ compare = icalrestriction_compare(restr,count);
+
+ } else {
+
+ compare = icalrestriction_compare(restr,count);
+ }
+
+ assert(compare != -1);
+
+ if (compare == 0){
+ char temp[TMP_BUF_SIZE];
+
+ snprintf(temp, TMP_BUF_SIZE,"Failed iTIP restrictions for %s property. Expected %s instances of the property and got %d",
+ icalenum_property_kind_to_string(kind),
+ restr_string_map[restr], count);
+
+ icalcomponent_add_property
+ (comp,
+ icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP),
+ 0));
+ }
+
+
+ prop = icalcomponent_get_first_property(comp, kind);
+
+ if (prop != 0 && prop_record->function !=0 ){
+ funcr = prop_record->function(prop_record,comp,prop);
+ }
+
+ if(funcr !=0){
+ icalcomponent_add_property
+ (comp,
+ icalproperty_vanew_xlicerror(
+ funcr,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_INVALIDITIP),
+ 0));
+
+ compare = 0;
+ }
+
+ valid = valid && compare;
+ }
+
+
+
+ return valid;
+
+
+}
+
+int icalrestriction_check(icalcomponent* outer_comp)
+{
+ icalcomponent_kind comp_kind;
+ icalproperty_method method;
+ icalcomponent* inner_comp;
+ icalproperty *method_prop;
+ int valid;
+
+ icalerror_check_arg_rz( (outer_comp!=0), "outer comp");
+
+
+ /* Get the Method value from the outer component */
+
+ comp_kind = icalcomponent_isa(outer_comp);
+
+ if (comp_kind != ICAL_VCALENDAR_COMPONENT){
+ icalerror_set_errno(ICAL_BADARG_ERROR);
+ return 0;
+ }
+
+ method_prop = icalcomponent_get_first_property(outer_comp,
+ ICAL_METHOD_PROPERTY);
+
+ if (method_prop == 0){
+ method = ICAL_METHOD_NONE;
+ } else {
+ method = icalproperty_get_method(method_prop);
+ }
+
+
+ /* Check the VCALENDAR wrapper */
+ valid = icalrestriction_check_component(ICAL_METHOD_NONE,outer_comp);
+
+
+ /* Now check the inner components */
+
+ for(inner_comp= icalcomponent_get_first_component(outer_comp,
+ ICAL_ANY_COMPONENT);
+ inner_comp != 0;
+ inner_comp= icalcomponent_get_next_component(outer_comp,
+ ICAL_ANY_COMPONENT)){
+
+ valid = valid && icalrestriction_check_component(method,inner_comp);
+
+ }
+
+
+ return valid;
+
+}
+
+icalrestriction_property_record*
+icalrestriction_get_property_restriction(icalproperty_method method,
+ icalcomponent_kind component,
+ icalproperty_kind property)
+{
+ int i;
+
+ for(i = 0;
+ icalrestriction_property_records[i].restriction != ICAL_RESTRICTION_NONE;
+ i++){
+
+ if (method == icalrestriction_property_records[i].method &&
+ component == icalrestriction_property_records[i].component &&
+ property == icalrestriction_property_records[i].property ){
+ return &icalrestriction_property_records[i];
+ }
+ }
+
+ return &null_prop_record;
+}
+
+
+icalrestriction_component_record*
+icalrestriction_get_component_restriction(icalproperty_method method,
+ icalcomponent_kind component,
+ icalcomponent_kind subcomponent)
+{
+
+ int i;
+
+ for(i = 0;
+ icalrestriction_component_records[i].restriction != ICAL_RESTRICTION_NONE;
+ i++){
+
+ if (method == icalrestriction_component_records[i].method &&
+ component == icalrestriction_component_records[i].component &&
+ subcomponent == icalrestriction_component_records[i].subcomponent ){
+ return &icalrestriction_component_records[i];
+ }
+ }
+
+ return &null_comp_record;
+}
+
diff --git a/libical/src/libical/icalvalue.c.in b/libical/src/libical/icalvalue.c.in
new file mode 100644
index 0000000000..7adcecb990
--- /dev/null
+++ b/libical/src/libical/icalvalue.c.in
@@ -0,0 +1,1388 @@
+/* -*- Mode: C -*- */
+/*======================================================================
+ FILE: icalvalue.c
+ CREATOR: eric 02 May 1999
+
+ $Id: icalvalue.c.in,v 1.1 2000/12/11 22:06:02 federico Exp $
+
+
+ (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 icalvalue.c
+
+ Contributions from:
+ Graham Davison (g.m.davison@computer.org)
+
+
+======================================================================*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "icalerror.h"
+#include "icalmemory.h"
+#include "icalparser.h"
+#include "icalenums.h"
+
+#include <stdlib.h> /* for malloc */
+#include <stdio.h> /* for sprintf */
+#include <string.h> /* For memset, others */
+#include <stddef.h> /* For offsetof() macro */
+#include <errno.h>
+#include <time.h> /* for mktime */
+#include <stdlib.h> /* for atoi and atof */
+#include <limits.h> /* for SHRT_MAX */
+
+#if _MAC_OS_
+#include "icalmemory_strdup.h"
+#endif
+
+#define TMP_BUF_SIZE 1024
+
+void print_datetime_to_string(char* str, struct icaltimetype *data);
+void print_date_to_string(char* str, struct icaltimetype *data);
+void print_time_to_string(char* str, struct icaltimetype *data);
+void print_recur_to_string(char* str, struct icaltimetype *data);
+
+struct icalvalue_impl {
+ icalvalue_kind kind;
+ char id[5];
+ int size;
+ icalproperty* parent;
+
+ union data {
+ struct icalattachtype v_attach;
+ /* void *v_binary; */ /* use v_attach */
+ const char *v_string;
+ /*char *v_text;*/
+ /*char *v_caladdress;*/
+ /*char *v_uri;*/
+ float v_float;
+ int v_int;
+ /*int v_boolean;*/
+ /*int v_integer;*/
+ struct icaldurationtype v_duration;
+ /*int v_utcoffset;*/
+
+ struct icalperiodtype v_period;
+ /*struct icalperiodtype v_datetimeperiod;*/
+ struct icalgeotype v_geo;
+ /*time_t v_time;*/
+ struct icaltimetype v_time;
+ /*struct icaltimetype v_date;*/
+ /*struct icaltimetype v_datetime;*/
+ /*struct icaltimetype v_datetimedate;*/
+
+ /* struct icalrecurrencetype was once included
+ directly ( not referenced ) in this union, but it
+ contributes 2000 bytes to every value, so now it is
+ a reference*/
+
+ struct icalrecurrencetype *v_recur;
+ union icaltriggertype v_trigger;
+ icalproperty_method v_method;
+ icalproperty_status v_status;
+
+ } data;
+};
+
+struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind){
+
+ struct icalvalue_impl* v;
+
+ if ( ( v = (struct icalvalue_impl*)
+ malloc(sizeof(struct icalvalue_impl))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ strcpy(v->id,"val");
+
+ v->kind = kind;
+ v->size = 0;
+ v->parent = 0;
+ memset(&(v->data),0,sizeof(v->data));
+
+ return v;
+
+}
+
+
+
+icalvalue*
+icalvalue_new (icalvalue_kind kind)
+{
+ return (icalvalue*)icalvalue_new_impl(kind);
+}
+
+icalvalue* icalvalue_new_clone(icalvalue* value){
+
+ struct icalvalue_impl* new;
+ struct icalvalue_impl* old = (struct icalvalue_impl*)value;
+
+ new = icalvalue_new_impl(old->kind);
+
+ if (new == 0){
+ return 0;
+ }
+
+
+ strcpy(new->id, old->id);
+ new->kind = old->kind;
+ new->size = old->size;
+
+ switch (new->kind){
+
+ /* The contents of the attach value may or may not be owned by the
+ * library. */
+ case ICAL_ATTACH_VALUE:
+ case ICAL_BINARY_VALUE:
+ {
+ /* HACK ugh. I don't feel like impleenting this */
+ }
+
+ case ICAL_STRING_VALUE:
+ case ICAL_TEXT_VALUE:
+ case ICAL_CALADDRESS_VALUE:
+ case ICAL_URI_VALUE:
+ {
+ if (old->data.v_string != 0) {
+ new->data.v_string=icalmemory_strdup(old->data.v_string);
+
+ if ( new->data.v_string == 0 ) {
+ return 0;
+ }
+
+ }
+ break;
+ }
+ case ICAL_RECUR_VALUE:
+ {
+ if(old->data.v_recur != 0){
+ new->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
+
+ if(new->data.v_recur == 0){
+ return 0;
+ }
+
+ memcpy( new->data.v_recur, old->data.v_recur,
+ sizeof(struct icalrecurrencetype));
+ }
+ break;
+ }
+
+ default:
+ {
+ /* all of the other types are stored as values, not
+ pointers, so we can just copy the whole structure. */
+
+ new->data = old->data;
+ }
+ }
+
+ return new;
+}
+
+char* icalmemory_strdup_and_dequote(const char* str)
+{
+ char* p;
+ char* out = (char*)malloc(sizeof(char) * strlen(str) +1);
+ char* pout;
+
+ if (out == 0){
+ return 0;
+ }
+
+ pout = out;
+
+ for (p = str; *p!=0; p++){
+
+ if( *p == '\\')
+ {
+ p++;
+ switch(*p){
+ case 0:
+ {
+ break;
+ *pout = '\0';
+ }
+ case 'n':
+ {
+ *pout = '\n';
+ break;
+ }
+ case 'N':
+ {
+ *pout = '\n';
+ break;
+ }
+ case '\\':
+ case ',':
+ case ';':
+ {
+ *pout = *p;
+ break;
+ }
+ default:
+ {
+ *pout = ' ';
+ }
+ }
+ } else {
+ *pout = *p;
+ }
+
+ pout++;
+
+ }
+
+ *pout = '\0';
+
+ return out;
+}
+
+icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* str,icalproperty** error)
+{
+
+ icalvalue *value = 0;
+
+ icalerror_check_arg_rz(str!=0,"str");
+
+ if (error != 0){
+ *error = 0;
+ }
+
+ switch (kind){
+
+ case ICAL_ATTACH_VALUE:
+ {
+ /* HACK */
+ value = 0;
+
+ if (error != 0){
+ char temp[TMP_BUF_SIZE];
+ sprintf(temp,"ATTACH Values are not implemented");
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+ icalerror_warn("Parsing ATTACH properties is unimplmeneted");
+ break;
+ }
+
+ case ICAL_BINARY_VALUE:
+ {
+ /* HACK */
+ value = 0;
+
+ if (error != 0){
+ char temp[TMP_BUF_SIZE];
+ sprintf(temp,"BINARY Values are not implemented");
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+ icalerror_warn("Parsing BINARY values is unimplmeneted");
+ break;
+ }
+
+ case ICAL_BOOLEAN_VALUE:
+ {
+ /* HACK */
+ value = 0;
+
+ if (error != 0){
+ char temp[TMP_BUF_SIZE];
+ sprintf(temp,"BOOLEAN Values are not implemented");
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+ icalerror_warn("Parsing BOOLEAN values is unimplmeneted");
+ break;
+ }
+
+ case ICAL_INTEGER_VALUE:
+ {
+ value = icalvalue_new_integer(atoi(str));
+ break;
+ }
+
+ case ICAL_FLOAT_VALUE:
+ {
+ value = icalvalue_new_float(atof(str));
+ break;
+ }
+
+ case ICAL_UTCOFFSET_VALUE:
+ {
+ value = icalparser_parse_value(kind,str,(icalcomponent*)0);
+ break;
+ }
+
+ case ICAL_TEXT_VALUE:
+ {
+ char* dequoted_str = icalmemory_strdup_and_dequote(str);
+ value = icalvalue_new_text(dequoted_str);
+ free(dequoted_str);
+ break;
+ }
+
+
+ case ICAL_STRING_VALUE:
+ {
+ value = icalvalue_new_string(str);
+ break;
+ }
+
+ case ICAL_CALADDRESS_VALUE:
+ {
+ value = icalvalue_new_caladdress(str);
+ break;
+ }
+
+ case ICAL_URI_VALUE:
+ {
+ value = icalvalue_new_uri(str);
+ break;
+ }
+
+ case ICAL_METHOD_VALUE:
+ {
+ icalproperty_method method = icalenum_string_to_method(str);
+
+ if(method == ICAL_METHOD_NONE){
+ value = 0;
+ } else {
+ value = icalvalue_new_method(method);
+ }
+
+ break;
+
+ }
+
+
+ case ICAL_STATUS_VALUE:
+ {
+ icalproperty_status status = icalenum_string_to_status(str);
+
+ if(status == ICAL_STATUS_NONE){
+ value = 0;
+ } else {
+ value = icalvalue_new_status(status);
+ }
+
+ break;
+
+ }
+ case ICAL_GEO_VALUE:
+ {
+ value = 0;
+ /* HACK */
+
+ if (error != 0){
+ char temp[TMP_BUF_SIZE];
+ sprintf(temp,"GEO Values are not implemented");
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+ /*icalerror_warn("Parsing GEO properties is unimplmeneted");*/
+
+ break;
+ }
+
+ case ICAL_RECUR_VALUE:
+ case ICAL_DATE_VALUE:
+ case ICAL_DATETIME_VALUE:
+ case ICAL_DATETIMEDATE_VALUE:
+ case ICAL_DATETIMEPERIOD_VALUE:
+ case ICAL_TIME_VALUE:
+ case ICAL_DURATION_VALUE:
+ case ICAL_PERIOD_VALUE:
+ case ICAL_TRIGGER_VALUE:
+ {
+ value = icalparser_parse_value(kind,str,error);
+ break;
+ }
+
+ default:
+ {
+
+ if (error != 0 ){
+ char temp[TMP_BUF_SIZE];
+
+ snprintf(temp,TMP_BUF_SIZE,"Unknown type for \'%s\'",str);
+
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+ icalerror_warn("icalvalue_new_from_string got an unknown value type");
+ value=0;
+ }
+ }
+
+
+ if (error != 0 && *error == 0 && value == 0){
+ char temp[TMP_BUF_SIZE];
+
+ snprintf(temp,TMP_BUF_SIZE,"Failed to parse value: \'%s\'",str);
+
+ *error = icalproperty_vanew_xlicerror(
+ temp,
+ icalparameter_new_xlicerrortype(
+ ICAL_XLICERRORTYPE_VALUEPARSEERROR),
+ 0);
+ }
+
+
+ return value;
+
+}
+
+icalvalue* icalvalue_new_from_string(icalvalue_kind kind,const char* str)
+{
+ return icalvalue_new_from_string_with_error(kind,str,(icalproperty*)0);
+}
+
+
+
+void
+icalvalue_free (icalvalue* value)
+{
+ struct icalvalue_impl* v = (struct icalvalue_impl*)value;
+
+ icalerror_check_arg_rv((value != 0),"value");
+
+#ifdef ICAL_FREE_ON_LIST_IS_ERROR
+ icalerror_assert( (v->parent ==0),"This value is still attached to a property");
+
+#else
+ if(v->parent !=0){
+ return;
+ }
+#endif
+
+
+ switch (v->kind){
+ case ICAL_BINARY_VALUE:
+ case ICAL_ATTACH_VALUE: {
+ /* HACK ugh. This will be tough to implement */
+ }
+ case ICAL_TEXT_VALUE:
+ case ICAL_CALADDRESS_VALUE:
+ case ICAL_URI_VALUE:
+ {
+ if (v->data.v_string != 0) {
+ free((void*)v->data.v_string);
+ v->data.v_string = 0;
+ }
+ break;
+ }
+ case ICAL_RECUR_VALUE:
+ {
+ if(v->data.v_recur != 0){
+ free((void*)v->data.v_recur);
+ v->data.v_recur = 0;
+ }
+ break;
+ }
+
+ default:
+ {
+ /* Nothing to do */
+ }
+ }
+
+ v->kind = ICAL_NO_VALUE;
+ v->size = 0;
+ v->parent = 0;
+ memset(&(v->data),0,sizeof(v->data));
+ v->id[0] = 'X';
+ free(v);
+}
+
+int
+icalvalue_is_valid (icalvalue* value)
+{
+ /*struct icalvalue_impl* v = (struct icalvalue_impl*)value;*/
+
+ if(value == 0){
+ return 0;
+ }
+
+ return 1;
+}
+
+char* icalvalue_binary_as_ical_string(icalvalue* value) {
+
+ const char* data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_binary(value);
+
+ str = (char*)icalmemory_tmp_buffer(60);
+ sprintf(str,"icalvalue_binary_as_ical_string is not implemented yet");
+
+ return str;
+}
+
+
+char* icalvalue_int_as_ical_string(icalvalue* value) {
+
+ int data;
+ char* str = (char*)icalmemory_tmp_buffer(2);
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_integer(value);
+
+ sprintf(str,"%d",data);
+
+ return str;
+}
+
+char* icalvalue_utcoffset_as_ical_string(icalvalue* value)
+{
+ int data,h,m,s;
+ char sign;
+ char* str = (char*)icalmemory_tmp_buffer(9);
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_utcoffset(value);
+
+ if (abs(data) == data){
+ sign = '+';
+ } else {
+ sign = '-';
+ }
+
+ h = data/3600;
+ m = (data - (h*3600))/ 60;
+ s = (data - (h*3600) - (m*60));
+
+ sprintf(str,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s));
+
+ return str;
+}
+
+char* icalvalue_string_as_ical_string(icalvalue* value) {
+
+ const char* data;
+ char* str = 0;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = ((struct icalvalue_impl*)value)->data.v_string;
+
+ str = (char*)icalmemory_tmp_buffer(strlen(data)+1);
+
+ strcpy(str,data);
+
+ return str;
+}
+
+
+char* icalvalue_recur_as_ical_string(icalvalue* value)
+{
+ char* str;
+ char *str_p;
+ size_t buf_sz = 200;
+ char temp[20];
+ int i,j;
+ struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
+ struct icalrecurrencetype *recur = impl->data.v_recur;
+
+ struct { char* str;size_t offset; short limit; } recurmap[] =
+ {
+ {";BYSECOND=",offsetof(struct icalrecurrencetype,by_second),60},
+ {";BYMINUTE=",offsetof(struct icalrecurrencetype,by_minute),60},
+ {";BYHOUR=",offsetof(struct icalrecurrencetype,by_hour),24},
+ {";BYDAY=",offsetof(struct icalrecurrencetype,by_day),7},
+ {";BYMONTHDAY=",offsetof(struct icalrecurrencetype,by_month_day),31},
+ {";BYYEARDAY=",offsetof(struct icalrecurrencetype,by_year_day),366},
+ {";BYWEEKNO=",offsetof(struct icalrecurrencetype,by_week_no),52},
+ {";BYMONTH=",offsetof(struct icalrecurrencetype,by_month),12},
+ {";BYSETPOS=",offsetof(struct icalrecurrencetype,by_set_pos),366},
+ {0,0,0},
+ };
+
+
+
+ icalerror_check_arg_rz((value != 0),"value");
+
+ if(recur->freq == ICAL_NO_RECURRENCE){
+ return 0;
+ }
+
+ str = (char*)icalmemory_tmp_buffer(buf_sz);
+ str_p = str;
+
+ icalmemory_append_string(&str,&str_p,&buf_sz,"FREQ=");
+ icalmemory_append_string(&str,&str_p,&buf_sz,
+ icalrecur_recurrence_to_string(recur->freq));
+
+ if(recur->until.year != 0){
+
+ temp[0] = 0;
+ print_datetime_to_string(temp,&(recur->until));
+
+ icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL=");
+ icalmemory_append_string(&str,&str_p,&buf_sz, temp);
+ }
+
+ if(recur->count != 0){
+ sprintf(temp,"%d",recur->count);
+ icalmemory_append_string(&str,&str_p,&buf_sz,";COUNT=");
+ icalmemory_append_string(&str,&str_p,&buf_sz, temp);
+ }
+
+ if(recur->interval != 0){
+ sprintf(temp,"%d",recur->interval);
+ icalmemory_append_string(&str,&str_p,&buf_sz,";INTERVAL=");
+ icalmemory_append_string(&str,&str_p,&buf_sz, temp);
+ }
+
+ for(j =0; recurmap[j].str != 0; j++){
+ short* array = (short*)(recurmap[j].offset+ (size_t)recur);
+ short limit = recurmap[j].limit;
+
+ /* Skip unused arrays */
+ if( array[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
+
+ icalmemory_append_string(&str,&str_p,&buf_sz,recurmap[j].str);
+
+ for(i=0; i< limit && array[i] != ICAL_RECURRENCE_ARRAY_MAX;
+ i++){
+ if (j == 3) { /* BYDAY */
+ short dow = icalrecurrencetype_day_day_of_week(array[i]);
+ const char *daystr = icalrecur_weekday_to_string(dow);
+ short pos = icalrecurrencetype_day_position(array[i]);
+
+ if (pos == 0)
+ icalmemory_append_string(&str,&str_p,&buf_sz,daystr);
+ else {
+ sprintf(temp,"%d%s",pos,daystr);
+ icalmemory_append_string(&str,&str_p,&buf_sz,temp);
+ }
+
+ } else {
+ sprintf(temp,"%d",array[i]);
+ icalmemory_append_string(&str,&str_p,&buf_sz, temp);
+ }
+
+ if( (i+1)<limit &&array[i+1]
+ != ICAL_RECURRENCE_ARRAY_MAX){
+ icalmemory_append_char(&str,&str_p,&buf_sz,',');
+ }
+ }
+ }
+ }
+
+ return str;
+}
+
+char* icalvalue_text_as_ical_string(icalvalue* value) {
+
+ char *str;
+ char *str_p;
+ char *rtrn;
+ const char *p;
+ size_t buf_sz;
+ int line_length;
+
+ line_length = 0;
+
+ buf_sz = strlen(((struct icalvalue_impl*)value)->data.v_string)+1;
+
+ str_p = str = (char*)icalmemory_new_buffer(buf_sz);
+
+ if (str_p == 0){
+ return 0;
+ }
+
+ for(p=((struct icalvalue_impl*)value)->data.v_string; *p!=0; p++){
+
+ switch(*p){
+ case '\n': {
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\\n");
+ line_length+=3;
+ break;
+ }
+
+ case '\t': {
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\\t");
+ line_length+=3;
+ break;
+ }
+ case '\r': {
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\\r");
+ line_length+=3;
+ break;
+ }
+ case '\b': {
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\\b");
+ line_length+=3;
+ break;
+ }
+ case '\f': {
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\\f");
+ line_length+=3;
+ break;
+ }
+
+ case ';':
+ case ',':{
+ icalmemory_append_char(&str,&str_p,&buf_sz,'\\');
+ icalmemory_append_char(&str,&str_p,&buf_sz,*p);
+ line_length+=3;
+ break;
+ }
+
+ case '"':{
+ icalmemory_append_char(&str,&str_p,&buf_sz,'\\');
+ icalmemory_append_char(&str,&str_p,&buf_sz,*p);
+ line_length+=3;
+ break;
+ }
+
+ default: {
+ icalmemory_append_char(&str,&str_p,&buf_sz,*p);
+ line_length++;
+ }
+ }
+
+ if (line_length > 65 && *p == ' '){
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\n ");
+ line_length=0;
+ }
+
+
+ if (line_length > 75){
+ icalmemory_append_string(&str,&str_p,&buf_sz,"\n ");
+ line_length=0;
+ }
+
+ }
+
+ /* Assume the last character is not a '\0' and add one. We could
+ check *str_p != 0, but that would be an uninitialized memory
+ read. */
+
+
+ icalmemory_append_char(&str,&str_p,&buf_sz,'\0');
+
+ rtrn = icalmemory_tmp_copy(str);
+
+ icalmemory_free_buffer(str);
+
+ return rtrn;
+}
+
+
+char* icalvalue_attach_as_ical_string(icalvalue* value) {
+
+ struct icalattachtype a;
+ char * str;
+
+ icalerror_check_arg_rz( (value!=0),"value");
+
+ a = icalvalue_get_attach(value);
+
+ if (a.binary != 0) {
+ return icalvalue_binary_as_ical_string(value);
+ } else if (a.base64 != 0) {
+ str = (char*)icalmemory_tmp_buffer(strlen(a.base64)+1);
+ strcpy(str,a.base64);
+ return str;
+ } else if (a.url != 0){
+ return icalvalue_string_as_ical_string(value);
+ } else {
+ icalerrno = ICAL_MALFORMEDDATA_ERROR;
+ return 0;
+ }
+}
+
+void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size,
+ char* sep, unsigned int value) {
+
+ char temp[TMP_BUF_SIZE];
+
+ sprintf(temp,"%d",value);
+
+ icalmemory_append_string(buf, buf_ptr, buf_size, temp);
+ icalmemory_append_string(buf, buf_ptr, buf_size, sep);
+
+}
+
+char* icalvalue_duration_as_ical_string(icalvalue* value) {
+
+ struct icaldurationtype data;
+ char *buf, *output_line;
+ size_t buf_size = 256;
+ char* buf_ptr = 0;
+
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_duration(value);
+
+ buf = (char*)icalmemory_new_buffer(buf_size);
+ buf_ptr = buf;
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, "P");
+
+
+ if (data.weeks != 0 ) {
+ append_duration_segment(&buf, &buf_ptr, &buf_size, "W", data.weeks);
+ }
+
+ if (data.days != 0 ) {
+ append_duration_segment(&buf, &buf_ptr, &buf_size, "D", data.days);
+ }
+
+ if (data.hours != 0 || data.minutes != 0 || data.seconds != 0) {
+
+ icalmemory_append_string(&buf, &buf_ptr, &buf_size, "T");
+
+ if (data.hours != 0 ) {
+ append_duration_segment(&buf, &buf_ptr, &buf_size, "H", data.hours);
+ }
+ if (data.minutes != 0 ) {
+ append_duration_segment(&buf, &buf_ptr, &buf_size, "M", data.minutes);
+ }
+ if (data.seconds != 0 ) {
+ append_duration_segment(&buf, &buf_ptr, &buf_size, "S", data.seconds);
+ }
+
+ }
+
+ output_line = icalmemory_tmp_copy(buf);
+ icalmemory_free_buffer(buf);
+
+ return output_line;
+
+
+}
+
+void print_time_to_string(char* str, struct icaltimetype *data)
+{
+ char temp[20];
+
+ if (data->is_utc == 1){
+ sprintf(temp,"%02d%02d%02dZ",data->hour,data->minute,data->second);
+ } else {
+ sprintf(temp,"%02d%02d%02d",data->hour,data->minute,data->second);
+ }
+
+ strcat(str,temp);
+}
+
+
+char* icalvalue_time_as_ical_string(icalvalue* value) {
+
+ struct icaltimetype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_time(value);
+
+ str = (char*)icalmemory_tmp_buffer(8);
+
+ str[0] = 0;
+ print_time_to_string(str,&data);
+
+ return str;
+}
+
+void print_date_to_string(char* str, struct icaltimetype *data)
+{
+ char temp[20];
+
+ sprintf(temp,"%04d%02d%02d",data->year,data->month,data->day);
+
+ strcat(str,temp);
+}
+
+char* icalvalue_date_as_ical_string(icalvalue* value) {
+
+ struct icaltimetype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_date(value);
+
+ str = (char*)icalmemory_tmp_buffer(9);
+
+ str[0] = 0;
+ print_date_to_string(str,&data);
+
+ return str;
+}
+
+void print_datetime_to_string(char* str, struct icaltimetype *data)
+{
+ print_date_to_string(str,data);
+ strcat(str,"T");
+ print_time_to_string(str,data);
+
+}
+
+char* icalvalue_datetime_as_ical_string(icalvalue* value) {
+
+ struct icaltimetype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_date(value);
+
+ str = (char*)icalmemory_tmp_buffer(20);
+
+ str[0] = 0;
+
+ print_datetime_to_string(str,&data);
+
+ return str;
+
+}
+
+
+char* icalvalue_datetimedate_as_ical_string(icalvalue* value) {
+
+ struct icaltimetype data;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_datetime(value);
+
+ if (data.is_date == 1){
+ return icalvalue_date_as_ical_string(value);
+ } else {
+ return icalvalue_datetime_as_ical_string(value);
+ }
+}
+
+
+char* icalvalue_float_as_ical_string(icalvalue* value) {
+
+ float data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_float(value);
+
+ str = (char*)icalmemory_tmp_buffer(15);
+
+ sprintf(str,"%f",data);
+
+ return str;
+}
+
+char* icalvalue_geo_as_ical_string(icalvalue* value) {
+
+ struct icalgeotype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+
+ data = icalvalue_get_geo(value);
+
+ str = (char*)icalmemory_tmp_buffer(25);
+
+ sprintf(str,"%f;%f",data.lat,data.lon);
+
+ return str;
+}
+
+char* icalvalue_datetimeperiod_as_ical_string(icalvalue* value) {
+
+ struct icalperiodtype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_datetimeperiod(value);
+
+ str = (char*)icalmemory_tmp_buffer(60);
+
+ if( data.end.second == -1){
+ /* This is a DATE-TIME value, since there is no end value */
+ icalvalue *v= icalvalue_new_datetime(data.start);
+
+ strcpy(str,icalvalue_datetime_as_ical_string(v));
+
+ free(v);
+
+ } else {
+ icalvalue *v1 = icalvalue_new_datetime(data.start);
+ icalvalue *v2 = icalvalue_new_datetime(data.end);
+
+ sprintf(str,"%s/%s",
+ icalvalue_datetime_as_ical_string(v1),
+ icalvalue_datetime_as_ical_string(v2)
+ );
+
+ free(v1);
+ free(v2);
+
+ }
+
+ return str;
+}
+
+char* icalvalue_period_as_ical_string(icalvalue* value) {
+
+ struct icalperiodtype data;
+ char* str;
+ icalvalue *s,*e;
+
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_period(value);
+
+ str = (char*)icalmemory_tmp_buffer(60);
+
+ s = icalvalue_new_datetime(data.start);
+
+ if (data.end.second != -1){
+ /* use the end date */
+ e = icalvalue_new_datetime(data.end);
+
+ sprintf(str,"%s/%s",
+ icalvalue_datetime_as_ical_string(s),
+ icalvalue_datetime_as_ical_string(e)
+ );
+
+
+ } else {
+ /* use the duration */
+ e = icalvalue_new_duration(data.duration);
+
+ sprintf(str,"%s/%s",
+ icalvalue_datetime_as_ical_string(s),
+ icalvalue_duration_as_ical_string(e)
+ );
+
+ }
+
+ icalvalue_free(e);
+ icalvalue_free(s);
+ return str;
+}
+
+char* icalvalue_trigger_as_ical_string(icalvalue* value) {
+
+ union icaltriggertype data;
+ char* str;
+ icalerror_check_arg_rz( (value!=0),"value");
+ data = icalvalue_get_trigger(value);
+
+ str = (char*)icalmemory_tmp_buffer(60);
+ sprintf(str,"icalvalue_trigger_as_ical_string is not implemented yet");
+
+ return str;
+}
+
+const char*
+icalvalue_as_ical_string (icalvalue* value)
+{
+ struct icalvalue_impl* v = (struct icalvalue_impl*)value;
+
+ v=v;
+
+ if(value == 0){
+ return 0;
+ }
+
+ switch (v->kind){
+
+ case ICAL_ATTACH_VALUE:
+ return icalvalue_attach_as_ical_string(value);
+
+ case ICAL_BINARY_VALUE:
+ return icalvalue_binary_as_ical_string(value);
+
+ case ICAL_BOOLEAN_VALUE:
+ case ICAL_INTEGER_VALUE:
+ return icalvalue_int_as_ical_string(value);
+
+ case ICAL_UTCOFFSET_VALUE:
+ return icalvalue_utcoffset_as_ical_string(value);
+
+ case ICAL_TEXT_VALUE:
+ return icalvalue_text_as_ical_string(value);
+
+ case ICAL_STRING_VALUE:
+ case ICAL_URI_VALUE:
+ case ICAL_CALADDRESS_VALUE:
+ return icalvalue_string_as_ical_string(value);
+
+ case ICAL_DATE_VALUE:
+ return icalvalue_date_as_ical_string(value);
+ case ICAL_DATETIME_VALUE:
+ return icalvalue_datetime_as_ical_string(value);
+ case ICAL_DATETIMEDATE_VALUE:
+ return icalvalue_datetimedate_as_ical_string(value);
+ case ICAL_DURATION_VALUE:
+ return icalvalue_duration_as_ical_string(value);
+ case ICAL_TIME_VALUE:
+ return icalvalue_time_as_ical_string(value);
+
+ case ICAL_PERIOD_VALUE:
+ return icalvalue_period_as_ical_string(value);
+ case ICAL_DATETIMEPERIOD_VALUE:
+ return icalvalue_datetimeperiod_as_ical_string(value);
+
+ case ICAL_FLOAT_VALUE:
+ return icalvalue_float_as_ical_string(value);
+
+ case ICAL_GEO_VALUE:
+ return icalvalue_geo_as_ical_string(value);
+
+ case ICAL_RECUR_VALUE:
+ return icalvalue_recur_as_ical_string(value);
+
+ case ICAL_TRIGGER_VALUE:
+ return icalvalue_trigger_as_ical_string(value);
+
+ case ICAL_METHOD_VALUE:
+ return icalenum_method_to_string(v->data.v_method);
+
+ case ICAL_STATUS_VALUE:
+ return icalenum_status_to_string(v->data.v_status);
+
+
+ case ICAL_NO_VALUE:
+ default:
+ {
+ return 0;
+ }
+ }
+}
+
+
+icalvalue_kind
+icalvalue_isa (icalvalue* value)
+{
+ struct icalvalue_impl* v = (struct icalvalue_impl*)value;
+
+ if(value == 0){
+ return ICAL_NO_VALUE;
+ }
+
+ return v->kind;
+}
+
+
+int
+icalvalue_isa_value (void* value)
+{
+ struct icalvalue_impl *impl = (struct icalvalue_impl *)value;
+
+ icalerror_check_arg_rz( (value!=0), "value");
+
+ if (strcmp(impl->id,"val") == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+icalparameter_xliccomparetype
+icalvalue_compare(icalvalue* a, icalvalue *b)
+{
+ struct icalvalue_impl *impla = (struct icalvalue_impl *)a;
+ struct icalvalue_impl *implb = (struct icalvalue_impl *)b;
+
+ icalerror_check_arg_rz( (a!=0), "a");
+ icalerror_check_arg_rz( (b!=0), "b");
+
+ /* Not the same type; they can only be unequal */
+ if (icalvalue_isa(a) != icalvalue_isa(b)){
+ return ICAL_XLICCOMPARETYPE_NOTEQUAL;
+ }
+
+ switch (icalvalue_isa(a)){
+
+ case ICAL_ATTACH_VALUE:
+ case ICAL_BINARY_VALUE:
+
+ case ICAL_BOOLEAN_VALUE:
+ {
+ if (icalvalue_get_boolean(a) == icalvalue_get_boolean(b)){
+ return ICAL_XLICCOMPARETYPE_EQUAL;
+ } else {
+ return ICAL_XLICCOMPARETYPE_NOTEQUAL;
+ }
+ }
+
+ case ICAL_FLOAT_VALUE:
+ {
+ if (impla->data.v_float > implb->data.v_float){
+ return ICAL_XLICCOMPARETYPE_GREATER;
+ } else if (impla->data.v_float < implb->data.v_float){
+ return ICAL_XLICCOMPARETYPE_LESS;
+ } else {
+ return ICAL_XLICCOMPARETYPE_EQUAL;
+ }
+ }
+
+ case ICAL_INTEGER_VALUE:
+ case ICAL_UTCOFFSET_VALUE:
+ {
+ if (impla->data.v_int > implb->data.v_int){
+ return ICAL_XLICCOMPARETYPE_GREATER;
+ } else if (impla->data.v_int < implb->data.v_int){
+ return ICAL_XLICCOMPARETYPE_LESS;
+ } else {
+ return ICAL_XLICCOMPARETYPE_EQUAL;
+ }
+ }
+
+ case ICAL_TEXT_VALUE:
+ case ICAL_URI_VALUE:
+ case ICAL_CALADDRESS_VALUE:
+ case ICAL_TRIGGER_VALUE:
+ case ICAL_DATE_VALUE:
+ case ICAL_DATETIME_VALUE:
+ case ICAL_DATETIMEDATE_VALUE:
+ case ICAL_DURATION_VALUE: /* HACK. Not correct for DURATION */
+ case ICAL_TIME_VALUE:
+ case ICAL_DATETIMEPERIOD_VALUE:
+ {
+ int r;
+
+ r = strcmp(icalvalue_as_ical_string(a),
+ icalvalue_as_ical_string(b));
+
+ if (r > 0) {
+ return ICAL_XLICCOMPARETYPE_GREATER;
+ } else if (r < 0){
+ return ICAL_XLICCOMPARETYPE_LESS;
+ } else {
+ return 0;
+ }
+
+
+ }
+
+ case ICAL_METHOD_VALUE:
+ {
+ if (icalvalue_get_method(a) == icalvalue_get_method(b)){
+ return ICAL_XLICCOMPARETYPE_EQUAL;
+ } else {
+ return ICAL_XLICCOMPARETYPE_NOTEQUAL;
+ }
+
+ }
+
+ case ICAL_STATUS_VALUE:
+ {
+ if (icalvalue_get_status(a) == icalvalue_get_status(b)){
+ return ICAL_XLICCOMPARETYPE_EQUAL;
+ } else {
+ return ICAL_XLICCOMPARETYPE_NOTEQUAL;
+ }
+
+ }
+
+ case ICAL_PERIOD_VALUE:
+ case ICAL_GEO_VALUE:
+ case ICAL_RECUR_VALUE:
+ case ICAL_NO_VALUE:
+ default:
+ {
+ icalerror_warn("Comparison not implemented for value type");
+ return ICAL_XLICCOMPARETYPE_REGEX+1; /* HACK */
+ }
+ }
+
+}
+
+void icalvalue_set_parent(icalvalue* value,
+ icalproperty* property)
+{
+ struct icalvalue_impl* v = (struct icalvalue_impl*)value;
+
+ v->parent = property;
+
+}
+
+icalproperty* icalvalue_get_parent(icalvalue* value)
+{
+ struct icalvalue_impl* v = (struct icalvalue_impl*)value;
+
+
+ return v->parent;
+}
+
+
+
+/* Recur is a special case, so it is not auto generated. Well,
+ actually, it is auto-generated, but you will have to manually
+ remove the auto-generated version after each generation. */
+icalvalue*
+icalvalue_new_recur (struct icalrecurrencetype v)
+{
+ struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE);
+
+ icalvalue_set_recur((icalvalue*)impl,v);
+
+ return (icalvalue*)impl;
+}
+
+void
+icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v)
+{
+ struct icalvalue_impl* impl;
+
+ icalerror_check_arg_rv( (value!=0),"value");
+ icalerror_check_value_type(value, ICAL_RECUR_VALUE);
+
+ impl = (struct icalvalue_impl*)value;
+
+ if (impl->data.v_recur != 0){
+ free(impl->data.v_recur);
+ impl->data.v_recur = 0;
+ }
+
+ impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
+
+ if (impl->data.v_recur == 0){
+ icalerror_set_errno(ICAL_ALLOCATION_ERROR);
+ return;
+ } else {
+ memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
+ }
+
+}
+
+struct icalrecurrencetype
+icalvalue_get_recur(icalvalue* value)
+{
+ icalerror_check_arg( (value!=0),"value");
+ icalerror_check_value_type(value, ICAL_RECUR_VALUE);
+
+ return *(((struct icalvalue_impl*)value)->data.v_recur);
+}
+
+
+
+
+/* The remaining interfaces are 'new', 'set' and 'get' for each of the value
+ types */
+
+
+/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalvalue.h.in b/libical/src/libical/icalvalue.h.in
new file mode 100644
index 0000000000..7ad2c3e0f3
--- /dev/null
+++ b/libical/src/libical/icalvalue.h.in
@@ -0,0 +1,58 @@
+/* -*- Mode: C -*- */
+/*======================================================================
+ FILE: icalvalue.h
+ CREATOR: eric 20 March 1999
+
+
+ $Id: icalvalue.h.in,v 1.1 2000/12/11 22:06:03 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 icalvalue.h
+
+ ======================================================================*/
+
+#ifndef ICALVALUE_H
+#define ICALVALUE_H
+
+#include <time.h>
+#include "icalenums.h"
+#include "icaltypes.h"
+#include "icalrecur.h"
+
+typedef void icalvalue;
+
+icalvalue* icalvalue_new(icalvalue_kind kind);
+
+icalvalue* icalvalue_new_clone(icalvalue* value);
+
+icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str);
+
+void icalvalue_free(icalvalue* value);
+
+int icalvalue_is_valid(icalvalue* value);
+
+const char* icalvalue_as_ical_string(icalvalue* value);
+
+icalvalue_kind icalvalue_isa(icalvalue* value);
+
+int icalvalue_isa_value(void*);
+
+icalparameter_xliccomparetype
+icalvalue_compare(icalvalue* a, icalvalue *b);
+
+/* Everything below this line is machine generated. Do not edit. */
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 <ctype.h> /* For tolower() */
+#include <string.h> /* for index() */
+#include <stdlib.h> /* for malloc and free */
+
+
+
+struct icalclassify_parts {
+ icalcomponent *c;
+ icalproperty_method method;
+ char* organizer;
+ icalparameter_partstat reply_partstat;
+ char* reply_attendee;
+ char* uid;
+ int sequence;
+ struct icaltimetype dtstamp;
+ struct icaltimetype recurrence_id;
+};
+
+
+char* icalclassify_lowercase(const char* str)
+{
+ char* p = 0;
+ char* new = icalmemory_strdup(str);
+
+ if(str ==0){
+ return 0;
+ }
+
+ for(p = new; *p!=0; p++){
+ *p = tolower(*p);
+ }
+
+ return new;
+}
+
+/* Return a set of components that intersect in time with comp. For
+component X and Y to intersect:
+ X.DTSTART < Y.DTEND && X.DTEND > Y.DTSTART
+*/
+
+
+icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp)
+{
+ icalcomponent *return_set;
+ icalcomponent *c;
+ struct icaltime_span span,compspan;
+
+ icalerror_clear_errno();
+ compspan = icalcomponent_get_span(comp);
+
+ if(icalerrno != ICAL_NO_ERROR){
+ return 0;
+ }
+
+
+ return_set = icalcomponent_new(ICAL_XROOT_COMPONENT);
+
+ for(c = icalset_get_first_component(set);
+ c != 0;
+ c = icalset_get_next_component(set)){
+
+ icalerror_clear_errno();
+
+ span = icalcomponent_get_span(c);
+
+ if(icalerrno != ICAL_NO_ERROR){
+ continue;
+ }
+
+ if (compspan.start < span.end &&
+ compspan.end > span.start){
+
+ icalcomponent *clone = icalcomponent_new_clone(c);
+
+ icalcomponent_add_component(return_set,clone);
+ }
+ }
+
+ if(icalcomponent_count_components(return_set,ICAL_ANY_COMPONENT) !=0){
+ return return_set;
+ } else {
+ icalcomponent_free(return_set);
+ return 0;
+ }
+}
+
+
+
+icalparameter_partstat icalclassify_find_attendee(icalcomponent *c,
+ const char* attendee)
+{
+ icalproperty *p;
+ char* lattendee = icalclassify_lowercase(attendee);
+ char* upn = 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.sequence<match_parts.sequence &&
+ icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
+ {
+ /* comp has a smaller sequence and a later DTSTAMP */
+ return ICAL_MISSEQUENCED_CLASS;
+ }
+
+ if( (comp_parts.sequence<match_parts.sequence )
+ /*&&icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0*/
+ ||
+ ( comp_parts.sequence == match_parts.sequence &&
+ icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){
+
+ return ICAL_OBSOLETE_CLASS;
+ }
+
+ }
+
+ p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
+ if (p == 0) {
+ return ICAL_UNKNOWN_CLASS;
+ }
+ method = icalproperty_get_method(p);
+
+ for (i =0; icalclassify_map[i].method != ICAL_METHOD_NONE; i++){
+ if(icalclassify_map[i].method == method){
+ if( (*(icalclassify_map[i].fn))(&comp_parts,&match_parts,user)==1){
+ class = icalclassify_map[i].class;
+ break;
+ }
+ }
+ }
+
+ icalssutil_free_parts(&comp_parts);
+ icalssutil_free_parts(&match_parts);
+
+ return class;
+
+}
diff --git a/libical/src/libicalss/icalclassify.h b/libical/src/libicalss/icalclassify.h
new file mode 100644
index 0000000000..ae76434378
--- /dev/null
+++ b/libical/src/libicalss/icalclassify.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C -*- */
+/*======================================================================
+ FILE: icalclassify.h
+ CREATOR: eric 21 Aug 2000
+
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of either:
+
+ The LGPL as published by the Free Software Foundation, version
+ 2.1, available at: http://www.fsf.org/copyleft/lesser.html
+
+ Or:
+
+ The Mozilla Public License Version 1.0. You may obtain a copy of
+ the License at http://www.mozilla.org/MPL/
+
+
+ =========================================================================*/
+
+#ifndef ICALCLASSIFY_H
+#define ICALCLASSIFY_H
+
+#include "ical.h"
+#include "icalset.h"
+
+
+typedef enum icalclass {
+ ICAL_NO_CLASS,
+ ICAL_PUBLISH_NEW_CLASS,
+ ICAL_PUBLISH_UPDATE_CLASS,
+ ICAL_PUBLISH_FREEBUSY_CLASS,
+ ICAL_REQUEST_NEW_CLASS,
+ ICAL_REQUEST_UPDATE_CLASS,
+ ICAL_REQUEST_RESCHEDULE_CLASS,
+ ICAL_REQUEST_DELEGATE_CLASS,
+ ICAL_REQUEST_NEW_ORGANIZER_CLASS,
+ ICAL_REQUEST_FORWARD_CLASS,
+ ICAL_REQUEST_STATUS_CLASS,
+ ICAL_REQUEST_FREEBUSY_CLASS,
+ ICAL_REPLY_ACCEPT_CLASS,
+ ICAL_REPLY_DECLINE_CLASS,
+ ICAL_REPLY_CRASHER_ACCEPT_CLASS,
+ ICAL_REPLY_CRASHER_DECLINE_CLASS,
+ ICAL_ADD_INSTANCE_CLASS,
+ ICAL_CANCEL_EVENT_CLASS,
+ ICAL_CANCEL_INSTANCE_CLASS,
+ ICAL_CANCEL_ALL_CLASS,
+ ICAL_REFRESH_CLASS,
+ ICAL_COUNTER_CLASS,
+ ICAL_DECLINECOUNTER_CLASS,
+ ICAL_MALFORMED_CLASS,
+ ICAL_OBSOLETE_CLASS, /* 21 */
+ ICAL_MISSEQUENCED_CLASS, /* 22 */
+ ICAL_UNKNOWN_CLASS /* 23 */
+} ical_class;
+
+ical_class icalclassify(icalcomponent* c,icalcomponent* match,
+ const char* user);
+
+icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
+
+#endif /* ICALCLASSIFY_H*/
+
+
+
+
+
diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c
new file mode 100644
index 0000000000..2c86ddcc2c
--- /dev/null
+++ b/libical/src/libicalss/icalcstp.c
@@ -0,0 +1,376 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: icalcstps.c
+ CREATOR: ebusboom 23 Jun 2000
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of either:
+
+ The LGPL as published by the Free Software Foundation, version
+ 2.1, available at: http://www.fsf.org/copyleft/lesser.html
+
+ Or:
+
+ The Mozilla Public License Version 1.0. You may obtain a copy of
+ the License at http://www.mozilla.org/MPL/
+
+
+ ======================================================================*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ical.h"
+#include "icalcstp.h"
+#include "pvl.h"
+
+#include <sys/types.h> /* For send(), others */
+#include <sys/socket.h> /* For send(), others. */
+#include <unistd.h> /* For alarm */
+#include <errno.h>
+
+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 <ctype.h> /* for tolower()*/
+#include <string.h> /* for strstr */
+#include <stdlib.h> /* for free(), malloc() */
+icalcomponent* icalmessage_get_inner(icalcomponent* comp)
+{
+ if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
+ return icalcomponent_get_first_real_component(comp);
+ } else {
+ return comp;
+ }
+}
+
+char* lowercase(const char* str)
+{
+ char* p = 0;
+ char* 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 <stdlib.h> /* for free and malloc */
+
+struct icalspanlist_impl {
+ pvl_list spans;
+};
+
+int compare_span(void* a, void* b)
+{
+ struct icaltime_span *span_a = (struct icaltime_span *)a ;
+ struct icaltime_span *span_b = (struct icaltime_span *)b ;
+
+ if(span_a->start == span_b->start){
+ return 0;
+ } else if(span_a->start < span_b->start){
+ return -1;
+ } else { /*if(span_a->start > span->b.start)*/
+ return 1;
+ }
+}
+
+icalcomponent* icalspanlist_get_inner(icalcomponent* comp)
+{
+ if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
+ return icalcomponent_get_first_real_component(comp);
+ } else {
+ return comp;
+ }
+}
+
+
+void print_span(int c, struct icaltime_span span );
+
+
+/* Make a free list from a set of component */
+icalspanlist* icalspanlist_new(icalset *set,
+ struct icaltimetype start,
+ struct icaltimetype end)
+{
+ struct icaltime_span range;
+ pvl_elem itr;
+ icalcomponent *c,*inner;
+ icalcomponent_kind kind, inner_kind;
+ struct icalspanlist_impl *sl;
+ struct icaltime_span *freetime;
+
+ if ( ( sl = (struct icalspanlist_impl*)
+ malloc(sizeof(struct icalspanlist_impl))) == 0) {
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ sl->spans = pvl_newlist();
+
+ range.start = icaltime_as_timet(start);
+ range.end = icaltime_as_timet(end);
+
+ printf("Range start: %s",ctime(&range.start));
+ printf("Range end : %s",ctime(&range.end));
+
+
+ /* Get a list of spans of busy time from the events in the set
+ and order the spans based on the start time */
+
+ for(c = icalset_get_first_component(set);
+ c != 0;
+ c = icalset_get_next_component(set)){
+
+ struct icaltime_span span;
+
+ kind = icalcomponent_isa(c);
+ inner = icalcomponent_get_inner(c);
+
+ if(!inner){
+ continue;
+ }
+
+ inner_kind = icalcomponent_isa(inner);
+
+ if( kind != ICAL_VEVENT_COMPONENT &&
+ inner_kind != ICAL_VEVENT_COMPONENT){
+ continue;
+ }
+
+ icalerror_clear_errno();
+
+ span = icalcomponent_get_span(c);
+ span.is_busy = 1;
+
+ if(icalerrno != ICAL_NO_ERROR){
+ continue;
+ }
+
+ if ((range.start < span.end && icaltime_is_null_time(end)) ||
+ (range.start < span.end && range.end > span.start )){
+
+ struct icaltime_span *s;
+
+ if ((s=(struct icaltime_span *)
+ malloc(sizeof(struct icaltime_span))) == 0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ memcpy(s,&span,sizeof(span));
+
+ pvl_insert_ordered(sl->spans,compare_span,(void*)s);
+
+ }
+ }
+
+ /* Now Fill in the free time spans. loop through the spans. if the
+ start of the range is not within the span, create a free entry
+ that runs from the start of the range to the start of the
+ span. */
+
+ for( itr = pvl_head(sl->spans);
+ itr != 0;
+ itr = pvl_next(itr))
+ {
+ struct icaltime_span *s = (icalproperty*)pvl_data(itr);
+
+ if ((freetime=(struct icaltime_span *)
+ malloc(sizeof(struct icaltime_span))) == 0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ if(range.start < s->start){
+ freetime->start = range.start;
+ freetime->end = s->start;
+
+ freetime->is_busy = 0;
+
+
+ pvl_insert_ordered(sl->spans,compare_span,(void*)freetime);
+ } else {
+ free(freetime);
+ }
+
+ range.start = s->end;
+ }
+
+ /* If the end of the range is null, then assume that everything
+ after the last item in the calendar is open and add a span
+ that indicates this */
+
+ if( icaltime_is_null_time(end)){
+ struct icaltime_span* last_span;
+
+ last_span = pvl_data(pvl_tail(sl->spans));
+
+ if (last_span != 0){
+
+ if ((freetime=(struct icaltime_span *)
+ malloc(sizeof(struct icaltime_span))) == 0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return 0;
+ }
+
+ freetime->is_busy = 0;
+ freetime->start = last_span->end;
+ freetime->end = freetime->start;
+ pvl_insert_ordered(sl->spans,compare_span,(void*)freetime);
+ }
+ }
+
+
+ return sl;
+
+}
+
+void icalspanlist_free(icalspanlist* s)
+{
+ struct icaltime_span *span;
+ struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s;
+
+ while( (span=pvl_pop(impl->spans)) != 0){
+ free(span);
+ }
+
+ pvl_free(impl->spans);
+
+ impl->spans = 0;
+}
+
+
+void icalspanlist_dump(icalspanlist* s){
+
+ int i = 0;
+ struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s;
+ pvl_elem itr;
+
+ for( itr = pvl_head(sl->spans);
+ itr != 0;
+ itr = pvl_next(itr))
+ {
+ struct icaltime_span *s = (icalproperty*)pvl_data(itr);
+
+ printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start));
+ printf(" end : %s",ctime(&s->end));
+
+ }
+}
+
+icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
+icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
+
+struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
+ struct icaltimetype t)
+{
+ struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl;
+ pvl_elem itr;
+ struct icalperiodtype period;
+ struct icaltime_span *s;
+
+ time_t rangett= icaltime_as_timet(t);
+
+ period.start = icaltime_null_time();
+ period.end = icaltime_null_time();
+
+ /* Is the reference time before the first span? If so, assume
+ that the reference time is free */
+ itr = pvl_head(impl->spans);
+ s = (icalproperty*)pvl_data(itr);
+
+ if (s == 0){
+ /* No elements in span */
+ return period;
+ }
+
+ if(rangett <s->start ){
+ /* End of period is start of first span if span is busy, end
+ of the span if it is free */
+ period.start = t;
+
+ if (s->is_busy == 0){
+ period.end = icaltime_from_timet(s->start,0,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 <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* 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 <io.h>
+#include <stdlib.h>
+#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 <string.h> /* For strdup() */
+
+int icalparser_flex_input(char* buf, int max_size);
+void icalparser_clear_flex_input();
+
+#undef YY_INPUT
+#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
+
+#undef SS_FATAL_ERROR
+#define SS_FATAL_ERROR(msg) sserror(msg)
+
+
+#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 <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines. This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#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 <string.h> /* For strdup() */
+
+int icalparser_flex_input(char* buf, int max_size);
+void icalparser_clear_flex_input();
+
+#undef YY_INPUT
+#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
+
+#undef SS_FATAL_ERROR
+#define SS_FATAL_ERROR(msg) sserror(msg)
+
+
+%}
+
+crlf \x0D?\x0A
+space [ ]
+qsafechar [^\x00-\x1F\"]
+safechar [^\x00-\x1F\"\:\;\,]
+tsafechar [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E]
+valuechar [^\x00-\x08\x10-\x1F]
+xname X-[a-zA-Z0-9\-]+
+xname2 [a-zA-Z0-9\-\ ]
+paramtext {safechar}+
+value {valuechar}+
+quotedstring \"{qsafechar}+\"
+digit [0-9]
+
+%array /* Make yytext an array. Slow, but handy. HACK */
+
+%option caseless
+
+%s sql string_value
+
+
+
+%%
+
+%{
+%}
+
+
+SELECT { return SELECT; }
+FROM { return FROM; }
+WHERE { return WHERE; }
+, { return COMMA; }
+"=" { return EQUALS; }
+"!=" { return NOTEQUALS; }
+"<" { return LESS; }
+">" { return GREATER; }
+"<=" { return LESSEQUALS; }
+">=" { return GREATEREQUALS; }
+AND { return AND; }
+OR { return OR; }
+[ \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 <stdlib.h>
+#include <string.h> /* for strdup() */
+#include <limits.h> /* 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 <stdio.h>
+
+#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 <alloca.h>
+#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 <malloc.h>
+#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 <malloc.h> */
+ #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 <stdlib.h>
+#include <string.h> /* for strdup() */
+#include <limits.h> /* 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 <v_string> 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);
+}
diff --git a/libical/src/test/process.c b/libical/src/test/process.c
new file mode 100644
index 0000000000..42ae3b8037
--- /dev/null
+++ b/libical/src/test/process.c
@@ -0,0 +1,452 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: process.c
+ CREATOR: eric 11 February 2000
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2000 Eric Busboom
+ http://www.softwarestudio.org
+
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.0 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and
+ limitations under the License.
+
+ The Original Code is eric. The Initial Developer of the Original
+ Code is Eric Busboom
+
+
+ ======================================================================*/
+
+#include <stdio.h> /* for printf */
+#include "ical.h"
+#include "icalss.h"
+#include <errno.h>
+#include <string.h> /* For strerror */
+#include <stdlib.h> /* for free */
+
+struct class_map {
+ ical_class class;
+ char *str;
+} class_map[] = {
+ {ICAL_NO_CLASS,"No class"},
+ {ICAL_PUBLISH_NEW_CLASS,"New Publish"},
+ {ICAL_PUBLISH_UPDATE_CLASS,"New Publish"},
+ {ICAL_REQUEST_NEW_CLASS,"New request"},
+ {ICAL_REQUEST_UPDATE_CLASS,"Update"},
+ {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"},
+ {ICAL_REQUEST_DELEGATE_CLASS,"Delegate"},
+ {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"},
+ {ICAL_REQUEST_FORWARD_CLASS,"Forward"},
+ {ICAL_REQUEST_STATUS_CLASS,"Status request"},
+ {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"},
+ {ICAL_REPLY_DECLINE_CLASS,"Decline reply"},
+ {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"},
+ {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"},
+ {ICAL_ADD_INSTANCE_CLASS,"Add instance"},
+ {ICAL_CANCEL_EVENT_CLASS,"Cancel event"},
+ {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"},
+ {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"},
+ {ICAL_REFRESH_CLASS,"Refresh"},
+ {ICAL_COUNTER_CLASS,"Counter"},
+ {ICAL_DECLINECOUNTER_CLASS,"Decline counter"},
+ {ICAL_MALFORMED_CLASS,"Malformed"},
+ {ICAL_OBSOLETE_CLASS,"Obsolete"},
+ {ICAL_MISSEQUENCED_CLASS,"Missequenced"},
+ {ICAL_UNKNOWN_CLASS,"Unknown"}
+};
+
+char* find_class_string(ical_class class)
+{
+ int i;
+
+ for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){
+ if (class_map[i].class == class){
+ return class_map[i].str;
+ }
+ }
+
+ return "Unknown";
+}
+
+void send_message(icalcomponent *reply,const char* this_user)
+{
+ printf("From: %s\n\n%s\n",this_user,icalcomponent_as_ical_string(reply));
+
+
+}
+
+
+int main(int argc, char* argv[])
+{
+ icalcomponent *c, *next_c;
+ int i=0;
+ char *class_string;
+ int dont_remove;
+
+ icalset* f = icalset_new_file("../../test-data/process-incoming.ics");
+ icalset* trash = icalset_new_file("trash.ics");
+ icalset* cal = icalset_new_file("../../test-data/process-calendar.ics");
+ icalset* out = icalset_new_file("outgoing.ics");
+
+ const char* this_user = "alice@cal.softwarestudio.org";
+
+ assert(f!= 0);
+ assert(cal!=0);
+ assert(trash!=0);
+ assert(out!=0);
+
+
+ /* Foreach incoming message */
+ for(c=icalset_get_first_component(f);c!=0;c = next_c){
+
+ ical_class class;
+ icalcomponent *match;
+ icalcomponent *inner;
+ icalcomponent *p;
+ icalcomponent *reply = 0;
+
+ assert(c!=0);
+
+ inner = icalcomponent_get_first_real_component(c);
+
+ i++;
+ reply = 0;
+ dont_remove = 0;
+
+ if(inner == 0){
+ printf("Bad component, no inner\n %s\n",
+ icalcomponent_as_ical_string(c));
+ continue;
+ }
+
+ /* Find a booked component that is matched to the incoming
+ message, based on the incoming component's UID, SEQUENCE
+ and RECURRENCE-ID*/
+
+ match = icalset_fetch_match(cal,c);
+
+ class = icalclassify(c,match,this_user);
+
+ class_string = find_class_string(class);
+
+ /* Print out the notes associated with the incoming component
+ and the matched component in the */
+ {
+ const char *c_note=0;
+ const char *m_note=0;
+ icalproperty *p;
+
+ for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY);
+ p!= 0;
+ p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){
+
+ if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){
+ c_note = icalproperty_get_x(p);
+ }
+ }
+
+ if (match != 0){
+ for(p = icalcomponent_get_first_property(match,
+ ICAL_X_PROPERTY);
+ p!= 0;
+ p = icalcomponent_get_next_property(match,
+ ICAL_X_PROPERTY)){
+ if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){
+ m_note = icalproperty_get_x(p);
+ }
+ }
+ }
+
+ if(c_note != 0){
+ printf("Incoming: %s\n",c_note);
+ }
+ if(m_note != 0){
+ printf("Match : %s\n",m_note);
+ }
+ }
+
+ /* Main processing structure */
+
+ switch (class){
+ case ICAL_NO_CLASS: {
+ char temp[1024];
+ /* Huh? Return an error to sender */
+ icalrestriction_check(c);
+ icalcomponent_convert_errors(c);
+
+ snprintf(temp,1024,"I can't understand the component you sent. \n Here is the component you sent, possibly with error messages:\n %s",icalcomponent_as_ical_string(c));
+
+ reply = icalmessage_new_error_reply(
+ c,
+ this_user,
+ temp,
+ "",
+ ICAL_UNKNOWN_STATUS
+ );
+
+
+
+ break;
+ }
+ case ICAL_PUBLISH_NEW_CLASS: {
+
+ /* Don't accept published events from anyone but
+ self. If self, fall through to ICAL_REQUEST_NEW_CLASS */
+
+
+
+ }
+ case ICAL_REQUEST_NEW_CLASS: {
+
+ /* Book the new component if it does not overlap
+ anything. If the time is busy and the start time is
+ an even modulo 4, delegate to
+ bob@cal.softwarestudio.org. If the time is busy and
+ is 1 modulo 4, counterpropose for the first
+ available free time. Otherwise, deline the meeting */
+
+ icalcomponent *overlaps;
+ overlaps = icalclassify_find_overlaps(cal,c);
+
+ if(overlaps == 0){
+ /* No overlaps, book the meeting */
+/* icalset_add_component(cal,icalcomponent_new_clone(c));*/
+
+ /* Return a reply */
+ reply = icalmessage_new_accept_reply(c,this_user,
+ "I can make it to this meeting");
+
+ icalset_add_component(out,reply);
+
+ } else {
+ /* There was a conflict, so delegate, counterpropose
+ or decline it */
+ struct icaltimetype dtstart
+ = icalcomponent_get_dtstart(c);
+
+ if(dtstart.hour%4 == 0){
+ /* Delegate the meeting */
+ reply = icalmessage_new_delegate_reply(c,
+ this_user,
+ "bob@cal.softwarestudio.org",
+ "Unfortunately, I have another commitment that \
+conflicts with this meeting. I am delegating my attendance to Bob. ");
+
+ icalset_add_component(out,reply);
+
+
+ } else if (dtstart.hour%4 == 1) {
+ /* Counter propose to next available time */
+ icalcomponent *newc;
+ struct icalperiodtype next_time;
+
+ icalspanlist *spanl =
+ icalspanlist_new(cal,dtstart,
+ icaltime_null_time());
+
+ next_time = icalspanlist_next_free_time(
+ spanl,icalcomponent_get_dtstart(c));
+
+ newc = icalcomponent_new_clone(c);
+
+ icalcomponent_set_dtstart(newc,next_time.start);
+
+
+ /* Hack, the duration of the counterproposed
+ meeting may be longer than the free time
+ available */
+ icalcomponent_set_duration(newc,
+ icalcomponent_get_duration(c));
+
+ reply = icalmessage_new_counterpropose_reply(c,
+ newc,
+ this_user,
+ "Unfortunately, I have another commitment that \
+conflicts with this meeting. I am proposing a time that works better for me.");
+
+ icalset_add_component(out,reply);
+
+ } else {
+ /* Decline the meeting */
+
+ reply = icalmessage_new_decline_reply(c,
+ this_user,
+ "I can't make it to this meeting");
+
+ icalset_add_component(out,reply);
+
+ }
+
+
+ }
+ break;
+ }
+ case ICAL_PUBLISH_FREEBUSY_CLASS: {
+ /* Store the busy time information in a file named after
+ the sender */
+ break;
+ }
+
+ case ICAL_PUBLISH_UPDATE_CLASS: {
+ /* Only accept publish updates from self. If self, fall
+ throught to ICAL_REQUEST_UPDATE_CLASS */
+ }
+
+ case ICAL_REQUEST_UPDATE_CLASS: {
+ /* always accept the changes */
+ break;
+ }
+
+ case ICAL_REQUEST_RESCHEDULE_CLASS: {
+ /* Use same rules as REQUEST_NEW */
+ icalcomponent *overlaps;
+ overlaps = icalclassify_find_overlaps(cal,c);
+
+ break;
+ }
+ case ICAL_REQUEST_DELEGATE_CLASS: {
+
+ break;
+ }
+ case ICAL_REQUEST_NEW_ORGANIZER_CLASS: {
+ break;
+ }
+ case ICAL_REQUEST_FORWARD_CLASS: {
+ break;
+ }
+ case ICAL_REQUEST_STATUS_CLASS: {
+ break;
+ }
+
+ case ICAL_REQUEST_FREEBUSY_CLASS: {
+ break;
+ }
+ case ICAL_REPLY_ACCEPT_CLASS: {
+ /* Change the PARTSTAT of the sender */
+ break;
+ }
+ case ICAL_REPLY_DECLINE_CLASS: {
+ /* Change the PARTSTAT of the sender */
+ break;
+ }
+ case ICAL_REPLY_CRASHER_ACCEPT_CLASS: {
+ /* Add the crasher to the ATTENDEE list with the
+ appropriate PARTSTAT */
+ break;
+ }
+ case ICAL_REPLY_CRASHER_DECLINE_CLASS: {
+ /* Add the crasher to the ATTENDEE list with the
+ appropriate PARTSTAT */
+ break;
+ }
+ case ICAL_ADD_INSTANCE_CLASS: {
+ break;
+ }
+ case ICAL_CANCEL_EVENT_CLASS: {
+ /* Remove the component */
+ break;
+ }
+ case ICAL_CANCEL_INSTANCE_CLASS: {
+ break;
+ }
+ case ICAL_CANCEL_ALL_CLASS: {
+ /* Remove the component */
+ break;
+ }
+ case ICAL_REFRESH_CLASS: {
+ /* Resend the latest copy of the request */
+ break;
+ }
+ case ICAL_COUNTER_CLASS: {
+ break;
+ }
+ case ICAL_DECLINECOUNTER_CLASS: {
+ break;
+ }
+ case ICAL_MALFORMED_CLASS: {
+ /* Send back an error */
+ break;
+ }
+ case ICAL_OBSOLETE_CLASS: {
+ printf(" ** Got an obsolete component:\n%s",
+ icalcomponent_as_ical_string(c));
+ /* Send back an error */
+ break;
+ }
+ case ICAL_MISSEQUENCED_CLASS: {
+ printf(" ** Got a missequenced component:\n%s",
+ icalcomponent_as_ical_string(c));
+ /* Send back an error */
+ break;
+ }
+ case ICAL_UNKNOWN_CLASS: {
+ printf(" ** Don't know what to do with this component:\n%s",
+ icalcomponent_as_ical_string(c));
+ /* Send back an error */
+ break;
+ }
+ }
+
+#if(0)
+ if (reply != 0){
+
+ /* Don't send the reply if the RSVP parameter indicates not to*/
+ icalcomponent *reply_inner;
+ icalproperty *attendee;
+ icalparameter *rsvp;
+
+ reply_inner = icalcomponent_get_first_real_component(reply);
+ attendee = icalcomponent_get_first_property(reply_inner,
+ ICAL_ATTENDEE_PROPERTY);
+ rsvp = icalproperty_get_first_parameter(attendee,
+ ICAL_RSVP_PARAMETER);
+
+ if(rsvp == 0 || icalparameter_get_rsvp(rsvp) == 1){
+ icalrestriction_check(reply);
+ send_message(reply,this_user);
+ }
+
+ icalcomponent_free(reply);
+ }
+#endif
+
+ if(reply !=0){
+ printf("%s\n",icalcomponent_as_ical_string(reply));
+ }
+
+ next_c = icalset_get_next_component(f);
+
+ if(dont_remove == 0){
+ /*icalset_remove_component(f,c);
+ icalset_add_component(trash,c);*/
+ }
+ }
+
+#if (0)
+
+ for(c = icalset_get_first_component(out);
+ c!=0;
+ c = icalset_get_next_component(out)){
+
+ printf("%s",icalcomponent_as_ical_string(c));
+
+ }
+#endif
+
+ icalset_free(f);
+ icalset_free(trash);
+ icalset_free(cal);
+ icalset_free(out);
+
+ return 0;
+}
+
+
diff --git a/libical/src/test/testclassify.c b/libical/src/test/testclassify.c
new file mode 100644
index 0000000000..821baac251
--- /dev/null
+++ b/libical/src/test/testclassify.c
@@ -0,0 +1,157 @@
+/* -*- Mode: C -*-
+ ======================================================================
+ FILE: testclassify.c
+ CREATOR: eric 11 February 2000
+
+ $Id$
+ $Locker$
+
+ (C) COPYRIGHT 2000 Eric Busboom
+ http://www.softwarestudio.org
+
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.0 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and
+ limitations under the License.
+
+ The Original Code is eric. The Initial Developer of the Original
+ Code is Eric Busboom
+
+
+ ======================================================================*/
+
+#include <stdio.h> /* for printf */
+#include "ical.h"
+#include <errno.h>
+#include <string.h> /* For strerror */
+#include "icalset.h"
+#include "icalclassify.h"
+#include "icalssutil.h"
+
+
+struct class_map {
+ ical_class class;
+ char *str;
+} class_map[] = {
+ {ICAL_NO_CLASS,"No class"},
+ {ICAL_PUBLISH_NEW_CLASS,"New Publish"},
+ {ICAL_PUBLISH_UPDATE_CLASS,"Update Publish"},
+ {ICAL_REQUEST_NEW_CLASS,"New request"},
+ {ICAL_REQUEST_UPDATE_CLASS,"Update"},
+ {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"},
+ {ICAL_REQUEST_DELEGATE_CLASS,"Delegate"},
+ {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"},
+ {ICAL_REQUEST_FORWARD_CLASS,"Forward"},
+ {ICAL_REQUEST_STATUS_CLASS,"Status request"},
+ {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"},
+ {ICAL_REPLY_DECLINE_CLASS,"Decline reply"},
+ {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"},
+ {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"},
+ {ICAL_ADD_INSTANCE_CLASS,"Add instance"},
+ {ICAL_CANCEL_EVENT_CLASS,"Cancel event"},
+ {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"},
+ {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"},
+ {ICAL_REFRESH_CLASS,"Refresh"},
+ {ICAL_COUNTER_CLASS,"Counter"},
+ {ICAL_DECLINECOUNTER_CLASS,"Decline counter"},
+ {ICAL_MALFORMED_CLASS,"Malformed"},
+ {ICAL_OBSOLETE_CLASS,"Obsolete"},
+ {ICAL_MISSEQUENCED_CLASS,"Missequenced"},
+ {ICAL_UNKNOWN_CLASS,"Unknown"}
+};
+
+char* find_class_string(ical_class class)
+{
+ int i;
+
+ for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){
+ if (class_map[i].class == class){
+ return class_map[i].str;
+ }
+ }
+
+ return "Unknown";
+}
+
+
+int main(int argc, char* argv[])
+{
+ icalcomponent *c;
+ int i=0;
+
+ icalset* f = icalset_new_file("../../test-data/incoming.ics");
+ icalset* cal = icalset_new_file("../../test-data/calendar.ics");
+
+ assert(f!= 0);
+ assert(cal!=0);
+
+
+ /* Foreach incoming message */
+ for(c=icalset_get_first_component(f);c!=0;
+ c=icalset_get_next_component(f)){
+
+ ical_class class;
+ icalcomponent *match;
+ icalcomponent *inner = icalcomponent_get_first_real_component(c);
+ icalcomponent *p;
+ const char *this_uid;
+ const char *i_x_note=0;
+ const char *c_x_note=0;
+
+ i++;
+
+ if(inner == 0){
+ continue;
+ }
+
+ p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
+ this_uid = icalproperty_get_uid(p);
+
+ assert(this_uid != 0);
+
+ /* Find a booked component that is matched to the incoming
+ message, based on the incoming component's UID, SEQUENCE
+ and RECURRENCE-ID*/
+
+ match = icalset_fetch(cal,this_uid);
+
+ class = icalclassify(c,match,"A@example.com");
+
+ for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY);
+ p!= 0;
+ p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){
+ if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){
+ i_x_note = icalproperty_get_x(p);
+ }
+ }
+
+
+ if(i_x_note == 0){
+ i_x_note = "None";
+ }
+
+ for(p = icalcomponent_get_first_property(match,ICAL_X_PROPERTY);
+ p!= 0;
+ p = icalcomponent_get_next_property(match,ICAL_X_PROPERTY)){
+ if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){
+ c_x_note = icalproperty_get_x(p);
+ }
+ }
+
+ if(c_x_note == 0){
+ c_x_note = "None";
+ }
+
+
+ printf("Test %d\nIncoming: %s\nMatched: %s\nClassification: %s\n\n",i,i_x_note,c_x_note,find_class_string(class));
+ }
+
+ return 0;
+}
+
+