aboutsummaryrefslogtreecommitdiffstats
path: root/libical/src
diff options
context:
space:
mode:
Diffstat (limited to 'libical/src')
-rw-r--r--libical/src/.cvsignore2
-rw-r--r--libical/src/Makefile.am7
-rw-r--r--libical/src/libical/.cvsignore22
-rw-r--r--libical/src/libical/Makefile.am237
-rw-r--r--libical/src/libical/icalarray.c147
-rw-r--r--libical/src/libical/icalarray.h61
-rw-r--r--libical/src/libical/icalattendee.c30
-rw-r--r--libical/src/libical/icalattendee.h68
-rw-r--r--libical/src/libical/icalcomponent.c1917
-rw-r--r--libical/src/libical/icalcomponent.h264
-rw-r--r--libical/src/libical/icalderivedparameter.c.in211
-rw-r--r--libical/src/libical/icalderivedparameter.h.in37
-rw-r--r--libical/src/libical/icalderivedproperty.c.in250
-rw-r--r--libical/src/libical/icalderivedproperty.h.in23
-rw-r--r--libical/src/libical/icalderivedvalue.c.in299
-rw-r--r--libical/src/libical/icalderivedvalue.h.in58
-rw-r--r--libical/src/libical/icalduration.c320
-rw-r--r--libical/src/libical/icalduration.h60
-rw-r--r--libical/src/libical/icalenums.c135
-rw-r--r--libical/src/libical/icalenums.h157
-rw-r--r--libical/src/libical/icalerror.c194
-rw-r--r--libical/src/libical/icalerror.h153
-rw-r--r--libical/src/libical/icallangbind.c272
-rw-r--r--libical/src/libical/icallangbind.h49
-rw-r--r--libical/src/libical/icallexer.l161
-rw-r--r--libical/src/libical/icalmemory.c287
-rw-r--r--libical/src/libical/icalmemory.h80
-rw-r--r--libical/src/libical/icalmime.c386
-rw-r--r--libical/src/libical/icalmime.h43
-rw-r--r--libical/src/libical/icalparameter.c392
-rw-r--r--libical/src/libical/icalparameter.h69
-rw-r--r--libical/src/libical/icalparameterimpl.h52
-rw-r--r--libical/src/libical/icalparser.c1121
-rw-r--r--libical/src/libical/icalparser.h93
-rw-r--r--libical/src/libical/icalperiod.c170
-rw-r--r--libical/src/libical/icalperiod.h55
-rw-r--r--libical/src/libical/icalproperty.c808
-rw-r--r--libical/src/libical/icalproperty.h116
-rw-r--r--libical/src/libical/icalrecur.c2353
-rw-r--r--libical/src/libical/icalrecur.h189
-rw-r--r--libical/src/libical/icalrestriction.c.in447
-rw-r--r--libical/src/libical/icalrestriction.h64
-rw-r--r--libical/src/libical/icaltime.c714
-rw-r--r--libical/src/libical/icaltime.h156
-rw-r--r--libical/src/libical/icaltimezone.c1597
-rw-r--r--libical/src/libical/icaltimezone.h142
-rw-r--r--libical/src/libical/icaltypes.c263
-rw-r--r--libical/src/libical/icaltypes.h136
-rw-r--r--libical/src/libical/icalvalue.c1196
-rw-r--r--libical/src/libical/icalvalue.h85
-rw-r--r--libical/src/libical/icalvalueimpl.h91
-rw-r--r--libical/src/libical/icalversion.h.in7
-rw-r--r--libical/src/libical/icalyacc.y404
-rw-r--r--libical/src/libical/pvl.c761
-rw-r--r--libical/src/libical/pvl.h94
-rw-r--r--libical/src/libical/sspm.c1613
-rw-r--r--libical/src/libical/sspm.h143
-rw-r--r--libical/src/libical/vsnprintf.c167
-rw-r--r--libical/src/libicalss/.cvsignore10
-rw-r--r--libical/src/libicalss/Makefile.am69
-rw-r--r--libical/src/libicalss/icalcalendar.c265
-rw-r--r--libical/src/libicalss/icalcalendar.h67
-rw-r--r--libical/src/libicalss/icalclassify.c696
-rw-r--r--libical/src/libicalss/icalclassify.h73
-rw-r--r--libical/src/libicalss/icalcomponent.h115
-rw-r--r--libical/src/libicalss/icalcsdb.h67
-rw-r--r--libical/src/libicalss/icalcstp.c116
-rw-r--r--libical/src/libicalss/icalcstp.h79
-rw-r--r--libical/src/libicalss/icalcstpclient.c343
-rw-r--r--libical/src/libicalss/icalcstpclient.h100
-rw-r--r--libical/src/libicalss/icalcstpserver.c278
-rw-r--r--libical/src/libicalss/icalcstpserver.h101
-rw-r--r--libical/src/libicalss/icaldirset.c753
-rw-r--r--libical/src/libicalss/icaldirset.h82
-rw-r--r--libical/src/libicalss/icaldirsetimpl.h47
-rw-r--r--libical/src/libicalss/icalfileset.c637
-rw-r--r--libical/src/libicalss/icalfileset.h105
-rw-r--r--libical/src/libicalss/icalfilesetimpl.h49
-rw-r--r--libical/src/libicalss/icalgauge.c447
-rw-r--r--libical/src/libicalss/icalgauge.h51
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h63
-rw-r--r--libical/src/libicalss/icalmessage.c376
-rw-r--r--libical/src/libicalss/icalmessage.h71
-rw-r--r--libical/src/libicalss/icalset.c367
-rw-r--r--libical/src/libicalss/icalset.h111
-rw-r--r--libical/src/libicalss/icalspanlist.c309
-rw-r--r--libical/src/libicalss/icalspanlist.h54
-rw-r--r--libical/src/libicalss/icalsslexer.l113
-rw-r--r--libical/src/libicalss/icalssutil.c29
-rw-r--r--libical/src/libicalss/icalssutil.h27
-rw-r--r--libical/src/libicalss/icalssyacc.h22
-rw-r--r--libical/src/libicalss/icalssyacc.y245
-rw-r--r--libical/src/libicalvcal/.cvsignore12
-rw-r--r--libical/src/libicalvcal/Makefile.am29
-rw-r--r--libical/src/libicalvcal/README.TXT951
-rw-r--r--libical/src/libicalvcal/icalvcal.c517
-rw-r--r--libical/src/libicalvcal/icalvcal.h39
-rw-r--r--libical/src/libicalvcal/port.h88
-rw-r--r--libical/src/libicalvcal/vcaltest.c118
-rw-r--r--libical/src/libicalvcal/vcaltmp.c337
-rw-r--r--libical/src/libicalvcal/vcaltmp.h128
-rw-r--r--libical/src/libicalvcal/vcc.h80
-rw-r--r--libical/src/libicalvcal/vcc.y1176
-rw-r--r--libical/src/libicalvcal/vctest.c95
-rw-r--r--libical/src/libicalvcal/vobject.c1452
-rw-r--r--libical/src/libicalvcal/vobject.h366
-rw-r--r--libical/src/python/.cvsignore2
-rw-r--r--libical/src/python/ChangeLog109
-rw-r--r--libical/src/python/Collection.py124
-rw-r--r--libical/src/python/Component.py670
-rw-r--r--libical/src/python/DerivedProperties.py59
-rw-r--r--libical/src/python/Libical.py39
-rw-r--r--libical/src/python/LibicalWrap.i352
-rw-r--r--libical/src/python/Makefile.am42
-rw-r--r--libical/src/python/Property.py839
-rw-r--r--libical/src/python/Store.py176
-rw-r--r--libical/src/python/python-binding.txt434
-rw-r--r--libical/src/python/test.py373
-rw-r--r--libical/src/test/.cvsignore18
-rw-r--r--libical/src/test/Makefile.am25
-rw-r--r--libical/src/test/copycluster.c130
-rw-r--r--libical/src/test/findobj.c72
-rw-r--r--libical/src/test/icaltestparser.c122
-rw-r--r--libical/src/test/process.c446
-rw-r--r--libical/src/test/recur.c120
-rw-r--r--libical/src/test/regression.c3605
-rw-r--r--libical/src/test/storage.c459
-rw-r--r--libical/src/test/stow.c866
-rw-r--r--libical/src/test/testclassify.c156
-rw-r--r--libical/src/test/testmime.c340
-rw-r--r--libical/src/test/testvcal.c64
131 files changed, 0 insertions, 40795 deletions
diff --git a/libical/src/.cvsignore b/libical/src/.cvsignore
deleted file mode 100644
index c038ed7864..0000000000
--- a/libical/src/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in \ No newline at end of file
diff --git a/libical/src/Makefile.am b/libical/src/Makefile.am
deleted file mode 100644
index d6ba22c548..0000000000
--- a/libical/src/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-if WITH_PYTHON
-PYTHON_DIR = python
-else
-PYTHON_DIR =
-endif
-
-SUBDIRS = libical libicalss libicalvcal # $(PYTHON_DIR) test
diff --git a/libical/src/libical/.cvsignore b/libical/src/libical/.cvsignore
deleted file mode 100644
index ef04480fde..0000000000
--- a/libical/src/libical/.cvsignore
+++ /dev/null
@@ -1,22 +0,0 @@
-Makefile
-Makefile.in
-icalitipy.c
-icalitipy.h
-icalitipl.c
-icallexer.c
-icalyacc.c
-icalyacc.h
-y.output
-*.lo
-*.la
-.libs
-.deps
-icalversion.h
-ical.h
-icalderivedparameter.c
-icalderivedparameter.h
-icalderivedproperty.c
-icalderivedproperty.h
-icalderivedvalue.h
-icalderivedvalue.c
-icalrestriction.c
diff --git a/libical/src/libical/Makefile.am b/libical/src/libical/Makefile.am
deleted file mode 100644
index 9e1a6da9ca..0000000000
--- a/libical/src/libical/Makefile.am
+++ /dev/null
@@ -1,237 +0,0 @@
-#======================================================================
-# FILE: Makefile.am
-# CREATOR: eric
-#
-# $Id: Makefile.am,v 1.30 2001/06/14 02:50:46 damon 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 icalcomponent.c
-#
-#======================================================================
-
-
-DESIGNDATA = $(top_srcdir)/design-data
-ICALSCRIPTS = $(top_srcdir)/scripts
-
-lib_LTLIBRARIES = libical.la
-
-noinst_LTLIBRARIES = libical-static.la
-libical_static_la_SOURCES = $(libical_la_SOURCES)
-libical_static_la_LDFLAGS = --all-static
-
-YFLAGS = -d -v -t -pical_yy
-LFLAGS = -Pical_yy
-LEX_OUTPUT_ROOT = lex.ical_yy
-
-CPPFLAGS = -DPACKAGE_DATA_DIR=\""$(datadir)/$(PACKAGE)"\"
-
-all: ical.h
-
-INCLUDES = \
- -I$(top_builddir) \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -I$(srcdir)
-
-libical_la_LDFLAGS = -version-info 0:0:0
-
-libical_la_SOURCES = \
- $(BUILT_SOURCES) \
- icalarray.c \
- icalarray.h \
- icalattendee.h \
- icalattendee.c \
- icalcomponent.c \
- icalcomponent.h \
- icalenums.c \
- icalenums.h \
- icalerror.c \
- icalerror.h \
- icallexer.l \
- icalmemory.c \
- icalmemory.h \
- icalmime.c \
- icalmime.h \
- icalparameter.c \
- icalparameter.h \
- icalparameterimpl.h \
- icalparser.c \
- icalparser.h \
- icalproperty.c \
- icalproperty.h \
- icalrecur.c \
- icalrecur.h \
- icalrestriction.h \
- icaltime.c \
- icaltime.h \
- icaltimezone.c \
- icaltimezone.h \
- icalduration.h \
- icalduration.c \
- icalperiod.h \
- icalperiod.c \
- icaltypes.c \
- icaltypes.h \
- icalvalue.c \
- icalvalue.h \
- icalvalueimpl.h \
- icalyacc.h \
- icalyacc.y \
- pvl.c \
- pvl.h \
- sspm.c \
- sspm.h \
- vsnprintf.c \
- icallangbind.h \
- icallangbind.c
-
-libicalincludedir = $(includedir)
-
-libicalinclude_HEADERS = ical.h
-
-# ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering. It
-# is required to make the combined header ical.h properly
-COMBINEDHEADERS = \
- $(top_builddir)/src/libical/icalversion.h \
- $(top_srcdir)/src/libical/icaltime.h \
- $(top_srcdir)/src/libical/icalduration.h \
- $(top_srcdir)/src/libical/icalperiod.h \
- $(top_srcdir)/src/libical/icalenums.h \
- $(top_srcdir)/src/libical/icaltypes.h \
- $(top_srcdir)/src/libical/icalrecur.h \
- icalderivedvalue.h \
- icalderivedparameter.h \
- $(top_srcdir)/src/libical/icalvalue.h \
- $(top_srcdir)/src/libical/icalparameter.h \
- icalderivedproperty.h \
- $(top_srcdir)/src/libical/icalproperty.h \
- $(top_srcdir)/src/libical/icalattendee.h \
- $(top_srcdir)/src/libical/pvl.h \
- $(top_srcdir)/src/libical/icalarray.h \
- $(top_srcdir)/src/libical/icalcomponent.h \
- $(top_srcdir)/src/libical/icaltimezone.h \
- $(top_srcdir)/src/libical/icalparser.h \
- $(top_srcdir)/src/libical/icalmemory.h \
- $(top_srcdir)/src/libical/icalerror.h \
- $(top_srcdir)/src/libical/icalrestriction.h \
- $(top_srcdir)/src/libical/sspm.h \
- $(top_srcdir)/src/libical/icalmime.h \
- $(top_srcdir)/src/libical/icallangbind.h
-
-BUILT_COMBINEDHEADERS = \
- icalderivedparameter.h \
- icalderivedproperty.h \
- icalderivedvalue.h
-
-BUILT_SOURCES = \
- $(BUILT_COMBINEDHEADERS)\
- icalderivedparameter.c \
- icalderivedproperty.c \
- icalrestriction.c \
- icalderivedvalue.c
-
-ical.h: $(COMBINEDHEADERS)
- cat $(COMBINEDHEADERS) \
- | egrep -v "#include.*\"ical" \
- | egrep -v "#include.*\"pvl\.h\"" > ical.h
-
-icallexer.c : icalyacc.h
-
-
-# parameters
-
-PARAMETERDEPS = \
- $(ICALSCRIPTS)/mkderivedparameters.pl \
- $(DESIGNDATA)/parameters.csv \
- icalderivedparameter.c.in \
- icalderivedparameter.h.in
-
-icalderivedparameter.h: $(PARAMETERDEPS)
- $(PERL) -I $(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.h.in -h $(DESIGNDATA)/parameters.csv > icalderivedparameter.h
-
-icalderivedparameter.c: $(PARAMETERDEPS) $(BUILT_COMBINEDHEADERS)
- $(PERL) -I $(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.c.in -c $(DESIGNDATA)/parameters.csv > icalderivedparameter.c
-
-# properties
-
-PROPERTYDEPS = \
- $(ICALSCRIPTS)/mkderivedproperties.pl \
- $(DESIGNDATA)/properties.csv \
- $(DESIGNDATA)/value-types.csv \
- icalderivedproperty.c.in \
- icalderivedproperty.h.in
-
-
-icalderivedproperty.h: $(PROPERTYDEPS)
- $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \
- -i $(srcdir)/icalderivedproperty.h.in -h $(DESIGNDATA)/properties.csv\
- ${DESIGNDATA}/value-types.csv > icalderivedproperty.h
-
-icalderivedproperty.c: $(PROPERTYDEPS) $(BUILT_COMBINEDHEADERS)
- $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \
- -i $(srcdir)/icalderivedproperty.c.in -c $(DESIGNDATA)/properties.csv \
- ${DESIGNDATA}/value-types.csv > icalderivedproperty.c
-
-# restrictions
-
-RESTRICTIONDEPS = \
- $(ICALSCRIPTS)/mkrestrictiontable.pl \
- $(DESIGNDATA)/restrictions.csv \
- icalrestriction.c.in
-
-icalrestriction.c: $(RESTRICTIONDEPS)
- $(PERL) $(ICALSCRIPTS)/mkrestrictiontable.pl -i $(srcdir)/icalrestriction.c.in \
- $(DESIGNDATA)/restrictions.csv > icalrestriction.c
-
-# values
-
-VALUEDEPS = \
- $(ICALSCRIPTS)/mkderivedvalues.pl \
- $(DESIGNDATA)/value-types.csv \
- icalderivedvalue.c.in \
- icalderivedvalue.h.in
-
-icalderivedvalue.h: $(VALUEDEPS)
- $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedvalues.pl \
- -i $(srcdir)/icalderivedvalue.h.in -h $(DESIGNDATA)/value-types.csv > icalderivedvalue.h
-
-icalderivedvalue.c: $(VALUEDEPS) $(BUILT_COMBINEDHEADERS)
- $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedvalues.pl \
- -i $(srcdir)/icalderivedvalue.c.in -c $(DESIGNDATA)/value-types.csv > icalderivedvalue.c
-
-
-
-# housekeeping
-CONFIG_CLEAN_FILES = y.output
-
-CLEANFILES += $(BUILT_SOURCES)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
- cd $(distdir); rm -f ical.h
-
-EXTRA_DIST = \
- icalderivedparameter.c.in \
- icalderivedparameter.h.in \
- icalderivedproperty.c.in \
- icalderivedproperty.h.in \
- icalrestriction.c.in \
- icalderivedvalue.c.in \
- icalderivedvalue.h.in \
- icalversion.h.in \
- icallexer.c \
- icalyacc.c
-
diff --git a/libical/src/libical/icalarray.c b/libical/src/libical/icalarray.c
deleted file mode 100644
index 9aea671b64..0000000000
--- a/libical/src/libical/icalarray.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*-
- ======================================================================
- FILE: icalarray.c
- CREATOR: Damon Chaplin 07 March 2001
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2001, Ximian, Inc.
-
- 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 <stdlib.h>
-#include <string.h>
-
-#include "icalarray.h"
-#include "icalerror.h"
-
-
-static void icalarray_expand (icalarray *array,
- int space_needed);
-
-
-icalarray*
-icalarray_new (int element_size,
- int increment_size)
-{
- icalarray *array;
-
- array = (icalarray*) malloc (sizeof (icalarray));
- if (!array) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return NULL;
- }
-
- array->element_size = element_size;
- array->increment_size = increment_size;
- array->num_elements = 0;
- array->space_allocated = 0;
- array->data = NULL;
-
- return array;
-}
-
-
-void
-icalarray_free (icalarray *array)
-{
- if (array->data)
- free (array->data);
- free (array);
-}
-
-
-void
-icalarray_append (icalarray *array,
- void *element)
-{
- if (array->num_elements >= array->space_allocated)
- icalarray_expand (array, 1);
-
- memcpy (array->data + array->num_elements * array->element_size, element,
- array->element_size);
- array->num_elements++;
-}
-
-
-void*
-icalarray_element_at (icalarray *array,
- int position)
-{
- assert (position >= 0);
- assert (position < array->num_elements);
-
- return array->data + position * array->element_size;
-}
-
-
-void
-icalarray_remove_element_at (icalarray *array,
- int position)
-{
- void *dest;
- int elements_to_move;
-
- assert (position >= 0);
- assert (position < array->num_elements);
-
- dest = array->data + position * array->element_size;
- elements_to_move = array->num_elements - position - 1;
-
- if (elements_to_move > 0)
- memmove (dest, dest + array->element_size,
- elements_to_move * array->element_size);
-
- array->num_elements--;
-}
-
-
-void
-icalarray_sort (icalarray *array,
- int (*compare) (const void *,
- const void *))
-{
- qsort (array->data, array->num_elements, array->element_size, compare);
-}
-
-
-static void
-icalarray_expand (icalarray *array,
- int space_needed)
-{
- int new_space_allocated;
- void *new_data;
-
- new_space_allocated = array->space_allocated + array->increment_size;
-
- if (space_needed > array->increment_size)
- new_space_allocated += space_needed;
-
- new_data = realloc (array->data,
- new_space_allocated * array->element_size);
- if (new_data) {
- array->data = new_data;
- array->space_allocated = new_space_allocated;
- } else {
- icalerror_set_errno(ICAL_ALLOCATION_ERROR);
- }
-}
-
-
diff --git a/libical/src/libical/icalarray.h b/libical/src/libical/icalarray.h
deleted file mode 100644
index cbf72688da..0000000000
--- a/libical/src/libical/icalarray.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*======================================================================
- FILE: icalarray.h
- CREATOR: Damon Chaplin 07 March 2001
-
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2001, Ximian, Inc.
-
- 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 ICALARRAY_H
-#define ICALARRAY_H
-
-/* An array of arbitrarily-sized elements which grows dynamically as elements
- are added. */
-
-
-typedef struct _icalarray icalarray;
-struct _icalarray {
- int element_size;
- int increment_size;
- int num_elements;
- int space_allocated;
- void *data;
-};
-
-
-
-icalarray *icalarray_new (int element_size,
- int increment_size);
-void icalarray_free (icalarray *array);
-
-void icalarray_append (icalarray *array,
- void *element);
-void icalarray_remove_element_at (icalarray *array,
- int position);
-
-void *icalarray_element_at (icalarray *array,
- int position);
-
-void icalarray_sort (icalarray *array,
- int (*compare) (const void *, const void *));
-
-
-#endif /* ICALARRAY_H */
diff --git a/libical/src/libical/icalattendee.c b/libical/src/libical/icalattendee.c
deleted file mode 100644
index 30cb949c40..0000000000
--- a/libical/src/libical/icalattendee.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalattendee.c
- CREATOR: eric 08 Mar 01
-
- $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 icaltypes.c
-
- ======================================================================*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalattendee.h"
diff --git a/libical/src/libical/icalattendee.h b/libical/src/libical/icalattendee.h
deleted file mode 100644
index 023b30734c..0000000000
--- a/libical/src/libical/icalattendee.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalattendee.h
- CREATOR: eric 8 Mar 01
-
-
- (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 icaltypes.h
-
-======================================================================*/
-
-#ifndef ICALATTENDEE_H
-#define ICALATTENDEE_H
-
-#include <time.h>
-#include "icalenums.h"
-#include "icaltime.h"
-#include "icalduration.h"
-#include "icalperiod.h"
-#include "icalderivedparameter.h"
-#include "icalderivedvalue.h"
-
-struct icalorganizertype {
- const char* value;
- const char* common_name;
- const char* dir;
- const char* sentby;
- const char* language;
-
-};
-
-/* Create a copy of the given organizer. Libical will not own the
- memory for the strings in the copy; the call must free them */
-struct icalorganizertype icalorganizertype_new_clone(struct icalorganizertype a);
-
-
-struct icalattendeetype {
- const char* cuid; /* Cal user id, contents of the property value */
- /*icalparameter_cutype cutype;*/
- const char* member;
- /*icalparameter_role role;*/
- int rsvp;
- const char* delto;
- const char* delfrom;
- const char* sentby;
- const char* cn;
- const char* dir;
- const char* language;
-};
-
-/* Create a copy of the given attendee. Libical will not own the
- memory for the strings in the copy; the call must free them */
-struct icalattendeetype icalattendeetype_new_clone(struct icalattendeetype a);
-
-
-#endif /* !ICALATTENDEE_H */
diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c
deleted file mode 100644
index 64b2e0d97f..0000000000
--- a/libical/src/libical/icalcomponent.c
+++ /dev/null
@@ -1,1917 +0,0 @@
-/*======================================================================
- FILE: icalcomponent.c
- CREATOR: eric 28 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 icalcomponent.c
-
-======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalcomponent.h"
-#include "pvl.h" /* "Pointer-to-void list" */
-#include "icalerror.h"
-#include "icalmemory.h"
-#include "icalenums.h"
-#include "icaltime.h"
-#include "icalarray.h"
-#include "icaltimezone.h"
-#include "icalduration.h"
-#include "icalperiod.h"
-#include "icalparser.h"
-
-#include <stdlib.h> /* for malloc */
-#include <stdarg.h> /* for va_list, etc */
-#include <errno.h>
-#include <assert.h>
-#include <stdio.h> /* for fprintf */
-#include <string.h> /* for strdup */
-
-#define MAX_TMP 1024
-
-struct icalcomponent_impl
-{
- char id[5];
- icalcomponent_kind kind;
- char* x_name;
- pvl_list properties;
- pvl_elem property_iterator;
- pvl_list components;
- pvl_elem component_iterator;
- icalcomponent* parent;
-
- /* An array of icaltimezone structs. We use this so we can do fast
- lookup of timezones using binary searches. timezones_sorted is
- set to 0 whenever we add a timezone, so we remember to sort the
- array before doing a binary search. */
- icalarray* timezones;
- int timezones_sorted;
-};
-
-/* icalproperty functions that only components get to use */
-void icalproperty_set_parent(icalproperty* property,
- icalcomponent* component);
-icalcomponent* icalproperty_get_parent(icalproperty* property);
-void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args);
-icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind);
-int icalcomponent_property_sorter(void *a, void *b);
-
-static void icalcomponent_merge_vtimezone (icalcomponent *comp,
- icalcomponent *vtimezone,
- icalarray *tzids_to_rename);
-static void icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
- icalcomponent *vtimezone,
- icalproperty *tzid_prop,
- const char *tzid,
- icalarray *tzids_to_rename);
-static int icalcomponent_get_tzid_prefix_len (const char *tzid);
-static void icalcomponent_rename_tzids(icalcomponent* comp,
- icalarray* rename_table);
-static void icalcomponent_rename_tzids_callback(icalparameter *param,
- void *data);
-static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1,
- icalcomponent *vtimezone2);
-static int icalcomponent_compare_timezone_fn (const void *elem1,
- const void *elem2);
-
-
-void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args)
-{
- void* vp;
-
- while((vp = va_arg(args, void*)) != 0) {
-
- assert (icalcomponent_isa_component(vp) != 0 ||
- icalproperty_isa_property(vp) != 0 ) ;
-
- if (icalcomponent_isa_component(vp) != 0 ){
-
- icalcomponent_add_component((icalcomponent*)impl,
- (icalcomponent*)vp);
-
- } else if (icalproperty_isa_property(vp) != 0 ){
-
- icalcomponent_add_property((icalcomponent*)impl,
- (icalproperty*)vp);
- }
- }
-}
-
-icalcomponent*
-icalcomponent_new_impl (icalcomponent_kind kind)
-{
- struct icalcomponent_impl* comp;
-
- if ( ( comp = (struct icalcomponent_impl*)
- malloc(sizeof(struct icalcomponent_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- strcpy(comp->id,"comp");
-
- comp->kind = kind;
- comp->properties = pvl_newlist();
- comp->property_iterator = 0;
- comp->components = pvl_newlist();
- comp->component_iterator = 0;
- comp->x_name = 0;
- comp->parent = 0;
- comp->timezones = NULL;
- comp->timezones_sorted = 1;
-
- return comp;
-}
-
-icalcomponent*
-icalcomponent_new (icalcomponent_kind kind)
-{
- return (icalcomponent*)icalcomponent_new_impl(kind);
-}
-
-icalcomponent*
-icalcomponent_vanew (icalcomponent_kind kind, ...)
-{
- va_list args;
-
- struct icalcomponent_impl *impl = icalcomponent_new_impl(kind);
-
- if (impl == 0){
- return 0;
- }
-
- va_start(args,kind);
- icalcomponent_add_children(impl, args);
- va_end(args);
-
- return (icalcomponent*) impl;
-}
-
-icalcomponent* icalcomponent_new_from_string(char* str)
-{
- return icalparser_parse_string(str);
-}
-
-icalcomponent* icalcomponent_new_clone(icalcomponent* component)
-{
- struct icalcomponent_impl *old = (struct icalcomponent_impl*)component;
- struct icalcomponent_impl *new;
- icalproperty *p;
- icalcomponent *c;
- pvl_elem itr;
-
- icalerror_check_arg_rz( (component!=0), "component");
-
- new = icalcomponent_new_impl(old->kind);
-
- if (new == 0){
- return 0;
- }
-
-
- for( itr = pvl_head(old->properties);
- itr != 0;
- itr = pvl_next(itr))
- {
- p = (icalproperty*)pvl_data(itr);
- icalcomponent_add_property(new,icalproperty_new_clone(p));
- }
-
-
- for( itr = pvl_head(old->components);
- itr != 0;
- itr = pvl_next(itr))
- {
- c = (icalcomponent*)pvl_data(itr);
- icalcomponent_add_component(new,icalcomponent_new_clone(c));
- }
-
- return new;
-
-}
-
-
-void
-icalcomponent_free (icalcomponent* component)
-{
- icalproperty* prop;
- icalcomponent* comp;
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rv( (component!=0), "component");
-
-#ifdef ICAL_FREE_ON_LIST_IS_ERROR
- icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component");
-#else
- if(c->parent != 0){
- return;
- }
-#endif
-
- if(component != 0 ){
-
- while( (prop=pvl_pop(c->properties)) != 0){
- assert(prop != 0);
- icalproperty_set_parent(prop,0);
- icalproperty_free(prop);
- }
-
- pvl_free(c->properties);
-
- while( (comp=pvl_data(pvl_head(c->components))) != 0){
- assert(comp!=0);
- icalcomponent_remove_component(component,comp);
- icalcomponent_free(comp);
- }
-
- pvl_free(c->components);
-
- if (c->x_name != 0) {
- free(c->x_name);
- }
-
- if (c->timezones)
- icaltimezone_array_free (c->timezones);
-
- c->kind = ICAL_NO_COMPONENT;
- c->properties = 0;
- c->property_iterator = 0;
- c->components = 0;
- c->component_iterator = 0;
- c->x_name = 0;
- c->id[0] = 'X';
- c->timezones = NULL;
-
- free(c);
- }
-
-}
-
-char*
-icalcomponent_as_ical_string (icalcomponent* component)
-{
- char* buf, *out_buf;
- char* tmp_buf;
- size_t buf_size = 1024;
- char* buf_ptr = 0;
- pvl_elem itr;
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
-
-#ifdef ICAL_UNIX_NEWLINE
- char newline[] = "\n";
-#else
- char newline[] = "\r\n";
-#endif
-
- icalcomponent *c;
- icalproperty *p;
- icalcomponent_kind kind = icalcomponent_isa(component);
-
- const char* kind_string;
-
- buf = icalmemory_new_buffer(buf_size);
- buf_ptr = buf;
-
- icalerror_check_arg_rz( (component!=0), "component");
- icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT");
-
- kind_string = icalenum_component_kind_to_string(kind);
-
- icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component");
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
-
-
-
- for( itr = pvl_head(impl->properties);
- itr != 0;
- itr = pvl_next(itr))
- {
- p = (icalproperty*)pvl_data(itr);
-
- icalerror_assert((p!=0),"Got a null property");
- tmp_buf = icalproperty_as_ical_string(p);
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
- }
-
-
- for( itr = pvl_head(impl->components);
- itr != 0;
- itr = pvl_next(itr))
- {
- c = (icalcomponent*)pvl_data(itr);
-
- tmp_buf = icalcomponent_as_ical_string(c);
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
-
- }
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size,
- icalenum_component_kind_to_string(kind));
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
-
- out_buf = icalmemory_tmp_copy(buf);
- free(buf);
-
- return out_buf;
-}
-
-
-int
-icalcomponent_is_valid (icalcomponent* component)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component;
-
-
- if ( (strcmp(impl->id,"comp") == 0) &&
- impl->kind != ICAL_NO_COMPONENT){
- return 1;
- } else {
- return 0;
- }
-
-}
-
-
-icalcomponent_kind
-icalcomponent_isa (icalcomponent* component)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component;
- icalerror_check_arg_rz( (component!=0), "component");
-
- if(component != 0)
- {
- return impl->kind;
- }
-
- return ICAL_NO_COMPONENT;
-}
-
-
-int
-icalcomponent_isa_component (void* component)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component;
-
- icalerror_check_arg_rz( (component!=0), "component");
-
- if (strcmp(impl->id,"comp") == 0) {
- return 1;
- } else {
- return 0;
- }
-
-}
-
-int icalcomponent_property_sorter(void *a, void *b)
-{
- icalproperty_kind kinda, kindb;
- const char *ksa, *ksb;
-
- kinda = icalproperty_isa((icalproperty*)a);
- kindb = icalproperty_isa((icalproperty*)b);
-
- ksa = icalenum_property_kind_to_string(kinda);
- ksb = icalenum_property_kind_to_string(kindb);
-
- return strcmp(ksa,ksb);
-}
-
-
-void
-icalcomponent_add_property (icalcomponent* component, icalproperty* property)
-{
- struct icalcomponent_impl *impl;
-
- icalerror_check_arg_rv( (component!=0), "component");
- icalerror_check_arg_rv( (property!=0), "property");
-
- impl = (struct icalcomponent_impl*)component;
-
- icalerror_assert( (!icalproperty_get_parent(property)),"The property has already been added to a component. Remove the property with icalcomponent_remove_property before calling icalcomponent_add_property");
-
- icalproperty_set_parent(property,component);
-
-#ifdef ICAL_INSERT_ORDERED
- pvl_insert_ordered(impl->properties,
- icalcomponent_property_sorter,property);
-#else
- pvl_push(impl->properties,property);
-#endif
-
-}
-
-
-void
-icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
-{
- struct icalcomponent_impl *impl;
- pvl_elem itr, next_itr;
- struct icalproperty_impl *pimpl;
-
- icalerror_check_arg_rv( (component!=0), "component");
- icalerror_check_arg_rv( (property!=0), "property");
-
- impl = (struct icalcomponent_impl*)component;
-
- pimpl = (struct icalproperty_impl*)property;
-
- icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component");
-
-
- for( itr = pvl_head(impl->properties);
- itr != 0;
- itr = next_itr)
- {
- next_itr = pvl_next(itr);
-
- if( pvl_data(itr) == (void*)property ){
-
- if (impl->property_iterator == itr){
- impl->property_iterator = pvl_next(itr);
- }
-
- pvl_remove( impl->properties, itr);
- icalproperty_set_parent(property,0);
- }
- }
-}
-
-int
-icalcomponent_count_properties (icalcomponent* component,
- icalproperty_kind kind)
-{
- int count=0;
- pvl_elem itr;
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rz( (component!=0), "component");
-
- for( itr = pvl_head(impl->properties);
- itr != 0;
- itr = pvl_next(itr))
- {
- if(kind == icalproperty_isa((icalproperty*)pvl_data(itr)) ||
- kind == ICAL_ANY_PROPERTY){
- count++;
- }
- }
-
-
- return count;
-
-}
-
-icalproperty* icalcomponent_get_current_property (icalcomponent* component)
-{
-
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
- icalerror_check_arg_rz( (component!=0),"component");
-
- if ((c->property_iterator==0)){
- return 0;
- }
-
- return (icalproperty*) pvl_data(c->property_iterator);
-
-}
-
-icalproperty*
-icalcomponent_get_first_property (icalcomponent* component, icalproperty_kind kind)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
- icalerror_check_arg_rz( (component!=0),"component");
-
- for( c->property_iterator = pvl_head(c->properties);
- c->property_iterator != 0;
- c->property_iterator = pvl_next(c->property_iterator)) {
-
- icalproperty *p = (icalproperty*) pvl_data(c->property_iterator);
-
- if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) {
-
- return p;
- }
- }
- return 0;
-}
-
-icalproperty*
-icalcomponent_get_next_property (icalcomponent* component, icalproperty_kind kind)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
- icalerror_check_arg_rz( (component!=0),"component");
-
- if (c->property_iterator == 0){
- return 0;
- }
-
- for( c->property_iterator = pvl_next(c->property_iterator);
- c->property_iterator != 0;
- c->property_iterator = pvl_next(c->property_iterator)) {
-
- icalproperty *p = (icalproperty*) pvl_data(c->property_iterator);
-
- if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) {
-
- return p;
- }
- }
-
- return 0;
-}
-
-
-icalproperty**
-icalcomponent_get_properties (icalcomponent* component, icalproperty_kind kind);
-
-
-void
-icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
-{
- struct icalcomponent_impl *impl, *cimpl;
-
- icalerror_check_arg_rv( (parent!=0), "parent");
- icalerror_check_arg_rv( (child!=0), "child");
-
- impl = (struct icalcomponent_impl*)parent;
- cimpl = (struct icalcomponent_impl*)child;
-
- icalerror_assert( (cimpl->parent ==0),"The child component has already been added to a parent component. Remove the component with icalcomponent_remove_component before calling icalcomponent_add_component");
-
- cimpl->parent = parent;
-
- pvl_push(impl->components,child);
-
- /* If the new component is a VTIMEZONE, add it to our array. */
- if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) {
- /* FIXME: Currently we are also creating this array when loading in
- a builtin VTIMEZONE, when we don't need it. */
- if (!impl->timezones)
- impl->timezones = icaltimezone_array_new ();
-
- icaltimezone_array_append_from_vtimezone (impl->timezones, child);
-
- /* Flag that we need to sort it before doing any binary searches. */
- impl->timezones_sorted = 0;
- }
-}
-
-
-void
-icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
-{
- struct icalcomponent_impl *impl,*cimpl;
- pvl_elem itr, next_itr;
-
- icalerror_check_arg_rv( (parent!=0), "parent");
- icalerror_check_arg_rv( (child!=0), "child");
-
- impl = (struct icalcomponent_impl*)parent;
- cimpl = (struct icalcomponent_impl*)child;
-
- /* If the component is a VTIMEZONE, remove it from our array as well. */
- if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) {
- icaltimezone *zone;
- int i, num_elements;
-
- num_elements = impl->timezones ? impl->timezones->num_elements : 0;
- for (i = 0; i < num_elements; i++) {
- zone = icalarray_element_at (impl->timezones, i);
- if (icaltimezone_get_component (zone) == child) {
- icaltimezone_free (zone, 0);
- icalarray_remove_element_at (impl->timezones, i);
- break;
- }
- }
- }
-
- for( itr = pvl_head(impl->components);
- itr != 0;
- itr = next_itr)
- {
- next_itr = pvl_next(itr);
-
- if( pvl_data(itr) == (void*)child ){
-
- if (impl->component_iterator == itr){
- /* Don't let the current iterator become invalid */
-
- /* HACK. The semantics for this are troubling. */
- impl->component_iterator =
- pvl_next(impl->component_iterator);
-
- }
- pvl_remove( impl->components, itr);
- cimpl->parent = 0;
- break;
- }
- }
-}
-
-
-int
-icalcomponent_count_components (icalcomponent* component,
- icalcomponent_kind kind)
-{
- int count=0;
- pvl_elem itr;
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rz( (component!=0), "component");
-
- for( itr = pvl_head(impl->components);
- itr != 0;
- itr = pvl_next(itr))
- {
- if(kind == icalcomponent_isa((icalcomponent*)pvl_data(itr)) ||
- kind == ICAL_ANY_COMPONENT){
- count++;
- }
- }
-
- return count;
-}
-
-icalcomponent*
-icalcomponent_get_current_component(icalcomponent* component)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rz( (component!=0),"component");
-
- if (c->component_iterator == 0){
- return 0;
- }
-
- return (icalcomponent*) pvl_data(c->component_iterator);
-}
-
-icalcomponent*
-icalcomponent_get_first_component (icalcomponent* component,
- icalcomponent_kind kind)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rz( (component!=0),"component");
-
- for( c->component_iterator = pvl_head(c->components);
- c->component_iterator != 0;
- c->component_iterator = pvl_next(c->component_iterator)) {
-
- icalcomponent *p = (icalcomponent*) pvl_data(c->component_iterator);
-
- if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) {
-
- return p;
- }
- }
-
- return 0;
-}
-
-
-icalcomponent*
-icalcomponent_get_next_component (icalcomponent* component, icalcomponent_kind kind)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- icalerror_check_arg_rz( (component!=0),"component");
-
- if (c->component_iterator == 0){
- return 0;
- }
-
- for( c->component_iterator = pvl_next(c->component_iterator);
- c->component_iterator != 0;
- c->component_iterator = pvl_next(c->component_iterator)) {
-
- icalcomponent *p = (icalcomponent*) pvl_data(c->component_iterator);
-
- if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) {
-
- return p;
- }
- }
-
- return 0;
-}
-
-icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c)
-{
- icalcomponent *comp;
-
- for(comp = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT);
- comp != 0;
- comp = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){
-
- icalcomponent_kind kind = icalcomponent_isa(comp);
-
- if(kind == ICAL_VEVENT_COMPONENT ||
- kind == ICAL_VTODO_COMPONENT ||
- kind == ICAL_VJOURNAL_COMPONENT ){
- return comp;
- }
- }
- return 0;
-}
-
-struct icaltime_span icalcomponent_get_span(icalcomponent* comp)
-{
- icalcomponent *inner;
- icalproperty *p, *duration;
- icalcomponent_kind kind;
- struct icaltime_span span;
- struct icaltimetype start;
-
- span.start = 0;
- span.end = 0;
- span.is_busy= 1;
-
- /* initial Error checking */
-
-/* icalerror_check_arg_rz( (comp!=0),"comp");*/
-
- kind = icalcomponent_isa(comp);
-
- if(kind == ICAL_VCALENDAR_COMPONENT){
- inner = icalcomponent_get_first_real_component(comp);
-
- /* Maybe there is a VTIMEZONE in there */
- if (inner == 0){
- inner = icalcomponent_get_first_component(comp,
- ICAL_VTIMEZONE_COMPONENT);
- }
-
- } else {
- inner = comp;
- }
-
- if (inner == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/
- return span;
- }
-
- kind = icalcomponent_isa(inner);
-
- if( !( kind == ICAL_VEVENT_COMPONENT ||
- kind == ICAL_VJOURNAL_COMPONENT ||
- kind == ICAL_VTODO_COMPONENT ||
- kind == ICAL_VFREEBUSY_COMPONENT )) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/
- return span;
-
- }
-
-
-
- /* Get to work. starting with DTSTART */
-
- p = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY);
-
- if (p ==0 ) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- /*icalerror_warn("icalcomponent_get_span: component has no DTSTART time");*/
- return span;
- }
-
-
- start = icalproperty_get_dtstart(p);
-
- icalerror_clear_errno();
-
- /* FIXME: Needs updating to new icaltimezone functions. */
-#if 0
- span.start = icalcomponent_convert_time(p);
-#endif
-
-#ifdef TEST_CONVERT_TIME
- printf("convert time:\n %s %s",
- icalproperty_as_ical_string(p), ctime(&span.start));
-#endif
-
- if(icalerrno != ICAL_NO_ERROR){
- span.start = 0;
- return span;
- }
-
- /* The end time could be specified as either a DTEND or a DURATION */
- p = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY);
- duration = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
-
- if (p==0 && duration == 0 && start.is_date != 1) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- /*icalerror_warn("icalcomponent_get_span: component has neither DTEND nor DURATION time");*/
- span.start = 0;
- return span;
- }
-
- if (p!=0){
- /* FIXME: Needs updating to new icaltimezone functions. */
-#if 0
- span.end = icalcomponent_convert_time(p);
-#endif
- } else if (start.is_date == 1) {
- /* Duration is all day */
- span.end = span.start + 60*60*24;
- } else {
- /* Use the duration */
- struct icaldurationtype dur;
- time_t durt;
-
-
- dur = icalproperty_get_duration(duration);
-
- durt = icaldurationtype_as_int(dur);
- span.end = span.start+durt;
- }
-
- return span;
-
-}
-
-
-int icalcomponent_count_errors(icalcomponent* component)
-{
- int errors = 0;
- icalproperty *p;
- icalcomponent *c;
- pvl_elem itr;
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
-
- for( itr = pvl_head(impl->properties);
- itr != 0;
- itr = pvl_next(itr))
- {
- p = (icalproperty*)pvl_data(itr);
-
- if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY)
- {
- errors++;
- }
- }
-
-
- for( itr = pvl_head(impl->components);
- itr != 0;
- itr = pvl_next(itr))
- {
- c = (icalcomponent*)pvl_data(itr);
-
- errors += icalcomponent_count_errors(c);
-
- }
-
- return errors;
-}
-
-
-void icalcomponent_strip_errors(icalcomponent* component)
-{
- icalproperty *p;
- icalcomponent *c;
- pvl_elem itr, next_itr;
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
-
- for( itr = pvl_head(impl->properties);
- itr != 0;
- itr = next_itr)
- {
- p = (icalproperty*)pvl_data(itr);
- next_itr = pvl_next(itr);
-
- if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY)
- {
- icalcomponent_remove_property(component,p);
- }
- }
-
- for( itr = pvl_head(impl->components);
- itr != 0;
- itr = pvl_next(itr))
- {
- c = (icalcomponent*)pvl_data(itr);
- icalcomponent_strip_errors(c);
- }
-}
-
-/* Hack. This will change the state of the iterators */
-void icalcomponent_convert_errors(icalcomponent* component)
-{
- icalproperty *p, *next_p;
- icalcomponent *c;
-
- for(p = icalcomponent_get_first_property(component,ICAL_ANY_PROPERTY);
- p != 0;
- p = next_p){
-
- next_p = icalcomponent_get_next_property(component,ICAL_ANY_PROPERTY);
-
- if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY)
- {
- struct icalreqstattype rst;
- icalparameter *param = icalproperty_get_first_parameter
- (p,ICAL_XLICERRORTYPE_PARAMETER);
-
- rst.code = ICAL_UNKNOWN_STATUS;
- rst.desc = 0;
-
- switch(icalparameter_get_xlicerrortype(param)){
-
- case ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR: {
- rst.code = ICAL_3_2_INVPARAM_STATUS;
- break;
- }
- case ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR: {
- rst.code = ICAL_3_3_INVPARAMVAL_STATUS;
- break;
- }
- case ICAL_XLICERRORTYPE_PROPERTYPARSEERROR: {
- rst.code = ICAL_3_0_INVPROPNAME_STATUS;
- break;
- }
- case ICAL_XLICERRORTYPE_VALUEPARSEERROR: {
- rst.code = ICAL_3_1_INVPROPVAL_STATUS;
- break;
- }
- case ICAL_XLICERRORTYPE_COMPONENTPARSEERROR: {
- rst.code = ICAL_3_4_INVCOMP_STATUS;
- break;
- }
-
- default: {
- }
- }
- if (rst.code != ICAL_UNKNOWN_STATUS){
-
- rst.debug = icalproperty_get_xlicerror(p);
- icalcomponent_add_property(component,
- icalproperty_new_requeststatus(
- icalreqstattype_as_string(rst)
- )
- );
-
- icalcomponent_remove_property(component,p);
- }
- }
- }
-
- for(c = icalcomponent_get_first_component(component,ICAL_ANY_COMPONENT);
- c != 0;
- c = icalcomponent_get_next_component(component,ICAL_ANY_COMPONENT)){
-
- icalcomponent_convert_errors(c);
- }
-}
-
-
-icalcomponent* icalcomponent_get_parent(icalcomponent* component)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- return c->parent;
-}
-
-void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent)
-{
- struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
-
- c->parent = parent;
-}
-
-icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0};
-
-
-struct icalcomponent_kind_map {
- icalcomponent_kind kind;
- char name[20];
-};
-
-
-
-static struct icalcomponent_kind_map component_map[] =
-{
- { ICAL_VEVENT_COMPONENT, "VEVENT" },
- { ICAL_VTODO_COMPONENT, "VTODO" },
- { ICAL_VJOURNAL_COMPONENT, "VJOURNAL" },
- { ICAL_VCALENDAR_COMPONENT, "VCALENDAR" },
- { ICAL_VFREEBUSY_COMPONENT, "VFREEBUSY" },
- { ICAL_VTIMEZONE_COMPONENT, "VTIMEZONE" },
- { ICAL_VALARM_COMPONENT, "VALARM" },
- { ICAL_XSTANDARD_COMPONENT, "STANDARD" }, /*These are part of RFC2445 */
- { ICAL_XDAYLIGHT_COMPONENT, "DAYLIGHT" }, /*but are not really components*/
- { ICAL_X_COMPONENT, "X" },
- { ICAL_VSCHEDULE_COMPONENT, "SCHEDULE" },
-
- /* CAP components */
- { ICAL_VQUERY_COMPONENT, "VQUERY" },
- { ICAL_VCAR_COMPONENT, "VCAR" },
- { ICAL_VCOMMAND_COMPONENT, "VCOMMAND" },
-
- /* libical private components */
- { ICAL_XLICINVALID_COMPONENT, "X-LIC-UNKNOWN" },
- { ICAL_XLICMIMEPART_COMPONENT, "X-LIC-MIME-PART" },
- { ICAL_ANY_COMPONENT, "ANY" },
- { ICAL_XROOT_COMPONENT, "XROOT" },
-
- /* End of list */
- { ICAL_NO_COMPONENT, "" },
-};
-
-
-
-const char* icalcomponent_kind_to_string(icalcomponent_kind kind)
-{
- int i;
-
- for (i=0; component_map[i].kind != ICAL_NO_COMPONENT; i++) {
- if (component_map[i].kind == kind) {
- return component_map[i].name;
- }
- }
-
- return 0;
-
-}
-
-icalcomponent_kind icalcomponent_string_to_kind(const char* string)
-{
- int i;
-
- if (string ==0 ) {
- return ICAL_NO_COMPONENT;
- }
-
- for (i=0; component_map[i].kind != ICAL_NO_COMPONENT; i++) {
- if (strcmp(component_map[i].name, string) == 0) {
- return component_map[i].kind;
- }
- }
-
- return ICAL_NO_COMPONENT;
-}
-
-
-
-icalcompiter
-icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
- icalcompiter itr;
- pvl_elem i;
-
- itr.kind = kind;
-
- icalerror_check_arg_re( (component!=0),"component",icalcompiter_null);
-
- for( i = pvl_head(impl->components); i != 0; i = pvl_next(i)) {
-
- icalcomponent *c = (icalcomponent*) pvl_data(i);
-
- if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) {
-
- itr.iter = i;
-
- return itr;
- }
- }
-
- return icalcompiter_null;
-}
-
-icalcompiter
-icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
- icalcompiter itr;
- pvl_elem i;
-
- itr.kind = kind;
-
- icalerror_check_arg_re( (component!=0),"component",icalcompiter_null);
-
- for( i = pvl_tail(impl->components); i != 0; i = pvl_prior(i)) {
-
- icalcomponent *c = (icalcomponent*) pvl_data(i);
-
- if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) {
-
- itr.iter = pvl_next(i);
-
- return itr;
- }
- }
-
- return icalcompiter_null;;
-}
-
-
-icalcomponent* icalcompiter_next(icalcompiter* i)
-{
- if (i->iter == 0){
- return 0;
- }
-
- icalerror_check_arg_rz( (i!=0),"i");
-
- for( i->iter = pvl_next(i->iter);
- i->iter != 0;
- i->iter = pvl_next(i->iter)) {
-
- icalcomponent *c = (icalcomponent*) pvl_data(i->iter);
-
- if (icalcomponent_isa(c) == i->kind
- || i->kind == ICAL_ANY_COMPONENT) {
-
- return icalcompiter_deref(i);;
- }
- }
-
- return 0;
-
-}
-
-icalcomponent* icalcompiter_prior(icalcompiter* i)
-{
- if (i->iter == 0){
- return 0;
- }
-
- for( i->iter = pvl_prior(i->iter);
- i->iter != 0;
- i->iter = pvl_prior(i->iter)) {
-
- icalcomponent *c = (icalcomponent*) pvl_data(i->iter);
-
- if (icalcomponent_isa(c) == i->kind
- || i->kind == ICAL_ANY_COMPONENT) {
-
- return icalcompiter_deref(i);;
- }
- }
-
- return 0;
-
-}
-icalcomponent* icalcompiter_deref(icalcompiter* i)
-{
- if(i->iter ==0){
- return 0;
- }
-
- return pvl_data(i->iter);
-}
-
-icalcomponent* icalcomponent_get_inner(icalcomponent* comp)
-{
- if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
- return icalcomponent_get_first_real_component(comp);
- } else {
- return comp;
- }
-}
-
-
-void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v)
-{
-
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY);
-
-
- if (prop == 0){
- prop = icalproperty_new_dtstart(v);
- icalcomponent_add_property(inner, prop);
- }
-
- icalproperty_set_dtstart(prop,v);
-
-}
-
-
-struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
-
- if (prop == 0){
- return icaltime_null_time();
- }
-
- return icalproperty_get_dtstart(prop);
-}
-
-
-struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
-
- icalproperty *end_prop
- = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
-
- icalproperty *dur_prop
- = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
-
-
- if( end_prop == 0 && dur_prop == 0){
- return icaltime_null_time();
- } else if ( end_prop != 0) {
- return icalproperty_get_dtend(end_prop);
- } else if ( dur_prop != 0) {
-
- struct icaltimetype start =
- icalcomponent_get_dtstart(inner);
- struct icaldurationtype duration =
- icalproperty_get_duration(dur_prop);
-
- struct icaltimetype end = icaltime_add(start,duration);
-
- return end;
-
- } else {
- /* Error, both duration and dtend have been specified */
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return icaltime_null_time();
-
- }
-
-}
-
-
-void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
-
- icalproperty *end_prop
- = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
-
- icalproperty *dur_prop
- = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
-
-
- if( end_prop == 0 && dur_prop == 0){
- end_prop = icalproperty_new_dtend(v);
- icalcomponent_add_property(inner,end_prop);
- } else if ( end_prop != 0) {
- icalproperty_set_dtend(end_prop,v);
- } else if ( dur_prop != 0) {
- struct icaltimetype start =
- icalcomponent_get_dtstart(inner);
-
- struct icaltimetype end =
- icalcomponent_get_dtend(inner);
-
- struct icaldurationtype dur
- = icaltime_subtract(end,start);
-
- icalproperty_set_duration(dur_prop,dur);
-
- } else {
- /* Error, both duration and dtend have been specified */
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- }
-}
-
-void icalcomponent_set_duration(icalcomponent* comp,
- struct icaldurationtype v)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
-
- icalproperty *end_prop
- = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
-
- icalproperty *dur_prop
- = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
-
-
- if( end_prop == 0 && dur_prop == 0){
- dur_prop = icalproperty_new_duration(v);
- icalcomponent_add_property(inner, dur_prop);
- } else if ( end_prop != 0) {
- struct icaltimetype start =
- icalcomponent_get_dtstart(inner);
-
- struct icaltimetype new_end = icaltime_add(start,v);
-
- icalproperty_set_dtend(end_prop,new_end);
-
- } else if ( dur_prop != 0) {
- icalproperty_set_duration(dur_prop,v);
- } else {
- /* Error, both duration and dtend have been specified */
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- }
-}
-
-struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
-
- icalproperty *end_prop
- = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
-
- icalproperty *dur_prop
- = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
-
- struct icaldurationtype null_duration;
- memset(&null_duration,0,sizeof(struct icaldurationtype));
-
-
- if( end_prop == 0 && dur_prop == 0){
- return null_duration;
- } else if ( end_prop != 0) {
- struct icaltimetype start =
- icalcomponent_get_dtstart(inner);
- time_t startt = icaltime_as_timet(start);
-
- struct icaltimetype end =
- icalcomponent_get_dtend(inner);
- time_t endt = icaltime_as_timet(end);
-
- return icaldurationtype_from_int(endt-startt);
- } else if ( dur_prop != 0) {
- return icalproperty_get_duration(dur_prop);
- } else {
- /* Error, both duration and dtend have been specified */
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return null_duration;
- }
-}
-
-void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method)
-{
- icalproperty *prop
- = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY);
-
-
- if (prop == 0){
- prop = icalproperty_new_method(method);
- icalcomponent_add_property(comp, prop);
- }
-
- icalproperty_set_method(prop,method);
-
-}
-
-icalproperty_method icalcomponent_get_method(icalcomponent* comp)
-{
- icalproperty *prop
- = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY);
-
- if (prop == 0){
- return ICAL_METHOD_NONE;
- }
-
- return icalproperty_get_method(prop);
-}
-
-void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v)
-{
-
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner, ICAL_DTSTAMP_PROPERTY);
-
-
- if (prop == 0){
- prop = icalproperty_new_dtstamp(v);
- icalcomponent_add_property(inner, prop);
- }
-
- icalproperty_set_dtstamp(prop,v);
-
-}
-
-
-struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
-
- if (prop == 0){
- return icaltime_null_time();
- }
-
- return icalproperty_get_dtstamp(prop);
-}
-
-
-void icalcomponent_set_summary(icalcomponent* comp, const char* v)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner, ICAL_SUMMARY_PROPERTY);
-
- if (prop == 0){
- prop = icalproperty_new_summary(v);
- icalcomponent_add_property(inner, prop);
- }
-
- icalproperty_set_summary(prop,v);
-}
-
-
-const char* icalcomponent_get_summary(icalcomponent* comp)
-{
- icalcomponent *inner = icalcomponent_get_inner(comp);
- icalproperty *prop
- = icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY);
-
- if (prop == 0){
- return 0;
- }
-
- return icalproperty_get_summary(prop);
-
-}
-
-void icalcomponent_set_comment(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_comment(icalcomponent* comp);
-
-void icalcomponent_set_uid(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_uid(icalcomponent* comp);
-
-void icalcomponent_set_recurrenceid(icalcomponent* comp,
- struct icaltimetype v);
-struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
-
-
-
-
-icalcomponent* icalcomponent_new_vcalendar()
-{
- return icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
-}
-icalcomponent* icalcomponent_new_vevent()
-{
- return icalcomponent_new(ICAL_VEVENT_COMPONENT);
-}
-icalcomponent* icalcomponent_new_vtodo()
-{
- return icalcomponent_new(ICAL_VTODO_COMPONENT);
-}
-icalcomponent* icalcomponent_new_vjournal()
-{
- return icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
-}
-icalcomponent* icalcomponent_new_valarm()
-{
- return icalcomponent_new(ICAL_VALARM_COMPONENT);
-}
-icalcomponent* icalcomponent_new_vfreebusy()
-{
- return icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
-}
-icalcomponent* icalcomponent_new_vtimezone()
-{
- return icalcomponent_new(ICAL_VTIMEZONE_COMPONENT);
-}
-icalcomponent* icalcomponent_new_xstandard()
-{
- return icalcomponent_new(ICAL_XSTANDARD_COMPONENT);
-}
-icalcomponent* icalcomponent_new_xdaylight()
-{
- return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT);
-}
-
-
-/*
- * Timezone stuff.
- */
-
-/* This takes 2 VCALENDAR components and merges the second one into the first,
- resolving any problems with conflicting TZIDs. comp_to_merge will no
- longer exist after calling this function. */
-void icalcomponent_merge_component(icalcomponent* comp,
- icalcomponent* comp_to_merge)
-{
- icalcomponent *subcomp, *next_subcomp;
- icalarray *tzids_to_rename;
- int i;
-
- /* Check that both components are VCALENDAR components. */
- assert (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT);
- assert (icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT);
-
- /* Step through each subcomponent of comp_to_merge, looking for VTIMEZONEs.
- For each VTIMEZONE found, check if we need to add it to comp and if we
- need to rename it and all TZID references to it. */
- tzids_to_rename = icalarray_new (sizeof (char*), 16);
- subcomp = icalcomponent_get_first_component (comp_to_merge,
- ICAL_VTIMEZONE_COMPONENT);
- while (subcomp) {
- next_subcomp = icalcomponent_get_next_component (comp_to_merge,
- ICAL_VTIMEZONE_COMPONENT);
- /* This will add the VTIMEZONE to comp, if necessary, and also update
- the array of TZIDs we need to rename. */
- icalcomponent_merge_vtimezone (comp, subcomp, tzids_to_rename);
- /* FIXME: Handle possible NEWFAILED error. */
-
- subcomp = next_subcomp;
- }
-
- /* If we need to do any renaming of TZIDs, do it now. */
- if (tzids_to_rename->num_elements != 0) {
- icalcomponent_rename_tzids (comp_to_merge, tzids_to_rename);
-
- /* Now free the tzids_to_rename array. */
- for (i = 0; i < tzids_to_rename->num_elements; i++) {
- free (icalarray_element_at (tzids_to_rename, i));
- }
- icalarray_free (tzids_to_rename);
- }
-
- /* Now move all the components from comp_to_merge to comp, excluding
- VTIMEZONE components. */
- subcomp = icalcomponent_get_first_component (comp_to_merge,
- ICAL_ANY_COMPONENT);
- while (subcomp) {
- next_subcomp = icalcomponent_get_next_component (comp_to_merge,
- ICAL_ANY_COMPONENT);
- if (icalcomponent_isa(subcomp) != ICAL_VTIMEZONE_COMPONENT) {
- icalcomponent_remove_component (comp_to_merge, subcomp);
- icalcomponent_add_component (comp, subcomp);
- }
- subcomp = next_subcomp;
- }
-
- /* Free comp_to_merge. We have moved most of the subcomponents over to
- comp now. */
- icalcomponent_free (comp_to_merge);
-}
-
-
-static void icalcomponent_merge_vtimezone (icalcomponent *comp,
- icalcomponent *vtimezone,
- icalarray *tzids_to_rename)
-{
- icalproperty *tzid_prop;
- const char *tzid;
- char *tzid_copy;
- icaltimezone *existing_vtimezone;
-
- /* Get the TZID of the VTIMEZONE. */
- tzid_prop = icalcomponent_get_first_property (vtimezone, ICAL_TZID_PROPERTY);
- if (!tzid_prop)
- return;
-
- tzid = icalproperty_get_tzid (tzid_prop);
- if (!tzid)
- return;
-
- /* See if there is already a VTIMEZONE in comp with the same TZID. */
- existing_vtimezone = icalcomponent_get_timezone (comp, tzid);
-
- /* If there is no existing VTIMEZONE with the same TZID, we can just move
- the VTIMEZONE to comp and return. */
- if (!existing_vtimezone) {
- icalcomponent_remove_component (icalcomponent_get_parent (vtimezone),
- vtimezone);
- icalcomponent_add_component (comp, vtimezone);
- return;
- }
-
- /* If the TZID has a '/' prefix, then we don't have to worry about the
- clashing TZIDs, as they are supposed to be exactly the same VTIMEZONE. */
- if (tzid[0] == '/')
- return;
-
- /* Now we have two VTIMEZONEs with the same TZID (which isn't a globally
- unique one), so we compare the VTIMEZONE components to see if they are
- the same. If they are, we don't need to do anything. We make a copy of
- the tzid, since the parameter may get modified in these calls. */
- tzid_copy = strdup (tzid);
- if (!tzid_copy) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- if (!icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone)) {
- /* FIXME: Handle possible NEWFAILED error. */
-
- /* Now we have two different VTIMEZONEs with the same TZID. */
- icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop,
- tzid_copy, tzids_to_rename);
- }
- free (tzid_copy);
-}
-
-
-static void
-icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
- icalcomponent *vtimezone,
- icalproperty *tzid_prop,
- const char *tzid,
- icalarray *tzids_to_rename)
-{
- struct icalcomponent_impl *impl = (struct icalcomponent_impl*)comp;
- int tzid_len, i, suffix, max_suffix = 0, num_elements;
- char *tzid_copy, *new_tzid, suffix_buf[32];
-
- /* Find the length of the TZID without any trailing digits. */
- tzid_len = icalcomponent_get_tzid_prefix_len (tzid);
-
- /* Step through each of the VTIMEZONEs in comp. We may already have the
- clashing VTIMEZONE in the calendar, but it may have been renamed
- (i.e. a unique number added on the end of the TZID, e.g. 'London2').
- So we compare the new VTIMEZONE with any VTIMEZONEs that have the
- same prefix (e.g. 'London'). If it matches any of those, we have to
- rename the TZIDs to that TZID, else we rename to a new TZID, using
- the biggest numeric suffix found + 1. */
- num_elements = impl->timezones ? impl->timezones->num_elements : 0;
- for (i = 0; i < num_elements; i++) {
- icaltimezone *zone;
- char *existing_tzid, *existing_tzid_copy;
- int existing_tzid_len;
-
- zone = icalarray_element_at (impl->timezones, i);
- existing_tzid = icaltimezone_get_tzid (zone);
-
- /* Find the length of the TZID without any trailing digits. */
- existing_tzid_len = icalcomponent_get_tzid_prefix_len (existing_tzid);
-
- /* Check if we have the same prefix. */
- if (tzid_len == existing_tzid_len
- && !strncmp (tzid, existing_tzid, tzid_len)) {
- /* Compare the VTIMEZONEs. */
- if (icalcomponent_compare_vtimezones (icaltimezone_get_component (zone),
- vtimezone)) {
- /* The VTIMEZONEs match, so we can use the existing VTIMEZONE. But
- we have to rename TZIDs to this TZID. */
- tzid_copy = strdup (tzid);
- existing_tzid_copy = strdup (existing_tzid);
- if (!tzid_copy || !existing_tzid_copy) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- } else {
- icalarray_append (tzids_to_rename, tzid_copy);
- icalarray_append (tzids_to_rename, existing_tzid_copy);
- }
- return;
- } else {
- /* FIXME: Handle possible NEWFAILED error. */
-
- /* Convert the suffix to an integer and remember the maximum numeric
- suffix found. */
- suffix = atoi (existing_tzid + existing_tzid_len);
- if (max_suffix < suffix)
- max_suffix = suffix;
- }
- }
- }
-
- /* We didn't find a VTIMEZONE that matched, so we have to rename the TZID,
- using the maximum numerical suffix found + 1. */
- tzid_copy = strdup (tzid);
- sprintf (suffix_buf, "%i", max_suffix + 1);
- new_tzid = malloc (tzid_len + strlen (suffix_buf) + 1);
- if (!new_tzid || !tzid_copy) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- strncpy (new_tzid, tzid, tzid_len);
- strcpy (new_tzid + tzid_len, suffix_buf);
- icalarray_append (tzids_to_rename, tzid_copy);
- icalarray_append (tzids_to_rename, new_tzid);
-}
-
-
-/* Returns the length of the TZID, without any trailing digits. */
-static int icalcomponent_get_tzid_prefix_len (const char *tzid)
-{
- int len;
- const char *p;
-
- len = strlen (tzid);
- p = tzid + len - 1;
- while (len > 0 && *p >= '0' && *p <= '9') {
- p--;
- len--;
- }
-
- return len;
-}
-
-
-/* Renames all references to the given TZIDs to a new name. rename_table
- contains pairs of strings - a current TZID, and the new TZID to rename it
- to. */
-static void icalcomponent_rename_tzids(icalcomponent* comp,
- icalarray* rename_table)
-{
- icalcomponent_foreach_tzid (comp, icalcomponent_rename_tzids_callback,
- rename_table);
-}
-
-
-static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data)
-{
- icalarray *rename_table = data;
- const char *tzid;
- int i;
-
- tzid = icalparameter_get_tzid (param);
- if (!tzid)
- return;
-
- /* Step through the rename table to see if the current TZID matches
- any of the ones we want to rename. */
- for (i = 0; i < rename_table->num_elements - 1; i += 2) {
- if (!strcmp (tzid, icalarray_element_at (rename_table, i))) {
- icalparameter_set_tzid (param, icalarray_element_at (rename_table, i + 1));
- break;
- }
- }
-}
-
-
-/* Calls the given function for each TZID parameter found in the component. */
-void icalcomponent_foreach_tzid(icalcomponent* comp,
- void (*callback)(icalparameter *param, void *data),
- void *callback_data)
-{
- icalproperty *prop;
- icalproperty_kind kind;
- icalparameter *param;
- icalcomponent *subcomp;
-
- /* First look for any TZID parameters used in this component itself. */
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
- kind = icalproperty_isa (prop);
-
- /* These are the only properties that can have a TZID. Note that
- COMPLETED, CREATED, DTSTAMP & LASTMODIFIED must be in UTC. */
- if (kind == ICAL_DTSTART_PROPERTY || kind == ICAL_DTEND_PROPERTY
- || kind == ICAL_DUE_PROPERTY || kind == ICAL_EXDATE_PROPERTY
- || kind == ICAL_RDATE_PROPERTY) {
- param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
- if (param)
- (*callback) (param, callback_data);
- }
-
- prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
- }
-
- /* Now recursively check child components. */
- subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
- while (subcomp) {
- icalcomponent_foreach_tzid (subcomp, callback, callback_data);
- subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT);
- }
-}
-
-
-
-/* Returns the icaltimezone from the component corresponding to the given
- TZID, or NULL if the component does not have a corresponding VTIMEZONE. */
-icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid)
-{
- struct icalcomponent_impl *impl;
- icaltimezone *zone;
- int lower, upper, middle, cmp;
- char *zone_tzid;
-
- impl = (struct icalcomponent_impl*)comp;
-
- if (!impl->timezones)
- return NULL;
-
- /* Sort the array if necessary (by the TZID string). */
- if (!impl->timezones_sorted) {
- icalarray_sort (impl->timezones, icalcomponent_compare_timezone_fn);
- impl->timezones_sorted = 1;
- }
-
- /* Do a simple binary search. */
- lower = middle = 0;
- upper = impl->timezones->num_elements;
-
- while (lower < upper) {
- middle = (lower + upper) >> 1;
- zone = icalarray_element_at (impl->timezones, middle);
- zone_tzid = icaltimezone_get_tzid (zone);
- cmp = strcmp (tzid, zone_tzid);
- if (cmp == 0)
- return zone;
- else if (cmp < 0)
- upper = middle;
- else
- lower = middle + 1;
- }
-
- return NULL;
-}
-
-
-/* A function to compare 2 icaltimezone elements, used for qsort(). */
-static int icalcomponent_compare_timezone_fn (const void *elem1,
- const void *elem2)
-{
- icaltimezone *zone1, *zone2;
- const char *zone1_tzid, *zone2_tzid;
- int retval;
-
- zone1 = (icaltimezone*) elem1;
- zone2 = (icaltimezone*) elem2;
-
- zone1_tzid = icaltimezone_get_tzid (zone1);
- zone2_tzid = icaltimezone_get_tzid (zone2);
-
- return strcmp (zone1_tzid, zone2_tzid);
-}
-
-
-/* Compares 2 VTIMEZONE components to see if they match, ignoring their TZIDs.
- It returns 1 if they match, 0 if they don't, or -1 on error. */
-static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1,
- icalcomponent *vtimezone2)
-{
- icalproperty *prop1, *prop2;
- const char *tzid1, *tzid2;
- char *tzid2_copy, *string1, *string2;
- int cmp;
-
- /* Get the TZID property of the first VTIMEZONE. */
- prop1 = icalcomponent_get_first_property (vtimezone1, ICAL_TZID_PROPERTY);
- if (!prop1)
- return -1;
-
- tzid1 = icalproperty_get_tzid (prop1);
- if (!tzid1)
- return -1;
-
- /* Get the TZID property of the second VTIMEZONE. */
- prop2 = icalcomponent_get_first_property (vtimezone2, ICAL_TZID_PROPERTY);
- if (!prop2)
- return -1;
-
- tzid2 = icalproperty_get_tzid (prop2);
- if (!tzid2)
- return -1;
-
- /* Copy the second TZID, and set the property to the same as the first
- TZID, since we don't care if these match of not. */
- tzid2_copy = strdup (tzid2);
- if (!tzid2_copy) {
- icalerror_set_errno (ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- icalproperty_set_tzid (prop2, tzid1);
-
- /* Now convert both VTIMEZONEs to strings and compare them. */
- string1 = icalcomponent_as_ical_string (vtimezone1);
- if (!string1) {
- free (tzid2_copy);
- return -1;
- }
-
- string2 = icalcomponent_as_ical_string (vtimezone2);
- if (!string2) {
- free (string1);
- free (tzid2_copy);
- return -1;
- }
-
- cmp = strcmp (string1, string2);
-
- free (string1);
- free (string2);
-
- /* Now reset the second TZID. */
- icalproperty_set_tzid (prop2, tzid2_copy);
- free (tzid2_copy);
-
- return (cmp == 0) ? 1 : 0;
-}
diff --git a/libical/src/libical/icalcomponent.h b/libical/src/libical/icalcomponent.h
deleted file mode 100644
index 55c0592bb2..0000000000
--- a/libical/src/libical/icalcomponent.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcomponent.h
- CREATOR: eric 20 March 1999
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The original code is icalcomponent.h
-
-======================================================================*/
-
-#ifndef ICALCOMPONENT_H
-#define ICALCOMPONENT_H
-
-#include "icalproperty.h"
-#include "icalvalue.h"
-#include "icalenums.h" /* defines icalcomponent_kind */
-#include "icalattendee.h"
-#include "pvl.h"
-
-typedef void icalcomponent;
-
-/* An opaque struct representing a timezone. We declare this here to avoid
- a circular dependancy. */
-#ifndef ICALTIMEONE_DEFINED
-#define ICALTIMEONE_DEFINED
-typedef struct _icaltimezone icaltimezone;
-#endif
-
-
-/* This is exposed so that callers will not have to allocate and
- deallocate iterators. Pretend that you can't see it. */
-typedef struct icalcompiter
-{
- icalcomponent_kind kind;
- pvl_elem iter;
-
-} icalcompiter;
-
-icalcomponent* icalcomponent_new(icalcomponent_kind kind);
-icalcomponent* icalcomponent_new_clone(icalcomponent* component);
-icalcomponent* icalcomponent_new_from_string(char* str);
-icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...);
-void icalcomponent_free(icalcomponent* component);
-
-char* icalcomponent_as_ical_string(icalcomponent* component);
-
-int icalcomponent_is_valid(icalcomponent* component);
-
-icalcomponent_kind icalcomponent_isa(icalcomponent* component);
-
-int icalcomponent_isa_component (void* component);
-
-/*
- * Working with properties
- */
-
-void icalcomponent_add_property(icalcomponent* component,
- icalproperty* property);
-
-void icalcomponent_remove_property(icalcomponent* component,
- icalproperty* property);
-
-int icalcomponent_count_properties(icalcomponent* component,
- icalproperty_kind kind);
-
-/* Iterate through the properties */
-icalproperty* icalcomponent_get_current_property(icalcomponent* component);
-
-icalproperty* icalcomponent_get_first_property(icalcomponent* component,
- icalproperty_kind kind);
-icalproperty* icalcomponent_get_next_property(icalcomponent* component,
- icalproperty_kind kind);
-
-
-/*
- * Working with components
- */
-
-
-/* Return the first VEVENT, VTODO or VJOURNAL sub-component of cop, or
- comp if it is one of those types */
-
-icalcomponent* icalcomponent_get_inner(icalcomponent* comp);
-
-
-void icalcomponent_add_component(icalcomponent* parent,
- icalcomponent* child);
-
-void icalcomponent_remove_component(icalcomponent* parent,
- icalcomponent* child);
-
-int icalcomponent_count_components(icalcomponent* component,
- icalcomponent_kind kind);
-
-/* This takes 2 VCALENDAR components and merges the second one into the first,
- resolving any problems with conflicting TZIDs. comp_to_merge will no
- longer exist after calling this function. */
-void icalcomponent_merge_component(icalcomponent* comp,
- icalcomponent* comp_to_merge);
-
-
-/* Iteration Routines. There are two forms of iterators, internal and
-external. The internal ones came first, and are almost completely
-sufficient, but they fail badly when you want to construct a loop that
-removes components from the container.*/
-
-
-/* Iterate through components */
-icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
-
-icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
- icalcomponent_kind kind);
-icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
- icalcomponent_kind kind);
-
-/* Using external iterators */
-icalcompiter icalcomponent_begin_component(icalcomponent* component,
- icalcomponent_kind kind);
-icalcompiter icalcomponent_end_component(icalcomponent* component,
- icalcomponent_kind kind);
-icalcomponent* icalcompiter_next(icalcompiter* i);
-icalcomponent* icalcompiter_prior(icalcompiter* i);
-icalcomponent* icalcompiter_deref(icalcompiter* i);
-
-
-
-
-/* Working with embedded error properties */
-
-int icalcomponent_count_errors(icalcomponent* component);
-
-/* Remove all X-LIC-ERROR properties*/
-void icalcomponent_strip_errors(icalcomponent* component);
-
-/* Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
-void icalcomponent_convert_errors(icalcomponent* component);
-
-/* Internal operations. They are private, and you should not be using them. */
-icalcomponent* icalcomponent_get_parent(icalcomponent* component);
-void icalcomponent_set_parent(icalcomponent* component,
- icalcomponent* parent);
-
-/* Kind conversion routiens */
-
-icalcomponent_kind icalcomponent_string_to_kind(const char* string);
-
-const char* icalcomponent_kind_to_string(icalcomponent_kind kind);
-
-
-/************* Derived class methods. ****************************
-
-If the code was in an OO language, the remaining routines would be
-members of classes derived from icalcomponent. Don't call them on the
-wrong component subtypes. */
-
-/* For VCOMPONENT: Return a reference to the first VEVENT, VTODO or
- VJOURNAL */
-icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c);
-
-/* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
- times of an event in UTC */
-struct icaltime_span icalcomponent_get_span(icalcomponent* comp);
-
-/******************** Convienience routines **********************/
-
-void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v);
-struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp);
-
-/* For the icalcomponent routines only, dtend and duration are tied
- together. If you call the set routine for one and the other exists,
- the routine will calculate the change to the other. That is, if
- there is a DTEND and you call set_duration, the routine will modify
- DTEND to be the sum of DTSTART and the duration. If you call a get
- routine for one and the other exists, the routine will calculate
- the return value. If you call a set routine and neither exists, the
- routine will create the apcompriate comperty */
-
-
-struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
-void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
-
-void icalcomponent_set_duration(icalcomponent* comp,
- struct icaldurationtype v);
-struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
-
-void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method);
-icalproperty_method icalcomponent_get_method(icalcomponent* comp);
-
-struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp);
-void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v);
-
-
-void icalcomponent_set_summary(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_summary(icalcomponent* comp);
-
-void icalcomponent_set_comment(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_comment(icalcomponent* comp);
-
-void icalcomponent_set_uid(icalcomponent* comp, const char* v);
-const char* icalcomponent_get_uid(icalcomponent* comp);
-
-void icalcomponent_set_recurrenceid(icalcomponent* comp,
- struct icaltimetype v);
-struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
-
-
-void icalcomponent_set_organizer(icalcomponent* comp,
- struct icalorganizertype org);
- struct icalorganizertype icalcomponent_get_organizer(icalcomponent* comp);
-
-
-void icalcomponent_add_attendee(icalcomponent *comp,
- struct icalattendeetype attendee);
-
-int icalcomponent_remove_attendee(icalcomponent *comp, char* cuid);
-
-/* Get the Nth attendee. Out of range indices return an attendee
- with cuid == 0 */
-struct icalattendeetype icalcomponent_get_attendee(icalcomponent *comp,
- int index);
-
-/* Calls the given function for each TZID parameter found in the component,
- and any subcomponents. */
-void icalcomponent_foreach_tzid(icalcomponent* comp,
- void (*callback)(icalparameter *param, void *data),
- void *callback_data);
-
-/* Returns the icaltimezone in the component corresponding to the TZID, or NULL
- if it can't be found. */
-icaltimezone* icalcomponent_get_timezone(icalcomponent* comp,
- const char *tzid);
-
-
-/*************** Type Specific routines ***************/
-
-icalcomponent* icalcomponent_new_vcalendar();
-icalcomponent* icalcomponent_new_vevent();
-icalcomponent* icalcomponent_new_vtodo();
-icalcomponent* icalcomponent_new_vjournal();
-icalcomponent* icalcomponent_new_valarm();
-icalcomponent* icalcomponent_new_vfreebusy();
-icalcomponent* icalcomponent_new_vtimezone();
-icalcomponent* icalcomponent_new_xstandard();
-icalcomponent* icalcomponent_new_xdaylight();
-
-
-
-#endif /* !ICALCOMPONENT_H */
-
-
-
diff --git a/libical/src/libical/icalderivedparameter.c.in b/libical/src/libical/icalderivedparameter.c.in
deleted file mode 100644
index 4af6e95c0e..0000000000
--- a/libical/src/libical/icalderivedparameter.c.in
+++ /dev/null
@@ -1,211 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalderivedparameters.{c,h}
- CREATOR: eric 09 May 1999
-
- $Id: icalderivedparameter.c.in,v 1.1 2001/04/17 17:23:17 jpr 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 "icalparameterimpl.h"
-
-#include "icalproperty.h"
-#include "icalerror.h"
-#include "icalmemory.h"
-
-#include <stdlib.h> /* for malloc() */
-#include <errno.h>
-#include <string.h> /* for memset() */
-
-icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
-
-struct icalparameter_impl* icalparameter_new_impl(icalparameter_kind kind);
-
-/* This map associates each of the parameters with the string
- representation of the paramter's name */
-struct icalparameter_kind_map {
- icalparameter_kind kind;
- char *name;
-
-};
-
-extern struct icalparameter_kind_map parameter_map[];
-
-
-const char* icalparameter_kind_to_string(icalparameter_kind kind)
-{
- int i;
-
- for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
- if (parameter_map[i].kind == kind) {
- return parameter_map[i].name;
- }
- }
-
- return 0;
-
-}
-
-icalparameter_kind icalparameter_string_to_kind(const char* string)
-{
- int i;
-
- if (string ==0 ) {
- return ICAL_NO_PARAMETER;
- }
-
- for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
-
- if (strcmp(parameter_map[i].name, string) == 0) {
- return parameter_map[i].kind;
- }
- }
-
- if(strncmp(string,"X-",2)==0){
- return ICAL_X_PARAMETER;
- }
-
- return ICAL_NO_PARAMETER;
-}
-
-/* This map associates the enumerations for the VALUE parameter with
- the kinds of VALUEs. */
-
-struct icalparameter_value_kind_map {
- icalparameter_value value;
- icalvalue_kind kind;
-};
-
-extern struct icalparameter_value_kind_map value_kind_map[];
-
-
-icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value)
-{
- int i;
-
- for (i=0; value_kind_map[i].kind != ICAL_NO_VALUE; i++) {
-
- if (value_kind_map[i].value == value) {
- return value_kind_map[i].kind;
- }
- }
-
- return ICAL_NO_VALUE;
-}
-
-
-/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */
-
-struct icalparameter_map {
- icalparameter_kind kind;
- int enumeration;
- const char* str;
-};
-
-
-extern struct icalparameter_map icalparameter_map[];
-
-
-const char* icalparameter_enum_to_string(int e)
-{
- int i;
-
- icalerror_check_arg_rz(e >= ICALPARAMETER_FIRST_ENUM,"e");
- icalerror_check_arg_rz(e <= ICALPARAMETER_LAST_ENUM,"e");
-
- for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
- if(e == icalparameter_map[i].enumeration){
- return icalparameter_map[i].str;
- }
- }
-
- return 0;
-}
-
-int icalparameter_string_to_enum(const char* str)
-{
- int i;
-
- icalerror_check_arg_rz(str != 0,"str");
-
- for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
- if(strcmp(str,icalparameter_map[i].str) == 0) {
- return icalparameter_map[i].enumeration;
- }
- }
-
- return 0;
-}
-
-icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val)
-{
-
- struct icalparameter_impl* param=0;
- int found_kind = 0;
- int i;
-
- icalerror_check_arg_rz((val!=0),"val");
-
- /* Search through the parameter map to find a matching kind */
-
- param = icalparameter_new_impl(kind);
-
- for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
- if(kind == icalparameter_map[i].kind) {
- found_kind = 1;
- if(strcmp(val,icalparameter_map[i].str) == 0) {
-
- param->data = (int)icalparameter_map[i].enumeration;
- return param;
- }
- }
- }
-
- if(found_kind == 1){
- /* The kind was in the parameter map, but the string did not
- match, so assume that it is an alternate value, like an
- X-value.*/
-
- icalparameter_set_xvalue(param, val);
-
- } else {
-
- /* If the kind was not found, then it must be a string type */
-
- ((struct icalparameter_impl*)param)->string = icalmemory_strdup(val);
-
- }
-
- return param;
-}
-
-
-
-
-/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedparameter.h.in b/libical/src/libical/icalderivedparameter.h.in
deleted file mode 100644
index e9fdd19fa7..0000000000
--- a/libical/src/libical/icalderivedparameter.h.in
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalparam.h
- CREATOR: eric 20 March 1999
-
-
- $Id: icalderivedparameter.h.in,v 1.1 2001/04/17 17:23:17 jpr 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 ICALDERIVEDPARAMETER_H
-#define ICALDERIVEDPARAMETER_H
-
-
-typedef void icalparameter;
-
-const char* icalparameter_enum_to_string(int e);
-int icalparameter_string_to_enum(const char* str);
-
diff --git a/libical/src/libical/icalderivedproperty.c.in b/libical/src/libical/icalderivedproperty.c.in
deleted file mode 100644
index ceec0b797d..0000000000
--- a/libical/src/libical/icalderivedproperty.c.in
+++ /dev/null
@@ -1,250 +0,0 @@
-/* -*- Mode: C -*- */
-
-/*======================================================================
- FILE: icalderivedproperty.c
- CREATOR: eric 15 Feb 2001
-
- $Id: icalderivedproperty.c.in,v 1.1 2001/04/17 17:23:17 jpr 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
-
-======================================================================*/
-
-#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 "icalparser.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
-
-struct icalproperty_impl*
-icalproperty_new_impl (icalproperty_kind kind);
-
-/* This map associates the property kinds with the string
- representation of the property name and the kind of VALUE that the
- property uses as a default */
-
-struct icalproperty_map {
- icalproperty_kind kind;
- const char *name;
- icalvalue_kind value;
-
-};
-
-extern struct icalproperty_map property_map[];
-
-const char* icalproperty_kind_to_string(icalproperty_kind kind)
-{
- int i;
-
- for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
- if (property_map[i].kind == kind) {
- return property_map[i].name;
- }
- }
-
- return 0;
-
-}
-
-
-icalproperty_kind icalproperty_string_to_kind(const char* string)
-{
- int i;
-
- if (string ==0 ) {
- return ICAL_NO_PROPERTY;
- }
-
-
- for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
- if (strcmp(property_map[i].name, string) == 0) {
- return property_map[i].kind;
- }
- }
-
- if(strncmp(string,"X-",2)==0){
- return ICAL_X_PROPERTY;
- }
-
-
- return ICAL_NO_PROPERTY;
-}
-
-
-icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind)
-{
- int i;
-
- for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
- if ( property_map[i].value == kind ) {
- return property_map[i].kind;
- }
- }
-
- return ICAL_NO_VALUE;
-}
-
-
-
-icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind)
-{
- int i;
-
- for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
- if ( property_map[i].kind == kind ) {
- return property_map[i].value;
- }
- }
-
- return ICAL_NO_VALUE;
-}
-
-
-/* This map associates the property enumerations with the king of
- property that they are used in and the string representation of the
- enumeration */
-
-struct icalproperty_enum_map {
- icalproperty_kind prop;
- int prop_enum;
- const char* str;
-};
-
-extern struct icalproperty_enum_map enum_map[];
-
-
-const char* icalproperty_enum_to_string(int e)
-{
- icalerror_check_arg_rz(e >= ICALPROPERTY_FIRST_ENUM,"e");
- icalerror_check_arg_rz(e <= ICALPROPERTY_LAST_ENUM,"e");
-
- return enum_map[e-ICALPROPERTY_FIRST_ENUM].str;
-}
-
-int icalproperty_string_to_enum(const char* str)
-{
- int i;
-
- icalerror_check_arg_rz(str!=0,"str")
-
- while(*str == ' '){
- str++;
- }
-
- for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
- if ( strcmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
- return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum;
- }
- }
-
- return 0;
-}
-
-int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e)
-{
- int i;
-
-
- for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
- if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum == e &&
- enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == kind ){
- return 1;
- }
- }
-
- return 0;
-}
-
-
-const char* icalproperty_method_to_string(icalproperty_method method)
-{
- icalerror_check_arg_rz(method >= ICAL_METHOD_X,"method");
- icalerror_check_arg_rz(method <= ICAL_METHOD_NONE,"method");
-
- return enum_map[method-ICALPROPERTY_FIRST_ENUM].str;
-}
-
-icalproperty_method icalproperty_string_to_method(const char* str)
-{
- int i;
-
- icalerror_check_arg_rx(str!=0,"str",ICAL_METHOD_NONE)
-
- while(*str == ' '){
- str++;
- }
-
- for (i=ICAL_METHOD_X-ICALPROPERTY_FIRST_ENUM;
- i != ICAL_METHOD_NONE-ICALPROPERTY_FIRST_ENUM;
- i++) {
- if ( strcmp(enum_map[i].str, str) == 0) {
- return (icalproperty_method)enum_map[i].prop_enum;
- }
- }
-
- return ICAL_METHOD_NONE;
-}
-
-
-const char* icalenum_status_to_string(icalproperty_status status)
-{
- icalerror_check_arg_rz(status >= ICAL_STATUS_X,"status");
- icalerror_check_arg_rz(status <= ICAL_STATUS_NONE,"status");
-
- return enum_map[status-ICALPROPERTY_FIRST_ENUM].str;
-}
-
-icalproperty_status icalenum_string_to_status(const char* str)
-{
- int i;
-
- icalerror_check_arg_rx(str!=0,"str",ICAL_STATUS_NONE)
-
- while(*str == ' '){
- str++;
- }
-
- for (i=ICAL_STATUS_X-ICALPROPERTY_FIRST_ENUM;
- i != ICAL_STATUS_NONE-ICALPROPERTY_FIRST_ENUM;
- i++) {
- if ( strcmp(enum_map[i].str, str) == 0) {
- return (icalproperty_method)enum_map[i].prop_enum;
- }
- }
-
- return ICAL_STATUS_NONE;
-
-}
-
-
-
-/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedproperty.h.in b/libical/src/libical/icalderivedproperty.h.in
deleted file mode 100644
index 6ce34afafb..0000000000
--- a/libical/src/libical/icalderivedproperty.h.in
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalderivedproperties.{c,h}
- CREATOR: eric 09 May 1999
-
- $Id: icalderivedproperty.h.in,v 1.1 2001/04/17 17:23:17 jpr Exp $
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
- ======================================================================*/
-
-
-#ifndef ICALDERIVEDPROPERTY_H
-#define ICALDERIVEDPROPERTY_H
-
-#include <time.h>
-#include "icalparameter.h"
-#include "icalderivedvalue.h"
-#include "icalrecur.h"
-
-typedef void icalproperty;
-
-
-/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedvalue.c.in b/libical/src/libical/icalderivedvalue.c.in
deleted file mode 100644
index 420ffb9ef0..0000000000
--- a/libical/src/libical/icalderivedvalue.c.in
+++ /dev/null
@@ -1,299 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalvalue.c
- CREATOR: eric 02 May 1999
-
- $Id: icalderivedvalue.c.in,v 1.1 2001/04/17 17:23:17 jpr 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 "icalvalueimpl.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 */
-
-
-
-#define TMP_BUF_SIZE 1024
-
-struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind);
-
-/* This map associates each of the value types with its string
- representation */
-struct icalvalue_kind_map {
- icalvalue_kind kind;
- char name[20];
-};
-
-extern struct icalvalue_kind_map value_map[];
-
-const char* icalvalue_kind_to_string(icalvalue_kind kind)
-{
- int i;
-
- for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
- if (value_map[i].kind == kind) {
- return value_map[i].name;
- }
- }
-
- return 0;
-}
-
-icalvalue_kind icalvalue_string_to_kind(const char* str)
-{
- int i;
-
- for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
- if (strcmp(value_map[i].name,str) == 0) {
- return value_map[i].kind;
- }
- }
-
- return value_map[i].kind;
-
-}
-
-icalvalue* icalvalue_new_x (const char* v){
- struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE);
- icalerror_check_arg_rz( (v!=0),"v");
-
- icalvalue_set_x((icalvalue*)impl,v);
- return (icalvalue*)impl;
-}
-void icalvalue_set_x(icalvalue* value, const char* v) {
- struct icalvalue_impl* impl;
- icalerror_check_arg_rv( (value!=0),"value");
- icalerror_check_arg_rv( (v!=0),"v");
-
- impl = (struct icalvalue_impl*)value;
- if(impl->x_value!=0) {free((void*)impl->x_value);}
-
- impl->x_value = icalmemory_strdup(v);
-
- if (impl->x_value == 0){
- errno = ENOMEM;
- }
-
- }
-const char* icalvalue_get_x(icalvalue* value) {
-
- icalerror_check_arg( (value!=0),"value");
- icalerror_check_value_type(value, ICAL_X_VALUE);
- return ((struct icalvalue_impl*)value)->x_value;
-}
-
-/* Recur is a special case, so it is not auto generated. */
-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_NEWFAILED_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);
-}
-
-
-
-
-icalvalue*
-icalvalue_new_trigger (struct icaltriggertype v)
-{
- struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
-
- icalvalue_set_trigger((icalvalue*)impl,v);
-
- return (icalvalue*)impl;
-}
-
-void
-icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
-{
- struct icalvalue_impl* impl;
-
- icalerror_check_arg_rv( (value!=0),"value");
-
- impl = (struct icalvalue_impl*)value;
-
- if(!icaltime_is_null_time(v.time)){
- icalvalue_set_datetime((icalvalue*)impl,v.time);
- impl->kind = ICAL_DATETIME_VALUE;
- } else {
- icalvalue_set_duration((icalvalue*)impl,v.duration);
- impl->kind = ICAL_DURATION_VALUE;
- }
-
-}
-
-struct icaltriggertype
-icalvalue_get_trigger(icalvalue* value)
-{
- struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
- struct icaltriggertype tr;
-
- icalerror_check_arg( (value!=0),"value");
- icalerror_check_arg( (value!=0),"value");
-
- if(impl->kind == ICAL_DATETIME_VALUE){
- tr.duration = icaldurationtype_from_int(0);
- tr.time = impl->data.v_time;
- } else if(impl->kind == ICAL_DURATION_VALUE){
- tr.time = icaltime_null_time();
- tr.duration = impl->data.v_duration;
- } else {
- tr.duration = icaldurationtype_from_int(0);
- tr.time = icaltime_null_time();
- icalerror_set_errno(ICAL_BADARG_ERROR);
- }
-
- return tr;
-}
-
-/* DATE-TIME-PERIOD is a special case, and is not auto generated */
-
-icalvalue*
-icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
-{
- struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);
-
- icalvalue_set_datetimeperiod((icalvalue*)impl,v);
-
- return (icalvalue*)impl;
-}
-
-void
-icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v)
-{
- struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
-
- icalerror_check_arg_rv( (value!=0),"value");
-
- icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
-
- if(!icaltime_is_null_time(v.time)){
- if(!icaltime_is_valid_time(v.time)){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
- }
- impl->kind = ICAL_DATETIME_VALUE;
- icalvalue_set_datetime(impl,v.time);
- } else if (!icalperiodtype_is_null_period(v.period)) {
- if(!icalperiodtype_is_valid_period(v.period)){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
- }
- impl->kind = ICAL_PERIOD_VALUE;
- icalvalue_set_period(impl,v.period);
- } else {
- icalerror_set_errno(ICAL_BADARG_ERROR);
- }
-}
-
-struct icaldatetimeperiodtype
-icalvalue_get_datetimeperiod(icalvalue* value)
-{
- struct icaldatetimeperiodtype dtp;
-
- struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
- icalerror_check_arg( (value!=0),"value");
- icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
-
- if(impl->kind == ICAL_DATETIME_VALUE){
- dtp.period = icalperiodtype_null_period();
- dtp.time = impl->data.v_time;
- } else if(impl->kind == ICAL_PERIOD_VALUE) {
- dtp.period = impl->data.v_period;
- dtp.time = icaltime_null_time();
- } else {
- dtp.period = icalperiodtype_null_period();
- dtp.time = icaltime_null_time();
- icalerror_set_errno(ICAL_BADARG_ERROR);
- }
-
- return dtp;
-}
-
-
-
-
-
-
-
-
-
-/* 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/icalderivedvalue.h.in b/libical/src/libical/icalderivedvalue.h.in
deleted file mode 100644
index 640dd86821..0000000000
--- a/libical/src/libical/icalderivedvalue.h.in
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalvalue.h
- CREATOR: eric 20 March 1999
-
-
- $Id: icalderivedvalue.h.in,v 1.1 2001/04/17 17:23:17 jpr 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 ICALDERIVEDVALUE_H
-#define ICALDERIVEDVALUE_H
-
-#include "icaltypes.h"
-#include "icalrecur.h"
-#include "icaltime.h"
-#include "icalduration.h"
-#include "icalperiod.h"
-
-typedef void icalvalue;
-
-
-
-void icalvalue_set_x(icalvalue* value, const char* v);
-icalvalue* icalvalue_new_x(const char* v);
-const char* icalvalue_get_x(icalvalue* value);
-
-icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
-void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
-struct icalrecurrencetype icalvalue_get_recur(icalvalue* value);
-
-icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
-void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
-struct icaltriggertype icalvalue_get_trigger(icalvalue* value);
-
-icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
-void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v);
-struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value);
-
-/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalduration.c b/libical/src/libical/icalduration.c
deleted file mode 100644
index 18a74396f5..0000000000
--- a/libical/src/libical/icalduration.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icaltime.c
- CREATOR: eric 02 June 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
-
-#include "icalduration.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef ICAL_NO_LIBICAL
-#define icalerror_set_errno(x)
-#define icalerror_check_arg_rv(x,y)
-#define icalerror_check_arg_re(x,y,z)
-#else
-#include "icalerror.h"
-#include "icalmemory.h"
-#endif
-
-
-
-
-/* From Seth Alves, <alves@hungry.com> */
-struct icaldurationtype icaldurationtype_from_int(int t)
-{
- struct icaldurationtype dur;
- int used = 0;
-
- dur = icaldurationtype_null_duration();
-
- if(t < 0){
- dur.is_neg = 1;
- t = -t;
- }
-
- dur.weeks = (t - used) / (60 * 60 * 24 * 7);
- used += dur.weeks * (60 * 60 * 24 * 7);
- dur.days = (t - used) / (60 * 60 * 24);
- used += dur.days * (60 * 60 * 24);
- dur.hours = (t - used) / (60 * 60);
- used += dur.hours * (60 * 60);
- dur.minutes = (t - used) / (60);
- used += dur.minutes * (60);
- dur.seconds = (t - used);
-
- return dur;
-}
-
-#ifndef ICAL_NO_LIBICAL
-#include "icalvalue.h"
-struct icaldurationtype icaldurationtype_from_string(const char* str)
-{
-
- int i;
- int begin_flag = 0;
- int time_flag = 0;
- int date_flag = 0;
- int week_flag = 0;
- int digits=-1;
- int scan_size = -1;
- int size = strlen(str);
- char p;
- struct icaldurationtype d;
-
- memset(&d, 0, sizeof(struct icaldurationtype));
-
- for(i=0;i != size;i++){
- p = str[i];
-
- switch(p)
- {
- case '-': {
- if(i != 0 || begin_flag == 1) goto error;
-
- d.is_neg = 1;
- break;
- }
-
- case 'P': {
- if (i != 0 && i !=1 ) goto error;
- begin_flag = 1;
- break;
- }
-
- case 'T': {
- time_flag = 1;
- break;
- }
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
-
- /* HACK. Skip any more digits if the l;ast one
- read has not been assigned */
- if(digits != -1){
- break;
- }
-
- if (begin_flag == 0) goto error;
- /* Get all of the digits, not one at a time */
- scan_size = sscanf((char*)(str+i),"%d",&digits);
- if(scan_size == 0) goto error;
- break;
- }
-
- case 'H': {
- if (time_flag == 0||week_flag == 1||d.hours !=0||digits ==-1)
- goto error;
- d.hours = digits; digits = -1;
- break;
- }
- case 'M': {
- if (time_flag == 0||week_flag==1||d.minutes != 0||digits ==-1)
- goto error;
- d.minutes = digits; digits = -1;
- break;
- }
- case 'S': {
- if (time_flag == 0||week_flag==1||d.seconds!=0||digits ==-1)
- goto error;
- d.seconds = digits; digits = -1;
- break;
- }
- case 'W': {
- if (time_flag==1||date_flag==1||d.weeks!=0||digits ==-1)
- goto error;
- week_flag = 1;
- d.weeks = digits; digits = -1;
- break;
- }
- case 'D': {
- if (time_flag==1||week_flag==1||d.days!=0||digits ==-1)
- goto error;
- date_flag = 1;
- d.days = digits; digits = -1;
- break;
- }
- default: {
- goto error;
- }
-
- }
- }
-
- return d;
-
-
- error:
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- memset(&d, 0, sizeof(struct icaldurationtype));
- return d;
-
-}
-
-#define TMP_BUF_SIZE 1024
-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* icaldurationtype_as_ical_string(struct icaldurationtype d)
-{
-
- char *buf, *output_line;
- size_t buf_size = 256;
- char* buf_ptr = 0;
- int seconds;
-
- buf = (char*)icalmemory_new_buffer(buf_size);
- buf_ptr = buf;
-
-
- seconds = icaldurationtype_as_int(d);
-
- if(seconds !=0){
-
- if(d.is_neg == 1){
- icalmemory_append_char(&buf, &buf_ptr, &buf_size, '-');
- }
-
- icalmemory_append_char(&buf, &buf_ptr, &buf_size, 'P');
-
- if (d.weeks != 0 ) {
- append_duration_segment(&buf, &buf_ptr, &buf_size, "W", d.weeks);
- }
-
- if (d.days != 0 ) {
- append_duration_segment(&buf, &buf_ptr, &buf_size, "D", d.days);
- }
-
- if (d.hours != 0 || d.minutes != 0 || d.seconds != 0) {
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "T");
-
- if (d.hours != 0 ) {
- append_duration_segment(&buf, &buf_ptr, &buf_size, "H", d.hours);
- }
- if (d.minutes != 0 ) {
- append_duration_segment(&buf, &buf_ptr, &buf_size, "M",
- d.minutes);
- }
- if (d.seconds != 0 ) {
- append_duration_segment(&buf, &buf_ptr, &buf_size, "S",
- d.seconds);
- }
-
- }
- } else {
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PTS0");
- }
-
- output_line = icalmemory_tmp_copy(buf);
- icalmemory_free_buffer(buf);
-
- return output_line;
-
-}
-
-#endif
-
-
-/* From Russel Steinthal */
-int icaldurationtype_as_int(struct icaldurationtype dur)
-{
- return (int)( (dur.seconds +
- (60 * dur.minutes) +
- (60 * 60 * dur.hours) +
- (60 * 60 * 24 * dur.days) +
- (60 * 60 * 24 * 7 * dur.weeks))
- * (dur.is_neg==1? -1 : 1) ) ;
-}
-
-struct icaldurationtype icaldurationtype_null_duration()
-{
- struct icaldurationtype d;
-
- memset(&d,0,sizeof(struct icaldurationtype));
-
- return d;
-}
-
-int icaldurationtype_is_null_duration(struct icaldurationtype d)
-{
- if(icaldurationtype_as_int(d) == 0){
- return 1;
- } else {
- return 0;
- }
-}
-
-
-
-struct icaltimetype icaltime_add(struct icaltimetype t,
- struct icaldurationtype d)
-{
- int dt = icaldurationtype_as_int(d);
-
- t.second += dt;
-
- t = icaltime_normalize(t);
-
- return t;
-}
-
-struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
- struct icaltimetype t2)
-{
-
- time_t t1t = icaltime_as_timet(t1);
- time_t t2t = icaltime_as_timet(t2);
-
- return icaldurationtype_from_int(t1t-t2t);
-
-
-}
-
diff --git a/libical/src/libical/icalduration.h b/libical/src/libical/icalduration.h
deleted file mode 100644
index dd6e311f47..0000000000
--- a/libical/src/libical/icalduration.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalduration.h
- CREATOR: eric 26 Jan 2001
-
-
- $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 ICALDURATION_H
-#define ICALDURATION_H
-
-#include "icaltime.h"
-
-struct icaldurationtype
-{
- int is_neg;
- unsigned int days;
- unsigned int weeks;
- unsigned int hours;
- unsigned int minutes;
- unsigned int seconds;
-};
-
-struct icaldurationtype icaldurationtype_from_int(int t);
-struct icaldurationtype icaldurationtype_from_string(const char*);
-int icaldurationtype_as_int(struct icaldurationtype duration);
-char* icaldurationtype_as_ical_string(struct icaldurationtype d);
-struct icaldurationtype icaldurationtype_null_duration();
-int icaldurationtype_is_null_duration(struct icaldurationtype d);
-
-struct icaltimetype icaltime_add(struct icaltimetype t,
- struct icaldurationtype d);
-
-struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
- struct icaltimetype t2);
-
-#endif /* !ICALDURATION_H */
-
-
-
diff --git a/libical/src/libical/icalenums.c b/libical/src/libical/icalenums.c
deleted file mode 100644
index 6751933c3e..0000000000
--- a/libical/src/libical/icalenums.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalenum.c
- CREATOR: eric 29 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 icalenum.c
-
- ======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalenums.h"
-
-#include <stdio.h> /* For fprintf */
-#include <stdio.h> /* For stderr */
-#include <string.h> /* For strncmp */
-#include <assert.h>
-
-
-
-struct {
- enum icalrequeststatus kind;
- int major;
- int minor;
- const char* str;
-} request_status_map[] = {
- {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."},
- {ICAL_2_1_FALLBACK_STATUS, 2,1,"Success but fallback taken on one or more property values."},
- {ICAL_2_2_IGPROP_STATUS, 2,2,"Success, invalid property ignored."},
- {ICAL_2_3_IGPARAM_STATUS, 2,3,"Success, invalid property parameter ignored."},
- {ICAL_2_4_IGXPROP_STATUS, 2,4,"Success, unknown non-standard property ignored."},
- {ICAL_2_5_IGXPARAM_STATUS, 2,5,"Success, unknown non standard property value ignored."},
- {ICAL_2_6_IGCOMP_STATUS, 2,6,"Success, invalid calendar component ignored."},
- {ICAL_2_7_FORWARD_STATUS, 2,7,"Success, request forwarded to Calendar User."},
- {ICAL_2_8_ONEEVENT_STATUS, 2,8,"Success, repeating event ignored. Scheduled as a single component."},
- {ICAL_2_9_TRUNC_STATUS, 2,9,"Success, truncated end date time to date boundary."},
- {ICAL_2_10_ONETODO_STATUS, 2,10,"Success, repeating VTODO ignored. Scheduled as a single VTODO."},
- {ICAL_2_11_TRUNCRRULE_STATUS, 2,11,"Success, unbounded RRULE clipped at some finite number of instances "},
- {ICAL_3_0_INVPROPNAME_STATUS, 3,0,"Invalid property name."},
- {ICAL_3_1_INVPROPVAL_STATUS, 3,1,"Invalid property value."},
- {ICAL_3_2_INVPARAM_STATUS, 3,2,"Invalid property parameter."},
- {ICAL_3_3_INVPARAMVAL_STATUS, 3,3,"Invalid property parameter value."},
- {ICAL_3_4_INVCOMP_STATUS, 3,4,"Invalid calendar component."},
- {ICAL_3_5_INVTIME_STATUS, 3,5,"Invalid date or time."},
- {ICAL_3_6_INVRULE_STATUS, 3,6,"Invalid rule."},
- {ICAL_3_7_INVCU_STATUS, 3,7,"Invalid Calendar User."},
- {ICAL_3_8_NOAUTH_STATUS, 3,8,"No authority."},
- {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."},
- {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."},
- {ICAL_3_11_MISSREQCOMP_STATUS, 3,11,"Required component or property missing."},
- {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."},
- {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"},
- {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."},
- {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."},
- {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."},
- {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."},
- {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."},
- {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."},
- {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"}
-};
-
-
-const char* icalenum_reqstat_desc(icalrequeststatus stat)
-{
-
- int i;
-
- for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
- if ( request_status_map[i].kind == stat) {
- return request_status_map[i].str;
- }
- }
-
- return 0;
-}
-
-
-short icalenum_reqstat_major(icalrequeststatus stat)
-{
- int i;
-
- for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
- if ( request_status_map[i].kind == stat) {
- return request_status_map[i].major;
- }
- }
- return -1;
-}
-
-short icalenum_reqstat_minor(icalrequeststatus stat)
-{
- int i;
-
- for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
- if ( request_status_map[i].kind == stat) {
- return request_status_map[i].minor;
- }
- }
- return -1;
-}
-
-
-icalrequeststatus icalenum_num_to_reqstat(short major, short minor)
-{
- int i;
-
- for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
- if ( request_status_map[i].major == major && request_status_map[i].minor == minor) {
- return request_status_map[i].kind;
- }
- }
- return 0;
-}
-
-
-
diff --git a/libical/src/libical/icalenums.h b/libical/src/libical/icalenums.h
deleted file mode 100644
index 21031dd20e..0000000000
--- a/libical/src/libical/icalenums.h
+++ /dev/null
@@ -1,157 +0,0 @@
-
-/* -*- Mode: C -*-*/
-/*======================================================================
- FILE: icalenums.h
-
-
-
- (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 icalenums.h
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
-======================================================================*/
-
-#ifndef ICALENUMS_H
-#define ICALENUMS_H
-
-
-
-/***********************************************************************
- * Component enumerations
-**********************************************************************/
-
-typedef enum icalcomponent_kind {
- ICAL_NO_COMPONENT,
- ICAL_ANY_COMPONENT, /* Used to select all components*/
- ICAL_XROOT_COMPONENT,
- ICAL_XATTACH_COMPONENT, /* MIME attached data, returned by parser. */
- ICAL_VEVENT_COMPONENT,
- ICAL_VTODO_COMPONENT,
- ICAL_VJOURNAL_COMPONENT,
- ICAL_VCALENDAR_COMPONENT,
- ICAL_VFREEBUSY_COMPONENT,
- ICAL_VALARM_COMPONENT,
- ICAL_XAUDIOALARM_COMPONENT,
- ICAL_XDISPLAYALARM_COMPONENT,
- ICAL_XEMAILALARM_COMPONENT,
- ICAL_XPROCEDUREALARM_COMPONENT,
- ICAL_VTIMEZONE_COMPONENT,
- ICAL_XSTANDARD_COMPONENT,
- ICAL_XDAYLIGHT_COMPONENT,
- ICAL_X_COMPONENT,
- ICAL_VSCHEDULE_COMPONENT,
- ICAL_VQUERY_COMPONENT,
- ICAL_VCAR_COMPONENT,
- ICAL_VCOMMAND_COMPONENT,
- ICAL_XLICINVALID_COMPONENT,
- ICAL_XLICMIMEPART_COMPONENT /* a non-stardard component that mirrors
- structure of MIME data */
-
-} icalcomponent_kind;
-
-
-
-/***********************************************************************
- * Request Status codes
- **********************************************************************/
-
-typedef enum icalrequeststatus {
- ICAL_UNKNOWN_STATUS,
- ICAL_2_0_SUCCESS_STATUS,
- ICAL_2_1_FALLBACK_STATUS,
- ICAL_2_2_IGPROP_STATUS,
- ICAL_2_3_IGPARAM_STATUS,
- ICAL_2_4_IGXPROP_STATUS,
- ICAL_2_5_IGXPARAM_STATUS,
- ICAL_2_6_IGCOMP_STATUS,
- ICAL_2_7_FORWARD_STATUS,
- ICAL_2_8_ONEEVENT_STATUS,
- ICAL_2_9_TRUNC_STATUS,
- ICAL_2_10_ONETODO_STATUS,
- ICAL_2_11_TRUNCRRULE_STATUS,
- ICAL_3_0_INVPROPNAME_STATUS,
- ICAL_3_1_INVPROPVAL_STATUS,
- ICAL_3_2_INVPARAM_STATUS,
- ICAL_3_3_INVPARAMVAL_STATUS,
- ICAL_3_4_INVCOMP_STATUS,
- ICAL_3_5_INVTIME_STATUS,
- ICAL_3_6_INVRULE_STATUS,
- ICAL_3_7_INVCU_STATUS,
- ICAL_3_8_NOAUTH_STATUS,
- ICAL_3_9_BADVERSION_STATUS,
- ICAL_3_10_TOOBIG_STATUS,
- ICAL_3_11_MISSREQCOMP_STATUS,
- ICAL_3_12_UNKCOMP_STATUS,
- ICAL_3_13_BADCOMP_STATUS,
- ICAL_3_14_NOCAP_STATUS,
- ICAL_4_0_BUSY_STATUS,
- ICAL_5_0_MAYBE_STATUS,
- ICAL_5_1_UNAVAIL_STATUS,
- ICAL_5_2_NOSERVICE_STATUS,
- ICAL_5_3_NOSCHED_STATUS
-} icalrequeststatus;
-
-
-const char* icalenum_reqstat_desc(icalrequeststatus stat);
-short icalenum_reqstat_major(icalrequeststatus stat);
-short icalenum_reqstat_minor(icalrequeststatus stat);
-icalrequeststatus icalenum_num_to_reqstat(short major, short minor);
-
-/***********************************************************************
- * Conversion functions
-**********************************************************************/
-
-
-/* Thse routines used to be in icalenums.c, but were moved into the
- icalproperty, icalparameter, icalvalue, or icalcomponent modules. */
-
-/* const char* icalproperty_kind_to_string(icalproperty_kind kind);*/
-#define icalenum_property_kind_to_string(x) icalproperty_kind_to_string(x)
-
-/*icalproperty_kind icalproperty_string_to_kind(const char* string)*/
-#define icalenum_string_to_property_kind(x) icalproperty_string_to_kind(x)
-
-/*icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);*/
-#define icalenum_property_kind_to_value_kind(x) icalproperty_kind_to_value_kind(x)
-
-/*const char* icalenum_method_to_string(icalproperty_method);*/
-#define icalenum_method_to_string(x) icalproperty_method_to_string(x)
-
-/*icalproperty_method icalenum_string_to_method(const char* string);*/
-#define icalenum_string_to_method(x) icalproperty_string_to_method(x)
-
-/*const char* icalenum_status_to_string(icalproperty_status);*/
-#define icalenum_status_to_string(x) icalproperty_status_to_string(x)
-
-/*icalproperty_status icalenum_string_to_status(const char* string);*/
-#define icalenum_string_to_status(x) icalproperty_string_to_status(x)
-
-/*icalvalue_kind icalenum_string_to_value_kind(const char* str);*/
-#define icalenum_string_to_value_kind(x) icalvalue_string_to_kind(x)
-
-/*const char* icalenum_value_kind_to_string(icalvalue_kind kind);*/
-#define icalenum_value_kind_to_string(x) icalvalue_kind_to_string(x)
-
-/*const char* icalenum_component_kind_to_string(icalcomponent_kind kind);*/
-#define icalenum_component_kind_to_string(x) icalcomponent_kind_to_string(x)
-
-/*icalcomponent_kind icalenum_string_to_component_kind(const char* string);*/
-#define icalenum_string_to_component_kind(x) icalcomponent_string_to_kind(x)
-
-
-#endif /* !ICALENUMS_H */
-
diff --git a/libical/src/libical/icalerror.c b/libical/src/libical/icalerror.c
deleted file mode 100644
index 05191defb9..0000000000
--- a/libical/src/libical/icalerror.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalerror.c
- CREATOR: eric 16 May 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 icalerror.c
-
- ======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalerror.h"
-
-icalerrorenum icalerrno;
-
-int foo;
-void icalerror_stop_here(void)
-{
- foo++; /* Keep optimizers from removing routine */
-}
-
-void icalerror_crash_here(void)
-{
- int *p=0;
- *p = 1;
-
- assert( *p);
-}
-
-
-void icalerror_clear_errno() {
-
- icalerrno = ICAL_NO_ERROR;
-}
-
-#ifdef ICAL_ERRORS_ARE_FATAL
-int icalerror_errors_are_fatal = 1;
-#else
-int icalerror_errors_are_fatal = 0;
-#endif
-
-struct icalerror_state {
- icalerrorenum error;
- icalerrorstate state;
-};
-
-struct icalerror_state error_state_map[] =
-{
- { ICAL_BADARG_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_NEWFAILED_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_PARSE_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_INTERNAL_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_FILE_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_USAGE_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_UNIMPLEMENTED_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_UNKNOWN_ERROR,ICAL_ERROR_DEFAULT},
- { ICAL_NO_ERROR,ICAL_ERROR_DEFAULT}
-
-};
-
-struct icalerror_string_map {
- const char* str;
- icalerrorenum error;
- char name[160];
-};
-
-static struct icalerror_string_map string_map[] =
-{
- {"BADARG",ICAL_BADARG_ERROR,"BADARG: Bad argument to function"},
- { "NEWFAILED",ICAL_NEWFAILED_ERROR,"NEWFAILED: Failed to create a new object via a *_new() routine"},
- {"MALFORMEDDATA",ICAL_MALFORMEDDATA_ERROR,"MALFORMEDDATA: An input string was not correctly formed or a component has missing or extra properties"},
- { "PARSE",ICAL_PARSE_ERROR,"PARSE: Failed to parse a part of an iCal component"},
- {"INTERNAL",ICAL_INTERNAL_ERROR,"INTERNAL: Random internal error. This indicates an error in the library code, not an error in use"},
- { "FILE",ICAL_FILE_ERROR,"FILE: An operation on a file failed. Check errno for more detail."},
- { "USAGE",ICAL_USAGE_ERROR,"USAGE: Failed to propertyl sequence calls to a set of interfaces"},
- { "UNIMPLEMENTED",ICAL_UNIMPLEMENTED_ERROR,"UNIMPLEMENTED: This feature has not been implemented"},
- { "NO",ICAL_NO_ERROR,"NO: No error"},
- {"UNKNOWN",ICAL_UNKNOWN_ERROR,"UNKNOWN: Unknown error type -- icalerror_strerror() was probably given bad input"}
-};
-
-
-icalerrorenum icalerror_error_from_string(const char* str){
-
- icalerrorenum e;
- int i = 0;
-
- for( i = 0; string_map[i].error != ICAL_NO_ERROR; i++){
- if (strcmp(string_map[i].str,str) == 0){
- e = string_map[i].error;
- }
- }
-
- return e;
-}
-
-icalerrorstate icalerror_supress(const char* error){
-
- icalerrorenum e = icalerror_error_from_string(error);
- icalerrorstate es;
-
- if (e == ICAL_NO_ERROR){
- return ICAL_ERROR_UNKNOWN;
- }
-
-
- es = icalerror_get_error_state(e);
- icalerror_set_error_state(e,ICAL_ERROR_NONFATAL);
-
- return es;
-}
-
-char* icalerror_perror()
-{
- return icalerror_strerror(icalerrno);
-}
-
-void icalerror_restore(const char* error, icalerrorstate es){
-
-
- icalerrorenum e = icalerror_error_from_string(error);
-
- if (e != ICAL_NO_ERROR){
- icalerror_set_error_state(e,es);
- }
-
-}
-
-
-
-void icalerror_set_error_state( icalerrorenum error,
- icalerrorstate state)
-{
- int i;
-
- for(i = ICAL_BADARG_ERROR; error_state_map[i].error!= ICAL_NO_ERROR;i++){
- if(error_state_map[i].error == error){
- error_state_map[i].state = state;
- }
- }
-}
-
-icalerrorstate icalerror_get_error_state( icalerrorenum error)
-{
- int i;
-
- for(i = ICAL_BADARG_ERROR; error_state_map[i].error!= ICAL_NO_ERROR;i++){
- if(error_state_map[i].error == error){
- return error_state_map[i].state;
- }
- }
-
- return ICAL_ERROR_UNKNOWN;
-}
-
-
-
-
-char* icalerror_strerror(icalerrorenum e) {
-
- int i;
-
- for (i=0; string_map[i].error != ICAL_UNKNOWN_ERROR; i++) {
- if (string_map[i].error == e) {
- return string_map[i].name;
- }
- }
-
- return string_map[i].name; /* Return string for ICAL_UNKNOWN_ERROR*/
-
-}
-
-
-
diff --git a/libical/src/libical/icalerror.h b/libical/src/libical/icalerror.h
deleted file mode 100644
index 790fa90f22..0000000000
--- a/libical/src/libical/icalerror.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalerror.h
- CREATOR: eric 09 May 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 icalerror.h
-
-======================================================================*/
-
-
-#ifndef ICALERROR_H
-#define ICALERROR_H
-
-#include <assert.h>
-#include <stdio.h> /* For icalerror_warn() */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-/* This routine is called before any error is triggered. It is called
- by icalerror_set_errno, so it does not appear in all of the macros
- below */
-void icalerror_stop_here(void);
-
-void icalerror_crash_here(void);
-
-typedef enum icalerrorenum {
-
- ICAL_BADARG_ERROR,
- ICAL_NEWFAILED_ERROR,
- ICAL_ALLOCATION_ERROR,
- ICAL_MALFORMEDDATA_ERROR,
- ICAL_PARSE_ERROR,
- ICAL_INTERNAL_ERROR, /* Like assert --internal consist. prob */
- ICAL_FILE_ERROR,
- ICAL_USAGE_ERROR,
- ICAL_UNIMPLEMENTED_ERROR,
- ICAL_UNKNOWN_ERROR, /* Used for problems in input to icalerror_strerror()*/
- ICAL_NO_ERROR
-
-} icalerrorenum;
-
-/* The libical error enumeration, like errno*/
-extern icalerrorenum icalerrno;
-
-/* If true, libicl aborts after a call to icalerror_set_error*/
-extern int icalerror_errors_are_fatal;
-
-/* Warning messages */
-
-#ifdef __GNUC__ca
-#define icalerror_warn(message) {fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);}
-#else /* __GNU_C__ */
-#define icalerror_warn(message) {fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);}
-#endif /* __GNU_C__ */
-
-
-void icalerror_clear_errno(void);
-void _icalerror_set_errno(icalerrorenum);
-
-/* Make an individual error fatal or non-fatal. */
-typedef enum icalerrorstate {
- ICAL_ERROR_FATAL, /* Not fata */
- ICAL_ERROR_NONFATAL, /* Fatal */
- ICAL_ERROR_DEFAULT, /* Use the value of icalerror_errors_are_fatal*/
- ICAL_ERROR_UNKNOWN /* Asked state for an unknown error type */
-} icalerrorstate ;
-
-char* icalerror_strerror(icalerrorenum e);
-char* icalerror_perror();
-void icalerror_set_error_state( icalerrorenum error, icalerrorstate);
-icalerrorstate icalerror_get_error_state( icalerrorenum error);
-
-
-#define icalerror_set_errno(x) \
-icalerrno = x; \
-if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \
- (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \
- icalerror_errors_are_fatal == 1 )){ \
- icalerror_warn(icalerror_strerror(x)); \
- assert(0); \
-}
-
-
-#ifdef ICAL_ERRORS_ARE_FATAL
-#undef NDEBUG
-#endif
-
-#define icalerror_check_value_type(value,type);
-#define icalerror_check_property_type(value,type);
-#define icalerror_check_parameter_type(value,type);
-#define icalerror_check_component_type(value,type);
-
-/* Assert with a message */
-#ifdef ICAL_ERRORS_ARE_FATAL
-
-#ifdef __GNUC__
-#define icalerror_assert(test,message) if(!(test)){fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);icalerror_stop_here(); abort();}
-#else /*__GNUC__*/
-#define icalerror_assert(test,message) if(!(test)){fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);icalerror_stop_here(); abort();}
-#endif /*__GNUC__*/
-
-#else /* ICAL_ERRORS_ARE_FATAL */
-#define icalerror_assert(test,message)
-#endif /* ICAL_ERRORS_ARE_FATAL */
-
-/* Check & abort if check fails */
-#define icalerror_check_arg(test,arg) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); }
-
-/* Check & return void if check fails*/
-#define icalerror_check_arg_rv(test,arg) if(!(test)) {icalerror_set_errno(ICAL_BADARG_ERROR); return; }
-
-/* Check & return 0 if check fails*/
-#define icalerror_check_arg_rz(test,arg) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); return 0;}
-
-/* Check & return an error if check fails*/
-#define icalerror_check_arg_re(test,arg,error) if(!(test)) { icalerror_stop_here(); assert(0); return error;}
-
-/* Check & return something*/
-#define icalerror_check_arg_rx(test,arg,x) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); return x;}
-
-
-
-/* String interfaces to set an error to NONFATAL and restore it to its
- original value */
-
-icalerrorstate icalerror_supress(const char* error);
-void icalerror_restore(const char* error, icalerrorstate es);
-
-
-#endif /* !ICALERROR_H */
-
-
-
diff --git a/libical/src/libical/icallangbind.c b/libical/src/libical/icallangbind.c
deleted file mode 100644
index 866eb700cc..0000000000
--- a/libical/src/libical/icallangbind.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icallangbind.c
- CREATOR: eric 15 dec 2000
-
- DESCRIPTION:
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 1999 Eric Busboom
- http://www.softwarestudio.org
-
- This package is free software and is provided "as is" without
- express or implied warranty. It may be used, redistributed and/or
- modified under the same terms as perl itself. ( Either the Artistic
- License or the GPL. )
-
- ======================================================================*/
-
-#include "icalcomponent.h"
-#include "icalproperty.h"
-#include "icalerror.h"
-#include "icalmemory.h"
-#include <malloc.h>
-#include <string.h>
-
-int* icallangbind_new_array(int size){
- int* p = (int*)malloc(size*sizeof(int));
- return p; /* Caller handles failures */
-}
-
-void icallangbind_free_array(int* array){
- free(array);
-}
-
-int icallangbind_access_array(int* array, int index) {
- return array[index];
-}
-
-
-
-/* LIke icalcomponent_get_first_component, buut takes a string for the
- kind and can iterate over X properties as if each X name was a
- seperate kind */
-icalproperty* icallangbind_get_first_property(icalcomponent *c,
- const char* prop)
-{
- icalproperty_kind kind = icalproperty_string_to_kind(prop);
- icalproperty *p;
-
- if (kind == ICAL_NO_PROPERTY){
- return 0;
- }
-
- if(kind == ICAL_X_PROPERTY){
- for(p = icalcomponent_get_first_property(c,kind);
- p !=0;
- p = icalcomponent_get_next_property(c,kind)){
-
- if(strcmp(icalproperty_get_x_name(p),prop) == 0){
- return p;
- }
- }
- } else {
- p=icalcomponent_get_first_property(c,kind);
-
- return p;
- }
-
- return 0;
-
-}
-
-icalproperty* icallangbind_get_next_property(icalcomponent *c,
- const char* prop)
-{
- icalproperty_kind kind = icalenum_string_to_property_kind(prop);
- icalproperty *p;
-
- if (kind == ICAL_NO_PROPERTY){
- return 0;
- }
-
- if(kind == ICAL_X_PROPERTY){
- for(p = icalcomponent_get_next_property(c,kind);
- p !=0;
- p = icalcomponent_get_next_property(c,kind)){
-
- if(strcmp(icalproperty_get_x_name(p),prop) == 0){
- return p;
- }
- }
- } else {
- p=icalcomponent_get_next_property(c,kind);
-
- return p;
- }
-
- return 0;
-
-}
-
-
-icalcomponent* icallangbind_get_first_component(icalcomponent *c,
- const char* comp)
-{
- icalcomponent_kind kind = icalenum_string_to_component_kind(comp);
-
- if (kind == ICAL_NO_COMPONENT){
- return 0;
- }
- return icalcomponent_get_first_component(c,kind);
-}
-
-icalcomponent* icallangbind_get_next_component(icalcomponent *c,
- const char* comp)
-{
- icalcomponent_kind kind = icalenum_string_to_component_kind(comp);
-
- if (kind == ICAL_NO_COMPONENT){
- return 0;
- }
- return icalcomponent_get_next_component(c,kind);
-}
-
-
-#define APPENDS(x) icalmemory_append_string(&buf, &buf_ptr, &buf_size, x);
-
-#define APPENDC(x) icalmemory_append_char(&buf, &buf_ptr, &buf_size, x);
-
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
-{
- char tmp[25];
- size_t buf_size = 1024;
- char* buf = icalmemory_new_buffer(buf_size);
- char* buf_ptr = buf;
- icalparameter *param;
-
- icalvalue* value;
-
- if( prop == 0){
- return 0;
- }
-
- APPENDS("{ ");
-
- value = icalproperty_get_value(prop);
-
- APPENDS(" 'name' ");
- APPENDS(sep);
- APPENDC('\'');
- APPENDS(icalenum_property_kind_to_string(icalproperty_isa(prop)));
- APPENDC('\'');
-
- if(value){
- APPENDS(", 'value_type' ");
- APPENDS(sep);
- APPENDC('\'');
- APPENDS(icalenum_value_kind_to_string(icalvalue_isa(value)));
- APPENDC('\'');
- }
-
- APPENDS(", 'pid' ");
- APPENDS(sep);
- APPENDC('\'');
- snprintf(tmp,25,"%p",prop);
- APPENDS(tmp);
- APPENDC('\'');
-
-
- if(value){
- switch (icalvalue_isa(value)){
-
- case ICAL_ATTACH_VALUE:
- case ICAL_BINARY_VALUE:
- case ICAL_NO_VALUE: {
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
- break;
- }
-
- default:
- {
- const char* str = icalvalue_as_ical_string(value);
- char* copy = (char*) malloc(strlen(str)+1);
-
- const char *i;
- char *j;
-
- if(copy ==0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- break;
- }
- /* Remove any newlines */
-
- for(j=copy, i = str; *i != 0; j++,i++){
- if(*i=='\n'){
- i++;
- }
- *j = *i;
- }
-
- *j = 0;
-
- APPENDS(", 'value'");
- APPENDS(sep);
- APPENDC('\'');
- APPENDS(copy);
- APPENDC('\'');
-
- free(copy);
- break;
-
- }
- }
- }
-
- /* Add Parameters */
-
- for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER);
- param != 0;
- param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)){
-
- const char* str = icalparameter_as_ical_string(param);
- char *copy = icalmemory_tmp_copy(str);
- char *v;
-
- if(copy == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- continue;
- }
-
- v = strchr(copy,'=');
-
-
- if(v == 0){
- continue;
- }
-
- *v = 0;
-
- v++;
-
- APPENDS(", ");
- APPENDC('\'');
- APPENDS(copy);
- APPENDC('\'');
- APPENDS(sep);
- APPENDC('\'');
- APPENDS(v);
- APPENDC('\'');
-
- }
-
-
- APPENDC('}');
-
- icalmemory_add_tmp_buffer(buf);
- return buf;
-
-}
-
-#include "fcntl.h"
-int icallangbind_string_to_open_flag(const char* str)
-{
- if (strcmp(str,"r") == 0) {return O_RDONLY;}
- else if (strcmp(str,"r+") == 0) {return O_RDWR;}
- else if (strcmp(str,"w") == 0) {return O_WRONLY;}
- else if (strcmp(str,"a") == 0) {return O_WRONLY|O_APPEND;}
- else return -1;
-}
-
diff --git a/libical/src/libical/icallangbind.h b/libical/src/libical/icallangbind.h
deleted file mode 100644
index 2ed50038eb..0000000000
--- a/libical/src/libical/icallangbind.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icallangbind.h
- CREATOR: eric 25 jan 2001
-
- DESCRIPTION:
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 1999 Eric Busboom
- http://www.softwarestudio.org
-
- This package is free software and is provided "as is" without
- express or implied warranty. It may be used, redistributed and/or
- modified under the same terms as perl itself. ( Either the Artistic
- License or the GPL. )
-
- ======================================================================*/
-
-#ifndef __ICALLANGBIND_H__
-#define __ICALLANGBIND_H__
-
-int* icallangbind_new_array(int size);
-void icallangbind_free_array(int* array);
-int icallangbind_access_array(int* array, int index);
-icalproperty* icallangbind_get_property(icalcomponent *c, int n, const char* prop);
-const char* icallangbind_get_property_val(icalproperty* p);
-const char* icallangbind_get_parameter(icalproperty *p, const char* parameter);
-icalcomponent* icallangbind_get_component(icalcomponent *c, const char* comp);
-
-icalproperty* icallangbind_get_first_property(icalcomponent *c,
- const char* prop);
-
-icalproperty* icallangbind_get_next_property(icalcomponent *c,
- const char* prop);
-
-icalcomponent* icallangbind_get_first_component(icalcomponent *c,
- const char* comp);
-
-icalcomponent* icallangbind_get_next_component(icalcomponent *c,
- const char* comp);
-
-
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
-
-
-int icallangbind_string_to_open_flag(const char* str);
-#endif /*__ICALLANGBIND_H__*/
diff --git a/libical/src/libical/icallexer.l b/libical/src/libical/icallexer.l
deleted file mode 100644
index d76a7938e3..0000000000
--- a/libical/src/libical/icallexer.l
+++ /dev/null
@@ -1,161 +0,0 @@
-%{
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icallexer.l
- CREATOR: eric 10 June 1999
-
- DESCRIPTION:
-
- $Id: icallexer.l,v 1.8 2001/01/23 20:22:33 jpr Exp $
- $Locker: $
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
- The original code is icalitip.y
-
-
-
- ======================================================================*/
-#include "icalparser.h"
-#include "icalenums.h"
-#include "icalmemory.h"
-#include "assert.h"
-#include "icalyacc.h"
-
-#include <string.h> /* For strdup() */
-
-int icalparser_flex_input(char* buf, int max_size);
-void icalparser_clear_flex_input(void);
-
-
-#define ICAL_MAX_STR_CONST 1024
-
-#undef YY_INPUT
-#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
-#undef yywrap
-
-#undef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) ical_yyerror(msg)
-
-icalvalue_kind value_kind=ICAL_NO_VALUE;
-void set_parser_value_state(icalvalue_kind kind);
-extern int yydebug;
-
-void ical_yyerror(char *s);
-
-void init_str_buf(void);
-
-int last_state;
-
-char *str_buf;
-char *str_buf_p;
-size_t buf_sz; /* = ICAL_MAX_STR_CONST;*/
-
-%}
-
-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 quoted_string
-%s binary_value boolean_value uri_value time_value duration_value number_value period_value recur_value text_value utcoffset_value
-%s enum_param_value string_param_value stringlist_param_value keyword line_start component seperator parameter end_of_value paramtext
-
-
-
-%%
-
-%{
-%}
-
-
-<time_value>{
-{digit}+ { ical_yylval.v_string =icalmemory_tmp_copy(yytext) ;
- return DIGITS; }
-T { return TIME_CHAR; }
-Z { return UTC_CHAR; }
-[\/\+\-PWHMSD] { return yytext[0]; }
-{crlf} { return EOL;}
-
-}
-
-<utcoffset_value>{
-{crlf} { return EOL;}
-\-|\+ { return yytext[0]; }
-{digit}{digit} { ical_yylval.v_int=atoi(yytext); return INTNUMBER; }
-
-}
-
-<enum_param_value>{
-. { return CHARACTER; }
-{crlf} { return EOL;}
-
-}
-
-<seperator>{
-, { BEGIN(last_state); return COMMA; }
-}
-
-
-%%
-
-int yywrap()
-{
- return 1;
-}
-
-
-void set_parser_value_state(icalvalue_kind kind)
-{
-
- switch (kind){
-
- case ICAL_UTCOFFSET_VALUE:
- {BEGIN(utcoffset_value);break;}
-
- case ICAL_DATETIMEPERIOD_VALUE:
- case ICAL_DURATION_VALUE:
- case ICAL_PERIOD_VALUE:
- {BEGIN(time_value);break;}
-
- default:
- {
- assert(1==0);
- }
- }
-}
-
-void init_str_buf(void)
-{
- str_buf = icalmemory_tmp_buffer(ICAL_MAX_STR_CONST);
- str_buf_p = str_buf;
- buf_sz = ICAL_MAX_STR_CONST;
-
-
-}
-
diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c
deleted file mode 100644
index 297ead8826..0000000000
--- a/libical/src/libical/icalmemory.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalmemory.c
- CREATOR: eric 30 June 1999
-
- $Id$
- $Locker$
-
- 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.
-
-
- 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 icalmemory.h
-
- ======================================================================*/
-
-/* libical often passes strings back to the caller. To make these
- * interfaces simple, I did not want the caller to have to pass in a
- * memory buffer, but having libical pass out newly allocated memory
- * makes it difficult to de-allocate the memory.
- *
- * The ring buffer in this scheme makes it possible for libical to pass
- * out references to memory which the caller does not own, and be able
- * to de-allocate the memory later. The ring allows libical to have
- * several buffers active simultaneously, which is handy when creating
- * string representations of components. */
-
-#define ICALMEMORY_C
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef DMALLOC
-#include "dmalloc.h"
-#endif
-
-#include "icalmemory.h"
-#include "icalerror.h"
-
-#include <stdio.h> /* for printf (debugging) */
-#include <stdlib.h> /* for malloc, realloc */
-#include <string.h> /* for memset(), strdup */
-
-#define BUFFER_RING_SIZE 25
-#define MIN_BUFFER_SIZE 200
-
-void icalmemory_free_tmp_buffer (void* buf);
-
-
-/* HACK. Not threadsafe */
-void* buffer_ring[BUFFER_RING_SIZE];
-int buffer_pos = -1;
-int initialized = 0;
-
-/* Add an existing buffer to the buffer ring */
-void icalmemory_add_tmp_buffer(void* buf)
-{
- /* I don't think I need this -- I think static arrays are
- initialized to 0 as a standard part of C, but I am not sure. */
- if (initialized == 0){
- int i;
- for(i=0; i<BUFFER_RING_SIZE; i++){
- buffer_ring[i] = 0;
- }
- initialized = 1;
- }
-
- /* Wrap around the ring */
- if(++buffer_pos == BUFFER_RING_SIZE){
- buffer_pos = 0;
- }
-
- /* Free buffers as their slots are overwritten */
- if ( buffer_ring[buffer_pos] != 0){
- free( buffer_ring[buffer_pos]);
- buffer_ring[buffer_pos] = 0;
- }
-
- /* Assign the buffer to a slot */
- buffer_ring[buffer_pos] = buf;
-}
-
-/* Create a new temporary buffer on the ring. Libical owns these and
- wil deallocate them. */
-void*
-icalmemory_tmp_buffer (size_t size)
-{
- char *buf;
-
- if (size < MIN_BUFFER_SIZE){
- size = MIN_BUFFER_SIZE;
- }
-
- buf = (void*)malloc(size);
-
- if( buf == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(buf,0,size);
-
- icalmemory_add_tmp_buffer(buf);
-
- return buf;
-}
-
-void icalmemory_free_ring()
-{
-
- int i;
- for(i=0; i<BUFFER_RING_SIZE; i++){
- if ( buffer_ring[i] != 0){
- free( buffer_ring[i]);
- }
- buffer_ring[i] = 0;
- }
-
- initialized = 1;
-
-}
-
-
-
-/* Like strdup, but the buffer is on the ring. */
-char*
-icalmemory_tmp_copy(const char* str)
-{
- char* b = icalmemory_tmp_buffer(strlen(str)+1);
-
- strcpy(b,str);
-
- return b;
-}
-
-
-char* icalmemory_strdup(const char *s)
-{
- return strdup(s);
-}
-
-void
-icalmemory_free_tmp_buffer (void* buf)
-{
- if(buf == 0)
- {
- return;
- }
-
- free(buf);
-}
-
-
-/* These buffer routines create memory the old fashioned way -- so the
- caller will have to delocate the new memory */
-
-void* icalmemory_new_buffer(size_t size)
-{
- void *b = malloc(size);
-
- if( b == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(b,0,size);
-
- return b;
-}
-
-void* icalmemory_resize_buffer(void* buf, size_t size)
-{
- void *b = realloc(buf, size);
-
- if( b == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- return b;
-}
-
-void icalmemory_free_buffer(void* buf)
-{
- free(buf);
-}
-
-void
-icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
- const char* string)
-{
- char *new_buf;
- char *new_pos;
-
- size_t data_length, final_length, string_length;
-
-#ifndef ICAL_NO_INTERNAL_DEBUG
- icalerror_check_arg_rv( (buf!=0),"buf");
- icalerror_check_arg_rv( (*buf!=0),"*buf");
- icalerror_check_arg_rv( (pos!=0),"pos");
- icalerror_check_arg_rv( (*pos!=0),"*pos");
- icalerror_check_arg_rv( (buf_size!=0),"buf_size");
- icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
- icalerror_check_arg_rv( (string!=0),"string");
-#endif
-
- string_length = strlen(string);
- data_length = (size_t)*pos - (size_t)*buf;
- final_length = data_length + string_length;
-
- if ( final_length >= (size_t) *buf_size) {
-
-
- *buf_size = (*buf_size) * 2 + final_length;
-
- new_buf = realloc(*buf,*buf_size);
-
- new_pos = (void*)((size_t)new_buf + data_length);
-
- *pos = new_pos;
- *buf = new_buf;
- }
-
- strcpy(*pos, string);
-
- *pos += string_length;
-}
-
-
-void
-icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
- char ch)
-{
- char *new_buf;
- char *new_pos;
-
- size_t data_length, final_length;
-
-#ifndef ICAL_NO_INTERNAL_DEBUG
- icalerror_check_arg_rv( (buf!=0),"buf");
- icalerror_check_arg_rv( (*buf!=0),"*buf");
- icalerror_check_arg_rv( (pos!=0),"pos");
- icalerror_check_arg_rv( (*pos!=0),"*pos");
- icalerror_check_arg_rv( (buf_size!=0),"buf_size");
- icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
-#endif
-
- data_length = (size_t)*pos - (size_t)*buf;
-
- final_length = data_length + 2;
-
- if ( final_length > (size_t) *buf_size ) {
-
-
- *buf_size = (*buf_size) * 2 + final_length +1;
-
- new_buf = realloc(*buf,*buf_size);
-
- new_pos = (void*)((size_t)new_buf + data_length);
-
- *pos = new_pos;
- *buf = new_buf;
- }
-
- **pos = ch;
- *pos += 1;
- **pos = 0;
-}
diff --git a/libical/src/libical/icalmemory.h b/libical/src/libical/icalmemory.h
deleted file mode 100644
index 52364e289f..0000000000
--- a/libical/src/libical/icalmemory.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalmemory.h
- CREATOR: eric 30 June 1999
-
-
- $Id$
- $Locker$
-
- 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 Initial Developer of the Original Code is Eric Busboom
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-======================================================================*/
-
-#ifndef ICALMEMORY_H
-#define ICALMEMORY_H
-
-#include <sys/types.h> /* for size_t */
-
-
-/* Tmp buffers are managed by ical. References can be returned to the
- caller, although the caller will not own the memory. */
-
-void* icalmemory_tmp_buffer(size_t size);
-char* icalmemory_tmp_copy(const char* str);
-
-/* Add an externally allocated buffer to the ring. */
-void icalmemory_add_tmp_buffer(void*);
-
-
-/* Free all memory used in the ring */
-void icalmemory_free_ring(void);
-
-/* Non-tmp buffers must be freed. These are mostly wrappers around
- * malloc, etc, but are used so the caller can change the memory
- * allocators in a future version of the library */
-
-void* icalmemory_new_buffer(size_t size);
-void* icalmemory_resize_buffer(void* buf, size_t size);
-void icalmemory_free_buffer(void* buf);
-
-/* icalmemory_append_string will copy the string 'string' to the
- buffer 'buf' starting at position 'pos', reallocing 'buf' if it is
- too small. 'buf_size' is the size of 'buf' and will be changed if
- 'buf' is reallocated. 'pos' will point to the last byte of the new
- string in 'buf', usually a '\0' */
-
-/* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on
- normally allocated memory, or on buffers created from
- icalmemory_new_buffer, never with buffers created by
- icalmemory_tmp_buffer. If icalmemory_append_string has to resize a
- buffer on the ring, the ring will loose track of it an you will
- have memory problems. */
-
-void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
- const char* string);
-
-/* icalmemory_append_char is similar, but is appends a character instead of a string */
-void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
- char ch);
-
-/* A wrapper around strdup. Partly to trap calls to strdup, partly
- because in -ansi, gcc on Red Hat claims that strudup is undeclared */
-char* icalmemory_strdup(const char *s);
-
-#endif /* !ICALMEMORY_H */
-
-
-
diff --git a/libical/src/libical/icalmime.c b/libical/src/libical/icalmime.c
deleted file mode 100644
index 6e11e9e326..0000000000
--- a/libical/src/libical/icalmime.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/* -*- Mode: C -*-*/
-/*======================================================================
- FILE: icalmime.c
- CREATOR: eric 26 July 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 "icalmime.h"
-#include "icalerror.h"
-#include "icalmemory.h"
-#include "sspm.h"
-#include "stdlib.h"
-#include <string.h> /* For strdup */
-#include <stdio.h> /* for snprintf*/
-
-#ifdef DMALLOC
-#include "dmalloc.h"
-#endif
-
-
-/* These *_part routines are called by the MIME parser via the
- local_action_map */
-
-struct text_part
-{
- char* buf;
- char* buf_pos;
- size_t buf_size;
-};
-
-void* icalmime_text_new_part()
-{
-
-#define BUF_SIZE 2048
-
- struct text_part* impl;
-
- if ( ( impl = (struct text_part*)
- malloc(sizeof(struct text_part))) == 0) {
- return 0;
- }
-
- impl->buf = icalmemory_new_buffer(BUF_SIZE);
- impl->buf_pos = impl->buf;
- impl->buf_size = BUF_SIZE;
-
- return impl;
-}
-void icalmime_text_add_line(void *part,
- struct sspm_header *header,
- char* line, size_t size)
-{
- struct text_part* impl = (struct text_part*) part;
-
- icalmemory_append_string(&(impl->buf),&(impl->buf_pos),
- &(impl->buf_size),line);
-
-}
-
-void* icalmime_textcalendar_end_part(void* part)
-{
-
- struct text_part* impl = (struct text_part*) part;
- icalcomponent *c = icalparser_parse_string(impl->buf);
-
- icalmemory_free_buffer(impl->buf);
- free(impl);
-
- return c;
-
-}
-
-void* icalmime_text_end_part(void* part)
-{
- struct text_part* impl = ( struct text_part*) part;
-
- icalmemory_add_tmp_buffer(impl->buf);
- free(impl);
-
- return impl->buf;
-}
-
-void icalmime_text_free_part(void *part)
-{
- part = part;
-}
-
-
-/* Ignore Attachments for now */
-
-void* icalmime_attachment_new_part()
-{
- return 0;
-}
-void icalmime_attachment_add_line(void *part, struct sspm_header *header,
- char* line, size_t size)
-{
- part = part;
- header = header;
- line = line;
- size = size;
-}
-
-void* icalmime_attachment_end_part(void* part)
-{
- return 0;
-}
-
-void icalmime_attachment_free_part(void *part)
-{
-}
-
-
-
-
-struct sspm_action_map icalmime_local_action_map[] =
-{
- {SSPM_TEXT_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_textcalendar_end_part,icalmime_text_free_part},
- {SSPM_TEXT_MAJOR_TYPE,SSPM_ANY_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_text_end_part,icalmime_text_free_part},
- {SSPM_TEXT_MAJOR_TYPE,SSPM_PLAIN_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_text_end_part,icalmime_text_free_part},
- {SSPM_APPLICATION_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part},
- {SSPM_IMAGE_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part},
- {SSPM_AUDIO_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part},
- {SSPM_IMAGE_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part},
- {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,0,0,0,0}
-};
-
-#define NUM_PARTS 100 /* HACK. Hard Limit */
-
-
-
-struct sspm_part* icalmime_make_part(icalcomponent* comp)
-{
- comp = comp;
- return 0;
-}
-
-char* icalmime_as_mime_string(char* icalcomponent);
-
-icalcomponent* icalmime_parse(char* (*get_string)(char *s, size_t size,
- void *d),
- void *data)
-{
- struct sspm_part *parts;
- int i, last_level=0;
- icalcomponent *root=0, *parent=0, *comp=0, *last = 0;
-
- if ( (parts = (struct sspm_part *)
- malloc(NUM_PARTS*sizeof(struct sspm_part)))==0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(parts,0,sizeof(parts));
-
- sspm_parse_mime(parts,
- NUM_PARTS, /* Max parts */
- icalmime_local_action_map, /* Actions */
- get_string,
- data, /* data for get_string*/
- 0 /* First header */);
-
-
-
- for(i = 0; i <NUM_PARTS && parts[i].header.major != SSPM_NO_MAJOR_TYPE ; i++){
-
-#define TMPSZ 1024
- char mimetype[TMPSZ];
- char* major = sspm_major_type_string(parts[i].header.major);
- char* minor = sspm_minor_type_string(parts[i].header.minor);
-
- if(parts[i].header.minor == SSPM_UNKNOWN_MINOR_TYPE ){
- assert(parts[i].header.minor_text !=0);
- minor = parts[i].header.minor_text;
- }
-
- sprintf(mimetype,"%s/%s",major,minor);
-
- comp = icalcomponent_new(ICAL_XLICMIMEPART_COMPONENT);
-
- if(comp == 0){
- /* HACK Handle Error */
- assert(0);
- }
-
- if(parts[i].header.error!=SSPM_NO_ERROR){
- char *str;
- char* temp[256];
-
- if(parts[i].header.error==SSPM_UNEXPECTED_BOUNDARY_ERROR){
- str = "Got an unexpected boundary, possibly due to a MIME header for a MULTIPART part that is missing the Content-Type line";
- }
-
- if(parts[i].header.error==SSPM_WRONG_BOUNDARY_ERROR){
- str = "Got the wrong boundary for the opening of a MULTIPART part.";
- }
-
- if(parts[i].header.error==SSPM_NO_BOUNDARY_ERROR){
- str = "Got a multipart header that did not specify a boundary";
- }
-
- if(parts[i].header.error==SSPM_NO_HEADER_ERROR){
- str = "Did not get a header for the part. Is there a blank\
-line between the header and the previous boundary\?";
-
- }
-
- if(parts[i].header.error_text != 0){
- snprintf((char*)temp,256,
- "%s: %s",str,parts[i].header.error_text);
- } else {
- strcpy((char*)temp,str);
- }
-
- icalcomponent_add_property
- (comp,
- icalproperty_vanew_xlicerror(
- (char*)temp,
- icalparameter_new_xlicerrortype(
- ICAL_XLICERRORTYPE_MIMEPARSEERROR),
- 0));
- }
-
- if(parts[i].header.major != SSPM_NO_MAJOR_TYPE &&
- parts[i].header.major != SSPM_UNKNOWN_MAJOR_TYPE){
-
- icalcomponent_add_property(comp,
- icalproperty_new_xlicmimecontenttype((char*)
- icalmemory_strdup(mimetype)));
-
- }
-
- if (parts[i].header.encoding != SSPM_NO_ENCODING){
-
- icalcomponent_add_property(comp,
- icalproperty_new_xlicmimeencoding(
- sspm_encoding_string(parts[i].header.encoding)));
- }
-
- if (parts[i].header.filename != 0){
- icalcomponent_add_property(comp,
- icalproperty_new_xlicmimefilename(parts[i].header.filename));
- }
-
- if (parts[i].header.content_id != 0){
- icalcomponent_add_property(comp,
- icalproperty_new_xlicmimecid(parts[i].header.content_id));
- }
-
- if (parts[i].header.charset != 0){
- icalcomponent_add_property(comp,
- icalproperty_new_xlicmimecharset(parts[i].header.charset));
- }
-
- /* Add iCal components as children of the component */
- if(parts[i].header.major == SSPM_TEXT_MAJOR_TYPE &&
- parts[i].header.minor == SSPM_CALENDAR_MINOR_TYPE &&
- parts[i].data != 0){
-
- icalcomponent_add_component(comp,
- (icalcomponent*)parts[i].data);
- parts[i].data = 0;
-
- } else if(parts[i].header.major == SSPM_TEXT_MAJOR_TYPE &&
- parts[i].header.minor != SSPM_CALENDAR_MINOR_TYPE &&
- parts[i].data != 0){
-
- /* Add other text components as "DESCRIPTION" properties */
-
- icalcomponent_add_property(comp,
- icalproperty_new_description(
- (char*)icalmemory_strdup((char*)parts[i].data)));
-
- parts[i].data = 0;
- }
-
-
- if(root!= 0 && parts[i].level == 0){
- /* We've already assigned the root, but there is another
- part at the root level. This is probably a parse
- error*/
- icalcomponent_free(comp);
- continue;
- }
-
- if(parts[i].level == last_level && last_level != 0){
- icalerror_assert(parent!=0,"No parent for adding component");
-
- icalcomponent_add_component(parent,comp);
-
- } else if (parts[i].level == last_level && last_level == 0 &&
- root == 0) {
-
- root = comp;
- parent = comp;
-
- } else if (parts[i].level > last_level){
-
- parent = last;
- icalcomponent_add_component(parent,comp);
-
- last_level = parts[i].level;
-
- } else if (parts[i].level < last_level){
-
- parent = icalcomponent_get_parent(parent);
- icalcomponent_add_component(parent,comp);
-
- last_level = parts[i].level;
- } else {
- assert(0);
- }
-
- last = comp;
- last_level = parts[i].level;
- assert(parts[i].data == 0);
- }
-
- sspm_free_parts(parts,NUM_PARTS);
- free(parts);
-
- return root;
-}
-
-
-
-int icalmime_test(char* (*get_string)(char *s, size_t size, void *d),
- void *data)
-{
- char *out;
- struct sspm_part *parts;
- int i;
-
- if ( (parts = (struct sspm_part *)
- malloc(NUM_PARTS*sizeof(struct sspm_part)))==0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(parts,0,sizeof(parts));
-
- sspm_parse_mime(parts,
- NUM_PARTS, /* Max parts */
- icalmime_local_action_map, /* Actions */
- get_string,
- data, /* data for get_string*/
- 0 /* First header */);
-
- for(i = 0; i <NUM_PARTS && parts[i].header.major != SSPM_NO_MAJOR_TYPE ;
- i++){
- if(parts[i].header.minor == SSPM_CALENDAR_MINOR_TYPE){
- parts[i].data = icalmemory_strdup(
- icalcomponent_as_ical_string((icalcomponent*)parts[i].data));
- }
- }
-
- sspm_write_mime(parts,NUM_PARTS,&out,"To: bob@bob.org");
-
- printf("%s\n",out);
-
- return 0;
-
-}
-
-
diff --git a/libical/src/libical/icalmime.h b/libical/src/libical/icalmime.h
deleted file mode 100644
index b22288842d..0000000000
--- a/libical/src/libical/icalmime.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalmime.h
- CREATOR: eric 26 July 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 ICALMIME_H
-#define ICALMIME_H
-
-#include "icalcomponent.h"
-#include "icalparser.h"
-
-icalcomponent* icalmime_parse( char* (*line_gen_func)(char *s, size_t size,
- void *d),
- void *data);
-
-/* The inverse of icalmime_parse, not implemented yet. Use sspm.h directly. */
-char* icalmime_as_mime_string(char* component);
-
-
-
-#endif /* !ICALMIME_H */
-
-
-
diff --git a/libical/src/libical/icalparameter.c b/libical/src/libical/icalparameter.c
deleted file mode 100644
index 7e0d15cef3..0000000000
--- a/libical/src/libical/icalparameter.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalderivedparameters.{c,h}
- CREATOR: eric 09 May 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 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 "icalparameterimpl.h"
-
-#include <stdlib.h> /* for malloc() */
-#include <errno.h>
-#include <string.h> /* for memset() */
-
-/* In icalderivedparameter */
-icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val);
-
-
-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;
- v->data = 0;
-
- return v;
-}
-
-icalparameter*
-icalparameter_new (icalparameter_kind kind)
-{
- struct icalparameter_impl* v = icalparameter_new_impl(kind);
-
- return (icalparameter*) v;
-
-}
-
-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);
-}
-
-
-
-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;
-}
-
-icalparameter* icalparameter_new_from_string(const char *str)
-{
- char* eq;
- char* cpy;
- icalparameter_kind kind;
- icalparameter *param;
-
- icalerror_check_arg_rz(str != 0,"str");
-
- cpy = icalmemory_strdup(str);
-
- if (cpy == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- eq = strchr(cpy,'=');
-
- if(eq == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- *eq = '\0';
-
- eq++;
-
- kind = icalparameter_string_to_kind(cpy);
-
- if(kind == ICAL_NO_PARAMETER){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- param = icalparameter_new_from_value_string(kind,eq);
-
- if(kind == ICAL_X_PARAMETER){
- icalparameter_set_xname(param,cpy);
- }
-
- free(cpy);
-
- return param;
-
-}
-
-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;
-
- 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;
-
- if(impl->kind == ICAL_X_PARAMETER) {
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size,
- icalparameter_get_xname(impl));
-
- } else {
-
- kind_string = icalparameter_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, "=");
-
- if(impl->string !=0){
- int qm = 0;
-
- /* Encapsulate the property in quotes if necessary */
- if (strchr (impl->string, ';') != 0 || strchr (impl->string, ':') != 0) {
- icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
- qm = 1;
- }
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, impl->string);
- if (qm == 1) {
- icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
- }
- } else if (impl->data != 0){
- const char* str = icalparameter_enum_to_string(impl->data);
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
- } else {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- /* 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_rz( (param!=0),"param");
-
- return impl->parent;
-}
-
-
-/* Everything below this line is machine generated. Do not edit. */
-/* ALTREP */
diff --git a/libical/src/libical/icalparameter.h b/libical/src/libical/icalparameter.h
deleted file mode 100644
index 3f3b59f049..0000000000
--- a/libical/src/libical/icalparameter.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalparam.h
- CREATOR: eric 20 March 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 icalparam.h
-
- ======================================================================*/
-
-#ifndef ICALPARAM_H
-#define ICALPARAM_H
-
-#include "icalderivedparameter.h"
-
-/* Declared in icalderivedparameter.h */
-/*typedef void icalparameter;*/
-
-icalparameter* icalparameter_new(icalparameter_kind kind);
-icalparameter* icalparameter_new_clone(icalparameter* p);
-
-/* Create from string of form "PARAMNAME=VALUE" */
-icalparameter* icalparameter_new_from_string(const char* value);
-
-/* Create from just the value, the part after the "=" */
-icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind, const 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);
-
-/* Convert enumerations */
-
-const char* icalparameter_kind_to_string(icalparameter_kind kind);
-icalparameter_kind icalparameter_string_to_kind(const char* string);
-
-
-
-#endif
diff --git a/libical/src/libical/icalparameterimpl.h b/libical/src/libical/icalparameterimpl.h
deleted file mode 100644
index 2d0fdd642d..0000000000
--- a/libical/src/libical/icalparameterimpl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalparameterimpl.h
- CREATOR: eric 09 May 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 icalderivedparameters.{c,h}
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
- ======================================================================*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef ICALPARAMETER_IMPL
-#define ICALPARAMETER_IMPL
-
-#include "icalparameter.h"
-#include "icalproperty.h"
-
-struct icalparameter_impl
-{
- icalparameter_kind kind;
- char id[5];
- int size;
- const char* string;
- const char* x_name;
- icalproperty* parent;
-
- int data;
-};
-
-
-#endif /*ICALPARAMETER_IMPL*/
diff --git a/libical/src/libical/icalparser.c b/libical/src/libical/icalparser.c
deleted file mode 100644
index 4a389540f0..0000000000
--- a/libical/src/libical/icalparser.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*-
- ======================================================================
- FILE: icalparser.c
- CREATOR: eric 04 August 1999
-
- $Id$
- $Locker$
-
- 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.
-
-
- 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 Initial Developer of the Original Code is Eric Busboom
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
- ======================================================================*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include "icalparser.h"
-#include "pvl.h"
-#include "icalmemory.h"
-#include "icalerror.h"
-#include "icalvalue.h"
-#include "icalderivedparameter.h"
-#include "icalparameter.h"
-#include "icalproperty.h"
-#include "icalcomponent.h"
-
-#include <string.h> /* For strncpy & size_t */
-#include <stdio.h> /* For FILE and fgets and sprintf */
-#include <stdlib.h> /* for free */
-
-
-extern icalvalue* icalparser_yy_value;
-void set_parser_value_state(icalvalue_kind kind);
-int ical_yyparse(void);
-
-char* icalparser_get_next_char(char c, char *str, int qm);
-char* icalparser_get_next_parameter(char* line,char** end);
-char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind);
-char* icalparser_get_prop_name(char* line, char** end);
-char* icalparser_get_param_name(char* line, char **end);
-
-#define TMP_BUF_SIZE 80
-
-struct icalparser_impl
-{
- int buffer_full; /* flag indicates that temp is smaller that
- data being read into it*/
- int continuation_line; /* last line read was a continuation line */
- size_t tmp_buf_size;
- char temp[TMP_BUF_SIZE];
- icalcomponent *root_component;
- int version;
- int level;
- int lineno;
- icalparser_state state;
- pvl_list components;
-
- void *line_gen_data;
-
-};
-
-
-icalparser* icalparser_new(void)
-{
- struct icalparser_impl* impl = 0;
- if ( ( impl = (struct icalparser_impl*)
- malloc(sizeof(struct icalparser_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- impl->root_component = 0;
- impl->components = pvl_newlist();
- impl->level = 0;
- impl->state = ICALPARSER_SUCCESS;
-
- impl->tmp_buf_size = TMP_BUF_SIZE;
- impl->buffer_full = 0;
- impl->continuation_line = 0;
- impl->lineno = 0;
-
- memset(impl->temp,0, TMP_BUF_SIZE);
-
- return (icalparser*)impl;
-}
-
-
-void icalparser_free(icalparser* parser)
-{
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
- icalcomponent *c;
-
- if (impl->root_component != 0){
- icalcomponent_free(impl->root_component);
- }
-
- while( (c=pvl_pop(impl->components)) != 0){
- icalcomponent_free(c);
- }
-
- pvl_free(impl->components);
-
- free(impl);
-}
-
-void icalparser_set_gen_data(icalparser* parser, void* data)
-{
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
-
- impl->line_gen_data = data;
-}
-
-
-icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind,
- char* str,
- icalproperty **error);
-
-
-
-char* icalparser_get_next_char(char c, char *str, int qm)
-{
- int quote_mode = 0;
- char* p;
-
-
- for(p=str; *p!=0; p++){
- if (qm == 1) {
- if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){
- quote_mode =1;
- continue;
- }
-
- if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){
- quote_mode =0;
- continue;
- }
- }
-
- if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){
- return p;
- }
- }
-
- return 0;
-}
-
-/* make a new tmp buffer out of a substring */
-char* make_segment(char* start, char* end)
-{
- char *buf;
- size_t size = (size_t)end - (size_t)start;
-
- buf = icalmemory_tmp_buffer(size+1);
-
-
- strncpy(buf,start,size);
- *(buf+size) = 0;
-
- return buf;
-
-}
-
-const char* input_buffer;
-const char* input_buffer_p;
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
-int icalparser_flex_input(char* buf, int max_size)
-{
- int n = min(max_size,strlen(input_buffer_p));
-
- if (n > 0){
- memcpy(buf, input_buffer_p, n);
- input_buffer_p += n;
- return n;
- } else {
- return 0;
- }
-}
-
-void icalparser_clear_flex_input(void)
-{
- input_buffer_p = input_buffer+strlen(input_buffer);
-}
-
-/* Call the flex/bison parser to parse a complex value */
-
-icalvalue* icalparser_parse_value(icalvalue_kind kind,
- const char* str, icalproperty** error)
-{
- int r;
- input_buffer_p = input_buffer = str;
-
- set_parser_value_state(kind);
- icalparser_yy_value = 0;
-
- r = ical_yyparse();
-
- /* Error. Parse failed */
- if( icalparser_yy_value == 0 || r != 0){
-
- if(icalparser_yy_value !=0){
- icalvalue_free(icalparser_yy_value);
- icalparser_yy_value = 0;
- }
-
- return 0;
- }
-
- if (error != 0){
- *error = 0;
- }
-
- return icalparser_yy_value;
-}
-
-char* icalparser_get_prop_name(char* line, char** end)
-{
- char* p;
- char* v;
- char *str;
-
- p = icalparser_get_next_char(';',line,1);
- v = icalparser_get_next_char(':',line,1);
- if (p== 0 && v == 0) {
- return 0;
- }
-
- /* There is no ';' or, it is after the ';' that marks the beginning of
- the value */
- if (v!=0 && ( p == 0 || p > v)){
- str = make_segment(line,v);
- *end = v+1;
- } else {
- str = make_segment(line,p);
- *end = p+1;
- }
-
- return str;
-}
-
-char* icalparser_get_param_name(char* line, char **end)
-{
-
- char* next;
- char* quote;
- char *str;
-
- next = icalparser_get_next_char('=',line,1);
-
- if (next == 0) {
- return 0;
- }
-
- str = make_segment(line,next);
- *end = next+1;
- if (**end == '"') {
- *end = *end+1;
- next = icalparser_get_next_char('"',*end,0);
- if (next == 0) {
- return 0;
- }
-
- *end = make_segment(*end,next);
- }
-
- return str;
-
-}
-
-char* icalparser_get_next_paramvalue(char* line, char **end)
-{
-
- char* next;
- char *str;
-
- next = icalparser_get_next_char(',',line,1);
-
- if (next == 0){
- next = (char*)(size_t)line+(size_t)strlen(line);\
- }
-
- if (next == line){
- return 0;
- } else {
- str = make_segment(line,next);
- *end = next+1;
- return str;
- }
-
-}
-
-/* A property may have multiple values, if the values are seperated by
- commas in the content line. This routine will look for the next
- comma after line and will set the next place to start searching in
- end. */
-
-char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
-{
-
- char* next;
- char *p;
- char *str;
- size_t length = strlen(line);
-
- p = line;
- while(1){
-
- next = icalparser_get_next_char(',',p,1);
-
- /* Unforunately, RFC2445 says that for the RECUR value, COMMA
- can both seperate digits in a list, and it can seperate
- multiple recurrence specifications. This is not a friendly
- part of the spec. This weirdness tries to
- distinguish the two uses. it is probably a HACK*/
-
- if( kind == ICAL_RECUR_VALUE ) {
- if ( next != 0 &&
- (*end+length) > next+5 &&
- strncmp(next,"FREQ",4) == 0
- ) {
- /* The COMMA was followed by 'FREQ', is it a real seperator*/
- /* Fall through */
- } else if (next != 0){
- /* Not real, get the next COMMA */
- p = next+1;
- next = 0;
- continue;
- }
- }
-
- /* If the comma is preceeded by a '\', then it is a literal and
- not a value seperator*/
-
- if ( (next!=0 && *(next-1) == '\\') ||
- (next!=0 && *(next-3) == '\\')
- )
- /*second clause for '/' is on prev line. HACK may be out of bounds */
- {
- p = next+1;
- } else {
- break;
- }
-
- }
-
- if (next == 0){
- next = (char*)(size_t)line+length;
- *end = next;
- } else {
- *end = next+1;
- }
-
- if (next == line){
- return 0;
- }
-
-
- str = make_segment(line,next);
- return str;
-
-}
-
-char* icalparser_get_next_parameter(char* line,char** end)
-{
- char *next;
- char *v;
- char *str;
-
- v = icalparser_get_next_char(':',line,1);
- next = icalparser_get_next_char(';', line,1);
-
- /* There is no ';' or, it is after the ':' that marks the beginning of
- the value */
-
- if (next == 0 || next > v) {
- next = icalparser_get_next_char(':', line,1);
- }
-
- if (next != 0) {
- str = make_segment(line,next);
- *end = next+1;
- return str;
- } else {
- *end = line;
- return 0;
- }
-}
-
-/* Get a single property line, from the property name through the
- final new line, and include any continuation lines */
-
-char* icalparser_get_line(icalparser *parser,
- char* (*line_gen_func)(char *s, size_t size, void *d))
-{
- char *line;
- char *line_p;
- struct icalparser_impl* impl = (struct icalparser_impl*)parser;
- size_t buf_size = impl->tmp_buf_size;
-
-
- line_p = line = icalmemory_new_buffer(buf_size);
- line[0] = '\0';
-
- /* Read lines by calling line_gen_func and putting the data into
- impl->temp. If the line is a continuation line ( begins with a
- space after a newline ) then append the data onto line and read
- again. Otherwise, exit the loop. */
-
- while(1) {
-
- /* The first part of the loop deals with the temp buffer,
- which was read on he last pass through the loop. The
- routine is split like this because it has to read lone line
- ahead to determine if a line is a continuation line. */
-
-
- /* The tmp buffer is not clear, so transfer the data in it to the
- output. This may be left over from a previous call */
- if (impl->temp[0] != '\0' ) {
-
- /* If the last position in the temp buffer is occupied,
- mark the buffer as full. The means we will do another
- read later, because the line is not finished */
- if (impl->temp[impl->tmp_buf_size-1] == 0 &&
- impl->temp[impl->tmp_buf_size-2] != '\n'&&
- impl->temp[impl->tmp_buf_size-2] != 0 ){
- impl->buffer_full = 1;
- } else {
- impl->buffer_full = 0;
- }
-
- /* Copy the temp to the output and clear the temp buffer. */
- if(impl->continuation_line==1){
- /* back up the pointer to erase the continuation characters */
- impl->continuation_line = 0;
- line_p--;
-
- if ( *(line_p-1) == '\r'){
- line_p--;
- }
-
- /* copy one space up to eliminate the leading space*/
- icalmemory_append_string(&line,&line_p,&buf_size,
- impl->temp+1);
-
- } else {
- icalmemory_append_string(&line,&line_p,&buf_size,impl->temp);
- }
-
- impl->temp[0] = '\0' ;
- }
-
- impl->temp[impl->tmp_buf_size-1] = 1; /* Mark end of buffer */
-
- /****** Here is where the routine gets string data ******************/
- if ((*line_gen_func)(impl->temp,impl->tmp_buf_size,impl->line_gen_data)
- ==0){/* Get more data */
-
- /* If the first position is clear, it means we didn't get
- any more data from the last call to line_ge_func*/
- if (impl->temp[0] == '\0'){
-
- if(line[0] != '\0'){
- /* There is data in the output, so fall trhough and process it*/
- break;
- } else {
- /* No data in output; return and signal that there
- is no more input*/
- free(line);
- return 0;
- }
- }
- }
-
-
- /* If the output line ends in a '\n' and the temp buffer
- begins with a ' ', then the buffer holds a continuation
- line, so keep reading. */
-
- if ( line_p > line+1 && *(line_p-1) == '\n' && impl->temp[0] == ' ') {
-
- impl->continuation_line = 1;
-
- } else if ( impl->buffer_full == 1 ) {
-
- /* The buffer was filled on the last read, so read again */
-
- } else {
-
- /* Looks like the end of this content line, so break */
- break;
- }
-
-
- }
-
- /* Erase the final newline and/or carriage return*/
- if ( line_p > line+1 && *(line_p-1) == '\n') {
- *(line_p-1) = '\0';
- if ( *(line_p-2) == '\r'){
- *(line_p-2) = '\0';
- }
-
- } else {
- *(line_p) = '\0';
- }
-
- return line;
-
-}
-
-void insert_error(icalcomponent* comp, char* text,
- char* message, icalparameter_xlicerrortype type)
-{
- char temp[1024];
-
- if (text == 0){
- snprintf(temp,1024,"%s:",message);
- } else {
- snprintf(temp,1024,"%s: %s",message,text);
- }
-
- icalcomponent_add_property
- (comp,
- icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(type),
- 0));
-}
-
-int line_is_blank(char* line){
- int i=0;
-
- for(i=0; *(line+i)!=0; i++){
- char c = *(line+i);
-
- if(c != ' ' && c != '\n' && c != '\t'){
- return 0;
- }
- }
-
- return 1;
-}
-
-icalcomponent* icalparser_parse(icalparser *parser,
- char* (*line_gen_func)(char *s, size_t size,
- void* d))
-{
-
- char* line;
- icalcomponent *c=0;
- icalcomponent *root=0;
- struct icalparser_impl *impl = (struct icalparser_impl*)parser;
- icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
-
- icalerror_check_arg_rz((parser !=0),"parser");
-
- icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL);
-
- do{
- line = icalparser_get_line(parser, line_gen_func);
-
- if ((c = icalparser_add_line(parser,line)) != 0){
-
- if(icalcomponent_get_parent(c) !=0){
- /* This is bad news... assert? */
- }
-
- assert(impl->root_component == 0);
- assert(pvl_count(impl->components) ==0);
-
- if (root == 0){
- /* Just one component */
- root = c;
- } else if(icalcomponent_isa(root) != ICAL_XROOT_COMPONENT) {
- /*Got a second component, so move the two components under
- an XROOT container */
- icalcomponent *tempc = icalcomponent_new(ICAL_XROOT_COMPONENT);
- icalcomponent_add_component(tempc, root);
- icalcomponent_add_component(tempc, c);
- root = tempc;
- } else if(icalcomponent_isa(root) == ICAL_XROOT_COMPONENT) {
- /* Already have an XROOT container, so add the component
- to it*/
- icalcomponent_add_component(root, c);
-
- } else {
- /* Badness */
- assert(0);
- }
-
- c = 0;
-
- }
- if(line != 0){
- free(line);
- }
- } while ( line != 0);
-
- icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
-
- return root;
-
-}
-
-
-icalcomponent* icalparser_add_line(icalparser* parser,
- char* line)
-{
- char *p;
- char *str;
- char *end;
- int vcount = 0;
- icalproperty *prop;
- icalproperty_kind prop_kind;
- icalvalue *value;
- icalvalue_kind value_kind = ICAL_NO_VALUE;
-
-
- struct icalparser_impl *impl = (struct icalparser_impl*)parser;
- icalerror_check_arg_rz((parser != 0),"parser");
-
-
- if (line == 0)
- {
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
-
- if(line_is_blank(line) == 1){
- return 0;
- }
-
- /* Begin by getting the property name at the start of the line. The
- property name may end up being "BEGIN" or "END" in which case it
- is not really a property, but the marker for the start or end of
- a component */
-
- end = 0;
- str = icalparser_get_prop_name(line, &end);
-
- if (str == 0 || strlen(str) == 0 ){
- /* Could not get a property name */
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
-
- if (tail){
- insert_error(tail,line,
- "Got a data line, but could not find a property name or component begin tag",
- ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
- }
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
-
- /**********************************************************************
- * Handle begin and end of components
- **********************************************************************/
- /* If the property name is BEGIN or END, we are actually
- starting or ending a new component */
-
- if(strcmp(str,"BEGIN") == 0){
- icalcomponent *c;
- icalcomponent_kind comp_kind;
-
- impl->level++;
- str = icalparser_get_next_value(end,&end, value_kind);
-
-
- comp_kind = icalenum_string_to_component_kind(str);
-
- if (comp_kind == ICAL_NO_COMPONENT){
- c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
- insert_error(c,str,"Parse error in component name",
- ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
- }
-
- c = icalcomponent_new(comp_kind);
-
- if (c == 0){
- c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
- insert_error(c,str,"Parse error in component name",
- ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
- }
-
- pvl_push(impl->components,c);
-
- impl->state = ICALPARSER_BEGIN_COMP;
- return 0;
-
- } else if (strcmp(str,"END") == 0 ) {
- icalcomponent* tail;
-
- impl->level--;
- str = icalparser_get_next_value(end,&end, value_kind);
-
- /* Pop last component off of list and add it to the second-to-last*/
- impl->root_component = pvl_pop(impl->components);
-
- tail = pvl_data(pvl_tail(impl->components));
-
- if(tail != 0){
- icalcomponent_add_component(tail,impl->root_component);
- }
-
- tail = 0;
-
- /* Return the component if we are back to the 0th level */
- if (impl->level == 0){
- icalcomponent *rtrn;
-
- if(pvl_count(impl->components) != 0){
- /* There are still components on the stack -- this means
- that one of them did not have a proper "END" */
- pvl_push(impl->components,impl->root_component);
- icalparser_clean(parser); /* may reset impl->root_component*/
- }
-
- assert(pvl_count(impl->components) == 0);
-
- impl->state = ICALPARSER_SUCCESS;
- rtrn = impl->root_component;
- impl->root_component = 0;
- return rtrn;
-
- } else {
- impl->state = ICALPARSER_END_COMP;
- return 0;
- }
- }
-
-
- /* There is no point in continuing if we have not seen a
- component yet */
-
- if(pvl_data(pvl_tail(impl->components)) == 0){
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
-
-
- /**********************************************************************
- * Handle property names
- **********************************************************************/
-
- /* At this point, the property name really is a property name,
- (Not a component name) so make a new property and add it to
- the component */
-
-
- prop_kind = icalproperty_string_to_kind(str);
-
- prop = icalproperty_new(prop_kind);
-
- if (prop != 0){
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
-
- if(prop_kind==ICAL_X_PROPERTY){
- icalproperty_set_x_name(prop,str);
- }
-
- icalcomponent_add_property(tail, prop);
-
- /* Set the value kind for the default for this type of
- property. This may be re-set by a VALUE parameter */
- value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop));
-
- } else {
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
-
- insert_error(tail,str,"Parse error in property name",
- ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);
-
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
-
- /**********************************************************************
- * Handle parameter values
- **********************************************************************/
-
- /* Now, add any parameters to the last property */
-
- p = 0;
- while(1) {
-
- if (*(end-1) == ':'){
- /* if the last seperator was a ":" and the value is a
- URL, icalparser_get_next_parameter will find the
- ':' in the URL, so better break now. */
- break;
- }
-
- str = icalparser_get_next_parameter(end,&end);
-
- if (str != 0){
- char* name;
- char* pvalue;
-
- icalparameter *param = 0;
- icalparameter_kind kind;
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
-
- name = icalparser_get_param_name(str,&pvalue);
-
- if (name == 0){
- /* 'tail' defined above */
- insert_error(tail, str, "Cant parse parameter name",
- ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
- tail = 0;
- break;
- }
-
- kind = icalparameter_string_to_kind(name);
-
- if(kind == ICAL_X_PARAMETER){
- param = icalparameter_new(ICAL_X_PARAMETER);
-
- if(param != 0){
- icalparameter_set_xname(param,name);
- icalparameter_set_xvalue(param,pvalue);
- }
-
-
- } else if (kind != ICAL_NO_PARAMETER){
- param = icalparameter_new_from_value_string(kind,pvalue);
- } else {
- /* Error. Failed to parse the parameter*/
- /* 'tail' defined above */
- insert_error(tail, str, "Cant parse parameter name",
- ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
-
- if (param == 0){
- /* 'tail' defined above */
- insert_error(tail,str,"Cant parse parameter value",
- ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
-
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- continue;
- }
-
- /* If it is a VALUE parameter, set the kind of value*/
- if (icalparameter_isa(param)==ICAL_VALUE_PARAMETER){
-
- value_kind = (icalvalue_kind)
- icalparameter_value_to_value_kind(
- icalparameter_get_value(param)
- );
-
- if (value_kind == ICAL_NO_VALUE){
-
- /* Ooops, could not parse the value of the
- parameter ( it was not one of the defined
- values ), so reset the value_kind */
-
- insert_error(
- tail, str,
- "Got a VALUE parameter with an unknown type",
- ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
- icalparameter_free(param);
-
- value_kind =
- icalproperty_kind_to_value_kind(
- icalproperty_isa(prop));
-
- icalparameter_free(param);
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
- }
- }
-
- /* Everything is OK, so add the parameter */
- icalproperty_add_parameter(prop,param);
- tail = 0;
-
- } else { /* if ( str != 0) */
- /* If we did not get a param string, go on to looking
- for a value */
- break;
- } /* if ( str != 0) */
-
- } /* while(1) */
-
- /**********************************************************************
- * Handle values
- **********************************************************************/
-
- /* Look for values. If there are ',' characters in the values,
- then there are multiple values, so clone the current
- parameter and add one part of the value to each clone */
-
- vcount=0;
- while(1) {
- str = icalparser_get_next_value(end,&end, value_kind);
-
- if (str != 0){
-
- if (vcount > 0){
- /* Actually, only clone after the second value */
- icalproperty* clone = icalproperty_new_clone(prop);
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
-
- icalcomponent_add_property(tail, clone);
- prop = clone;
- tail = 0;
- }
-
- value = icalvalue_new_from_string(value_kind, str);
-
- /* Don't add properties without value */
- if (value == 0){
- char temp[200]; /* HACK */
-
- icalproperty_kind prop_kind = icalproperty_isa(prop);
- icalcomponent* tail = pvl_data(pvl_tail(impl->components));
-
- sprintf(temp,"Cant parse as %s value in %s property. Removing entire property",
- icalvalue_kind_to_string(value_kind),
- icalproperty_kind_to_string(prop_kind));
-
- insert_error(tail, str, temp,
- ICAL_XLICERRORTYPE_VALUEPARSEERROR);
-
- /* Remove the troublesome property */
- icalcomponent_remove_property(tail,prop);
- icalproperty_free(prop);
- prop = 0;
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
-
- } else {
- vcount++;
- icalproperty_set_value(prop, value);
- }
-
-
- } else {
- if (vcount == 0){
- char temp[200]; /* HACK */
-
- icalproperty_kind prop_kind = icalproperty_isa(prop);
- icalcomponent *tail = pvl_data(pvl_tail(impl->components));
-
- sprintf(temp,"No value for %s property. Removing entire property",
- icalproperty_kind_to_string(prop_kind));
-
- insert_error(tail, str, temp,
- ICAL_XLICERRORTYPE_VALUEPARSEERROR);
-
- /* Remove the troublesome property */
- icalcomponent_remove_property(tail,prop);
- icalproperty_free(prop);
- prop = 0;
- tail = 0;
- impl->state = ICALPARSER_ERROR;
- return 0;
- } else {
-
- break;
- }
- }
- }
-
- /****************************************************************
- * End of component parsing.
- *****************************************************************/
-
- if (pvl_data(pvl_tail(impl->components)) == 0 &&
- impl->level == 0){
- /* HACK. Does this clause ever get executed? */
- impl->state = ICALPARSER_SUCCESS;
- assert(0);
- return impl->root_component;
- } else {
- impl->state = ICALPARSER_IN_PROGRESS;
- return 0;
- }
-
-}
-
-icalparser_state icalparser_get_state(icalparser* parser)
-{
- struct icalparser_impl* impl = (struct icalparser_impl*) parser;
- return impl->state;
-
-}
-
-icalcomponent* icalparser_clean(icalparser* parser)
-{
- struct icalparser_impl* impl = (struct icalparser_impl*) parser;
- icalcomponent *tail;
-
- icalerror_check_arg_rz((parser != 0 ),"parser");
-
- /* We won't get a clean exit if some components did not have an
- "END" tag. Clear off any component that may be left in the list */
-
- while((tail=pvl_data(pvl_tail(impl->components))) != 0){
-
- insert_error(tail," ",
- "Missing END tag for this component. Closing component at end of input.",
- ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
-
-
- impl->root_component = pvl_pop(impl->components);
- tail=pvl_data(pvl_tail(impl->components));
-
- if(tail != 0){
- if(icalcomponent_get_parent(impl->root_component)!=0){
- icalerror_warn("icalparser_clean is trying to attach a component for the second time");
- } else {
- icalcomponent_add_component(tail,impl->root_component);
- }
- }
-
- }
-
- return impl->root_component;
-
-}
-
-struct slg_data {
- const char* pos;
- const char* str;
-};
-
-char* string_line_generator(char *out, size_t buf_size, void *d)
-{
- char *n;
- size_t size;
- struct slg_data* data = (struct slg_data*)d;
-
- if(data->pos==0){
- data->pos=data->str;
- }
-
- /* If the pointer is at the end of the string, we are done */
- if (*(data->pos)==0){
- return 0;
- }
-
- n = strchr(data->pos,'\n');
-
- if (n == 0){
- size = strlen(data->pos);
- } else {
- n++; /* include newline in output */
- size = (n-data->pos);
- }
-
- if (size > buf_size-1){
- size = buf_size-1;
- }
-
-
- strncpy(out,data->pos,size);
-
- *(out+size) = '\0';
-
- data->pos += size;
-
- return out;
-}
-
-icalcomponent* icalparser_parse_string(const char* str)
-{
- icalcomponent *c;
- struct slg_data d;
- icalparser *p;
-
- icalerrorstate es = icalerror_get_error_state(ICAL_PARSE_ERROR);
-
- d.pos = 0;
- d.str = str;
-
- p = icalparser_new();
- icalparser_set_gen_data(p,&d);
-
- icalerror_set_error_state(ICAL_PARSE_ERROR,ICAL_ERROR_NONFATAL);
-
- c = icalparser_parse(p,string_line_generator);
-
- icalerror_set_error_state(ICAL_PARSE_ERROR,es);
-
- icalparser_free(p);
-
- return c;
-
-}
diff --git a/libical/src/libical/icalparser.h b/libical/src/libical/icalparser.h
deleted file mode 100644
index 5e1c88ffc0..0000000000
--- a/libical/src/libical/icalparser.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalparser.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 icalparser.h
-
-======================================================================*/
-
-
-#ifndef ICALPARSER_H
-#define ICALPARSER_H
-
-#include "icalenums.h"
-#include "icaltypes.h"
-#include"icalcomponent.h"
-
-#include <stdio.h> /* For FILE* */
-
-typedef void* icalparser;
-
-
-/***********************************************************************
- * Line-oriented parsing.
- *
- * Create a new parser via icalparse_new_parser, then add ines one at
- * a time with icalparse_add_line(). icalparser_add_line() will return
- * non-zero when it has finished with a component.
- ***********************************************************************/
-
-typedef enum icalparser_state {
- ICALPARSER_ERROR,
- ICALPARSER_SUCCESS,
- ICALPARSER_BEGIN_COMP,
- ICALPARSER_END_COMP,
- ICALPARSER_IN_PROGRESS
-} icalparser_state;
-
-icalparser* icalparser_new(void);
-icalcomponent* icalparser_add_line(icalparser* parser, char* str );
-icalcomponent* icalparser_clean(icalparser* parser);
-icalparser_state icalparser_get_state(icalparser* parser);
-void icalparser_free(icalparser* parser);
-
-
-/***********************************************************************
- * Message oriented parsing. icalparser_parse takes a string that
- * holds the text ( in RFC 2445 format ) and returns a pointer to an
- * icalcomponent. The caller owns the memory. line_gen_func is a
- * pointer to a function that returns one content line per invocation
- **********************************************************************/
-
-icalcomponent* icalparser_parse(icalparser *parser,
- char* (*line_gen_func)(char *s, size_t size, void *d));
-
-/* Set the data that icalparser_parse will give to the line_gen_func
- as the parameter 'd'*/
-void icalparser_set_gen_data(icalparser* parser, void* data);
-
-
-icalcomponent* icalparser_parse_string(const char* str);
-
-
-/***********************************************************************
- * Parser support functions
- ***********************************************************************/
-
-/* Use the flex/bison parser to turn a string into a value type */
-icalvalue* icalparser_parse_value(icalvalue_kind kind,
- const char* str, icalcomponent** errors);
-
-/* Given a line generator function, return a single iCal content line.*/
-char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
-
-char* string_line_generator(char *out, size_t buf_size, void *d);
-
-#endif /* !ICALPARSE_H */
diff --git a/libical/src/libical/icalperiod.c b/libical/src/libical/icalperiod.c
deleted file mode 100644
index c74c157eff..0000000000
--- a/libical/src/libical/icalperiod.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalperiod.c
- CREATOR: eric 02 June 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
-
-#include "icalperiod.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef ICAL_NO_LIBICAL
-#define icalerror_set_errno(x)
-#define icalerror_check_arg_rv(x,y)
-#define icalerror_check_arg_re(x,y,z)
-#else
-#include "icalerror.h"
-#include "icalmemory.h"
-#endif
-
-
-
-
-struct icalperiodtype icalperiodtype_from_string (const char* str)
-{
-
- struct icalperiodtype p, null_p;
- char *s = icalmemory_strdup(str);
- char *start, *end = s;
- icalerrorstate es;
-
- /* Errors are normally generated in the following code, so save
- the error state for resoration later */
-
- icalerrorenum e = icalerrno;
-
- p.start = p.end = icaltime_null_time();
- p.duration = icaldurationtype_from_int(0);
-
- null_p = p;
-
- if(s == 0) goto error;
-
- start = s;
- end = strchr(s, '/');
-
- if(end == 0) goto error;
-
- *end = 0;
- end++;
-
- p.start = icaltime_from_string(start);
-
- if (icaltime_is_null_time(p.start)) goto error;
-
- es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
- icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL);
-
- p.end = icaltime_from_string(end);
-
- icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
-
-
- if (icaltime_is_null_time(p.end)){
-
- p.duration = icaldurationtype_from_string(end);
-
- if(icaldurationtype_as_int(p.duration) == 0) goto error;
- }
-
- icalerrno = e;
-
- return p;
-
- error:
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return null_p;
-}
-
-
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
-{
-
- const char* start;
- const char* end;
-
- char *buf;
- size_t buf_size = 40;
- char* buf_ptr = 0;
-
- buf = (char*)icalmemory_new_buffer(buf_size);
- buf_ptr = buf;
-
-
- start = icaltime_as_ical_string(p.start);
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, start);
-
- if(!icaltime_is_null_time(p.end)){
- end = icaltime_as_ical_string(p.end);
- } else {
- end = icaldurationtype_as_ical_string(p.duration);
- }
-
- icalmemory_append_char(&buf, &buf_ptr, &buf_size, '/');
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, end);
-
-
- return buf;
-}
-
-
-
-struct icalperiodtype icalperiodtype_null_period() {
- struct icalperiodtype p;
- p.start = icaltime_null_time();
- p.end = icaltime_null_time();
- p.duration = icaldurationtype_null_duration();
-
- return p;
-}
-int icalperiodtype_is_null_period(struct icalperiodtype p){
-
- if(icaltime_is_null_time(p.start) &&
- icaltime_is_null_time(p.end) &&
- icaldurationtype_is_null_duration(p.duration)){
- return 1;
- } else {
- return 0;
- }
-}
-
-int icalperiodtype_is_valid_period(struct icalperiodtype p){
- if(icaltime_is_valid_time(p.start) &&
- (icaltime_is_valid_time(p.end) || icaltime_is_null_time(p.end)) )
- {
- return 1;
- }
-
- return 0;
-}
-
diff --git a/libical/src/libical/icalperiod.h b/libical/src/libical/icalperiod.h
deleted file mode 100644
index 64d53237ad..0000000000
--- a/libical/src/libical/icalperiod.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalperiod.h
- CREATOR: eric 26 Jan 2001
-
-
- $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 ICALPERIOD_H
-#define ICALPERIOD_H
-
-#include "icaltime.h"
-#include "icalduration.h"
-
-struct icalperiodtype
-{
- struct icaltimetype start;
- struct icaltimetype end;
- struct icaldurationtype duration;
-};
-
-struct icalperiodtype icalperiodtype_from_string (const char* str);
-
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
-struct icalperiodtype icalperiodtype_null_period();
-int icalperiodtype_is_null_period(struct icalperiodtype p);
-int icalperiodtype_is_valid_period(struct icalperiodtype p);
-
-
-
-
-#endif /* !ICALTIME_H */
-
-
-
diff --git a/libical/src/libical/icalproperty.c b/libical/src/libical/icalproperty.c
deleted file mode 100644
index c5638827e5..0000000000
--- a/libical/src/libical/icalproperty.c
+++ /dev/null
@@ -1,808 +0,0 @@
-/* -*- Mode: C -*- */
-
-/*======================================================================
- FILE: icalproperty.c
- CREATOR: eric 28 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 icalproperty.c
-
-======================================================================*/
-/*#line 27 "icalproperty.c.in"*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "icalproperty.h"
-#include "icalparameter.h"
-#include "icalcomponent.h"
-#include "pvl.h"
-#include "icalenums.h"
-#include "icalerror.h"
-#include "icalmemory.h"
-#include "icalparser.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 *prop,va_list args)
-{
-
- void* vp;
-
- struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
-
- 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)
-{
- if(kind == ICAL_NO_PROPERTY){
- return 0;
- }
-
- return (icalproperty*)icalproperty_new_impl(kind);
-}
-
-
-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;
-
-}
-
-icalproperty* icalproperty_new_from_string(char* str)
-{
-
- size_t buf_size = 1024;
- char* buf = icalmemory_new_buffer(buf_size);
- char* buf_ptr = buf;
- icalproperty *prop;
- icalcomponent *comp;
- int errors = 0;
-
- icalerror_check_arg_rz( (str!=0),"str");
-
- /* Is this a HACK or a crafty reuse of code? */
-
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:VCALENDAR\n");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "\n");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:VCALENDAR\n");
-
- comp = icalparser_parse_string(buf);
-
- if(comp == 0){
- icalerror_set_errno(ICAL_PARSE_ERROR);
- return 0;
- }
-
- errors = icalcomponent_count_errors(comp);
-
- prop = icalcomponent_get_first_property(comp,ICAL_ANY_PROPERTY);
-
- icalcomponent_remove_property(comp,prop);
-
- icalcomponent_free(comp);
- free(buf);
-
- if(errors > 0){
- icalproperty_free(prop);
- return 0;
- } else {
- return prop;
- }
-
-}
-
-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 = icalproperty_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);
-
-
-
- /* Determine what VALUE parameter to include. The VALUE parameters
- are ignored in the normal parameter printing ( the block after
- this one, so we need to do it here */
- {
- const char* kind_string = 0;
-
- icalparameter *orig_val_param
- = icalproperty_get_first_parameter(prop,ICAL_VALUE_PARAMETER);
-
- icalvalue *value = icalproperty_get_value(impl);
-
- icalvalue_kind orig_kind = ICAL_NO_VALUE;
-
- icalvalue_kind this_kind = ICAL_NO_VALUE;
-
- icalvalue_kind default_kind
- = icalproperty_kind_to_value_kind(impl->kind);
-
- if(orig_val_param){
- orig_kind = (icalvalue_kind)icalparameter_get_value(orig_val_param);
- }
-
- if(value != 0){
- this_kind = icalvalue_isa(value);
- }
-
-
- if(this_kind == default_kind &&
- orig_kind != ICAL_NO_VALUE){
- /* The kind is the default, so it does not need to be
- included, but do it anyway, since it was explicit in
- the property. But, use the default, not the one
- specified in the property */
-
- kind_string = icalvalue_kind_to_string(default_kind);
-
- } else if (this_kind != default_kind && this_kind != ICAL_NO_VALUE){
- /* Not the default, so it must be specified */
- kind_string = icalvalue_kind_to_string(this_kind);
- } else {
- /* Don'tinclude the VALUE parameter at all */
- }
-
- if(kind_string!=0){
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, "VALUE=");
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
- 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);
- icalparameter_kind kind = icalparameter_isa(param);
-
- if(kind==ICAL_VALUE_PARAMETER){
- continue;
- }
-
- 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)
-{
- icalparameter_kind kind;
-
- icalerror_check_arg_rv( (prop!=0),"prop");
- icalerror_check_arg_rv( (parameter!=0),"parameter");
-
- kind = icalparameter_isa(parameter);
-
- icalproperty_remove_parameter(prop,kind);
-
- icalproperty_add_parameter(prop,parameter);
-}
-
-void icalproperty_set_parameter_from_string(icalproperty* prop,
- const char* name, const char* value)
-{
-
- icalparameter_kind kind;
- icalparameter *param;
-
- icalerror_check_arg_rv( (prop!=0),"prop");
- icalerror_check_arg_rv( (name!=0),"name");
- icalerror_check_arg_rv( (value!=0),"value");
-
- kind = icalparameter_string_to_kind(name);
-
- if(kind == ICAL_NO_PARAMETER){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
- }
-
- param = icalparameter_new_from_value_string(kind,value);
-
- if (param == 0){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
- }
-
- icalproperty_set_parameter(prop,param);
-
-}
-
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
- const char* name)
-{
- icalparameter_kind kind;
- icalparameter *param;
- char* str;
- char* pv;
-
- icalerror_check_arg_rz( (prop!=0),"prop");
- icalerror_check_arg_rz( (name!=0),"name");
-
- kind = icalparameter_string_to_kind(name);
-
- if(kind == ICAL_NO_PROPERTY){
- /* icalenum_string_to_parameter_kind will set icalerrno */
- return 0;
- }
-
- param = icalproperty_get_first_parameter(prop,kind);
-
- if (param == 0){
- return 0;
- }
-
- str = icalparameter_as_ical_string(param);
-
- pv = strchr(str,'=');
-
- if(pv == 0){
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
- return 0;
- }
-
- return pv+1;
-
-}
-
-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);
-}
-
-
-void icalproperty_set_value_from_string(icalproperty* prop,const char* str,
- const char* type)
-{
- icalvalue *oval,*nval;
- icalvalue_kind kind = ICAL_NO_VALUE;
-
- icalerror_check_arg_rv( (prop!=0),"prop");
- icalerror_check_arg_rv( (str!=0),"str");
- icalerror_check_arg_rv( (type!=0),"type");
-
- if(strcmp(type,"NO")==0){
- /* Get the type from the value the property already has, if it exists */
- oval = icalproperty_get_value(prop);
- if(oval != 0){
- /* Use the existing value kind */
- kind = icalvalue_isa(oval);
- } else {
- /* Use the default kind for the property */
- kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop));
- }
- } else {
- /* Use the given kind string */
- kind = icalvalue_string_to_kind(type);
- }
-
- if(kind == ICAL_NO_VALUE){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return;
- }
-
- nval = icalvalue_new_from_string(kind, str);
-
- if(nval == 0){
- /* icalvalue_new_from_string sets errno */
- assert(icalerrno != ICAL_NO_ERROR);
- return;
- }
-
- icalproperty_set_value(prop,nval);
-
-
-}
-
-icalvalue*
-icalproperty_get_value (icalproperty* prop)
-{
- struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
-
- icalerror_check_arg_rz( (prop!=0),"prop");
-
- return p->value;
-}
-
-const char* icalproperty_get_value_as_string(icalproperty* prop)
-{
- icalvalue *value;
-
- struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
-
- icalerror_check_arg_rz( (prop!=0),"prop");
-
- value = impl->value;
-
- return icalvalue_as_ical_string(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_NEWFAILED_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;
-}
-
-
-/* From Jonathan Yue <jonathan.yue@cp.net> */
-char* icalproperty_get_name (icalproperty* prop)
-{
-
- const char* property_name = 0;
- size_t buf_size = 256;
- char* buf = icalmemory_new_buffer(buf_size);
- char* buf_ptr = buf;
-
- struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
-
- icalerror_check_arg_rz( (prop!=0),"prop");
-
- if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){
- property_name = impl->x_name;
- } else {
- property_name = icalproperty_kind_to_string(impl->kind);
- }
-
- if (property_name == 0 ) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
-
- } else {
- /* _append_string will automatically grow the buffer if
- property_name is longer than the initial buffer size */
- icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name);
- }
-
- /* Add the buffer to the temporary buffer ring -- the caller will
- not have to free the memory. */
- icalmemory_add_tmp_buffer(buf);
-
- return buf;
-}
-
-
-
-
-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_rz( (property!=0),"property");
-
- return impl->parent;
-}
-
-
-
-
-
-
-
-/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalproperty.h b/libical/src/libical/icalproperty.h
deleted file mode 100644
index 6f5f1bfaef..0000000000
--- a/libical/src/libical/icalproperty.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalproperty.h
- CREATOR: eric 20 March 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 icalparam.h
-
- ======================================================================*/
-
-
-#ifndef ICALPROPERTY_H
-#define ICALPROPERTY_H
-
-#include <time.h>
-
-
-#include "icalderivedparameter.h"
-
-#include "icalvalue.h"
-#include "icalrecur.h"
-
-/* Actually in icalderivedproperty.h:
- typedef void icalproperty; */
-
-#include "icalderivedproperty.h" /* To get icalproperty_kind enumerations */
-
-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_set_parameter_from_string(icalproperty* prop,
- const char* name, const char* value);
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
- const char* name);
-
-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);
-void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind);
-
-icalvalue* icalproperty_get_value(icalproperty* prop);
-const char* icalproperty_get_value_as_string(icalproperty* prop);
-
-/* Deal with X properties */
-
-void icalproperty_set_x_name(icalproperty* prop, char* name);
-char* icalproperty_get_x_name(icalproperty* prop);
-
-/* Return the name of the property -- the type name converted to a
- string, or the value of _get_x_name if the type is and X property */
-char* icalproperty_get_name (icalproperty* prop);
-
-icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
-
-/* Convert kinds to string and get default value type */
-
-icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);
-icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind);
-const char* icalproperty_kind_to_string(icalproperty_kind kind);
-icalproperty_kind icalproperty_string_to_kind(const char* string);
-
-icalproperty_method icalproperty_string_to_method(const char* str);
-const char* icalproperty_method_to_string(icalproperty_method method);
-
-
-const char* icalproperty_enum_to_string(int e);
-int icalproperty_string_to_enum(const char* str);
-
-const char* icalproperty_status_to_string(icalproperty_status);
-icalproperty_status icalproperty_string_to_status(const char* string);
-
-int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e);
-
-
-
-
-#endif /*ICALPROPERTY_H*/
diff --git a/libical/src/libical/icalrecur.c b/libical/src/libical/icalrecur.c
deleted file mode 100644
index d998cd0e39..0000000000
--- a/libical/src/libical/icalrecur.c
+++ /dev/null
@@ -1,2353 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalrecur.c
- CREATOR: eric 16 May 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/
-
-
- How this code works:
-
- Processing starts when the caller generates a new recurrence
- iterator via icalrecur_iterator_new(). This routine copies the
- recurrence rule into the iterator and extracts things like start and
- end dates. Then, it checks if the rule is legal, using some logic
- from RFC2445 and some logic that probably should be in RFC2445.
-
- Then, icalrecur_iterator_new() re-writes some of the BY*
- arrays. This involves ( via a call to setup_defaults() ) :
-
- 1) For BY rule parts with no data ( ie BYSECOND was not specified )
- copy the corresponding time part from DTSTART into the BY array. (
- So impl->by_ptrs[BY_SECOND] will then have one element if is
- originally had none ) This only happens if the BY* rule part data
- would expand the number of occurrences in the occurrence set. This
- lets the code ignore DTSTART later on and still use it to get the
- time parts that were not specified in any other way.
-
- 2) For the by rule part that are not the same interval as the
- frequency -- for HOURLY anything but BYHOUR, for instance -- copy the
- first data element from the rule part into the first occurrence. For
- example, for "INTERVAL=MONTHLY and BYHOUR=10,30", initialize the
- first time to be returned to have an hour of 10.
-
- Finally, for INTERVAL=YEARLY, the routine expands the rule to get
- all of the days specified in the rule. The code will do this for
- each new year, and this is the first expansion. This is a special
- case for the yearly interval; no other frequency gets expanded this
- way. The yearly interval is the most complex, so some special
- processing is required.
-
- After creating a new iterator, the caller will make successive calls
- to icalrecur_iterator_next() to get the next time specified by the
- rule. The main part of this routine is a switch on the frequency of
- the rule. Each different frequency is handled by a different
- routine.
-
- For example, next_hour handles the case of INTERVAL=HOURLY, and it
- is called by other routines to get the next hour. First, the routine
- tries to get the next minute part of a time with a call to
- next_minute(). If next_minute() returns 1, it has reached the end of
- its data, usually the last element of the BYMINUTE array. Then, if
- there is data in the BYHOUR array, the routine changes the hour to
- the next one in the array. If INTERVAL=HOURLY, the routine advances
- the hour by the interval.
-
- If the routine used the last hour in the BYHOUR array, and the
- INTERVAL=HOURLY, then the routine calls increment_monthday() to set
- the next month day. The increment_* routines may call higher routine
- to increment the month or year also.
-
- The code for INTERVAL=DAILY is handled by next_day(). First, the
- routine tries to get the next hour part of a time with a call to
- next_hour. If next_hour() returns 1, it has reached the end of its
- data, usually the last element of the BYHOUR array. This means that
- next_day() should increment the time to the next day. If FREQUENCY==DAILY,
- the routine increments the day by the interval; otherwise, it
- increments the day by 1.
-
- Next_day() differs from next_hour because it does not use the BYDAY
- array to select an appropriate day. Instead, it returns every day (
- incrementing by 1 if the frequency is not DAILY with INTERVAL!=1)
- Any days that are not specified in an non-empty BYDAY array are
- filtered out later.
-
- Generally, the flow of these routine is for a next_* call a next_*
- routine of a lower interval ( next_day calls next_hour) and then to
- possibly call an increment_* routine of an equal or higher
- interval. ( next_day calls increment_monthday() )
-
- When the call to the original next_* routine returns,
- icalrecur_iterator_next() will check the returned data against other
- BYrule parts to determine if is should be excluded by calling
- check_contracting_rules. Generally, a contracting rule is any with a
- larger time span than the interval. For instance, if
- INTERVAL=DAILY, BYMONTH is a contracting rule part.
-
- Check_contracting_rules() uses icalrecur_check_rulepart() to do its
- work. icalrecur_check_rulepart() uses expand_map[] to determine if a rule
- is contracting, and if it is, and if the BY rule part has some data,
- then the routine checks if the value of a component of the time is
- part of the byrule part. For instance, for "INTERVAL=DAILY;
- BYMONTH=6,10", icalrecur_check_rulepart() would check that the time value
- given to it has a month of either 6 or 10.
-
- Finally, icalrecur_iterator_next() does a few other checks on the
- time value, and if it passes, it returns the time.
-
- A note about the end_of_data flag. The flag indicates that the
- routine is at the end of its data -- the last BY rule if the routine
- is using by rules, or the last day of the week/month/year/etc if
- not.
-
- This flag is usually set early in a next_* routine and returned in
- the end. The way it is used allows the next_* routine to set the
- last time back to the first element in a BYxx rule, and then signal
- to the higer level routine to increment the next higher level. For
- instance. WITH FREQ=MONTHLY;BYDAY=TU,FR, After next_weekday_by_month
- runs though both TU and FR, it sets the week day back to TU and sets
- end_of_data to 1x. This signals next_month to increment the month.
-
-
- ======================================================================*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalrecur.h"
-
-#ifdef ICAL_NO_LIBICAL
-#define icalerror_set_errno(x)
-#define icalerror_check_arg_rv(x,y)
-#else
-#include "icalerror.h"
-#include "icalmemory.h"
-#endif
-
-#include <stdlib.h> /* for malloc */
-#include <errno.h> /* for errno */
-#include <string.h> /* for strdup and strchr*/
-#include <assert.h>
-#include <stddef.h> /* For offsetof() macro */
-
-#include "pvl.h"
-
-#define TEMP_MAX 1024
-
-
-#define BYDAYIDX impl->by_indices[BY_DAY]
-#define BYDAYPTR impl->by_ptrs[BY_DAY]
-
-#define BYMONIDX impl->by_indices[BY_MONTH]
-#define BYMONPTR impl->by_ptrs[BY_MONTH]
-
-#define BYMDIDX impl->by_indices[BY_MONTH_DAY]
-#define BYMDPTR impl->by_ptrs[BY_MONTH_DAY]
-
-#define BYWEEKIDX impl->by_indices[BY_WEEK_NO]
-#define BYWEEKPTR impl->by_ptrs[BY_WEEK_NO]
-
-const char* icalrecur_freq_to_string(icalrecurrencetype_frequency kind);
-icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str);
-
-const char* icalrecur_weekday_to_string(icalrecurrencetype_weekday kind);
-icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str);
-
-
-
-/*********************** Rule parsing routines ************************/
-
-struct icalrecur_parser {
- const char* rule;
- char* copy;
- char* this_clause;
- char* next_clause;
-
- struct icalrecurrencetype rt;
-};
-
-const char* icalrecur_first_clause(struct icalrecur_parser *parser)
-{
- char *idx;
- parser->this_clause = parser->copy;
-
- idx = strchr(parser->this_clause,';');
-
- if (idx == 0){
- parser->next_clause = 0;
- return 0;
- }
-
- *idx = 0;
- idx++;
- parser->next_clause = idx;
-
- return parser->this_clause;
-
-}
-
-const char* icalrecur_next_clause(struct icalrecur_parser *parser)
-{
- char* idx;
-
- parser->this_clause = parser->next_clause;
-
- if(parser->this_clause == 0){
- return 0;
- }
-
- idx = strchr(parser->this_clause,';');
-
- if (idx == 0){
- parser->next_clause = 0;
- } else {
-
- *idx = 0;
- idx++;
- parser->next_clause = idx;
- }
-
- return parser->this_clause;
-
-}
-
-void icalrecur_clause_name_and_value(struct icalrecur_parser *parser,
- char** name, char** value)
-{
- char *idx;
-
- *name = parser->this_clause;
-
- idx = strchr(parser->this_clause,'=');
-
- if (idx == 0){
- *name = 0;
- *value = 0;
- return;
- }
-
- *idx = 0;
- idx++;
- *value = idx;
-}
-
-void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
- int size, char* vals)
-{
- char *t, *n;
- int i=0;
- int sign = 1;
- short v;
-
- n = vals;
-
- while(n != 0){
-
- if(i == size){
- return;
- }
-
- t = n;
-
- n = strchr(t,',');
-
- if(n != 0){
- *n = 0;
- n++;
- }
-
- /* Get optional sign. HACK. sign is not allowed for all BYxxx
- rule parts */
- if( *t == '-'){
- sign = -1;
- t++;
- } else if (*t == '+'){
- sign = 1;
- t++;
- } else {
- sign = 1;
- }
-
- v = atoi(t) * sign ;
-
-
- array[i++] = v;
- array[i] = ICAL_RECURRENCE_ARRAY_MAX;
-
- }
-
-}
-
-void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
-{
-
- char *t, *n;
- int i=0;
- int sign = 1;
- int weekno = 0;
- icalrecurrencetype_weekday wd;
- short *array = parser->rt.by_day;
- char* end;
- char* vals_copy;
-
- vals_copy = icalmemory_strdup(vals);
-
- end = (char*)vals_copy+strlen(vals_copy);
- n = vals_copy;
-
- while(n != 0){
-
-
- t = n;
-
- n = strchr(t,',');
-
- if(n != 0){
- *n = 0;
- n++;
- }
-
- /* Get optional sign. */
- if( *t == '-'){
- sign = -1;
- t++;
- } else if (*t == '+'){
- sign = 1;
- t++;
- } else {
- sign = 1;
- }
-
- weekno = 0;
- /* Get Optional weekno */
- if( sscanf(t,"%d",&weekno) != 0){
- if (n != 0){
- int weeknolen = (n-t)-3; /* 3 -> one for \0, 2 for day name */
- /* could use abs(log10(weekno))+1, but that needs libm */
- t += weeknolen;
- } else {
- t = end -2;
- }
- }
-
- wd = icalrecur_string_to_weekday(t);
-
- array[i++] = sign* ((int)wd + 8*weekno);
- array[i] = ICAL_RECURRENCE_ARRAY_MAX;
-
- }
-
- free(vals_copy);
-
-}
-
-
-struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
-{
- struct icalrecur_parser parser;
-
- memset(&parser,0,sizeof(parser));
- icalrecurrencetype_clear(&parser.rt);
-
- icalerror_check_arg_re(str!=0,"str",parser.rt);
-
-
- /* Set up the parser struct */
- parser.rule = str;
- parser.copy = icalmemory_strdup(parser.rule);
- parser.this_clause = parser.copy;
-
- if(parser.copy == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return parser.rt;
- }
-
- /* Loop through all of the clauses */
- for(icalrecur_first_clause(&parser);
- parser.this_clause != 0;
- icalrecur_next_clause(&parser))
- {
- char *name, *value;
- icalrecur_clause_name_and_value(&parser,&name,&value);
-
- if(name == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- icalrecurrencetype_clear(&parser.rt);
- return parser.rt;
- }
-
- if (strcmp(name,"FREQ") == 0){
- parser.rt.freq = icalrecur_string_to_freq(value);
- } else if (strcmp(name,"COUNT") == 0){
- parser.rt.count = atoi(value);
- } else if (strcmp(name,"UNTIL") == 0){
- parser.rt.until = icaltime_from_string(value);
- } else if (strcmp(name,"INTERVAL") == 0){
- parser.rt.interval = atoi(value);
- } else if (strcmp(name,"WKST") == 0){
- parser.rt.week_start = icalrecur_string_to_weekday(value);
- } else if (strcmp(name,"BYSECOND") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_second,
- ICAL_BY_SECOND_SIZE,value);
- } else if (strcmp(name,"BYMINUTE") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_minute,
- ICAL_BY_MINUTE_SIZE,value);
- } else if (strcmp(name,"BYHOUR") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_hour,
- ICAL_BY_HOUR_SIZE,value);
- } else if (strcmp(name,"BYDAY") == 0){
- icalrecur_add_bydayrules(&parser,value);
- } else if (strcmp(name,"BYMONTHDAY") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_month_day,
- ICAL_BY_MONTHDAY_SIZE,value);
- } else if (strcmp(name,"BYYEARDAY") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_year_day,
- ICAL_BY_YEARDAY_SIZE,value);
- } else if (strcmp(name,"BYWEEKNO") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_week_no,
- ICAL_BY_WEEKNO_SIZE,value);
- } else if (strcmp(name,"BYMONTH") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_month,
- ICAL_BY_MONTH_SIZE,value);
- } else if (strcmp(name,"BYSETPOS") == 0){
- icalrecur_add_byrules(&parser,parser.rt.by_set_pos,
- ICAL_BY_SETPOS_SIZE,value);
- } else {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- icalrecurrencetype_clear(&parser.rt);
- return parser.rt;
- }
-
- }
-
- free(parser.copy);
-
- return parser.rt;
-
-}
-
-#ifndef ICAL_NO_LIBICAL
-
-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},
-};
-
-/* A private routine in icalvalue.c */
-void print_date_to_string(char* str, struct icaltimetype *data);
-void print_datetime_to_string(char* str, struct icaltimetype *data);
-
-char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
-{
- char* str;
- char *str_p;
- size_t buf_sz = 200;
- char temp[20];
- int i,j;
-
- 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_freq_to_string(recur->freq));
-
- if(recur->until.year != 0){
-
- temp[0] = 0;
- if (recur->until.is_date)
- print_date_to_string(temp,&(recur->until));
- else
- 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;
-
- 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;
-}
-#endif
-
-
-
-/************************* occurrence iteration routiens ******************/
-
-enum byrule {
- NO_CONTRACTION = -1,
- BY_SECOND = 0,
- BY_MINUTE = 1,
- BY_HOUR = 2,
- BY_DAY = 3,
- BY_MONTH_DAY = 4,
- BY_YEAR_DAY = 5,
- BY_WEEK_NO = 6,
- BY_MONTH = 7,
- BY_SET_POS
-};
-
-
-
-struct icalrecur_iterator_impl {
-
- struct icaltimetype dtstart; /* Hack. Make into time_t */
- struct icaltimetype last; /* last time return from _iterator_next*/
- int occurrence_no; /* number of step made on t iterator */
- struct icalrecurrencetype rule;
-
- short days[366];
- short days_index;
-
- enum byrule byrule;
- short by_indices[9];
- short orig_data[9]; /* 1 if there was data in the byrule */
-
-
- short *by_ptrs[9]; /* Pointers into the by_* array elements of the rule */
-
-};
-
-int icalrecur_iterator_sizeof_byarray(short* byarray)
-{
- int array_itr;
-
- for(array_itr = 0;
- byarray[array_itr] != ICAL_RECURRENCE_ARRAY_MAX;
- array_itr++){
- }
-
- return array_itr;
-}
-
-enum expand_table {
- UNKNOWN = 0,
- CONTRACT = 1,
- EXPAND =2,
- ILLEGAL=3
-};
-
-/* The split map indicates, for a particular interval, wether a BY_*
- rule part expands the number of instances in the occcurrence set or
- contracts it. 1=> contract, 2=>expand, and 3 means the pairing is
- not allowed. */
-struct expand_split_map_struct
-{
- icalrecurrencetype_frequency frequency;
-
- /* Elements of the 'map' array correspond to the BYxxx rules:
- Second,Minute,Hour,Day,Month Day,Year Day,Week No,Month*/
-
- short map[8];
-};
-
-struct expand_split_map_struct expand_map[] =
-{
- {ICAL_SECONDLY_RECURRENCE,{1,1,1,1,1,1,1,1}},
- {ICAL_MINUTELY_RECURRENCE,{2,1,1,1,1,1,1,1}},
- {ICAL_HOURLY_RECURRENCE, {2,2,1,1,1,1,1,1}},
- {ICAL_DAILY_RECURRENCE, {2,2,2,1,1,1,1,1}},
- {ICAL_WEEKLY_RECURRENCE, {2,2,2,2,3,3,1,1}},
- {ICAL_MONTHLY_RECURRENCE, {2,2,2,2,2,3,3,1}},
- {ICAL_YEARLY_RECURRENCE, {2,2,2,2,2,2,2,2}},
- {ICAL_NO_RECURRENCE, {0,0,0,0,0,0,0,0}}
-
-};
-
-
-
-/* Check that the rule has only the two given interday byrule parts. */
-int icalrecur_two_byrule(struct icalrecur_iterator_impl* impl,
- enum byrule one,enum byrule two)
-{
- short test_array[9];
- enum byrule itr;
- int passes = 0;
-
- memset(test_array,0,9);
-
- test_array[one] = 1;
- test_array[two] = 1;
-
- for(itr = BY_DAY; itr != BY_SET_POS; itr++){
-
- if( (test_array[itr] == 0 &&
- impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX
- ) ||
- (test_array[itr] == 1 &&
- impl->by_ptrs[itr][0] == ICAL_RECURRENCE_ARRAY_MAX
- )
- ) {
- /* test failed */
- passes = 0;
- }
- }
-
- return passes;
-
-}
-
-/* Check that the rule has only the one given interdat byrule parts. */
-int icalrecur_one_byrule(struct icalrecur_iterator_impl* impl,enum byrule one)
-{
- int passes = 1;
- enum byrule itr;
-
- for(itr = BY_DAY; itr != BY_SET_POS; itr++){
-
- if ((itr==one && impl->by_ptrs[itr][0] == ICAL_RECURRENCE_ARRAY_MAX) ||
- (itr!=one && impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX)) {
- passes = 0;
- }
- }
-
- return passes;
-}
-
-int count_byrules(struct icalrecur_iterator_impl* impl)
-{
- int count = 0;
- enum byrule itr;
-
- for(itr = BY_DAY; itr <= BY_SET_POS; itr++){
- if(impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX){
- count++;
- }
- }
-
- return count;
-}
-
-
-void setup_defaults(struct icalrecur_iterator_impl* impl,
- enum byrule byrule, icalrecurrencetype_frequency req,
- short deftime, int *timepart)
-{
-
- icalrecurrencetype_frequency freq;
- freq = impl->rule.freq;
-
- /* Re-write the BY rule arrays with data from the DTSTART time so
- we don't have to explicitly deal with DTSTART */
-
- if(impl->by_ptrs[byrule][0] == ICAL_RECURRENCE_ARRAY_MAX &&
- expand_map[freq].map[byrule] != CONTRACT){
- impl->by_ptrs[byrule][0] = deftime;
- }
-
- /* Initialize the first occurence */
- if( freq != req && expand_map[freq].map[byrule] != CONTRACT){
- *timepart = impl->by_ptrs[byrule][0];
- }
-
-
-}
-
-int has_by_data(struct icalrecur_iterator_impl* impl, enum byrule byrule){
-
- return (impl->orig_data[byrule] == 1);
-}
-
-
-int expand_year_days(struct icalrecur_iterator_impl* impl,short year);
-
-
-icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
- struct icaltimetype dtstart)
-{
- struct icalrecur_iterator_impl* impl;
- icalrecurrencetype_frequency freq;
-
- short days_in_month;
-
- if ( ( impl = (struct icalrecur_iterator_impl *)
- malloc(sizeof(struct icalrecur_iterator_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(impl,0,sizeof(struct icalrecur_iterator_impl));
-
- impl->rule = rule;
- impl->last = dtstart;
- impl->dtstart = dtstart;
- impl->days_index =0;
- impl->occurrence_no = 0;
- freq = impl->rule.freq;
-
- /* Set up convienience pointers to make the code simpler. Allows
- us to iterate through all of the BY* arrays in the rule. */
-
- impl->by_ptrs[BY_MONTH]=impl->rule.by_month;
- impl->by_ptrs[BY_WEEK_NO]=impl->rule.by_week_no;
- impl->by_ptrs[BY_YEAR_DAY]=impl->rule.by_year_day;
- impl->by_ptrs[BY_MONTH_DAY]=impl->rule.by_month_day;
- impl->by_ptrs[BY_DAY]=impl->rule.by_day;
- impl->by_ptrs[BY_HOUR]=impl->rule.by_hour;
- impl->by_ptrs[BY_MINUTE]=impl->rule.by_minute;
- impl->by_ptrs[BY_SECOND]=impl->rule.by_second;
- impl->by_ptrs[BY_SET_POS]=impl->rule.by_set_pos;
-
- memset(impl->orig_data,0,9);
-
- /* Note which by rules had data in them when the iterator was
- created. We can't use the actuall by_x arrays, because the
- empty ones will be given default values later in this
- routine. The orig_data array will be used later in has_by_data */
-
- impl->orig_data[BY_MONTH]
- = (impl->rule.by_month[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_WEEK_NO]
- =(impl->rule.by_week_no[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_YEAR_DAY]
- =(impl->rule.by_year_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_MONTH_DAY]
- =(impl->rule.by_month_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_DAY]
- = (impl->rule.by_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_HOUR]
- = (impl->rule.by_hour[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_MINUTE]
- = (impl->rule.by_minute[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_SECOND]
- = (impl->rule.by_second[0]!=ICAL_RECURRENCE_ARRAY_MAX);
- impl->orig_data[BY_SET_POS]
- = (impl->rule.by_set_pos[0]!=ICAL_RECURRENCE_ARRAY_MAX);
-
-
- /* Check if the recurrence rule is legal */
-
- /* If the BYYEARDAY appears, no other date rule part may appear. */
-
- if(icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_MONTH) ||
- icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_WEEK_NO) ||
- icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_MONTH_DAY) ||
- icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_DAY) ){
-
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
-
- return 0;
- }
-
- /* BYWEEKNO and BYMONTH rule parts may not both appear.*/
-
- if(icalrecur_two_byrule(impl,BY_WEEK_NO,BY_MONTH)){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
-
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- /* BYWEEKNO and BYMONTHDAY rule parts may not both appear.*/
-
- if(icalrecur_two_byrule(impl,BY_WEEK_NO,BY_MONTH_DAY)){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
-
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
-
- /*For MONTHLY recurrences (FREQ=MONTHLY) neither BYYEARDAY nor
- BYWEEKNO may appear. */
-
- if(freq == ICAL_MONTHLY_RECURRENCE &&
- icalrecur_one_byrule(impl,BY_WEEK_NO)){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
-
- /*For WEEKLY recurrences (FREQ=WEEKLY) neither BYMONTHDAY nor
- BYYEARDAY may appear. */
-
- if(freq == ICAL_WEEKLY_RECURRENCE &&
- icalrecur_one_byrule(impl,BY_MONTH_DAY )) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- /* BYYEARDAY may only appear in YEARLY rules */
- if(freq != ICAL_YEARLY_RECURRENCE &&
- icalrecur_one_byrule(impl,BY_YEAR_DAY )) {
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- /* Rewrite some of the rules and set up defaults to make later
- processing easier. Primarily, t involves copying an element
- from the start time into the coresponding BY_* array when the
- BY_* array is empty */
-
-
- setup_defaults(impl,BY_SECOND,ICAL_SECONDLY_RECURRENCE,impl->dtstart.second,
- &(impl->last.second));
-
- setup_defaults(impl,BY_MINUTE,ICAL_MINUTELY_RECURRENCE,impl->dtstart.minute,
- &(impl->last.minute));
-
- setup_defaults(impl,BY_HOUR,ICAL_HOURLY_RECURRENCE,impl->dtstart.hour,
- &(impl->last.hour));
-
- setup_defaults(impl,BY_MONTH_DAY,ICAL_DAILY_RECURRENCE,impl->dtstart.day,
- &(impl->last.day));
-
- setup_defaults(impl,BY_MONTH,ICAL_MONTHLY_RECURRENCE,impl->dtstart.month,
- &(impl->last.month));
-
-
- if(impl->rule.freq == ICAL_WEEKLY_RECURRENCE ){
-
- if(impl->by_ptrs[BY_DAY][0] == ICAL_RECURRENCE_ARRAY_MAX){
-
- /* Weekly recurrences with no BY_DAY data should occur on the
- same day of the week as the start time . */
- impl->by_ptrs[BY_DAY][0] = icaltime_day_of_week(impl->dtstart);
-
- } else {
- /* If there is BY_DAY data, then we need to move the initial
- time to the start of the BY_DAY data. That is if the
- start time is on a Wednesday, and the rule has
- BYDAY=MO,WE,FR, move the initial time back to
- monday. Otherwise, jumping to the next week ( jumping 7
- days ahead ) will skip over some occurrences in the
- second week. */
-
- /* This is probably a HACK. There should be some more
- general way to solve this problem */
-
- short dow = impl->by_ptrs[BY_DAY][0]-icaltime_day_of_week(impl->last);
-
- if(dow < 0) {
- /* initial time is after first day of BY_DAY data */
-
- impl->last.day += dow;
- impl->last = icaltime_normalize(impl->last);
- }
- }
-
-
- }
-
- /* For YEARLY rule, begin by setting up the year days array */
-
- if(impl->rule.freq == ICAL_YEARLY_RECURRENCE){
- struct icaltimetype next;
-
- for (;;) {
- expand_year_days(impl,impl->last.year);
- if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX)
- break;
- increment_year(impl,impl->rule.interval);
- }
-
- /* Copy the first day into last. */
- next = icaltime_from_day_of_year(impl->days[0], impl->last.year);
-
- impl->last.day = next.day;
- impl->last.month = next.month;
- }
-
-
- /* If this is a monthly interval with by day data, then we need to
- set the last value to the appropriate day of the month */
-
- if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE &&
- has_by_data(impl,BY_DAY)) {
-
- short dow = icalrecurrencetype_day_day_of_week(
- impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]);
- short pos = icalrecurrencetype_day_position(
- impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]);
-
- short poscount = 0;
- days_in_month =
- icaltime_days_in_month(impl->last.month, impl->last.year);
-
- if(pos >= 0){
- /* Count up from the first day pf the month to find the
- pos'th weekday of dow ( like the second monday. ) */
-
- for(impl->last.day = 1;
- impl->last.day <= days_in_month;
- impl->last.day++){
-
- if(icaltime_day_of_week(impl->last) == dow){
- if(++poscount == pos || pos == 0){
- break;
- }
- }
- }
- } else {
- /* Count down from the last day pf the month to find the
- pos'th weekday of dow ( like the second to last monday. ) */
- pos = -pos;
- for(impl->last.day = days_in_month;
- impl->last.day != 0;
- impl->last.day--){
-
- if(icaltime_day_of_week(impl->last) == dow){
- if(++poscount == pos ){
- break;
- }
- }
- }
- }
-
-
- if(impl->last.day > days_in_month || impl->last.day == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
- }
-
-
-
- return impl;
-}
-
-
-void icalrecur_iterator_free(icalrecur_iterator* i)
-{
-
- struct icalrecur_iterator_impl* impl =
- (struct icalrecur_iterator_impl*)i;
-
- icalerror_check_arg_rv((impl!=0),"impl");
-
- free(impl);
-
-}
-
-
-void increment_year(struct icalrecur_iterator_impl* impl, int inc)
-{
- impl->last.year+=inc;
-}
-
-/* Increment month is different that the other incement_* routines --
- it figures out the interval for itself, and uses BYMONTH data if
- available. */
-void increment_month(struct icalrecur_iterator_impl* impl)
-{
- int years;
-
- if(has_by_data(impl,BY_MONTH) ){
- /* Ignore the frequency and use the byrule data */
-
- impl->by_indices[BY_MONTH]++;
-
- if (impl->by_ptrs[BY_MONTH][impl->by_indices[BY_MONTH]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
- impl->by_indices[BY_MONTH] = 0;
-
- increment_year(impl,1);
-
- }
-
- impl->last.month =
- impl->by_ptrs[BY_MONTH][impl->by_indices[BY_MONTH]];
-
- } else {
-
- int inc;
-
- if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE){
- inc = impl->rule.interval;
- } else {
- inc = 1;
- }
-
- impl->last.month+=inc;
-
- /* Months are offset by one */
- impl->last.month--;
-
- years = impl->last.month / 12;
-
- impl->last.month = impl->last.month % 12;
-
- impl->last.month++;
-
- if (years != 0){
- increment_year(impl,years);
- }
- }
-}
-
-void increment_monthday(struct icalrecur_iterator_impl* impl, int inc)
-{
- int i;
-
- for(i=0; i<inc; i++){
-
- short days_in_month =
- icaltime_days_in_month(impl->last.month,impl->last.year);
-
- impl->last.day++;
-
- if (impl->last.day > days_in_month){
- impl->last.day = impl->last.day-days_in_month;
- increment_month(impl);
- }
- }
-}
-
-
-void increment_hour(struct icalrecur_iterator_impl* impl, int inc)
-{
- short days;
-
- impl->last.hour+=inc;
-
- days = impl->last.hour / 24;
- impl->last.hour = impl->last.hour % 24;
-
- if (impl->days != 0){
- increment_monthday(impl,days);
- }
-}
-
-void increment_minute(struct icalrecur_iterator_impl* impl, int inc)
-{
- short hours;
-
- impl->last.minute+=inc;
-
- hours = impl->last.minute / 60;
- impl->last.minute = impl->last.minute % 60;
-
- if (hours != 0){
- increment_hour(impl,hours);
- }
-
-}
-
-void increment_second(struct icalrecur_iterator_impl* impl, int inc)
-{
- short minutes;
-
- impl->last.second+=inc;
-
- minutes = impl->last.second / 60;
- impl->last.second = impl->last.second % 60;
-
- if (minutes != 0)
- {
- increment_minute(impl, minutes);
- }
-}
-
-#if 0
-#include "ical.h"
-void test_increment()
-{
- struct icalrecur_iterator_impl impl;
-
- impl.last = icaltime_from_string("20000101T000000Z");
-
- printf("Orig: %s\n",icaltime_as_ctime(impl.last));
-
- increment_second(&impl,5);
- printf("+ 5 sec : %s\n",icaltime_as_ctime(impl.last));
-
- increment_second(&impl,355);
- printf("+ 355 sec : %s\n",icaltime_as_ctime(impl.last));
-
- increment_minute(&impl,5);
- printf("+ 5 min : %s\n",icaltime_as_ctime(impl.last));
-
- increment_minute(&impl,360);
- printf("+ 360 min : %s\n",icaltime_as_ctime(impl.last));
- increment_hour(&impl,5);
- printf("+ 5 hours : %s\n",icaltime_as_ctime(impl.last));
- increment_hour(&impl,43);
- printf("+ 43 hours : %s\n",icaltime_as_ctime(impl.last));
- increment_monthday(&impl,3);
- printf("+ 3 days : %s\n",icaltime_as_ctime(impl.last));
- increment_monthday(&impl,600);
- printf("+ 600 days : %s\n",icaltime_as_ctime(impl.last));
-
-}
-
-#endif
-
-short next_second(struct icalrecur_iterator_impl* impl)
-{
-
- short has_by_data = (impl->by_ptrs[BY_SECOND][0]!=ICAL_RECURRENCE_ARRAY_MAX);
- short this_frequency = (impl->rule.freq == ICAL_SECONDLY_RECURRENCE);
-
- short end_of_data = 0;
-
- assert(has_by_data || this_frequency);
-
- if( has_by_data ){
- /* Ignore the frequency and use the byrule data */
-
- impl->by_indices[BY_SECOND]++;
-
- if (impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
- impl->by_indices[BY_SECOND] = 0;
-
- end_of_data = 1;
- }
-
-
- impl->last.second =
- impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]];
-
-
- } else if( !has_by_data && this_frequency ){
- /* Compute the next value from the last time and the frequency interval*/
- increment_second(impl, impl->rule.interval);
-
- }
-
- /* If we have gone through all of the seconds on the BY list, then we
- need to move to the next minute */
-
- if(has_by_data && end_of_data && this_frequency ){
- increment_minute(impl,1);
- }
-
- return end_of_data;
-
-}
-
-int next_minute(struct icalrecur_iterator_impl* impl)
-{
-
- short has_by_data = (impl->by_ptrs[BY_MINUTE][0]!=ICAL_RECURRENCE_ARRAY_MAX);
- short this_frequency = (impl->rule.freq == ICAL_MINUTELY_RECURRENCE);
-
- short end_of_data = 0;
-
- assert(has_by_data || this_frequency);
-
-
- if (next_second(impl) == 0){
- return 0;
- }
-
- if( has_by_data ){
- /* Ignore the frequency and use the byrule data */
-
- impl->by_indices[BY_MINUTE]++;
-
- if (impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
-
- impl->by_indices[BY_MINUTE] = 0;
-
- end_of_data = 1;
- }
-
- impl->last.minute =
- impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]];
-
- } else if( !has_by_data && this_frequency ){
- /* Compute the next value from the last time and the frequency interval*/
- increment_minute(impl,impl->rule.interval);
- }
-
-/* If we have gone through all of the minutes on the BY list, then we
- need to move to the next hour */
-
- if(has_by_data && end_of_data && this_frequency ){
- increment_hour(impl,1);
- }
-
- return end_of_data;
-}
-
-int next_hour(struct icalrecur_iterator_impl* impl)
-{
-
- short has_by_data = (impl->by_ptrs[BY_HOUR][0]!=ICAL_RECURRENCE_ARRAY_MAX);
- short this_frequency = (impl->rule.freq == ICAL_HOURLY_RECURRENCE);
-
- short end_of_data = 0;
-
- assert(has_by_data || this_frequency);
-
- if (next_minute(impl) == 0){
- return 0;
- }
-
- if( has_by_data ){
- /* Ignore the frequency and use the byrule data */
-
- impl->by_indices[BY_HOUR]++;
-
- if (impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
- impl->by_indices[BY_HOUR] = 0;
-
- end_of_data = 1;
- }
-
- impl->last.hour =
- impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]];
-
- } else if( !has_by_data && this_frequency ){
- /* Compute the next value from the last time and the frequency interval*/
- increment_hour(impl,impl->rule.interval);
-
- }
-
- /* If we have gone through all of the hours on the BY list, then we
- need to move to the next day */
-
- if(has_by_data && end_of_data && this_frequency ){
- increment_monthday(impl,1);
- }
-
- return end_of_data;
-
-}
-
-int next_day(struct icalrecur_iterator_impl* impl)
-{
-
- short has_by_data = (impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
- short this_frequency = (impl->rule.freq == ICAL_DAILY_RECURRENCE);
-
- assert(has_by_data || this_frequency);
-
- if (next_hour(impl) == 0){
- return 0;
- }
-
- /* Always increment through the interval, since this routine is not
- called by any other next_* routine, and the days that are
- excluded will be taken care of by restriction filtering */
-
- if(this_frequency){
- increment_monthday(impl,impl->rule.interval);
- } else {
- increment_monthday(impl,1);
- }
-
-
- return 0;
-
-}
-
-
-int next_yearday(struct icalrecur_iterator_impl* impl)
-{
-
- short has_by_data = (impl->by_ptrs[BY_YEAR_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
-
- short end_of_data = 0;
-
- assert(has_by_data );
-
- if (next_hour(impl) == 0){
- return 0;
- }
-
- impl->by_indices[BY_YEAR_DAY]++;
-
- if (impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
- impl->by_indices[BY_YEAR_DAY] = 0;
-
- end_of_data = 1;
- }
-
- impl->last.day =
- impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]];
-
- if(has_by_data && end_of_data){
- increment_year(impl,1);
- }
-
- return end_of_data;
-
-}
-
-/* This routine is only called by next_week. It is certain that BY_DAY
-has data */
-
-int next_weekday_by_week(struct icalrecur_iterator_impl* impl)
-{
-
- short end_of_data = 0;
- short start_of_week, dow;
- struct icaltimetype next;
-
- if (next_hour(impl) == 0){
- return 0;
- }
-
- assert( impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
-
- while(1) {
-
- impl->by_indices[BY_DAY]++; /* Look at next elem in BYDAY array */
-
- /* Are we at the end of the BYDAY array? */
- if (impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
-
- impl->by_indices[BY_DAY] = 0; /* Reset to 0 */
- end_of_data = 1; /* Signal that we're at the end */
- }
-
- /* Add the day of week offset to to the start of this week, and use
- that to get the next day */
- dow = impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]];
- start_of_week = icaltime_start_doy_of_week(impl->last);
-
- dow--; /*Sun is 1, not 0 */
-
- if(dow+start_of_week <1 && !end_of_data){
- /* The selected date is in the previous year. */
- continue;
- }
-
- next = icaltime_from_day_of_year(start_of_week + dow,impl->last.year);
-
- impl->last.day = next.day;
- impl->last.month = next.month;
- impl->last.year = next.year;
-
- return end_of_data;
- }
-
-}
-
-int nth_weekday(short dow, short pos, struct icaltimetype t){
-
- short days_in_month = icaltime_days_in_month(t.month,t.year);
- short end_dow, start_dow;
- short wd;
-
- if(pos >= 0){
- t.day = 1;
- start_dow = icaltime_day_of_week(t);
-
- if (pos != 0) {
- pos--;
- }
-
- /* find month day of first occurrence of dow -- such as the
- month day of the first monday */
-
- wd = dow-start_dow+1;
-
- if (wd <= 0){
- wd = wd + 7;
- }
-
- wd = wd + pos * 7;
-
- } else {
- t.day = days_in_month;
- end_dow = icaltime_day_of_week(t);
-
- pos++;
-
- /* find month day of last occurrence of dow -- such as the
- month day of the last monday */
-
- wd = (end_dow - dow);
-
- if (wd < 0){
- wd = wd+ 7;
- }
-
- wd = days_in_month - wd;
-
- wd = wd + pos * 7;
- }
-
- return wd;
-}
-
-
-int next_month(struct icalrecur_iterator_impl* impl)
-{
- int data_valid = 1;
-
- short this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE);
-
- assert( has_by_data(impl,BY_MONTH) || this_frequency);
-
- /* Iterate through the occurrences within a day. If we don't get to
- the end of the intra-day data, don't bother going to the next
- month */
-
- if (next_hour(impl) == 0){
- return data_valid; /* Signal that the data is valid */
- }
-
-
- /* Now iterate through the occurrences within a month -- by days,
- weeks or weekdays. */
-
- if(has_by_data(impl,BY_DAY) && has_by_data(impl,BY_MONTH_DAY)){
- /* Cases like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=13 */
- short day, idx,j;
- short days_in_month = icaltime_days_in_month(impl->last.month,
- impl->last.year);
- /* Iterate through the remaining days in the month and check if
- each day is listed in the BY_DAY array and in the BY_MONTHDAY
- array. This seems very inneficient, but I think it is the
- simplest way to account for both BYDAY=1FR (First friday in
- month) and BYDAY=FR ( every friday in month ) */
-
- for(day = impl->last.day+1; day <= days_in_month; day++){
- for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){
- for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
- short dow =
- icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]);
- short pos = icalrecurrencetype_day_position(BYDAYPTR[idx]);
- short mday = BYMDPTR[j];
- short this_dow;
-
- impl->last.day = day;
- this_dow = icaltime_day_of_week(impl->last);
-
- if( (pos == 0 && dow == this_dow && mday == day) ||
- (nth_weekday(dow,pos,impl->last) == day && mday==day)){
- goto MDEND;
- }
- }
- }
- }
-
- MDEND:
-
- if ( day > days_in_month){
- impl->last.day = 1;
- increment_month(impl);
- data_valid = 0; /* signal that impl->last is invalid */
- }
-
-
- } else if(has_by_data(impl,BY_DAY)){
- /* Cases like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR */
- /* For this case, the weekdays are relative to the
- month. BYDAY=FR -> First Friday in month, etc. */
-
- short day, idx;
- short days_in_month = icaltime_days_in_month(impl->last.month,
- impl->last.year);
-
- assert( BYDAYPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
-
- /* Iterate through the remaining days in the month and check if
- each day is listed in the BY_DAY array. This seems very
- inneficient, but I think it is the simplest way to account
- for both BYDAY=1FR (First friday in month) and BYDAY=FR (
- every friday in month ) */
-
- for(day = impl->last.day+1; day <= days_in_month; day++){
- for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){
- short dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]);
- short pos = icalrecurrencetype_day_position(BYDAYPTR[idx]);
- short this_dow;
-
- impl->last.day = day;
- this_dow = icaltime_day_of_week(impl->last);
-
- if( (pos == 0 && dow == this_dow ) ||
- (nth_weekday(dow,pos,impl->last) == day)){
- goto DEND;
- }
- }
- }
-
- DEND:
-
- if ( day > days_in_month){
- impl->last.day = 1;
- increment_month(impl);
- data_valid = 0; /* signal that impl->last is invalid */
- }
-
- } else if (has_by_data(impl,BY_MONTH_DAY)) {
- /* Cases like: FREQ=MONTHLY;COUNT=10;BYMONTHDAY=-3 */
- short day;
-
- assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
-
- BYMDIDX++;
-
- /* Are we at the end of the BYDAY array? */
- if (BYMDPTR[BYMDIDX] ==ICAL_RECURRENCE_ARRAY_MAX){
-
- BYMDIDX = 0; /* Reset to 0 */
- increment_month(impl);
- }
-
- day = BYMDPTR[BYMDIDX];
-
- if (day < 0) {
- day = icaltime_days_in_month(impl->last.month,impl->last.year)+
- day + 1;
- }
-
- impl->last.day = day;
-
- } else {
- increment_month(impl);
- }
-
- return data_valid; /* Signal that the data is valid */
-
-}
-
-
-int next_week(struct icalrecur_iterator_impl* impl)
-{
- short has_by_data = (impl->by_ptrs[BY_WEEK_NO][0]!=ICAL_RECURRENCE_ARRAY_MAX);
- short this_frequency = (impl->rule.freq == ICAL_WEEKLY_RECURRENCE);
- short end_of_data = 0;
-
-
- /* Increment to the next week day */
- if (next_weekday_by_week(impl) == 0){
- return 0; /* Have not reached end of week yet */
- }
-
- /* If we get here, we have incremented through the entire week, and
- can increment to the next week */
-
-
- if( has_by_data){
- /* Use the Week Number byrule data */
- int week_no;
- struct icaltimetype t;
-
- impl->by_indices[BY_WEEK_NO]++;
-
- if (impl->by_ptrs[BY_WEEK_NO][impl->by_indices[BY_WEEK_NO]]
- ==ICAL_RECURRENCE_ARRAY_MAX){
- impl->by_indices[BY_WEEK_NO] = 0;
-
- end_of_data = 1;
- }
-
- t = impl->last;
- t.month=1; /* HACK, should be setting to the date of the first week of year*/
- t.day=1;
-
- week_no = impl->by_ptrs[BY_WEEK_NO][impl->by_indices[BY_WEEK_NO]];
-
- impl->last.day += week_no*7;
-
- impl->last = icaltime_normalize(impl->last);
-
- } else if( !has_by_data && this_frequency ){
- /* If there is no BY_WEEK_NO data, just jump forward 7 days. */
- increment_monthday(impl,7*impl->rule.interval);
- }
-
-
- if(has_by_data && end_of_data && this_frequency ){
- increment_year(impl,1);
- }
-
- return end_of_data;
-
-}
-
-
-/* Expand the BYDAY rule part and return a pointer to a newly allocated list of days. */
-pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
-{
- /* Try to calculate each of the occurrences. */
- int i;
- pvl_list days_list = pvl_newlist();
-
- short start_dow, end_dow, end_year_day;
- struct icaltimetype tmp = impl->last;
-
- tmp.year= year;
- tmp.month = 1;
- tmp.day = 1;
- tmp.is_date = 1;
-
- /* Find the day that 1st Jan falls on, 1 (Sun) to 7 (Sat). */
- start_dow = icaltime_day_of_week(tmp);
-
- /* Get the last day of the year*/
- tmp.year= year;
- tmp.month = 12;
- tmp.day = 31;
- tmp.is_date = 1;
-
- end_dow = icaltime_day_of_week(tmp);
- end_year_day = icaltime_day_of_year(tmp);
-
- for(i = 0; BYDAYPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
- /* This is 1 (Sun) to 7 (Sat). */
- short dow =
- icalrecurrencetype_day_day_of_week(BYDAYPTR[i]);
- short pos = icalrecurrencetype_day_position(BYDAYPTR[i]);
-
- if(pos == 0){
- /* The day was specified without a position -- it is just
- a bare day of the week ( BYDAY=SU) so add all of the
- days of the year with this day-of-week*/
- int doy, tmp_start_doy;
-
- tmp_start_doy = ((dow + 7 - start_dow) % 7) + 1;
-
- for (doy = tmp_start_doy; doy <= end_year_day; doy += 7)
- pvl_push(days_list,(void*)(int)doy);
-
- } else if ( pos > 0) {
- int first;
- /* First occurrence of dow in year */
- if( dow >= start_dow) {
- first = dow - start_dow + 1;
- } else {
- first = dow - start_dow + 8;
- }
-
- pvl_push(days_list,(void*)(first+ (pos-1) * 7));
-
- } else { /* pos < 0 */
- icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
- }
- }
-
- return days_list;
-}
-
-
-/* For INTERVAL=YEARLY, set up the days[] array in the iterator to
- list all of the days of the current year that are specified in this
- rule. */
-
-int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
-{
- int j,k;
- int days_index=0;
- struct icaltimetype t;
- int flags;
-
- t = icaltime_null_time();
-
-#define HBD(x) has_by_data(impl,x)
-
- t.is_date = 1; /* Needed to make day_of_year routines work property */
-
- memset(&t,0,sizeof(t));
- memset(impl->days,ICAL_RECURRENCE_ARRAY_MAX_BYTE,sizeof(impl->days));
-
- flags = (HBD(BY_DAY) ? 1<<BY_DAY : 0) +
- (HBD(BY_WEEK_NO) ? 1<<BY_WEEK_NO : 0) +
- (HBD(BY_MONTH_DAY) ? 1<<BY_MONTH_DAY : 0) +
- (HBD(BY_MONTH) ? 1<<BY_MONTH : 0) +
- (HBD(BY_YEAR_DAY) ? 1<<BY_YEAR_DAY : 0);
-
-
- switch(flags) {
-
- case 0: {
- /* FREQ=YEARLY; */
-
- break;
- }
- case 1<<BY_MONTH: {
- /* FREQ=YEARLY; BYMONTH=3,11*/
-
- for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
- struct icaltimetype t;
- short month = impl->by_ptrs[BY_MONTH][j];
- short doy;
-
- t = impl->dtstart;
- t.year = year;
- t.month = month;
- t.is_date = 1;
-
- doy = icaltime_day_of_year(t);
-
- impl->days[days_index++] = doy;
-
- }
- break;
- }
-
- case 1<<BY_MONTH_DAY: {
- /* FREQ=YEARLY; BYMONTHDAY=1,15*/
- for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++)
- {
- short month_day = impl->by_ptrs[BY_MONTH_DAY][k];
- short doy;
-
- t = impl->dtstart;
- t.day = month_day;
- t.year = year;
- t.is_date = 1;
-
- doy = icaltime_day_of_year(t);
-
- impl->days[days_index++] = doy;
-
- }
- break;
- }
-
- case (1<<BY_MONTH_DAY) + (1<<BY_MONTH): {
- /* FREQ=YEARLY; BYMONTHDAY=1,15; BYMONTH=10 */
-
- for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
- for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++)
- {
- short month = impl->by_ptrs[BY_MONTH][j];
- short month_day = impl->by_ptrs[BY_MONTH_DAY][k];
- short doy;
-
- t.day = month_day;
- t.month = month;
- t.year = year;
- t.is_date = 1;
-
- doy = icaltime_day_of_year(t);
- impl->days[days_index++] = doy;
-
- }
- }
-
- break;
- }
-
- case 1<<BY_WEEK_NO: {
- /* FREQ=YEARLY; BYWEEKNO=20,50 */
-
- struct icaltimetype t;
- short dow;
-
- t.day = impl->dtstart.day;
- t.month = impl->dtstart.month;
- t.year = year;
- t.is_date = 1;
-
- dow = icaltime_day_of_week(t);
- /* HACK Not finished */
-
- icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
-
- break;
- }
-
- case (1<<BY_WEEK_NO) + (1<<BY_MONTH_DAY): {
- /*FREQ=YEARLY; WEEKNO=20,50; BYMONTH= 6,11 */
- icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
- break;
- }
-
- case 1<<BY_DAY: {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR*/
- int days_index = 0;
- pvl_elem i;
- pvl_list days = expand_by_day(impl,year);
-
-
- for(i=pvl_head(days);i!=0;i=pvl_next(i)){
- short day = (short)(int)pvl_data(i);
- impl->days[days_index++] = day;
- }
-
- pvl_free(days);
-
- break;
- }
-
- case (1<<BY_DAY)+(1<<BY_MONTH): {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTH = 12*/
-
-
- for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
- short month = impl->by_ptrs[BY_MONTH][j];
- short days_in_month = icaltime_days_in_month(month,year);
- short first_dow, last_dow, doy_offset;
-
- struct icaltimetype t;
- memset(&t,0,sizeof(struct icaltimetype));
- t.year = year;
- t.month = month;
- t.day = 1;
- t.is_date = 1;
-
- first_dow = icaltime_day_of_week(t);
-
- /* This holds the day offset used to calculate the day of the year
- from the month day. Just add the month day to this. */
- doy_offset = icaltime_day_of_year(t) - 1;
-
- t.day = days_in_month;
- last_dow = icaltime_day_of_week(t);
-
- for(k=0;impl->by_ptrs[BY_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++){
- short day_coded = impl->by_ptrs[BY_DAY][k];
- enum icalrecurrencetype_weekday dow =
- icalrecurrencetype_day_day_of_week(day_coded);
- short pos = icalrecurrencetype_day_position(day_coded);
- short first_matching_day, last_matching_day, day, month_day;
-
- /* Calculate the first day in the month with the given weekday,
- and the last day. */
- first_matching_day = ((dow + 7 - first_dow) % 7) + 1;
- last_matching_day = days_in_month - ((last_dow + 7 - dow) % 7);
-
- if (pos == 0) {
- /* Add all of instances of the weekday within the month. */
- for (day = first_matching_day; day <= days_in_month; day += 7)
- impl->days[days_index++] = doy_offset + day;
-
- } else if (pos > 0) {
- /* Add the nth instance of the weekday within the month. */
- month_day = first_matching_day + (pos - 1) * 7;
-
- if (month_day <= days_in_month)
- impl->days[days_index++] = doy_offset + month_day;
-
- } else {
- /* Add the -nth instance of the weekday within the month.*/
- month_day = last_matching_day + (pos + 1) * 7;
-
- if (month_day > 0)
- impl->days[days_index++] = doy_offset + month_day;
- }
- }
- }
- break;
- }
-
- case (1<<BY_DAY) + (1<<BY_MONTH_DAY) : {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=1,15*/
-
- int days_index = 0;
- pvl_elem itr;
- pvl_list days = expand_by_day(impl,year);
-
- for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
- short day = (short)(int)pvl_data(itr);
- struct icaltimetype tt;
- short i,j;
-
- tt = icaltime_from_day_of_year(day,year);
-
- for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
- short mday = BYMDPTR[j];
-
- if(tt.day == mday){
- impl->days[days_index++] = day;
- }
- }
-
- }
-
- pvl_free(days);
-
- break;
- }
-
- case (1<<BY_DAY) + (1<<BY_MONTH_DAY) + (1<<BY_MONTH): {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=10; MYMONTH=6,11*/
-
- int days_index = 0;
- pvl_elem itr;
- pvl_list days = expand_by_day(impl,year);
-
- for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
- short day = (short)(int)pvl_data(itr);
- struct icaltimetype tt;
- short i,j;
-
- tt = icaltime_from_day_of_year(day,year);
-
- for(i = 0; BYMONPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
- for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
- short mday = BYMDPTR[j];
- short month = BYMONPTR[i];
-
- if(tt.month == month && tt.day == mday){
- impl->days[days_index++] = day;
- }
- }
- }
-
- }
-
- pvl_free(days);
-
- break;
-
- }
-
- case (1<<BY_DAY) + (1<<BY_WEEK_NO) : {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; WEEKNO=20,50*/
-
- int days_index = 0;
- pvl_elem itr;
- pvl_list days = expand_by_day(impl,year);
-
- for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
- short day = (short)(int)pvl_data(itr);
- struct icaltimetype tt;
- short i;
-
- tt = icaltime_from_day_of_year(day,year);
-
- for(i = 0; BYWEEKPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
- short weekno = BYWEEKPTR[i];
-
- if(weekno== icaltime_week_number(tt)){
- impl->days[days_index++] = day;
- }
- }
-
- }
-
- pvl_free(days);
- break;
- }
-
- case (1<<BY_DAY) + (1<<BY_WEEK_NO) + (1<<BY_MONTH_DAY): {
- /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; WEEKNO=20,50; BYMONTHDAY=1,15*/
- icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
- break;
- }
-
- case 1<<BY_YEAR_DAY: {
- for(j=0;impl->by_ptrs[BY_YEAR_DAY][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
- short doy = impl->by_ptrs[BY_YEAR_DAY][j];
- impl->days[days_index++] = doy;
- }
- break;
- }
-
- default: {
- icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
- break;
- }
-
- }
-
- return 0;
-}
-
-
-int next_year(struct icalrecur_iterator_impl* impl)
-{
- struct icaltimetype next;
-
- if (next_hour(impl) == 0){
- return 0;
- }
-
- if (impl->days[++impl->days_index] == ICAL_RECURRENCE_ARRAY_MAX){
- impl->days_index = 0;
-
- for (;;) {
- increment_year(impl,impl->rule.interval);
- expand_year_days(impl,impl->last.year);
- if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX)
- break;
- }
- }
-
- next = icaltime_from_day_of_year(impl->days[impl->days_index],impl->last.year);
-
- impl->last.day = next.day;
- impl->last.month = next.month;
-
- return 1;
-}
-
-int icalrecur_check_rulepart(struct icalrecur_iterator_impl* impl,
- short v, enum byrule byrule)
-{
- int itr;
-
- if(impl->by_ptrs[byrule][0]!=ICAL_RECURRENCE_ARRAY_MAX){
- for(itr=0; impl->by_ptrs[byrule][itr]!=ICAL_RECURRENCE_ARRAY_MAX;itr++){
- if(impl->by_ptrs[byrule][itr] == v){
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-int check_contract_restriction(struct icalrecur_iterator_impl* impl,
- enum byrule byrule, short v)
-{
- int pass = 0;
- int itr;
- icalrecurrencetype_frequency freq = impl->rule.freq;
-
- if(impl->by_ptrs[byrule][0]!=ICAL_RECURRENCE_ARRAY_MAX &&
- expand_map[freq].map[byrule] == CONTRACT){
- for(itr=0; impl->by_ptrs[byrule][itr]!=ICAL_RECURRENCE_ARRAY_MAX;itr++){
- if(impl->by_ptrs[byrule][itr] == v){
- pass=1;
- break;
- }
- }
-
- return pass;
- } else {
- /* This is not a contracting byrule, or it has no data, so the
- test passes*/
- return 1;
- }
-}
-
-
-int check_contracting_rules(struct icalrecur_iterator_impl* impl)
-{
-
- int day_of_week=0;
- int week_no=0;
- int year_day=0;
-
- if (
- check_contract_restriction(impl,BY_SECOND,impl->last.second) &&
- check_contract_restriction(impl,BY_MINUTE,impl->last.minute) &&
- check_contract_restriction(impl,BY_HOUR,impl->last.hour) &&
- check_contract_restriction(impl,BY_DAY,day_of_week) &&
- check_contract_restriction(impl,BY_WEEK_NO,week_no) &&
- check_contract_restriction(impl,BY_MONTH_DAY,impl->last.day) &&
- check_contract_restriction(impl,BY_MONTH,impl->last.month) &&
- check_contract_restriction(impl,BY_YEAR_DAY,year_day) )
- {
-
- return 1;
- } else {
- return 0;
- }
-}
-
-struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr)
-{
- int valid = 1;
- struct icalrecur_iterator_impl* impl =
- (struct icalrecur_iterator_impl*)itr;
-
- if( (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) ||
- (!icaltime_is_null_time(impl->rule.until) &&
- icaltime_compare(impl->last,impl->rule.until) > 0)) {
- return icaltime_null_time();
- }
-
- if(impl->occurrence_no == 0
- && icaltime_compare(impl->last,impl->dtstart) >= 0){
-
- impl->occurrence_no++;
- return impl->last;
- }
-
- do {
- valid = 1;
- switch(impl->rule.freq){
-
- case ICAL_SECONDLY_RECURRENCE: {
- next_second(impl);
- break;
- }
- case ICAL_MINUTELY_RECURRENCE: {
- next_minute(impl);
- break;
- }
- case ICAL_HOURLY_RECURRENCE: {
- next_hour(impl);
- break;
- }
- case ICAL_DAILY_RECURRENCE: {
- next_day(impl);
- break;
- }
- case ICAL_WEEKLY_RECURRENCE: {
- next_week(impl);
- break;
- }
- case ICAL_MONTHLY_RECURRENCE: {
- valid = next_month(impl);
- break;
- }
- case ICAL_YEARLY_RECURRENCE:{
- next_year(impl);
- break;
- }
- default:{
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return icaltime_null_time();
- }
- }
-
- if(impl->last.year >= 2038 ){
- /* HACK */
- return icaltime_null_time();
- }
-
- } while(!check_contracting_rules(impl)
- || icaltime_compare(impl->last,impl->dtstart) < 0
- || valid == 0);
-
-
-/* Ignore null times and times that are after the until time */
- if( !icaltime_is_null_time(impl->rule.until) &&
- icaltime_compare(impl->last,impl->rule.until) > 0 ) {
- return icaltime_null_time();
- }
-
- impl->occurrence_no++;
-
- return impl->last;
-}
-
-
-/************************** Type Routines **********************/
-
-
-void icalrecurrencetype_clear(struct icalrecurrencetype *recur)
-{
- memset(recur,ICAL_RECURRENCE_ARRAY_MAX_BYTE,
- sizeof(struct icalrecurrencetype));
-
- recur->week_start = ICAL_MONDAY_WEEKDAY;
- recur->freq = ICAL_NO_RECURRENCE;
- recur->interval = 1;
- memset(&(recur->until),0,sizeof(struct icaltimetype));
- recur->count = 0;
-}
-
-/* The 'day' element of icalrecurrencetype_weekday is encoded to allow
-reporesentation of both the day of the week ( Monday, Tueday), but
-also the Nth day of the week ( First tuesday of the month, last
-thursday of the year) These routines decode the day values.
-
-The day's position in the period ( Nth-ness) and the numerical value
-of the day are encoded together as: pos*7 + dow
-
-A position of 0 means 'any' or 'every'
-
- */
-
-enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
-{
- return abs(day)%8;
-}
-
-short icalrecurrencetype_day_position(short day)
-{
- short wd, pos;
-
- wd = icalrecurrencetype_day_day_of_week(day);
-
- pos = (abs(day)-wd)/8 * ((day<0)?-1:1);
-
-
- return pos;
-}
-
-
-/****************** Enumeration Routines ******************/
-
-struct {icalrecurrencetype_weekday wd; const char * str; }
-wd_map[] = {
- {ICAL_SUNDAY_WEEKDAY,"SU"},
- {ICAL_MONDAY_WEEKDAY,"MO"},
- {ICAL_TUESDAY_WEEKDAY,"TU"},
- {ICAL_WEDNESDAY_WEEKDAY,"WE"},
- {ICAL_THURSDAY_WEEKDAY,"TH"},
- {ICAL_FRIDAY_WEEKDAY,"FR"},
- {ICAL_SATURDAY_WEEKDAY,"SA"},
- {ICAL_NO_WEEKDAY,0}
-};
-
-const char* icalrecur_weekday_to_string(icalrecurrencetype_weekday kind)
-{
- int i;
-
- for (i=0; wd_map[i].wd != ICAL_NO_WEEKDAY; i++) {
- if ( wd_map[i].wd == kind) {
- return wd_map[i].str;
- }
- }
-
- return 0;
-}
-
-icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str)
-{
- int i;
-
- for (i=0; wd_map[i].wd != ICAL_NO_WEEKDAY; i++) {
- if ( strcmp(str,wd_map[i].str) == 0){
- return wd_map[i].wd;
- }
- }
-
- return ICAL_NO_WEEKDAY;
-}
-
-
-
-struct {
- icalrecurrencetype_frequency kind;
- const char* str;
-} freq_map[] = {
- {ICAL_SECONDLY_RECURRENCE,"SECONDLY"},
- {ICAL_MINUTELY_RECURRENCE,"MINUTELY"},
- {ICAL_HOURLY_RECURRENCE,"HOURLY"},
- {ICAL_DAILY_RECURRENCE,"DAILY"},
- {ICAL_WEEKLY_RECURRENCE,"WEEKLY"},
- {ICAL_MONTHLY_RECURRENCE,"MONTHLY"},
- {ICAL_YEARLY_RECURRENCE,"YEARLY"},
- {ICAL_NO_RECURRENCE,0}
-};
-
-const char* icalrecur_freq_to_string(icalrecurrencetype_frequency kind)
-{
- int i;
-
- for (i=0; freq_map[i].kind != ICAL_NO_RECURRENCE ; i++) {
- if ( freq_map[i].kind == kind ) {
- return freq_map[i].str;
- }
- }
- return 0;
-}
-
-icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str)
-{
- int i;
-
- for (i=0; freq_map[i].kind != ICAL_NO_RECURRENCE ; i++) {
- if ( strcmp(str,freq_map[i].str) == 0){
- return freq_map[i].kind;
- }
- }
- return ICAL_NO_RECURRENCE;
-}
-
-/* Fill an array with the 'count' number of occurrences generated by
- the rrule. Note that the times are returned in UTC, but the times
- are calculated in local time. YOu will have to convert the results
- back into local time before using them. */
-
-int icalrecur_expand_recurrence(char* rule, time_t start,
- int count, time_t* array)
-{
- struct icalrecurrencetype recur;
- icalrecur_iterator* ritr;
- time_t tt;
- struct icaltimetype icstart, next;
- int i = 0;
-
- memset(array, 0, count*sizeof(time_t));
-
- icstart = icaltime_from_timet(start,0);
-
- recur = icalrecurrencetype_from_string(rule);
-
- for(ritr = icalrecur_iterator_new(recur,icstart),
- next = icalrecur_iterator_next(ritr);
- !icaltime_is_null_time(next) && i < count;
- next = icalrecur_iterator_next(ritr)){
-
- tt = icaltime_as_timet(next);
-
- if (tt >= start ){
- array[i++] = tt;
- }
-
- }
-
- icalrecur_iterator_free(ritr);
-
- return 1;
-}
diff --git a/libical/src/libical/icalrecur.h b/libical/src/libical/icalrecur.h
deleted file mode 100644
index 5fcdc15a8c..0000000000
--- a/libical/src/libical/icalrecur.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalrecur.h
- CREATOR: eric 20 March 2000
-
-
- (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/
-
-How to use:
-
-1) Get a rule and a start time from a component
- icalproperty rrule;
- struct icalrecurrencetype recur;
- struct icaltimetype dtstart;
-
- rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY);
- recur = icalproperty_get_rrule(rrule);
- start = icalproperty_get_dtstart(dtstart);
-
-Or, just make them up:
- recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE");
- dtstart = icaltime_from_string("19970101T123000")
-
-2) Create an iterator
- icalrecur_iterator* ritr;
- ritr = icalrecur_iterator_new(recur,start);
-
-3) Iterator over the occurrences
- struct icaltimetype next;
- while (next = icalrecur_iterator_next(ritr)
- && !icaltime_is_null_time(next){
- Do something with next
- }
-
-Note that that the time returned by icalrecur_iterator_next is in
-whatever timezone that dtstart is in.
-
-======================================================================*/
-
-#ifndef ICALRECUR_H
-#define ICALRECUR_H
-
-#include <time.h>
-#include "icaltime.h"
-
-/***********************************************************************
- * Recurrance enumerations
-**********************************************************************/
-
-typedef enum icalrecurrencetype_frequency
-{
- /* These enums are used to index an array, so don't change the
- order or the integers */
-
- ICAL_SECONDLY_RECURRENCE=0,
- ICAL_MINUTELY_RECURRENCE=1,
- ICAL_HOURLY_RECURRENCE=2,
- ICAL_DAILY_RECURRENCE=3,
- ICAL_WEEKLY_RECURRENCE=4,
- ICAL_MONTHLY_RECURRENCE=5,
- ICAL_YEARLY_RECURRENCE=6,
- ICAL_NO_RECURRENCE=7
-
-} icalrecurrencetype_frequency;
-
-typedef enum icalrecurrencetype_weekday
-{
- ICAL_NO_WEEKDAY,
- ICAL_SUNDAY_WEEKDAY,
- ICAL_MONDAY_WEEKDAY,
- ICAL_TUESDAY_WEEKDAY,
- ICAL_WEDNESDAY_WEEKDAY,
- ICAL_THURSDAY_WEEKDAY,
- ICAL_FRIDAY_WEEKDAY,
- ICAL_SATURDAY_WEEKDAY
-} icalrecurrencetype_weekday;
-
-enum {
- ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f,
- ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f
-};
-
-
-
-/********************** Recurrence type routines **************/
-
-/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of
- the values and fields in struct icalrecurrencetype */
-
-#define ICAL_BY_SECOND_SIZE 61
-#define ICAL_BY_MINUTE_SIZE 61
-#define ICAL_BY_HOUR_SIZE 25
-#define ICAL_BY_DAY_SIZE 364 /* 7 days * 52 weeks */
-#define ICAL_BY_MONTHDAY_SIZE 32
-#define ICAL_BY_YEARDAY_SIZE 367
-#define ICAL_BY_WEEKNO_SIZE 54
-#define ICAL_BY_MONTH_SIZE 13
-#define ICAL_BY_SETPOS_SIZE 367
-
-/* Main struct for holding digested recurrence rules */
-struct icalrecurrencetype
-{
- icalrecurrencetype_frequency freq;
-
-
- /* until and count are mutually exclusive. */
- struct icaltimetype until;
- int count;
-
- short interval;
-
- icalrecurrencetype_weekday week_start;
-
- /* The BY* parameters can each take a list of values. Here I
- * assume that the list of values will not be larger than the
- * range of the value -- that is, the client will not name a
- * value more than once.
-
- * Each of the lists is terminated with the value
- * ICAL_RECURRENCE_ARRAY_MAX unless the the list is full.
- */
-
- short by_second[ICAL_BY_SECOND_SIZE];
- short by_minute[ICAL_BY_MINUTE_SIZE];
- short by_hour[ICAL_BY_HOUR_SIZE];
- short by_day[ICAL_BY_DAY_SIZE]; /* Encoded value, see below */
- short by_month_day[ICAL_BY_MONTHDAY_SIZE];
- short by_year_day[ ICAL_BY_YEARDAY_SIZE];
- short by_week_no[ICAL_BY_WEEKNO_SIZE];
- short by_month[ICAL_BY_MONTH_SIZE];
- short by_set_pos[ICAL_BY_SETPOS_SIZE];
-};
-
-
-void icalrecurrencetype_clear(struct icalrecurrencetype *r);
-
-/* The 'day' element of the by_day array is encoded to allow
-representation of both the day of the week ( Monday, Tueday), but also
-the Nth day of the week ( First tuesday of the month, last thursday of
-the year) These routines decode the day values */
-
-/* 1 == Monday, etc. */
-enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
-
-/* 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */
-short icalrecurrencetype_day_position(short day);
-
-
-/***********************************************************************
- * Recurrance rule parser
-**********************************************************************/
-
-/* Convert between strings ans recurrencetype structures. */
-struct icalrecurrencetype icalrecurrencetype_from_string(const char* str);
-char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
-
-
-/********** recurrence iteration routines ********************/
-
-typedef void icalrecur_iterator;
-
-/* Create a new recurrence rule iterator */
-icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
- struct icaltimetype dtstart);
-
-/* Get the next occurrence from an iterator */
-struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*);
-
-/* Free the iterator */
-void icalrecur_iterator_free(icalrecur_iterator*);
-
-/* Fills array up with at most 'count' time_t values, each
- representing an occurrence time in seconds past the POSIX epoch */
-int icalrecur_expand_recurrence(char* rule, time_t start,
- int count, time_t* array);
-
-
-#endif
diff --git a/libical/src/libical/icalrestriction.c.in b/libical/src/libical/icalrestriction.c.in
deleted file mode 100644
index 454442531f..0000000000
--- a/libical/src/libical/icalrestriction.c.in
+++ /dev/null
@@ -1,447 +0,0 @@
-/* -*- 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/icalrestriction.h b/libical/src/libical/icalrestriction.h
deleted file mode 100644
index 6d414db4af..0000000000
--- a/libical/src/libical/icalrestriction.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalrestriction.h
- CREATOR: eric 24 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 icalrestriction.h
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
-
-======================================================================*/
-
-#include "icalproperty.h"
-#include "icalcomponent.h"
-
-#ifndef ICALRESTRICTION_H
-#define ICALRESTRICTION_H
-
-/* These must stay in this order for icalrestriction_compare to work */
-typedef enum icalrestriction_kind {
- ICAL_RESTRICTION_NONE=0, /* 0 */
- ICAL_RESTRICTION_ZERO, /* 1 */
- ICAL_RESTRICTION_ONE, /* 2 */
- ICAL_RESTRICTION_ZEROPLUS, /* 3 */
- ICAL_RESTRICTION_ONEPLUS, /* 4 */
- ICAL_RESTRICTION_ZEROORONE, /* 5 */
- ICAL_RESTRICTION_ONEEXCLUSIVE, /* 6 */
- ICAL_RESTRICTION_ONEMUTUAL, /* 7 */
- ICAL_RESTRICTION_UNKNOWN /* 8 */
-} icalrestriction_kind;
-
-int
-icalrestriction_compare(icalrestriction_kind restr, int count);
-
-
-int
-icalrestriction_is_parameter_allowed(icalproperty_kind property,
- icalparameter_kind parameter);
-
-int icalrestriction_check(icalcomponent* comp);
-
-
-#endif /* !ICALRESTRICTION_H */
-
-
-
diff --git a/libical/src/libical/icaltime.c b/libical/src/libical/icaltime.c
deleted file mode 100644
index 698035537b..0000000000
--- a/libical/src/libical/icaltime.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icaltime.c
- CREATOR: eric 02 June 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
-
-#include "icaltime.h"
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef ICAL_NO_LIBICAL
-#define icalerror_set_errno(x)
-#define icalerror_check_arg_rv(x,y)
-#define icalerror_check_arg_re(x,y,z)
-#else
-#include "icalerror.h"
-#include "icalmemory.h"
-#endif
-
-#include "icaltimezone.h"
-
-
-struct icaltimetype
-icaltime_from_timet(time_t tm, int is_date)
-{
- struct icaltimetype tt = icaltime_null_time();
- struct tm t;
-
- t = *(gmtime(&tm));
-
- if(is_date == 0){
- tt.second = t.tm_sec;
- tt.minute = t.tm_min;
- tt.hour = t.tm_hour;
- } else {
- tt.second = tt.minute =tt.hour = 0 ;
- }
-
- tt.day = t.tm_mday;
- tt.month = t.tm_mon + 1;
- tt.year = t.tm_year+ 1900;
-
- tt.is_utc = 1;
- tt.is_date = is_date;
-
- return tt;
-}
-
-struct icaltimetype
-icaltime_from_timet_with_zone(time_t tm, int is_date, icaltimezone *zone)
-{
- struct icaltimetype tt;
- struct tm t;
- icaltimezone *utc_zone;
-
- utc_zone = icaltimezone_get_utc_timezone ();
-
- /* Convert the time_t to a struct tm in UTC time. We can trust gmtime
- for this. */
- t = *(gmtime(&tm));
-
- tt.year = t.tm_year + 1900;
- tt.month = t.tm_mon + 1;
- tt.day = t.tm_mday;
-
- tt.is_utc = (zone == utc_zone) ? 1 : 0;
- tt.is_date = is_date;
- tt.is_daylight = 0;
- tt.zone = NULL;
-
- if (is_date) {
- /* We don't convert DATE values between timezones. */
- tt.hour = 0;
- tt.minute = 0;
- tt.second = 0;
- } else {
- tt.hour = t.tm_hour;
- tt.minute = t.tm_min;
- tt.second = t.tm_sec;
-
- /* Use our timezone functions to convert to the required timezone. */
- icaltimezone_convert_time (&tt, utc_zone, zone);
- }
-
- return tt;
-}
-
-/* Returns the current time in the given timezone, as an icaltimetype. */
-struct icaltimetype icaltime_current_time_with_zone(icaltimezone *zone)
-{
- return icaltime_from_timet_with_zone (time (NULL), 0, zone);
-}
-
-/* Returns the current day as an icaltimetype, with is_date set. */
-struct icaltimetype icaltime_today(void)
-{
- return icaltime_from_timet_with_zone (time (NULL), 1, NULL);
-}
-
-
-/* Structure used by set_tz to hold an old value of TZ, and the new
- value, which is in memory we will have to free in unset_tz */
-/* This will hold the last "TZ=XXX" string we used with putenv(). After we
- call putenv() again to set a new TZ string, we can free the previous one.
- As far as I know, no libc implementations actually free the memory used in
- the environment variables (how could they know if it is a static string or
- a malloc'ed string?), so we have to free it ourselves. */
-static char* saved_tz = NULL;
-
-
-/* If you use set_tz(), you must call unset_tz() some time later to restore the
- original TZ. Pass unset_tz() the string that set_tz() returns. */
-char* set_tz(const char* tzid)
-{
- char *old_tz, *old_tz_copy = NULL, *new_tz;
-
- /* Get the old TZ setting and save a copy of it to return. */
- old_tz = getenv("TZ");
- if(old_tz){
- old_tz_copy = (char*)malloc(strlen (old_tz) + 4);
-
- if(old_tz_copy == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- strcpy (old_tz_copy, "TZ=");
- strcpy (old_tz_copy + 3, old_tz);
- }
-
- /* Create the new TZ string. */
- new_tz = (char*)malloc(strlen (tzid) + 4);
-
- if(new_tz == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- strcpy (new_tz, "TZ=");
- strcpy (new_tz + 3, tzid);
-
- /* Add the new TZ to the environment. */
- putenv(new_tz);
-
- /* Free any previous TZ environment string we have used. */
- if (saved_tz)
- free (saved_tz);
-
- /* Save a pointer to the TZ string we just set, so we can free it later. */
- saved_tz = new_tz;
-
- return old_tz_copy; /* This will be zero if the TZ env var was not set */
-}
-
-void unset_tz(char *tzstr)
-{
- /* restore the original environment */
-
- if(tzstr!=0){
- putenv(tzstr);
- } else {
- putenv("TZ"); /* Delete from environment */
- }
-
- /* Free any previous TZ environment string we have used. */
- if (saved_tz)
- free (saved_tz);
-
- /* Save a pointer to the TZ string we just set, so we can free it later.
- (This can possibly be NULL if there was no TZ to restore.) */
- saved_tz = tzstr;
-}
-
-time_t icaltime_as_timet(struct icaltimetype tt)
-{
- struct tm stm;
- time_t t;
-
- memset(&stm,0,sizeof( struct tm));
-
- if(icaltime_is_null_time(tt)) {
- return 0;
- }
-
- stm.tm_sec = tt.second;
- stm.tm_min = tt.minute;
- stm.tm_hour = tt.hour;
- stm.tm_mday = tt.day;
- stm.tm_mon = tt.month-1;
- stm.tm_year = tt.year-1900;
- stm.tm_isdst = -1;
-
- if(tt.is_utc == 1 || tt.is_date == 1){
- char *old_tz = set_tz("UTC");
- t = mktime(&stm);
- unset_tz(old_tz);
- } else {
- t = mktime(&stm);
- }
-
- return t;
-
-}
-
-time_t icaltime_as_timet_with_zone(struct icaltimetype tt, icaltimezone *zone)
-{
- icaltimezone *utc_zone;
- struct tm stm;
- time_t t;
- char *old_tz;
-
- utc_zone = icaltimezone_get_utc_timezone ();
-
- /* If the time is the special null time, return 0. */
- if (icaltime_is_null_time(tt)) {
- return 0;
- }
-
- /* Use our timezone functions to convert to UTC. */
- if (!tt.is_date)
- icaltimezone_convert_time (&tt, zone, utc_zone);
-
- /* Copy the icaltimetype to a struct tm. */
- memset (&stm, 0, sizeof (struct tm));
-
- stm.tm_sec = tt.second;
- stm.tm_min = tt.minute;
- stm.tm_hour = tt.hour;
- stm.tm_mday = tt.day;
- stm.tm_mon = tt.month-1;
- stm.tm_year = tt.year-1900;
- stm.tm_isdst = -1;
-
- /* Set TZ to UTC and use mktime to convert to a time_t. */
- old_tz = set_tz ("UTC");
- t = mktime (&stm);
- unset_tz (old_tz);
-
- return t;
-}
-
-char* icaltime_as_ical_string(struct icaltimetype tt)
-{
- size_t size = 17;
- char* buf = icalmemory_new_buffer(size);
-
- if(tt.is_date){
- snprintf(buf, size,"%04d%02d%02d",tt.year,tt.month,tt.day);
- } else {
- char* fmt;
- if(tt.is_utc){
- fmt = "%04d%02d%02dT%02d%02d%02dZ";
- } else {
- fmt = "%04d%02d%02dT%02d%02d%02d";
- }
- snprintf(buf, size,fmt,tt.year,tt.month,tt.day,
- tt.hour,tt.minute,tt.second);
- }
-
- icalmemory_add_tmp_buffer(buf);
-
- return buf;
-
-}
-
-
-/* Normalize the icaltime, so that all fields are within the normal range. */
-
-struct icaltimetype icaltime_normalize(struct icaltimetype tt)
-{
- icaltime_adjust (&tt, 0, 0, 0, 0);
- return tt;
-}
-
-
-#ifndef ICAL_NO_LIBICAL
-#include "icalvalue.h"
-
-struct icaltimetype icaltime_from_string(const char* str)
-{
- struct icaltimetype tt = icaltime_null_time();
- int size;
-
- icalerror_check_arg_re(str!=0,"str",icaltime_null_time());
-
- size = strlen(str);
-
- if(size == 15) { /* floating time */
- tt.is_utc = 0;
- tt.is_date = 0;
- } else if (size == 16) { /* UTC time, ends in 'Z'*/
- tt.is_utc = 1;
- tt.is_date = 0;
-
- if(str[15] != 'Z'){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return icaltime_null_time();
- }
-
- } else if (size == 8) { /* A DATE */
- tt.is_utc = 1;
- tt.is_date = 1;
- } else { /* error */
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return icaltime_null_time();
- }
-
- if(tt.is_date == 1){
- sscanf(str,"%04d%02d%02d",&tt.year,&tt.month,&tt.day);
- } else {
- char tsep;
- sscanf(str,"%04d%02d%02d%c%02d%02d%02d",&tt.year,&tt.month,&tt.day,
- &tsep,&tt.hour,&tt.minute,&tt.second);
-
- if(tsep != 'T'){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return icaltime_null_time();
- }
-
- }
-
- return tt;
-}
-#endif
-
-char ctime_str[20];
-char* icaltime_as_ctime(struct icaltimetype t)
-{
- time_t tt;
-
- tt = icaltime_as_timet(t);
- sprintf(ctime_str,"%s",ctime(&tt));
-
- ctime_str[strlen(ctime_str)-1] = 0;
-
- return ctime_str;
-}
-
-
-short days_in_month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
-
-short icaltime_days_in_month(short month,short year)
-{
-
- int is_leap =0;
- int days = days_in_month[month];
-
- assert(month > 0);
- assert(month <= 12);
-
- if( (year % 4 == 0 && year % 100 != 0) ||
- year % 400 == 0){
- is_leap =1;
- }
-
- if( month == 2){
- days += is_leap;
- }
-
- return days;
-}
-
-/* Returns whether the specified year is a leap year. Year is the normal year,
- e.g. 2001. */
-int
-icaltime_is_leap_year (int year)
-{
- if (year <= 1752)
- return !(year % 4);
- else
- return (!(year % 4) && (year % 100)) || !(year % 400);
-}
-
-/* 1-> Sunday, 7->Saturday */
-short icaltime_day_of_week(struct icaltimetype t){
- struct tm stm;
-
- stm.tm_year = t.year - 1900;
- stm.tm_mon = t.month - 1;
- stm.tm_mday = t.day;
- stm.tm_hour = 0;
- stm.tm_min = 0;
- stm.tm_sec = 0;
- stm.tm_isdst = -1;
-
- mktime (&stm);
-
- return stm.tm_wday + 1;
-}
-
-/* Day of the year that the first day of the week (Sunday) is on.
- FIXME: Doesn't take into account different week start days. */
-short icaltime_start_doy_of_week(struct icaltimetype t){
- struct tm stm;
-
- stm.tm_year = t.year - 1900;
- stm.tm_mon = t.month - 1;
- stm.tm_mday = t.day;
- stm.tm_hour = 0;
- stm.tm_min = 0;
- stm.tm_sec = 0;
- stm.tm_isdst = -1;
-
- mktime (&stm);
-
- /* Move back to the start of the week. */
- stm.tm_mday -= stm.tm_wday;
-
- mktime (&stm);
-
- /* If we are still in the same year as the original date, we just return
- the day of the year. */
- if (t.year - 1900 == stm.tm_year){
- return stm.tm_yday+1;
- } else {
- /* return negative to indicate that start of week is in
- previous year. */
- int is_leap = 0;
- int year = stm.tm_year;
-
- if( (year % 4 == 0 && year % 100 != 0) ||
- year % 400 == 0){
- is_leap =1;
- }
-
- return (stm.tm_yday+1)-(365+is_leap);
- }
-
-}
-
-/* FIXME: Doesn't take into account the start day of the week. strftime assumes
- that weeks start on Monday. */
-short icaltime_week_number(struct icaltimetype ictt)
-{
- struct tm stm;
- int week_no;
- char str[8];
-
- stm.tm_year = ictt.year - 1900;
- stm.tm_mon = ictt.month - 1;
- stm.tm_mday = ictt.day;
- stm.tm_hour = 0;
- stm.tm_min = 0;
- stm.tm_sec = 0;
- stm.tm_isdst = -1;
-
- mktime (&stm);
-
- strftime(str,5,"%V", &stm);
-
- week_no = atoi(str);
-
- return week_no;
-}
-
-static const short days_in_year[2][13] =
-{ /* jan feb mar apr may jun jul aug sep oct nov dec */
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
- { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
-};
-
-/* Returns the day of the year, counting from 1 (Jan 1st). */
-short icaltime_day_of_year(struct icaltimetype t){
- int is_leap = 0;
-
- if (icaltime_is_leap_year (t.year))
- is_leap = 1;
-
- return days_in_year[is_leap][t.month - 1] + t.day;
-}
-
-
-/* Jan 1 is day #1, not 0 */
-struct icaltimetype icaltime_from_day_of_year(short doy, short year)
-{
- struct icaltimetype tt = { 0 };
- int is_leap = 0, month;
-
- tt.year = year;
- if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
- is_leap = 1;
-
- assert(doy > 0);
- assert(doy <= days_in_year[is_leap][12]);
-
- for (month = 11; month >= 0; month--) {
- if (doy > days_in_year[is_leap][month]) {
- tt.month = month + 1;
- tt.day = doy - days_in_year[is_leap][month];
- return tt;
- }
- }
-
- /* Shouldn't reach here. */
- assert (0);
-}
-
-struct icaltimetype icaltime_null_time()
-{
- struct icaltimetype t;
- memset(&t,0,sizeof(struct icaltimetype));
-
- return t;
-}
-
-
-int icaltime_is_valid_time(struct icaltimetype t){
- if(t.is_utc > 1 || t.is_utc < 0 ||
- t.year < 0 || t.year > 3000 ||
- t.is_date > 1 || t.is_date < 0){
- return 0;
- } else {
- return 1;
- }
-
-}
-
-int icaltime_is_null_time(struct icaltimetype t)
-{
- if (t.second +t.minute+t.hour+t.day+t.month+t.year == 0){
- return 1;
- }
-
- return 0;
-
-}
-
-int icaltime_compare(struct icaltimetype a, struct icaltimetype b)
-{
- int retval;
-
- if (a.year > b.year)
- retval = 1;
- else if (a.year < b.year)
- retval = -1;
-
- else if (a.month > b.month)
- retval = 1;
- else if (a.month < b.month)
- retval = -1;
-
- else if (a.day > b.day)
- retval = 1;
- else if (a.day < b.day)
- retval = -1;
-
- else if (a.hour > b.hour)
- retval = 1;
- else if (a.hour < b.hour)
- retval = -1;
-
- else if (a.minute > b.minute)
- retval = 1;
- else if (a.minute < b.minute)
- retval = -1;
-
- else if (a.second > b.second)
- retval = 1;
- else if (a.second < b.second)
- retval = -1;
-
- else
- retval = 0;
-
- return retval;
-}
-
-int
-icaltime_compare_date_only (struct icaltimetype a, struct icaltimetype b)
-{
- int retval;
-
- if (a.year > b.year)
- retval = 1;
- else if (a.year < b.year)
- retval = -1;
-
- else if (a.month > b.month)
- retval = 1;
- else if (a.month < b.month)
- retval = -1;
-
- else if (a.day > b.day)
- retval = 1;
- else if (a.day < b.day)
- retval = -1;
-
- else
- retval = 0;
-
- return retval;
-}
-
-/* These are defined in icalduration.c:
-struct icaltimetype icaltime_add(struct icaltimetype t,
- struct icaldurationtype d)
-struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
- struct icaltimetype t2)
-*/
-
-
-
-/* Adds (or subtracts) a time from a icaltimetype.
- NOTE: This function is exactly the same as icaltimezone_adjust_change()
- except for the type of the first parameter. */
-void
-icaltime_adjust (struct icaltimetype *tt,
- int days,
- int hours,
- int minutes,
- int seconds)
-{
- int second, minute, hour, day;
- int minutes_overflow, hours_overflow, days_overflow, years_overflow;
- int days_in_month;
-
- /* Add on the seconds. */
- second = tt->second + seconds;
- tt->second = second % 60;
- minutes_overflow = second / 60;
- if (tt->second < 0) {
- tt->second += 60;
- minutes_overflow--;
- }
-
- /* Add on the minutes. */
- minute = tt->minute + minutes + minutes_overflow;
- tt->minute = minute % 60;
- hours_overflow = minute / 60;
- if (tt->minute < 0) {
- tt->minute += 60;
- hours_overflow--;
- }
-
- /* Add on the hours. */
- hour = tt->hour + hours + hours_overflow;
- tt->hour = hour % 24;
- days_overflow = hour / 24;
- if (tt->hour < 0) {
- tt->hour += 24;
- days_overflow--;
- }
-
- /* Normalize the month. We do this before handling the day since we may
- need to know what month it is to get the number of days in it.
- Note that months are 1 to 12, so we have to be a bit careful. */
- if (tt->month >= 13) {
- years_overflow = (tt->month - 1) / 12;
- tt->year += years_overflow;
- tt->month -= years_overflow * 12;
- } else if (tt->month <= 0) {
- /* 0 to -11 is -1 year out, -12 to -23 is -2 years. */
- years_overflow = (tt->month / 12) - 1;
- tt->year += years_overflow;
- tt->month -= years_overflow * 12;
- }
-
- /* Add on the days. */
- day = tt->day + days + days_overflow;
- if (day > 0) {
- for (;;) {
- days_in_month = icaltime_days_in_month (tt->month, tt->year);
- if (day <= days_in_month)
- break;
-
- tt->month++;
- if (tt->month >= 13) {
- tt->year++;
- tt->month = 1;
- }
-
- day -= days_in_month;
- }
- } else {
- while (day <= 0) {
- if (tt->month == 1) {
- tt->year--;
- tt->month = 12;
- } else {
- tt->month--;
- }
-
- day += icaltime_days_in_month (tt->month, tt->year);
- }
- }
- tt->day = day;
-}
diff --git a/libical/src/libical/icaltime.h b/libical/src/libical/icaltime.h
deleted file mode 100644
index b2a536b2b5..0000000000
--- a/libical/src/libical/icaltime.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icaltime.h
- CREATOR: eric 02 June 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
-
-
-======================================================================*/
-
-#ifndef ICALTIME_H
-#define ICALTIME_H
-
-#include <time.h>
-
-/* An opaque struct representing a timezone. We declare this here to avoid
- a circular dependancy. */
-#ifndef ICALTIMEONE_DEFINED
-#define ICALTIMEONE_DEFINED
-typedef struct _icaltimezone icaltimezone;
-#endif
-
-/* icaltime_span is returned by icalcomponent_get_span() */
-struct icaltime_span {
- time_t start; /* in UTC */
- time_t end; /* in UTC */
- int is_busy; /* 1->busy time, 0-> free time */
-};
-
-
-struct icaltimetype
-{
- int year; /* Actual year, e.g. 2001. */
- int month; /* 1 (Jan) to 12 (Dec). */
- int day;
- int hour;
- int minute;
- int second;
-
- int is_utc; /* 1-> time is in UTC timezone */
-
- int is_date; /* 1 -> interpret this as date. */
-
- int is_daylight; /* 1 -> time is in daylight savings time. */
-
- const char* zone; /*Ptr to Olsen placename. Libical does not own mem*/
-};
-
-/* Convert seconds past UNIX epoch to a timetype*/
-struct icaltimetype icaltime_from_timet(time_t v, int is_date);
-
-/* Newer version of above, using timezones. */
-struct icaltimetype icaltime_from_timet_with_zone(time_t tm, int is_date,
- icaltimezone *zone);
-
-/* Returns the current time in the given timezone, as an icaltimetype. */
-struct icaltimetype icaltime_current_time_with_zone(icaltimezone *zone);
-
-/* Returns the current day as an icaltimetype, with is_date set. */
-struct icaltimetype icaltime_today(void);
-
-/* Return the time as seconds past the UNIX epoch */
-time_t icaltime_as_timet(struct icaltimetype);
-
-/* Newer version of above, using timezones. */
-time_t icaltime_as_timet_with_zone(struct icaltimetype tt, icaltimezone *zone);
-
-/* Return a string represention of the time, in RFC2445 format. The
- string is owned by libical */
-char* icaltime_as_ical_string(struct icaltimetype tt);
-
-/* Like icaltime_from_timet(), except that the input may be in seconds
- past the epoch in floating time. This routine is deprecated */
-struct icaltimetype icaltime_from_int(int v, int is_date, int is_utc);
-
-/* Like icaltime_as_timet, but in a floating epoch. This routine is deprecated */
-int icaltime_as_int(struct icaltimetype);
-
-/* create a time from an ISO format string */
-struct icaltimetype icaltime_from_string(const char* str);
-
-/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */
-struct icaltimetype icaltime_null_time(void);
-
-/* Return true of the time is null. */
-int icaltime_is_null_time(struct icaltimetype t);
-
-/* Returns false if the time is clearly invalid, but is not null. This
- is usually the result of creating a new time type buy not clearing
- it, or setting one of the flags to an illegal value. */
-int icaltime_is_valid_time(struct icaltimetype t);
-
-/* Reset all of the time components to be in their normal ranges. For
- instance, given a time with minutes=70, the minutes will be reduces
- to 10, and the hour incremented. This allows the caller to do
- arithmetic on times without worrying about overflow or
- underflow. */
-struct icaltimetype icaltime_normalize(struct icaltimetype t);
-
-/* Return the day of the year of the given time */
-short icaltime_day_of_year(struct icaltimetype t);
-
-/* Create a new time, given a day of year and a year. */
-struct icaltimetype icaltime_from_day_of_year(short doy, short year);
-
-/* Return the day of the week of the given time. Sunday is 1 */
-short icaltime_day_of_week(struct icaltimetype t);
-
-/* Return the day of the year for the Sunday of the week that the
- given time is within. */
-short icaltime_start_doy_of_week(struct icaltimetype t);
-
-/* Return a string with the time represented in the same format as ctime(). THe string is owned by libical */
-char* icaltime_as_ctime(struct icaltimetype);
-
-/* Return the week number for the week the given time is within */
-short icaltime_week_number(struct icaltimetype t);
-
-/* Create a new time from a weeknumber and a year. */
-struct icaltimetype icaltime_from_week_number(short week_number, short year);
-
-/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
-int icaltime_compare(struct icaltimetype a,struct icaltimetype b);
-
-/* like icaltime_compare, but only use the date parts. */
-int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b);
-
-/* Return the number of days in the given month */
-short icaltime_days_in_month(short month,short year);
-
-/* Adds or subtracts a number of days, hours, minutes and seconds. */
-void icaltime_adjust(struct icaltimetype *tt, int days, int hours,
- int minutes, int seconds);
-
-#endif /* !ICALTIME_H */
-
-
-
diff --git a/libical/src/libical/icaltimezone.c b/libical/src/libical/icaltimezone.c
deleted file mode 100644
index fcb12c378b..0000000000
--- a/libical/src/libical/icaltimezone.c
+++ /dev/null
@@ -1,1597 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*======================================================================
- FILE: icaltimezone.h
- CREATOR: Damon Chaplin 15 March 2001
-
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2001, Damon Chaplin
-
- 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "icalproperty.h"
-#include "icalarray.h"
-#include "icalerror.h"
-#include "icalparser.h"
-#include "icaltimezone.h"
-
-/* This is the toplevel directory where the timezone data is installed in. */
-#define ZONEINFO_DIRECTORY PACKAGE_DATA_DIR "/zoneinfo"
-
-/* The prefix we use to uniquely identify TZIDs. */
-#define TZID_PREFIX "/softwarestudio.org/"
-#define TZID_PREFIX_LEN 20
-
-/* This is the filename of the file containing the city names and coordinates
- of all the builtin timezones. */
-#define ZONES_TAB_FILENAME "zones.tab"
-
-/* This is the number of years of extra coverage we do when expanding the
- timezone changes. */
-#define ICALTIMEZONE_EXTRA_COVERAGE 5
-
-/* This is the maximum year we will expand to. time_t values only go up to
- somewhere around 2037. */
-#define ICALTIMEZONE_MAX_YEAR 2035
-
-
-struct _icaltimezone {
- /* The unique ID of this timezone,
- e.g. "/softwarestudio.org/Olson_20010601_1/Africa/Banjul".
- This should only be used to identify a VTIMEZONE. It is not meant to
- be displayed to the user in any form. */
- char *tzid;
-
- /* The location for the timezone, e.g. "Africa/Accra" for the Olson
- database. We look for this in the "LOCATION" or "X-LIC-LOCATION"
- properties of the VTIMEZONE component. It isn't a standard property
- yet. This will be NULL if no location is found in the VTIMEZONE. */
- char *location;
-
- /* This will be set to a combination of the TZNAME properties from the last
- STANDARD and DAYLIGHT components in the VTIMEZONE, e.g. "EST/EDT".
- If they both use the same TZNAME, or only one type of component is
- found, then only one TZNAME will appear, e.g. "AZOT". If no TZNAME
- is found this will be NULL. */
- char *tznames;
-
- /* The coordinates of the city, in degrees. */
- double latitude;
- double longitude;
-
- /* The toplevel VTIMEZONE component loaded from the .ics file for this
- timezone. If we need to regenerate the changes data we need this. */
- icalcomponent *component;
-
- /* If this is not NULL it points to the builtin icaltimezone that the
- above TZID refers to. This icaltimezone should be used instead when
- accessing the timezone changes data, so that the expanded timezone
- changes data is shared between calendar components. */
- icaltimezone *builtin_timezone;
-
- /* This is the last year for which we have expanded the data to.
- If we need to calculate a date past this we need to expand the
- timezone component data from scratch. */
- int end_year;
-
- /* A dynamically-allocated array of time zone changes, sorted by the
- time of the change in local time. So we can do fast binary-searches
- to convert from local time to UTC. */
- icalarray *changes;
-};
-
-
-typedef struct _icaltimezonechange icaltimezonechange;
-
-struct _icaltimezonechange {
- /* The offset to add to UTC to get local time, in seconds. */
- int utc_offset;
-
- /* The offset to add to UTC, before this change, in seconds. */
- int prev_utc_offset;
-
- /* The time that the change came into effect, in UTC.
- Note that the prev_utc_offset applies to this local time,
- since we haven't changed to the new offset yet. */
- int year; /* Actual year, e.g. 2001. */
- char month; /* 1 (Jan) to 12 (Dec). */
- char day;
- char hour;
- char minute;
- char second;
-
- /* Whether this is STANDARD or DAYLIGHT time. */
- char is_daylight;
-};
-
-
-/* An array of icaltimezones for the builtin timezones. */
-icalarray *builtin_timezones = NULL;
-
-/* This is the special UTC timezone, which isn't in builtin_timezones. */
-icaltimezone utc_timezone = { 0 };
-
-
-
-static void icaltimezone_reset (icaltimezone *zone);
-static char* icaltimezone_get_location_from_vtimezone (icalcomponent *component);
-static char* icaltimezone_get_tznames_from_vtimezone (icalcomponent *component);
-static void icaltimezone_expand_changes (icaltimezone *zone,
- int end_year);
-static void icaltimezone_expand_vtimezone (icalcomponent *comp,
- int end_year,
- icalarray *changes);
-static int icaltimezone_compare_change_fn (const void *elem1,
- const void *elem2);
-
-static int icaltimezone_find_nearby_change (icaltimezone *zone,
- icaltimezonechange *change);
-
-static void icaltimezone_adjust_change (icaltimezonechange *tt,
- int days,
- int hours,
- int minutes,
- int seconds);
-
-static void icaltimezone_init (icaltimezone *zone);
-
-/* Gets the TZID, LOCATION/X-LIC-LOCATION, and TZNAME properties from the
- VTIMEZONE component and places them in the icaltimezone. It returns 1 on
- success, or 0 if the TZID can't be found. */
-static int icaltimezone_get_vtimezone_properties (icaltimezone *zone,
- icalcomponent *component);
-
-
-static void icaltimezone_load_builtin_timezone (icaltimezone *zone);
-
-static void icaltimezone_ensure_coverage (icaltimezone *zone,
- int end_year);
-
-
-static void icaltimezone_init_builtin_timezones(void);
-
-static void icaltimezone_parse_zone_tab (void);
-
-static char* icaltimezone_load_get_line_fn (char *s,
- size_t size,
- void *data);
-
-static void format_utc_offset (int utc_offset,
- char *buffer);
-
-
-/* Creates a new icaltimezone. */
-icaltimezone*
-icaltimezone_new (void)
-{
- icaltimezone *zone;
-
- zone = (icaltimezone*) malloc (sizeof (icaltimezone));
- if (!zone) {
- icalerror_set_errno (ICAL_NEWFAILED_ERROR);
- return;
- }
-
- icaltimezone_init (zone);
-
- return zone;
-}
-
-
-/* Frees all memory used for the icaltimezone. */
-void
-icaltimezone_free (icaltimezone *zone,
- int free_struct)
-{
- icaltimezone_reset (zone);
- if (free_struct)
- free (zone);
-}
-
-
-/* Resets the icaltimezone to the initial state, freeing most of the fields. */
-static void
-icaltimezone_reset (icaltimezone *zone)
-{
- if (zone->tzid)
- free (zone->tzid);
- if (zone->location)
- free (zone->location);
- if (zone->tznames)
- free (zone->tznames);
- if (zone->component)
- icalcomponent_free (zone->component);
- if (zone->changes)
- icalarray_free (zone->changes);
-
- icaltimezone_init (zone);
-}
-
-
-/* Initializes an icaltimezone. */
-static void
-icaltimezone_init (icaltimezone *zone)
-{
- zone->tzid = NULL;
- zone->location = NULL;
- zone->tznames = NULL;
- zone->latitude = 0.0;
- zone->longitude = 0.0;
- zone->component = NULL;
- zone->builtin_timezone = NULL;
- zone->end_year = 0;
- zone->changes = NULL;
-}
-
-
-/* Gets the TZID, LOCATION/X-LIC-LOCATION and TZNAME properties of the
- VTIMEZONE component and stores them in the icaltimezone.
- It returns 1 on success, or 0 if the TZID can't be found.
- Note that it expects the zone to be initialized or reset - it doesn't free
- any old values. */
-static int
-icaltimezone_get_vtimezone_properties (icaltimezone *zone,
- icalcomponent *component)
-{
- icalproperty *prop;
- const char *tzid, *location;
-
- prop = icalcomponent_get_first_property (component, ICAL_TZID_PROPERTY);
- if (!prop)
- return 0;
-
- /* A VTIMEZONE MUST have a TZID, or a lot of our code won't work. */
- tzid = icalproperty_get_tzid (prop);
- if (!tzid)
- return 0;
-
- zone->tzid = strdup (tzid);
- zone->component = component;
- zone->location = icaltimezone_get_location_from_vtimezone (component);
- zone->tznames = icaltimezone_get_tznames_from_vtimezone (component);
-
- return 1;
-}
-
-/* Gets the LOCATION or X-LIC-LOCATION property from a VTIMEZONE. */
-static char*
-icaltimezone_get_location_from_vtimezone (icalcomponent *component)
-{
- icalproperty *prop;
- const char *location;
- char *name;
- int found_location = 0;
-
- prop = icalcomponent_get_first_property (component,
- ICAL_LOCATION_PROPERTY);
- if (prop) {
- location = icalproperty_get_location (prop);
- if (location)
- return strdup (location);
- }
-
- prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY);
- while (prop) {
- name = icalproperty_get_x_name (prop);
- if (name && !strcmp (name, "X-LIC-LOCATION")) {
- location = icalproperty_get_x (prop);
- if (location)
- return strdup (location);
- }
- prop = icalcomponent_get_next_property (component,
- ICAL_X_PROPERTY);
- }
-
- return NULL;
-}
-
-
-/* Gets the TZNAMEs used for the last STANDARD & DAYLIGHT components in a
- VTIMEZONE. If both STANDARD and DAYLIGHT components use the same TZNAME,
- it returns that. If they use different TZNAMEs, it formats them like
- "EST/EDT". The returned string should be freed by the caller. */
-static char*
-icaltimezone_get_tznames_from_vtimezone (icalcomponent *component)
-{
- icalcomponent *comp;
- icalcomponent_kind type;
- icalproperty *prop;
- struct icaltimetype dtstart;
- struct icaldatetimeperiodtype rdate;
- const char *current_tzname;
- const char *standard_tzname = NULL, *daylight_tzname = NULL;
- struct icaltimetype standard_max_date, daylight_max_date;
- struct icaltimetype current_max_date;
-
- /* Step through the STANDARD & DAYLIGHT subcomponents. */
- comp = icalcomponent_get_first_component (component, ICAL_ANY_COMPONENT);
- while (comp) {
- type = icalcomponent_isa (comp);
- if (type == ICAL_XSTANDARD_COMPONENT
- || type == ICAL_XDAYLIGHT_COMPONENT) {
- current_max_date = icaltime_null_time ();
- current_tzname = NULL;
-
- /* Step through the properties. We want to find the TZNAME, and
- the largest DTSTART or RDATE. */
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
- switch (icalproperty_isa (prop)) {
- case ICAL_TZNAME_PROPERTY:
- current_tzname = icalproperty_get_tzname (prop);
- break;
-
- case ICAL_DTSTART_PROPERTY:
- dtstart = icalproperty_get_dtstart (prop);
- if (icaltime_compare (dtstart, current_max_date) > 0)
- current_max_date = dtstart;
-
- break;
-
- case ICAL_RDATE_PROPERTY:
- rdate = icalproperty_get_rdate (prop);
- if (icaltime_compare (rdate.time, current_max_date) > 0)
- current_max_date = rdate.time;
-
- break;
-
- default:
- break;
- }
-
- prop = icalcomponent_get_next_property (comp,
- ICAL_ANY_PROPERTY);
- }
-
- if (current_tzname) {
- if (type == ICAL_XSTANDARD_COMPONENT) {
- if (!standard_tzname
- || icaltime_compare (current_max_date,
- standard_max_date) > 0) {
- standard_max_date = current_max_date;
- standard_tzname = current_tzname;
- }
- } else {
- if (!daylight_tzname
- || icaltime_compare (current_max_date,
- daylight_max_date) > 0) {
- daylight_max_date = current_max_date;
- daylight_tzname = current_tzname;
- }
- }
- }
- }
-
- comp = icalcomponent_get_next_component (component,
- ICAL_ANY_COMPONENT);
- }
-
- /* If both standard and daylight TZNAMEs were found, if they are the same
- we return just one, else we format them like "EST/EDT". */
- if (standard_tzname && daylight_tzname) {
- int standard_len, daylight_len;
- char *tznames;
-
- if (!strcmp (standard_tzname, daylight_tzname))
- return strdup (standard_tzname);
-
- standard_len = strlen (standard_tzname);
- daylight_len = strlen (daylight_tzname);
- tznames = malloc (standard_len + daylight_len + 2);
- strcpy (tznames, standard_tzname);
- tznames[standard_len] = '/';
- strcpy (tznames + standard_len + 1, daylight_tzname);
- return tznames;
- } else {
- const char *tznames;
-
- /* If either of the TZNAMEs was found just return that, else NULL. */
- tznames = standard_tzname ? standard_tzname : daylight_tzname;
- return tznames ? strdup (tznames) : NULL;
- }
-}
-
-
-static void
-icaltimezone_ensure_coverage (icaltimezone *zone,
- int end_year)
-{
- /* When we expand timezone changes we always expand at least up to this
- year, plus ICALTIMEZONE_EXTRA_COVERAGE. */
- static int icaltimezone_minimum_expansion_year = -1;
-
- int changes_end_year;
-
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
-
- if (icaltimezone_minimum_expansion_year == -1) {
- struct tm *tmp_tm;
- time_t t;
-
- t = time (NULL);
- tmp_tm = localtime (&t);
- icaltimezone_minimum_expansion_year = tmp_tm->tm_year + 1900;
- }
-
- changes_end_year = end_year;
- if (changes_end_year < icaltimezone_minimum_expansion_year)
- changes_end_year = icaltimezone_minimum_expansion_year;
-
- changes_end_year += ICALTIMEZONE_EXTRA_COVERAGE;
-
- if (changes_end_year > ICALTIMEZONE_MAX_YEAR)
- changes_end_year = ICALTIMEZONE_MAX_YEAR;
-
- if (!zone->changes || zone->end_year < end_year)
- icaltimezone_expand_changes (zone, changes_end_year);
-}
-
-
-static void
-icaltimezone_expand_changes (icaltimezone *zone,
- int end_year)
-{
- icalarray *changes;
- icalcomponent *comp;
-
-#if 0
- printf ("\nExpanding changes for: %s to year: %i\n", zone->tzid, end_year);
-#endif
-
- changes = icalarray_new (sizeof (icaltimezonechange), 32);
- if (!changes)
- return;
-
- /* Scan the STANDARD and DAYLIGHT subcomponents. */
- comp = icalcomponent_get_first_component (zone->component,
- ICAL_ANY_COMPONENT);
- while (comp) {
- icaltimezone_expand_vtimezone (comp, end_year, changes);
- comp = icalcomponent_get_next_component (zone->component,
- ICAL_ANY_COMPONENT);
- }
-
- /* Sort the changes. We may have duplicates but I don't think it will
- matter. */
- icalarray_sort (changes, icaltimezone_compare_change_fn);
-
- if (zone->changes)
- icalarray_free (zone->changes);
-
- zone->changes = changes;
- zone->end_year = end_year;
-}
-
-
-static void
-icaltimezone_expand_vtimezone (icalcomponent *comp,
- int end_year,
- icalarray *changes)
-{
- icaltimezonechange change;
- icalproperty *prop;
- struct icaltimetype dtstart, occ;
- struct icalrecurrencetype rrule;
- icalrecur_iterator* rrule_iterator;
- struct icaldatetimeperiodtype rdate;
- int found_dtstart = 0, found_tzoffsetto = 0, found_tzoffsetfrom = 0;
- int has_recurrence = 0;
-
- /* First we check if it is a STANDARD or DAYLIGHT component, and
- just return if it isn't. */
- if (icalcomponent_isa (comp) == ICAL_XSTANDARD_COMPONENT)
- change.is_daylight = 0;
- else if (icalcomponent_isa (comp) == ICAL_XDAYLIGHT_COMPONENT)
- change.is_daylight = 1;
- else
- return;
-
- /* Step through each of the properties to find the DTSTART,
- TZOFFSETFROM and TZOFFSETTO. We can't expand recurrences here
- since we need these properties before we can do that. */
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
- switch (icalproperty_isa (prop)) {
- case ICAL_DTSTART_PROPERTY:
- dtstart = icalproperty_get_dtstart (prop);
- found_dtstart = 1;
- break;
- case ICAL_TZOFFSETTO_PROPERTY:
- change.utc_offset = icalproperty_get_tzoffsetto (prop);
- /*printf ("Found TZOFFSETTO: %i\n", change.utc_offset);*/
- found_tzoffsetto = 1;
- break;
- case ICAL_TZOFFSETFROM_PROPERTY:
- change.prev_utc_offset = icalproperty_get_tzoffsetfrom (prop);
- /*printf ("Found TZOFFSETFROM: %i\n", change.prev_utc_offset);*/
- found_tzoffsetfrom = 1;
- break;
- case ICAL_RDATE_PROPERTY:
- case ICAL_RRULE_PROPERTY:
- has_recurrence = 1;
- break;
- default:
- /* Just ignore any other properties. */
- break;
- }
-
- prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
- }
-
- /* If we didn't find a DTSTART, TZOFFSETTO and TZOFFSETFROM we have to
- ignore the component. FIXME: Add an error property? */
- if (!found_dtstart || !found_tzoffsetto || !found_tzoffsetfrom)
- return;
-
-#if 0
- printf ("\n Expanding component DTSTART (Y/M/D): %i/%i/%i %i:%02i:%02i\n",
- dtstart.year, dtstart.month, dtstart.day,
- dtstart.hour, dtstart.minute, dtstart.second);
-#endif
-
- /* If the STANDARD/DAYLIGHT component has no recurrence data, we just add
- a single change for the DTSTART. */
- if (!has_recurrence) {
- change.year = dtstart.year;
- change.month = dtstart.month;
- change.day = dtstart.day;
- change.hour = dtstart.hour;
- change.minute = dtstart.minute;
- change.second = dtstart.second;
-
- /* Convert to UTC. */
- icaltimezone_adjust_change (&change, 0, 0, 0, -change.prev_utc_offset);
-
-#if 0
- printf (" Appending single DTSTART (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
- change.year, change.month, change.day,
- change.hour, change.minute, change.second);
-#endif
-
- /* Add the change to the array. */
- icalarray_append (changes, &change);
- return;
- }
-
- /* The component has recurrence data, so we expand that now. */
- prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
- while (prop) {
-#if 0
- printf ("Expanding property...\n");
-#endif
- switch (icalproperty_isa (prop)) {
- case ICAL_RDATE_PROPERTY:
- rdate = icalproperty_get_rdate (prop);
- change.year = rdate.time.year;
- change.month = rdate.time.month;
- change.day = rdate.time.day;
- /* RDATEs with a DATE value inherit the time from
- the DTSTART. */
- if (rdate.time.is_date) {
- change.hour = dtstart.hour;
- change.minute = dtstart.minute;
- change.second = dtstart.second;
- } else {
- change.hour = rdate.time.hour;
- change.minute = rdate.time.minute;
- change.second = rdate.time.second;
-
- /* The spec was a bit vague about whether RDATEs were in local
- time or UTC so we support both to be safe. So if it is in
- UTC we have to add the UTC offset to get a local time. */
- if (!rdate.time.is_utc)
- icaltimezone_adjust_change (&change, 0, 0, 0,
- -change.prev_utc_offset);
- }
-
-#if 0
- printf (" Appending RDATE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
- change.year, change.month, change.day,
- change.hour, change.minute, change.second);
-#endif
-
- icalarray_append (changes, &change);
- break;
- case ICAL_RRULE_PROPERTY:
- rrule = icalproperty_get_rrule (prop);
-
- /* If the rrule UNTIL value is set and is in UTC, we convert it to
- a local time, since the recurrence code has no way to convert
- it itself. */
- if (!icaltime_is_null_time (rrule.until) && rrule.until.is_utc) {
-#if 0
- printf (" Found RRULE UNTIL in UTC.\n");
-#endif
-
- /* To convert from UTC to a local time, we use the TZOFFSETFROM
- since that is the offset from UTC that will be in effect
- when each of the RRULE occurrences happens. */
- icaltime_adjust (&rrule.until, 0, 0, 0,
- change.prev_utc_offset);
- rrule.until.is_utc = 0;
- }
-
- rrule_iterator = icalrecur_iterator_new (rrule, dtstart);
- for (;;) {
- occ = icalrecur_iterator_next (rrule_iterator);
- if (occ.year > end_year || icaltime_is_null_time (occ))
- break;
-
- change.year = occ.year;
- change.month = occ.month;
- change.day = occ.day;
- change.hour = occ.hour;
- change.minute = occ.minute;
- change.second = occ.second;
-
-#if 0
- printf (" Appending RRULE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
- change.year, change.month, change.day,
- change.hour, change.minute, change.second);
-#endif
-
- icaltimezone_adjust_change (&change, 0, 0, 0,
- -change.prev_utc_offset);
-
- icalarray_append (changes, &change);
- }
-
- icalrecur_iterator_free (rrule_iterator);
- break;
- default:
- break;
- }
-
- prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
- }
-}
-
-
-/* A function to compare 2 icaltimezonechange elements, used for qsort(). */
-static int
-icaltimezone_compare_change_fn (const void *elem1,
- const void *elem2)
-{
- const icaltimezonechange *change1, *change2;
- int retval;
-
- change1 = elem1;
- change2 = elem2;
-
- if (change1->year < change2->year)
- retval = -1;
- else if (change1->year > change2->year)
- retval = 1;
-
- else if (change1->month < change2->month)
- retval = -1;
- else if (change1->month > change2->month)
- retval = 1;
-
- else if (change1->day < change2->day)
- retval = -1;
- else if (change1->day > change2->day)
- retval = 1;
-
- else if (change1->hour < change2->hour)
- retval = -1;
- else if (change1->hour > change2->hour)
- retval = 1;
-
- else if (change1->minute < change2->minute)
- retval = -1;
- else if (change1->minute > change2->minute)
- retval = 1;
-
- else if (change1->second < change2->second)
- retval = -1;
- else if (change1->second > change2->second)
- retval = 1;
-
- else
- retval = 0;
-
- return retval;
-}
-
-
-
-void
-icaltimezone_convert_time (struct icaltimetype *tt,
- icaltimezone *from_zone,
- icaltimezone *to_zone)
-{
- int utc_offset, is_daylight;
-
- /* If the time is a DATE value or both timezones are the same, or we are
- converting a floating time, we don't need to do anything. */
- if (tt->is_date || from_zone == to_zone || from_zone == NULL)
- return;
-
- /* Convert the time to UTC by getting the UTC offset and subtracting it. */
- utc_offset = icaltimezone_get_utc_offset (from_zone, tt, NULL);
- icaltime_adjust (tt, 0, 0, 0, -utc_offset);
-
- /* Now we convert the time to the new timezone by getting the UTC offset
- of our UTC time and adding it. */
- utc_offset = icaltimezone_get_utc_offset_of_utc_time (to_zone, tt,
- &is_daylight);
- tt->is_daylight = is_daylight;
- icaltime_adjust (tt, 0, 0, 0, utc_offset);
-}
-
-
-
-
-
-/* Calculates the UTC offset of a given local time in the given timezone.
- It is the number of seconds to add to UTC to get local time.
- The is_daylight flag is set to 1 if the time is in daylight-savings time. */
-int
-icaltimezone_get_utc_offset (icaltimezone *zone,
- struct icaltimetype *tt,
- int *is_daylight)
-{
- icaltimezonechange *zone_change, *prev_zone_change, tt_change, tmp_change;
- int change_num, step, utc_offset_change, cmp;
- int change_num_to_use;
- char want_daylight;
-
- if (is_daylight)
- *is_daylight = 0;
-
- /* For local times and UTC return 0. */
- if (zone == NULL || zone == &utc_timezone)
- return 0;
-
- /* Use the builtin icaltimezone if possible. */
- if (zone->builtin_timezone)
- zone = zone->builtin_timezone;
-
- /* Make sure the changes array is expanded up to the given time. */
- icaltimezone_ensure_coverage (zone, tt->year);
-
- if (!zone->changes || zone->changes->num_elements == 0)
- return 0;
-
- /* Copy the time parts of the icaltimetype to an icaltimezonechange so we
- can use our comparison function on it. */
- tt_change.year = tt->year;
- tt_change.month = tt->month;
- tt_change.day = tt->day;
- tt_change.hour = tt->hour;
- tt_change.minute = tt->minute;
- tt_change.second = tt->second;
-
- /* This should find a change close to the time, either the change before
- it or the change after it. */
- change_num = icaltimezone_find_nearby_change (zone, &tt_change);
-
- /* Sanity check. */
- icalerror_assert (change_num >= 0,
- "Negative timezone change index");
- icalerror_assert (change_num < zone->changes->num_elements,
- "Timezone change index out of bounds");
-
- /* Now move backwards or forwards to find the timezone change that applies
- to tt. It should only have to do 1 or 2 steps. */
- zone_change = icalarray_element_at (zone->changes, change_num);
- step = 1;
- change_num_to_use = -1;
- for (;;) {
- /* Copy the change, so we can adjust it. */
- tmp_change = *zone_change;
-
- /* If the clock is going backward, check if it is in the region of time
- that is used twice. If it is, use the change with the daylight
- setting which matches tt, or use standard if we don't know. */
- if (tmp_change.utc_offset < tmp_change.prev_utc_offset) {
- /* If the time change is at 2:00AM local time and the clock is
- going back to 1:00AM we adjust the change to 1:00AM. We may
- have the wrong change but we'll figure that out later. */
- icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
- tmp_change.utc_offset);
- } else {
- icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
- tmp_change.prev_utc_offset);
- }
-
- cmp = icaltimezone_compare_change_fn (&tt_change, &tmp_change);
-
- /* If the given time is on or after this change, then this change may
- apply, but we continue as a later change may be the right one.
- If the given time is before this change, then if we have already
- found a change which applies we can use that, else we need to step
- backwards. */
- if (cmp >= 0)
- change_num_to_use = change_num;
- else
- step = -1;
-
- /* If we are stepping backwards through the changes and we have found
- a change that applies, then we know this is the change to use so
- we exit the loop. */
- if (step == -1 && change_num_to_use != -1)
- break;
-
- change_num += step;
-
- /* If we go past the start of the changes array, then we have no data
- for this time so we return a UTC offset of 0. */
- if (change_num < 0)
- return 0;
-
- if (change_num >= zone->changes->num_elements)
- break;
-
- zone_change = icalarray_element_at (zone->changes, change_num);
- }
-
- /* If we didn't find a change to use, then we have a bug! */
- icalerror_assert (change_num_to_use != -1,
- "No applicable timezone change found");
-
- /* Now we just need to check if the time is in the overlapped region of
- time when clocks go back. */
- zone_change = icalarray_element_at (zone->changes, change_num_to_use);
-
- utc_offset_change = zone_change->utc_offset - zone_change->prev_utc_offset;
- if (utc_offset_change < 0 && change_num_to_use > 0) {
- tmp_change = *zone_change;
- icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
- tmp_change.prev_utc_offset);
-
- if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) < 0) {
- /* The time is in the overlapped region, so we may need to use
- either the current zone_change or the previous one. If the
- time has the is_daylight field set we use the matching change,
- else we use the change with standard time. */
- prev_zone_change = icalarray_element_at (zone->changes,
- change_num_to_use - 1);
-
- /* I was going to add an is_daylight flag to struct icaltimetype,
- but iCalendar doesn't let us distinguish between standard and
- daylight time anyway, so there's no point. So we just use the
- standard time instead. */
- want_daylight = (tt->is_daylight == 1) ? 1 : 0;
-
-#if 0
- if (zone_change->is_daylight == prev_zone_change->is_daylight)
- printf (" **** Same is_daylight setting\n");
-#endif
-
- if (zone_change->is_daylight != want_daylight
- && prev_zone_change->is_daylight == want_daylight)
- zone_change = prev_zone_change;
- }
- }
-
- /* Now we know exactly which timezone change applies to the time, so
- we can return the UTC offset and whether it is a daylight time. */
- if (is_daylight)
- *is_daylight = zone_change->is_daylight;
- return zone_change->utc_offset;
-}
-
-
-/* Calculates the UTC offset of a given UTC time in the given timezone.
- It is the number of seconds to add to UTC to get local time.
- The is_daylight flag is set to 1 if the time is in daylight-savings time. */
-int
-icaltimezone_get_utc_offset_of_utc_time (icaltimezone *zone,
- struct icaltimetype *tt,
- int *is_daylight)
-{
- icaltimezonechange *zone_change, tt_change, tmp_change;
- int change_num, step, change_num_to_use;
-
- if (is_daylight)
- *is_daylight = 0;
-
- /* For local times and UTC return 0. */
- if (zone == NULL || zone == &utc_timezone)
- return 0;
-
- /* Use the builtin icaltimezone if possible. */
- if (zone->builtin_timezone)
- zone = zone->builtin_timezone;
-
- /* Make sure the changes array is expanded up to the given time. */
- icaltimezone_ensure_coverage (zone, tt->year);
-
- if (!zone->changes || zone->changes->num_elements == 0)
- return 0;
-
- /* Copy the time parts of the icaltimetype to an icaltimezonechange so we
- can use our comparison function on it. */
- tt_change.year = tt->year;
- tt_change.month = tt->month;
- tt_change.day = tt->day;
- tt_change.hour = tt->hour;
- tt_change.minute = tt->minute;
- tt_change.second = tt->second;
-
- /* This should find a change close to the time, either the change before
- it or the change after it. */
- change_num = icaltimezone_find_nearby_change (zone, &tt_change);
-
- /* Sanity check. */
- icalerror_assert (change_num >= 0,
- "Negative timezone change index");
- icalerror_assert (change_num < zone->changes->num_elements,
- "Timezone change index out of bounds");
-
- /* Now move backwards or forwards to find the timezone change that applies
- to tt. It should only have to do 1 or 2 steps. */
- zone_change = icalarray_element_at (zone->changes, change_num);
- step = 1;
- change_num_to_use = -1;
- for (;;) {
- /* Copy the change and adjust it to UTC. */
- tmp_change = *zone_change;
-
- /* If the given time is on or after this change, then this change may
- apply, but we continue as a later change may be the right one.
- If the given time is before this change, then if we have already
- found a change which applies we can use that, else we need to step
- backwards. */
- if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) >= 0)
- change_num_to_use = change_num;
- else
- step = -1;
-
- /* If we are stepping backwards through the changes and we have found
- a change that applies, then we know this is the change to use so
- we exit the loop. */
- if (step == -1 && change_num_to_use != -1)
- break;
-
- change_num += step;
-
- /* If we go past the start of the changes array, then we have no data
- for this time so we return a UTC offset of 0. */
- if (change_num < 0)
- return 0;
-
- if (change_num >= zone->changes->num_elements)
- break;
-
- zone_change = icalarray_element_at (zone->changes, change_num);
- }
-
- /* If we didn't find a change to use, then we have a bug! */
- icalerror_assert (change_num_to_use != -1,
- "No applicable timezone change found");
-
- /* Now we know exactly which timezone change applies to the time, so
- we can return the UTC offset and whether it is a daylight time. */
- zone_change = icalarray_element_at (zone->changes, change_num_to_use);
- if (is_daylight)
- *is_daylight = zone_change->is_daylight;
-
- return zone_change->utc_offset;
-}
-
-
-/* Returns the index of a timezone change which is close to the time given
- in change. */
-static int
-icaltimezone_find_nearby_change (icaltimezone *zone,
- icaltimezonechange *change)
-{
- icaltimezonechange *zone_change;
- int lower, upper, middle, cmp;
-
- /* Do a simple binary search. */
- lower = middle = 0;
- upper = zone->changes->num_elements;
-
- while (lower < upper) {
- middle = (lower + upper) >> 1;
- zone_change = icalarray_element_at (zone->changes, middle);
- cmp = icaltimezone_compare_change_fn (change, zone_change);
- if (cmp == 0)
- break;
- else if (cmp < 0)
- upper = middle;
- else
- lower = middle + 1;
- }
-
- return middle;
-}
-
-
-
-
-/* Adds (or subtracts) a time from a icaltimezonechange.
- NOTE: This function is exactly the same as icaltime_adjust()
- except for the type of the first parameter. */
-static void
-icaltimezone_adjust_change (icaltimezonechange *tt,
- int days,
- int hours,
- int minutes,
- int seconds)
-{
- int second, minute, hour, day;
- int minutes_overflow, hours_overflow, days_overflow;
- int days_in_month;
-
- /* Add on the seconds. */
- second = tt->second + seconds;
- tt->second = second % 60;
- minutes_overflow = second / 60;
- if (tt->second < 0) {
- tt->second += 60;
- minutes_overflow--;
- }
-
- /* Add on the minutes. */
- minute = tt->minute + minutes + minutes_overflow;
- tt->minute = minute % 60;
- hours_overflow = minute / 60;
- if (tt->minute < 0) {
- tt->minute += 60;
- hours_overflow--;
- }
-
- /* Add on the hours. */
- hour = tt->hour + hours + hours_overflow;
- tt->hour = hour % 24;
- days_overflow = hour / 24;
- if (tt->hour < 0) {
- tt->hour += 24;
- days_overflow--;
- }
-
- /* Add on the days. */
- day = tt->day + days + days_overflow;
- if (day > 0) {
- for (;;) {
- days_in_month = icaltime_days_in_month (tt->month, tt->year);
- if (day <= days_in_month)
- break;
-
- tt->month++;
- if (tt->month >= 13) {
- tt->year++;
- tt->month = 1;
- }
-
- day -= days_in_month;
- }
- } else {
- while (day <= 0) {
- if (tt->month == 1) {
- tt->year--;
- tt->month = 12;
- } else {
- tt->month--;
- }
-
- day += icaltime_days_in_month (tt->month, tt->year);
- }
- }
- tt->day = day;
-}
-
-
-char*
-icaltimezone_get_tzid (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return NULL. */
- if (!zone)
- return NULL;
-
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
-
- return zone->tzid;
-}
-
-
-char*
-icaltimezone_get_location (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return NULL. */
- if (!zone)
- return NULL;
-
- /* Note that for builtin timezones this comes from zones.tab so we don't
- need to check the timezone is loaded here. */
- return zone->location;
-}
-
-
-char*
-icaltimezone_get_tznames (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return NULL. */
- if (!zone)
- return NULL;
-
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
-
- return zone->tznames;
-}
-
-
-/* Returns the latitude of a builtin timezone. */
-double
-icaltimezone_get_latitude (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return 0. */
- if (!zone)
- return 0.0;
-
- /* Note that for builtin timezones this comes from zones.tab so we don't
- need to check the timezone is loaded here. */
- return zone->latitude;
-}
-
-
-/* Returns the longitude of a builtin timezone. */
-double
-icaltimezone_get_longitude (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return 0. */
- if (!zone)
- return 0.0;
-
- /* Note that for builtin timezones this comes from zones.tab so we don't
- need to check the timezone is loaded here. */
- return zone->longitude;
-}
-
-
-/* Returns the VTIMEZONE component of a timezone. */
-icalcomponent*
-icaltimezone_get_component (icaltimezone *zone)
-{
- /* If this is a floating time, without a timezone, return NULL. */
- if (!zone)
- return NULL;
-
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
-
- return zone->component;
-}
-
-
-/* Sets the VTIMEZONE component of an icaltimezone, initializing the tzid,
- location & tzname fields. It returns 1 on success or 0 on failure, i.e.
- no TZID was found. */
-int
-icaltimezone_set_component (icaltimezone *zone,
- icalcomponent *comp)
-{
- icaltimezone_reset (zone);
- return icaltimezone_get_vtimezone_properties (zone, comp);
-}
-
-
-icalarray*
-icaltimezone_array_new (void)
-{
- return icalarray_new (sizeof (icaltimezone), 16);
-}
-
-
-void
-icaltimezone_array_append_from_vtimezone (icalarray *timezones,
- icalcomponent *child)
-{
- icaltimezone zone;
-
- icaltimezone_init (&zone);
- if (icaltimezone_get_vtimezone_properties (&zone, child))
- icalarray_append (timezones, &zone);
-}
-
-
-void
-icaltimezone_array_free (icalarray *timezones)
-{
- icaltimezone *zone;
- int i;
-
- for (i = 0; i < timezones->num_elements; i++) {
- zone = icalarray_element_at (timezones, i);
- icaltimezone_free (zone, 0);
- }
-
- icalarray_free (timezones);
-}
-
-
-/*
- * BUILTIN TIMEZONE HANDLING
- */
-
-
-/* Returns an icalarray of icaltimezone structs, one for each builtin timezone.
- This will load and parse the zones.tab file to get the timezone names and
- their coordinates. It will not load the VTIMEZONE data for any timezones. */
-icalarray*
-icaltimezone_get_builtin_timezones (void)
-{
- if (!builtin_timezones)
- icaltimezone_init_builtin_timezones ();
-
- return builtin_timezones;
-}
-
-
-/* Returns a single builtin timezone, given its Olson city name. */
-icaltimezone*
-icaltimezone_get_builtin_timezone (const char *location)
-{
- icaltimezone *zone;
- int lower, upper, middle, cmp;
- char *zone_location;
-
- if (!location || !location[0])
- return NULL;
-
- if (!strcmp (location, "UTC"))
- return &utc_timezone;
-
- if (!builtin_timezones)
- icaltimezone_init_builtin_timezones ();
-
- /* Do a simple binary search. */
- lower = middle = 0;
- upper = builtin_timezones->num_elements;
-
- while (lower < upper) {
- middle = (lower + upper) >> 1;
- zone = icalarray_element_at (builtin_timezones, middle);
- zone_location = icaltimezone_get_location (zone);
- cmp = strcmp (location, zone_location);
- if (cmp == 0)
- return zone;
- else if (cmp < 0)
- upper = middle;
- else
- lower = middle + 1;
- }
-
- return NULL;
-}
-
-
-/* Returns a single builtin timezone, given its TZID. */
-icaltimezone*
-icaltimezone_get_builtin_timezone_from_tzid (const char *tzid)
-{
- int num_slashes = 0;
- const char *p, *zone_tzid;
- icaltimezone *zone;
-
- if (!tzid || !tzid[0])
- return NULL;
-
- /* Check that the TZID starts with our unique prefix. */
- if (strncmp (tzid, TZID_PREFIX, TZID_PREFIX_LEN))
- return NULL;
-
- /* Get the location, which is after the 3rd '/' character. */
- p = tzid;
- for (p = tzid; *p; p++) {
- if (*p == '/') {
- num_slashes++;
- if (num_slashes == 3)
- break;
- }
- }
-
- if (num_slashes != 3)
- return NULL;
-
- p++;
-
- /* Now we can use the function to get the builtin timezone from the
- location string. */
- zone = icaltimezone_get_builtin_timezone (p);
- if (!zone)
- return NULL;
-
- /* Check that the builtin TZID matches exactly. We don't want to return
- a different version of the VTIMEZONE. */
- zone_tzid = icaltimezone_get_tzid (zone);
- if (!strcmp (zone_tzid, tzid))
- return zone;
- else
- return NULL;
-}
-
-
-/* Returns the special UTC timezone. */
-icaltimezone*
-icaltimezone_get_utc_timezone (void)
-{
- return &utc_timezone;
-}
-
-
-
-/* This initializes the builtin timezone data, i.e. the builtin_timezones
- array and the special UTC timezone. It should be called before any
- code that uses the timezone functions. */
-static void
-icaltimezone_init_builtin_timezones (void)
-{
- /* Initialize the special UTC timezone. */
- utc_timezone.tzid = "UTC";
-
- icaltimezone_parse_zone_tab ();
-}
-
-
-/* This parses the zones.tab file containing the names and locations of the
- builtin timezones. It creates the builtin_timezones array which is an
- icalarray of icaltimezone structs. It only fills in the location, latitude
- and longtude fields; the rest are left blank. The VTIMEZONE component is
- loaded later if it is needed. The timezones in the zones.tab file are
- sorted by their name, which is useful for binary searches. */
-static void
-icaltimezone_parse_zone_tab (void)
-{
- char *filename;
- FILE *fp;
- char buf[1024]; /* Used to store each line of zones.tab as it is read. */
- char location[1024]; /* Stores the city name when parsing buf. */
- int filename_len;
- int latitude_degrees, latitude_minutes, latitude_seconds;
- int longitude_degrees, longitude_minutes, longitude_seconds;
- icaltimezone zone;
-
- icalerror_assert (builtin_timezones == NULL,
- "Parsing zones.tab file multiple times");
-
- builtin_timezones = icalarray_new (sizeof (icaltimezone), 32);
-
- filename_len = strlen (ZONEINFO_DIRECTORY) + strlen (ZONES_TAB_FILENAME)
- + 2;
-
- filename = (char*) malloc (filename_len);
- if (!filename) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- snprintf (filename, filename_len, "%s/%s", ZONEINFO_DIRECTORY,
- ZONES_TAB_FILENAME);
-
- fp = fopen (filename, "r");
- free (filename);
- if (!fp) {
- icalerror_set_errno(ICAL_FILE_ERROR);
- return;
- }
-
- while (fgets (buf, sizeof(buf), fp)) {
- if (*buf == '#') continue;
-
- /* The format of each line is: "latitude longitude location". */
- if (sscanf (buf, "%4d%2d%2d %4d%2d%2d %s",
- &latitude_degrees, &latitude_minutes,
- &latitude_seconds,
- &longitude_degrees, &longitude_minutes,
- &longitude_seconds,
- &location) != 7) {
- fprintf (stderr, "Invalid timezone description line: %s\n", buf);
- continue;
- }
-
- icaltimezone_init (&zone);
- zone.location = strdup (location);
-
- if (latitude_degrees >= 0)
- zone.latitude = (double) latitude_degrees
- + (double) latitude_minutes / 60
- + (double) latitude_seconds / 3600;
- else
- zone.latitude = (double) latitude_degrees
- - (double) latitude_minutes / 60
- - (double) latitude_seconds / 3600;
-
- if (longitude_degrees >= 0)
- zone.longitude = (double) longitude_degrees
- + (double) longitude_minutes / 60
- + (double) longitude_seconds / 3600;
- else
- zone.longitude = (double) longitude_degrees
- - (double) longitude_minutes / 60
- - (double) longitude_seconds / 3600;
-
- icalarray_append (builtin_timezones, &zone);
-
-#if 0
- printf ("Found zone: %s %f %f\n",
- location, zone.latitude, zone.longitude);
-#endif
- }
-
- fclose (fp);
-}
-
-
-/* Loads the builtin VTIMEZONE data for the given timezone. */
-static void
-icaltimezone_load_builtin_timezone (icaltimezone *zone)
-{
- char *filename;
- int filename_len;
- FILE *fp;
- icalparser *parser;
- icalcomponent *comp, *subcomp;
-
- /* If the location isn't set, it isn't a builtin timezone. */
- if (!zone->location || !zone->location[0])
- return;
-
- filename_len = strlen (ZONEINFO_DIRECTORY) + strlen (zone->location) + 6;
-
- filename = (char*) malloc (filename_len);
- if (!filename) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- snprintf (filename, filename_len, "%s/%s.ics", ZONEINFO_DIRECTORY,
- zone->location);
-
- fp = fopen (filename, "r");
- free (filename);
- if (!fp) {
- icalerror_set_errno(ICAL_FILE_ERROR);
- return;
- }
-
- parser = icalparser_new ();
- icalparser_set_gen_data (parser, fp);
- comp = icalparser_parse (parser, icaltimezone_load_get_line_fn);
- icalparser_free (parser);
- fclose (fp);
-
- /* Find the VTIMEZONE component inside the VCALENDAR. There should be 1. */
- subcomp = icalcomponent_get_first_component (comp,
- ICAL_VTIMEZONE_COMPONENT);
- if (!subcomp) {
- icalerror_set_errno(ICAL_PARSE_ERROR);
- return;
- }
-
- icaltimezone_get_vtimezone_properties (zone, subcomp);
-}
-
-
-/* Callback used from icalparser_parse() */
-static char *
-icaltimezone_load_get_line_fn (char *s,
- size_t size,
- void *data)
-{
- return fgets (s, size, (FILE*) data);
-}
-
-
-
-
-/*
- * DEBUGGING
- */
-
-/*
- * This outputs a list of timezone changes for the given timezone to the
- * given file, up to the maximum year given. We compare this output with the
- * output from 'vzic --dump-changes' to make sure that we are consistent.
- * (vzic is the Olson timezone database to VTIMEZONE converter.)
- *
- * The output format is:
- *
- * Zone-Name [tab] Date [tab] Time [tab] UTC-Offset
- *
- * The Date and Time fields specify the time change in UTC.
- *
- * The UTC Offset is for local (wall-clock) time. It is the amount of time
- * to add to UTC to get local time.
- */
-int
-icaltimezone_dump_changes (icaltimezone *zone,
- int max_year,
- FILE *fp)
-{
- static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- icaltimezonechange *zone_change;
- int change_num;
- char buffer[8];
-
- /* Make sure the changes array is expanded up to the given time. */
- icaltimezone_ensure_coverage (zone, max_year);
-
-#if 0
- printf ("Num changes: %i\n", zone->changes->num_elements);
-#endif
-
- change_num = 0;
- for (change_num = 0; change_num < zone->changes->num_elements; change_num++) {
- zone_change = icalarray_element_at (zone->changes, change_num);
-
- if (zone_change->year > max_year)
- break;
-
- fprintf (fp, "%s\t%2i %s %04i\t%2i:%02i:%02i",
- zone->location,
- zone_change->day, months[zone_change->month - 1],
- zone_change->year,
- zone_change->hour, zone_change->minute, zone_change->second);
-
- /* Wall Clock Time offset from UTC. */
- format_utc_offset (zone_change->utc_offset, buffer);
- fprintf (fp, "\t%s", buffer);
-
- fprintf (fp, "\n");
- }
-}
-
-
-/* This formats a UTC offset as "+HHMM" or "+HHMMSS".
- buffer should have space for 8 characters. */
-static void
-format_utc_offset (int utc_offset,
- char *buffer)
-{
- char *sign = "+";
- int hours, minutes, seconds;
-
- if (utc_offset < 0) {
- utc_offset = -utc_offset;
- sign = "-";
- }
-
- hours = utc_offset / 3600;
- minutes = (utc_offset % 3600) / 60;
- seconds = utc_offset % 60;
-
- /* Sanity check. Standard timezone offsets shouldn't be much more than 12
- hours, and daylight saving shouldn't change it by more than a few hours.
- (The maximum offset is 15 hours 56 minutes at present.) */
- if (hours < 0 || hours >= 24 || minutes < 0 || minutes >= 60
- || seconds < 0 || seconds >= 60) {
- fprintf (stderr, "Warning: Strange timezone offset: H:%i M:%i S:%i\n",
- hours, minutes, seconds);
- }
-
- if (seconds == 0)
- sprintf (buffer, "%s%02i%02i", sign, hours, minutes);
- else
- sprintf (buffer, "%s%02i%02i%02i", sign, hours, minutes, seconds);
-}
diff --git a/libical/src/libical/icaltimezone.h b/libical/src/libical/icaltimezone.h
deleted file mode 100644
index 1e8ec70048..0000000000
--- a/libical/src/libical/icaltimezone.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*======================================================================
- FILE: icaltimezone.h
- CREATOR: Damon Chaplin 15 March 2001
-
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2001, Damon Chaplin
-
- 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 ICALTIMEZONE_H
-#define ICALTIMEZONE_H
-
-#include <stdio.h> /* For FILE* */
-#include "icaltime.h"
-#include "icalarray.h"
-#include "icalcomponent.h"
-
-
-/*
- * Creating/Destroying individual icaltimezones.
- */
-
-/* Creates a new icaltimezone. */
-icaltimezone *icaltimezone_new (void);
-
-/* Frees all memory used for the icaltimezone. Set free_struct to free the
- icaltimezone struct as well. */
-void icaltimezone_free (icaltimezone *zone,
- int free_struct);
-
-
-/*
- * Accessing timezones.
- */
-
-/* Returns the array of builtin icaltimezones. */
-icalarray* icaltimezone_get_builtin_timezones (void);
-
-/* Returns a single builtin timezone, given its Olson city name. */
-icaltimezone* icaltimezone_get_builtin_timezone (const char *location);
-
-/* Returns a single builtin timezone, given its TZID. */
-icaltimezone* icaltimezone_get_builtin_timezone_from_tzid (const char *tzid);
-
-/* Returns the UTC timezone. */
-icaltimezone* icaltimezone_get_utc_timezone (void);
-
-/* Returns the TZID of a timezone. */
-char* icaltimezone_get_tzid (icaltimezone *zone);
-
-/* Returns the city name of a timezone. */
-char* icaltimezone_get_location (icaltimezone *zone);
-
-/* Returns the TZNAME properties used in the latest STANDARD and DAYLIGHT
- components. If they are the same it will return just one, e.g. "LMT".
- If they are different it will format them like "EST/EDT". Note that this
- may also return NULL. */
-char* icaltimezone_get_tznames (icaltimezone *zone);
-
-/* Returns the latitude of a builtin timezone. */
-double icaltimezone_get_latitude (icaltimezone *zone);
-
-/* Returns the longitude of a builtin timezone. */
-double icaltimezone_get_longitude (icaltimezone *zone);
-
-/* Returns the VTIMEZONE component of a timezone. */
-icalcomponent* icaltimezone_get_component (icaltimezone *zone);
-
-/* Sets the VTIMEZONE component of an icaltimezone, initializing the tzid,
- location & tzname fields. It returns 1 on success or 0 on failure, i.e.
- no TZID was found. */
-int icaltimezone_set_component (icaltimezone *zone,
- icalcomponent *comp);
-
-/*
- * Converting times between timezones.
- */
-
-void icaltimezone_convert_time (struct icaltimetype *tt,
- icaltimezone *from_zone,
- icaltimezone *to_zone);
-
-
-/*
- * Getting offsets from UTC.
- */
-
-/* Calculates the UTC offset of a given local time in the given timezone.
- It is the number of seconds to add to UTC to get local time.
- The is_daylight flag is set to 1 if the time is in daylight-savings time. */
-int icaltimezone_get_utc_offset (icaltimezone *zone,
- struct icaltimetype *tt,
- int *is_daylight);
-
-/* Calculates the UTC offset of a given UTC time in the given timezone.
- It is the number of seconds to add to UTC to get local time.
- The is_daylight flag is set to 1 if the time is in daylight-savings time. */
-int icaltimezone_get_utc_offset_of_utc_time (icaltimezone *zone,
- struct icaltimetype *tt,
- int *is_daylight);
-
-
-
-/*
- * Handling arrays of timezones. Mainly for internal use.
- */
-icalarray* icaltimezone_array_new (void);
-
-void icaltimezone_array_append_from_vtimezone (icalarray *timezones,
- icalcomponent *child);
-void icaltimezone_array_free (icalarray *timezones);
-
-
-
-/*
- * Debugging Output.
- */
-
-/* Dumps information about changes in the timezone up to and including
- max_year. */
-int icaltimezone_dump_changes (icaltimezone *zone,
- int max_year,
- FILE *fp);
-
-#endif /* ICALTIMEZONE_H */
diff --git a/libical/src/libical/icaltypes.c b/libical/src/libical/icaltypes.c
deleted file mode 100644
index c6c388a978..0000000000
--- a/libical/src/libical/icaltypes.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icaltypes.c
- CREATOR: eric 16 May 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 icaltypes.c
-
- ======================================================================*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icaltypes.h"
-#include "icalerror.h"
-#include "icalmemory.h"
-#include <stdlib.h> /* for malloc and abs() */
-#include <errno.h> /* for errno */
-#include <string.h> /* for icalmemory_strdup */
-#include <assert.h>
-
-#define TEMP_MAX 1024
-
-void*
-icalattachtype_get_data (struct icalattachtype* type);
-
-struct icalattachtype*
-icalattachtype_new()
-{
- struct icalattachtype* v;
-
- if ( ( v = (struct icalattachtype*)
- malloc(sizeof(struct icalattachtype))) == 0) {
- errno = ENOMEM;
- return 0;
- }
-
- v->refcount = 1;
-
- v->binary = 0;
- v->owns_binary = 0;
-
- v->base64 = 0;
- v->owns_base64 = 0;
-
- v->url = 0;
-
- return v;
-}
-
-
-void
-icalattachtype_free(struct icalattachtype* v)
-{
- icalerror_check_arg( (v!=0),"v");
-
- v->refcount--;
-
- if (v->refcount <= 0){
-
- if (v->base64 != 0 && v->owns_base64 != 0){
- free(v->base64);
- }
-
- if (v->binary != 0 && v->owns_binary != 0){
- free(v->binary);
- }
-
- if (v->url != 0){
- free(v->url);
- }
-
- free(v);
- }
-}
-
-void icalattachtype_add_reference(struct icalattachtype* v)
-{
- icalerror_check_arg( (v!=0),"v");
- v->refcount++;
-}
-
-void icalattachtype_set_url(struct icalattachtype* v, char* url)
-{
- icalerror_check_arg( (v!=0),"v");
-
- if (v->url != 0){
- free (v->url);
- }
-
- v->url = icalmemory_strdup(url);
-
- /* HACK This routine should do something if icalmemory_strdup returns NULL */
-
-}
-
-char* icalattachtype_get_url(struct icalattachtype* v)
-{
- icalerror_check_arg( (v!=0),"v");
- return v->url;
-}
-
-void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
- int owns)
-{
- icalerror_check_arg( (v!=0),"v");
-
- v->base64 = base64;
- v->owns_base64 = !(owns != 0 );
-
-}
-
-char* icalattachtype_get_base64(struct icalattachtype* v)
-{
- icalerror_check_arg( (v!=0),"v");
- return v->base64;
-}
-
-void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
- int owns)
-{
- icalerror_check_arg( (v!=0),"v");
-
- v->binary = binary;
- v->owns_binary = !(owns != 0 );
-
-}
-
-void* icalattachtype_get_binary(struct icalattachtype* v)
-{
- icalerror_check_arg( (v!=0),"v");
- return v->binary;
-}
-
-
-struct icaltriggertype icaltriggertype_from_string(const char* str)
-{
-
-
- struct icaltriggertype tr, null_tr;
- int old_ieaf = icalerror_errors_are_fatal;
-
- tr.time= icaltime_null_time();
- tr.duration = icaldurationtype_from_int(0);
-
- null_tr = tr;
-
- if(str == 0) goto error;
-
-
- icalerror_errors_are_fatal = 0;
-
- tr.time = icaltime_from_string(str);
-
- icalerror_errors_are_fatal = old_ieaf;
-
- if (icaltime_is_null_time(tr.time)){
-
- tr.duration = icaldurationtype_from_string(str);
-
- if(icaldurationtype_as_int(tr.duration) == 0) goto error;
- }
-
- return tr;
-
- error:
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return null_tr;
-
-}
-
-
-struct icalreqstattype icalreqstattype_from_string(char* str)
-{
- char *p1,*p2;
- struct icalreqstattype stat;
- int major, minor;
-
- icalerror_check_arg((str != 0),"str");
-
- stat.code = ICAL_UNKNOWN_STATUS;
- stat.debug = 0;
- stat.desc = 0;
-
- /* Get the status numbers */
-
- sscanf(str, "%d.%d",&major, &minor);
-
- if (major <= 0 || minor < 0){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return stat;
- }
-
- stat.code = icalenum_num_to_reqstat(major, minor);
-
- if (stat.code == ICAL_UNKNOWN_STATUS){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return stat;
- }
-
-
- p1 = strchr(str,';');
-
- if (p1 == 0){
-/* icalerror_set_errno(ICAL_BADARG_ERROR);*/
- return stat;
- }
-
- /* Just ignore the second clause; it will be taken from inside the library
- */
-
-
-
- p2 = strchr(p1+1,';');
- if (p2 != 0 && *p2 != 0){
- stat.debug = p2+1;
- }
-
- return stat;
-
-}
-
-char* icalreqstattype_as_string(struct icalreqstattype stat)
-{
- char *temp;
-
- temp = (char*)icalmemory_tmp_buffer(TEMP_MAX);
-
- icalerror_check_arg_rz((stat.code != ICAL_UNKNOWN_STATUS),"Status");
-
- if (stat.desc == 0){
- stat.desc = icalenum_reqstat_desc(stat.code);
- }
-
- if(stat.debug != 0){
- snprintf(temp,TEMP_MAX,"%d.%d;%s;%s", icalenum_reqstat_major(stat.code),
- icalenum_reqstat_minor(stat.code),
- stat.desc, stat.debug);
-
- } else {
- snprintf(temp,TEMP_MAX,"%d.%d;%s", icalenum_reqstat_major(stat.code),
- icalenum_reqstat_minor(stat.code),
- stat.desc);
- }
-
- return temp;
-}
diff --git a/libical/src/libical/icaltypes.h b/libical/src/libical/icaltypes.h
deleted file mode 100644
index 04e04c9dc3..0000000000
--- a/libical/src/libical/icaltypes.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icaltypes.h
- CREATOR: eric 20 March 1999
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The original code is icaltypes.h
-
-======================================================================*/
-
-#ifndef ICALTYPES_H
-#define ICALTYPES_H
-
-#include <time.h>
-#include "icalenums.h"
-#include "icaltime.h"
-#include "icalduration.h"
-#include "icalperiod.h"
-
-
-/* This type type should probably be an opaque type... */
-struct icalattachtype
-{
- void* binary;
- int owns_binary;
-
- char* base64;
- int owns_base64;
-
- char* url;
-
- int refcount;
-
-};
-
-/* converts base64 to binary, fetches url and stores as binary, or
- just returns data */
-
-struct icalattachtype* icalattachtype_new(void);
-void icalattachtype_add_reference(struct icalattachtype* v);
-void icalattachtype_free(struct icalattachtype* v);
-
-void icalattachtype_set_url(struct icalattachtype* v, char* url);
-char* icalattachtype_get_url(struct icalattachtype* v);
-
-void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
- int owns);
-char* icalattachtype_get_base64(struct icalattachtype* v);
-
-void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
- int owns);
-void* icalattachtype_get_binary(struct icalattachtype* v);
-
-struct icalgeotype
-{
- float lat;
- float lon;
-};
-
-
-struct icaldatetimeperiodtype
-{
- struct icaltimetype time;
- struct icalperiodtype period;
-};
-
-
-struct icaltriggertype
-{
- struct icaltimetype time;
- struct icaldurationtype duration;
-};
-
-struct icaltriggertype icaltriggertype_from_string(const char* str);
-
-/* struct icalreqstattype. This struct contains two string pointers,
-but don't try to free either of them. The "desc" string is a pointer
-to a static table inside the library. Don't try to free it. The
-"debug" string is a pointer into the string that the called passed
-into to icalreqstattype_from_string. Don't try to free it either, and
-don't use it after the original string has been freed.
-
-BTW, you would get that original string from
-*icalproperty_get_requeststatus() or icalvalue_get_text(), when
-operating on a the value of a request_status property. */
-
-struct icalreqstattype {
-
- icalrequeststatus code;
- const char* desc;
- const char* debug;
-};
-
-struct icalreqstattype icalreqstattype_from_string(char* str);
-char* icalreqstattype_as_string(struct icalreqstattype);
-
-
-
-struct icaltimezonephase {
- const char* tzname;
- int is_stdandard; /* 1 = standard tme, 0 = daylight savings time */
- struct icaltimetype dtstart;
- int offsetto;
- int tzoffsetfrom;
- const char* comment;
- struct icaldatetimeperiodtype rdate;
- const char* rrule;
-};
-
-
-struct icaltimezonetype {
- const char* tzid;
- struct icaltimetype last_mod;
- const char* tzurl;
-
- /* Array of phases. The end of the array is a phase with tzname == 0 */
- struct icaltimezonephase *phases;
-};
-
-void icaltimezonetype_free(struct icaltimezonetype tzt);
-
-
-#endif /* !ICALTYPES_H */
diff --git a/libical/src/libical/icalvalue.c b/libical/src/libical/icalvalue.c
deleted file mode 100644
index 8c5c1303ea..0000000000
--- a/libical/src/libical/icalvalue.c
+++ /dev/null
@@ -1,1196 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalvalue.c
- CREATOR: eric 02 May 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 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 "icalvalueimpl.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_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;
- v->x_value = 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)
-{
- const 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:
- {
- *pout = '\0';
- break;
-
- }
- 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_enum(icalvalue_kind kind, int x_type, const char* str)
-{
- int e = icalproperty_string_to_enum(str);
- struct icalvalue_impl *value;
-
- if(e != 0 && icalproperty_enum_belongs_to_property(
- icalproperty_value_kind_to_kind(kind),e)) {
-
- value = icalvalue_new_impl(kind);
- value->data.v_enum = e;
- } else {
- /* Make it an X value */
- value = icalvalue_new_impl(kind);
- value->data.v_enum = x_type;
- icalvalue_set_x(value,str);
- }
-
- return value;
-}
-
-
-icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* str,icalproperty** error)
-{
-
- struct icalvalue_impl *value = 0;
-
- icalerror_check_arg_rz(str!=0,"str");
-
- if (error != 0){
- *error = 0;
- }
-
- switch (kind){
-
- case ICAL_ATTACH_VALUE:
- case ICAL_BINARY_VALUE:
- case ICAL_BOOLEAN_VALUE:
- {
- /* HACK */
- value = 0;
-
- if (error != 0){
- char temp[TMP_BUF_SIZE];
- sprintf(temp,"%s Values are not implemented",
- icalparameter_kind_to_string(kind));
- *error = icalproperty_vanew_xlicerror(
- temp,
- icalparameter_new_xlicerrortype(
- ICAL_XLICERRORTYPE_VALUEPARSEERROR),
- 0);
- }
- break;
- }
-
-
- case ICAL_TRANSP_VALUE:
- value = icalvalue_new_enum(kind, ICAL_TRANSP_X,str);
- break;
- case ICAL_METHOD_VALUE:
- value = icalvalue_new_enum(kind, ICAL_METHOD_X,str);
- break;
- case ICAL_STATUS_VALUE:
- value = icalvalue_new_enum(kind, ICAL_STATUS_X,str);
- break;
- case ICAL_ACTION_VALUE:
- value = icalvalue_new_enum(kind, ICAL_ACTION_X,str);
- break;
- case ICAL_CLASS_VALUE:
- value = icalvalue_new_enum(kind, ICAL_CLASS_X,str);
- 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_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:
- {
- struct icalrecurrencetype rt;
- rt = icalrecurrencetype_from_string(str);
- value = icalvalue_new_recur(rt);
- break;
- }
-
- case ICAL_TIME_VALUE:
- case ICAL_DATE_VALUE:
- case ICAL_DATETIME_VALUE:
- case ICAL_DATETIMEDATE_VALUE:
- {
- struct icaltimetype tt;
- tt = icaltime_from_string(str);
- if(!icaltime_is_null_time(tt)){
- value = icalvalue_new_impl(kind);
- value->data.v_time = tt;
- }
- break;
- }
-
- case ICAL_DATETIMEPERIOD_VALUE:
- {
- struct icaltimetype tt;
- struct icalperiodtype p;
- tt = icaltime_from_string(str);
- p = icalperiodtype_from_string(str);
-
- if(!icaltime_is_null_time(tt)){
- value = icalvalue_new_datetime(tt);
- } else if (!icalperiodtype_is_null_period(p)){
- value = icalvalue_new_period(p);
- }
-
- break;
- }
-
- case ICAL_DURATION_VALUE:
- {
- struct icaldurationtype dur = icaldurationtype_from_string(str);
-
- if(icaldurationtype_is_null_duration(dur)){
- value = 0;
- } else {
- value = icalvalue_new_duration(dur);
- }
-
- break;
- }
-
- case ICAL_PERIOD_VALUE:
- {
- struct icalperiodtype p;
- p = icalperiodtype_from_string(str);
-
- if(!icalperiodtype_is_null_period(p)){
- value = icalvalue_new_period(p);
- }
- break;
- }
-
- case ICAL_TRIGGER_VALUE:
- {
- struct icaltriggertype tr = icaltriggertype_from_string(str);
- value = icalvalue_new_trigger(tr);
- 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
-
- if(v->x_value != 0){
- free(v->x_value);
- }
-
- 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;
-}
-
-
-#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign*/
-char* icalvalue_int_as_ical_string(icalvalue* value) {
-
- int data;
- char* str = (char*)icalmemory_tmp_buffer(MAX_INT_DIGITS);
-
- icalerror_check_arg_rz( (value!=0),"value");
-
- data = icalvalue_get_integer(value);
-
- snprintf(str,MAX_INT_DIGITS,"%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)
-{
- struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
- struct icalrecurrencetype *recur = impl->data.v_recur;
-
- return icalrecurrencetype_as_string(recur);
-}
-
-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;
- }
-}
-
-
-char* icalvalue_duration_as_ical_string(icalvalue* value) {
-
- struct icaldurationtype data;
-
- icalerror_check_arg_rz( (value!=0),"value");
- data = icalvalue_get_duration(value);
-
- return icaldurationtype_as_ical_string(data);
-}
-
-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);
-}
-
-const char* icalvalue_datetime_as_ical_string(icalvalue* value) {
-
- struct icaltimetype data;
- char* str;
- icalvalue_kind kind = icalvalue_isa(value);
-
- icalerror_check_arg_rz( (value!=0),"value");
-
-
- if( !(kind == ICAL_DATETIMEDATE_VALUE ||
- kind == ICAL_DATE_VALUE ||
- kind == ICAL_DATETIME_VALUE ||
- kind == ICAL_TIME_VALUE))
- {
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return 0;
- }
-
- data = icalvalue_get_datetime(value);
-
- str = (char*)icalmemory_tmp_buffer(20);
-
- str[0] = 0;
-
- print_datetime_to_string(str,&data);
-
- return str;
-
-}
-
-
-const 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;
-}
-
-const char* icalvalue_datetimeperiod_as_ical_string(icalvalue* value) {
- struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value);
-
- icalerror_check_arg_rz( (value!=0),"value");
-
- if(!icaltime_is_null_time(dtp.time)){
- return icaltime_as_ical_string(dtp.time);
- } else {
- return icalperiodtype_as_ical_string(dtp.period);
- }
-}
-
-const char* icalvalue_period_as_ical_string(icalvalue* value) {
- struct icalperiodtype data;
- icalerror_check_arg_rz( (value!=0),"value");
- data = icalvalue_get_period(value);
-
- return icalperiodtype_as_ical_string(data);
-
-}
-
-char* icalvalue_trigger_as_ical_string(icalvalue* value) {
-
- struct icaltriggertype data;
-
- icalerror_check_arg_rz( (value!=0),"value");
- data = icalvalue_get_trigger(value);
-
- if(!icaltime_is_null_time(data.time)){
- return icaltime_as_ical_string(data.time);
- } else {
- return icaldurationtype_as_ical_string(data.duration);
- }
-
-}
-
-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_ACTION_VALUE:
- case ICAL_METHOD_VALUE:
- case ICAL_STATUS_VALUE:
- case ICAL_TRANSP_VALUE:
- case ICAL_CLASS_VALUE:
- if(v->x_value !=0){
- return icalmemory_tmp_copy(v->x_value);
- }
-
- return icalproperty_enum_to_string(v->data.v_enum);
-
- case ICAL_X_VALUE:
- return icalmemory_tmp_copy(v->x_value);
-
- 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;
- }
-}
-
-
-int icalvalue_is_time(icalvalue* a) {
- icalvalue_kind kind = icalvalue_isa(a);
-
- if(kind == ICAL_DATETIMEDATE_VALUE ||
- kind == ICAL_DATETIME_VALUE ||
- kind == ICAL_DATE_VALUE ||
- kind == ICAL_TIME_VALUE ){
- return 1;
- }
-
- 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_is_time(a) && icalvalue_is_time(b)) &&
- 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_DURATION_VALUE:
- {
- int a = icaldurationtype_as_int(impla->data.v_duration);
- int b = icaldurationtype_as_int(implb->data.v_duration);
-
- if (a > b){
- return ICAL_XLICCOMPARETYPE_GREATER;
- } else if (a < b){
- 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_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 ICAL_XLICCOMPARETYPE_EQUAL;
- }
-
-
- }
-
- 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;
-}
-
-
-
-/* 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 b/libical/src/libical/icalvalue.h
deleted file mode 100644
index 6983c23275..0000000000
--- a/libical/src/libical/icalvalue.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalvalue.h
- CREATOR: eric 20 March 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 icalvalue.h
-
- ======================================================================*/
-
-#ifndef ICALVALUE_H
-#define ICALVALUE_H
-
-#include <time.h>
-#include "icalenums.h"
-#include "icaltypes.h"
-#include "icalrecur.h"
-#include "icalduration.h"
-#include "icalperiod.h"
-#include "icalderivedproperty.h" /* For icalproperty_method, etc. */
-#include "icalderivedparameter.h"
-#include "icalderivedvalue.h"
-
-/* Defined in icalderivedvalue.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);
-
-
-/* Special, non autogenerated value accessors */
-
-icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
-void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
-struct icalrecurrencetype icalvalue_get_recur(icalvalue* value);
-
-icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
-void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
-struct icaltriggertype icalvalue_get_trigger(icalvalue* value);
-
-icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
-void icalvalue_set_datetimeperiod(icalvalue* value,
- struct icaldatetimeperiodtype v);
-struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value);
-
-/* Convert enumerations */
-
-icalvalue_kind icalvalue_string_to_kind(const char* str);
-const char* icalvalue_kind_to_string(icalvalue_kind kind);
-
-
-#endif /*ICALVALUE_H*/
diff --git a/libical/src/libical/icalvalueimpl.h b/libical/src/libical/icalvalueimpl.h
deleted file mode 100644
index b103c9cb3f..0000000000
--- a/libical/src/libical/icalvalueimpl.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalvalue.c
- CREATOR: eric 02 May 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 icalvalue.c
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
-
-======================================================================*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef ICALVALUEIMPL_H
-#define ICALVALUEIMPL_H
-
-#include "icalenums.h"
-
-
-struct icalvalue_impl {
- icalvalue_kind kind; /*this is the kind that is visible from the outside*/
-
- char id[5];
- int size;
- icalproperty* parent;
- const char* x_value;
-
- 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;
- struct icaltriggertype v_trigger;
-
- int v_enum;
- /* v_enum takes care of several enumerated types including:
- icalproperty_method v_method;
- icalproperty_status v_status;
- icalproperty_action v_action;
- icalproperty_class v_class;
- icalproperty_transp v_transp;
- */
-
- } data;
-};
-
-#endif
diff --git a/libical/src/libical/icalversion.h.in b/libical/src/libical/icalversion.h.in
deleted file mode 100644
index 5d213693e5..0000000000
--- a/libical/src/libical/icalversion.h.in
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef ICAL_VERSION_H
-#define ICAL_VERSION_H
-
-#define ICAL_PACKAGE "@PACKAGE@"
-#define ICAL_VERSION "@VERSION@"
-
-#endif
diff --git a/libical/src/libical/icalyacc.y b/libical/src/libical/icalyacc.y
deleted file mode 100644
index c78299fa2a..0000000000
--- a/libical/src/libical/icalyacc.y
+++ /dev/null
@@ -1,404 +0,0 @@
-%{
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalitip.y
- CREATOR: eric 10 June 1999
-
- DESCRIPTION:
-
- $Id: icalyacc.y,v 1.12 2001/06/14 02:50:46 damon Exp $
- $Locker: $
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
- The original code is icalitip.y
-
-
-
- =======================================================================*/
-
-#include <stdlib.h>
-#include <string.h> /* for strdup() */
-#include "icalparser.h"
-#include "pvl.h"
-
-icalvalue *icalparser_yy_value; /* Current Value */
-
-void ical_yyerror(char* s);
-void icalparser_clear_flex_input();
-int ical_yy_lex(void);
-
-/* Globals for UTCOFFSET values */
-int utc;
-int utc_b;
-int utcsign;
-
-/* Globals for DURATION values */
-struct icaldurationtype duration;
-
-/* Globals for TRIGGER values */
-struct icaltriggertype trigger;
-
-void copy_list(short* array, size_t size);
-void add_prop(icalproperty_kind);
-void icalparser_fill_date(struct tm* t, char* dstr);
-void icalparser_fill_time(struct tm* t, char* tstr);
-void set_value_type(icalvalue_kind kind);
-void set_parser_value_state();
-struct icaltimetype fill_datetime(char* d, char* t);
-void ical_yy_error(char *s); /* Don't know why I need this.... */
-int yylex(void); /* Or this. */
-
-
-
-/* Set the state of the lexer so it will interpret values ( iCAL
- VALUEs, that is, ) correctly. */
-
-%}
-
-%union {
- float v_float;
- int v_int;
- char* v_string;
-}
-
-
- /* Renaming hack */
-
-/*
-#define yymaxdepth ical_yy_maxdepth
-#define yyparse ical_yy_parse
-#define yyerror ical_yy_error
-#define yylval ical_yy_lval
-#define yychar ical_yy_char
-#define yydebug ical_yy_debug
-#define yypact ical_yy_pact
-#define yyr1 ical_yy_r1
-#define yyr2 ical_yy_r2
-#define yydef ical_yy_def
-#define yychk ical_yy_chk
-#define yypgo ical_yy_pgo
-#define yyact ical_yy_act
-#define yyexca ical_yy_exca
-#define yyerrflag ical_yy_errflag
-#define yynerrs ical_yy_nerrs
-#define yyps ical_yy_ps
-#define yypv ical_yy_pv
-#define yys ical_yy_s
-#define yy_yys ical_yy_yys
-#define yystate ical_yy_state
-#define yytmp ical_yy_tmp
-#define yyv ical_yy_v
-#define yy_yyv ical_yy_yyv
-#define yyval ical_yy_val
-#define yylloc ical_yy_lloc
-#define yyreds ical_yy_reds
-#define yytoks ical_yy_toks
-#define yylhs ical_yy_yylhs
-#define yylen ical_yy_yylen
-#define yydefred ical_yy_yydefred
-#define yydgoto ical_yy_yydgoto
-#define yydefred ical_yy_yydefred
-#define yydgoto ical_yy_yydgoto
-#define yysindex ical_yy_yysindex
-#define yyrindex ical_yy_yyrindex
-#define yygindex ical_yy_yygindex
-#define yytable ical_yy_yytable
-#define yycheck ical_yy_yycheck
-#define yyname ical_yy_yyname
-#define yyrule ical_yy_yyrule
-#define yy_scan_bytes ical_yy_scan_bytes
-#define yy_scan_string ical_yy_scan_string
-#define yy_scan_buffer ical_yy_scan_buffer
-*/
-
-/* These are redefined with the -P option to flex */
-/*
-#define yy_create_buffer ical_yy_create_buffer
-#define yy_delete_buffer ical_yy_delete_buffer
-#define yy_flex_debug ical_yy_flex_debug
-#define yy_init_buffer ical_yy_init_buffer
-#define yy_flush_buffer ical_yy_flush_buffer
-#define yy_load_buffer_state ical_yy_load_buffer_state
-#define yy_switch_to_buffer ical_yy_switch_to_buffer
-#define yyin ical_yyin
-#define yyleng ical_yyleng
-#define yylex ical_yylex
-#define yylineno ical_yylineno
-#define yyout ical_yyout
-#define yyrestart ical_yyrestart
-#define yytext ical_yytext
-#define yywrap ical_yywrap
-*/
-
-
-%token <v_string> DIGITS
-%token <v_int> INTNUMBER
-%token <v_float> FLOATNUMBER
-%token <v_string> STRING
-%token EOL EQUALS CHARACTER COLON COMMA SEMICOLON MINUS TIMESEPERATOR
-
-%token TRUE FALSE
-
-%token FREQ BYDAY BYHOUR BYMINUTE BYMONTH BYMONTHDAY BYSECOND BYSETPOS BYWEEKNO
-%token BYYEARDAY DAILY MINUTELY MONTHLY SECONDLY WEEKLY HOURLY YEARLY
-%token INTERVAL COUNT UNTIL WKST MO SA SU TU WE TH FR
-
-%token BIT8 ACCEPTED ADD AUDIO BASE64 BINARY BOOLEAN BUSY BUSYTENTATIVE
-%token BUSYUNAVAILABLE CALADDRESS CANCEL CANCELLED CHAIR CHILD COMPLETED
-%token CONFIDENTIAL CONFIRMED COUNTER DATE DATETIME DECLINECOUNTER DECLINED
-%token DELEGATED DISPLAY DRAFT DURATION EMAIL END FINAL FLOAT FREE GREGORIAN
-%token GROUP INDIVIDUAL INPROCESS INTEGER NEEDSACTION NONPARTICIPANT
-%token OPAQUE OPTPARTICIPANT PARENT PERIOD PRIVATE PROCEDURE PUBLIC PUBLISH
-%token RECUR REFRESH REPLY REQPARTICIPANT REQUEST RESOURCE ROOM SIBLING
-%token START TENTATIVE TEXT THISANDFUTURE THISANDPRIOR TIME TRANSPAENT
-%token UNKNOWN UTCOFFSET XNAME
-
-%token ALTREP CN CUTYPE DAYLIGHT DIR ENCODING EVENT FBTYPE FMTTYPE LANGUAGE
-%token MEMBER PARTSTAT RANGE RELATED RELTYPE ROLE RSVP SENTBY STANDARD URI
-
-%token TIME_CHAR UTC_CHAR
-
-
-%%
-
-value:
- date_value
- | datetime_value
- | duration_value
- | period_value
- | utcoffset_value
- | error {
- icalparser_yy_value = 0;
- icalparser_clear_flex_input();
- yyclearin;
- }
-
-
-date_value: DIGITS
- {
- struct icaltimetype stm;
-
- stm = fill_datetime($1,0);
-
- stm.hour = -1;
- stm.minute = -1;
- stm.second = -1;
- stm.is_utc = 0;
- stm.is_date = 1;
-
- icalparser_yy_value = icalvalue_new_date(stm);
- }
-
-utc_char:
- /*empty*/ {utc = 0;}
- | UTC_CHAR {utc = 1;}
-
-/* This is used in the period_value, where there may be two utc characters per rule. */
-utc_char_b:
- /*empty*/ {utc_b = 0;}
- | UTC_CHAR {utc_b = 1;}
-
-datetime_value:
- DIGITS TIME_CHAR DIGITS utc_char
- {
- struct icaltimetype stm;
- stm = fill_datetime($1, $3);
- stm.is_utc = utc;
- stm.is_date = 0;
-
- icalparser_yy_value =
- icalvalue_new_datetime(stm);
- }
-
-
-/* Duration */
-
-
-dur_date: dur_day
- | dur_day dur_time
-
-dur_week: DIGITS 'W'
- {
- duration.weeks = atoi($1);
- }
-
-dur_time: TIME_CHAR dur_hour
- {
- }
- | TIME_CHAR dur_minute
- {
- }
- | TIME_CHAR dur_second
- {
- }
-
-dur_hour: DIGITS 'H'
- {
- duration.hours = atoi($1);
- }
- | DIGITS 'H' dur_minute
- {
- duration.hours = atoi($1);
- }
-
-dur_minute: DIGITS 'M'
- {
- duration.minutes = atoi($1);
- }
- | DIGITS 'M' dur_second
- {
- duration.minutes = atoi($1);
- }
-
-dur_second: DIGITS 'S'
- {
- duration.seconds = atoi($1);
- }
-
-dur_day: DIGITS 'D'
- {
- duration.days = atoi($1);
- }
-
-dur_prefix: /* empty */
- {
- duration.is_neg = 0;
- }
- | '+'
- {
- duration.is_neg = 0;
- }
- | '-'
- {
- duration.is_neg = 1;
- }
-
-duration_value: dur_prefix 'P' dur_date
- {
- icalparser_yy_value = icalvalue_new_duration(duration);
- memset(&duration,0, sizeof(duration));
- }
- | dur_prefix 'P' dur_time
- {
- icalparser_yy_value = icalvalue_new_duration(duration);
- memset(&duration,0, sizeof(duration));
- }
- | dur_prefix 'P' dur_week
- {
- icalparser_yy_value = icalvalue_new_duration(duration);
- memset(&duration,0, sizeof(duration));
- }
-
-
-/* Period */
-
-period_value: DIGITS TIME_CHAR DIGITS utc_char '/' DIGITS TIME_CHAR DIGITS utc_char_b
- {
- struct icalperiodtype p;
-
- p.start = fill_datetime($1,$3);
- p.start.is_utc = utc;
- p.start.is_date = 0;
-
-
- p.end = fill_datetime($6,$8);
- p.end.is_utc = utc_b;
- p.end.is_date = 0;
-
- p.duration.days = -1;
- p.duration.weeks = -1;
- p.duration.hours = -1;
- p.duration.minutes = -1;
- p.duration.seconds = -1;
-
- icalparser_yy_value = icalvalue_new_period(p);
- }
- | DIGITS TIME_CHAR DIGITS utc_char '/' duration_value
- {
- struct icalperiodtype p;
-
- p.start = fill_datetime($1,$3);
- p.start.is_utc = utc;
- p.start.is_date = 0;
-
- p.end.year = -1;
- p.end.month = -1;
- p.end.day = -1;
- p.end.hour = -1;
- p.end.minute = -1;
- p.end.second = -1;
-
- /* The duration_value rule setes the global 'duration'
- variable, but it also creates a new value in
- icalparser_yy_value. So, free that, then copy
- 'duration' into the icalperiodtype struct. */
-
- p.duration = icalvalue_get_duration(icalparser_yy_value);
- icalvalue_free(icalparser_yy_value);
- icalparser_yy_value = 0;
-
- icalparser_yy_value = icalvalue_new_period(p);
-
- }
-
-
-trigger:
-
-
-
-/* UTC Offset */
-
-plusminus: '+' { utcsign = 1; }
- | '-' { utcsign = -1; }
-
-utcoffset_value:
- plusminus INTNUMBER INTNUMBER
- {
- icalparser_yy_value = icalvalue_new_utcoffset( utcsign * (($2*3600) + ($3*60)) );
- }
-
- | plusminus INTNUMBER INTNUMBER INTNUMBER
- {
- icalparser_yy_value = icalvalue_new_utcoffset(utcsign * (($2*3600) + ($3*60) +($4)));
- }
-
-%%
-
-struct icaltimetype fill_datetime(char* datestr, char* timestr)
-{
- struct icaltimetype stm;
-
- memset(&stm,0,sizeof(stm));
-
- if (datestr != 0){
- sscanf(datestr,"%4d%2d%2d",&(stm.year), &(stm.month),
- &(stm.day));
- }
-
- if (timestr != 0){
- sscanf(timestr,"%2d%2d%2d", &(stm.hour), &(stm.minute),
- &(stm.second));
- }
-
- return stm;
-
-}
-
-void ical_yyerror(char* s)
-{
- /*fprintf(stderr,"Parse error \'%s\'\n", s);*/
-}
-
diff --git a/libical/src/libical/pvl.c b/libical/src/libical/pvl.c
deleted file mode 100644
index 2a733e8aa9..0000000000
--- a/libical/src/libical/pvl.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/*======================================================================
- FILE: pvl.c
- CREATOR: eric November, 1995
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-======================================================================*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pvl.h"
-#include <errno.h>
-#include <assert.h>
-#include <stdlib.h>
-
-
-
-/*
- struct pvl_list_t
-
- The list structure. This is the hanlde for the entire list
-
- This type is also private. Use pvl_list instead
-
- */
-
-typedef struct pvl_list_t
-{
- int MAGIC; /* Magic Identifier */
- struct pvl_elem_t *head; /* Head of list */
- struct pvl_elem_t *tail; /* Tail of list */
- int count; /* Number of items in the list */
- struct pvl_elem_t *p; /* Pointer used for iterators */
-} pvl_list_t;
-
-
-
-
-/* This global is incremented for each call to pvl_new_element(); it gives each
- * list a unique identifer */
-
-int pvl_elem_count = 0;
-int pvl_list_count = 0;
-
-
-/*----------------------------------------------------------------------
- Function: pvl_list pvl_newlist()
-
- Purpose:
-
- Creates a new list, clears the pointers and assigns a magic number
-
- Returns:
-
- Pointer to the new list
- 0 if there is no available memory.
- *----------------------------------------------------------------------*/
-
-pvl_list
-pvl_newlist()
-{
- struct pvl_list_t *L;
-
- if ( ( L = (struct pvl_list_t*)malloc(sizeof(struct pvl_list_t))) == 0)
- {
- errno = ENOMEM;
- return 0;
- }
-
- L->MAGIC = pvl_list_count;
- pvl_list_count++;
- L->head = 0;
- L->tail = 0;
- L->count = 0;
- L->p = 0;
-
- return L;
-}
-
-void
-pvl_free(pvl_list l)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- pvl_clear(l);
-
- free(L);
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_new_element(void *d, struct pvl_elem_t *next,struct pvl_elem_t *prior)
-
- Purpose:
- Creates a new list element, assigns a magic number, and assigns
- the next and previous pointers.
-
- Passing in the next and previous points may seem odd, but it allos the user
- to set them while keeping the internal data hidden. In nearly all cases,
- the user is the pvl library itself.
-
- Parameters:
-
- d The data item to be stored in the list
- next Pointer value to assign to the member "next"
- prior Pointer value to assign to the member "prior"
-
- Returns:
-
- A pointer to the new element.
- 0 if there is no memory available.
-
- *----------------------------------------------------------------------*/
-
-pvl_elem
-pvl_new_element(void *d, pvl_elem next,pvl_elem prior)
-{
- struct pvl_elem_t *E;
-
- if ( ( E = (struct pvl_elem_t*)malloc(sizeof(struct pvl_elem_t))) == 0)
- {
- errno = ENOMEM;
- return 0;
- }
-
- E->MAGIC = pvl_elem_count++;
- E->d = d;
- E->next = next;
- E->prior = prior;
-
- return (pvl_elem)E;
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_unshift(pvl_list l,void *d)
-
- Purpose:
-
- Add a new element to the from of the list
-
- Parameters:
-
- l The list to add the item to
- d Pointer to the item to add
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void
-pvl_unshift(pvl_list l,void *d)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- struct pvl_elem_t *E = pvl_new_element(d,L->head,0);
-
- if (E->next != 0)
- {
- /* Link the head node to it */
- E->next->prior = E;
- }
-
- /* move the head */
- L->head = E;
-
- /* maybe move the tail */
-
- if (L->tail == 0)
- {
- L->tail = E;
- }
-
- L->count++;
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_shift(pvl_list l)
-
- Purpose:
-
- Remove an element from the front of the list
-
- Parameters:
-
- l The list to operate on
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void*
-pvl_shift(pvl_list l)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- if (L->head == 0)
- {
- return 0;
- }
-
- return pvl_remove(l,(void*)L->head);
-
-}
-
-/*----------------------------------------------------------------------
- Function: void pvl_push(pvl_list l,void *d)
-
- Purpose:
-
- Add a new item to the tail of the list
-
- Paramters:
-
- l The list to operate on
- d Pointer to the item to add
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void
-pvl_push(pvl_list l,void *d)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- struct pvl_elem_t *E = pvl_new_element(d,0,L->tail);
-
- /* These are done in pvl_new_element
- E->next = 0;
- E->prior = L->tail;
- */
-
- if (L->tail != 0)
- {
- L->tail->next = E;
- }
-
- if (L->head == 0)
- {
- L->head = E;
- }
-
- L->tail = E;
-
- L->count++;
-
-}
-
-/*----------------------------------------------------------------------
- Function: void* pvl_pop(pvl_list l)
-
- Purpose:
-
- Remove an element from the tail of the list
-
- Paramters:
-
- l The list to operate on
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void*
-pvl_pop(pvl_list l)
-{
-
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- if ( L->tail == 0)
- {
- return 0;
- }
-
- return pvl_remove(l,(void*) L->tail);;
-
-}
-
-
-/*----------------------------------------------------------------------
- Function: void pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
-
- Purpose:
-
- Add a new item to a list that is ordered by a comparison function.
- This routine assumes that the list is properly ordered.
-
- l The list to operate on
- f Pointer to a comparison function
- d Pointer to data to pass to the comparison function
-
- Returns:
-
- void
-
- *----------------------------------------------------------------------*/
-
-void
-pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- struct pvl_elem_t *P;
-
- L->count++;
-
- /* Empty list, add to head */
-
- if(L->head == 0)
- {
- pvl_unshift(l,d);
- return;
- }
-
- /* smaller than head, add to head */
-
- if ( ((*f)(d,L->head->d)) <= 0)
- {
- pvl_unshift(l,d);
- return;
- }
-
- /* larger than tail, add to tail */
- if ( (*f)(d,L->tail->d) >= 0)
- {
- pvl_push(l,d);
- return;
- }
-
-
- /* Search for the first element that is smaller, and add before it */
-
- for (P=L->head; P != 0; P = P->next)
- {
- if ( (*f)(P->d,d) >= 0)
- {
- pvl_insert_before(l,P,d);
- return;
- }
- }
-
- /* badness, choke */
-
- assert(0);
-
-}
-
-/*----------------------------------------------------------------------
- Function: void pvl_insert_after(pvl_list l,pvl_elem p,void *d)
-
- Purpose:
-
- Add a new item after the referenced element.
-
- Parameters:
-
- l The list to operate on
- p The list element to add the item after
- d Pointer to the item to add.
-
- Returns:
-
- void
-
- *----------------------------------------------------------------------*/
-
-void
-pvl_insert_after(pvl_list l,pvl_elem p,void *d)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- struct pvl_elem_t *P = (struct pvl_elem_t *)p;
- struct pvl_elem_t *E = 0;
-
- L->count++;
-
- if (P == 0)
- {
- pvl_unshift(l,d);
- return;
- }
-
- if ( P == L->tail)
- {
- E = pvl_new_element(d,0,P);
- L->tail = E;
- E->prior->next = E;
- }
- else
- {
- E = pvl_new_element(d,P->next,P);
- E->next->prior = E;
- E->prior->next = E;
- }
-}
-
-/*----------------------------------------------------------------------
- Function: void pvl_insert_before(pvl_list l,pvl_elem p,void *d)
-
- Purpose:
-
- Add an item after a referenced item
-
- Parameters:
-
- l The list to operate on
- p The list element to add the item before
- d Pointer to the data to be added.
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void
-pvl_insert_before(pvl_list l,pvl_elem p,void *d)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- struct pvl_elem_t *P = (struct pvl_elem_t *)p;
- struct pvl_elem_t *E = 0;
-
- L->count++;
-
- if (P == 0)
- {
- pvl_unshift(l,d);
- return;
- }
-
- if ( P == L->head)
- {
- E = pvl_new_element(d,P,0);
- E->next->prior = E;
- L->head = E;
- }
- else
- {
- E = pvl_new_element(d,P,P->prior);
- E->prior->next = E;
- E->next->prior = E;
- }
-}
-
-/*----------------------------------------------------------------------
- Function: void pvl_remove(pvl_list l,pvl_elem e)
-
- Purpose:
-
- Remove the referenced item from the list
-
- This routine will free the element, but not the data item that the
- element contains.
-
- Parameters:
-
- l The list to operate on
- e The element to remove.
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void*
-pvl_remove(pvl_list l,pvl_elem e)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- struct pvl_elem_t *E = (struct pvl_elem_t *)e;
- void* data;
-
- if (E == L->head)
- {
- if (E->next != 0)
- {
- E->next->prior = 0;
- L->head = E->next;
- } else {
- /* E Also points to tail -> only one element in list */
- L->tail = 0;
- L->head = 0;
- }
- }
- else if (E == L->tail)
- {
- if (E->prior != 0)
- {
- E->prior->next = 0;
- L->tail = E->prior;
- } else {
- /* E points to the head, so it was the last element */
- /* This case should be taken care of in the previous clause */
- L->head = 0;
- L->tail = 0;
- }
- }
- else
- {
- E->prior->next = E->next;
- E->next->prior = E->prior;
- }
-
-
- L->count--;
-
- data = E->d;
-
- E->prior = 0;
- E->next = 0;
- E->d = 0;
-
- free(E);
-
- return data;
-
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v)
-
- Purpose:
-
- Return a pointer to data that satisfies a function
-
- This routine will interate through the entire list and call the
- find function for each item. It will break and return a pointer to the
- data that causes the find function to return 1.
-
- Parameters:
-
- l The list to operate on
- f Pointer to the find function
- v Pointer to constant data to pass into the function
-
- Returns:
-
- Pointer to the element that the find function found.
-
- *----------------------------------------------------------------------*/
-
-pvl_elem
-pvl_find(pvl_list l,pvl_findf f,void* v)
-{
- pvl_elem e;
-
- for (e=pvl_head(l); e!= 0; e = pvl_next(e))
- {
- if ( (*f)(((struct pvl_elem_t *)e)->d,v) == 1)
- {
- /* Save this elem for a call to find_next */
- ((struct pvl_list_t *)l)->p = e;
- return e;
- }
- }
-
- return 0;
-
-}
-/*----------------------------------------------------------------------
- Function: void* pvl_find_next(pvl_list l,pvl_findf f,void* v)
-
- Purpose:
-
- Like pvl_find(), but continues the search where the last find() or
- find_next() left off
-
- Parameters:
-
- l The list to operate on
- f Pointer to the find function
- v Pointer to constant data to pass into the function
-
- Returns:
-
- Pointer to the element that the find function found.
-
- *----------------------------------------------------------------------*/
-
-pvl_elem
-pvl_find_next(pvl_list l,pvl_findf f,void* v)
-{
-
- pvl_elem e;
-
- for (e=pvl_head(l); e!= 0; e = pvl_next(e))
- {
- if ( (*f)(((struct pvl_elem_t *)e)->d,v) == 1)
- {
- /* Save this elem for a call to find_next */
- ((struct pvl_list_t *)l)->p = e;
- return e;
- }
- }
-
- return 0;
-
-}
-
-/*----------------------------------------------------------------------
- Function: void pvl_clear(pvl_list l)
-
- Purpose:
-
- Remove the all the elements in the list. The does not free the data items
- the elements hold.
-
-
- Returns:
- *----------------------------------------------------------------------*/
-
-void
-pvl_clear(pvl_list l)
-{
- pvl_elem e = pvl_head(l);
- pvl_elem next;
-
- if (e == 0) {
- return;
- }
-
- while(e != 0)
- {
- next = pvl_next(e);
- pvl_remove(l,e);
- e = next;
- }
-}
-
-/*----------------------------------------------------------------------
- Function: int pvl_count(pvl_list l)
-
- Purpose:
-
- Returns the number of items in the list.
-
- Returns:
- *----------------------------------------------------------------------*/
-
-int
-pvl_count(pvl_list l)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- return L->count;
-}
-
-
-/*----------------------------------------------------------------------
- Function: pvl_elem pvl_next(pvl_elem e)
-
- Purpose:
- Returns a pointer to the given element
-
- Returns:
- *----------------------------------------------------------------------*/
-
-pvl_elem
-pvl_next(pvl_elem e)
-{
- struct pvl_elem_t *E = (struct pvl_elem_t *)e;
-
- if (E == 0){
- return 0;
- }
-
- return (pvl_elem)E->next;
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_elem pvl_prior(pvl_elem e)
-
- Purpose:
-
- Returns a pointer to the element previous to the element given.
-
- Returns:
- *----------------------------------------------------------------------*/
-
-pvl_elem
-pvl_prior(pvl_elem e)
-{
- struct pvl_elem_t *E = (struct pvl_elem_t *)e;
-
- return (pvl_elem)E->prior;
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_elem pvl_head(pvl_list l )
-
- Purpose:
-
- Returns a pointer to the first item in the list.
-
- Returns:
- *----------------------------------------------------------------------*/
-pvl_elem
-pvl_head(pvl_list l )
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
-
- return (pvl_elem)L->head;
-}
-
-/*----------------------------------------------------------------------
- Function: pvl_elem pvl_tail(pvl_list l)
-
- Purpose:
-
- Returns a pointer to the last item in the list.
-
- Returns:
- *----------------------------------------------------------------------*/
-pvl_elem
-pvl_tail(pvl_list l)
-{
- struct pvl_list_t *L = (struct pvl_list_t *)l;
- return (pvl_elem)L->tail;
-}
-
-/*----------------------------------------------------------------------
- Function:
-
-
- Purpose:
-
-
- Returns:
- *----------------------------------------------------------------------*/
-
-#ifndef PVL_USE_MACROS
-void*
-pvl_data(pvl_elem e)
-{
- struct pvl_elem_t *E = (struct pvl_elem_t *)e;
-
- if ( e == 0){
- return 0;
- }
-
- return E->d;
-}
-#endif
-
-/*----------------------------------------------------------------------
- Function: void pvl_apply(pvl_list l,pvl_applyf f, void *v)
-
- Purpose:
-
- Call a function for every item in the list.
-
- Paramters:
-
- l The list to operate on
- f Pointer to the function to call
- v Data to pass to the function on every iteration
-
- Returns:
-
- void
- *----------------------------------------------------------------------*/
-
-void
-pvl_apply(pvl_list l,pvl_applyf f, void *v)
-{
- pvl_elem e;
-
- for (e=pvl_head(l); e!= 0; e = pvl_next(e))
- {
- (*f)(((struct pvl_elem_t *)e)->d,v);
- }
-
-}
diff --git a/libical/src/libical/pvl.h b/libical/src/libical/pvl.h
deleted file mode 100644
index 14a15a15eb..0000000000
--- a/libical/src/libical/pvl.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*======================================================================
- FILE: pvl.h
- CREATOR: eric November, 1995
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-======================================================================*/
-
-
-#ifndef __PVL_H__
-#define __PVL_H__
-
-typedef void* pvl_list;
-typedef void* pvl_elem;
-
-/*
- struct pvl_elem_t
-
- This type is private. Always use pvl_elem instead. The struct would
- not even appear in this header except to make code in the USE_MACROS
- blocks work
-
- */
-typedef struct pvl_elem_t
-{
- int MAGIC; /* Magic Identifier */
- void *d; /* Pointer to data user is storing */
- struct pvl_elem_t *next; /* Next element */
- struct pvl_elem_t *prior; /* prior element */
-} pvl_elem_t;
-
-
-
-/* This global is incremented for each call to pvl_new_element(); it gives each
- * list a unique identifer */
-
-extern int pvl_elem_count;
-extern int pvl_list_count;
-
-/* Create new lists or elements */
-pvl_elem pvl_new_element(void* d, pvl_elem next,pvl_elem prior);
-pvl_list pvl_newlist(void);
-void pvl_free(pvl_list);
-
-/* Add, remove, or get the head of the list */
-void pvl_unshift(pvl_list l,void *d);
-void* pvl_shift(pvl_list l);
-pvl_elem pvl_head(pvl_list);
-
-/* Add, remove or get the tail of the list */
-void pvl_push(pvl_list l,void *d);
-void* pvl_pop(pvl_list l);
-pvl_elem pvl_tail(pvl_list);
-
-/* Insert elements in random places */
-typedef int (*pvl_comparef)(void* a, void* b); /* a, b are of the data type*/
-void pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d);
-void pvl_insert_after(pvl_list l,pvl_elem e,void *d);
-void pvl_insert_before(pvl_list l,pvl_elem e,void *d);
-
-/* Remove an element, or clear the entire list */
-void* pvl_remove(pvl_list,pvl_elem); /* Remove element, return data */
-void pvl_clear(pvl_list); /* Remove all elements, de-allocate all data */
-
-int pvl_count(pvl_list);
-
-/* Navagate the list */
-pvl_elem pvl_next(pvl_elem e);
-pvl_elem pvl_prior(pvl_elem e);
-
-/* get the data in the list */
-#ifndef PVL_USE_MACROS
-void* pvl_data(pvl_elem);
-#else
-#define pvl_data(x) x==0 ? 0 : ((struct pvl_elem_t *)x)->d;
-#endif
-
-
-/* Find an element for which a function returns true */
-typedef int (*pvl_findf)(void* a, void* b); /*a is list elem, b is other data*/
-pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v);
-pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v);
-
-/* Pass each element in the list to a function */
-typedef void (*pvl_applyf)(void* a, void* b); /*a is list elem, b is other data*/
-void pvl_apply(pvl_list l,pvl_applyf f, void *v);
-
-
-#endif /* __PVL_H__ */
-
-
-
-
-
diff --git a/libical/src/libical/sspm.c b/libical/src/libical/sspm.c
deleted file mode 100644
index 311747c8f5..0000000000
--- a/libical/src/libical/sspm.c
+++ /dev/null
@@ -1,1613 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: sspm.c Parse Mime
- CREATOR: eric 25 June 2000
-
- $Id$
- $Locker$
-
- 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.
-
-
- 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 Initial Developer of the Original Code is Eric Busboom
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
- ======================================================================*/
-
-#include <stdio.h>
-#include <string.h>
-#include "sspm.h"
-#include <assert.h>
-#include <ctype.h> /* for tolower */
-#include <stdlib.h> /* for malloc, free */
-#include <string.h> /* for strcasecmp */
-
-#ifdef DMALLOC
-#include "dmalloc.h"
-#endif
-
-#define TMP_BUF_SIZE 1024
-
-
-enum mime_state {
- UNKNOWN_STATE,
- IN_HEADER,
- END_OF_HEADER,
- IN_BODY,
- OPENING_PART,
- END_OF_PART,
- TERMINAL_END_OF_PART,
- END_OF_INPUT
-};
-
-struct mime_impl{
- struct sspm_part *parts;
- size_t max_parts;
- int part_no;
- int level;
- struct sspm_action_map *actions;
- char* (*get_string)(char *s, size_t size, void* data);
- void* get_string_data;
- char temp[TMP_BUF_SIZE];
- enum mime_state state;
-};
-
-void sspm_free_header(struct sspm_header *header);
-void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header);
-void sspm_read_header(struct mime_impl *impl,struct sspm_header *header);
-
-char* sspm_strdup(char* str){
-
- char* s;
-
- s = strdup(str);
-
- return s;
-}
-
-
-struct major_content_type_map
-{
- enum sspm_major_type type;
- char* str;
-
-} major_content_type_map[] =
-{
- {SSPM_MULTIPART_MAJOR_TYPE,"multipart" },
- {SSPM_TEXT_MAJOR_TYPE,"text" },
- {SSPM_TEXT_MAJOR_TYPE,"text" },
- {SSPM_IMAGE_MAJOR_TYPE,"image" },
- {SSPM_AUDIO_MAJOR_TYPE,"audio" },
- {SSPM_VIDEO_MAJOR_TYPE,"video" },
- {SSPM_APPLICATION_MAJOR_TYPE,"application" },
- {SSPM_MULTIPART_MAJOR_TYPE,"multipart" },
- {SSPM_MESSAGE_MAJOR_TYPE,"message" },
- {SSPM_UNKNOWN_MAJOR_TYPE,"" },
-};
-
-struct minor_content_type_map
-{
- enum sspm_minor_type type;
- char* str;
-
-} minor_content_type_map[] =
-{
- {SSPM_ANY_MINOR_TYPE,"*" },
- {SSPM_PLAIN_MINOR_TYPE,"plain" },
- {SSPM_RFC822_MINOR_TYPE,"rfc822" },
- {SSPM_DIGEST_MINOR_TYPE,"digest" },
- {SSPM_CALENDAR_MINOR_TYPE,"calendar" },
- {SSPM_MIXED_MINOR_TYPE,"mixed" },
- {SSPM_RELATED_MINOR_TYPE,"related" },
- {SSPM_ALTERNATIVE_MINOR_TYPE,"alternative" },
- {SSPM_PARALLEL_MINOR_TYPE, "parallel" },
- {SSPM_UNKNOWN_MINOR_TYPE,"" }
-};
-
-
-
-struct encoding_map {
- enum sspm_encoding encoding;
- char* str;
-} sspm_encoding_map[] =
-{
- {SSPM_NO_ENCODING,""},
- {SSPM_QUOTED_PRINTABLE_ENCODING,"quoted-printable"},
- {SSPM_8BIT_ENCODING,"8bit"},
- {SSPM_7BIT_ENCODING,"7bit"},
- {SSPM_BINARY_ENCODING,"binary"},
- {SSPM_BASE64_ENCODING,"base64"},
- {SSPM_UNKNOWN_ENCODING,""}
-
-};
-
-
-char* sspm_get_parameter(char* line, char* parameter)
-{
- char *p,*s,*q;
- static char name[1024];
-
- /* Find where the parameter name is in the line */
- p = strstr(line,parameter);
-
- if( p == 0){
- return 0;
- }
-
- /* skip over the parameter name, the '=' and any blank spaces */
-
- p+=strlen(parameter);
-
- while(*p==' ' || *p == '='){
- p++;
- }
-
- /*now find the next semicolon*/
-
- s = strchr(p,';');
-
- /* Strip of leading quote */
- q = strchr(p,'\"');
-
- if(q !=0){
- p = q+1;
- }
-
- if(s != 0){
- strncpy(name,p,(size_t)s-(size_t)p);
- } else {
- strcpy(name,p);
- }
-
- /* Strip off trailing quote, if it exists */
-
- q = strrchr(name,'\"');
-
- if (q != 0){
- *q='\0';
- }
-
- return name;
-}
-
-char* sspm_property_name(char* line)
-{
- static char name[1024];
- char *c = strchr(line,':');
-
- if(c != 0){
- strncpy(name,line,(size_t)c-(size_t)line);
- name[(size_t)c-(size_t)line] = '\0';
- return name;
- } else {
- return 0;
- }
-}
-
-char* sspm_value(char* line)
-{
- static char value[1024];
-
- char *c,*s, *p;
-
- /* Find the first colon and the next semicolon */
-
- c = strchr(line,':');
- s = strchr(c,';');
-
- /* Skip the colon */
- c++;
-
- if (s == 0){
- s = c+strlen(line);
- }
-
- for(p=value; c != s; c++){
- if(*c!=' ' && *c!='\n'){
- *(p++) = *c;
- }
- }
-
- *p='\0';
-
- return value;
-
-}
-
-char *mime_headers[] = {
- "Content-Type",
- "Content-Transfer-Encoding",
- "Content-Disposition",
- "Content-Id",
- "Mime-Version",
- 0
-};
-
-
-void* sspm_default_new_part()
-{
- return 0;
-}
-void sspm_default_add_line(void *part, struct sspm_header *header,
- char* line, size_t size)
-{
-}
-
-void* sspm_default_end_part(void* part)
-{
- return 0;
-}
-
-void sspm_default_free_part(void *part)
-{
-}
-
-
-
-struct sspm_action_map sspm_action_map[] =
-{
- {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,sspm_default_new_part,sspm_default_add_line,sspm_default_end_part,sspm_default_free_part},
-};
-
-int sspm_is_mime_header(char *line)
-{
- char *name = sspm_property_name(line);
- int i;
-
- if(name == 0){
- return 0;
- }
-
- for(i = 0; mime_headers[i] != 0; i++){
- if(strcasecmp(name, mime_headers[i]) == 0)
- return 1;
- }
-
- return 0;
-}
-
-int sspm_is_mail_header(char* line)
-{
- char *name = sspm_property_name(line);
-
- if (name != 0){
- return 1;
- }
-
- return 0;
-
-}
-
-int sspm_is_blank(char* line)
-{
- char *p;
- char c =0;
-
- for(p=line; *p!=0; p++){
- if( ! (*p == ' '|| *p == '\t' || *p=='\n') ){
- c++;
- }
- }
-
- if (c==0){
- return 1;
- }
-
- return 0;
-
-}
-
-int sspm_is_continuation_line(char* line)
-{
- if (line[0] == ' '|| line[0] == '\t' ) {
- return 1;
- }
-
- return 0;
-}
-
-int sspm_is_mime_boundary(char *line)
-{
- if( line[0] == '-' && line[1] == '-') {
- return 1;
- }
-
- return 0;
-}
-
-int sspm_is_mime_terminating_boundary(char *line)
-{
-
-
- if (sspm_is_mime_boundary(line) &&
- strstr(line,"--\n")){
- return 1;
- }
-
- return 0;
-}
-
-enum line_type {
- EMPTY,
- BLANK,
- MIME_HEADER,
- MAIL_HEADER,
- HEADER_CONTINUATION,
- BOUNDARY,
- TERMINATING_BOUNDARY,
- UNKNOWN_TYPE
-};
-
-
-enum line_type get_line_type(char* line){
-
- if (line == 0){
- return EMPTY;
- } else if(sspm_is_blank(line)){
- return BLANK;
- } else if (sspm_is_mime_header(line)){
- return MIME_HEADER;
- } else if (sspm_is_mail_header(line)){
- return MAIL_HEADER;
- } else if (sspm_is_continuation_line(line)){
- return HEADER_CONTINUATION;
- } else if (sspm_is_mime_terminating_boundary(line)){
- return TERMINATING_BOUNDARY;
- } else if (sspm_is_mime_boundary(line)) {
- return BOUNDARY;
- } else {
- return UNKNOWN_TYPE;
- }
-
-
-}
-
-
-struct sspm_action_map get_action(struct mime_impl *impl,
- enum sspm_major_type major,
- enum sspm_minor_type minor)
-{
- int i;
-
- /* Read caller suppled action map */
-
- if (impl->actions != 0){
- for(i=0; impl->actions[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){
- if((major == impl->actions[i].major &&
- minor == impl->actions[i].minor) ||
- (major == impl->actions[i].major &&
- minor == SSPM_ANY_MINOR_TYPE)){
- return impl->actions[i];
- }
- }
- }
-
- /* Else, read default action map */
-
- for(i=0; sspm_action_map[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){
- if((major == sspm_action_map[i].major &&
- minor == sspm_action_map[i].minor) ||
- (major == sspm_action_map[i].major &&
- minor == SSPM_ANY_MINOR_TYPE)){
- break;
- }
- }
-
- return sspm_action_map[i];
-}
-
-
-char* sspm_lowercase(char* str)
-{
- char* p = 0;
- char* new = sspm_strdup(str);
-
- if(str ==0){
- return 0;
- }
-
- for(p = new; *p!=0; p++){
- *p = tolower(*p);
- }
-
- return new;
-}
-
-enum sspm_major_type sspm_find_major_content_type(char* type)
-{
- int i;
-
- char* ltype = sspm_lowercase(type);
-
- for (i=0; major_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE; i++){
- if(strncmp(ltype, major_content_type_map[i].str,
- strlen(major_content_type_map[i].str))==0){
- free(ltype);
- return major_content_type_map[i].type;
- }
- }
- free(ltype);
- return major_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
-}
-
-enum sspm_minor_type sspm_find_minor_content_type(char* type)
-{
- int i;
- char* ltype = sspm_lowercase(type);
-
- char *p = strchr(ltype,'/');
-
- if (p==0){
- return SSPM_UNKNOWN_MINOR_TYPE;
- }
-
- p++; /* Skip the '/' */
-
- for (i=0; minor_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE; i++){
- if(strncmp(p, minor_content_type_map[i].str,
- strlen(minor_content_type_map[i].str))==0){
- free(ltype);
- return minor_content_type_map[i].type;
- }
- }
-
- free(ltype);
- return minor_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
-}
-
-char* sspm_major_type_string(enum sspm_major_type type)
-{
- int i;
-
- for (i=0; major_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE;
- i++){
-
- if(type == major_content_type_map[i].type){
- return major_content_type_map[i].str;
- }
- }
-
- return major_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
-}
-
-char* sspm_minor_type_string(enum sspm_minor_type type)
-{
- int i;
- for (i=0; minor_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE;
- i++){
- if(type == minor_content_type_map[i].type){
- return minor_content_type_map[i].str;
- }
- }
-
- return minor_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
-}
-
-
-char* sspm_encoding_string(enum sspm_encoding type)
-{
- int i;
- for (i=0; sspm_encoding_map[i].encoding != SSPM_UNKNOWN_ENCODING;
- i++){
- if(type == sspm_encoding_map[i].encoding){
- return sspm_encoding_map[i].str;
- }
- }
-
- return sspm_encoding_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
-}
-
-/* Interpret a header line and add its data to the header
- structure. */
-void sspm_build_header(struct sspm_header *header, char* line)
-{
- char *prop;
- char *val;
-
- val = sspm_strdup(sspm_value(line));
- prop = sspm_strdup(sspm_property_name(line));
-
- if(strcmp(prop,"Content-Type") == 0){
-
- /* Create a new mime_header, fill in content-type
- and possibly boundary */
-
- char* boundary= sspm_get_parameter(line,"boundary");
-
- header->def = 0;
- header->major = sspm_find_major_content_type(val);
- header->minor = sspm_find_minor_content_type(val);
-
- if(header->minor == SSPM_UNKNOWN_MINOR_TYPE){
- char *p = strchr(val,'/');
-
- if (p != 0){
- p++; /* Skip the '/' */
-
- header->minor_text = sspm_strdup(p);
- } else {
- /* Error, malformed content type */
- header->minor_text = sspm_strdup("unknown");
- }
- }
- if (boundary != 0){
- header->boundary = sspm_strdup(boundary);
- }
-
- } else if(strcmp(prop,"Content-Transfer-Encoding")==0){
- char* encoding = sspm_value(line);
- char* lencoding = sspm_lowercase(encoding);
-
- if(strcmp(lencoding,"base64")==0){
- header->encoding = SSPM_BASE64_ENCODING;
- } else if(strcmp(lencoding,"quoted-printable")==0){
- header->encoding = SSPM_QUOTED_PRINTABLE_ENCODING;
- } else if(strcmp(lencoding,"binary")==0){
- header->encoding = SSPM_BINARY_ENCODING;
- } else if(strcmp(lencoding,"7bit")==0){
- header->encoding = SSPM_7BIT_ENCODING;
- } else if(strcmp(lencoding,"8bit")==0){
- header->encoding = SSPM_8BIT_ENCODING;
- } else {
- header->encoding = SSPM_UNKNOWN_ENCODING;
- }
-
-
- free(lencoding);
-
- header->def = 0;
-
- } else if(strcmp(prop,"Content-Id")==0){
- char* cid = sspm_value(line);
- header->content_id = sspm_strdup(cid);
- header->def = 0;
-
- }
- free(val);
- free(prop);
-}
-
-char* sspm_get_next_line(struct mime_impl *impl)
-{
- char* s;
- s = impl->get_string(impl->temp,TMP_BUF_SIZE,impl->get_string_data);
-
- if(s == 0){
- impl->state = END_OF_INPUT;
- }
- return s;
-}
-
-
-void sspm_store_part(struct mime_impl *impl, struct sspm_header header,
- int level, void *part, size_t size)
-{
-
- impl->parts[impl->part_no].header = header;
- impl->parts[impl->part_no].level = level;
- impl->parts[impl->part_no].data = part;
- impl->parts[impl->part_no].data_size = size;
- impl->part_no++;
-}
-
-void sspm_set_error(struct sspm_header* header, enum sspm_error error,
- char* message)
-{
- header->error = error;
-
- if(header->error_text!=0){
- free(header->error_text);
- }
-
- header->def = 0;
-
- if(message != 0){
- header->error_text = sspm_strdup(message);
- } else {
- header->error_text = 0;
- }
-
-}
-
-void* sspm_make_part(struct mime_impl *impl,
- struct sspm_header *header,
- struct sspm_header *parent_header,
- void **end_part,
- size_t *size)
-{
-
- /* For a single part type, read to the boundary, if there is a
- boundary. Otherwise, read until the end of input. This routine
- assumes that the caller has read the header and has left the input
- at the first blank line */
-
- char *line;
- void *part;
- int end = 0;
-
- struct sspm_action_map action = get_action(
- impl,
- header->major,
- header->minor);
-
- *size = 0;
- part =action.new_part();
-
- impl->state = IN_BODY;
-
- while(end == 0 && (line = sspm_get_next_line(impl)) != 0){
-
- if(sspm_is_mime_boundary(line)){
-
- /* If there is a boundary, then this must be a multipart
- part, so there must be a parent_header. */
- if(parent_header == 0){
- char* boundary;
- end = 1;
- *end_part = 0;
-
- sspm_set_error(header,SSPM_UNEXPECTED_BOUNDARY_ERROR,line);
-
- /* Read until the paired terminating boundary */
- if((boundary = (char*)malloc(strlen(line)+5)) == 0){
- fprintf(stderr,"Out of memory");
- abort();
- }
- strcpy(boundary,line);
- strcat(boundary,"--");
- while((line = sspm_get_next_line(impl)) != 0){
- /*printf("Error: %s\n",line);*/
- if(strcmp(boundary,line)==0){
- break;
- }
- }
- free(boundary);
-
- break;
- }
-
- if(strncmp((line+2),parent_header->boundary,
- sizeof(parent_header->boundary)) == 0){
- *end_part = action.end_part(part);
-
- if(sspm_is_mime_boundary(line)){
- impl->state = END_OF_PART;
- } else if ( sspm_is_mime_terminating_boundary(line)){
- impl->state = TERMINAL_END_OF_PART;
- }
- end = 1;
- } else {
- /* Error, this is not the correct terminating boundary*/
-
- /* read and discard until we get the right boundary. */
- char* boundary;
- char msg[256];
-
- snprintf(msg,256,
- "Expected: %s--. Got: %s",
- parent_header->boundary,line);
-
- sspm_set_error(parent_header,
- SSPM_WRONG_BOUNDARY_ERROR,msg);
-
- /* Read until the paired terminating boundary */
- if((boundary = (char*)malloc(strlen(line)+5)) == 0){
- fprintf(stderr,"Out of memory");
- abort();
- }
- strcpy(boundary,line);
- strcat(boundary,"--");
- while((line = sspm_get_next_line(impl)) != 0){
- if(strcmp(boundary,line)==0){
- break;
- }
- }
- free(boundary);
-
- }
- } else {
- char* data=0;
- char* rtrn=0;
- *size = strlen(line);
-
- data = (char*)malloc(*size+2);
- assert(data != 0);
- if (header->encoding == SSPM_BASE64_ENCODING){
- rtrn = decode_base64(data,line,size);
- } else if(header->encoding == SSPM_QUOTED_PRINTABLE_ENCODING){
- rtrn = decode_quoted_printable(data,line,size);
- }
-
- if(rtrn == 0){
- strcpy(data,line);
- }
-
- /* add a end-of-string after the data, just in case binary
- data from decode64 gets passed to a tring handling
- routine in add_line */
- data[*size+1]='\0';
-
- action.add_line(part,header,data,*size);
-
- free(data);
- }
- }
-
- if (end == 0){
- /* End the part if the input is exhausted */
- *end_part = action.end_part(part);
- }
-
- return end_part;
-}
-
-
-void* sspm_make_multipart_subpart(struct mime_impl *impl,
- struct sspm_header *parent_header)
-{
- struct sspm_header header;
- char *line;
- void* part;
- size_t size;
-
- if(parent_header->boundary == 0){
- /* Error. Multipart headers must have a boundary*/
-
- sspm_set_error(parent_header,SSPM_NO_BOUNDARY_ERROR,0);
- /* read all of the reamining lines */
- while((line = sspm_get_next_line(impl)) != 0){
- }
-
- return 0;
- }
-
-
- /* Step 1: Read the opening boundary */
-
- if(get_line_type(impl->temp) != BOUNDARY){
- while((line=sspm_get_next_line(impl)) != 0 ){
- if(sspm_is_mime_boundary(line)){
-
- assert(parent_header != 0);
-
- /* Check if it is the right boundary */
- if(!sspm_is_mime_terminating_boundary(line) &&
- strncmp((line+2),parent_header->boundary,
- sizeof(parent_header->boundary))
- == 0){
- /* The +2 in strncmp skips over the leading "--" */
-
- break;
- } else {
- /* Got the wrong boundary, so read and discard
- until we get the right boundary. */
- char* boundary;
- char msg[256];
-
- snprintf(msg,256,
- "Expected: %s. Got: %s",
- parent_header->boundary,line);
-
- sspm_set_error(parent_header,
- SSPM_WRONG_BOUNDARY_ERROR,msg);
-
- /* Read until the paired terminating boundary */
- if((boundary = (char*)malloc(strlen(line)+5)) == 0){
- fprintf(stderr,"Out of memory");
- abort();
- }
- strcpy(boundary,line);
- strcat(boundary,"--");
- while((line = sspm_get_next_line(impl)) != 0){
- if(strcmp(boundary,line)==0){
- break;
- }
- }
- free(boundary);
-
- return 0;
- }
- }
- }
- }
-
- /* Step 2: Get the part header */
- sspm_read_header(impl,&header);
-
- /* If the header is still listed as default, there was probably an
- error */
- if(header.def == 1 && header.error != SSPM_NO_ERROR){
- sspm_set_error(&header,SSPM_NO_HEADER_ERROR,0);
- return 0;
- }
-
- if(header.error!= SSPM_NO_ERROR){
- sspm_store_part(impl,header,impl->level,0,0);
- return 0;
- }
-
- /* Step 3: read the body */
-
- if(header.major == SSPM_MULTIPART_MAJOR_TYPE){
- struct sspm_header *child_header;
- child_header = &(impl->parts[impl->part_no].header);
-
- /* Store the multipart part */
- sspm_store_part(impl,header,impl->level,0,0);
-
- /* now get all of the sub-parts */
- part = sspm_make_multipart_part(impl,child_header);
-
- if(get_line_type(impl->temp) != TERMINATING_BOUNDARY){
-
- sspm_set_error(child_header,SSPM_NO_BOUNDARY_ERROR,impl->temp);
- return 0;
- }
-
- sspm_get_next_line(impl); /* Step past the terminating boundary */
-
- } else {
- sspm_make_part(impl, &header,parent_header,&part,&size);
-
- memset(&(impl->parts[impl->part_no]), 0, sizeof(struct sspm_part));
-
- sspm_store_part(impl,header,impl->level,part,size);
-
- }
-
- return part;
-}
-
-void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header)
-{
- void *part=0;
-
- /* Now descend a level into each of the children of this part */
- impl->level++;
-
- /* Now we are working on the CHILD */
- memset(&(impl->parts[impl->part_no]), 0, sizeof(struct sspm_part));
-
- do{
- part = sspm_make_multipart_subpart(impl,header);
-
- if (part==0){
- /* Clean up the part in progress */
- impl->parts[impl->part_no].header.major
- = SSPM_NO_MAJOR_TYPE;
- impl->parts[impl->part_no].header.minor
- = SSPM_NO_MINOR_TYPE;
-
- }
-
-
- } while (get_line_type(impl->temp) != TERMINATING_BOUNDARY &&
- impl->state != END_OF_INPUT);
-
- impl->level--;
-
- return 0;
-}
-
-
-void sspm_read_header(struct mime_impl *impl,struct sspm_header *header)
-{
-#define BUF_SIZE 1024
-#define MAX_HEADER_LINES 25
-
- char *buf;
- char header_lines[MAX_HEADER_LINES][BUF_SIZE]; /* HACK, hard limits */
- int current_line = -1;
- int end = 0;
-
- memset(header_lines,0,sizeof(header_lines));
- memset(header,0,sizeof(struct sspm_header));
-
- /* Set up default header */
- header->def = 1;
- header->major = SSPM_TEXT_MAJOR_TYPE;
- header->minor = SSPM_PLAIN_MINOR_TYPE;
- header->error = SSPM_NO_ERROR;
- header->error_text = 0;
-
- /* Read all of the lines into memory */
- while(end==0&& (buf=sspm_get_next_line(impl)) != 0){
-
- enum line_type line_type = get_line_type(buf);
-
- switch(line_type){
- case BLANK: {
- end = 1;
- impl->state = END_OF_HEADER;
- break;
- }
-
- case MAIL_HEADER:
- case MIME_HEADER: {
- impl->state = IN_HEADER;
- current_line++;
-
- assert(strlen(buf) < BUF_SIZE);
-
- strcpy(header_lines[current_line],buf);
-
- break;
- }
-
- case HEADER_CONTINUATION: {
- char* last_line, *end;
- char *buf_start;
-
- if(current_line < 0){
- /* This is not really a continuation line, since
- we have not see any header line yet */
- sspm_set_error(header,SSPM_MALFORMED_HEADER_ERROR,buf);
- return;
- }
-
- last_line = header_lines[current_line];
- end = (char*) ( (size_t)strlen(last_line)+
- (size_t)last_line);
-
- impl->state = IN_HEADER;
-
-
- /* skip over the spaces in buf start, and remove the new
- line at the end of the lat line */
- if (last_line[strlen(last_line)-1] == '\n'){
- last_line[strlen(last_line)-1] = '\0';
- }
- buf_start = buf;
- while(*buf_start == ' ' ||*buf_start == '\t' ){
- buf_start++;
- }
-
- assert( strlen(buf_start) + strlen(last_line) < BUF_SIZE);
-
- strcat(last_line,buf_start);
-
- break;
- }
-
- default: {
- sspm_set_error(header,SSPM_MALFORMED_HEADER_ERROR,buf);
- return;
- }
- }
- }
-
-
- for(current_line = 0;
- current_line < MAX_HEADER_LINES && header_lines[current_line][0] != 0;
- current_line++){
-
- sspm_build_header(header,header_lines[current_line]);
- }
-
-
-}
-
-/* Root routine for parsing mime entries*/
-int sspm_parse_mime(struct sspm_part *parts,
- size_t max_parts,
- struct sspm_action_map *actions,
- char* (*get_string)(char *s, size_t size, void* data),
- void *get_string_data,
- struct sspm_header *first_header
- )
-{
- struct mime_impl impl;
- struct sspm_header header;
- void *part;
- int i;
-
- /* Initialize all of the data */
- memset(&impl,0,sizeof(struct mime_impl));
- memset(&header,0,sizeof(struct sspm_header));
-
- for(i = 0; i<(int)max_parts; i++){
- parts[i].header.major = SSPM_NO_MAJOR_TYPE;
- parts[i].header.minor = SSPM_NO_MINOR_TYPE;
- }
-
- impl.parts = parts;
- impl.max_parts = max_parts;
- impl.part_no = 0;
- impl.actions = actions;
- impl.get_string = get_string;
- impl.get_string_data = get_string_data;
-
- /* Read the header of the message. This will be the email header,
- unless first_header is specified. But ( HACK) that var is not
- currently being used */
- sspm_read_header(&impl,&header);
-
- if(header.major == SSPM_MULTIPART_MAJOR_TYPE){
- struct sspm_header *child_header;
- child_header = &(impl.parts[impl.part_no].header);
-
- sspm_store_part(&impl,header,impl.level,0,0);
-
- part = sspm_make_multipart_part(&impl,child_header);
-
- } else {
- void *part;
- size_t size;
- sspm_make_part(&impl, &header, 0,&part,&size);
-
- memset(&(impl.parts[impl.part_no]), 0, sizeof(struct sspm_part));
-
- sspm_store_part(&impl,header,impl.level,part,size);
- }
-
- return 0;
-}
-
-void sspm_free_parts(struct sspm_part *parts, size_t max_parts)
-{
- int i;
-
- for(i = 0; i<(int)max_parts && parts[i].header.major != SSPM_NO_MAJOR_TYPE;
- i++){
- sspm_free_header(&(parts[i].header));
- }
-}
-
-void sspm_free_header(struct sspm_header *header)
-{
- if(header->boundary!=0){
- free(header->boundary);
- }
- if(header->minor_text!=0){
- free(header->minor_text);
- }
- if(header->charset!=0){
- free(header->charset);
- }
- if(header->filename!=0){
- free(header->filename);
- }
- if(header->content_id!=0){
- free(header->content_id);
- }
- if(header->error_text!=0){
- free(header->error_text);
- }
-}
-
-/***********************************************************************
-The remaining code is beased on code from the mimelite distribution,
-which has the following notice:
-
-| Authorship:
-| Copyright (c) 1994 Gisle Hannemyr.
-| Permission is granted to hack, make and distribute copies of this
-| program as long as this copyright notice is not removed.
-| Flames, bug reports, comments and improvements to:
-| snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway
-| email: Inet: gisle@oslonett.no
-
-The code is heavily modified by Eric Busboom.
-
-***********************************************************************/
-
-char *decode_quoted_printable(char *dest,
- char *src,
- size_t *size)
-{
- int cc;
- size_t i=0;
-
- while (*src != 0 && i < *size) {
- if (*src == '=') {
-
- src++;
- if (!*src) {
- break;
- }
-
- /* remove soft line breaks*/
- if ((*src == '\n') || (*src == '\r')){
- src++;
- if ((*src == '\n') || (*src == '\r')){
- src++;
- }
- continue;
- }
-
- cc = isdigit(*src) ? (*src - '0') : (*src - 55);
- cc *= 0x10;
- src++;
- if (!*src) {
- break;
- }
- cc += isdigit(*src) ? (*src - '0') : (*src - 55);
-
- *dest = cc;
-
- } else {
- *dest = *src;
- }
-
- dest++;
- src++;
- i++;
- }
-
- *dest = '\0';
-
- *size = i;
- return(dest);
-}
-
-char *decode_base64(char *dest,
- char *src,
- size_t *size)
-{
- int cc;
- char buf[4] = {0,0,0,0};
- int p = 0;
- int valid_data = 0;
- size_t size_out=0;
-
- while (*src && p<(int)*size && (cc!= -1)) {
-
- /* convert a character into the Base64 alphabet */
- cc = *src++;
-
- if ((cc >= 'A') && (cc <= 'Z')) cc = cc - 'A';
- else if ((cc >= 'a') && (cc <= 'z')) cc = cc - 'a' + 26;
- else if ((cc >= '0') && (cc <= '9')) cc = cc - '0' + 52;
- else if (cc == '/') cc = 63;
- else if (cc == '+') cc = 62;
- else cc = -1;
-
- assert(cc<64);
-
- /* If we've reached the end, fill the remaining slots in
- the bucket and do a final conversion */
- if(cc== -1){
- if(valid_data == 0){
- return 0;
- }
-
- while(p%4!=3){
- p++;
- buf[p%4] = 0;
- }
- } else {
- buf[p%4] = cc;
- size_out++;
- valid_data = 1;
- }
-
-
- /* When we have 4 base64 letters, convert them into three
- bytes */
- if (p%4 == 3) {
- *dest++ =(buf[0]<< 2)|((buf[1] & 0x30) >> 4);
- *dest++ =((buf[1] & 0x0F) << 4)|((buf[2] & 0x3C) >> 2);
- *dest++ =((buf[2] & 0x03) << 6)|(buf[3] & 0x3F);
-
- memset(buf,0,4);
- }
-
- p++;
-
- }
- /* Calculate the size of the converted data*/
- *size = ((int)(size_out/4))*3;
- if(size_out%4 == 2) *size+=1;
- if(size_out%4 == 3) *size+=2;
-
- return(dest);
-}
-
-
-/***********************************************************************
-
- Routines to output MIME
-
-**********************************************************************/
-
-
-struct sspm_buffer {
- char* buffer;
- char* pos;
- size_t buf_size;
- int line_pos;
-};
-
-void sspm_append_string(struct sspm_buffer* buf, char* string);
-void sspm_write_part(struct sspm_buffer *buf,struct sspm_part *part, int *part_num);
-
-void sspm_append_hex(struct sspm_buffer* buf, char ch)
-{
- char tmp[3];
-
- sprintf(tmp,"=%02X",ch);
-
- sspm_append_string(buf,tmp);
-}
-
-/* a copy of icalmemory_append_char */
-void sspm_append_char(struct sspm_buffer* buf, char ch)
-{
- char *new_buf;
- char *new_pos;
-
- size_t data_length, final_length;
-
- data_length = (size_t)buf->pos - (size_t)buf->buffer;
-
- final_length = data_length + 2;
-
- if ( final_length > (size_t) buf->buf_size ) {
-
- buf->buf_size = (buf->buf_size) * 2 + final_length +1;
-
- new_buf = realloc(buf->buffer,buf->buf_size);
-
- new_pos = (void*)((size_t)new_buf + data_length);
-
- buf->pos = new_pos;
- buf->buffer = new_buf;
- }
-
- *(buf->pos) = ch;
- buf->pos += 1;
- *(buf->pos) = 0;
-}
-/* A copy of icalmemory_append_string */
-void sspm_append_string(struct sspm_buffer* buf, char* string)
-{
- char *new_buf;
- char *new_pos;
-
- size_t data_length, final_length, string_length;
-
- string_length = strlen(string);
- data_length = (size_t)buf->pos - (size_t)buf->buffer;
- final_length = data_length + string_length;
-
- if ( final_length >= (size_t) buf->buf_size) {
-
-
- buf->buf_size = (buf->buf_size) * 2 + final_length;
-
- new_buf = realloc(buf->buffer,buf->buf_size);
-
- new_pos = (void*)((size_t)new_buf + data_length);
-
- buf->pos = new_pos;
- buf->buffer = new_buf;
- }
-
- strcpy(buf->pos, string);
-
- buf->pos += string_length;
-}
-
-
-
-static int sspm_is_printable(char c)
-{
- return (c >= 33) && (c <= 126) && (c != '=');
-
-}
-
-
-void sspm_encode_quoted_printable(struct sspm_buffer *buf, char* data)
-{
- char *p;
- int lpos = 0;
-
- for(p = data; *p != 0; p++){
-
- if(sspm_is_printable(*p)){
- /* plain characters can represent themselves */
- /* RFC2045 Rule #2 */
- sspm_append_char(buf,*p);
- lpos++;
- } else if ( *p == '\t' || *p == ' ' ) {
-
- /* For tabs and spaces, only encode if they appear at the
- end of the line */
- /* RFC2045 Rule #3 */
-
- char n = *(p+1);
-
- if( n == '\n' || n == '\r'){
- sspm_append_hex(buf,*p);
- lpos += 3;
- } else {
- sspm_append_char(buf,*p);
- lpos++;
- }
-
- } else if( *p == '\n' || *p == '\r'){
- sspm_append_char(buf,*p);
-
- lpos=0;
-
- } else {
- /* All others need to be encoded */
- sspm_append_hex(buf,*p);
- lpos+=3;
- }
-
-
- /* Add line breaks */
- if (lpos > 72){
- lpos = 0;
- sspm_append_string(buf,"=\n");
- }
- }
-}
-
-static char BaseTable[64] = {
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
- 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
- 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
-};
-
-void sspm_write_base64(struct sspm_buffer *buf, char* inbuf,int size )
-{
-
- char outbuf[4];
- int i;
-
- outbuf[0] = outbuf[1] = outbuf[2] = outbuf[3] = 65;
-
- switch(size){
-
- case 4:
- outbuf[3] = inbuf[2] & 0x3F;
-
- case 3:
- outbuf[2] = ((inbuf[1] & 0x0F) << 2) | ((inbuf[2] & 0xC0) >> 6);
-
- case 2:
- outbuf[0] = (inbuf[0] & 0xFC) >> 2;
- outbuf[1] = ((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4);
- break;
-
- default:
- assert(0);
- }
-
- for(i = 0; i < 4; i++){
-
- if(outbuf[i] == 65){
- sspm_append_char(buf,'=');
- } else {
- sspm_append_char(buf,BaseTable[(int)outbuf[i]]);
- }
- }
-}
-
-void sspm_encode_base64(struct sspm_buffer *buf, char* data, size_t size)
-{
-
- char *p;
- char inbuf[3];
- int i = 0;
- int first = 1;
- int lpos = 0;
-
- inbuf[0] = inbuf[1] = inbuf[2] = 0;
-
- for (p = data; *p !=0; p++){
-
- if (i%3 == 0 && first == 0){
-
- sspm_write_base64(buf, inbuf, 4);
- lpos+=4;
-
- inbuf[0] = inbuf[1] = inbuf[2] = 0;
- }
-
- assert(lpos%4 == 0);
-
- if (lpos == 72){
- sspm_append_string(buf,"\n");
- lpos = 0;
- }
-
- inbuf[i%3] = *p;
-
- i++;
- first = 0;
-
- }
-
-
- /* If the inbuf was not exactly filled on the last byte, we need
- to spit out the odd bytes that did get in -- either one or
- two. This will result in an output of two bytes and '==' or
- three bytes and '=', respectively */
-
- if (i%3 == 1 && first == 0){
- sspm_write_base64(buf, inbuf, 2);
- } else if (i%3 == 2 && first == 0){
- sspm_write_base64(buf, inbuf, 3);
- }
-
-}
-
-void sspm_write_header(struct sspm_buffer *buf,struct sspm_header *header)
-{
-
- int i;
- char temp[TMP_BUF_SIZE];
- char* major;
- char* minor;
-
- /* Content-type */
-
- major = sspm_major_type_string(header->major);
- minor = sspm_minor_type_string(header->minor);
-
- if(header->minor == SSPM_UNKNOWN_MINOR_TYPE ){
- assert(header->minor_text !=0);
- minor = header->minor_text;
- }
-
- sprintf(temp,"Content-Type: %s/%s",major,minor);
-
- sspm_append_string(buf,temp);
-
- if(header->boundary != 0){
- sprintf(temp,";boundary=\"%s\"",header->boundary);
- sspm_append_string(buf,temp);
- }
-
- /* Append any content type parameters */
- if(header->content_type_params != 0){
- for(i=0; *(header->content_type_params[i])!= 0;i++){
- sprintf(temp,header->content_type_params[i]);
- sspm_append_char(buf,';');
- sspm_append_string(buf,temp);
- }
- }
-
- sspm_append_char(buf,'\n');
-
- /*Content-Transfer-Encoding */
-
- if(header->encoding != SSPM_UNKNOWN_ENCODING &&
- header->encoding != SSPM_NO_ENCODING){
- sprintf(temp,"Content-Transfer-Encoding: %s\n",
- sspm_encoding_string(header->encoding));
- }
-
- sspm_append_char(buf,'\n');
-
-}
-
-void sspm_write_multipart_part(struct sspm_buffer *buf,
- struct sspm_part *parts,
- int* part_num)
-{
-
- int parent_level, level;
- struct sspm_header *header = &(parts[*part_num].header);
- /* Write the header for the multipart part */
- sspm_write_header(buf,header);
-
- parent_level = parts[*part_num].level;
-
- (*part_num)++;
-
- level = parts[*part_num].level;
-
- while(parts[*part_num].header.major != SSPM_NO_MAJOR_TYPE &&
- level == parent_level+1){
-
- assert(header->boundary);
- sspm_append_string(buf,header->boundary);
- sspm_append_char(buf,'\n');
-
- if (parts[*part_num].header.major == SSPM_MULTIPART_MAJOR_TYPE){
- sspm_write_multipart_part(buf,parts,part_num);
- } else {
- sspm_write_part(buf, &(parts[*part_num]), part_num);
- }
-
- (*part_num)++;
- level = parts[*part_num].level;
- }
-
- sspm_append_string(buf,"\n\n--");
- sspm_append_string(buf,header->boundary);
- sspm_append_string(buf,"\n");
-
- (*part_num)--; /* undo last, spurious, increment */
-}
-
-void sspm_write_part(struct sspm_buffer *buf,struct sspm_part *part,int *part_num)
-{
-
- /* Write header */
- sspm_write_header(buf,&(part->header));
-
- /* Write part data */
-
- if(part->data == 0){
- return;
- }
-
- if(part->header.encoding == SSPM_BASE64_ENCODING) {
- assert(part->data_size != 0);
- sspm_encode_base64(buf,part->data,part->data_size);
- } else if(part->header.encoding == SSPM_QUOTED_PRINTABLE_ENCODING) {
- sspm_encode_quoted_printable(buf,part->data);
- } else {
- sspm_append_string(buf,part->data);
- }
-
- sspm_append_string(buf,"\n\n");
-}
-
-int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
- char **output_string, char* header)
-{
- struct sspm_buffer buf;
- int part_num =0;
-
- buf.buffer = malloc(4096);
- buf.pos = buf.buffer;
- buf.buf_size = 10;
- buf.line_pos = 0;
-
- /* write caller's header */
- if(header != 0){
- sspm_append_string(&buf,header);
- }
-
- if(buf.buffer[strlen(buf.buffer)-1] != '\n'){
- sspm_append_char(&buf,'\n');
- }
-
- /* write mime-version header */
- sspm_append_string(&buf,"Mime-Version: 1.0\n");
-
- /* End of header */
-
- /* Write body parts */
- while(parts[part_num].header.major != SSPM_NO_MAJOR_TYPE){
- if (parts[part_num].header.major == SSPM_MULTIPART_MAJOR_TYPE){
- sspm_write_multipart_part(&buf,parts,&part_num);
- } else {
- sspm_write_part(&buf, &(parts[part_num]), &part_num);
- }
-
- part_num++;
- }
-
-
- *output_string = buf.buffer;
-
- return 0;
-}
-
diff --git a/libical/src/libical/sspm.h b/libical/src/libical/sspm.h
deleted file mode 100644
index 864a23a36f..0000000000
--- a/libical/src/libical/sspm.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: sspm.h Mime Parser
- CREATOR: eric 25 June 2000
-
- $Id$
- $Locker$
-
- 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.
-
-
- 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 Initial Developer of the Original Code is Eric Busboom
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
- ======================================================================*/
-
-#ifndef SSPM_H
-#define SSPM_H
-
-enum sspm_major_type {
- SSPM_NO_MAJOR_TYPE,
- SSPM_TEXT_MAJOR_TYPE,
- SSPM_IMAGE_MAJOR_TYPE,
- SSPM_AUDIO_MAJOR_TYPE,
- SSPM_VIDEO_MAJOR_TYPE,
- SSPM_APPLICATION_MAJOR_TYPE,
- SSPM_MULTIPART_MAJOR_TYPE,
- SSPM_MESSAGE_MAJOR_TYPE,
- SSPM_UNKNOWN_MAJOR_TYPE
-};
-
-enum sspm_minor_type {
- SSPM_NO_MINOR_TYPE,
- SSPM_ANY_MINOR_TYPE,
- SSPM_PLAIN_MINOR_TYPE,
- SSPM_RFC822_MINOR_TYPE,
- SSPM_DIGEST_MINOR_TYPE,
- SSPM_CALENDAR_MINOR_TYPE,
- SSPM_MIXED_MINOR_TYPE,
- SSPM_RELATED_MINOR_TYPE,
- SSPM_ALTERNATIVE_MINOR_TYPE,
- SSPM_PARALLEL_MINOR_TYPE,
- SSPM_UNKNOWN_MINOR_TYPE
-};
-
-enum sspm_encoding {
- SSPM_NO_ENCODING,
- SSPM_QUOTED_PRINTABLE_ENCODING,
- SSPM_8BIT_ENCODING,
- SSPM_7BIT_ENCODING,
- SSPM_BINARY_ENCODING,
- SSPM_BASE64_ENCODING,
- SSPM_UNKNOWN_ENCODING
-};
-
-enum sspm_error{
- SSPM_NO_ERROR,
- SSPM_UNEXPECTED_BOUNDARY_ERROR,
- SSPM_WRONG_BOUNDARY_ERROR,
- SSPM_NO_BOUNDARY_ERROR,
- SSPM_NO_HEADER_ERROR,
- SSPM_MALFORMED_HEADER_ERROR
-};
-
-
-struct sspm_header
-{
- int def;
- char* boundary;
- enum sspm_major_type major;
- enum sspm_minor_type minor;
- char *minor_text;
- char ** content_type_params;
- char* charset;
- enum sspm_encoding encoding;
- char* filename;
- char* content_id;
- enum sspm_error error;
- char* error_text;
-};
-
-struct sspm_part {
- struct sspm_header header;
- int level;
- size_t data_size;
- void *data;
-};
-
-struct sspm_action_map {
- enum sspm_major_type major;
- enum sspm_minor_type minor;
- void* (*new_part)();
- void (*add_line)(void *part, struct sspm_header *header,
- char* line, size_t size);
- void* (*end_part)(void* part);
- void (*free_part)(void *part);
-};
-
-char* sspm_major_type_string(enum sspm_major_type type);
-char* sspm_minor_type_string(enum sspm_minor_type type);
-char* sspm_encoding_string(enum sspm_encoding type);
-
-int sspm_parse_mime(struct sspm_part *parts,
- size_t max_parts,
- struct sspm_action_map *actions,
- char* (*get_string)(char *s, size_t size, void* data),
- void *get_string_data,
- struct sspm_header *first_header
- );
-
-void sspm_free_parts(struct sspm_part *parts, size_t max_parts);
-
-char *decode_quoted_printable(char *dest,
- char *src,
- size_t *size);
-char *decode_base64(char *dest,
- char *src,
- size_t *size);
-
-
-int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
- char **output_string, char* header);
-
-#endif /*SSPM_H*/
diff --git a/libical/src/libical/vsnprintf.c b/libical/src/libical/vsnprintf.c
deleted file mode 100644
index 6339183dd4..0000000000
--- a/libical/src/libical/vsnprintf.c
+++ /dev/null
@@ -1,167 +0,0 @@
-#ifdef __osf__
-/*
- * Revision 12: http://theos.com/~deraadt/snprintf.c
- *
- * Copyright (c) 1997 Theo de Raadt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#if __STDC__
-#include <stdarg.h>
-#include <stdlib.h>
-#else
-#include <varargs.h>
-#endif
-#include <setjmp.h>
-
-#ifndef roundup
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#endif
-
-static int pgsize;
-static char *curobj;
-static sigjmp_buf bail;
-
-#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */
-
-static char *
-msetup(str, n)
- char *str;
- size_t n;
-{
- char *e;
-
- if (n == 0)
- return NULL;
- if (pgsize == 0)
- pgsize = getpagesize();
- curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
- if (curobj == NULL)
- return NULL;
- e = curobj + n + EXTRABYTES;
- e = (char *)roundup((unsigned long)e, pgsize);
- if (mprotect(e, pgsize, PROT_NONE) == -1) {
- free(curobj);
- curobj = NULL;
- return NULL;
- }
- e = e - n - EXTRABYTES;
- *e = '\0';
- return (e);
-}
-
-static void
-mcatch(int i)
-{
- siglongjmp(bail, 1);
-}
-
-static void
-mcleanup(str, n, p)
- char *str;
- size_t n;
- char *p;
-{
- strncpy(str, p, n-1);
- str[n-1] = '\0';
- if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE|PROT_EXEC) == -1)
- mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE);
- free(curobj);
-}
-
-int
-#if __STDC__
-vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
-#else
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- char *fmt;
- char *ap;
-#endif
-{
- struct sigaction osa, nsa;
- char *p;
- int ret = n + 1; /* if we bail, indicated we overflowed */
-
- memset(&nsa, 0, sizeof nsa);
- nsa.sa_handler = mcatch;
- sigemptyset(&nsa.sa_mask);
-
- p = msetup(str, n);
- if (p == NULL) {
- *str = '\0';
- return 0;
- }
- if (sigsetjmp(bail, 1) == 0) {
- if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
- mcleanup(str, n, p);
- return (0);
- }
- ret = vsprintf(p, fmt, ap);
- }
- mcleanup(str, n, p);
- (void) sigaction(SIGSEGV, &osa, NULL);
- return (ret);
-}
-
-int
-#if __STDC__
-snprintf(char *str, size_t n, char const *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-
- return (vsnprintf(str, n, fmt, ap));
- va_end(ap);
-}
-
-
-#else
-
-/* ANSI C forbids an empty source file... */
-
-static void vsnprintf_dummy_func() {
- vsnprintf_dummy_func();
-}
-
-#endif
diff --git a/libical/src/libicalss/.cvsignore b/libical/src/libicalss/.cvsignore
deleted file mode 100644
index 04a3e1b036..0000000000
--- a/libical/src/libicalss/.cvsignore
+++ /dev/null
@@ -1,10 +0,0 @@
-Makefile
-.deps
-Makefile.in
-*.lo
-*.la
-.libs
-y.output
-icalsslexer.c
-icalssyacc.c
-icalss.h
diff --git a/libical/src/libicalss/Makefile.am b/libical/src/libicalss/Makefile.am
deleted file mode 100644
index 9e11bc3fc8..0000000000
--- a/libical/src/libicalss/Makefile.am
+++ /dev/null
@@ -1,69 +0,0 @@
-lib_LTLIBRARIES = libicalss.la
-
-YFLAGS =-d -v -p ss
-LFLAGS = -Pss
-LEX_OUTPUT_ROOT = lex.ss
-
-all: icalss.h
-
-INCLUDES = \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -I$(top_srcdir)/src/libical \
- -I$(top_builddir)/src/libical
-
-libicalss_la_LDFLAGS = -version-info 0:0:0
-
-libicalss_la_SOURCES = \
- icalcalendar.h \
- icalclassify.c \
- icalclassify.h \
- icalgauge.c \
- icalgauge.h \
- icalgaugeimpl.h \
- icaldirset.h \
- icaldirsetimpl.h \
- icalfileset.c \
- icalfileset.h \
- icalfilesetimpl.h \
- icalset.c \
- icalset.h \
- icalsslexer.l \
- icalssyacc.h \
- icalssyacc.y \
- icalspanlist.c \
- icalspanlist.h \
- icalmessage.c \
- icalmessage.h \
- icalcstpclient.c \
- icalcstpclient.h \
- icalcstpserver.c \
- icalcstpserver.h \
- icalcstp.c \
- icalcstp.h
-
-libicalssincludedir = $(includedir)
-
-COMBINEDHEADERS = \
- $(srcdir)/icalgauge.h \
- $(srcdir)/icalset.h \
- $(srcdir)/icalfileset.h \
- $(srcdir)/icaldirset.h \
- $(srcdir)/icalcalendar.h \
- $(srcdir)/icalclassify.h \
- $(srcdir)/icalspanlist.h \
- $(srcdir)/icalmessage.h \
- $(srcdir)/icalcstp.h \
- $(srcdir)/icalcstpclient.h \
- $(srcdir)/icalcstpserver.h
-
-
-icalss.h: $(COMBINEDHEADERS)
- cat $(COMBINEDHEADERS) | egrep -v "#include.*\"ical" \
- | egrep -v "#include.*\"pvl\.h\"" > icalss.h
-
-
-libicalssinclude_HEADERS = icalss.h
-
-CONFIG_CLEAN_FILES = y.output
-
diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c
deleted file mode 100644
index e63b5330ad..0000000000
--- a/libical/src/libicalss/icalcalendar.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*======================================================================
- FILE: icalcalendar.c
- CREATOR: eric 23 December 1999
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- ======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include "icalcalendar.h"
-#include "icalset.h"
-#include "icalfileset.h"
-#include "icaldirset.h"
-#include <limits.h>
-#include <sys/stat.h> /* For mkdir, stat */
-#include <sys/types.h> /* For mkdir */
-#include <fcntl.h> /* For mkdir */
-#include <unistd.h> /* For mkdir, stat */
-#include <stdlib.h> /* for malloc */
-#include <string.h> /* for strcat */
-#include <errno.h>
-
-#define BOOKED_DIR "booked"
-#define INCOMING_FILE "incoming.ics"
-#define PROP_FILE "properties.ics"
-#define FBLIST_FILE "freebusy.ics"
-
-struct icalcalendar_impl
-{
- char* dir;
- icalcomponent* freebusy;
- icalcomponent* properties;
- icalset* booked;
- icalset* incoming;
-};
-
-struct icalcalendar_impl* icalcalendar_new_impl()
-{
- struct icalcalendar_impl* impl;
-
- if ( ( impl = (struct icalcalendar_impl*)
- malloc(sizeof(struct icalcalendar_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- return impl;
-}
-
-
-icalerrorenum icalcalendar_create(struct icalcalendar_impl* impl)
-{
- char path[PATH_MAX];
- struct stat sbuf;
- int r;
-
- icalerror_check_arg_re((impl != 0),"impl",ICAL_BADARG_ERROR);
-
- path[0] = '\0';
- strcpy(path,impl->dir);
- strcat(path,"/");
- strcat(path,BOOKED_DIR);
-
- r = stat(path,&sbuf);
-
- if( r != 0 && errno == ENOENT){
-
- if(mkdir(path,0777)!=0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
- }
-
- return ICAL_NO_ERROR;
-}
-
-icalcalendar* icalcalendar_new(char* dir)
-{
- struct icalcalendar_impl* impl;
-
- icalerror_check_arg_rz((dir != 0),"dir");
-
- impl = icalcalendar_new_impl();
-
- if (impl == 0){
- return 0;
- }
-
- impl->dir = (char*)strdup(dir);
- impl->freebusy = 0;
- impl->properties = 0;
- impl->booked = 0;
- impl->incoming = 0;
-
- if (icalcalendar_create(impl) != ICAL_NO_ERROR){
- free(impl);
- return 0;
- }
-
- return impl;
-}
-
-void icalcalendar_free(icalcalendar* calendar)
-{
-
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
-
- if (impl->dir !=0){
- free(impl->dir);
- }
-
- if (impl->freebusy !=0){
- icalfileset_free(impl->freebusy);
- }
-
- if (impl->properties !=0){
- icalfileset_free(impl->properties);
- }
-
- if (impl->booked !=0){
- icaldirset_free(impl->booked);
- }
-
- if (impl->incoming !=0){
- icaldirset_free(impl->incoming);
- }
-
- impl->dir = 0;
- impl->freebusy = 0;
- impl->properties = 0;
- impl->booked = 0;
- impl->incoming = 0;
-
-
- free(impl);
-}
-
-
-int icalcalendar_lock(icalcalendar* calendar)
-{
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
- return 0;
-}
-
-int icalcalendar_unlock(icalcalendar* calendar)
-{
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
- return 0;
-}
-
-int icalcalendar_islocked(icalcalendar* calendar)
-{
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
- return 0;
-}
-
-int icalcalendar_ownlock(icalcalendar* calendar)
-{
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
- return 0;
-}
-
-icalset* icalcalendar_get_booked(icalcalendar* calendar)
-{
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- char dir[PATH_MAX];
-
- icalerror_check_arg_rz((impl != 0),"impl");
-
- dir[0] = '\0';
- strcpy(dir,impl->dir);
- strcat(dir,"/");
- strcat(dir,BOOKED_DIR);
-
- if (impl->booked == 0){
- icalerror_clear_errno();
- impl->booked = icaldirset_new(dir);
- assert(icalerrno == ICAL_NO_ERROR);
- }
-
- return impl->booked;
-
-}
-
-icalset* icalcalendar_get_incoming(icalcalendar* calendar)
-{
- char path[PATH_MAX];
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
-
- path[0] = '\0';
- strcpy(path,impl->dir);
- strcat(path,"/");
- strcat(path,INCOMING_FILE);
-
- if (impl->properties == 0){
- impl->properties = icalfileset_new(path);
- }
-
- return impl->properties;
-}
-
-icalset* icalcalendar_get_properties(icalcalendar* calendar)
-{
- char path[PATH_MAX];
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
-
- path[0] = '\0';
- strcpy(path,impl->dir);
- strcat(path,"/");
- strcat(path,PROP_FILE);
-
- if (impl->properties == 0){
- impl->properties = icalfileset_new(path);
- }
-
- return impl->properties;
-}
-
-icalset* icalcalendar_get_freebusy(icalcalendar* calendar)
-{
- char path[PATH_MAX];
- struct icalcalendar_impl *impl = (struct icalcalendar_impl*)calendar;
- icalerror_check_arg_rz((impl != 0),"impl");
-
- path[0] = '\0';
- strcpy(path,impl->dir);
- strcat(path,"/");
- strcat(path,FBLIST_FILE);
-
-
- if (impl->freebusy == 0){
- impl->freebusy = icalfileset_new(path);
- }
-
- return impl->freebusy;
-}
-
-
-
-
diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h
deleted file mode 100644
index f07457c60d..0000000000
--- a/libical/src/libicalss/icalcalendar.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- 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
-
-#include "ical.h"
-#include "icalset.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 */
-
-
-
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c
deleted file mode 100644
index ad2d6d6fd8..0000000000
--- a/libical/src/libicalss/icalclassify.c
+++ /dev/null
@@ -1,696 +0,0 @@
-/* -*- 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;
- }
-}
-
-
-
-icalproperty* icalclassify_find_attendee(icalcomponent *c,
- const char* attendee)
-{
- icalproperty *p;
- char* lattendee = icalclassify_lowercase(attendee);
- char* upn = strchr(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 = strchr(this_attendee,':');
-
- if(this_upn == 0){
- continue;
- }
-
- if(strcmp(this_upn,upn)==0){
- return p;
- }
-
- }
-
- return 0;
-
-}
-
-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)
-{
- icalproperty* attendee;
- icalclassify_pre;
-
- attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
-
- if(attendee != 0&&
- 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)
-{
- icalproperty* attendee;
- icalclassify_pre;
-
- attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
-
-
- if( attendee != 0 &&
- 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)
-{
- icalproperty* attendee;
- icalclassify_pre;
-
- attendee= icalclassify_find_attendee(match->c,comp->reply_attendee);
-
- if(attendee == 0 &&
- 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;
- icalproperty* attendee;
- icalclassify_pre;
-
-
- attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);
-
- if(attendee == 0 &&
- 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
deleted file mode 100644
index ae76434378..0000000000
--- a/libical/src/libicalss/icalclassify.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- 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/icalcomponent.h b/libical/src/libicalss/icalcomponent.h
deleted file mode 100644
index 9e0e9f5a9f..0000000000
--- a/libical/src/libicalss/icalcomponent.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcomponent.h
- CREATOR: eric 20 March 1999
-
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
- The original code is icalcomponent.h
-
-======================================================================*/
-
-#ifndef ICALCOMPONENT_H
-#define ICALCOMPONENT_H
-
-#include "icalproperty.h"
-#include "icalvalue.h"
-#include "icalenums.h" /* defines icalcomponent_kind */
-
-typedef void icalcomponent;
-
-icalcomponent* icalcomponent_new(icalcomponent_kind kind);
-icalcomponent* icalcomponent_new_clone(icalcomponent* component);
-icalcomponent* icalcomponent_new_from_string(char* str);
-icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...);
-void icalcomponent_free(icalcomponent* component);
-
-char* icalcomponent_as_ical_string(icalcomponent* component);
-
-int icalcomponent_is_valid(icalcomponent* component);
-
-icalcomponent_kind icalcomponent_isa(icalcomponent* component);
-
-int icalcomponent_isa_component (void* component);
-
-/*
- * Working with properties
- */
-
-void icalcomponent_add_property(icalcomponent* component,
- icalproperty* property);
-
-void icalcomponent_remove_property(icalcomponent* component,
- icalproperty* property);
-
-int icalcomponent_count_properties(icalcomponent* component,
- icalproperty_kind kind);
-
-/* Iterate through the properties */
-icalproperty* icalcomponent_get_current_property(icalcomponent* component);
-
-icalproperty* icalcomponent_get_first_property(icalcomponent* component,
- icalproperty_kind kind);
-icalproperty* icalcomponent_get_next_property(icalcomponent* component,
- icalproperty_kind kind);
-
-/* Return a null-terminated array of icalproperties*/
-
-icalproperty** icalcomponent_get_properties(icalcomponent* component,
- icalproperty_kind kind);
-
-
-/*
- * Working with components
- */
-
-
-void icalcomponent_add_component(icalcomponent* parent,
- icalcomponent* child);
-
-void icalcomponent_remove_component(icalcomponent* parent,
- icalcomponent* child);
-
-int icalcomponent_count_components(icalcomponent* component,
- icalcomponent_kind kind);
-
-/* Iterate through components */
-icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
-
-icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
- icalcomponent_kind kind);
-icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
- icalcomponent_kind kind);
-
-/* Return a null-terminated array of icalproperties*/
-icalproperty** icalcomponent_get_component(icalcomponent* component,
- icalproperty_kind kind);
-
-/* Working with embedded error properties */
-
-int icalcomponent_count_errors(icalcomponent* component);
-void icalcomponent_strip_errors(icalcomponent* component);
-
-
-/* Internal operations. You don't see these... */
-icalcomponent* icalcomponent_get_parent(icalcomponent* component);
-void icalcomponent_set_parent(icalcomponent* component,
- icalcomponent* parent);
-
-#endif /* !ICALCOMPONENT_H */
-
-
-
diff --git a/libical/src/libicalss/icalcsdb.h b/libical/src/libicalss/icalcsdb.h
deleted file mode 100644
index 4619b94fd0..0000000000
--- a/libical/src/libicalss/icalcsdb.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcsdb.h Calendar Server Database
- 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/
-
-
-======================================================================*/
-
-#ifndef ICALCSDB_H
-#define ICALCSDB_H
-
-#include "ical.h"
-
-typedef void icalcsdb;
-
-icalcsdb* icalcsdb_new(char* path);
-
-void icalcsdb_free(icalcsdb* csdb);
-
-icalerrorenum icalcsdb_create(icalcsdb* db, char* calid);
-
-icalerrorenum icalcsdb_delete(icalcsdb* db, char* calid);
-
-icalerrorenum icalcsdb_move(icalcsdb* db, char* oldcalid, char* newcalid);
-
-icalerrorenum icalcsdb_noop(icalcsdb* db);
-
-char* icalcsdb_generateuid(icalcsdb* db);
-
-icalcomponent* icalcsdb_expand_upn(icalcsdb* db, char* upn);
-icalcomponent* icalcsdb_expand_calid(icalcsdb* db, char* calid);
-
-icalerrorenum icalcsbd_senddata(icalcsdb* db, icalcomponent* comp);
-
-icalset* icalcsdb_get_calendar(icalcsdb* db, char* calid,
- icalcomponent *gauge);
-
-icalset* icalcsdb_get_vcars(icalcsdb* db);
-
-icalset* icalcsdb_get_properties(icalcsdb* db);
-
-icalset* icalcsdb_get_capabilities(icalcsdb* db);
-
-icalset* icalcsdb_get_timezones(icalcsdb* db);
-
-
-#endif /* !ICALCSDB_H */
-
-
-
diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c
deleted file mode 100644
index 3b212b424a..0000000000
--- a/libical/src/libicalss/icalcstp.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- 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>
-#include <stdlib.h> /* for malloc */
-#include <string.h>
-
-
-struct command_map {
- enum icalcstp_command command;
- char *str;
-} command_map[] =
-{
- {ICAL_ABORT_COMMAND,"ABORT"},
- {ICAL_AUTHENTICATE_COMMAND,"AUTHENTICATE"},
- {ICAL_CAPABILITY_COMMAND,"CAPABILITY"},
- {ICAL_CONTINUE_COMMAND,"CONTINUE"},
- {ICAL_CALIDEXPAND_COMMAND,"CALIDEXPAND"},
- {ICAL_IDENTIFY_COMMAND,"IDENTIFY"},
- {ICAL_DISCONNECT_COMMAND,"DISCONNECT"},
- {ICAL_SENDDATA_COMMAND,"SENDDATA"},
- {ICAL_STARTTLS_COMMAND,"STARTTLS"},
- {ICAL_UPNEXPAND_COMMAND,"UPNEXPAND"},
- {ICAL_UNKNOWN_COMMAND,"UNKNOWN"}
-};
-
-
-icalcstp_command icalcstp_line_command(char* line)
-{
- int i;
-
- for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){
- size_t l = strlen(command_map[i].str);
-
- if(strncmp(line, command_map[i].str, l) == 0){
- return command_map[i].command;
- }
-
- }
-
- return ICAL_UNKNOWN_COMMAND;
-}
-
-icalrequeststatus icalcstp_line_response_code(char* line)
-{
- struct icalreqstattype rs;
-
- rs = icalreqstattype_from_string(line);
-
- return rs.code;
-}
-
-int icalcstp_line_is_endofdata(char* line)
-{
- if(line[0] == '.' && line[1] == '\n'){
- return 1;
- }
-
- return 0;
-
-}
-
-int icalcstp_line_is_mime(char* line)
-{
-}
-
-
-const char* icalcstp_command_to_string(icalcstp_command command){
-
- int i;
-
- for(i = 0; command_map[i].command != ICAL_UNKNOWN_COMMAND; i++){
- size_t l = strlen(command_map[i].str);
-
- if(command_map[i].command == command){
- return command_map[i].str;
- }
-
- }
-
- return command_map[i].str;
-
-}
-
diff --git a/libical/src/libicalss/icalcstp.h b/libical/src/libicalss/icalcstp.h
deleted file mode 100644
index dfc361830e..0000000000
--- a/libical/src/libicalss/icalcstp.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- 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
-
-#include "ical.h"
-
-
-/* Connection state, from the state machine in RFC2445 */
-enum cstps_state {
- NO_STATE,
- CONNECTED,
- AUTHENTICATED,
- IDENTIFIED,
- DISCONNECTED,
- RECEIVE
-};
-
-/* CSTP Commands that a client can issue to a server */
-typedef enum icalcstp_command {
- ICAL_ABORT_COMMAND,
- ICAL_AUTHENTICATE_COMMAND,
- ICAL_CAPABILITY_COMMAND,
- ICAL_CONTINUE_COMMAND,
- ICAL_CALIDEXPAND_COMMAND,
- ICAL_IDENTIFY_COMMAND,
- ICAL_DISCONNECT_COMMAND,
- ICAL_SENDDATA_COMMAND,
- ICAL_STARTTLS_COMMAND,
- ICAL_UPNEXPAND_COMMAND,
- ICAL_COMPLETE_COMMAND,
- ICAL_UNKNOWN_COMMAND
-} icalcstp_command;
-
-
-
-/* A statement is a combination of command or response code and a
- component that the server and client exchage with each other. */
-struct icalcstp_statement {
- icalcstp_command command;
- char* str_data; /* If non-NUll use as arguments to command */
- int int_data; /* If non-NULL use as arguments to command */
-
- icalrequeststatus code;
-
- icalcomponent* data;
-};
-
-const char* icalcstp_command_to_string(icalcstp_command command);
-icalcstp_command icalcstp_string_to_command(const char* str);
-
-#endif /* !ICALCSTP_H */
-
-
-
diff --git a/libical/src/libicalss/icalcstpclient.c b/libical/src/libicalss/icalcstpclient.c
deleted file mode 100644
index d53d53f568..0000000000
--- a/libical/src/libicalss/icalcstpclient.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/* -*- 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 "icalcstpclient.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>
-#include <stdlib.h> /* for malloc */
-#include <string.h>
-
-#define EOL "\n"
-
-
-/* Client state machine */
-
-typedef enum icalcstpc_line_type {
- ICALCSTPC_RESPONSE_CODE_LINE,
- ICALCSTPC_TERMINATOR_LINE,
- ICALCSTPC_APPLICATION_DATA_LINE
-} icalcstpc_line_type;
-
-typedef enum icalcstpc_state {
- ICALCSTPC_SEND_STATE,
- ICALCSTPC_RESPONSE_CODE_STATE,
- ICALCSTPC_RESPONSE_DATA_STATE
-} icalcstpc_state;
-
-
-
-struct icalcstpc_impl {
- int timeout;
- icalparser *parser;
- icalcstp_command command;
- icalcstpc_state state;
- char* next_output;
- char* next_input;
-};
-
-icalcstpc* icalcstpc_new()
-{
- struct icalcstpc_impl *impl;
-
- impl = malloc(sizeof(struct icalcstpc_impl));
-
- if(impl == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- memset(impl,0,sizeof(struct icalcstpc_impl));
-
- return impl;
-}
-
-void icalcstpc_free(icalcstpc* cstpc)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstpc;
-
- if(impl->next_output != 0){
- free(impl->next_output);
- }
-
- if(impl->next_input != 0){
- free(impl->next_input);
- }
-
-
- if(impl->parser != 0){
- icalparser_free(impl->parser);
- }
-}
-
-/* Get the next string to send to the server */
-char* icalcstpc_next_output(icalcstpc* cstp, char * line)
-{
- char* out;
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- if(impl->next_output == 0){
- return 0;
- }
-
- out = impl->next_output;
-
- impl->next_output = 0;
-
- icalmemory_add_tmp_buffer(out);
-
- return out;
-}
-
-/* process the next string sent by the server */
-int icalcstpc_next_input(icalcstpc* cstp, char* line)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
- icalcstpc_line_type line_type;
-
- if(icalcstp_line_is_endofdata(line) || line == 0){
- return 0;
- }
-
- switch (impl->command){
- case ICAL_ABORT_COMMAND:{
- break;
- }
- case ICAL_AUTHENTICATE_COMMAND:{
- break;
- }
- case ICAL_CAPABILITY_COMMAND:{
- break;
- }
- case ICAL_CONTINUE_COMMAND:{
- break;
- }
- case ICAL_CALIDEXPAND_COMMAND:{
- break;
- }
- case ICAL_IDENTIFY_COMMAND:{
- break;
- }
- case ICAL_DISCONNECT_COMMAND:{
- break;
- }
- case ICAL_SENDDATA_COMMAND:{
- break;
- }
- case ICAL_STARTTLS_COMMAND:{
- break;
- }
- case ICAL_UPNEXPAND_COMMAND:{
- break;
- }
- case ICAL_COMPLETE_COMMAND:{
- break;
- }
- case ICAL_UNKNOWN_COMMAND:{
- break;
- }
- default:
- break;
- }
-}
-
-/* After icalcstpc_next_input returns a 0, there are responses
- ready. use these to get them */
-icalcstpc_response icalcstpc_first_response(icalcstpc* cstp)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
-}
-
-
-icalcstpc_response icalcstpc_next_response(icalcstpc* cstp)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-}
-
-
-int icalcstpc_set_timeout(icalcstpc* cstp, int sec)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-}
-
-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\n";
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpclient_setup_output(icalcstpc* cstp, size_t sz)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- if(impl->next_output != 0){
- icalerror_set_errno(ICAL_USAGE_ERROR);
- return ICAL_USAGE_ERROR;
- }
-
- impl->next_output = malloc(sz);
-
- if(impl->next_output == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return ICAL_NEWFAILED_ERROR;
- }
-
- return ICAL_NO_ERROR;
-
-}
-
-icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
- char* data, char* f(char*))
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
- char* command_str;
- icalerrorenum error;
- size_t sz;
-
- icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR);
- icalerror_check_arg_re(mechanism!=0,"mechanism",ICAL_BADARG_ERROR);
- icalerror_check_arg_re(data!=0,"data",ICAL_BADARG_ERROR);
- icalerror_check_arg_re(f!=0,"f",ICAL_BADARG_ERROR);
-
- impl->command = ICAL_AUTHENTICATE_COMMAND;
-
- command_str = icalcstp_command_to_string(impl->command);
-
- sz = strlen(command_str) + strlen(mechanism) + strlen(data) + 4;
-
- if((error=icalcstpclient_setup_output(cstp,sz)) != ICAL_NO_ERROR){
- return error;
- }
-
- sprintf(impl->next_output,"%s %s %s%s",command_str,mechanism,data,EOL);
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_capability(icalcstpc* cstp)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
- char* command_str;
- icalerrorenum error;
- size_t sz;
-
- icalerror_check_arg_re(cstp!=0,"cstp",ICAL_BADARG_ERROR);
-
- impl->command = ICAL_CAPABILITY_COMMAND;
-
- command_str = icalcstp_command_to_string(impl->command);
-
- sz = strlen(command_str);
-
- if((error=icalcstpclient_setup_output(cstp,sz)) != ICAL_NO_ERROR){
- return error;
- }
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- impl->command = ICAL_CALIDEXPAND_COMMAND;
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- impl->command = ICAL_CONTINUE_COMMAND;
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_disconnect(icalcstpc* cstp)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
-
- impl->command = ICAL_DISCONNECT_COMMAND;
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
-
- impl->command = ICAL_IDENTIFY_COMMAND;
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
- char* data, char * f(char*))
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- impl->command = ICAL_STARTTLS_COMMAND;
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
-
- impl->command = ICAL_UPNEXPAND_COMMAND;
-
- return ICAL_NO_ERROR;
-}
-
-icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
- icalcomponent *comp)
-{
- struct icalcstpc_impl *impl = (struct icalcstpc_impl *)cstp;
-
- impl->command = ICAL_SENDDATA_COMMAND;
-
- return ICAL_NO_ERROR;
-}
-
-
-
-
diff --git a/libical/src/libicalss/icalcstpclient.h b/libical/src/libicalss/icalcstpclient.h
deleted file mode 100644
index 8d9d0c904c..0000000000
--- a/libical/src/libicalss/icalcstpclient.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcstpclient.h
- CREATOR: eric 4 Feb 01
-
- $Id$
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The original code is icalcstp.h
-
-======================================================================*/
-
-
-#ifndef ICALCSTPC_H
-#define ICALCSTPC_H
-
-#include "ical.h"
-#include "icalcstp.h"
-
-/********************** Client (Sender) Interfaces **************************/
-
-/* How to use:
-
- 1) Construct a new icalcstpc
- 2) Issue a command by calling one of the command routines.
- 3) Repeat until both call icalcstpc_next_output and
- icalcstpc_next_input return 0:
- 3a) Call icalcstpc_next_output. Send string to server.
- 3b) Get string from server, & give to icalcstp_next_input()
- 4) Iterate with icalcstpc_first_response & icalcstp_next_response to
- get the servers responses
- 5) Repeat at #2
-*/
-
-
-typedef void icalcstpc;
-
-/* Response code sent by the server. */
-typedef struct icalcstpc_response {
- icalrequeststatus code;
- char *arg; /* These strings are owned by libical */
- char *debug_text;
- char *more_text;
- void* result;
-} icalcstpc_response;
-
-
-icalcstpc* icalcstpc_new();
-
-void icalcstpc_free(icalcstpc* cstpc);
-
-int icalcstpc_set_timeout(icalcstpc* cstp, int sec);
-
-
-/* Get the next string to send to the server */
-char* icalcstpc_next_output(icalcstpc* cstp, char* line);
-
-/* process the next string from the server */
-int icalcstpc_next_input(icalcstpc* cstp, char * line);
-
-/* After icalcstpc_next_input returns a 0, there are responses
- ready. use these to get them */
-icalcstpc_response icalcstpc_first_response(icalcstpc* cstp);
-icalcstpc_response icalcstpc_next_response(icalcstpc* cstp);
-
-/* Issue a command */
-icalerrorenum icalcstpc_abort(icalcstpc* cstp);
-icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
- char* init_data, char* f(char*) );
-icalerrorenum icalcstpc_capability(icalcstpc* cstp);
-icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid);
-icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time);
-icalerrorenum icalcstpc_disconnect(icalcstpc* cstp);
-icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id);
-icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
- char* init_data, char* f(char*));
-icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time,
- icalcomponent *comp);
-icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid);
-icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
- icalcomponent *comp);
-
-
-#endif /* !ICALCSTPC_H */
-
-
-
diff --git a/libical/src/libicalss/icalcstpserver.c b/libical/src/libicalss/icalcstpserver.c
deleted file mode 100644
index 1a6ed7b976..0000000000
--- a/libical/src/libicalss/icalcstpserver.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalcstpserver.c
- CREATOR: ebusboom 13 Feb 01
-
- $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 "icalcstpserver.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>
-#include <stdlib.h> /* for malloc */
-#include <string.h>
-
-
-
-struct icalcstps_impl {
- int timeout;
- icalparser *parser;
- enum cstps_state major_state;
- struct icalcstps_commandfp commandfp;
-};
-
-
-
-
-/* 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 icalcstp_command command;
- void (*action)();
- enum cstps_state next_state;
-
-} server_state_table[] =
-{
- { CONNECTED, ICAL_CAPABILITY_COMMAND , 0, CONNECTED},
- { CONNECTED, ICAL_AUTHENTICATE_COMMAND , 0, IDENTIFIED}, /* Non-standard */
- { IDENTIFIED, ICAL_STARTTLS_COMMAND, 0, IDENTIFIED},
- { IDENTIFIED, ICAL_IDENTIFY_COMMAND, 0, IDENTIFIED},
- { IDENTIFIED, ICAL_CAPABILITY_COMMAND, 0, IDENTIFIED},
- { IDENTIFIED, ICAL_SENDDATA_COMMAND, 0, RECEIVE},
- { IDENTIFIED, ICAL_DISCONNECT_COMMAND, 0, DISCONNECTED},
- { DISCONNECTED, 0, 0, 0},
- { RECEIVE, ICAL_DISCONNECT_COMMAND, 0, DISCONNECTED},
- { RECEIVE, ICAL_CONTINUE_COMMAND, 0, RECEIVE},
- { RECEIVE, ICAL_ABORT_COMMAND , 0, IDENTIFIED},
- { RECEIVE, ICAL_COMPLETE_COMMAND , 0, IDENTIFIED}
-};
-
-
-/**********************************************************************/
-
-
-
-icalcstps* icalcstps_new(struct icalcstps_commandfp cfp)
-{
- struct icalcstps_impl* impl;
-
- if ( ( impl = (struct icalcstps_impl*)
- malloc(sizeof(struct icalcstps_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- impl->commandfp = cfp;
- 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;
-
-
-icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data)
-{ return ICAL_NO_ERROR;
-}
-icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data)
-{ return ICAL_NO_ERROR;
-}
-icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data)
-{
- return ICAL_NO_ERROR;
-}
-icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data)
-{ return ICAL_NO_ERROR;
-}
-
-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*)strstr(" ",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);
- }
-
- return 0;
-}
-
- /* 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);
-};
-
diff --git a/libical/src/libicalss/icalcstpserver.h b/libical/src/libicalss/icalcstpserver.h
deleted file mode 100644
index 6fa2254b2e..0000000000
--- a/libical/src/libicalss/icalcstpserver.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalcstpserver.h
- CREATOR: eric 13 Feb 01
-
- $Id$
-
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The original code is icalcstp.h
-
-======================================================================*/
-
-
-#ifndef ICALCSTPS_H
-#define ICALCSTPS_H
-
-#include "ical.h"
-
-
-/********************** Server (Reciever) Interfaces *************************/
-
-/* On the server side, the caller will recieve data from the incoming
- socket and pass it to icalcstps_next_input. The caller then takes
- the return from icalcstps_next_outpu and sends it out through the
- socket. This gives the caller a point of control. If the cstp code
- connected to the socket itself, it would be hard for the caller to
- do anything else after the cstp code was started.
-
- All of the server and client command routines will generate
- response codes. On the server side, these responses will be turned
- into text and sent to the client. On the client side, the reponse
- is the one sent from the server.
-
- Since each command can return multiple responses, the responses are
- stored in the icalcstps object and are accesses by
- icalcstps_first_response() and icalcstps_next_response()
-
- How to use:
-
- 1) Construct a new icalcstps, bound to your code via stubs
- 2) Repeat forever:
- 2a) Get string from client & give to icalcstps_next_input()
- 2b) Repeat until icalcstp_next_output returns 0:
- 2b1) Call icalcstps_next_output.
- 2b2) Send string to client.
-*/
-
-
-
-typedef void icalcstps;
-
-/* Pointers to the rountines that
- icalcstps_process_incoming will call when it recognizes a CSTP
- command in the data. BTW, the CONTINUE command is named 'cont'
- because 'continue' is a C keyword */
-
-struct icalcstps_commandfp {
- icalerrorenum (*abort)(icalcstps* cstp);
- icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism,
- char* data);
- icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid);
- icalerrorenum (*capability)(icalcstps* cstp);
- icalerrorenum (*cont)(icalcstps* cstp, unsigned int time);
- icalerrorenum (*identify)(icalcstps* cstp, char* id);
- icalerrorenum (*disconnect)(icalcstps* cstp);
- icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time,
- icalcomponent *comp);
- icalerrorenum (*starttls)(icalcstps* cstp, char* command,
- char* data);
- icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn);
- icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data);
-};
-
-
-
-icalcstps* icalcstps_new(struct icalcstps_commandfp stubs);
-
-void icalcstps_free(icalcstps* cstp);
-
-int icalcstps_set_timeout(icalcstps* cstp, int sec);
-
-/* Get the next string to send to the client */
-char* icalcstps_next_output(icalcstps* cstp);
-
-/* process the next string from the client */
-int icalcstps_next_input(icalcstps* cstp);
-
-#endif /* ICALCSTPS */
diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c
deleted file mode 100644
index 3a7b9cfdd9..0000000000
--- a/libical/src/libicalss/icaldirset.c
+++ /dev/null
@@ -1,753 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icaldirset.c
- 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
-
-
- ======================================================================*/
-
-
-/*
-
- icaldirset manages a database of ical components and offers
- interfaces for reading, writting and searching for components.
-
- icaldirset groups components in to clusters based on their DTSTAMP
- time -- all components that start in the same month are grouped
- together in a single file. All files in a sotre are kept in a single
- directory.
-
- The primary interfaces are icaldirset_first and icaldirset_next. These
- routine iterate through all of the components in the store, subject
- to the current gauge. A gauge is an icalcomponent that is tested
- against other componets for a match. If a gauge has been set with
- icaldirset_select, icaldirset_first and icaldirset_next will only
- return componentes that match the gauge.
-
- The Store generated UIDs for all objects that are stored if they do
- not already have a UID. The UID is the name of the cluster (month &
- year as MMYYYY) plus a unique serial number. The serial number is
- stored as a property of the cluster.
-
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include "ical.h"
-#include "icaldirset.h"
-#include "pvl.h"
-#include "icalerror.h"
-#include "icalparser.h"
-#include "icaldirset.h"
-#include "icalfileset.h"
-#include "icalfilesetimpl.h"
-#include "icalgauge.h"
-
-#include <limits.h> /* For PATH_MAX */
-#include <dirent.h> /* for opendir() */
-#include <errno.h>
-#include <sys/types.h> /* for opendir() */
-#include <sys/stat.h> /* for stat */
-#include <unistd.h> /* for stat, getpid */
-#include <time.h> /* for clock() */
-#include <stdlib.h> /* for rand(), srand() */
-#include <sys/utsname.h> /* for uname */
-#include <string.h> /* for strdup */
-#include "icaldirsetimpl.h"
-
-
-struct icaldirset_impl* icaldirset_new_impl()
-{
- struct icaldirset_impl* impl;
-
- if ( ( impl = (struct icaldirset_impl*)
- malloc(sizeof(struct icaldirset_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- strcpy(impl->id,ICALDIRSET_ID);
-
- return impl;
-}
-
-const char* icaldirset_path(icaldirset* cluster)
-{
- struct icaldirset_impl *impl = icaldirset_new_impl();
-
- return impl->dir;
-
-}
-
-void icaldirset_mark(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- icalfileset_mark(impl->cluster);
-}
-
-
-icalerrorenum icaldirset_commit(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- return icalfileset_commit(impl->cluster);
-
-}
-
-void icaldirset_lock(const char* dir)
-{
-}
-
-
-void icaldirset_unlock(const char* dir)
-{
-}
-
-/* Load the contents of the store directory into the store's internal directory list*/
-icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
-{
- struct dirent *de;
- DIR* dp;
- char *str;
-
- dp = opendir(impl->dir);
-
- if ( dp == 0) {
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
-
- /* clear contents of directory list */
- while((str = pvl_pop(impl->directory))){
- free(str);
- }
-
- /* load all of the cluster names in the directory list */
- for(de = readdir(dp);
- de != 0;
- de = readdir(dp)){
-
- /* Remove known directory names '.' and '..'*/
- if (strcmp(de->d_name,".") == 0 ||
- strcmp(de->d_name,"..") == 0 ){
- continue;
- }
-
- pvl_push(impl->directory, (void*)strdup(de->d_name));
- }
-
- closedir(dp);
-
- return ICAL_NO_ERROR;
-}
-
-icaldirset* icaldirset_new(const char* dir)
-{
- struct icaldirset_impl *impl = icaldirset_new_impl();
- struct stat sbuf;
-
- if (impl == 0){
- return 0;
- }
-
- icalerror_check_arg_rz( (dir!=0), "dir");
-
- if (stat(dir,&sbuf) != 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- return 0;
- }
-
- /* dir is not the name of a direectory*/
- if (!S_ISDIR(sbuf.st_mode)){
- icalerror_set_errno(ICAL_USAGE_ERROR);
- return 0;
- }
-
- icaldirset_lock(dir);
-
- impl = icaldirset_new_impl();
-
- if (impl ==0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- impl->directory = pvl_newlist();
- impl->directory_iterator = 0;
- impl->dir = (char*)strdup(dir);
- impl->gauge = 0;
- impl->first_component = 0;
- impl->cluster = 0;
-
- icaldirset_read_directory(impl);
-
- return (icaldirset*) impl;
-}
-
-void icaldirset_free(icaldirset* s)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)s;
- char* str;
-
- icaldirset_unlock(impl->dir);
-
- if(impl->dir !=0){
- free(impl->dir);
- }
-
- if(impl->gauge !=0){
- icalcomponent_free(impl->gauge);
- }
-
- if(impl->cluster !=0){
- icalfileset_free(impl->cluster);
- }
-
- while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){
- free(str);
- }
-
- if(impl->directory != 0){
- pvl_free(impl->directory);
- }
-
- impl->directory = 0;
- impl->directory_iterator = 0;
- impl->dir = 0;
- impl->gauge = 0;
- impl->first_component = 0;
-
- free(impl);
-
-}
-
-/* icaldirset_next_uid_number updates a serial number in the Store
- directory in a file called SEQUENCE */
-
-int icaldirset_next_uid_number(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
- char sequence = 0;
- char temp[128];
- char filename[ICAL_PATH_MAX];
- char *r;
- FILE *f;
- struct stat sbuf;
-
- icalerror_check_arg_rz( (store!=0), "store");
-
- sprintf(filename,"%s/%s",impl->dir,"SEQUENCE");
-
- /* Create the file if it does not exist.*/
- if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){
-
- f = fopen(filename,"w");
- if (f != 0){
- fprintf(f,"0");
- fclose(f);
- } else {
- icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
- return 0;
- }
-
- }
-
- if ( (f = fopen(filename,"r+")) != 0){
-
- rewind(f);
- r = fgets(temp,128,f);
-
- if (r == 0){
- sequence = 1;
- } else {
- sequence = atoi(temp)+1;
- }
-
- rewind(f);
-
- fprintf(f,"%d",sequence);
-
- fclose(f);
-
- return sequence;
-
- } else {
- icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
- return 0;
- }
-
-}
-
-icalerrorenum icaldirset_next_cluster(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
- char path[ICAL_PATH_MAX];
-
- if (impl->directory_iterator == 0){
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
- return ICAL_INTERNAL_ERROR;
- }
- impl->directory_iterator = pvl_next(impl->directory_iterator);
-
- if (impl->directory_iterator == 0){
- /* There are no more clusters */
- if(impl->cluster != 0){
- icalfileset_free(impl->cluster);
- impl->cluster = 0;
- }
- return ICAL_NO_ERROR;
- }
-
- sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
-
- icalfileset_free(impl->cluster);
-
- impl->cluster = icalfileset_new(path);
-
- return icalerrno;
-}
-
-void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
-{
- char uidstring[ICAL_PATH_MAX];
- icalproperty *uid;
- struct utsname unamebuf;
-
- icalerror_check_arg_rv( (store!=0), "store");
- icalerror_check_arg_rv( (comp!=0), "comp");
-
- uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
-
- if (uid == 0) {
-
- uname(&unamebuf);
-
- sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename);
-
- uid = icalproperty_new_uid(uidstring);
- icalcomponent_add_property(comp,uid);
- } else {
-
- strcpy(uidstring,icalproperty_get_uid(uid));
- }
-}
-
-
-/* This assumes that the top level component is a VCALENDAR, and there
- is an inner component of type VEVENT, VTODO or VJOURNAL. The inner
- component must have a DTAMP property */
-
-icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
-{
- struct icaldirset_impl *impl;
- char clustername[ICAL_PATH_MAX];
- icalproperty *dt;
- icalvalue *v;
- struct icaltimetype tm;
- icalerrorenum error = ICAL_NO_ERROR;
- icalcomponent *inner;
-
- impl = (struct icaldirset_impl*)store;
- icalerror_check_arg_rz( (store!=0), "store");
- icalerror_check_arg_rz( (comp!=0), "comp");
-
- errno = 0;
-
- icaldirset_add_uid(store,comp);
-
- /* Determine which cluster this object belongs in. This is a HACK */
-
- for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
- inner != 0;
- inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
-
- dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
-
- if (dt != 0){
- break;
- }
- }
-
- if (dt == 0){
-
- for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
- inner != 0;
- inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
-
- dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
-
- if (dt != 0){
- break;
- }
- }
-
- }
-
- if (dt == 0){
-
-
- icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store");
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return ICAL_BADARG_ERROR;
- }
-
- v = icalproperty_get_value(dt);
-
- tm = icalvalue_get_datetime(v);
-
- snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month);
-
- /* Load the cluster and insert the object */
-
- if(impl->cluster != 0 &&
- strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){
- icalfileset_free(impl->cluster);
- impl->cluster = 0;
- }
-
- if (impl->cluster == 0){
- impl->cluster = icalfileset_new(clustername);
-
- if (impl->cluster == 0){
- error = icalerrno;
- }
- }
-
- if (error != ICAL_NO_ERROR){
- icalerror_set_errno(error);
- return error;
- }
-
- /* Add the component to the cluster */
-
- icalfileset_add_component(impl->cluster,comp);
-
- icalfileset_mark(impl->cluster);
-
- return ICAL_NO_ERROR;
-}
-
-/* Remove a component in the current cluster. HACK. This routine is a
- "friend" of icalfileset, and breaks its encapsulation. It was
- either do it this way, or add several layers of interfaces that had
- no other use. */
-icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- struct icalfileset_impl *filesetimpl =
- (struct icalfileset_impl*)impl->cluster;
-
- icalcomponent *filecomp = filesetimpl->cluster;
-
- icalcompiter i;
- int found = 0;
-
- icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR);
- icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR);
- icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR);
-
- for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT);
- icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
-
- icalcomponent *this = icalcompiter_deref(&i);
-
- if (this == comp){
- found = 1;
- break;
- }
- }
-
- if (found != 1){
- icalerror_warn("icaldirset_remove_component: component is not part of current cluster");
- icalerror_set_errno(ICAL_USAGE_ERROR);
- return ICAL_USAGE_ERROR;
- }
-
- icalfileset_remove_component(impl->cluster,comp);
-
- icalfileset_mark(impl->cluster);
-
- /* If the removal emptied the fileset, get the next fileset */
- if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){
-
- icalerrorenum error = icaldirset_next_cluster(store);
-
- if(impl->cluster != 0 && error == ICAL_NO_ERROR){
- icalfileset_get_first_component(impl->cluster);
- } else {
- /* HACK. Not strictly correct for impl->cluster==0 */
- return error;
- }
- } else {
- /* Do nothing */
- }
-
- return ICAL_NO_ERROR;
-}
-
-
-
-int icaldirset_count_components(icaldirset* store,
- icalcomponent_kind kind)
-{
- /* HACK, not implemented */
-
- assert(0);
-
- return 0;
-}
-
-
-icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c)
-{
- fprintf(stderr," icaldirset_fetch_match is not implemented\n");
- assert(0);
-}
-
-
-icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid)
-{
- icalcomponent *gauge;
- icalcomponent *old_gauge;
- icalcomponent *c;
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- icalerror_check_arg_rz( (store!=0), "store");
- icalerror_check_arg_rz( (uid!=0), "uid");
-
- gauge =
- icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_uid(
- uid,
- icalparameter_new_xliccomparetype(
- ICAL_XLICCOMPARETYPE_EQUAL),
- 0),
- 0),
- 0);
-
- old_gauge = impl->gauge;
- impl->gauge = gauge;
-
- c= icaldirset_get_first_component(store);
-
- impl->gauge = old_gauge;
-
- icalcomponent_free(gauge);
-
- return c;
-}
-
-
-int icaldirset_has_uid(icaldirset* store, const char* uid)
-{
- icalcomponent *c;
-
- icalerror_check_arg_rz( (store!=0), "store");
- icalerror_check_arg_rz( (uid!=0), "uid");
-
- /* HACK. This is a temporary implementation. _has_uid should use a
- database, and _fetch should use _has_uid, not the other way
- around */
- c = icaldirset_fetch(store,uid);
-
- return c!=0;
-
-}
-
-
-icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge)
- {
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR);
- icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR);
-
- if (!icalcomponent_is_valid(gauge)){
- return ICAL_BADARG_ERROR;
- }
-
- impl->gauge = gauge;
-
- return ICAL_NO_ERROR;
-}
-
-
-icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
- icalcomponent *new)
-{
- assert(0);
- return ICAL_NO_ERROR; /* HACK, not implemented */
-
-}
-
-
-void icaldirset_clear(icaldirset* store)
-{
-
- assert(0);
- return;
- /* HACK, not implemented */
-}
-
-icalcomponent* icaldirset_get_current_component(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
-
- if(impl->cluster == 0){
- icaldirset_get_first_component(store);
- }
-
- return icalfileset_get_current_component(impl->cluster);
-
-}
-
-
-icalcomponent* icaldirset_get_first_component(icaldirset* store)
-{
- struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
- icalerrorenum error;
- char path[ICAL_PATH_MAX];
-
- error = icaldirset_read_directory(impl);
-
- if (error != ICAL_NO_ERROR){
- icalerror_set_errno(error);
- return 0;
- }
-
- impl->directory_iterator = pvl_head(impl->directory);
-
- if (impl->directory_iterator == 0){
- icalerror_set_errno(error);
- return 0;
- }
-
- snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator));
-
- /* If the next cluster we need is different than the current cluster,
- delete the current one and get a new one */
-
- if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){
- icalfileset_free(impl->cluster);
- impl->cluster = 0;
- }
-
- if (impl->cluster == 0){
- impl->cluster = icalfileset_new(path);
-
- if (impl->cluster == 0){
- error = icalerrno;
- }
- }
-
- if (error != ICAL_NO_ERROR){
- icalerror_set_errno(error);
- return 0;
- }
-
- impl->first_component = 1;
-
- return icaldirset_get_next_component(store);
-}
-
-icalcomponent* icaldirset_get_next_component(icaldirset* store)
-{
- struct icaldirset_impl *impl;
- icalcomponent *c;
- icalerrorenum error;
-
- icalerror_check_arg_rz( (store!=0), "store");
-
- impl = (struct icaldirset_impl*)store;
-
- if(impl->cluster == 0){
-
- icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first");
- icalerror_set_errno(ICAL_USAGE_ERROR);
- return 0;
-
- }
-
- /* Set the component iterator for the following for loop */
- if (impl->first_component == 1){
- icalfileset_get_first_component(impl->cluster);
- impl->first_component = 0;
- } else {
- icalfileset_get_next_component(impl->cluster);
- }
-
-
- while(1){
- /* Iterate through all of the objects in the cluster*/
- for( c = icalfileset_get_current_component(impl->cluster);
- c != 0;
- c = icalfileset_get_next_component(impl->cluster)){
-
- /* If there is a gauge defined and the component does not
- pass the gauge, skip the rest of the loop */
-
-#if 0 /* HACK */
- if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){
- continue;
- }
-#else
- assert(0); /* icalgauge_test needs to be fixed */
-#endif
- /* Either there is no gauge, or the component passed the
- gauge, so return it*/
-
- return c;
- }
-
- /* Fell through the loop, so the component we want is not
- in this cluster. Load a new cluster and try again.*/
-
- error = icaldirset_next_cluster(store);
-
- if(impl->cluster == 0 || error != ICAL_NO_ERROR){
- /* No more clusters */
- return 0;
- } else {
- c = icalfileset_get_first_component(impl->cluster);
-
- return c;
- }
-
- }
-
- return 0; /* Should never get here */
-}
-
-
-
-
-
-
-
diff --git a/libical/src/libicalss/icaldirset.h b/libical/src/libicalss/icaldirset.h
deleted file mode 100644
index 7d205ecf0a..0000000000
--- a/libical/src/libicalss/icaldirset.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- 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
-
-#include "ical.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 */
-
-
-
diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h
deleted file mode 100644
index 0e69ba2f2e..0000000000
--- a/libical/src/libicalss/icaldirsetimpl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- 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/icalfileset.c b/libical/src/libicalss/icalfileset.c
deleted file mode 100644
index b6e3430f7d..0000000000
--- a/libical/src/libicalss/icalfileset.c
+++ /dev/null
@@ -1,637 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalfileset.c
- CREATOR: eric 23 December 1999
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The Original Code is eric. The Initial Developer of the Original
- Code is Eric Busboom
-
-
- ======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalfileset.h"
-#include "icalgauge.h"
-#include <errno.h>
-#include <sys/stat.h> /* for stat */
-#include <unistd.h> /* for stat, getpid */
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h> /* for fcntl */
-#include <unistd.h> /* for fcntl */
-#include "icalfilesetimpl.h"
-
-extern int errno;
-
-int icalfileset_lock(icalfileset *cluster);
-int icalfileset_unlock(icalfileset *cluster);
-icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode);
-int icalfileset_filesize(icalfileset* cluster);
-
-icalerrorenum icalfileset_create_cluster(const char *path);
-
-icalfileset* icalfileset_new_impl()
-{
- struct icalfileset_impl* impl;
-
- if ( ( impl = (struct icalfileset_impl*)
- malloc(sizeof(struct icalfileset_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- errno = ENOMEM;
- return 0;
- }
-
- memset(impl,0,sizeof(struct icalfileset_impl));
-
- strcpy(impl->id,ICALFILESET_ID);
-
- return impl;
-}
-
-
-icalfileset* icalfileset_new(const char* path)
-{
- return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664);
-}
-
-icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
-{
- struct icalfileset_impl *impl = icalfileset_new_impl();
- struct icaltimetype tt;
- off_t cluster_file_size;
-
- memset(&tt,0,sizeof(struct icaltimetype));
-
- icalerror_clear_errno();
- icalerror_check_arg_rz( (path!=0), "path");
-
- if (impl == 0){
- return 0;
- }
-
- impl->path = strdup(path);
-
- cluster_file_size = icalfileset_filesize(impl);
-
- if(cluster_file_size < 0){
- icalfileset_free(impl);
- return 0;
- }
-
- impl->fd = open(impl->path,flags, mode);
-
- if (impl->fd < 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- icalfileset_free(impl);
- return 0;
- }
-
- icalfileset_lock(impl);
-
- if(cluster_file_size > 0 ){
- icalerrorenum error;
- if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){
- icalfileset_free(impl);
- return 0;
- }
- }
-
- if(impl->cluster == 0){
- impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
- }
-
- return impl;
-}
-
-char* icalfileset_read_from_file(char *s, size_t size, void *d)
-{
-
- char* p = s;
- int fd = (int)d;
-
- /* Simulate fgets -- read single characters and stop at '\n' */
-
- for(p=s; p<s+size-1;p++){
-
- if(read(fd,p,1) != 1 || *p=='\n'){
- p++;
- break;
- }
- }
-
- *p = '\0';
-
- if(*s == 0){
- return 0;
- } else {
- return s;
- }
-
-}
-
-
-icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode)
-{
-
- icalparser *parser;
-
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- parser = icalparser_new();
- icalparser_set_gen_data(parser,(void*)impl->fd);
- impl->cluster = icalparser_parse(parser,icalfileset_read_from_file);
- icalparser_free(parser);
-
- if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){
- icalerror_set_errno(ICAL_PARSE_ERROR);
- return ICAL_PARSE_ERROR;
- }
-
- if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){
- /* The parser got a single component, so it did not put it in
- an XROOT. */
- icalcomponent *cl = impl->cluster;
- impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
- icalcomponent_add_component(impl->cluster,cl);
- }
-
- return ICAL_NO_ERROR;
-
-}
-
-int icalfileset_filesize(icalfileset* cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- int cluster_file_size;
- struct stat sbuf;
-
- if (stat(impl->path,&sbuf) != 0){
-
- /* A file by the given name does not exist, or there was
- another error */
- cluster_file_size = 0;
- if (errno == ENOENT) {
- /* It was because the file does not exist */
- return 0;
- } else {
- /* It was because of another error */
- icalerror_set_errno(ICAL_FILE_ERROR);
- return -1;
- }
- } else {
- /* A file by the given name exists, but is it a regular file? */
-
- if (!S_ISREG(sbuf.st_mode)){
- /* Nope, not a regular file */
- icalerror_set_errno(ICAL_FILE_ERROR);
- return -1;
- } else {
- /* Lets assume that it is a file of the right type */
- return sbuf.st_size;
- }
- }
-
- /*return -1; not reached*/
-}
-
-void icalfileset_free(icalfileset* cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_rv((cluster!=0),"cluster");
-
- if (impl->cluster != 0){
- icalfileset_commit(cluster);
- icalcomponent_free(impl->cluster);
- impl->cluster=0;
- }
-
- if(impl->fd > 0){
- icalfileset_unlock(impl);
- close(impl->fd);
- impl->fd = -1;
- }
-
- if(impl->path != 0){
- free(impl->path);
- impl->path = 0;
- }
-
- free(impl);
-}
-
-const char* icalfileset_path(icalfileset* cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- icalerror_check_arg_rz((cluster!=0),"cluster");
-
- return impl->path;
-}
-
-
-int icalfileset_lock(icalfileset *cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- struct flock lock;
- int rtrn;
-
- icalerror_check_arg_rz((impl->fd>0),"impl->fd");
- errno = 0;
- lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
- lock.l_start = 0; /* byte offset relative to l_whence */
- lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
- lock.l_len = 0; /* #bytes (0 means to EOF) */
-
- rtrn = fcntl(impl->fd, F_SETLKW, &lock);
-
- return rtrn;
-}
-
-int icalfileset_unlock(icalfileset *cluster)
-{
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- struct flock lock;
- icalerror_check_arg_rz((impl->fd>0),"impl->fd");
-
- lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
- lock.l_start = 0; /* byte offset relative to l_whence */
- lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
- lock.l_len = 0; /* #bytes (0 means to EOF) */
-
- return (fcntl(impl->fd, F_UNLCK, &lock));
-
-}
-
-#ifdef ICAL_SAFESAVES
-int icalfileset_safe_saves=1;
-#else
-int icalfileset_safe_saves=0;
-#endif
-
-icalerrorenum icalfileset_commit(icalfileset* cluster)
-{
- char tmp[ICAL_PATH_MAX];
- char *str;
- icalcomponent *c;
- off_t write_size=0;
-
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
-
- icalerror_check_arg_re((impl->fd>0),"impl->fd is invalid",
- ICAL_INTERNAL_ERROR) ;
-
- if (impl->changed == 0 ){
- return ICAL_NO_ERROR;
- }
-
- if(icalfileset_safe_saves == 1){
- snprintf(tmp,ICAL_PATH_MAX,"cp %s %s.bak",impl->path,impl->path);
-
- if(system(tmp) < 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
- }
-
- if(lseek(impl->fd,SEEK_SET,0) < 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
-
- for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT);
- c != 0;
- c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){
- int sz;
-
- str = icalcomponent_as_ical_string(c);
-
- sz=write(impl->fd,str,strlen(str));
-
- if ( sz != strlen(str)){
- perror("write");
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
-
- write_size += sz;
- }
-
- impl->changed = 0;
-
- if(ftruncate(impl->fd,write_size) < 0){
- return ICAL_FILE_ERROR;
- }
-
- return ICAL_NO_ERROR;
-
-}
-
-void icalfileset_mark(icalfileset* cluster){
-
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_rv((impl!=0),"cluster");
-
- impl->changed = 1;
-
-}
-
-icalcomponent* icalfileset_get_component(icalfileset* cluster){
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
-
- return impl->cluster;
-}
-
-
-/* manipulate the components in the cluster */
-
-icalerrorenum icalfileset_add_component(icalfileset *cluster,
- icalcomponent* child)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_re((cluster!=0),"cluster", ICAL_BADARG_ERROR);
- icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
-
- icalcomponent_add_component(impl->cluster,child);
-
- icalfileset_mark(cluster);
-
- return ICAL_NO_ERROR;
-
-}
-
-icalerrorenum icalfileset_remove_component(icalfileset *cluster,
- icalcomponent* child)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_re((cluster!=0),"cluster",ICAL_BADARG_ERROR);
- icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
-
- icalcomponent_remove_component(impl->cluster,child);
-
- icalfileset_mark(cluster);
-
- return ICAL_NO_ERROR;
-}
-
-int icalfileset_count_components(icalfileset *cluster,
- icalcomponent_kind kind)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
-
- if(cluster == 0){
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return -1;
- }
-
- return icalcomponent_count_components(impl->cluster,kind);
-}
-
-icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
-
- icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR);
-
- impl->gauge = gauge;
-
- return ICAL_NO_ERROR;
-}
-
-void icalfileset_clear(icalfileset* gauge)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge;
-
- impl->gauge = 0;
-
-}
-
-icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid)
-{
- icalcompiter i;
- struct icalfileset_impl* impl = (struct icalfileset_impl*)store;
-
- for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT);
- icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
-
- icalcomponent *this = icalcompiter_deref(&i);
- icalcomponent *inner = icalcomponent_get_first_real_component(this);
- icalcomponent *p;
- const char *this_uid;
-
- if(inner != 0){
- p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
- this_uid = icalproperty_get_uid(p);
-
- if(this_uid==0){
- icalerror_warn("icalfileset_fetch found a component with no UID");
- continue;
- }
-
- if (strcmp(uid,this_uid)==0){
- return this;
- }
- }
- }
-
- return 0;
-}
-
-int icalfileset_has_uid(icalfileset* store,const char* uid)
-{
- assert(0); /* HACK, not implemented */
- return 0;
-}
-
-/******* support routines for icalfileset_fetch_match *********/
-
-struct icalfileset_id{
- char* uid;
- char* recurrence_id;
- int sequence;
-};
-
-void icalfileset_id_free(struct icalfileset_id *id)
-{
- if(id->recurrence_id != 0){
- free(id->recurrence_id);
- }
-
- if(id->uid != 0){
- free(id->uid);
- }
-
-}
-
-struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
-{
-
- icalcomponent *inner;
- struct icalfileset_id id;
- icalproperty *p;
-
- inner = icalcomponent_get_first_real_component(comp);
-
- p = icalcomponent_get_first_property(inner, ICAL_UID_PROPERTY);
-
- assert(p!= 0);
-
- id.uid = strdup(icalproperty_get_uid(p));
-
- p = icalcomponent_get_first_property(inner, ICAL_SEQUENCE_PROPERTY);
-
- if(p == 0) {
- id.sequence = 0;
- } else {
- id.sequence = icalproperty_get_sequence(p);
- }
-
- p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);
-
- if (p == 0){
- id.recurrence_id = 0;
- } else {
- icalvalue *v;
- v = icalproperty_get_value(p);
- id.recurrence_id = strdup(icalvalue_as_ical_string(v));
-
- assert(id.recurrence_id != 0);
- }
-
- return id;
-}
-
-/* Find the component that is related to the given
- component. Currently, it just matches based on UID and
- RECURRENCE-ID */
-icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
- icalcompiter i;
-
- struct icalfileset_id comp_id, match_id;
-
- comp_id = icalfileset_get_id(comp);
-
- for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT);
- icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
-
- icalcomponent *match = icalcompiter_deref(&i);
-
- match_id = icalfileset_get_id(match);
-
- if(strcmp(comp_id.uid, match_id.uid) == 0 &&
- ( comp_id.recurrence_id ==0 ||
- strcmp(comp_id.recurrence_id, match_id.recurrence_id) ==0 )){
-
- /* HACK. What to do with SEQUENCE? */
-
- icalfileset_id_free(&match_id);
- icalfileset_id_free(&comp_id);
- return match;
-
- }
-
- icalfileset_id_free(&match_id);
- }
-
- icalfileset_id_free(&comp_id);
- return 0;
-
-}
-
-
-icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old,
- icalcomponent *new)
-{
- assert(0); /* HACK, not implemented */
- return ICAL_NO_ERROR;
-}
-
-
-/* Iterate through components */
-icalcomponent* icalfileset_get_current_component (icalfileset* cluster)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_rz((cluster!=0),"cluster");
-
- return icalcomponent_get_current_component(impl->cluster);
-}
-
-
-icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
- icalcomponent *c=0;
-
- icalerror_check_arg_rz((cluster!=0),"cluster");
-
- do {
- if (c == 0){
- c = icalcomponent_get_first_component(impl->cluster,
- ICAL_ANY_COMPONENT);
- } else {
- c = icalcomponent_get_next_component(impl->cluster,
- ICAL_ANY_COMPONENT);
- }
-
- if(c != 0 && (impl->gauge == 0 ||
- icalgauge_compare(impl->gauge,c) == 1)){
- return c;
- }
-
- } while(c != 0);
-
-
- return 0;
-}
-
-icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
-{
- struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
- icalcomponent *c;
-
- icalerror_check_arg_rz((cluster!=0),"cluster");
-
- do {
- c = icalcomponent_get_next_component(impl->cluster,
- ICAL_ANY_COMPONENT);
-
- if(c != 0 && (impl->gauge == 0 ||
- icalgauge_compare(impl->gauge,c) == 1)){
- return c;
- }
-
- } while(c != 0);
-
-
- return 0;
-}
-
diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h
deleted file mode 100644
index c785921463..0000000000
--- a/libical/src/libicalss/icalfileset.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- 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
-
-#include "ical.h"
-#include "icalset.h"
-#include "icalgauge.h"
-#include <sys/types.h> /* For open() flags and mode */
-#include <sys/stat.h> /* For open() flags and mode */
-#include <fcntl.h> /* For open() flags and mode */
-
-extern int icalfileset_safe_saves;
-
-typedef void icalfileset;
-
-
-/* icalfileset
- icalfilesetfile
- icalfilesetdir
-*/
-
-
-icalfileset* icalfileset_new(const char* path);
-
-/* Like _new, but takes open() flags for opening the file */
-icalfileset* icalfileset_new_open(const char* path,
- int flags, mode_t mode);
-
-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, icalgauge* 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 */
-
-
-
diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h
deleted file mode 100644
index fcd3415121..0000000000
--- a/libical/src/libicalss/icalfilesetimpl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalfilesetimpl.h
- CREATOR: eric 23 December 1999
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The Original Code is eric. The Initial Developer of the Original
- Code is Eric Busboom
-
-
- ======================================================================*/
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "icalgauge.h"
-
-/* This definition is in its own file so it can be kept out of the
- main header file, but used by "friend classes" like icaldirset*/
-
-#define ICALFILESET_ID "fset"
-
-struct icalfileset_impl {
-
- char id[5]; /*fset*/
- char *path;
- icalcomponent* cluster;
- icalgauge* gauge;
- int changed;
- int fd; /* file descriptor */
-};
-
diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c
deleted file mode 100644
index b958ecfc9d..0000000000
--- a/libical/src/libicalss/icalgauge.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalgauge.c
- CREATOR: eric 23 December 1999
-
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of either:
-
- The LGPL as published by the Free Software Foundation, version
- 2.1, available at: http://www.fsf.org/copyleft/lesser.html
-
- Or:
-
- The Mozilla Public License Version 1.0. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- The Original Code is eric. The Initial Developer of the Original
- Code is Eric Busboom
-
-
-======================================================================*/
-
-#include "ical.h"
-#include "icalgauge.h"
-#include "icalgaugeimpl.h"
-#include <stdlib.h>
-
-extern char* input_buffer;
-extern char* input_buffer_p;
-int ssparse(void);
-
-struct icalgauge_impl *icalss_yy_gauge;
-
-icalgauge* icalgauge_new_from_sql(char* sql)
-{
- struct icalgauge_impl *impl;
-
- int r;
-
- if ( ( impl = (struct icalgauge_impl*)
- malloc(sizeof(struct icalgauge_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- impl->select = pvl_newlist();
- impl->from = pvl_newlist();
- impl->where = pvl_newlist();
-
- icalss_yy_gauge = impl;
-
- input_buffer_p = input_buffer = sql;
- r = ssparse();
-
- return impl;
-}
-
-
-void icalgauge_free(icalgauge* gauge)
-{
- struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
- struct icalgauge_where *w;
-
- assert(impl->select != 0);
- assert(impl->where != 0);
- assert(impl->from != 0);
-
- if(impl->select){
- while( (w=pvl_pop(impl->select)) != 0){
- if(w->value != 0){
- free(w->value);
- }
- free(w);
- }
- pvl_free(impl->select);
- }
-
- if(impl->where){
- while( (w=pvl_pop(impl->where)) != 0){
-
- if(w->value != 0){
- free(w->value);
- }
- free(w);
- }
- pvl_free(impl->where);
- }
-
- if(impl->from){
- pvl_free(impl->from);
- }
-
-}
-
-/* Convert a VQUERY component into a gauge */
-icalcomponent* icalgauge_make_gauge(icalcomponent* query);
-
-/* icaldirset_test compares a component against a gauge, and returns
- true if the component passes the test
-
- The gauge is a VCALENDAR component that specifies how to test the
- target components. The guage holds a collection of VEVENT, VTODO or
- VJOURNAL sub-components. Each of the sub-components has a
- collection of properties that are compared to corresponding
- properties in the target component, according to the
- X-LIC-COMPARETYPE parameters to the gauge's properties.
-
- When a gauge has several sub-components, the results of testing the
- target against each of them is ORed together - the target
- component will pass if it matches any of the sub-components in the
- gauge. However, the results of matching the properties in a
- sub-component are ANDed -- the target must match every property in
- a gauge sub-component to match the sub-component.
-
- Here is an example:
-
- BEGIN:XROOT
- DTSTART;X-LIC-COMPARETYPE=LESS:19981025T020000
- ORGANIZER;X-LIC-COMPARETYPE=EQUAL:mrbig@host.com
- END:XROOT
- BEGIN:XROOT
- LOCATION;X-LIC-COMPARETYPE=EQUAL:McNary's Pub
- END:XROOT
-
- This gauge has two sub-components; one which will match a VEVENT
- based on start time, and organizer, and another that matches based
- on LOCATION. A target component will pass the test if it matched
- either of the sub-components.
-
- */
-
-
-int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
-{
- int pass = 1,localpass = 0;
- icalproperty *p;
- icalcomponent *child,*subgauge;
- icalcomponent_kind gaugekind, compkind;
-
- icalerror_check_arg_rz( (comp!=0), "comp");
- icalerror_check_arg_rz( (gauge!=0), "gauge");
-
- gaugekind = icalcomponent_isa(gauge);
- compkind = icalcomponent_isa(comp);
-
- if( ! (gaugekind == compkind || gaugekind == ICAL_ANY_COMPONENT) ){
- return 0;
- }
-
- /* Test properties. For each property in the gauge, search through
- the component for a similar property. If one is found, compare
- the two properties value with the comparison specified in the
- gauge with the X-LIC-COMPARETYPE parameter */
-
- for(p = icalcomponent_get_first_property(gauge,ICAL_ANY_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(gauge,ICAL_ANY_PROPERTY)){
-
- icalproperty* targetprop;
- icalparameter* compareparam;
- icalparameter_xliccomparetype compare;
- int rel; /* The relationship between the gauge and target values.*/
-
- /* Extract the comparison type from the gauge. If there is no
- comparison type, assume that it is "EQUAL" */
-
- compareparam = icalproperty_get_first_parameter(
- p,
- ICAL_XLICCOMPARETYPE_PARAMETER);
-
- if (compareparam!=0){
- compare = icalparameter_get_xliccomparetype(compareparam);
- } else {
- compare = ICAL_XLICCOMPARETYPE_EQUAL;
- }
-
- /* Find a property in the component that has the same type
- as the gauge property. HACK -- multiples of a single
- property type in the gauge will match only the first
- instance in the component */
-
- targetprop = icalcomponent_get_first_property(comp,
- icalproperty_isa(p));
-
- if(targetprop != 0){
-
- /* Compare the values of the gauge property and the target
- property */
-
- rel = icalvalue_compare(icalproperty_get_value(p),
- icalproperty_get_value(targetprop));
-
- /* Now see if the comparison is equavalent to the comparison
- specified in the gauge */
-
- if (rel == compare){
- localpass++;
- } else if (compare == ICAL_XLICCOMPARETYPE_LESSEQUAL &&
- ( rel == ICAL_XLICCOMPARETYPE_LESS ||
- rel == ICAL_XLICCOMPARETYPE_EQUAL)) {
- localpass++;
- } else if (compare == ICAL_XLICCOMPARETYPE_GREATEREQUAL &&
- ( rel == ICAL_XLICCOMPARETYPE_GREATER ||
- rel == ICAL_XLICCOMPARETYPE_EQUAL)) {
- localpass++;
- } else if (compare == ICAL_XLICCOMPARETYPE_NOTEQUAL &&
- ( rel == ICAL_XLICCOMPARETYPE_GREATER ||
- rel == ICAL_XLICCOMPARETYPE_LESS)) {
- localpass++;
- } else {
- localpass = 0;
- }
-
- pass = pass && (localpass>0);
- }
- }
-
- /* Test subcomponents. Look for a child component that has a
- counterpart in the gauge. If one is found, recursively call
- icaldirset_test */
-
- for(subgauge = icalcomponent_get_first_component(gauge,ICAL_ANY_COMPONENT);
- subgauge != 0;
- subgauge = icalcomponent_get_next_component(gauge,ICAL_ANY_COMPONENT)){
-
- gaugekind = icalcomponent_isa(subgauge);
-
- if (gaugekind == ICAL_ANY_COMPONENT){
- child = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
- } else {
- child = icalcomponent_get_first_component(comp,gaugekind);
- }
-
- if(child !=0){
- localpass = icalgauge_compare_recurse(child,subgauge);
- pass = pass && localpass;
- } else {
- pass = 0;
- }
- }
-
- return pass;
-}
-
-
-int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
-{
-
- struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
- icalcomponent *inner;
- int local_pass = 0;
- int last_clause = 1, this_clause = 1;
- pvl_elem e;
-
- icalerror_check_arg_rz( (comp!=0), "comp");
- icalerror_check_arg_rz( (gauge!=0), "gauge");
-
- inner = icalcomponent_get_first_real_component(comp);
-
- if(inner == 0){
- icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
- return 0;
- }
-
-
- /* Check that this component is one of the FROM types */
- local_pass = 0;
- for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){
- icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
-
- if(k == icalcomponent_isa(inner)){
- local_pass=1;
- }
- }
-
- if(local_pass == 0){
- return 0;
- }
-
-
- /* Check each where clause against the component */
- for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){
- struct icalgauge_where *w = pvl_data(e);
- icalcomponent *sub_comp;
- icalvalue *v;
- icalproperty *prop;
- icalvalue_kind vk;
-
- if(w->prop == ICAL_NO_PROPERTY || w->value == 0){
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
- return 0;
- }
-
- /* First, create a value from the gauge */
- vk = icalenum_property_kind_to_value_kind(w->prop);
-
- if(vk == ICAL_NO_VALUE){
- icalerror_set_errno(ICAL_INTERNAL_ERROR);
- return 0;
- }
-
- v = icalvalue_new_from_string(vk,w->value);
-
- if (v == 0){
- /* Keep error set by icalvalue_from-string*/
- return 0;
- }
-
- /* Now find the corresponding property in the component,
- descending into a sub-component if necessary */
-
- if(w->comp == ICAL_NO_COMPONENT){
- sub_comp = inner;
- } else {
- sub_comp = icalcomponent_get_first_component(inner,w->comp);
- if(sub_comp == 0){
- return 0;
- }
- }
-
- this_clause = 0;
- local_pass = 0;
- for(prop = icalcomponent_get_first_property(sub_comp,w->prop);
- prop != 0;
- prop = icalcomponent_get_next_property(sub_comp,w->prop)){
- icalvalue* prop_value;
- icalgaugecompare relation;
-
- prop_value = icalproperty_get_value(prop);
-
- relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
-
- if (relation == w->compare){
- local_pass++;
- } else if (w->compare == ICALGAUGECOMPARE_LESSEQUAL &&
- ( relation == ICALGAUGECOMPARE_LESS ||
- relation == ICALGAUGECOMPARE_EQUAL)) {
- local_pass++;
- } else if (w->compare == ICALGAUGECOMPARE_GREATEREQUAL &&
- ( relation == ICALGAUGECOMPARE_GREATER ||
- relation == ICALGAUGECOMPARE_EQUAL)) {
- local_pass++;
- } else if (w->compare == ICALGAUGECOMPARE_NOTEQUAL &&
- ( relation == ICALGAUGECOMPARE_GREATER ||
- relation == ICALGAUGECOMPARE_LESS)) {
- local_pass++;
- } else {
- local_pass = 0;
- }
- }
-
- this_clause = local_pass > 0 ? 1 : 0;
-
- /* Now look at the logic operator for this clause to see how
- the value should be merge with the previous clause */
-
- if(w->logic == ICALGAUGELOGIC_AND){
- last_clause = this_clause && last_clause;
- } else if(w->logic == ICALGAUGELOGIC_AND) {
- last_clause = this_clause || last_clause;
- } else {
- last_clause = this_clause;
- }
- }
-
- return last_clause;
-
-}
-
-
-void icalgauge_dump(icalcomponent* gauge)
-{
-
- pvl_elem *p;
- struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
-
-
- printf("--- Select ---\n");
- for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){
- struct icalgauge_where *w = pvl_data(p);
-
- if(w->comp != ICAL_NO_COMPONENT){
- printf("%s ",icalenum_component_kind_to_string(w->comp));
- }
-
- if(w->prop != ICAL_NO_PROPERTY){
- printf("%s ",icalenum_property_kind_to_string(w->prop));
- }
-
- if (w->compare != ICALGAUGECOMPARE_NONE){
- printf("%d ",w->compare);
- }
-
-
- if (w->value!=0){
- printf("%s",w->value);
- }
-
-
- printf("\n");
- }
-
- printf("--- From ---\n");
- for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){
- icalcomponent_kind k = (icalcomponent_kind)pvl_data(p);
-
- printf("%s\n",icalenum_component_kind_to_string(k));
- }
-
- printf("--- Where ---\n");
- for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){
- struct icalgauge_where *w = pvl_data(p);
-
- if(w->logic != ICALGAUGELOGIC_NONE){
- printf("%d ",w->logic);
- }
-
- if(w->comp != ICAL_NO_COMPONENT){
- printf("%s ",icalenum_component_kind_to_string(w->comp));
- }
-
- if(w->prop != ICAL_NO_PROPERTY){
- printf("%s ",icalenum_property_kind_to_string(w->prop));
- }
-
- if (w->compare != ICALGAUGECOMPARE_NONE){
- printf("%d ",w->compare);
- }
-
-
- if (w->value!=0){
- printf("%s",w->value);
- }
-
-
- printf("\n");
- }
-
-
-}
-
diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h
deleted file mode 100644
index 1caf0ac7d1..0000000000
--- a/libical/src/libicalss/icalgauge.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- 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);
-
-void icalgauge_dump(icalcomponent* gauge);
-
-/* Return true is comp matches the gauge. The component must be in
- cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
- sub component */
-int icalgauge_compare(icalgauge* g, icalcomponent* comp);
-
-/* Clone the component, but only return the properties specified in
- the gauge */
-icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
-
-#endif /* ICALGAUGE_H*/
diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h
deleted file mode 100644
index 73a2813242..0000000000
--- a/libical/src/libicalss/icalgaugeimpl.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- 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/
-
-======================================================================*/
-
-#include "ical.h"
-
-#include "pvl.h"
-
-typedef enum icalgaugecompare {
- ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
- ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
- ICALGAUGECOMPARE_LESSEQUAL=ICAL_XLICCOMPARETYPE_LESSEQUAL,
- ICALGAUGECOMPARE_GREATER=ICAL_XLICCOMPARETYPE_GREATER,
- ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
- ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
- ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
- ICALGAUGECOMPARE_NONE=0
-} icalgaugecompare;
-
-typedef enum icalgaugelogic {
- ICALGAUGELOGIC_NONE,
- ICALGAUGELOGIC_AND,
- ICALGAUGELOGIC_OR
-} icalgaugelogic;
-
-
-struct icalgauge_where {
- icalgaugelogic logic;
- icalcomponent_kind comp;
- icalproperty_kind prop;
- icalgaugecompare compare;
- char* value;
-};
-
-struct icalgauge_impl
-{
-
- pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/
- pvl_list from; /* List of component_kinds, as integers */
- pvl_list where; /* List of icalgaugecompare */
-};
-
-
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c
deleted file mode 100644
index e1e8d8015c..0000000000
--- a/libical/src/libicalss/icalmessage.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/* -*- 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* n = icalmemory_strdup(str);
-
- if(str ==0){
- return 0;
- }
-
- for(p = n; *p!=0; p++){
- *p = tolower(*p);
- }
-
- return n;
-}
-
-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)),
- 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));
-
- 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* oldc,
- icalcomponent* newc,
- const char* user,
- const char* msg)
-{
- icalcomponent *reply;
-
- icalerror_check_arg_rz(oldc,"oldc");
- icalerror_check_arg_rz(newc,"newc");
-
- reply = icalcomponent_new_clone(newc);
-
- icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
-
- return newc;
-
-}
-
-
-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
deleted file mode 100644
index 24f1c9f243..0000000000
--- a/libical/src/libicalss/icalmessage.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- 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* oldc,
- icalcomponent* newc,
- 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/icalset.c b/libical/src/libicalss/icalset.c
deleted file mode 100644
index 2120609928..0000000000
--- a/libical/src/libicalss/icalset.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/* -*- Mode: C -*- */
-/*======================================================================
- FILE: icalset.c
- CREATOR: eric 17 Jul 2000
-
-
- Icalset is the "base class" for representations of a collection of
- iCal components. Derived classes (actually delegates) include:
-
- icalfileset Store components 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
-
-
-======================================================================*/
-
-#include "ical.h"
-#include "icalset.h"
-#include "icalfileset.h"
-#include "icalfilesetimpl.h"
-#include "icaldirset.h"
-#include "icaldirsetimpl.h"
-#include <stdlib.h>
-/*#include "icalheapset.h"*/
-/*#include "icalmysqlset.h"*/
-
-#define ICALSET_ID "set "
-
-struct icalset_fp {
- void (*free)(icalset* set);
- const char* (*path)(icalset* set);
- void (*mark)(icalset* set);
- icalerrorenum (*commit)(icalset* set);
- icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
- icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
- int (*count_components)(icalset* set,
- icalcomponent_kind kind);
- icalerrorenum (*select)(icalset* set, icalcomponent* gauge);
- void (*clear)(icalset* set);
- icalcomponent* (*fetch)(icalset* set, const char* uid);
- icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
- int (*has_uid)(icalset* set, const char* uid);
- icalerrorenum (*modify)(icalset* set, icalcomponent *old,
- icalcomponent *new);
- icalcomponent* (*get_current_component)(icalset* set);
- icalcomponent* (*get_first_component)(icalset* set);
- icalcomponent* (*get_next_component)(icalset* set);
-};
-
-struct icalset_fp icalset_dirset_fp = {
- icaldirset_free,
- icaldirset_path,
- icaldirset_mark,
- icaldirset_commit,
- icaldirset_add_component,
- icaldirset_remove_component,
- icaldirset_count_components,
- icaldirset_select,
- icaldirset_clear,
- icaldirset_fetch,
- icaldirset_fetch_match,
- icaldirset_has_uid,
- icaldirset_modify,
- icaldirset_get_current_component,
- icaldirset_get_first_component,
- icaldirset_get_next_component
-};
-
-
-struct icalset_fp icalset_fileset_fp = {
- icalfileset_free,
- icalfileset_path,
- icalfileset_mark,
- icalfileset_commit,
- icalfileset_add_component,
- icalfileset_remove_component,
- icalfileset_count_components,
- icalfileset_select,
- icalfileset_clear,
- icalfileset_fetch,
- icalfileset_fetch_match,
- icalfileset_has_uid,
- icalfileset_modify,
- icalfileset_get_current_component,
- icalfileset_get_first_component,
- icalfileset_get_next_component
-};
-
-struct icalset_impl {
-
- char id[5]; /* "set " */
-
- void *derived_impl;
- struct icalset_fp *fp;
-};
-
-/* Figure out what was actually passed in as the set. This could be a
- set or and of the derived types such as dirset or fileset. Note
- this routine returns a value, not a reference, to avoid memory
- leaks in the methods */
-struct icalset_impl icalset_get_impl(icalset* set)
-{
- struct icalset_impl impl;
-
- memset(&impl,0,sizeof(impl));
- icalerror_check_arg_re( (set!=0),"set",impl);
-
- if(strcmp((char*)set,ICALSET_ID)==0) {
- /* It is actually a set, so just sent the reference back out. */
- return *(struct icalset_impl*)set;
- } else if(strcmp((char*)set,ICALFILESET_ID)==0) {
- /* Make a new set from the fileset */
- impl.fp = &icalset_fileset_fp;
- impl.derived_impl = set;
- strcpy(impl.id,ICALFILESET_ID);/* HACK. Is this necessary? */
- return impl;
- } else if(strcmp((char*)set,ICALDIRSET_ID)==0) {
- /* Make a new set from the dirset */
- impl.fp = &icalset_dirset_fp;
- impl.derived_impl = set;
- strcpy(impl.id,ICALDIRSET_ID);/* HACK. Is this necessary? */
- return impl;
- } else {
- /* The type of set is unknown, so throw an error */
- icalerror_assert((0),"Unknown set type");
- return impl;
- }
-}
-
-
-struct icalset_impl* icalset_new_impl()
-{
-
- struct icalset_impl* impl;
-
- if ( ( impl = (struct icalset_impl*)
- malloc(sizeof(struct icalset_impl))) == 0) {
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- strcpy(impl->id,ICALSET_ID);
-
- impl->derived_impl = 0;
- impl->fp = 0;
-
- return impl;
-}
-
-struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset)
-{
- struct icalset_impl *impl = icalset_new_impl();
-
- icalerror_check_arg_rz( (fset!=0),"fset");
-
- if(impl == 0){
- free(impl);
- return 0;
- }
-
- impl->derived_impl = fset;
-
- if (impl->derived_impl == 0){
- free(impl);
- return 0;
- }
-
- impl->fp = &icalset_fileset_fp;
-
- return (struct icalset_impl*)impl;
-}
-
-icalset* icalset_new_file(const char* path)
-{
- icalfileset *fset = icalfileset_new(path);
-
- if(fset == 0){
- return 0;
- }
-
- return (icalset*)icalset_new_file_from_ref(fset);
-}
-
-icalset* icalset_new_dir_from_ref(icaldirset *dset)
-{
-
- struct icalset_impl *impl = icalset_new_impl();
-
- icalerror_check_arg_rz( (dset!=0),"dset");
-
- if(impl == 0){
- return 0;
- }
-
- impl->derived_impl = dset;
-
- if (impl->derived_impl == 0){
- free(impl);
- return 0;
- }
-
- impl->fp = &icalset_dirset_fp;
-
- return impl;
-}
-
-icalset* icalset_new_dir(const char* path)
-{
- icaldirset *dset = icaldirset_new(path);
-
- if(dset == 0){
- return 0;
- }
-
- return icalset_new_dir_from_ref(dset);
-}
-
-icalset* icalset_new_heap(void)
-{
- struct icalset_impl *impl = icalset_new_impl();
-
-
- if(impl == 0){
- free(impl);
- return 0;
- }
-
- return 0;
-}
-
-icalset* icalset_new_mysql(const char* path)
-{
- struct icalset_impl *impl = icalset_new_impl();
-
- if(impl == 0){
- free(impl);
- return 0;
- }
-
- return 0;
-}
-
-void icalset_free(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->free))(impl.derived_impl);
-
- if(strcmp((char*)set,ICALSET_ID)) {
- free(set);
- }
-}
-
-const char* icalset_path(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->path))(impl.derived_impl);
-}
-
-void icalset_mark(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->mark))(impl.derived_impl);
-}
-
-icalerrorenum icalset_commit(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->commit))(impl.derived_impl);
-}
-
-icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->add_component))(impl.derived_impl,comp);
-}
-
-icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->remove_component))(impl.derived_impl,comp);
-}
-
-int icalset_count_components(icalset* set,icalcomponent_kind kind)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->count_components))(impl.derived_impl,kind);
-}
-
-icalerrorenum icalset_select(icalset* set, icalcomponent* gauge)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->select))(impl.derived_impl,gauge);
-}
-
-void icalset_clear(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- (*(impl.fp->clear))(impl.derived_impl);
-}
-
-icalcomponent* icalset_fetch(icalset* set, const char* uid)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->fetch))(impl.derived_impl,uid);
-}
-
-icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->fetch_match))(impl.derived_impl,comp);
-}
-
-
-int icalset_has_uid(icalset* set, const char* uid)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->has_uid))(impl.derived_impl,uid);
-}
-
-icalerrorenum icalset_modify(icalset* set, icalcomponent *old,
- icalcomponent *new)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->modify))(impl.derived_impl,old,new);
-}
-
-icalcomponent* icalset_get_current_component(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->get_current_component))(impl.derived_impl);
-}
-
-icalcomponent* icalset_get_first_component(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->get_first_component))(impl.derived_impl);
-}
-
-icalcomponent* icalset_get_next_component(icalset* set)
-{
- struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->get_next_component))(impl.derived_impl);
-}
-
-
-
-
diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h
deleted file mode 100644
index 7b083dae24..0000000000
--- a/libical/src/libicalss/icalset.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- 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
-
-#include <limits.h> /* For PATH_MAX */
-#include "ical.h"
-#include "icalerror.h"
-
-#ifdef PATH_MAX
-#define ICAL_PATH_MAX PATH_MAX
-#else
-#define ICAL_PATH_MAX 1024
-#endif
-
-
-
-
-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 */
-
-
-
diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c
deleted file mode 100644
index cab6a81c68..0000000000
--- a/libical/src/libicalss/icalspanlist.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/* -*- 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);
- } else {
- period.end = icaltime_from_timet(s->end,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);
- } else {
- period.start = icaltime_from_timet(rangett,0);
- }
-
- period.end = icaltime_from_timet(s->end,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
deleted file mode 100644
index 83cb1c8a6d..0000000000
--- a/libical/src/libicalss/icalspanlist.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- 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/icalsslexer.l b/libical/src/libicalss/icalsslexer.l
deleted file mode 100644
index 848a9bc74f..0000000000
--- a/libical/src/libicalss/icalsslexer.l
+++ /dev/null
@@ -1,113 +0,0 @@
-%{
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalsslexer.l
- CREATOR: eric 8 Aug 2000
-
- DESCRIPTION:
-
- $Id: icalsslexer.l,v 1.1.1.2 2001/01/23 19:20:41 jpr 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; }
-\' { return QUOTE; }
-[ \t\n\r]+ ;
-; { return EOL; }
-\'[\*A-Za-z0-9\-\.]+\' {
- int c = input();
- unput(c);
- if(c!='\''){
- sslval.v_string= icalmemory_tmp_copy(sstext);
- return STRING;
- } else {
- /*ssmore();*/
- }
-}
-
-[\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext);
- return STRING; }
-
-
-. { return yytext[0]; }
-
-%%
-
-int sswrap()
-{
- return 1;
-}
-
diff --git a/libical/src/libicalss/icalssutil.c b/libical/src/libicalss/icalssutil.c
deleted file mode 100644
index 8db141d41d..0000000000
--- a/libical/src/libicalss/icalssutil.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- 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
deleted file mode 100644
index 3890da6a11..0000000000
--- a/libical/src/libicalss/icalssutil.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- 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.h b/libical/src/libicalss/icalssyacc.h
deleted file mode 100644
index 9a933dc735..0000000000
--- a/libical/src/libicalss/icalssyacc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-typedef union {
- char* v_string;
-} YYSTYPE;
-#define STRING 257
-#define SELECT 258
-#define FROM 259
-#define WHERE 260
-#define COMMA 261
-#define QUOTE 262
-#define EQUALS 263
-#define NOTEQUALS 264
-#define LESS 265
-#define GREATER 266
-#define LESSEQUALS 267
-#define GREATEREQUALS 268
-#define AND 269
-#define OR 270
-#define EOL 271
-#define END 272
-
-
-extern YYSTYPE sslval;
diff --git a/libical/src/libicalss/icalssyacc.y b/libical/src/libicalss/icalssyacc.y
deleted file mode 100644
index 047b158e93..0000000000
--- a/libical/src/libicalss/icalssyacc.y
+++ /dev/null
@@ -1,245 +0,0 @@
-%{
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icalssyacc.y
- CREATOR: eric 08 Aug 2000
-
- DESCRIPTION:
-
- $Id: icalssyacc.y,v 1.1.1.2 2001/01/23 19:20:41 jpr 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 "icalgauge.h"
-#include "icalgaugeimpl.h"
-
-
-extern struct icalgauge_impl *icalss_yy_gauge;
-
-void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
- icalgaugecompare compare , char* value);
-void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
-void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
-void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
-void sserror(char *s); /* Don't know why I need this.... */
-
-
-
-%}
-
-%union {
- char* v_string;
-}
-
-
-%token <v_string> STRING
-%token SELECT FROM WHERE COMMA QUOTE 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,ICALGAUGECOMPARE_EQUAL,$3); }
-
- | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_NOTEQUAL,$3); }
- | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESS,$3); }
- | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATER,$3); }
- | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESSEQUAL,$3); }
- | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATEREQUAL,$3); }
- ;
-
-where_list:
- where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
- | where_list AND where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
- | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
- ;
-
-
-%%
-
-void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
- icalgaugecompare compare , char* value_str)
-{
-
- struct icalgauge_where *where;
- char *compstr, *propstr, *c, *s,*l;
-
- if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- memset(where,0,sizeof(struct icalgauge_where));
- where->logic = ICALGAUGELOGIC_NONE;
- where->compare = ICALGAUGECOMPARE_NONE;
- where->comp = ICAL_NO_COMPONENT;
- where->prop = ICAL_NO_PROPERTY;
-
- /* remove enclosing quotes */
- s = value_str;
- if(*s == '\''){
- s++;
- }
- l = s+strlen(s)-1;
- if(*l == '\''){
- *l=0;
- }
-
- where->value = strdup(s);
-
- /* 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){
- where->comp = icalenum_string_to_component_kind(compstr);
- } else {
- where->comp = ICAL_NO_COMPONENT;
- }
-
- where->prop = icalenum_string_to_property_kind(propstr);
-
- where->compare = compare;
-
- if(where->value == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- free(where->value);
- return;
- }
-
- pvl_push(impl->where,where);
-}
-
-void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
-{
- pvl_elem e = pvl_tail(impl->where);
- struct icalgauge_where *where = pvl_data(e);
-
- where->logic = l;
-
-}
-
-
-
-void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
-{
- char *c, *compstr, *propstr;
- struct icalgauge_where *where;
-
- /* Uses only the prop and comp fields of the where structure */
- if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return;
- }
-
- memset(where,0,sizeof(struct icalgauge_where));
- where->logic = ICALGAUGELOGIC_NONE;
- where->compare = ICALGAUGECOMPARE_NONE;
- where->comp = ICAL_NO_COMPONENT;
- where->prop = ICAL_NO_PROPERTY;
-
- /* 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){
- where->comp = icalenum_string_to_component_kind(compstr);
- } else {
- where->comp = ICAL_NO_COMPONENT;
- }
-
-
- /* If the property was '*', then accept all properties */
- if(strcmp("*",propstr) == 0) {
- where->prop = ICAL_ANY_PROPERTY;
- } else {
- where->prop = icalenum_string_to_property_kind(propstr);
- }
-
-
- if(where->prop == ICAL_NO_PROPERTY){
- icalgauge_free(where);
- icalerror_set_errno(ICAL_BADARG_ERROR);
- return;
- }
-
- pvl_push(impl->select,where);
-}
-
-void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
-{
- icalcomponent_kind ckind;
-
- ckind = icalenum_string_to_component_kind(str1);
-
- if(ckind == ICAL_NO_COMPONENT){
- assert(0);
- }
-
- pvl_push(impl->from,(void*)ckind);
-
-}
-
-
-void sserror(char *s){
- fprintf(stderr,"Parse error \'%s\'\n", s);
-}
diff --git a/libical/src/libicalvcal/.cvsignore b/libical/src/libicalvcal/.cvsignore
deleted file mode 100644
index 533caa2f3d..0000000000
--- a/libical/src/libicalvcal/.cvsignore
+++ /dev/null
@@ -1,12 +0,0 @@
-*.la
-*.lo
-.libs
-.deps
-Makefile
-Makefile.in
-libtool
-ltconfig
-ltmain.sh
-stamp-h
-stamp-h.in
-vcc.c \ No newline at end of file
diff --git a/libical/src/libicalvcal/Makefile.am b/libical/src/libicalvcal/Makefile.am
deleted file mode 100644
index c409347d14..0000000000
--- a/libical/src/libicalvcal/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-lib_LTLIBRARIES = libicalvcal.la
-
-INCLUDES = \
- -I$(top_builddir) \
- -I$(top_srcdir)/src/libical \
- -I$(top_builddir)/src/libical \
- -I$(top_srcdir)/src/libicalss
-
-libicalvcal_la_LDFLAGS = -version-info 0:0:0
-
-libicalvcal_la_SOURCES = \
- icalvcal.c \
- vcc.y \
- vobject.c \
- vcaltmp.c
-
-libicalvcalincludedir = $(includedir)/libicalvcal
-
-libicalvcalinclude_HEADERS = \
- icalvcal.h \
- port.h \
- vcc.h \
- vobject.h \
- vcaltmp.h
-
-EXTRA_DIST = \
- README.TXT \
- vcaltest.c \
- vctest.c
diff --git a/libical/src/libicalvcal/README.TXT b/libical/src/libicalvcal/README.TXT
deleted file mode 100644
index c8ce8b0979..0000000000
--- a/libical/src/libicalvcal/README.TXT
+++ /dev/null
@@ -1,951 +0,0 @@
-NOTE: If you used the earlier APIs released by Versit
-then you will want to look at the document "migrate.doc"
-included with this package. It contains a discussion of
-the differences between the old API and this one.
-
-----------------------------------------------------------------
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
------------------------------------------------------------------
-
-
- VObject for VCard/VCalendar
-
-Table of Contents
-=================
-1. VObject
-2. Internal Representations of VCard/VCalendar
-3. Iterating Through VObject's Properties or Values
-4. Pretty Printing a VObject Tree
-5. Building A VObject Representation of A VCard/VCalendar
-6. Converting A VObject Representation Into Its Textual Representation
-7. Miscellaneous Notes On VObject APIs usages
-8. Brief descriptions of each APIs
-9. Additional Programming Notes.
-
-This document is mainly about the VObject and its APIs. The main
-use of a VObject is to represent a VCard or a VCalendar inside
-a program. However, its use is not limited to aforemention as it
-can represent an arbitrary information that makes up of a tree or
-forest of properties/values.
-
-1. VObject
- =======
-A VObject can have a name (id) and a list of associated properties and
-a value. Each property is itself a VObject.
-
-2. Internal Representations of VCard/VCalendar
- ===========================================
-A list of VCard or a VCalendar is represented by a list of VObjects.
-The name (id) of the VObjects in the list is either VCCardProp or
-VCCalProp. Each of these VObjects can have a list of properties.
-Since a property is represented as a VObject, each of these properties
-can have a name, a list of properties, and a value.
-
-For example, the input file "vobject.vcf":
-
-BEGIN:VCARD
-N:Alden;Roland
-FN:Roland H. Alden
-ORG:AT&T;Versit Project Office
-TITLE:Consultant
-EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-EMAIL;INTERNET:ralden@sfgate.com
-EMAIL;MCIMail:242-2200
-LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111
-LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111=0A=
-U.S.A.
-TEL;WORK;PREF;MSG:+1 415 296 9106
-TEL;WORK;FAX:+1 415 296 9016
-TEL;MSG;CELL:+1 415 608 5981
-ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-SOUND:ROW-LAND H ALL-DIN
-LOGO;GIF;BASE64:
- R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- QjExMSEhIRAQEO///87v9973/73n95zW71K13jGl1nvG50Kt3iGc1gCMzq3e94zO
- 7xCU1nO952O15wAAACwAAAAApgBOAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv
- /8CgcEj8QTaeywWTyWCUno2kSK0KI5tLc8vtNi+WiHVMlj0mFK96nalsxOW4fPSw
- cNj4tQc+7xcjGh4WExJTJYUTFkp3eU0eEH6RkpOUlTARhRoWm5ydFpCWoS0QEqAu
- ARKaHRcVjV0borEoFl0cSre4Sq67FA+yvwAeTU8XHZ7HmxS6u2wVfMCVpAE3pJoW
- ylrMptDcOqSF4OHg3eQ5pInInb7lcc86mNbLzBXsZbRfUOn6ucyNHvVWJHCpQFDf
- MWwEEzLqx2YCQCqF3OnItClJNmYcJD7cSAKTuI/gtnEcOQKkyVIk6/+ds5CkFcMM
- 61LiENikwi1jBnNyuvUSjwWZOS5uIZarqNFcNl32XMMB6I06GgoJ+bZp1ZKeDl8E
- +MC1K1cBIhZ4HUu2LAsCZdOWRQDt20lxIlccSHsgrNq7Xc/ixcsWmNu34WKyYJCW
- gQjCe9XqTZy2L4pv04gg2sSKSc8OLgTcBSuWsdkVaD2TdXyiQxebFyjo1Gnx6tJm
- LuaqrdtZtNfFtruSNmF5IKujwIsmJbjwtRqNJhrcNVw79wcRAgogmE4ArIjQzj/s
- JvHAGCFDQR4UqigPK4sBe62XwO51OwADiMcqUG+iOdcFAL+hW20BfAoEexlwAnu6
- mZDAXQ1EVh//WfhxJB5gIbHgwFgOTOiVAgOuVQKAfKFg3weGwSBYFZMp4hpDGKyA
- 3lgJKECWgiMQyBVpW+0V4oJjNfhCNkR1IgWEb21QlRK9GdfFCgeOZYBsXgm4noYj
- GEBhAQHYh0J8XenoQnFGdrkUciJY6FUAK15ogozakcBhliKsyZWHDMZQ0wWC/Aim
- DB6h01KRr/lXQgFxAqDcWDACgCZpUnrVQJtjwTnWjS6MWAYqqfDnSaEkJOlVXQBo
- 2pWTMUJ53WgAuPncCR9q6VQMAYjZlXWJmknCoSUM2p4BC+SaKwG88hoZlvfFMM4f
- hQh5TXkv+RklWYtC91mopJIAKFkJlDAW/wF25ShnLbeo5gmQ+1FGkJdrKCuCi2OR
- BuwHBcwqKgABrMtVAgpem61XkLbAJ7n8uiIpvGVhO4KpH1QLbbpqLheZvQCkGoNL
- thSzSTg2UGVBBzbtaxwKsYrmgLvRAlCmWgwMAADD66rKAgR3XlGspcdkZYK8ibU7
- asgEl+XAyB8I7PCqMWiWncGGimpfAgO4ypXSPpOVLwsRCDJxRD2AoyeRRv5kApO5
- fXwzwvfOKLKtaTWtbQxccmGLTZy8xYlVSvXbhbk0M2YzrYfJJ0K8m+V9NgxpyC04
- UycI/aiuiH9Y8NftDUwWp1Wm5UABnAUKwwRsPFGBt4Oc9PZvGvNLwf8JOZt8Arpe
- eY23yDovwIDiBX74NAsPVLDJj3Hh4JEExsKcjrlKf9DsCVx3ZfLqAKBuG1s/A90C
- z2KjYHjjyPOdG1spz6BBUr+BcUxUb1nDCTa/VZD2Uv+YkLPAKJC9dNEh7628WgqI
- ybzlaA+ufxMa6bxC6ciLUQLcx5UGIAAsAkDA6wQkOxrcY39yo4cQMNWCAPTKV1R4
- wPkgaBxzOc8FtMiF1NoGoXBRJjgoPApmPsjCFlbMdzCM4TFy50IXxI2DPcHAv2rY
- gghsEIeu8CAPW6ABIPYEFkOsAeaMyIz0JfGJUExBBGRIRX0IMYovWCIT1eBELNpA
- i1vcgta8iANPCIQOghzQABl30J0tXqBla4wjFLFQxZzAUY42CIAd5OYBCuKxB2c4
- I0b28EcrQKADgmSKB9RYyDhA4BqCxIBqrtjIMTwoFeCjYSU3KZMQAAA7
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-PRODID:-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-START:19960523T120000
-END:19960523T130000
-SUBTYPE:PHONE CALL
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-DESCRIPTION:VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland
-END:VEVENT
-BEGIN:VEVENT
-START:19960523T113000
-END:19960523T115500
-SUBTYPE:LUNCH
-SUMMARY:Eat in the cafeteria today
-END:VEVENT
-END:VCALENDAR
-
-END:VCARD
-
-
-will conceptually be be represented as
- vcard
- VCNameProp
- VCFamilyNameProp=Alden
- VCGivenNameProp=Roland
- VCFullNameProp=Roland H.Alden
- ....
-
-note that
- EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-will be represented as:
- VCEmailAddress=sf!rincon!ralden@alden.attmail.com
- VCWork
- VCPreferred
- VCInternet
-where the lower level properties are properties of the property
-VCEmailAddress.
-
-Groupings are flattened out in the VObject representation such
-that:
- a.b:blah
- a.c:blahblah
-are represented as:
- b=blah
- VCGrouping=a
- c=blahblah
- VCGrouping=a
-i.e. one can read the above as:
- the property "b" has value "blah" and property "VCGrouping"
- with the value "a".
- the property "c" has value "blahblah" and property "VCGrouping"
- with the value "a".
-likewise, multi-level groupings are flatten similarly. e.g.
- a.b.c:blah
- a.b.e:blahblah
--->
- c=blah
- VCGrouping=b
- VCGrouping=a
- e=blahblah
- VCGrouping=b
- VCGrouping=a
-which read:
- the property "c" has value "blah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
- the property "e" has value "blahblah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
-
-3. Iterating Through VObject's Properties or Values
- ================================================
-The following is a skeletal form of iterating through
-all properties of a vobject, o:
-
- // assume the object of interest, o, is of type VObject
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- // ... do something with "each" property
- }
-
-Use the API vObjectName() to access a VObject's name.
-Use the API vObjectValueType() to determine if a VObject has
- a value. For VCard/VCalendar application, you
- should not need this function as practically
- all values are either of type VCVT_USTRINGZ or
- VCVT_RAW (i.e set by setVObjectUStringZValue and
- setVObjectAnyValue APIs respectively), and the
- value returned by calls to vObjectUStringZValue
- and vObjectAnyValue are 0 if a VObject has no
- value. (There is a minor exception where VObject with
- VCDataSizeProp has value that is set by
- setVObjectLongValue).
-Use the APIs vObject???Value() to access a VObject's value.
- where ??? is the expected type.
-Use the APIs setvObject???Value() to set or modify a VObject's value.
- where ??? is the expected type.
-Use the API isAPropertyOf() to query if a name match the name of
- a property of a VObject. Since isAPropertyOf() return
- the matching property, we can use that to retrieve
- a property and subsequently the value of the property.
-
-4. Pretty Printing a VObject Tree
- ==============================
-VObject tree can be pretty printed with the printVObject() function.
-The output of pretty printing a VObject representation of the input
-test file "vobject.vcf" is shown below. Note that the indentation
-indicates the tree hirerarchy where the immediate children nodes
-of a parent node is all at the same indentation level and the
-immediate children nodes are the immediate properties of the
-associated parent nodes. In the following, {N,FN,ORG,TITLE,...}
-are immediate properties of VCARD. {F and G} are properties of N
-with value {"Alden" and "Roland"} respectively; FN has no property
-but has the value "Roland H. Alden"; EMAIL has value and
-the properties WORK, PREF, and INTERNET.
-
-
-VCARD
- N
- F="Alden"
- G="Roland"
- FN="Roland H. Alden"
- ORG
- ORGNAME="AT&T"
- OUN="Versit Project Office"
- TITLE="Consultant"
- EMAIL="sf!rincon!ralden@alden.attmail.com"
- WORK
- PREF
- INTERNET
- EMAIL="ralden@sfgate.com"
- INTERNET
- EMAIL="242-2200"
- MCIMail
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111"
- DOM
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111
- U.S.A."
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- TEL="+1 415 296 9106"
- WORK
- PREF
- MSG
- TEL="+1 415 296 9016"
- WORK
- FAX
- TEL="+1 415 608 5981"
- MSG
- CELL
- ADR
- EXT ADD="Suite 2208"
- STREET="One Pine Street"
- L="San Francisco"
- R="CA"
- PC="94111"
- C="U.S.A."
- SOUND="ROW-LAND H ALL-DIN"
- LOGO=[raw data]
- GIF
- BASE64
- DataSize=1482
-VCALENDAR
- DCREATED="19960523T100522"
- PRODID="-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN"
- VERSION="0.3"
- VEVENT
- START="19960523T120000"
- END="19960523T130000"
- SUBTYPE="PHONE CALL"
- SUMMARY="VERSIT PDI PR Teleconference/Interview"
- DESCRIPTION="VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland"
- VEVENT
- START="19960523T113000"
- END="19960523T115500"
- SUBTYPE="LUNCH"
- SUMMARY="Eat in the cafeteria today"
-
-5. Building A VObject Representation of A VCard/VCalendar
- ======================================================
-The parser in vcc.y converts an input file with one or more
-VCard/VCalendar that is in their textual representation
-into their corresponding VObject representation.
-
-VObject representation of a VCard/VCalendar can also be built
-directly with calls to the VObject building APIs. e.g.
-
- VObject *prop;
- VObject *vcard = newVObject(VCCardProp);
- prop = addProp(vcard,VCNameProp);
- addPropValue(prop,VCFamilyNameProp,"Alden");
- addPropValue(prop,VCGivenNameProp,"Roland");
- addPropValue(vcard,VCFullNameProp,"Roland H. Alden");
- ....
-
-6. Converting A VObject Representation Into Its Textual Representation
- ===================================================================
-The VObject representation can be converted back to its textual
-representation via the call to writeVObject() or writeMemVObject()
-API. e.g.
- a. to write to a file:
- // assume vcard is of type VObject
- FILE *fp = fopen("alden.vcf","w");
- writeVObject(fp,vcard);
- a. to write to memory, and let the API allocate the required memory.
- char* clipboard = writeVObject(0,0,vcard);
- ... do something to clipboard
- free(clipboard);
- b. to write to a user allocated buffer:
- char clipboard[16384];
- int len = 16384;
- char *buf = writeVObject(clipboard,&len,vcard);
- ... buf will be equal to clipboard if the write
- is successful otherwise 0.
-
-In the case of writing to memory, the memory buffer can be either
-allocated by the API or the user. If the user allocate the
-memory for the buffer, then the length of the buffer needs to be
-communicated to the API via a variable. The variable passed as
-the length argument will be overwritten with the actual size
-of the text output. A 0 return value from writeMemVObject()
-indicates an error which could be caused by overflowing the
-size of the buffer or lack of heap memory.
-
-7. Miscellaneous Notes On VObject APIs usages
- ==========================================
-a. vcc.h -- contains basic interfaces to the parser:
- VObject* Parse_MIME(const char *input, unsigned long len);
- VObject* Parse_MIME_FromFile(FILE *file);
- -- both of this return a null-terminated list of
- VObject that is either a VCARD or VCALENDAR.
- To iterate through this list, do
- VObject *t, *v;
- v = Parse_Mime_FromFile(fp);
- while (v) {
- // ... do something to v.
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- note that call to cleanVObject will release
- resource used to represent the VObject.
-
-b. vobject.h -- contains basic interfaces to the VObject APIs.
- see the header for more details.
- The structure of VObject is purposely (hiddened) not exposed
- to the user. Every access has to be done via
- the APIs. This way, if we need to change the
- structure or implementation, the client need not
- recompile as long as the interfaces remain the
- same.
-
-c. values of a property is determined by the property definition
- itself. The vobject APIs does not attempt to enforce
- any of such definition. It is the consumer responsibility
- to know what value is expected from a property. e.g
- most properties have unicode string value, so to access
- the value of these type of properties, you will use
- the vObjectUStringZValue() to read the value and
- setVObjectUStringZValue() to set or modify the value.
- Refer to the VCard and VCalendar specifications for
- the definition of each property.
-
-d. properties name (id) are case incensitive.
-
-8. Brief descriptions of each APIs
- ===============================
- * the predefined properties' names (id) are listed under vobject.h
- each is of the form VC*Prop. e.g.
- #define VC7bitProp "7BIT"
- #define VCAAlarmProp "AALARM"
- ....
-
- * consumer of a VObject can only define pointers to VObject.
-
- * a variable of type VObjectIterator, say "i", can be used to iterate
- through a VObject's properties, say "o". The APIs related to
- VObjectIterator are:
- void initPropIterator(VObjectIterator *i, VObject *o);
- -- e.g. usage
- initPropIterator(&i,o);
- int moreIteration(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) { ... }
- VObject* nextVObject(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- }
-
- * VObject can be chained together to form a list. e.g. of such
- use is in the parser where the return value of the parser is
- a link list of VObject. A link list of VObject can be
- built by:
- void addList(VObject **o, VObject *p);
- and iterated by
- VObject* nextVObjectInList(VObject *o);
- -- next VObjectInList return 0 if the list
- is exhausted.
-
- * the following APIs are mainly used to construct a VObject tree:
- VObject* newVObject(const char *id);
- -- used extensively internally by VObject APIs but when
- used externally, its use is mainly limited to the
- construction of top level object (e.g. an object
- with VCCardProp or VCCalendarProp id).
-
- void deleteVObject(VObject *p);
- -- to deallocate single VObject, for most user, use
- cleanVObject(VObject *o) instead for freeing all
- resources associated with the VObject.
-
- char* dupStr(const char *s, unsigned int size);
- -- duplicate a string s. If size is 0, the string is
- assume to be a null-terminated.
-
- void deleteStr(const char *p);
- -- used to deallocate a string allocated by dupStr();
-
- void setVObjectName(VObject *o, const char* id);
- -- set the id of VObject o. This function is not
- normally used by the user. The setting of id
- is normally done as part of other APIs (e.g.
- addProp()).
-
- void setVObjectStringZValue(VObject *o, const char *s);
- -- set a string value of a VObject.
-
- void setVObjectUStringZValue(VObject *o, const wchar_t *s);
- -- set a Unicode string value of a VObject.
-
- void setVObjectIntegerValue(VObject *o, unsigned int i);
- -- set an integer value of a VObject.
-
- void setVObjectLongValue(VObject *o, unsigned long l);
- -- set an long integer value of a VObject.
-
- void setVObjectAnyValue(VObject *o, void *t);
- -- set any value of a VObject. The value type is
- unspecified.
-
- VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
- -- set a raw data (stream of bytes) value of a VObject
- whose size is size. The internal VObject representation
- is
- this object = val
- VCDataSizeProp=size
- i.e. the value val will be attached to the VObject prop
- and a property of VCDataSize whose value is size
- is also added to the object.
-
- void setVObjectVObjectValue(VObject *o, VObject *p);
- -- set a VObject as the value of another VObject.
-
- const char* vObjectName(VObject *o);
- -- retrieve the VObject's Name (i.e. id).
-
- const char* vObjectStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated string.
-
- const wchar_t* vObjectUStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated unicode string.
-
- unsigned int vObjectIntegerValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- integer.
-
- unsigned long vObjectLongValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- long integer.
-
- void* vObjectAnyValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- any value.
-
- VObject* vObjectVObjectValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- a VObject.
-
- VObject* addVObjectProp(VObject *o, VObject *p);
- -- add a VObject p as a property of VObject o.
- (not normally used externally for building a
- VObject).
-
- VObject* addProp(VObject *o, const char *id);
- -- add a property whose name is id to VObject o.
-
- VObject* addPropValue(VObject *o, const char *id, const char *v);
- -- add a property whose name is id and whose value
- is a null-terminated string to VObject o.
-
- VObject* addPropSizedValue(VObject *o, const char *id,
- const char *v, unsigned int size);
- -- add a property whose name is id and whose value
- is a stream of bytes of size size, to VObject o.
-
- VObject* addGroup(VObject *o, const char *g);
- -- add a group g to VObject o.
- e.g. if g is a.b.c, you will have
- o
- c
- VCGroupingProp=b
- VCGroupingProp=a
- and the object c is returned.
-
- VObject* isAPropertyOf(VObject *o, const char *id);
- -- query if a property by the name id is in o and
- return the VObject that represent that property.
-
- void printVObject(VObject *o);
- -- pretty print VObject o to stdout (for debugging use).
-
- void writeVObject(FILE *fp, VObject *o);
- -- convert VObject o to its textual representation and
- write it to file.
-
- char* writeMemVObject(char *s, int *len, VObject *o);
- -- convert VObject o to its textual representation and
- write it to memory. If s is 0, then memory required
- to hold the textual representation will be allocated
- by this API. If a variable len is passed, len will
- be overwriten with the byte size of the textual
- representation. If s is non-zero, then s has to
- be a user allocated buffer whose size has be passed
- in len as a variable. Memory allocated by the API
- has to be freed with call to free. The return value
- of this API is either the user supplied buffer,
- the memory allocated by the API, or 0 (in case of
- failure).
-
- void cleanStrTbl();
- -- this function has to be called when all
- VObject has been destroyed.
-
- void cleanVObject(VObject *o);
- -- release all resources used by VObject o.
-
- wchar_t* fakeUnicode(const char *ps, int *bytes);
- -- convert char* to wchar_t*.
-
- extern int uStrLen(const wchar_t *u);
- -- length of unicode u.
-
- char *fakeCString(const wchar_t *u);
- -- convert wchar_t to CString (blindly assumes that
- this could be done).
-
-9. Additional Programming Notes
- ============================
-In the following notes, please refers to the listing
-of Example.vcf and its VObject Representation
-(shown at the end of this section).
-
-* Handling the Return Value of the VCard/VCalendar Parser
- The example input text file contains two root VObjects
- (a VCalendar and a VCard). The output of the VCard/VCalendar
- parser is a null-terminated list of VObjects. For this
- particular input file, the list will have two VObjects.
- The following shows a template for iterating through the
- output of the Parser:
-
- VObject *t, *v;
- v = Parse_Mime_fromFileName("example.vcf");
- while (v) {
- // currently, v will either be a VCard or a VCalendar
- // do whatever your application need to do to
- // v here ...
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
-* Iterating Through a VCard/VCalendar VObject
- From the VObject APIs point of view, a VCard VObject
- is the same as a VCalendar VObject. However, the application
- needs to know what are in a VCard or a VCalendar.
- For example, A VCalendar VObject can have VCDCreatedProp,
- a VCGEOLocationProp, etc, and one or more VCEventProp and
- or VCTodoProp. The VCEventProp and VCTodoProp can have
- many properties of their own, which in turn could have
- more properties (e.g. VCDAlarmProp can be a VCEventProp
- VObject's property, and VCRunTimeProp can be a
- VCDAlarmProp VObject's property. Because a VObject tree
- can be arbitrarily complex, in general, to process all
- properties and values of a VObject tree, a recursive walk
- is desirable. An example recursive VObject tree walk
- can be found in the vobject.c source lines for printVObject*
- and writeVObject* APIs. Depending on what the application need
- to do with a VCard or a VCalendar, a recursive walk
- of the VObject tree may or may not be desirable. An example
- template of a non-recursive walk is shown below:
-
- void processVCardVCalendar(char *inputFile)
- {
- VObject *t, *v;
- v = Parse_Mime_fromFileName(inputFile);
- while (v) {
- char *n = vObjectName(v);
- if (strcmp(n,VCCardProp) == 0) {
- do_VCard(v);
- }
- else if (strcmp(n,VCCalendarProp) == 0) {
- do_VCalendar(v);
- }
- else {
- // don't know how to handle anything else!
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- }
-
- void do_VCard(VObject *vcard)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCard VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCNameProp)==0) {
- do_name(eachProp);
- }
- else if (strcmp(n,VCEmailProp)==0) {
- do_email(eachProp);
- }
- else if (strcmp(n,VCLabelProp)==0) {
- do_label(eachProp);
- }
- else if ....
- }
- }
-
- void do_VCalendar(VObject *vcal)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primarly purpose of this example is to
- // show how to iterate through a VCalendar VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCDCreatedProp)==0) {
- do_DCreated(eachProp);
- }
- else if (strcmp(n,VCVersionProp)==0) {
- do_Version(eachProp);
- }
- else if (strcmp(n,VCTodoProp)==0) {
- do_Todo(eachProp);
- }
- else if (strcmp(n,VCEventProp)==0) {
- do_Event(eachProp);
- }
- else if ....
- }
- }
-
- void do_Todo(VObject *vtodo) { ... }
-
- void do_Event(VObject *vevent) { ... }
-
- ...
-
-* Property's Values and Properties
- The VObject APIs do not attempt to check for the
- correctness of the values of a property. Nor do they
- will prevent the user from attaching a non-VCard/VCalendar
- standard property to a VCard/VCalendar property. Take
- the example of line [11] of the example, "O.K" is not
- a valid value of VCStatusProp. It is up to the application
- to accept or reject the value of a property.
-
-* Output of printVObject
- PrintVObject pretty prints a VObject tree in human
- readable form. See the listing at the end of the file
- for an example output of printVObject on the example
- input file "Example.vcf".
-
- Note that binary data are not shown in the output of
- printVObject. Instead, a note is made ([raw data]) to
- indicate that there exists such a binary data.
-
-* Note on Binary Data
- When the value of a property is a binary data, it is only
- useful to know the size of the binary data.
-
- In the case of the VCard/VCalendar parser, it chooses
- to represent the size information as a separate property
- called VCDataSizeProp whose value is the size of the binary
- data. The APIs sequence to construct the VObject subtree
- of line [44] of Example.vcf is
-
- // VObject *vcard;
- VObject *p1 = addProp(vcard,VCLogoProp);
- (void) addProp(p1,VCGIFProp);
- (void) addProp(p1,VCBASE64Prop);
- VObject *p2 = addProp(p1,VCDataSizeProp);
- (void) setVObjectLongValue(p2,1482);
- setVObjectAnyValue(vcard,...pointer to binary data);
-
- Note the presence of VCBase64Prop will cause the
- writeVObject API to output the binary data as BASE64 text.
- For VCard/VCalendar application, having the VCBase64Prop
- property is pratically always neccessary for property with
- binary data as its value.
-
-* Note on Quoted-Printable String
- String value with embedded newline are written out as
- quoted-prinatable string. It is therefore important
- to mark a property with a string value that has
- one or more embedded newlines, with the VCQutedPrintableProp
- property. e.g.
-
- // VObject *root;
- char *msg="To be\nor\nnot to be";
- VObject *p = addPropValue(root,VCDescriptionProp,msg);
- // the following is how you mark a property with
- // a property. In this case, the marker is
- // VCQuotedPrintableProp
- addProp(p,VCQuotedPrintableProp);
-
-* Note on Unicode
- Although, the current parser takes ASCII text file only,
- string values are all stored as Unicode in the VObject tree.
- For now, when using the VObject APIs to construct a
- VObject tree, one should always convert ASCII string value
- to a Unicode string value:
-
- // VObject *root;
- VObject *p = addProp(root,VCSomeProp);
- setVObjectUStringZValue(p,fakeUnicode(someASCIIStringZvalue));
-
- An API is provided to simplify the above process:
-
- addPropValue(root,VCSomeProp,someASCIIStringZValue);
-
- Note that someASCIISTringZValue is automatically converted to
- Unicode by addPropValue API, where as, the former code
- sequence do an explicit call to fakeUnicode.
-
- To read back the value, one should use the vObjectUStringZValue
- API not vObjectStringZValue API. The value returned by the
- vObjectUStringZValue API is a Unicode string. If the application
- do not know how to handle Unicode string, it can use the
- fakeCString API to convert it back to ASCII string (as long
- as the conversion is meaningful).
-
- Note that fakeCString return a heap allocated memory. It is
- important to call deleteStr on fakeCString return value if
- it is not longer required (or there will be memory leak).
-
- NOTE: Unfortunately, at the point when this document is written,
- there is still no consensus on how Unicode is to be handled
- in the textual representation of VCard/VCalendar. So, there
- is no version of writeVObject and the parser to output and
- input Unicode textual representation of VCard/VCalendar.
-
-
-Example.vcf
------------
-line
-number Input Text (example.vcf)
------- ----------
-1 BEGIN:VCALENDAR
-2 DCREATED:19961102T100522
-3 GEO:0,0
-4 VERSION:1.0
-5 BEGIN:VEVENT
-6 DTSTART:19961103T000000
-7 DTEND:20000101T000000
-8 DESCRIPTION;QUOTED-PRINTABLE:To be =0A=
-9 or =0A=
-10 not to be
-11 STATUS:O.K.
-12 X-ACTION:No action required
-13 DALARM:19961103T114500;5;3;Enjoy
-14 MALARM:19970101T120000;;;johny@nowhere.com;Call Mom.
-15 END:VEVENT
-16
-17 BEGIN:VTODO
-18 DUE:19960614T0173000
-19 DESCRIPTION:Relex.
-20 END:VTODO
-21
-22 END:VCALENDAR
-23
-24 BEGIN:VCARD
-25 N:Alden;Roland
-26 FN:Roland H. Alden
-27 ORG:AT&T;Versit Project Office
-28 TITLE:Consultant
-29 EMAIL;WORK;PREF;INTERNET:ralden@ralden.com
-30 LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-31 Suite 2208=0A=
-32 One Pine Street=0A=
-33 San Francisco, CA 94111
-34 LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-35 Suite 2208=0A=
-36 One Pine Street=0A=
-37 San Francisco, CA 94111=0A=
-38 U.S.A.
-39 TEL;WORK;PREF;MSG:+1 415 296 9106
-40 TEL;WORK;FAX:+1 415 296 9016
-41 TEL;MSG;CELL:+1 415 608 5981
-42 ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-43 SOUND:ROW-LAND H ALL-DIN
-44 LOGO;GIF;BASE64:
-45 R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- ... 30 lines of BASE64 data not shown here.
-76 END:VCARD
-
-
-VObject Representation of Example.vcf:
--------------------------------------
-line
-in
-text
-file VObject Tree as Printed by printVObject API
----- -------------------------------------------
-1 VCALENDAR
-2 DCREATED="19961102T100522"
-3 GEO="0,0"
-4 VERSION="1.0"
-5 VEVENT
-6 DTSTART="19961103T000000"
-7 DTEND="20000101T000000"
-8 DESCRIPTION="To be
-9 or
-10 not to be"
-8 QUOTED-PRINTABLE
-11 STATUS="O.K."
-12 X-ACTION="No action required"
-13 DALARM
-13 RUNTIME="19961103T114500"
-13 SNOOZETIME="5"
-13 REPEATCOUNT="3"
-13 DISPLAYSTRING="Enjoy"
-14 MALARM
-14 RUNTIME="19970101T120000"
-14 EMAIL="johny@nowhere.com"
-14 NOTE="Call Mom"
-17 VTODO
-18 DUE="19960614T0173000"
-19 DESCRIPTION="Relex."
-24 VCARD
-25 N
-25 F="Alden"
-25 G="Roland"
-26 FN="Roland H. Alden"
-27 ORG
-27 ORGNAME="AT&T"
-27 OUN="Versit Project Office"
-28 TITLE="Consultant"
-29 EMAIL="ralden@alden.com"
-29 WORK
-29 PREF
-29 INTERNET
-30 LABEL="Roland H. Alden
-31 Suite 2208
-32 One Pine Street
-33 San Francisco, CA 94111"
-30 DOM
-30 POSTAL
-30 PARCEL
-30 HOME
-30 WORK
-30 QUOTED-PRINTABLE
-34 LABEL="Roland H. Alden
-35 Suite 2208
-36 One Pine Street
-37 San Francisco, CA 94111
-38 U.S.A."
-34 POSTAL
-34 PARCEL
-34 HOME
-34 WORK
-34 QUOTED-PRINTABLE
-39 TEL="+1 415 296 9106"
-39 WORK
-39 PREF
-39 MSG
-40 TEL="+1 415 296 9016"
-40 WORK
-40 FAX
-41 TEL="+1 415 608 5981"
-41 MSG
-41 CELL
-42 ADR
-42 EXT ADD="Suite 2208"
-42 STREET="One Pine Street"
-42 L="San Francisco"
-42 R="CA"
-42 PC="94111"
-42 C="U.S.A."
-43 SOUND="ROW-LAND H ALL-DIN"
-44 LOGO=[raw data]
-44 GIF
-44 BASE64
-44 DATASIZE=1482
-
diff --git a/libical/src/libicalvcal/icalvcal.c b/libical/src/libicalvcal/icalvcal.c
deleted file mode 100644
index 24c3155178..0000000000
--- a/libical/src/libicalvcal/icalvcal.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/*======================================================================
- FILE: icalvcal.c
- CREATOR: eric 25 May 00
-
- $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 icalvcal.c
-
-
-
- The icalvcal_convert routine calls icalvcal_traverse_objects to do
- its work.s his routine steps through through all of the properties
- and components of a VObject. For each name of a property or a
- component, icalvcal_traverse_objects looks up the name in
- conversion_table[]. This table indicates wether the name is of a
- component or a property, lists a routine to handle conversion, and
- has extra data for the conversion.
-
- The conversion routine will create new iCal components or properties
- and add them to the iCal component structure.
-
- The most common conversion routine is dc_prop. This routine converts
- properties for which the text representation of the vCal component
- is identical the iCal representation.
-
- ======================================================================*/
-
-#include "icalvcal.h"
-#include <string.h>
-
-enum datatype {
- COMPONENT,
- PROPERTY,
- PARAMETER,
- UNSUPPORTED
-};
-
-
-struct conversion_table_struct {
- char* vcalname;
- enum datatype type;
- void* (*conversion_func)(int icaltype, VObject *o);
- int icaltype;
-};
-
-struct conversion_table_struct conversion_table[];
-void* dc_prop(int icaltype, VObject *object);
-
-static void icalvcal_traverse_objects(VObject *object,icalcomponent* last_comp,
- icalproperty* last_prop)
-{
- VObjectIterator iterator;
- char* name = "[No Name]";
- icalcomponent* subc = 0;
- int i;
-
- if ( vObjectName(object)== 0){
- printf("ERROR, object has no name");
- assert(0);
- return;
- }
-
- name = (char*)vObjectName(object);
-
- /* Lookup this object in the conversion table */
- for (i = 0; conversion_table[i].vcalname != 0; i++){
- if(strcmp(conversion_table[i].vcalname, name) == 0){
- break;
- }
- }
-
- /* Did not find the object. It may be an X-property, or an unknown
- property */
- if (conversion_table[i].vcalname == 0){
-
- /* Handle X properties */
- if(strncmp(name, "X-",2) == 0){
- icalproperty* prop = (icalproperty*)dc_prop(ICAL_X_PROPERTY,object);
- icalproperty_set_x_name(prop,name);
- icalcomponent_add_property(last_comp,prop);
- } else {
- assert(0);
- return;
- }
-
- } else {
-
- /* The vCal property is in the table, and it is not an X
- property, so try to convert it to an iCal component,
- property or parameter. */
-
- switch(conversion_table[i].type){
-
-
- case COMPONENT: {
- subc =
- (icalcomponent*)(conversion_table[i].conversion_func
- (conversion_table[i].icaltype,
- object));
-
- icalcomponent_add_component(last_comp,subc);
-
- assert(subc!=0);
-
- break;
- }
-
- case PROPERTY: {
-
- if (vObjectValueType(object) &&
- conversion_table[i].conversion_func != 0 ) {
-
- icalproperty* prop =
- (icalproperty*)(conversion_table[i].conversion_func
- (conversion_table[i].icaltype,
- object));
-
- icalcomponent_add_property(last_comp,prop);
- last_prop = prop;
-
- }
- break;
- }
-
- case PARAMETER: {
- break;
- }
-
- case UNSUPPORTED: {
-
- /* If the property is listed as UNSUPPORTED, insert a
- X_LIC_ERROR property to note this fact. */
-
- char temp[1024];
- char* message = "Unsupported vCal property";
- icalparameter *error_param;
- icalproperty *error_prop;
-
- snprintf(temp,1024,"%s: %s",message,name);
-
- error_param = icalparameter_new_xlicerrortype(
- ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR
- );
-
- error_prop = icalproperty_new_xlicerror(temp);
- icalproperty_add_parameter(error_prop, error_param);
-
- icalcomponent_add_property(last_comp,error_prop);
-
- break;
- }
- }
- }
-
-
- /* Now, step down into the next vCalproperty */
-
- initPropIterator(&iterator,object);
- while (moreIteration(&iterator)) {
- VObject *eachProp = nextVObject(&iterator);
-
- /* If 'object' is a component, then the next traversal down
- should use it as the 'last_comp' */
-
- if(subc!=0){
- icalvcal_traverse_objects(eachProp,subc,last_prop);
-
- } else {
- icalvcal_traverse_objects(eachProp,last_comp,last_prop);
- }
- }
-}
-
-icalcomponent* icalvcal_convert(VObject *object){
-
- char* name = (char*)vObjectName(object);
- icalcomponent* container = icalcomponent_new(ICAL_XROOT_COMPONENT);
- icalcomponent* root;
-
- icalerror_check_arg_rz( (object!=0),"Object");
-
- /* The root object must be a VCALENDAR */
- if(*name==0 || strcmp(name,VCCalProp) != 0){
- return 0; /* HACK. Should return an error */
- }
-
-
- icalvcal_traverse_objects(object,container,0);
-
- /* HACK. I am using the extra 'container' component because I am
- lazy. I know there is a way to get rid of it, but I did not care
- to find it. */
-
- root = icalcomponent_get_first_component(container,ICAL_ANY_COMPONENT);
-
- icalcomponent_remove_component(container, root);
- icalcomponent_free(container);
-
- return root;
-
-}
-
-/* comp() is useful for most components, but alarm, daylight and
- * timezone are different. In vcal, they are properties, and in ical,
- * they are components. Although because of the way that vcal treats
- * everything as a property, alarm_comp() daylight_comp() and
- * timezone_comp() may not really be necessary, I think it would be
- * easier to use them. */
-
-void* comp(int icaltype, VObject *o)
-{
- icalcomponent_kind kind = (icalcomponent_kind)icaltype;
-
- icalcomponent* c = icalcomponent_new(kind);
-
- return (void* )c;
-}
-
-void* alarm_comp(int icaltype, VObject *o)
-{
- icalcomponent_kind kind = (icalcomponent_kind)icaltype;
-
- icalcomponent* c = icalcomponent_new(kind);
-
- return (void*)c;
-}
-
-void* daylight_comp(int icaltype, VObject *o)
-{
- icalcomponent_kind kind = (icalcomponent_kind)icaltype;
-
- icalcomponent* c = icalcomponent_new(kind);
-
- return (void*)c;
-}
-
-void* timezone_comp(int icaltype, VObject *o)
-{
- icalcomponent_kind kind = (icalcomponent_kind)icaltype;
-
- icalcomponent* c = icalcomponent_new(kind);
-
- return (void*)c;
-}
-
-
-/* These #defines indicate conversion routines that are not defined yet. */
-
-#define categories_prop 0
-#define transp_prop 0
-#define status_prop 0
-
-#define parameter 0
-#define rsvp_parameter 0
-
-
-
-/* directly convertable property. The string representation of vcal is
- the same as ical */
-
-void* dc_prop(int icaltype, VObject *object)
-{
- icalproperty_kind kind = (icalproperty_kind)icaltype;
- icalproperty *prop;
- icalvalue *value;
- icalvalue_kind value_kind;
- char *s,*t=0;
-
- prop = icalproperty_new(kind);
-
- value_kind =
- icalenum_property_kind_to_value_kind(
- icalproperty_isa(prop));
-
-
- switch (vObjectValueType(object)) {
- case VCVT_USTRINGZ: {
- s = t = fakeCString(vObjectUStringZValue(object));
- break;
- }
- case VCVT_STRINGZ: {
- s = (char*)vObjectStringZValue(object);
- break;
- }
- }
-
- value = icalvalue_new_from_string(value_kind,s);
-
- if(t!=0){
- deleteStr(t);
- }
-
- icalproperty_set_value(prop,value);
-
- return (void*)prop;
-}
-
-
-/* My extraction program screwed up, so this table does not have all
-of the vcal properties in it. I didn't feel like re-doing the entire
-table, so you'll have to find the missing properties the hard way --
-the code will assert */
-
-struct conversion_table_struct conversion_table[] =
-{
-{VCCalProp, COMPONENT, comp, ICAL_VCALENDAR_COMPONENT},
-{VCTodoProp, COMPONENT, comp, ICAL_VTODO_COMPONENT},
-{VCEventProp, COMPONENT, comp, ICAL_VEVENT_COMPONENT},
-{VCAAlarmProp, COMPONENT, alarm_comp, ICAL_XAUDIOALARM_COMPONENT},
-{VCDAlarmProp, COMPONENT, alarm_comp, ICAL_XDISPLAYALARM_COMPONENT},
-{VCMAlarmProp, COMPONENT, alarm_comp, ICAL_XEMAILALARM_COMPONENT},
-{VCPAlarmProp, COMPONENT, alarm_comp, ICAL_XPROCEDUREALARM_COMPONENT},
-{VCDayLightProp, COMPONENT, daylight_comp,0},
-{VCTimeZoneProp, COMPONENT, timezone_comp, ICAL_VTIMEZONE_COMPONENT},
-{VCProdIdProp, PROPERTY, dc_prop, ICAL_PRODID_PROPERTY},
-{VCClassProp, PROPERTY, dc_prop, ICAL_CLASS_PROPERTY},
-{VCDCreatedProp, PROPERTY, dc_prop, ICAL_CREATED_PROPERTY},
-{VCDescriptionProp, PROPERTY, dc_prop, ICAL_DESCRIPTION_PROPERTY},
-{VCAttendeeProp, PROPERTY, dc_prop, ICAL_ATTENDEE_PROPERTY},
-{VCCategoriesProp, PROPERTY, categories_prop,ICAL_CATEGORIES_PROPERTY},
-{VCDTendProp, PROPERTY, dc_prop, ICAL_DTEND_PROPERTY},
-{VCDTstartProp, PROPERTY, dc_prop, ICAL_DTSTART_PROPERTY},
-{VCDueProp, PROPERTY, dc_prop, ICAL_DUE_PROPERTY},
-{VCLocationProp, PROPERTY, dc_prop, ICAL_LOCATION_PROPERTY},
-{VCSummaryProp, PROPERTY, dc_prop, ICAL_SUMMARY_PROPERTY},
-{VCVersionProp, PROPERTY, dc_prop, ICAL_VERSION_PROPERTY},
-{VCTranspProp, PROPERTY, transp_prop, ICAL_TRANSP_PROPERTY},
-{VCUniqueStringProp, PROPERTY, dc_prop, ICAL_UID_PROPERTY},
-{VCURLProp, PROPERTY, dc_prop, ICAL_URL_PROPERTY},
-{VCLastModifiedProp, PROPERTY, dc_prop, ICAL_LASTMODIFIED_PROPERTY},
-{VCSequenceProp, PROPERTY, dc_prop, ICAL_SEQUENCE_PROPERTY},
-{VCPriorityProp, PROPERTY, dc_prop, ICAL_PRIORITY_PROPERTY},
-{VCStatusProp, PROPERTY, status_prop, ICAL_STATUS_PROPERTY},
-{VCRSVPProp, UNSUPPORTED, rsvp_parameter,ICAL_RSVP_PARAMETER },
-{VCEncodingProp, UNSUPPORTED, parameter, ICAL_ENCODING_PARAMETER},
-{VCRoleProp, UNSUPPORTED, parameter, ICAL_ROLE_PARAMETER},
-{VCStatusProp, UNSUPPORTED, parameter, ICAL_STATUS_PROPERTY},
-{VCQuotedPrintableProp,UNSUPPORTED,0, 0},
-{VC7bitProp, UNSUPPORTED,0, 0},
-{VC8bitProp, UNSUPPORTED,0, 0},
-{VCAdditionalNamesProp,UNSUPPORTED,0, 0},
-{VCAdrProp, UNSUPPORTED,0, 0},
-{VCAgentProp, UNSUPPORTED,0, 0},
-{VCAIFFProp, UNSUPPORTED,0, 0},
-{VCAOLProp, UNSUPPORTED,0, 0},
-{VCAppleLinkProp, UNSUPPORTED,0, 0},
-{VCAttachProp, UNSUPPORTED,0, 0},
-{VCATTMailProp, UNSUPPORTED,0, 0},
-{VCAudioContentProp, UNSUPPORTED,0, 0},
-{VCAVIProp, UNSUPPORTED,0, 0},
-{VCBase64Prop, UNSUPPORTED,0, 0},
-{VCBBSProp, UNSUPPORTED,0, 0},
-{VCBirthDateProp, UNSUPPORTED,0, 0},
-{VCBMPProp, UNSUPPORTED,0, 0},
-{VCBodyProp, UNSUPPORTED,0, 0},
-{VCCaptionProp, UNSUPPORTED,0, 0},
-{VCCarProp, UNSUPPORTED,0, 0},
-{VCCellularProp, UNSUPPORTED,0, 0},
-{VCCGMProp, UNSUPPORTED,0, 0},
-{VCCharSetProp, UNSUPPORTED,0, 0},
-{VCCIDProp, UNSUPPORTED,0, 0},
-{VCCISProp, UNSUPPORTED,0, 0},
-{VCCityProp, UNSUPPORTED,0, 0},
-{VCCommentProp, UNSUPPORTED,0, 0},
-{VCCompletedProp, UNSUPPORTED,0, 0},
-{VCCountryNameProp, UNSUPPORTED,0, 0},
-{VCDataSizeProp, UNSUPPORTED,0, 0},
-{VCDeliveryLabelProp, UNSUPPORTED,0, 0},
-{VCDIBProp, UNSUPPORTED,0, 0},
-{VCDisplayStringProp, UNSUPPORTED,0, 0},
-{VCDomesticProp, UNSUPPORTED,0, 0},
-{VCEmailAddressProp, UNSUPPORTED,0, 0},
-{VCEndProp, UNSUPPORTED,0, 0},
-{VCEWorldProp, UNSUPPORTED,0, 0},
-{VCExNumProp, UNSUPPORTED,0, 0},
-{VCExpDateProp, UNSUPPORTED,0, 0},
-{VCExpectProp, UNSUPPORTED,0, 0},
-{VCFamilyNameProp, UNSUPPORTED,0, 0},
-{VCFaxProp, UNSUPPORTED,0, 0},
-{VCFullNameProp, UNSUPPORTED,0, 0},
-{VCGeoProp, UNSUPPORTED,0, 0},
-{VCGeoLocationProp, UNSUPPORTED,0, 0},
-{VCGIFProp, UNSUPPORTED,0, 0},
-{VCGivenNameProp, UNSUPPORTED,0, 0},
-{VCGroupingProp, UNSUPPORTED,0, 0},
-{VCHomeProp, UNSUPPORTED,0, 0},
-{VCIBMMailProp, UNSUPPORTED,0, 0},
-{VCInlineProp, UNSUPPORTED,0, 0},
-{VCInternationalProp, UNSUPPORTED,0, 0},
-{VCInternetProp, UNSUPPORTED,0, 0},
-{VCISDNProp, UNSUPPORTED,0, 0},
-{VCJPEGProp, UNSUPPORTED,0, 0},
-{VCLanguageProp, UNSUPPORTED,0, 0},
-{VCLastRevisedProp, UNSUPPORTED,0, 0},
-{VCLogoProp, UNSUPPORTED,0, 0},
-{VCMailerProp, UNSUPPORTED,0, 0},
-{VCMCIMailProp, UNSUPPORTED,0, 0},
-{VCMessageProp, UNSUPPORTED,0, 0},
-{VCMETProp, UNSUPPORTED,0, 0},
-{VCModemProp, UNSUPPORTED,0, 0},
-{VCMPEG2Prop, UNSUPPORTED,0, 0},
-{VCMPEGProp, UNSUPPORTED,0, 0},
-{VCMSNProp, UNSUPPORTED,0, 0},
-{VCNamePrefixesProp, UNSUPPORTED,0, 0},
-{VCNameProp, UNSUPPORTED,0, 0},
-{VCNameSuffixesProp, UNSUPPORTED,0, 0},
-{VCNoteProp, UNSUPPORTED,0, 0},
-{VCOrgNameProp, UNSUPPORTED,0, 0},
-{VCOrgProp, UNSUPPORTED,0, 0},
-{VCOrgUnit2Prop, UNSUPPORTED,0, 0},
-{VCOrgUnit3Prop, UNSUPPORTED,0, 0},
-{VCOrgUnit4Prop, UNSUPPORTED,0, 0},
-{VCOrgUnitProp, UNSUPPORTED,0, 0},
-{VCPagerProp, UNSUPPORTED,0, 0},
-{VCParcelProp, UNSUPPORTED,0, 0},
-{VCPartProp, UNSUPPORTED,0, 0},
-{VCPCMProp, UNSUPPORTED,0, 0},
-{VCPDFProp, UNSUPPORTED,0, 0},
-{VCPGPProp, UNSUPPORTED,0, 0},
-{VCPhotoProp, UNSUPPORTED,0, 0},
-{VCPICTProp, UNSUPPORTED,0, 0},
-{VCPMBProp, UNSUPPORTED,0, 0},
-{VCPostalBoxProp, UNSUPPORTED,0, 0},
-{VCPostalCodeProp, UNSUPPORTED,0, 0},
-{VCPostalProp, UNSUPPORTED,0, 0},
-{VCPowerShareProp, UNSUPPORTED,0, 0},
-{VCPreferredProp, UNSUPPORTED,0, 0},
-{VCProcedureNameProp, UNSUPPORTED,0, 0},
-{VCProdigyProp, UNSUPPORTED,0, 0},
-{VCPronunciationProp, UNSUPPORTED,0, 0},
-{VCPSProp, UNSUPPORTED,0, 0},
-{VCPublicKeyProp, UNSUPPORTED,0, 0},
-{VCQPProp, UNSUPPORTED,0, 0},
-{VCQuickTimeProp, UNSUPPORTED,0, 0},
-{VCRDateProp, UNSUPPORTED,0, 0},
-{VCRegionProp, UNSUPPORTED,0, 0},
-{VCRepeatCountProp, UNSUPPORTED,0, 0},
-{VCResourcesProp, UNSUPPORTED,0, 0},
-{VCRNumProp, UNSUPPORTED,0, 0},
-{VCRRuleProp, UNSUPPORTED,0, 0},
-{VCRunTimeProp, UNSUPPORTED,0, 0},
-{VCSnoozeTimeProp, UNSUPPORTED,0, 0},
-{VCStartProp, UNSUPPORTED,0, 0},
-{VCStreetAddressProp, UNSUPPORTED,0, 0},
-{VCSubTypeProp, UNSUPPORTED,0, 0},
-{VCTelephoneProp, UNSUPPORTED,0, 0},
-{VCTIFFProp, UNSUPPORTED,0, 0},
-{VCTitleProp, UNSUPPORTED,0, 0},
-{VCTLXProp, UNSUPPORTED,0, 0},
-{VCURLValueProp, UNSUPPORTED,0, 0},
-{VCValueProp, UNSUPPORTED,0, 0},
-{VCVideoProp, UNSUPPORTED,0, 0},
-{VCVoiceProp, UNSUPPORTED,0, 0},
-{VCWAVEProp, UNSUPPORTED,0, 0},
-{VCWMFProp, UNSUPPORTED,0, 0},
-{VCWorkProp, UNSUPPORTED,0, 0},
-{VCX400Prop, UNSUPPORTED,0, 0},
-{VCX509Prop, UNSUPPORTED,0, 0},
-{VCXRuleProp, UNSUPPORTED,0, 0},
-{0,0,0,0}
-};
-
-
-#if 0
- switch (vObjectValueType(object)) {
- case VCVT_USTRINGZ: {
- char c;
- char *t,*s;
- s = t = fakeCString(vObjectUStringZValue(object));
- printf(" ustringzstring:%s\n",s);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- char c;
- const char *s = vObjectStringZValue(object);
- printf(" stringzstring:%s\n",s);
- break;
- }
- case VCVT_UINT:
- {
- int i = vObjectIntegerValue(object);
- printf(" int:%d\n",i);
- break;
- }
- case VCVT_ULONG:
- {
- long l = vObjectLongValue(object);
- printf(" int:%d\n",l);
- break;
- }
- case VCVT_VOBJECT:
- {
- printf("ERROR, should not get here\n");
- break;
- }
- case VCVT_RAW:
- case 0:
- default:
- break;
- }
-
-#endif
diff --git a/libical/src/libicalvcal/icalvcal.h b/libical/src/libicalvcal/icalvcal.h
deleted file mode 100644
index f2316c2d0f..0000000000
--- a/libical/src/libicalvcal/icalvcal.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C -*-*/
-/*======================================================================
- FILE: icalvcal.h
- CREATOR: eric 25 May 00
-
-
-
- (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 icalvcal.h
-
-
-======================================================================*/
-
-#ifndef ICALVCAL_H
-#define ICALVCAL_H
-
-#include "ical.h"
-#include "vcc.h"
-
-/* Convert a vObject into an icalcomponent */
-
-icalcomponent* icalvcal_convert(VObject *object);
-
-#endif /* !ICALVCAL_H */
-
-
-
diff --git a/libical/src/libicalvcal/port.h b/libical/src/libicalvcal/port.h
deleted file mode 100644
index 1768beebd8..0000000000
--- a/libical/src/libicalvcal/port.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __PORT_H__
-#define __PORT_H__ 1
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-/* some of these #defines are commented out because */
-/* Visual C++ sets them on the compiler command line instead */
-
-/* #define _DEBUG */
-/* #define WIN32 */
-/* #define WIN16 */
-/* #define _WINDOWS */
-/* #define __MWERKS__ */
-/* #define INCLUDEMFC */
-
-#define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard"
-#define vCalendarClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCalendar"
-
-/* The above strings vCardClipboardFormat and vCalendarClipboardFormat
-are globally unique IDs which can be used to generate clipboard format
-ID's as per the requirements of a specific platform. For example, in
-Windows they are used as the parameter in a call to RegisterClipboardFormat.
-For example:
-
- CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat);
-
-*/
-
-#define vCardMimeType "text/x-vCard"
-#define vCalendarMimeType "text/x-vCalendar"
-
-#define DLLEXPORT(t) t
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#define stricmp strcasecmp
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __PORT_H__ */
diff --git a/libical/src/libicalvcal/vcaltest.c b/libical/src/libicalvcal/vcaltest.c
deleted file mode 100644
index 5528aab1d1..0000000000
--- a/libical/src/libicalvcal/vcaltest.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-SUBTYPE:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-FILE *cfp;
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal, *vevent;
-#if _CONSOLE
- cfp = stdout;
-#else
- cfp = fopen("vcaltest.out","w");
-#endif
- if (cfp == 0) return;
- vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(cfp,vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- fprintf(cfp,"open output file '%s' failed\n", OUTFILE);
- }
- if (cfp != stdout) fclose(cfp);
- }
-
-void main() {
- testVcalAPIs();
- }
-
diff --git a/libical/src/libicalvcal/vcaltmp.c b/libical/src/libicalvcal/vcaltmp.c
deleted file mode 100644
index ccb21a649a..0000000000
--- a/libical/src/libicalvcal/vcaltmp.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
-This module provides some helper APIs for creating
-a VCalendar object.
-
-Note on APIs:
- 1. The APIs does not attempt to verify if the arguments
- passed are correct.
- 2. Where the argument to an API is not applicable, pass
- the value 0.
- 3. See the test program at the bottom of this file as an
- example of usage.
- 4. This code calls APIs in vobject.c.
-
-*/
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-
-#include <stdio.h>
-#include <string.h>
-#include "vcaltmp.h"
-
-
-DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- )
- {
- VObject *vcal = newVObject(VCCalProp);
-#define Z(p,v) if (v) addPropValue(vcal,p,v);
- Z(VCDCreatedProp, date_created);
- Z(VCLocationProp, location)
- Z(VCProdIdProp, product_id)
- Z(VCTimeZoneProp, time_zone)
- Z(VCVersionProp, version)
-#undef Z
- return vcal;
- }
-
-
-DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- )
- {
- VObject *vevent = addProp(vcal,VCEventProp);
-#define Z(p,v) if (v) addPropValue(vevent,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDTendProp,end_date_time);
- if (description) {
- VObject *p = addPropValue(vevent,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCCategoriesProp,categories);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCTranspProp,transparency);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vevent;
- }
-
-
-DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- )
- {
- VObject *vtodo = addProp(vcal,VCTodoProp);
-#define Z(p,v) if (v) addPropValue(vtodo,p,v);
- Z(VCDTstartProp,start_date_time);
- Z(VCDueProp,due_date_time);
- Z(VCCompletedProp,date_time_complete);
- if (description) {
- VObject *p = addPropValue(vtodo,VCDescriptionProp,description);
- if (strchr(description,'\n'))
- addProp(p,VCQuotedPrintableProp);
- }
- Z(VCSummaryProp,summary);
- Z(VCPriorityProp,priority);
- Z(VCClassProp,classification);
- Z(VCStatusProp,status);
- Z(VCUniqueStringProp,uid);
- Z(VCURLProp,url);
-#undef Z
- return vtodo;
- }
-
-
-DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- )
- {
- VObject *aalarm= addProp(vevent,VCAAlarmProp);
-#define Z(p,v) if (v) addPropValue(aalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCAudioContentProp,audio_content);
-#undef Z
- return aalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- )
- {
- VObject *malarm= addProp(vevent,VCMAlarmProp);
-#define Z(p,v) if (v) addPropValue(malarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCEmailAddressProp,email_address);
- Z(VCNoteProp,note);
-#undef Z
- return malarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- )
- {
- VObject *dalarm= addProp(vevent,VCDAlarmProp);
-#define Z(p,v) if (v) addPropValue(dalarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCDisplayStringProp,display_string);
-#undef Z
- return dalarm;
- }
-
-
-DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- )
- {
- VObject *palarm= addProp(vevent,VCPAlarmProp);
-#define Z(p,v) if (v) addPropValue(palarm,p,v);
- Z(VCRunTimeProp,run_time);
- Z(VCSnoozeTimeProp,snooze_time);
- Z(VCRepeatCountProp,repeat_count);
- Z(VCProcedureNameProp,procedure_name);
-#undef Z
- return palarm;
- }
-
-
-#ifdef _TEST
-
-#if 0
-This testcase would generate a file call "frankcal.vcf" with
-the following content:
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-GEO:37.24,-17.87
-PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-DTSTART:19960523T120000
-DTEND:19960523T130000
-DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A=
-With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A=
-activities with European Press representatives.
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-CATEGORIES:PHONE CALL
-STATUS:CONFIRMED
-TRANSP:19960523T100522-4000F100582713-009251
-UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2
-DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!;
-MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!;
-PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2;
-X-LDC-OR2-OLE:c:\temp\agenda.doc
-END:VEVENT
-
-BEGIN:VTODO
-DUE:19960614T0173000
-DESCRIPTION:Review VCalendar helper API.
-END:VTODO
-
-END:VCALENDAR
-
-#endif
-
-void testVcalAPIs() {
- FILE *fp;
- VObject *vcal = vcsCreateVCal(
- "19960523T100522",
- "37.24,-17.87",
- "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN",
- 0,
- "0.3"
- );
-
- VObject *vevent = vcsAddEvent(
- vcal,
- "19960523T120000",
- "19960523T130000",
- "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.",
- "VERSIT PDI PR Teleconference/Interview",
- "PHONE CALL",
- 0,
- "CONFIRMED",
- "19960523T100522-4000F100582713-009251",
- "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2",
- 0
- );
-
- vcsAddDAlarm(vevent, "19960523T114500", "5", "3",
- "Your Telecon Starts At Noon!!!");
- vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com",
- "Remember 05/23 Noon Telecon!!!");
- vcsAddPAlarm(vevent, "19960523T115500", 0 ,0,
- "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2");
-
- addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc");
-
- vcsAddTodo(
- vcal,
- 0,
- "19960614T0173000",
- 0,
- "Review VCalendar helper API.",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- );
-
- /* now do something to the resulting VObject */
- /* pretty print on stdout for fun */
- printVObject(vcal);
- /* open the output text file */
-
-#define OUTFILE "frankcal.vcf"
-
- fp = fopen(OUTFILE, "w");
- if (fp) {
- /* write it in text form */
- writeVObject(fp,vcal);
- fclose(fp);
- }
- else {
- printf("open output file '%s' failed\n", OUTFILE);
- }
- }
-
-void main() {
- testVcalAPIs();
- }
-
-#endif
-
-
-/* end of source file vcaltmp.c */
diff --git a/libical/src/libicalvcal/vcaltmp.h b/libical/src/libicalvcal/vcaltmp.h
deleted file mode 100644
index 4c4afde963..0000000000
--- a/libical/src/libicalvcal/vcaltmp.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#include "vcc.h"
-
-#ifndef __VCALTMP_H__
-#define __VCALTMP_H__
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-extern DLLEXPORT(VObject*) vcsCreateVCal(
- char *date_created,
- char *location,
- char *product_id,
- char *time_zone,
- char *version
- );
-
-extern DLLEXPORT(VObject*) vcsAddEvent(
- VObject *vcal,
- char *start_date_time,
- char *end_date_time,
- char *description,
- char *summary,
- char *categories,
- char *classification,
- char *status,
- char *transparency,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddTodo(
- VObject *vcal,
- char *start_date_time,
- char *due_date_time,
- char *date_time_complete,
- char *description,
- char *summary,
- char *priority,
- char *classification,
- char *status,
- char *uid,
- char *url
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddAAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *audio_content
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddMAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *email_address,
- char *note
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddDAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *display_string
- );
-
-
-extern DLLEXPORT(VObject*) vcsAddPAlarm(
- VObject *vevent,
- char *run_time,
- char *snooze_time,
- char *repeat_count,
- char *procedure_name
- );
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCALTMP_H__ */
-
-
diff --git a/libical/src/libicalvcal/vcc.h b/libical/src/libicalvcal/vcc.h
deleted file mode 100644
index 0e52034710..0000000000
--- a/libical/src/libicalvcal/vcc.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-#ifndef __VCC_H__
-#define __VCC_H__ 1
-
-#include "vobject.h"
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-typedef void (*MimeErrorHandler)(char *);
-
-extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
-
-extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
-extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
-
-
-/* NOTE regarding Parse_MIME_FromFile
-The function above, Parse_MIME_FromFile, comes in two flavors,
-neither of which is exported from the DLL. Each version takes
-a CFile or FILE* as a parameter, neither of which can be
-passed across a DLL interface (at least that is my experience).
-If you are linking this code into your build directly then
-you may find them a more convenient API that the other flavors
-that take a file name. If you use them with the DLL LIB you
-will get a link error.
-*/
-
-
-#if INCLUDEMFC
-extern VObject* Parse_MIME_FromFile(CFile *file);
-#else
-extern VObject* Parse_MIME_FromFile(FILE *file);
-#endif
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VCC_H__ */
-
diff --git a/libical/src/libicalvcal/vcc.y b/libical/src/libicalvcal/vcc.y
deleted file mode 100644
index 70feefab57..0000000000
--- a/libical/src/libicalvcal/vcc.y
+++ /dev/null
@@ -1,1176 +0,0 @@
-%{
-
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vcc.c
- * doc: Parser for vCard and vCalendar. Note that this code is
- * generated by a yacc parser generator. Generally it should not
- * be edited by hand. The real source is vcc.y. The #line directives
- * can be commented out here to make it easier to trace through
- * in a debugger. However, if a bug is found it should
- * be fixed in vcc.y and this file regenerated.
- */
-
-
-/* debugging utilities */
-#if __DEBUG
-#define DBG_(x) printf x
-#else
-#define DBG_(x)
-#endif
-
-/**** External Functions ****/
-
-/* assign local name to parser variables and functions so that
- we can use more than one yacc based parser.
-*/
-
-#define yyparse mime_parse
-#define yylex mime_lex
-#define yyerror mime_error
-#define yychar mime_char
-/* #define p_yyval p_mime_val */
-#undef yyval
-#define yyval mime_yyval
-/* #define p_yylval p_mime_lval */
-#undef yylval
-#define yylval mime_yylval
-#define yydebug mime_debug
-#define yynerrs mime_nerrs
-#define yyerrflag mime_errflag
-#define yyss mime_ss
-#define yyssp mime_ssp
-#define yyvs mime_vs
-#define yyvsp mime_vsp
-#define yylhs mime_lhs
-#define yylen mime_len
-#define yydefred mime_defred
-#define yydgoto mime_dgoto
-#define yysindex mime_sindex
-#define yyrindex mime_rindex
-#define yygindex mime_gindex
-#define yytable mime_table
-#define yycheck mime_check
-#define yyname mime_name
-#define yyrule mime_rule
-#define YYPREFIX "mime_"
-
-
-#ifndef _NO_LINE_FOLDING
-#define _SUPPORT_LINE_FOLDING 1
-#endif
-
-/* undef below if compile with MFC */
-/* #define INCLUDEMFC 1 */
-
-#if defined(WIN32) || defined(_WIN32)
-#ifdef INCLUDEMFC
-#include <afx.h>
-#endif
-#endif
-
-#include <string.h>
-#ifndef __MWERKS__
-#include <malloc.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "vcc.h"
-
-/**** Types, Constants ****/
-
-#define YYDEBUG 1 /* 1 to compile in some debugging code */
-#define MAXTOKEN 256 /* maximum token (line) length */
-#define YYSTACKSIZE 50 /* ~unref ? */
-#define MAXLEVEL 10 /* max # of nested objects parseable */
- /* (includes outermost) */
-
-
-/**** Global Variables ****/
-int mime_lineNum, mime_numErrors; /* yyerror() can use these */
-static VObject* vObjList;
-static VObject *curProp;
-static VObject *curObj;
-static VObject* ObjStack[MAXLEVEL];
-static int ObjStackTop;
-
-
-/* A helpful utility for the rest of the app. */
-#if __CPLUSPLUS__
-extern "C" {
-#endif
-
- extern void Parse_Debug(const char *s);
- static void yyerror(char *s);
-
-#if __CPLUSPLUS__
- };
-#endif
-
-int yyparse();
-
-enum LexMode {
- L_NORMAL,
- L_VCARD,
- L_VCAL,
- L_VEVENT,
- L_VTODO,
- L_VALUES,
- L_BASE64,
- L_QUOTED_PRINTABLE
- };
-
-/**** Private Forward Declarations ****/
-static int pushVObject(const char *prop);
-static VObject* popVObject();
-static void lexPopMode(int top);
-static int lexWithinMode(enum LexMode mode);
-static void lexPushMode(enum LexMode mode);
-static void enterProps(const char *s);
-static void enterAttr(const char *s1, const char *s2);
-static void enterValues(const char *value);
-static void mime_error_(char *s);
-
-%}
-
-/***************************************************************************/
-/*** The grammar ****/
-/***************************************************************************/
-
-%union {
- char *str;
- VObject *vobj;
- }
-
-%token
- EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE
- BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL
- BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO
- ID
-
-/*
- * NEWLINE is the token that would occur outside a vCard,
- * while LINESEP is the token that would occur inside a vCard.
- */
-
-%token <str>
- STRING ID
-
-%type <str> name value
-
-%type <vobj> vcard vcal vobject
-
-%start mime
-
-%%
-
-
-mime: vobjects
- ;
-
-vobjects: vobject
- { addList(&vObjList, $1); curObj = 0; }
- vobjects
- | vobject
- { addList(&vObjList, $1); curObj = 0; }
- ;
-
-vobject: vcard
- | vcal
- ;
-
-vcard:
- BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- items END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- | BEGIN_VCARD
- {
- lexPushMode(L_VCARD);
- if (!pushVObject(VCCardProp)) YYERROR;
- }
- END_VCARD
- {
- lexPopMode(0);
- $$ = popVObject();
- }
- ;
-
-items: item items
- | item
- ;
-
-item: prop COLON
- {
- lexPushMode(L_VALUES);
- }
- values LINESEP
- {
- if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
- lexPopMode(0);
- lexPopMode(0);
- }
- | error
- ;
-
-prop: name
- {
- enterProps($1);
- }
- attr_params
- | name
- {
- enterProps($1);
- }
- ;
-
-attr_params: attr_param attr_params
- | attr_param
- ;
-
-attr_param: SEMICOLON attr
- ;
-
-attr: name
- {
- enterAttr($1,0);
- }
- | name EQ name
- {
- enterAttr($1,$3);
-
- }
- ;
-
-name: ID
- ;
-
-values: value SEMICOLON { enterValues($1); } values
- | value
- { enterValues($1); }
- ;
-
-value: STRING
- | { $$ = 0; }
- ;
-
-vcal:
- BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- calitems
- END_VCAL
- { $$ = popVObject(); }
- | BEGIN_VCAL
- { if (!pushVObject(VCCalProp)) YYERROR; }
- END_VCAL
- { $$ = popVObject(); }
- ;
-
-calitems: calitem calitems
- | calitem
- ;
-
-calitem:
- eventitem
- | todoitem
- | items
- ;
-
-eventitem:
- BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- items
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VEVENT
- {
- lexPushMode(L_VEVENT);
- if (!pushVObject(VCEventProp)) YYERROR;
- }
- END_VEVENT
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-todoitem:
- BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- items
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- | BEGIN_VTODO
- {
- lexPushMode(L_VTODO);
- if (!pushVObject(VCTodoProp)) YYERROR;
- }
- END_VTODO
- {
- lexPopMode(0);
- popVObject();
- }
- ;
-
-%%
-static int pushVObject(const char *prop)
- {
- VObject *newObj;
- if (ObjStackTop == MAXLEVEL)
- return FALSE;
-
- ObjStack[++ObjStackTop] = curObj;
-
- if (curObj) {
- newObj = addProp(curObj,prop);
- curObj = newObj;
- }
- else
- curObj = newVObject(prop);
-
- return TRUE;
- }
-
-
-/* This pops the recently built vCard off the stack and returns it. */
-static VObject* popVObject()
- {
- VObject *oldObj;
- if (ObjStackTop < 0) {
- yyerror("pop on empty Object Stack\n");
- return 0;
- }
- oldObj = curObj;
- curObj = ObjStack[ObjStackTop--];
-
- return oldObj;
- }
-
-
-static void enterValues(const char *value)
- {
- if (fieldedProp && *fieldedProp) {
- if (value) {
- addPropValue(curProp,*fieldedProp,value);
- }
- /* else this field is empty, advance to next field */
- fieldedProp++;
- }
- else {
- if (value) {
- setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
- }
- }
- deleteStr(value);
- }
-
-static void enterProps(const char *s)
- {
- curProp = addGroup(curObj,s);
- deleteStr(s);
- }
-
-static void enterAttr(const char *s1, const char *s2)
- {
- const char *p1, *p2;
- p1 = lookupProp_(s1);
- if (s2) {
- VObject *a;
- p2 = lookupProp_(s2);
- a = addProp(curProp,p1);
- setVObjectStringZValue(a,p2);
- }
- else
- addProp(curProp,p1);
- if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0))
- lexPushMode(L_BASE64);
- else if (stricmp(p1,VCQuotedPrintableProp) == 0
- || (s2 && stricmp(p2,VCQuotedPrintableProp)==0))
- lexPushMode(L_QUOTED_PRINTABLE);
- deleteStr(s1); deleteStr(s2);
- }
-
-
-#define MAX_LEX_LOOKAHEAD_0 32
-#define MAX_LEX_LOOKAHEAD 64
-#define MAX_LEX_MODE_STACK_SIZE 10
-#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
-
-struct LexBuf {
- /* input */
-#ifdef INCLUDEMFC
- CFile *inputFile;
-#else
- FILE *inputFile;
-#endif
- char *inputString;
- unsigned long curPos;
- unsigned long inputLen;
- /* lookahead buffer */
- /* -- lookahead buffer is short instead of char so that EOF
- / can be represented correctly.
- */
- unsigned long len;
- short buf[MAX_LEX_LOOKAHEAD];
- unsigned long getPtr;
- /* context stack */
- unsigned long lexModeStackTop;
- enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
- /* token buffer */
- unsigned long maxToken;
- char *strs;
- unsigned long strsLen;
- } lexBuf;
-
-static void lexPushMode(enum LexMode mode)
- {
- if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
- yyerror("lexical context stack overflow");
- else {
- lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
- }
- }
-
-static void lexPopMode(int top)
- {
- /* special case of pop for ease of error recovery -- this
- version will never underflow */
- if (top)
- lexBuf.lexModeStackTop = 0;
- else
- if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--;
- }
-
-static int lexWithinMode(enum LexMode mode) {
- unsigned long i;
- for (i=0;i<lexBuf.lexModeStackTop;i++)
- if (mode == lexBuf.lexModeStack[i]) return 1;
- return 0;
- }
-
-static char lexGetc_()
- {
- /* get next char from input, no buffering. */
- if (lexBuf.curPos == lexBuf.inputLen)
- return EOF;
- else if (lexBuf.inputString)
- return *(lexBuf.inputString + lexBuf.curPos++);
- else {
-#ifdef INCLUDEMFC
- char result;
- return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
-#else
- return fgetc(lexBuf.inputFile);
-#endif
- }
- }
-
-static int lexGeta()
- {
- ++lexBuf.len;
- return (lexBuf.buf[lexBuf.getPtr] = lexGetc_());
- }
-
-static int lexGeta_(int i)
- {
- ++lexBuf.len;
- return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
- }
-
-static void lexSkipLookahead() {
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* don't skip EOF. */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- }
-
-static int lexLookahead() {
- int c = (lexBuf.len)?
- lexBuf.buf[lexBuf.getPtr]:
- lexGeta();
- /* do the \r\n -> \n or \r -> \n translation here */
- if (c == '\r') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
- lexGeta_(1);
- if (a == '\n') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = c = '\n';
- }
- else if (c == '\n') {
- int a = (lexBuf.len>1)?
- lexBuf.buf[lexBuf.getPtr+1]:
- lexGeta_(1);
- if (a == '\r') {
- lexSkipLookahead();
- }
- lexBuf.buf[lexBuf.getPtr] = '\n';
- }
- return c;
- }
-
-static int lexGetc() {
- int c = lexLookahead();
- if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
- /* EOF will remain in lookahead buffer */
- lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
- lexBuf.len--;
- }
- return c;
- }
-
-static void lexSkipLookaheadWord() {
- if (lexBuf.strsLen <= lexBuf.len) {
- lexBuf.len -= lexBuf.strsLen;
- lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
- }
- }
-
-static void lexClearToken()
- {
- lexBuf.strsLen = 0;
- }
-
-static void lexAppendc(int c)
- {
- lexBuf.strs[lexBuf.strsLen] = c;
- /* append up to zero termination */
- if (c == 0) return;
- lexBuf.strsLen++;
- if (lexBuf.strsLen > lexBuf.maxToken) {
- /* double the token string size */
- lexBuf.maxToken <<= 1;
- lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken);
- }
- }
-
-static char* lexStr() {
- return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1);
- }
-
-static void lexSkipWhite() {
- int c = lexLookahead();
- while (c == ' ' || c == '\t') {
- lexSkipLookahead();
- c = lexLookahead();
- }
- }
-
-static char* lexGetWord() {
- int c;
- lexSkipWhite();
- lexClearToken();
- c = lexLookahead();
- while (c != EOF && !strchr("\t\n ;:=",c)) {
- lexAppendc(c);
- lexSkipLookahead();
- c = lexLookahead();
- }
- lexAppendc(0);
- return lexStr();
- }
-
-static void lexPushLookaheadc(int c) {
- int putptr;
- /* can't putback EOF, because it never leaves lookahead buffer */
- if (c == EOF) return;
- putptr = (int)lexBuf.getPtr - 1;
- if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
- lexBuf.getPtr = putptr;
- lexBuf.buf[putptr] = c;
- lexBuf.len += 1;
- }
-
-static char* lexLookaheadWord() {
- /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
- / and thing bigger than that will stop the lookahead and return 0;
- / leading white spaces are not recoverable.
- */
- int c;
- int len = 0;
- int curgetptr = 0;
- lexSkipWhite();
- lexClearToken();
- curgetptr = (int)lexBuf.getPtr; /* remember! */
- while (len < (MAX_LEX_LOOKAHEAD_0)) {
- c = lexGetc();
- len++;
- if (c == EOF || strchr("\t\n ;:=", c)) {
- lexAppendc(0);
- /* restore lookahead buf. */
- lexBuf.len += len;
- lexBuf.getPtr = curgetptr;
- return lexStr();
- }
- else
- lexAppendc(c);
- }
- lexBuf.len += len; /* char that has been moved to lookahead buffer */
- lexBuf.getPtr = curgetptr;
- return 0;
- }
-
-#ifdef _SUPPORT_LINE_FOLDING
-static void handleMoreRFC822LineBreak(int c) {
- /* suport RFC 822 line break in cases like
- * ADR: foo;
- * morefoo;
- * more foo;
- */
- if (c == ';') {
- int a;
- lexSkipLookahead();
- /* skip white spaces */
- a = lexLookahead();
- while (a == ' ' || a == '\t') {
- lexSkipLookahead();
- a = lexLookahead();
- }
- if (a == '\n') {
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- /* continuation, throw away all the \n and spaces read so
- * far
- */
- lexSkipWhite();
- lexPushLookaheadc(';');
- }
- else {
- lexPushLookaheadc('\n');
- lexPushLookaheadc(';');
- }
- }
- else {
- lexPushLookaheadc(';');
- }
- }
- }
-
-static char* lexGet1Value() {
- int c;
- lexSkipWhite();
- c = lexLookahead();
- lexClearToken();
- while (c != EOF && c != ';') {
- if (c == '\n') {
- int a;
- lexSkipLookahead();
- a = lexLookahead();
- if (a == ' ' || a == '\t') {
- lexAppendc(' ');
- lexSkipLookahead();
- }
- else {
- lexPushLookaheadc('\n');
- break;
- }
- }
- else {
- lexAppendc(c);
- lexSkipLookahead();
- }
- c = lexLookahead();
- }
- lexAppendc(0);
- handleMoreRFC822LineBreak(c);
- return c==EOF?0:lexStr();
- }
-#endif
-
-
-static int match_begin_name(int end) {
- char *n = lexLookaheadWord();
- int token = ID;
- if (n) {
- if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
- else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
- else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
- else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
- deleteStr(n);
- return token;
- }
- return 0;
- }
-
-
-#ifdef INCLUDEMFC
-void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
-#else
-void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
-#endif
- {
- /* initialize lex mode stack */
- lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
-
- /* iniatialize lex buffer. */
- lexBuf.inputString = (char*) inputstring;
- lexBuf.inputLen = inputlen;
- lexBuf.curPos = 0;
- lexBuf.inputFile = inputfile;
-
- lexBuf.len = 0;
- lexBuf.getPtr = 0;
-
- lexBuf.maxToken = MAXTOKEN;
- lexBuf.strs = (char*)malloc(MAXTOKEN);
- lexBuf.strsLen = 0;
-
- }
-
-static void finiLex() {
- free(lexBuf.strs);
- }
-
-
-/* This parses and converts the base64 format for binary encoding into
- * a decoded buffer (allocated with new). See RFC 1521.
- */
-static char * lexGetDataFromBase64()
- {
- unsigned long bytesLen = 0, bytesMax = 0;
- int quadIx = 0, pad = 0;
- unsigned long trip = 0;
- unsigned char b;
- int c;
- unsigned char *bytes = NULL;
- unsigned char *oldBytes = NULL;
-
- DBG_(("db: lexGetDataFromBase64\n"));
- while (1) {
- c = lexGetc();
- if (c == '\n') {
- ++mime_lineNum;
- if (lexLookahead() == '\n') {
- /* a '\n' character by itself means end of data */
- break;
- }
- else continue; /* ignore '\n' */
- }
- else {
- if ((c >= 'A') && (c <= 'Z'))
- b = (unsigned char)(c - 'A');
- else if ((c >= 'a') && (c <= 'z'))
- b = (unsigned char)(c - 'a') + 26;
- else if ((c >= '0') && (c <= '9'))
- b = (unsigned char)(c - '0') + 52;
- else if (c == '+')
- b = 62;
- else if (c == '/')
- b = 63;
- else if (c == '=') {
- b = 0;
- pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
- } else { /* error condition */
- if (bytes) free(bytes);
- else if (oldBytes) free(oldBytes);
- /* error recovery: skip until 2 adjacent newlines. */
- DBG_(("db: invalid character 0x%x '%c'\n", c,c));
- if (c != EOF) {
- c = lexGetc();
- while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
- }
- c = lexGetc();
- }
- }
- return NULL;
- }
- trip = (trip << 6) | b;
- if (++quadIx == 4) {
- unsigned char outBytes[3];
- int numOut;
- int i;
- for (i = 0; i < 3; i++) {
- outBytes[2-i] = (unsigned char)(trip & 0xFF);
- trip >>= 8;
- }
- numOut = 3 - pad;
- if (bytesLen + numOut > bytesMax) {
- if (!bytes) {
- bytesMax = 1024;
- bytes = (unsigned char*)malloc((size_t)bytesMax);
- }
- else {
- bytesMax <<= 2;
- oldBytes = bytes;
- bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax);
- }
- if (bytes == 0) {
- mime_error("out of memory while processing BASE64 data\n");
- }
- }
- if (bytes) {
- memcpy(bytes + bytesLen, outBytes, numOut);
- bytesLen += numOut;
- }
- trip = 0;
- quadIx = 0;
- }
- }
- } /* while */
- DBG_(("db: bytesLen = %d\n", bytesLen));
- /* kludge: all this won't be necessary if we have tree form
- representation */
- if (bytes) {
- setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
- free(bytes);
- }
- else if (oldBytes) {
- setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
- free(oldBytes);
- }
- return 0;
- }
-
-static int match_begin_end_name(int end) {
- int token;
- lexSkipWhite();
- if (lexLookahead() != ':') return ID;
- lexSkipLookahead();
- lexSkipWhite();
- token = match_begin_name(end);
- if (token == ID) {
- lexPushLookaheadc(':');
- DBG_(("db: ID '%s'\n", yylval.str));
- return ID;
- }
- else if (token != 0) {
- lexSkipLookaheadWord();
- deleteStr(yylval.str);
- DBG_(("db: begin/end %d\n", token));
- return token;
- }
- return 0;
- }
-
-static char* lexGetQuotedPrintable()
- {
- char cur;
-
- lexClearToken();
- do {
- cur = lexGetc();
- switch (cur) {
- case '=': {
- int c = 0;
- int next[2];
- int i;
- for (i = 0; i < 2; i++) {
- next[i] = lexGetc();
- if (next[i] >= '0' && next[i] <= '9')
- c = c * 16 + next[i] - '0';
- else if (next[i] >= 'A' && next[i] <= 'F')
- c = c * 16 + next[i] - 'A' + 10;
- else
- break;
- }
- if (i == 0) {
- /* single '=' follow by LINESEP is continuation sign? */
- if (next[0] == '\n') {
- ++mime_lineNum;
- }
- else {
- lexPushLookaheadc('=');
- goto EndString;
- }
- }
- else if (i == 1) {
- lexPushLookaheadc(next[1]);
- lexPushLookaheadc(next[0]);
- lexAppendc('=');
- } else {
- lexAppendc(c);
- }
- break;
- } /* '=' */
- case '\n': {
- lexPushLookaheadc('\n');
- goto EndString;
- }
- case (char)EOF:
- break;
- default:
- lexAppendc(cur);
- break;
- } /* switch */
- } while (cur != (char)EOF);
-
-EndString:
- lexAppendc(0);
- return lexStr();
- } /* LexQuotedPrintable */
-
-int yylex() {
-
- int lexmode = LEXMODE();
- if (lexmode == L_VALUES) {
- int c = lexGetc();
- if (c == ';') {
- DBG_(("db: SEMICOLON\n"));
- lexPushLookaheadc(c);
-#ifdef _SUPPORT_LINE_FOLDING
- handleMoreRFC822LineBreak(c);
-#endif
- lexSkipLookahead();
- return SEMICOLON;
- }
- else if (strchr("\n",c)) {
- ++mime_lineNum;
- /* consume all line separator(s) adjacent to each other */
- c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }
- DBG_(("db: LINESEP\n"));
- return LINESEP;
- }
- else {
- char *p = 0;
- lexPushLookaheadc(c);
- if (lexWithinMode(L_BASE64)) {
- /* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
- yylval.str = p;
- return STRING;
- }
- else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
- p = lexGetQuotedPrintable();
- }
- else {
-#ifdef _SUPPORT_LINE_FOLDING
- p = lexGet1Value();
-#else
- p = lexGetStrUntil(";\n");
-#endif
- }
- if (p) {
- DBG_(("db: STRING: '%s'\n", p));
- yylval.str = p;
- return STRING;
- }
- else return 0;
- }
- }
- else {
- /* normal mode */
- while (1) {
- int c = lexGetc();
- switch(c) {
- case ':': {
- /* consume all line separator(s) adjacent to each other */
- /* ignoring linesep immediately after colon. */
-/* c = lexLookahead();
- while (strchr("\n",c)) {
- lexSkipLookahead();
- c = lexLookahead();
- ++mime_lineNum;
- }*/
- DBG_(("db: COLON\n"));
- return COLON;
- }
- case ';':
- DBG_(("db: SEMICOLON\n"));
- return SEMICOLON;
- case '=':
- DBG_(("db: EQ\n"));
- return EQ;
- /* ignore whitespace in this mode */
- case '\t':
- case ' ': continue;
- case '\n': {
- ++mime_lineNum;
- continue;
- }
- case EOF: return 0;
- break;
- default: {
- lexPushLookaheadc(c);
- if (isalpha(c)) {
- char *t = lexGetWord();
- yylval.str = t;
- if (!stricmp(t, "begin")) {
- return match_begin_end_name(0);
- }
- else if (!stricmp(t,"end")) {
- return match_begin_end_name(1);
- }
- else {
- DBG_(("db: ID '%s'\n", t));
- return ID;
- }
- }
- else {
- /* unknow token */
- return 0;
- }
- break;
- }
- }
- }
- }
- return 0;
- }
-
-
-/***************************************************************************/
-/*** Public Functions ****/
-/***************************************************************************/
-
-static VObject* Parse_MIMEHelper()
- {
- ObjStackTop = -1;
- mime_numErrors = 0;
- mime_lineNum = 1;
- vObjList = 0;
- curObj = 0;
-
- if (yyparse() != 0)
- return 0;
-
- finiLex();
- return vObjList;
- }
-
-DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
- {
- initLex(input, len, 0);
- return Parse_MIMEHelper();
- }
-
-
-#if INCLUDEMFC
-
-DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
- {
- unsigned long startPos;
- VObject *result;
-
- initLex(0,-1,file);
- startPos = file->GetPosition();
- if (!(result = Parse_MIMEHelper()))
- file->Seek(startPos, CFile::begin);
- return result;
- }
-
-#else
-
-VObject* Parse_MIME_FromFile(FILE *file)
- {
- VObject *result;
- long startPos;
-
- initLex(0,(unsigned long)-1,file);
- startPos = ftell(file);
- if (!(result = Parse_MIMEHelper())) {
- fseek(file,startPos,SEEK_SET);
- }
- return result;
- }
-
-DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
- {
- FILE *fp = fopen(fname,"r");
- if (fp) {
- VObject* o = Parse_MIME_FromFile(fp);
- fclose(fp);
- return o;
- }
- else {
- char msg[256];
- snprintf(msg, sizeof(msg), "can't open file '%s' for reading\n", fname);
- mime_error_(msg);
- return 0;
- }
- }
-
-#endif
-
-
-static MimeErrorHandler mimeErrorHandler;
-
-DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me)
- {
- mimeErrorHandler = me;
- }
-
-static void mime_error(char *s)
- {
- char msg[256];
- if (mimeErrorHandler) {
- sprintf(msg,"%s at line %d", s, mime_lineNum);
- mimeErrorHandler(msg);
- }
- }
-
-static void mime_error_(char *s)
- {
- if (mimeErrorHandler) {
- mimeErrorHandler(s);
- }
- }
-
diff --git a/libical/src/libicalvcal/vctest.c b/libical/src/libicalvcal/vctest.c
deleted file mode 100644
index 7975d1e200..0000000000
--- a/libical/src/libicalvcal/vctest.c
+++ /dev/null
@@ -1,95 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include "vcc.h"
-
-FILE *cfp;
-
-void myMimeErrorHandler(char *s)
-{
- printf("%s\n", s);
-}
-
-void main(int argc, char **argv)
-{
- int testmem = 0;
-
- char * foo[2] = {"foo","alden.vcf"};
-
-argc = 2;
-argv = foo;
-
-#ifdef _CONSOLE
- cfp = stdout;
- registerMimeErrorHandler(myMimeErrorHandler);
-#else
- cfp = fopen("vctest.out", "w");
- if (!cfp) return;
-#endif
- ++argv;
- while (--argc) {
- FILE *fp;
- if (strcmp(*argv,"-testmem") == 0) {
- testmem = 1;
- argv++;
- continue;
- }
- fprintf(cfp,"processing %s\n",*argv);
- fp = fopen(*argv,"r");
- if (!fp) {
- fprintf(cfp,"error opening file\n");
- }
- else {
- VObject *v, *t;
- FILE *ofp;
- char buf[256];
- char *p;
- strcpy(buf,*argv);
- p = strchr(buf,'.');
- if (p) *p = 0;
- strcat(buf,".out");
- fprintf(cfp,"reading text input from '%s'...\n", *argv);
- /*v = Parse_MIME_FromFile(fp); */
- v = Parse_MIME_FromFileName(*argv);
- writeVObjectToFile(buf,v);
- cleanVObject(v);
-
- /*
- fprintf(cfp,"pretty print internal format of '%s'...\n", *argv);
- ofp = fopen(buf,"w");
- while (v) {
- printVObject(cfp,v);
- if (testmem) {
- char *s, *p;
- fprintf(cfp,"test writing to mem...\n");
- p = s = writeMemVObject(0,0,v);
- if (s) {
- while (*s) {
- fputc(*s,ofp);
- s++;
- }
- free(p);
- }
- }
- else {
- writeVObject(ofp,v);
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
- fclose(ofp);
- fclose(fp);
- */
- }
-
- cleanStrTbl();
- argv++;
-
- }
-
- if (cfp != stdout) fclose(cfp);
-
-}
-
diff --git a/libical/src/libicalvcal/vobject.c b/libical/src/libicalvcal/vobject.c
deleted file mode 100644
index d685b04278..0000000000
--- a/libical/src/libicalvcal/vobject.c
+++ /dev/null
@@ -1,1452 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
- * src: vobject.c
- * doc: vobject and APIs to construct vobject, APIs pretty print
- * vobject, and convert a vobject into its textual representation.
- */
-
-#ifndef MWERKS
-#include <malloc.h>
-#endif
-
-#include "vobject.h"
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-
-#define NAME_OF(o) o->id
-#define VALUE_TYPE(o) o->valType
-#define STRINGZ_VALUE_OF(o) o->val.strs
-#define USTRINGZ_VALUE_OF(o) o->val.ustrs
-#define INTEGER_VALUE_OF(o) o->val.i
-#define LONG_VALUE_OF(o) o->val.l
-#define ANY_VALUE_OF(o) o->val.any
-#define VOBJECT_VALUE_OF(o) o->val.vobj
-
-typedef union ValueItem {
- const char *strs;
- const wchar_t *ustrs;
- unsigned int i;
- unsigned long l;
- void *any;
- VObject *vobj;
- } ValueItem;
-
-struct VObject {
- VObject *next;
- const char *id;
- VObject *prop;
- unsigned short valType;
- ValueItem val;
- };
-
-typedef struct StrItem StrItem;
-
-struct StrItem {
- StrItem *next;
- const char *s;
- unsigned int refCnt;
- };
-
-const char** fieldedProp;
-
-
-
-/*----------------------------------------------------------------------
- The following functions involve with memory allocation:
- newVObject
- deleteVObject
- dupStr
- deleteStr
- newStrItem
- deleteStrItem
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) newVObject_(const char *id)
-{
- VObject *p = (VObject*)malloc(sizeof(VObject));
- p->next = 0;
- p->id = id;
- p->prop = 0;
- VALUE_TYPE(p) = 0;
- ANY_VALUE_OF(p) = 0;
- return p;
-}
-
-DLLEXPORT(VObject*) newVObject(const char *id)
-{
- return newVObject_(lookupStr(id));
-}
-
-DLLEXPORT(void) deleteVObject(VObject *p)
-{
- unUseStr(p->id);
- free(p);
-}
-
-DLLEXPORT(char*) dupStr(const char *s, unsigned int size)
-{
- char *t;
- if (size == 0) {
- size = strlen(s);
- }
- t = (char*)malloc(size+1);
- if (t) {
- memcpy(t,s,size);
- t[size] = 0;
- return t;
- }
- else {
- return (char*)0;
- }
-}
-
-DLLEXPORT(void) deleteStr(const char *p)
-{
- if (p) free((void*)p);
-}
-
-
-static StrItem* newStrItem(const char *s, StrItem *next)
-{
- StrItem *p = (StrItem*)malloc(sizeof(StrItem));
- p->next = next;
- p->s = s;
- p->refCnt = 1;
- return p;
-}
-
-static void deleteStrItem(StrItem *p)
-{
- free((void*)p);
-}
-
-
-/*----------------------------------------------------------------------
- The following function provide accesses to VObject's value.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(const char*) vObjectName(VObject *o)
-{
- return NAME_OF(o);
-}
-
-DLLEXPORT(void) setVObjectName(VObject *o, const char* id)
-{
- NAME_OF(o) = id;
-}
-
-DLLEXPORT(const char*) vObjectStringZValue(VObject *o)
-{
- return STRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = dupStr(s,0);
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s)
-{
- STRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_STRINGZ;
-}
-
-DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o)
-{
- return USTRINGZ_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = (wchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2);
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s)
-{
- USTRINGZ_VALUE_OF(o) = s;
- VALUE_TYPE(o) = VCVT_USTRINGZ;
-}
-
-DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o)
-{
- return INTEGER_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i)
-{
- INTEGER_VALUE_OF(o) = i;
- VALUE_TYPE(o) = VCVT_UINT;
-}
-
-DLLEXPORT(unsigned long) vObjectLongValue(VObject *o)
-{
- return LONG_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l)
-{
- LONG_VALUE_OF(o) = l;
- VALUE_TYPE(o) = VCVT_ULONG;
-}
-
-DLLEXPORT(void*) vObjectAnyValue(VObject *o)
-{
- return ANY_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t)
-{
- ANY_VALUE_OF(o) = t;
- VALUE_TYPE(o) = VCVT_RAW;
-}
-
-DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o)
-{
- return VOBJECT_VALUE_OF(o);
-}
-
-DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p)
-{
- VOBJECT_VALUE_OF(o) = p;
- VALUE_TYPE(o) = VCVT_VOBJECT;
-}
-
-DLLEXPORT(int) vObjectValueType(VObject *o)
-{
- return VALUE_TYPE(o);
-}
-
-
-/*----------------------------------------------------------------------
- The following functions can be used to build VObject.
- ----------------------------------------------------------------------*/
-
-DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p)
-{
- /* circular link list pointed to tail */
- /*
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- ...
- p1 {next,id,prop,val}
- V
- pn
- -->
- o {next,id,prop,val}
- V
- pn {next,id,prop,val}
- V
- p {next,id,prop,val}
- ...
- p1 {next,id,prop,val}
- V
- pn
- */
-
- VObject *tail = o->prop;
- if (tail) {
- p->next = tail->next;
- o->prop = tail->next = p;
- }
- else {
- o->prop = p->next = p;
- }
- return p;
-}
-
-DLLEXPORT(VObject*) addProp(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject(id));
-}
-
-DLLEXPORT(VObject*) addProp_(VObject *o, const char *id)
-{
- return addVObjectProp(o,newVObject_(id));
-}
-
-DLLEXPORT(void) addList(VObject **o, VObject *p)
-{
- p->next = 0;
- if (*o == 0) {
- *o = p;
- }
- else {
- VObject *t = *o;
- while (t->next) {
- t = t->next;
- }
- t->next = p;
- }
-}
-
-DLLEXPORT(VObject*) nextVObjectInList(VObject *o)
-{
- return o->next;
-}
-
-DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size)
-{
- VObject *sizeProp;
- setVObjectAnyValue(prop, val);
- sizeProp = addProp(prop,VCDataSizeProp);
- setVObjectLongValue(sizeProp, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size)
-{
- void *p = dupStr((const char *)val,size);
- return setValueWithSize_(prop,p,p?size:0);
-}
-
-DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->prop;
- i->next = 0;
-}
-
-DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o)
-{
- i->start = o->next;
- i->next = 0;
-}
-
-DLLEXPORT(int) moreIteration(VObjectIterator *i)
-{
- return (i->start && (i->next==0 || i->next!=i->start));
-}
-
-DLLEXPORT(VObject*) nextVObject(VObjectIterator *i)
-{
- if (i->start && i->next != i->start) {
- if (i->next == 0) {
- i->next = i->start->next;
- return i->next;
- }
- else {
- i->next = i->next->next;
- return i->next;
- }
- }
- else return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id)
-{
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- if (!stricmp(id,each->id))
- return each;
- }
- return (VObject*)0;
-}
-
-DLLEXPORT(VObject*) addGroup(VObject *o, const char *g)
-{
- /*
- a.b.c
- -->
- prop(c)
- prop(VCGrouping=b)
- prop(VCGrouping=a)
- */
- char *dot = strrchr(g,'.');
- if (dot) {
- VObject *p, *t;
- char *gs, *n = dot+1;
- gs = dupStr(g,0); /* so we can write to it. */
- /* used to be
- * t = p = addProp_(o,lookupProp_(n));
- */
- t = p = addProp_(o,lookupProp(n));
- dot = strrchr(gs,'.');
- *dot = 0;
- do {
- dot = strrchr(gs,'.');
- if (dot) {
- n = dot+1;
- *dot=0;
- }
- else
- n = gs;
- /* property(VCGroupingProp=n);
- * and the value may have VCGrouping property
- */
- t = addProp(t,VCGroupingProp);
- setVObjectStringZValue(t,lookupProp_(n));
- } while (n != gs);
- deleteStr(gs);
- return p;
- }
- else
- return addProp_(o,lookupProp(g));
-}
-
-DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v)
-{
- VObject *prop;
- prop = addProp(o,p);
- setVObjectUStringZValue_(prop, fakeUnicode(v,0));
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- VObject *prop;
- prop = addProp(o,p);
- setValueWithSize_(prop, (void*)v, size);
- return prop;
-}
-
-DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v,
- unsigned int size)
-{
- return addPropSizedValue_(o,p,dupStr(v,size),size);
-}
-
-
-
-/*----------------------------------------------------------------------
- The following pretty print a VObject
- ----------------------------------------------------------------------*/
-
-static void printVObject_(FILE *fp, VObject *o, int level);
-
-static void indent(FILE *fp, int level)
-{
- int i;
- for (i=0;i<level*4;i++) {
- fputc(' ', fp);
- }
-}
-
-static void printValue(FILE *fp, VObject *o, int level)
-{
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char c;
- char *t,*s;
- s = t = fakeCString(USTRINGZ_VALUE_OF(o));
- fputc('"',fp);
- while (c=*t,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- t++;
- }
- fputc('"',fp);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- char c;
- const char *s = STRINGZ_VALUE_OF(o);
- fputc('"',fp);
- while (c=*s,c) {
- fputc(c,fp);
- if (c == '\n') indent(fp,level+2);
- s++;
- }
- fputc('"',fp);
- break;
- }
- case VCVT_UINT:
- fprintf(fp,"%d", INTEGER_VALUE_OF(o)); break;
- case VCVT_ULONG:
- fprintf(fp,"%ld", LONG_VALUE_OF(o)); break;
- case VCVT_RAW:
- fprintf(fp,"[raw data]"); break;
- case VCVT_VOBJECT:
- fprintf(fp,"[vobject]\n");
- printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
- break;
- case 0:
- fprintf(fp,"[none]"); break;
- default:
- fprintf(fp,"[unknown]"); break;
- }
-}
-
-static void printNameValue(FILE *fp,VObject *o, int level)
-{
- indent(fp,level);
- if (NAME_OF(o)) {
- fprintf(fp,"%s", NAME_OF(o));
- }
- if (VALUE_TYPE(o)) {
- fputc('=',fp);
- printValue(fp,o, level);
- }
- fprintf(fp,"\n");
-}
-
-static void printVObject_(FILE *fp, VObject *o, int level)
- {
- VObjectIterator t;
- if (o == 0) {
- fprintf(fp,"[NULL]\n");
- return;
- }
- printNameValue(fp,o,level);
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- printVObject_(fp,eachProp,level+1);
- }
- }
-
-void printVObject(FILE *fp,VObject *o)
-{
- printVObject_(fp,o,0);
-}
-
-DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- printVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- printVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) cleanVObject(VObject *o)
-{
- if (o == 0) return;
- if (o->prop) {
- /* destroy time: cannot use the iterator here.
- Have to break the cycle in the circular link
- list and turns it into regular NULL-terminated
- list -- since at some point of destruction,
- the reference entry for the iterator to work
- will not longer be valid.
- */
- VObject *p;
- p = o->prop->next;
- o->prop->next = 0;
- do {
- VObject *t = p->next;
- cleanVObject(p);
- p = t;
- } while (p);
- }
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ:
- case VCVT_STRINGZ:
- case VCVT_RAW:
- /* assume they are all allocated by malloc. */
- free((char*)STRINGZ_VALUE_OF(o));
- break;
- case VCVT_VOBJECT:
- cleanVObject(VOBJECT_VALUE_OF(o));
- break;
- }
- deleteVObject(o);
-}
-
-DLLEXPORT(void) cleanVObjects(VObject *list)
-{
- while (list) {
- VObject *t = list;
- list = nextVObjectInList(list);
- cleanVObject(t);
- }
-}
-
-/*----------------------------------------------------------------------
- The following is a String Table Facilities.
- ----------------------------------------------------------------------*/
-
-#define STRTBLSIZE 255
-
-static StrItem *strTbl[STRTBLSIZE];
-
-static unsigned int hashStr(const char *s)
-{
- unsigned int h = 0;
- int i;
- for (i=0;s[i];i++) {
- h += s[i]*i;
- }
- return h % STRTBLSIZE;
-}
-
-DLLEXPORT(const char*) lookupStr(const char *s)
-{
- StrItem *t;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt++;
- return t->s;
- }
- t = t->next;
- } while (t);
- }
- s = dupStr(s,0);
- strTbl[h] = newStrItem(s,strTbl[h]);
- return s;
-}
-
-DLLEXPORT(void) unUseStr(const char *s)
-{
- StrItem *t, *p;
- unsigned int h = hashStr(s);
- if ((t = strTbl[h]) != 0) {
- p = t;
- do {
- if (stricmp(t->s,s) == 0) {
- t->refCnt--;
- if (t->refCnt == 0) {
- if (p == strTbl[h]) {
- strTbl[h] = t->next;
- }
- else {
- p->next = t->next;
- }
- deleteStr(t->s);
- deleteStrItem(t);
- return;
- }
- }
- p = t;
- t = t->next;
- } while (t);
- }
-}
-
-DLLEXPORT(void) cleanStrTbl()
-{
- int i;
- for (i=0; i<STRTBLSIZE;i++) {
- StrItem *t = strTbl[i];
- while (t) {
- StrItem *p;
- deleteStr(t->s);
- p = t;
- t = t->next;
- deleteStrItem(p);
- } while (t);
- strTbl[i] = 0;
- }
-}
-
-
-struct PreDefProp {
- const char *name;
- const char *alias;
- const char** fields;
- unsigned int flags;
- };
-
-/* flags in PreDefProp */
-#define PD_BEGIN 0x1
-#define PD_INTERNAL 0x2
-
-static const char *adrFields[] = {
- VCPostalBoxProp,
- VCExtAddressProp,
- VCStreetAddressProp,
- VCCityProp,
- VCRegionProp,
- VCPostalCodeProp,
- VCCountryNameProp,
- 0
-};
-
-static const char *nameFields[] = {
- VCFamilyNameProp,
- VCGivenNameProp,
- VCAdditionalNamesProp,
- VCNamePrefixesProp,
- VCNameSuffixesProp,
- NULL
- };
-
-static const char *orgFields[] = {
- VCOrgNameProp,
- VCOrgUnitProp,
- VCOrgUnit2Prop,
- VCOrgUnit3Prop,
- VCOrgUnit4Prop,
- NULL
- };
-
-static const char *AAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCAudioContentProp,
- 0
- };
-
-/* ExDate -- has unamed fields */
-/* RDate -- has unamed fields */
-
-static const char *DAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCDisplayStringProp,
- 0
- };
-
-static const char *MAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCEmailAddressProp,
- VCNoteProp,
- 0
- };
-
-static const char *PAlarmFields[] = {
- VCRunTimeProp,
- VCSnoozeTimeProp,
- VCRepeatCountProp,
- VCProcedureNameProp,
- 0
- };
-
-static struct PreDefProp propNames[] = {
- { VC7bitProp, 0, 0, 0 },
- { VC8bitProp, 0, 0, 0 },
- { VCAAlarmProp, 0, AAlarmFields, 0 },
- { VCAdditionalNamesProp, 0, 0, 0 },
- { VCAdrProp, 0, adrFields, 0 },
- { VCAgentProp, 0, 0, 0 },
- { VCAIFFProp, 0, 0, 0 },
- { VCAOLProp, 0, 0, 0 },
- { VCAppleLinkProp, 0, 0, 0 },
- { VCAttachProp, 0, 0, 0 },
- { VCAttendeeProp, 0, 0, 0 },
- { VCATTMailProp, 0, 0, 0 },
- { VCAudioContentProp, 0, 0, 0 },
- { VCAVIProp, 0, 0, 0 },
- { VCBase64Prop, 0, 0, 0 },
- { VCBBSProp, 0, 0, 0 },
- { VCBirthDateProp, 0, 0, 0 },
- { VCBMPProp, 0, 0, 0 },
- { VCBodyProp, 0, 0, 0 },
- { VCBusinessRoleProp, 0, 0, 0 },
- { VCCalProp, 0, 0, PD_BEGIN },
- { VCCaptionProp, 0, 0, 0 },
- { VCCardProp, 0, 0, PD_BEGIN },
- { VCCarProp, 0, 0, 0 },
- { VCCategoriesProp, 0, 0, 0 },
- { VCCellularProp, 0, 0, 0 },
- { VCCGMProp, 0, 0, 0 },
- { VCCharSetProp, 0, 0, 0 },
- { VCCIDProp, VCContentIDProp, 0, 0 },
- { VCCISProp, 0, 0, 0 },
- { VCCityProp, 0, 0, 0 },
- { VCClassProp, 0, 0, 0 },
- { VCCommentProp, 0, 0, 0 },
- { VCCompletedProp, 0, 0, 0 },
- { VCContentIDProp, 0, 0, 0 },
- { VCCountryNameProp, 0, 0, 0 },
- { VCDAlarmProp, 0, DAlarmFields, 0 },
- { VCDataSizeProp, 0, 0, PD_INTERNAL },
- { VCDayLightProp, 0, 0, 0 },
- { VCDCreatedProp, 0, 0, 0 },
- { VCDeliveryLabelProp, 0, 0, 0 },
- { VCDescriptionProp, 0, 0, 0 },
- { VCDIBProp, 0, 0, 0 },
- { VCDisplayStringProp, 0, 0, 0 },
- { VCDomesticProp, 0, 0, 0 },
- { VCDTendProp, 0, 0, 0 },
- { VCDTstartProp, 0, 0, 0 },
- { VCDueProp, 0, 0, 0 },
- { VCEmailAddressProp, 0, 0, 0 },
- { VCEncodingProp, 0, 0, 0 },
- { VCEndProp, 0, 0, 0 },
- { VCEventProp, 0, 0, PD_BEGIN },
- { VCEWorldProp, 0, 0, 0 },
- { VCExNumProp, 0, 0, 0 },
- { VCExpDateProp, 0, 0, 0 },
- { VCExpectProp, 0, 0, 0 },
- { VCExtAddressProp, 0, 0, 0 },
- { VCFamilyNameProp, 0, 0, 0 },
- { VCFaxProp, 0, 0, 0 },
- { VCFullNameProp, 0, 0, 0 },
- { VCGeoLocationProp, 0, 0, 0 },
- { VCGeoProp, 0, 0, 0 },
- { VCGIFProp, 0, 0, 0 },
- { VCGivenNameProp, 0, 0, 0 },
- { VCGroupingProp, 0, 0, 0 },
- { VCHomeProp, 0, 0, 0 },
- { VCIBMMailProp, 0, 0, 0 },
- { VCInlineProp, 0, 0, 0 },
- { VCInternationalProp, 0, 0, 0 },
- { VCInternetProp, 0, 0, 0 },
- { VCISDNProp, 0, 0, 0 },
- { VCJPEGProp, 0, 0, 0 },
- { VCLanguageProp, 0, 0, 0 },
- { VCLastModifiedProp, 0, 0, 0 },
- { VCLastRevisedProp, 0, 0, 0 },
- { VCLocationProp, 0, 0, 0 },
- { VCLogoProp, 0, 0, 0 },
- { VCMailerProp, 0, 0, 0 },
- { VCMAlarmProp, 0, MAlarmFields, 0 },
- { VCMCIMailProp, 0, 0, 0 },
- { VCMessageProp, 0, 0, 0 },
- { VCMETProp, 0, 0, 0 },
- { VCModemProp, 0, 0, 0 },
- { VCMPEG2Prop, 0, 0, 0 },
- { VCMPEGProp, 0, 0, 0 },
- { VCMSNProp, 0, 0, 0 },
- { VCNamePrefixesProp, 0, 0, 0 },
- { VCNameProp, 0, nameFields, 0 },
- { VCNameSuffixesProp, 0, 0, 0 },
- { VCNoteProp, 0, 0, 0 },
- { VCOrgNameProp, 0, 0, 0 },
- { VCOrgProp, 0, orgFields, 0 },
- { VCOrgUnit2Prop, 0, 0, 0 },
- { VCOrgUnit3Prop, 0, 0, 0 },
- { VCOrgUnit4Prop, 0, 0, 0 },
- { VCOrgUnitProp, 0, 0, 0 },
- { VCPagerProp, 0, 0, 0 },
- { VCPAlarmProp, 0, PAlarmFields, 0 },
- { VCParcelProp, 0, 0, 0 },
- { VCPartProp, 0, 0, 0 },
- { VCPCMProp, 0, 0, 0 },
- { VCPDFProp, 0, 0, 0 },
- { VCPGPProp, 0, 0, 0 },
- { VCPhotoProp, 0, 0, 0 },
- { VCPICTProp, 0, 0, 0 },
- { VCPMBProp, 0, 0, 0 },
- { VCPostalBoxProp, 0, 0, 0 },
- { VCPostalCodeProp, 0, 0, 0 },
- { VCPostalProp, 0, 0, 0 },
- { VCPowerShareProp, 0, 0, 0 },
- { VCPreferredProp, 0, 0, 0 },
- { VCPriorityProp, 0, 0, 0 },
- { VCProcedureNameProp, 0, 0, 0 },
- { VCProdIdProp, 0, 0, 0 },
- { VCProdigyProp, 0, 0, 0 },
- { VCPronunciationProp, 0, 0, 0 },
- { VCPSProp, 0, 0, 0 },
- { VCPublicKeyProp, 0, 0, 0 },
- { VCQPProp, VCQuotedPrintableProp, 0, 0 },
- { VCQuickTimeProp, 0, 0, 0 },
- { VCQuotedPrintableProp, 0, 0, 0 },
- { VCRDateProp, 0, 0, 0 },
- { VCRegionProp, 0, 0, 0 },
- { VCRelatedToProp, 0, 0, 0 },
- { VCRepeatCountProp, 0, 0, 0 },
- { VCResourcesProp, 0, 0, 0 },
- { VCRNumProp, 0, 0, 0 },
- { VCRoleProp, 0, 0, 0 },
- { VCRRuleProp, 0, 0, 0 },
- { VCRSVPProp, 0, 0, 0 },
- { VCRunTimeProp, 0, 0, 0 },
- { VCSequenceProp, 0, 0, 0 },
- { VCSnoozeTimeProp, 0, 0, 0 },
- { VCStartProp, 0, 0, 0 },
- { VCStatusProp, 0, 0, 0 },
- { VCStreetAddressProp, 0, 0, 0 },
- { VCSubTypeProp, 0, 0, 0 },
- { VCSummaryProp, 0, 0, 0 },
- { VCTelephoneProp, 0, 0, 0 },
- { VCTIFFProp, 0, 0, 0 },
- { VCTimeZoneProp, 0, 0, 0 },
- { VCTitleProp, 0, 0, 0 },
- { VCTLXProp, 0, 0, 0 },
- { VCTodoProp, 0, 0, PD_BEGIN },
- { VCTranspProp, 0, 0, 0 },
- { VCUniqueStringProp, 0, 0, 0 },
- { VCURLProp, 0, 0, 0 },
- { VCURLValueProp, 0, 0, 0 },
- { VCValueProp, 0, 0, 0 },
- { VCVersionProp, 0, 0, 0 },
- { VCVideoProp, 0, 0, 0 },
- { VCVoiceProp, 0, 0, 0 },
- { VCWAVEProp, 0, 0, 0 },
- { VCWMFProp, 0, 0, 0 },
- { VCWorkProp, 0, 0, 0 },
- { VCX400Prop, 0, 0, 0 },
- { VCX509Prop, 0, 0, 0 },
- { VCXRuleProp, 0, 0, 0 },
- { 0,0,0,0 }
- };
-
-
-static struct PreDefProp* lookupPropInfo(const char* str)
-{
- /* brute force for now, could use a hash table here. */
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- return &propNames[i];
- }
-
- return 0;
-}
-
-
-DLLEXPORT(const char*) lookupProp_(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char* s;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- return lookupStr(str);
-}
-
-
-DLLEXPORT(const char*) lookupProp(const char* str)
-{
- int i;
-
- for (i = 0; propNames[i].name; i++)
- if (stricmp(str, propNames[i].name) == 0) {
- const char *s;
- fieldedProp = propNames[i].fields;
- s = propNames[i].alias?propNames[i].alias:propNames[i].name;
- return lookupStr(s);
- }
- fieldedProp = 0;
- return lookupStr(str);
-}
-
-
-/*----------------------------------------------------------------------
- APIs to Output text form.
- ----------------------------------------------------------------------*/
-#define OFILE_REALLOC_SIZE 256
-typedef struct OFile {
- FILE *fp;
- char *s;
- int len;
- int limit;
- int alloc:1;
- int fail:1;
- } OFile;
-
-#if 0
-static void appendsOFile(OFile *fp, const char *s)
-{
- int slen;
- if (fp->fail) return;
- slen = strlen(s);
- if (fp->fp) {
- fwrite(s,1,slen,fp->fp);
- }
- else {
-stuff:
- if (fp->len + slen < fp->limit) {
- memcpy(fp->s+fp->len,s,slen);
- fp->len += slen;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = (char *) realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-#else
-static void appendcOFile_(OFile *fp, char c)
-{
- if (fp->fail) return;
- if (fp->fp) {
- fputc(c,fp->fp);
- }
- else {
-stuff:
- if (fp->len+1 < fp->limit) {
- fp->s[fp->len] = c;
- fp->len++;
- return;
- }
- else if (fp->alloc) {
- fp->limit = fp->limit + OFILE_REALLOC_SIZE;
- fp->s = realloc(fp->s,fp->limit);
- if (fp->s) goto stuff;
- }
- if (fp->alloc)
- free(fp->s);
- fp->s = 0;
- fp->fail = 1;
- }
-}
-
-static void appendcOFile(OFile *fp, char c)
-{
- if (c == '\n') {
- /* write out as <CR><LF> */
- appendcOFile_(fp,0xd);
- appendcOFile_(fp,0xa);
- }
- else
- appendcOFile_(fp,c);
-}
-
-static void appendsOFile(OFile *fp, const char *s)
-{
- int i, slen;
- slen = strlen(s);
- for (i=0; i<slen; i++) {
- appendcOFile(fp,s[i]);
- }
-}
-
-#endif
-
-static void initOFile(OFile *fp, FILE *ofp)
-{
- fp->fp = ofp;
- fp->s = 0;
- fp->len = 0;
- fp->limit = 0;
- fp->alloc = 0;
- fp->fail = 0;
-}
-
-static void initMemOFile(OFile *fp, char *s, int len)
-{
- fp->fp = 0;
- fp->s = s;
- fp->len = 0;
- fp->limit = s?len:0;
- fp->alloc = s?0:1;
- fp->fail = 0;
-}
-
-
-static int writeBase64(OFile *fp, unsigned char *s, long len)
-{
- long cur = 0;
- int i, numQuads = 0;
- unsigned long trip;
- unsigned char b;
- char quad[5];
-#define MAXQUADS 16
-
- quad[4] = 0;
-
- while (cur < len) {
- /* collect the triplet of bytes into 'trip' */
- trip = 0;
- for (i = 0; i < 3; i++) {
- b = (cur < len) ? *(s + cur) : 0;
- cur++;
- trip = trip << 8 | b;
- }
- /* fill in 'quad' with the appropriate four characters */
- for (i = 3; i >= 0; i--) {
- b = (unsigned char)(trip & 0x3F);
- trip = trip >> 6;
- if ((3 - i) < (cur - len))
- quad[i] = '='; /* pad char */
- else if (b < 26) quad[i] = (char)b + 'A';
- else if (b < 52) quad[i] = (char)(b - 26) + 'a';
- else if (b < 62) quad[i] = (char)(b - 52) + '0';
- else if (b == 62) quad[i] = '+';
- else quad[i] = '/';
- }
- /* now output 'quad' with appropriate whitespace and line ending */
- appendsOFile(fp, (numQuads == 0 ? " " : ""));
- appendsOFile(fp, quad);
- appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
- numQuads = (numQuads + 1) % MAXQUADS;
- }
- appendcOFile(fp,'\n');
-
- return 1;
-}
-
-static void writeString(OFile *fp, const char *s)
-{
- appendsOFile(fp,s);
-}
-
-static void writeQPString(OFile *fp, const char *s)
-{
- char buf[4];
- int count=0;
- const char *p = s;
-
- while (*p) {
- /* break up lines biggger than 75 chars */
- if(count >=74){
- count=0;
- appendsOFile(fp,"=\n");
- }
-
- /* escape any non ASCII characters and '=' as per rfc1521 */
- if (*p<= 0x1f || *p >=0x7f || *p == '=' ) {
- sprintf(buf,"=%02X",(unsigned char)*p);
- appendsOFile(fp,buf);
- count+=3;
- } else {
- appendcOFile(fp,*p);
- count++;
- }
- p++;
- }
-}
-
-
-
-static void writeVObject_(OFile *fp, VObject *o);
-
-static void writeValue(OFile *fp, VObject *o, unsigned long size,int quote)
-{
- if (o == 0) return;
- switch (VALUE_TYPE(o)) {
- case VCVT_USTRINGZ: {
- char *s = fakeCString(USTRINGZ_VALUE_OF(o));
- if(quote) writeQPString(fp, s);
- else writeString(fp,s);
- deleteStr(s);
- break;
- }
- case VCVT_STRINGZ: {
- if(quote) writeQPString(fp, STRINGZ_VALUE_OF(o));
- else writeString(fp,STRINGZ_VALUE_OF(o));
- break;
- }
- case VCVT_UINT: {
- char buf[16];
- sprintf(buf,"%u", INTEGER_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_ULONG: {
- char buf[16];
- sprintf(buf,"%lu", LONG_VALUE_OF(o));
- appendsOFile(fp,buf);
- break;
- }
- case VCVT_RAW: {
- appendcOFile(fp,'\n');
- writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
- break;
- }
- case VCVT_VOBJECT:
- appendcOFile(fp,'\n');
- writeVObject_(fp,VOBJECT_VALUE_OF(o));
- break;
- }
-}
-
-static void writeAttrValue(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
- appendcOFile(fp,';');
- appendsOFile(fp,NAME_OF(o));
- }
- else
- appendcOFile(fp,';');
- if (VALUE_TYPE(o)) {
- appendcOFile(fp,'=');
- writeValue(fp,o,0,0);
- }
-}
-
-static void writeGroup(OFile *fp, VObject *o)
-{
- char buf1[256];
- char buf2[256];
- strcpy(buf1,NAME_OF(o));
- while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
- strcpy(buf2,STRINGZ_VALUE_OF(o));
- strcat(buf2,".");
- strcat(buf2,buf1);
- strcpy(buf1,buf2);
- }
- appendsOFile(fp,buf1);
-}
-
-static int inList(const char **list, const char *s)
-{
- if (list == 0) return 0;
- while (*list) {
- if (stricmp(*list,s) == 0) return 1;
- list++;
- }
- return 0;
-}
-
-static void writeProp(OFile *fp, VObject *o)
-{
- int isQuoted=0;
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- VObjectIterator t;
- const char **fields_ = 0;
- pi = lookupPropInfo(NAME_OF(o));
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- writeVObject_(fp,o);
- return;
- }
- if (isAPropertyOf(o,VCGroupingProp))
- writeGroup(fp,o);
- else
- appendsOFile(fp,NAME_OF(o));
- if (pi) fields_ = pi->fields;
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- const char *s;
- VObject *eachProp = nextVObject(&t);
- s = NAME_OF(eachProp);
- if (stricmp(VCGroupingProp,s) && !inList(fields_,s))
- writeAttrValue(fp,eachProp);
- if (stricmp(VCQPProp,s)==0 || stricmp(VCQuotedPrintableProp,s)==0)
- isQuoted=1;
- }
- if (fields_) {
- int i = 0, n = 0;
- const char** fields = fields_;
- /* output prop as fields */
- appendcOFile(fp,':');
- while (*fields) {
- VObject *t = isAPropertyOf(o,*fields);
- i++;
- if (t) n = i;
- fields++;
- }
- fields = fields_;
- for (i=0;i<n;i++) {
- writeValue(fp,isAPropertyOf(o,*fields),0,isQuoted);
- fields++;
- if (i<(n-1)) appendcOFile(fp,';');
- }
- }
- }
-
- if (VALUE_TYPE(o)) {
- unsigned long size = 0;
- VObject *p = isAPropertyOf(o,VCDataSizeProp);
- if (p) size = LONG_VALUE_OF(p);
- appendcOFile(fp,':');
- writeValue(fp,o,size,isQuoted);
- }
-
- appendcOFile(fp,'\n');
-}
-
-static void writeVObject_(OFile *fp, VObject *o)
-{
- if (NAME_OF(o)) {
- struct PreDefProp *pi;
- pi = lookupPropInfo(NAME_OF(o));
-
- if (pi && ((pi->flags & PD_BEGIN) != 0)) {
- VObjectIterator t;
- const char *begin = NAME_OF(o);
- appendsOFile(fp,"BEGIN:");
- appendsOFile(fp,begin);
- appendcOFile(fp,'\n');
- initPropIterator(&t,o);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- writeProp(fp, eachProp);
- }
- appendsOFile(fp,"END:");
- appendsOFile(fp,begin);
- appendsOFile(fp,"\n\n");
- }
- }
-}
-
-void writeVObject(FILE *fp, VObject *o)
-{
- OFile ofp;
- initOFile(&ofp,fp);
- writeVObject_(&ofp,o);
-}
-
-DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- writeVObject(fp,o);
- fclose(fp);
- }
-}
-
-DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
-{
- FILE *fp = fopen(fname,"w");
- if (fp) {
- while (list) {
- writeVObject(fp,list);
- list = nextVObjectInList(list);
- }
- fclose(fp);
- }
-}
-
-DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- writeVObject_(&ofp,o);
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list)
-{
- OFile ofp;
- initMemOFile(&ofp,s,len?*len:0);
- while (list) {
- writeVObject_(&ofp,list);
- list = nextVObjectInList(list);
- }
- if (len) *len = ofp.len;
- appendcOFile(&ofp,0);
- return ofp.s;
-}
-
-/*----------------------------------------------------------------------
- APIs to do fake Unicode stuff.
- ----------------------------------------------------------------------*/
-DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes)
-{
- wchar_t *r, *pw;
- int len = strlen(ps)+1;
-
- pw = r = (wchar_t*)malloc(sizeof(wchar_t)*len);
- if (bytes)
- *bytes = len * sizeof(wchar_t);
-
- while (*ps) {
- if (*ps == '\n')
- *pw = (wchar_t)0x2028;
- else if (*ps == '\r')
- *pw = (wchar_t)0x2029;
- else
- *pw = (wchar_t)(unsigned char)*ps;
- ps++; pw++;
- }
- *pw = (wchar_t)0;
-
- return r;
-}
-
-DLLEXPORT(int) uStrLen(const wchar_t *u)
-{
- int i = 0;
- while (*u != (wchar_t)0) { u++; i++; }
- return i;
-}
-
-DLLEXPORT(char*) fakeCString(const wchar_t *u)
-{
- char *s, *t;
- int len = uStrLen(u) + 1;
- t = s = (char*)malloc(len);
- while (*u) {
- if (*u == (wchar_t)0x2028)
- *t = '\n';
- else if (*u == (wchar_t)0x2029)
- *t = '\r';
- else
- *t = (char)*u;
- u++; t++;
- }
- *t = 0;
- return s;
-}
-
-/* end of source file vobject.c */
diff --git a/libical/src/libicalvcal/vobject.h b/libical/src/libicalvcal/vobject.h
deleted file mode 100644
index bc31dc8297..0000000000
--- a/libical/src/libicalvcal/vobject.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.
-
-The software is provided with RESTRICTED RIGHTS. Use, duplication, or
-disclosure by the government are subject to restrictions set forth in
-DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-
-***************************************************************************/
-
-/*
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
-For more information on this API see the readme.txt file
-which accompanied this distribution.
-
- Also visit:
-
- http://www.versit.com
- http://www.ralden.com
-
-*/
-
-
-#ifndef __VOBJECT_H__
-#define __VOBJECT_H__ 1
-
-
-#include "port.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-extern "C" {
-#endif
-
-
-#define VC7bitProp "7BIT"
-#define VC8bitProp "8BIT"
-#define VCAAlarmProp "AALARM"
-#define VCAdditionalNamesProp "ADDN"
-#define VCAdrProp "ADR"
-#define VCAgentProp "AGENT"
-#define VCAIFFProp "AIFF"
-#define VCAOLProp "AOL"
-#define VCAppleLinkProp "APPLELINK"
-#define VCAttachProp "ATTACH"
-#define VCAttendeeProp "ATTENDEE"
-#define VCATTMailProp "ATTMAIL"
-#define VCAudioContentProp "AUDIOCONTENT"
-#define VCAVIProp "AVI"
-#define VCBase64Prop "BASE64"
-#define VCBBSProp "BBS"
-#define VCBirthDateProp "BDAY"
-#define VCBMPProp "BMP"
-#define VCBodyProp "BODY"
-#define VCBusinessRoleProp "ROLE"
-#define VCCalProp "VCALENDAR"
-#define VCCaptionProp "CAP"
-#define VCCardProp "VCARD"
-#define VCCarProp "CAR"
-#define VCCategoriesProp "CATEGORIES"
-#define VCCellularProp "CELL"
-#define VCCGMProp "CGM"
-#define VCCharSetProp "CS"
-#define VCCIDProp "CID"
-#define VCCISProp "CIS"
-#define VCCityProp "L"
-#define VCClassProp "CLASS"
-#define VCCommentProp "NOTE"
-#define VCCompletedProp "COMPLETED"
-#define VCContentIDProp "CONTENT-ID"
-#define VCCountryNameProp "C"
-#define VCDAlarmProp "DALARM"
-#define VCDataSizeProp "DATASIZE"
-#define VCDayLightProp "DAYLIGHT"
-#define VCDCreatedProp "DCREATED"
-#define VCDeliveryLabelProp "LABEL"
-#define VCDescriptionProp "DESCRIPTION"
-#define VCDIBProp "DIB"
-#define VCDisplayStringProp "DISPLAYSTRING"
-#define VCDomesticProp "DOM"
-#define VCDTendProp "DTEND"
-#define VCDTstartProp "DTSTART"
-#define VCDueProp "DUE"
-#define VCEmailAddressProp "EMAIL"
-#define VCEncodingProp "ENCODING"
-#define VCEndProp "END"
-#define VCEventProp "VEVENT"
-#define VCEWorldProp "EWORLD"
-#define VCExNumProp "EXNUM"
-#define VCExpDateProp "EXDATE"
-#define VCExpectProp "EXPECT"
-#define VCExtAddressProp "EXT ADD"
-#define VCFamilyNameProp "F"
-#define VCFaxProp "FAX"
-#define VCFullNameProp "FN"
-#define VCGeoProp "GEO"
-#define VCGeoLocationProp "GEO"
-#define VCGIFProp "GIF"
-#define VCGivenNameProp "G"
-#define VCGroupingProp "Grouping"
-#define VCHomeProp "HOME"
-#define VCIBMMailProp "IBMMail"
-#define VCInlineProp "INLINE"
-#define VCInternationalProp "INTL"
-#define VCInternetProp "INTERNET"
-#define VCISDNProp "ISDN"
-#define VCJPEGProp "JPEG"
-#define VCLanguageProp "LANG"
-#define VCLastModifiedProp "LAST-MODIFIED"
-#define VCLastRevisedProp "REV"
-#define VCLocationProp "LOCATION"
-#define VCLogoProp "LOGO"
-#define VCMailerProp "MAILER"
-#define VCMAlarmProp "MALARM"
-#define VCMCIMailProp "MCIMAIL"
-#define VCMessageProp "MSG"
-#define VCMETProp "MET"
-#define VCModemProp "MODEM"
-#define VCMPEG2Prop "MPEG2"
-#define VCMPEGProp "MPEG"
-#define VCMSNProp "MSN"
-#define VCNamePrefixesProp "NPRE"
-#define VCNameProp "N"
-#define VCNameSuffixesProp "NSUF"
-#define VCNoteProp "NOTE"
-#define VCOrgNameProp "ORGNAME"
-#define VCOrgProp "ORG"
-#define VCOrgUnit2Prop "OUN2"
-#define VCOrgUnit3Prop "OUN3"
-#define VCOrgUnit4Prop "OUN4"
-#define VCOrgUnitProp "OUN"
-#define VCPagerProp "PAGER"
-#define VCPAlarmProp "PALARM"
-#define VCParcelProp "PARCEL"
-#define VCPartProp "PART"
-#define VCPCMProp "PCM"
-#define VCPDFProp "PDF"
-#define VCPGPProp "PGP"
-#define VCPhotoProp "PHOTO"
-#define VCPICTProp "PICT"
-#define VCPMBProp "PMB"
-#define VCPostalBoxProp "BOX"
-#define VCPostalCodeProp "PC"
-#define VCPostalProp "POSTAL"
-#define VCPowerShareProp "POWERSHARE"
-#define VCPreferredProp "PREF"
-#define VCPriorityProp "PRIORITY"
-#define VCProcedureNameProp "PROCEDURENAME"
-#define VCProdIdProp "PRODID"
-#define VCProdigyProp "PRODIGY"
-#define VCPronunciationProp "SOUND"
-#define VCPSProp "PS"
-#define VCPublicKeyProp "KEY"
-#define VCQPProp "QP"
-#define VCQuickTimeProp "QTIME"
-#define VCQuotedPrintableProp "QUOTED-PRINTABLE"
-#define VCRDateProp "RDATE"
-#define VCRegionProp "R"
-#define VCRelatedToProp "RELATED-TO"
-#define VCRepeatCountProp "REPEATCOUNT"
-#define VCResourcesProp "RESOURCES"
-#define VCRNumProp "RNUM"
-#define VCRoleProp "ROLE"
-#define VCRRuleProp "RRULE"
-#define VCRSVPProp "RSVP"
-#define VCRunTimeProp "RUNTIME"
-#define VCSequenceProp "SEQUENCE"
-#define VCSnoozeTimeProp "SNOOZETIME"
-#define VCStartProp "START"
-#define VCStatusProp "STATUS"
-#define VCStreetAddressProp "STREET"
-#define VCSubTypeProp "SUBTYPE"
-#define VCSummaryProp "SUMMARY"
-#define VCTelephoneProp "TEL"
-#define VCTIFFProp "TIFF"
-#define VCTimeZoneProp "TZ"
-#define VCTitleProp "TITLE"
-#define VCTLXProp "TLX"
-#define VCTodoProp "VTODO"
-#define VCTranspProp "TRANSP"
-#define VCUniqueStringProp "UID"
-#define VCURLProp "URL"
-#define VCURLValueProp "URLVAL"
-#define VCValueProp "VALUE"
-#define VCVersionProp "VERSION"
-#define VCVideoProp "VIDEO"
-#define VCVoiceProp "VOICE"
-#define VCWAVEProp "WAVE"
-#define VCWMFProp "WMF"
-#define VCWorkProp "WORK"
-#define VCX400Prop "X400"
-#define VCX509Prop "X509"
-#define VCXRuleProp "XRULE"
-
-/* Extensions */
-
-#define XPilotIdProp "X-PILOTID"
-#define XPilotStatusProp "X-PILOTSTAT"
-
-typedef struct VObject VObject;
-
-typedef struct VObjectIterator {
- VObject* start;
- VObject* next;
- } VObjectIterator;
-
-extern DLLEXPORT(VObject*) newVObject(const char *id);
-extern DLLEXPORT(void) deleteVObject(VObject *p);
-extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
-extern DLLEXPORT(void) deleteStr(const char *p);
-extern DLLEXPORT(void) unUseStr(const char *s);
-
-extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
-extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
-extern DLLEXPORT(void) setVObjectUStringZValue(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectUStringZValue_(VObject *o, const wchar_t *s);
-extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
-extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
-extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
-extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
-extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
-
-extern DLLEXPORT(const char*) vObjectName(VObject *o);
-extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
-extern DLLEXPORT(const wchar_t*) vObjectUStringZValue(VObject *o);
-extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
-extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
-extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
-extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
-extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
-
-extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
-extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
-extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
-extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
-extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
-extern DLLEXPORT(void) addList(VObject **o, VObject *p);
-
-extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
-
-extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
-extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
-extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
-extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
-
-extern DLLEXPORT(char*) writeMemVObject(char *s, int *len, VObject *o);
-extern DLLEXPORT(char*) writeMemVObjects(char *s, int *len, VObject *list);
-
-extern DLLEXPORT(const char*) lookupStr(const char *s);
-extern DLLEXPORT(void) cleanStrTbl();
-
-extern DLLEXPORT(void) cleanVObject(VObject *o);
-extern DLLEXPORT(void) cleanVObjects(VObject *list);
-
-extern DLLEXPORT(const char*) lookupProp(const char* str);
-extern DLLEXPORT(const char*) lookupProp_(const char* str);
-
-extern DLLEXPORT(wchar_t*) fakeUnicode(const char *ps, int *bytes);
-extern DLLEXPORT(int) uStrLen(const wchar_t *u);
-extern DLLEXPORT(char*) fakeCString(const wchar_t *u);
-
-extern DLLEXPORT(void) printVObjectToFile(char *fname,VObject *o);
-extern DLLEXPORT(void) printVObjectsToFile(char *fname,VObject *list);
-extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
-extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
-
-extern DLLEXPORT(int) vObjectValueType(VObject *o);
-
-/* return type of vObjectValueType: */
-#define VCVT_NOVALUE 0
- /* if the VObject has no value associated with it. */
-#define VCVT_STRINGZ 1
- /* if the VObject has value set by setVObjectStringZValue. */
-#define VCVT_USTRINGZ 2
- /* if the VObject has value set by setVObjectUStringZValue. */
-#define VCVT_UINT 3
- /* if the VObject has value set by setVObjectIntegerValue. */
-#define VCVT_ULONG 4
- /* if the VObject has value set by setVObjectLongValue. */
-#define VCVT_RAW 5
- /* if the VObject has value set by setVObjectAnyValue. */
-#define VCVT_VOBJECT 6
- /* if the VObject has value set by setVObjectVObjectValue. */
-
-extern const char** fieldedProp;
-
-/* NOTE regarding printVObject and writeVObject
-
-The functions below are not exported from the DLL because they
-take a FILE* as a parameter, which cannot be passed across a DLL
-interface (at least that is my experience). Instead you can use
-their companion functions which take file names or pointers
-to memory. However, if you are linking this code into
-your build directly then you may find them a more convenient API
-and you can go ahead and use them. If you try to use them with
-the DLL LIB you will get a link error.
-*/
-extern void printVObject(FILE *fp,VObject *o);
-extern void writeVObject(FILE *fp, VObject *o);
-
-
-#if defined(__CPLUSPLUS__) || defined(__cplusplus)
-}
-#endif
-
-#endif /* __VOBJECT_H__ */
-
-
diff --git a/libical/src/python/.cvsignore b/libical/src/python/.cvsignore
deleted file mode 100644
index 3dda72986f..0000000000
--- a/libical/src/python/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile.in
-Makefile
diff --git a/libical/src/python/ChangeLog b/libical/src/python/ChangeLog
deleted file mode 100644
index 7b16306ce5..0000000000
--- a/libical/src/python/ChangeLog
+++ /dev/null
@@ -1,109 +0,0 @@
-2001-03-13 Eric Busboom <eric@softwarestudio.org>
-
- * Component.py Added Component.property()
-
-2001-03-10 Patrick Lewis <plewis@inetarena.com>
-
- * Added __str__ method to Collection.Collection
-
- * Component.Component can now be initialized without arguments
-
- * Made _singular_property and _multiple_properties (in Component)
- useful for nearly all the specific component interfaces
-
- * Changed Property.Attendee and Property.Organizer to allow creation
- with no arguments
-
- * Filled in Todo skeleton
-
- * Added test function for an Event
-
-
-2001-03-05 Eric Busboom <eric@softwarestudio.org>
-
- * Property.py Added a lot of exception code to signal failure to
- create a Property.
-
- * DerivedProperties.py Added derived property classes for RDATE
- and TRIGGER, two properties that can have one of two value types.
-
-
-2001-03-04 Eric Busboom <eric@softwarestudio.org>
-
- * Property.pm Added Property.ConstructorFailedError exception
-
- * Component.pm fixed bug in Collection.__setslice__. "," used
- instead of ":"
-
-2001-03-04 Patrick Lewis <plewis@inetarena.com>
-
- * Split Libical.py file into Component.py, Property.py, Collection.py,
- and Store.py
-
- * Added test_* functions to test.py
-
- * Changed component bindings to return a Collection when objects can
- have multiple values
-
- * Changed Component object to allow for creation of an object without
- an initial string
-
- * Added Todo and Journal events
-
-2001-02-28 Eric Busboom <eric@softwarestudio.org>
-
- * Property Remove most internal data. The property now work
- alsmost entirely off of the icalproperty that it holds a reference
- to. Made changes in all derived Properties to accomodate the
- change.
-
- * Property Added __del__
-
- * Component Component.properties() now caches properties that it
- constructs, so two calls to properties() to that get the same
- icalproperty will also get the same Property.
-
- * Property Added Property.__cmp__ to test equality of properties
- based on ical string values
-
-2001-02-27 Eric Busboom <eric@softwarestudio.org>
-
- * Property Added Property.ref() to set/get the reference to the
- Property's internal icalproperty
-
- * Property Property._update_value now changes the icalproperty
- value if a reference has been set.
-
- * Component re-instituted Component.properties(). The routine now
- adds a 'ref' key to the dict that holds the python pointer
- string. The C hex value of the pointer is in the 'pid' key
-
-
-2001-02-27 Patrick Lewis <plewis@inetarena.com>
-
- * Backed out changes to Component removing comp_p;
- Component.comp_p should be restored
-
-2001-02-26 Eric Busboom <eric@softwarestudio.org>
-
- * Period Added test routine,test_period()
-
- * Period implemented methods in period
-
- * Time Addedd addition and subtraction operators
-
-2001-02-25 Eric Busboom <eric@softwarestudio.org>
-
- * Libical.py Added test routine for time, time_test()
-
- * Libical.py Remove end of line chars ('\r\n" ) from
- Property._str__. Caller should add these lines itself
-
- * Liical.py CHanges Time._update_values to set time VALUE type
- based on use of is_date, rather than length of string.
-
- * Libical.py Removed call to _update_value in TIme::timezone
-
-
- * Libical.py changed update_value to _update_value
-
diff --git a/libical/src/python/Collection.py b/libical/src/python/Collection.py
deleted file mode 100644
index 48092aadaa..0000000000
--- a/libical/src/python/Collection.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Collection.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from types import *
-
-class Collection:
- """A group of components that can be modified somewhat like a list.
-
- Usage:
- Collection(componet, propSequence)
-
- component is a Component object
- propSequence is a list or tuple of Property (or subclass of Property)
- of objects already in component
- """
-
- def __init__(self, component, propSequence):
- self._properties = list(propSequence[:])
- self._component = component
-
- def __getslice__(self, beg, end):
- return Collection(self._component, self._properties[beg:end])
-
- def __setslice__(self, beg, end, sequence):
-
- if not isinstance(sequence,ListType):
- raise TypeError, "must assign list (not instance) to slice"
-
- oldProps = self._properties[beg:end]
-
- for p in oldProps:
- self._component.remove_property(p)
-
- self._properties[beg:end] = sequence
- for p in sequence:
- self._component.add_property(p)
-
- def __getitem__(self, i):
- return self._properties[i]
-
- def __setitem__(self, i, prop):
- self._component.remove_property(self._properties[i])
- self._component.add_property(prop)
- self._properties[i]=prop
-
- def __delitem__(self, i):
- self._component.remove_property(self._properties[i])
- del self._properties[i]
-
- def __len__(self):
- return len(self._properties)
-
- def __str__(self):
- s = "[ "
- if len(self._properties) > 0:
- s = s + str(self._properties[0])
- for p in self._properties[1:]:
- s = "%s, %s" % (s, p)
- s = s + " ]"
- return s
-
- def append(self, property):
- self._properties.append(property)
- self._component.add_property(property)
-
-class ComponentCollection:
-
- def __init__(self, parent, componentSequence):
- self._parent = parent
- self._components = list(componentSequence[:])
-
- def __getslice__(self, beg, end):
- return ComponentCollection(self._parent, self._components[beg:end])
-
- def __setslice__(self, beg, end, sequence):
- oldComps = self._components[beg:end]
- self._components.__setslice__(beg, end, sequence)
- for c in sequence:
- self._components.addComponent(c)
- for c in oldComps:
- self._parent.remove_component(c)
-
- def __getitem__(self, i):
- return self._components[i]
-
- def __setitem__(self, i, prop):
- self._parent.remove_component(self._components[i])
- self._parent.add_property(prop)
- self._components[i]=prop
-
- def __delitem__(self, i):
- self._parent.remove_componet(self._components[i])
- del self._components[i]
-
- def __len__(self):
- return len(self._components)
-
- def append(self, property):
- self._components.append(property)
- self._parent.addComponent(property)
diff --git a/libical/src/python/Component.py b/libical/src/python/Component.py
deleted file mode 100644
index f4399f6c20..0000000000
--- a/libical/src/python/Component.py
+++ /dev/null
@@ -1,670 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Component.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from LibicalWrap import *
-from types import *
-from Property import *
-from Collection import *
-
-class Component:
-
- def __init__(self,str=None, component_kind="ANY", ref=None):
-
- if ref != None:
- self._ref = ref
- else:
- self._ref = None
- if str != None:
- self._ref = icalparser_parse_string(str)
- else:
- kind = icalenum_string_to_component_kind(component_kind)
- self._ref = icalcomponent_new(kind)
-
- self.cached_props = {}
-
- def __del__(self):
- if self._ref != None and \
- icalcomponent_get_parent(self._ref) != None:
-
- for k in self.cached_props.keys():
- del self.cached_props[k]
-
- icalcomponent_free(self._ref)
- self._ref = None
-
- def _prop_from_ref(self,p):
-
- d_string = icallangbind_property_eval_string(p,":")
- d = eval(d_string)
- d['ref'] = p
-
- if not self.cached_props.has_key(p):
-
- if d['value_type'] == 'DATE-TIME' or d['value_type'] == 'DATE':
- prop = Time(d,)
- elif d['value_type'] == 'PERIOD':
- prop = Period(d)
- elif d['value_type'] == 'DURATION':
- prop = Duration(d)
- elif d['name'] == 'ATTACH':
- prop = Attach(d)
- elif d['name'] == 'ATTENDEE':
- prop = Attendee(d)
- elif d['name'] == 'ORGANIZER':
- prop = Organizer(d)
- else:
- prop=Property(ref=p)
-
- self.cached_props[p] = prop
-
- def property(self, type):
-
- p = icallangbind_get_first_property(self._ref,type)
-
- if p !='NULL':
- self._prop_from_ref(p)
- prop = self.cached_props[p]
- return prop
- else :
- return None
-
- def properties(self,type='ANY'):
- """
- Return a list of Property instances, each representing a
- property of the type 'type.'
- """
-
- props = []
-
- p = icallangbind_get_first_property(self._ref,type)
-
- while p !='NULL':
- self._prop_from_ref(p)
- prop = self.cached_props[p]
- props.append(prop)
- p = icallangbind_get_next_property(self._ref,type)
-
- return Collection(self,props)
-
- def add_property(self, prop):
- "Adds the property object to the component."
-
- if not isinstance(prop,Property):
- raise TypeError
-
- prop_p = prop.ref()
-
- if not prop_p:
- s = str(prop)
- prop_p = icalproperty_new_from_string(s)
-
- if prop_p == 'NULL':
- raise "Bad property string: " + s
-
- prop.ref(prop_p)
-
- if icalproperty_get_parent(prop_p)=='NULL':
- icalcomponent_add_property(self._ref, prop_p)
- elif icalproperty_get_parent(prop_p) != self._ref:
- raise "Property is already a child of another component"
-
-
- def remove_property(self,prop):
-
- if prop.ref() and self.cached_props.has_key(prop.ref()):
-
- del self.cached_props[prop.ref()]
- icalcomponent_remove_property(self._ref,prop.ref())
-
- def components(self,type='ANY'):
- comps = []
-
- return comps
-
- def add_component(self, componentObj):
- "Adds a child component."
- pass
-
-
- def remove_component(self, component):
- "Removes a child component"
- pass
-
- def as_ical_string(self):
- return self.__str__()
-
- def __str__(self):
-
- return icalcomponent_as_ical_string(self._ref)
-
-
-
-def NewComponent(comp):
- "Converts a string or C icalcomponent into the right component object."
-
- wasStr=0 # Were we passed a string or an icalcomponent?
-
- if isinstance (comp, StringType):
- compStr = comp
- comp = icalparser_parse_string(comp)
- wasStr=1
- else:
- compStr = icalcomponent_as_ical_string(comp)
-
- kind = icalcomponent_isa(comp)
- kindStr = icalenum_component_kind_to_string(kind)
- # Do I need to free kind? (I think not).
-
- if kindStr == 'VEVENT':
- newComp = Event(compStr)
- elif kindStr == 'VTODO':
- newComp = Todo(compStr)
- elif kindStr == 'VJOURNAL':
- newComp = Journal(compstr)
- else:
- newComp = Component(compStr)
-
- # I don't think I need to free the component created when passed a string,
- # as it wasn't created with a _new function.
-
- return newComp
-
-
-class GenericComponent(Component):
-
- def __init__(self):
-
- # Component.__init__(self, str) # Call from subclasses
- self._recurrence_set=None
-
- def _singular_property(self, name, value_type, value=None,
- property_obj=None, enumerated_values=None):
- """Sets or gets the value of a method which exists once per Component.
-
- This is a constructor method for properties without a strictly defined
- object."""
-
- curr_properties = self.properties(name)
-
- # Get the value
- if value==None:
- if len(curr_properties) == 0:
- return None
- elif len(curr_properties) == 1:
- return curr_properties[0].value()
- else:
- raise ValueError, "too many properties of type %s" % propType
-
- # Set the value
- else:
- # Check if value is in enumerated_values
- if enumerated_values:
- value = upper(value)
- if value not in enumerated_values:
- raise ValueError, "%s is not one of %s" \
- % (value, enumerated_values)
-
- # Create the new property
- if property_obj:
- if not isinstance(value, property_obj):
- # Create a special property_obj property
- if property_obj == Time:
- p = Time(value, name)
- ## p.value_type(value_type)
- else:
- p = property_obj()
- ## p.value_type(value_type)
- p.value(value)
- else:
- p = value # value is already a property_obj
- else:
- # Create a generic property
- p = Property(name)
- ## p.value_type(value_type)
- p.value(value)
-
- if len(curr_properties) == 1:
- self.remove_property(curr_properties[0])
- elif len(curr_properties) > 1:
- raise ValueError, "too many properties of type %s" % propType
-
- self.add_property(p)
-
- def method(self, v=None):
- "Sets or returns the value of the METHOD property."
- return self._singular_property("METHOD", "TEXT", v)
-
- def prodid(self, v=None):
- "Sets or returns the value of the PRODID property."
- return self._singular_property("PRODID", "TEXT", v)
-
- def calscale(self, v=None):
- "Sets or returns the value of the CALSCALE property."
- return self._singular_property("CALSCALE", "TEXT", v)
-
- def class_prop(self, v=None): # Class is a reserved word
- "Sets or returns the value of the CLASS property."
- if v!=None:
- v = upper(v)
- return self._singular_property('CLASS', 'TEXT', v)
-
- def created(self, v=None):
- """Sets or returns the value of the CREATED property.
-
- Usage:
- created(time_obj) # Set the value using a Time object
- created('19970101T123000Z') # Set using an iCalendar string
- created(982362522) # Set using seconds
- created() # Return an iCalendar string
- """
- return self._singular_property("CREATED", "DATE-TIME", v, Time)
-
- def description(self, v=None):
- "Sets or returns the value of the DESCRIPTION property."
- return self._singular_property("DESCRIPTION", "TEXT", v)
-
- def dtstamp(self, v=None):
- """Sets or returns the value of the DTSTAMP property.
-
- Usage:
- dtstamp(time_obj) # Set the value using a Time object
- dtstamp('19970101T123000Z')# Set using an iCalendar string
- dtstamp(982362522) # Set using seconds
- dtstamp() # Return an iCalendar string
- """
- return self._singular_property("DTSTAMP", "DATE-TIME", v, Time)
-
- def dtstart(self, v=None):
- """Sets or returns the value of the DTSTART property.
-
- Usage:
- dtstart(time_obj) # Set the value using a Time object
- dtstart('19970101T123000Z') # Set the value as an iCalendar string
- dtstart(982362522) # Set the value using seconds (time_t)
- dtstart() # Return the time as an iCalendar string
- """
- return self._singular_property("DTSTART", "DATE-TIME", v, Time)
-
- def last_modified(self, v=None):
- """Sets or returns the value of the LAST-MODIFIED property.
-
- Usage:
- lastmodified(time_obj) # Set the value using a Time object
- lastmodified('19970101T123000Z')# Set using an iCalendar string
- lastmodified(982362522) # Set using seconds
- lastmodified() # Return an iCalendar string
- """
- return self._singular_property("LAST-MODIFIED", "DATE-TIME", v, Time)
-
- def organizer(self, v=None):
- """Sets or gets the value of the ORGANIZER property.
-
- Usage:
- organizer(orgObj) # Set value using an organizer object
- organizer('MAILTO:jd@not.com') # Set value using a CAL-ADDRESS string
- organizer() # Return a CAL-ADDRESS string
- """
- return self._singular_property('ORGANIZER', 'CAL-ADDRESS', v,
- Organizer)
-
- def recurrence_id(self, v=None):
- """Sets or gets the value for the RECURRENCE-ID property.
-
- Usage:
- recurrence_id(recIdObj) # Set using a Recurrence_Id object
- recurrence_id("19700801T133000") # Set using an iCalendar string
- recurrence_id(8349873494) # Set using seconds from epoch
- recurrence_id() # Return an iCalendar string
- """
- return self._singular_property('RECURRENCE-ID', 'DATE-TIME', v,
- Recurrence_Id)
-
- def sequence(self, v=None):
- """Sets or gets the SEQUENCE value of the Event.
-
- Usage:
- sequence(1) # Set the value using an integer
- sequence('2') # Set the value using a string containing an integer
- sequence() # Return an integer
- """
- if isinstance(v, StringType):
- v = int(str)
- return self._singular_property('SEQUENCE', 'INTEGER', v)
-
- def summary(self, v=None):
- "Sets or gets the SUMMARY value of the Event."
- return self._singular_property('SUMMARY', 'TEXT', v)
-
- def uid(self, v=None):
- "Sets or gets the UID of the Event."
- return self._singular_property('UID', 'TEXT', v)
-
- def url(self, v=None):
- """Sets or returns the URL property."""
- return self._singular_property('URL', 'URI', v)
-
- ####
- # Not quite sure if this is how we want to handle recurrence rules, but
- # this is a start.
-
- def recurrence_set(self):
- "Returns the Events RecurrenceSet object."
- if self._recurrence_set == None: # i.e haven't initialized one
- self._recurrence_set = RecurrenceSet()
- return self._recurrence_set
-
- ###
- # Alarm interface. Returns an ComponentCollection.
-
- def alarms(self, values=None):
- """Sets or returns ALARM components.
-
- Examples:
- alarms((alarm1,)) # Set using Alarm component
- alarms() # Returns an ComponentCollection of all Alarms
- """
- if values!=None:
- for alarm in values:
- self.addComponent(alarm)
- else:
- return ComponentCollection(self, self.components('VALARM'))
-
- ####
- # Methods that deal with Properties that can occur multiple times are
- # below. They use the Collection class to return their Properties.
-
- def _multiple_properties(self, name, value_type, values,
- property_obj=None):
- "Processes set/get for Properties that can have multiple instances."
-
- # Set value
- if values!=None:
- if not isinstance(values, TupleType) \
- and not isinstance(values, ListType):
- raise TypeError, "%s is not a tuple or list."
-
- # Delete old properties
- for p in self.properties(name):
- self.remove_property(p)
-
- for v in values:
- if property_obj: # Specialized properties
- if not isinstance(v, property_obj): # Make new object
- new_prop = property_obj()
- new_prop.value(v)
- else: # Use existing object
- new_prop = v
- else: # Generic properties
- new_prop= Property()
- new_prop.name(name)
- # new_prop.value_type(value_type)
- new_prop.value(v)
-
- self.add_property(new_prop)
-
- # Get value
- else:
- return Collection(self, self.properties(name))
-
- def attachments(self, values=None):
- """Sets or returns a Collection of Attach properties.
-
- 'values' can be a sequence containing URLs (strings) and/or file-ish
- objects.
- """
- return self._multiple_properties("ATTACH", "", value, Attach)
-
- def attendees(self, value=None):
- """Sets attendees or returns a Collection of Attendee objects.
-
- If setting the attendees, pass a sequence as the argument.
- Examples:
- # Set using Attendee objects
- attendees((attObj1, attObj2))
- # Set using a CAL-ADDRESS string
- attendees(['MAILTO:jdoe@somewhere.com'])
- # Set using a combination of Attendee objects and strings
- attendees(['MAILTO:jdoe@somewhere.com', attObj1])
- # Returns a list of Attendee objects
- attendees()
-
- When setting the attendees, any previous Attendee objects in the Event
- are overwritten. If you want to add to the Attendees, one way to do it
- is:
-
- attendees().append(Attendee('MAILTO:jdoe@nothere.com'))
- """
- return self._multiple_properties("ATTENDEE", "", value, Attendee)
-
- def categories(self, value=None):
- """Sets categories or returns a Collection of CATEGORIES properties.
-
- If setting the categories, pass a sequence as the argument.
- Examples:
- # Set using string[s]
- categories(('APPOINTMENT', 'EDUCATION'))
- # Returns a list of Category properites
- categories()
-
- When setting the attendees, any previous category Properties in the
- Event are overwritten. If you want to add to the categories, one way
- to do it is:
-
- new_cat=Property('CATEGORIES')
- new_cat.value_type('TEXT')
- new_cat.value('PERSONAL')
- categories().append(new_cat)
- """
- return self._multiple_properties("CATEGORIES", "TEXT", value)
-
- def comments(self, value=None):
- "Sets or returns a Collection of COMMENT properties."
- return self._multiple_properties('COMMENT', 'TEXT', value)
-
- def contacts(self, value=None):
- "Sets or returns a Collection of CONTACT properties."
- return self._multiple_properties('CONTACT', 'TEXT', value)
-
- def related_tos(self, value=None):
- "Sets or returns a Collectoin of RELATED-TO properties."
- return self._multiple_properties('RELATED-TO', 'TEXT', value)
-
-
-class Event(GenericComponent):
- "The iCalendar Event object."
-
- def __init__(self, str=None):
- Component.__init__(self, str, "VEVENT")
- GenericComponent.__init__(self)
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VEVENT"
-
- def clone(self):
- "Returns a copy of the object."
- return Event(self.asIcalString())
-
- def dtend(self, v=None):
- """Sets or returns the value of the DTEND property.
-
- Usage:
- dtend(time_obj) # Set the value using a Time object
- dtend('19970101T123000Z') # Set the value as an iCalendar string
- dtend(982362522) # Set the value using seconds (time_t)
- dtend() # Return the time as an iCalendar string
-
- If the dtend value is being set and duration() has a value, the
- duration property will be removed.
- """
- if v != None:
- duration = self.properties('DURATION')
- for d in duration: # Clear DURATION properties
- self.remove_property(d)
- return self._singular_property("DTEND", "DATE-TIME", v, Time)
-
- def duration(self, v=None):
- """Sets or returns the value of the duration property.
-
- Usage:
- duration(dur_obj) # Set the value using a Duration object
- duration("P3DT12H") # Set value as an iCalendar string
- duration(3600) # Set duration using seconds
- duration() # Return duration as an iCalendar string
-
- If the duration value is being set and dtend() has a value, the dtend
- property will be removed.
- """
-
- if v != None:
- dtend = self.properites('DTEND')
- for d in dtend:
- self.remove_property(d) # Clear DTEND properties
- return self._singular_property("DURATION", "DURATION", v, Duration)
-
- def status(self, v=None):
- "Sets or returns the value of the STATUS property."
-
- # These values are only good for VEVENT components (i.e. don't copy
- # & paste into VTODO or VJOURNAL
- valid_values=('TENTATIVE', 'CONFIRMED', 'CANCELLED')
- return self._singular_property("STATUS", "TEXT", v,
- enumerated_values=valid_values)
-
- def geo(self, v=None):
- """Sets or returns the value of the GEO property.
-
- Usage:
- geo(value) or
- geo() # Returns the icalendar string
-
- 'value' is either a icalendar GEO string or a sequence with two 'float'
- numbers.
-
- Examples:
- geo('40.232;-115.9531') # Set value using string
- geo((40.232, -115.9531)) # Set value using a sequence
- geo() # Returns "40.232;-115.9531"
-
- To get the GEO property represented as a tuple and numbers instead of
- the iCalendar string, use geo_get_tuple().
- """
-
- if isinstance(v, ListType) or isinstance(v, TupleType):
- v = "%s;%s" % (float(v[0]), float(v[1]))
- return self._singular_property("GEO", "FLOAT", v)
-
- def geo_get_tuple(self):
- """Returns the GEO property as a tuple."""
-
- geo = self.geo()
- geo = split(geo, ';')
- return float(geo[0]), float(geo[1])
-
- def location(self, v=None):
- """Sets or returns the LOCATION property."""
- return self._singular_property("LOCATION", "TEXT", v)
-
- def transp(self, v=None):
- """Sets or returns the TRANSP property."""
- ok_values = ('OPAQUE', 'TRANSPARENT')
- return self._singular_property('TRANSP', 'TEXT', v,
- enumerated_values=ok_values)
-
- def resources(self, v=None):
- pass
-
-class Todo(GenericComponent):
- "The iCalendar TODO component."
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VTODO"
-
- def clone(self):
- "Returns a copy of the object."
- return Todo(self.asIcalString())
-
- def completed(self, value=None):
- return self._singular_property('COMPLETED', 'DATE-TIME', value, Time)
-
- def geo(self, value=None):
- if isinstance(v, ListType) or isinstance(v, TupleType):
- v = "%s;%s" % (float(v[0]), float(v[1]))
- return self._singular_property("GEO", "FLOAT", value)
-
- def location(self, value=None):
- return self._singular_property('LOCATION', 'TEXT', value)
-
- def percent(self, value=None):
- if value!=None:
- value = str(int(value))
- return self._singular_property('PERCENT', 'INTEGER', value)
-
- def status(self, value=None):
- if value!=None:
- value=upper(value)
- ok_values = ('NEEDS-ACTION', 'COMPLETED', 'IN-PROCESS', 'CANCELLED')
- return self._singular_property('STATUS', 'TEXT', value,
- enumerated_values=ok_values)
-
- def due(self, value=None):
- if value != None:
- duration = self.properties('DURATION')
- for d in duration:
- self.remove_property(d) # Clear DURATION properties
- return self._singular_property('DUE', 'DATE-TIME', value, Time)
-
- def duration(self, value=None):
- if value != None:
- due = self.properites('DUE')
- for d in due:
- self.remove_property(d) # Clear DUE properties
- return self._singular_property("DURATION", "DURATION", value, Duration)
-
- def resources():
- pass
-
-
-class Journal(GenericComponent):
- "The iCalendar JOURNAL component."
-
- def component_type(self):
- "Returns the type of component for the object."
- return "VJOURNAL"
-
- def clone(self):
- "Returns a copy of the object."
- return Journal(self.asIcalString())
-
- def status(self, v=None):
- if v!=None:
- v = upper(v)
- ok_values=('DRAFT', 'FINAL', 'CANCELLED')
- return self._singular_property('STATUS', 'TEXT', v,
- enumerated_values=ok_values)
-
diff --git a/libical/src/python/DerivedProperties.py b/libical/src/python/DerivedProperties.py
deleted file mode 100644
index b557a1f7d7..0000000000
--- a/libical/src/python/DerivedProperties.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: DerivedProperties.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from Property import Time, Period, Duration
-
-def RDate(arg):
-
- class RDate_Time(Time):
- def __init__(self,arg): Time.__init__(self,arg,"RDATE")
-
- class RDate_Period(Period):
- def __init__(self,arg): Period.__init__(self,arg,"RDATE")
-
- p = None
- for c in [RDate_Time, RDate_Period]:
- try: return c(arg)
- except Property.ConstructorFailedError, d: pass
- raise Property.ConstructorFailedError("Failed to construct RDATE from "+str(arg))
-
-
-def Trigger(arg):
- class Trigger_Time(Time):
- def __init__(self,arg): Time.__init__(self,arg,"TRIGGER")
-
- class Trigger_Duration(Duration):
- def __init__(self,arg): Duration.__init__(self,arg,"TRIGGER")
-
- p = None
- for c in [Trigger_Duration, Trigger_Time]:
- try: return c(arg)
- except Property.ConstructorFailedError, d: pass
- raise Property.ConstructorFailedError("Failed to construct TRIGGER from "+str(arg))
-
-
-
diff --git a/libical/src/python/Libical.py b/libical/src/python/Libical.py
deleted file mode 100644
index 78a0fff8ff..0000000000
--- a/libical/src/python/Libical.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Libical.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-
-import LibicalWrap
-
-from Component import Component, NewComponent, Event, Todo, Journal
-
-# Will eventually remove Time for real Property events
-from Property import Property, Time, Duration, Period, Attendee, Organizer, \
- Recurrence_Id, Attach, RecurrenceSet
-
-from DerivedProperties import RDate, Trigger
-
-from Store import Store, FileStore
diff --git a/libical/src/python/LibicalWrap.i b/libical/src/python/LibicalWrap.i
deleted file mode 100644
index c6b6740383..0000000000
--- a/libical/src/python/LibicalWrap.i
+++ /dev/null
@@ -1,352 +0,0 @@
-/* -*- Mode: C -*-*/
-/*======================================================================
- FILE: ical.i
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
-
- Contributions from:
- Graham Davison (g.m.davison@computer.org)
-
- ======================================================================*/
-
-%module LibicalWrap
-
-
-%{
-#include "ical.h"
-#include "icalss.h"
-
-#include <sys/types.h> /* for size_t */
-#include <time.h>
-
-%}
-
-
-#include "fcntl.h" /* For Open flags */
-
-typedef void icalcomponent;
-typedef void icalproperty;
-
-icalcomponent* icalparser_parse_string(char* str);
-
-
-icalcomponent* icalcomponent_new(int kind);
-icalcomponent* icalcomponent_new_clone(icalcomponent* component);
-icalcomponent* icalcomponent_new_from_string(char* str);
-
-char* icalcomponent_as_ical_string(icalcomponent* component);
-
-void icalcomponent_free(icalcomponent* component);
-int icalcomponent_count_errors(icalcomponent* component);
-void icalcomponent_strip_errors(icalcomponent* component);
-void icalcomponent_convert_errors(icalcomponent* component);
-
-icalproperty* icalcomponent_get_current_property(icalcomponent* component);
-
-icalproperty* icalcomponent_get_first_property(icalcomponent* component,
- int kind);
-icalproperty* icalcomponent_get_next_property(icalcomponent* component,
- int kind);
-
-icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
-
-icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
- int kind);
-icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
- int kind);
-
-void icalcomponent_add_property(icalcomponent* component,
- icalproperty* property);
-
-void icalcomponent_remove_property(icalcomponent* component,
- icalproperty* property);
-
-
-icalcomponent* icalcomponent_get_parent(icalcomponent* component);
-int icalcomponent_isa(icalcomponent* component);
-
-int icalrestriction_check(icalcomponent* comp);
-
-
-/* actually takes icalproperty_kind */
-icalproperty* icalproperty_new(int kind);
-
-icalproperty* icalproperty_new_from_string(char* str);
-
-char* icalproperty_as_ical_string(icalproperty *prop);
-
-void icalproperty_set_parameter_from_string(icalproperty* prop,
- const char* name, const char* value);
-void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char * kind);
-
-const char* icalproperty_get_value_as_string(icalproperty* prop);
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
- const char* name);
-
-
-icalcomponent* icalproperty_get_parent(icalproperty* property);
-
-int icalerror_supress(const char* error);
-void icalerror_restore(const char* error, int es);
-char* icalerror_perror();
-void icalerror_clear_errno(void);
-
-const char* icalproperty_kind_to_string(int kind);
-int icalproperty_string_to_kind(const char* string);
-int icalproperty_kind_to_value_kind(int kind);
-
-const char* icalvalue_kind_to_string(int kind);
-int icalvalue_string_to_kind(const char* str);
-
-const char* icalparameter_kind_to_string(int kind);
-int icalparameter_string_to_kind(const char* string);
-
-const char* icalenum_component_kind_to_string(int kind);
-int icalenum_string_to_component_kind(const char* string);
-
-int* icallangbind_new_array(int size);
-void icallangbind_free_array(int* array);
-int icallangbind_access_array(int* array, int index);
-
-
-
-int icalrecur_expand_recurrence(char* rule, int start,
- int count, int* array);
-
-
-/* Iterate through properties and components using strings for the kind */
-icalproperty* icallangbind_get_first_property(icalcomponent *c,
- const char* prop);
-
-icalproperty* icallangbind_get_next_property(icalcomponent *c,
- const char* prop);
-
-icalcomponent* icallangbind_get_first_component(icalcomponent *c,
- const char* comp);
-
-icalcomponent* icallangbind_get_next_component(icalcomponent *c,
- const char* comp);
-
-
-/* Return a string that can be evaluated in perl or python to
- generated a hash that holds the property's name, value and
- parameters. Sep is the hash seperation string, "=>" for perl and
- ":" for python */
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
-
-int icallangbind_string_to_open_flag(const char* str);
-
-/***********************************************************************
- Time routines
-***********************************************************************/
-
-
-struct icaltimetype
-{
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
-
- int is_utc; /* 1-> time is in UTC timezone */
-
- int is_date; /* 1 -> interpret this as date. */
-
- const char* zone; /*Ptr to Olsen placename. Libical does not own mem*/
-};
-
-
-/* Convert seconds past UNIX epoch to a timetype*/
-struct icaltimetype icaltime_from_timet(int v, int is_date);
-
-/* Return the time as seconds past the UNIX epoch */
-/* Normally, this returns a time_t, but SWIG tries to turn that type
- into a pointer */
-int icaltime_as_timet(struct icaltimetype);
-
-/* Return a string represention of the time, in RFC2445 format. The
- string is owned by libical */
-char* icaltime_as_ical_string(struct icaltimetype tt);
-
-/* create a time from an ISO format string */
-struct icaltimetype icaltime_from_string(const char* str);
-
-/* Routines for handling timezones */
-/* Return the offset of the named zone as seconds. tt is a time
- indicating the date for which you want the offset */
-int icaltime_utc_offset(struct icaltimetype tt, const char* tzid);
-
-/* convert tt, of timezone tzid, into a utc time. Does nothing if the
- time is already UTC. */
-struct icaltimetype icaltime_as_utc(struct icaltimetype tt,
- const char* tzid);
-
-/* convert tt, a time in UTC, into a time in timezone tzid */
-struct icaltimetype icaltime_as_zone(struct icaltimetype tt,
- const char* tzid);
-
-/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */
-struct icaltimetype icaltime_null_time(void);
-
-/* Return true of the time is null. */
-int icaltime_is_null_time(struct icaltimetype t);
-
-/* Returns false if the time is clearly invalid, but is not null. This
- is usually the result of creating a new time type buy not clearing
- it, or setting one of the flags to an illegal value. */
-int icaltime_is_valid_time(struct icaltimetype t);
-
-/* Reset all of the time components to be in their normal ranges. For
- instance, given a time with minutes=70, the minutes will be reduces
- to 10, and the hour incremented. This allows the caller to do
- arithmetic on times without worrying about overflow or
- underflow. */
-struct icaltimetype icaltime_normalize(struct icaltimetype t);
-
-/* Return the day of the year of the given time */
-short icaltime_day_of_year(struct icaltimetype t);
-
-/* Create a new time, given a day of year and a year. */
-struct icaltimetype icaltime_from_day_of_year(short doy, short year);
-
-/* Return the day of the week of the given time. Sunday is 0 */
-short icaltime_day_of_week(struct icaltimetype t);
-
-/* Return the day of the year for the Sunday of the week that the
- given time is within. */
-short icaltime_start_doy_of_week(struct icaltimetype t);
-
-/* Return a string with the time represented in the same format as ctime(). THe string is owned by libical */
-char* icaltime_as_ctime(struct icaltimetype);
-
-/* Return the week number for the week the given time is within */
-short icaltime_week_number(struct icaltimetype t);
-
-/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
-int icaltime_compare(struct icaltimetype a,struct icaltimetype b);
-
-/* like icaltime_compare, but only use the date parts. */
-int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b);
-
-/* Return the number of days in the given month */
-short icaltime_days_in_month(short month,short year);
-
-
-/***********************************************************************
- Duration Routines
-***********************************************************************/
-
-
-struct icaldurationtype
-{
- int is_neg;
- unsigned int days;
- unsigned int weeks;
- unsigned int hours;
- unsigned int minutes;
- unsigned int seconds;
-};
-
-struct icaldurationtype icaldurationtype_from_int(int t);
-struct icaldurationtype icaldurationtype_from_string(const char*);
-int icaldurationtype_as_int(struct icaldurationtype duration);
-char* icaldurationtype_as_ical_string(struct icaldurationtype d);
-struct icaldurationtype icaldurationtype_null_duration();
-int icaldurationtype_is_null_duration(struct icaldurationtype d);
-
-struct icaltimetype icaltime_add(struct icaltimetype t,
- struct icaldurationtype d);
-
-struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
- struct icaltimetype t2);
-
-
-/***********************************************************************
- Period Routines
-***********************************************************************/
-
-
-struct icalperiodtype
-{
- struct icaltimetype start;
- struct icaltimetype end;
- struct icaldurationtype duration;
-};
-
-struct icalperiodtype icalperiodtype_from_string (const char* str);
-
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
-struct icalperiodtype icalperiodtype_null_period();
-int icalperiodtype_is_null_period(struct icalperiodtype p);
-int icalperiodtype_is_valid_period(struct icalperiodtype p);
-
-
-/***********************************************************************
- Storage Routines
-***********************************************************************/
-
-icalfileset* icalfileset_new(const char* path);
-
-/* Like _new, but takes open() flags for opening the file */
-icalfileset* icalfileset_new_open(const char* path,
- int flags, int mode);
-
-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, icalgauge* 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);
diff --git a/libical/src/python/Makefile.am b/libical/src/python/Makefile.am
deleted file mode 100644
index 8eaf4a74cb..0000000000
--- a/libical/src/python/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-
-lib_LTLIBRARIES = libLibicalWrap.la
-
-libLibicalWrap_la_SOURCES = LibicalWrap.c
-
-INCLUDES = \
- -I$(top_builddir) \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src \
- -I$(top_srcdir)/src/libical \
- -I$(top_builddir)/src/libical \
- -I$(top_srcdir)/src/libicalss \
- $(PY_CFLAGS)
-
-LDADD = ../libical/libical.la ../libicalss/libicalss.la
-
-all: LibicalWrap.so
-
-LibicalWrap.c: LibicalWrap.i
- swig -python -o LibicalWrap.c LibicalWrap.i
-
-# This part should be done with libtool, but I don't know how to do
-# it. Libtool needs to generate a shared library in this directory
-# regardless of the value of AM_DISABLE_SHARED
-LibicalWrap.so: LibicalWrap.c
- ld -shared -o LibicalWrap.so LibicalWrap.o ../libical/.libs/libical.a ../libicalss/.libs/libicalss.a
-
-CLEANFILES = LibicalWrap.c LibicalWrap_wrap.doc Libical.pyc LibicalWrap.so
-
-EXTRA_DIST = \
-Libical.py \
-LibicalWrap.i \
-python-binding.txt \
-test.py \
-Collection.py \
-Component.py \
-DerivedProperties.py \
-Property.py \
-Store.py \
-ChangeLog
-
-
diff --git a/libical/src/python/Property.py b/libical/src/python/Property.py
deleted file mode 100644
index d63b265525..0000000000
--- a/libical/src/python/Property.py
+++ /dev/null
@@ -1,839 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Property.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from LibicalWrap import *
-from types import *
-import regsub
-import base64
-from string import index, upper
-
-#def icalerror_supress(arg):
-# pass
-
-#def icalerror_restore(a,b):
-# pass
-
-def error_type():
- error = icalerror_perror()
- return error[:index(error,':')]
-
-class Property:
- """ Represent any iCalendar Property.
-
- Usage:
- Property(dict)
-
- Where:
- dict is a dictionary with keys of 'name', 'value_type', and 'value'.
- In addition, parameter:parameter value entries may be included.
- """
-
- class ConstructorFailedError(Exception):
- "Failed to construct a property"
-
- class UpdateFailedError(Exception):
- "Failed to update the value of a property"
-
-
- def __init__(self, type = None, ref = None):
-
-
- assert(ref == None or isinstance(ref,StringType))
- assert(type == None or isinstance(type,StringType))
-
- self._ref = None
-
- if ref != None:
- self._ref = ref
- elif type != None:
- kind = icalproperty_string_to_kind(type)
- self._ref = icalproperty_new(kind)
-
-
- if self._ref == None or self._ref == 'NULL':
- raise Property.ConstructorFailedError("Failed to construct Property")
-
- self._deleted = 0;
-
-
- # Initialize all of the required keys
-
-
- def __del__(self):
-
- self._deleted = 1;
-
- if not self._deleted and \
- self.ref() and \
- icalproperty_get_parent(self.ref()) == 'NULL':
-
- icalproperty_free(self.ref())
-
- def name(self,v=None):
- """ Return the name of the property """
- str = icalproperty_as_ical_string(self._ref)
-
- idx = index(str, '\n')
-
- return str[:idx]
-
- def ref(self,v=None):
- """ Return the internal reference to the libical icalproperty """
- if(v != None):
-
- if not self._deleted and self._ref and \
- icalproperty_get_parent(self._ref) == 'NULL':
-
- icalproperty_free(self._ref)
-
- self._ref = v
-
- return self._ref
-
-
- def value(self,v=None, kind = None):
- """ Return the RFC2445 representation of the value """
-
- if(v != None):
-
- if kind != None:
- # Get the default kind of value for this property
- default_kind = icalvalue_kind_to_string(icalproperty_kind_to_value_kind(icalproperty_string_to_kind(self.name())))
-
- if(kind != default_kind):
- self.__setitem__('VALUE',kind)
- vt = kind
- elif self.__getitem__('VALUE'):
- vt = self.__getitem__('VALUE')
- else:
- vt = 'NO' # Use the kind of the existing value
-
-
- icalerror_clear_errno()
-
- #e1=icalerror_supress("MALFORMEDDATA")
- icalproperty_set_value_from_string(self._ref,v,vt)
- #icalerror_restore("MALFORMEDDATA",e1)
-
- if error_type() != "NO":
- raise Property.UpdateFailedError(error_type())
-
- s = icalproperty_get_value_as_string(self._ref)
- assert(s == v)
-
- return icalproperty_get_value_as_string(self._ref)
-
- def parameters(self):
-
- d_string = icallangbind_property_eval_string(self._ref,":")
- dict = eval(d_string)
-
- desc_keys = ('name', 'value', 'value_type', 'pid', 'ref', 'deleted' )
-
- def foo(k,d=dict):
- if d.has_key(k): del d[k]
-
- map( foo, desc_keys)
-
- return filter(lambda p, s=self: s[p] != None, dict.keys())
-
-
- def as_ical_string(self):
-
- return icalproperty_as_ical_string(self._ref)
-
- def __getitem__(self,key):
- """ Return property values by name """
- key = upper(key)
-
- str = icalproperty_get_parameter_as_string(self._ref,key)
-
- if(str == 'NULL'): return None
-
- return str
-
- def __setitem__(self,key,value):
- """ Set Property Values by Name """
- key = upper(key)
-
- icalproperty_set_parameter_from_string(self._ref,key,value)
-
- return self.__getitem__(key)
-
- def __str__(self):
-
- str = self.as_ical_string()
- return regsub.gsub('\r?\n ?','',str)
-
- def __cmp__(self, other):
- s_str = str(self)
- o_str = str(other)
-
- return cmp(s_str,o_str)
-
-
-class Time(Property):
- """ Represent iCalendar DATE, TIME and DATE-TIME """
- def __init__(self, arg, name="DTSTART"):
- """
- Create a new Time from a string or number of seconds past the
- POSIX epoch
-
- Time("19970325T123000Z") Construct from an iCalendar string
- Time(8349873494) Construct from seconds past POSIX epoch
-
- """
- e1=icalerror_supress("MALFORMEDDATA")
- e2=icalerror_supress("BADARG")
-
- if isinstance(arg, DictType):
- # Dictionary -- used for creating from Component
- self.tt = icaltime_from_string(arg['value'])
- Property.__init__(self, ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
- # Create from an iCal string
- self.tt = icaltime_from_string(arg)
- elif isinstance(arg, IntType) or \
- isinstance(arg, FloatType):
- # Create from seconds past the POSIX epoch
- self.tt = icaltime_from_timet(int(arg),0)
- elif isinstance(arg, Time):
- # Copy an instance
- self.tt = arg.tt
- else:
- self.tt = icaltime_null_time()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e1)
- icalerror_restore("BADARG",e2)
-
- if icaltime_is_null_time(self.tt):
- raise Property.ConstructorFailedError("Failed to construct a Time")
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct a Time")
-
- def _update_value(self):
- self.tt = icaltime_normalize(self.tt)
- self.value(icaltime_as_ical_string(self.tt),"DATE-TIME")
-
- def valid(self):
- " Return true if this is a valid time "
- return not icaltime_is_null_time(self.tt)
-
- def utc_seconds(self,v=None):
- """ Return or set time in seconds past POSIX epoch"""
- if (v!=None):
- self.tt = icaltime_from_timet(v,0)
- self._update_value()
-
- return icaltime_as_timet(self.tt)
-
- def is_utc(self,v=None):
- """ Return or set boolean indicating if time is in UTC """
- if(v != None):
- icaltimetype_is_utc_set(self.tt,v)
- self._update_value()
- return icaltimetype_is_utc_get(self.tt)
-
- def is_date(self,v=None):
- """ Return or set boolean indicating if time is actually a date """
- if(v != None):
- icaltimetype_is_date_set(self.tt,v)
- self._update_value()
- return icaltimetype_is_date_get(self.tt)
-
- def timezone(self,v=None):
- """ Return or set the timezone string for this time """
-
- if (v != None):
- assert(isinstance(v,StringType) )
- self['TZID'] = v
- return self['TZID']
-
- def second(self,v=None):
- """ Get or set the seconds component of this time """
- if(v != None):
- icaltimetype_second_set(self.tt,v)
- self._update_value()
- return icaltimetype_second_get(self.tt)
-
- def minute(self,v=None):
- """ Get or set the minute component of this time """
- if(v != None):
- icaltimetype_minute_set(self.tt,v)
- self._update_value()
- return icaltimetype_minute_get(self.tt)
-
- def hour(self,v=None):
- """ Get or set the hour component of this time """
- if(v != None):
- icaltimetype_hour_set(self.tt,v)
- self._update_value()
- return icaltimetype_hour_get(self.tt)
-
- def day(self,v=None):
- """ Get or set the month day component of this time """
- if(v != None):
- icaltimetype_day_set(self.tt,v)
- self._update_value()
- return icaltimetype_day_get(self.tt)
-
- def month(self,v=None):
- """ Get or set the month component of this time. January is month 1 """
- if(v != None):
- icaltimetype_month_set(self.tt,v)
- self._update_value()
- return icaltimetype_month_get(self.tt)
-
- def year(self,v=None):
- """ Get or set the year component of this time """
- if(v != None):
- icaltimetype_year_set(self.tt,v)
- self._update_value()
-
- return icaltimetype_year_get(self.tt)
-
-
-
- def __add__(self,o):
-
- other = Duration(o,"DURATION")
-
- if not other.valid():
- return Duration(0,"DURATION")
-
- seconds = self.utc_seconds() + other.seconds()
-
- new = Time(seconds,self.name())
- new.timezone(self.timezone())
- new.is_utc(self.is_utc())
-
- return new
-
- def __radd_(self,o):
- return self.__add__(o)
-
-
- def __sub__(self,o):
-
-
- if isinstance(o,Time):
- # Subtract a time from this time and return a duration
- seconds = self.utc_seconds() - other.utc_seconds()
- return Duration(seconds)
- elif isinstance(o,Duration):
- # Subtract a duration from this time and return a time
- other = Duration(o)
- if(not other.valid()):
- return Time()
-
- seconds = self.utc_seconds() - other.seconds()
- return Time(seconds)
- else:
- raise TypeError, "subtraction with Time reqires Time or Duration"
-
-class Duration(Property):
- """
- Represent a length of time, like 3 minutes, or 6 days, 20 seconds.
-
-
- """
-
- def __init__(self, arg, name="DURATION"):
- """
- Create a new duration from an RFC2445 string or number of seconds.
- Construct the duration from an iCalendar string or a number of seconds.
-
- Duration("P3DT2H34M45S") Construct from an iCalendar string
- Duration(3660) Construct from seconds
- """
-
- self.dur = None
-
- e=icalerror_supress("MALFORMEDDATA")
-
- if isinstance(arg, DictType):
-
- self.dur = icaldurationtype_from_string(arg['value'])
- Property.__init__(self,ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
- self.dur = icaldurationtype_from_string(arg)
- elif isinstance(arg, IntType):
- self.dur = icaldurationtype_from_int(arg)
- elif isinstance(arg,Duration):
- self.dur = arg.dur
- else:
- self.dur = icaldurationtype_null_duration()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e)
-
- if self.dur == None or icaldurationtype_is_null_duration(self.dur):
- raise Property.ConstructorFailedError("Failed to construct Duration from " +str(arg))
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct Duration from " + str(arg))
-
- def _update_value(self):
-
- self.value(icaldurationtype_as_ical_string(self.dur),"DURATION")
-
- def valid(self):
- "Return true if this is a valid duration"
-
- return not icaldurationtype_is_null_duration(self.dur)
-
- def seconds(self,v=None):
- """Return or set duration in seconds"""
- if(v != None):
- self.dur = icaldurationtype_from_int(v);
- self.dict['value'] = icaltimedurationtype_as_ical_string(self.dur)
- return icaldurationtype_as_int(self.dur)
-
-
-class Period(Property):
- """Represent a span of time"""
- def __init__(self,arg,name='FREEBUSY'):
- """ """
-
- Property.__init__(self, type = name)
-
- self.pt=None
-
- #icalerror_clear_errno()
- e1=icalerror_supress("MALFORMEDDATA")
- e2=icalerror_supress("BADARG")
-
- if isinstance(arg, DictType):
-
-
- es=icalerror_supress("MALFORMEDDATA")
- self.pt = icalperiodtype_from_string(arg['value'])
- icalerror_restore("MALFORMEDDATA",es)
-
- Property.__init__(self, ref=arg['ref'])
- else:
- if isinstance(arg, StringType):
-
- self.pt = icalperiodtype_from_string(arg)
-
- else:
- self.pt = icalperiodtype_null_period()
-
- Property.__init__(self,type=name)
-
- icalerror_restore("MALFORMEDDATA",e1)
- icalerror_restore("BADARG",e2)
-
-
- if self.pt == None or icalperiodtype_is_null_period(self.pt):
- raise Property.ConstructorFailedError("Failed to construct Period")
-
-
- try:
- self._update_value()
- except Property.UpdateFailedError:
- raise Property.ConstructorFailedError("Failed to construct Period")
-
- def _end_is_duration(self):
- dur = icalperiodtype_duration_get(self.pt)
- if not icaldurationtype_is_null_duration(dur):
- return 1
- return 0
-
- def _end_is_time(self):
- end = icalperiodtype_end_get(self.pt)
- if not icaltime_is_null_time(end):
- return 1
- return 0
-
- def _update_value(self):
-
- self.value(icalperiodtype_as_ical_string(self.pt),"PERIOD")
-
-
- def valid(self):
- "Return true if this is a valid period"
-
- return not icalperiodtype_is_null_period(self.dur)
-
- def start(self,v=None):
- """
- Return or set start time of the period. The start time may be
- expressed as an RFC2445 format string or an instance of Time.
- The return value is an instance of Time
- """
-
- if(v != None):
- if isinstance(t,Time):
- t = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- t = Time(v,"DTSTART")
- else:
- raise TypeError
-
- icalperiodtype_start_set(self.pt,t.tt)
-
- self._update_value()
-
-
- return Time(icaltime_as_timet(icalperiodtype_start_get(self.pt)),
- "DTSTART")
-
- def end(self,v=None):
- """
- Return or set end time of the period. The end time may be
- expressed as an RFC2445 format string or an instance of Time.
- The return value is an instance of Time.
-
- If the Period has a duration set, but not an end time, this
- method will caluculate the end time from the duration. """
-
- if(v != None):
-
- if isinstance(t,Time):
- t = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- t = Time(v)
- else:
- raise TypeError
-
- if(self._end_is_duration()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- dur = t.utc_seconds()-start;
- icalperiodtype_duration_set(self.pt,
- icaldurationtype_from_int(dur))
- else:
- icalperiodtype_end_set(self.pt,t.tt)
-
- self._update_value()
-
- if(self._end_is_time()):
- rt = Time(icaltime_as_timet(icalperiodtype_end_get(self.pt)),
- 'DTEND')
- rt.timezone(self.timezone())
- return rt
- elif(self._end_is_duration()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- dur = icaldurationtype_as_int(icalperiodtype_duration_get(self.pt))
- rt = Time(start+dur,'DTEND')
- rt.timezone(self.timezone())
- return rt
- else:
- return Time({},'DTEND')
-
-
-
- def duration(self,v=None):
- """
- Return or set the duration of the period. The duration may be
- expressed as an RFC2445 format string or an instance of Duration.
- The return value is an instance of Duration.
-
- If the period has an end time set, but not a duration, this
- method will calculate the duration from the end time. """
-
- if(v != None):
-
- if isinstance(t,Duration):
- d = v
- elif isinstance(t,StringType) or isinstance(t,IntType):
- d = Duration(v)
- else:
- raise TypeError
-
- if(self._end_is_time()):
- start = icaltime_as_timet(icalperiodtype_start_get(self.pt))
- end = start + d.seconds()
-
- icalperiodtype_end_set(self.pt,icaltime_from_timet(end,0))
- else:
- icalperiodtype_duration_set(self.pt,d.dur)
-
- if(self._end_is_time()):
- start =icaltime_as_timet(icalperiodtype_start_get(self.pt))
- end = icaltime_as_timet(icalperiodtype_end_get(self.pt))
-
- print "End is time " + str(end-start)
-
- return Duration(end-start,"DURATION")
-
- elif(self._end_is_duration()):
- dur = icaldurationtype_as_int(
- icalperiodtype_duration_get(self.pt))
-
- return Duration(dur,"DURATION")
- else:
-
-
- return Duration(0,"DURATION")
-
-
- def timezone(self,v=None):
- """ Return or set the timezone string for this time """
- if (v != None):
- self['TZID'] = v
- return self['TZID']
-
-class Attendee(Property):
- """Class for Attendee properties.
-
- Usage:
- Attendee([dict])
- Attendee([address])
-
- Where:
- dict is an optional dictionary with keys of
- 'value': CAL-ADDRESS string and any parameter: parameter_value entries.
- 'name' and 'value_type' entries in dict are ignored and automatically set
- with the appropriate values.
- address is the CAL-ADDRESS (string) of the Attendee
- """
-
- def __init__(self, arg={}):
-
- assert(isinstance(arg,DictType))
-
- ref = None
-
- if arg!={}:
- ref = arg['ref']
-
- Property.__init__(self,type='ATTENDEE',ref=ref)
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- # Methods for accessing enumerated parameters
- def cn(self, v=None): self._doParam('CN', v)
- def cutype(self, v=None): self._doParam('CUTYPE', v)
- def dir(self, v=None): self._doParam('DIR', v)
- def delegated_from(self, v=None): self._doParam('DELEGATED-FROM', v)
- def delegated_to(self, v=None): self._doParam('DELEGATED-TO', v)
- def language(self, v=None): self._doParam('LANGUAGE', v)
- def member(self, v=None): self._doParam('MEMBER', v)
- def partstat(self, v=None): self._doParam('PARTSTAT', v)
- def role(self, v=None): self._doParam('ROLE', v)
- def rsvp(self, v=None): self._doParam('RSVP', v)
- def sent_by(self, v=None): self._doParam('SENT-BY', v)
-
-
-class Organizer(Property):
- """Class for Organizer property.
- """
-
- def __init__(self, arg={}):
-
- assert(isinstance(arg, DictType))
-
- ref = None
- if arg != {}:
- ref = arg['ref']
- Property.__init__(self, type='ORGANIZER', ref=ref)
-
-## param_t = ( 'CN', 'DIR', 'SENT-BY', 'LANGUAGE' )
-## for param in param_t:
-## self[param] = None
-## if value != None:
-## self.value(value)
-
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- def name(self):
- "Return the name of the property."
- return Property.name(self)
-
- def value_type(self):
- "Return the value type of the property."
- return self._desc['value_type']
-
- # Methods for accessing enumerated parameters
- def cn(self, v=None): self._doParam('CN', v)
- def dir(self, v=None): self._doParam('DIR', v)
- def language(self, v=None): self._doParam('LANGUAGE', v)
- def sent_by(self, v=None): self._doParam('SENT-BY', v)
-
-class Recurrence_Id(Time):
- """Class for RECURRENCE-ID property.
-
- Usage:
- Reccurence_Id(dict) # A normal property dictionary
- Reccurence_Id("19960401") # An iCalendar string
- Reccurence_Id(8349873494) # Seconds from epoch
-
- If the 'dict' constructor is used, 'name' and 'value_type'
- entries in dict are ignored and automatically set with the appropriate
- values.
- """
-
- def __init__(self, dict={}):
- Time.__init__(self, dict)
- Property.name(self, 'RECURRENCE-ID')
-
- def name(self):
- return Property.name(self)
-
- def _doParam(self, parameter, v):
- if v!=None:
- self[parameter]=v
- return self[parameter]
-
- # Enumerated parameters
- def value_parameter(self, v=None):
- """Sets or gets the VALUE parameter value.
-
- The value passed should be either "DATE-TIME" or "DATE". Setting this
- parameter has no impact on the property's value_type. Doing something
- like:
-
- rid=Recurrence_Id("19960401") # Sets value & makes value_type="DATE"
- rid.value_parameter("DATE-TIME") # Sets the parameter VALUE=DATE-TIME
-
- Would be allowed (even though it is wrong), so pay attention.
- Verifying the component will reveal the error.
- """
- if v!=None and v!="DATE" and v!="DATE-TIME":
- raise ValueError, "%s is an invalid VALUE parameter value" % str(v)
- self._doParam("VALUE", v)
-
- def tzid(self, v=None):
- "Sets or gets the TZID parameter value."
- self._doParam("TZID", v)
-
- def range_parameter(self, v=None): # 'range' is a builtin function
- "Sets or gets the RANGE parameter value."
- if v!=None and v!="THISANDPRIOR" and v!= "THISANDFUTURE":
- raise ValueError, "%s is an invalid RANGE parameter value" % str(v)
- self._doParam("RANGE", v)
-
-class Attach(Property):
- """A class representing an ATTACH property.
-
- Usage:
- Attach(uriString [, parameter_dict])
- Attach(fileObj [, parameter_dict])
- """
-
- def __init__(self, value=None, parameter_dict={}):
- Property.__init__(self, parameter_dict)
- Property.name(self, 'ATTACH')
- self.value(value)
-
- def value(self, v=None):
- "Returns or sets the value of the property."
- if v != None:
- if isinstance(v, StringType): # Is a URI
- self._desc['value']=v
- Property.value_type(self, 'URI')
- else:
- try:
- tempStr = v.read()
- except:
- raise TypeError,"%s must be a URL string or file-ish type"\
- % str(v)
- self._desc['value'] = base64.encodestring(tempStr)
- Property.value_type(self, 'BINARY')
- else:
- return self._desc['value']
-
- def name(self):
- "Returns the name of the property."
- return Property.name(self)
-
- def value_type(self):
- return Property.value_type(self)
-
- def fmttype(self, v=None):
- "Gets or sets the FMTYPE parameter."
- if v!= None:
- self['FMTTYPE']=v
- else:
- return self['FMTTYPE']
-
-class RecurrenceSet:
- """
- Represents a set of event occurrences. This
- class controls a component's RRULE, EXRULE, RDATE and EXDATE
- properties and can produce from them a set of occurrences.
- """
-
- def __init__(self):
- pass
-
- def include(self, **params):
- """
- Include a date or rule to the set.
-
- Use date= or pass in a
- Time instance to include a date. Included dates will add an
- RDATE property or will remove an EXDATE property of the same
- date.
-
- Use rule= or pass in a string to include a rule. Included
- rules with either add a RRULE property or remove an EXRULE
- property.
-
- """
- pass
-
- def exclude(self, **params):
- """
- Exclude date or rule to the set.
-
- Use date= or pass in a Time instance to exclude a
- date. Excluded dates will add an EXDATE property or will remove
- an RDATE property of the same date.
-
- Use rule= or pass in a string to exclude a rule. Excluded
- rules with either add an EXRULE property or remove an RRULE
- property.
-
- """
- pass
-
- def occurrences(self, count=None):
- """
- Return 'count' occurrences as a tuple of Time instances.
- """
- pass
-
-
diff --git a/libical/src/python/Store.py b/libical/src/python/Store.py
deleted file mode 100644
index 6d13bd5211..0000000000
--- a/libical/src/python/Store.py
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: Store.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from LibicalWrap import *
-from Error import LibicalError
-from Component import Component
-
-class Store:
- """
- Base class for several component storage methods
- """
-
- class AddFailedError(LibicalError):
- "Failed to add a property to the file store"
-
- class ConstructorFailedError(LibicalError):
- "Failed to create a Store "
-
- def __init__(self):
- pass
-
- def path(self):
- pass
-
- def mark(self):
- pass
-
- def commit(self):
- pass
-
- def add_component(self, comp):
- pass
-
- def remove_component(self, comp):
- pass
-
- def count_components(self, kind):
- pass
-
- def select(self, gauge):
- pass
-
- def clearSelect(self):
- pass
-
- def fetch(self, uid):
- pass
-
- def fetchMatch(self, comp):
- pass
-
- def modify(self, oldc, newc):
- pass
-
- def current_component(self):
- pass
-
- def first_component(self):
- pass
-
- def next_component(self):
- pass
-
-
-class FileStore(Store):
-
- def __init__(self, file,mode="r",flags=0664):
-
- _flags = icallangbind_string_to_open_flag(mode)
-
-
- if _flags == -1:
- raise Store.ConstructorFailedError("Illegal value for mode: "+mode)
-
- e1=icalerror_supress("FILE")
- self._ref = icalfileset_new_open(file,_flags,flags)
- icalerror_restore("FILE",e1)
-
- print self._ref
-
- if self._ref == None or self._ref == 'NULL':
- raise Store.ConstructorFailedError(file)
-
- def __del__(self):
- icalfileset_free(self._ref)
-
- def path(self):
- return icalfileset_path(self._ref)
-
- def mark(self):
- icalfileset_mark(self._ref)
-
- def commit(self):
- icalfileset_commit(self._ref)
-
- def add_component(self, comp):
- if not isinstance(comp,Component):
- raise Store.AddFailedError("Argument is not a component")
-
- error = icalfileset_add_component(self._ref,comp)
-
- def remove_component(self, comp):
- if not isinstance(comp,Component):
- raise Store.AddFailedError("Argument is not a component")
-
- error = icalfileset_remove_component(self._ref,comp)
-
-
-
- def count_components(self, kind):
- pass
-
- def select(self, gauge):
- pass
-
- def clearSelect(self):
- pass
-
- def fetch(self, uid):
- pass
-
- def fetchMatch(self, comp):
- pass
-
- def modify(self, oldc, newc):
- pass
-
- def current_component(self):
- comp_ref = icalfileset_get_current_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return Component(ref=comp_ref)
-
- def first_component(self):
- comp_ref = icalfileset_get_first_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return Component(ref=comp_ref)
-
- def next_component(self):
-
- comp_ref = icalfileset_get_next_component(self._ref)
-
- if comp_ref == None:
- return None
-
- return Component(ref=comp_ref)
-
diff --git a/libical/src/python/python-binding.txt b/libical/src/python/python-binding.txt
deleted file mode 100644
index 7fc9e066bf..0000000000
--- a/libical/src/python/python-binding.txt
+++ /dev/null
@@ -1,434 +0,0 @@
-
-Classes for python binding to libical
-(Indentation indicates inheritance)
-
- Component
- Event
- JournalEntry
- Todo
- FreeBusy
- Timezone
- Alarm
- AudioAlarm
- EmailAlarm
- ProcedureAlarm
- DisplayAlarm
-
- Property
- Attendee
- Organizer
- Status
- Error
-
- Time
- Period
- Date
- RecurrenceSet
-
- Timezone
- TimezonePhase
-
- Store
- FileStore
- DirStore
- CAPStore
- HeapStore
- MySQLStore
-
-
-
-Component is the central class in the design. The component can be
-though of as a container for child components and properties, or as
-representation of a specific kind of iCal object. The first
-interface offers general property and component accessors, and the
-second treats some types of objects in a special way.
-
-The general interface offers simple manipulators for child property
-and components, and it only works with immediate children. So, given
-the Component:
-
- BEGIN:VCALENDAR
- METHOD:PUBLISH
- BEGIN:VEVENT
- BEGIN:VALARM
- COMMENT: An Alarm
- END:VALARM
- END:VEVENT
- END:VCALENDAR
-
-A caller would have to descend three levels to access the COMMENT
-property in the alarm, but only one to access the METHOD property.
-
-Libical is almost entirely dedicated to the general interface; it
-includes all of the *get_first_*, *_next_next_*, *_add_* and *_remove_*
-routines.
-
-The specific interface works with derived classes of Property and
-Component. In this interface, the caller could get the COMMENT in the
-alarm in the example in two steps. First the caller would ask the
-Event object for its alarms, then then the caller would ask the first
-Alarm object for its comment.
-
-The Specific interface is part of the
-derived classes of Component. This interface names all of the types of
-properties and components that can be accessed from the derived
-component type.
-
-In libical, the specific interface is primarily the "convenience
-routines in icalcomponent.h, such as:
-
-
- struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
- void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
-
- void icalcomponent_set_duration(icalcomponent* comp,
- struct icaldurationtype v);
- struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
-
-These routines are smarter and do more work than the general
-interface. From the general interface, you can set the DTEND
-property of a component by creating the property and adding it to a
-component. But, if the component already has a DURATION property, then
-this is an error -- a component can't have both.
-
-icalcomponent_set_dtend determines if the component already has a
-DURATION. If it does, it substracts the dtstart time from the new
-dtend time and sets the duration to that. Otherwise, it creates aor
-changes the DTEND.
-
-Also, icalcomponent_set_duration works the same regardless if the
-component is a VCALENDAR or a VEVENT. If it is a VCALENDAR, the
-routine descends into the VEVENT before making any changes. If it is
-allready a VEVENT ( or VTODO or VJOURNAL ) the routine just makes the
-changes. With icalcomponent_add_property, you need to do this check
-yourself.
-
-( There should probably be a class between Component
-and Event ,JournalEntry and Todo that names all of the properties and
-components. Then Event, JournalEntry and Todo would remove the
-accessors that did not apply to them. )
-
-Parameters are accessed as dictionaries from Property or as attributes
-of a derived class of Property. Both the names and the values of the
-parameters are strings.
-
-The Store hierarchy is a interface to various ways to store iCal
-components. Each of these has the same interface as its corresponding
-libical module:
-
- FileStore icalfileset Store iCal components in a single file
- DirStore icaldirset Use multiple files, one per month of
- DTSTART
- CAPStore Access components in a CAP server
- HeapStore Components stored in memory
- MySQLStore Components stored in a MySQL
- database.
-
-The only iCal value objects that will be implemented as Python classes
-are Time, Duration and Period. RecurrenceSet handles recurrence
-rules. It replaces the properties RRULE, RDATE, EXRULE and EXDATE.
-
-(Not all of the libical modules are implemented )
-
-
-How to Use the library
-----------------------
-
-The most common usecases will be something like this:
-
-1)Caller opens a Store object on a file, server or database. The
-caller retrieves one or more component. Some of the components will be
-booked on the user's calendar. Other components will be messages that
-other users have sent, like requests for meetings.
-
-2) The caller will use the Specific interface ( using methods specific
-to each property ) to example the component and decide what to do with
-it.
-
-3) Rarely, the caller will access the general interface to do things
-that the specific interface has not implemented or cannot manage
-well.
-
-4) Cller may create a new component, using a combination of the
-general and specific interfaces. The caller may send the message to
-another user via mail, or may submit it to the user's CAP server with
-the CAPStore class.
-
-
-Following are the methods in each of the classes.
-
-Component
- Construct from string
- output string in ical form
-
- Get a Property by type
- Get a set of Properties by type
- Remove a Property by reference
-
- Get a Component by type
- Get a set of Components by type
- Remove a Component by reference
-
- Validate the component ( insert properties for errors )
- Count error properties
- Remove error properties
- Convert error properties into REQUEST-STATUS properties
-
-Event, JournalEntry, Todo
-
- Construct from string
- output string in ical form
-
- There are get/set accessors for every property. These are
- listed in a later section
-
-
-FreeBusy
-
- Construct from string
- Construct from arguments
- output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- method
- prodid
- attendee
- dtstamp
- dtstart
- freebusy
- organizer
- uid
- comment
- contact
- request-status
- url
- duration
- sequence
-
-TimezonePhase
-
- Construct from string
- Construct from arguments
- output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- tzname
- offsetto
- offsetfrom
- rrule
- rdate
- comment
-
-TimeZone
-
- Construct from string
- Construct from arguments
- output string in ical form
-
- Accessors for the following properties. See below for return
- types for these properties:
-
- tzid
- last-modified
- tzurl
- standard (returns TimezonePhase)
- daylight (returns TimezonePhase)
-
-
-Property
-
- Construct from string
- Construct from arguments
- output string in ical form
-
- Dictionary access to parameters
-
- Get/set value
-
-Attendee
-
- Construct from string
- Construct from arguments
- output string in ical form
-
- Access to the following properties and parameters:
- cuid
- cutype
- member
- role
- rsvp
- delto
- delfrom
- sentby
- cn
- dir
- language
-
-Organizer
-
- Access to the following properties:
- common_name
- dir
- sentby
- language
-
-
-Time
-Date
-Period
-
- Same interfaces as libical modules.
-
-RecurenceSet
- I don't know -- need to think about it more.
-
-Store
- Similar methods to the icalset modules.
-
-
-RFC2445 Properties
-
-This is a list of all of the RFC2445 properties and their associated
-VALUE type.
-
-
-Property Value
-----------------------------
-CALSCALE TEXT
-METHOD TEXT
-PRODID TEXT
-VERSION TEXT
-CATEGORIES TEXT
-CLASS TEXT
-COMMENT TEXT
-DESCRIPTION TEXT
-LOCATION TEXT
-PERCENT-COMPLETE INTEGER
-PRIORITY INTEGER
-RESOURCES TEXT
-STATUS STATUS
-SUMMARY TEXT
-COMPLETED DATE-TIME
-FREEBUSY PERIOD
-TRANSP TEXT
-TZNAME TEXT
-TZOFFSETFROM UTC-OFFSET
-TZOFFSETTO UTC-OFFSET
-TZURL URI
-TZID TEXT
-ATTENDEE CAL-ADDRESS
-CONTACT TEXT
-ORGANIZER CAL-ADDRESS
-RELATED-TO TEXT
-URL URI
-UID TEXT
-EXRULE RECUR
-RRULE RECUR
-ACTION TEXT
-REPEAT INTEGER
-CREATED DATE-TIME
-DTSTAMP DATE-TIME
-LAST-MODIFIED DATE-TIME
-SEQUENCE INTEGER
-X TEXT
-REQUEST-STATUS STRING
-ATTACH URL, BINARY
-GEO FLOAT
-DTEND DATE-TIME
-DUE DATE-TIME
-DTSTART DATE-TIME
-RECURRENCE-ID DATE-TIME
-EXDATE DATE-TIME
-RDATE DATE-TIME, PERIOD
-TRIGGER DATE-TIME, DURATION
-DURATION DURATION
-
-Some of the properties can appear multiple times in a component, other
-can appear only once. For a particular component, the number of times
-a property can apper may also change with the METHOD property
-associated with the component. This list shows which properties can
-appear multiple times for some ( but not all ) combinations of
-component type and METHOD value:
-
-ATTACH
-ATTENDEE
-CATEGORIES
-COMMENT
-CONTACT
-EXDATE
-EXRULE
-FREEBUSY
-NONE
-RDATE
-RELATEDTO
-REQUESTSTATUS
-RESOURCES
-RRULE
-TZNAME
-TZURL
-X
-
-
-This is a list of the value types and their associated python return
-types. A lowercased return type is a python builtin, and an
-uppercase-first-letter is a class in the library:
-
-
-Value Return Type
------------------------------------
-BINARY file
-BOOLEAN number
-CAL-ADDRESS string
-DATE Time
-DATE-TIME Time
-DURATION Duration
-FLOAT number
-GEO tuple
-INTEGER number
-METHOD string
-PERIOD Period
-RECUR RecurrenceSet
-TEXT string
-TIME Time
-URI string
-UTC-OFFSET number
-STATUS string
-X string
-
-
-I suspect that the Component class should use the three previous
-tables to create the property accessor methods on the fly. If the
-method generation system is general enough, we could also use it for
-other classes, such as Alarm, Timezone, Attendee, Organizer and
-Freebusy.
-
-
-Memory Handling
----------------
-
-One of the things that made the perl binding to libcal difficult was
-that if a Component (in perl) returns a reference to a child Component
-(in perl), the child Component (in perl) will contain a reference to a
-libical component. When the caller is done with the child component in
-perl, the caller just drops it and lets perl reclaim the memory.
-
-The destructor for Component needs to free the libical component that
-it holds a reference to, but the child's libical component is still
-being used by libical. So perl frees the libical component and later,
-libical tries to reference freed memory.
-
-The situation is actually a little better than that, because libical
-will throw an error when you try to free a component that is still
-attached to a parent.
-
-So, the perl library has to be able to determine when the destructor
-should free a libical component or not. The perl library calls
-icalcomponent_get_parent(), and if is it non-zero, it does not free
-the component.
-
-It is not hard, just more code, and something to watch out for.
-
diff --git a/libical/src/python/test.py b/libical/src/python/test.py
deleted file mode 100644
index 1fdf515408..0000000000
--- a/libical/src/python/test.py
+++ /dev/null
@@ -1,373 +0,0 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
-#======================================================================
-# FILE: test.py
-# CREATOR: eric
-#
-# DESCRIPTION:
-#
-#
-# $Id$
-# $Locker$
-#
-# (C) COPYRIGHT 2001, Eric Busboom <eric@softwarestudio.org>
-# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com>
-#
-# 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/
-#======================================================================
-
-from Libical import *
-
-def error_type():
- error = icalerror_perror()
- return error[:index(error,':')]
-
-comp_str = """
-BEGIN:VEVENT
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com
-COMMENT: When in the course of writting comments and nonsense text\, it
- becomes necessary to insert a newline
-DTSTART:19972512T120000
-DTSTART:19970101T120000Z
-DTSTART:19970101
-DURATION:P3DT4H25M
-FREEBUSY:19970101T120000/19970101T120000
-FREEBUSY:19970101T120000/PT3H
-FREEBUSY:19970101T120000/PT3H
-END:VEVENT"""
-
-
-def test_property():
-
- print "--------------------------- Test Property ----------------------"
-
- liw = LibicalWrap
- icalprop = liw.icalproperty_new_from_string("ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com")
-
- print liw.icalproperty_as_ical_string(icalprop)
-
- p = Property(ref=icalprop)
-
- print p.name()
- print p.parameters()
- print p['ROLE']
-
- p['ROLE'] = 'INDIVIDUAL'
-
- print p['ROLE']
-
- print p.value()
- p.value("mailto:Bob@bob.com")
- print p.value()
-
-
- print p.as_ical_string()
-
- try:
- p = Property()
- except Property.ConstructorFailedError:
- pass
- else:
- assert(0)
-
-def test_time():
- "Test routine"
-
- print"-------------------Test Time --------------------------------"
-
- t = Time("19970325T123010Z",'DTSTART')
-
- assert(t.year() == 1997)
- assert(t.month() == 3)
- assert(t.day() == 25)
- assert(t.hour() == 12)
- assert(t.minute() == 30)
- assert(t.second() == 10)
- assert(t.is_utc())
- assert(not t.is_date())
-
- print t
-
- t.timezone("America/Los_Angeles")
- print str(t)
- assert(str(t)=='DTSTART;TZID=America/Los_Angeles:19970325T123010Z')
-
- t.second(t.second()+80)
-
- print t
-
- assert(t.minute() == 31)
- assert(t.second() == 30)
-
- d = Duration(3600,"DURATION")
- t2 = t + d
-
- print t2
- assert(t2.hour() == 13)
-
- t2 = t - d
-
- print t2
- assert(isinstance(t2,Time))
- assert(t2.hour() == 11)
-
-
-def test_period():
-
- print"-------------------Test Period--------------------------------"
-
- p = Period("19970101T180000Z/19970101T233000Z")
-
- print p
-
-
- assert(str(p) == 'FREEBUSY:19970101T180000Z/19970101T233000Z')
-
- print p.start()
- assert(str(p.start()) == 'DTSTART:19970101T180000Z')
-
- print p.end()
- assert(str(p.end()) == 'DTEND:19970101T233000Z')
-
- print p.duration()
- assert(str(p.duration()) == 'DURATION:PT5H30M')
- p = None
-
- p = Period("19970101T180000Z/PT5H30M")
- print p
-
- print p.start()
- assert(str(p.start()) == 'DTSTART:19970101T180000Z')
-
- print p.end()
- assert(str(p.end()) == 'DTEND:19970101T233000Z')
-
- print p.duration()
- assert(str(p.duration()) == 'DURATION:PT5H30M')
-
-
-def test_duration():
-
- print "-------------- Test Duration ----------------"
-
- # Ical string
-
- d = Duration("P3DT4H25M")
-
- print str(d)
-
- assert(str(d) == "DURATION:P3DT4H25M")
-
- print d.seconds()
-
- assert(d.seconds() == 275100)
-
- # seconds
-
- d = Duration(-275100)
-
- print str(d)
-
- assert(str(d) == "DURATION:-P3DT4H25M")
-
- print d.seconds()
-
- assert(d.seconds() == -275100)
-
- #error
-
- try:
- d = Duration("P10WT7M")
- print str(d)
- assert(0)
- except: pass
-
- try:
- d = Duration("Pgiberish")
- print str(d)
- assert(0)
- except:
- pass
-
-
-
-def test_attach():
-
- file = open('littlefile.txt')
- attachProp = Attach(file)
- file.close()
- attachProp.fmttype('text/ascii')
- print "\n" + attachProp.name()
- print attachProp.value_type()
- print attachProp.fmttype()
- attachProp['fmttype']=None
- print "Calling value()"
- print attachProp.value()
- print "Calling asIcalString()"
- print attachProp.as_ical_string()
-
-
-def test_component():
-
- print "------------------- Test Component ----------------------"
-
-
- c = Component(comp_str);
-
- props = c.properties()
-
- for p in props:
- print p.as_ical_string()
-
- dtstart = c.properties('DTSTART')[0]
-
- print dtstart
-
- print "\n Orig hour: ", dtstart.hour()
- assert(dtstart.hour() == 12)
-
- dtstart.hour(dtstart.hour() + 5)
-
- print "\n New hour: ", dtstart.hour()
- assert(dtstart.hour() == 17)
-
- attendee = c.properties('ATTENDEE')[0]
-
- print attendee
-
- t = Time("20011111T123030")
- t.name('DTEND')
-
- c.add_property(t)
-
-
- print c
-
- dtstart1 = c.properties('DTSTART')[0]
- dtstart2 = c.properties('DTSTART')[0]
- dtstart3 = c.property('DTSTART')
-
- assert(dtstart1 is dtstart2)
- assert(dtstart1 == dtstart2)
-
- assert(dtstart1 is dtstart3)
- assert(dtstart1 == dtstart3)
-
-
- p = Property(type="SUMMARY");
- p.value("This is a summary")
-
- c.properties().append(p)
-
- print c.as_ical_string()
-
- p = c.properties("SUMMARY")[0]
- assert(p!=None);
- print str(p)
- assert(str(p) == "SUMMARY:This is a summary")
-
- c.properties()[:] = [p]
-
- print c.as_ical_string()
-
-
-def test_event():
- print "------------ Event Class ----------------------"
- event = Event()
- event.created("20010313T123000Z")
- #print "created =", event.created()
- assert (event.created() == "20010313T123000Z")
-
- event.organizer("MAILTO:j_doe@nowhere.com")
- org = event.properties('ORGANIZER')[0]
- #print org.cn()
- org.cn('Jane Doe')
- assert (isinstance(org, Organizer))
- #print "organizer =", event.organizer()
- assert (event.organizer() == "MAILTO:j_doe@nowhere.com")
-
- event.dtstart("20010401T183000Z")
- #print "dtstart =", event.dtstart()
- assert (event.dtstart()=="20010401T183000Z")
-
- dtend = Time('20010401T190000Z', 'DTEND')
- event.dtend(dtend)
- assert (event.dtend()==dtend.value())
- assert (event.dtend() == '20010401T190000Z')
-
- att = Attendee()
- att.value('jsmith@nothere.com')
- event.attendees(('ef_hutton@listenup.com', att))
-
- event.description("A short description. Longer ones break things.")
- event.status('TeNtAtIvE')
-
- print event.as_ical_string()
-
-
-def test_derivedprop():
-
- print "------------ Derived Properties -----------------"
-
- p = RDate("20011111T123030")
-
- print str(p)
-
-
- p = RDate("19970101T120000/19970101T123000")
-
- print str(p)
-
- try:
- p = RDate("P3DT4H25M")
- print str(p)
- assert(0)
- except: pass
-
-
- p = Trigger("P3DT4H25M")
-
- print str(p)
-
- p = Trigger("20011111T123030")
-
- print str(p)
-
- try:
- p = Trigger("19970101T120000/19970101T123000")
- print str(p)
- assert(0)
- except: pass
-
-
-def run_tests():
- test_property()
-
- test_time()
-
- test_period()
-
- test_component()
-
- test_duration()
-
- test_derivedprop()
-
- test_event()
-
- #test_attach()
-
-
-
-if __name__ == "__main__":
- run_tests()
-
diff --git a/libical/src/test/.cvsignore b/libical/src/test/.cvsignore
deleted file mode 100644
index ed72bfe59f..0000000000
--- a/libical/src/test/.cvsignore
+++ /dev/null
@@ -1,18 +0,0 @@
-*.la
-*.lo
-.libs
-Makefile
-Makefile.in
-.deps
-.libs
-copycluster
-regression
-parser
-findobj
-storage
-stow
-recur
-testmime
-testvcal
-
-
diff --git a/libical/src/test/Makefile.am b/libical/src/test/Makefile.am
deleted file mode 100644
index d4fa33c040..0000000000
--- a/libical/src/test/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-
-noinst_PROGRAMS = copycluster regression parser storage stow recur testmime testvcal process testclassify
-
-LDADD = ../libicalss/.libs/libicalss.a ../libicalvcal/.libs/libicalvcal.a ../libical/.libs/libical.a
-
-INCLUDES = \
- -I. \
- -I../libicalvcal \
- -I$(srcdir)/../libicalvcal \
- -I$(srcdir) \
- -I../libical \
- -I$(srcdir)/../libical \
- -I../libicalss \
- -I$(srcdir)/../libicalss
-
-copycluster_SOURCES = copycluster.c
-regression_SOURCES = regression.c
-parser_SOURCES = icaltestparser.c
-storage_SOURCES = storage.c
-stow_SOURCES = stow.c
-testvcal_SOURCES = testvcal.c
-recur_SOURCES = recur.c
-testmime_SOURCES = testmime.c
-process_SOURCES = process.c
-testclassify_SOURCES = testclassify.c
diff --git a/libical/src/test/copycluster.c b/libical/src/test/copycluster.c
deleted file mode 100644
index 4eefc37758..0000000000
--- a/libical/src/test/copycluster.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: copycluster.c
- CREATOR: eric 15 January 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 "icalfileset.h"
-#include <errno.h>
-#include <string.h> /* For strerror */
-#include <signal.h> /* for signal */
-#include <unistd.h> /* for alarm */
-#include "icalrestriction.h"
-
-static void sig_alrm(int i){
- fprintf(stderr,"Could not get lock on file\n");
- exit(1);
-}
-/* This program copies a file that holds iCal components to an other file. */
-
-
-void usage(char* arg0) {
- printf("usage: %s cluster-file1 cluster-file2\n",arg0);
-}
-
-int main(int c, char *argv[]){
-
- icalfileset *clusterin, *clusterout;
- icalcomponent *itr;
- int count=0;
- int tostdout = 0;
-
- if(c < 2 || c > 3){
- usage(argv[0]);
- exit(1);
- }
-
- if (c == 2){
- tostdout = 1;
- }
-
-
- icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
-
-
- signal(SIGALRM,sig_alrm);
-
- alarm(0);
- clusterin = icalfileset_new(argv[1]);
- alarm(0);
-
- if (clusterin == 0){
- printf("Could not open input cluster \"%s\"",argv[1]);
-
- exit(1);
- }
-
- if (!tostdout){
- clusterout = icalfileset_new(argv[2]);
- if (clusterout == 0){
- printf("Could not open output cluster \"%s\"\n",argv[2]);
- exit(1);
- }
- }
-
-
- for (itr = icalset_get_first_component(clusterin);
- itr != 0;
- itr = icalset_get_next_component(clusterin)){
-
- icalerror_set_error_state(ICAL_BADARG_ERROR, ICAL_ERROR_NONFATAL);
- icalrestriction_check(itr);
- icalerror_set_error_state(ICAL_BADARG_ERROR, ICAL_ERROR_DEFAULT);
-
- if (itr != 0){
-
- if(tostdout){
-
- printf("--------------\n%s\n",icalcomponent_as_ical_string(itr));
-
- } else {
-
- icalfileset_add_component(clusterout,
- icalcomponent_new_clone(itr));
- }
-
- count++;
-
- } else {
- printf("Got NULL component");
- }
- }
-
-
- printf("Transfered %d components\n",count);
-
- icalfileset_free(clusterin);
-
- if (!tostdout){
- icalfileset_mark(clusterout);
- icalfileset_free(clusterout);
- }
-
- return 0;
-}
-
-
diff --git a/libical/src/test/findobj.c b/libical/src/test/findobj.c
deleted file mode 100644
index c31101c33d..0000000000
--- a/libical/src/test/findobj.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: findobj.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 "icalcalendar.h"
-#include "icaldirset.h"
-#include <errno.h>
-#include <string.h> /* For strerror */
-#include "icalrestriction.h"
-
-/* This program finds an object stored in a calendar */
-
-void usage(char* arg0) {
- printf("usage: %s calendar-dir uid\n",arg0);
-}
-
-int main(int c, char *argv[]){
-
- icalcalendar *cal;
- icaldirset *booked;
- icalcomponent *itr;
-
- if(c < 2 || c > 3){
- usage(argv[0]);
- exit(1);
- }
-
- cal = icalcalendar_new(argv[1]);
-
- if(cal == 0){
- fprintf(stderr,"%s: error in opening calendar \"%s\": %s. errno is \"%s\"\n",
- argv[0],argv[1],icalerror_strerror(icalerrno),
- strerror(errno));
- }
-
- booked = icalcalendar_get_booked(cal);
-
- itr = icaldirset_fetch(booked,argv[2]);
-
-
- if(itr != 0){
- printf("%s",icalcomponent_as_ical_string(itr));
- }
-
- return 0;
-}
-
diff --git a/libical/src/test/icaltestparser.c b/libical/src/test/icaltestparser.c
deleted file mode 100644
index e5973e0d4a..0000000000
--- a/libical/src/test/icaltestparser.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: icaltestparser.c
- CREATOR: eric 20 June 1999
-
- $Id$
- $Locker$
-
- 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 author is Eric Busboom
- The original code is icaltestparser.c
-
-
- (C) COPYRIGHT 1999 The Software Studio.
- http://www.softwarestudio.org
-
- ======================================================================*/
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include "ical.h"
-
-#include <stdlib.h>
-
-char str[] = "BEGIN:VCALENDAR\
-PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\
-VERSION:2.0\
-BEGIN:VTIMEZONE\
-TZID:US-Eastern\
-BEGIN:STANDARD\
-DTSTART:19990404T020000\
-RDATE:19990u404xT020000\
-TZOFFSETFROM:-0500\
-TZOFFSETTO:-0400\
-END:STANDARD\
-BEGIN:DAYLIGHT\
-DTSTART:19990404T020000\
-RDATE:19990404T020000\
-TZOFFSETFROM:-0500\
-TZOFFSETTO:-0400\
-TZNAME:EDT\
-Dkjhgri:derhvnv;\
-BEGIN:dfkjh\
-END:dfdfkjh\
-END:DAYLIGHT\
-END:VTIMEZONE\
-BEGIN:VEVENT\
-GEO:Bongo\
-DTSTAMP:19980309T231000Z\
-UID:guid-1.host1.com\
-ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP\
- :MAILTO:employee-A@host.com\
-DESCRIPTION:Project XYZ Review Meeting\
-CATEGORIES:MEETING\
-CLASS:PUBLIC\
-CREATED:19980309T130000Z\
-SUMMARY:XYZ Project Review\
-DTSTART;TZID=US-Eastern:19980312T083000\
-DTEND;TZID=US-Eastern:19980312T093000\
-LOCATION:1CP Conference Room 4350\
-END:VEVENT\
-END:VCALENDAR\
-";
-
-extern int yydebug;
-
-/* Have the parser fetch data from stdin */
-
-char* read_stream(char *s, size_t size, void *d)
-{
- char *c = fgets(s,size, (FILE*)d);
-
- return c;
-
-}
-
-
-
-int main(int argc, char* argv[])
-{
-
- char* line;
- FILE* stream;
- icalcomponent *c;
- icalparser *parser = icalparser_new();
-
- stream = fopen(argv[1],"r");
-
- assert(stream != 0);
-
- icalparser_set_gen_data(parser,stream);
-
- do{
-
- line = icalparser_get_line(parser,read_stream);
-
- c = icalparser_add_line(parser,line);
-
-
- if (c != 0){
- /*icalcomponent_convert_errors(c);*/
- printf("%s",icalcomponent_as_ical_string(c));
- printf("\n---------------\n");
- icalcomponent_free(c);
- }
-
- } while ( line != 0);
-
- return 0;
- }
diff --git a/libical/src/test/process.c b/libical/src/test/process.c
deleted file mode 100644
index 56f1c65fb1..0000000000
--- a/libical/src/test/process.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/* -*- 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.
-
- ======================================================================*/
-
-#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 *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/recur.c b/libical/src/test/recur.c
deleted file mode 100644
index f4d9a38647..0000000000
--- a/libical/src/test/recur.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: recur.c
- CREATOR: ebusboom 8jun00
-
- DESCRIPTION:
-
- Test program for expanding recurrences. Run as:
-
- ./recur ../../test-data/recur.txt
-
-
- (C) COPYRIGHT 1999 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.
-
- ======================================================================*/
-
-#include "ical.h"
-#include <assert.h>
-#include <string.h> /* for strdup */
-#include <stdlib.h> /* for malloc */
-#include <stdio.h> /* for printf */
-#include <time.h> /* for time() */
-#include <signal.h> /* for signal */
-#include <unistd.h> /* for alarm */
-#include "icalmemory.h"
-#include "icaldirset.h"
-#include "icalfileset.h"
-
-static void sig_alrm(int i){
- fprintf(stderr,"Could not get lock on file\n");
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- icalfileset *cin;
- struct icaltimetype start, next;
- icalcomponent *itr;
- icalproperty *desc, *dtstart, *rrule;
- struct icalrecurrencetype recur;
- icalrecur_iterator* ritr;
- time_t tt;
- char* file;
-
- icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
-
- signal(SIGALRM,sig_alrm);
-
-
- if (argc <= 1){
- file = "../../test-data/recur.txt";
- } else if (argc == 2){
- file = argv[1];
- } else {
- fprintf(stderr,"usage: recur [input file]\n");
- exit(1);
- }
-
- alarm(300); /* to get file lock */
- cin = icalfileset_new(file);
- alarm(0);
-
- if(cin == 0){
- fprintf(stderr,"recur: can't open file %s\n",file);
- exit(1);
- }
-
-
- for (itr = icalfileset_get_first_component(cin);
- itr != 0;
- itr = icalfileset_get_next_component(cin)){
-
- desc = icalcomponent_get_first_property(itr,ICAL_DESCRIPTION_PROPERTY);
- dtstart = icalcomponent_get_first_property(itr,ICAL_DTSTART_PROPERTY);
- rrule = icalcomponent_get_first_property(itr,ICAL_RRULE_PROPERTY);
-
- if (desc == 0 || dtstart == 0 || rrule == 0){
- printf("\n******** Error in input component ********\n");
- printf("The following component is malformed:\n %s\n",
- icalcomponent_as_ical_string(itr));
- continue;
- }
-
- printf("\n\n#### %s\n",icalproperty_get_description(desc));
- printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule)));
- recur = icalproperty_get_rrule(rrule);
- start = icalproperty_get_dtstart(dtstart);
-
- ritr = icalrecur_iterator_new(recur,start);
-
- tt = icaltime_as_timet(start);
-
- printf("#### %s\n",ctime(&tt ));
-
- for(ritr = icalrecur_iterator_new(recur,start),
- next = icalrecur_iterator_next(ritr);
- !icaltime_is_null_time(next);
- next = icalrecur_iterator_next(ritr)){
-
- tt = icaltime_as_timet(next);
-
- printf(" %s",ctime(&tt ));
-
- }
-
- }
-
- return 0;
-}
diff --git a/libical/src/test/regression.c b/libical/src/test/regression.c
deleted file mode 100644
index 08696207f2..0000000000
--- a/libical/src/test/regression.c
+++ /dev/null
@@ -1,3605 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: regression.c
- CREATOR: eric 03 April 1999
-
- DESCRIPTION:
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
- The original code is regression.c
-
-
- ======================================================================*/
-
-#include "ical.h"
-#include "icalss.h"
-
-#include <assert.h>
-#include <string.h> /* for strdup */
-#include <stdlib.h> /* for malloc */
-#include <stdio.h> /* for printf */
-#include <time.h> /* for time() */
-#include <unistd.h> /* for unlink, fork */
-#include <sys/wait.h> /* For waitpid */
-#include <sys/types.h> /* For wait pid */
-#include <sys/time.h> /* for select */
-
-
-/* For GNU libc, strcmp appears to be a macro, so using strcmp in
- assert results in incomprehansible assertion messages. This
- eliminates the problem */
-
-int regrstrcmp(const char* a, const char* b){
- return strcmp(a,b);
-}
-
-/* This example creates and minipulates the ical object that appears
- * in rfc 2445, page 137 */
-
-char str[] = "BEGIN:VCALENDAR\
-PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\
-VERSION:2.0\
-BEGIN:VTIMEZONE\
-TZID:US-Eastern\
-BEGIN:STANDARD\
-DTSTART:19981025T020000\
-RDATE:19981025T020000\
-TZOFFSETFROM:-0400\
-TZOFFSETTO:-0500\
-TZNAME:EST\
-END:STANDARD\
-BEGIN:DAYLIGHT\
-DTSTART:19990404T020000\
-RDATE:19990404T020000\
-TZOFFSETFROM:-0500\
-TZOFFSETTO:-0400\
-TZNAME:EDT\
-END:DAYLIGHT\
-END:VTIMEZONE\
-BEGIN:VEVENT\
-DTSTAMP:19980309T231000Z\
-UID:guid-1.host1.com\
-ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\
-DESCRIPTION:Project XYZ Review Meeting\
-CATEGORIES:MEETING\
-CLASS:PUBLIC\
-CREATED:19980309T130000Z\
-SUMMARY:XYZ Project Review\
-DTSTART;TZID=US-Eastern:19980312T083000\
-DTEND;TZID=US-Eastern:19980312T093000\
-LOCATION:1CP Conference Room 4350\
-END:VEVENT\
-BEGIN:BOOGA\
-DTSTAMP:19980309T231000Z\
-X-LIC-FOO:Booga\
-DTSTOMP:19980309T231000Z\
-UID:guid-1.host1.com\
-END:BOOGA\
-END:VCALENDAR";
-
-
-icalcomponent* create_simple_component()
-{
-
- icalcomponent* calendar;
- struct icalperiodtype rtime;
-
- rtime.start = icaltime_from_timet( time(0),0);
- rtime.end = icaltime_from_timet( time(0),0);
-
- rtime.end.hour++;
-
-
-
- /* Create calendar and add properties */
- calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
-
-
- icalcomponent_add_property(
- calendar,
- icalproperty_new_version("2.0")
- );
-
- printf("%s\n",icalcomponent_as_ical_string(calendar));
-
- return calendar;
-
-}
-
-/* Create a new component */
-icalcomponent* create_new_component()
-{
-
- icalcomponent* calendar;
- icalcomponent* timezone;
- icalcomponent* tzc;
- icalcomponent* event;
- struct icaltimetype atime = icaltime_from_timet( time(0),0);
- struct icaldatetimeperiodtype rtime;
- icalproperty* property;
-
- rtime.period.start = icaltime_from_timet( time(0),0);
- rtime.period.end = icaltime_from_timet( time(0),0);
- rtime.period.end.hour++;
- rtime.time = icaltime_null_time();
-
-
-
- /* Create calendar and add properties */
- calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
-
-
- icalcomponent_add_property(
- calendar,
- icalproperty_new_version("2.0")
- );
-
- icalcomponent_add_property(
- calendar,
- icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN")
- );
-
- /* Create a timezone object and add it to the calendar */
-
- timezone = icalcomponent_new(ICAL_VTIMEZONE_COMPONENT);
-
- icalcomponent_add_property(
- timezone,
- icalproperty_new_tzid("US_Eastern")
- );
-
- /* Add a sub-component of the timezone */
- tzc = icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT);
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_dtstart(atime)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_rdate(rtime)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzoffsetfrom(-4.0)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzoffsetto(-5.0)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzname("EST")
- );
-
- icalcomponent_add_component(timezone,tzc);
-
- icalcomponent_add_component(calendar,timezone);
-
- /* Add a second subcomponent */
- tzc = icalcomponent_new(ICAL_XSTANDARD_COMPONENT);
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_dtstart(atime)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_rdate(rtime)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzoffsetfrom(-4.0)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzoffsetto(-5.0)
- );
-
- icalcomponent_add_property(
- tzc,
- icalproperty_new_tzname("EST")
- );
-
- icalcomponent_add_component(timezone,tzc);
-
- /* Add an event */
-
- event = icalcomponent_new(ICAL_VEVENT_COMPONENT);
-
- icalcomponent_add_property(
- event,
- icalproperty_new_dtstamp(atime)
- );
-
- icalcomponent_add_property(
- event,
- icalproperty_new_uid("guid-1.host1.com")
- );
-
- /* add a property that has parameters */
- property = icalproperty_new_organizer("mrbig@host.com");
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_role(ICAL_ROLE_CHAIR)
- );
-
- icalcomponent_add_property(event,property);
-
- /* add another property that has parameters */
- property = icalproperty_new_attendee("employee-A@host.com");
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT)
- );
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_rsvp(ICAL_RSVP_TRUE)
- );
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_cutype(ICAL_CUTYPE_GROUP)
- );
-
- icalcomponent_add_property(event,property);
-
-
- /* more properties */
-
- icalcomponent_add_property(
- event,
- icalproperty_new_description("Project XYZ Review Meeting")
- );
-
- icalcomponent_add_property(
- event,
- icalproperty_new_categories("MEETING")
- );
-
- icalcomponent_add_property(
- event,
- icalproperty_new_class("PUBLIC")
- );
-
- icalcomponent_add_property(
- event,
- icalproperty_new_created(atime)
- );
-
- icalcomponent_add_property(
- event,
- icalproperty_new_summary("XYZ Project Review")
- );
-
-
- property = icalproperty_new_dtstart(atime);
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_tzid("US-Eastern")
- );
-
- icalcomponent_add_property(event,property);
-
-
- property = icalproperty_new_dtend(atime);
-
- icalproperty_add_parameter(
- property,
- icalparameter_new_tzid("US-Eastern")
- );
-
- icalcomponent_add_property(event,property);
-
- icalcomponent_add_property(
- event,
- icalproperty_new_location("1CP Conference Room 4350")
- );
-
- icalcomponent_add_component(calendar,event);
-
- printf("%s\n",icalcomponent_as_ical_string(calendar));
-
- icalcomponent_free(calendar);
-
- return 0;
-}
-
-
-/* Create a new component, using the va_args list */
-
-icalcomponent* create_new_component_with_va_args()
-{
-
- icalcomponent* calendar;
- struct icaltimetype atime = icaltime_from_timet( time(0),0);
- struct icaldatetimeperiodtype rtime;
-
- rtime.period.start = icaltime_from_timet( time(0),0);
- rtime.period.end = icaltime_from_timet( time(0),0);
- rtime.period.end.hour++;
- rtime.time = icaltime_null_time();
-
- calendar =
- icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"),
- icalcomponent_vanew(
- ICAL_VTIMEZONE_COMPONENT,
- icalproperty_new_tzid("US_Eastern"),
- icalcomponent_vanew(
- ICAL_XDAYLIGHT_COMPONENT,
- icalproperty_new_dtstart(atime),
- icalproperty_new_rdate(rtime),
- icalproperty_new_tzoffsetfrom(-4.0),
- icalproperty_new_tzoffsetto(-5.0),
- icalproperty_new_tzname("EST"),
- 0
- ),
- icalcomponent_vanew(
- ICAL_XSTANDARD_COMPONENT,
- icalproperty_new_dtstart(atime),
- icalproperty_new_rdate(rtime),
- icalproperty_new_tzoffsetfrom(-5.0),
- icalproperty_new_tzoffsetto(-4.0),
- icalproperty_new_tzname("EST"),
- 0
- ),
- 0
- ),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstamp(atime),
- icalproperty_new_uid("guid-1.host1.com"),
- icalproperty_vanew_organizer(
- "mrbig@host.com",
- icalparameter_new_role(ICAL_ROLE_CHAIR),
- 0
- ),
- icalproperty_vanew_attendee(
- "employee-A@host.com",
- icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT),
- icalparameter_new_rsvp(ICAL_RSVP_TRUE),
- icalparameter_new_cutype(ICAL_CUTYPE_GROUP),
- 0
- ),
- icalproperty_new_description("Project XYZ Review Meeting"),
- icalproperty_new_categories("MEETING"),
- icalproperty_new_class("PUBLIC"),
- icalproperty_new_created(atime),
- icalproperty_new_summary("XYZ Project Review"),
- icalproperty_vanew_dtstart(
- atime,
- icalparameter_new_tzid("US-Eastern"),
- 0
- ),
- icalproperty_vanew_dtend(
- atime,
- icalparameter_new_tzid("US-Eastern"),
- 0
- ),
- icalproperty_new_location("1CP Conference Room 4350"),
- 0
- ),
- 0
- );
-
- printf("%s\n",icalcomponent_as_ical_string(calendar));
-
-
- icalcomponent_free(calendar);
-
- return 0;
-}
-
-
-/* Return a list of all attendees who are required. */
-
-char** get_required_attendees(icalproperty* event)
-{
- icalproperty* p;
- icalparameter* parameter;
-
- char **attendees;
- int max = 10;
- int c = 0;
-
- attendees = malloc(max * (sizeof (char *)));
-
- assert(event != 0);
- assert(icalcomponent_isa(event) == ICAL_VEVENT_COMPONENT);
-
- for(
- p = icalcomponent_get_first_property(event,ICAL_ATTENDEE_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(event,ICAL_ATTENDEE_PROPERTY)
- ) {
-
- parameter = icalproperty_get_first_parameter(p,ICAL_ROLE_PARAMETER);
-
- if ( icalparameter_get_role(parameter) == ICAL_ROLE_REQPARTICIPANT)
- {
- attendees[c++] = icalmemory_strdup(icalproperty_get_attendee(p));
-
- if (c >= max) {
- max *= 2;
- attendees = realloc(attendees, max * (sizeof (char *)));
- }
-
- }
- }
-
- return attendees;
-}
-
-/* If an attendee has a PARTSTAT of NEEDSACTION or has no PARTSTAT
- parameter, change it to TENTATIVE. */
-
-void update_attendees(icalproperty* event)
-{
- icalproperty* p;
- icalparameter* parameter;
-
-
- assert(event != 0);
- assert(icalcomponent_isa(event) == ICAL_VEVENT_COMPONENT);
-
- for(
- p = icalcomponent_get_first_property(event,ICAL_ATTENDEE_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(event,ICAL_ATTENDEE_PROPERTY)
- ) {
-
- parameter = icalproperty_get_first_parameter(p,ICAL_PARTSTAT_PARAMETER);
-
- if (parameter == 0) {
-
- icalproperty_add_parameter(
- p,
- icalparameter_new_partstat(ICAL_PARTSTAT_TENTATIVE)
- );
-
- } else if (icalparameter_get_partstat(parameter) == ICAL_PARTSTAT_NEEDSACTION) {
-
- icalproperty_remove_parameter(p,ICAL_PARTSTAT_PARAMETER);
-
- icalparameter_free(parameter);
-
- icalproperty_add_parameter(
- p,
- icalparameter_new_partstat(ICAL_PARTSTAT_TENTATIVE)
- );
- }
-
- }
-}
-
-
-void test_values()
-{
- icalvalue *v;
- icalvalue *copy;
-
- v = icalvalue_new_caladdress("cap://value/1");
- printf("caladdress 1: %s\n",icalvalue_get_caladdress(v));
- icalvalue_set_caladdress(v,"cap://value/2");
- printf("caladdress 2: %s\n",icalvalue_get_caladdress(v));
- printf("String: %s\n",icalvalue_as_ical_string(v));
-
- copy = icalvalue_new_clone(v);
- printf("Clone: %s\n",icalvalue_as_ical_string(v));
- icalvalue_free(v);
- icalvalue_free(copy);
-
-
- v = icalvalue_new_boolean(1);
- printf("caladdress 1: %d\n",icalvalue_get_boolean(v));
- icalvalue_set_boolean(v,2);
- printf("caladdress 2: %d\n",icalvalue_get_boolean(v));
- printf("String: %s\n",icalvalue_as_ical_string(v));
-
- copy = icalvalue_new_clone(v);
- printf("Clone: %s\n",icalvalue_as_ical_string(v));
- icalvalue_free(v);
- icalvalue_free(copy);
-
-
- v = icalvalue_new_date(icaltime_from_timet( time(0),0));
- printf("date 1: %s\n",icalvalue_as_ical_string(v));
- icalvalue_set_date(v,icaltime_from_timet( time(0)+3600,0));
- printf("date 2: %s\n",icalvalue_as_ical_string(v));
-
- copy = icalvalue_new_clone(v);
- printf("Clone: %s\n",icalvalue_as_ical_string(v));
- icalvalue_free(v);
- icalvalue_free(copy);
-
-
- v = icalvalue_new(-1);
-
- printf("Invalid type: %p\n",v);
-
- if (v!=0) icalvalue_free(v);
-
- assert(ICAL_BOOLEAN_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_BOOLEAN));
- assert(ICAL_UTCOFFSET_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_UTCOFFSET));
- assert(ICAL_RECUR_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_RECUR));
- assert(ICAL_CALADDRESS_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_CALADDRESS));
- assert(ICAL_PERIOD_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_PERIOD));
- assert(ICAL_BINARY_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_BINARY));
- assert(ICAL_TEXT_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_TEXT));
- assert(ICAL_DURATION_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_DURATION));
- assert(ICAL_INTEGER_VALUE == icalparameter_value_to_value_kind(ICAL_VALUE_INTEGER));
- assert(ICAL_TIME_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_TIME));
- assert(ICAL_URI_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_URI));
- assert(ICAL_FLOAT_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_FLOAT));
- assert(ICAL_X_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_X));
- assert(ICAL_DATETIME_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_DATETIME));
- assert(ICAL_DATE_VALUE ==
- icalparameter_value_to_value_kind(ICAL_VALUE_DATE));
-
- /* v = icalvalue_new_caladdress(0);
-
- printf("Bad string: %p\n",v);
-
- if (v!=0) icalvalue_free(v); */
-
-}
-
-void test_properties()
-{
- icalproperty *prop;
- icalparameter *param;
-
- icalproperty *clone;
-
- prop = icalproperty_vanew_comment(
- "Another Comment",
- icalparameter_new_cn("A Common Name 1"),
- icalparameter_new_cn("A Common Name 2"),
- icalparameter_new_cn("A Common Name 3"),
- icalparameter_new_cn("A Common Name 4"),
- 0);
-
- for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER);
- param != 0;
- param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) {
-
- printf("Prop parameter: %s\n",icalparameter_get_cn(param));
- }
-
- printf("Prop value: %s\n",icalproperty_get_comment(prop));
-
-
- printf("As iCAL string:\n %s\n",icalproperty_as_ical_string(prop));
-
- clone = icalproperty_new_clone(prop);
-
- printf("Clone:\n %s\n",icalproperty_as_ical_string(prop));
-
- icalproperty_free(clone);
- icalproperty_free(prop);
-
- prop = icalproperty_new(-1);
-
- printf("Invalid type: %p\n",prop);
-
- if (prop!=0) icalproperty_free(prop);
-
- /*
- prop = icalproperty_new_method(0);
-
- printf("Bad string: %p\n",prop);
-
-
- if (prop!=0) icalproperty_free(prop);
- */
-}
-
-void test_parameters()
-{
- icalparameter *p;
- int i;
- int enums[] = {ICAL_CUTYPE_INDIVIDUAL,ICAL_CUTYPE_RESOURCE,ICAL_FBTYPE_BUSY,ICAL_PARTSTAT_NEEDSACTION,ICAL_ROLE_NONPARTICIPANT,ICAL_XLICCOMPARETYPE_LESSEQUAL,ICAL_XLICERRORTYPE_MIMEPARSEERROR,-1};
-
- char* str1 = "A Common Name";
-
- p = icalparameter_new_cn(str1);
-
- printf("Common Name: %s\n",icalparameter_get_cn(p));
-
- assert(regrstrcmp(str1,icalparameter_get_cn(p)) == 0);
-
- printf("As String: %s\n",icalparameter_as_ical_string(p));
-
- assert(regrstrcmp(icalparameter_as_ical_string(p),"CN=A Common Name")==0);
-
- icalparameter_free(p);
-
-
- p = icalparameter_new_from_string("PARTSTAT=ACCEPTED");
- assert(icalparameter_isa(p) == ICAL_PARTSTAT_PARAMETER);
- assert(icalparameter_get_partstat(p) == ICAL_PARTSTAT_ACCEPTED);
-
- p = icalparameter_new_from_string("ROLE=CHAIR");
- assert(icalparameter_isa(p) == ICAL_ROLE_PARAMETER);
- assert(icalparameter_get_partstat(p) == ICAL_ROLE_CHAIR);
-
- p = icalparameter_new_from_string("PARTSTAT=X-FOO");
- assert(icalparameter_isa(p) == ICAL_PARTSTAT_PARAMETER);
- assert(icalparameter_get_partstat(p) == ICAL_PARTSTAT_X);
-
- p = icalparameter_new_from_string("X-PARAM=X-FOO");
- assert(icalparameter_isa(p) == ICAL_X_PARAMETER);
-
-
- for (i=0;enums[i] != -1; i++){
-
- printf("%s\n",icalparameter_enum_to_string(enums[i]));
- assert(icalparameter_string_to_enum(
- icalparameter_enum_to_string(enums[i]))==enums[i]);
- }
-
-
-}
-
-
-void test_components()
-{
-
- icalcomponent* c;
- icalcomponent* child;
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"),
- icalproperty_vanew_comment(
- "A Comment",
- icalparameter_new_cn("A Common Name 1"),
- 0),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_description("This is an event"),
- icalproperty_vanew_comment(
- "Another Comment",
- icalparameter_new_cn("A Common Name 1"),
- icalparameter_new_cn("A Common Name 2"),
- icalparameter_new_cn("A Common Name 3"),
- icalparameter_new_cn("A Common Name 4"),
- 0),
- icalproperty_vanew_xlicerror(
- "This is only a test",
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_COMPONENTPARSEERROR),
- 0),
-
- 0
- ),
- 0
- );
-
- printf("Original Component:\n%s\n\n",icalcomponent_as_ical_string(c));
-
- child = icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT);
-
- printf("Child Component:\n%s\n\n",icalcomponent_as_ical_string(child));
-
- icalcomponent_free(c);
-
-}
-
-void test_memory()
-{
- size_t bufsize = 256;
- int i;
- char *p;
-
- char S1[] = "1) When in the Course of human events, ";
- char S2[] = "2) it becomes necessary for one people to dissolve the political bands which have connected them with another, ";
- char S3[] = "3) and to assume among the powers of the earth, ";
- char S4[] = "4) the separate and equal station to which the Laws of Nature and of Nature's God entitle them, ";
- char S5[] = "5) a decent respect to the opinions of mankind requires that they ";
- char S6[] = "6) should declare the causes which impel them to the separation. ";
- char S7[] = "7) We hold these truths to be self-evident, ";
- char S8[] = "8) that all men are created equal, ";
-
-/* char S9[] = "9) that they are endowed by their Creator with certain unalienable Rights, ";
- char S10[] = "10) that among these are Life, Liberty, and the pursuit of Happiness. ";
- char S11[] = "11) That to secure these rights, Governments are instituted among Men, ";
- char S12[] = "12) deriving their just powers from the consent of the governed. ";
-*/
-
-
- char *f, *b1, *b2, *b3, *b4, *b5, *b6, *b7, *b8;
-
-#define BUFSIZE 1024
-
- f = icalmemory_new_buffer(bufsize);
- p = f;
- b1 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b1, S1);
- icalmemory_append_string(&f, &p, &bufsize, b1);
-
- b2 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b2, S2);
- icalmemory_append_string(&f, &p, &bufsize, b2);
-
- b3 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b3, S3);
- icalmemory_append_string(&f, &p, &bufsize, b3);
-
- b4 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b4, S4);
- icalmemory_append_string(&f, &p, &bufsize, b4);
-
- b5 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b5, S5);
- icalmemory_append_string(&f, &p, &bufsize, b5);
-
- b6 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b6, S6);
- icalmemory_append_string(&f, &p, &bufsize, b6);
-
- b7 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b7, S7);
- icalmemory_append_string(&f, &p, &bufsize, b7);
-
- b8 = icalmemory_tmp_buffer(BUFSIZE);
- strcpy(b8, S8);
- icalmemory_append_string(&f, &p, &bufsize, b8);
-
-
- printf("1: %p %s \n",b1,b1);
- printf("2: %p %s\n",b2,b2);
- printf("3: %p %s\n",b3,b3);
- printf("4: %p %s\n",b4,b4);
- printf("5: %p %s\n",b5,b5);
- printf("6: %p %s\n",b6,b6);
- printf("7: %p %s\n",b7,b7);
- printf("8: %p %s\n",b8,b8);
-
-
- printf("Final: %s\n", f);
-
- printf("Final buffer size: %d\n",bufsize);
-
- free(f);
-
- bufsize = 4;
-
- f = icalmemory_new_buffer(bufsize);
-
- memset(f,0,bufsize);
- p = f;
-
- icalmemory_append_char(&f, &p, &bufsize, 'a');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'b');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'c');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'd');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'e');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'f');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'g');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'h');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'i');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'j');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'a');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'b');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'c');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'd');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'e');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'f');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'g');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'h');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'i');
- printf("Char-by-Char buffer: %s\n", f);
- icalmemory_append_char(&f, &p, &bufsize, 'j');
- printf("Char-by-Char buffer: %s\n", f);
-
- for(i=0; i<100; i++){
- f = icalmemory_tmp_buffer(bufsize);
-
- assert(f!=0);
-
- memset(f,0,bufsize);
- sprintf(f,"%d",i);
- }
-}
-
-
-int test_store()
-{
-
- icalcomponent *c, *gauge;
- icalerrorenum error;
- icalcomponent *next, *itr;
- icalfileset* cluster;
- struct icalperiodtype rtime;
- icaldirset *s = icaldirset_new("store");
- int i;
-
- rtime.start = icaltime_from_timet( time(0),0);
-
- cluster = icalfileset_new("clusterin.vcd");
-
- if (cluster == 0){
- printf("Failed to create cluster: %s\n",icalerror_strerror(icalerrno));
- return 0;
- }
-
-#define NUMCOMP 4
-
- /* Duplicate every component in the cluster NUMCOMP times */
-
- icalerror_clear_errno();
-
- for (i = 1; i<NUMCOMP+1; i++){
-
- /*rtime.start.month = i%12;*/
- rtime.start.month = i;
- rtime.end = rtime.start;
- rtime.end.hour++;
-
- for (itr = icalfileset_get_first_component(cluster);
- itr != 0;
- itr = icalfileset_get_next_component(cluster)){
- icalcomponent *clone;
- icalproperty *p;
-
-
- if(icalcomponent_isa(itr) != ICAL_VEVENT_COMPONENT){
- continue;
- }
-
- assert(itr != 0);
-
- /* Change the dtstart and dtend times in the component
- pointed to by Itr*/
-
- clone = icalcomponent_new_clone(itr);
- assert(icalerrno == ICAL_NO_ERROR);
- assert(clone !=0);
-
- /* DTSTART*/
- p = icalcomponent_get_first_property(clone,ICAL_DTSTART_PROPERTY);
- assert(icalerrno == ICAL_NO_ERROR);
-
- if (p == 0){
- p = icalproperty_new_dtstart(rtime.start);
- icalcomponent_add_property(clone,p);
- } else {
- icalproperty_set_dtstart(p,rtime.start);
- }
- assert(icalerrno == ICAL_NO_ERROR);
-
- /* DTEND*/
- p = icalcomponent_get_first_property(clone,ICAL_DTEND_PROPERTY);
- assert(icalerrno == ICAL_NO_ERROR);
-
- if (p == 0){
- p = icalproperty_new_dtstart(rtime.end);
- icalcomponent_add_property(clone,p);
- } else {
- icalproperty_set_dtstart(p,rtime.end);
- }
- assert(icalerrno == ICAL_NO_ERROR);
-
- printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(clone));
-
- error = icaldirset_add_component(s,clone);
-
- assert(icalerrno == ICAL_NO_ERROR);
-
- }
-
- }
-
- gauge =
- icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_summary(
- "Submit Income Taxes",
- icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL),
- 0),
- 0),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_summary(
- "Bastille Day Party",
- icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL),
- 0),
- 0),
- 0);
-
-#if 0
-
-
- icaldirset_select(s,gauge);
-
- for(c = icaldirset_first(s); c != 0; c = icaldirset_next(s)){
-
- printf("Got one! (%d)\n", count++);
-
- if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
- if (icaldirset_store(s2,c) == 0){
- printf("Failed to write!\n");
- }
- icalcomponent_free(c);
- } else {
- printf("Failed to get component\n");
- }
- }
-
-
- icaldirset_free(s2);
-#endif
-
-
- for(c = icaldirset_get_first_component(s);
- c != 0;
- c = next){
-
- next = icaldirset_get_next_component(s);
-
- if (c != 0){
- /*icaldirset_remove_component(s,c);*/
- printf("%s", icalcomponent_as_ical_string(c));;
- } else {
- printf("Failed to get component\n");
- }
-
-
- }
-
- icaldirset_free(s);
- return 0;
-}
-
-int test_compare()
-{
- icalvalue *v1, *v2;
-
- v1 = icalvalue_new_caladdress("cap://value/1");
- v2 = icalvalue_new_clone(v1);
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- v1 = icalvalue_new_caladdress("A");
- v2 = icalvalue_new_caladdress("B");
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- v1 = icalvalue_new_caladdress("B");
- v2 = icalvalue_new_caladdress("A");
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- v1 = icalvalue_new_integer(5);
- v2 = icalvalue_new_integer(5);
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- v1 = icalvalue_new_integer(5);
- v2 = icalvalue_new_integer(10);
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- v1 = icalvalue_new_integer(10);
- v2 = icalvalue_new_integer(5);
-
- printf("%d\n",icalvalue_compare(v1,v2));
-
- return 0;
-}
-
-void test_restriction()
-{
- icalcomponent *comp;
- struct icaltimetype atime = icaltime_from_timet( time(0),0);
- int valid;
-
- struct icaldatetimeperiodtype rtime;
-
- rtime.period.start = icaltime_from_timet( time(0),0);
- rtime.period.end = icaltime_from_timet( time(0),0);
- rtime.period.end.hour++;
- rtime.time = icaltime_null_time();
-
- comp =
- icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"),
- icalproperty_new_method(ICAL_METHOD_REQUEST),
- icalcomponent_vanew(
- ICAL_VTIMEZONE_COMPONENT,
- icalproperty_new_tzid("US_Eastern"),
- icalcomponent_vanew(
- ICAL_XDAYLIGHT_COMPONENT,
- icalproperty_new_dtstart(atime),
- icalproperty_new_rdate(rtime),
- icalproperty_new_tzoffsetfrom(-4.0),
- icalproperty_new_tzoffsetto(-5.0),
- icalproperty_new_tzname("EST"),
- 0
- ),
- icalcomponent_vanew(
- ICAL_XSTANDARD_COMPONENT,
- icalproperty_new_dtstart(atime),
- icalproperty_new_rdate(rtime),
- icalproperty_new_tzoffsetfrom(-5.0),
- icalproperty_new_tzoffsetto(-4.0),
- icalproperty_new_tzname("EST"),
- 0
- ),
- 0
- ),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstamp(atime),
- icalproperty_new_uid("guid-1.host1.com"),
- icalproperty_vanew_organizer(
- "mrbig@host.com",
- icalparameter_new_role(ICAL_ROLE_CHAIR),
- 0
- ),
- icalproperty_vanew_attendee(
- "employee-A@host.com",
- icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT),
- icalparameter_new_rsvp(ICAL_RSVP_TRUE),
- icalparameter_new_cutype(ICAL_CUTYPE_GROUP),
- 0
- ),
- icalproperty_new_description("Project XYZ Review Meeting"),
- icalproperty_new_categories("MEETING"),
- icalproperty_new_class("PUBLIC"),
- icalproperty_new_created(atime),
- icalproperty_new_summary("XYZ Project Review"),
- /* icalproperty_new_dtstart(
- atime,
- icalparameter_new_tzid("US-Eastern"),
- 0
- ),*/
- icalproperty_vanew_dtend(
- atime,
- icalparameter_new_tzid("US-Eastern"),
- 0
- ),
- icalproperty_new_location("1CP Conference Room 4350"),
- 0
- ),
- 0
- );
-
- valid = icalrestriction_check(comp);
-
- printf("#### %d ####\n%s\n",valid, icalcomponent_as_ical_string(comp));
-
-}
-
-#if 0
-void test_calendar()
-{
- icalcomponent *comp;
- icalfileset *c;
- icaldirset *s;
- icalcalendar* calendar = icalcalendar_new("calendar");
- icalerrorenum error;
- struct icaltimetype atime = icaltime_from_timet( time(0),0);
-
- comp = icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_description("This is an event"),
- icalproperty_new_dtstart(atime),
- icalproperty_vanew_comment(
- "Another Comment",
- icalparameter_new_cn("A Common Name 1"),
- icalparameter_new_cn("A Common Name 2"),
- icalparameter_new_cn("A Common Name 3"),
- icalparameter_new_cn("A Common Name 4"),
- 0),
- icalproperty_vanew_xlicerror(
- "This is only a test",
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_COMPONENTPARSEERROR),
- 0),
-
- 0);
-
-
- s = icalcalendar_get_booked(calendar);
-
- error = icaldirset_add_component(s,comp);
-
- assert(error == ICAL_NO_ERROR);
-
- c = icalcalendar_get_properties(calendar);
-
- error = icalfileset_add_component(c,icalcomponent_new_clone(comp));
-
- assert(error == ICAL_NO_ERROR);
-
- icalcalendar_free(calendar);
-
-}
-#endif
-
-void test_increment(void);
-
-void print_occur(struct icalrecurrencetype recur, struct icaltimetype start)
-{
- struct icaltimetype next;
- icalrecur_iterator* ritr;
-
- time_t tt = icaltime_as_timet(start);
-
- printf("#### %s\n",icalrecurrencetype_as_string(&recur));
- printf("#### %s\n",ctime(&tt ));
-
- for(ritr = icalrecur_iterator_new(recur,start),
- next = icalrecur_iterator_next(ritr);
- !icaltime_is_null_time(next);
- next = icalrecur_iterator_next(ritr)){
-
- tt = icaltime_as_timet(next);
-
- printf(" %s",ctime(&tt ));
-
- }
-
- icalrecur_iterator_free(ritr);
-}
-
-void test_recur()
-{
- struct icalrecurrencetype rt;
- struct icaltimetype start;
- time_t array[25];
- int i;
-
- rt = icalrecurrencetype_from_string("FREQ=MONTHLY;UNTIL=19971224T000000Z;INTERVAL=1;BYDAY=TU,2FR,3SA");
- start = icaltime_from_string("19970905T090000Z");
-
- print_occur(rt,start);
-
- printf("\n Using icalrecur_expand_recurrence\n");
-
- icalrecur_expand_recurrence("FREQ=MONTHLY;UNTIL=19971224T000000Z;INTERVAL=1;BYDAY=TU,2FR,3SA",
- icaltime_as_timet(start),
- 25,
- array);
-
- for(i =0; array[i] != 0 && i < 25 ; i++){
-
- printf(" %s",ctime(&(array[i])));
- }
-
-
-/* test_increment();*/
-
-}
-
-void test_expand_recurrence(){
-
- time_t arr[10];
- time_t now = 931057385;
- int i;
- icalrecur_expand_recurrence( "FREQ=MONTHLY;BYDAY=MO,WE", now,
- 5, arr );
-
- printf("Start %s",ctime(&now) );
- for (i=0; i<5; i++)
- {
- printf("i=%d %s\n", i, ctime(&arr[i]) );
- }
-
-}
-
-
-
-enum byrule {
- NO_CONTRACTION = -1,
- BY_SECOND = 0,
- BY_MINUTE = 1,
- BY_HOUR = 2,
- BY_DAY = 3,
- BY_MONTH_DAY = 4,
- BY_YEAR_DAY = 5,
- BY_WEEK_NO = 6,
- BY_MONTH = 7,
- BY_SET_POS
-};
-
-struct icalrecur_iterator_impl {
-
- struct icaltimetype dtstart;
- struct icaltimetype last; /* last time return from _iterator_next*/
- int occurrence_no; /* number of step made on this iterator */
- struct icalrecurrencetype rule;
-
- short days[366];
- short days_index;
-
- enum byrule byrule;
- short by_indices[9];
-
-
- short *by_ptrs[9]; /* Pointers into the by_* array elements of the rule */
-};
-
-void icalrecurrencetype_test()
-{
- icalvalue *v = icalvalue_new_from_string(
- ICAL_RECUR_VALUE,
- "FREQ=YEARLY;UNTIL=20060101T000000;INTERVAL=2;BYDAY=SU,WE;BYSECOND=15,30; BYMONTH=1,6,11");
-
- struct icalrecurrencetype r = icalvalue_get_recur(v);
- struct icaltimetype t = icaltime_from_timet( time(0), 0);
- struct icaltimetype next;
- time_t tt;
-
- struct icalrecur_iterator_impl* itr
- = (struct icalrecur_iterator_impl*) icalrecur_iterator_new(r,t);
-
- do {
-
- next = icalrecur_iterator_next(itr);
- tt = icaltime_as_timet(next);
-
- printf("%s",ctime(&tt ));
-
- } while( ! icaltime_is_null_time(next));
-
-}
-
-/* From Federico Mena Quintero <federico@ximian.com> */
-void test_recur_parameter_bug(){
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ical.h>
-
- static const char test_icalcomp_str[] =
-"BEGIN:VEVENT\r\n"
-"RRULE\r\n"
-" ;X-EVOLUTION-ENDDATE=20030209T081500\r\n"
-" :FREQ=DAILY;COUNT=10;INTERVAL=6\r\n"
-"END:VEVENT\r\n";
-
- icalcomponent *icalcomp;
- icalproperty *prop;
- struct icalrecurrencetype recur;
- int n_errors;
-
- icalcomp = icalparser_parse_string ((char *) test_icalcomp_str);
- if (!icalcomp) {
- fprintf (stderr, "main(): could not parse the component\n");
- exit (EXIT_FAILURE);
- }
-
- printf("%s\n\n",icalcomponent_as_ical_string(icalcomp));
-
- n_errors = icalcomponent_count_errors (icalcomp);
- if (n_errors) {
- icalproperty *p;
-
- for (p = icalcomponent_get_first_property (icalcomp,
- ICAL_XLICERROR_PROPERTY);
- p;
- p = icalcomponent_get_next_property (icalcomp,
- ICAL_XLICERROR_PROPERTY)) {
- char *str;
-
- str = icalproperty_as_ical_string (p);
- fprintf (stderr, "error: %s\n", str);
- }
- }
-
- prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
- if (!prop) {
- fprintf (stderr, "main(): could not get the RRULE property");
- exit (EXIT_FAILURE);
- }
-
- recur = icalproperty_get_rrule (prop);
-
- printf("%s\n",icalrecurrencetype_as_string(&recur));
-
-}
-
-
-void test_duration()
-{
-
-
- struct icaldurationtype d;
-
- d = icaldurationtype_from_string("PT8H30M");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 30600);
-
- d = icaldurationtype_from_string("-PT8H30M");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == -30600);
-
- d = icaldurationtype_from_string("PT10H10M10S");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 36610);
-
- d = icaldurationtype_from_string("P7W");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 4233600);
-
- d = icaldurationtype_from_string("P2DT8H30M");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 203400);
-
- icalerror_errors_are_fatal = 0;
-
- d = icaldurationtype_from_string("P-2DT8H30M");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 0);
-
- d = icaldurationtype_from_string("P7W8H");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 0);
-
- d = icaldurationtype_from_string("T10H");
- printf("%s\n",icaldurationtype_as_ical_string(d));
- assert(icaldurationtype_as_int(d) == 0);
-
-
- icalerror_errors_are_fatal = 1;
-
-}
-
-void test_period()
-{
-
- struct icalperiodtype p;
- icalvalue *v;
-
- p = icalperiodtype_from_string("19971015T050000Z/PT8H30M");
- printf("%s\n",icalperiodtype_as_ical_string(p));
- assert(strcmp(icalperiodtype_as_ical_string(p),
- "19971015T050000Z/PT8H30M") == 0);
-
- p = icalperiodtype_from_string("19971015T050000Z/19971015T060000Z");
- printf("%s\n",icalperiodtype_as_ical_string(p));
- assert(strcmp(icalperiodtype_as_ical_string(p),
- "19971015T050000Z/19971015T060000Z") == 0);
-
- p = icalperiodtype_from_string("19970101T120000/PT3H");
- printf("%s\n",icalperiodtype_as_ical_string(p));
- assert(strcmp(icalperiodtype_as_ical_string(p),
- "19970101T120000/PT3H") == 0);
-
- v = icalvalue_new_from_string(ICAL_PERIOD_VALUE,"19970101T120000/PT3H");
- printf("%s\n",icalvalue_as_ical_string(v));
- assert(strcmp(icalvalue_as_ical_string(v),
- "19970101T120000/PT3H") == 0);
-
-
-}
-
-void test_strings(){
-
- icalvalue *v;
-
- v = icalvalue_new_text("foo;bar;bats");
-
- printf("%s\n",icalvalue_as_ical_string(v));
-
- icalvalue_free(v);
-
- v = icalvalue_new_text("foo\\;b\nar\\;ba\tts");
-
- printf("%s\n",icalvalue_as_ical_string(v));
-
- icalvalue_free(v);
-
-
-}
-
-void test_requeststat()
-{
- icalrequeststatus s;
- struct icalreqstattype st, st2;
- char temp[1024];
-
- s = icalenum_num_to_reqstat(2,1);
-
- assert(s == ICAL_2_1_FALLBACK_STATUS);
-
- assert(icalenum_reqstat_major(s) == 2);
- assert(icalenum_reqstat_minor(s) == 1);
-
- printf("2.1: %s\n",icalenum_reqstat_desc(s));
-
- st.code = s;
- st.debug = "booga";
- st.desc = 0;
-
- printf("%s\n",icalreqstattype_as_string(st));
-
- st.desc = " A non-standard description";
-
- printf("%s\n",icalreqstattype_as_string(st));
-
-
- st.desc = 0;
-
- sprintf(temp,"%s\n",icalreqstattype_as_string(st));
-
-
- st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga");
-
- printf("%d -- %d -- %s -- %s\n",icalenum_reqstat_major(st2.code),
- icalenum_reqstat_minor(st2.code),
- icalenum_reqstat_desc(st2.code),
- st2.debug);
-
- st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga");
- printf("%s\n",icalreqstattype_as_string(st2));
-
- st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;");
- printf("%s\n",icalreqstattype_as_string(st2));
-
- st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.");
- printf("%s\n",icalreqstattype_as_string(st2));
-
- st2 = icalreqstattype_from_string("2.1;");
- printf("%s\n",icalreqstattype_as_string(st2));
-
- st2 = icalreqstattype_from_string("2.1");
- printf("%s\n",icalreqstattype_as_string(st2));
-
-#ifndef ICAL_ERRORS_ARE_FATAL
- st2 = icalreqstattype_from_string("16.4");
- assert(st2.code == ICAL_UNKNOWN_STATUS);
-
- st2 = icalreqstattype_from_string("1.");
- assert(st2.code == ICAL_UNKNOWN_STATUS);
-#endif
-}
-
-char ictt_str[1024];
-char* ictt_as_string(struct icaltimetype t)
-{
-
- sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d%s",t.year,t.month,t.day,
- t.hour,t.minute,t.second,t.is_utc?" Z":"");
-
- return ictt_str;
-}
-
-
-char* ical_timet_string(time_t t)
-{
- struct tm stm = *(gmtime(&t));
-
- sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d Z",stm.tm_year+1900,
- stm.tm_mon+1,stm.tm_mday,stm.tm_hour,stm.tm_min,stm.tm_sec);
-
- return ictt_str;
-
-}
-
-void do_test_time(char* zone)
-{
- struct icaltimetype ictt, icttutc, icttutczone, icttdayl,
- icttla, icttny,icttphoenix, icttlocal, icttnorm;
- time_t tt,tt2, tt_p200;
- int offset_la, offset_tz;
- icalvalue *v;
- short day_of_week,start_day_of_week, day_of_year;
-
- icalerror_errors_are_fatal = 0;
-
- ictt = icaltime_from_string("20001103T183030Z");
-
- tt = icaltime_as_timet(ictt);
-
- assert(tt==973276230); /* Fri Nov 3 10:30:30 PST 2000 in PST
- Fri Nov 3 18:30:30 PST 2000 in UTC */
-
- offset_la = icaltime_utc_offset(ictt,"America/Los_Angeles");
- offset_tz = icaltime_utc_offset(ictt, zone);
-
- printf(" Normalize \n");
- printf("Orig (ical) : %s\n", ictt_as_string(ictt));
- icttnorm = ictt;
- icttnorm.second -= 60 * 60 * 24 * 5;
- icttnorm = icaltime_normalize(icttnorm);
- printf("-5d in sec : %s\n", ictt_as_string(icttnorm));
- icttnorm.day += 60;
- icttnorm = icaltime_normalize(icttnorm);
- printf("+60 d : %s\n", ictt_as_string(icttnorm));
-
-
- printf("\n As time_t \n");
-
- tt2 = icaltime_as_timet(ictt);
- printf("20001103T183030Z (timet): %s\n",ical_timet_string(tt2));
- printf("20001103T183030Z : %s\n",ictt_as_string(ictt));
- assert(tt2 == tt);
-
- icttlocal = icaltime_from_string("20001103T183030");
- tt2 = icaltime_as_timet(icttlocal);
- printf("20001103T183030 (timet): %s\n",ical_timet_string(tt2));
- printf("20001103T183030 : %s\n",ictt_as_string(icttlocal));
- assert(tt-tt2 == offset_tz);
-
- printf("\n From time_t \n");
-
- printf("Orig : %s\n",ical_timet_string(tt));
- printf("As utc : %s\n", ictt_as_string(ictt));
-
- icttlocal = icaltime_as_zone(ictt,zone);
- printf("As local : %s\n", ictt_as_string(icttlocal));
-
-
- printf("\n Convert to and from lib c \n");
-
- printf("System time is: %s\n",ical_timet_string(tt));
-
- v = icalvalue_new_datetime(ictt);
-
- printf("System time from libical: %s\n",icalvalue_as_ical_string(v));
-
- tt2 = icaltime_as_timet(ictt);
- printf("Converted back to libc: %s\n",ical_timet_string(tt2));
-
- printf("\n Incrementing time \n");
-
- icttnorm = ictt;
-
- icttnorm.year++;
- tt2 = icaltime_as_timet(icttnorm);
- printf("Add a year: %s\n",ical_timet_string(tt2));
-
- icttnorm.month+=13;
- tt2 = icaltime_as_timet(icttnorm);
- printf("Add 13 months: %s\n",ical_timet_string(tt2));
-
- icttnorm.second+=90;
- tt2 = icaltime_as_timet(icttnorm);
- printf("Add 90 seconds: %s\n",ical_timet_string(tt2));
-
- printf("\n Day Of week \n");
-
- day_of_week = icaltime_day_of_week(ictt);
- start_day_of_week = icaltime_start_doy_of_week(ictt);
- day_of_year = icaltime_day_of_year(ictt);
-
-
- printf("Today is day of week %d, day of year %d\n",day_of_week,day_of_year);
- printf("Week started n doy of %d\n",start_day_of_week);
- assert(day_of_week == 6);
- assert(day_of_year == 308);
- assert(start_day_of_week == 303 );
-
- printf("\n TimeZone Conversions \n");
-
- icttla = icaltime_as_zone(ictt,"America/Los_Angeles");
- assert(icttla.hour == 10);
-
- icttutc = icaltime_as_utc(icttla,"America/Los_Angeles");
- assert(icaltime_compare(icttla,
- icaltime_from_string("20001103T103030"))==0);
-
- icttutczone = icaltime_as_zone(ictt,"Etc/GMT0");
- icttutczone.is_utc = 1;
- assert(icaltime_compare(icttutc, icttutczone) == 0);
- assert(icaltime_compare(icttutc, ictt) == 0);
-
- icttny = icaltime_as_zone(ictt,"America/New_York");
-
- icttphoenix = icaltime_as_zone(ictt,"America/Phoenix");
-
- printf("Orig (ctime): %s\n", ical_timet_string(tt) );
- printf("Orig (ical) : %s\n", ictt_as_string(ictt));
- printf("UTC : %s\n", ictt_as_string(icttutc));
- printf("Los Angeles : %s\n", ictt_as_string(icttla));
- printf("Phoenix : %s\n", ictt_as_string(icttphoenix));
- printf("New York : %s\n", ictt_as_string(icttny));
-
-
- /* Daylight savings test for New York */
- printf("\n Daylight Savings \n");
-
- printf("Orig (ctime): %s\n", ical_timet_string(tt) );
- printf("Orig (ical) : %s\n", ictt_as_string(ictt));
- printf("NY : %s\n", ictt_as_string(icttny));
-
- assert(strcmp(ictt_as_string(icttny),"2000-11-03 13:30:30")==0);
-
- tt_p200 = tt + 200 * 24 * 60 * 60 ; /* Add 200 days */
-
- icttdayl = icaltime_from_timet(tt_p200,0);
- icttny = icaltime_as_zone(icttdayl,"America/New_York");
-
- printf("Orig +200d : %s\n", ical_timet_string(tt_p200) );
- printf("NY+200D : %s\n", ictt_as_string(icttny));
-
- assert(strcmp(ictt_as_string(icttny),"2001-05-22 14:30:30")==0);
-
- /* Daylight savings test for Los Angeles */
-
- icttla = icaltime_as_zone(ictt,"America/Los_Angeles");
-
- printf("\nOrig (ctime): %s\n", ical_timet_string(tt) );
- printf("Orig (ical) : %s\n", ictt_as_string(ictt));
- printf("LA : %s\n", ictt_as_string(icttla));
-
- assert(strcmp(ictt_as_string(icttla),"2000-11-03 10:30:30")==0);
-
- icttla = icaltime_as_zone(icttdayl,"America/Los_Angeles");
-
- printf("Orig +200d : %s\n", ical_timet_string(tt_p200) );
- printf("LA+200D : %s\n", ictt_as_string(icttla));
-
- assert(strcmp(ictt_as_string(icttla),"2001-05-22 11:30:30")==0);
-
- icalerror_errors_are_fatal = 1;
-}
-
-void test_iterators()
-{
- icalcomponent *c,*inner,*next;
- icalcompiter i;
-
- c= icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_version("1"),0),
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_version("2"),0),
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_version("3"),0),
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_version("4"),0),
- icalcomponent_vanew(ICAL_VTODO_COMPONENT,
- icalproperty_vanew_version("5"),0),
- icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT,
- icalproperty_vanew_version("6"),0),
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_version("7"),0),
- icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT,
- icalproperty_vanew_version("8"),0),
- icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT,
- icalproperty_vanew_version("9"),0),
- icalcomponent_vanew(ICAL_VJOURNAL_COMPONENT,
- icalproperty_vanew_version("10"),0),
- 0);
-
- printf("1: ");
-
- /* List all of the VEVENTS */
- for(i = icalcomponent_begin_component(c,ICAL_VEVENT_COMPONENT);
- icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
-
- icalcomponent *this = icalcompiter_deref(&i);
-
- icalproperty *p =
- icalcomponent_get_first_property(this,
- ICAL_VERSION_PROPERTY);
- const char* s = icalproperty_get_version(p);
-
- printf("%s ",s);
-
- }
-
- printf("\n2: ");
-
-#if 0
- for(inner = icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT);
- inner != 0;
- inner = next){
-
- next = icalcomponent_get_next_component(c,ICAL_VEVENT_COMPONENT);
-
- icalcomponent_remove_component(c,inner);
-
- icalcomponent_free(inner);
- }
-#endif
-
- /* Delete all of the VEVENTS */
- /* reset iterator */
- icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT);
-
- while((inner=icalcomponent_get_current_component(c)) != 0 ){
- if(icalcomponent_isa(inner) == ICAL_VEVENT_COMPONENT){
- icalcomponent_remove_component(c,inner);
- } else {
- icalcomponent_get_next_component(c,ICAL_VEVENT_COMPONENT);
- }
- }
-
-
-
- /* List all remaining components */
- for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT);
- inner != 0;
- inner = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){
-
-
- icalproperty *p =
- icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY);
-
- const char* s = icalproperty_get_version(p);
-
- printf("%s ",s);
- }
-
- printf("\n3: ");
-
-
- /* Remove all remaining components */
- for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT);
- inner != 0;
- inner = next){
-
- icalcomponent *this;
- icalproperty *p;
- const char* s;
- next = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT);
-
- p=icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY);
- s = icalproperty_get_version(p);
- printf("rem:%s ",s);
-
- icalcomponent_remove_component(c,inner);
-
- this = icalcomponent_get_current_component(c);
-
- if(this != 0){
- p=icalcomponent_get_first_property(this,ICAL_VERSION_PROPERTY);
- s = icalproperty_get_version(p);
- printf("next:%s; ",s);
- }
-
- icalcomponent_free(inner);
- }
-
- printf("\n4: ");
-
-
- /* List all remaining components */
- for(inner = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT);
- inner != 0;
- inner = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){
-
- icalproperty *p =
- icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY);
-
- const char* s = icalproperty_get_version(p);
-
- printf("%s ",s);
- }
-
- printf("\n");
-}
-
-
-
-char* test_set_tz(const char* tzid)
-{
- char *tzstr = 0;
- char *tmp;
-
- /* Put the new time zone into the environment */
- if(getenv("TZ") != 0){
- tzstr = (char*)icalmemory_strdup(getenv("TZ"));
-
- if(tzstr == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
- }
-
- tmp = (char*)malloc(1024);
-
- if(tmp == 0){
- icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- return 0;
- }
-
- snprintf(tmp,1024,"TZ=%s",tzid);
-
- /* HACK. In some libc versions, putenv gives the string to the
- system and in some it gives a copy, so the following might be a
- memory leak. THe linux man page says that glibc2.1.2 take
- ownership ( no leak) while BSD4.4 uses a copy ( A leak ) */
- putenv(tmp);
-
- return tzstr; /* This will be zero if the TZ env var was not set */
-}
-
-void test_unset_tz(char* tzstr)
-{
- /* restore the original environment */
-
- if(tzstr!=0){
- char temp[1024];
- snprintf(temp,1024,"TZ=%s",tzstr);
- putenv(temp);
- free(tzstr);
- } else {
- putenv("TZ"); /* Delete from environment */
- }
-}
-
-
-void test_time()
-{
- char zones[6][40] = { "America/Los_Angeles","America/New_York","Europe/London","Asia/Shanghai", ""};
- int i;
- char* old_tz;
- int orig_month;
- time_t tt;
- struct tm stm;
-
- tt = time(0);
-
- stm = *(localtime(&tt));
-
- orig_month = stm.tm_mon;
-
- do_test_time(0);
-
- old_tz = test_set_tz(zones[0]);
-
- for(i = 0; zones[i][0] != 0; i++){
-
- if(zones[i][0] != 0){
- test_set_tz(zones[i]);
- }
-
- printf(" ######### Timezone: %s ############\n",zones[i]);
-
- do_test_time(zones[i]);
-
- }
-
- test_unset_tz(old_tz);
-
-}
-
-
-void test_icalset()
-{
- icalcomponent *c;
-
- icalset* f = icalset_new_file("2446.ics");
- icalset* d = icalset_new_dir("outdir");
-
- assert(f!=0);
- assert(d!=0);
-
- for(c = icalset_get_first_component(f);
- c != 0;
- c = icalset_get_next_component(f)){
-
- icalcomponent *clone;
-
- clone = icalcomponent_new_clone(c);
-
- icalset_add_component(d,clone);
-
- printf(" class %d\n",icalclassify(c,0,"user"));
-
- }
-}
-
-void test_classify()
-{
- icalcomponent *c,*match;
-
- icalset* f = icalset_new_file("../../test-data/classify.ics");
-
- assert(f!=0);
-
- c = icalset_get_first_component(f);
- match = icalset_get_next_component(f);
-
- printf("Class %d\n",icalclassify(c,match,"A@example.com"));
-
-
-}
-
-void print_span(int c, struct icaltime_span span ){
-
- printf("#%02d start: %s\n",c,ical_timet_string(span.start));
- printf(" end : %s\n",ical_timet_string(span.end));
-
-}
-
-struct icaltimetype icaltime_as_local(struct icaltimetype tt) {
- return icaltime_as_zone(tt,0);
-}
-
-void test_span()
-{
- time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000,
- Sat Nov 4 15:00:00 PST 2000 */
- time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000
- Sat Nov 4 16:00:00 PST 2000 */
- struct icaldurationtype dur;
- struct icaltime_span span;
- icalcomponent *c;
-
- memset(&dur,0,sizeof(dur));
- dur.minutes = 30;
-
- span.start = tm1;
- span.end = tm2;
- print_span(0,span);
-
- /* Specify save timezone as in commend above */
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(
- icaltime_as_local(icaltime_from_timet(tm1,0)),
- icalparameter_new_tzid("US/Pacific"),0),
- icalproperty_vanew_dtend(
- icaltime_as_local(icaltime_from_timet(tm2,0)),
- icalparameter_new_tzid("US/Pacific"),0),
- 0
- );
-
- printf("%s\n",icalcomponent_as_ical_string(c));
-
- span = icalcomponent_get_span(c);
-
- print_span(1,span);
-
- icalcomponent_free(c);
-
- /* Use machine's local timezone. Same as above if run in US/Pacific */
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0),0),
- icalproperty_vanew_dtend(icaltime_from_timet(tm2,0),0),
- 0
- );
-
- span = icalcomponent_get_span(c);
-
- print_span(2,span);
-
- icalcomponent_free(c);
-
- /* Specify different timezone */
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(
- icaltime_as_local(icaltime_from_timet(tm1,0)),
- icalparameter_new_tzid("US/Eastern"),0),
- icalproperty_vanew_dtend(
- icaltime_as_local(icaltime_from_timet(tm2,0)),
- icalparameter_new_tzid("US/Eastern"),0),
- 0
- );
- span = icalcomponent_get_span(c);
- print_span(3,span);
-
- icalcomponent_free(c);
-
-
- /* Specify different timezone for start and end*/
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(
- icaltime_as_local(icaltime_from_timet(tm1,0)),
- icalparameter_new_tzid("US/Eastern"),0),
- icalproperty_vanew_dtend(
- icaltime_as_local(icaltime_from_timet(tm2,0)),
- icalparameter_new_tzid("US/Pacific"),0),
- 0
- );
- span = icalcomponent_get_span(c);
- print_span(4,span);
-
- icalcomponent_free(c);
-
- /* Use Duration */
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(
- icaltime_as_local(icaltime_from_timet(tm1,0)),
- icalparameter_new_tzid("US/Pacific"),0),
- icalproperty_new_duration(dur),
-
- 0
- );
- span = icalcomponent_get_span(c);
- print_span(5,span);
-
- icalcomponent_free(c);
-
-
-#ifndef ICAL_ERRORS_ARE_FATAL
- /* Both UTC and Timezone -- an error */
- icalerror_clear_errno();
- c =
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0),
- icalparameter_new_tzid("US/Eastern"),0),
- icalproperty_vanew_dtend(icaltime_from_timet(tm2,0),
- icalparameter_new_tzid("US/Eastern"),0),
- 0
- );
-
- span = icalcomponent_get_span(c);
- assert(icalerrno != ICAL_NO_ERROR);
-
- icalcomponent_free(c);
-
-#endif /*ICAL_ERRORS_ARE_FATAL*/
-
-}
-
-icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
-
-void test_overlaps()
-{
-
-#if 0 /* Hack, not working right now */
- icalcomponent *cset,*c;
- icalset *set;
- time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000,
- Sat Nov 4 15:00:00 PST 2000 */
- time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000
- Sat Nov 4 16:00:00 PST 2000 */
-
- time_t hh = 1800; /* one half hour */
-
- set = icalset_new_file("../../test-data/overlaps.ics");
-
- printf("-- 1 -- \n");
- c = icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(icaltime_from_timet(tm1-hh,0),0),
- icalproperty_vanew_dtend(icaltime_from_timet(tm2-hh,0),0),
- 0
- );
-
- cset = icalclassify_find_overlaps(set,c);
-
- printf("%s\n",icalcomponent_as_ical_string(cset));
-
- printf("-- 2 -- \n");
- c = icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(icaltime_from_timet(tm1-hh,0),0),
- icalproperty_vanew_dtend(icaltime_from_timet(tm2,0),0),
- 0
- );
-
- cset = icalclassify_find_overlaps(set,c);
-
- printf("%s\n",icalcomponent_as_ical_string(cset));
-
- printf("-- 3 -- \n");
- c = icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_dtstart(icaltime_from_timet(tm1+5*hh,0),0),
- icalproperty_vanew_dtend(icaltime_from_timet(tm2+5*hh,0),0),
- 0
- );
-
- cset = icalclassify_find_overlaps(set,c);
-
- printf("%s\n",icalcomponent_as_ical_string(cset));
-
-#endif
-
-}
-
-void test_fblist()
-{
- icalspanlist *sl;
- icalset* set = icalset_new_file("../../test-data/spanlist.ics");
- struct icalperiodtype period;
-
- sl = icalspanlist_new(set,
- icaltime_from_string("19970324T120000Z"),
- icaltime_from_string("19990424T020000Z"));
-
- printf("Restricted spanlist\n");
- icalspanlist_dump(sl);
-
- period= icalspanlist_next_free_time(sl,
- icaltime_from_string("19970801T120000Z"));
-
-
- printf("Next Free time: %s\n",icaltime_as_ctime(period.start));
- printf(" %s\n",icaltime_as_ctime(period.end));
-
-
- icalspanlist_free(sl);
-
- printf("Unrestricted spanlist\n");
-
- sl = icalspanlist_new(set,
- icaltime_from_string("19970324T120000Z"),
- icaltime_null_time());
-
- printf("Restricted spanlist\n");
-
- icalspanlist_dump(sl);
-
- period= icalspanlist_next_free_time(sl,
- icaltime_from_string("19970801T120000Z"));
-
-
- printf("Next Free time: %s\n",icaltime_as_ctime(period.start));
- printf(" %s\n",icaltime_as_ctime(period.end));
-
-
- icalspanlist_free(sl);
-
-
-}
-
-void test_convenience(){
-
- icalcomponent *c;
- int duration;
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(icaltime_from_string("19970801T120000")),
- icalproperty_new_dtend(icaltime_from_string("19970801T130000")),
- 0
- ),
- 0);
-
- printf("** 1 DTSTART and DTEND **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(icaltime_from_string("19970801T120000Z")),
- icalproperty_new_duration(icaldurationtype_from_string("PT1H30M")),
- 0
- ),
- 0);
-
- printf("\n** 2 DTSTART and DURATION **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(icaltime_from_string("19970801T120000")),
- icalproperty_new_dtend(icaltime_from_string("19970801T130000")),
- 0
- ),
- 0);
-
- icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M"));
-
- printf("** 3 DTSTART and DTEND, Set DURATION **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(icaltime_from_string("19970801T120000Z")),
- icalproperty_new_duration(icaldurationtype_from_string("PT1H30M")),
- 0
- ),
- 0);
-
- icalcomponent_set_dtend(c,icaltime_from_string("19970801T133000Z"));
-
- printf("\n** 4 DTSTART and DURATION, set DTEND **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- 0
- ),
- 0);
-
- icalcomponent_set_dtstart(c,icaltime_from_string("19970801T120000Z"));
- icalcomponent_set_dtend(c,icaltime_from_string("19970801T133000Z"));
-
- printf("\n** 5 Set DTSTART and DTEND **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- 0
- ),
- 0);
-
-
- icalcomponent_set_dtstart(c,icaltime_from_string("19970801T120000Z"));
- icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M"));
-
- printf("\n** 6 Set DTSTART and DURATION **\n%s\n\n",
- icalcomponent_as_ical_string(c));
-
-
- duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
-
- printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c)));
- printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c)));
- printf("Dur: %d m\n",duration);
-
- icalcomponent_free(c);
-
-}
-
-void test_time_parser()
-{
- struct icaltimetype tt;
-
- icalerror_errors_are_fatal = 0;
-
- tt = icaltime_from_string("19970101T1000");
- assert(icaltime_is_null_time(tt));
-
- tt = icaltime_from_string("19970101X100000");
- assert(icaltime_is_null_time(tt));
-
- tt = icaltime_from_string("19970101T100000");
- assert(!icaltime_is_null_time(tt));
- printf("%s\n",icaltime_as_ctime(tt));
-
- tt = icaltime_from_string("19970101T100000Z");
- assert(!icaltime_is_null_time(tt));
- printf("%s\n",icaltime_as_ctime(tt));
-
- tt = icaltime_from_string("19970101");
- assert(!icaltime_is_null_time(tt));
- printf("%s\n",icaltime_as_ctime(tt));
-
- icalerror_errors_are_fatal = 1;
-
-}
-
-void test_recur_parser()
-{
- struct icalrecurrencetype rt;
-
- printf("FREQ=YEARLY;UNTIL=20000131T090000Z;BYMONTH=1,2,3,4,8;BYYEARDAY=34,65,76,78;BYDAY=-1TU,3WE,-4FR,SU,SA\n");
-
- rt = icalrecurrencetype_from_string("FREQ=YEARLY;UNTIL=20000131T090000Z;BYMONTH=1,2,3,4,8;BYYEARDAY=34,65,76,78;BYDAY=-1TU,3WE,-4FR,SU,SA");
-
- printf("%s\n\n",icalrecurrencetype_as_string(&rt));
-
- printf("FREQ=DAILY;COUNT=3;BYMONTH=1,2,3,4,8;BYYEARDAY=34,65,76,78;BYDAY=-1TU,3WE,-4FR,SU,S\n");
-
- rt = icalrecurrencetype_from_string("FREQ=DAILY;COUNT=3;BYMONTH=1,2,3,4,8;BYYEARDAY=34,65,76,78;BYDAY=-1TU,3WE,-4FR,SU,SA");
-
- printf("%s\n",icalrecurrencetype_as_string(&rt));
-
-}
-
-char* ical_strstr(const char *haystack, const char *needle){
- return strstr(haystack,needle);
-}
-
-void test_doy()
-{
- struct icaltimetype tt1, tt2;
- short doy;
-
- tt1 = icaltime_from_string("19950301");
- doy = icaltime_day_of_year(tt1);
- tt2 = icaltime_from_day_of_year(doy,1995);
- printf("%d %s %s\n",doy, icaltime_as_ctime(tt1),icaltime_as_ctime(tt2));
- assert(tt2.day == 1 && tt2.month == 3);
- assert(doy == 60);
-
- tt1 = icaltime_from_string("19960301");
- doy = icaltime_day_of_year(tt1);
- tt2 = icaltime_from_day_of_year(doy,1996);
- printf("%d %s %s\n",doy, icaltime_as_ctime(tt1),icaltime_as_ctime(tt2));
- assert(tt2.day == 1 && tt2.month == 3);
- assert(doy == 61);
-
- tt1 = icaltime_from_string("19970301");
- doy = icaltime_day_of_year(tt1);
- tt2 = icaltime_from_day_of_year(doy,1997);
- printf("%d %s %s\n",doy, icaltime_as_ctime(tt1),icaltime_as_ctime(tt2));
- assert(tt2.day == 1 && tt2.month == 3);
- assert(doy == 60);
-
-}
-
-
-void test_x(){
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ical.h>
-
- static const char test_icalcomp_str[] =
-"BEGIN:VEVENT\r\n"
-"RRULE\r\n"
-" ;X-EVOLUTION-ENDDATE=20030209T081500\r\n"
-" :FREQ=DAILY;COUNT=10;INTERVAL=6\r\n"
-"X-COMMENT;X-FOO=BAR: Booga\r\n"
-"END:VEVENT\r\n";
-
- icalcomponent *icalcomp;
- icalproperty *prop;
- struct icalrecurrencetype recur;
- int n_errors;
-
- icalcomp = icalparser_parse_string ((char *) test_icalcomp_str);
- if (!icalcomp) {
- fprintf (stderr, "main(): could not parse the component\n");
- exit (EXIT_FAILURE);
- }
-
- printf("%s\n\n",icalcomponent_as_ical_string(icalcomp));
-
- n_errors = icalcomponent_count_errors (icalcomp);
- if (n_errors) {
- icalproperty *p;
-
- for (p = icalcomponent_get_first_property (icalcomp,
- ICAL_XLICERROR_PROPERTY);
- p;
- p = icalcomponent_get_next_property (icalcomp,
- ICAL_XLICERROR_PROPERTY)) {
- char *str;
-
- str = icalproperty_as_ical_string (p);
- fprintf (stderr, "error: %s\n", str);
- }
- }
-
- prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY);
- if (!prop) {
- fprintf (stderr, "main(): could not get the RRULE property");
- exit (EXIT_FAILURE);
- }
-
- recur = icalproperty_get_rrule (prop);
-
- printf("%s\n",icalrecurrencetype_as_string(&recur));
-
-}
-
-void test_gauge_sql() {
-
-
- icalgauge *g;
-
- printf("\nSELECT DTSTART,DTEND,COMMENT FROM VEVENT,VTODO WHERE VEVENT.SUMMARY = 'Bongoa' AND SEQUENCE < 5\n");
-
- g = icalgauge_new_from_sql("SELECT DTSTART,DTEND,COMMENT FROM VEVENT,VTODO WHERE VEVENT.SUMMARY = 'Bongoa' AND SEQUENCE < 5");
-
- icalgauge_dump(g);
-
- icalgauge_free(g);
-
- printf("\nSELECT * FROM VEVENT,VTODO WHERE VEVENT.SUMMARY = 'Bongoa' AND SEQUENCE < 5 OR METHOD != 'CREATE'\n");
-
- g = icalgauge_new_from_sql("SELECT * FROM VEVENT,VTODO WHERE VEVENT.SUMMARY = 'Bongoa' AND SEQUENCE < 5 OR METHOD != 'CREATE'");
-
- icalgauge_dump(g);
-
- icalgauge_free(g);
-
-}
-
-void test_gauge_compare() {
-
- icalgauge *g;
- icalcomponent *c;
-
- /* Equality */
-
- c = icalcomponent_vanew(ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(
- icaltime_from_string("20000101T000002")),0),0);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART = '20000101T000002'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART = '20000101T000002'\n");
- assert(c!=0);
- assert(g!=0);
-
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART = '20000101T000001'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART = '20000101T000001'\n");
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 0);
-
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART != '20000101T000003'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART != '20000101T000003'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
-
- /* Less than */
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART < '20000101T000003'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART < '20000101T000003'\n");
-
- assert(icalgauge_compare(g,c) == 1);
-
- assert(g!=0);
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART < '20000101T000002'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART < '20000101T000002'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 0);
-
- icalgauge_free(g);
-
- /* Greater than */
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART > '20000101T000001'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART > '20000101T000001'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART > '20000101T000002'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART > '20000101T000002'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 0);
-
- icalgauge_free(g);
-
-
- /* Greater than or Equal to */
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART >= '20000101T000002'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART >= '20000101T000002'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART >= '20000101T000003'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART >= '20000101T000003'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 0);
-
- icalgauge_free(g);
-
- /* Less than or Equal to */
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART <= '20000101T000002'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART <= '20000101T000002'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART <= '20000101T000001'");
-
- printf("SELECT * FROM VEVENT WHERE DTSTART <= '20000101T000001'\n");
-
-
- assert(g!=0);
- assert(icalgauge_compare(g,c) == 0);
-
- icalgauge_free(g);
-
- icalcomponent_free(c);
-
-
- /* Complex comparisions */
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_method(ICAL_METHOD_REQUEST),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(
- icaltime_from_string("20000101T000002")),
- icalproperty_new_comment("foo"),
- icalcomponent_vanew(
- ICAL_VALARM_COMPONENT,
- icalproperty_new_dtstart(
- icaltime_from_string("20000101T120000")),
-
- 0),
- 0),
- 0);
-
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE VALARM.DTSTART = '20000101T120000'");
-
- printf("SELECT * FROM VEVENT WHERE VALARM.DTSTART = '20000101T120000'\n");
-
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE COMMENT = 'foo'");
-
- printf("SELECT * FROM VEVENT WHERE COMMENT = 'foo'\n");
-
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
-
- g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE COMMENT = 'foo' AND VALARM.DTSTART = '20000101T120000'");
-
- printf("SELECT * FROM VEVENT WHERE COMMENT = 'foo' AND VALARM.DTSTART = '20000101T120000'\n");
-
- assert(icalgauge_compare(g,c) == 1);
-
- icalgauge_free(g);
-
- icalcomponent_free(c);
-
-}
-
-icalcomponent* make_component(int i){
-
- icalcomponent *c;
-
- struct icaltimetype t = icaltime_from_string("20000101T120000Z");
-
- t.day += i;
-
- icaltime_normalize(t);
-
- c = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_method(ICAL_METHOD_REQUEST),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstart(t),
- 0),
- 0);
-
- assert(c != 0);
-
- return c;
-
-}
-void test_fileset()
-{
- icalfileset *fs;
- icalcomponent *c;
- int i;
- char *path = "test_fileset.ics";
- icalgauge *g = icalgauge_new_from_sql(
- "SELECT * FROM VEVENT WHERE DTSTART > '20000103T120000Z' AND DTSTART <= '20000106T120000Z'");
-
-
- unlink(path);
-
- fs = icalfileset_new(path);
-
- assert(fs != 0);
-
- for (i = 0; i!= 10; i++){
- c = make_component(i);
- icalfileset_add_component(fs,c);
- }
-
- icalfileset_commit(fs);
-
- icalfileset_free(fs);
- fs = icalfileset_new(path);
-
-
- printf("== No Selections \n");
-
- for (c = icalfileset_get_first_component(fs);
- c != 0;
- c = icalfileset_get_next_component(fs)){
- struct icaltimetype t = icalcomponent_get_dtstart(c);
-
- printf("%s\n",icaltime_as_ctime(t));
- }
-
- icalfileset_select(fs,g);
-
- printf("\n== DTSTART > '20000103T120000Z' AND DTSTART <= '20000106T120000Z' \n");
-
- for (c = icalfileset_get_first_component(fs);
- c != 0;
- c = icalfileset_get_next_component(fs)){
- struct icaltimetype t = icalcomponent_get_dtstart(c);
-
- printf("%s\n",icaltime_as_ctime(t));
- }
-
- icalfileset_free(fs);
-
-}
-
-void microsleep(int us)
-{
- struct timeval tv;
-
- tv.tv_sec = 0;
- tv.tv_usec = us;
-
- select(0,0,0,0,&tv);
-
-}
-
-
-void test_file_locks()
-{
- pid_t pid;
- char *path = "test_fileset_locktest.ics";
- icalfileset *fs;
- icalcomponent *c, *c2;
- struct icaldurationtype d;
- int i;
- int final,sec;
-
- icalfileset_safe_saves = 1;
-
- icalerror_clear_errno();
-
- unlink(path);
-
- fs = icalfileset_new(path);
-
- if(icalfileset_get_first_component(fs)==0){
- c = make_component(0);
-
- d = icaldurationtype_from_int(1);
-
- icalcomponent_set_duration(c,d);
-
- icalfileset_add_component(fs,c);
-
- c2 = icalcomponent_new_clone(c);
-
- icalfileset_add_component(fs,c2);
-
- icalfileset_commit(fs);
- }
-
- icalfileset_free(fs);
-
- assert(icalerrno == ICAL_NO_ERROR);
-
- pid = fork();
-
- assert(pid >= 0);
-
- if(pid == 0){
- /*child*/
- int i;
-
- microsleep(rand()/(RAND_MAX/100));
-
- for(i = 0; i< 50; i++){
- fs = icalfileset_new(path);
-
-
- assert(fs != 0);
-
- c = icalfileset_get_first_component(fs);
-
- assert(c!=0);
-
- d = icalcomponent_get_duration(c);
- d = icaldurationtype_from_int(icaldurationtype_as_int(d)+1);
-
- icalcomponent_set_duration(c,d);
- icalcomponent_set_summary(c,"Child");
-
- c2 = icalcomponent_new_clone(c);
- icalcomponent_set_summary(c2,"Child");
- icalfileset_add_component(fs,c2);
-
- icalfileset_mark(fs);
- icalfileset_commit(fs);
-
- icalfileset_free(fs);
-
- microsleep(rand()/(RAND_MAX/20));
-
-
- }
-
- exit(0);
-
- } else {
- /* parent */
- int i;
-
- for(i = 0; i< 50; i++){
- fs = icalfileset_new(path);
-
- assert(fs != 0);
-
- c = icalfileset_get_first_component(fs);
-
- assert(c!=0);
-
- d = icalcomponent_get_duration(c);
- d = icaldurationtype_from_int(icaldurationtype_as_int(d)+1);
-
- icalcomponent_set_duration(c,d);
- icalcomponent_set_summary(c,"Parent");
-
- c2 = icalcomponent_new_clone(c);
- icalcomponent_set_summary(c2,"Parent");
- icalfileset_add_component(fs,c2);
-
- icalfileset_mark(fs);
- icalfileset_commit(fs);
- icalfileset_free(fs);
-
- putc('.',stdout);
- fflush(stdout);
-
- }
- }
-
- assert(waitpid(pid,0,0)==pid);
-
-
- fs = icalfileset_new(path);
-
- i=1;
-
- c = icalfileset_get_first_component(fs);
- final = icaldurationtype_as_int(icalcomponent_get_duration(c));
- for (c = icalfileset_get_next_component(fs);
- c != 0;
- c = icalfileset_get_next_component(fs)){
- struct icaldurationtype d = icalcomponent_get_duration(c);
- sec = icaldurationtype_as_int(d);
-
- /*printf("%d,%d ",i,sec);*/
- assert(i == sec);
- i++;
- }
-
- printf("\nFinal: %d\n",final);
-
-
- assert(sec == final);
-}
-
-void test_action()
-{
- icalcomponent *c;
- icalproperty *p;
-
- static const char test_icalcomp_str[] =
-"BEGIN:VEVENT\n"
-"ACTION:EMAIL\n"
-"ACTION:PROCEDURE\n"
-"ACTION:AUDIO\n"
-"ACTION:FUBAR\n"
-"END:VEVENT\r\n";
-
-
- c = icalparser_parse_string ((char *) test_icalcomp_str);
- if (!c) {
- fprintf (stderr, "main(): could not parse the component\n");
- exit (EXIT_FAILURE);
- }
-
- printf("%s\n\n",icalcomponent_as_ical_string(c));
-
- p = icalcomponent_get_first_property(c,ICAL_ACTION_PROPERTY);
-
- assert(icalproperty_get_action(p) == ICAL_ACTION_EMAIL);
-
- p = icalcomponent_get_next_property(c,ICAL_ACTION_PROPERTY);
-
- assert(icalproperty_get_action(p) == ICAL_ACTION_PROCEDURE);
-
- p = icalcomponent_get_next_property(c,ICAL_ACTION_PROPERTY);
-
- assert(icalproperty_get_action(p) == ICAL_ACTION_AUDIO);
-
- p = icalcomponent_get_next_property(c,ICAL_ACTION_PROPERTY);
-
- assert(icalproperty_get_action(p) == ICAL_ACTION_X);
- assert(regrstrcmp(icalvalue_get_x(icalproperty_get_value(p)), "FUBAR")==0);
-
-
-}
-
-
-
-void test_trigger()
-{
-
- struct icaltriggertype tr;
- icalcomponent *c;
- icalproperty *p;
- char* str;
-
- static const char test_icalcomp_str[] =
-"BEGIN:VEVENT\n"
-"TRIGGER;VALUE=DATE-TIME:19980403T120000\n"
-"TRIGGER:-PT15M\n"
-"TRIGGER:19980403T120000\n"
-"TRIGGER;VALUE=DURATION:-PT15M\n"
-"END:VEVENT\r\n";
-
-
- c = icalparser_parse_string ((char *) test_icalcomp_str);
- if (!c) {
- fprintf (stderr, "main(): could not parse the component\n");
- exit (EXIT_FAILURE);
- }
-
- printf("%s\n\n",icalcomponent_as_ical_string(c));
-
- for(p = icalcomponent_get_first_property(c,ICAL_TRIGGER_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(c,ICAL_TRIGGER_PROPERTY)){
- tr = icalproperty_get_trigger(p);
-
- if(!icaltime_is_null_time(tr.time)){
- printf("value=DATE-TIME:%s\n", icaltime_as_ical_string(tr.time));
- } else {
- printf("value=DURATION:%s\n", icaldurationtype_as_ical_string(tr.duration));
- }
- }
-
- /* Trigger, as a DATETIME */
- tr.duration = icaldurationtype_null_duration();
- tr.time = icaltime_from_string("19970101T120000");
- p = icalproperty_new_trigger(tr);
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
- /* TRIGGER, as a DURATION */
- tr.time = icaltime_null_time();
- tr.duration = icaldurationtype_from_string("P3DT3H50M45S");
- p = icalproperty_new_trigger(tr);
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DURATION\n :P3DT3H50M45S\n",str) == 0);
- icalproperty_free(p);
-
- /* TRIGGER, as a DATETIME, VALUE=DATETIME*/
- tr.duration = icaldurationtype_null_duration();
- tr.time = icaltime_from_string("19970101T120000");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DATETIME));
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
- /*TRIGGER, as a DURATION, VALUE=DATETIME */
- tr.time = icaltime_null_time();
- tr.duration = icaldurationtype_from_string("P3DT3H50M45S");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DATETIME ));
-
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DURATION\n :P3DT3H50M45S\n",str) == 0);
- icalproperty_free(p);
-
- /* TRIGGER, as a DATETIME, VALUE=DURATION*/
- tr.duration = icaldurationtype_null_duration();
- tr.time = icaltime_from_string("19970101T120000");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DURATION));
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
- /*TRIGGER, as a DURATION, VALUE=DURATION */
- tr.time = icaltime_null_time();
- tr.duration = icaldurationtype_from_string("P3DT3H50M45S");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DURATION));
-
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DURATION\n :P3DT3H50M45S\n",str) == 0);
- icalproperty_free(p);
-
-
- /* TRIGGER, as a DATETIME, VALUE=BINARY */
- tr.duration = icaldurationtype_null_duration();
- tr.time = icaltime_from_string("19970101T120000");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
- /*TRIGGER, as a DURATION, VALUE=BINARY */
- tr.time = icaltime_null_time();
- tr.duration = icaldurationtype_from_string("P3DT3H50M45S");
- p = icalproperty_new_trigger(tr);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
-
- str = icalproperty_as_ical_string(p);
-
- printf("%s\n",str);
- assert(regrstrcmp("TRIGGER\n ;VALUE=DURATION\n :P3DT3H50M45S\n",str) == 0);
- icalproperty_free(p);
-
-
-
-}
-
-void test_rdate()
-{
-
- struct icaldatetimeperiodtype dtp;
- icalproperty *p;
- char* str;
- struct icalperiodtype period;
-
- period.start = icaltime_from_string("19970101T120000");
- period.end = icaltime_null_time();
- period.duration = icaldurationtype_from_string("PT3H10M15S");
-
- /* RDATE, as DATE-TIME */
- dtp.time = icaltime_from_string("19970101T120000");
- dtp.period = icalperiodtype_null_period();
- p = icalproperty_new_rdate(dtp);
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as PERIOD */
- dtp.time = icaltime_null_time();
- dtp.period = period;
- p = icalproperty_new_rdate(dtp);
-
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=PERIOD\n :19970101T120000/PT3H10M15S\n",str) == 0);
- icalproperty_free(p);
-
- /* RDATE, as DATE-TIME, VALUE=DATE-TIME */
- dtp.time = icaltime_from_string("19970101T120000");
- dtp.period = icalperiodtype_null_period();
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_DATETIME));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as PERIOD, VALUE=DATE-TIME */
- dtp.time = icaltime_null_time();
- dtp.period = period;
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_DATETIME));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=PERIOD\n :19970101T120000/PT3H10M15S\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as DATE-TIME, VALUE=PERIOD */
- dtp.time = icaltime_from_string("19970101T120000");
- dtp.period = icalperiodtype_null_period();
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_PERIOD));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as PERIOD, VALUE=PERIOD */
- dtp.time = icaltime_null_time();
- dtp.period = period;
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_PERIOD));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=PERIOD\n :19970101T120000/PT3H10M15S\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as DATE-TIME, VALUE=BINARY */
- dtp.time = icaltime_from_string("19970101T120000");
- dtp.period = icalperiodtype_null_period();
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=DATE-TIME\n :19970101T120000\n",str) == 0);
- icalproperty_free(p);
-
-
- /* RDATE, as PERIOD, VALUE=BINARY */
- dtp.time = icaltime_null_time();
- dtp.period = period;
- p = icalproperty_new_rdate(dtp);
- icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
- str = icalproperty_as_ical_string(p);
- printf("%s\n",str);
- assert(regrstrcmp("RDATE\n ;VALUE=PERIOD\n :19970101T120000/PT3H10M15S\n",str) == 0);
- icalproperty_free(p);
-
-
-}
-
-
-void test_langbind()
-{
- icalcomponent *c, *inner;
- icalproperty *p;
-
- static const char test_str[] =
-"BEGIN:VEVENT\n"
-"ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n"
-"COMMENT: Comment that \n spans a line\n"
-"DTSTART:19970101T120000\n"
-"DTSTART:19970101T120000Z\n"
-"DTSTART:19970101\n"
-"DURATION:P3DT4H25M\n"
-"FREEBUSY:19970101T120000/19970101T120000\n"
-"FREEBUSY:19970101T120000/P3DT4H25M\n"
-"END:VEVENT\n";
-
-
- printf("%s\n",test_str);
-
- c = icalparser_parse_string(test_str);
- inner = icalcomponent_get_inner(c);
-
-
- for(
- p = icallangbind_get_first_property(inner,"ANY");
- p != 0;
- p = icallangbind_get_next_property(inner,"ANY")
- ) {
-
- printf("%s\n",icallangbind_property_eval_string(p,":"));
- }
-
-
-
- p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
-
- icalproperty_set_parameter_from_string(p,"CUTYPE","INDIVIDUAL");
-
- printf("%s\n",icalproperty_as_ical_string(p));
-
-
- icalproperty_set_value_from_string(p,"mary@foo.org","TEXT");
-
- printf("%s\n",icalproperty_as_ical_string(p));
-
-}
-
-void test_property_parse()
-{
- icalproperty *p;
-
- p= icalproperty_new_from_string(
- "ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com");
-
- assert (p != 0);
- printf("%s\n",icalproperty_as_ical_string(p));
-
-
- p= icalproperty_new_from_string("DTSTART:19970101T120000Z\n");
-
- assert (p != 0);
- printf("%s\n",icalproperty_as_ical_string(p));
-
-}
-
-
-void test_value_parameter()
-{
-
- icalcomponent *c;
- icalproperty *p;
- icalparameter *param;
-
- static const char test_icalcomp_str[] =
-"BEGIN:VEVENT\n"
-"DTSTART;VALUE=DATE-TIME:19971123T123000\n"
-"DTSTART;VALUE=DATE:19971123\n"
-"DTSTART;VALUE=FOO:19971123T123000\n"
-"END:VEVENT\n";
-
- c = icalparser_parse_string ((char *) test_icalcomp_str);
- if (!c) {
- fprintf (stderr, "main(): could not parse the component\n");
- exit (EXIT_FAILURE);
- }
-
- printf("%s",icalcomponent_as_ical_string(c));
-
- p = icalcomponent_get_first_property(c,ICAL_DTSTART_PROPERTY);
- param = icalproperty_get_first_parameter(p,ICAL_VALUE_PARAMETER);
- assert(icalparameter_get_value(param) == ICAL_VALUE_DATETIME);
-
- p = icalcomponent_get_next_property(c,ICAL_DTSTART_PROPERTY);
- param = icalproperty_get_first_parameter(p,ICAL_VALUE_PARAMETER);
- assert(icalparameter_get_value(param) == ICAL_VALUE_DATE);
-
-}
-
-
-void test_x_property()
-{
- icalproperty *p;
-
- p= icalproperty_new_from_string(
- "X-LIC-PROPERTY: This is a note");
-
- printf("%s\n",icalproperty_as_ical_string(p));
-
- assert(icalproperty_isa(p) == ICAL_X_PROPERTY);
- assert(regrstrcmp(icalproperty_get_x_name(p),"X-LIC-PROPERTY")==0);
- assert(regrstrcmp(icalproperty_get_x(p)," This is a note")==0);
-
-}
-
-int main(int argc, char *argv[])
-{
- int c;
- extern char *optarg;
- extern int optopt;
- int errflg=0;
- char* program_name = strrchr(argv[0],'/');
- int ttime=0, trecur=0,tspan=0, tmisc=0, tgauge = 0, tfile = 0,
- tbasic = 0;
-
- if(argc==1) {
- ttime = trecur = tspan = tmisc = tgauge = tfile = tbasic = 1;
- }
-
- while ((c = getopt(argc, argv, "t:s:r:m:g:f:b:")) != -1) {
- switch (c) {
-
- case 'b': {
- tbasic = atoi(optarg);
- break;
- }
-
- case 't': {
- ttime = atoi(optarg);
- break;
- }
-
- case 's': {
- tspan = atoi(optarg);
- break;
- }
-
- case 'r': {
- trecur = atoi(optarg);
- break;
- }
-
-
- case 'm': {
- tmisc = atoi(optarg);
- break;
- }
-
-
- case 'g': {
- tgauge = atoi(optarg);
- break;
- }
-
- case 'f': {
- tfile = atoi(optarg);
- break;
- }
-
- case ':': {/* Option given without an operand */
- fprintf(stderr,
- "%s: Option -%c requires an operand\n",
- program_name,optopt);
- errflg++;
- break;
- }
- case '?': {
- errflg++;
- }
-
- }
-
- }
-
-
- if(ttime==1 || ttime==2){
- printf("\n------------Test time parser ----------\n");
- test_time_parser();
-
- }
-
- if(ttime==1 || ttime==3){
- printf("\n------------Test time----------------\n");
- test_time();
- }
-
- if(ttime==1 || ttime==4){
- printf("\n------------Test day of year---------\n");
- test_doy();
- }
-
- if(ttime==1 || ttime==5){
- printf("\n------------Test duration---------------\n");
- test_duration();
- }
-
- if(ttime==1 || ttime==6){
- printf("\n------------Test period ----------------\n");
- test_period();
- }
-
-
-
- if(trecur==1 || trecur==2){
- printf("\n------------Test recur parser ----------\n");
- test_recur_parser();
- }
-
- if(trecur==1 || trecur==3){
- printf("\n------------Test recur---------------\n");
- test_recur();
- }
-
- if(trecur==1 || trecur==4){
- printf("\n------------Test parameter bug---------\n");
- test_recur_parameter_bug();
- }
-
- if(trecur==1 || trecur==5){
- printf("\n------------Test Array Expansion---------\n");
- test_expand_recurrence();
- }
-
-
-
-
- if(tspan==1 || tspan==2){
- printf("\n------------Test FBlist------------\n");
- test_fblist();
- }
-
- if(tspan==1 || tspan==3){
- printf("\n------------Test Overlaps------------\n");
- test_overlaps();
- }
-
- if(tspan==1 || tspan==4){
- printf("\n------------Test Span----------------\n");
- test_span();
- }
-
- if(tgauge == 1 || tgauge == 2){
- printf("\n------------Test Gauge SQL----------------\n");
- test_gauge_sql();
- }
-
- if(tgauge == 1 || tgauge == 3){
- printf("\n------------Test Gauge Compare--------------\n");
- test_gauge_compare();
- }
-
- if(tfile ==1 || tfile == 2){
- printf("\n------------Test File Set--------------\n");
- test_fileset();
- }
-
- if(tfile ==1 || tfile == 3){
- printf("\n------------Test File Locks--------------\n");
- test_file_locks();
- }
-
-
-
- if(tmisc == 1 || tmisc == 2){
- printf("\n------------Test X Props and Params--------\n");
- test_x();
- }
-
- if(tmisc == 1 || tmisc == 3){
- printf("\n------------Test Trigger ------------------\n");
- test_trigger();
- }
-
- if(tmisc == 1 || tmisc == 4){
-
- printf("\n------------Test Restriction---------------\n");
- test_restriction();
- }
-
- if(tmisc == 1 || tmisc == 5){
-
- printf("\n------------Test RDATE---------------\n");
- test_rdate();
- }
-
- if(tmisc == 1 || tmisc == 6){
-
- printf("\n------------Test language binding---------------\n");
- test_langbind();
- }
-
-
- if(tmisc == 1 || tmisc == 7){
-
- printf("\n------------Test property parser---------------\n");
- test_property_parse();
- }
-
- if(tmisc == 1 || tmisc == 8){
- printf("\n------------Test Action ------------------\n");
- test_action();
- }
-
- if(tmisc == 1 || tmisc == 9){
- printf("\n------------Test Value Parameter ------------------\n");
- test_value_parameter();
- }
-
- if(tmisc == 1 || tmisc == 10){
- printf("\n------------Test X property ------------------\n");
- test_x_property();
- }
-
-
- if(tbasic == 1 || tbasic == 2){
- printf("\n------------Test Values---------------\n");
- test_values();
- }
-
- if(tbasic == 1 || tbasic == 3){
- printf("\n------------Test Parameters-----------\n");
- test_parameters();
- }
-
- if(tbasic == 1 || tbasic == 4){
- printf("\n------------Test Properties-----------\n");
- test_properties();
- }
-
- if(tbasic == 1 || tbasic == 5){
- printf("\n------------Test Components ----------\n");
- test_components();
- }
-
- if(tmisc == 1){
-
- printf("\n------------Test Convenience ------------\n");
- test_convenience();
-
-
- printf("\n------------Test classify ---------------\n");
- test_classify();
-
-
- printf("\n------------Test Iterators-----------\n");
- test_iterators();
-
-
- printf("\n-----------Test request status-------\n");
- test_requeststat();
-
- printf("\n------------Test strings---------------\n");
- test_strings();
-
- printf("\n------------Test Compare---------------\n");
- test_compare();
-
- printf("\n------------Create Components --------\n");
- create_new_component();
-
- printf("\n----- Create Components with vaargs ---\n");
- create_new_component_with_va_args();
-
- printf("\n------------Test Memory---------------\n");
- test_memory();
- }
-
- return 0;
-}
-
-
-
diff --git a/libical/src/test/storage.c b/libical/src/test/storage.c
deleted file mode 100644
index 2d8bc586f4..0000000000
--- a/libical/src/test/storage.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: usecases.c
- CREATOR: eric 03 April 1999
-
- DESCRIPTION:
-
- $Id$
- $Locker$
-
- (C) COPYRIGHT 1999 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 author is Eric Busboom
- The original code is usecases.c
-
-
- ======================================================================*/
-
-#include "ical.h"
-#include <assert.h>
-#include <string.h> /* for strdup */
-#include <stdlib.h> /* for malloc */
-#include <stdio.h> /* for printf */
-#include <time.h> /* for time() */
-#include "icalmemory.h"
-#include "icaldirset.h"
-#include "icalfileset.h"
-#include "icalerror.h"
-#include "icalrestriction.h"
-#include "icalcalendar.h"
-
-#define OUTPUT_FILE "filesetout.ics"
-
-char str[] = "BEGIN:VCALENDAR\n\
-PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\n\
-VERSION:2.0\n\
-BEGIN:VTIMEZONE\n\
-TZID:US-Eastern\n\
-BEGIN:STANDARD\n\
-DTSTART:19981025T020000\n\
-RDATE:19981025T020000\n\
-TZOFFSETFROM:-0400\n\
-TZOFFSETTO:-0500\n\
-TZNAME:EST\n\
-END:STANDARD\n\
-BEGIN:DAYLIGHT\n\
-DTSTART:19990404T020000\n\
-RDATE:19990404T020000\n\
-TZOFFSETFROM:-0500\n\
-TZOFFSETTO:-0400\n\
-TZNAME:EDT\n\
-END:DAYLIGHT\n\
-END:VTIMEZONE\n\
-BEGIN:VEVENT\n\
-DTSTAMP:19980309T231000Z\n\
-UID:guid-1.host1.com\n\
-ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\n\
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n\
-DESCRIPTION:Project XYZ Review Meeting\n\
-CATEGORIES:MEETING\n\
-CLASS:PUBLIC\n\
-CREATED:19980309T130000Z\n\
-SUMMARY:XYZ Project Review\n\
-DTSTART;TZID=US-Eastern:19980312T083000\n\
-DTEND;TZID=US-Eastern:19980312T093000\n\
-LOCATION:1CP Conference Room 4350\n\
-END:VEVENT\n\
-BEGIN:BOOGA\n\
-DTSTAMP:19980309T231000Z\n\
-X-LIC-FOO:Booga\n\
-DTSTOMP:19980309T231000Z\n\
-UID:guid-1.host1.com\n\
-END:BOOGA\n\
-END:VCALENDAR";
-
-char str2[] = "BEGIN:VCALENDAR\n\
-PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\n\
-VERSION:2.0\n\
-BEGIN:VEVENT\n\
-DTSTAMP:19980309T231000Z\n\
-UID:guid-1.host1.com\n\
-ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\n\
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n\
-DESCRIPTION:Project XYZ Review Meeting\n\
-CATEGORIES:MEETING\n\
-CLASS:PUBLIC\n\
-CREATED:19980309T130000Z\n\
-SUMMARY:XYZ Project Review\n\
-DTSTART;TZID=US-Eastern:19980312T083000\n\
-DTEND;TZID=US-Eastern:19980312T093000\n\
-LOCATION:1CP Conference Room 4350\n\
-END:VEVENT\n\
-END:VCALENDAR\n\
-";
-
-
-void test_fileset()
-{
- icalfileset *cout;
- int month = 0;
- int count=0;
- struct icaltimetype start, end;
- icalcomponent *c,*clone, *itr;
-
- start = icaltime_from_timet( time(0),0);
- end = start;
- end.hour++;
-
- cout = icalfileset_new(OUTPUT_FILE);
- assert(cout != 0);
-
- c = icalparser_parse_string(str2);
- assert(c != 0);
-
- /* Add data to the file */
-
- for(month = 1; month < 10; month++){
- icalcomponent *event;
- icalproperty *dtstart, *dtend;
-
- cout = icalfileset_new(OUTPUT_FILE);
- assert(cout != 0);
-
- start.month = month;
- end.month = month;
-
- clone = icalcomponent_new_clone(c);
- assert(clone !=0);
- event = icalcomponent_get_first_component(clone,ICAL_VEVENT_COMPONENT);
- assert(event != 0);
-
- dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
- assert(dtstart!=0);
- icalproperty_set_dtstart(dtstart,start);
-
- dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- assert(dtend!=0);
- icalproperty_set_dtend(dtend,end);
-
- icalfileset_add_component(cout,clone);
- icalfileset_commit(cout);
-
- icalfileset_free(cout);
-
- }
-
-
- /* Print them out */
-
-
- cout = icalfileset_new(OUTPUT_FILE);
- assert(cout != 0);
-
- for (itr = icalfileset_get_first_component(cout);
- itr != 0;
- itr = icalfileset_get_next_component(cout)){
-
- icalcomponent *event;
- icalproperty *dtstart, *dtend;
-
- count++;
-
- event = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT);
-
- dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
- dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
-
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
-
- }
-
- /* Remove all of them */
-
- icalfileset_free(cout);
-
- cout = icalfileset_new(OUTPUT_FILE);
- assert(cout != 0);
-
- for (itr = icalfileset_get_first_component(cout);
- itr != 0;
- itr = icalfileset_get_next_component(cout)){
-
-
- icalfileset_remove_component(cout, itr);
- }
-
- icalfileset_free(cout);
-
-
- /* Print them out again */
-
- cout = icalfileset_new(OUTPUT_FILE);
- assert(cout != 0);
- count =0;
-
- for (itr = icalfileset_get_first_component(cout);
- itr != 0;
- itr = icalfileset_get_next_component(cout)){
-
- icalcomponent *event;
- icalproperty *dtstart, *dtend;
-
- count++;
-
- event = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT);
-
- dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
- dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
-
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
-
- }
-
- icalfileset_free(cout);
-
-
-}
-
-
-
-int test_dirset()
-{
-
- icalcomponent *c, *gauge;
- icalerrorenum error;
- icalcomponent *itr;
- icalfileset* cluster;
- struct icalperiodtype rtime;
- icaldirset *s = icaldirset_new("store");
- int i;
-
- assert(s != 0);
-
- rtime.start = icaltime_from_timet( time(0),0);
-
- cluster = icalfileset_new(OUTPUT_FILE);
-
- assert(cluster != 0);
-
-#define NUMCOMP 4
-
- /* Duplicate every component in the cluster NUMCOMP times */
-
- icalerror_clear_errno();
-
- for (i = 1; i<NUMCOMP+1; i++){
-
- /*rtime.start.month = i%12;*/
- rtime.start.month = i;
- rtime.end = rtime.start;
- rtime.end.hour++;
-
- for (itr = icalfileset_get_first_component(cluster);
- itr != 0;
- itr = icalfileset_get_next_component(cluster)){
- icalcomponent *clone, *inner;
- icalproperty *p;
-
- inner = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT);
- if (inner == 0){
- continue;
- }
-
- /* Change the dtstart and dtend times in the component
- pointed to by Itr*/
-
- clone = icalcomponent_new_clone(itr);
- inner = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT);
-
- assert(icalerrno == ICAL_NO_ERROR);
- assert(inner !=0);
-
- /* DTSTART*/
- p = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
- assert(icalerrno == ICAL_NO_ERROR);
-
- if (p == 0){
- p = icalproperty_new_dtstart(rtime.start);
- icalcomponent_add_property(inner,p);
- } else {
- icalproperty_set_dtstart(p,rtime.start);
- }
- assert(icalerrno == ICAL_NO_ERROR);
-
- /* DTEND*/
- p = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
- assert(icalerrno == ICAL_NO_ERROR);
-
- if (p == 0){
- p = icalproperty_new_dtstart(rtime.end);
- icalcomponent_add_property(inner,p);
- } else {
- icalproperty_set_dtstart(p,rtime.end);
- }
- assert(icalerrno == ICAL_NO_ERROR);
-
- printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner));
-
- error = icaldirset_add_component(s,
- icalcomponent_new_clone(itr));
-
- assert(icalerrno == ICAL_NO_ERROR);
-
- }
-
- }
-
- gauge =
- icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_summary(
- "Submit Income Taxes",
- icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL),
- 0),
- 0),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_vanew_summary(
- "Bastille Day Party",
- icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL),
- 0),
- 0),
- 0);
-
-#if 0
-
-
- icaldirset_select(s,gauge);
-
- for(c = icaldirset_first(s); c != 0; c = icaldirset_next(s)){
-
- printf("Got one! (%d)\n", count++);
-
- if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
- if (icaldirset_store(s2,c) == 0){
- printf("Failed to write!\n");
- }
- icalcomponent_free(c);
- } else {
- printf("Failed to get component\n");
- }
- }
-
-
- icaldirset_free(s2);
-#endif
-
-
- for(c = icaldirset_get_first_component(s);
- c != 0;
- c = icaldirset_get_next_component(s)){
-
- if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
- } else {
- printf("Failed to get component\n");
- }
-
- }
-
- /* Remove all of the components */
- i=0;
- while((c=icaldirset_get_current_component(s)) != 0 ){
- i++;
-
- icaldirset_remove_component(s,c);
- }
-
-
- icaldirset_free(s);
- return 0;
-}
-
-#if 0
-void test_calendar()
-{
- icalcomponent *comp;
- icalfileset *c;
- icaldirset *s;
- icalcalendar* calendar = icalcalendar_new("calendar");
- icalerrorenum error;
- struct icaltimetype atime = icaltime_from_timet( time(0),0,0);
-
- comp = icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_description("This is an event"),
- icalproperty_new_dtstart(atime),
- icalproperty_vanew_comment(
- "Another Comment",
- icalparameter_new_cn("A Common Name 1"),
- icalparameter_new_cn("A Common Name 2"),
- icalparameter_new_cn("A Common Name 3"),
- icalparameter_new_cn("A Common Name 4"),
- 0),
- icalproperty_vanew_xlicerror(
- "This is only a test",
- icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_COMPONENTPARSEERROR),
- 0),
-
- 0);
-
-
- s = icalcalendar_get_booked(calendar);
-
- error = icaldirset_add_component(s,comp);
-
- assert(error == ICAL_NO_ERROR);
-
- c = icalcalendar_get_properties(calendar);
-
- error = icalfileset_add_component(c,icalcomponent_new_clone(comp));
-
- assert(error == ICAL_NO_ERROR);
-
- icalcalendar_free(calendar);
-
-}
-#endif
-
-
-int main(int argc, char *argv[])
-{
-
-/* printf("\n------------Test File Set---------------\n");
- test_fileset(); */
-
- printf("\n------------Test Dir Set---------------\n");
- test_dirset();
-
-#if 0
-
-
- printf("\n------------Test Calendar---------------\n");
- test_calendar();
-
-#endif
-
- return 0;
-}
-
-
-
diff --git a/libical/src/test/stow.c b/libical/src/test/stow.c
deleted file mode 100644
index e676c677f3..0000000000
--- a/libical/src/test/stow.c
+++ /dev/null
@@ -1,866 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: stow.c
- CREATOR: eric 29 April 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 Initial Developer of the Original Code is Eric Busboom
-
- ======================================================================*/
-
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h> /* for PATH_MAX */
-#include <assert.h>
-#include <stdlib.h>
-#include <sys/utsname.h> /* for uname */
-#include <sys/stat.h> /* for stat */
-#include <unistd.h> /* for stat, getpid, getopt */
-#include <pwd.h> /* For getpwent */
-#include <sys/types.h> /* For getpwent */
-#include <ctype.h> /* for tolower */
-
-#include "ical.h"
-#include "icalcalendar.h"
-#include "icalfileset.h"
-#include "icalmime.h"
-
-char* program_name;
-#define TMPSIZE 2048
-#define SENDMAIL "/usr/lib/sendmail -t"
-
-void usage(char *message);
-
-#ifndef PATH_MAX
-#define PATH_MAX 256 /* HACK */
-#endif
-
-
-enum options {
- STORE_IN_FILE,
- STORE_IN_DB,
- INPUT_IS_MIME,
- INPUT_IS_ICAL,
- INPUT_FROM_STDIN,
- INPUT_FROM_FILE,
- ERRORS_TO_STDOUT,
- ERRORS_TO_ORGANIZER
-};
-
-struct options_struct
-{
- enum options storage;
- enum options input_type;
- enum options input_source;
- enum options errors;
- char* input_file;
- char* calid;
- char* output_file;
-};
-
-
-enum file_type
-{
- ERROR,
- NO_FILE,
- DIRECTORY,
- REGULAR,
- OTHER
-};
-
-enum file_type test_file(char *path)
-{
- struct stat sbuf;
- enum file_type type;
-
- errno = 0;
-
- /* Check if the path already exists and if it is a directory*/
- if (stat(path,&sbuf) != 0){
-
- /* A file by the given name does not exist, or there was
- another error */
- if(errno == ENOENT)
- {
- type = NO_FILE;
- } else {
- type = ERROR;
- }
-
- } else {
- /* A file by the given name exists, but is it a directory? */
-
- if (S_ISDIR(sbuf.st_mode)){
- type = DIRECTORY;
- } else if(S_ISREG(sbuf.st_mode)){
- type = REGULAR;
- } else {
- type = OTHER;
- }
- }
-
- return type;
-}
-
-char* lowercase(const char* str)
-{
- char* p = 0;
- char* new = strdup(str);
-
- if(str ==0){
- return 0;
- }
-
- for(p = new; *p!=0; p++){
- *p = tolower(*p);
- }
-
- return new;
-}
-
-#if 0
-char* get_local_attendee(struct options_struct *opt)
-{
- char attendee[PATH_MAX];
-
- if(opt->calid){
-
- strncpy(attendee,opt->calid,PATH_MAX);
-
- } else {
-
- char* user = getenv("USER");
- struct utsname uts;
- uname(&utget_option);
- /* HACK nodename may not be a fully qualified domain name */
- snprintf(attendee,PATH_MAX,"%s@%s",user,uts.nodename);
-
- }
-
- return lowercase(attendee);
-}
-#endif
-
-
-icalcomponent* get_first_real_component(icalcomponent *comp)
-{
- icalcomponent *c;
-
- for(c = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
- c != 0;
- c = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
- if (icalcomponent_isa(c) == ICAL_VEVENT_COMPONENT ||
- icalcomponent_isa(c) == ICAL_VTODO_COMPONENT ||
- icalcomponent_isa(c) == ICAL_VJOURNAL_COMPONENT )
- {
- return c;
- }
- }
-
- return 0;
-}
-
-
-
-char* make_mime(char* to, const char* from, const char* subject,
- const char* text_message, const char* method,
- const char* ical_message)
-{
- size_t size = strlen(to)+strlen(from)+strlen(subject)+
- strlen(text_message)+ strlen(ical_message)+TMPSIZE;
-
- char mime_part_1[TMPSIZE];
- char mime_part_2[TMPSIZE];
- char content_id[TMPSIZE];
- char boundary[TMPSIZE];
- struct utsname uts;
- char* m;
-
-
- if ((m = malloc(sizeof(char)*size)) == 0){
- fprintf(stderr,"%s: Can't allocate memory: %s\n",program_name,strerror(errno));
- exit(1);
- }
-
- uname(&uts);
-
- srand(time(0)<<getpid());
- sprintf(content_id,"%d-%d@%s",(int)time(0),rand(),uts.nodename);
- sprintf(boundary,"%d-%d-%s",(int)time(0),rand(),uts.nodename);
-
- sprintf(mime_part_1,"Content-ID: %s\n\
-Content-type: text/plain\n\
-Content-Description: Text description of error message\n\n\
-%s\n\n--%s",
- content_id,text_message,boundary);
-
- if(ical_message != 0 && method != 0){
- sprintf(mime_part_2,"Content-ID: %s\n\
-Content-type: text/calendar; method=%s\n\
-Content-Description: iCal component reply\n\n\
-%s\n\n--%s--",
- content_id,method,ical_message,boundary);
- }
-
- sprintf(m,"To: %s\n\
-From: %s\n\
-Subject: %s\n\
-MIME-Version: 1.0\n\
-Content-ID: %s\n\
-Content-Type: multipart/mixed; boundary=\"%s\"\n\
-\n\
- This is a multimedia message in MIME format\n\
-\n\
---%s\n\
-%s\n\
-",
- to,from,subject,content_id,boundary,boundary,
- mime_part_1);
-
- if(ical_message != 0 && method != 0){
- strcat(m, mime_part_2);
- } else {
- strcat(m,"--\n");
- }
-
- return m;
-}
-
-/* The incoming component had fatal errors */
-void return_failure(icalcomponent* comp, char* message,
- struct options_struct *opt)
-{
- char* local_attendee = opt->calid;
- FILE* p;
-
- icalcomponent *inner = get_first_real_component(comp);
-
- icalproperty *organizer_prop = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY);
- const char *organizer = icalproperty_get_organizer(organizer_prop);
-
- organizer += 7;
-
- if (opt->errors == ERRORS_TO_ORGANIZER){
- p = popen(SENDMAIL,"w");
- } else {
- p = stdout;
- }
-
- if(p == 0){
- fprintf(stderr,
- "%s: fatal. Could not open pipe to sendmail (\"%s\") \n",
- program_name,SENDMAIL);
- exit(1);
- }
-
- fputs(make_mime(organizer, local_attendee, "iMIP error",
- message, "reply",
- icalcomponent_as_ical_string(comp)),p);
-
- if (opt->errors == ERRORS_TO_ORGANIZER){
- pclose(p);
- }
-}
-
-/* The program had a fatal error and could not process the incoming component*/
-void return_error(icalcomponent* comp, char* message, struct options_struct *opt)
-{
-
-
- fputs(make_mime("Dest", "Source", "iMIP system failure",
- message, 0,0),stdout);
-
-}
-
-icalcomponent* make_reply(icalcomponent *comp, icalproperty *return_status,
- struct options_struct *opt)
-
-{
- icalcomponent *reply, *rinner;
- icalcomponent *inner = get_first_real_component(comp);
- icalproperty *p=0;
- char* local_attendee = opt->calid;
- char attendee[TMPSIZE];
-
- char prodid[TMPSIZE];
-
- snprintf(attendee,TMPSIZE,"mailto:%s",local_attendee);
-
- snprintf(prodid,TMPSIZE,"-//Softwarestudio.org//%s version %s//EN",ICAL_PACKAGE,ICAL_VERSION);
-
- /* Create the base component */
- reply = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version(strdup("2.0")),
- icalproperty_new_prodid(strdup(prodid)),
- icalproperty_new_method(ICAL_METHOD_REPLY),
- icalcomponent_vanew(
- ICAL_VEVENT_COMPONENT,
- icalproperty_new_clone(
- icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY)),
- icalproperty_new_clone(
- icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY)),
- icalproperty_new_clone(
- icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY)),
- icalproperty_new_attendee(attendee),
- 0),
- 0);
-
-
- /* Convert errors into request-status properties and transfers
- them to the reply component */
-
- icalcomponent_convert_errors(comp);
-
- rinner = get_first_real_component(reply);
-
- for(p = icalcomponent_get_first_property(inner,
- ICAL_REQUESTSTATUS_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(inner,
- ICAL_REQUESTSTATUS_PROPERTY)){
-
- icalcomponent_add_property(rinner,icalproperty_new_clone(p));
- }
-
- if(return_status != 0){
- icalcomponent_add_property(rinner, return_status);
- }
-
- return reply;
-
-}
-
-int check_attendee(icalproperty *p, struct options_struct *opt){
- const char* s = icalproperty_get_attendee(p);
- char* lower_attendee = lowercase(s);
- char* local_attendee = opt->calid;
-
- /* Check that attendee begins with "mailto:" */
- if (strncmp(lower_attendee,"mailto:",7) == 0){
- /* skip over the mailto: part */
- lower_attendee += 7;
-
- if(strcmp(lower_attendee,local_attendee) == 0){
- return 1;
- }
-
- lower_attendee -= 7;
-
- free(lower_attendee);
- }
-
- return 0;
-}
-
-char static_component_error_str[PATH_MAX];
-char* check_component(icalcomponent* comp, icalproperty **return_status,
- struct options_struct *opt)
-{
- char* component_error_str=0;
- icalcomponent* inner;
- int errors = 0;
- icalproperty *p;
- int found_attendee = 0;
-
- *return_status = 0;
-
- /* This do/while loop only executes once because it is being used
- to fake exceptions */
-
- do {
-
- /* Check that we actually got a component */
- if(comp == 0){
- strcpy(static_component_error_str,
- "Did not find a component");
- component_error_str = static_component_error_str;
- break;
- }
-
- /* Check that the root component is a VCALENDAR */
- if(icalcomponent_isa(comp) != ICAL_VCALENDAR_COMPONENT){
- strcpy(static_component_error_str,
- "Root component is not a VCALENDAR");
- component_error_str = static_component_error_str;
- break;
- }
-
-
- /* Check that the component has a METHOD */
-
- if (icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY) == 0)
- {
- strcpy(static_component_error_str,
- "Component does not have a METHOD property");
- component_error_str = static_component_error_str;
- break;
- }
-
- inner = get_first_real_component(comp);
-
-
- /* Check that the compopnent has an organizer */
- if(icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY) == 0){
- fprintf(stderr,"%s: fatal. Component does not have an ORGANIZER property\n",program_name);
-
- exit(1);
- }
-
-
- /* Check for this user as an attendee or organizer */
-
- for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)){
-
- found_attendee += check_attendee(p,opt);
- }
-
- for(p = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(inner,ICAL_ORGANIZER_PROPERTY)){
-
- found_attendee += check_attendee(p,opt);
- }
-
- if (found_attendee == 0){
- struct icalreqstattype rs;
- char* rs_string;
- memset(static_component_error_str,0,PATH_MAX);
-
- snprintf(static_component_error_str,PATH_MAX,
- "This target user (%s) is not listed as an attendee or organizer",
- opt->calid );
- component_error_str = static_component_error_str;
-
- rs.code = ICAL_3_7_INVCU_STATUS;
- rs.desc = 0;
- rs.debug = component_error_str;
- rs_string = icalreqstattype_as_string(rs);
-
- *return_status = icalproperty_new_requeststatus(rs_string);
-
- break;
- }
-
-
-
- /* Check that the component passes iTIP restrictions */
-
- errors = icalcomponent_count_errors(comp);
- icalrestriction_check(comp);
-
- if(errors != icalcomponent_count_errors(comp)){
- snprintf(static_component_error_str,PATH_MAX,
- "The component does not conform to iTIP restrictions.\n Here is the original component; look at the X-LIC-ERROR properties\nfor details\n\n%s",icalcomponent_as_ical_string(comp));
- component_error_str = static_component_error_str;
- break;
- }
-
-
-
- } while(0);
-
- return component_error_str;
-}
-
-
-void usage(char *message)
-{
- fprintf(stderr,"Usage: %s [-emdcn] [-i inputfile] [-o outputfile] [-u calid]\n",program_name);
- fprintf(stderr,"-e\tInput data is encapsulated in a MIME Message \n\
--m\tInput is raw iCal \n\
--i\tSpecify input file. Otherwise, input comes from stdin\n\
--o\tSpecify file to save incoming message to\n\
--d\tSpecify database to send data to\n\
--u\tSet the calid to store the data to\n\
--n\tSend errors to stdout instead of organizer\n\
-");
-
-}
-
-
-void get_options(int argc, char* argv[], struct options_struct *opt)
-{
- int c;
- extern char *optarg;
- extern int optind, optopt;
- int errflg=0;
-
- opt->storage = STORE_IN_FILE;
- opt->input_source = INPUT_FROM_STDIN;
- opt->input_type = INPUT_IS_ICAL;
- opt->input_file = 0;
- opt->errors = ERRORS_TO_ORGANIZER;
- opt->calid = 0;
- opt->output_file = 0;
-
-
- while ((c = getopt(argc, argv, "nemu:o:d:b:c:i:")) != -1) {
- switch (c) {
- case 'e': { /* Input data is MIME encapsulated */
- opt->input_type = INPUT_IS_MIME;
- break;
- }
- case 'm': { /* Input is iCal. Default*/
- opt->input_type = INPUT_IS_ICAL;
- break;
- }
- case 'i': { /* Input comes from named file */
- opt->input_source = INPUT_FROM_FILE;
- opt->input_file = strdup(optarg);
- break;
- }
- case 'o': { /* Output goes to named file. Default*/
- opt->output_file = strdup(optarg);
- opt->storage = STORE_IN_FILE;
- break;
- }
- case 'd': { /* Output goes to database */
- fprintf(stderr,"%s: option -d is unimplmented\n",program_name);
- opt->storage = STORE_IN_DB;
- errflg++;
- break;
- }
- case 'c': {
-
- break;
- }
- case 'u': { /* Set the calid for the output database or
- file. Default is user name of user running
- program */
- opt->calid = strdup(optarg);
- break;
- }
-
- case 'n': { /* Dump error to stdout. Default is to
- send error to the organizer specified
- in the iCal data */
- opt->errors = ERRORS_TO_STDOUT;
- break;
- }
-
- case ':': {/* Option given without an operand */
- fprintf(stderr,
- "%s: Option -%c requires an operand\n",
- program_name,optopt);
- errflg++;
- break;
- }
- case '?': {
- errflg++;
- }
-
- }
-
- if (errflg >0){
- usage("");
- exit(1);
- }
- }
-
- if(opt->calid == 0){
- /* If no calid specified, use username */
- char attendee[PATH_MAX];
- char* user = getenv("USER");
- struct utsname uts;
- uname(&uts);
- /* HACK nodename may not be a fully qualified domain name */
- snprintf(attendee,PATH_MAX,"%s@%s",user,uts.nodename);
-
- opt->calid = lowercase(attendee);
- }
-
- if(opt->storage == STORE_IN_FILE &&
- opt->output_file ==0){
- char file[PATH_MAX];
- char* user = getenv("USER");
- struct passwd *pw;
-
- if(!user){
- fprintf(stderr,"%s: Can't get username. Try explicitly specifing the output file with -o", program_name);
- exit(1);
- }
-
- /* Find password entry for user */
- while( (pw = getpwent())!=0){
- if(strcmp(user,pw->pw_name)==0){
- break;
- }
- }
-
- if(pw==0){
- fprintf(stderr,"%s: Can't get get password entry for user \"%s\" Try explicitly specifing the output file with -o",
- program_name,user);
- exit(1);
- }
-
- if(pw->pw_dir==0){
- fprintf(stderr,"%s: User \"%s\" has no home directory. Try explicitly specifing the output file with -o",
- program_name, user);
- exit(1);
- }
-
- snprintf(file,PATH_MAX,"%s/.facs/%s",pw->pw_dir,opt->calid);
-
- opt->output_file = strdup(file);
- }
-
-
- /* Now try to create the calendar directory if it does
- not exist */
-
- if(opt->storage == STORE_IN_FILE ) {
- char * p;
- char* facspath = strdup(opt->output_file);
- enum file_type type;
-
- /* Cut off the last slash to make it just a directoy */
-
- p = strrchr(facspath,'/');
-
- if (p == 0){
- fprintf(stderr,"%s: Invalid calendar filename \"%s\"",
- program_name,facspath);
- exit(1);
- }
-
- *p='\0';
-
- type = test_file(facspath);
-
- errno = 0;
- if (type == NO_FILE){
-
- if(mkdir(facspath,0775) != 0){
- fprintf(stderr,
- "%s: Failed to create calendar directory %s: %s\n",
- program_name,facspath, strerror(errno));
- exit(1);
- } else {
- fprintf(stderr,"%s: Creating calendar directory %s\n",
- program_name,facspath);
- }
-
- } else if(type==REGULAR || type == ERROR){
- fprintf(stderr,"%s: Cannot create calendar directory %s\n",
- program_name,facspath);
- exit(1);
- }
- }
-}
-
-char* check_options(struct options_struct *opt)
-{
- return 0;
-}
-
-void store_component(icalcomponent *comp, struct options_struct *opt)
-{
- icalerrorenum error;
-
-
- if(opt->storage == STORE_IN_FILE){
- icalfileset *fs = icalfileset_new(opt->output_file);
-
- if (fs == 0){
- fprintf(stderr,
- "%s: Failed to get incoming component directory: %s\n",
- program_name, icalerror_strerror(icalerrno));
- exit(1);
- }
-
-
- error = icalfileset_add_component(fs,comp);
-
- if (error != ICAL_NO_ERROR){
- fprintf(stderr,"%s: Failed to write incoming component: %s\n",
- program_name, icalerror_strerror(icalerrno));
- exit(1);
- }
-
- error = icalfileset_commit(fs);
-
- if (error != ICAL_NO_ERROR){
- fprintf(stderr,"%s: Failed to commit incoming cluster: %s\n",
- program_name, icalerror_strerror(icalerrno));
- exit(1);
- }
-
- icalfileset_free(fs);
-
- return;
- } else {
- assert(0);
- }
-}
-
-char* read_stream(char *s, size_t size, void *d)
-{
- char *c = fgets(s,size, (FILE*)d);
-
- return c;
-}
-
-icalcomponent* read_nonmime_component(struct options_struct *opt)
-{
- FILE *stream;
- icalcomponent *comp;
- icalparser* parser = icalparser_new();
- char* line;
-
- if(opt->input_source == INPUT_FROM_FILE){
- stream = fopen(opt->input_file,"r");
-
- if (stream == 0){
- perror("Can't open input file");
- exit(1);
- }
-
- } else {
- stream = stdin;
- }
-
- assert(stream != 0);
- icalparser_set_gen_data(parser,stream);
-
- do {
- line = icalparser_get_line(parser,read_stream);
-
- comp = icalparser_add_line(parser,line);
-
- if (comp != 0){
- return comp;
- }
-
- } while ( line != 0);
-
- if(opt->input_source == INPUT_FROM_FILE){
- fclose(stream);
- }
-
-
- return comp;
- }
-
-icalcomponent* find_vcalendar(icalcomponent* comp)
-{
- icalcomponent *c,*rtrn;
-
- for(c = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
- c != 0;
- c = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
-
- if(icalcomponent_isa(c) == ICAL_VCALENDAR_COMPONENT){
- icalcomponent_remove_component(comp,c);
- return c;
- }
-
- if((rtrn=find_vcalendar(c)) != 0){
- return rtrn;
- }
- }
-
- return 0;
-}
-
-icalcomponent* read_mime_component(struct options_struct *opt)
-{
- icalcomponent *comp,*mimecomp;
- FILE* stream;
-
- if(opt->input_source == INPUT_FROM_FILE){
- stream = fopen(opt->input_file,"r");
-
- if (stream == 0){
- perror("Can't open input file");
- exit(1);
- }
-
- } else {
- stream = stdin;
- }
-
- assert(stream != 0);
-
- mimecomp = icalmime_parse(read_stream,(void*)stream);
-
- /* now find the iCal component embedded within the mime component */
- comp = find_vcalendar(mimecomp);
-
-
- if(comp == 0){
- return 0;
- }
-
- return comp;
-}
-
-icalcomponent* read_component(struct options_struct *opt)
-{
- if(opt->input_type == INPUT_IS_MIME){
- return read_mime_component(opt);
- } else if (opt->input_type == INPUT_IS_ICAL){
- return read_nonmime_component(opt);
- } else {
- fprintf(stderr,"%s: Internal Error; unknown option for input_type\n",
- program_name);
- exit(1);
- }
-}
-
-int main(int argc, char* argv[] )
-{
- char* options_error_str;
- char* component_error_str;
- icalcomponent* comp, *reply;
- struct options_struct opt;
- icalproperty *return_status;
-
- program_name = strrchr(argv[0],'/');
-
- get_options(argc, argv, &opt);
-
- if ( (options_error_str = check_options(&opt)) != 0 ){
- usage(options_error_str);
- exit(1);
- }
-
- comp = read_component(&opt);
-
- if ( (component_error_str =
- check_component(comp,&return_status,&opt)) != 0){
- reply = make_reply(comp,return_status,&opt);
- return_failure(reply, component_error_str, &opt);
- icalcomponent_free(reply);
- exit(0);
- }
-
- store_component(comp,&opt);
-
-
- /* Don't free the component comp, since it is now part of the
- store, and will be freed there */
-
- exit(0);
-}
-
diff --git a/libical/src/test/testclassify.c b/libical/src/test/testclassify.c
deleted file mode 100644
index 2c6c785dfa..0000000000
--- a/libical/src/test/testclassify.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- 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"
-
-
-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;
-}
-
-
diff --git a/libical/src/test/testmime.c b/libical/src/test/testmime.c
deleted file mode 100644
index 5dfc3b7d31..0000000000
--- a/libical/src/test/testmime.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE:
- CREATOR: eric 25 June 2000
-
- $Id$
- $Locker$
-
- 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.
-
-
- 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 Initial Developer of the Original Code is Eric Busboom
-
- (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
- ======================================================================*/
-
-#include "ical.h"
-#include "sspm.h"
-#include "icalmime.h"
-#include <stdlib.h> /* For rand */
-#include <string.h> /* for strrchr, strdup*/
-#include <unistd.h> /* for getopt */
-
-/*int sspm_parse_mime(struct sspm_part *parts,
- size_t max_parts,
- struct sspm_action_map *actions,
- char* (*get_string)(char *s, size_t size, void* data),
- void *get_string_data,
- struct sspm_header *first_header
- );
-*/
-
-
-
-char* major_type_string[] = {
- "TEXT",
- "IMAGE",
- "AUDIO",
- "VIDEO",
- "APPLICATION",
- "MULTIPART",
- "MESSAGE",
- "UNKNOWN",
- "NO"
-};
-
-char* minor_type_string[] = {
- "ANY",
- "PLAIN",
- "RFC822",
- "DIGEST",
- "CALENDAR",
- "MIXED",
- "RELATED",
- "ALTERNATIVE",
- "PARALLEL",
- "UNKNOWN",
- "NO"
-};
-
-
-char* read_stream(char *s, size_t size, void *d)
-{
- char *c = fgets(s,size, (FILE*)d);
-
- return c;
-
-}
-
-
-int main(int argc, char* argv[]) {
-
- FILE *f;
- int c;
- extern char *optarg;
- extern int optind, optopt;
- int errflg=0;
- char* program_name;
-
- struct options{
- int normal;
- int stress;
- int base64;
- int qp;
- int sleep;
- int count;
- char* input_file;
- } opt;
-
- memset(&opt,0,sizeof(opt));
-
- program_name = (char*)strrchr((char*)argv[0],'/');
- program_name++;
-
- while ((c = getopt(argc, argv, "nsbqi:S:c:")) != -1) {
- switch (c) {
- case 'i': { /* Input comes from named file */
- opt.input_file = strdup(optarg);
- break;
- }
- case 'n':{ /* Normal */
-
- if(opt.stress+opt.base64+opt.qp != 0){
- fprintf(stderr,
- "%s: Use only one of n,s,b and q\n",
- program_name);
- }
- opt.normal = 1;
- break;
- }
- case 's':{ /* Stress-test*/
- if(opt.base64+opt.normal+opt.qp != 0){
- fprintf(stderr,
- "%s: Use only one of n,s,b and q\n",
- program_name);
- }
- opt.stress = 1;
- break;
- }
- case 'b':{ /* test base64 decoding*/
- if(opt.stress+opt.normal+opt.qp != 0){
- fprintf(stderr,
- "%s: Use only one of n,s,b and q\n",
- program_name);
- }
- opt.base64 = 1;
- break;
- }
- case 'q':{ /* test quoted-printable decoding*/
- if(opt.stress+opt.base64+opt.normal != 0){
- fprintf(stderr,
- "%s: Use only one of n,s,b and q\n",
- program_name);
- }
- opt.qp = 1;
- break;
- }
- case 'S':{ /* sleep at end of run */
- opt.sleep = atoi(optarg);
- break;
- }
-
- case 'c':{ /* number of iterations of stress test */
- opt.count = atoi(optarg);
- break;
- }
-
- case ':': {/* Option given without an operand */
- fprintf(stderr,
- "%s: Option -%c requires an operand\n",
- program_name,optopt);
- errflg++;
- break;
- }
- case '?': {
- errflg++;
- }
- }
- }
-
- if (errflg >0){
- fprintf(stderr,"Usage: %s [-n|-s|-b|-q] [-i input_file]\n",
- program_name);
- exit(1);
- }
-
- if(opt.stress+opt.base64+opt.normal+opt.qp == 0){
- fprintf(stderr,
- "%s: Must have one of n,s,b or q\n",
- program_name);
- }
-
- if(opt.input_file){
- f = fopen(opt.input_file,"r");
- if (f == 0){
- fprintf(stderr,"Could not open input file \"%s\"\n",
- opt.input_file);
- exit(1);
- }
- } else {
- f = stdin;
- }
-
-
-
- if(opt.normal == 1){
- icalcomponent *c;
-
- c = icalmime_parse(read_stream,f);
-
- printf("%s\n",icalcomponent_as_ical_string(c));
-
- icalcomponent_free(c);
-
- } else if (opt.stress==1 ){
- /* Read file in by lines, then randomize the lines into a
- string buffer */
-
- char *array[1024];
- char temp[1024];
- char *buf;
- int i,last;
- int size;
- int non_rand;
- int rand_lines;
- int r;
- int j;
- icalcomponent *c;
- struct slg_data {
- char* pos;
- char* str;
- } d;
-
- for(i=0; !feof(f); i++){
- fgets(temp,1024,f);
- array[i] = strdup(temp);
- size += strlen(temp);
- }
- last = i;
-
- buf = malloc(size*2);
- assert(buf != 0);
-
-
- for(j=0; j<opt.count; j++){
-
- srand(j);
- memset(buf,0,size*2);
- /* First insert some non-randomized lines */
- non_rand = ((float)rand()/(float)RAND_MAX) * last;
- for(i=0;i<non_rand;i++){
- strcat(buf,array[i]);
- }
-
- /* Then, insert some lines at random */
-
- rand_lines = last - non_rand;
-
- for(i=0;i<rand_lines;i++){
- srand(i);
- r = ((float)rand()/(float)RAND_MAX) * rand_lines;
- strcat(buf,array[r+non_rand]);
-
- }
-
- d.pos = 0;
- d.str = buf;
-
- c = icalmime_parse(string_line_generator,&d);
-
- printf("%s\n",icalcomponent_as_ical_string(c));
-
- icalcomponent_free(c);
-
- }
-
- free(buf);
-
- for(i=0; i<last; i++){
- free(array[i]);
- }
-
- } else if(opt.qp == 1){
- char str[4096];
- char conv[4096];
-
- memset(str,0,4096);
-
- while(!feof(f) && fgets(str,4096,f)!=0){
- size_t size;
-
- size = strlen(str);
- memset(conv,0,4096);
- decode_quoted_printable(conv,str,&size);
-
- conv[size] = '\0';
- printf("%s",conv);
- memset(str,0,4096);
-
- }
- } else if (opt.base64 == 1) {
- char str[4096];
- char conv[4096];
-
- memset(str,0,4096);
-
- while(!feof(f) && fgets(str,4096,f)!=0){
- size_t size;
-
- size = strlen(str);
- memset(conv,0,4096);
- decode_base64(conv,str,&size);
-
- conv[size] = '\0';
- printf("%s",conv);
- memset(str,0,4096);
-
- }
- }
-
- if (opt.sleep != 0){
- sleep(opt.sleep);
- }
-
- if( opt.input_file != 0){
- free(opt.input_file);
- }
-
- icalmemory_free_ring();
-
- return 0;
-
-}
-
-
-
-
-
-
-
-
diff --git a/libical/src/test/testvcal.c b/libical/src/test/testvcal.c
deleted file mode 100644
index f82adffcc8..0000000000
--- a/libical/src/test/testvcal.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C -*-
- ======================================================================
- FILE: vcal.c
- CREATOR: eric 26 May 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 "icalvcal.h"
-#include <stdio.h>
-
-/* Given a vCal data file as its first argument, this program will
- print out an equivalent iCal component.
-
- For instance:
-
- ./testvcal ../../test-data/user-cal.vcf
-
-*/
-
-int main(int argc, char* argv[])
-{
- VObject *vcal = 0;
- icalcomponent *comp;
- char* file;
-
- if (argc != 2){
- file = "../../test-data/user-cal.vcf";
- } else {
- file = argv[1];
- }
-
-
- vcal = Parse_MIME_FromFileName(file);
-
- assert(vcal != 0);
-
- comp = icalvcal_convert(vcal);
-
- printf("%s\n",icalcomponent_as_ical_string(comp));
-
- return 0;
-}
-
-