summaryrefslogtreecommitdiffabout
path: root/libical
authorzautrix <zautrix>2004-06-29 11:59:46 (UTC)
committer zautrix <zautrix>2004-06-29 11:59:46 (UTC)
commitda43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff)
tree16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical
parent627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff)
downloadkdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz
kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/astime.h65
-rw-r--r--libical/src/libical/caldate.c176
-rw-r--r--libical/src/libical/ical.h2060
-rw-r--r--libical/src/libical/icalarray.c163
-rw-r--r--libical/src/libical/icalarray.h63
-rw-r--r--libical/src/libical/icalattach.c139
-rw-r--r--libical/src/libical/icalattach.h60
-rw-r--r--libical/src/libical/icalattachimpl.h59
-rw-r--r--libical/src/libical/icalcomponent.c1891
-rw-r--r--libical/src/libical/icalcomponent.h90
-rw-r--r--libical/src/libical/icalderivedparameter.c807
-rw-r--r--libical/src/libical/icalderivedparameter.h199
-rw-r--r--libical/src/libical/icalderivedproperty.c1062
-rw-r--r--libical/src/libical/icalderivedproperty.h214
-rw-r--r--libical/src/libical/icalderivedvalue.c892
-rw-r--r--libical/src/libical/icalderivedvalue.h249
-rw-r--r--libical/src/libical/icalduration.c89
-rw-r--r--libical/src/libical/icalduration.h4
-rw-r--r--libical/src/libical/icalenums.c39
-rw-r--r--libical/src/libical/icalenums.h10
-rw-r--r--libical/src/libical/icalerror.c54
-rw-r--r--libical/src/libical/icalerror.h23
-rw-r--r--libical/src/libical/icallangbind.c47
-rw-r--r--libical/src/libical/icallangbind.h5
-rw-r--r--libical/src/libical/icalmemory.c148
-rw-r--r--libical/src/libical/icalmemory.h19
-rw-r--r--libical/src/libical/icalmime.c6
-rw-r--r--libical/src/libical/icalparameter.c113
-rw-r--r--libical/src/libical/icalparameter.h2
-rw-r--r--libical/src/libical/icalparser.c365
-rw-r--r--libical/src/libical/icalparser.h29
-rw-r--r--libical/src/libical/icalperiod.c14
-rw-r--r--libical/src/libical/icalperiod.h6
-rw-r--r--libical/src/libical/icalproperty.c509
-rw-r--r--libical/src/libical/icalproperty.h42
-rw-r--r--libical/src/libical/icalrecur.c789
-rw-r--r--libical/src/libical/icalrecur.h71
-rw-r--r--libical/src/libical/icalrestriction.c116
-rw-r--r--libical/src/libical/icaltime.c1116
-rw-r--r--libical/src/libical/icaltime.h262
-rw-r--r--libical/src/libical/icaltimezone.c1672
-rw-r--r--libical/src/libical/icaltimezone.h167
-rw-r--r--libical/src/libical/icaltypes.c140
-rw-r--r--libical/src/libical/icaltypes.h35
-rw-r--r--libical/src/libical/icalvalue.c518
-rw-r--r--libical/src/libical/icalvalue.h27
-rw-r--r--libical/src/libical/icalvalueimpl.h6
-rw-r--r--libical/src/libical/icalversion.h2
-rw-r--r--libical/src/libical/libical.pro128
-rw-r--r--libical/src/libical/libicalE.pro122
-rw-r--r--libical/src/libical/pvl.c497
-rw-r--r--libical/src/libical/pvl.h37
-rw-r--r--libical/src/libical/sspm.c23
-rw-r--r--libical/src/libical/vsnprintf.c28
-rw-r--r--libical/src/libicalss/icalcalendar.c263
-rw-r--r--libical/src/libicalss/icalcalendar.h2
-rw-r--r--libical/src/libicalss/icalclassify.c132
-rw-r--r--libical/src/libicalss/icalclassify.h36
-rw-r--r--libical/src/libicalss/icalcluster.c245
-rw-r--r--libical/src/libicalss/icalcluster.h61
-rw-r--r--libical/src/libicalss/icalclusterimpl.h45
-rw-r--r--libical/src/libicalss/icaldirset.c542
-rw-r--r--libical/src/libicalss/icaldirset.h54
-rw-r--r--libical/src/libicalss/icaldirsetimpl.h19
-rw-r--r--libical/src/libicalss/icalfileset.c725
-rw-r--r--libical/src/libicalss/icalfileset.h105
-rw-r--r--libical/src/libicalss/icalfilesetimpl.h18
-rw-r--r--libical/src/libicalss/icalgauge.c172
-rw-r--r--libical/src/libicalss/icalgauge.h26
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h12
-rw-r--r--libical/src/libicalss/icalmessage.c11
-rw-r--r--libical/src/libicalss/icalset.c528
-rw-r--r--libical/src/libicalss/icalset.h121
-rw-r--r--libical/src/libicalss/icalspanlist.c386
-rw-r--r--libical/src/libicalss/icalspanlist.h29
-rw-r--r--libical/src/libicalss/icalss.h719
-rw-r--r--libical/src/libicalss/icalsslexer.c1624
-rw-r--r--libical/src/libicalss/icalssyacc.c270
-rw-r--r--libical/src/libicalss/icalssyacc.h12
-rw-r--r--libical/src/libicalss/libicalss.pro70
-rw-r--r--libical/src/libicalss/libicalssE.pro78
81 files changed, 14935 insertions, 6839 deletions
diff --git a/libical/src/libical/astime.h b/libical/src/libical/astime.h
new file mode 100644
index 0000000..6962c06
--- a/dev/null
+++ b/libical/src/libical/astime.h
@@ -0,0 +1,65 @@
1/*
2 *Copyright (c) 1986-2000, Hiram Clawson
3 *All rights reserved.
4 *
5 *Redistribution and use in source and binary forms, with or
6 *without modification, are permitted provided that the following
7 *conditions are met:
8 *
9 * Redistributions of source code must retain the above
10 * copyright notice, this list of conditions and the
11 * following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions and
15 * the following disclaimer in the documentation and/or
16 * other materials provided with the distribution.
17 *
18 * Neither name of The Museum of Hiram nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior
21 * written permission.
22 *
23 *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 *CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 *INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 *IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 *INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 *(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 *HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 *STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 *IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 *THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/**
38 *@file astime.h
39 * @brief contains definitions of structures used for time calculations.
40 */
41
42 #ifndef_astime_h_
43#define _astime_h_
44
45typedef struct ut_instant {
46 doublej_date; /**< julian decimal date, 0 = 01 Jan 4713 BC 12 HR UT */
47 long year; /**< year, valid range [-4,713, +2,147,483,647] */
48 int month; /**< [1-12]*/
49 int day; /**< [1-31]*/
50 int i_hour; /**< [0-23]*/
51 int i_minute; /**< [0-59]*/
52 int i_second; /**< [0-59]*/
53 double d_hour; /**< [0.0-23.9999] includes minute and second */
54 double d_minute; /**< [0.0-59.9999] includes second*/
55 double d_second; /**< [0.0-59.9999]*/
56 int weekday; /**< [0-6]*/
57 int day_of_year; /**< [1-366]*/
58} UTinstant, * UTinstantPtr;
59
60 /* Functions in caldate.c*/
61
62 long caldat( UTinstantPtr );/** converts julian date to year,mo,da */
63 double juldat( UTinstantPtr );/** returns julian day from year,mo,da */
64
65 #endif /* _astime_h_*/
diff --git a/libical/src/libical/caldate.c b/libical/src/libical/caldate.c
new file mode 100644
index 0000000..f5554f6
--- a/dev/null
+++ b/libical/src/libical/caldate.c
@@ -0,0 +1,176 @@
1/*
2 *Copyright (c) 1986-2000, Hiram Clawson
3 *All rights reserved.
4 *
5 *Redistribution and use in source and binary forms, with or
6 *without modification, are permitted provided that the following
7 *conditions are met:
8 *
9 * Redistributions of source code must retain the above
10 * copyright notice, this list of conditions and the
11 * following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions and
15 * the following disclaimer in the documentation and/or
16 * other materials provided with the distribution.
17 *
18 * Neither name of The Museum of Hiram nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior
21 * written permission.
22 *
23 *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 *CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 *INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 *IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 *INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 *(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 *HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 *STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 *IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 *THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include "astime.h" /* time structures*/
38
39/**
40 *caldat computes the day of the week, the day of the year
41 *the gregorian (or julian) calendar date and the universal
42 *time from the julian decimal date.
43 *for astronomical purposes, The Gregorian calendar reform occurred
44 *on 15 Oct. 1582. This is 05 Oct 1582 by the julian calendar.
45
46 * Input:a ut_instant structure pointer, where the j_date element
47 * has been set. ( = 0 for 01 Jan 4713 B.C. 12 HR UT )
48 *
49 *output: will set all the other elements of the structure.
50 * As a convienence, the function will also return the year.
51 *
52 *Reference: Astronomial formulae for calculators, meeus, p 23
53 *from fortran program by F. Espenak - April 1982 Page 277,
54 *50 Year canon of solar eclipses: 1986-2035
55 *
56 */
57
58long caldat( date )
59struct ut_instant * date;
60{
61 double frac;
62 long jd;
63 long ka;
64 long kb;
65 long kc;
66 long kd;
67 long ke;
68 long ialp;
69
70 jd = (long) (date->j_date + 0.5);/* integer julian date */
71 frac = date->j_date + 0.5 - (double) jd + 1.0e-10; /* day fraction */
72 ka = (long) jd;
73 if ( jd >= 2299161L )
74 {
75 ialp = ( (double) jd - 1867216.25 ) / ( 36524.25 );
76 ka = jd + 1L + ialp - ( ialp >> 2 );
77 }
78 kb = ka + 1524L;
79 kc = ( (double) kb - 122.1 ) / 365.25;
80 kd = (double) kc * 365.25;
81 ke = (double) ( kb - kd ) / 30.6001;
82 date->day = kb - kd - ((long) ( (double) ke * 30.6001 ));
83 if ( ke > 13L )
84 date->month = ke - 13L;
85 else
86 date->month = ke - 1L;
87 if ( (date->month == 2) && (date->day > 28) )
88 date->day = 29;
89 if ( (date->month == 2) && (date->day == 29) && (ke == 3L) )
90 date->year = kc - 4716L;
91 else if ( date->month > 2 )
92 date->year = kc - 4716L;
93 else
94 date->year = kc - 4715L;
95 date->i_hour = date->d_hour = frac * 24.0;/* hour */
96 date->i_minute = date->d_minute =
97 ( date->d_hour - (double) date->i_hour ) * 60.0; /* minute */
98 date->i_second = date->d_second =
99 ( date->d_minute - (double) date->i_minute ) * 60.0;/* second */
100 date->weekday = (jd + 1L) % 7L;/* day of week */
101 if ( date->year == ((date->year >> 2) << 2) )
102 date->day_of_year =
103 ( ( 275 * date->month ) / 9)
104 - ((date->month + 9) / 12)
105 + date->day - 30;
106 else
107 date->day_of_year =
108 ( ( 275 * date->month ) / 9)
109 - (((date->month + 9) / 12) << 1)
110 + date->day - 30;
111 return( date->year );
112}
113
114/**
115 *juldat computes the julian decimal date (j_date) from
116 *the gregorian (or Julian) calendar date.
117 *for astronomical purposes, The Gregorian calendar reform occurred
118 *on 15 Oct. 1582. This is 05 Oct 1582 by the julian calendar.
119 *Input: a ut_instant structure pointer where Day, Month, Year and
120 * i_hour, i_minute, d_second have been set for the date
121 * in question.
122 *
123 *Output: the j_date and weekday elements of the structure will be set.
124 * Also, the return value of the function will be the j_date too.
125 *
126 *Reference: Astronomial formulae for calculators, meeus, p 23
127 *from fortran program by F. Espenak - April 1982 Page 276,
128 *50 Year canon of solar eclipses: 1986-2035
129 */
130
131double juldat( date )
132struct ut_instant * date;
133{
134 double frac, gyr;
135 long iy0, im0;
136 long ia, ib;
137 long jd;
138
139 /* decimal day fraction*/
140 frac = (( double)date->i_hour/ 24.0)
141 + ((double) date->i_minute / 1440.0)
142 + (date->d_second / 86400.0);
143 /* convert date to format YYYY.MMDDdd*/
144 gyr = (double) date->year
145 + (0.01 * (double) date->month)
146 + (0.0001 * (double) date->day)
147 + (0.0001 * frac) + 1.0e-9;
148 /* conversion factors */
149 if ( date->month <= 2 )
150 {
151 iy0 = date->year - 1L;
152 im0 = date->month + 12;
153 }
154 else
155 {
156 iy0 = date->year;
157 im0 = date->month;
158 }
159 ia = iy0 / 100L;
160 ib = 2L - ia + (ia >> 2);
161 /* calculate julian date*/
162 if ( date->year < 0L )
163 jd = (long) ((365.25 * (double) iy0) - 0.75)
164 + (long) (30.6001 * (im0 + 1L) )
165 + (long) date->day + 1720994L;
166 else
167 jd = (long) (365.25 * (double) iy0)
168 + (long) (30.6001 * (double) (im0 + 1L))
169 + (long) date->day + 1720994L;
170 if ( gyr >= 1582.1015 ) /* on or after 15 October 1582*/
171 jd += ib;
172 date->j_date = (double) jd + frac + 0.5;
173 jd = (long) (date->j_date + 0.5);
174 date->weekday = (jd + 1L) % 7L;
175 return( date->j_date );
176 } /* end of double juldat( date )*/
diff --git a/libical/src/libical/ical.h b/libical/src/libical/ical.h
index 69a2c3a..0ae2c15 100644
--- a/libical/src/libical/ical.h
+++ b/libical/src/libical/ical.h
@@ -1 +1,122 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4/*
5 $Id$
6*/
7/* config.h. Generated by configure. */
8/* config.h.in. Generated from configure.in by autoheader. */
9
10/* Define to 1 if you have the <assert.h> header file. */
11#define HAVE_ASSERT_H 1
12
13/* Define to 1 if you have the `gmtime_r' function. */
14#define HAVE_GMTIME_R 1
15
16/* Define to 1 if you have the <inttypes.h> header file. */
17#define HAVE_INTTYPES_H 1
18
19/* Define to 1 if you have the `iswspace' function. */
20#define HAVE_ISWSPACE 1
21
22/* Define to 1 if you have the <memory.h> header file. */
23#define HAVE_MEMORY_H 1
24
25/* Define if we have pthread. */
26#define HAVE_PTHREAD
27
28/* Define to 1 if you have the <pthread.h> header file. */
29#define HAVE_PTHREAD_H 1
30
31/* Define to 1 if you have the `snprintf' function. */
32#define HAVE_SNPRINTF 1
33
34/* Define to 1 if you have the <stdint.h> header file. */
35#define HAVE_STDINT_H 1
36
37/* Define to 1 if you have the <stdlib.h> header file. */
38#define HAVE_STDLIB_H 1
39
40/* Define to 1 if you have the `strdup' function. */
41#define HAVE_STRDUP 1
42
43/* Define to 1 if you have the <strings.h> header file. */
44#define HAVE_STRINGS_H 1
45
46/* Define to 1 if you have the <string.h> header file. */
47#define HAVE_STRING_H 1
48
49/* Define to 1 if you have the <sys/stat.h> header file. */
50#define HAVE_SYS_STAT_H 1
51
52/* Define to 1 if you have the <sys/types.h> header file. */
53#define HAVE_SYS_TYPES_H 1
54
55/* Define to 1 if you have the <time.h> header file. */
56#define HAVE_TIME_H 1
57
58/* Define to 1 if you have the <unistd.h> header file. */
59#define HAVE_UNISTD_H 1
60
61/* Define to 1 if you have the <wctype.h> header file. */
62#define HAVE_WCTYPE_H 1
63
64/* Define to make icalerror_* calls abort instead of internally signalling an
65 error */
66#define ICAL_ERRORS_ARE_FATAL 1
67
68/* Define if we want _REENTRANT */
69/* #undef ICAL_REENTRANT */
70
71/* Define to terminate lines with "
72" instead of "
73" */
74#define ICAL_UNIX_NEWLINE 1
75
76/* Define to 1 if you DO NOT WANT to see deprecated messages */
77#define NO_WARN_DEPRECATED 1
78
79/* Define to 1 if you DO NO WANT to see the warning messages related to
80 ICAL_MALFORMEDDATA_ERROR and parsing .ics zoneinfo files */
81#define NO_WARN_ICAL_MALFORMEDDATA_ERROR_HACK 1
82
83/* Name of package */
84#define PACKAGE "libical"
85
86/* Define to the address where bug reports for this package should be sent. */
87#define PACKAGE_BUGREPORT ""
88
89/* Define to the full name of this package. */
90#define PACKAGE_NAME ""
91
92/* Define to the full name and version of this package. */
93#define PACKAGE_STRING ""
94
95/* Define to the one symbol short name of this package. */
96#define PACKAGE_TARNAME ""
97
98/* Define to the version of this package. */
99#define PACKAGE_VERSION ""
100
101/* Define to 1 if you have the ANSI C header files. */
102#define STDC_HEADERS 1
103
104/* Define to 1 if your <sys/time.h> declares `struct tm'. */
105/* #undef TM_IN_SYS_TIME */
106
107/* Version number of package */
108#define VERSION "0.24"
109
110/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
111 `char[]'. */
112#define YYTEXT_POINTER 1
113
114/* Define to empty if `const' does not conform to ANSI C. */
115/* #undef const */
116
117/* Define to `int' if <sys/types.h> does not define. */
118/* #undef mode_t */
119
120/* Define to `unsigned' if <sys/types.h> does not define. */
121/* #undef size_t */
1#ifndef ICAL_VERSION_H 122#ifndef ICAL_VERSION_H
@@ -4,3 +125,3 @@
4#define ICAL_PACKAGE "libical" 125#define ICAL_PACKAGE "libical"
5#define ICAL_VERSION "0.23" 126#define ICAL_VERSION "0.24"
6 127
@@ -13,4 +134,2 @@
13 134
14 $Id$
15 $Locker$
16 135
@@ -35,2 +154,66 @@
35 154
155 /**@file icaltime.h
156 *@brief struct icaltimetype is a pseudo-object that abstracts time
157 *handling.
158 *
159 *It can represent either a DATE or a DATE-TIME (floating, UTC or in a
160 *given timezone), and it keeps track internally of its native timezone.
161 *
162 *The typical usage is to call the correct constructor specifying the
163 *desired timezone. If this is not known until a later time, the
164 *correct behavior is to specify a NULL timezone and call
165 *icaltime_convert_to_zone() at a later time.
166 *
167 *There are several ways to create a new icaltimetype:
168 *
169 *- icaltime_null_time()
170 *- icaltime_null_date()
171 *- icaltime_current_time_with_zone()
172 *- icaltime_today()
173 *- icaltime_from_timet_with_zone(time_t tm, int is_date,
174 * icaltimezone *zone)
175 * - icaltime_from_string_with_zone(const char* str, icaltimezone *zone)
176 *- icaltime_from_day_of_year(int doy, int year)
177 *- icaltime_from_week_number(int week_number, int year)
178 *
179 *italtimetype objects can be converted to different formats:
180 *
181 *- icaltime_as_timet(struct icaltimetype tt)
182 *- icaltime_as_timet_with_zone(struct icaltimetype tt,
183 * icaltimezone *zone)
184 *- icaltime_as_ical_string(struct icaltimetype tt)
185 *
186 *Accessor methods include:
187 *
188 *- icaltime_get_timezone(struct icaltimetype t)
189 *- icaltime_get_tzid(struct icaltimetype t)
190 *- icaltime_set_timezone(struct icaltimetype t, const icaltimezone *zone)
191 *- icaltime_day_of_year(struct icaltimetype t)
192 *- icaltime_day_of_week(struct icaltimetype t)
193 *- icaltime_start_doy_of_week(struct icaltimetype t)
194 *- icaltime_week_number(struct icaltimetype t)
195 *
196 *Query methods include:
197 *
198 *- icaltime_is_null_time(struct icaltimetype t)
199 *- icaltime_is_valid_time(struct icaltimetype t)
200 *- icaltime_is_date(struct icaltimetype t)
201 *- icaltime_is_utc(struct icaltimetype t)
202 *- icaltime_is_floating(struct icaltimetype t)
203 *
204 *Modify, compare and utility methods include:
205 *
206 *- icaltime_add(struct icaltimetype t, struct icaldurationtype d)
207 *- icaltime_subtract(struct icaltimetype t1, struct icaltimetype t2)
208 * - icaltime_compare_with_zone(struct icaltimetype a,struct icaltimetype b)
209 *- icaltime_compare(struct icaltimetype a,struct icaltimetype b)
210 *- icaltime_compare_date_only(struct icaltimetype a,
211 * struct icaltimetype b)
212 *- icaltime_adjust(struct icaltimetype *tt, int days, int hours,
213 * int minutes, int seconds);
214 *- icaltime_normalize(struct icaltimetype t);
215 *- icaltime_convert_to_zone(const struct icaltimetype tt,
216 * icaltimezone *zone);
217 */
218
36#ifndef ICALTIME_H 219#ifndef ICALTIME_H
@@ -40,14 +223,28 @@
40 223
41/* icaltime_span is returned by icalcomponent_get_span() */ 224/* An opaque struct representing a timezone. We declare this here to avoid
225 a circular dependancy. */
226#ifndef ICALTIMEZONE_DEFINED
227#define ICALTIMEZONE_DEFINED
228 typedef struct _icaltimezone icaltimezone;
229#endif
230
231/** icaltime_span is returned by icalcomponent_get_span() */
42struct icaltime_span { 232struct icaltime_span {
43 time_t start; /* in UTC */ 233 time_t start; /**< in UTC */
44 time_t end; /* in UTC */ 234 time_t end; /**< in UTC */
45 int is_busy; /* 1->busy time, 0-> free time */ 235 int is_busy; /**< 1->busy time, 0-> free time */
46}; 236};
47 237
238typedef struct icaltime_span icaltime_span;
48 239
240/*
241 *FIXME
242 *
243 *is_utc is redundant, and might be considered a minor optimization.
244 *It might be deprecated, so you should use icaltime_is_utc() instead.
245 */
49struct icaltimetype 246struct icaltimetype
50{ 247{
51 int year; 248 int year;/**< Actual year, e.g. 2001. */
52 int month; 249 int month;/**< 1 (Jan) to 12 (Dec). */
53 int day; 250 int day;
@@ -57,95 +254,145 @@ struct icaltimetype
57 254
58 int is_utc; /* 1-> time is in UTC timezone */ 255 int is_utc; /**< 1-> time is in UTC timezone */
59 256
60 int is_date; /* 1 -> interpret this as date. */ 257 int is_date; /**< 1 -> interpret this as date. */
61 258
62 const char* zone; /*Ptr to Olsen placename. Libical does not own mem*/ 259 int is_daylight; /**< 1 -> time is in daylight savings time. */
260
261 const icaltimezone *zone;/**< timezone */
63 }; 262 };
64 263
65/* Convert seconds past UNIX epoch to a timetype*/ 264typedef struct icaltimetype icaltimetype;
66struct icaltimetype icaltime_from_timet(time_t v, int is_date);
67 265
68/* Return the time as seconds past the UNIX epoch */ 266/** Return a null time, which indicates no time has been set.
69time_t icaltime_as_timet(struct icaltimetype); 267 This time represent the beginning of the epoch */
268struct icaltimetype icaltime_null_time(void);
70 269
71/* Return a string represention of the time, in RFC2445 format. The 270/** Return a null date */
72 string is owned by libical */ 271struct icaltimetype icaltime_null_date(void);
73char* icaltime_as_ical_string(struct icaltimetype tt);
74 272
75/* Like icaltime_from_timet(), except that the input may be in seconds 273/** Returns the current time in the given timezone, as an icaltimetype. */
76 past the epoch in floating time. This routine is deprecated */ 274struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone);
77struct icaltimetype icaltime_from_int(int v, int is_date, int is_utc);
78 275
79/* Like icaltime_as_timet, but in a floating epoch. This routine is deprecated */ 276/** Returns the current day as an icaltimetype, with is_date set. */
80int icaltime_as_int(struct icaltimetype); 277struct icaltimetype icaltime_today(void);
81 278
82/* create a time from an ISO format string */ 279/** Convert seconds past UNIX epoch to a timetype*/
280struct icaltimetype icaltime_from_timet(const time_t v, const int is_date);
281
282/** Convert seconds past UNIX epoch to a timetype, using timezones. */
283struct icaltimetype icaltime_from_timet_with_zone(const time_t tm,
284 const int is_date, const icaltimezone *zone);
285
286/** create a time from an ISO format string */
83struct icaltimetype icaltime_from_string(const char* str); 287struct icaltimetype icaltime_from_string(const char* str);
84 288
85/* Routines for handling timezones */ 289/** create a time from an ISO format string */
86/* Return the offset of the named zone as seconds. tt is a time 290struct icaltimetype icaltime_from_string_with_zone(const char* str,
87 indicating the date for which you want the offset */ 291 const icaltimezone *zone);
88int icaltime_utc_offset(struct icaltimetype tt, const char* tzid);
89 292
90/* convert tt, of timezone tzid, into a utc time. Does nothing if the 293/** Create a new time, given a day of year and a year. */
91 time is already UTC. */ 294struct icaltimetype icaltime_from_day_of_year(const int doy,
92struct icaltimetype icaltime_as_utc(struct icaltimetype tt, 295 const int year);
93 const char* tzid);
94 296
95/* convert tt, a time in UTC, into a time in timezone tzid */ 297 /**@brief Contructor (TODO).
96struct icaltimetype icaltime_as_zone(struct icaltimetype tt, 298 * Create a new time from a weeknumber and a year. */
97 const char* tzid); 299struct icaltimetype icaltime_from_week_number(const int week_number,
300 const int year);
98 301
99/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */ 302/** Return the time as seconds past the UNIX epoch */
100struct icaltimetype icaltime_null_time(void); 303time_t icaltime_as_timet(const struct icaltimetype);
304
305/** Return the time as seconds past the UNIX epoch, using timezones. */
306time_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
307 const icaltimezone *zone);
308
309/** Return a string represention of the time, in RFC2445 format. The
310 string is owned by libical */
311const char* icaltime_as_ical_string(const struct icaltimetype tt);
312
313/** @brief Return the timezone */
314const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
315
316/** @brief Return the tzid, or NULL for a floating time */
317char *icaltime_get_tzid(const struct icaltimetype t);
318
319/** @brief Set the timezone */
320struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
321 const icaltimezone *zone);
101 322
102/* Return true of the time is null. */ 323/** Return the day of the year of the given time */
103int icaltime_is_null_time(struct icaltimetype t); 324int icaltime_day_of_year(const struct icaltimetype t);
104 325
105/* Returns false if the time is clearly invalid, but is not null. This 326/** Return the day of the week of the given time. Sunday is 1 */
327int icaltime_day_of_week(const struct icaltimetype t);
328
329/** Return the day of the year for the Sunday of the week that the
330 given time is within. */
331int icaltime_start_doy_of_week(const struct icaltimetype t);
332
333/** Return the week number for the week the given time is within */
334int icaltime_week_number(const struct icaltimetype t);
335
336/** Return true of the time is null. */
337int icaltime_is_null_time(const struct icaltimetype t);
338
339/** Returns false if the time is clearly invalid, but is not null. This
106 is usually the result of creating a new time type buy not clearing 340 is usually the result of creating a new time type buy not clearing
107 it, or setting one of the flags to an illegal value. */ 341 it, or setting one of the flags to an illegal value. */
108int icaltime_is_valid_time(struct icaltimetype t); 342int icaltime_is_valid_time(const struct icaltimetype t);
109 343
110/* Reset all of the time components to be in their normal ranges. For 344/** @brief Returns true if time is of DATE type, false if DATE-TIME */
111 instance, given a time with minutes=70, the minutes will be reduces 345int icaltime_is_date(const struct icaltimetype t);
112 to 10, and the hour incremented. This allows the caller to do
113 arithmetic on times without worrying about overflow or
114 underflow. */
115struct icaltimetype icaltime_normalize(struct icaltimetype t);
116 346
117/* Return the day of the year of the given time */ 347/** @brief Returns true if time is relative to UTC zone */
118short icaltime_day_of_year(struct icaltimetype t); 348int icaltime_is_utc(const struct icaltimetype t);
119 349
120/* Create a new time, given a day of year and a year. */ 350/** @brief Returns true if time is a floating time */
121struct icaltimetype icaltime_from_day_of_year(short doy, short year); 351int icaltime_is_floating(const struct icaltimetype t);
122 352
123/* Return the day of the week of the given time. Sunday is 1 */ 353/** Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
124short icaltime_day_of_week(struct icaltimetype t); 354int icaltime_compare_with_zone(const struct icaltimetype a,
355 const struct icaltimetype b);
125 356
126/* Return the day of the year for the Sunday of the week that the 357/** Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
127 given time is within. */ 358int icaltime_compare(const struct icaltimetype a,
128short icaltime_start_doy_of_week(struct icaltimetype t); 359 const struct icaltimetype b);
129 360
130/* Return a string with the time represented in the same format as ctime(). THe string is owned by libical */ 361/** like icaltime_compare, but only use the date parts. */
131char* icaltime_as_ctime(struct icaltimetype); 362int icaltime_compare_date_only(const struct icaltimetype a,
363 const struct icaltimetype b);
132 364
133/* Return the week number for the week the given time is within */ 365/** Adds or subtracts a number of days, hours, minutes and seconds. */
134short icaltime_week_number(struct icaltimetype t); 366void icaltime_adjust(struct icaltimetype *tt, const int days,
367 const int hours, const int minutes, const int seconds);
135 368
136/* Create a new time from a weeknumber and a year. */ 369/** Normalize the icaltime, so that all fields are within the normal range. */
137struct icaltimetype icaltime_from_week_number(short week_number, short year); 370struct icaltimetype icaltime_normalize(const struct icaltimetype t);
138 371
139/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */ 372/** convert tt, of timezone tzid, into a utc time. Does nothing if the
140int icaltime_compare(struct icaltimetype a,struct icaltimetype b); 373 time is already UTC. */
374struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
375 icaltimezone *zone);
141 376
142/* like icaltime_compare, but only use the date parts. */ 377/** Return the number of days in the given month */
143int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b); 378int icaltime_days_in_month(const int month, const int year);
144 379
145/* Return the number of days in the given month */
146short icaltime_days_in_month(short month,short year);
147 380
381/** @brief calculate an icaltimespan given a start and end time. */
382struct icaltime_span icaltime_span_new(struct icaltimetype dtstart,
383 struct icaltimetype dtend,
384 int is_busy);
148 385
149#endif /* !ICALTIME_H */ 386/** @brief Returns true if the two spans overlap **/
387int icaltime_span_overlaps(icaltime_span *s1,
388 icaltime_span *s2);
150 389
390/** @brief Returns true if the span is totally within the containing
391 * span
392 */
393int icaltime_span_contains(icaltime_span *s,
394 icaltime_span *container);
395
396
397#endif /* !ICALTIME_H */
151 398
@@ -158,4 +405,2 @@ short icaltime_days_in_month(short month,short year);
158 405
159 $Id$
160 $Locker$
161 406
@@ -198,4 +443,6 @@ int icaldurationtype_as_int(struct icaldurationtype duration);
198char* icaldurationtype_as_ical_string(struct icaldurationtype d); 443char* icaldurationtype_as_ical_string(struct icaldurationtype d);
199struct icaldurationtype icaldurationtype_null_duration(); 444struct icaldurationtype icaldurationtype_null_duration(void);
445struct icaldurationtype icaldurationtype_bad_duration(void);
200int icaldurationtype_is_null_duration(struct icaldurationtype d); 446int icaldurationtype_is_null_duration(struct icaldurationtype d);
447int icaldurationtype_is_bad_duration(struct icaldurationtype d);
201 448
@@ -217,4 +464,2 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
217 464
218 $Id$
219 $Locker$
220 465
@@ -253,8 +498,8 @@ struct icalperiodtype icalperiodtype_from_string (const char* str);
253const char* icalperiodtype_as_ical_string(struct icalperiodtype p); 498const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
254struct icalperiodtype icalperiodtype_null_period();
255int icalperiodtype_is_null_period(struct icalperiodtype p);
256int icalperiodtype_is_valid_period(struct icalperiodtype p);
257 499
500struct icalperiodtype icalperiodtype_null_period(void);
258 501
502int icalperiodtype_is_null_period(struct icalperiodtype p);
259 503
504int icalperiodtype_is_valid_period(struct icalperiodtype p);
260 505
@@ -309,2 +554,3 @@ typedef enum icalcomponent_kind {
309 ICAL_VCALENDAR_COMPONENT, 554 ICAL_VCALENDAR_COMPONENT,
555 ICAL_VAGENDA_COMPONENT,
310 ICAL_VFREEBUSY_COMPONENT, 556 ICAL_VFREEBUSY_COMPONENT,
@@ -364,3 +610,7 @@ typedef enum icalrequeststatus {
364 ICAL_3_14_NOCAP_STATUS, 610 ICAL_3_14_NOCAP_STATUS,
611 ICAL_3_15_INVCOMMAND,
365 ICAL_4_0_BUSY_STATUS, 612 ICAL_4_0_BUSY_STATUS,
613 ICAL_4_1_STORE_ACCESS_DENIED,
614 ICAL_4_2_STORE_FAILED,
615 ICAL_4_3_STORE_NOT_FOUND,
366 ICAL_5_0_MAYBE_STATUS, 616 ICAL_5_0_MAYBE_STATUS,
@@ -368,3 +618,5 @@ typedef enum icalrequeststatus {
368 ICAL_5_2_NOSERVICE_STATUS, 618 ICAL_5_2_NOSERVICE_STATUS,
369 ICAL_5_3_NOSCHED_STATUS 619 ICAL_5_3_NOSCHED_STATUS,
620 ICAL_6_1_CONTAINER_NOT_FOUND,
621 ICAL_9_0_UNRECOGNIZED_COMMAND
370} icalrequeststatus; 622} icalrequeststatus;
@@ -376,2 +628,3 @@ short icalenum_reqstat_minor(icalrequeststatus stat);
376icalrequeststatus icalenum_num_to_reqstat(short major, short minor); 628icalrequeststatus icalenum_num_to_reqstat(short major, short minor);
629char* icalenum_reqstat_code(icalrequeststatus stat);
377 630
@@ -450,35 +703,2 @@ icalrequeststatus icalenum_num_to_reqstat(short major, short minor);
450 703
451/* This type type should probably be an opaque type... */
452struct icalattachtype
453{
454 void* binary;
455 int owns_binary;
456
457 char* base64;
458 int owns_base64;
459
460 char* url;
461
462 int refcount;
463
464};
465
466/* converts base64 to binary, fetches url and stores as binary, or
467 just returns data */
468
469struct icalattachtype* icalattachtype_new(void);
470void icalattachtype_add_reference(struct icalattachtype* v);
471void icalattachtype_free(struct icalattachtype* v);
472
473void icalattachtype_set_url(struct icalattachtype* v, char* url);
474char* icalattachtype_get_url(struct icalattachtype* v);
475
476void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
477 int owns);
478char* icalattachtype_get_base64(struct icalattachtype* v);
479
480void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
481 int owns);
482void* icalattachtype_get_binary(struct icalattachtype* v);
483
484struct icalgeotype 704struct icalgeotype
@@ -503,2 +723,3 @@ struct icaltriggertype
503 723
724struct icaltriggertype icaltriggertype_from_int(const int reltime);
504struct icaltriggertype icaltriggertype_from_string(const char* str); 725struct icaltriggertype icaltriggertype_from_string(const char* str);
@@ -506,2 +727,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str);
506int icaltriggertype_is_null_trigger(struct icaltriggertype tr); 727int icaltriggertype_is_null_trigger(struct icaltriggertype tr);
728int icaltriggertype_is_bad_trigger(struct icaltriggertype tr);
507 729
@@ -573,2 +795,7 @@ void icaltimezonetype_free(struct icaltimezonetype tzt);
573 the License at http://www.mozilla.org/MPL/ 795 the License at http://www.mozilla.org/MPL/
796*/
797
798/**
799@file icalrecur.h
800@brief Routines for dealing with recurring time
574 801
@@ -577,2 +804,4 @@ How to use:
5771) Get a rule and a start time from a component 8041) Get a rule and a start time from a component
805
806@code
578 icalproperty rrule; 807 icalproperty rrule;
@@ -584,12 +813,21 @@ How to use:
584 start = icalproperty_get_dtstart(dtstart); 813 start = icalproperty_get_dtstart(dtstart);
814@endcode
585 815
586Or, just make them up: 816Or, just make them up:
817
818@code
587 recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); 819 recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE");
588 dtstart = icaltime_from_string("19970101T123000") 820 dtstart = icaltime_from_string("19970101T123000")
821@endcode
589 822
5902) Create an iterator 8232) Create an iterator
824
825@code
591 icalrecur_iterator* ritr; 826 icalrecur_iterator* ritr;
592 ritr = icalrecur_iterator_new(recur,start); 827 ritr = icalrecur_iterator_new(recur,start);
828@endcode
593 829
5943) Iterator over the occurrences 8303) Iterator over the occurrences
831
832@code
595 struct icaltimetype next; 833 struct icaltimetype next;
@@ -599,2 +837,3 @@ Or, just make them up:
599 } 837 }
838@endcode
600 839
@@ -603,3 +842,3 @@ whatever timezone that dtstart is in.
603 842
604======================================================================*/ 843*/
605 844
@@ -610,5 +849,5 @@ whatever timezone that dtstart is in.
610 849
611/*********************************************************************** 850/*
612 * Recurrance enumerations 851 * Recurrance enumerations
613**********************************************************************/ 852 */
614 853
@@ -649,3 +888,5 @@ enum {
649 888
650/********************** Recurrence type routines **************/ 889/**
890 * Recurrence type routines
891 */
651 892
@@ -664,3 +905,3 @@ enum {
664 905
665/* Main struct for holding digested recurrence rules */ 906/** Main struct for holding digested recurrence rules */
666struct icalrecurrencetype 907struct icalrecurrencetype
@@ -701,19 +942,21 @@ void icalrecurrencetype_clear(struct icalrecurrencetype *r);
701 942
702/* The 'day' element of the by_day array is encoded to allow 943/**
703representation of both the day of the week ( Monday, Tueday), but also 944 * Array Encoding
704the Nth day of the week ( First tuesday of the month, last thursday of 945 *
705the year) These routines decode the day values */ 946 * The 'day' element of the by_day array is encoded to allow
947 * representation of both the day of the week ( Monday, Tueday), but also
948 * the Nth day of the week ( First tuesday of the month, last thursday of
949 * the year) These routines decode the day values
950 */
706 951
707/* 1 == Monday, etc. */ 952/** 1 == Monday, etc. */
708enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); 953enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
709 954
710/* 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ 955/** 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */
711short icalrecurrencetype_day_position(short day); 956int icalrecurrencetype_day_position(short day);
712 957
713 958
714/*********************************************************************** 959/** Recurrance rule parser */
715 * Recurrance rule parser
716**********************************************************************/
717 960
718/* Convert between strings ans recurrencetype structures. */ 961/** Convert between strings and recurrencetype structures. */
719struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); 962struct icalrecurrencetype icalrecurrencetype_from_string(const char* str);
@@ -722,7 +965,7 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
722 965
723/********** recurrence iteration routines ********************/ 966/** Recurrence iteration routines */
724 967
725typedef void icalrecur_iterator; 968typedef struct icalrecur_iterator_impl icalrecur_iterator;
726 969
727/* Create a new recurrence rule iterator */ 970/** Create a new recurrence rule iterator */
728icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, 971icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
@@ -730,10 +973,14 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
730 973
731/* Get the next occurrence from an iterator */ 974/** Get the next occurrence from an iterator */
732struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); 975struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*);
733 976
734/* Free the iterator */ 977void icalrecur_iterator_decrement_count(icalrecur_iterator*);
978
979/** Free the iterator */
735void icalrecur_iterator_free(icalrecur_iterator*); 980void icalrecur_iterator_free(icalrecur_iterator*);
736 981
737/* Fills array up with at most 'count' time_t values, each 982/**
738 representing an occurrence time in seconds past the POSIX epoch */ 983 * Fills array up with at most 'count' time_t values, each
984 * representing an occurrence time in seconds past the POSIX epoch
985 */
739int icalrecur_expand_recurrence(char* rule, time_t start, 986int icalrecur_expand_recurrence(char* rule, time_t start,
@@ -745,2 +992,62 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
745/*====================================================================== 992/*======================================================================
993 FILE: icalattach.h
994 CREATOR: acampi 28 May 02
995
996
997 (C) COPYRIGHT 2002, Andrea Campi
998
999 This program is free software; you can redistribute it and/or modify
1000 it under the terms of either:
1001
1002 The LGPL as published by the Free Software Foundation, version
1003 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1004
1005 Or:
1006
1007 The Mozilla Public License Version 1.0. You may obtain a copy of
1008 the License at http://www.mozilla.org/MPL/
1009
1010 The original code is icalattach.h
1011
1012======================================================================*/
1013
1014#ifndef ICALATTACH_H
1015#define ICALATTACH_H
1016
1017
1018typedef struct icalattach_impl icalattach;
1019
1020typedef void (* icalattach_free_fn_t) (unsigned char *data, void *user_data);
1021
1022icalattach *icalattach_new_from_url (const char *url);
1023icalattach *icalattach_new_from_data (unsigned char *data,
1024 icalattach_free_fn_t free_fn, void *free_fn_data);
1025
1026void icalattach_ref (icalattach *attach);
1027void icalattach_unref (icalattach *attach);
1028
1029int icalattach_get_is_url (icalattach *attach);
1030const char *icalattach_get_url (icalattach *attach);
1031unsigned char *icalattach_get_data (icalattach *attach);
1032
1033struct icalattachtype* icalattachtype_new(void);
1034void icalattachtype_add_reference(struct icalattachtype* v);
1035void icalattachtype_free(struct icalattachtype* v);
1036
1037void icalattachtype_set_url(struct icalattachtype* v, char* url);
1038char* icalattachtype_get_url(struct icalattachtype* v);
1039
1040void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
1041 int owns);
1042char* icalattachtype_get_base64(struct icalattachtype* v);
1043
1044void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
1045 int owns);
1046void* icalattachtype_get_binary(struct icalattachtype* v);
1047
1048
1049
1050#endif /* !ICALATTACH_H */
1051/* -*- Mode: C -*- */
1052/*======================================================================
746 FILE: icalvalue.h 1053 FILE: icalvalue.h
@@ -749,4 +1056,2 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
749 1056
750 $Id$
751 $Locker$
752 1057
@@ -775,3 +1080,3 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
775 1080
776typedef void icalvalue; 1081typedef struct icalvalue_impl icalvalue;
777 1082
@@ -781,7 +1086,3 @@ void icalvalue_set_x(icalvalue* value, const char* v);
781icalvalue* icalvalue_new_x(const char* v); 1086icalvalue* icalvalue_new_x(const char* v);
782const char* icalvalue_get_x(icalvalue* value); 1087const char* icalvalue_get_x(const icalvalue* value);
783
784icalvalue* icalvalue_new_attach (struct icalattachtype* v);
785void icalvalue_set_attach(icalvalue* value, struct icalattachtype* v);
786struct icalattachtype* icalvalue_get_attach(icalvalue* value);
787 1088
@@ -789,3 +1090,3 @@ icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
789void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); 1090void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
790struct icalrecurrencetype icalvalue_get_recur(icalvalue* value); 1091struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
791 1092
@@ -793,3 +1094,3 @@ icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
793void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); 1094void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
794struct icaltriggertype icalvalue_get_trigger(icalvalue* value); 1095struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
795 1096
@@ -797,3 +1098,7 @@ icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
797void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v); 1098void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v);
798struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value); 1099struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
1100
1101icalvalue *icalvalue_new_attach (icalattach *attach);
1102void icalvalue_set_attach (icalvalue *value, icalattach *attach);
1103icalattach *icalvalue_get_attach (const icalvalue *value);
799 1104
@@ -801,3 +1106,2 @@ void icalvalue_reset_kind(icalvalue* value);
801 1106
802/* Everything below this line is machine generated. Do not edit. */
803typedef enum icalvalue_kind { 1107typedef enum icalvalue_kind {
@@ -805,28 +1109,29 @@ typedef enum icalvalue_kind {
805 ICAL_QUERY_VALUE=5001, 1109 ICAL_QUERY_VALUE=5001,
806 ICAL_TRIGGER_VALUE=5002, 1110 ICAL_DATE_VALUE=5002,
807 ICAL_STATUS_VALUE=5003, 1111 ICAL_ATTACH_VALUE=5003,
808 ICAL_TRANSP_VALUE=5004, 1112 ICAL_GEO_VALUE=5004,
809 ICAL_CLASS_VALUE=5005, 1113 ICAL_STATUS_VALUE=5005,
810 ICAL_DATE_VALUE=5006, 1114 ICAL_TRANSP_VALUE=5006,
811 ICAL_STRING_VALUE=5007, 1115 ICAL_STRING_VALUE=5007,
812 ICAL_INTEGER_VALUE=5008, 1116 ICAL_TEXT_VALUE=5008,
813 ICAL_PERIOD_VALUE=5009, 1117 ICAL_REQUESTSTATUS_VALUE=5009,
814 ICAL_TEXT_VALUE=5010, 1118 ICAL_BINARY_VALUE=5010,
815 ICAL_DURATION_VALUE=5011, 1119 ICAL_PERIOD_VALUE=5011,
816 ICAL_BOOLEAN_VALUE=5012, 1120 ICAL_FLOAT_VALUE=5012,
817 ICAL_URI_VALUE=5013, 1121 ICAL_DATETIMEPERIOD_VALUE=5013,
818 ICAL_DATETIMEPERIOD_VALUE=5014, 1122 ICAL_INTEGER_VALUE=5014,
819 ICAL_GEO_VALUE=5015, 1123 ICAL_CLASS_VALUE=5015,
820 ICAL_DATETIME_VALUE=5016, 1124 ICAL_URI_VALUE=5016,
821 ICAL_UTCOFFSET_VALUE=5017, 1125 ICAL_DURATION_VALUE=5017,
822 ICAL_ATTACH_VALUE=5018, 1126 ICAL_BOOLEAN_VALUE=5018,
823 ICAL_ACTION_VALUE=5019, 1127 ICAL_X_VALUE=5019,
824 ICAL_CALADDRESS_VALUE=5020, 1128 ICAL_CALADDRESS_VALUE=5020,
825 ICAL_X_VALUE=5021, 1129 ICAL_TRIGGER_VALUE=5021,
826 ICAL_FLOAT_VALUE=5022, 1130 ICAL_XLICCLASS_VALUE=5022,
827 ICAL_REQUESTSTATUS_VALUE=5023, 1131 ICAL_RECUR_VALUE=5023,
828 ICAL_METHOD_VALUE=5024, 1132 ICAL_ACTION_VALUE=5024,
829 ICAL_BINARY_VALUE=5025, 1133 ICAL_DATETIME_VALUE=5025,
830 ICAL_RECUR_VALUE=5026, 1134 ICAL_UTCOFFSET_VALUE=5026,
831 ICAL_NO_VALUE=5027 1135 ICAL_METHOD_VALUE=5027,
1136 ICAL_NO_VALUE=5028
832} icalvalue_kind ; 1137} icalvalue_kind ;
@@ -888,7 +1193,41 @@ typedef enum icalproperty_transp {
888 ICAL_TRANSP_OPAQUE = 10039, 1193 ICAL_TRANSP_OPAQUE = 10039,
889 ICAL_TRANSP_TRANSPARENT = 10040, 1194 ICAL_TRANSP_OPAQUENOCONFLICT = 10040,
890 ICAL_TRANSP_NONE = 10041 1195 ICAL_TRANSP_TRANSPARENT = 10041,
1196 ICAL_TRANSP_TRANSPARENTNOCONFLICT = 10042,
1197 ICAL_TRANSP_NONE = 10043
891} icalproperty_transp; 1198} icalproperty_transp;
892 1199
893#define ICALPROPERTY_LAST_ENUM 10042 1200typedef enum icalproperty_xlicclass {
1201 ICAL_XLICCLASS_X = 10044,
1202 ICAL_XLICCLASS_PUBLISHNEW = 10045,
1203 ICAL_XLICCLASS_PUBLISHUPDATE = 10046,
1204 ICAL_XLICCLASS_PUBLISHFREEBUSY = 10047,
1205 ICAL_XLICCLASS_REQUESTNEW = 10048,
1206 ICAL_XLICCLASS_REQUESTUPDATE = 10049,
1207 ICAL_XLICCLASS_REQUESTRESCHEDULE = 10050,
1208 ICAL_XLICCLASS_REQUESTDELEGATE = 10051,
1209 ICAL_XLICCLASS_REQUESTNEWORGANIZER = 10052,
1210 ICAL_XLICCLASS_REQUESTFORWARD = 10053,
1211 ICAL_XLICCLASS_REQUESTSTATUS = 10054,
1212 ICAL_XLICCLASS_REQUESTFREEBUSY = 10055,
1213 ICAL_XLICCLASS_REPLYACCEPT = 10056,
1214 ICAL_XLICCLASS_REPLYDECLINE = 10057,
1215 ICAL_XLICCLASS_REPLYDELEGATE = 10058,
1216 ICAL_XLICCLASS_REPLYCRASHERACCEPT = 10059,
1217 ICAL_XLICCLASS_REPLYCRASHERDECLINE = 10060,
1218 ICAL_XLICCLASS_ADDINSTANCE = 10061,
1219 ICAL_XLICCLASS_CANCELEVENT = 10062,
1220 ICAL_XLICCLASS_CANCELINSTANCE = 10063,
1221 ICAL_XLICCLASS_CANCELALL = 10064,
1222 ICAL_XLICCLASS_REFRESH = 10065,
1223 ICAL_XLICCLASS_COUNTER = 10066,
1224 ICAL_XLICCLASS_DECLINECOUNTER = 10067,
1225 ICAL_XLICCLASS_MALFORMED = 10068,
1226 ICAL_XLICCLASS_OBSOLETE = 10069,
1227 ICAL_XLICCLASS_MISSEQUENCED = 10070,
1228 ICAL_XLICCLASS_UNKNOWN = 10071,
1229 ICAL_XLICCLASS_NONE = 10072
1230} icalproperty_xlicclass;
1231
1232#define ICALPROPERTY_LAST_ENUM 10073
894 1233
@@ -897,3 +1236,3 @@ typedef enum icalproperty_transp {
897icalvalue* icalvalue_new_query(const char* v); 1236icalvalue* icalvalue_new_query(const char* v);
898const char* icalvalue_get_query(icalvalue* value); 1237const char* icalvalue_get_query(const icalvalue* value);
899void icalvalue_set_query(icalvalue* value, const char* v); 1238void icalvalue_set_query(icalvalue* value, const char* v);
@@ -901,5 +1240,17 @@ void icalvalue_set_query(icalvalue* value, const char* v);
901 1240
1241 /* DATE */
1242icalvalue* icalvalue_new_date(struct icaltimetype v);
1243struct icaltimetype icalvalue_get_date(const icalvalue* value);
1244void icalvalue_set_date(icalvalue* value, struct icaltimetype v);
1245
1246
1247 /* GEO */
1248icalvalue* icalvalue_new_geo(struct icalgeotype v);
1249struct icalgeotype icalvalue_get_geo(const icalvalue* value);
1250void icalvalue_set_geo(icalvalue* value, struct icalgeotype v);
1251
1252
902 /* STATUS */ 1253 /* STATUS */
903icalvalue* icalvalue_new_status(enum icalproperty_status v); 1254icalvalue* icalvalue_new_status(enum icalproperty_status v);
904enum icalproperty_status icalvalue_get_status(icalvalue* value); 1255enum icalproperty_status icalvalue_get_status(const icalvalue* value);
905void icalvalue_set_status(icalvalue* value, enum icalproperty_status v); 1256void icalvalue_set_status(icalvalue* value, enum icalproperty_status v);
@@ -909,3 +1260,3 @@ void icalvalue_set_status(icalvalue* value, enum icalproperty_status v);
909icalvalue* icalvalue_new_transp(enum icalproperty_transp v); 1260icalvalue* icalvalue_new_transp(enum icalproperty_transp v);
910enum icalproperty_transp icalvalue_get_transp(icalvalue* value); 1261enum icalproperty_transp icalvalue_get_transp(const icalvalue* value);
911void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v); 1262void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v);
@@ -913,24 +1264,24 @@ void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v);
913 1264
914 /* CLASS */ 1265 /* STRING */
915icalvalue* icalvalue_new_class(enum icalproperty_class v); 1266icalvalue* icalvalue_new_string(const char* v);
916enum icalproperty_class icalvalue_get_class(icalvalue* value); 1267const char* icalvalue_get_string(const icalvalue* value);
917void icalvalue_set_class(icalvalue* value, enum icalproperty_class v); 1268void icalvalue_set_string(icalvalue* value, const char* v);
918 1269
919 1270
920 /* DATE */ 1271 /* TEXT */
921icalvalue* icalvalue_new_date(struct icaltimetype v); 1272icalvalue* icalvalue_new_text(const char* v);
922struct icaltimetype icalvalue_get_date(icalvalue* value); 1273const char* icalvalue_get_text(const icalvalue* value);
923void icalvalue_set_date(icalvalue* value, struct icaltimetype v); 1274void icalvalue_set_text(icalvalue* value, const char* v);
924 1275
925 1276
926 /* STRING */ 1277 /* REQUEST-STATUS */
927icalvalue* icalvalue_new_string(const char* v); 1278icalvalue* icalvalue_new_requeststatus(struct icalreqstattype v);
928const char* icalvalue_get_string(icalvalue* value); 1279struct icalreqstattype icalvalue_get_requeststatus(const icalvalue* value);
929void icalvalue_set_string(icalvalue* value, const char* v); 1280void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v);
930 1281
931 1282
932 /* INTEGER */ 1283 /* BINARY */
933icalvalue* icalvalue_new_integer(int v); 1284icalvalue* icalvalue_new_binary(const char* v);
934int icalvalue_get_integer(icalvalue* value); 1285const char* icalvalue_get_binary(const icalvalue* value);
935void icalvalue_set_integer(icalvalue* value, int v); 1286void icalvalue_set_binary(icalvalue* value, const char* v);
936 1287
@@ -939,3 +1290,3 @@ void icalvalue_set_integer(icalvalue* value, int v);
939icalvalue* icalvalue_new_period(struct icalperiodtype v); 1290icalvalue* icalvalue_new_period(struct icalperiodtype v);
940struct icalperiodtype icalvalue_get_period(icalvalue* value); 1291struct icalperiodtype icalvalue_get_period(const icalvalue* value);
941void icalvalue_set_period(icalvalue* value, struct icalperiodtype v); 1292void icalvalue_set_period(icalvalue* value, struct icalperiodtype v);
@@ -943,18 +1294,18 @@ void icalvalue_set_period(icalvalue* value, struct icalperiodtype v);
943 1294
944 /* TEXT */ 1295 /* FLOAT */
945icalvalue* icalvalue_new_text(const char* v); 1296icalvalue* icalvalue_new_float(float v);
946const char* icalvalue_get_text(icalvalue* value); 1297float icalvalue_get_float(const icalvalue* value);
947void icalvalue_set_text(icalvalue* value, const char* v); 1298void icalvalue_set_float(icalvalue* value, float v);
948 1299
949 1300
950 /* DURATION */ 1301 /* INTEGER */
951icalvalue* icalvalue_new_duration(struct icaldurationtype v); 1302icalvalue* icalvalue_new_integer(int v);
952struct icaldurationtype icalvalue_get_duration(icalvalue* value); 1303int icalvalue_get_integer(const icalvalue* value);
953void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v); 1304void icalvalue_set_integer(icalvalue* value, int v);
954 1305
955 1306
956 /* BOOLEAN */ 1307 /* CLASS */
957icalvalue* icalvalue_new_boolean(int v); 1308icalvalue* icalvalue_new_class(enum icalproperty_class v);
958int icalvalue_get_boolean(icalvalue* value); 1309enum icalproperty_class icalvalue_get_class(const icalvalue* value);
959void icalvalue_set_boolean(icalvalue* value, int v); 1310void icalvalue_set_class(icalvalue* value, enum icalproperty_class v);
960 1311
@@ -963,3 +1314,3 @@ void icalvalue_set_boolean(icalvalue* value, int v);
963icalvalue* icalvalue_new_uri(const char* v); 1314icalvalue* icalvalue_new_uri(const char* v);
964const char* icalvalue_get_uri(icalvalue* value); 1315const char* icalvalue_get_uri(const icalvalue* value);
965void icalvalue_set_uri(icalvalue* value, const char* v); 1316void icalvalue_set_uri(icalvalue* value, const char* v);
@@ -967,18 +1318,24 @@ void icalvalue_set_uri(icalvalue* value, const char* v);
967 1318
968 /* GEO */ 1319 /* DURATION */
969icalvalue* icalvalue_new_geo(struct icalgeotype v); 1320icalvalue* icalvalue_new_duration(struct icaldurationtype v);
970struct icalgeotype icalvalue_get_geo(icalvalue* value); 1321struct icaldurationtype icalvalue_get_duration(const icalvalue* value);
971void icalvalue_set_geo(icalvalue* value, struct icalgeotype v); 1322void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v);
972 1323
973 1324
974 /* DATE-TIME */ 1325 /* BOOLEAN */
975icalvalue* icalvalue_new_datetime(struct icaltimetype v); 1326icalvalue* icalvalue_new_boolean(int v);
976struct icaltimetype icalvalue_get_datetime(icalvalue* value); 1327int icalvalue_get_boolean(const icalvalue* value);
977void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v); 1328void icalvalue_set_boolean(icalvalue* value, int v);
978 1329
979 1330
980 /* UTC-OFFSET */ 1331 /* CAL-ADDRESS */
981icalvalue* icalvalue_new_utcoffset(int v); 1332icalvalue* icalvalue_new_caladdress(const char* v);
982int icalvalue_get_utcoffset(icalvalue* value); 1333const char* icalvalue_get_caladdress(const icalvalue* value);
983void icalvalue_set_utcoffset(icalvalue* value, int v); 1334void icalvalue_set_caladdress(icalvalue* value, const char* v);
1335
1336
1337 /* X-LIC-CLASS */
1338icalvalue* icalvalue_new_xlicclass(enum icalproperty_xlicclass v);
1339enum icalproperty_xlicclass icalvalue_get_xlicclass(const icalvalue* value);
1340void icalvalue_set_xlicclass(icalvalue* value, enum icalproperty_xlicclass v);
984 1341
@@ -987,3 +1344,3 @@ void icalvalue_set_utcoffset(icalvalue* value, int v);
987icalvalue* icalvalue_new_action(enum icalproperty_action v); 1344icalvalue* icalvalue_new_action(enum icalproperty_action v);
988enum icalproperty_action icalvalue_get_action(icalvalue* value); 1345enum icalproperty_action icalvalue_get_action(const icalvalue* value);
989void icalvalue_set_action(icalvalue* value, enum icalproperty_action v); 1346void icalvalue_set_action(icalvalue* value, enum icalproperty_action v);
@@ -991,18 +1348,12 @@ void icalvalue_set_action(icalvalue* value, enum icalproperty_action v);
991 1348
992 /* CAL-ADDRESS */ 1349 /* DATE-TIME */
993icalvalue* icalvalue_new_caladdress(const char* v); 1350icalvalue* icalvalue_new_datetime(struct icaltimetype v);
994const char* icalvalue_get_caladdress(icalvalue* value); 1351struct icaltimetype icalvalue_get_datetime(const icalvalue* value);
995void icalvalue_set_caladdress(icalvalue* value, const char* v); 1352void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v);
996
997
998 /* FLOAT */
999icalvalue* icalvalue_new_float(float v);
1000float icalvalue_get_float(icalvalue* value);
1001void icalvalue_set_float(icalvalue* value, float v);
1002 1353
1003 1354
1004 /* REQUEST-STATUS */ 1355 /* UTC-OFFSET */
1005icalvalue* icalvalue_new_requeststatus(struct icalreqstattype v); 1356icalvalue* icalvalue_new_utcoffset(int v);
1006struct icalreqstattype icalvalue_get_requeststatus(icalvalue* value); 1357int icalvalue_get_utcoffset(const icalvalue* value);
1007void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v); 1358void icalvalue_set_utcoffset(icalvalue* value, int v);
1008 1359
@@ -1011,11 +1362,5 @@ void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v);
1011icalvalue* icalvalue_new_method(enum icalproperty_method v); 1362icalvalue* icalvalue_new_method(enum icalproperty_method v);
1012enum icalproperty_method icalvalue_get_method(icalvalue* value); 1363enum icalproperty_method icalvalue_get_method(const icalvalue* value);
1013void icalvalue_set_method(icalvalue* value, enum icalproperty_method v); 1364void icalvalue_set_method(icalvalue* value, enum icalproperty_method v);
1014 1365
1015
1016 /* BINARY */
1017icalvalue* icalvalue_new_binary(const char* v);
1018const char* icalvalue_get_binary(icalvalue* value);
1019void icalvalue_set_binary(icalvalue* value, const char* v);
1020
1021#endif /*ICALVALUE_H*/ 1366#endif /*ICALVALUE_H*/
@@ -1027,4 +1372,2 @@ void icalvalue_set_binary(icalvalue* value, const char* v);
1027 1372
1028 $Id$
1029 $Locker$
1030 1373
@@ -1053,3 +1396,3 @@ void icalvalue_set_binary(icalvalue* value, const char* v);
1053 1396
1054typedef void icalparameter; 1397typedef struct icalparameter_impl icalparameter;
1055 1398
@@ -1058,3 +1401,2 @@ int icalparameter_string_to_enum(const char* str);
1058 1401
1059/* Everything below this line is machine generated. Do not edit. */
1060typedef enum icalparameter_kind { 1402typedef enum icalparameter_kind {
@@ -1137,3 +1479,3 @@ typedef enum icalparameter_related {
1137 ICAL_RELATED_START = 20031, 1479 ICAL_RELATED_START = 20031,
1138 ICAL_RELATED_END = 20032, 1480 ICAL_RELATED_END = 20032,
1139 ICAL_RELATED_NONE = 20033 1481 ICAL_RELATED_NONE = 20033
@@ -1193,3 +1535,5 @@ typedef enum icalparameter_xliccomparetype {
1193 ICAL_XLICCOMPARETYPE_REGEX = 20072, 1535 ICAL_XLICCOMPARETYPE_REGEX = 20072,
1194 ICAL_XLICCOMPARETYPE_NONE = 20073 1536 ICAL_XLICCOMPARETYPE_ISNULL = 20073,
1537 ICAL_XLICCOMPARETYPE_ISNOTNULL = 20074,
1538 ICAL_XLICCOMPARETYPE_NONE = 20075
1195} icalparameter_xliccomparetype; 1539} icalparameter_xliccomparetype;
@@ -1197,45 +1541,26 @@ typedef enum icalparameter_xliccomparetype {
1197typedef enum icalparameter_xlicerrortype { 1541typedef enum icalparameter_xlicerrortype {
1198 ICAL_XLICERRORTYPE_X = 20074, 1542 ICAL_XLICERRORTYPE_X = 20076,
1199 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR = 20075, 1543 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR = 20077,
1200 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR = 20076, 1544 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR = 20078,
1201 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR = 20077, 1545 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR = 20079,
1202 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR = 20078, 1546 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR = 20080,
1203 ICAL_XLICERRORTYPE_VALUEPARSEERROR = 20079, 1547 ICAL_XLICERRORTYPE_VALUEPARSEERROR = 20081,
1204 ICAL_XLICERRORTYPE_INVALIDITIP = 20080, 1548 ICAL_XLICERRORTYPE_INVALIDITIP = 20082,
1205 ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR = 20081, 1549 ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR = 20083,
1206 ICAL_XLICERRORTYPE_MIMEPARSEERROR = 20082, 1550 ICAL_XLICERRORTYPE_MIMEPARSEERROR = 20084,
1207 ICAL_XLICERRORTYPE_NONE = 20083 1551 ICAL_XLICERRORTYPE_VCALPROPPARSEERROR = 20085,
1552 ICAL_XLICERRORTYPE_NONE = 20086
1208} icalparameter_xlicerrortype; 1553} icalparameter_xlicerrortype;
1209 1554
1210#define ICALPARAMETER_LAST_ENUM 20084 1555#define ICALPARAMETER_LAST_ENUM 20087
1211 1556
1212/* DELEGATED-FROM */ 1557/* LANGUAGE */
1213icalparameter* icalparameter_new_delegatedfrom(const char* v); 1558icalparameter* icalparameter_new_language(const char* v);
1214const char* icalparameter_get_delegatedfrom(icalparameter* value); 1559const char* icalparameter_get_language(const icalparameter* value);
1215void icalparameter_set_delegatedfrom(icalparameter* value, const char* v); 1560void icalparameter_set_language(icalparameter* value, const char* v);
1216
1217/* DELEGATED-TO */
1218icalparameter* icalparameter_new_delegatedto(const char* v);
1219const char* icalparameter_get_delegatedto(icalparameter* value);
1220void icalparameter_set_delegatedto(icalparameter* value, const char* v);
1221
1222/* RANGE */
1223icalparameter* icalparameter_new_range(icalparameter_range v);
1224icalparameter_range icalparameter_get_range(icalparameter* value);
1225void icalparameter_set_range(icalparameter* value, icalparameter_range v);
1226
1227/* ENCODING */
1228icalparameter* icalparameter_new_encoding(icalparameter_encoding v);
1229icalparameter_encoding icalparameter_get_encoding(icalparameter* value);
1230void icalparameter_set_encoding(icalparameter* value, icalparameter_encoding v);
1231
1232/* RSVP */
1233icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v);
1234icalparameter_rsvp icalparameter_get_rsvp(icalparameter* value);
1235void icalparameter_set_rsvp(icalparameter* value, icalparameter_rsvp v);
1236 1561
1237/* PARTSTAT */ 1562/* DIR */
1238icalparameter* icalparameter_new_partstat(icalparameter_partstat v); 1563icalparameter* icalparameter_new_dir(const char* v);
1239icalparameter_partstat icalparameter_get_partstat(icalparameter* value); 1564const char* icalparameter_get_dir(const icalparameter* value);
1240void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v); 1565void icalparameter_set_dir(icalparameter* value, const char* v);
1241 1566
@@ -1243,24 +1568,29 @@ void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v);
1243icalparameter* icalparameter_new_reltype(icalparameter_reltype v); 1568icalparameter* icalparameter_new_reltype(icalparameter_reltype v);
1244icalparameter_reltype icalparameter_get_reltype(icalparameter* value); 1569icalparameter_reltype icalparameter_get_reltype(const icalparameter* value);
1245void icalparameter_set_reltype(icalparameter* value, icalparameter_reltype v); 1570void icalparameter_set_reltype(icalparameter* value, icalparameter_reltype v);
1246 1571
1247/* CUTYPE */
1248icalparameter* icalparameter_new_cutype(icalparameter_cutype v);
1249icalparameter_cutype icalparameter_get_cutype(icalparameter* value);
1250void icalparameter_set_cutype(icalparameter* value, icalparameter_cutype v);
1251
1252/* MEMBER */
1253icalparameter* icalparameter_new_member(const char* v);
1254const char* icalparameter_get_member(icalparameter* value);
1255void icalparameter_set_member(icalparameter* value, const char* v);
1256
1257/* FMTTYPE */ 1572/* FMTTYPE */
1258icalparameter* icalparameter_new_fmttype(const char* v); 1573icalparameter* icalparameter_new_fmttype(const char* v);
1259const char* icalparameter_get_fmttype(icalparameter* value); 1574const char* icalparameter_get_fmttype(const icalparameter* value);
1260void icalparameter_set_fmttype(icalparameter* value, const char* v); 1575void icalparameter_set_fmttype(icalparameter* value, const char* v);
1261 1576
1262/* SENT-BY */ 1577/* TZID */
1263icalparameter* icalparameter_new_sentby(const char* v); 1578icalparameter* icalparameter_new_tzid(const char* v);
1264const char* icalparameter_get_sentby(icalparameter* value); 1579const char* icalparameter_get_tzid(const icalparameter* value);
1265void icalparameter_set_sentby(icalparameter* value, const char* v); 1580void icalparameter_set_tzid(icalparameter* value, const char* v);
1581
1582/* RANGE */
1583icalparameter* icalparameter_new_range(icalparameter_range v);
1584icalparameter_range icalparameter_get_range(const icalparameter* value);
1585void icalparameter_set_range(icalparameter* value, icalparameter_range v);
1586
1587/* DELEGATED-TO */
1588icalparameter* icalparameter_new_delegatedto(const char* v);
1589const char* icalparameter_get_delegatedto(const icalparameter* value);
1590void icalparameter_set_delegatedto(icalparameter* value, const char* v);
1591
1592/* CN */
1593icalparameter* icalparameter_new_cn(const char* v);
1594const char* icalparameter_get_cn(const icalparameter* value);
1595void icalparameter_set_cn(icalparameter* value, const char* v);
1266 1596
@@ -1268,24 +1598,34 @@ void icalparameter_set_sentby(icalparameter* value, const char* v);
1268icalparameter* icalparameter_new_value(icalparameter_value v); 1598icalparameter* icalparameter_new_value(icalparameter_value v);
1269icalparameter_value icalparameter_get_value(icalparameter* value); 1599icalparameter_value icalparameter_get_value(const icalparameter* value);
1270void icalparameter_set_value(icalparameter* value, icalparameter_value v); 1600void icalparameter_set_value(icalparameter* value, icalparameter_value v);
1271 1601
1272/* ALTREP */ 1602/* X-LIC-COMPARETYPE */
1273icalparameter* icalparameter_new_altrep(const char* v); 1603icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v);
1274const char* icalparameter_get_altrep(icalparameter* value); 1604icalparameter_xliccomparetype icalparameter_get_xliccomparetype(const icalparameter* value);
1275void icalparameter_set_altrep(icalparameter* value, const char* v); 1605void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xliccomparetype v);
1276 1606
1277/* DIR */ 1607/* X */
1278icalparameter* icalparameter_new_dir(const char* v); 1608icalparameter* icalparameter_new_x(const char* v);
1279const char* icalparameter_get_dir(icalparameter* value); 1609const char* icalparameter_get_x(const icalparameter* value);
1280void icalparameter_set_dir(icalparameter* value, const char* v); 1610void icalparameter_set_x(icalparameter* value, const char* v);
1281 1611
1282/* RELATED */ 1612/* SENT-BY */
1283icalparameter* icalparameter_new_related(icalparameter_related v); 1613icalparameter* icalparameter_new_sentby(const char* v);
1284icalparameter_related icalparameter_get_related(icalparameter* value); 1614const char* icalparameter_get_sentby(const icalparameter* value);
1285void icalparameter_set_related(icalparameter* value, icalparameter_related v); 1615void icalparameter_set_sentby(icalparameter* value, const char* v);
1286 1616
1287/* CN */ 1617/* MEMBER */
1288icalparameter* icalparameter_new_cn(const char* v); 1618icalparameter* icalparameter_new_member(const char* v);
1289const char* icalparameter_get_cn(icalparameter* value); 1619const char* icalparameter_get_member(const icalparameter* value);
1290void icalparameter_set_cn(icalparameter* value, const char* v); 1620void icalparameter_set_member(icalparameter* value, const char* v);
1621
1622/* RSVP */
1623icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v);
1624icalparameter_rsvp icalparameter_get_rsvp(const icalparameter* value);
1625void icalparameter_set_rsvp(icalparameter* value, icalparameter_rsvp v);
1626
1627/* CUTYPE */
1628icalparameter* icalparameter_new_cutype(icalparameter_cutype v);
1629icalparameter_cutype icalparameter_get_cutype(const icalparameter* value);
1630void icalparameter_set_cutype(icalparameter* value, icalparameter_cutype v);
1291 1631
@@ -1293,24 +1633,24 @@ void icalparameter_set_cn(icalparameter* value, const char* v);
1293icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v); 1633icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v);
1294icalparameter_xlicerrortype icalparameter_get_xlicerrortype(icalparameter* value); 1634icalparameter_xlicerrortype icalparameter_get_xlicerrortype(const icalparameter* value);
1295void icalparameter_set_xlicerrortype(icalparameter* value, icalparameter_xlicerrortype v); 1635void icalparameter_set_xlicerrortype(icalparameter* value, icalparameter_xlicerrortype v);
1296 1636
1297/* X */ 1637/* RELATED */
1298icalparameter* icalparameter_new_x(const char* v); 1638icalparameter* icalparameter_new_related(icalparameter_related v);
1299const char* icalparameter_get_x(icalparameter* value); 1639icalparameter_related icalparameter_get_related(const icalparameter* value);
1300void icalparameter_set_x(icalparameter* value, const char* v); 1640void icalparameter_set_related(icalparameter* value, icalparameter_related v);
1301 1641
1302/* LANGUAGE */ 1642/* ENCODING */
1303icalparameter* icalparameter_new_language(const char* v); 1643icalparameter* icalparameter_new_encoding(icalparameter_encoding v);
1304const char* icalparameter_get_language(icalparameter* value); 1644icalparameter_encoding icalparameter_get_encoding(const icalparameter* value);
1305void icalparameter_set_language(icalparameter* value, const char* v); 1645void icalparameter_set_encoding(icalparameter* value, icalparameter_encoding v);
1306 1646
1307/* ROLE */ 1647/* ALTREP */
1308icalparameter* icalparameter_new_role(icalparameter_role v); 1648icalparameter* icalparameter_new_altrep(const char* v);
1309icalparameter_role icalparameter_get_role(icalparameter* value); 1649const char* icalparameter_get_altrep(const icalparameter* value);
1310void icalparameter_set_role(icalparameter* value, icalparameter_role v); 1650void icalparameter_set_altrep(icalparameter* value, const char* v);
1311 1651
1312/* X-LIC-COMPARETYPE */ 1652/* DELEGATED-FROM */
1313icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v); 1653icalparameter* icalparameter_new_delegatedfrom(const char* v);
1314icalparameter_xliccomparetype icalparameter_get_xliccomparetype(icalparameter* value); 1654const char* icalparameter_get_delegatedfrom(const icalparameter* value);
1315void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xliccomparetype v); 1655void icalparameter_set_delegatedfrom(icalparameter* value, const char* v);
1316 1656
@@ -1318,9 +1658,14 @@ void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xlicc
1318icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v); 1658icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v);
1319icalparameter_fbtype icalparameter_get_fbtype(icalparameter* value); 1659icalparameter_fbtype icalparameter_get_fbtype(const icalparameter* value);
1320void icalparameter_set_fbtype(icalparameter* value, icalparameter_fbtype v); 1660void icalparameter_set_fbtype(icalparameter* value, icalparameter_fbtype v);
1321 1661
1322/* TZID */ 1662/* ROLE */
1323icalparameter* icalparameter_new_tzid(const char* v); 1663icalparameter* icalparameter_new_role(icalparameter_role v);
1324const char* icalparameter_get_tzid(icalparameter* value); 1664icalparameter_role icalparameter_get_role(const icalparameter* value);
1325void icalparameter_set_tzid(icalparameter* value, const char* v); 1665void icalparameter_set_role(icalparameter* value, icalparameter_role v);
1666
1667/* PARTSTAT */
1668icalparameter* icalparameter_new_partstat(icalparameter_partstat v);
1669icalparameter_partstat icalparameter_get_partstat(const icalparameter* value);
1670void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v);
1326 1671
@@ -1328,2 +1673,147 @@ void icalparameter_set_tzid(icalparameter* value, const char* v);
1328 1673
1674/* Everything below this line is machine generated. Do not edit. */
1675/* -*- Mode: C -*- */
1676/*======================================================================
1677 FILE: icalvalue.h
1678 CREATOR: eric 20 March 1999
1679
1680
1681
1682 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1683
1684 This program is free software; you can redistribute it and/or modify
1685 it under the terms of either:
1686
1687 The LGPL as published by the Free Software Foundation, version
1688 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1689
1690 Or:
1691
1692 The Mozilla Public License Version 1.0. You may obtain a copy of
1693 the License at http://www.mozilla.org/MPL/
1694
1695 The original code is icalvalue.h
1696
1697 ======================================================================*/
1698
1699#ifndef ICALVALUE_H
1700#define ICALVALUE_H
1701
1702#include <time.h>
1703
1704/* Defined in icalderivedvalue.h */
1705/*typedef struct icalvalue_impl icalvalue;*/
1706
1707icalvalue* icalvalue_new(icalvalue_kind kind);
1708
1709icalvalue* icalvalue_new_clone(const icalvalue* value);
1710
1711icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str);
1712
1713void icalvalue_free(icalvalue* value);
1714
1715int icalvalue_is_valid(const icalvalue* value);
1716
1717const char* icalvalue_as_ical_string(const icalvalue* value);
1718
1719icalvalue_kind icalvalue_isa(const icalvalue* value);
1720
1721int icalvalue_isa_value(void*);
1722
1723icalparameter_xliccomparetype icalvalue_compare(const icalvalue* a, const icalvalue *b);
1724
1725
1726/* Special, non autogenerated value accessors */
1727
1728icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
1729void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
1730struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
1731
1732icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
1733void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
1734struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
1735
1736icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
1737void icalvalue_set_datetimeperiod(icalvalue* value,
1738 struct icaldatetimeperiodtype v);
1739struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
1740
1741/* Convert enumerations */
1742
1743icalvalue_kind icalvalue_string_to_kind(const char* str);
1744const char* icalvalue_kind_to_string(const icalvalue_kind kind);
1745
1746/** Check validity of a specific icalvalue_kind **/
1747int icalvalue_kind_is_valid(const icalvalue_kind kind);
1748
1749/** Encode a character string in ical format, esacpe certain characters, etc. */
1750int icalvalue_encode_ical_string(const char *szText, char *szEncText, int MaxBufferLen);
1751
1752#endif /*ICALVALUE_H*/
1753/* -*- Mode: C -*- */
1754/*======================================================================
1755 FILE: icalparam.h
1756 CREATOR: eric 20 March 1999
1757
1758
1759
1760
1761
1762 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1763
1764 This program is free software; you can redistribute it and/or modify
1765 it under the terms of either:
1766
1767 The LGPL as published by the Free Software Foundation, version
1768 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1769
1770 Or:
1771
1772 The Mozilla Public License Version 1.0. You may obtain a copy of
1773 the License at http://www.mozilla.org/MPL/
1774
1775 The original code is icalparam.h
1776
1777 ======================================================================*/
1778
1779#ifndef ICALPARAM_H
1780#define ICALPARAM_H
1781
1782
1783/* Declared in icalderivedparameter.h */
1784/*typedef struct icalparameter_impl icalparameter;*/
1785
1786icalparameter* icalparameter_new(icalparameter_kind kind);
1787icalparameter* icalparameter_new_clone(icalparameter* p);
1788
1789/* Create from string of form "PARAMNAME=VALUE" */
1790icalparameter* icalparameter_new_from_string(const char* value);
1791
1792/* Create from just the value, the part after the "=" */
1793icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind, const char* value);
1794
1795void icalparameter_free(icalparameter* parameter);
1796
1797char* icalparameter_as_ical_string(icalparameter* parameter);
1798
1799int icalparameter_is_valid(icalparameter* parameter);
1800
1801icalparameter_kind icalparameter_isa(icalparameter* parameter);
1802
1803int icalparameter_isa_parameter(void* param);
1804
1805/* Acess the name of an X parameer */
1806void icalparameter_set_xname (icalparameter* param, const char* v);
1807const char* icalparameter_get_xname(icalparameter* param);
1808void icalparameter_set_xvalue (icalparameter* param, const char* v);
1809const char* icalparameter_get_xvalue(icalparameter* param);
1810
1811/* Convert enumerations */
1812
1813const char* icalparameter_kind_to_string(icalparameter_kind kind);
1814icalparameter_kind icalparameter_string_to_kind(const char* string);
1815
1816
1817
1818#endif
1329/* -*- Mode: C -*- 1819/* -*- Mode: C -*-
@@ -1333,3 +1823,2 @@ void icalparameter_set_tzid(icalparameter* value, const char* v);
1333 1823
1334 $Id$
1335 1824
@@ -1344,6 +1833,4 @@ void icalparameter_set_tzid(icalparameter* value, const char* v);
1344 1833
1345typedef void icalproperty; 1834typedef struct icalproperty_impl icalproperty;
1346 1835
1347
1348/* Everything below this line is machine generated. Do not edit. */
1349typedef enum icalproperty_kind { 1836typedef enum icalproperty_kind {
@@ -1351,5 +1838,9 @@ typedef enum icalproperty_kind {
1351 ICAL_ACTION_PROPERTY, 1838 ICAL_ACTION_PROPERTY,
1839 ICAL_ALLOWCONFLICT_PROPERTY,
1352 ICAL_ATTACH_PROPERTY, 1840 ICAL_ATTACH_PROPERTY,
1353 ICAL_ATTENDEE_PROPERTY, 1841 ICAL_ATTENDEE_PROPERTY,
1842 ICAL_CALID_PROPERTY,
1843 ICAL_CALMASTER_PROPERTY,
1354 ICAL_CALSCALE_PROPERTY, 1844 ICAL_CALSCALE_PROPERTY,
1845 ICAL_CARID_PROPERTY,
1355 ICAL_CATEGORIES_PROPERTY, 1846 ICAL_CATEGORIES_PROPERTY,
@@ -1360,2 +1851,6 @@ typedef enum icalproperty_kind {
1360 ICAL_CREATED_PROPERTY, 1851 ICAL_CREATED_PROPERTY,
1852 ICAL_DECREED_PROPERTY,
1853 ICAL_DEFAULTCHARSET_PROPERTY,
1854 ICAL_DEFAULTLOCALE_PROPERTY,
1855 ICAL_DEFAULTTZID_PROPERTY,
1361 ICAL_DESCRIPTION_PROPERTY, 1856 ICAL_DESCRIPTION_PROPERTY,
@@ -1367,2 +1862,3 @@ typedef enum icalproperty_kind {
1367 ICAL_EXDATE_PROPERTY, 1862 ICAL_EXDATE_PROPERTY,
1863 ICAL_EXPAND_PROPERTY,
1368 ICAL_EXRULE_PROPERTY, 1864 ICAL_EXRULE_PROPERTY,
@@ -1376,2 +1872,3 @@ typedef enum icalproperty_kind {
1376 ICAL_ORGANIZER_PROPERTY, 1872 ICAL_ORGANIZER_PROPERTY,
1873 ICAL_OWNER_PROPERTY,
1377 ICAL_PERCENTCOMPLETE_PROPERTY, 1874 ICAL_PERCENTCOMPLETE_PROPERTY,
@@ -1384,2 +1881,3 @@ typedef enum icalproperty_kind {
1384 ICAL_RELATEDTO_PROPERTY, 1881 ICAL_RELATEDTO_PROPERTY,
1882 ICAL_RELCALID_PROPERTY,
1385 ICAL_REPEAT_PROPERTY, 1883 ICAL_REPEAT_PROPERTY,
@@ -1404,2 +1902,3 @@ typedef enum icalproperty_kind {
1404 ICAL_X_PROPERTY, 1902 ICAL_X_PROPERTY,
1903 ICAL_XLICCLASS_PROPERTY,
1405 ICAL_XLICCLUSTERCOUNT_PROPERTY, 1904 ICAL_XLICCLUSTERCOUNT_PROPERTY,
@@ -1415,3 +1914,2 @@ typedef enum icalproperty_kind {
1415 1914
1416icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
1417 1915
@@ -1420,8 +1918,13 @@ icalproperty* icalproperty_new_action(enum icalproperty_action v);
1420void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v); 1918void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v);
1421enum icalproperty_action icalproperty_get_action(icalproperty* prop);icalproperty* icalproperty_vanew_attach(struct icalattachtype* v, ...); 1919enum icalproperty_action icalproperty_get_action(const icalproperty* prop);icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
1920
1921/* ALLOW-CONFLICT */
1922icalproperty* icalproperty_new_allowconflict(const char* v);
1923void icalproperty_set_allowconflict(icalproperty* prop, const char* v);
1924const char* icalproperty_get_allowconflict(const icalproperty* prop);icalproperty* icalproperty_vanew_allowconflict(const char* v, ...);
1422 1925
1423/* ATTACH */ 1926/* ATTACH */
1424icalproperty* icalproperty_new_attach(struct icalattachtype* v); 1927icalproperty* icalproperty_new_attach(icalattach * v);
1425void icalproperty_set_attach(icalproperty* prop, struct icalattachtype* v); 1928void icalproperty_set_attach(icalproperty* prop, icalattach * v);
1426struct icalattachtype* icalproperty_get_attach(icalproperty* prop);icalproperty* icalproperty_vanew_attendee(const char* v, ...); 1929icalattach * icalproperty_get_attach(const icalproperty* prop);icalproperty* icalproperty_vanew_attach(icalattach * v, ...);
1427 1930
@@ -1430,3 +1933,13 @@ icalproperty* icalproperty_new_attendee(const char* v);
1430void icalproperty_set_attendee(icalproperty* prop, const char* v); 1933void icalproperty_set_attendee(icalproperty* prop, const char* v);
1431const char* icalproperty_get_attendee(icalproperty* prop);icalproperty* icalproperty_vanew_calscale(const char* v, ...); 1934const char* icalproperty_get_attendee(const icalproperty* prop);icalproperty* icalproperty_vanew_attendee(const char* v, ...);
1935
1936/* CALID */
1937icalproperty* icalproperty_new_calid(const char* v);
1938void icalproperty_set_calid(icalproperty* prop, const char* v);
1939const char* icalproperty_get_calid(const icalproperty* prop);icalproperty* icalproperty_vanew_calid(const char* v, ...);
1940
1941/* CALMASTER */
1942icalproperty* icalproperty_new_calmaster(const char* v);
1943void icalproperty_set_calmaster(icalproperty* prop, const char* v);
1944const char* icalproperty_get_calmaster(const icalproperty* prop);icalproperty* icalproperty_vanew_calmaster(const char* v, ...);
1432 1945
@@ -1435,3 +1948,8 @@ icalproperty* icalproperty_new_calscale(const char* v);
1435void icalproperty_set_calscale(icalproperty* prop, const char* v); 1948void icalproperty_set_calscale(icalproperty* prop, const char* v);
1436const char* icalproperty_get_calscale(icalproperty* prop);icalproperty* icalproperty_vanew_categories(const char* v, ...); 1949const char* icalproperty_get_calscale(const icalproperty* prop);icalproperty* icalproperty_vanew_calscale(const char* v, ...);
1950
1951/* CARID */
1952icalproperty* icalproperty_new_carid(const char* v);
1953void icalproperty_set_carid(icalproperty* prop, const char* v);
1954const char* icalproperty_get_carid(const icalproperty* prop);icalproperty* icalproperty_vanew_carid(const char* v, ...);
1437 1955
@@ -1440,8 +1958,8 @@ icalproperty* icalproperty_new_categories(const char* v);
1440void icalproperty_set_categories(icalproperty* prop, const char* v); 1958void icalproperty_set_categories(icalproperty* prop, const char* v);
1441const char* icalproperty_get_categories(icalproperty* prop);icalproperty* icalproperty_vanew_class(const char* v, ...); 1959const char* icalproperty_get_categories(const icalproperty* prop);icalproperty* icalproperty_vanew_categories(const char* v, ...);
1442 1960
1443/* CLASS */ 1961/* CLASS */
1444icalproperty* icalproperty_new_class(const char* v); 1962icalproperty* icalproperty_new_class(enum icalproperty_class v);
1445void icalproperty_set_class(icalproperty* prop, const char* v); 1963void icalproperty_set_class(icalproperty* prop, enum icalproperty_class v);
1446const char* icalproperty_get_class(icalproperty* prop);icalproperty* icalproperty_vanew_comment(const char* v, ...); 1964enum icalproperty_class icalproperty_get_class(const icalproperty* prop);icalproperty* icalproperty_vanew_class(enum icalproperty_class v, ...);
1447 1965
@@ -1450,3 +1968,3 @@ icalproperty* icalproperty_new_comment(const char* v);
1450void icalproperty_set_comment(icalproperty* prop, const char* v); 1968void icalproperty_set_comment(icalproperty* prop, const char* v);
1451const char* icalproperty_get_comment(icalproperty* prop);icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...); 1969const char* icalproperty_get_comment(const icalproperty* prop);icalproperty* icalproperty_vanew_comment(const char* v, ...);
1452 1970
@@ -1455,3 +1973,3 @@ icalproperty* icalproperty_new_completed(struct icaltimetype v);
1455void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v); 1973void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v);
1456struct icaltimetype icalproperty_get_completed(icalproperty* prop);icalproperty* icalproperty_vanew_contact(const char* v, ...); 1974struct icaltimetype icalproperty_get_completed(const icalproperty* prop);icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...);
1457 1975
@@ -1460,3 +1978,3 @@ icalproperty* icalproperty_new_contact(const char* v);
1460void icalproperty_set_contact(icalproperty* prop, const char* v); 1978void icalproperty_set_contact(icalproperty* prop, const char* v);
1461const char* icalproperty_get_contact(icalproperty* prop);icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...); 1979const char* icalproperty_get_contact(const icalproperty* prop);icalproperty* icalproperty_vanew_contact(const char* v, ...);
1462 1980
@@ -1465,3 +1983,23 @@ icalproperty* icalproperty_new_created(struct icaltimetype v);
1465void icalproperty_set_created(icalproperty* prop, struct icaltimetype v); 1983void icalproperty_set_created(icalproperty* prop, struct icaltimetype v);
1466struct icaltimetype icalproperty_get_created(icalproperty* prop);icalproperty* icalproperty_vanew_description(const char* v, ...); 1984struct icaltimetype icalproperty_get_created(const icalproperty* prop);icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...);
1985
1986/* DECREED */
1987icalproperty* icalproperty_new_decreed(const char* v);
1988void icalproperty_set_decreed(icalproperty* prop, const char* v);
1989const char* icalproperty_get_decreed(const icalproperty* prop);icalproperty* icalproperty_vanew_decreed(const char* v, ...);
1990
1991/* DEFAULT-CHARSET */
1992icalproperty* icalproperty_new_defaultcharset(const char* v);
1993void icalproperty_set_defaultcharset(icalproperty* prop, const char* v);
1994const char* icalproperty_get_defaultcharset(const icalproperty* prop);icalproperty* icalproperty_vanew_defaultcharset(const char* v, ...);
1995
1996/* DEFAULT-LOCALE */
1997icalproperty* icalproperty_new_defaultlocale(const char* v);
1998void icalproperty_set_defaultlocale(icalproperty* prop, const char* v);
1999const char* icalproperty_get_defaultlocale(const icalproperty* prop);icalproperty* icalproperty_vanew_defaultlocale(const char* v, ...);
2000
2001/* DEFAULT-TZID */
2002icalproperty* icalproperty_new_defaulttzid(const char* v);
2003void icalproperty_set_defaulttzid(icalproperty* prop, const char* v);
2004const char* icalproperty_get_defaulttzid(const icalproperty* prop);icalproperty* icalproperty_vanew_defaulttzid(const char* v, ...);
1467 2005
@@ -1470,3 +2008,3 @@ icalproperty* icalproperty_new_description(const char* v);
1470void icalproperty_set_description(icalproperty* prop, const char* v); 2008void icalproperty_set_description(icalproperty* prop, const char* v);
1471const char* icalproperty_get_description(icalproperty* prop);icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...); 2009const char* icalproperty_get_description(const icalproperty* prop);icalproperty* icalproperty_vanew_description(const char* v, ...);
1472 2010
@@ -1475,3 +2013,3 @@ icalproperty* icalproperty_new_dtend(struct icaltimetype v);
1475void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v); 2013void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v);
1476struct icaltimetype icalproperty_get_dtend(icalproperty* prop);icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...); 2014struct icaltimetype icalproperty_get_dtend(const icalproperty* prop);icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...);
1477 2015
@@ -1480,3 +2018,3 @@ icalproperty* icalproperty_new_dtstamp(struct icaltimetype v);
1480void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v); 2018void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v);
1481struct icaltimetype icalproperty_get_dtstamp(icalproperty* prop);icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...); 2019struct icaltimetype icalproperty_get_dtstamp(const icalproperty* prop);icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...);
1482 2020
@@ -1485,3 +2023,3 @@ icalproperty* icalproperty_new_dtstart(struct icaltimetype v);
1485void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v); 2023void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v);
1486struct icaltimetype icalproperty_get_dtstart(icalproperty* prop);icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...); 2024struct icaltimetype icalproperty_get_dtstart(const icalproperty* prop);icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...);
1487 2025
@@ -1490,3 +2028,3 @@ icalproperty* icalproperty_new_due(struct icaltimetype v);
1490void icalproperty_set_due(icalproperty* prop, struct icaltimetype v); 2028void icalproperty_set_due(icalproperty* prop, struct icaltimetype v);
1491struct icaltimetype icalproperty_get_due(icalproperty* prop);icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...); 2029struct icaltimetype icalproperty_get_due(const icalproperty* prop);icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...);
1492 2030
@@ -1495,3 +2033,3 @@ icalproperty* icalproperty_new_duration(struct icaldurationtype v);
1495void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v); 2033void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v);
1496struct icaldurationtype icalproperty_get_duration(icalproperty* prop);icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...); 2034struct icaldurationtype icalproperty_get_duration(const icalproperty* prop);icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...);
1497 2035
@@ -1500,3 +2038,8 @@ icalproperty* icalproperty_new_exdate(struct icaltimetype v);
1500void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v); 2038void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v);
1501struct icaltimetype icalproperty_get_exdate(icalproperty* prop);icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...); 2039struct icaltimetype icalproperty_get_exdate(const icalproperty* prop);icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...);
2040
2041/* EXPAND */
2042icalproperty* icalproperty_new_expand(int v);
2043void icalproperty_set_expand(icalproperty* prop, int v);
2044int icalproperty_get_expand(const icalproperty* prop);icalproperty* icalproperty_vanew_expand(int v, ...);
1502 2045
@@ -1505,3 +2048,3 @@ icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v);
1505void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v); 2048void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v);
1506struct icalrecurrencetype icalproperty_get_exrule(icalproperty* prop);icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...); 2049struct icalrecurrencetype icalproperty_get_exrule(const icalproperty* prop);icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...);
1507 2050
@@ -1510,3 +2053,3 @@ icalproperty* icalproperty_new_freebusy(struct icalperiodtype v);
1510void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v); 2053void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v);
1511struct icalperiodtype icalproperty_get_freebusy(icalproperty* prop);icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...); 2054struct icalperiodtype icalproperty_get_freebusy(const icalproperty* prop);icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...);
1512 2055
@@ -1515,3 +2058,3 @@ icalproperty* icalproperty_new_geo(struct icalgeotype v);
1515void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v); 2058void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v);
1516struct icalgeotype icalproperty_get_geo(icalproperty* prop);icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...); 2059struct icalgeotype icalproperty_get_geo(const icalproperty* prop);icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...);
1517 2060
@@ -1520,3 +2063,3 @@ icalproperty* icalproperty_new_lastmodified(struct icaltimetype v);
1520void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v); 2063void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v);
1521struct icaltimetype icalproperty_get_lastmodified(icalproperty* prop);icalproperty* icalproperty_vanew_location(const char* v, ...); 2064struct icaltimetype icalproperty_get_lastmodified(const icalproperty* prop);icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...);
1522 2065
@@ -1525,3 +2068,3 @@ icalproperty* icalproperty_new_location(const char* v);
1525void icalproperty_set_location(icalproperty* prop, const char* v); 2068void icalproperty_set_location(icalproperty* prop, const char* v);
1526const char* icalproperty_get_location(icalproperty* prop);icalproperty* icalproperty_vanew_maxresults(int v, ...); 2069const char* icalproperty_get_location(const icalproperty* prop);icalproperty* icalproperty_vanew_location(const char* v, ...);
1527 2070
@@ -1530,3 +2073,3 @@ icalproperty* icalproperty_new_maxresults(int v);
1530void icalproperty_set_maxresults(icalproperty* prop, int v); 2073void icalproperty_set_maxresults(icalproperty* prop, int v);
1531int icalproperty_get_maxresults(icalproperty* prop);icalproperty* icalproperty_vanew_maxresultssize(int v, ...); 2074int icalproperty_get_maxresults(const icalproperty* prop);icalproperty* icalproperty_vanew_maxresults(int v, ...);
1532 2075
@@ -1535,3 +2078,3 @@ icalproperty* icalproperty_new_maxresultssize(int v);
1535void icalproperty_set_maxresultssize(icalproperty* prop, int v); 2078void icalproperty_set_maxresultssize(icalproperty* prop, int v);
1536int icalproperty_get_maxresultssize(icalproperty* prop);icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...); 2079int icalproperty_get_maxresultssize(const icalproperty* prop);icalproperty* icalproperty_vanew_maxresultssize(int v, ...);
1537 2080
@@ -1540,3 +2083,3 @@ icalproperty* icalproperty_new_method(enum icalproperty_method v);
1540void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v); 2083void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v);
1541enum icalproperty_method icalproperty_get_method(icalproperty* prop);icalproperty* icalproperty_vanew_organizer(const char* v, ...); 2084enum icalproperty_method icalproperty_get_method(const icalproperty* prop);icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...);
1542 2085
@@ -1545,3 +2088,8 @@ icalproperty* icalproperty_new_organizer(const char* v);
1545void icalproperty_set_organizer(icalproperty* prop, const char* v); 2088void icalproperty_set_organizer(icalproperty* prop, const char* v);
1546const char* icalproperty_get_organizer(icalproperty* prop);icalproperty* icalproperty_vanew_percentcomplete(int v, ...); 2089const char* icalproperty_get_organizer(const icalproperty* prop);icalproperty* icalproperty_vanew_organizer(const char* v, ...);
2090
2091/* OWNER */
2092icalproperty* icalproperty_new_owner(const char* v);
2093void icalproperty_set_owner(icalproperty* prop, const char* v);
2094const char* icalproperty_get_owner(const icalproperty* prop);icalproperty* icalproperty_vanew_owner(const char* v, ...);
1547 2095
@@ -1550,3 +2098,3 @@ icalproperty* icalproperty_new_percentcomplete(int v);
1550void icalproperty_set_percentcomplete(icalproperty* prop, int v); 2098void icalproperty_set_percentcomplete(icalproperty* prop, int v);
1551int icalproperty_get_percentcomplete(icalproperty* prop);icalproperty* icalproperty_vanew_priority(int v, ...); 2099int icalproperty_get_percentcomplete(const icalproperty* prop);icalproperty* icalproperty_vanew_percentcomplete(int v, ...);
1552 2100
@@ -1555,3 +2103,3 @@ icalproperty* icalproperty_new_priority(int v);
1555void icalproperty_set_priority(icalproperty* prop, int v); 2103void icalproperty_set_priority(icalproperty* prop, int v);
1556int icalproperty_get_priority(icalproperty* prop);icalproperty* icalproperty_vanew_prodid(const char* v, ...); 2104int icalproperty_get_priority(const icalproperty* prop);icalproperty* icalproperty_vanew_priority(int v, ...);
1557 2105
@@ -1560,3 +2108,3 @@ icalproperty* icalproperty_new_prodid(const char* v);
1560void icalproperty_set_prodid(icalproperty* prop, const char* v); 2108void icalproperty_set_prodid(icalproperty* prop, const char* v);
1561const char* icalproperty_get_prodid(icalproperty* prop);icalproperty* icalproperty_vanew_query(const char* v, ...); 2109const char* icalproperty_get_prodid(const icalproperty* prop);icalproperty* icalproperty_vanew_prodid(const char* v, ...);
1562 2110
@@ -1565,3 +2113,3 @@ icalproperty* icalproperty_new_query(const char* v);
1565void icalproperty_set_query(icalproperty* prop, const char* v); 2113void icalproperty_set_query(icalproperty* prop, const char* v);
1566const char* icalproperty_get_query(icalproperty* prop);icalproperty* icalproperty_vanew_queryname(const char* v, ...); 2114const char* icalproperty_get_query(const icalproperty* prop);icalproperty* icalproperty_vanew_query(const char* v, ...);
1567 2115
@@ -1570,3 +2118,3 @@ icalproperty* icalproperty_new_queryname(const char* v);
1570void icalproperty_set_queryname(icalproperty* prop, const char* v); 2118void icalproperty_set_queryname(icalproperty* prop, const char* v);
1571const char* icalproperty_get_queryname(icalproperty* prop);icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...); 2119const char* icalproperty_get_queryname(const icalproperty* prop);icalproperty* icalproperty_vanew_queryname(const char* v, ...);
1572 2120
@@ -1575,3 +2123,3 @@ icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v);
1575void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v); 2123void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v);
1576struct icaldatetimeperiodtype icalproperty_get_rdate(icalproperty* prop);icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...); 2124struct icaldatetimeperiodtype icalproperty_get_rdate(const icalproperty* prop);icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...);
1577 2125
@@ -1580,3 +2128,3 @@ icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v);
1580void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v); 2128void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v);
1581struct icaltimetype icalproperty_get_recurrenceid(icalproperty* prop);icalproperty* icalproperty_vanew_relatedto(const char* v, ...); 2129struct icaltimetype icalproperty_get_recurrenceid(const icalproperty* prop);icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...);
1582 2130
@@ -1585,3 +2133,8 @@ icalproperty* icalproperty_new_relatedto(const char* v);
1585void icalproperty_set_relatedto(icalproperty* prop, const char* v); 2133void icalproperty_set_relatedto(icalproperty* prop, const char* v);
1586const char* icalproperty_get_relatedto(icalproperty* prop);icalproperty* icalproperty_vanew_repeat(int v, ...); 2134const char* icalproperty_get_relatedto(const icalproperty* prop);icalproperty* icalproperty_vanew_relatedto(const char* v, ...);
2135
2136/* RELCALID */
2137icalproperty* icalproperty_new_relcalid(const char* v);
2138void icalproperty_set_relcalid(icalproperty* prop, const char* v);
2139const char* icalproperty_get_relcalid(const icalproperty* prop);icalproperty* icalproperty_vanew_relcalid(const char* v, ...);
1587 2140
@@ -1590,3 +2143,3 @@ icalproperty* icalproperty_new_repeat(int v);
1590void icalproperty_set_repeat(icalproperty* prop, int v); 2143void icalproperty_set_repeat(icalproperty* prop, int v);
1591int icalproperty_get_repeat(icalproperty* prop);icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...); 2144int icalproperty_get_repeat(const icalproperty* prop);icalproperty* icalproperty_vanew_repeat(int v, ...);
1592 2145
@@ -1595,3 +2148,3 @@ icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v);
1595void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v); 2148void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v);
1596struct icalreqstattype icalproperty_get_requeststatus(icalproperty* prop);icalproperty* icalproperty_vanew_resources(const char* v, ...); 2149struct icalreqstattype icalproperty_get_requeststatus(const icalproperty* prop);icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...);
1597 2150
@@ -1600,3 +2153,3 @@ icalproperty* icalproperty_new_resources(const char* v);
1600void icalproperty_set_resources(icalproperty* prop, const char* v); 2153void icalproperty_set_resources(icalproperty* prop, const char* v);
1601const char* icalproperty_get_resources(icalproperty* prop);icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...); 2154const char* icalproperty_get_resources(const icalproperty* prop);icalproperty* icalproperty_vanew_resources(const char* v, ...);
1602 2155
@@ -1605,3 +2158,3 @@ icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v);
1605void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v); 2158void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v);
1606struct icalrecurrencetype icalproperty_get_rrule(icalproperty* prop);icalproperty* icalproperty_vanew_scope(const char* v, ...); 2159struct icalrecurrencetype icalproperty_get_rrule(const icalproperty* prop);icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...);
1607 2160
@@ -1610,3 +2163,3 @@ icalproperty* icalproperty_new_scope(const char* v);
1610void icalproperty_set_scope(icalproperty* prop, const char* v); 2163void icalproperty_set_scope(icalproperty* prop, const char* v);
1611const char* icalproperty_get_scope(icalproperty* prop);icalproperty* icalproperty_vanew_sequence(int v, ...); 2164const char* icalproperty_get_scope(const icalproperty* prop);icalproperty* icalproperty_vanew_scope(const char* v, ...);
1612 2165
@@ -1615,3 +2168,3 @@ icalproperty* icalproperty_new_sequence(int v);
1615void icalproperty_set_sequence(icalproperty* prop, int v); 2168void icalproperty_set_sequence(icalproperty* prop, int v);
1616int icalproperty_get_sequence(icalproperty* prop);icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...); 2169int icalproperty_get_sequence(const icalproperty* prop);icalproperty* icalproperty_vanew_sequence(int v, ...);
1617 2170
@@ -1620,3 +2173,3 @@ icalproperty* icalproperty_new_status(enum icalproperty_status v);
1620void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v); 2173void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v);
1621enum icalproperty_status icalproperty_get_status(icalproperty* prop);icalproperty* icalproperty_vanew_summary(const char* v, ...); 2174enum icalproperty_status icalproperty_get_status(const icalproperty* prop);icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...);
1622 2175
@@ -1625,3 +2178,3 @@ icalproperty* icalproperty_new_summary(const char* v);
1625void icalproperty_set_summary(icalproperty* prop, const char* v); 2178void icalproperty_set_summary(icalproperty* prop, const char* v);
1626const char* icalproperty_get_summary(icalproperty* prop);icalproperty* icalproperty_vanew_target(const char* v, ...); 2179const char* icalproperty_get_summary(const icalproperty* prop);icalproperty* icalproperty_vanew_summary(const char* v, ...);
1627 2180
@@ -1630,8 +2183,8 @@ icalproperty* icalproperty_new_target(const char* v);
1630void icalproperty_set_target(icalproperty* prop, const char* v); 2183void icalproperty_set_target(icalproperty* prop, const char* v);
1631const char* icalproperty_get_target(icalproperty* prop);icalproperty* icalproperty_vanew_transp(const char* v, ...); 2184const char* icalproperty_get_target(const icalproperty* prop);icalproperty* icalproperty_vanew_target(const char* v, ...);
1632 2185
1633/* TRANSP */ 2186/* TRANSP */
1634icalproperty* icalproperty_new_transp(const char* v); 2187icalproperty* icalproperty_new_transp(enum icalproperty_transp v);
1635void icalproperty_set_transp(icalproperty* prop, const char* v); 2188void icalproperty_set_transp(icalproperty* prop, enum icalproperty_transp v);
1636const char* icalproperty_get_transp(icalproperty* prop);icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...); 2189enum icalproperty_transp icalproperty_get_transp(const icalproperty* prop);icalproperty* icalproperty_vanew_transp(enum icalproperty_transp v, ...);
1637 2190
@@ -1640,3 +2193,3 @@ icalproperty* icalproperty_new_trigger(struct icaltriggertype v);
1640void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v); 2193void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v);
1641struct icaltriggertype icalproperty_get_trigger(icalproperty* prop);icalproperty* icalproperty_vanew_tzid(const char* v, ...); 2194struct icaltriggertype icalproperty_get_trigger(const icalproperty* prop);icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...);
1642 2195
@@ -1645,3 +2198,3 @@ icalproperty* icalproperty_new_tzid(const char* v);
1645void icalproperty_set_tzid(icalproperty* prop, const char* v); 2198void icalproperty_set_tzid(icalproperty* prop, const char* v);
1646const char* icalproperty_get_tzid(icalproperty* prop);icalproperty* icalproperty_vanew_tzname(const char* v, ...); 2199const char* icalproperty_get_tzid(const icalproperty* prop);icalproperty* icalproperty_vanew_tzid(const char* v, ...);
1647 2200
@@ -1650,3 +2203,3 @@ icalproperty* icalproperty_new_tzname(const char* v);
1650void icalproperty_set_tzname(icalproperty* prop, const char* v); 2203void icalproperty_set_tzname(icalproperty* prop, const char* v);
1651const char* icalproperty_get_tzname(icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...); 2204const char* icalproperty_get_tzname(const icalproperty* prop);icalproperty* icalproperty_vanew_tzname(const char* v, ...);
1652 2205
@@ -1655,3 +2208,3 @@ icalproperty* icalproperty_new_tzoffsetfrom(int v);
1655void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v); 2208void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v);
1656int icalproperty_get_tzoffsetfrom(icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetto(int v, ...); 2209int icalproperty_get_tzoffsetfrom(const icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...);
1657 2210
@@ -1660,3 +2213,3 @@ icalproperty* icalproperty_new_tzoffsetto(int v);
1660void icalproperty_set_tzoffsetto(icalproperty* prop, int v); 2213void icalproperty_set_tzoffsetto(icalproperty* prop, int v);
1661int icalproperty_get_tzoffsetto(icalproperty* prop);icalproperty* icalproperty_vanew_tzurl(const char* v, ...); 2214int icalproperty_get_tzoffsetto(const icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetto(int v, ...);
1662 2215
@@ -1665,3 +2218,3 @@ icalproperty* icalproperty_new_tzurl(const char* v);
1665void icalproperty_set_tzurl(icalproperty* prop, const char* v); 2218void icalproperty_set_tzurl(icalproperty* prop, const char* v);
1666const char* icalproperty_get_tzurl(icalproperty* prop);icalproperty* icalproperty_vanew_uid(const char* v, ...); 2219const char* icalproperty_get_tzurl(const icalproperty* prop);icalproperty* icalproperty_vanew_tzurl(const char* v, ...);
1667 2220
@@ -1670,3 +2223,3 @@ icalproperty* icalproperty_new_uid(const char* v);
1670void icalproperty_set_uid(icalproperty* prop, const char* v); 2223void icalproperty_set_uid(icalproperty* prop, const char* v);
1671const char* icalproperty_get_uid(icalproperty* prop);icalproperty* icalproperty_vanew_url(const char* v, ...); 2224const char* icalproperty_get_uid(const icalproperty* prop);icalproperty* icalproperty_vanew_uid(const char* v, ...);
1672 2225
@@ -1675,3 +2228,3 @@ icalproperty* icalproperty_new_url(const char* v);
1675void icalproperty_set_url(icalproperty* prop, const char* v); 2228void icalproperty_set_url(icalproperty* prop, const char* v);
1676const char* icalproperty_get_url(icalproperty* prop);icalproperty* icalproperty_vanew_version(const char* v, ...); 2229const char* icalproperty_get_url(const icalproperty* prop);icalproperty* icalproperty_vanew_url(const char* v, ...);
1677 2230
@@ -1680,3 +2233,3 @@ icalproperty* icalproperty_new_version(const char* v);
1680void icalproperty_set_version(icalproperty* prop, const char* v); 2233void icalproperty_set_version(icalproperty* prop, const char* v);
1681const char* icalproperty_get_version(icalproperty* prop);icalproperty* icalproperty_vanew_x(const char* v, ...); 2234const char* icalproperty_get_version(const icalproperty* prop);icalproperty* icalproperty_vanew_version(const char* v, ...);
1682 2235
@@ -1685,3 +2238,8 @@ icalproperty* icalproperty_new_x(const char* v);
1685void icalproperty_set_x(icalproperty* prop, const char* v); 2238void icalproperty_set_x(icalproperty* prop, const char* v);
1686const char* icalproperty_get_x(icalproperty* prop);icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...); 2239const char* icalproperty_get_x(const icalproperty* prop);icalproperty* icalproperty_vanew_x(const char* v, ...);
2240
2241/* X-LIC-CLASS */
2242icalproperty* icalproperty_new_xlicclass(enum icalproperty_xlicclass v);
2243void icalproperty_set_xlicclass(icalproperty* prop, enum icalproperty_xlicclass v);
2244enum icalproperty_xlicclass icalproperty_get_xlicclass(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicclass(enum icalproperty_xlicclass v, ...);
1687 2245
@@ -1690,3 +2248,3 @@ icalproperty* icalproperty_new_xlicclustercount(const char* v);
1690void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v); 2248void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v);
1691const char* icalproperty_get_xlicclustercount(icalproperty* prop);icalproperty* icalproperty_vanew_xlicerror(const char* v, ...); 2249const char* icalproperty_get_xlicclustercount(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...);
1692 2250
@@ -1695,3 +2253,3 @@ icalproperty* icalproperty_new_xlicerror(const char* v);
1695void icalproperty_set_xlicerror(icalproperty* prop, const char* v); 2253void icalproperty_set_xlicerror(icalproperty* prop, const char* v);
1696const char* icalproperty_get_xlicerror(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...); 2254const char* icalproperty_get_xlicerror(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicerror(const char* v, ...);
1697 2255
@@ -1700,3 +2258,3 @@ icalproperty* icalproperty_new_xlicmimecharset(const char* v);
1700void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v); 2258void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v);
1701const char* icalproperty_get_xlicmimecharset(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...); 2259const char* icalproperty_get_xlicmimecharset(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...);
1702 2260
@@ -1705,3 +2263,3 @@ icalproperty* icalproperty_new_xlicmimecid(const char* v);
1705void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v); 2263void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v);
1706const char* icalproperty_get_xlicmimecid(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...); 2264const char* icalproperty_get_xlicmimecid(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...);
1707 2265
@@ -1710,3 +2268,3 @@ icalproperty* icalproperty_new_xlicmimecontenttype(const char* v);
1710void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v); 2268void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v);
1711const char* icalproperty_get_xlicmimecontenttype(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...); 2269const char* icalproperty_get_xlicmimecontenttype(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...);
1712 2270
@@ -1715,3 +2273,3 @@ icalproperty* icalproperty_new_xlicmimeencoding(const char* v);
1715void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v); 2273void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v);
1716const char* icalproperty_get_xlicmimeencoding(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...); 2274const char* icalproperty_get_xlicmimeencoding(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...);
1717 2275
@@ -1720,3 +2278,3 @@ icalproperty* icalproperty_new_xlicmimefilename(const char* v);
1720void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v); 2278void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v);
1721const char* icalproperty_get_xlicmimefilename(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...); 2279const char* icalproperty_get_xlicmimefilename(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...);
1722 2280
@@ -1725,150 +2283,6 @@ icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v);
1725void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v); 2283void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v);
1726const char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop); 2284const char* icalproperty_get_xlicmimeoptinfo(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...);
1727
1728#endif /*ICALPROPERTY_H*/
1729/* -*- Mode: C -*- */
1730/*======================================================================
1731 FILE: icalvalue.h
1732 CREATOR: eric 20 March 1999
1733
1734
1735 $Id$
1736 $Locker$
1737
1738
1739
1740 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1741
1742 This program is free software; you can redistribute it and/or modify
1743 it under the terms of either:
1744
1745 The LGPL as published by the Free Software Foundation, version
1746 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1747
1748 Or:
1749
1750 The Mozilla Public License Version 1.0. You may obtain a copy of
1751 the License at http://www.mozilla.org/MPL/
1752
1753 The original code is icalvalue.h
1754
1755 ======================================================================*/
1756
1757#ifndef ICALVALUE_H
1758#define ICALVALUE_H
1759
1760#include <time.h>
1761
1762/* Defined in icalderivedvalue.h */
1763/*typedef void icalvalue;*/
1764
1765icalvalue* icalvalue_new(icalvalue_kind kind);
1766
1767icalvalue* icalvalue_new_clone(icalvalue* value);
1768
1769icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str);
1770
1771void icalvalue_free(icalvalue* value);
1772
1773int icalvalue_is_valid(icalvalue* value);
1774
1775const char* icalvalue_as_ical_string(icalvalue* value);
1776
1777icalvalue_kind icalvalue_isa(icalvalue* value);
1778
1779int icalvalue_isa_value(void*);
1780
1781icalparameter_xliccomparetype icalvalue_compare(icalvalue* a, icalvalue *b);
1782
1783
1784/* Special, non autogenerated value accessors */
1785
1786icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
1787void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
1788struct icalrecurrencetype icalvalue_get_recur(icalvalue* value);
1789
1790icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
1791void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
1792struct icaltriggertype icalvalue_get_trigger(icalvalue* value);
1793
1794icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
1795void icalvalue_set_datetimeperiod(icalvalue* value,
1796 struct icaldatetimeperiodtype v);
1797struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value);
1798
1799/* Convert enumerations */
1800
1801icalvalue_kind icalvalue_string_to_kind(const char* str);
1802const char* icalvalue_kind_to_string(icalvalue_kind kind);
1803
1804
1805#endif /*ICALVALUE_H*/
1806/* -*- Mode: C -*- */
1807/*======================================================================
1808 FILE: icalparam.h
1809 CREATOR: eric 20 March 1999
1810
1811
1812 $Id$
1813 $Locker$
1814
1815
1816
1817 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1818
1819 This program is free software; you can redistribute it and/or modify
1820 it under the terms of either:
1821
1822 The LGPL as published by the Free Software Foundation, version
1823 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1824
1825 Or:
1826
1827 The Mozilla Public License Version 1.0. You may obtain a copy of
1828 the License at http://www.mozilla.org/MPL/
1829
1830 The original code is icalparam.h
1831
1832 ======================================================================*/
1833
1834#ifndef ICALPARAM_H
1835#define ICALPARAM_H
1836
1837
1838/* Declared in icalderivedparameter.h */
1839/*typedef void icalparameter;*/
1840 2285
1841icalparameter* icalparameter_new(icalparameter_kind kind);
1842icalparameter* icalparameter_new_clone(icalparameter* p);
1843
1844/* Create from string of form "PARAMNAME=VALUE" */
1845icalparameter* icalparameter_new_from_string(const char* value);
1846
1847/* Create from just the value, the part after the "=" */
1848icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind, const char* value);
1849
1850void icalparameter_free(icalparameter* parameter);
1851
1852char* icalparameter_as_ical_string(icalparameter* parameter);
1853
1854int icalparameter_is_valid(icalparameter* parameter);
1855
1856icalparameter_kind icalparameter_isa(icalparameter* parameter);
1857
1858int icalparameter_isa_parameter(void* param);
1859
1860/* Acess the name of an X parameer */
1861void icalparameter_set_xname (icalparameter* param, const char* v);
1862const char* icalparameter_get_xname(icalparameter* param);
1863void icalparameter_set_xvalue (icalparameter* param, const char* v);
1864const char* icalparameter_get_xvalue(icalparameter* param);
1865
1866/* Convert enumerations */
1867 2286
1868const char* icalparameter_kind_to_string(icalparameter_kind kind); 2287#endif /*ICALPROPERTY_H*/
1869icalparameter_kind icalparameter_string_to_kind(const char* string);
1870
1871
1872
1873#endif
1874/* -*- Mode: C -*- */ 2288/* -*- Mode: C -*- */
@@ -1879,4 +2293,2 @@ icalparameter_kind icalparameter_string_to_kind(const char* string);
1879 2293
1880 $Id$
1881 $Locker$
1882 2294
@@ -1906,3 +2318,3 @@ icalparameter_kind icalparameter_string_to_kind(const char* string);
1906#include <time.h> 2318#include <time.h>
1907 2319#include <stdarg.h> /* for va_... */
1908 2320
@@ -1911,3 +2323,3 @@ icalparameter_kind icalparameter_string_to_kind(const char* string);
1911/* Actually in icalderivedproperty.h: 2323/* Actually in icalderivedproperty.h:
1912 typedef void icalproperty; */ 2324 typedef struct icalproperty_impl icalproperty; */
1913 2325
@@ -1927,2 +2339,3 @@ int icalproperty_isa_property(void* property);
1927 2339
2340void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
1928void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter); 2341void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter);
@@ -1937,3 +2350,14 @@ void icalproperty_remove_parameter(icalproperty* prop,
1937 2350
1938int icalproperty_count_parameters(icalproperty* prop); 2351void icalproperty_remove_parameter_by_kind(icalproperty* prop,
2352 icalparameter_kind kind);
2353
2354void icalproperty_remove_parameter_by_name(icalproperty* prop,
2355 const char *name);
2356
2357void icalproperty_remove_parameter_by_ref(icalproperty* prop,
2358 icalparameter *param);
2359
2360
2361
2362int icalproperty_count_parameters(const icalproperty* prop);
1939 2363
@@ -1948,4 +2372,4 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* value, co
1948 2372
1949icalvalue* icalproperty_get_value(icalproperty* prop); 2373icalvalue* icalproperty_get_value(const icalproperty* prop);
1950const char* icalproperty_get_value_as_string(icalproperty* prop); 2374const char* icalproperty_get_value_as_string(const icalproperty* prop);
1951 2375
@@ -1956,5 +2380,7 @@ const char* icalproperty_get_x_name(icalproperty* prop);
1956 2380
1957/* Return the name of the property -- the type name converted to a 2381/** Return the name of the property -- the type name converted to a
1958 string, or the value of _get_x_name if the type is and X property */ 2382 * string, or the value of _get_x_name if the type is and X
1959const char* icalproperty_get_name (icalproperty* prop); 2383 * property
2384 */
2385const char* icalproperty_get_property_name (const icalproperty* prop);
1960 2386
@@ -1965,3 +2391,3 @@ icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
1965icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind); 2391icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);
1966icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind); 2392icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind);
1967const char* icalproperty_kind_to_string(icalproperty_kind kind); 2393const char* icalproperty_kind_to_string(icalproperty_kind kind);
@@ -1969,2 +2395,5 @@ icalproperty_kind icalproperty_string_to_kind(const char* string);
1969 2395
2396/** Check validity of a specific icalproperty_kind **/
2397int icalproperty_kind_is_valid(const icalproperty_kind kind);
2398
1970icalproperty_method icalproperty_string_to_method(const char* str); 2399icalproperty_method icalproperty_string_to_method(const char* str);
@@ -1975,2 +2404,3 @@ const char* icalproperty_enum_to_string(int e);
1975int icalproperty_string_to_enum(const char* str); 2404int icalproperty_string_to_enum(const char* str);
2405int icalproperty_kind_and_string_to_enum(const int kind, const char* str);
1976 2406
@@ -1985,64 +2415,2 @@ int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e);
1985#endif /*ICALPROPERTY_H*/ 2415#endif /*ICALPROPERTY_H*/
1986/* -*- Mode: C -*- */
1987/*======================================================================
1988 FILE: icalattendee.h
1989 CREATOR: eric 8 Mar 01
1990
1991
1992 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1993
1994 This program is free software; you can redistribute it and/or modify
1995 it under the terms of either:
1996
1997 The LGPL as published by the Free Software Foundation, version
1998 2.1, available at: http://www.fsf.org/copyleft/lesser.html
1999
2000 Or:
2001
2002 The Mozilla Public License Version 1.0. You may obtain a copy of
2003 the License at http://www.mozilla.org/MPL/
2004
2005 The original code is icaltypes.h
2006
2007======================================================================*/
2008
2009#ifndef ICALATTENDEE_H
2010#define ICALATTENDEE_H
2011
2012#include <time.h>
2013
2014struct icalorganizertype {
2015 const char* value;
2016 const char* common_name;
2017 const char* dir;
2018 const char* sentby;
2019 const char* language;
2020
2021};
2022
2023/* Create a copy of the given organizer. Libical will not own the
2024 memory for the strings in the copy; the call must free them */
2025struct icalorganizertype icalorganizertype_new_clone(struct icalorganizertype a);
2026
2027
2028struct icalattendeetype {
2029 const char* cuid; /* Cal user id, contents of the property value */
2030 /*icalparameter_cutype cutype;*/
2031 const char* member;
2032 /*icalparameter_role role;*/
2033 int rsvp;
2034 const char* delto;
2035 const char* delfrom;
2036 const char* sentby;
2037 const char* cn;
2038 const char* dir;
2039 const char* language;
2040};
2041
2042/* Create a copy of the given attendee. Libical will not own the
2043 memory for the strings in the copy; the call must free them */
2044struct icalattendeetype icalattendeetype_new_clone(struct icalattendeetype a);
2045
2046
2047#endif /* !ICALATTENDEE_H */
2048/*====================================================================== 2416/*======================================================================
@@ -2059,19 +2427,17 @@ struct icalattendeetype icalattendeetype_new_clone(struct icalattendeetype a);
2059 2427
2060typedef void* pvl_list; 2428typedef struct pvl_list_t* pvl_list;
2061typedef void* pvl_elem; 2429typedef struct pvl_elem_t* pvl_elem;
2062 2430
2063/* 2431/**
2064 struct pvl_elem_t 2432 * This type is private. Always use pvl_elem instead. The struct would
2065 2433 * not even appear in this header except to make code in the USE_MACROS
2066 This type is private. Always use pvl_elem instead. The struct would 2434 * blocks work
2067 not even appear in this header except to make code in the USE_MACROS 2435 */
2068 blocks work
2069 2436
2070 */
2071typedef struct pvl_elem_t 2437typedef struct pvl_elem_t
2072{ 2438{
2073 int MAGIC; /* Magic Identifier */ 2439 int MAGIC; /**< Magic Identifier */
2074 void *d; /* Pointer to data user is storing */ 2440 void *d; /**< Pointer to data user is storing */
2075 struct pvl_elem_t *next;/* Next element */ 2441 struct pvl_elem_t *next;/**< Next element */
2076 struct pvl_elem_t *prior;/* prior element */ 2442 struct pvl_elem_t *prior;/**< Prior element */
2077} pvl_elem_t; 2443} pvl_elem_t;
@@ -2080,4 +2446,6 @@ typedef struct pvl_elem_t
2080 2446
2081/* This global is incremented for each call to pvl_new_element(); it gives each 2447/**
2082 * list a unique identifer */ 2448 * This global is incremented for each call to pvl_new_element(); it gives each
2449 * list a unique identifer
2450 */
2083 2451
@@ -2130,4 +2498,7 @@ pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v);
2130 2498
2131/* Pass each element in the list to a function */ 2499/**
2132typedef void (*pvl_applyf)(void* a, void* b); /*a is list elem, b is other data*/ 2500 * Pass each element in the list to a function
2501 * a is list elem, b is other data
2502 */
2503typedef void (*pvl_applyf)(void* a, void* b);
2133void pvl_apply(pvl_list l,pvl_applyf f, void *v); 2504void pvl_apply(pvl_list l,pvl_applyf f, void *v);
@@ -2141,2 +2512,63 @@ void pvl_apply(pvl_list l,pvl_applyf f, void *v);
2141 2512
2513/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2514/*======================================================================
2515 FILE: icalarray.h
2516 CREATOR: Damon Chaplin 07 March 2001
2517
2518
2519
2520 (C) COPYRIGHT 2001, Ximian, Inc.
2521
2522 This program is free software; you can redistribute it and/or modify
2523 it under the terms of either:
2524
2525 The LGPL as published by the Free Software Foundation, version
2526 2.1, available at: http://www.fsf.org/copyleft/lesser.html
2527
2528 Or:
2529
2530 The Mozilla Public License Version 1.0. You may obtain a copy of
2531 the License at http://www.mozilla.org/MPL/
2532
2533
2534======================================================================*/
2535
2536
2537#ifndef ICALARRAY_H
2538#define ICALARRAY_H
2539
2540/** @file icalarray.h
2541 *
2542 * @brief An array of arbitrarily-sized elements which grows
2543 * dynamically as elements are added.
2544 */
2545
2546typedef struct _icalarray icalarray;
2547struct _icalarray {
2548 unsigned int element_size;
2549 unsigned int increment_size;
2550 unsigned int num_elements;
2551 unsigned int space_allocated;
2552 void *data;
2553};
2554
2555
2556
2557 icalarray *icalarray_new (int element_size,
2558 int increment_size);
2559 void icalarray_free (icalarray*array);
2560
2561 void icalarray_append (icalarray*array,
2562 void *element);
2563 void icalarray_remove_element_at (icalarray*array,
2564 int position);
2565
2566 void *icalarray_element_at (icalarray*array,
2567 int position);
2568
2569 void icalarray_sort (icalarray*array,
2570 int (*compare) (const void *, const void *));
2571
2572
2573#endif /* ICALARRAY_H */
2142/* -*- Mode: C -*- */ 2574/* -*- Mode: C -*- */
@@ -2168,3 +2600,12 @@ void pvl_apply(pvl_list l,pvl_applyf f, void *v);
2168 2600
2169typedef void icalcomponent; 2601typedef struct icalcomponent_impl icalcomponent;
2602
2603#ifndef ICALTIMEZONE_DEFINED
2604#define ICALTIMEZONE_DEFINED
2605/** @brief An opaque struct representing a timezone.
2606 * We declare this here to avoid a circular dependancy.
2607 */
2608 typedef struct _icaltimezone icaltimezone;
2609#endif
2610
2170 2611
@@ -2189,3 +2630,3 @@ int icalcomponent_is_valid(icalcomponent* component);
2189 2630
2190icalcomponent_kind icalcomponent_isa(icalcomponent* component); 2631icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
2191 2632
@@ -2235,2 +2676,10 @@ int icalcomponent_count_components(icalcomponent* component,
2235 2676
2677/**
2678 This takes 2 VCALENDAR components and merges the second one into the first,
2679 resolving any problems with conflicting TZIDs. comp_to_merge will no
2680 longer exist after calling this function. */
2681void icalcomponent_merge_component(icalcomponent* comp,
2682 icalcomponent* comp_to_merge);
2683
2684
2236/* Iteration Routines. There are two forms of iterators, internal and 2685/* Iteration Routines. There are two forms of iterators, internal and
@@ -2259,12 +2708,16 @@ icalcomponent* icalcompiter_deref(icalcompiter* i);
2259 2708
2709/* Working with embedded error properties */
2260 2710
2261 2711
2712/* Check the component against itip rules and insert error properties*/
2262/* Working with embedded error properties */ 2713/* Working with embedded error properties */
2714int icalcomponent_check_restrictions(icalcomponent* comp);
2263 2715
2716/** Count embedded errors. */
2264int icalcomponent_count_errors(icalcomponent* component); 2717int icalcomponent_count_errors(icalcomponent* component);
2265 2718
2266/* Remove all X-LIC-ERROR properties*/ 2719/** Remove all X-LIC-ERROR properties*/
2267void icalcomponent_strip_errors(icalcomponent* component); 2720void icalcomponent_strip_errors(icalcomponent* component);
2268 2721
2269/* Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/ 2722/** Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
2270void icalcomponent_convert_errors(icalcomponent* component); 2723void icalcomponent_convert_errors(icalcomponent* component);
@@ -2276,3 +2729,5 @@ void icalcomponent_set_parent(icalcomponent* component,
2276 2729
2277/* Kind conversion routiens */ 2730/* Kind conversion routines */
2731
2732int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
2278 2733
@@ -2289,3 +2744,3 @@ wrong component subtypes. */
2289 2744
2290/* For VCOMPONENT: Return a reference to the first VEVENT, VTODO or 2745/** For VCOMPONENT: Return a reference to the first VEVENT, VTODO or
2291 VJOURNAL */ 2746 VJOURNAL */
@@ -2293,3 +2748,3 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c);
2293 2748
2294/* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end 2749/** For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
2295 times of an event in UTC */ 2750 times of an event in UTC */
@@ -2315,2 +2770,5 @@ void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
2315 2770
2771struct icaltimetype icalcomponent_get_due(icalcomponent* comp);
2772void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v);
2773
2316void icalcomponent_set_duration(icalcomponent* comp, 2774void icalcomponent_set_duration(icalcomponent* comp,
@@ -2325,3 +2783,2 @@ void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v);
2325 2783
2326
2327void icalcomponent_set_summary(icalcomponent* comp, const char* v); 2784void icalcomponent_set_summary(icalcomponent* comp, const char* v);
@@ -2335,2 +2792,5 @@ const char* icalcomponent_get_uid(icalcomponent* comp);
2335 2792
2793void icalcomponent_set_relcalid(icalcomponent* comp, const char* v);
2794const char* icalcomponent_get_relcalid(icalcomponent* comp);
2795
2336void icalcomponent_set_recurrenceid(icalcomponent* comp, 2796void icalcomponent_set_recurrenceid(icalcomponent* comp,
@@ -2339,19 +2799,37 @@ struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
2339 2799
2800void icalcomponent_set_description(icalcomponent* comp, const char* v);
2801const char* icalcomponent_get_description(icalcomponent* comp);
2340 2802
2341void icalcomponent_set_organizer(icalcomponent* comp, 2803void icalcomponent_set_location(icalcomponent* comp, const char* v);
2342 struct icalorganizertype org); 2804const char* icalcomponent_get_location(icalcomponent* comp);
2343 struct icalorganizertype icalcomponent_get_organizer(icalcomponent* comp);
2344 2805
2806void icalcomponent_set_sequence(icalcomponent* comp, int v);
2807int icalcomponent_get_sequence(icalcomponent* comp);
2345 2808
2346void icalcomponent_add_attendee(icalcomponent *comp, 2809void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v);
2347 struct icalattendeetype attendee); 2810enum icalproperty_status icalcomponent_get_status(icalcomponent* comp);
2348 2811
2349int icalcomponent_remove_attendee(icalcomponent *comp, char* cuid);
2350 2812
2351/* Get the Nth attendee. Out of range indices return an attendee 2813/** Calls the given function for each TZID parameter found in the
2352 with cuid == 0 */ 2814 component, and any subcomponents. */
2353struct icalattendeetype icalcomponent_get_attendee(icalcomponent *comp, 2815void icalcomponent_foreach_tzid(icalcomponent* comp,
2354 int index); 2816 void (*callback)(icalparameter *param, void *data),
2817 void *callback_data);
2355 2818
2819/** Returns the icaltimezone in the component corresponding to the
2820 TZID, or NULL if it can't be found. */
2821icaltimezone* icalcomponent_get_timezone(icalcomponent* comp,
2822 const char *tzid);
2356 2823
2824int icalproperty_recurrence_is_excluded(icalcomponent *comp,
2825 struct icaltimetype *dtstart,
2826 struct icaltimetype *recurtime);
2827
2828void icalcomponent_foreach_recurrence(icalcomponent* comp,
2829 struct icaltimetype start,
2830 struct icaltimetype end,
2831 void (*callback)(icalcomponent *comp,
2832 struct icaltime_span *span,
2833 void *data),
2834 void *callback_data);
2357 2835
@@ -2369,9 +2847,168 @@ icalcomponent* icalcomponent_new_xstandard();
2369icalcomponent* icalcomponent_new_xdaylight(); 2847icalcomponent* icalcomponent_new_xdaylight();
2848icalcomponent* icalcomponent_new_vagenda();
2849icalcomponent* icalcomponent_new_vquery();
2370 2850
2851#endif /* !ICALCOMPONENT_H */
2852/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2853/*======================================================================
2854 FILE: icaltimezone.h
2855 CREATOR: Damon Chaplin 15 March 2001
2371 2856
2372 2857
2373#endif /* !ICALCOMPONENT_H */
2374 2858
2859 (C) COPYRIGHT 2001, Damon Chaplin
2860
2861 This program is free software; you can redistribute it and/or modify
2862 it under the terms of either:
2863
2864 The LGPL as published by the Free Software Foundation, version
2865 2.1, available at: http://www.fsf.org/copyleft/lesser.html
2866
2867 Or:
2868
2869 The Mozilla Public License Version 1.0. You may obtain a copy of
2870 the License at http://www.mozilla.org/MPL/
2871
2872
2873======================================================================*/
2874/**
2875 * @file icaltimezone.h
2876 * @brief timezone handling routines
2877 */
2878
2879#ifndef ICALTIMEZONE_H
2880#define ICALTIMEZONE_H
2881
2882#include <stdio.h> /* For FILE* */
2883
2884
2885#ifndef ICALTIMEZONE_DEFINED
2886#define ICALTIMEZONE_DEFINED
2887/** @brief An opaque struct representing a timezone.
2888 * We declare this here to avoid a circular dependancy.
2889 */
2890 typedef struct _icaltimezone icaltimezone;
2891#endif
2892
2893/**
2894 * @par Creating/Destroying individual icaltimezones.
2895 */
2896
2897/** Creates a new icaltimezone. */
2898 icaltimezone *icaltimezone_new (void);
2899
2900/** Frees all memory used for the icaltimezone. Set free_struct to free the
2901 icaltimezone struct as well. */
2902 void icaltimezone_free (icaltimezone *zone,
2903 int free_struct);
2904
2905
2906/**
2907 * @par Accessing timezones.
2908 */
2909
2910/** Free any builtin timezone information **/
2911void icaltimezone_free_builtin_timezones(void);
2912
2913/** Returns the array of builtin icaltimezones. */
2914 icalarray* icaltimezone_get_builtin_timezones(void);
2375 2915
2916/** Returns a single builtin timezone, given its Olson city name. */
2917 icaltimezone* icaltimezone_get_builtin_timezone(const char *location);
2376 2918
2919/** Returns a single builtin timezone, given its TZID. */
2920icaltimezone* icaltimezone_get_builtin_timezone_from_tzid (const char *tzid);
2921
2922/** Returns the UTC timezone. */
2923 icaltimezone* icaltimezone_get_utc_timezone(void);
2924
2925/** Returns the TZID of a timezone. */
2926 char* icaltimezone_get_tzid (icaltimezone*zone);
2927
2928/** Returns the city name of a timezone. */
2929 char* icaltimezone_get_location (icaltimezone*zone);
2930
2931/** Returns the TZNAME properties used in the latest STANDARD and DAYLIGHT
2932 components. If they are the same it will return just one, e.g. "LMT".
2933 If they are different it will format them like "EST/EDT". Note that this
2934 may also return NULL. */
2935 char* icaltimezone_get_tznames (icaltimezone*zone);
2936
2937/** Returns the latitude of a builtin timezone. */
2938 double icaltimezone_get_latitude (icaltimezone*zone);
2939
2940/** Returns the longitude of a builtin timezone. */
2941 double icaltimezone_get_longitude (icaltimezone*zone);
2942
2943/** Returns the VTIMEZONE component of a timezone. */
2944 icalcomponent* icaltimezone_get_component (icaltimezone*zone);
2945
2946/** Sets the VTIMEZONE component of an icaltimezone, initializing the tzid,
2947 location & tzname fields. It returns 1 on success or 0 on failure, i.e.
2948 no TZID was found. */
2949 int icaltimezone_set_component (icaltimezone*zone,
2950 icalcomponent*comp);
2951
2952/**
2953 * @par Converting times between timezones.
2954 */
2955
2956 void icaltimezone_convert_time (struct icaltimetype *tt,
2957 icaltimezone*from_zone,
2958 icaltimezone*to_zone);
2959
2960
2961/**
2962 * @par Getting offsets from UTC.
2963 */
2964
2965/** Calculates the UTC offset of a given local time in the given
2966 timezone. It is the number of seconds to add to UTC to get local
2967 time. The is_daylight flag is set to 1 if the time is in
2968 daylight-savings time. */
2969 int icaltimezone_get_utc_offset (icaltimezone*zone,
2970 struct icaltimetype *tt,
2971 int *is_daylight);
2972
2973/** Calculates the UTC offset of a given UTC time in the given
2974 timezone. It is the number of seconds to add to UTC to get local
2975 time. The is_daylight flag is set to 1 if the time is in
2976 daylight-savings time. */
2977 int icaltimezone_get_utc_offset_of_utc_time (icaltimezone*zone,
2978 struct icaltimetype *tt,
2979 int *is_daylight);
2980
2981
2982
2983/*
2984 * Handling arrays of timezones. Mainly for internal use.
2985 */
2986 icalarray* icaltimezone_array_new (void);
2987
2988 void icaltimezone_array_append_from_vtimezone (icalarray *timezones,
2989 icalcomponent *child);
2990 void icaltimezone_array_free (icalarray*timezones);
2991
2992
2993/*
2994 * @par Handling the default location the timezone files
2995 */
2996
2997/** Set the directory to look for the zonefiles */
2998void set_zone_directory(char *path);
2999
3000/** Free memory dedicated to the zonefile directory */
3001void free_zone_directory(void);
3002
3003/*
3004 * @par Debugging Output.
3005 */
3006
3007/** Dumps information about changes in the timezone up to and including
3008 max_year. */
3009 int icaltimezone_dump_changes (icaltimezone*zone,
3010 int max_year,
3011 FILE *fp);
3012
3013#endif /* ICALTIMEZONE_H */
2377/* -*- Mode: C -*- */ 3014/* -*- Mode: C -*- */
@@ -2381,3 +3018,2 @@ icalcomponent* icalcomponent_new_xdaylight();
2381 3018
2382 $Id$
2383 3019
@@ -2408,12 +3044,13 @@ icalcomponent* icalcomponent_new_xdaylight();
2408 3044
2409typedef void* icalparser; 3045typedef struct icalparser_impl icalparser;
2410 3046
2411 3047
2412/*********************************************************************** 3048/**
2413 * Line-oriented parsing. 3049 * @file icalparser.h
3050 * @brief Line-oriented parsing.
2414 * 3051 *
2415 * Create a new parser via icalparse_new_parser, then add ines one at 3052 * Create a new parser via icalparse_new_parser, then add lines one at
2416 * a time with icalparse_add_line(). icalparser_add_line() will return 3053 * a time with icalparse_add_line(). icalparser_add_line() will return
2417 * non-zero when it has finished with a component. 3054 * non-zero when it has finished with a component.
2418 ***********************************************************************/ 3055 */
2419 3056
@@ -2434,3 +3071,3 @@ void icalparser_free(icalparser* parser);
2434 3071
2435/*********************************************************************** 3072/**
2436 * Message oriented parsing. icalparser_parse takes a string that 3073 * Message oriented parsing. icalparser_parse takes a string that
@@ -2439,9 +3076,11 @@ void icalparser_free(icalparser* parser);
2439 * pointer to a function that returns one content line per invocation 3076 * pointer to a function that returns one content line per invocation
2440 **********************************************************************/ 3077 */
2441 3078
2442icalcomponent* icalparser_parse(icalparser *parser, 3079icalcomponent* icalparser_parse(icalparser *parser,
2443 char* (*line_gen_func)(char *s, size_t size, void *d)); 3080 char* (*line_gen_func)(char *s, size_t size, void *d));
2444 3081
2445/* Set the data that icalparser_parse will give to the line_gen_func 3082/**
2446 as the parameter 'd'*/ 3083 Set the data that icalparser_parse will give to the line_gen_func
3084 as the parameter 'd'
3085 */
2447void icalparser_set_gen_data(icalparser* parser, void* data); 3086void icalparser_set_gen_data(icalparser* parser, void* data);
@@ -2456,3 +3095,3 @@ icalcomponent* icalparser_parse_string(const char* str);
2456 3095
2457/* Use the flex/bison parser to turn a string into a value type */ 3096/** Use the flex/bison parser to turn a string into a value type */
2458icalvalue* icalparser_parse_value(icalvalue_kind kind, 3097icalvalue* icalparser_parse_value(icalvalue_kind kind,
@@ -2460,6 +3099,6 @@ icalvalue* icalparser_parse_value(icalvalue_kind kind,
2460 3099
2461/* Given a line generator function, return a single iCal content line.*/ 3100/** Given a line generator function, return a single iCal content line.*/
2462char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d)); 3101char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
2463 3102
2464char* string_line_generator(char *out, size_t buf_size, void *d); 3103char* icalparser_string_line_generator(char *out, size_t buf_size, void *d);
2465 3104
@@ -2472,4 +3111,2 @@ char* string_line_generator(char *out, size_t buf_size, void *d);
2472 3111
2473 $Id$
2474 $Locker$
2475 3112
@@ -2494,4 +3131,7 @@ char* string_line_generator(char *out, size_t buf_size, void *d);
2494 3131
3132#ifndef WIN32
2495#include <sys/types.h> /* for size_t */ 3133#include <sys/types.h> /* for size_t */
2496 3134#else
3135#include <stddef.h>
3136#endif
2497 3137
@@ -2503,3 +3143,3 @@ char* icalmemory_tmp_copy(const char* str);
2503 3143
2504/* Add an externally allocated buffer to the ring. */ 3144/** Add an externally allocated buffer to the ring. */
2505void icalmemory_add_tmp_buffer(void*); 3145void icalmemory_add_tmp_buffer(void*);
@@ -2507,3 +3147,3 @@ void icalmemory_add_tmp_buffer(void*);
2507 3147
2508/* Free all memory used in the ring */ 3148/** Free all memory used in the ring */
2509void icalmemory_free_ring(void); 3149void icalmemory_free_ring(void);
@@ -2518,3 +3158,4 @@ void icalmemory_free_buffer(void* buf);
2518 3158
2519/* icalmemory_append_string will copy the string 'string' to the 3159/**
3160 icalmemory_append_string will copy the string 'string' to the
2520 buffer 'buf' starting at position 'pos', reallocing 'buf' if it is 3161 buffer 'buf' starting at position 'pos', reallocing 'buf' if it is
@@ -2534,3 +3175,3 @@ void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
2534 3175
2535/* icalmemory_append_char is similar, but is appends a character instead of a string */ 3176/** icalmemory_append_char is similar, but is appends a character instead of a string */
2536void icalmemory_append_char(char** buf, char** pos, size_t* buf_size, 3177void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
@@ -2538,4 +3179,4 @@ void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
2538 3179
2539/* A wrapper around strdup. Partly to trap calls to strdup, partly 3180/** A wrapper around strdup. Partly to trap calls to strdup, partly
2540 because in -ansi, gcc on Red Hat claims that strudup is undeclared */ 3181 because in -ansi, gcc on Red Hat claims that strdup is undeclared */
2541char* icalmemory_strdup(const char *s); 3182char* icalmemory_strdup(const char *s);
@@ -2551,3 +3192,2 @@ char* icalmemory_strdup(const char *s);
2551 3192
2552 $Id$
2553 3193
@@ -2580,3 +3220,2 @@ char* icalmemory_strdup(const char *s);
2580#ifdef HAVE_CONFIG_H 3220#ifdef HAVE_CONFIG_H
2581#include "config.h"
2582#endif 3221#endif
@@ -2586,3 +3225,3 @@ char* icalmemory_strdup(const char *s);
2586 3225
2587/* This routine is called before any error is triggered. It is called 3226/** This routine is called before any error is triggered. It is called
2588 by icalerror_set_errno, so it does not appear in all of the macros 3227 by icalerror_set_errno, so it does not appear in all of the macros
@@ -2594,3 +3233,3 @@ void icalerror_crash_here(void);
2594typedef enum icalerrorenum { 3233typedef enum icalerrorenum {
2595 3234 ICAL_NO_ERROR, /* icalerrno may not be initialized - put it first so and pray that the compiler initialize things to zero */
2596 ICAL_BADARG_ERROR, 3235 ICAL_BADARG_ERROR,
@@ -2604,4 +3243,3 @@ typedef enum icalerrorenum {
2604 ICAL_UNIMPLEMENTED_ERROR, 3243 ICAL_UNIMPLEMENTED_ERROR,
2605 ICAL_UNKNOWN_ERROR, /* Used for problems in input to icalerror_strerror()*/ 3244 ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror()*/
2606 ICAL_NO_ERROR
2607 3245
@@ -2609,6 +3247,10 @@ typedef enum icalerrorenum {
2609 3247
2610/* The libical error enumeration, like errno*/ 3248icalerrorenum * icalerrno_return(void);
2611extern icalerrorenum icalerrno; 3249#define icalerrno (*(icalerrno_return()))
2612 3250
2613/* If true, libicl aborts after a call to icalerror_set_error*/ 3251/** If true, libicl aborts after a call to icalerror_set_error
3252 *
3253 * @warning NOT THREAD SAFE -- recommended that you do not change
3254 * this in a multithreaded program.
3255 */
2614extern int icalerror_errors_are_fatal; 3256extern int icalerror_errors_are_fatal;
@@ -2625,2 +3267,3 @@ extern int icalerror_errors_are_fatal;
2625void icalerror_clear_errno(void); 3267void icalerror_clear_errno(void);
3268void _icalerror_set_errno(icalerrorenum);
2626 3269
@@ -2649,3 +3292,3 @@ if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \
2649#else 3292#else
2650void icalerror_set_errno(icalerrorenum); 3293void icalerror_set_errno(icalerrorenum x);
2651#endif 3294#endif
@@ -2707,3 +3350,2 @@ void icalerror_restore(const char* error, icalerrorstate es);
2707 3350
2708 $Id$
2709 3351
@@ -2768,4 +3410,2 @@ int icalrestriction_check(icalcomponent* comp);
2768 3410
2769 $Id$
2770 $Locker$
2771 3411
@@ -2912,4 +3552,2 @@ int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
2912 3552
2913 $Id$
2914 $Locker$
2915 3553
@@ -2954,4 +3592,2 @@ char* icalmime_as_mime_string(char* component);
2954 3592
2955 $Id$
2956 $Locker$
2957 3593
@@ -2990,2 +3626,5 @@ icalcomponent* icallangbind_get_next_component(icalcomponent *c,
2990 3626
3627icalparameter* icallangbind_get_first_parameter(icalproperty *prop);
3628
3629icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
2991 3630
@@ -2995,2 +3634,7 @@ const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
2995int icallangbind_string_to_open_flag(const char* str); 3634int icallangbind_string_to_open_flag(const char* str);
3635
3636const char* icallangbind_quote_as_ical(const char* str);
2996#endif /*__ICALLANGBIND_H__*/ 3637#endif /*__ICALLANGBIND_H__*/
3638#ifdef __cplusplus
3639};
3640#endif
diff --git a/libical/src/libical/icalarray.c b/libical/src/libical/icalarray.c
new file mode 100644
index 0000000..78e1ada
--- a/dev/null
+++ b/libical/src/libical/icalarray.c
@@ -0,0 +1,163 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*-
2 ======================================================================
3 FILE: icalarray.c
4 CREATOR: Damon Chaplin 07 March 2001
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2001, Ximian, Inc.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22
23 ======================================================================*/
24
25/** @file icalarray.c
26 *
27 * @brief An array of arbitrarily-sized elements which grows
28 * dynamically as elements are added.
29 */
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35#include <stdlib.h>
36#include <string.h>
37
38#include "icalarray.h"
39#include "icalerror.h"
40
41
42 static void icalarray_expand (icalarray*array,
43 int space_needed);
44
45/** @brief Constructor
46 */
47
48icalarray*
49 icalarray_new (int element_size,
50 int increment_size)
51{
52 icalarray *array;
53
54 array = (icalarray*) malloc (sizeof (icalarray));
55 if (!array) {
56 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
57 return NULL;
58 }
59
60 array->element_size = element_size;
61 array->increment_size = increment_size;
62 array->num_elements = 0;
63 array->space_allocated = 0;
64 array->data = NULL;
65
66 return array;
67}
68
69/** @brief Destructor
70 */
71
72void
73 icalarray_free (icalarray*array)
74{
75 if (array->data)
76 free (array->data);
77 free (array);
78}
79
80
81void
82 icalarray_append (icalarray*array,
83 void *element)
84{
85 if (array->num_elements >= array->space_allocated)
86 icalarray_expand (array, 1);
87
88 memcpy ((char *)(array->data) + ( array->num_elements * array->element_size ), element,
89 array->element_size);
90 array->num_elements++;
91}
92
93
94void*
95 icalarray_element_at (icalarray*array,
96 int position)
97{
98 assert (position >= 0);
99 assert (position < array->num_elements);
100
101 return (char *)(array->data) + (position * array->element_size);
102}
103
104
105void
106 icalarray_remove_element_at (icalarray*array,
107 int position)
108{
109 void *dest;
110 int elements_to_move;
111
112 assert (position >= 0);
113 assert (position < array->num_elements);
114
115 dest = (char *)array->data + (position * array->element_size);
116 elements_to_move = array->num_elements - position - 1;
117
118 if (elements_to_move > 0)
119 memmove (dest, (char *)dest + array->element_size,
120 elements_to_move * array->element_size);
121
122 array->num_elements--;
123}
124
125
126void
127 icalarray_sort (icalarray*array,
128 int (*compare) (const void *,
129 const void *))
130{
131 qsort (array->data, array->num_elements, array->element_size, compare);
132}
133
134
135static void
136 icalarray_expand (icalarray*array,
137 int space_needed)
138{
139 int new_space_allocated;
140 void *new_data;
141
142 new_space_allocated = array->space_allocated + array->increment_size;
143
144 if (space_needed > array->increment_size)
145 new_space_allocated += space_needed;
146
147 /*
148 new_data = realloc (array->data,
149 new_space_allocated * array->element_size);
150 */
151 new_data = malloc(new_space_allocated * array->element_size);
152 memcpy(new_data,array->data,array->element_size*array->space_allocated);
153 free(array->data);
154
155 if (new_data) {
156 array->data = new_data;
157 array->space_allocated = new_space_allocated;
158 } else {
159 icalerror_set_errno(ICAL_ALLOCATION_ERROR);
160 }
161}
162
163
diff --git a/libical/src/libical/icalarray.h b/libical/src/libical/icalarray.h
new file mode 100644
index 0000000..e265167
--- a/dev/null
+++ b/libical/src/libical/icalarray.h
@@ -0,0 +1,63 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/*======================================================================
3 FILE: icalarray.h
4 CREATOR: Damon Chaplin 07 March 2001
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2001, Ximian, Inc.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23
24======================================================================*/
25
26
27#ifndef ICALARRAY_H
28#define ICALARRAY_H
29
30/** @file icalarray.h
31 *
32 * @brief An array of arbitrarily-sized elements which grows
33 * dynamically as elements are added.
34 */
35
36typedef struct _icalarray icalarray;
37struct _icalarray {
38 unsigned int element_size;
39 unsigned int increment_size;
40 unsigned int num_elements;
41 unsigned int space_allocated;
42 void *data;
43};
44
45
46
47 icalarray *icalarray_new (int element_size,
48 int increment_size);
49 void icalarray_free (icalarray*array);
50
51 void icalarray_append (icalarray*array,
52 void *element);
53 void icalarray_remove_element_at (icalarray*array,
54 int position);
55
56 void *icalarray_element_at (icalarray*array,
57 int position);
58
59 void icalarray_sort (icalarray*array,
60 int (*compare) (const void *, const void *));
61
62
63#endif /* ICALARRAY_H */
diff --git a/libical/src/libical/icalattach.c b/libical/src/libical/icalattach.c
new file mode 100644
index 0000000..8da9d43
--- a/dev/null
+++ b/libical/src/libical/icalattach.c
@@ -0,0 +1,139 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalattach.c
4 CREATOR: acampi 28 May 02
5
6 $Id$
7 $Locker$
8
9
10 (C) COPYRIGHT 2000, Andrea Campi
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23 The original code is icaltypes.c
24
25 ======================================================================*/
26#ifdef HAVE_CONFIG_H
27#include "config.h"
28#endif
29
30#include "icaltypes.h"
31#include "icalerror.h"
32#include "icalmemory.h"
33#include "icalattachimpl.h"
34#include <stdlib.h> /* for malloc and abs() */
35#include <errno.h> /* for errno */
36#include <string.h> /* for icalmemory_strdup */
37#include <assert.h>
38
39icalattach *
40icalattach_new_from_url (const char *url)
41{
42 icalattach *attach;
43 char *url_copy;
44
45 icalerror_check_arg_rz ((url != NULL), "url");
46
47 if ((attach = malloc (sizeof (icalattach))) == NULL) {
48 errno = ENOMEM;
49 return NULL;
50 }
51
52 if ((url_copy = strdup (url)) == NULL) {
53 free (attach);
54 errno = ENOMEM;
55 return NULL;
56 }
57
58 attach->refcount = 1;
59 attach->is_url = 1;
60 attach->u.url.url = url_copy;
61
62 return attach;
63}
64
65icalattach *
66icalattach_new_from_data (unsigned char *data, icalattach_free_fn_t free_fn,
67 void *free_fn_data)
68{
69 icalattach *attach;
70
71 icalerror_check_arg_rz ((data != NULL), "data");
72
73 if ((attach = malloc (sizeof (icalattach))) == NULL) {
74 errno = ENOMEM;
75 return NULL;
76 }
77
78 attach->refcount = 1;
79 attach->is_url = 0;
80 attach->u.data.data = data;
81 attach->u.data.free_fn = free_fn;
82 attach->u.data.free_fn_data = free_fn_data;
83
84 return attach;
85}
86
87void
88icalattach_ref (icalattach *attach)
89{
90 icalerror_check_arg_rv ((attach != NULL), "attach");
91 icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0");
92
93 attach->refcount++;
94}
95
96void
97icalattach_unref (icalattach *attach)
98{
99 icalerror_check_arg_rv ((attach != NULL), "attach");
100 icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0");
101
102 attach->refcount--;
103
104 if (attach->refcount != 0)
105 return;
106
107 if (attach->is_url)
108 free (attach->u.url.url);
109 else if (attach->u.data.free_fn)
110 (* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data);
111
112 free (attach);
113}
114
115int
116icalattach_get_is_url (icalattach *attach)
117{
118 icalerror_check_arg_rz ((attach != NULL), "attach");
119
120 return attach->is_url ? 1 : 0;
121}
122
123const char *
124icalattach_get_url (icalattach *attach)
125{
126 icalerror_check_arg_rz ((attach != NULL), "attach");
127 icalerror_check_arg_rz ((attach->is_url), "attach->is_url");
128
129 return attach->u.url.url;
130}
131
132unsigned char *
133icalattach_get_data (icalattach *attach)
134{
135 icalerror_check_arg_rz ((attach != NULL), "attach");
136 icalerror_check_arg_rz ((!attach->is_url), "!attach->is_url");
137
138 return attach->u.data.data;
139}
diff --git a/libical/src/libical/icalattach.h b/libical/src/libical/icalattach.h
new file mode 100644
index 0000000..ba4488d
--- a/dev/null
+++ b/libical/src/libical/icalattach.h
@@ -0,0 +1,60 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalattach.h
4 CREATOR: acampi 28 May 02
5
6
7 (C) COPYRIGHT 2002, Andrea Campi
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of either:
11
12 The LGPL as published by the Free Software Foundation, version
13 2.1, available at: http://www.fsf.org/copyleft/lesser.html
14
15 Or:
16
17 The Mozilla Public License Version 1.0. You may obtain a copy of
18 the License at http://www.mozilla.org/MPL/
19
20 The original code is icalattach.h
21
22======================================================================*/
23
24#ifndef ICALATTACH_H
25#define ICALATTACH_H
26
27
28typedef struct icalattach_impl icalattach;
29
30typedef void (* icalattach_free_fn_t) (unsigned char *data, void *user_data);
31
32icalattach *icalattach_new_from_url (const char *url);
33icalattach *icalattach_new_from_data (unsigned char *data,
34 icalattach_free_fn_t free_fn, void *free_fn_data);
35
36void icalattach_ref (icalattach *attach);
37void icalattach_unref (icalattach *attach);
38
39int icalattach_get_is_url (icalattach *attach);
40const char *icalattach_get_url (icalattach *attach);
41unsigned char *icalattach_get_data (icalattach *attach);
42
43struct icalattachtype* icalattachtype_new(void);
44void icalattachtype_add_reference(struct icalattachtype* v);
45void icalattachtype_free(struct icalattachtype* v);
46
47void icalattachtype_set_url(struct icalattachtype* v, char* url);
48char* icalattachtype_get_url(struct icalattachtype* v);
49
50void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
51 int owns);
52char* icalattachtype_get_base64(struct icalattachtype* v);
53
54void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
55 int owns);
56void* icalattachtype_get_binary(struct icalattachtype* v);
57
58
59
60#endif /* !ICALATTACH_H */
diff --git a/libical/src/libical/icalattachimpl.h b/libical/src/libical/icalattachimpl.h
new file mode 100644
index 0000000..b8abe63
--- a/dev/null
+++ b/libical/src/libical/icalattachimpl.h
@@ -0,0 +1,59 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalattachimpl.h
4 CREATOR: acampi 28 May 02
5
6 $Id$
7
8
9 (C) COPYRIGHT 2000, Andrea Campi
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The original code is icalattachimpl.h
23
24
25======================================================================*/
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31#ifndef ICALATTACHIMPL_H
32#define ICALATTACHIMPL_H
33
34#include "icalattach.h"
35
36/* Private structure for ATTACH values */
37struct icalattach_impl {
38 /* Reference count */
39 int refcount;
40
41 union {
42 /* URL attachment data */
43 struct {
44 char *url;
45 } url;
46
47 /* Inline data */
48 struct {
49 unsigned char *data;
50 icalattach_free_fn_t free_fn;
51 void *free_fn_data;
52 } data;
53 } u;
54
55 /* TRUE if URL, FALSE if inline data */
56 unsigned int is_url : 1;
57};
58
59#endif
diff --git a/libical/src/libical/icalcomponent.c b/libical/src/libical/icalcomponent.c
index af0d3ec..fbd0492 100644
--- a/libical/src/libical/icalcomponent.c
+++ b/libical/src/libical/icalcomponent.c
@@ -6,3 +6,2 @@
6 6
7
8 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 7 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -35,2 +34,4 @@
35#include "icaltime.h" 34#include "icaltime.h"
35#include "icalarray.h"
36#include "icaltimezone.h"
36#include "icalduration.h" 37#include "icalduration.h"
@@ -38,2 +39,3 @@
38#include "icalparser.h" 39#include "icalparser.h"
40#include "icalrestriction.h"
39 41
@@ -44,5 +46,4 @@
44#include <stdio.h> /* for fprintf */ 46#include <stdio.h> /* for fprintf */
45#include <string.h> 47#include <string.h> /* for strdup */
46 48#include <limits.h> /* for INT_MAX */
47#define MAX_TMP 1024
48 49
@@ -58,2 +59,9 @@ struct icalcomponent_impl
58 icalcomponent* parent; 59 icalcomponent* parent;
60
61 /** An array of icaltimezone structs. We use this so we can do fast
62 lookup of timezones using binary searches. timezones_sorted is
63 set to 0 whenever we add a timezone, so we remember to sort the
64 array before doing a binary search. */
65 icalarray* timezones;
66 int timezones_sorted;
59}; 67};
@@ -64,8 +72,25 @@ void icalproperty_set_parent(icalproperty* property,
64icalcomponent* icalproperty_get_parent(icalproperty* property); 72icalcomponent* icalproperty_get_parent(icalproperty* property);
65void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args); 73void icalcomponent_add_children(icalcomponent *impl,va_list args);
66icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind); 74static icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind);
67int icalcomponent_property_sorter(void *a, void *b); 75
68 76static void icalcomponent_merge_vtimezone (icalcomponent *comp,
69 77 icalcomponent *vtimezone,
70void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args) 78 icalarray *tzids_to_rename);
79static void icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
80 icalcomponent *vtimezone,
81 icalproperty *tzid_prop,
82 const char *tzid,
83 icalarray *tzids_to_rename);
84static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid);
85static void icalcomponent_rename_tzids(icalcomponent* comp,
86 icalarray* rename_table);
87static void icalcomponent_rename_tzids_callback(icalparameter *param,
88 void *data);
89 static int icalcomponent_compare_vtimezones (icalcomponent*vtimezone1,
90 icalcomponent*vtimezone2);
91 static int icalcomponent_compare_timezone_fn (const void*elem1,
92 const void*elem2);
93
94
95void icalcomponent_add_children(icalcomponent *impl, va_list args)
71{ 96{
@@ -79,10 +104,6 @@ void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args)
79 if (icalcomponent_isa_component(vp) != 0 ){ 104 if (icalcomponent_isa_component(vp) != 0 ){
80 105 icalcomponent_add_component(impl, (icalcomponent*)vp);
81 icalcomponent_add_component((icalcomponent*)impl,
82 (icalcomponent*)vp);
83 106
84 } else if (icalproperty_isa_property(vp) != 0 ){ 107 } else if (icalproperty_isa_property(vp) != 0 ){
85 108 icalcomponent_add_property(impl, (icalproperty*)vp);
86 icalcomponent_add_property((icalcomponent*)impl,
87 (icalproperty*)vp);
88 } 109 }
@@ -91,9 +112,11 @@ void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args)
91 112
92icalcomponent* 113static icalcomponent*
93icalcomponent_new_impl (icalcomponent_kind kind) 114icalcomponent_new_impl (icalcomponent_kind kind)
94{ 115{
95 struct icalcomponent_impl* comp; 116 icalcomponent* comp;
96 117
97 if ( ( comp = (struct icalcomponent_impl*) 118 if (!icalcomponent_kind_is_valid(kind))
98 malloc(sizeof(struct icalcomponent_impl))) == 0) { 119 return NULL;
120
121 if ( ( comp = (icalcomponent*) malloc(sizeof(icalcomponent))) == 0) {
99 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 122 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -111,2 +134,4 @@ icalcomponent_new_impl (icalcomponent_kind kind)
111 comp->parent = 0; 134 comp->parent = 0;
135 comp->timezones = NULL;
136 comp->timezones_sorted = 1;
112 137
@@ -115,2 +140,4 @@ icalcomponent_new_impl (icalcomponent_kind kind)
115 140
141/** @brief Constructor
142 */
116icalcomponent* 143icalcomponent*
@@ -118,5 +145,7 @@ icalcomponent_new (icalcomponent_kind kind)
118{ 145{
119 return (icalcomponent*)icalcomponent_new_impl(kind); 146 return icalcomponent_new_impl(kind);
120} 147}
121 148
149/** @brief Constructor
150 */
122icalcomponent* 151icalcomponent*
@@ -126,3 +155,3 @@ icalcomponent_vanew (icalcomponent_kind kind, ...)
126 155
127 struct icalcomponent_impl *impl = icalcomponent_new_impl(kind); 156 icalcomponent *impl = icalcomponent_new_impl(kind);
128 157
@@ -136,5 +165,7 @@ icalcomponent_vanew (icalcomponent_kind kind, ...)
136 165
137 return (icalcomponent*) impl; 166 return impl;
138} 167}
139 168
169/** @brief Constructor
170 */
140icalcomponent* icalcomponent_new_from_string(char* str) 171icalcomponent* icalcomponent_new_from_string(char* str)
@@ -144,6 +175,7 @@ icalcomponent* icalcomponent_new_from_string(char* str)
144 175
145icalcomponent* icalcomponent_new_clone(icalcomponent* component) 176/** @brief Constructor
177 */
178icalcomponent* icalcomponent_new_clone(icalcomponent* old)
146{ 179{
147 struct icalcomponent_impl *old = (struct icalcomponent_impl*)component; 180 icalcomponent *new;
148 struct icalcomponent_impl *new;
149 icalproperty *p; 181 icalproperty *p;
@@ -152,3 +184,3 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* component)
152 184
153 icalerror_check_arg_rz( (component!=0), "component"); 185 icalerror_check_arg_rz( (old!=0), "component");
154 186
@@ -182,5 +214,6 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* component)
182 214
183 215/*** @brief Destructor
216 */
184void 217void
185icalcomponent_free (icalcomponent* component) 218icalcomponent_free (icalcomponent* c)
186{ 219{
@@ -188,5 +221,4 @@ icalcomponent_free (icalcomponent* component)
188 icalcomponent* comp; 221 icalcomponent* comp;
189 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
190 222
191 icalerror_check_arg_rv( (component!=0), "component"); 223 icalerror_check_arg_rv( (c!=0), "component");
192 224
@@ -200,11 +232,14 @@ icalcomponent_free (icalcomponent* component)
200 232
201 if(component != 0 ){ 233 if(c != 0 ){
202 234
203 while( (prop=pvl_pop(c->properties)) != 0){ 235 if ( c->properties != 0 )
204 assert(prop != 0); 236 {
205 icalproperty_set_parent(prop,0); 237 while( (prop=pvl_pop(c->properties)) != 0){
206 icalproperty_free(prop); 238 assert(prop != 0);
207 } 239 icalproperty_set_parent(prop,0);
208 240 icalproperty_free(prop);
209 pvl_free(c->properties); 241 }
242 pvl_free(c->properties);
243 }
244
210 245
@@ -212,3 +247,3 @@ icalcomponent_free (icalcomponent* component)
212 assert(comp!=0); 247 assert(comp!=0);
213 icalcomponent_remove_component(component,comp); 248 icalcomponent_remove_component(c,comp);
214 icalcomponent_free(comp); 249 icalcomponent_free(comp);
@@ -222,2 +257,5 @@ icalcomponent_free (icalcomponent* component)
222 257
258 if (c->timezones)
259 icaltimezone_array_free (c->timezones);
260
223 c->kind = ICAL_NO_COMPONENT; 261 c->kind = ICAL_NO_COMPONENT;
@@ -229,2 +267,3 @@ icalcomponent_free (icalcomponent* component)
229 c->id[0] = 'X'; 267 c->id[0] = 'X';
268 c->timezones = NULL;
230 269
@@ -235,3 +274,3 @@ icalcomponent_free (icalcomponent* component)
235char* 274char*
236icalcomponent_as_ical_string (icalcomponent* component) 275icalcomponent_as_ical_string (icalcomponent* impl)
237{ 276{
@@ -242,12 +281,16 @@ icalcomponent_as_ical_string (icalcomponent* component)
242 pvl_elem itr; 281 pvl_elem itr;
243 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
244 282
283/* WIN32 automatically adds the \r, Anybody else need it?
245#ifdef ICAL_UNIX_NEWLINE 284#ifdef ICAL_UNIX_NEWLINE
285*/
246 char newline[] = "\n"; 286 char newline[] = "\n";
287/*
247#else 288#else
248 char newline[] = "\n"; 289 char newline[] = "\r\n";
249#endif 290#endif
291*/
292
250 icalcomponent *c; 293 icalcomponent *c;
251 icalproperty *p; 294 icalproperty *p;
252 icalcomponent_kind kind = icalcomponent_isa(component); 295 icalcomponent_kind kind = icalcomponent_isa(impl);
253 296
@@ -258,3 +301,3 @@ icalcomponent_as_ical_string (icalcomponent* component)
258 301
259 icalerror_check_arg_rz( (component!=0), "component"); 302 icalerror_check_arg_rz( (impl!=0), "component");
260 icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT"); 303 icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT");
@@ -269,3 +312,4 @@ icalcomponent_as_ical_string (icalcomponent* component)
269 312
270 313
314
271 for( itr = pvl_head(impl->properties); 315 for( itr = pvl_head(impl->properties);
@@ -273,5 +317,3 @@ icalcomponent_as_ical_string (icalcomponent* component)
273 itr = pvl_next(itr)) 317 itr = pvl_next(itr))
274 { 318 {
275 // printf("3333calcomponent_as_ical_string System Timezone2: %s %s \n", *tzname, getenv("TZ") );
276
277 p = (icalproperty*)pvl_data(itr); 319 p = (icalproperty*)pvl_data(itr);
@@ -288,4 +330,3 @@ icalcomponent_as_ical_string (icalcomponent* component)
288 itr = pvl_next(itr)) 330 itr = pvl_next(itr))
289 { 331 {
290
291 c = (icalcomponent*)pvl_data(itr); 332 c = (icalcomponent*)pvl_data(itr);
@@ -293,2 +334,3 @@ icalcomponent_as_ical_string (icalcomponent* component)
293 tmp_buf = icalcomponent_as_ical_string(c); 334 tmp_buf = icalcomponent_as_ical_string(c);
335
294 icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); 336 icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
@@ -297,6 +339,6 @@ icalcomponent_as_ical_string (icalcomponent* component)
297 339
298 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:"); //tzset(); 340 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:");
299 icalmemory_append_string(&buf, &buf_ptr, &buf_size, 341 icalmemory_append_string(&buf, &buf_ptr, &buf_size,
300 icalcomponent_kind_to_string(kind)); 342 icalcomponent_kind_to_string(kind));
301 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); //tzset(); 343 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
302 344
@@ -312,7 +354,4 @@ icalcomponent_is_valid (icalcomponent* component)
312{ 354{
313 struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; 355 if ( (strcmp(component->id,"comp") == 0) &&
314 356 component->kind != ICAL_NO_COMPONENT){
315
316 if ( (strcmp(impl->id,"comp") == 0) &&
317 impl->kind != ICAL_NO_COMPONENT){
318 return 1; 357 return 1;
@@ -326,6 +365,5 @@ icalcomponent_is_valid (icalcomponent* component)
326icalcomponent_kind 365icalcomponent_kind
327icalcomponent_isa (icalcomponent* component) 366icalcomponent_isa (const icalcomponent* component)
328{ 367{
329 struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; 368 icalerror_check_arg_rx( (component!=0), "component", ICAL_NO_COMPONENT);
330 icalerror_check_arg_rz( (component!=0), "component");
331 369
@@ -333,3 +371,3 @@ icalcomponent_isa (icalcomponent* component)
333 { 371 {
334 return impl->kind; 372 return component->kind;
335 } 373 }
@@ -343,3 +381,3 @@ icalcomponent_isa_component (void* component)
343{ 381{
344 struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; 382 icalcomponent *impl = component;
345 383
@@ -355,17 +393,2 @@ icalcomponent_isa_component (void* component)
355 393
356int icalcomponent_property_sorter(void *a, void *b)
357{
358 icalproperty_kind kinda, kindb;
359 const char *ksa, *ksb;
360
361 kinda = icalproperty_isa((icalproperty*)a);
362 kindb = icalproperty_isa((icalproperty*)b);
363
364 ksa = icalproperty_kind_to_string(kinda);
365 ksb = icalproperty_kind_to_string(kindb);
366
367 return strcmp(ksa,ksb);
368}
369
370
371void 394void
@@ -373,4 +396,2 @@ icalcomponent_add_property (icalcomponent* component, icalproperty* property)
373{ 396{
374 struct icalcomponent_impl *impl;
375
376 icalerror_check_arg_rv( (component!=0), "component"); 397 icalerror_check_arg_rv( (component!=0), "component");
@@ -378,4 +399,2 @@ icalcomponent_add_property (icalcomponent* component, icalproperty* property)
378 399
379 impl = (struct icalcomponent_impl*)component;
380
381 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"); 400 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");
@@ -384,9 +403,3 @@ icalcomponent_add_property (icalcomponent* component, icalproperty* property)
384 403
385#ifdef ICAL_INSERT_ORDERED 404 pvl_push(component->properties,property);
386 pvl_insert_ordered(impl->properties,
387 icalcomponent_property_sorter,property);
388#else
389 pvl_push(impl->properties,property);
390#endif
391
392} 405}
@@ -397,5 +410,3 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
397{ 410{
398 struct icalcomponent_impl *impl;
399 pvl_elem itr, next_itr; 411 pvl_elem itr, next_itr;
400 struct icalproperty_impl *pimpl;
401 412
@@ -404,6 +415,2 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
404 415
405 impl = (struct icalcomponent_impl*)component;
406
407 pimpl = (struct icalproperty_impl*)property;
408
409 icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component"); 416 icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component");
@@ -411,3 +418,3 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
411 418
412 for( itr = pvl_head(impl->properties); 419 for( itr = pvl_head(component->properties);
413 itr != 0; 420 itr != 0;
@@ -419,7 +426,7 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
419 426
420 if (impl->property_iterator == itr){ 427 if (component->property_iterator == itr){
421 impl->property_iterator = pvl_next(itr); 428 component->property_iterator = pvl_next(itr);
422 } 429 }
423 430
424 pvl_remove( impl->properties, itr); 431 pvl_remove( component->properties, itr);
425 icalproperty_set_parent(property,0); 432 icalproperty_set_parent(property,0);
@@ -435,3 +442,2 @@ icalcomponent_count_properties (icalcomponent* component,
435 pvl_elem itr; 442 pvl_elem itr;
436 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
437 443
@@ -439,3 +445,3 @@ icalcomponent_count_properties (icalcomponent* component,
439 445
440 for( itr = pvl_head(impl->properties); 446 for( itr = pvl_head(component->properties);
441 itr != 0; 447 itr != 0;
@@ -456,7 +462,5 @@ icalproperty* icalcomponent_get_current_property (icalcomponent* component)
456{ 462{
457
458 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
459 icalerror_check_arg_rz( (component!=0),"component"); 463 icalerror_check_arg_rz( (component!=0),"component");
460 464
461 if ((c->property_iterator==0)){ 465 if ((component->property_iterator==0)){
462 return 0; 466 return 0;
@@ -464,4 +468,3 @@ icalproperty* icalcomponent_get_current_property (icalcomponent* component)
464 468
465 return (icalproperty*) pvl_data(c->property_iterator); 469 return (icalproperty*) pvl_data(component->property_iterator);
466
467} 470}
@@ -469,6 +472,5 @@ icalproperty* icalcomponent_get_current_property (icalcomponent* component)
469icalproperty* 472icalproperty*
470icalcomponent_get_first_property (icalcomponent* component, icalproperty_kind kind) 473icalcomponent_get_first_property (icalcomponent* c, icalproperty_kind kind)
471{ 474{
472 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 475 icalerror_check_arg_rz( (c!=0),"component");
473 icalerror_check_arg_rz( (component!=0),"component");
474 476
@@ -489,6 +491,5 @@ icalcomponent_get_first_property (icalcomponent* component, icalproperty_kind ki
489icalproperty* 491icalproperty*
490icalcomponent_get_next_property (icalcomponent* component, icalproperty_kind kind) 492icalcomponent_get_next_property (icalcomponent* c, icalproperty_kind kind)
491{ 493{
492 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 494 icalerror_check_arg_rz( (c!=0),"component");
493 icalerror_check_arg_rz( (component!=0),"component");
494 495
@@ -521,4 +522,2 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
521{ 522{
522 struct icalcomponent_impl *impl, *cimpl;
523
524 icalerror_check_arg_rv( (parent!=0), "parent"); 523 icalerror_check_arg_rv( (parent!=0), "parent");
@@ -526,6 +525,3 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
526 525
527 impl = (struct icalcomponent_impl*)parent; 526 if (child->parent !=0) {
528 cimpl = (struct icalcomponent_impl*)child;
529
530 if (cimpl->parent !=0) {
531 icalerror_set_errno(ICAL_USAGE_ERROR); 527 icalerror_set_errno(ICAL_USAGE_ERROR);
@@ -533,5 +529,18 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
533 529
534 cimpl->parent = parent; 530 child->parent = parent;
531
532 pvl_push(parent->components,child);
535 533
536 pvl_push(impl->components,child); 534 /* If the new component is a VTIMEZONE, add it to our array. */
535 if (child->kind == ICAL_VTIMEZONE_COMPONENT) {
536 /* FIXME: Currently we are also creating this array when loading in
537 a builtin VTIMEZONE, when we don't need it. */
538 if (!parent->timezones)
539 parent->timezones = icaltimezone_array_new ();
540
541 icaltimezone_array_append_from_vtimezone (parent->timezones, child);
542
543 /* Flag that we need to sort it before doing any binary searches. */
544 parent->timezones_sorted = 0;
545 }
537} 546}
@@ -542,3 +551,2 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
542{ 551{
543 struct icalcomponent_impl *impl,*cimpl;
544 pvl_elem itr, next_itr; 552 pvl_elem itr, next_itr;
@@ -548,6 +556,19 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
548 556
549 impl = (struct icalcomponent_impl*)parent; 557 /* If the component is a VTIMEZONE, remove it from our array as well. */
550 cimpl = (struct icalcomponent_impl*)child; 558 if (child->kind == ICAL_VTIMEZONE_COMPONENT) {
551 559 icaltimezone *zone;
552 for( itr = pvl_head(impl->components); 560 int i, num_elements;
561
562 num_elements = parent->timezones ? parent->timezones->num_elements : 0;
563 for (i = 0; i < num_elements; i++) {
564 zone = icalarray_element_at (parent->timezones, i);
565 if (icaltimezone_get_component (zone) == child) {
566 icaltimezone_free (zone, 0);
567 icalarray_remove_element_at (parent->timezones, i);
568 break;
569 }
570 }
571 }
572
573 for( itr = pvl_head(parent->components);
553 itr != 0; 574 itr != 0;
@@ -559,3 +580,3 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
559 580
560 if (impl->component_iterator == itr){ 581 if (parent->component_iterator == itr){
561 /* Don't let the current iterator become invalid */ 582 /* Don't let the current iterator become invalid */
@@ -563,8 +584,8 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
563 /* HACK. The semantics for this are troubling. */ 584 /* HACK. The semantics for this are troubling. */
564 impl->component_iterator = 585 parent->component_iterator =
565 pvl_next(impl->component_iterator); 586 pvl_next(parent->component_iterator);
566 587
567 } 588 }
568 pvl_remove( impl->components, itr); 589 pvl_remove( parent->components, itr);
569 cimpl->parent = 0; 590 child->parent = 0;
570 break; 591 break;
@@ -581,3 +602,2 @@ icalcomponent_count_components (icalcomponent* component,
581 pvl_elem itr; 602 pvl_elem itr;
582 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
583 603
@@ -585,3 +605,3 @@ icalcomponent_count_components (icalcomponent* component,
585 605
586 for( itr = pvl_head(impl->components); 606 for( itr = pvl_head(component->components);
587 itr != 0; 607 itr != 0;
@@ -601,7 +621,5 @@ icalcomponent_get_current_component(icalcomponent* component)
601{ 621{
602 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component;
603
604 icalerror_check_arg_rz( (component!=0),"component"); 622 icalerror_check_arg_rz( (component!=0),"component");
605 623
606 if (c->component_iterator == 0){ 624 if (component->component_iterator == 0){
607 return 0; 625 return 0;
@@ -609,3 +627,3 @@ icalcomponent_get_current_component(icalcomponent* component)
609 627
610 return (icalcomponent*) pvl_data(c->component_iterator); 628 return (icalcomponent*) pvl_data(component->component_iterator);
611} 629}
@@ -613,8 +631,6 @@ icalcomponent_get_current_component(icalcomponent* component)
613icalcomponent* 631icalcomponent*
614icalcomponent_get_first_component (icalcomponent* component, 632icalcomponent_get_first_component (icalcomponent* c,
615 icalcomponent_kind kind) 633 icalcomponent_kind kind)
616{ 634{
617 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 635 icalerror_check_arg_rz( (c!=0),"component");
618
619 icalerror_check_arg_rz( (component!=0),"component");
620 636
@@ -637,7 +653,5 @@ icalcomponent_get_first_component (icalcomponent* component,
637icalcomponent* 653icalcomponent*
638icalcomponent_get_next_component (icalcomponent* component, icalcomponent_kind kind) 654icalcomponent_get_next_component (icalcomponent* c, icalcomponent_kind kind)
639{ 655{
640 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 656 icalerror_check_arg_rz( (c!=0),"component");
641
642 icalerror_check_arg_rz( (component!=0),"component");
643 657
@@ -675,3 +689,5 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c)
675 kind == ICAL_VJOURNAL_COMPONENT || 689 kind == ICAL_VJOURNAL_COMPONENT ||
676 kind == ICAL_VFREEBUSY_COMPONENT ){ 690 kind == ICAL_VFREEBUSY_COMPONENT ||
691 kind == ICAL_VQUERY_COMPONENT ||
692 kind == ICAL_VAGENDA_COMPONENT){
677 return comp; 693 return comp;
@@ -682,61 +698,27 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c)
682 698
683time_t icalcomponent_convert_time(icalproperty *p)
684{
685 struct icaltimetype sict;
686 time_t convt;
687 icalproperty *tzp;
688
689
690 /* Though it says _dtstart, it will work for dtend too */
691 sict = icalproperty_get_dtstart(p);
692
693 tzp = icalproperty_get_first_parameter(p,ICAL_TZID_PARAMETER);
694
695 if (sict.is_utc == 1 && tzp != 0){
696 icalerror_warn("icalcomponent_get_span: component has a UTC DTSTART with a timezone specified ");
697 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
698 return 0;
699 }
700 699
701 if(sict.is_utc == 1){ 700 /**@brief Get the timespan covered by this component, in UTC
702 /* _as_timet will use gmtime() to do the conversion */ 701 *(deprecated)
703 convt = icaltime_as_timet(sict); 702 *
704 703 * see icalcomponent_foreach_recurrence() for a better way to
705#ifdef TEST_CONVERT_TIME 704 * extract spans from an component.
706 printf("convert time: use as_timet:\n %s\n %s", 705 *
707 icalproperty_as_ical_string(p), ctime(&convt)); 706 *This method can be called on either a VCALENDAR or any real
708#endif 707 *component. If the VCALENDAR contains no real component, but
709 708 *contains a VTIMEZONE, we return that span instead.
710 } else if (sict.is_utc == 0 && tzp == 0 ) { 709 *This might not be a desirable behavior; we keep it for now
711 time_t offset; 710 *for backward compatibility, but it might be deprecated at a
712 711 *future time.
713 /* _as_timet will use localtime() to do the conversion */ 712 *
714 convt = icaltime_as_timet(sict); 713 *FIXME this API needs to be clarified. DTEND is defined as the
715 offset = icaltime_utc_offset(sict,0); 714 *first available time after the end of this event, so the span
716 convt += offset; 715 *should actually end 1 second before DTEND.
717 716 */
718#ifdef TEST_CONVERT_TIME 717
719 printf("convert time: use as_timet and adjust:\n %s\n %s", 718icaltime_span icalcomponent_get_span(icalcomponent* comp)
720 icalproperty_as_ical_string(p), ctime(&convt));
721#endif
722 } else {
723 /* Convert the time to UTC for the named timezone*/
724 const char* timezone = icalparameter_get_tzid(tzp);
725 convt = icaltime_as_timet(icaltime_as_utc(sict,timezone));
726
727#ifdef TEST_CONVERT_TIME
728 printf("convert time: use _as_utc:\n %s\n %s",
729 icalproperty_as_ical_string(p), ctime(&convt));
730#endif
731 }
732
733 return convt;
734}
735struct icaltime_span icalcomponent_get_span(icalcomponent* comp)
736{ 719{
737 icalcomponent *inner; 720 icalcomponent *inner;
738 icalproperty *p, *duration;
739 icalcomponent_kind kind; 721 icalcomponent_kind kind;
740 struct icaltime_span span; 722 icaltime_span span;
741 struct icaltimetype start; 723 struct icaltimetype start, end;
742 724
@@ -747,7 +729,8 @@ struct icaltime_span icalcomponent_get_span(icalcomponent* comp)
747 /* initial Error checking */ 729 /* initial Error checking */
730 if (comp == NULL) {
731 return span;
732 }
748 733
749/* icalerror_check_arg_rz( (comp!=0),"comp");*/ 734 /* FIXME this might go away */
750
751 kind = icalcomponent_isa(comp); 735 kind = icalcomponent_isa(comp);
752
753 if(kind == ICAL_VCALENDAR_COMPONENT){ 736 if(kind == ICAL_VCALENDAR_COMPONENT){
@@ -783,63 +766,325 @@ struct icaltime_span icalcomponent_get_span(icalcomponent* comp)
783 766
767 /* Get to work. starting with DTSTART */
768 start = icalcomponent_get_dtstart(comp);
769 if (icaltime_is_null_time(start)) {
770 return span;
771 }
772 span.start = icaltime_as_timet_with_zone(start,
773 icaltimezone_get_utc_timezone());
784 774
775 /* The end time could be specified as either a DTEND or a DURATION */
776 /* icalcomponent_get_dtend takes care of these cases. */
777 end = icalcomponent_get_dtend(comp);
778 if (icaltime_is_null_time(end)) {
779 if (!icaltime_is_date(start)) {
780 /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION
781 it takes no time */
782 span.start = 0;
783 return span;
784 } else {
785 end = start;
786 }
787 }
785 788
786 /* Get to work. starting with DTSTART */ 789 span.end = icaltime_as_timet_with_zone(end,
790 icaltimezone_get_utc_timezone());
791 if (icaltime_is_date(start)) {
792 /* Until the end of the day*/
793 span.end += 60*60*24 - 1;
794 }
787 795
788 p = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY); 796 return span;
789 797
790 if (p ==0 ) { 798}
791 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 799
792 /*icalerror_warn("icalcomponent_get_span: component has no DTSTART time");*/ 800/**
793 return span; 801 * Decide if this recurrance is acceptable
802 *
803 * @param comp A valid icalcomponent.
804 * @param dtstart The base dtstart value for this component.
805 * @param recurtime The time to test against.
806 *
807 * @return true if the recurrence value is excluded, false otherwise.
808 *
809 * This function decides if a specific recurrence value is
810 * excluded by EXRULE or EXDATE properties.
811 *
812 * It's not the most efficient code. You might get better performance
813 * if you assume that recurtime is always increasing for each
814 * call. Then you could:
815 *
816 * - sort the EXDATE values
817 * - save the state of each EXRULE iterator for the next call.
818 *
819 * In this case though you don't need to worry how you call this
820 * function. It will always return the correct result.
821 */
822
823int icalproperty_recurrence_is_excluded(icalcomponent *comp,
824 struct icaltimetype *dtstart,
825 struct icaltimetype *recurtime) {
826 icalproperty *exdate, *exrule;
827
828 if (comp == NULL ||
829 dtstart == NULL ||
830 recurtime == NULL ||
831 icaltime_is_null_time(*recurtime))
832 /* BAD DATA */
833 return 1;
834
835 /** first test against the exdate values **/
836 for (exdate = icalcomponent_get_first_property(comp,ICAL_EXDATE_PROPERTY);
837 exdate != NULL;
838 exdate = icalcomponent_get_next_property(comp,ICAL_EXDATE_PROPERTY)) {
839
840 struct icaltimetype exdatetime = icalproperty_get_exdate(exdate);
841
842 if (icaltime_compare(*recurtime, exdatetime) == 0) {
843 /** MATCHED **/
844 return 1;
845 }
846 }
847
848 /** Now test against the EXRULEs **/
849 for (exrule = icalcomponent_get_first_property(comp,ICAL_EXRULE_PROPERTY);
850 exdate != NULL;
851 exdate = icalcomponent_get_next_property(comp,ICAL_EXRULE_PROPERTY)) {
852
853 struct icalrecurrencetype recur = icalproperty_get_exrule(exrule);
854 icalrecur_iterator *exrule_itr = icalrecur_iterator_new(recur, *dtstart);
855 struct icaltimetype exrule_time;
856
857 while (1) {
858 int result;
859 exrule_time = icalrecur_iterator_next(exrule_itr);
860
861 if (icaltime_is_null_time(exrule_time))
862 break;
863
864 result = icaltime_compare(*recurtime, exrule_time);
865 if (result == 0) {
866 icalrecur_iterator_free(exrule_itr);
867 return 1; /** MATCH **/
868 }
869 if (result == 1)
870 break; /** exrule_time > recurtime **/
794 } 871 }
795 872
873 icalrecur_iterator_free(exrule_itr);
874 }
796 875
797 start = icalproperty_get_dtstart(p); 876 return 0; /** no matches **/
877}
798 878
799 icalerror_clear_errno(); 879/**
880 * @brief Return the busy status based on the TRANSP property.
881 *
882 * @param comp A valid icalcomponent.
883 *
884 * @return 1 if the event is a busy item, 0 if it is not.
885 */
800 886
801 span.start = icalcomponent_convert_time(p); 887static int icalcomponent_is_busy(icalcomponent *comp) {
888 icalproperty *transp;
889 enum icalproperty_status status;
890 int ret = 1;
802 891
803#ifdef TEST_CONVERT_TIME 892 /** @todo check access control here, converting busy->free if the
804 printf("convert time:\n %s %s", 893 permissions do not allow access... */
805 icalproperty_as_ical_string(p), ctime(&span.start));
806#endif
807 894
808 if(icalerrno != ICAL_NO_ERROR){ 895 /* Is this a busy time? Check the TRANSP property */
809 span.start = 0; 896 transp = icalcomponent_get_first_property(comp, ICAL_TRANSP_PROPERTY);
810 return span; 897
898 if (transp) {
899 icalvalue *transp_val = icalproperty_get_value(transp);
900
901 switch (icalvalue_get_transp(transp_val)) {
902 case ICAL_TRANSP_OPAQUE:
903 case ICAL_TRANSP_OPAQUENOCONFLICT:
904 case ICAL_TRANSP_NONE:
905 ret = 1;
906 break;
907 case ICAL_TRANSP_TRANSPARENT:
908 case ICAL_TRANSP_TRANSPARENTNOCONFLICT:
909 ret = 0;
910 break;
911 default:
912 ret = 0;
913 break;
811 } 914 }
915 }
916 status = icalcomponent_get_status(comp);
917 if (ret && status) {
918 switch (status) {
919 case ICAL_STATUS_CANCELLED:
920 case ICAL_STATUS_TENTATIVE:
921 ret = 0;
922 break;
923 default:
924 break;
925 }
926 }
927 return(ret);
928}
812 929
813 /* The end time could be specified as either a DTEND or a DURATION */
814 p = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY);
815 duration = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
816 930
817 if (p==0 && duration == 0 && start.is_date != 1) {
818 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
819 /*icalerror_warn("icalcomponent_get_span: component has neither DTEND nor DURATION time");*/
820 span.start = 0;
821 return span;
822 }
823 931
824 if (p!=0){
825 span.end = icalcomponent_convert_time(p);
826 } else if (start.is_date == 1) {
827 /* Duration is all day */
828 span.end = span.start + 60*60*24;
829 } else {
830 /* Use the duration */
831 struct icaldurationtype dur;
832 time_t durt;
833
834
835 dur = icalproperty_get_duration(duration);
836 932
837 durt = icaldurationtype_as_int(dur); 933/**
838 span.end = span.start+durt; 934 * @brief cycle through all recurrances of an event
935 *
936 * @param comp A valid VEVENT component
937 * @param start Ignore timespans before this
938 * @param end Ignore timespans after this
939 * @param callback Function called for each timespan within the range
940 * @param callback_data Pointer passed back to the callback function
941 *
942 * This function will call the specified callback function for once
943 * for the base value of DTSTART, and foreach recurring date/time
944 * value.
945 *
946 * It will filter out events that are specified as an EXDATE or an EXRULE.
947 *
948 * @todo We do not filter out duplicate RRULES/RDATES
949 * @todo We do not handle RDATEs with explicit periods
950 */
951
952void icalcomponent_foreach_recurrence(icalcomponent* comp,
953 struct icaltimetype start,
954 struct icaltimetype end,
955 void (*callback)(icalcomponent *comp,
956 struct icaltime_span *span,
957 void *data),
958 void *callback_data)
959{
960 struct icaltimetype dtstart, dtend;
961 icaltime_span recurspan, basespan, limit_span;
962 time_t limit_start, limit_end;
963 int dtduration;
964 icalproperty *rrule, *rdate;
965 struct icaldurationtype dur;
966 pvl_elem property_iterator;/* for saving the iterator */
967
968 if (comp == NULL || callback == NULL)
969 return;
970
971 dtstart = icalcomponent_get_dtstart(comp);
972
973 if (icaltime_is_null_time(dtstart))
974 return;
975
976
977 /* The end time could be specified as either a DTEND or a DURATION */
978 /* icalcomponent_get_dtend takes care of these cases. */
979 dtend = icalcomponent_get_dtend(comp);
980
981 /* Now set up the base span for this item, corresponding to the
982 base DTSTART and DTEND */
983 basespan = icaltime_span_new(dtstart, dtend, 1);
984
985 basespan.is_busy = icalcomponent_is_busy(comp);
986
987
988 /** Calculate the ceiling and floor values.. **/
989 limit_start = icaltime_as_timet_with_zone(start, icaltimezone_get_utc_timezone());
990 if (!icaltime_is_null_time(end))
991 limit_end = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone());
992 else
993 limit_end = INT_MAX; /* max 32 bit time_t */
994
995 limit_span.start = limit_start;
996 limit_span.end = limit_end;
997
998
999 /* Do the callback for the initial DTSTART entry */
1000
1001 if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &dtstart)) {
1002 /** call callback action **/
1003 if (icaltime_span_overlaps(&basespan, &limit_span))
1004 (*callback) (comp, &basespan, callback_data);
1005 }
1006
1007 recurspan = basespan;
1008 dtduration = basespan.end - basespan.start;
1009
1010 /* Now cycle through the rrule entries */
1011 for (rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY);
1012 rrule != NULL;
1013 rrule = icalcomponent_get_next_property(comp,ICAL_RRULE_PROPERTY)) {
1014
1015 struct icalrecurrencetype recur = icalproperty_get_rrule(rrule);
1016 icalrecur_iterator *rrule_itr = icalrecur_iterator_new(recur, dtstart);
1017 struct icaltimetype rrule_time = icalrecur_iterator_next(rrule_itr);
1018 /** note that icalrecur_iterator_next always returns dtstart
1019 the first time.. **/
1020
1021 while (1) {
1022 rrule_time = icalrecur_iterator_next(rrule_itr);
1023
1024 if (icaltime_is_null_time(rrule_time))
1025 break;
1026
1027 dur = icaltime_subtract(rrule_time, dtstart);
1028
1029 recurspan.start = basespan.start + icaldurationtype_as_int(dur);
1030 recurspan.end = recurspan.start + dtduration;
1031
1032 /** save the iterator ICK! **/
1033 property_iterator = comp->property_iterator;
1034
1035 if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rrule_time)) {
1036 /** call callback action **/
1037 if (icaltime_span_overlaps(&recurspan, &limit_span))
1038 (*callback) (comp, &recurspan, callback_data);
1039 }
1040 comp->property_iterator = property_iterator;
1041 } /* end of iteration over a specific RRULE */
1042
1043 icalrecur_iterator_free(rrule_itr);
1044 } /* end of RRULE loop */
1045
1046
1047 /** Now process RDATE entries **/
1048 for (rdate = icalcomponent_get_first_property(comp,ICAL_RDATE_PROPERTY);
1049 rdate != NULL;
1050 rdate = icalcomponent_get_next_property(comp,ICAL_RDATE_PROPERTY)) {
1051
1052 struct icaldatetimeperiodtype rdate_period = icalproperty_get_rdate(rdate);
1053
1054 /** RDATES can specify raw datetimes, periods, or dates.
1055 we only support raw datetimes for now..
1056
1057 @todo Add support for other types **/
1058
1059 if (icaltime_is_null_time(rdate_period.time))
1060 continue;
1061
1062 dur = icaltime_subtract(rdate_period.time, dtstart);
1063
1064 recurspan.start = basespan.start + icaldurationtype_as_int(dur);
1065 recurspan.end = recurspan.start + dtduration;
1066
1067 /** save the iterator ICK! **/
1068 property_iterator = comp->property_iterator;
1069
1070 if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rdate_period.time)) {
1071 /** call callback action **/
1072 (*callback) (comp, &recurspan, callback_data);
839 } 1073 }
1074 comp->property_iterator = property_iterator;
1075 }
1076}
1077
840 1078
841 return span;
842 1079
1080int icalcomponent_check_restrictions(icalcomponent* comp){
1081 icalerror_check_arg_rz(comp!=0,"comp");
1082 return icalrestriction_check(comp);
843} 1083}
844 1084
1085/** @brief returns the number of errors encountered parsing the data
1086 *
1087 * This function counts the number times the X-LIC-ERROR occurs
1088 * in the data structure.
1089 */
845 1090
@@ -851,5 +1096,4 @@ int icalcomponent_count_errors(icalcomponent* component)
851 pvl_elem itr; 1096 pvl_elem itr;
852 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
853 1097
854 for( itr = pvl_head(impl->properties); 1098 for( itr = pvl_head(component->properties);
855 itr != 0; 1099 itr != 0;
@@ -866,3 +1110,3 @@ int icalcomponent_count_errors(icalcomponent* component)
866 1110
867 for( itr = pvl_head(impl->components); 1111 for( itr = pvl_head(component->components);
868 itr != 0; 1112 itr != 0;
@@ -885,5 +1129,4 @@ void icalcomponent_strip_errors(icalcomponent* component)
885 pvl_elem itr, next_itr; 1129 pvl_elem itr, next_itr;
886 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
887 1130
888 for( itr = pvl_head(impl->properties); 1131 for( itr = pvl_head(component->properties);
889 itr != 0; 1132 itr != 0;
@@ -900,3 +1143,3 @@ void icalcomponent_strip_errors(icalcomponent* component)
900 1143
901 for( itr = pvl_head(impl->components); 1144 for( itr = pvl_head(component->components);
902 itr != 0; 1145 itr != 0;
@@ -954,2 +1197,3 @@ void icalcomponent_convert_errors(icalcomponent* component)
954 default: { 1197 default: {
1198 break;
955 } 1199 }
@@ -978,5 +1222,3 @@ icalcomponent* icalcomponent_get_parent(icalcomponent* component)
978{ 1222{
979 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 1223 return component->parent;
980
981 return c->parent;
982} 1224}
@@ -985,5 +1227,3 @@ void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent)
985{ 1227{
986 struct icalcomponent_impl *c = (struct icalcomponent_impl*)component; 1228 component->parent = parent;
987
988 c->parent = parent;
989} 1229}
@@ -1006,2 +1246,3 @@ static struct icalcomponent_kind_map component_map[] =
1006 { ICAL_VCALENDAR_COMPONENT, "VCALENDAR" }, 1246 { ICAL_VCALENDAR_COMPONENT, "VCALENDAR" },
1247 { ICAL_VAGENDA_COMPONENT, "VAGENDA" },
1007 { ICAL_VFREEBUSY_COMPONENT, "VFREEBUSY" }, 1248 { ICAL_VFREEBUSY_COMPONENT, "VFREEBUSY" },
@@ -1030,2 +1271,12 @@ static struct icalcomponent_kind_map component_map[] =
1030 1271
1272int icalcomponent_kind_is_valid(const icalcomponent_kind kind)
1273{
1274 int i = 0;
1275 do {
1276 if (component_map[i].kind == kind)
1277 return 1;
1278 } while (component_map[i++].kind != ICAL_NO_COMPONENT);
1279
1280 return 0;
1281}
1031 1282
@@ -1067,4 +1318,3 @@ icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind)
1067{ 1318{
1068 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component; 1319 icalcompiter itr;
1069 icalcompiter itr = icalcompiter_null;
1070 pvl_elem i; 1320 pvl_elem i;
@@ -1072,6 +1322,7 @@ icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind)
1072 itr.kind = kind; 1322 itr.kind = kind;
1323 itr.iter = NULL;
1073 1324
1074 icalerror_check_arg_re( (component!=0),"component",icalcompiter_null); 1325 icalerror_check_arg_re(component!=0,"component",icalcompiter_null);
1075 1326
1076 for( i = pvl_head(impl->components); i != 0; i = pvl_next(itr.iter)) { 1327 for( i = pvl_head(component->components); i != 0; i = pvl_next(i)) {
1077 1328
@@ -1093,3 +1344,2 @@ icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind)
1093{ 1344{
1094 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
1095 icalcompiter itr; 1345 icalcompiter itr;
@@ -1099,5 +1349,5 @@ icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind)
1099 1349
1100 icalerror_check_arg_re( (component!=0),"component",icalcompiter_null); 1350 icalerror_check_arg_re(component!=0,"component",icalcompiter_null);
1101 1351
1102 for( i = pvl_tail(impl->components); i != 0; i = pvl_prior(i)) { 1352 for( i = pvl_tail(component->components); i != 0; i = pvl_prior(i)) {
1103 1353
@@ -1182,10 +1432,56 @@ icalcomponent* icalcomponent_get_inner(icalcomponent* comp)
1182 1432
1433/** @brief sets the METHOD property to the given method
1434 */
1183 1435
1184void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v) 1436void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method)
1185{ 1437{
1438 icalproperty *prop
1439 = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY);
1186 1440
1187 icalcomponent *inner = icalcomponent_get_inner(comp); 1441
1442 if (prop == 0){
1443 prop = icalproperty_new_method(method);
1444 icalcomponent_add_property(comp, prop);
1445 }
1446
1447 icalproperty_set_method(prop,method);
1448
1449}
1450
1451/** @brief returns the METHOD property
1452 */
1453
1454icalproperty_method icalcomponent_get_method(icalcomponent* comp)
1455{
1188 icalproperty *prop 1456 icalproperty *prop
1189 = icalcomponent_get_first_property(inner, ICAL_DTSTART_PROPERTY); 1457 = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY);
1190 1458
1459 if (prop == 0){
1460 return ICAL_METHOD_NONE;
1461 }
1462
1463 return icalproperty_get_method(prop);
1464}
1465
1466#define ICALSETUPSET(p_kind) \
1467 icalcomponent *inner; \
1468 icalproperty *prop; \
1469 icalerror_check_arg_rv(comp!=0,"comp");\
1470 inner = icalcomponent_get_inner(comp); \
1471 if(inner == 0){\
1472 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);\
1473 return;\
1474 }\
1475 prop = icalcomponent_get_first_property(inner, p_kind);
1476
1477
1478 /**@brief Set DTSTART property to given icaltime
1479 *
1480 *This method respects the icaltime type (DATE vs DATE-TIME) and
1481 *timezone (or lack thereof).
1482 */
1483void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v)
1484{
1485 char *tzid;
1486 ICALSETUPSET(ICAL_DTSTART_PROPERTY);
1191 1487
@@ -1194,2 +1490,4 @@ void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v)
1194 icalcomponent_add_property(inner, prop); 1490 icalcomponent_add_property(inner, prop);
1491 } else {
1492 icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);
1195 } 1493 }
@@ -1198,5 +1496,46 @@ void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v)
1198 1496
1497 if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) {
1498 icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid));
1499 }
1199} 1500}
1200 1501
1502 /**@brief Get a DATE or DATE-TIME property as an icaltime
1503 *
1504 *If the property is a DATE-TIME with a timezone parameter and a
1505 *corresponding VTIMEZONE is present in the component, the
1506 *returned component will already be in the correct timezone;
1507 *otherwise the caller is responsible for converting it.
1508 *
1509 *FIXME this is useless until we can flag the failure
1510 */
1511static struct icaltimetype
1512icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop) {
1513
1514 icalparameter *param;
1515 struct icaltimetyperet;
1516
1517 ret = icalvalue_get_datetime(icalproperty_get_value(prop));
1518
1519 if ((param = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER))
1520 != NULL) {
1521 const char *tzid = icalparameter_get_tzid(param);
1522 icaltimezone *tz;
1523
1524 if ((tz = icalcomponent_get_timezone(comp, tzid)) != NULL) {
1525 icaltime_set_timezone(&ret, tz);
1526 }
1527 }
1528
1529 return ret;
1530}
1201 1531
1532 /**@brief Get DTSTART property as an icaltime
1533 *
1534 *If DTSTART is a DATE-TIME with a timezone parameter and a
1535 *corresponding VTIMEZONE is present in the component, the
1536 *returned component will already be in the correct timezone;
1537 *otherwise the caller is responsible for converting it.
1538 *
1539 *FIXME this is useless until we can flag the failure
1540 */
1202struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp) 1541struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp)
@@ -1204,5 +1543,5 @@ struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp)
1204 icalcomponent *inner = icalcomponent_get_inner(comp); 1543 icalcomponent *inner = icalcomponent_get_inner(comp);
1205 icalproperty *prop 1544 icalproperty *prop;
1206 = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
1207 1545
1546 prop = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
1208 if (prop == 0){ 1547 if (prop == 0){
@@ -1210,7 +1549,18 @@ struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp)
1210 } 1549 }
1211
1212 return icalproperty_get_dtstart(prop);
1213}
1214 1550
1551 return icalcomponent_get_datetime(comp, prop);
1552}
1215 1553
1554 /**@brief Get DTEND property as an icaltime
1555 *
1556 *If a DTEND property is not present but a DURATION is, we use
1557 *that to determine the proper end.
1558 *
1559 *If DTSTART is a DATE-TIME with a timezone parameter and a
1560 *corresponding VTIMEZONE is present in the component, the
1561 *returned component will already be in the correct timezone;
1562 *otherwise the caller is responsible for converting it.
1563 *
1564 *FIXME this is useless until we can flag the failure
1565 */
1216struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp) 1566struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp)
@@ -1218,16 +1568,12 @@ struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp)
1218 icalcomponent *inner = icalcomponent_get_inner(comp); 1568 icalcomponent *inner = icalcomponent_get_inner(comp);
1219
1220 icalproperty *end_prop 1569 icalproperty *end_prop
1221 = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); 1570 = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
1222
1223 icalproperty *dur_prop 1571 icalproperty *dur_prop
1224 = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); 1572 = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
1573 struct icaltimetyperet = icaltime_null_time();
1225 1574
1226 1575 if ( end_prop != 0) {
1227 if( end_prop == 0 && dur_prop == 0){ 1576 ret = icalcomponent_get_datetime(comp, end_prop);
1228 return icaltime_null_time();
1229 } else if ( end_prop != 0) {
1230 return icalproperty_get_dtend(end_prop);
1231 } else if ( dur_prop != 0) { 1577 } else if ( dur_prop != 0) {
1232 1578
1233 struct icaltimetype start = 1579 struct icaltimetype start =
@@ -1236,48 +1582,42 @@ struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp)
1236 icalproperty_get_duration(dur_prop); 1582 icalproperty_get_duration(dur_prop);
1237
1238 struct icaltimetype end = icaltime_add(start,duration);
1239 1583
1240 return end; 1584 struct icaltimetype end = icaltime_add(start,duration);
1241
1242 } else {
1243 /* Error, both duration and dtend have been specified */
1244 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1245 return icaltime_null_time();
1246 1585
1586 ret = end;
1247 } 1587 }
1248
1249}
1250 1588
1589 return ret;
1590}
1251 1591
1592 /**@brief Set DTEND property to given icaltime
1593 *
1594 *This method respects the icaltime type (DATE vs DATE-TIME) and
1595 *timezone (or lack thereof).
1596 *
1597 *This also checks that a DURATION property isn't already there,
1598 *and returns an error if it is. It's the caller's responsibility
1599 *to remove it.
1600 */
1252void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v) 1601void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v)
1253{ 1602{
1254 icalcomponent *inner = icalcomponent_get_inner(comp); 1603 char *tzid;
1255 1604 ICALSETUPSET(ICAL_DTEND_PROPERTY);
1256 icalproperty *end_prop
1257 = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
1258
1259 icalproperty *dur_prop
1260 = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
1261
1262 1605
1263 if( end_prop == 0 && dur_prop == 0){ 1606 if (icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY)
1264 end_prop = icalproperty_new_dtend(v); 1607 != NULL) {
1265 icalcomponent_add_property(inner,end_prop); 1608 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1266 } else if ( end_prop != 0) { 1609 return;
1267 icalproperty_set_dtend(end_prop,v); 1610 }
1268 } else if ( dur_prop != 0) {
1269 struct icaltimetype start =
1270 icalcomponent_get_dtstart(inner);
1271
1272 struct icaltimetype end =
1273 icalcomponent_get_dtend(inner);
1274 1611
1275 struct icaldurationtype dur 1612 if (prop == 0) {
1276 = icaltime_subtract(end,start); 1613 prop = icalproperty_new_dtend(v);
1614 icalcomponent_add_property(inner, prop);
1615 } else {
1616 icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);
1617 }
1277 1618
1278 icalproperty_set_duration(dur_prop,dur); 1619 icalproperty_set_dtend(prop,v);
1279 1620
1280 } else { 1621 if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) {
1281 /* Error, both duration and dtend have been specified */ 1622 icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid));
1282 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1283 } 1623 }
@@ -1285,2 +1625,11 @@ void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v)
1285 1625
1626 /**@brief Set DURATION property to given icalduration
1627 *
1628 *This method respects the icaltime type (DATE vs DATE-TIME) and
1629 *timezone (or lack thereof).
1630 *
1631 *This also checks that a DTEND property isn't already there,
1632 *and returns an error if it is. It's the caller's responsibility
1633 *to remove it.
1634 */
1286void icalcomponent_set_duration(icalcomponent* comp, 1635void icalcomponent_set_duration(icalcomponent* comp,
@@ -1288,27 +1637,14 @@ void icalcomponent_set_duration(icalcomponent* comp,
1288{ 1637{
1289 icalcomponent *inner = icalcomponent_get_inner(comp); 1638 ICALSETUPSET(ICAL_DURATION_PROPERTY);
1290
1291 icalproperty *end_prop
1292 = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
1293
1294 icalproperty *dur_prop
1295 = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
1296
1297
1298 if( end_prop == 0 && dur_prop == 0){
1299 dur_prop = icalproperty_new_duration(v);
1300 icalcomponent_add_property(inner, dur_prop);
1301 } else if ( end_prop != 0) {
1302 struct icaltimetype start =
1303 icalcomponent_get_dtstart(inner);
1304
1305 struct icaltimetype new_end = icaltime_add(start,v);
1306 1639
1307 icalproperty_set_dtend(end_prop,new_end); 1640 if (icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY) != NULL) {
1641 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1642 return;
1643 }
1308 1644
1309 } else if ( dur_prop != 0) { 1645 if (prop == 0) {
1310 icalproperty_set_duration(dur_prop,v); 1646 prop = icalproperty_new_duration(v);
1647 icalcomponent_add_property(inner, prop);
1311 } else { 1648 } else {
1312 /* Error, both duration and dtend have been specified */ 1649 icalproperty_set_duration(prop,v);
1313 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1314 } 1650 }
@@ -1316,2 +1652,7 @@ void icalcomponent_set_duration(icalcomponent* comp,
1316 1652
1653 /**@brief Get DURATION property as an icalduration
1654 *
1655 *If a DURATION property is not present but a DTEND is, we use
1656 *that to determine the proper end.
1657 */
1317struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp) 1658struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp)
@@ -1326,20 +1667,19 @@ struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp)
1326 1667
1327 struct icaldurationtype null_duration; 1668 struct icaldurationtype ret = icaldurationtype_null_duration();
1328 memset(&null_duration,0,sizeof(struct icaldurationtype));
1329 1669
1670 if ( dur_prop != 0 && end_prop == 0) {
1671 ret = icalproperty_get_duration(dur_prop);
1330 1672
1331 if( end_prop == 0 && dur_prop == 0){ 1673 } else if ( end_prop != 0 && dur_prop == 0) {
1332 return null_duration; 1674 /**
1333 } else if ( end_prop != 0) { 1675 * FIXME
1676 * We assume DTSTART and DTEND are not in different time zones.
1677 * Does the standard actually guarantee this?
1678 */
1334 struct icaltimetype start = 1679 struct icaltimetype start =
1335 icalcomponent_get_dtstart(inner); 1680 icalcomponent_get_dtstart(inner);
1336 time_t startt = icaltime_as_timet(start);
1337
1338 struct icaltimetype end = 1681 struct icaltimetype end =
1339 icalcomponent_get_dtend(inner); 1682 icalcomponent_get_dtend(inner);
1340 time_t endt = icaltime_as_timet(end); 1683
1341 1684 ret = icaltime_subtract(end, start);
1342 return icaldurationtype_from_int(endt-startt);
1343 } else if ( dur_prop != 0) {
1344 return icalproperty_get_duration(dur_prop);
1345 } else { 1685 } else {
@@ -1347,18 +1687,17 @@ struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp)
1347 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 1687 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1348 return null_duration;
1349 } 1688 }
1689 return ret;
1350} 1690}
1351 1691
1352void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method) 1692void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v)
1353{ 1693{
1354 icalproperty *prop
1355 = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY);
1356 1694
1695 ICALSETUPSET(ICAL_DTSTAMP_PROPERTY);
1357 1696
1358 if (prop == 0){ 1697 if (prop == 0){
1359 prop = icalproperty_new_method(method); 1698 prop = icalproperty_new_dtstamp(v);
1360 icalcomponent_add_property(comp, prop); 1699 icalcomponent_add_property(inner, prop);
1361 } 1700 }
1362 1701
1363 icalproperty_set_method(prop,method); 1702 icalproperty_set_dtstamp(prop,v);
1364 1703
@@ -1366,28 +1705,50 @@ void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method)
1366 1705
1367icalproperty_method icalcomponent_get_method(icalcomponent* comp) 1706
1707struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp)
1368{ 1708{
1709 icalcomponent *inner = icalcomponent_get_inner(comp);
1369 icalproperty *prop 1710 icalproperty *prop
1370 = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY); 1711 = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
1371 1712
1372 if (prop == 0){ 1713 if (prop == 0){
1373 return ICAL_METHOD_NONE; 1714 return icaltime_null_time();
1374 } 1715 }
1375 1716
1376 return icalproperty_get_method(prop); 1717 return icalproperty_get_dtstamp(prop);
1377} 1718}
1378 1719
1379void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v) 1720
1721void icalcomponent_set_summary(icalcomponent* comp, const char* v)
1722{
1723 ICALSETUPSET(ICAL_SUMMARY_PROPERTY)
1724
1725 if (prop == 0){
1726 prop = icalproperty_new_summary(v);
1727 icalcomponent_add_property(inner, prop);
1728 }
1729
1730 icalproperty_set_summary(prop,v);
1731}
1732
1733
1734const char* icalcomponent_get_summary(icalcomponent* comp)
1380{ 1735{
1736 icalcomponent *inner;
1737 icalproperty *prop;
1738 icalerror_check_arg_rz(comp!=0,"comp");
1381 1739
1382 icalcomponent *inner = icalcomponent_get_inner(comp); 1740 inner = icalcomponent_get_inner(comp);
1383 icalproperty *prop 1741
1384 = icalcomponent_get_first_property(inner, ICAL_DTSTAMP_PROPERTY); 1742 if(inner == 0){
1743 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1744 return 0;
1745 }
1385 1746
1747 prop= icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY);
1386 1748
1387 if (prop == 0){ 1749 if (prop == 0){
1388 prop = icalproperty_new_dtstamp(v); 1750 return 0;
1389 icalcomponent_add_property(inner, prop);
1390 } 1751 }
1391 1752
1392 icalproperty_set_dtstamp(prop,v); 1753 return icalproperty_get_summary(prop);
1393 1754
@@ -1395,37 +1756,60 @@ void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v)
1395 1756
1396 1757void icalcomponent_set_comment(icalcomponent* comp, const char* v)
1397struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp)
1398{ 1758{
1399 icalcomponent *inner = icalcomponent_get_inner(comp); 1759 ICALSETUPSET(ICAL_COMMENT_PROPERTY);
1400 icalproperty *prop
1401 = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
1402 1760
1403 if (prop == 0){ 1761 if (prop == 0){
1404 return icaltime_null_time(); 1762 prop = icalproperty_new_comment(v);
1763 icalcomponent_add_property(inner, prop);
1405 } 1764 }
1406 1765
1407 return icalproperty_get_dtstamp(prop); 1766 icalproperty_set_summary(prop,v);
1767
1408} 1768}
1769const char* icalcomponent_get_comment(icalcomponent* comp){
1770 icalcomponent *inner;
1771 icalproperty *prop;
1772 icalerror_check_arg_rz(comp!=0,"comp");
1409 1773
1774 inner = icalcomponent_get_inner(comp);
1410 1775
1411void icalcomponent_set_summary(icalcomponent* comp, const char* v) 1776 if(inner == 0){
1777 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1778 return 0;
1779 }
1780
1781 prop= icalcomponent_get_first_property(inner,ICAL_COMMENT_PROPERTY);
1782
1783 if (prop == 0){
1784 return 0;
1785 }
1786
1787 return icalproperty_get_comment(prop);
1788}
1789
1790void icalcomponent_set_uid(icalcomponent* comp, const char* v)
1412{ 1791{
1413 icalcomponent *inner = icalcomponent_get_inner(comp); 1792 ICALSETUPSET(ICAL_UID_PROPERTY);
1414 icalproperty *prop
1415 = icalcomponent_get_first_property(inner, ICAL_SUMMARY_PROPERTY);
1416 1793
1417 if (prop == 0){ 1794 if (prop == 0){
1418 prop = icalproperty_new_summary(v); 1795 prop = icalproperty_new_uid(v);
1419 icalcomponent_add_property(inner, prop); 1796 icalcomponent_add_property(inner, prop);
1420 } 1797 }
1421 1798
1422 icalproperty_set_summary(prop,v); 1799 icalproperty_set_summary(prop,v);
1800
1423} 1801}
1802const char* icalcomponent_get_uid(icalcomponent* comp){
1803 icalcomponent *inner;
1804 icalproperty *prop;
1805 icalerror_check_arg_rz(comp!=0,"comp");
1424 1806
1807 inner = icalcomponent_get_inner(comp);
1425 1808
1426const char* icalcomponent_get_summary(icalcomponent* comp) 1809 if(inner == 0){
1427{ 1810 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1428 icalcomponent *inner = icalcomponent_get_inner(comp); 1811 return 0;
1429 icalproperty *prop 1812 }
1430 = icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY); 1813
1814 prop= icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
1431 1815
@@ -1435,18 +1819,173 @@ const char* icalcomponent_get_summary(icalcomponent* comp)
1435 1819
1436 return icalproperty_get_summary(prop); 1820 return icalproperty_get_uid(prop);
1821}
1437 1822
1823void icalcomponent_set_recurrenceid(icalcomponent* comp, struct icaltimetype v)
1824{
1825 ICALSETUPSET(ICAL_RECURRENCEID_PROPERTY);
1826
1827 if (prop == 0){
1828 prop = icalproperty_new_recurrenceid(v);
1829 icalcomponent_add_property(inner, prop);
1830 }
1831
1832 icalproperty_set_recurrenceid(prop,v);
1438} 1833}
1834struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp)
1835{
1836 icalcomponent *inner;
1837 icalproperty *prop;
1838 if (comp == 0) {
1839 icalerror_set_errno(ICAL_BADARG_ERROR);
1840 return icaltime_null_time();
1841 }
1439 1842
1440void icalcomponent_set_comment(icalcomponent* comp, const char* v); 1843 inner = icalcomponent_get_inner(comp);
1441const char* icalcomponent_get_comment(icalcomponent* comp);
1442 1844
1443void icalcomponent_set_uid(icalcomponent* comp, const char* v); 1845 if(inner == 0){
1444const char* icalcomponent_get_uid(icalcomponent* comp); 1846 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1847 return icaltime_null_time();
1848 }
1445 1849
1446void icalcomponent_set_recurrenceid(icalcomponent* comp, 1850 prop= icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);
1447 struct icaltimetype v);
1448struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
1449 1851
1852 if (prop == 0){
1853 return icaltime_null_time();
1854 }
1855
1856 return icalproperty_get_recurrenceid(prop);
1857}
1858
1859void icalcomponent_set_description(icalcomponent* comp, const char* v)
1860{
1861 ICALSETUPSET(ICAL_DESCRIPTION_PROPERTY);
1862
1863 if (prop == 0){
1864 prop = icalproperty_new_description(v);
1865 icalcomponent_add_property(inner, prop);
1866 }
1867
1868 icalproperty_set_description(prop,v);
1869}
1870const char* icalcomponent_get_description(icalcomponent* comp)
1871{
1872 icalcomponent *inner;
1873 icalproperty *prop;
1874 icalerror_check_arg_rz(comp!=0,"comp");
1875
1876 inner = icalcomponent_get_inner(comp);
1877
1878 if(inner == 0){
1879 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1880 return 0;
1881 }
1882
1883 prop= icalcomponent_get_first_property(inner,ICAL_DESCRIPTION_PROPERTY);
1884
1885 if (prop == 0){
1886 return 0;
1887 }
1888
1889 return icalproperty_get_description(prop);
1890}
1891
1892void icalcomponent_set_location(icalcomponent* comp, const char* v)
1893{
1894 ICALSETUPSET(ICAL_LOCATION_PROPERTY)
1895
1896 if (prop == 0){
1897 prop = icalproperty_new_location(v);
1898 icalcomponent_add_property(inner, prop);
1899 }
1900
1901 icalproperty_set_location(prop,v);
1902}
1903const char* icalcomponent_get_location(icalcomponent* comp)
1904{
1905 icalcomponent *inner;
1906 icalproperty *prop;
1907 icalerror_check_arg_rz(comp!=0,"comp");
1908
1909 inner = icalcomponent_get_inner(comp);
1910
1911 if(inner == 0){
1912 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1913 return 0;
1914 }
1915
1916 prop= icalcomponent_get_first_property(inner,ICAL_LOCATION_PROPERTY);
1450 1917
1918 if (prop == 0){
1919 return 0;
1920 }
1921
1922 return icalproperty_get_location(prop);
1923}
1924
1925void icalcomponent_set_sequence(icalcomponent* comp, int v)
1926{
1927 ICALSETUPSET(ICAL_SEQUENCE_PROPERTY);
1928
1929 if (prop == 0){
1930 prop = icalproperty_new_sequence(v);
1931 icalcomponent_add_property(inner, prop);
1932 }
1933
1934 icalproperty_set_sequence(prop,v);
1935
1936}
1937int icalcomponent_get_sequence(icalcomponent* comp){
1938 icalcomponent *inner;
1939 icalproperty *prop;
1940 icalerror_check_arg_rz(comp!=0,"comp");
1941
1942 inner = icalcomponent_get_inner(comp);
1943
1944 if(inner == 0){
1945 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1946 return 0;
1947 }
1948
1949 prop= icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY);
1950
1951 if (prop == 0){
1952 return 0;
1953 }
1954
1955 return icalproperty_get_sequence(prop);
1956}
1957
1958
1959void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v)
1960{
1961 ICALSETUPSET(ICAL_STATUS_PROPERTY);
1962
1963 if (prop == 0){
1964 prop = icalproperty_new_status(v);
1965 icalcomponent_add_property(inner, prop);
1966 }
1967
1968 icalproperty_set_status(prop,v);
1969
1970}
1971enum icalproperty_status icalcomponent_get_status(icalcomponent* comp){
1972 icalcomponent *inner;
1973 icalproperty *prop;
1974 icalerror_check_arg_rz(comp!=0,"comp");
1975
1976 inner = icalcomponent_get_inner(comp);
1977
1978 if(inner == 0){
1979 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1980 return 0;
1981 }
1451 1982
1983 prop= icalcomponent_get_first_property(inner,ICAL_STATUS_PROPERTY);
1984
1985 if (prop == 0){
1986 return 0;
1987 }
1988
1989 return icalproperty_get_status(prop);
1990}
1452 1991
@@ -1488 +2027,569 @@ icalcomponent* icalcomponent_new_xdaylight()
1488} 2027}
2028icalcomponent* icalcomponent_new_vagenda()
2029{
2030 return icalcomponent_new(ICAL_VAGENDA_COMPONENT);
2031}
2032icalcomponent* icalcomponent_new_vquery()
2033{
2034 return icalcomponent_new(ICAL_VQUERY_COMPONENT);
2035}
2036
2037/*
2038 * Timezone stuff.
2039 */
2040
2041
2042/**
2043 * This takes 2 VCALENDAR components and merges the second one into the first,
2044 * resolving any problems with conflicting TZIDs. comp_to_merge will no
2045 * longer exist after calling this function.
2046 */
2047void icalcomponent_merge_component(icalcomponent* comp,
2048 icalcomponent* comp_to_merge)
2049{
2050 icalcomponent *subcomp, *next_subcomp;
2051 icalarray *tzids_to_rename;
2052 int i;
2053
2054 /* Check that both components are VCALENDAR components. */
2055 assert (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT);
2056 assert (icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT);
2057
2058 /* Step through each subcomponent of comp_to_merge, looking for VTIMEZONEs.
2059 For each VTIMEZONE found, check if we need to add it to comp and if we
2060 need to rename it and all TZID references to it. */
2061 tzids_to_rename = icalarray_new (sizeof (char*), 16);
2062 subcomp = icalcomponent_get_first_component (comp_to_merge,
2063 ICAL_VTIMEZONE_COMPONENT);
2064 while (subcomp) {
2065 next_subcomp = icalcomponent_get_next_component (comp_to_merge,
2066 ICAL_VTIMEZONE_COMPONENT);
2067 /* This will add the VTIMEZONE to comp, if necessary, and also update
2068 the array of TZIDs we need to rename. */
2069 icalcomponent_merge_vtimezone (comp, subcomp, tzids_to_rename);
2070 /* FIXME: Handle possible NEWFAILED error. */
2071
2072 subcomp = next_subcomp;
2073 }
2074
2075 /* If we need to do any renaming of TZIDs, do it now. */
2076 if (tzids_to_rename->num_elements != 0) {
2077 icalcomponent_rename_tzids (comp_to_merge, tzids_to_rename);
2078
2079 /* Now free the tzids_to_rename array. */
2080 for (i = 0; i < tzids_to_rename->num_elements; i++) {
2081 free (icalarray_element_at (tzids_to_rename, i));
2082 }
2083 icalarray_free (tzids_to_rename);
2084 }
2085
2086 /* Now move all the components from comp_to_merge to comp, excluding
2087 VTIMEZONE components. */
2088 subcomp = icalcomponent_get_first_component (comp_to_merge,
2089 ICAL_ANY_COMPONENT);
2090 while (subcomp) {
2091 next_subcomp = icalcomponent_get_next_component (comp_to_merge,
2092 ICAL_ANY_COMPONENT);
2093 if (icalcomponent_isa(subcomp) != ICAL_VTIMEZONE_COMPONENT) {
2094 icalcomponent_remove_component (comp_to_merge, subcomp);
2095 icalcomponent_add_component (comp, subcomp);
2096 }
2097 subcomp = next_subcomp;
2098 }
2099
2100 /* Free comp_to_merge. We have moved most of the subcomponents over to
2101 comp now. */
2102 icalcomponent_free (comp_to_merge);
2103}
2104
2105
2106static void icalcomponent_merge_vtimezone (icalcomponent *comp,
2107 icalcomponent *vtimezone,
2108 icalarray *tzids_to_rename)
2109{
2110 icalproperty *tzid_prop;
2111 const char *tzid;
2112 char *tzid_copy;
2113 icaltimezone *existing_vtimezone;
2114
2115 /* Get the TZID of the VTIMEZONE. */
2116 tzid_prop = icalcomponent_get_first_property (vtimezone, ICAL_TZID_PROPERTY);
2117 if (!tzid_prop)
2118 return;
2119
2120 tzid = icalproperty_get_tzid (tzid_prop);
2121 if (!tzid)
2122 return;
2123
2124 /* See if there is already a VTIMEZONE in comp with the same TZID. */
2125 existing_vtimezone = icalcomponent_get_timezone (comp, tzid);
2126
2127 /* If there is no existing VTIMEZONE with the same TZID, we can just move
2128 the VTIMEZONE to comp and return. */
2129 if (!existing_vtimezone) {
2130 icalcomponent_remove_component (icalcomponent_get_parent (vtimezone),
2131 vtimezone);
2132 icalcomponent_add_component (comp, vtimezone);
2133 return;
2134 }
2135
2136 /* If the TZID has a '/' prefix, then we don't have to worry about the
2137 clashing TZIDs, as they are supposed to be exactly the same VTIMEZONE. */
2138 if (tzid[0] == '/')
2139 return;
2140
2141 /* Now we have two VTIMEZONEs with the same TZID (which isn't a globally
2142 unique one), so we compare the VTIMEZONE components to see if they are
2143 the same. If they are, we don't need to do anything. We make a copy of
2144 the tzid, since the parameter may get modified in these calls. */
2145 tzid_copy = strdup (tzid);
2146 if (!tzid_copy) {
2147 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
2148 return;
2149 }
2150
2151 if (!icalcomponent_compare_vtimezones (comp, vtimezone)) {
2152 /* FIXME: Handle possible NEWFAILED error. */
2153
2154 /* Now we have two different VTIMEZONEs with the same TZID. */
2155 icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop,
2156 tzid_copy, tzids_to_rename);
2157 }
2158 free (tzid_copy);
2159}
2160
2161
2162static void
2163icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp,
2164 icalcomponent *vtimezone,
2165 icalproperty *tzid_prop,
2166 const char *tzid,
2167 icalarray *tzids_to_rename)
2168{
2169 int i, suffix, max_suffix = 0, num_elements;
2170 unsigned int tzid_len;
2171 char *tzid_copy, *new_tzid, suffix_buf[32];
2172
2173 /* Find the length of the TZID without any trailing digits. */
2174 tzid_len = icalcomponent_get_tzid_prefix_len (tzid);
2175
2176 /* Step through each of the VTIMEZONEs in comp. We may already have the
2177 clashing VTIMEZONE in the calendar, but it may have been renamed
2178 (i.e. a unique number added on the end of the TZID, e.g. 'London2').
2179 So we compare the new VTIMEZONE with any VTIMEZONEs that have the
2180 same prefix (e.g. 'London'). If it matches any of those, we have to
2181 rename the TZIDs to that TZID, else we rename to a new TZID, using
2182 the biggest numeric suffix found + 1. */
2183 num_elements = comp->timezones ? comp->timezones->num_elements : 0;
2184 for (i = 0; i < num_elements; i++) {
2185 icaltimezone *zone;
2186 char *existing_tzid, *existing_tzid_copy;
2187 unsigned int existing_tzid_len;
2188
2189 zone = icalarray_element_at (comp->timezones, i);
2190 existing_tzid = icaltimezone_get_tzid (zone);
2191
2192 /* Find the length of the TZID without any trailing digits. */
2193 existing_tzid_len = icalcomponent_get_tzid_prefix_len (existing_tzid);
2194
2195 /* Check if we have the same prefix. */
2196 if (tzid_len == existing_tzid_len
2197 && !strncmp (tzid, existing_tzid, tzid_len)) {
2198 /* Compare the VTIMEZONEs. */
2199 if (icalcomponent_compare_vtimezones (icaltimezone_get_component (zone),
2200 vtimezone)) {
2201 /* The VTIMEZONEs match, so we can use the existing VTIMEZONE. But
2202 we have to rename TZIDs to this TZID. */
2203 tzid_copy = strdup (tzid);
2204 existing_tzid_copy = strdup (existing_tzid);
2205 if (!tzid_copy || !existing_tzid_copy) {
2206 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
2207 } else {
2208 icalarray_append (tzids_to_rename, tzid_copy);
2209 icalarray_append (tzids_to_rename, existing_tzid_copy);
2210 }
2211 return;
2212 } else {
2213 /* FIXME: Handle possible NEWFAILED error. */
2214
2215 /* Convert the suffix to an integer and remember the maximum numeric
2216 suffix found. */
2217 suffix = atoi (existing_tzid + existing_tzid_len);
2218 if (max_suffix < suffix)
2219 max_suffix = suffix;
2220 }
2221 }
2222 }
2223
2224 /* We didn't find a VTIMEZONE that matched, so we have to rename the TZID,
2225 using the maximum numerical suffix found + 1. */
2226 tzid_copy = strdup (tzid);
2227 sprintf (suffix_buf, "%i", max_suffix + 1);
2228 new_tzid = malloc (tzid_len + strlen (suffix_buf) + 1);
2229 if (!new_tzid || !tzid_copy) {
2230 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
2231 return;
2232 }
2233
2234 strncpy (new_tzid, tzid, tzid_len);
2235 strcpy (new_tzid + tzid_len, suffix_buf);
2236 icalarray_append (tzids_to_rename, tzid_copy);
2237 icalarray_append (tzids_to_rename, new_tzid);
2238}
2239
2240
2241/* Returns the length of the TZID, without any trailing digits. */
2242static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid)
2243{
2244 int len;
2245 const char *p;
2246
2247 len = strlen (tzid);
2248 p = tzid + len - 1;
2249 while (len > 0 && *p >= '0' && *p <= '9') {
2250 p--;
2251 len--;
2252 }
2253
2254 return len;
2255}
2256
2257
2258/**
2259 * Renames all references to the given TZIDs to a new name. rename_table
2260 * contains pairs of strings - a current TZID, and the new TZID to rename it
2261 * to.
2262 */
2263static void icalcomponent_rename_tzids(icalcomponent* comp,
2264 icalarray* rename_table)
2265{
2266 icalcomponent_foreach_tzid (comp, icalcomponent_rename_tzids_callback,
2267 rename_table);
2268}
2269
2270
2271static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data)
2272{
2273 icalarray *rename_table = data;
2274 const char *tzid;
2275 int i;
2276
2277 tzid = icalparameter_get_tzid (param);
2278 if (!tzid)
2279 return;
2280
2281 /* Step through the rename table to see if the current TZID matches
2282 any of the ones we want to rename. */
2283 for (i = 0; i < rename_table->num_elements - 1; i += 2) {
2284 if (!strcmp (tzid, icalarray_element_at (rename_table, i))) {
2285 icalparameter_set_tzid (param, icalarray_element_at (rename_table, i + 1));
2286 break;
2287 }
2288 }
2289}
2290
2291
2292/**
2293 * Calls the given function for each TZID parameter found in the component.
2294 */
2295void icalcomponent_foreach_tzid(icalcomponent* comp,
2296 void (*callback)(icalparameter *param, void *data),
2297 void *callback_data)
2298{
2299 icalproperty *prop;
2300 icalproperty_kind kind;
2301 icalparameter *param;
2302 icalcomponent *subcomp;
2303
2304 /* First look for any TZID parameters used in this component itself. */
2305 prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
2306 while (prop) {
2307 kind = icalproperty_isa (prop);
2308
2309 /* These are the only properties that can have a TZID. Note that
2310 COMPLETED, CREATED, DTSTAMP & LASTMODIFIED must be in UTC. */
2311 if (kind == ICAL_DTSTART_PROPERTY || kind == ICAL_DTEND_PROPERTY
2312 || kind == ICAL_DUE_PROPERTY || kind == ICAL_EXDATE_PROPERTY
2313 || kind == ICAL_RDATE_PROPERTY) {
2314 param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
2315 if (param)
2316 (*callback) (param, callback_data);
2317 }
2318
2319 prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
2320 }
2321
2322 /* Now recursively check child components. */
2323 subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
2324 while (subcomp) {
2325 icalcomponent_foreach_tzid (subcomp, callback, callback_data);
2326 subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT);
2327 }
2328}
2329
2330
2331
2332/**
2333 * Returns the icaltimezone from the component corresponding to the given
2334 * TZID, or NULL if the component does not have a corresponding VTIMEZONE.
2335 */
2336icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid)
2337{
2338 icaltimezone *zone;
2339 int lower, upper, middle, cmp;
2340 char *zone_tzid;
2341
2342 if (!comp->timezones)
2343 return NULL;
2344
2345 /* Sort the array if necessary (by the TZID string). */
2346 if (!comp->timezones_sorted) {
2347 icalarray_sort (comp->timezones, icalcomponent_compare_timezone_fn);
2348 comp->timezones_sorted = 1;
2349 }
2350
2351 /* Do a simple binary search. */
2352 lower = middle = 0;
2353 upper = comp->timezones->num_elements;
2354
2355 while (lower < upper) {
2356 middle = (lower + upper) >> 1;
2357 zone = icalarray_element_at (comp->timezones, middle);
2358 zone_tzid = icaltimezone_get_tzid (zone);
2359 cmp = strcmp (tzid, zone_tzid);
2360 if (cmp == 0)
2361 return zone;
2362 else if (cmp < 0)
2363 upper = middle;
2364 else
2365 lower = middle + 1;
2366 }
2367
2368 return NULL;
2369}
2370
2371
2372/**
2373 * A function to compare 2 icaltimezone elements, used for qsort().
2374 */
2375 static int icalcomponent_compare_timezone_fn (const void*elem1,
2376 const void*elem2)
2377{
2378 icaltimezone *zone1, *zone2;
2379 const char *zone1_tzid, *zone2_tzid;
2380
2381 zone1 = (icaltimezone*) elem1;
2382 zone2 = (icaltimezone*) elem2;
2383
2384 zone1_tzid = icaltimezone_get_tzid (zone1);
2385 zone2_tzid = icaltimezone_get_tzid (zone2);
2386
2387 return strcmp (zone1_tzid, zone2_tzid);
2388}
2389
2390
2391/**
2392 * Compares 2 VTIMEZONE components to see if they match, ignoring their TZIDs.
2393 * It returns 1 if they match, 0 if they don't, or -1 on error.
2394 */
2395 static int icalcomponent_compare_vtimezones (icalcomponent*vtimezone1,
2396 icalcomponent*vtimezone2)
2397{
2398 icalproperty *prop1, *prop2;
2399 const char *tzid1, *tzid2;
2400 char *tzid2_copy, *string1, *string2;
2401 int cmp;
2402
2403 /* Get the TZID property of the first VTIMEZONE. */
2404 prop1 = icalcomponent_get_first_property (vtimezone1, ICAL_TZID_PROPERTY);
2405 if (!prop1)
2406 return -1;
2407
2408 tzid1 = icalproperty_get_tzid (prop1);
2409 if (!tzid1)
2410 return -1;
2411
2412 /* Get the TZID property of the second VTIMEZONE. */
2413 prop2 = icalcomponent_get_first_property (vtimezone2, ICAL_TZID_PROPERTY);
2414 if (!prop2)
2415 return -1;
2416
2417 tzid2 = icalproperty_get_tzid (prop2);
2418 if (!tzid2)
2419 return -1;
2420
2421 /* Copy the second TZID, and set the property to the same as the first
2422 TZID, since we don't care if these match of not. */
2423 tzid2_copy = strdup (tzid2);
2424 if (!tzid2_copy) {
2425 icalerror_set_errno (ICAL_NEWFAILED_ERROR);
2426 return 0;
2427 }
2428
2429 icalproperty_set_tzid (prop2, tzid1);
2430
2431 /* Now convert both VTIMEZONEs to strings and compare them. */
2432 string1 = icalcomponent_as_ical_string (vtimezone1);
2433 if (!string1) {
2434 free (tzid2_copy);
2435 return -1;
2436 }
2437
2438 string2 = icalcomponent_as_ical_string (vtimezone2);
2439 if (!string2) {
2440 free (string1);
2441 free (tzid2_copy);
2442 return -1;
2443 }
2444
2445 cmp = strcmp (string1, string2);
2446
2447 free (string1);
2448 free (string2);
2449
2450 /* Now reset the second TZID. */
2451 icalproperty_set_tzid (prop2, tzid2_copy);
2452 free (tzid2_copy);
2453
2454 return (cmp == 0) ? 1 : 0;
2455}
2456
2457
2458
2459
2460
2461
2462/**
2463 * @brief set the RELCALID property of a component.
2464 *
2465 * @param comp Valid calendar component.
2466 * @param v Relcalid URL value
2467 */
2468
2469void icalcomponent_set_relcalid(icalcomponent* comp, const char* v)
2470{
2471 ICALSETUPSET(ICAL_RELCALID_PROPERTY);
2472
2473 if (prop == 0){
2474 prop = icalproperty_new_relcalid(v);
2475 icalcomponent_add_property(inner, prop);
2476 }
2477
2478 icalproperty_set_relcalid(prop,v);
2479
2480}
2481
2482
2483/**
2484 * @brief get the RELCALID property of a component.
2485 *
2486 * @param comp Valid calendar component.
2487 */
2488
2489const char* icalcomponent_get_relcalid(icalcomponent* comp){
2490 icalcomponent *inner;
2491 icalproperty *prop;
2492 icalerror_check_arg_rz(comp!=0,"comp");
2493
2494 inner = icalcomponent_get_inner(comp);
2495
2496 if(inner == 0){
2497 return 0;
2498 }
2499
2500 prop= icalcomponent_get_first_property(inner,ICAL_RELCALID_PROPERTY);
2501
2502 if (prop == 0){
2503 return 0;
2504 }
2505
2506 return icalproperty_get_relcalid(prop);
2507}
2508
2509
2510/** @brief Return the time a TODO task is DUE.
2511 *
2512 * @param comp Valid calendar component.
2513 *
2514 * Uses the DUE: property if it exists, otherwise we calculate the DUE
2515 * value by adding the task's duration to the DTSTART time
2516 */
2517
2518struct icaltimetype icalcomponent_get_due(icalcomponent* comp)
2519{
2520 icalcomponent *inner = icalcomponent_get_inner(comp);
2521
2522 icalproperty *due_prop
2523 = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY);
2524
2525 icalproperty *dur_prop
2526 = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
2527
2528 if( due_prop == 0 && dur_prop == 0){
2529 return icaltime_null_time();
2530 } else if ( due_prop != 0) {
2531 return icalproperty_get_due(due_prop);
2532 } else if ( dur_prop != 0) {
2533
2534 struct icaltimetype start =
2535 icalcomponent_get_dtstart(inner);
2536 struct icaldurationtype duration =
2537 icalproperty_get_duration(dur_prop);
2538
2539 struct icaltimetype due = icaltime_add(start,duration);
2540
2541 return due;
2542
2543 } else {
2544 /* Error, both duration and due have been specified */
2545 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
2546 return icaltime_null_time();
2547
2548 }
2549
2550}
2551
2552/** @brief Set the due date of a VTODO task.
2553 *
2554 * @param comp Valid VTODO component.
2555 * @param v Valid due date time.
2556 *
2557 * - If no duration or due properties then set the DUE property.
2558 * - If a DUE property is already set, then reset it to the value v.
2559 * - If a DURATION property is already set, then calculate the new
2560 * duration based on the supplied value of v.
2561 */
2562
2563void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v)
2564{
2565 icalcomponent *inner = icalcomponent_get_inner(comp);
2566
2567 icalproperty *due_prop
2568 = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY);
2569
2570 icalproperty *dur_prop
2571 = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
2572
2573
2574 if( due_prop == 0 && dur_prop == 0){
2575 due_prop = icalproperty_new_due(v);
2576 icalcomponent_add_property(inner,due_prop);
2577 } else if ( due_prop != 0) {
2578 icalproperty_set_due(due_prop,v);
2579 } else if ( dur_prop != 0) {
2580 struct icaltimetype start =
2581 icalcomponent_get_dtstart(inner);
2582
2583 struct icaltimetype due =
2584 icalcomponent_get_due(inner);
2585
2586 struct icaldurationtype dur
2587 = icaltime_subtract(due,start);
2588
2589 icalproperty_set_duration(dur_prop,dur);
2590
2591 } else {
2592 /* Error, both duration and due have been specified */
2593 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
2594 }
2595}
diff --git a/libical/src/libical/icalcomponent.h b/libical/src/libical/icalcomponent.h
index 6046bbe..be9bf8c 100644
--- a/libical/src/libical/icalcomponent.h
+++ b/libical/src/libical/icalcomponent.h
@@ -29,6 +29,14 @@
29#include "icalenums.h" /* defines icalcomponent_kind */ 29#include "icalenums.h" /* defines icalcomponent_kind */
30#include "icalattendee.h"
31#include "pvl.h" 30#include "pvl.h"
32 31
33typedef void icalcomponent; 32typedef struct icalcomponent_impl icalcomponent;
33
34#ifndef ICALTIMEZONE_DEFINED
35#define ICALTIMEZONE_DEFINED
36/** @brief An opaque struct representing a timezone.
37 * We declare this here to avoid a circular dependancy.
38 */
39 typedef struct _icaltimezone icaltimezone;
40#endif
41
34 42
@@ -53,3 +61,3 @@ int icalcomponent_is_valid(icalcomponent* component);
53 61
54icalcomponent_kind icalcomponent_isa(icalcomponent* component); 62icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
55 63
@@ -99,2 +107,10 @@ int icalcomponent_count_components(icalcomponent* component,
99 107
108/**
109 This takes 2 VCALENDAR components and merges the second one into the first,
110 resolving any problems with conflicting TZIDs. comp_to_merge will no
111 longer exist after calling this function. */
112void icalcomponent_merge_component(icalcomponent* comp,
113 icalcomponent* comp_to_merge);
114
115
100/* Iteration Routines. There are two forms of iterators, internal and 116/* Iteration Routines. There are two forms of iterators, internal and
@@ -123,12 +139,16 @@ icalcomponent* icalcompiter_deref(icalcompiter* i);
123 139
140/* Working with embedded error properties */
124 141
125 142
143/* Check the component against itip rules and insert error properties*/
126/* Working with embedded error properties */ 144/* Working with embedded error properties */
145int icalcomponent_check_restrictions(icalcomponent* comp);
127 146
147/** Count embedded errors. */
128int icalcomponent_count_errors(icalcomponent* component); 148int icalcomponent_count_errors(icalcomponent* component);
129 149
130/* Remove all X-LIC-ERROR properties*/ 150/** Remove all X-LIC-ERROR properties*/
131void icalcomponent_strip_errors(icalcomponent* component); 151void icalcomponent_strip_errors(icalcomponent* component);
132 152
133/* Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/ 153/** Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
134void icalcomponent_convert_errors(icalcomponent* component); 154void icalcomponent_convert_errors(icalcomponent* component);
@@ -140,3 +160,5 @@ void icalcomponent_set_parent(icalcomponent* component,
140 160
141/* Kind conversion routiens */ 161/* Kind conversion routines */
162
163int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
142 164
@@ -153,3 +175,3 @@ wrong component subtypes. */
153 175
154/* For VCOMPONENT: Return a reference to the first VEVENT, VTODO or 176/** For VCOMPONENT: Return a reference to the first VEVENT, VTODO or
155 VJOURNAL */ 177 VJOURNAL */
@@ -157,3 +179,3 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c);
157 179
158/* For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end 180/** For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
159 times of an event in UTC */ 181 times of an event in UTC */
@@ -179,2 +201,5 @@ void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
179 201
202struct icaltimetype icalcomponent_get_due(icalcomponent* comp);
203void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v);
204
180void icalcomponent_set_duration(icalcomponent* comp, 205void icalcomponent_set_duration(icalcomponent* comp,
@@ -189,3 +214,2 @@ void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v);
189 214
190
191void icalcomponent_set_summary(icalcomponent* comp, const char* v); 215void icalcomponent_set_summary(icalcomponent* comp, const char* v);
@@ -199,2 +223,5 @@ const char* icalcomponent_get_uid(icalcomponent* comp);
199 223
224void icalcomponent_set_relcalid(icalcomponent* comp, const char* v);
225const char* icalcomponent_get_relcalid(icalcomponent* comp);
226
200void icalcomponent_set_recurrenceid(icalcomponent* comp, 227void icalcomponent_set_recurrenceid(icalcomponent* comp,
@@ -203,19 +230,37 @@ struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
203 230
231void icalcomponent_set_description(icalcomponent* comp, const char* v);
232const char* icalcomponent_get_description(icalcomponent* comp);
204 233
205void icalcomponent_set_organizer(icalcomponent* comp, 234void icalcomponent_set_location(icalcomponent* comp, const char* v);
206 struct icalorganizertype org); 235const char* icalcomponent_get_location(icalcomponent* comp);
207 struct icalorganizertype icalcomponent_get_organizer(icalcomponent* comp);
208 236
237void icalcomponent_set_sequence(icalcomponent* comp, int v);
238int icalcomponent_get_sequence(icalcomponent* comp);
209 239
210void icalcomponent_add_attendee(icalcomponent *comp, 240void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v);
211 struct icalattendeetype attendee); 241enum icalproperty_status icalcomponent_get_status(icalcomponent* comp);
212 242
213int icalcomponent_remove_attendee(icalcomponent *comp, char* cuid);
214 243
215/* Get the Nth attendee. Out of range indices return an attendee 244/** Calls the given function for each TZID parameter found in the
216 with cuid == 0 */ 245 component, and any subcomponents. */
217struct icalattendeetype icalcomponent_get_attendee(icalcomponent *comp, 246void icalcomponent_foreach_tzid(icalcomponent* comp,
218 int index); 247 void (*callback)(icalparameter *param, void *data),
248 void *callback_data);
219 249
250/** Returns the icaltimezone in the component corresponding to the
251 TZID, or NULL if it can't be found. */
252icaltimezone* icalcomponent_get_timezone(icalcomponent* comp,
253 const char *tzid);
220 254
255int icalproperty_recurrence_is_excluded(icalcomponent *comp,
256 struct icaltimetype *dtstart,
257 struct icaltimetype *recurtime);
258
259void icalcomponent_foreach_recurrence(icalcomponent* comp,
260 struct icaltimetype start,
261 struct icaltimetype end,
262 void (*callback)(icalcomponent *comp,
263 struct icaltime_span *span,
264 void *data),
265 void *callback_data);
221 266
@@ -233,8 +278,5 @@ icalcomponent* icalcomponent_new_xstandard();
233icalcomponent* icalcomponent_new_xdaylight(); 278icalcomponent* icalcomponent_new_xdaylight();
234 279icalcomponent* icalcomponent_new_vagenda();
235 280icalcomponent* icalcomponent_new_vquery();
236 281
237#endif /* !ICALCOMPONENT_H */ 282#endif /* !ICALCOMPONENT_H */
238
239
240
diff --git a/libical/src/libical/icalderivedparameter.c b/libical/src/libical/icalderivedparameter.c
index 6898eb6..91604f0 100644
--- a/libical/src/libical/icalderivedparameter.c
+++ b/libical/src/libical/icalderivedparameter.c
@@ -57,41 +57,2 @@ struct icalparameter_kind_map {
57 57
58extern struct icalparameter_kind_map parameter_map[];
59
60
61const char* icalparameter_kind_to_string(icalparameter_kind kind)
62{
63 int i;
64
65 for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
66 if (parameter_map[i].kind == kind) {
67 return parameter_map[i].name;
68 }
69 }
70
71 return 0;
72
73}
74
75icalparameter_kind icalparameter_string_to_kind(const char* string)
76{
77 int i;
78
79 if (string ==0 ) {
80 return ICAL_NO_PARAMETER;
81 }
82
83 for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
84
85 if (strcmp(parameter_map[i].name, string) == 0) {
86 return parameter_map[i].kind;
87 }
88 }
89
90 if(strncmp(string,"X-",2)==0){
91 return ICAL_X_PARAMETER;
92 }
93
94 return ICAL_NO_PARAMETER;
95}
96
97/* This map associates the enumerations for the VALUE parameter with 58/* This map associates the enumerations for the VALUE parameter with
@@ -104,20 +65,2 @@ struct icalparameter_value_kind_map {
104 65
105extern struct icalparameter_value_kind_map value_kind_map[];
106
107
108icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value)
109{
110 int i;
111
112 for (i=0; value_kind_map[i].kind != ICAL_NO_VALUE; i++) {
113
114 if (value_kind_map[i].value == value) {
115 return value_kind_map[i].kind;
116 }
117 }
118
119 return ICAL_NO_VALUE;
120}
121
122
123/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */ 66/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */
@@ -131,83 +74,4 @@ struct icalparameter_map {
131 74
132extern struct icalparameter_map icalparameter_map[];
133
134
135const char* icalparameter_enum_to_string(int e)
136{
137 int i;
138
139 icalerror_check_arg_rz(e >= ICALPARAMETER_FIRST_ENUM,"e");
140 icalerror_check_arg_rz(e <= ICALPARAMETER_LAST_ENUM,"e");
141
142 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
143 if(e == icalparameter_map[i].enumeration){
144 return icalparameter_map[i].str;
145 }
146 }
147
148 return 0;
149}
150
151int icalparameter_string_to_enum(const char* str)
152{
153 int i;
154
155 icalerror_check_arg_rz(str != 0,"str");
156
157 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
158 if(strcmp(str,icalparameter_map[i].str) == 0) {
159 return icalparameter_map[i].enumeration;
160 }
161 }
162
163 return 0;
164}
165 75
166icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val) 76static struct icalparameter_value_kind_map value_kind_map[15] = {
167{
168
169 struct icalparameter_impl* param=0;
170 int found_kind = 0;
171 int i;
172
173 icalerror_check_arg_rz((val!=0),"val");
174
175 /* Search through the parameter map to find a matching kind */
176
177 param = icalparameter_new_impl(kind);
178
179 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
180 if(kind == icalparameter_map[i].kind) {
181 found_kind = 1;
182 if(strcmp(val,icalparameter_map[i].str) == 0) {
183
184 param->data = (int)icalparameter_map[i].enumeration;
185 return param;
186 }
187 }
188 }
189
190 if(found_kind == 1){
191 /* The kind was in the parameter map, but the string did not
192 match, so assume that it is an alternate value, like an
193 X-value.*/
194
195 icalparameter_set_xvalue(param, val);
196
197 } else {
198
199 /* If the kind was not found, then it must be a string type */
200
201 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(val);
202
203 }
204
205 return param;
206}
207
208
209
210
211/* Everything below this line is machine generated. Do not edit. */
212struct icalparameter_value_kind_map value_kind_map[] = {
213 {ICAL_VALUE_BINARY,ICAL_BINARY_VALUE}, 77 {ICAL_VALUE_BINARY,ICAL_BINARY_VALUE},
@@ -229,3 +93,3 @@ struct icalparameter_value_kind_map value_kind_map[] = {
229 93
230static struct icalparameter_kind_map parameter_map[] = { 94static struct icalparameter_kind_map parameter_map[24] = {
231 {ICAL_ALTREP_PARAMETER,"ALTREP"}, 95 {ICAL_ALTREP_PARAMETER,"ALTREP"},
@@ -279,3 +143,3 @@ static struct icalparameter_map icalparameter_map[] = {
279 {ICAL_RELATED_PARAMETER,ICAL_RELATED_START,"START"}, 143 {ICAL_RELATED_PARAMETER,ICAL_RELATED_START,"START"},
280 {ICAL_RELATED_PARAMETER,ICAL_RELATED_END ,"END "}, 144 {ICAL_RELATED_PARAMETER,ICAL_RELATED_END,"END"},
281 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_PARENT,"PARENT"}, 145 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_PARENT,"PARENT"},
@@ -310,2 +174,4 @@ static struct icalparameter_map icalparameter_map[] = {
310 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_REGEX,"REGEX"}, 174 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_REGEX,"REGEX"},
175 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_ISNULL,"ISNULL"},
176 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_ISNOTNULL,"ISNOTNULL"},
311 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_COMPONENTPARSEERROR,"COMPONENT-PARSE-ERROR"}, 177 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_COMPONENTPARSEERROR,"COMPONENT-PARSE-ERROR"},
@@ -318,6 +184,7 @@ static struct icalparameter_map icalparameter_map[] = {
318 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_MIMEPARSEERROR,"MIME-PARSE-ERROR"}, 184 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_MIMEPARSEERROR,"MIME-PARSE-ERROR"},
185 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_VCALPROPPARSEERROR,"VCAL-PROP-PARSE-ERROR"},
319 {ICAL_NO_PARAMETER,0,""}}; 186 {ICAL_NO_PARAMETER,0,""}};
320 187
321/* DELEGATED-FROM */ 188/* LANGUAGE */
322icalparameter* icalparameter_new_delegatedfrom(const char* v) 189icalparameter* icalparameter_new_language(const char* v)
323{ 190{
@@ -326,3 +193,3 @@ icalparameter* icalparameter_new_delegatedfrom(const char* v)
326 icalerror_check_arg_rz( (v!=0),"v"); 193 icalerror_check_arg_rz( (v!=0),"v");
327 impl = icalparameter_new_impl(ICAL_DELEGATEDFROM_PARAMETER); 194 impl = icalparameter_new_impl(ICAL_LANGUAGE_PARAMETER);
328 if (impl == 0) { 195 if (impl == 0) {
@@ -331,3 +198,3 @@ icalparameter* icalparameter_new_delegatedfrom(const char* v)
331 198
332 icalparameter_set_delegatedfrom((icalparameter*) impl,v); 199 icalparameter_set_language((icalparameter*) impl,v);
333 if (icalerrno != ICAL_NO_ERROR) { 200 if (icalerrno != ICAL_NO_ERROR) {
@@ -340,3 +207,3 @@ icalparameter* icalparameter_new_delegatedfrom(const char* v)
340 207
341const char* icalparameter_get_delegatedfrom(icalparameter* param) 208const char* icalparameter_get_language(const icalparameter* param)
342{ 209{
@@ -344,6 +211,6 @@ const char* icalparameter_get_delegatedfrom(icalparameter* param)
344 icalerror_check_arg_rz( (param!=0), "param"); 211 icalerror_check_arg_rz( (param!=0), "param");
345 return (const char*)((struct icalparameter_impl*)param)->string; 212 return param->string;
346} 213}
347 214
348void icalparameter_set_delegatedfrom(icalparameter* param, const char* v) 215void icalparameter_set_language(icalparameter* param, const char* v)
349{ 216{
@@ -356,4 +223,4 @@ void icalparameter_set_delegatedfrom(icalparameter* param, const char* v)
356 223
357/* DELEGATED-TO */ 224/* DIR */
358icalparameter* icalparameter_new_delegatedto(const char* v) 225icalparameter* icalparameter_new_dir(const char* v)
359{ 226{
@@ -362,3 +229,3 @@ icalparameter* icalparameter_new_delegatedto(const char* v)
362 icalerror_check_arg_rz( (v!=0),"v"); 229 icalerror_check_arg_rz( (v!=0),"v");
363 impl = icalparameter_new_impl(ICAL_DELEGATEDTO_PARAMETER); 230 impl = icalparameter_new_impl(ICAL_DIR_PARAMETER);
364 if (impl == 0) { 231 if (impl == 0) {
@@ -367,3 +234,3 @@ icalparameter* icalparameter_new_delegatedto(const char* v)
367 234
368 icalparameter_set_delegatedto((icalparameter*) impl,v); 235 icalparameter_set_dir((icalparameter*) impl,v);
369 if (icalerrno != ICAL_NO_ERROR) { 236 if (icalerrno != ICAL_NO_ERROR) {
@@ -376,3 +243,3 @@ icalparameter* icalparameter_new_delegatedto(const char* v)
376 243
377const char* icalparameter_get_delegatedto(icalparameter* param) 244const char* icalparameter_get_dir(const icalparameter* param)
378{ 245{
@@ -380,6 +247,6 @@ const char* icalparameter_get_delegatedto(icalparameter* param)
380 icalerror_check_arg_rz( (param!=0), "param"); 247 icalerror_check_arg_rz( (param!=0), "param");
381 return (const char*)((struct icalparameter_impl*)param)->string; 248 return param->string;
382} 249}
383 250
384void icalparameter_set_delegatedto(icalparameter* param, const char* v) 251void icalparameter_set_dir(icalparameter* param, const char* v)
385{ 252{
@@ -392,4 +259,4 @@ void icalparameter_set_delegatedto(icalparameter* param, const char* v)
392 259
393/* RANGE */ 260/* RELTYPE */
394icalparameter* icalparameter_new_range(icalparameter_range v) 261icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
395{ 262{
@@ -397,5 +264,5 @@ icalparameter* icalparameter_new_range(icalparameter_range v)
397 icalerror_clear_errno(); 264 icalerror_clear_errno();
398 icalerror_check_arg_rz(v >= ICAL_RANGE_X,"v"); 265 icalerror_check_arg_rz(v >= ICAL_RELTYPE_X,"v");
399 icalerror_check_arg_rz(v < ICAL_RANGE_NONE,"v"); 266 icalerror_check_arg_rz(v < ICAL_RELTYPE_NONE,"v");
400 impl = icalparameter_new_impl(ICAL_RANGE_PARAMETER); 267 impl = icalparameter_new_impl(ICAL_RELTYPE_PARAMETER);
401 if (impl == 0) { 268 if (impl == 0) {
@@ -404,3 +271,3 @@ icalparameter* icalparameter_new_range(icalparameter_range v)
404 271
405 icalparameter_set_range((icalparameter*) impl,v); 272 icalparameter_set_reltype((icalparameter*) impl,v);
406 if (icalerrno != ICAL_NO_ERROR) { 273 if (icalerrno != ICAL_NO_ERROR) {
@@ -413,3 +280,3 @@ icalparameter* icalparameter_new_range(icalparameter_range v)
413 280
414icalparameter_range icalparameter_get_range(icalparameter* param) 281icalparameter_reltype icalparameter_get_reltype(const icalparameter* param)
415{ 282{
@@ -417,10 +284,13 @@ icalparameter_range icalparameter_get_range(icalparameter* param)
417icalerror_check_arg( (param!=0), "param"); 284icalerror_check_arg( (param!=0), "param");
285 if (param->string != 0){
286 return ICAL_RELTYPE_X;
287 }
418 288
419return (icalparameter_range)((struct icalparameter_impl*)param)->data; 289return (icalparameter_reltype)(param->data);
420} 290}
421 291
422void icalparameter_set_range(icalparameter* param, icalparameter_range v) 292void icalparameter_set_reltype(icalparameter* param, icalparameter_reltype v)
423{ 293{
424 icalerror_check_arg_rv(v >= ICAL_RANGE_X,"v"); 294 icalerror_check_arg_rv(v >= ICAL_RELTYPE_X,"v");
425 icalerror_check_arg_rv(v < ICAL_RANGE_NONE,"v"); 295 icalerror_check_arg_rv(v < ICAL_RELTYPE_NONE,"v");
426 icalerror_check_arg_rv( (param!=0), "param"); 296 icalerror_check_arg_rv( (param!=0), "param");
@@ -431,4 +301,4 @@ void icalparameter_set_range(icalparameter* param, icalparameter_range v)
431 301
432/* ENCODING */ 302/* FMTTYPE */
433icalparameter* icalparameter_new_encoding(icalparameter_encoding v) 303icalparameter* icalparameter_new_fmttype(const char* v)
434{ 304{
@@ -436,5 +306,4 @@ icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
436 icalerror_clear_errno(); 306 icalerror_clear_errno();
437 icalerror_check_arg_rz(v >= ICAL_ENCODING_X,"v"); 307 icalerror_check_arg_rz( (v!=0),"v");
438 icalerror_check_arg_rz(v < ICAL_ENCODING_NONE,"v"); 308 impl = icalparameter_new_impl(ICAL_FMTTYPE_PARAMETER);
439 impl = icalparameter_new_impl(ICAL_ENCODING_PARAMETER);
440 if (impl == 0) { 309 if (impl == 0) {
@@ -443,3 +312,3 @@ icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
443 312
444 icalparameter_set_encoding((icalparameter*) impl,v); 313 icalparameter_set_fmttype((icalparameter*) impl,v);
445 if (icalerrno != ICAL_NO_ERROR) { 314 if (icalerrno != ICAL_NO_ERROR) {
@@ -452,17 +321,48 @@ icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
452 321
453icalparameter_encoding icalparameter_get_encoding(icalparameter* param) 322const char* icalparameter_get_fmttype(const icalparameter* param)
454{ 323{
455 icalerror_clear_errno(); 324 icalerror_clear_errno();
456icalerror_check_arg( (param!=0), "param"); 325 icalerror_check_arg_rz( (param!=0), "param");
457 if ( ((struct icalparameter_impl*)param)->string != 0){ 326 return param->string;
458 return ICAL_ENCODING_X; 327}
459 }
460 328
461return (icalparameter_encoding)((struct icalparameter_impl*)param)->data; 329void icalparameter_set_fmttype(icalparameter* param, const char* v)
330{
331 icalerror_check_arg_rv( (v!=0),"v");
332 icalerror_check_arg_rv( (param!=0), "param");
333 icalerror_clear_errno();
334
335 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
462} 336}
463 337
464void icalparameter_set_encoding(icalparameter* param, icalparameter_encoding v) 338/* TZID */
339icalparameter* icalparameter_new_tzid(const char* v)
465{ 340{
466 icalerror_check_arg_rv(v >= ICAL_ENCODING_X,"v"); 341 struct icalparameter_impl *impl;
467 icalerror_check_arg_rv(v < ICAL_ENCODING_NONE,"v"); 342 icalerror_clear_errno();
343 icalerror_check_arg_rz( (v!=0),"v");
344 impl = icalparameter_new_impl(ICAL_TZID_PARAMETER);
345 if (impl == 0) {
346 return 0;
347 }
348
349 icalparameter_set_tzid((icalparameter*) impl,v);
350 if (icalerrno != ICAL_NO_ERROR) {
351 icalparameter_free((icalparameter*) impl);
352 return 0;
353 }
354
355 return (icalparameter*) impl;
356}
357
358const char* icalparameter_get_tzid(const icalparameter* param)
359{
360 icalerror_clear_errno();
361 icalerror_check_arg_rz( (param!=0), "param");
362 return param->string;
363}
364
365void icalparameter_set_tzid(icalparameter* param, const char* v)
366{
367 icalerror_check_arg_rv( (v!=0),"v");
468 icalerror_check_arg_rv( (param!=0), "param"); 368 icalerror_check_arg_rv( (param!=0), "param");
@@ -470,7 +370,7 @@ void icalparameter_set_encoding(icalparameter* param, icalparameter_encoding v)
470 370
471 ((struct icalparameter_impl*)param)->data = (int)v; 371 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
472} 372}
473 373
474/* RSVP */ 374/* RANGE */
475icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v) 375icalparameter* icalparameter_new_range(icalparameter_range v)
476{ 376{
@@ -478,5 +378,5 @@ icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
478 icalerror_clear_errno(); 378 icalerror_clear_errno();
479 icalerror_check_arg_rz(v >= ICAL_RSVP_X,"v"); 379 icalerror_check_arg_rz(v >= ICAL_RANGE_X,"v");
480 icalerror_check_arg_rz(v < ICAL_RSVP_NONE,"v"); 380 icalerror_check_arg_rz(v < ICAL_RANGE_NONE,"v");
481 impl = icalparameter_new_impl(ICAL_RSVP_PARAMETER); 381 impl = icalparameter_new_impl(ICAL_RANGE_PARAMETER);
482 if (impl == 0) { 382 if (impl == 0) {
@@ -485,3 +385,3 @@ icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
485 385
486 icalparameter_set_rsvp((icalparameter*) impl,v); 386 icalparameter_set_range((icalparameter*) impl,v);
487 if (icalerrno != ICAL_NO_ERROR) { 387 if (icalerrno != ICAL_NO_ERROR) {
@@ -494,3 +394,3 @@ icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
494 394
495icalparameter_rsvp icalparameter_get_rsvp(icalparameter* param) 395icalparameter_range icalparameter_get_range(const icalparameter* param)
496{ 396{
@@ -499,9 +399,9 @@ icalerror_check_arg( (param!=0), "param");
499 399
500return (icalparameter_rsvp)((struct icalparameter_impl*)param)->data; 400return (icalparameter_range)(param->data);
501} 401}
502 402
503void icalparameter_set_rsvp(icalparameter* param, icalparameter_rsvp v) 403void icalparameter_set_range(icalparameter* param, icalparameter_range v)
504{ 404{
505 icalerror_check_arg_rv(v >= ICAL_RSVP_X,"v"); 405 icalerror_check_arg_rv(v >= ICAL_RANGE_X,"v");
506 icalerror_check_arg_rv(v < ICAL_RSVP_NONE,"v"); 406 icalerror_check_arg_rv(v < ICAL_RANGE_NONE,"v");
507 icalerror_check_arg_rv( (param!=0), "param"); 407 icalerror_check_arg_rv( (param!=0), "param");
@@ -512,4 +412,4 @@ void icalparameter_set_rsvp(icalparameter* param, icalparameter_rsvp v)
512 412
513/* PARTSTAT */ 413/* DELEGATED-TO */
514icalparameter* icalparameter_new_partstat(icalparameter_partstat v) 414icalparameter* icalparameter_new_delegatedto(const char* v)
515{ 415{
@@ -517,5 +417,4 @@ icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
517 icalerror_clear_errno(); 417 icalerror_clear_errno();
518 icalerror_check_arg_rz(v >= ICAL_PARTSTAT_X,"v"); 418 icalerror_check_arg_rz( (v!=0),"v");
519 icalerror_check_arg_rz(v < ICAL_PARTSTAT_NONE,"v"); 419 impl = icalparameter_new_impl(ICAL_DELEGATEDTO_PARAMETER);
520 impl = icalparameter_new_impl(ICAL_PARTSTAT_PARAMETER);
521 if (impl == 0) { 420 if (impl == 0) {
@@ -524,3 +423,3 @@ icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
524 423
525 icalparameter_set_partstat((icalparameter*) impl,v); 424 icalparameter_set_delegatedto((icalparameter*) impl,v);
526 if (icalerrno != ICAL_NO_ERROR) { 425 if (icalerrno != ICAL_NO_ERROR) {
@@ -533,17 +432,48 @@ icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
533 432
534icalparameter_partstat icalparameter_get_partstat(icalparameter* param) 433const char* icalparameter_get_delegatedto(const icalparameter* param)
535{ 434{
536 icalerror_clear_errno(); 435 icalerror_clear_errno();
537icalerror_check_arg( (param!=0), "param"); 436 icalerror_check_arg_rz( (param!=0), "param");
538 if ( ((struct icalparameter_impl*)param)->string != 0){ 437 return param->string;
539 return ICAL_PARTSTAT_X; 438}
540 }
541 439
542return (icalparameter_partstat)((struct icalparameter_impl*)param)->data; 440void icalparameter_set_delegatedto(icalparameter* param, const char* v)
441{
442 icalerror_check_arg_rv( (v!=0),"v");
443 icalerror_check_arg_rv( (param!=0), "param");
444 icalerror_clear_errno();
445
446 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
543} 447}
544 448
545void icalparameter_set_partstat(icalparameter* param, icalparameter_partstat v) 449/* CN */
450icalparameter* icalparameter_new_cn(const char* v)
546{ 451{
547 icalerror_check_arg_rv(v >= ICAL_PARTSTAT_X,"v"); 452 struct icalparameter_impl *impl;
548 icalerror_check_arg_rv(v < ICAL_PARTSTAT_NONE,"v"); 453 icalerror_clear_errno();
454 icalerror_check_arg_rz( (v!=0),"v");
455 impl = icalparameter_new_impl(ICAL_CN_PARAMETER);
456 if (impl == 0) {
457 return 0;
458 }
459
460 icalparameter_set_cn((icalparameter*) impl,v);
461 if (icalerrno != ICAL_NO_ERROR) {
462 icalparameter_free((icalparameter*) impl);
463 return 0;
464 }
465
466 return (icalparameter*) impl;
467}
468
469const char* icalparameter_get_cn(const icalparameter* param)
470{
471 icalerror_clear_errno();
472 icalerror_check_arg_rz( (param!=0), "param");
473 return param->string;
474}
475
476void icalparameter_set_cn(icalparameter* param, const char* v)
477{
478 icalerror_check_arg_rv( (v!=0),"v");
549 icalerror_check_arg_rv( (param!=0), "param"); 479 icalerror_check_arg_rv( (param!=0), "param");
@@ -551,7 +481,7 @@ void icalparameter_set_partstat(icalparameter* param, icalparameter_partstat v)
551 481
552 ((struct icalparameter_impl*)param)->data = (int)v; 482 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
553} 483}
554 484
555/* RELTYPE */ 485/* VALUE */
556icalparameter* icalparameter_new_reltype(icalparameter_reltype v) 486icalparameter* icalparameter_new_value(icalparameter_value v)
557{ 487{
@@ -559,5 +489,5 @@ icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
559 icalerror_clear_errno(); 489 icalerror_clear_errno();
560 icalerror_check_arg_rz(v >= ICAL_RELTYPE_X,"v"); 490 icalerror_check_arg_rz(v >= ICAL_VALUE_X,"v");
561 icalerror_check_arg_rz(v < ICAL_RELTYPE_NONE,"v"); 491 icalerror_check_arg_rz(v < ICAL_VALUE_NONE,"v");
562 impl = icalparameter_new_impl(ICAL_RELTYPE_PARAMETER); 492 impl = icalparameter_new_impl(ICAL_VALUE_PARAMETER);
563 if (impl == 0) { 493 if (impl == 0) {
@@ -566,3 +496,3 @@ icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
566 496
567 icalparameter_set_reltype((icalparameter*) impl,v); 497 icalparameter_set_value((icalparameter*) impl,v);
568 if (icalerrno != ICAL_NO_ERROR) { 498 if (icalerrno != ICAL_NO_ERROR) {
@@ -575,3 +505,3 @@ icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
575 505
576icalparameter_reltype icalparameter_get_reltype(icalparameter* param) 506icalparameter_value icalparameter_get_value(const icalparameter* param)
577{ 507{
@@ -579,13 +509,13 @@ icalparameter_reltype icalparameter_get_reltype(icalparameter* param)
579icalerror_check_arg( (param!=0), "param"); 509icalerror_check_arg( (param!=0), "param");
580 if ( ((struct icalparameter_impl*)param)->string != 0){ 510 if (param->string != 0){
581 return ICAL_RELTYPE_X; 511 return ICAL_VALUE_X;
582 } 512 }
583 513
584return (icalparameter_reltype)((struct icalparameter_impl*)param)->data; 514return (icalparameter_value)(param->data);
585} 515}
586 516
587void icalparameter_set_reltype(icalparameter* param, icalparameter_reltype v) 517void icalparameter_set_value(icalparameter* param, icalparameter_value v)
588{ 518{
589 icalerror_check_arg_rv(v >= ICAL_RELTYPE_X,"v"); 519 icalerror_check_arg_rv(v >= ICAL_VALUE_X,"v");
590 icalerror_check_arg_rv(v < ICAL_RELTYPE_NONE,"v"); 520 icalerror_check_arg_rv(v < ICAL_VALUE_NONE,"v");
591 icalerror_check_arg_rv( (param!=0), "param"); 521 icalerror_check_arg_rv( (param!=0), "param");
@@ -596,4 +526,4 @@ void icalparameter_set_reltype(icalparameter* param, icalparameter_reltype v)
596 526
597/* CUTYPE */ 527/* X-LIC-COMPARETYPE */
598icalparameter* icalparameter_new_cutype(icalparameter_cutype v) 528icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v)
599{ 529{
@@ -601,5 +531,5 @@ icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
601 icalerror_clear_errno(); 531 icalerror_clear_errno();
602 icalerror_check_arg_rz(v >= ICAL_CUTYPE_X,"v"); 532 icalerror_check_arg_rz(v >= ICAL_XLICCOMPARETYPE_X,"v");
603 icalerror_check_arg_rz(v < ICAL_CUTYPE_NONE,"v"); 533 icalerror_check_arg_rz(v < ICAL_XLICCOMPARETYPE_NONE,"v");
604 impl = icalparameter_new_impl(ICAL_CUTYPE_PARAMETER); 534 impl = icalparameter_new_impl(ICAL_XLICCOMPARETYPE_PARAMETER);
605 if (impl == 0) { 535 if (impl == 0) {
@@ -608,3 +538,3 @@ icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
608 538
609 icalparameter_set_cutype((icalparameter*) impl,v); 539 icalparameter_set_xliccomparetype((icalparameter*) impl,v);
610 if (icalerrno != ICAL_NO_ERROR) { 540 if (icalerrno != ICAL_NO_ERROR) {
@@ -617,3 +547,3 @@ icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
617 547
618icalparameter_cutype icalparameter_get_cutype(icalparameter* param) 548icalparameter_xliccomparetype icalparameter_get_xliccomparetype(const icalparameter* param)
619{ 549{
@@ -621,13 +551,10 @@ icalparameter_cutype icalparameter_get_cutype(icalparameter* param)
621icalerror_check_arg( (param!=0), "param"); 551icalerror_check_arg( (param!=0), "param");
622 if ( ((struct icalparameter_impl*)param)->string != 0){
623 return ICAL_CUTYPE_X;
624 }
625 552
626return (icalparameter_cutype)((struct icalparameter_impl*)param)->data; 553return (icalparameter_xliccomparetype)(param->data);
627} 554}
628 555
629void icalparameter_set_cutype(icalparameter* param, icalparameter_cutype v) 556void icalparameter_set_xliccomparetype(icalparameter* param, icalparameter_xliccomparetype v)
630{ 557{
631 icalerror_check_arg_rv(v >= ICAL_CUTYPE_X,"v"); 558 icalerror_check_arg_rv(v >= ICAL_XLICCOMPARETYPE_X,"v");
632 icalerror_check_arg_rv(v < ICAL_CUTYPE_NONE,"v"); 559 icalerror_check_arg_rv(v < ICAL_XLICCOMPARETYPE_NONE,"v");
633 icalerror_check_arg_rv( (param!=0), "param"); 560 icalerror_check_arg_rv( (param!=0), "param");
@@ -638,4 +565,4 @@ void icalparameter_set_cutype(icalparameter* param, icalparameter_cutype v)
638 565
639/* MEMBER */ 566/* X */
640icalparameter* icalparameter_new_member(const char* v) 567icalparameter* icalparameter_new_x(const char* v)
641{ 568{
@@ -644,3 +571,3 @@ icalparameter* icalparameter_new_member(const char* v)
644 icalerror_check_arg_rz( (v!=0),"v"); 571 icalerror_check_arg_rz( (v!=0),"v");
645 impl = icalparameter_new_impl(ICAL_MEMBER_PARAMETER); 572 impl = icalparameter_new_impl(ICAL_X_PARAMETER);
646 if (impl == 0) { 573 if (impl == 0) {
@@ -649,3 +576,3 @@ icalparameter* icalparameter_new_member(const char* v)
649 576
650 icalparameter_set_member((icalparameter*) impl,v); 577 icalparameter_set_x((icalparameter*) impl,v);
651 if (icalerrno != ICAL_NO_ERROR) { 578 if (icalerrno != ICAL_NO_ERROR) {
@@ -658,3 +585,3 @@ icalparameter* icalparameter_new_member(const char* v)
658 585
659const char* icalparameter_get_member(icalparameter* param) 586const char* icalparameter_get_x(const icalparameter* param)
660{ 587{
@@ -662,6 +589,6 @@ const char* icalparameter_get_member(icalparameter* param)
662 icalerror_check_arg_rz( (param!=0), "param"); 589 icalerror_check_arg_rz( (param!=0), "param");
663 return (const char*)((struct icalparameter_impl*)param)->string; 590 return param->string;
664} 591}
665 592
666void icalparameter_set_member(icalparameter* param, const char* v) 593void icalparameter_set_x(icalparameter* param, const char* v)
667{ 594{
@@ -674,4 +601,4 @@ void icalparameter_set_member(icalparameter* param, const char* v)
674 601
675/* FMTTYPE */ 602/* SENT-BY */
676icalparameter* icalparameter_new_fmttype(const char* v) 603icalparameter* icalparameter_new_sentby(const char* v)
677{ 604{
@@ -680,3 +607,3 @@ icalparameter* icalparameter_new_fmttype(const char* v)
680 icalerror_check_arg_rz( (v!=0),"v"); 607 icalerror_check_arg_rz( (v!=0),"v");
681 impl = icalparameter_new_impl(ICAL_FMTTYPE_PARAMETER); 608 impl = icalparameter_new_impl(ICAL_SENTBY_PARAMETER);
682 if (impl == 0) { 609 if (impl == 0) {
@@ -685,3 +612,3 @@ icalparameter* icalparameter_new_fmttype(const char* v)
685 612
686 icalparameter_set_fmttype((icalparameter*) impl,v); 613 icalparameter_set_sentby((icalparameter*) impl,v);
687 if (icalerrno != ICAL_NO_ERROR) { 614 if (icalerrno != ICAL_NO_ERROR) {
@@ -694,3 +621,3 @@ icalparameter* icalparameter_new_fmttype(const char* v)
694 621
695const char* icalparameter_get_fmttype(icalparameter* param) 622const char* icalparameter_get_sentby(const icalparameter* param)
696{ 623{
@@ -698,6 +625,6 @@ const char* icalparameter_get_fmttype(icalparameter* param)
698 icalerror_check_arg_rz( (param!=0), "param"); 625 icalerror_check_arg_rz( (param!=0), "param");
699 return (const char*)((struct icalparameter_impl*)param)->string; 626 return param->string;
700} 627}
701 628
702void icalparameter_set_fmttype(icalparameter* param, const char* v) 629void icalparameter_set_sentby(icalparameter* param, const char* v)
703{ 630{
@@ -710,4 +637,4 @@ void icalparameter_set_fmttype(icalparameter* param, const char* v)
710 637
711/* SENT-BY */ 638/* MEMBER */
712icalparameter* icalparameter_new_sentby(const char* v) 639icalparameter* icalparameter_new_member(const char* v)
713{ 640{
@@ -716,3 +643,3 @@ icalparameter* icalparameter_new_sentby(const char* v)
716 icalerror_check_arg_rz( (v!=0),"v"); 643 icalerror_check_arg_rz( (v!=0),"v");
717 impl = icalparameter_new_impl(ICAL_SENTBY_PARAMETER); 644 impl = icalparameter_new_impl(ICAL_MEMBER_PARAMETER);
718 if (impl == 0) { 645 if (impl == 0) {
@@ -721,3 +648,3 @@ icalparameter* icalparameter_new_sentby(const char* v)
721 648
722 icalparameter_set_sentby((icalparameter*) impl,v); 649 icalparameter_set_member((icalparameter*) impl,v);
723 if (icalerrno != ICAL_NO_ERROR) { 650 if (icalerrno != ICAL_NO_ERROR) {
@@ -730,3 +657,3 @@ icalparameter* icalparameter_new_sentby(const char* v)
730 657
731const char* icalparameter_get_sentby(icalparameter* param) 658const char* icalparameter_get_member(const icalparameter* param)
732{ 659{
@@ -734,6 +661,6 @@ const char* icalparameter_get_sentby(icalparameter* param)
734 icalerror_check_arg_rz( (param!=0), "param"); 661 icalerror_check_arg_rz( (param!=0), "param");
735 return (const char*)((struct icalparameter_impl*)param)->string; 662 return param->string;
736} 663}
737 664
738void icalparameter_set_sentby(icalparameter* param, const char* v) 665void icalparameter_set_member(icalparameter* param, const char* v)
739{ 666{
@@ -746,4 +673,4 @@ void icalparameter_set_sentby(icalparameter* param, const char* v)
746 673
747/* VALUE */ 674/* RSVP */
748icalparameter* icalparameter_new_value(icalparameter_value v) 675icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
749{ 676{
@@ -751,5 +678,5 @@ icalparameter* icalparameter_new_value(icalparameter_value v)
751 icalerror_clear_errno(); 678 icalerror_clear_errno();
752 icalerror_check_arg_rz(v >= ICAL_VALUE_X,"v"); 679 icalerror_check_arg_rz(v >= ICAL_RSVP_X,"v");
753 icalerror_check_arg_rz(v < ICAL_VALUE_NONE,"v"); 680 icalerror_check_arg_rz(v < ICAL_RSVP_NONE,"v");
754 impl = icalparameter_new_impl(ICAL_VALUE_PARAMETER); 681 impl = icalparameter_new_impl(ICAL_RSVP_PARAMETER);
755 if (impl == 0) { 682 if (impl == 0) {
@@ -758,3 +685,3 @@ icalparameter* icalparameter_new_value(icalparameter_value v)
758 685
759 icalparameter_set_value((icalparameter*) impl,v); 686 icalparameter_set_rsvp((icalparameter*) impl,v);
760 if (icalerrno != ICAL_NO_ERROR) { 687 if (icalerrno != ICAL_NO_ERROR) {
@@ -767,3 +694,3 @@ icalparameter* icalparameter_new_value(icalparameter_value v)
767 694
768icalparameter_value icalparameter_get_value(icalparameter* param) 695icalparameter_rsvp icalparameter_get_rsvp(const icalparameter* param)
769{ 696{
@@ -771,13 +698,10 @@ icalparameter_value icalparameter_get_value(icalparameter* param)
771icalerror_check_arg( (param!=0), "param"); 698icalerror_check_arg( (param!=0), "param");
772 if ( ((struct icalparameter_impl*)param)->string != 0){
773 return ICAL_VALUE_X;
774 }
775 699
776return (icalparameter_value)((struct icalparameter_impl*)param)->data; 700return (icalparameter_rsvp)(param->data);
777} 701}
778 702
779void icalparameter_set_value(icalparameter* param, icalparameter_value v) 703void icalparameter_set_rsvp(icalparameter* param, icalparameter_rsvp v)
780{ 704{
781 icalerror_check_arg_rv(v >= ICAL_VALUE_X,"v"); 705 icalerror_check_arg_rv(v >= ICAL_RSVP_X,"v");
782 icalerror_check_arg_rv(v < ICAL_VALUE_NONE,"v"); 706 icalerror_check_arg_rv(v < ICAL_RSVP_NONE,"v");
783 icalerror_check_arg_rv( (param!=0), "param"); 707 icalerror_check_arg_rv( (param!=0), "param");
@@ -788,4 +712,4 @@ void icalparameter_set_value(icalparameter* param, icalparameter_value v)
788 712
789/* ALTREP */ 713/* CUTYPE */
790icalparameter* icalparameter_new_altrep(const char* v) 714icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
791{ 715{
@@ -793,4 +717,5 @@ icalparameter* icalparameter_new_altrep(const char* v)
793 icalerror_clear_errno(); 717 icalerror_clear_errno();
794 icalerror_check_arg_rz( (v!=0),"v"); 718 icalerror_check_arg_rz(v >= ICAL_CUTYPE_X,"v");
795 impl = icalparameter_new_impl(ICAL_ALTREP_PARAMETER); 719 icalerror_check_arg_rz(v < ICAL_CUTYPE_NONE,"v");
720 impl = icalparameter_new_impl(ICAL_CUTYPE_PARAMETER);
796 if (impl == 0) { 721 if (impl == 0) {
@@ -799,3 +724,3 @@ icalparameter* icalparameter_new_altrep(const char* v)
799 724
800 icalparameter_set_altrep((icalparameter*) impl,v); 725 icalparameter_set_cutype((icalparameter*) impl,v);
801 if (icalerrno != ICAL_NO_ERROR) { 726 if (icalerrno != ICAL_NO_ERROR) {
@@ -808,12 +733,17 @@ icalparameter* icalparameter_new_altrep(const char* v)
808 733
809const char* icalparameter_get_altrep(icalparameter* param) 734icalparameter_cutype icalparameter_get_cutype(const icalparameter* param)
810{ 735{
811 icalerror_clear_errno(); 736 icalerror_clear_errno();
812 icalerror_check_arg_rz( (param!=0), "param"); 737icalerror_check_arg( (param!=0), "param");
813 return (const char*)((struct icalparameter_impl*)param)->string; 738 if (param->string != 0){
739 return ICAL_CUTYPE_X;
740 }
741
742return (icalparameter_cutype)(param->data);
814} 743}
815 744
816void icalparameter_set_altrep(icalparameter* param, const char* v) 745void icalparameter_set_cutype(icalparameter* param, icalparameter_cutype v)
817{ 746{
818 icalerror_check_arg_rv( (v!=0),"v"); 747 icalerror_check_arg_rv(v >= ICAL_CUTYPE_X,"v");
748 icalerror_check_arg_rv(v < ICAL_CUTYPE_NONE,"v");
819 icalerror_check_arg_rv( (param!=0), "param"); 749 icalerror_check_arg_rv( (param!=0), "param");
@@ -821,7 +751,7 @@ void icalparameter_set_altrep(icalparameter* param, const char* v)
821 751
822 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 752 ((struct icalparameter_impl*)param)->data = (int)v;
823} 753}
824 754
825/* DIR */ 755/* X-LIC-ERRORTYPE */
826icalparameter* icalparameter_new_dir(const char* v) 756icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
827{ 757{
@@ -829,4 +759,5 @@ icalparameter* icalparameter_new_dir(const char* v)
829 icalerror_clear_errno(); 759 icalerror_clear_errno();
830 icalerror_check_arg_rz( (v!=0),"v"); 760 icalerror_check_arg_rz(v >= ICAL_XLICERRORTYPE_X,"v");
831 impl = icalparameter_new_impl(ICAL_DIR_PARAMETER); 761 icalerror_check_arg_rz(v < ICAL_XLICERRORTYPE_NONE,"v");
762 impl = icalparameter_new_impl(ICAL_XLICERRORTYPE_PARAMETER);
832 if (impl == 0) { 763 if (impl == 0) {
@@ -835,3 +766,3 @@ icalparameter* icalparameter_new_dir(const char* v)
835 766
836 icalparameter_set_dir((icalparameter*) impl,v); 767 icalparameter_set_xlicerrortype((icalparameter*) impl,v);
837 if (icalerrno != ICAL_NO_ERROR) { 768 if (icalerrno != ICAL_NO_ERROR) {
@@ -844,12 +775,14 @@ icalparameter* icalparameter_new_dir(const char* v)
844 775
845const char* icalparameter_get_dir(icalparameter* param) 776icalparameter_xlicerrortype icalparameter_get_xlicerrortype(const icalparameter* param)
846{ 777{
847 icalerror_clear_errno(); 778 icalerror_clear_errno();
848 icalerror_check_arg_rz( (param!=0), "param"); 779icalerror_check_arg( (param!=0), "param");
849 return (const char*)((struct icalparameter_impl*)param)->string; 780
781return (icalparameter_xlicerrortype)(param->data);
850} 782}
851 783
852void icalparameter_set_dir(icalparameter* param, const char* v) 784void icalparameter_set_xlicerrortype(icalparameter* param, icalparameter_xlicerrortype v)
853{ 785{
854 icalerror_check_arg_rv( (v!=0),"v"); 786 icalerror_check_arg_rv(v >= ICAL_XLICERRORTYPE_X,"v");
787 icalerror_check_arg_rv(v < ICAL_XLICERRORTYPE_NONE,"v");
855 icalerror_check_arg_rv( (param!=0), "param"); 788 icalerror_check_arg_rv( (param!=0), "param");
@@ -857,3 +790,3 @@ void icalparameter_set_dir(icalparameter* param, const char* v)
857 790
858 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 791 ((struct icalparameter_impl*)param)->data = (int)v;
859} 792}
@@ -881,3 +814,3 @@ icalparameter* icalparameter_new_related(icalparameter_related v)
881 814
882icalparameter_related icalparameter_get_related(icalparameter* param) 815icalparameter_related icalparameter_get_related(const icalparameter* param)
883{ 816{
@@ -886,3 +819,3 @@ icalerror_check_arg( (param!=0), "param");
886 819
887return (icalparameter_related)((struct icalparameter_impl*)param)->data; 820return (icalparameter_related)(param->data);
888} 821}
@@ -899,4 +832,4 @@ void icalparameter_set_related(icalparameter* param, icalparameter_related v)
899 832
900/* CN */ 833/* ENCODING */
901icalparameter* icalparameter_new_cn(const char* v) 834icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
902{ 835{
@@ -904,4 +837,5 @@ icalparameter* icalparameter_new_cn(const char* v)
904 icalerror_clear_errno(); 837 icalerror_clear_errno();
905 icalerror_check_arg_rz( (v!=0),"v"); 838 icalerror_check_arg_rz(v >= ICAL_ENCODING_X,"v");
906 impl = icalparameter_new_impl(ICAL_CN_PARAMETER); 839 icalerror_check_arg_rz(v < ICAL_ENCODING_NONE,"v");
840 impl = icalparameter_new_impl(ICAL_ENCODING_PARAMETER);
907 if (impl == 0) { 841 if (impl == 0) {
@@ -910,3 +844,3 @@ icalparameter* icalparameter_new_cn(const char* v)
910 844
911 icalparameter_set_cn((icalparameter*) impl,v); 845 icalparameter_set_encoding((icalparameter*) impl,v);
912 if (icalerrno != ICAL_NO_ERROR) { 846 if (icalerrno != ICAL_NO_ERROR) {
@@ -919,12 +853,17 @@ icalparameter* icalparameter_new_cn(const char* v)
919 853
920const char* icalparameter_get_cn(icalparameter* param) 854icalparameter_encoding icalparameter_get_encoding(const icalparameter* param)
921{ 855{
922 icalerror_clear_errno(); 856 icalerror_clear_errno();
923 icalerror_check_arg_rz( (param!=0), "param"); 857icalerror_check_arg( (param!=0), "param");
924 return (const char*)((struct icalparameter_impl*)param)->string; 858 if (param->string != 0){
859 return ICAL_ENCODING_X;
860 }
861
862return (icalparameter_encoding)(param->data);
925} 863}
926 864
927void icalparameter_set_cn(icalparameter* param, const char* v) 865void icalparameter_set_encoding(icalparameter* param, icalparameter_encoding v)
928{ 866{
929 icalerror_check_arg_rv( (v!=0),"v"); 867 icalerror_check_arg_rv(v >= ICAL_ENCODING_X,"v");
868 icalerror_check_arg_rv(v < ICAL_ENCODING_NONE,"v");
930 icalerror_check_arg_rv( (param!=0), "param"); 869 icalerror_check_arg_rv( (param!=0), "param");
@@ -932,7 +871,7 @@ void icalparameter_set_cn(icalparameter* param, const char* v)
932 871
933 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 872 ((struct icalparameter_impl*)param)->data = (int)v;
934} 873}
935 874
936/* X-LIC-ERRORTYPE */ 875/* ALTREP */
937icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v) 876icalparameter* icalparameter_new_altrep(const char* v)
938{ 877{
@@ -940,5 +879,4 @@ icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
940 icalerror_clear_errno(); 879 icalerror_clear_errno();
941 icalerror_check_arg_rz(v >= ICAL_XLICERRORTYPE_X,"v"); 880 icalerror_check_arg_rz( (v!=0),"v");
942 icalerror_check_arg_rz(v < ICAL_XLICERRORTYPE_NONE,"v"); 881 impl = icalparameter_new_impl(ICAL_ALTREP_PARAMETER);
943 impl = icalparameter_new_impl(ICAL_XLICERRORTYPE_PARAMETER);
944 if (impl == 0) { 882 if (impl == 0) {
@@ -947,3 +885,3 @@ icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
947 885
948 icalparameter_set_xlicerrortype((icalparameter*) impl,v); 886 icalparameter_set_altrep((icalparameter*) impl,v);
949 if (icalerrno != ICAL_NO_ERROR) { 887 if (icalerrno != ICAL_NO_ERROR) {
@@ -956,14 +894,12 @@ icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
956 894
957icalparameter_xlicerrortype icalparameter_get_xlicerrortype(icalparameter* param) 895const char* icalparameter_get_altrep(const icalparameter* param)
958{ 896{
959 icalerror_clear_errno(); 897 icalerror_clear_errno();
960icalerror_check_arg( (param!=0), "param"); 898 icalerror_check_arg_rz( (param!=0), "param");
961 899 return param->string;
962return (icalparameter_xlicerrortype)((struct icalparameter_impl*)param)->data;
963} 900}
964 901
965void icalparameter_set_xlicerrortype(icalparameter* param, icalparameter_xlicerrortype v) 902void icalparameter_set_altrep(icalparameter* param, const char* v)
966{ 903{
967 icalerror_check_arg_rv(v >= ICAL_XLICERRORTYPE_X,"v"); 904 icalerror_check_arg_rv( (v!=0),"v");
968 icalerror_check_arg_rv(v < ICAL_XLICERRORTYPE_NONE,"v");
969 icalerror_check_arg_rv( (param!=0), "param"); 905 icalerror_check_arg_rv( (param!=0), "param");
@@ -971,7 +907,7 @@ void icalparameter_set_xlicerrortype(icalparameter* param, icalparameter_xlicerr
971 907
972 ((struct icalparameter_impl*)param)->data = (int)v; 908 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
973} 909}
974 910
975/* X */ 911/* DELEGATED-FROM */
976icalparameter* icalparameter_new_x(const char* v) 912icalparameter* icalparameter_new_delegatedfrom(const char* v)
977{ 913{
@@ -980,3 +916,3 @@ icalparameter* icalparameter_new_x(const char* v)
980 icalerror_check_arg_rz( (v!=0),"v"); 916 icalerror_check_arg_rz( (v!=0),"v");
981 impl = icalparameter_new_impl(ICAL_X_PARAMETER); 917 impl = icalparameter_new_impl(ICAL_DELEGATEDFROM_PARAMETER);
982 if (impl == 0) { 918 if (impl == 0) {
@@ -985,3 +921,3 @@ icalparameter* icalparameter_new_x(const char* v)
985 921
986 icalparameter_set_x((icalparameter*) impl,v); 922 icalparameter_set_delegatedfrom((icalparameter*) impl,v);
987 if (icalerrno != ICAL_NO_ERROR) { 923 if (icalerrno != ICAL_NO_ERROR) {
@@ -994,3 +930,3 @@ icalparameter* icalparameter_new_x(const char* v)
994 930
995const char* icalparameter_get_x(icalparameter* param) 931const char* icalparameter_get_delegatedfrom(const icalparameter* param)
996{ 932{
@@ -998,6 +934,6 @@ const char* icalparameter_get_x(icalparameter* param)
998 icalerror_check_arg_rz( (param!=0), "param"); 934 icalerror_check_arg_rz( (param!=0), "param");
999 return (const char*)((struct icalparameter_impl*)param)->string; 935 return param->string;
1000} 936}
1001 937
1002void icalparameter_set_x(icalparameter* param, const char* v) 938void icalparameter_set_delegatedfrom(icalparameter* param, const char* v)
1003{ 939{
@@ -1010,4 +946,4 @@ void icalparameter_set_x(icalparameter* param, const char* v)
1010 946
1011/* LANGUAGE */ 947/* FBTYPE */
1012icalparameter* icalparameter_new_language(const char* v) 948icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v)
1013{ 949{
@@ -1015,4 +951,5 @@ icalparameter* icalparameter_new_language(const char* v)
1015 icalerror_clear_errno(); 951 icalerror_clear_errno();
1016 icalerror_check_arg_rz( (v!=0),"v"); 952 icalerror_check_arg_rz(v >= ICAL_FBTYPE_X,"v");
1017 impl = icalparameter_new_impl(ICAL_LANGUAGE_PARAMETER); 953 icalerror_check_arg_rz(v < ICAL_FBTYPE_NONE,"v");
954 impl = icalparameter_new_impl(ICAL_FBTYPE_PARAMETER);
1018 if (impl == 0) { 955 if (impl == 0) {
@@ -1021,3 +958,3 @@ icalparameter* icalparameter_new_language(const char* v)
1021 958
1022 icalparameter_set_language((icalparameter*) impl,v); 959 icalparameter_set_fbtype((icalparameter*) impl,v);
1023 if (icalerrno != ICAL_NO_ERROR) { 960 if (icalerrno != ICAL_NO_ERROR) {
@@ -1030,12 +967,17 @@ icalparameter* icalparameter_new_language(const char* v)
1030 967
1031const char* icalparameter_get_language(icalparameter* param) 968icalparameter_fbtype icalparameter_get_fbtype(const icalparameter* param)
1032{ 969{
1033 icalerror_clear_errno(); 970 icalerror_clear_errno();
1034 icalerror_check_arg_rz( (param!=0), "param"); 971icalerror_check_arg( (param!=0), "param");
1035 return (const char*)((struct icalparameter_impl*)param)->string; 972 if (param->string != 0){
973 return ICAL_FBTYPE_X;
974 }
975
976return (icalparameter_fbtype)(param->data);
1036} 977}
1037 978
1038void icalparameter_set_language(icalparameter* param, const char* v) 979void icalparameter_set_fbtype(icalparameter* param, icalparameter_fbtype v)
1039{ 980{
1040 icalerror_check_arg_rv( (v!=0),"v"); 981 icalerror_check_arg_rv(v >= ICAL_FBTYPE_X,"v");
982 icalerror_check_arg_rv(v < ICAL_FBTYPE_NONE,"v");
1041 icalerror_check_arg_rv( (param!=0), "param"); 983 icalerror_check_arg_rv( (param!=0), "param");
@@ -1043,3 +985,3 @@ void icalparameter_set_language(icalparameter* param, const char* v)
1043 985
1044 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 986 ((struct icalparameter_impl*)param)->data = (int)v;
1045} 987}
@@ -1067,3 +1009,3 @@ icalparameter* icalparameter_new_role(icalparameter_role v)
1067 1009
1068icalparameter_role icalparameter_get_role(icalparameter* param) 1010icalparameter_role icalparameter_get_role(const icalparameter* param)
1069{ 1011{
@@ -1071,3 +1013,3 @@ icalparameter_role icalparameter_get_role(icalparameter* param)
1071icalerror_check_arg( (param!=0), "param"); 1013icalerror_check_arg( (param!=0), "param");
1072 if ( ((struct icalparameter_impl*)param)->string != 0){ 1014 if (param->string != 0){
1073 return ICAL_ROLE_X; 1015 return ICAL_ROLE_X;
@@ -1075,3 +1017,3 @@ icalerror_check_arg( (param!=0), "param");
1075 1017
1076return (icalparameter_role)((struct icalparameter_impl*)param)->data; 1018return (icalparameter_role)(param->data);
1077} 1019}
@@ -1088,4 +1030,4 @@ void icalparameter_set_role(icalparameter* param, icalparameter_role v)
1088 1030
1089/* X-LIC-COMPARETYPE */ 1031/* PARTSTAT */
1090icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v) 1032icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
1091{ 1033{
@@ -1093,5 +1035,5 @@ icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v
1093 icalerror_clear_errno(); 1035 icalerror_clear_errno();
1094 icalerror_check_arg_rz(v >= ICAL_XLICCOMPARETYPE_X,"v"); 1036 icalerror_check_arg_rz(v >= ICAL_PARTSTAT_X,"v");
1095 icalerror_check_arg_rz(v < ICAL_XLICCOMPARETYPE_NONE,"v"); 1037 icalerror_check_arg_rz(v < ICAL_PARTSTAT_NONE,"v");
1096 impl = icalparameter_new_impl(ICAL_XLICCOMPARETYPE_PARAMETER); 1038 impl = icalparameter_new_impl(ICAL_PARTSTAT_PARAMETER);
1097 if (impl == 0) { 1039 if (impl == 0) {
@@ -1100,3 +1042,3 @@ icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v
1100 1042
1101 icalparameter_set_xliccomparetype((icalparameter*) impl,v); 1043 icalparameter_set_partstat((icalparameter*) impl,v);
1102 if (icalerrno != ICAL_NO_ERROR) { 1044 if (icalerrno != ICAL_NO_ERROR) {
@@ -1109,3 +1051,3 @@ icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v
1109 1051
1110icalparameter_xliccomparetype icalparameter_get_xliccomparetype(icalparameter* param) 1052icalparameter_partstat icalparameter_get_partstat(const icalparameter* param)
1111{ 1053{
@@ -1113,10 +1055,13 @@ icalparameter_xliccomparetype icalparameter_get_xliccomparetype(icalparameter* p
1113icalerror_check_arg( (param!=0), "param"); 1055icalerror_check_arg( (param!=0), "param");
1056 if (param->string != 0){
1057 return ICAL_PARTSTAT_X;
1058 }
1114 1059
1115return (icalparameter_xliccomparetype)((struct icalparameter_impl*)param)->data; 1060return (icalparameter_partstat)(param->data);
1116} 1061}
1117 1062
1118void icalparameter_set_xliccomparetype(icalparameter* param, icalparameter_xliccomparetype v) 1063void icalparameter_set_partstat(icalparameter* param, icalparameter_partstat v)
1119{ 1064{
1120 icalerror_check_arg_rv(v >= ICAL_XLICCOMPARETYPE_X,"v"); 1065 icalerror_check_arg_rv(v >= ICAL_PARTSTAT_X,"v");
1121 icalerror_check_arg_rv(v < ICAL_XLICCOMPARETYPE_NONE,"v"); 1066 icalerror_check_arg_rv(v < ICAL_PARTSTAT_NONE,"v");
1122 icalerror_check_arg_rv( (param!=0), "param"); 1067 icalerror_check_arg_rv( (param!=0), "param");
@@ -1127,79 +1072,131 @@ void icalparameter_set_xliccomparetype(icalparameter* param, icalparameter_xlicc
1127 1072
1128/* FBTYPE */ 1073
1129icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v) 1074const char* icalparameter_kind_to_string(icalparameter_kind kind)
1130{ 1075{
1131 struct icalparameter_impl *impl; 1076 int i;
1132 icalerror_clear_errno();
1133 icalerror_check_arg_rz(v >= ICAL_FBTYPE_X,"v");
1134 icalerror_check_arg_rz(v < ICAL_FBTYPE_NONE,"v");
1135 impl = icalparameter_new_impl(ICAL_FBTYPE_PARAMETER);
1136 if (impl == 0) {
1137 return 0;
1138 }
1139 1077
1140 icalparameter_set_fbtype((icalparameter*) impl,v); 1078 for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
1141 if (icalerrno != ICAL_NO_ERROR) { 1079 if (parameter_map[i].kind == kind) {
1142 icalparameter_free((icalparameter*) impl); 1080 return parameter_map[i].name;
1143 return 0; 1081 }
1144 } 1082 }
1083
1084 return 0;
1145 1085
1146 return (icalparameter*) impl;
1147} 1086}
1148 1087
1149icalparameter_fbtype icalparameter_get_fbtype(icalparameter* param) 1088icalparameter_kind icalparameter_string_to_kind(const char* string)
1150{ 1089{
1151 icalerror_clear_errno(); 1090 int i;
1152icalerror_check_arg( (param!=0), "param"); 1091
1153 if ( ((struct icalparameter_impl*)param)->string != 0){ 1092 if (string ==0 ) {
1154 return ICAL_FBTYPE_X; 1093 return ICAL_NO_PARAMETER;
1155 } 1094 }
1095
1096 for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) {
1097
1098 if (strcmp(parameter_map[i].name, string) == 0) {
1099 return parameter_map[i].kind;
1100 }
1101 }
1156 1102
1157return (icalparameter_fbtype)((struct icalparameter_impl*)param)->data; 1103 if(strncmp(string,"X-",2)==0){
1104 return ICAL_X_PARAMETER;
1105 }
1106
1107 return ICAL_NO_PARAMETER;
1158} 1108}
1159 1109
1160void icalparameter_set_fbtype(icalparameter* param, icalparameter_fbtype v) 1110
1111icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value)
1161{ 1112{
1162 icalerror_check_arg_rv(v >= ICAL_FBTYPE_X,"v"); 1113 int i;
1163 icalerror_check_arg_rv(v < ICAL_FBTYPE_NONE,"v"); 1114
1164 icalerror_check_arg_rv( (param!=0), "param"); 1115 for (i=0; value_kind_map[i].kind != ICAL_NO_VALUE; i++) {
1165 icalerror_clear_errno(); 1116
1166 1117 if (value_kind_map[i].value == value) {
1167 ((struct icalparameter_impl*)param)->data = (int)v; 1118 return value_kind_map[i].kind;
1119 }
1120 }
1121
1122 return ICAL_NO_VALUE;
1168} 1123}
1169 1124
1170/* TZID */ 1125
1171icalparameter* icalparameter_new_tzid(const char* v) 1126const char* icalparameter_enum_to_string(int e)
1172{ 1127{
1173 struct icalparameter_impl *impl; 1128 int i;
1174 icalerror_clear_errno();
1175 icalerror_check_arg_rz( (v!=0),"v");
1176 impl = icalparameter_new_impl(ICAL_TZID_PARAMETER);
1177 if (impl == 0) {
1178 return 0;
1179 }
1180 1129
1181 icalparameter_set_tzid((icalparameter*) impl,v); 1130 icalerror_check_arg_rz(e >= ICALPARAMETER_FIRST_ENUM,"e");
1182 if (icalerrno != ICAL_NO_ERROR) { 1131 icalerror_check_arg_rz(e <= ICALPARAMETER_LAST_ENUM,"e");
1183 icalparameter_free((icalparameter*) impl);
1184 return 0;
1185 }
1186 1132
1187 return (icalparameter*) impl; 1133 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
1134 if(e == icalparameter_map[i].enumeration){
1135 return icalparameter_map[i].str;
1136 }
1137 }
1138
1139 return 0;
1188} 1140}
1189 1141
1190const char* icalparameter_get_tzid(icalparameter* param) 1142int icalparameter_string_to_enum(const char* str)
1191{ 1143{
1192 icalerror_clear_errno(); 1144 int i;
1193 icalerror_check_arg_rz( (param!=0), "param"); 1145
1194 return (const char*)((struct icalparameter_impl*)param)->string; 1146 icalerror_check_arg_rz(str != 0,"str");
1147
1148 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
1149 if(strcmp(str,icalparameter_map[i].str) == 0) {
1150 return icalparameter_map[i].enumeration;
1151 }
1152 }
1153
1154 return 0;
1195} 1155}
1196 1156
1197void icalparameter_set_tzid(icalparameter* param, const char* v) 1157icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val)
1198{ 1158{
1199 icalerror_check_arg_rv( (v!=0),"v"); 1159
1200 icalerror_check_arg_rv( (param!=0), "param"); 1160 struct icalparameter_impl* param=0;
1201 icalerror_clear_errno(); 1161 int found_kind = 0;
1202 1162 int i;
1203 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 1163
1164 icalerror_check_arg_rz((val!=0),"val");
1165
1166 /* Search through the parameter map to find a matching kind */
1167
1168 param = icalparameter_new_impl(kind);
1169
1170 for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){
1171 if(kind == icalparameter_map[i].kind) {
1172 found_kind = 1;
1173 if(strcmp(val,icalparameter_map[i].str) == 0) {
1174
1175 param->data = (int)icalparameter_map[i].enumeration;
1176 return param;
1177 }
1178 }
1179 }
1180
1181 if(found_kind == 1){
1182 /* The kind was in the parameter map, but the string did not
1183 match, so assume that it is an alternate value, like an
1184 X-value.*/
1185
1186 icalparameter_set_xvalue(param, val);
1187
1188 } else {
1189
1190 /* If the kind was not found, then it must be a string type */
1191
1192 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(val);
1193
1194 }
1195
1196 return param;
1204} 1197}
1205 1198
1199
1200
1201
1202/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedparameter.h b/libical/src/libical/icalderivedparameter.h
index adf4724..cbf0035 100644
--- a/libical/src/libical/icalderivedparameter.h
+++ b/libical/src/libical/icalderivedparameter.h
@@ -32,3 +32,3 @@
32 32
33typedef void icalparameter; 33typedef struct icalparameter_impl icalparameter;
34 34
@@ -37,3 +37,2 @@ int icalparameter_string_to_enum(const char* str);
37 37
38/* Everything below this line is machine generated. Do not edit. */
39typedef enum icalparameter_kind { 38typedef enum icalparameter_kind {
@@ -116,3 +115,3 @@ typedef enum icalparameter_related {
116 ICAL_RELATED_START = 20031, 115 ICAL_RELATED_START = 20031,
117 ICAL_RELATED_END = 20032, 116 ICAL_RELATED_END = 20032,
118 ICAL_RELATED_NONE = 20033 117 ICAL_RELATED_NONE = 20033
@@ -172,3 +171,5 @@ typedef enum icalparameter_xliccomparetype {
172 ICAL_XLICCOMPARETYPE_REGEX = 20072, 171 ICAL_XLICCOMPARETYPE_REGEX = 20072,
173 ICAL_XLICCOMPARETYPE_NONE = 20073 172 ICAL_XLICCOMPARETYPE_ISNULL = 20073,
173 ICAL_XLICCOMPARETYPE_ISNOTNULL = 20074,
174 ICAL_XLICCOMPARETYPE_NONE = 20075
174} icalparameter_xliccomparetype; 175} icalparameter_xliccomparetype;
@@ -176,45 +177,26 @@ typedef enum icalparameter_xliccomparetype {
176typedef enum icalparameter_xlicerrortype { 177typedef enum icalparameter_xlicerrortype {
177 ICAL_XLICERRORTYPE_X = 20074, 178 ICAL_XLICERRORTYPE_X = 20076,
178 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR = 20075, 179 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR = 20077,
179 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR = 20076, 180 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR = 20078,
180 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR = 20077, 181 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR = 20079,
181 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR = 20078, 182 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR = 20080,
182 ICAL_XLICERRORTYPE_VALUEPARSEERROR = 20079, 183 ICAL_XLICERRORTYPE_VALUEPARSEERROR = 20081,
183 ICAL_XLICERRORTYPE_INVALIDITIP = 20080, 184 ICAL_XLICERRORTYPE_INVALIDITIP = 20082,
184 ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR = 20081, 185 ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR = 20083,
185 ICAL_XLICERRORTYPE_MIMEPARSEERROR = 20082, 186 ICAL_XLICERRORTYPE_MIMEPARSEERROR = 20084,
186 ICAL_XLICERRORTYPE_NONE = 20083 187 ICAL_XLICERRORTYPE_VCALPROPPARSEERROR = 20085,
188 ICAL_XLICERRORTYPE_NONE = 20086
187} icalparameter_xlicerrortype; 189} icalparameter_xlicerrortype;
188 190
189#define ICALPARAMETER_LAST_ENUM 20084 191#define ICALPARAMETER_LAST_ENUM 20087
190
191/* DELEGATED-FROM */
192icalparameter* icalparameter_new_delegatedfrom(const char* v);
193const char* icalparameter_get_delegatedfrom(icalparameter* value);
194void icalparameter_set_delegatedfrom(icalparameter* value, const char* v);
195
196/* DELEGATED-TO */
197icalparameter* icalparameter_new_delegatedto(const char* v);
198const char* icalparameter_get_delegatedto(icalparameter* value);
199void icalparameter_set_delegatedto(icalparameter* value, const char* v);
200
201/* RANGE */
202icalparameter* icalparameter_new_range(icalparameter_range v);
203icalparameter_range icalparameter_get_range(icalparameter* value);
204void icalparameter_set_range(icalparameter* value, icalparameter_range v);
205 192
206/* ENCODING */ 193/* LANGUAGE */
207icalparameter* icalparameter_new_encoding(icalparameter_encoding v); 194icalparameter* icalparameter_new_language(const char* v);
208icalparameter_encoding icalparameter_get_encoding(icalparameter* value); 195const char* icalparameter_get_language(const icalparameter* value);
209void icalparameter_set_encoding(icalparameter* value, icalparameter_encoding v); 196void icalparameter_set_language(icalparameter* value, const char* v);
210
211/* RSVP */
212icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v);
213icalparameter_rsvp icalparameter_get_rsvp(icalparameter* value);
214void icalparameter_set_rsvp(icalparameter* value, icalparameter_rsvp v);
215 197
216/* PARTSTAT */ 198/* DIR */
217icalparameter* icalparameter_new_partstat(icalparameter_partstat v); 199icalparameter* icalparameter_new_dir(const char* v);
218icalparameter_partstat icalparameter_get_partstat(icalparameter* value); 200const char* icalparameter_get_dir(const icalparameter* value);
219void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v); 201void icalparameter_set_dir(icalparameter* value, const char* v);
220 202
@@ -222,24 +204,29 @@ void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v);
222icalparameter* icalparameter_new_reltype(icalparameter_reltype v); 204icalparameter* icalparameter_new_reltype(icalparameter_reltype v);
223icalparameter_reltype icalparameter_get_reltype(icalparameter* value); 205icalparameter_reltype icalparameter_get_reltype(const icalparameter* value);
224void icalparameter_set_reltype(icalparameter* value, icalparameter_reltype v); 206void icalparameter_set_reltype(icalparameter* value, icalparameter_reltype v);
225 207
226/* CUTYPE */
227icalparameter* icalparameter_new_cutype(icalparameter_cutype v);
228icalparameter_cutype icalparameter_get_cutype(icalparameter* value);
229void icalparameter_set_cutype(icalparameter* value, icalparameter_cutype v);
230
231/* MEMBER */
232icalparameter* icalparameter_new_member(const char* v);
233const char* icalparameter_get_member(icalparameter* value);
234void icalparameter_set_member(icalparameter* value, const char* v);
235
236/* FMTTYPE */ 208/* FMTTYPE */
237icalparameter* icalparameter_new_fmttype(const char* v); 209icalparameter* icalparameter_new_fmttype(const char* v);
238const char* icalparameter_get_fmttype(icalparameter* value); 210const char* icalparameter_get_fmttype(const icalparameter* value);
239void icalparameter_set_fmttype(icalparameter* value, const char* v); 211void icalparameter_set_fmttype(icalparameter* value, const char* v);
240 212
241/* SENT-BY */ 213/* TZID */
242icalparameter* icalparameter_new_sentby(const char* v); 214icalparameter* icalparameter_new_tzid(const char* v);
243const char* icalparameter_get_sentby(icalparameter* value); 215const char* icalparameter_get_tzid(const icalparameter* value);
244void icalparameter_set_sentby(icalparameter* value, const char* v); 216void icalparameter_set_tzid(icalparameter* value, const char* v);
217
218/* RANGE */
219icalparameter* icalparameter_new_range(icalparameter_range v);
220icalparameter_range icalparameter_get_range(const icalparameter* value);
221void icalparameter_set_range(icalparameter* value, icalparameter_range v);
222
223/* DELEGATED-TO */
224icalparameter* icalparameter_new_delegatedto(const char* v);
225const char* icalparameter_get_delegatedto(const icalparameter* value);
226void icalparameter_set_delegatedto(icalparameter* value, const char* v);
227
228/* CN */
229icalparameter* icalparameter_new_cn(const char* v);
230const char* icalparameter_get_cn(const icalparameter* value);
231void icalparameter_set_cn(icalparameter* value, const char* v);
245 232
@@ -247,24 +234,34 @@ void icalparameter_set_sentby(icalparameter* value, const char* v);
247icalparameter* icalparameter_new_value(icalparameter_value v); 234icalparameter* icalparameter_new_value(icalparameter_value v);
248icalparameter_value icalparameter_get_value(icalparameter* value); 235icalparameter_value icalparameter_get_value(const icalparameter* value);
249void icalparameter_set_value(icalparameter* value, icalparameter_value v); 236void icalparameter_set_value(icalparameter* value, icalparameter_value v);
250 237
251/* ALTREP */ 238/* X-LIC-COMPARETYPE */
252icalparameter* icalparameter_new_altrep(const char* v); 239icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v);
253const char* icalparameter_get_altrep(icalparameter* value); 240icalparameter_xliccomparetype icalparameter_get_xliccomparetype(const icalparameter* value);
254void icalparameter_set_altrep(icalparameter* value, const char* v); 241void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xliccomparetype v);
255 242
256/* DIR */ 243/* X */
257icalparameter* icalparameter_new_dir(const char* v); 244icalparameter* icalparameter_new_x(const char* v);
258const char* icalparameter_get_dir(icalparameter* value); 245const char* icalparameter_get_x(const icalparameter* value);
259void icalparameter_set_dir(icalparameter* value, const char* v); 246void icalparameter_set_x(icalparameter* value, const char* v);
260 247
261/* RELATED */ 248/* SENT-BY */
262icalparameter* icalparameter_new_related(icalparameter_related v); 249icalparameter* icalparameter_new_sentby(const char* v);
263icalparameter_related icalparameter_get_related(icalparameter* value); 250const char* icalparameter_get_sentby(const icalparameter* value);
264void icalparameter_set_related(icalparameter* value, icalparameter_related v); 251void icalparameter_set_sentby(icalparameter* value, const char* v);
265 252
266/* CN */ 253/* MEMBER */
267icalparameter* icalparameter_new_cn(const char* v); 254icalparameter* icalparameter_new_member(const char* v);
268const char* icalparameter_get_cn(icalparameter* value); 255const char* icalparameter_get_member(const icalparameter* value);
269void icalparameter_set_cn(icalparameter* value, const char* v); 256void icalparameter_set_member(icalparameter* value, const char* v);
257
258/* RSVP */
259icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v);
260icalparameter_rsvp icalparameter_get_rsvp(const icalparameter* value);
261void icalparameter_set_rsvp(icalparameter* value, icalparameter_rsvp v);
262
263/* CUTYPE */
264icalparameter* icalparameter_new_cutype(icalparameter_cutype v);
265icalparameter_cutype icalparameter_get_cutype(const icalparameter* value);
266void icalparameter_set_cutype(icalparameter* value, icalparameter_cutype v);
270 267
@@ -272,24 +269,24 @@ void icalparameter_set_cn(icalparameter* value, const char* v);
272icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v); 269icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v);
273icalparameter_xlicerrortype icalparameter_get_xlicerrortype(icalparameter* value); 270icalparameter_xlicerrortype icalparameter_get_xlicerrortype(const icalparameter* value);
274void icalparameter_set_xlicerrortype(icalparameter* value, icalparameter_xlicerrortype v); 271void icalparameter_set_xlicerrortype(icalparameter* value, icalparameter_xlicerrortype v);
275 272
276/* X */ 273/* RELATED */
277icalparameter* icalparameter_new_x(const char* v); 274icalparameter* icalparameter_new_related(icalparameter_related v);
278const char* icalparameter_get_x(icalparameter* value); 275icalparameter_related icalparameter_get_related(const icalparameter* value);
279void icalparameter_set_x(icalparameter* value, const char* v); 276void icalparameter_set_related(icalparameter* value, icalparameter_related v);
280 277
281/* LANGUAGE */ 278/* ENCODING */
282icalparameter* icalparameter_new_language(const char* v); 279icalparameter* icalparameter_new_encoding(icalparameter_encoding v);
283const char* icalparameter_get_language(icalparameter* value); 280icalparameter_encoding icalparameter_get_encoding(const icalparameter* value);
284void icalparameter_set_language(icalparameter* value, const char* v); 281void icalparameter_set_encoding(icalparameter* value, icalparameter_encoding v);
285 282
286/* ROLE */ 283/* ALTREP */
287icalparameter* icalparameter_new_role(icalparameter_role v); 284icalparameter* icalparameter_new_altrep(const char* v);
288icalparameter_role icalparameter_get_role(icalparameter* value); 285const char* icalparameter_get_altrep(const icalparameter* value);
289void icalparameter_set_role(icalparameter* value, icalparameter_role v); 286void icalparameter_set_altrep(icalparameter* value, const char* v);
290 287
291/* X-LIC-COMPARETYPE */ 288/* DELEGATED-FROM */
292icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v); 289icalparameter* icalparameter_new_delegatedfrom(const char* v);
293icalparameter_xliccomparetype icalparameter_get_xliccomparetype(icalparameter* value); 290const char* icalparameter_get_delegatedfrom(const icalparameter* value);
294void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xliccomparetype v); 291void icalparameter_set_delegatedfrom(icalparameter* value, const char* v);
295 292
@@ -297,9 +294,14 @@ void icalparameter_set_xliccomparetype(icalparameter* value, icalparameter_xlicc
297icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v); 294icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v);
298icalparameter_fbtype icalparameter_get_fbtype(icalparameter* value); 295icalparameter_fbtype icalparameter_get_fbtype(const icalparameter* value);
299void icalparameter_set_fbtype(icalparameter* value, icalparameter_fbtype v); 296void icalparameter_set_fbtype(icalparameter* value, icalparameter_fbtype v);
300 297
301/* TZID */ 298/* ROLE */
302icalparameter* icalparameter_new_tzid(const char* v); 299icalparameter* icalparameter_new_role(icalparameter_role v);
303const char* icalparameter_get_tzid(icalparameter* value); 300icalparameter_role icalparameter_get_role(const icalparameter* value);
304void icalparameter_set_tzid(icalparameter* value, const char* v); 301void icalparameter_set_role(icalparameter* value, icalparameter_role v);
302
303/* PARTSTAT */
304icalparameter* icalparameter_new_partstat(icalparameter_partstat v);
305icalparameter_partstat icalparameter_get_partstat(const icalparameter* value);
306void icalparameter_set_partstat(icalparameter* value, icalparameter_partstat v);
305 307
@@ -307 +309,2 @@ void icalparameter_set_tzid(icalparameter* value, const char* v);
307 309
310/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedproperty.c b/libical/src/libical/icalderivedproperty.c
index b41562b..362bfbe 100644
--- a/libical/src/libical/icalderivedproperty.c
+++ b/libical/src/libical/icalderivedproperty.c
@@ -45,6 +45,5 @@
45 45
46#define TMP_BUF_SIZE 1024
47
48struct icalproperty_impl* 46struct icalproperty_impl*
49icalproperty_new_impl (icalproperty_kind kind); 47icalproperty_new_impl (icalproperty_kind kind);
48void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
50 49
@@ -61,72 +60,2 @@ struct icalproperty_map {
61 60
62extern struct icalproperty_map property_map[];
63extern void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
64const char* icalproperty_kind_to_string(icalproperty_kind kind)
65{
66 int i;
67
68 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
69 if (property_map[i].kind == kind) {
70 return property_map[i].name;
71 }
72 }
73
74 return 0;
75
76}
77
78
79icalproperty_kind icalproperty_string_to_kind(const char* string)
80{
81 int i;
82
83 if (string ==0 ) {
84 return ICAL_NO_PROPERTY;
85 }
86
87
88 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
89 if (strcmp(property_map[i].name, string) == 0) {
90 return property_map[i].kind;
91 }
92 }
93
94 if(strncmp(string,"X-",2)==0){
95 return ICAL_X_PROPERTY;
96 }
97
98
99 return ICAL_NO_PROPERTY;
100}
101
102
103icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind)
104{
105 int i;
106
107 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
108 if ( property_map[i].value == kind ) {
109 return property_map[i].kind;
110 }
111 }
112
113 return ICAL_NO_VALUE;
114}
115
116
117
118icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind)
119{
120 int i;
121
122 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
123 if ( property_map[i].kind == kind ) {
124 return property_map[i].value;
125 }
126 }
127
128 return ICAL_NO_VALUE;
129}
130
131
132/* This map associates the property enumerations with the king of 61/* This map associates the property enumerations with the king of
@@ -141,113 +70,6 @@ struct icalproperty_enum_map {
141 70
142extern struct icalproperty_enum_map enum_map[];
143
144
145const char* icalproperty_enum_to_string(int e)
146{
147 icalerror_check_arg_rz(e >= ICALPROPERTY_FIRST_ENUM,"e");
148 icalerror_check_arg_rz(e <= ICALPROPERTY_LAST_ENUM,"e");
149
150 return enum_map[e-ICALPROPERTY_FIRST_ENUM].str;
151}
152
153int icalproperty_string_to_enum(const char* str)
154{
155 int i;
156
157 icalerror_check_arg_rz(str!=0,"str")
158
159 while(*str == ' '){
160 str++;
161 }
162
163 for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
164 if ( strcmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
165 return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum;
166 }
167 }
168
169 return 0;
170}
171
172int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e)
173{
174 int i;
175
176
177 for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
178 if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum == e &&
179 enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == kind ){
180 return 1;
181 }
182 }
183
184 return 0;
185}
186
187
188const char* icalproperty_method_to_string(icalproperty_method method)
189{
190 icalerror_check_arg_rz(method >= ICAL_METHOD_X,"method");
191 icalerror_check_arg_rz(method <= ICAL_METHOD_NONE,"method");
192
193 return enum_map[method-ICALPROPERTY_FIRST_ENUM].str;
194}
195
196icalproperty_method icalproperty_string_to_method(const char* str)
197{
198 int i;
199
200 icalerror_check_arg_rx(str!=0,"str",ICAL_METHOD_NONE)
201
202 while(*str == ' '){
203 str++;
204 }
205
206 for (i=ICAL_METHOD_X-ICALPROPERTY_FIRST_ENUM;
207 i != ICAL_METHOD_NONE-ICALPROPERTY_FIRST_ENUM;
208 i++) {
209 if ( strcmp(enum_map[i].str, str) == 0) {
210 return (icalproperty_method)enum_map[i].prop_enum;
211 }
212 }
213
214 return ICAL_METHOD_NONE;
215}
216
217
218const char* icalenum_status_to_string(icalproperty_status status)
219{
220 icalerror_check_arg_rz(status >= ICAL_STATUS_X,"status");
221 icalerror_check_arg_rz(status <= ICAL_STATUS_NONE,"status");
222
223 return enum_map[status-ICALPROPERTY_FIRST_ENUM].str;
224}
225
226icalproperty_status icalenum_string_to_status(const char* str)
227{
228 int i;
229
230 icalerror_check_arg_rx(str!=0,"str",ICAL_STATUS_NONE)
231
232 while(*str == ' '){
233 str++;
234 }
235
236 for (i=ICAL_STATUS_X-ICALPROPERTY_FIRST_ENUM;
237 i != ICAL_STATUS_NONE-ICALPROPERTY_FIRST_ENUM;
238 i++) {
239 if ( strcmp(enum_map[i].str, str) == 0) {
240 return (icalproperty_method)enum_map[i].prop_enum;
241 }
242 }
243
244 return ICAL_STATUS_NONE;
245
246}
247
248
249 71
250/* Everything below this line is machine generated. Do not edit. */ 72static struct icalproperty_map property_map[77] = {
251static struct icalproperty_map property_map[] = {
252{ICAL_ACTION_PROPERTY,"ACTION",ICAL_ACTION_VALUE}, 73{ICAL_ACTION_PROPERTY,"ACTION",ICAL_ACTION_VALUE},
74{ICAL_ALLOWCONFLICT_PROPERTY,"ALLOW-CONFLICT",ICAL_TEXT_VALUE},
253{ICAL_ANY_PROPERTY,"ANY",ICAL_NO_VALUE}, 75{ICAL_ANY_PROPERTY,"ANY",ICAL_NO_VALUE},
@@ -255,5 +77,8 @@ static struct icalproperty_map property_map[] = {
255{ICAL_ATTENDEE_PROPERTY,"ATTENDEE",ICAL_CALADDRESS_VALUE}, 77{ICAL_ATTENDEE_PROPERTY,"ATTENDEE",ICAL_CALADDRESS_VALUE},
78{ICAL_CALID_PROPERTY,"CALID",ICAL_TEXT_VALUE},
79{ICAL_CALMASTER_PROPERTY,"CALMASTER",ICAL_TEXT_VALUE},
256{ICAL_CALSCALE_PROPERTY,"CALSCALE",ICAL_TEXT_VALUE}, 80{ICAL_CALSCALE_PROPERTY,"CALSCALE",ICAL_TEXT_VALUE},
81{ICAL_CARID_PROPERTY,"CARID",ICAL_TEXT_VALUE},
257{ICAL_CATEGORIES_PROPERTY,"CATEGORIES",ICAL_TEXT_VALUE}, 82{ICAL_CATEGORIES_PROPERTY,"CATEGORIES",ICAL_TEXT_VALUE},
258{ICAL_CLASS_PROPERTY,"CLASS",ICAL_TEXT_VALUE}, 83{ICAL_CLASS_PROPERTY,"CLASS",ICAL_CLASS_VALUE},
259{ICAL_COMMENT_PROPERTY,"COMMENT",ICAL_TEXT_VALUE}, 84{ICAL_COMMENT_PROPERTY,"COMMENT",ICAL_TEXT_VALUE},
@@ -262,2 +87,6 @@ static struct icalproperty_map property_map[] = {
262{ICAL_CREATED_PROPERTY,"CREATED",ICAL_DATETIME_VALUE}, 87{ICAL_CREATED_PROPERTY,"CREATED",ICAL_DATETIME_VALUE},
88{ICAL_DECREED_PROPERTY,"DECREED",ICAL_TEXT_VALUE},
89{ICAL_DEFAULTCHARSET_PROPERTY,"DEFAULT-CHARSET",ICAL_TEXT_VALUE},
90{ICAL_DEFAULTLOCALE_PROPERTY,"DEFAULT-LOCALE",ICAL_TEXT_VALUE},
91{ICAL_DEFAULTTZID_PROPERTY,"DEFAULT-TZID",ICAL_TEXT_VALUE},
263{ICAL_DESCRIPTION_PROPERTY,"DESCRIPTION",ICAL_TEXT_VALUE}, 92{ICAL_DESCRIPTION_PROPERTY,"DESCRIPTION",ICAL_TEXT_VALUE},
@@ -269,2 +98,3 @@ static struct icalproperty_map property_map[] = {
269{ICAL_EXDATE_PROPERTY,"EXDATE",ICAL_DATETIME_VALUE}, 98{ICAL_EXDATE_PROPERTY,"EXDATE",ICAL_DATETIME_VALUE},
99{ICAL_EXPAND_PROPERTY,"EXPAND",ICAL_INTEGER_VALUE},
270{ICAL_EXRULE_PROPERTY,"EXRULE",ICAL_RECUR_VALUE}, 100{ICAL_EXRULE_PROPERTY,"EXRULE",ICAL_RECUR_VALUE},
@@ -278,2 +108,3 @@ static struct icalproperty_map property_map[] = {
278{ICAL_ORGANIZER_PROPERTY,"ORGANIZER",ICAL_CALADDRESS_VALUE}, 108{ICAL_ORGANIZER_PROPERTY,"ORGANIZER",ICAL_CALADDRESS_VALUE},
109{ICAL_OWNER_PROPERTY,"OWNER",ICAL_TEXT_VALUE},
279{ICAL_PERCENTCOMPLETE_PROPERTY,"PERCENT-COMPLETE",ICAL_INTEGER_VALUE}, 110{ICAL_PERCENTCOMPLETE_PROPERTY,"PERCENT-COMPLETE",ICAL_INTEGER_VALUE},
@@ -286,2 +117,3 @@ static struct icalproperty_map property_map[] = {
286{ICAL_RELATEDTO_PROPERTY,"RELATED-TO",ICAL_TEXT_VALUE}, 117{ICAL_RELATEDTO_PROPERTY,"RELATED-TO",ICAL_TEXT_VALUE},
118{ICAL_RELCALID_PROPERTY,"RELCALID",ICAL_TEXT_VALUE},
287{ICAL_REPEAT_PROPERTY,"REPEAT",ICAL_INTEGER_VALUE}, 119{ICAL_REPEAT_PROPERTY,"REPEAT",ICAL_INTEGER_VALUE},
@@ -295,3 +127,3 @@ static struct icalproperty_map property_map[] = {
295{ICAL_TARGET_PROPERTY,"TARGET",ICAL_CALADDRESS_VALUE}, 127{ICAL_TARGET_PROPERTY,"TARGET",ICAL_CALADDRESS_VALUE},
296{ICAL_TRANSP_PROPERTY,"TRANSP",ICAL_TEXT_VALUE}, 128{ICAL_TRANSP_PROPERTY,"TRANSP",ICAL_TRANSP_VALUE},
297{ICAL_TRIGGER_PROPERTY,"TRIGGER",ICAL_TRIGGER_VALUE}, 129{ICAL_TRIGGER_PROPERTY,"TRIGGER",ICAL_TRIGGER_VALUE},
@@ -305,3 +137,4 @@ static struct icalproperty_map property_map[] = {
305{ICAL_VERSION_PROPERTY,"VERSION",ICAL_TEXT_VALUE}, 137{ICAL_VERSION_PROPERTY,"VERSION",ICAL_TEXT_VALUE},
306{ICAL_X_PROPERTY,"X",ICAL_TEXT_VALUE}, 138{ICAL_X_PROPERTY,"X",ICAL_X_VALUE},
139{ICAL_XLICCLASS_PROPERTY,"X-LIC-CLASS",ICAL_XLICCLASS_VALUE},
307{ICAL_XLICCLUSTERCOUNT_PROPERTY,"X-LIC-CLUSTERCOUNT",ICAL_STRING_VALUE}, 140{ICAL_XLICCLUSTERCOUNT_PROPERTY,"X-LIC-CLUSTERCOUNT",ICAL_STRING_VALUE},
@@ -316,3 +149,3 @@ static struct icalproperty_map property_map[] = {
316 149
317static struct icalproperty_enum_map enum_map[] = { 150static struct icalproperty_enum_map enum_map[75] = {
318 {ICAL_ACTION_PROPERTY,ICAL_ACTION_X,"" }, /*10000*/ 151 {ICAL_ACTION_PROPERTY,ICAL_ACTION_X,"" }, /*10000*/
@@ -357,4 +190,35 @@ static struct icalproperty_enum_map enum_map[] = {
357 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_OPAQUE,"OPAQUE" }, /*10039*/ 190 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_OPAQUE,"OPAQUE" }, /*10039*/
358 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_TRANSPARENT,"TRANSPARENT" }, /*10040*/ 191 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_OPAQUENOCONFLICT,"OPAQUE-NOCONFLICT" }, /*10040*/
359 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_NONE,"" }, /*10041*/ 192 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_TRANSPARENT,"TRANSPARENT" }, /*10041*/
193 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_TRANSPARENTNOCONFLICT,"TRANSPARENT-NOCONFLICT" }, /*10042*/
194 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_NONE,"" }, /*10043*/
195 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_X,"" }, /*10044*/
196 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_PUBLISHNEW,"PUBLISH-NEW" }, /*10045*/
197 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_PUBLISHUPDATE,"PUBLISH-UPDATE" }, /*10046*/
198 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_PUBLISHFREEBUSY,"PUBLISH-FREEBUSY" }, /*10047*/
199 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTNEW,"REQUEST-NEW" }, /*10048*/
200 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTUPDATE,"REQUEST-UPDATE" }, /*10049*/
201 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTRESCHEDULE,"REQUEST-RESCHEDULE" }, /*10050*/
202 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTDELEGATE,"REQUEST-DELEGATE" }, /*10051*/
203 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTNEWORGANIZER,"REQUEST-NEW-ORGANIZER" }, /*10052*/
204 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTFORWARD,"REQUEST-FORWARD" }, /*10053*/
205 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTSTATUS,"REQUEST-STATUS" }, /*10054*/
206 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REQUESTFREEBUSY,"REQUEST-FREEBUSY" }, /*10055*/
207 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REPLYACCEPT,"REPLY-ACCEPT" }, /*10056*/
208 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REPLYDECLINE,"REPLY-DECLINE" }, /*10057*/
209 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REPLYDELEGATE,"REPLY-DELEGATE" }, /*10058*/
210 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REPLYCRASHERACCEPT,"REPLY-CRASHER-ACCEPT" }, /*10059*/
211 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REPLYCRASHERDECLINE,"REPLY-CRASHER-DECLINE" }, /*10060*/
212 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_ADDINSTANCE,"ADD-INSTANCE" }, /*10061*/
213 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_CANCELEVENT,"CANCEL-EVENT" }, /*10062*/
214 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_CANCELINSTANCE,"CANCEL-INSTANCE" }, /*10063*/
215 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_CANCELALL,"CANCEL-ALL" }, /*10064*/
216 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_REFRESH,"REFRESH" }, /*10065*/
217 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_COUNTER,"COUNTER" }, /*10066*/
218 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_DECLINECOUNTER,"DECLINECOUNTER" }, /*10067*/
219 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_MALFORMED,"MALFORMED" }, /*10068*/
220 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_OBSOLETE,"OBSOLETE" }, /*10069*/
221 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_MISSEQUENCED,"MISSEQUENCED" }, /*10070*/
222 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_UNKNOWN,"UNKNOWN" }, /*10071*/
223 {ICAL_XLICCLASS_PROPERTY,ICAL_XLICCLASS_NONE,"" }, /*10072*/
360 {ICAL_NO_PROPERTY,0,""} 224 {ICAL_NO_PROPERTY,0,""}
@@ -371,2 +235,3 @@ icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...){
371} 235}
236
372/* ACTION */ 237/* ACTION */
@@ -383,3 +248,3 @@ void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v){
383} 248}
384enum icalproperty_action icalproperty_get_action(icalproperty* prop){ 249enum icalproperty_action icalproperty_get_action(const icalproperty* prop){
385 icalerror_check_arg( (prop!=0),"prop"); 250 icalerror_check_arg( (prop!=0),"prop");
@@ -387,3 +252,32 @@ enum icalproperty_action icalproperty_get_action(icalproperty* prop){
387} 252}
388icalproperty* icalproperty_vanew_attach(struct icalattachtype* v, ...){ 253icalproperty* icalproperty_vanew_allowconflict(const char* v, ...){
254 va_list args;
255 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ALLOWCONFLICT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
256
257 icalproperty_set_allowconflict((icalproperty*)impl,v);
258 va_start(args,v);
259 icalproperty_add_parameters(impl, args);
260 va_end(args);
261 return (icalproperty*)impl;
262}
263
264/* ALLOW-CONFLICT */
265icalproperty* icalproperty_new_allowconflict(const char* v) {
266 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ALLOWCONFLICT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
267
268 icalproperty_set_allowconflict((icalproperty*)impl,v);
269 return (icalproperty*)impl;
270}
271
272void icalproperty_set_allowconflict(icalproperty* prop, const char* v){
273 icalerror_check_arg_rv( (v!=0),"v");
274
275 icalerror_check_arg_rv( (prop!=0),"prop");
276 icalproperty_set_value(prop,icalvalue_new_text(v));
277}
278const char* icalproperty_get_allowconflict(const icalproperty* prop){
279 icalerror_check_arg( (prop!=0),"prop");
280 return icalvalue_get_text(icalproperty_get_value(prop));
281}
282icalproperty* icalproperty_vanew_attach(icalattach * v, ...){
389 va_list args; 283 va_list args;
@@ -397,4 +291,5 @@ icalproperty* icalproperty_vanew_attach(struct icalattachtype* v, ...){
397} 291}
292
398/* ATTACH */ 293/* ATTACH */
399icalproperty* icalproperty_new_attach(struct icalattachtype* v) { 294icalproperty* icalproperty_new_attach(icalattach * v) {
400 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 295 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -405,3 +300,3 @@ icalproperty* icalproperty_new_attach(struct icalattachtype* v) {
405 300
406void icalproperty_set_attach(icalproperty* prop, struct icalattachtype* v){ 301void icalproperty_set_attach(icalproperty* prop, icalattach * v){
407 icalerror_check_arg_rv( (v!=0),"v"); 302 icalerror_check_arg_rv( (v!=0),"v");
@@ -411,3 +306,3 @@ void icalproperty_set_attach(icalproperty* prop, struct icalattachtype* v){
411} 306}
412struct icalattachtype* icalproperty_get_attach(icalproperty* prop){ 307icalattach * icalproperty_get_attach(const icalproperty* prop){
413 icalerror_check_arg( (prop!=0),"prop"); 308 icalerror_check_arg( (prop!=0),"prop");
@@ -425,2 +320,3 @@ icalproperty* icalproperty_vanew_attendee(const char* v, ...){
425} 320}
321
426/* ATTENDEE */ 322/* ATTENDEE */
@@ -439,3 +335,3 @@ void icalproperty_set_attendee(icalproperty* prop, const char* v){
439} 335}
440const char* icalproperty_get_attendee(icalproperty* prop){ 336const char* icalproperty_get_attendee(const icalproperty* prop){
441 icalerror_check_arg( (prop!=0),"prop"); 337 icalerror_check_arg( (prop!=0),"prop");
@@ -443,2 +339,60 @@ const char* icalproperty_get_attendee(icalproperty* prop){
443} 339}
340icalproperty* icalproperty_vanew_calid(const char* v, ...){
341 va_list args;
342 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
343
344 icalproperty_set_calid((icalproperty*)impl,v);
345 va_start(args,v);
346 icalproperty_add_parameters(impl, args);
347 va_end(args);
348 return (icalproperty*)impl;
349}
350
351/* CALID */
352icalproperty* icalproperty_new_calid(const char* v) {
353 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
354
355 icalproperty_set_calid((icalproperty*)impl,v);
356 return (icalproperty*)impl;
357}
358
359void icalproperty_set_calid(icalproperty* prop, const char* v){
360 icalerror_check_arg_rv( (v!=0),"v");
361
362 icalerror_check_arg_rv( (prop!=0),"prop");
363 icalproperty_set_value(prop,icalvalue_new_text(v));
364}
365const char* icalproperty_get_calid(const icalproperty* prop){
366 icalerror_check_arg( (prop!=0),"prop");
367 return icalvalue_get_text(icalproperty_get_value(prop));
368}
369icalproperty* icalproperty_vanew_calmaster(const char* v, ...){
370 va_list args;
371 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALMASTER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
372
373 icalproperty_set_calmaster((icalproperty*)impl,v);
374 va_start(args,v);
375 icalproperty_add_parameters(impl, args);
376 va_end(args);
377 return (icalproperty*)impl;
378}
379
380/* CALMASTER */
381icalproperty* icalproperty_new_calmaster(const char* v) {
382 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALMASTER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
383
384 icalproperty_set_calmaster((icalproperty*)impl,v);
385 return (icalproperty*)impl;
386}
387
388void icalproperty_set_calmaster(icalproperty* prop, const char* v){
389 icalerror_check_arg_rv( (v!=0),"v");
390
391 icalerror_check_arg_rv( (prop!=0),"prop");
392 icalproperty_set_value(prop,icalvalue_new_text(v));
393}
394const char* icalproperty_get_calmaster(const icalproperty* prop){
395 icalerror_check_arg( (prop!=0),"prop");
396 return icalvalue_get_text(icalproperty_get_value(prop));
397}
444icalproperty* icalproperty_vanew_calscale(const char* v, ...){ 398icalproperty* icalproperty_vanew_calscale(const char* v, ...){
@@ -453,2 +407,3 @@ icalproperty* icalproperty_vanew_calscale(const char* v, ...){
453} 407}
408
454/* CALSCALE */ 409/* CALSCALE */
@@ -467,3 +422,32 @@ void icalproperty_set_calscale(icalproperty* prop, const char* v){
467} 422}
468const char* icalproperty_get_calscale(icalproperty* prop){ 423const char* icalproperty_get_calscale(const icalproperty* prop){
424 icalerror_check_arg( (prop!=0),"prop");
425 return icalvalue_get_text(icalproperty_get_value(prop));
426}
427icalproperty* icalproperty_vanew_carid(const char* v, ...){
428 va_list args;
429 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CARID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
430
431 icalproperty_set_carid((icalproperty*)impl,v);
432 va_start(args,v);
433 icalproperty_add_parameters(impl, args);
434 va_end(args);
435 return (icalproperty*)impl;
436}
437
438/* CARID */
439icalproperty* icalproperty_new_carid(const char* v) {
440 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CARID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
441
442 icalproperty_set_carid((icalproperty*)impl,v);
443 return (icalproperty*)impl;
444}
445
446void icalproperty_set_carid(icalproperty* prop, const char* v){
447 icalerror_check_arg_rv( (v!=0),"v");
448
449 icalerror_check_arg_rv( (prop!=0),"prop");
450 icalproperty_set_value(prop,icalvalue_new_text(v));
451}
452const char* icalproperty_get_carid(const icalproperty* prop){
469 icalerror_check_arg( (prop!=0),"prop"); 453 icalerror_check_arg( (prop!=0),"prop");
@@ -481,2 +465,3 @@ icalproperty* icalproperty_vanew_categories(const char* v, ...){
481} 465}
466
482/* CATEGORIES */ 467/* CATEGORIES */
@@ -495,3 +480,3 @@ void icalproperty_set_categories(icalproperty* prop, const char* v){
495} 480}
496const char* icalproperty_get_categories(icalproperty* prop){ 481const char* icalproperty_get_categories(const icalproperty* prop){
497 icalerror_check_arg( (prop!=0),"prop"); 482 icalerror_check_arg( (prop!=0),"prop");
@@ -499,6 +484,5 @@ const char* icalproperty_get_categories(icalproperty* prop){
499} 484}
500icalproperty* icalproperty_vanew_class(const char* v, ...){ 485icalproperty* icalproperty_vanew_class(enum icalproperty_class v, ...){
501 va_list args; 486 va_list args;
502 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 487 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY);
503
504 icalproperty_set_class((icalproperty*)impl,v); 488 icalproperty_set_class((icalproperty*)impl,v);
@@ -509,6 +493,6 @@ icalproperty* icalproperty_vanew_class(const char* v, ...){
509} 493}
510/* CLASS */
511icalproperty* icalproperty_new_class(const char* v) {
512 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
513 494
495/* CLASS */
496icalproperty* icalproperty_new_class(enum icalproperty_class v) {
497 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CLASS_PROPERTY);
514 icalproperty_set_class((icalproperty*)impl,v); 498 icalproperty_set_class((icalproperty*)impl,v);
@@ -517,11 +501,10 @@ icalproperty* icalproperty_new_class(const char* v) {
517 501
518void icalproperty_set_class(icalproperty* prop, const char* v){ 502void icalproperty_set_class(icalproperty* prop, enum icalproperty_class v){
519 icalerror_check_arg_rv( (v!=0),"v"); 503
520
521 icalerror_check_arg_rv( (prop!=0),"prop"); 504 icalerror_check_arg_rv( (prop!=0),"prop");
522 icalproperty_set_value(prop,icalvalue_new_text(v)); 505 icalproperty_set_value(prop,icalvalue_new_class(v));
523} 506}
524const char* icalproperty_get_class(icalproperty* prop){ 507enum icalproperty_class icalproperty_get_class(const icalproperty* prop){
525 icalerror_check_arg( (prop!=0),"prop"); 508 icalerror_check_arg( (prop!=0),"prop");
526 return icalvalue_get_text(icalproperty_get_value(prop)); 509 return icalvalue_get_class(icalproperty_get_value(prop));
527} 510}
@@ -537,2 +520,3 @@ icalproperty* icalproperty_vanew_comment(const char* v, ...){
537} 520}
521
538/* COMMENT */ 522/* COMMENT */
@@ -551,3 +535,3 @@ void icalproperty_set_comment(icalproperty* prop, const char* v){
551} 535}
552const char* icalproperty_get_comment(icalproperty* prop){ 536const char* icalproperty_get_comment(const icalproperty* prop){
553 icalerror_check_arg( (prop!=0),"prop"); 537 icalerror_check_arg( (prop!=0),"prop");
@@ -564,2 +548,3 @@ icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...){
564} 548}
549
565/* COMPLETED */ 550/* COMPLETED */
@@ -576,3 +561,3 @@ void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v){
576} 561}
577struct icaltimetype icalproperty_get_completed(icalproperty* prop){ 562struct icaltimetype icalproperty_get_completed(const icalproperty* prop){
578 icalerror_check_arg( (prop!=0),"prop"); 563 icalerror_check_arg( (prop!=0),"prop");
@@ -590,2 +575,3 @@ icalproperty* icalproperty_vanew_contact(const char* v, ...){
590} 575}
576
591/* CONTACT */ 577/* CONTACT */
@@ -604,3 +590,3 @@ void icalproperty_set_contact(icalproperty* prop, const char* v){
604} 590}
605const char* icalproperty_get_contact(icalproperty* prop){ 591const char* icalproperty_get_contact(const icalproperty* prop){
606 icalerror_check_arg( (prop!=0),"prop"); 592 icalerror_check_arg( (prop!=0),"prop");
@@ -617,2 +603,3 @@ icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...){
617} 603}
604
618/* CREATED */ 605/* CREATED */
@@ -629,3 +616,3 @@ void icalproperty_set_created(icalproperty* prop, struct icaltimetype v){
629} 616}
630struct icaltimetype icalproperty_get_created(icalproperty* prop){ 617struct icaltimetype icalproperty_get_created(const icalproperty* prop){
631 icalerror_check_arg( (prop!=0),"prop"); 618 icalerror_check_arg( (prop!=0),"prop");
@@ -633,2 +620,118 @@ struct icaltimetype icalproperty_get_created(icalproperty* prop){
633} 620}
621icalproperty* icalproperty_vanew_decreed(const char* v, ...){
622 va_list args;
623 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DECREED_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
624
625 icalproperty_set_decreed((icalproperty*)impl,v);
626 va_start(args,v);
627 icalproperty_add_parameters(impl, args);
628 va_end(args);
629 return (icalproperty*)impl;
630}
631
632/* DECREED */
633icalproperty* icalproperty_new_decreed(const char* v) {
634 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DECREED_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
635
636 icalproperty_set_decreed((icalproperty*)impl,v);
637 return (icalproperty*)impl;
638}
639
640void icalproperty_set_decreed(icalproperty* prop, const char* v){
641 icalerror_check_arg_rv( (v!=0),"v");
642
643 icalerror_check_arg_rv( (prop!=0),"prop");
644 icalproperty_set_value(prop,icalvalue_new_text(v));
645}
646const char* icalproperty_get_decreed(const icalproperty* prop){
647 icalerror_check_arg( (prop!=0),"prop");
648 return icalvalue_get_text(icalproperty_get_value(prop));
649}
650icalproperty* icalproperty_vanew_defaultcharset(const char* v, ...){
651 va_list args;
652 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTCHARSET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
653
654 icalproperty_set_defaultcharset((icalproperty*)impl,v);
655 va_start(args,v);
656 icalproperty_add_parameters(impl, args);
657 va_end(args);
658 return (icalproperty*)impl;
659}
660
661/* DEFAULT-CHARSET */
662icalproperty* icalproperty_new_defaultcharset(const char* v) {
663 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTCHARSET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
664
665 icalproperty_set_defaultcharset((icalproperty*)impl,v);
666 return (icalproperty*)impl;
667}
668
669void icalproperty_set_defaultcharset(icalproperty* prop, const char* v){
670 icalerror_check_arg_rv( (v!=0),"v");
671
672 icalerror_check_arg_rv( (prop!=0),"prop");
673 icalproperty_set_value(prop,icalvalue_new_text(v));
674}
675const char* icalproperty_get_defaultcharset(const icalproperty* prop){
676 icalerror_check_arg( (prop!=0),"prop");
677 return icalvalue_get_text(icalproperty_get_value(prop));
678}
679icalproperty* icalproperty_vanew_defaultlocale(const char* v, ...){
680 va_list args;
681 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTLOCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
682
683 icalproperty_set_defaultlocale((icalproperty*)impl,v);
684 va_start(args,v);
685 icalproperty_add_parameters(impl, args);
686 va_end(args);
687 return (icalproperty*)impl;
688}
689
690/* DEFAULT-LOCALE */
691icalproperty* icalproperty_new_defaultlocale(const char* v) {
692 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTLOCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
693
694 icalproperty_set_defaultlocale((icalproperty*)impl,v);
695 return (icalproperty*)impl;
696}
697
698void icalproperty_set_defaultlocale(icalproperty* prop, const char* v){
699 icalerror_check_arg_rv( (v!=0),"v");
700
701 icalerror_check_arg_rv( (prop!=0),"prop");
702 icalproperty_set_value(prop,icalvalue_new_text(v));
703}
704const char* icalproperty_get_defaultlocale(const icalproperty* prop){
705 icalerror_check_arg( (prop!=0),"prop");
706 return icalvalue_get_text(icalproperty_get_value(prop));
707}
708icalproperty* icalproperty_vanew_defaulttzid(const char* v, ...){
709 va_list args;
710 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTTZID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
711
712 icalproperty_set_defaulttzid((icalproperty*)impl,v);
713 va_start(args,v);
714 icalproperty_add_parameters(impl, args);
715 va_end(args);
716 return (icalproperty*)impl;
717}
718
719/* DEFAULT-TZID */
720icalproperty* icalproperty_new_defaulttzid(const char* v) {
721 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DEFAULTTZID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
722
723 icalproperty_set_defaulttzid((icalproperty*)impl,v);
724 return (icalproperty*)impl;
725}
726
727void icalproperty_set_defaulttzid(icalproperty* prop, const char* v){
728 icalerror_check_arg_rv( (v!=0),"v");
729
730 icalerror_check_arg_rv( (prop!=0),"prop");
731 icalproperty_set_value(prop,icalvalue_new_text(v));
732}
733const char* icalproperty_get_defaulttzid(const icalproperty* prop){
734 icalerror_check_arg( (prop!=0),"prop");
735 return icalvalue_get_text(icalproperty_get_value(prop));
736}
634icalproperty* icalproperty_vanew_description(const char* v, ...){ 737icalproperty* icalproperty_vanew_description(const char* v, ...){
@@ -643,2 +746,3 @@ icalproperty* icalproperty_vanew_description(const char* v, ...){
643} 746}
747
644/* DESCRIPTION */ 748/* DESCRIPTION */
@@ -657,3 +761,3 @@ void icalproperty_set_description(icalproperty* prop, const char* v){
657} 761}
658const char* icalproperty_get_description(icalproperty* prop){ 762const char* icalproperty_get_description(const icalproperty* prop){
659 icalerror_check_arg( (prop!=0),"prop"); 763 icalerror_check_arg( (prop!=0),"prop");
@@ -670,2 +774,3 @@ icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...){
670} 774}
775
671/* DTEND */ 776/* DTEND */
@@ -678,7 +783,12 @@ icalproperty* icalproperty_new_dtend(struct icaltimetype v) {
678void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v){ 783void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v){
784 icalvalue *value;
679 785
680 icalerror_check_arg_rv( (prop!=0),"prop"); 786 icalerror_check_arg_rv( (prop!=0),"prop");
681 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 787 if (v.is_date)
788 value = icalvalue_new_date(v);
789 else
790 value = icalvalue_new_datetime(v);
791 icalproperty_set_value(prop,value);
682} 792}
683struct icaltimetype icalproperty_get_dtend(icalproperty* prop){ 793struct icaltimetype icalproperty_get_dtend(const icalproperty* prop){
684 icalerror_check_arg( (prop!=0),"prop"); 794 icalerror_check_arg( (prop!=0),"prop");
@@ -695,2 +805,3 @@ icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...){
695} 805}
806
696/* DTSTAMP */ 807/* DTSTAMP */
@@ -707,3 +818,3 @@ void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v){
707} 818}
708struct icaltimetype icalproperty_get_dtstamp(icalproperty* prop){ 819struct icaltimetype icalproperty_get_dtstamp(const icalproperty* prop){
709 icalerror_check_arg( (prop!=0),"prop"); 820 icalerror_check_arg( (prop!=0),"prop");
@@ -720,2 +831,3 @@ icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...){
720} 831}
832
721/* DTSTART */ 833/* DTSTART */
@@ -728,7 +840,12 @@ icalproperty* icalproperty_new_dtstart(struct icaltimetype v) {
728void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v){ 840void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v){
841 icalvalue *value;
729 842
730 icalerror_check_arg_rv( (prop!=0),"prop"); 843 icalerror_check_arg_rv( (prop!=0),"prop");
731 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 844 if (v.is_date)
845 value = icalvalue_new_date(v);
846 else
847 value = icalvalue_new_datetime(v);
848 icalproperty_set_value(prop,value);
732} 849}
733struct icaltimetype icalproperty_get_dtstart(icalproperty* prop){ 850struct icaltimetype icalproperty_get_dtstart(const icalproperty* prop){
734 icalerror_check_arg( (prop!=0),"prop"); 851 icalerror_check_arg( (prop!=0),"prop");
@@ -745,2 +862,3 @@ icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...){
745} 862}
863
746/* DUE */ 864/* DUE */
@@ -753,7 +871,12 @@ icalproperty* icalproperty_new_due(struct icaltimetype v) {
753void icalproperty_set_due(icalproperty* prop, struct icaltimetype v){ 871void icalproperty_set_due(icalproperty* prop, struct icaltimetype v){
872 icalvalue *value;
754 873
755 icalerror_check_arg_rv( (prop!=0),"prop"); 874 icalerror_check_arg_rv( (prop!=0),"prop");
756 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 875 if (v.is_date)
876 value = icalvalue_new_date(v);
877 else
878 value = icalvalue_new_datetime(v);
879 icalproperty_set_value(prop,value);
757} 880}
758struct icaltimetype icalproperty_get_due(icalproperty* prop){ 881struct icaltimetype icalproperty_get_due(const icalproperty* prop){
759 icalerror_check_arg( (prop!=0),"prop"); 882 icalerror_check_arg( (prop!=0),"prop");
@@ -770,2 +893,3 @@ icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...){
770} 893}
894
771/* DURATION */ 895/* DURATION */
@@ -782,3 +906,3 @@ void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v){
782} 906}
783struct icaldurationtype icalproperty_get_duration(icalproperty* prop){ 907struct icaldurationtype icalproperty_get_duration(const icalproperty* prop){
784 icalerror_check_arg( (prop!=0),"prop"); 908 icalerror_check_arg( (prop!=0),"prop");
@@ -795,2 +919,3 @@ icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...){
795} 919}
920
796/* EXDATE */ 921/* EXDATE */
@@ -803,7 +928,12 @@ icalproperty* icalproperty_new_exdate(struct icaltimetype v) {
803void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v){ 928void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v){
929 icalvalue *value;
804 930
805 icalerror_check_arg_rv( (prop!=0),"prop"); 931 icalerror_check_arg_rv( (prop!=0),"prop");
806 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 932 if (v.is_date)
933 value = icalvalue_new_date(v);
934 else
935 value = icalvalue_new_datetime(v);
936 icalproperty_set_value(prop,value);
807} 937}
808struct icaltimetype icalproperty_get_exdate(icalproperty* prop){ 938struct icaltimetype icalproperty_get_exdate(const icalproperty* prop){
809 icalerror_check_arg( (prop!=0),"prop"); 939 icalerror_check_arg( (prop!=0),"prop");
@@ -811,2 +941,28 @@ struct icaltimetype icalproperty_get_exdate(icalproperty* prop){
811} 941}
942icalproperty* icalproperty_vanew_expand(int v, ...){
943 va_list args;
944 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXPAND_PROPERTY);
945 icalproperty_set_expand((icalproperty*)impl,v);
946 va_start(args,v);
947 icalproperty_add_parameters(impl, args);
948 va_end(args);
949 return (icalproperty*)impl;
950}
951
952/* EXPAND */
953icalproperty* icalproperty_new_expand(int v) {
954 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXPAND_PROPERTY);
955 icalproperty_set_expand((icalproperty*)impl,v);
956 return (icalproperty*)impl;
957}
958
959void icalproperty_set_expand(icalproperty* prop, int v){
960
961 icalerror_check_arg_rv( (prop!=0),"prop");
962 icalproperty_set_value(prop,icalvalue_new_integer(v));
963}
964int icalproperty_get_expand(const icalproperty* prop){
965 icalerror_check_arg( (prop!=0),"prop");
966 return icalvalue_get_integer(icalproperty_get_value(prop));
967}
812icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...){ 968icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...){
@@ -820,2 +976,3 @@ icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...){
820} 976}
977
821/* EXRULE */ 978/* EXRULE */
@@ -832,3 +989,3 @@ void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v){
832} 989}
833struct icalrecurrencetype icalproperty_get_exrule(icalproperty* prop){ 990struct icalrecurrencetype icalproperty_get_exrule(const icalproperty* prop){
834 icalerror_check_arg( (prop!=0),"prop"); 991 icalerror_check_arg( (prop!=0),"prop");
@@ -845,2 +1002,3 @@ icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...){
845} 1002}
1003
846/* FREEBUSY */ 1004/* FREEBUSY */
@@ -857,3 +1015,3 @@ void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v){
857} 1015}
858struct icalperiodtype icalproperty_get_freebusy(icalproperty* prop){ 1016struct icalperiodtype icalproperty_get_freebusy(const icalproperty* prop){
859 icalerror_check_arg( (prop!=0),"prop"); 1017 icalerror_check_arg( (prop!=0),"prop");
@@ -870,2 +1028,3 @@ icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...){
870} 1028}
1029
871/* GEO */ 1030/* GEO */
@@ -882,3 +1041,3 @@ void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v){
882} 1041}
883struct icalgeotype icalproperty_get_geo(icalproperty* prop){ 1042struct icalgeotype icalproperty_get_geo(const icalproperty* prop){
884 icalerror_check_arg( (prop!=0),"prop"); 1043 icalerror_check_arg( (prop!=0),"prop");
@@ -895,2 +1054,3 @@ icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...){
895} 1054}
1055
896/* LAST-MODIFIED */ 1056/* LAST-MODIFIED */
@@ -907,3 +1067,3 @@ void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v){
907} 1067}
908struct icaltimetype icalproperty_get_lastmodified(icalproperty* prop){ 1068struct icaltimetype icalproperty_get_lastmodified(const icalproperty* prop){
909 icalerror_check_arg( (prop!=0),"prop"); 1069 icalerror_check_arg( (prop!=0),"prop");
@@ -921,2 +1081,3 @@ icalproperty* icalproperty_vanew_location(const char* v, ...){
921} 1081}
1082
922/* LOCATION */ 1083/* LOCATION */
@@ -935,3 +1096,3 @@ void icalproperty_set_location(icalproperty* prop, const char* v){
935} 1096}
936const char* icalproperty_get_location(icalproperty* prop){ 1097const char* icalproperty_get_location(const icalproperty* prop){
937 icalerror_check_arg( (prop!=0),"prop"); 1098 icalerror_check_arg( (prop!=0),"prop");
@@ -948,2 +1109,3 @@ icalproperty* icalproperty_vanew_maxresults(int v, ...){
948} 1109}
1110
949/* MAXRESULTS */ 1111/* MAXRESULTS */
@@ -960,3 +1122,3 @@ void icalproperty_set_maxresults(icalproperty* prop, int v){
960} 1122}
961int icalproperty_get_maxresults(icalproperty* prop){ 1123int icalproperty_get_maxresults(const icalproperty* prop){
962 icalerror_check_arg( (prop!=0),"prop"); 1124 icalerror_check_arg( (prop!=0),"prop");
@@ -973,2 +1135,3 @@ icalproperty* icalproperty_vanew_maxresultssize(int v, ...){
973} 1135}
1136
974/* MAXRESULTSSIZE */ 1137/* MAXRESULTSSIZE */
@@ -985,3 +1148,3 @@ void icalproperty_set_maxresultssize(icalproperty* prop, int v){
985} 1148}
986int icalproperty_get_maxresultssize(icalproperty* prop){ 1149int icalproperty_get_maxresultssize(const icalproperty* prop){
987 icalerror_check_arg( (prop!=0),"prop"); 1150 icalerror_check_arg( (prop!=0),"prop");
@@ -998,2 +1161,3 @@ icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...){
998} 1161}
1162
999/* METHOD */ 1163/* METHOD */
@@ -1010,3 +1174,3 @@ void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v){
1010} 1174}
1011enum icalproperty_method icalproperty_get_method(icalproperty* prop){ 1175enum icalproperty_method icalproperty_get_method(const icalproperty* prop){
1012 icalerror_check_arg( (prop!=0),"prop"); 1176 icalerror_check_arg( (prop!=0),"prop");
@@ -1024,2 +1188,3 @@ icalproperty* icalproperty_vanew_organizer(const char* v, ...){
1024} 1188}
1189
1025/* ORGANIZER */ 1190/* ORGANIZER */
@@ -1038,3 +1203,3 @@ void icalproperty_set_organizer(icalproperty* prop, const char* v){
1038} 1203}
1039const char* icalproperty_get_organizer(icalproperty* prop){ 1204const char* icalproperty_get_organizer(const icalproperty* prop){
1040 icalerror_check_arg( (prop!=0),"prop"); 1205 icalerror_check_arg( (prop!=0),"prop");
@@ -1042,2 +1207,31 @@ const char* icalproperty_get_organizer(icalproperty* prop){
1042} 1207}
1208icalproperty* icalproperty_vanew_owner(const char* v, ...){
1209 va_list args;
1210 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_OWNER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
1211
1212 icalproperty_set_owner((icalproperty*)impl,v);
1213 va_start(args,v);
1214 icalproperty_add_parameters(impl, args);
1215 va_end(args);
1216 return (icalproperty*)impl;
1217}
1218
1219/* OWNER */
1220icalproperty* icalproperty_new_owner(const char* v) {
1221 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_OWNER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
1222
1223 icalproperty_set_owner((icalproperty*)impl,v);
1224 return (icalproperty*)impl;
1225}
1226
1227void icalproperty_set_owner(icalproperty* prop, const char* v){
1228 icalerror_check_arg_rv( (v!=0),"v");
1229
1230 icalerror_check_arg_rv( (prop!=0),"prop");
1231 icalproperty_set_value(prop,icalvalue_new_text(v));
1232}
1233const char* icalproperty_get_owner(const icalproperty* prop){
1234 icalerror_check_arg( (prop!=0),"prop");
1235 return icalvalue_get_text(icalproperty_get_value(prop));
1236}
1043icalproperty* icalproperty_vanew_percentcomplete(int v, ...){ 1237icalproperty* icalproperty_vanew_percentcomplete(int v, ...){
@@ -1051,2 +1245,3 @@ icalproperty* icalproperty_vanew_percentcomplete(int v, ...){
1051} 1245}
1246
1052/* PERCENT-COMPLETE */ 1247/* PERCENT-COMPLETE */
@@ -1063,3 +1258,3 @@ void icalproperty_set_percentcomplete(icalproperty* prop, int v){
1063} 1258}
1064int icalproperty_get_percentcomplete(icalproperty* prop){ 1259int icalproperty_get_percentcomplete(const icalproperty* prop){
1065 icalerror_check_arg( (prop!=0),"prop"); 1260 icalerror_check_arg( (prop!=0),"prop");
@@ -1076,2 +1271,3 @@ icalproperty* icalproperty_vanew_priority(int v, ...){
1076} 1271}
1272
1077/* PRIORITY */ 1273/* PRIORITY */
@@ -1088,3 +1284,3 @@ void icalproperty_set_priority(icalproperty* prop, int v){
1088} 1284}
1089int icalproperty_get_priority(icalproperty* prop){ 1285int icalproperty_get_priority(const icalproperty* prop){
1090 icalerror_check_arg( (prop!=0),"prop"); 1286 icalerror_check_arg( (prop!=0),"prop");
@@ -1102,2 +1298,3 @@ icalproperty* icalproperty_vanew_prodid(const char* v, ...){
1102} 1298}
1299
1103/* PRODID */ 1300/* PRODID */
@@ -1116,3 +1313,3 @@ void icalproperty_set_prodid(icalproperty* prop, const char* v){
1116} 1313}
1117const char* icalproperty_get_prodid(icalproperty* prop){ 1314const char* icalproperty_get_prodid(const icalproperty* prop){
1118 icalerror_check_arg( (prop!=0),"prop"); 1315 icalerror_check_arg( (prop!=0),"prop");
@@ -1130,2 +1327,3 @@ icalproperty* icalproperty_vanew_query(const char* v, ...){
1130} 1327}
1328
1131/* QUERY */ 1329/* QUERY */
@@ -1144,3 +1342,3 @@ void icalproperty_set_query(icalproperty* prop, const char* v){
1144} 1342}
1145const char* icalproperty_get_query(icalproperty* prop){ 1343const char* icalproperty_get_query(const icalproperty* prop){
1146 icalerror_check_arg( (prop!=0),"prop"); 1344 icalerror_check_arg( (prop!=0),"prop");
@@ -1158,2 +1356,3 @@ icalproperty* icalproperty_vanew_queryname(const char* v, ...){
1158} 1356}
1357
1159/* QUERYNAME */ 1358/* QUERYNAME */
@@ -1172,3 +1371,3 @@ void icalproperty_set_queryname(icalproperty* prop, const char* v){
1172} 1371}
1173const char* icalproperty_get_queryname(icalproperty* prop){ 1372const char* icalproperty_get_queryname(const icalproperty* prop){
1174 icalerror_check_arg( (prop!=0),"prop"); 1373 icalerror_check_arg( (prop!=0),"prop");
@@ -1185,2 +1384,3 @@ icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...){
1185} 1384}
1385
1186/* RDATE */ 1386/* RDATE */
@@ -1197,3 +1397,3 @@ void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v)
1197} 1397}
1198struct icaldatetimeperiodtype icalproperty_get_rdate(icalproperty* prop){ 1398struct icaldatetimeperiodtype icalproperty_get_rdate(const icalproperty* prop){
1199 icalerror_check_arg( (prop!=0),"prop"); 1399 icalerror_check_arg( (prop!=0),"prop");
@@ -1210,2 +1410,3 @@ icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...){
1210} 1410}
1411
1211/* RECURRENCE-ID */ 1412/* RECURRENCE-ID */
@@ -1218,7 +1419,12 @@ icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v) {
1218void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v){ 1419void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v){
1420 icalvalue *value;
1219 1421
1220 icalerror_check_arg_rv( (prop!=0),"prop"); 1422 icalerror_check_arg_rv( (prop!=0),"prop");
1221 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 1423 if (v.is_date)
1424 value = icalvalue_new_date(v);
1425 else
1426 value = icalvalue_new_datetime(v);
1427 icalproperty_set_value(prop,value);
1222} 1428}
1223struct icaltimetype icalproperty_get_recurrenceid(icalproperty* prop){ 1429struct icaltimetype icalproperty_get_recurrenceid(const icalproperty* prop){
1224 icalerror_check_arg( (prop!=0),"prop"); 1430 icalerror_check_arg( (prop!=0),"prop");
@@ -1236,2 +1442,3 @@ icalproperty* icalproperty_vanew_relatedto(const char* v, ...){
1236} 1442}
1443
1237/* RELATED-TO */ 1444/* RELATED-TO */
@@ -1250,3 +1457,32 @@ void icalproperty_set_relatedto(icalproperty* prop, const char* v){
1250} 1457}
1251const char* icalproperty_get_relatedto(icalproperty* prop){ 1458const char* icalproperty_get_relatedto(const icalproperty* prop){
1459 icalerror_check_arg( (prop!=0),"prop");
1460 return icalvalue_get_text(icalproperty_get_value(prop));
1461}
1462icalproperty* icalproperty_vanew_relcalid(const char* v, ...){
1463 va_list args;
1464 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RELCALID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
1465
1466 icalproperty_set_relcalid((icalproperty*)impl,v);
1467 va_start(args,v);
1468 icalproperty_add_parameters(impl, args);
1469 va_end(args);
1470 return (icalproperty*)impl;
1471}
1472
1473/* RELCALID */
1474icalproperty* icalproperty_new_relcalid(const char* v) {
1475 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RELCALID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
1476
1477 icalproperty_set_relcalid((icalproperty*)impl,v);
1478 return (icalproperty*)impl;
1479}
1480
1481void icalproperty_set_relcalid(icalproperty* prop, const char* v){
1482 icalerror_check_arg_rv( (v!=0),"v");
1483
1484 icalerror_check_arg_rv( (prop!=0),"prop");
1485 icalproperty_set_value(prop,icalvalue_new_text(v));
1486}
1487const char* icalproperty_get_relcalid(const icalproperty* prop){
1252 icalerror_check_arg( (prop!=0),"prop"); 1488 icalerror_check_arg( (prop!=0),"prop");
@@ -1263,2 +1499,3 @@ icalproperty* icalproperty_vanew_repeat(int v, ...){
1263} 1499}
1500
1264/* REPEAT */ 1501/* REPEAT */
@@ -1275,3 +1512,3 @@ void icalproperty_set_repeat(icalproperty* prop, int v){
1275} 1512}
1276int icalproperty_get_repeat(icalproperty* prop){ 1513int icalproperty_get_repeat(const icalproperty* prop){
1277 icalerror_check_arg( (prop!=0),"prop"); 1514 icalerror_check_arg( (prop!=0),"prop");
@@ -1288,2 +1525,3 @@ icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...){
1288} 1525}
1526
1289/* REQUEST-STATUS */ 1527/* REQUEST-STATUS */
@@ -1300,3 +1538,3 @@ void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v
1300} 1538}
1301struct icalreqstattype icalproperty_get_requeststatus(icalproperty* prop){ 1539struct icalreqstattype icalproperty_get_requeststatus(const icalproperty* prop){
1302 icalerror_check_arg( (prop!=0),"prop"); 1540 icalerror_check_arg( (prop!=0),"prop");
@@ -1314,2 +1552,3 @@ icalproperty* icalproperty_vanew_resources(const char* v, ...){
1314} 1552}
1553
1315/* RESOURCES */ 1554/* RESOURCES */
@@ -1328,3 +1567,3 @@ void icalproperty_set_resources(icalproperty* prop, const char* v){
1328} 1567}
1329const char* icalproperty_get_resources(icalproperty* prop){ 1568const char* icalproperty_get_resources(const icalproperty* prop){
1330 icalerror_check_arg( (prop!=0),"prop"); 1569 icalerror_check_arg( (prop!=0),"prop");
@@ -1341,2 +1580,3 @@ icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...){
1341} 1580}
1581
1342/* RRULE */ 1582/* RRULE */
@@ -1353,3 +1593,3 @@ void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v){
1353} 1593}
1354struct icalrecurrencetype icalproperty_get_rrule(icalproperty* prop){ 1594struct icalrecurrencetype icalproperty_get_rrule(const icalproperty* prop){
1355 icalerror_check_arg( (prop!=0),"prop"); 1595 icalerror_check_arg( (prop!=0),"prop");
@@ -1367,2 +1607,3 @@ icalproperty* icalproperty_vanew_scope(const char* v, ...){
1367} 1607}
1608
1368/* SCOPE */ 1609/* SCOPE */
@@ -1381,3 +1622,3 @@ void icalproperty_set_scope(icalproperty* prop, const char* v){
1381} 1622}
1382const char* icalproperty_get_scope(icalproperty* prop){ 1623const char* icalproperty_get_scope(const icalproperty* prop){
1383 icalerror_check_arg( (prop!=0),"prop"); 1624 icalerror_check_arg( (prop!=0),"prop");
@@ -1394,2 +1635,3 @@ icalproperty* icalproperty_vanew_sequence(int v, ...){
1394} 1635}
1636
1395/* SEQUENCE */ 1637/* SEQUENCE */
@@ -1406,3 +1648,3 @@ void icalproperty_set_sequence(icalproperty* prop, int v){
1406} 1648}
1407int icalproperty_get_sequence(icalproperty* prop){ 1649int icalproperty_get_sequence(const icalproperty* prop){
1408 icalerror_check_arg( (prop!=0),"prop"); 1650 icalerror_check_arg( (prop!=0),"prop");
@@ -1419,2 +1661,3 @@ icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...){
1419} 1661}
1662
1420/* STATUS */ 1663/* STATUS */
@@ -1431,3 +1674,3 @@ void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v){
1431} 1674}
1432enum icalproperty_status icalproperty_get_status(icalproperty* prop){ 1675enum icalproperty_status icalproperty_get_status(const icalproperty* prop){
1433 icalerror_check_arg( (prop!=0),"prop"); 1676 icalerror_check_arg( (prop!=0),"prop");
@@ -1445,2 +1688,3 @@ icalproperty* icalproperty_vanew_summary(const char* v, ...){
1445} 1688}
1689
1446/* SUMMARY */ 1690/* SUMMARY */
@@ -1459,3 +1703,3 @@ void icalproperty_set_summary(icalproperty* prop, const char* v){
1459} 1703}
1460const char* icalproperty_get_summary(icalproperty* prop){ 1704const char* icalproperty_get_summary(const icalproperty* prop){
1461 icalerror_check_arg( (prop!=0),"prop"); 1705 icalerror_check_arg( (prop!=0),"prop");
@@ -1473,2 +1717,3 @@ icalproperty* icalproperty_vanew_target(const char* v, ...){
1473} 1717}
1718
1474/* TARGET */ 1719/* TARGET */
@@ -1487,3 +1732,3 @@ void icalproperty_set_target(icalproperty* prop, const char* v){
1487} 1732}
1488const char* icalproperty_get_target(icalproperty* prop){ 1733const char* icalproperty_get_target(const icalproperty* prop){
1489 icalerror_check_arg( (prop!=0),"prop"); 1734 icalerror_check_arg( (prop!=0),"prop");
@@ -1491,6 +1736,5 @@ const char* icalproperty_get_target(icalproperty* prop){
1491} 1736}
1492icalproperty* icalproperty_vanew_transp(const char* v, ...){ 1737icalproperty* icalproperty_vanew_transp(enum icalproperty_transp v, ...){
1493 va_list args; 1738 va_list args;
1494 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRANSP_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1739 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRANSP_PROPERTY);
1495
1496 icalproperty_set_transp((icalproperty*)impl,v); 1740 icalproperty_set_transp((icalproperty*)impl,v);
@@ -1501,6 +1745,6 @@ icalproperty* icalproperty_vanew_transp(const char* v, ...){
1501} 1745}
1502/* TRANSP */
1503icalproperty* icalproperty_new_transp(const char* v) {
1504 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRANSP_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
1505 1746
1747/* TRANSP */
1748icalproperty* icalproperty_new_transp(enum icalproperty_transp v) {
1749 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRANSP_PROPERTY);
1506 icalproperty_set_transp((icalproperty*)impl,v); 1750 icalproperty_set_transp((icalproperty*)impl,v);
@@ -1509,11 +1753,10 @@ icalproperty* icalproperty_new_transp(const char* v) {
1509 1753
1510void icalproperty_set_transp(icalproperty* prop, const char* v){ 1754void icalproperty_set_transp(icalproperty* prop, enum icalproperty_transp v){
1511 icalerror_check_arg_rv( (v!=0),"v"); 1755
1512
1513 icalerror_check_arg_rv( (prop!=0),"prop"); 1756 icalerror_check_arg_rv( (prop!=0),"prop");
1514 icalproperty_set_value(prop,icalvalue_new_text(v)); 1757 icalproperty_set_value(prop,icalvalue_new_transp(v));
1515} 1758}
1516const char* icalproperty_get_transp(icalproperty* prop){ 1759enum icalproperty_transp icalproperty_get_transp(const icalproperty* prop){
1517 icalerror_check_arg( (prop!=0),"prop"); 1760 icalerror_check_arg( (prop!=0),"prop");
1518 return icalvalue_get_text(icalproperty_get_value(prop)); 1761 return icalvalue_get_transp(icalproperty_get_value(prop));
1519} 1762}
@@ -1528,2 +1771,3 @@ icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...){
1528} 1771}
1772
1529/* TRIGGER */ 1773/* TRIGGER */
@@ -1540,3 +1784,3 @@ void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v){
1540} 1784}
1541struct icaltriggertype icalproperty_get_trigger(icalproperty* prop){ 1785struct icaltriggertype icalproperty_get_trigger(const icalproperty* prop){
1542 icalerror_check_arg( (prop!=0),"prop"); 1786 icalerror_check_arg( (prop!=0),"prop");
@@ -1554,2 +1798,3 @@ icalproperty* icalproperty_vanew_tzid(const char* v, ...){
1554} 1798}
1799
1555/* TZID */ 1800/* TZID */
@@ -1568,3 +1813,3 @@ void icalproperty_set_tzid(icalproperty* prop, const char* v){
1568} 1813}
1569const char* icalproperty_get_tzid(icalproperty* prop){ 1814const char* icalproperty_get_tzid(const icalproperty* prop){
1570 icalerror_check_arg( (prop!=0),"prop"); 1815 icalerror_check_arg( (prop!=0),"prop");
@@ -1582,2 +1827,3 @@ icalproperty* icalproperty_vanew_tzname(const char* v, ...){
1582} 1827}
1828
1583/* TZNAME */ 1829/* TZNAME */
@@ -1596,3 +1842,3 @@ void icalproperty_set_tzname(icalproperty* prop, const char* v){
1596} 1842}
1597const char* icalproperty_get_tzname(icalproperty* prop){ 1843const char* icalproperty_get_tzname(const icalproperty* prop){
1598 icalerror_check_arg( (prop!=0),"prop"); 1844 icalerror_check_arg( (prop!=0),"prop");
@@ -1609,2 +1855,3 @@ icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...){
1609} 1855}
1856
1610/* TZOFFSETFROM */ 1857/* TZOFFSETFROM */
@@ -1621,3 +1868,3 @@ void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v){
1621} 1868}
1622int icalproperty_get_tzoffsetfrom(icalproperty* prop){ 1869int icalproperty_get_tzoffsetfrom(const icalproperty* prop){
1623 icalerror_check_arg( (prop!=0),"prop"); 1870 icalerror_check_arg( (prop!=0),"prop");
@@ -1634,2 +1881,3 @@ icalproperty* icalproperty_vanew_tzoffsetto(int v, ...){
1634} 1881}
1882
1635/* TZOFFSETTO */ 1883/* TZOFFSETTO */
@@ -1646,3 +1894,3 @@ void icalproperty_set_tzoffsetto(icalproperty* prop, int v){
1646} 1894}
1647int icalproperty_get_tzoffsetto(icalproperty* prop){ 1895int icalproperty_get_tzoffsetto(const icalproperty* prop){
1648 icalerror_check_arg( (prop!=0),"prop"); 1896 icalerror_check_arg( (prop!=0),"prop");
@@ -1660,2 +1908,3 @@ icalproperty* icalproperty_vanew_tzurl(const char* v, ...){
1660} 1908}
1909
1661/* TZURL */ 1910/* TZURL */
@@ -1674,3 +1923,3 @@ void icalproperty_set_tzurl(icalproperty* prop, const char* v){
1674} 1923}
1675const char* icalproperty_get_tzurl(icalproperty* prop){ 1924const char* icalproperty_get_tzurl(const icalproperty* prop){
1676 icalerror_check_arg( (prop!=0),"prop"); 1925 icalerror_check_arg( (prop!=0),"prop");
@@ -1688,2 +1937,3 @@ icalproperty* icalproperty_vanew_uid(const char* v, ...){
1688} 1937}
1938
1689/* UID */ 1939/* UID */
@@ -1702,3 +1952,3 @@ void icalproperty_set_uid(icalproperty* prop, const char* v){
1702} 1952}
1703const char* icalproperty_get_uid(icalproperty* prop){ 1953const char* icalproperty_get_uid(const icalproperty* prop){
1704 icalerror_check_arg( (prop!=0),"prop"); 1954 icalerror_check_arg( (prop!=0),"prop");
@@ -1716,2 +1966,3 @@ icalproperty* icalproperty_vanew_url(const char* v, ...){
1716} 1966}
1967
1717/* URL */ 1968/* URL */
@@ -1730,3 +1981,3 @@ void icalproperty_set_url(icalproperty* prop, const char* v){
1730} 1981}
1731const char* icalproperty_get_url(icalproperty* prop){ 1982const char* icalproperty_get_url(const icalproperty* prop){
1732 icalerror_check_arg( (prop!=0),"prop"); 1983 icalerror_check_arg( (prop!=0),"prop");
@@ -1744,2 +1995,3 @@ icalproperty* icalproperty_vanew_version(const char* v, ...){
1744} 1995}
1996
1745/* VERSION */ 1997/* VERSION */
@@ -1758,3 +2010,3 @@ void icalproperty_set_version(icalproperty* prop, const char* v){
1758} 2010}
1759const char* icalproperty_get_version(icalproperty* prop){ 2011const char* icalproperty_get_version(const icalproperty* prop){
1760 icalerror_check_arg( (prop!=0),"prop"); 2012 icalerror_check_arg( (prop!=0),"prop");
@@ -1772,2 +2024,3 @@ icalproperty* icalproperty_vanew_x(const char* v, ...){
1772} 2024}
2025
1773/* X */ 2026/* X */
@@ -1784,7 +2037,33 @@ void icalproperty_set_x(icalproperty* prop, const char* v){
1784 icalerror_check_arg_rv( (prop!=0),"prop"); 2037 icalerror_check_arg_rv( (prop!=0),"prop");
1785 icalproperty_set_value(prop,icalvalue_new_text(v)); 2038 icalproperty_set_value(prop,icalvalue_new_x(v));
1786} 2039}
1787const char* icalproperty_get_x(icalproperty* prop){ 2040const char* icalproperty_get_x(const icalproperty* prop){
1788 icalerror_check_arg( (prop!=0),"prop"); 2041 icalerror_check_arg( (prop!=0),"prop");
1789 return icalvalue_get_text(icalproperty_get_value(prop)); 2042 return icalvalue_get_x(icalproperty_get_value(prop));
2043}
2044icalproperty* icalproperty_vanew_xlicclass(enum icalproperty_xlicclass v, ...){
2045 va_list args;
2046 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLASS_PROPERTY);
2047 icalproperty_set_xlicclass((icalproperty*)impl,v);
2048 va_start(args,v);
2049 icalproperty_add_parameters(impl, args);
2050 va_end(args);
2051 return (icalproperty*)impl;
2052}
2053
2054/* X-LIC-CLASS */
2055icalproperty* icalproperty_new_xlicclass(enum icalproperty_xlicclass v) {
2056 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLASS_PROPERTY);
2057 icalproperty_set_xlicclass((icalproperty*)impl,v);
2058 return (icalproperty*)impl;
2059}
2060
2061void icalproperty_set_xlicclass(icalproperty* prop, enum icalproperty_xlicclass v){
2062
2063 icalerror_check_arg_rv( (prop!=0),"prop");
2064 icalproperty_set_value(prop,icalvalue_new_xlicclass(v));
2065}
2066enum icalproperty_xlicclass icalproperty_get_xlicclass(const icalproperty* prop){
2067 icalerror_check_arg( (prop!=0),"prop");
2068 return icalvalue_get_xlicclass(icalproperty_get_value(prop));
1790} 2069}
@@ -1800,2 +2079,3 @@ icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...){
1800} 2079}
2080
1801/* X-LIC-CLUSTERCOUNT */ 2081/* X-LIC-CLUSTERCOUNT */
@@ -1814,3 +2094,3 @@ void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v){
1814} 2094}
1815const char* icalproperty_get_xlicclustercount(icalproperty* prop){ 2095const char* icalproperty_get_xlicclustercount(const icalproperty* prop){
1816 icalerror_check_arg( (prop!=0),"prop"); 2096 icalerror_check_arg( (prop!=0),"prop");
@@ -1828,2 +2108,3 @@ icalproperty* icalproperty_vanew_xlicerror(const char* v, ...){
1828} 2108}
2109
1829/* X-LIC-ERROR */ 2110/* X-LIC-ERROR */
@@ -1842,3 +2123,3 @@ void icalproperty_set_xlicerror(icalproperty* prop, const char* v){
1842} 2123}
1843const char* icalproperty_get_xlicerror(icalproperty* prop){ 2124const char* icalproperty_get_xlicerror(const icalproperty* prop){
1844 icalerror_check_arg( (prop!=0),"prop"); 2125 icalerror_check_arg( (prop!=0),"prop");
@@ -1856,2 +2137,3 @@ icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...){
1856} 2137}
2138
1857/* X-LIC-MIMECHARSET */ 2139/* X-LIC-MIMECHARSET */
@@ -1870,3 +2152,3 @@ void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v){
1870} 2152}
1871const char* icalproperty_get_xlicmimecharset(icalproperty* prop){ 2153const char* icalproperty_get_xlicmimecharset(const icalproperty* prop){
1872 icalerror_check_arg( (prop!=0),"prop"); 2154 icalerror_check_arg( (prop!=0),"prop");
@@ -1884,2 +2166,3 @@ icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...){
1884} 2166}
2167
1885/* X-LIC-MIMECID */ 2168/* X-LIC-MIMECID */
@@ -1898,3 +2181,3 @@ void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v){
1898} 2181}
1899const char* icalproperty_get_xlicmimecid(icalproperty* prop){ 2182const char* icalproperty_get_xlicmimecid(const icalproperty* prop){
1900 icalerror_check_arg( (prop!=0),"prop"); 2183 icalerror_check_arg( (prop!=0),"prop");
@@ -1912,2 +2195,3 @@ icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...){
1912} 2195}
2196
1913/* X-LIC-MIMECONTENTTYPE */ 2197/* X-LIC-MIMECONTENTTYPE */
@@ -1926,3 +2210,3 @@ void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v){
1926} 2210}
1927const char* icalproperty_get_xlicmimecontenttype(icalproperty* prop){ 2211const char* icalproperty_get_xlicmimecontenttype(const icalproperty* prop){
1928 icalerror_check_arg( (prop!=0),"prop"); 2212 icalerror_check_arg( (prop!=0),"prop");
@@ -1940,2 +2224,3 @@ icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...){
1940} 2224}
2225
1941/* X-LIC-MIMEENCODING */ 2226/* X-LIC-MIMEENCODING */
@@ -1954,3 +2239,3 @@ void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v){
1954} 2239}
1955const char* icalproperty_get_xlicmimeencoding(icalproperty* prop){ 2240const char* icalproperty_get_xlicmimeencoding(const icalproperty* prop){
1956 icalerror_check_arg( (prop!=0),"prop"); 2241 icalerror_check_arg( (prop!=0),"prop");
@@ -1968,2 +2253,3 @@ icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...){
1968} 2253}
2254
1969/* X-LIC-MIMEFILENAME */ 2255/* X-LIC-MIMEFILENAME */
@@ -1982,3 +2268,3 @@ void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v){
1982} 2268}
1983const char* icalproperty_get_xlicmimefilename(icalproperty* prop){ 2269const char* icalproperty_get_xlicmimefilename(const icalproperty* prop){
1984 icalerror_check_arg( (prop!=0),"prop"); 2270 icalerror_check_arg( (prop!=0),"prop");
@@ -1996,2 +2282,3 @@ icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...){
1996} 2282}
2283
1997/* X-LIC-MIMEOPTINFO */ 2284/* X-LIC-MIMEOPTINFO */
@@ -2010,3 +2297,3 @@ void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v){
2010} 2297}
2011const char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop){ 2298const char* icalproperty_get_xlicmimeoptinfo(const icalproperty* prop){
2012 icalerror_check_arg( (prop!=0),"prop"); 2299 icalerror_check_arg( (prop!=0),"prop");
@@ -2014 +2301,214 @@ const char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop){
2014} 2301}
2302
2303int icalproperty_kind_is_valid(const icalproperty_kind kind)
2304{
2305 int i = 0;
2306 do {
2307 if (property_map[i].kind == kind)
2308 return 1;
2309 } while (property_map[i++].kind != ICAL_NO_PROPERTY);
2310
2311 return 0;
2312}
2313
2314const char* icalproperty_kind_to_string(icalproperty_kind kind)
2315{
2316 int i;
2317
2318 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
2319 if (property_map[i].kind == kind) {
2320 return property_map[i].name;
2321 }
2322 }
2323
2324 return 0;
2325
2326}
2327
2328
2329icalproperty_kind icalproperty_string_to_kind(const char* string)
2330{
2331 int i;
2332
2333 if (string ==0 ) {
2334 return ICAL_NO_PROPERTY;
2335 }
2336
2337
2338 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
2339 if (strcmp(property_map[i].name, string) == 0) {
2340 return property_map[i].kind;
2341 }
2342 }
2343
2344 if(strncmp(string,"X-",2)==0){
2345 return ICAL_X_PROPERTY;
2346 }
2347
2348
2349 return ICAL_NO_PROPERTY;
2350}
2351
2352
2353icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind)
2354{
2355 int i;
2356
2357 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
2358 if ( property_map[i].value == kind ) {
2359 return property_map[i].kind;
2360 }
2361 }
2362
2363 return ICAL_NO_PROPERTY;
2364}
2365
2366
2367
2368icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind)
2369{
2370 int i;
2371
2372 for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) {
2373 if ( property_map[i].kind == kind ) {
2374 return property_map[i].value;
2375 }
2376 }
2377
2378 return ICAL_NO_VALUE;
2379}
2380
2381
2382const char* icalproperty_enum_to_string(int e)
2383{
2384 icalerror_check_arg_rz(e >= ICALPROPERTY_FIRST_ENUM,"e");
2385 icalerror_check_arg_rz(e <= ICALPROPERTY_LAST_ENUM,"e");
2386
2387 return enum_map[e-ICALPROPERTY_FIRST_ENUM].str;
2388}
2389
2390int icalproperty_kind_and_string_to_enum(const int kind, const char* str)
2391{
2392 icalproperty_kind pkind;
2393 int i;
2394
2395 icalerror_check_arg_rz(str!=0,"str")
2396
2397 if ((pkind = icalproperty_value_kind_to_kind(kind)) == ICAL_NO_VALUE)
2398 return 0;
2399
2400 while(*str == ' '){
2401 str++;
2402 }
2403
2404 for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
2405 if (enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == pkind)
2406 break;
2407 }
2408 if (i == ICALPROPERTY_LAST_ENUM)
2409 return 0;
2410
2411 for (; i != ICALPROPERTY_LAST_ENUM; i++) {
2412 if ( strcmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
2413 return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum;
2414 }
2415 }
2416
2417 return 0;
2418}
2419
2420/** @deprecated please use icalproperty_kind_and_string_to_enum instead */
2421int icalproperty_string_to_enum(const char* str)
2422{
2423 int i;
2424
2425 icalerror_check_arg_rz(str!=0,"str")
2426
2427 while(*str == ' '){
2428 str++;
2429 }
2430
2431 for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
2432 if ( strcmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) {
2433 return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum;
2434 }
2435 }
2436
2437 return 0;
2438}
2439
2440int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e)
2441{
2442 int i;
2443
2444
2445 for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) {
2446 if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum == e &&
2447 enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == kind ){
2448 return 1;
2449 }
2450 }
2451
2452 return 0;
2453}
2454
2455
2456const char* icalproperty_method_to_string(icalproperty_method method)
2457{
2458 icalerror_check_arg_rz(method >= ICAL_METHOD_X,"method");
2459 icalerror_check_arg_rz(method <= ICAL_METHOD_NONE,"method");
2460
2461 return enum_map[method-ICALPROPERTY_FIRST_ENUM].str;
2462}
2463
2464icalproperty_method icalproperty_string_to_method(const char* str)
2465{
2466 int i;
2467
2468 icalerror_check_arg_rx(str!=0,"str",ICAL_METHOD_NONE)
2469
2470 while(*str == ' '){
2471 str++;
2472 }
2473
2474 for (i=ICAL_METHOD_X-ICALPROPERTY_FIRST_ENUM;
2475 i != ICAL_METHOD_NONE-ICALPROPERTY_FIRST_ENUM;
2476 i++) {
2477 if ( strcmp(enum_map[i].str, str) == 0) {
2478 return (icalproperty_method)enum_map[i].prop_enum;
2479 }
2480 }
2481
2482 return ICAL_METHOD_NONE;
2483}
2484
2485
2486const char* icalenum_status_to_string(icalproperty_status status)
2487{
2488 icalerror_check_arg_rz(status >= ICAL_STATUS_X,"status");
2489 icalerror_check_arg_rz(status <= ICAL_STATUS_NONE,"status");
2490
2491 return enum_map[status-ICALPROPERTY_FIRST_ENUM].str;
2492}
2493
2494icalproperty_status icalenum_string_to_status(const char* str)
2495{
2496 int i;
2497
2498 icalerror_check_arg_rx(str!=0,"str",ICAL_STATUS_NONE)
2499
2500 while(*str == ' '){
2501 str++;
2502 }
2503
2504 for (i=ICAL_STATUS_X-ICALPROPERTY_FIRST_ENUM;
2505 i != ICAL_STATUS_NONE-ICALPROPERTY_FIRST_ENUM;
2506 i++) {
2507 if ( strcmp(enum_map[i].str, str) == 0) {
2508 return (icalproperty_status)enum_map[i].prop_enum;
2509 }
2510 }
2511
2512 return ICAL_STATUS_NONE;
2513
2514}
diff --git a/libical/src/libical/icalderivedproperty.h b/libical/src/libical/icalderivedproperty.h
index 07e01b0..ae19c81 100644
--- a/libical/src/libical/icalderivedproperty.h
+++ b/libical/src/libical/icalderivedproperty.h
@@ -19,6 +19,4 @@
19 19
20typedef void icalproperty; 20typedef struct icalproperty_impl icalproperty;
21 21
22
23/* Everything below this line is machine generated. Do not edit. */
24typedef enum icalproperty_kind { 22typedef enum icalproperty_kind {
@@ -26,5 +24,9 @@ typedef enum icalproperty_kind {
26 ICAL_ACTION_PROPERTY, 24 ICAL_ACTION_PROPERTY,
25 ICAL_ALLOWCONFLICT_PROPERTY,
27 ICAL_ATTACH_PROPERTY, 26 ICAL_ATTACH_PROPERTY,
28 ICAL_ATTENDEE_PROPERTY, 27 ICAL_ATTENDEE_PROPERTY,
28 ICAL_CALID_PROPERTY,
29 ICAL_CALMASTER_PROPERTY,
29 ICAL_CALSCALE_PROPERTY, 30 ICAL_CALSCALE_PROPERTY,
31 ICAL_CARID_PROPERTY,
30 ICAL_CATEGORIES_PROPERTY, 32 ICAL_CATEGORIES_PROPERTY,
@@ -35,2 +37,6 @@ typedef enum icalproperty_kind {
35 ICAL_CREATED_PROPERTY, 37 ICAL_CREATED_PROPERTY,
38 ICAL_DECREED_PROPERTY,
39 ICAL_DEFAULTCHARSET_PROPERTY,
40 ICAL_DEFAULTLOCALE_PROPERTY,
41 ICAL_DEFAULTTZID_PROPERTY,
36 ICAL_DESCRIPTION_PROPERTY, 42 ICAL_DESCRIPTION_PROPERTY,
@@ -42,2 +48,3 @@ typedef enum icalproperty_kind {
42 ICAL_EXDATE_PROPERTY, 48 ICAL_EXDATE_PROPERTY,
49 ICAL_EXPAND_PROPERTY,
43 ICAL_EXRULE_PROPERTY, 50 ICAL_EXRULE_PROPERTY,
@@ -51,2 +58,3 @@ typedef enum icalproperty_kind {
51 ICAL_ORGANIZER_PROPERTY, 58 ICAL_ORGANIZER_PROPERTY,
59 ICAL_OWNER_PROPERTY,
52 ICAL_PERCENTCOMPLETE_PROPERTY, 60 ICAL_PERCENTCOMPLETE_PROPERTY,
@@ -59,2 +67,3 @@ typedef enum icalproperty_kind {
59 ICAL_RELATEDTO_PROPERTY, 67 ICAL_RELATEDTO_PROPERTY,
68 ICAL_RELCALID_PROPERTY,
60 ICAL_REPEAT_PROPERTY, 69 ICAL_REPEAT_PROPERTY,
@@ -79,2 +88,3 @@ typedef enum icalproperty_kind {
79 ICAL_X_PROPERTY, 88 ICAL_X_PROPERTY,
89 ICAL_XLICCLASS_PROPERTY,
80 ICAL_XLICCLUSTERCOUNT_PROPERTY, 90 ICAL_XLICCLUSTERCOUNT_PROPERTY,
@@ -90,3 +100,2 @@ typedef enum icalproperty_kind {
90 100
91icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
92 101
@@ -95,8 +104,13 @@ icalproperty* icalproperty_new_action(enum icalproperty_action v);
95void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v); 104void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v);
96enum icalproperty_action icalproperty_get_action(icalproperty* prop);icalproperty* icalproperty_vanew_attach(struct icalattachtype* v, ...); 105enum icalproperty_action icalproperty_get_action(const icalproperty* prop);icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
106
107/* ALLOW-CONFLICT */
108icalproperty* icalproperty_new_allowconflict(const char* v);
109void icalproperty_set_allowconflict(icalproperty* prop, const char* v);
110const char* icalproperty_get_allowconflict(const icalproperty* prop);icalproperty* icalproperty_vanew_allowconflict(const char* v, ...);
97 111
98/* ATTACH */ 112/* ATTACH */
99icalproperty* icalproperty_new_attach(struct icalattachtype* v); 113icalproperty* icalproperty_new_attach(icalattach * v);
100void icalproperty_set_attach(icalproperty* prop, struct icalattachtype* v); 114void icalproperty_set_attach(icalproperty* prop, icalattach * v);
101struct icalattachtype* icalproperty_get_attach(icalproperty* prop);icalproperty* icalproperty_vanew_attendee(const char* v, ...); 115icalattach * icalproperty_get_attach(const icalproperty* prop);icalproperty* icalproperty_vanew_attach(icalattach * v, ...);
102 116
@@ -105,3 +119,13 @@ icalproperty* icalproperty_new_attendee(const char* v);
105void icalproperty_set_attendee(icalproperty* prop, const char* v); 119void icalproperty_set_attendee(icalproperty* prop, const char* v);
106const char* icalproperty_get_attendee(icalproperty* prop);icalproperty* icalproperty_vanew_calscale(const char* v, ...); 120const char* icalproperty_get_attendee(const icalproperty* prop);icalproperty* icalproperty_vanew_attendee(const char* v, ...);
121
122/* CALID */
123icalproperty* icalproperty_new_calid(const char* v);
124void icalproperty_set_calid(icalproperty* prop, const char* v);
125const char* icalproperty_get_calid(const icalproperty* prop);icalproperty* icalproperty_vanew_calid(const char* v, ...);
126
127/* CALMASTER */
128icalproperty* icalproperty_new_calmaster(const char* v);
129void icalproperty_set_calmaster(icalproperty* prop, const char* v);
130const char* icalproperty_get_calmaster(const icalproperty* prop);icalproperty* icalproperty_vanew_calmaster(const char* v, ...);
107 131
@@ -110,3 +134,8 @@ icalproperty* icalproperty_new_calscale(const char* v);
110void icalproperty_set_calscale(icalproperty* prop, const char* v); 134void icalproperty_set_calscale(icalproperty* prop, const char* v);
111const char* icalproperty_get_calscale(icalproperty* prop);icalproperty* icalproperty_vanew_categories(const char* v, ...); 135const char* icalproperty_get_calscale(const icalproperty* prop);icalproperty* icalproperty_vanew_calscale(const char* v, ...);
136
137/* CARID */
138icalproperty* icalproperty_new_carid(const char* v);
139void icalproperty_set_carid(icalproperty* prop, const char* v);
140const char* icalproperty_get_carid(const icalproperty* prop);icalproperty* icalproperty_vanew_carid(const char* v, ...);
112 141
@@ -115,8 +144,8 @@ icalproperty* icalproperty_new_categories(const char* v);
115void icalproperty_set_categories(icalproperty* prop, const char* v); 144void icalproperty_set_categories(icalproperty* prop, const char* v);
116const char* icalproperty_get_categories(icalproperty* prop);icalproperty* icalproperty_vanew_class(const char* v, ...); 145const char* icalproperty_get_categories(const icalproperty* prop);icalproperty* icalproperty_vanew_categories(const char* v, ...);
117 146
118/* CLASS */ 147/* CLASS */
119icalproperty* icalproperty_new_class(const char* v); 148icalproperty* icalproperty_new_class(enum icalproperty_class v);
120void icalproperty_set_class(icalproperty* prop, const char* v); 149void icalproperty_set_class(icalproperty* prop, enum icalproperty_class v);
121const char* icalproperty_get_class(icalproperty* prop);icalproperty* icalproperty_vanew_comment(const char* v, ...); 150enum icalproperty_class icalproperty_get_class(const icalproperty* prop);icalproperty* icalproperty_vanew_class(enum icalproperty_class v, ...);
122 151
@@ -125,3 +154,3 @@ icalproperty* icalproperty_new_comment(const char* v);
125void icalproperty_set_comment(icalproperty* prop, const char* v); 154void icalproperty_set_comment(icalproperty* prop, const char* v);
126const char* icalproperty_get_comment(icalproperty* prop);icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...); 155const char* icalproperty_get_comment(const icalproperty* prop);icalproperty* icalproperty_vanew_comment(const char* v, ...);
127 156
@@ -130,3 +159,3 @@ icalproperty* icalproperty_new_completed(struct icaltimetype v);
130void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v); 159void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v);
131struct icaltimetype icalproperty_get_completed(icalproperty* prop);icalproperty* icalproperty_vanew_contact(const char* v, ...); 160struct icaltimetype icalproperty_get_completed(const icalproperty* prop);icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...);
132 161
@@ -135,3 +164,3 @@ icalproperty* icalproperty_new_contact(const char* v);
135void icalproperty_set_contact(icalproperty* prop, const char* v); 164void icalproperty_set_contact(icalproperty* prop, const char* v);
136const char* icalproperty_get_contact(icalproperty* prop);icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...); 165const char* icalproperty_get_contact(const icalproperty* prop);icalproperty* icalproperty_vanew_contact(const char* v, ...);
137 166
@@ -140,3 +169,23 @@ icalproperty* icalproperty_new_created(struct icaltimetype v);
140void icalproperty_set_created(icalproperty* prop, struct icaltimetype v); 169void icalproperty_set_created(icalproperty* prop, struct icaltimetype v);
141struct icaltimetype icalproperty_get_created(icalproperty* prop);icalproperty* icalproperty_vanew_description(const char* v, ...); 170struct icaltimetype icalproperty_get_created(const icalproperty* prop);icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...);
171
172/* DECREED */
173icalproperty* icalproperty_new_decreed(const char* v);
174void icalproperty_set_decreed(icalproperty* prop, const char* v);
175const char* icalproperty_get_decreed(const icalproperty* prop);icalproperty* icalproperty_vanew_decreed(const char* v, ...);
176
177/* DEFAULT-CHARSET */
178icalproperty* icalproperty_new_defaultcharset(const char* v);
179void icalproperty_set_defaultcharset(icalproperty* prop, const char* v);
180const char* icalproperty_get_defaultcharset(const icalproperty* prop);icalproperty* icalproperty_vanew_defaultcharset(const char* v, ...);
181
182/* DEFAULT-LOCALE */
183icalproperty* icalproperty_new_defaultlocale(const char* v);
184void icalproperty_set_defaultlocale(icalproperty* prop, const char* v);
185const char* icalproperty_get_defaultlocale(const icalproperty* prop);icalproperty* icalproperty_vanew_defaultlocale(const char* v, ...);
186
187/* DEFAULT-TZID */
188icalproperty* icalproperty_new_defaulttzid(const char* v);
189void icalproperty_set_defaulttzid(icalproperty* prop, const char* v);
190const char* icalproperty_get_defaulttzid(const icalproperty* prop);icalproperty* icalproperty_vanew_defaulttzid(const char* v, ...);
142 191
@@ -145,3 +194,3 @@ icalproperty* icalproperty_new_description(const char* v);
145void icalproperty_set_description(icalproperty* prop, const char* v); 194void icalproperty_set_description(icalproperty* prop, const char* v);
146const char* icalproperty_get_description(icalproperty* prop);icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...); 195const char* icalproperty_get_description(const icalproperty* prop);icalproperty* icalproperty_vanew_description(const char* v, ...);
147 196
@@ -150,3 +199,3 @@ icalproperty* icalproperty_new_dtend(struct icaltimetype v);
150void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v); 199void icalproperty_set_dtend(icalproperty* prop, struct icaltimetype v);
151struct icaltimetype icalproperty_get_dtend(icalproperty* prop);icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...); 200struct icaltimetype icalproperty_get_dtend(const icalproperty* prop);icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...);
152 201
@@ -155,3 +204,3 @@ icalproperty* icalproperty_new_dtstamp(struct icaltimetype v);
155void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v); 204void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v);
156struct icaltimetype icalproperty_get_dtstamp(icalproperty* prop);icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...); 205struct icaltimetype icalproperty_get_dtstamp(const icalproperty* prop);icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...);
157 206
@@ -160,3 +209,3 @@ icalproperty* icalproperty_new_dtstart(struct icaltimetype v);
160void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v); 209void icalproperty_set_dtstart(icalproperty* prop, struct icaltimetype v);
161struct icaltimetype icalproperty_get_dtstart(icalproperty* prop);icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...); 210struct icaltimetype icalproperty_get_dtstart(const icalproperty* prop);icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...);
162 211
@@ -165,3 +214,3 @@ icalproperty* icalproperty_new_due(struct icaltimetype v);
165void icalproperty_set_due(icalproperty* prop, struct icaltimetype v); 214void icalproperty_set_due(icalproperty* prop, struct icaltimetype v);
166struct icaltimetype icalproperty_get_due(icalproperty* prop);icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...); 215struct icaltimetype icalproperty_get_due(const icalproperty* prop);icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...);
167 216
@@ -170,3 +219,3 @@ icalproperty* icalproperty_new_duration(struct icaldurationtype v);
170void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v); 219void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v);
171struct icaldurationtype icalproperty_get_duration(icalproperty* prop);icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...); 220struct icaldurationtype icalproperty_get_duration(const icalproperty* prop);icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...);
172 221
@@ -175,3 +224,8 @@ icalproperty* icalproperty_new_exdate(struct icaltimetype v);
175void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v); 224void icalproperty_set_exdate(icalproperty* prop, struct icaltimetype v);
176struct icaltimetype icalproperty_get_exdate(icalproperty* prop);icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...); 225struct icaltimetype icalproperty_get_exdate(const icalproperty* prop);icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...);
226
227/* EXPAND */
228icalproperty* icalproperty_new_expand(int v);
229void icalproperty_set_expand(icalproperty* prop, int v);
230int icalproperty_get_expand(const icalproperty* prop);icalproperty* icalproperty_vanew_expand(int v, ...);
177 231
@@ -180,3 +234,3 @@ icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v);
180void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v); 234void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v);
181struct icalrecurrencetype icalproperty_get_exrule(icalproperty* prop);icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...); 235struct icalrecurrencetype icalproperty_get_exrule(const icalproperty* prop);icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...);
182 236
@@ -185,3 +239,3 @@ icalproperty* icalproperty_new_freebusy(struct icalperiodtype v);
185void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v); 239void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v);
186struct icalperiodtype icalproperty_get_freebusy(icalproperty* prop);icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...); 240struct icalperiodtype icalproperty_get_freebusy(const icalproperty* prop);icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...);
187 241
@@ -190,3 +244,3 @@ icalproperty* icalproperty_new_geo(struct icalgeotype v);
190void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v); 244void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v);
191struct icalgeotype icalproperty_get_geo(icalproperty* prop);icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...); 245struct icalgeotype icalproperty_get_geo(const icalproperty* prop);icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...);
192 246
@@ -195,3 +249,3 @@ icalproperty* icalproperty_new_lastmodified(struct icaltimetype v);
195void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v); 249void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v);
196struct icaltimetype icalproperty_get_lastmodified(icalproperty* prop);icalproperty* icalproperty_vanew_location(const char* v, ...); 250struct icaltimetype icalproperty_get_lastmodified(const icalproperty* prop);icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...);
197 251
@@ -200,3 +254,3 @@ icalproperty* icalproperty_new_location(const char* v);
200void icalproperty_set_location(icalproperty* prop, const char* v); 254void icalproperty_set_location(icalproperty* prop, const char* v);
201const char* icalproperty_get_location(icalproperty* prop);icalproperty* icalproperty_vanew_maxresults(int v, ...); 255const char* icalproperty_get_location(const icalproperty* prop);icalproperty* icalproperty_vanew_location(const char* v, ...);
202 256
@@ -205,3 +259,3 @@ icalproperty* icalproperty_new_maxresults(int v);
205void icalproperty_set_maxresults(icalproperty* prop, int v); 259void icalproperty_set_maxresults(icalproperty* prop, int v);
206int icalproperty_get_maxresults(icalproperty* prop);icalproperty* icalproperty_vanew_maxresultssize(int v, ...); 260int icalproperty_get_maxresults(const icalproperty* prop);icalproperty* icalproperty_vanew_maxresults(int v, ...);
207 261
@@ -210,3 +264,3 @@ icalproperty* icalproperty_new_maxresultssize(int v);
210void icalproperty_set_maxresultssize(icalproperty* prop, int v); 264void icalproperty_set_maxresultssize(icalproperty* prop, int v);
211int icalproperty_get_maxresultssize(icalproperty* prop);icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...); 265int icalproperty_get_maxresultssize(const icalproperty* prop);icalproperty* icalproperty_vanew_maxresultssize(int v, ...);
212 266
@@ -215,3 +269,3 @@ icalproperty* icalproperty_new_method(enum icalproperty_method v);
215void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v); 269void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v);
216enum icalproperty_method icalproperty_get_method(icalproperty* prop);icalproperty* icalproperty_vanew_organizer(const char* v, ...); 270enum icalproperty_method icalproperty_get_method(const icalproperty* prop);icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...);
217 271
@@ -220,3 +274,8 @@ icalproperty* icalproperty_new_organizer(const char* v);
220void icalproperty_set_organizer(icalproperty* prop, const char* v); 274void icalproperty_set_organizer(icalproperty* prop, const char* v);
221const char* icalproperty_get_organizer(icalproperty* prop);icalproperty* icalproperty_vanew_percentcomplete(int v, ...); 275const char* icalproperty_get_organizer(const icalproperty* prop);icalproperty* icalproperty_vanew_organizer(const char* v, ...);
276
277/* OWNER */
278icalproperty* icalproperty_new_owner(const char* v);
279void icalproperty_set_owner(icalproperty* prop, const char* v);
280const char* icalproperty_get_owner(const icalproperty* prop);icalproperty* icalproperty_vanew_owner(const char* v, ...);
222 281
@@ -225,3 +284,3 @@ icalproperty* icalproperty_new_percentcomplete(int v);
225void icalproperty_set_percentcomplete(icalproperty* prop, int v); 284void icalproperty_set_percentcomplete(icalproperty* prop, int v);
226int icalproperty_get_percentcomplete(icalproperty* prop);icalproperty* icalproperty_vanew_priority(int v, ...); 285int icalproperty_get_percentcomplete(const icalproperty* prop);icalproperty* icalproperty_vanew_percentcomplete(int v, ...);
227 286
@@ -230,3 +289,3 @@ icalproperty* icalproperty_new_priority(int v);
230void icalproperty_set_priority(icalproperty* prop, int v); 289void icalproperty_set_priority(icalproperty* prop, int v);
231int icalproperty_get_priority(icalproperty* prop);icalproperty* icalproperty_vanew_prodid(const char* v, ...); 290int icalproperty_get_priority(const icalproperty* prop);icalproperty* icalproperty_vanew_priority(int v, ...);
232 291
@@ -235,3 +294,3 @@ icalproperty* icalproperty_new_prodid(const char* v);
235void icalproperty_set_prodid(icalproperty* prop, const char* v); 294void icalproperty_set_prodid(icalproperty* prop, const char* v);
236const char* icalproperty_get_prodid(icalproperty* prop);icalproperty* icalproperty_vanew_query(const char* v, ...); 295const char* icalproperty_get_prodid(const icalproperty* prop);icalproperty* icalproperty_vanew_prodid(const char* v, ...);
237 296
@@ -240,3 +299,3 @@ icalproperty* icalproperty_new_query(const char* v);
240void icalproperty_set_query(icalproperty* prop, const char* v); 299void icalproperty_set_query(icalproperty* prop, const char* v);
241const char* icalproperty_get_query(icalproperty* prop);icalproperty* icalproperty_vanew_queryname(const char* v, ...); 300const char* icalproperty_get_query(const icalproperty* prop);icalproperty* icalproperty_vanew_query(const char* v, ...);
242 301
@@ -245,3 +304,3 @@ icalproperty* icalproperty_new_queryname(const char* v);
245void icalproperty_set_queryname(icalproperty* prop, const char* v); 304void icalproperty_set_queryname(icalproperty* prop, const char* v);
246const char* icalproperty_get_queryname(icalproperty* prop);icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...); 305const char* icalproperty_get_queryname(const icalproperty* prop);icalproperty* icalproperty_vanew_queryname(const char* v, ...);
247 306
@@ -250,3 +309,3 @@ icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v);
250void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v); 309void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v);
251struct icaldatetimeperiodtype icalproperty_get_rdate(icalproperty* prop);icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...); 310struct icaldatetimeperiodtype icalproperty_get_rdate(const icalproperty* prop);icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...);
252 311
@@ -255,3 +314,3 @@ icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v);
255void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v); 314void icalproperty_set_recurrenceid(icalproperty* prop, struct icaltimetype v);
256struct icaltimetype icalproperty_get_recurrenceid(icalproperty* prop);icalproperty* icalproperty_vanew_relatedto(const char* v, ...); 315struct icaltimetype icalproperty_get_recurrenceid(const icalproperty* prop);icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...);
257 316
@@ -260,3 +319,8 @@ icalproperty* icalproperty_new_relatedto(const char* v);
260void icalproperty_set_relatedto(icalproperty* prop, const char* v); 319void icalproperty_set_relatedto(icalproperty* prop, const char* v);
261const char* icalproperty_get_relatedto(icalproperty* prop);icalproperty* icalproperty_vanew_repeat(int v, ...); 320const char* icalproperty_get_relatedto(const icalproperty* prop);icalproperty* icalproperty_vanew_relatedto(const char* v, ...);
321
322/* RELCALID */
323icalproperty* icalproperty_new_relcalid(const char* v);
324void icalproperty_set_relcalid(icalproperty* prop, const char* v);
325const char* icalproperty_get_relcalid(const icalproperty* prop);icalproperty* icalproperty_vanew_relcalid(const char* v, ...);
262 326
@@ -265,3 +329,3 @@ icalproperty* icalproperty_new_repeat(int v);
265void icalproperty_set_repeat(icalproperty* prop, int v); 329void icalproperty_set_repeat(icalproperty* prop, int v);
266int icalproperty_get_repeat(icalproperty* prop);icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...); 330int icalproperty_get_repeat(const icalproperty* prop);icalproperty* icalproperty_vanew_repeat(int v, ...);
267 331
@@ -270,3 +334,3 @@ icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v);
270void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v); 334void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v);
271struct icalreqstattype icalproperty_get_requeststatus(icalproperty* prop);icalproperty* icalproperty_vanew_resources(const char* v, ...); 335struct icalreqstattype icalproperty_get_requeststatus(const icalproperty* prop);icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...);
272 336
@@ -275,3 +339,3 @@ icalproperty* icalproperty_new_resources(const char* v);
275void icalproperty_set_resources(icalproperty* prop, const char* v); 339void icalproperty_set_resources(icalproperty* prop, const char* v);
276const char* icalproperty_get_resources(icalproperty* prop);icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...); 340const char* icalproperty_get_resources(const icalproperty* prop);icalproperty* icalproperty_vanew_resources(const char* v, ...);
277 341
@@ -280,3 +344,3 @@ icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v);
280void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v); 344void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v);
281struct icalrecurrencetype icalproperty_get_rrule(icalproperty* prop);icalproperty* icalproperty_vanew_scope(const char* v, ...); 345struct icalrecurrencetype icalproperty_get_rrule(const icalproperty* prop);icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...);
282 346
@@ -285,3 +349,3 @@ icalproperty* icalproperty_new_scope(const char* v);
285void icalproperty_set_scope(icalproperty* prop, const char* v); 349void icalproperty_set_scope(icalproperty* prop, const char* v);
286const char* icalproperty_get_scope(icalproperty* prop);icalproperty* icalproperty_vanew_sequence(int v, ...); 350const char* icalproperty_get_scope(const icalproperty* prop);icalproperty* icalproperty_vanew_scope(const char* v, ...);
287 351
@@ -290,3 +354,3 @@ icalproperty* icalproperty_new_sequence(int v);
290void icalproperty_set_sequence(icalproperty* prop, int v); 354void icalproperty_set_sequence(icalproperty* prop, int v);
291int icalproperty_get_sequence(icalproperty* prop);icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...); 355int icalproperty_get_sequence(const icalproperty* prop);icalproperty* icalproperty_vanew_sequence(int v, ...);
292 356
@@ -295,3 +359,3 @@ icalproperty* icalproperty_new_status(enum icalproperty_status v);
295void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v); 359void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v);
296enum icalproperty_status icalproperty_get_status(icalproperty* prop);icalproperty* icalproperty_vanew_summary(const char* v, ...); 360enum icalproperty_status icalproperty_get_status(const icalproperty* prop);icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...);
297 361
@@ -300,3 +364,3 @@ icalproperty* icalproperty_new_summary(const char* v);
300void icalproperty_set_summary(icalproperty* prop, const char* v); 364void icalproperty_set_summary(icalproperty* prop, const char* v);
301const char* icalproperty_get_summary(icalproperty* prop);icalproperty* icalproperty_vanew_target(const char* v, ...); 365const char* icalproperty_get_summary(const icalproperty* prop);icalproperty* icalproperty_vanew_summary(const char* v, ...);
302 366
@@ -305,8 +369,8 @@ icalproperty* icalproperty_new_target(const char* v);
305void icalproperty_set_target(icalproperty* prop, const char* v); 369void icalproperty_set_target(icalproperty* prop, const char* v);
306const char* icalproperty_get_target(icalproperty* prop);icalproperty* icalproperty_vanew_transp(const char* v, ...); 370const char* icalproperty_get_target(const icalproperty* prop);icalproperty* icalproperty_vanew_target(const char* v, ...);
307 371
308/* TRANSP */ 372/* TRANSP */
309icalproperty* icalproperty_new_transp(const char* v); 373icalproperty* icalproperty_new_transp(enum icalproperty_transp v);
310void icalproperty_set_transp(icalproperty* prop, const char* v); 374void icalproperty_set_transp(icalproperty* prop, enum icalproperty_transp v);
311const char* icalproperty_get_transp(icalproperty* prop);icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...); 375enum icalproperty_transp icalproperty_get_transp(const icalproperty* prop);icalproperty* icalproperty_vanew_transp(enum icalproperty_transp v, ...);
312 376
@@ -315,3 +379,3 @@ icalproperty* icalproperty_new_trigger(struct icaltriggertype v);
315void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v); 379void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v);
316struct icaltriggertype icalproperty_get_trigger(icalproperty* prop);icalproperty* icalproperty_vanew_tzid(const char* v, ...); 380struct icaltriggertype icalproperty_get_trigger(const icalproperty* prop);icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...);
317 381
@@ -320,3 +384,3 @@ icalproperty* icalproperty_new_tzid(const char* v);
320void icalproperty_set_tzid(icalproperty* prop, const char* v); 384void icalproperty_set_tzid(icalproperty* prop, const char* v);
321const char* icalproperty_get_tzid(icalproperty* prop);icalproperty* icalproperty_vanew_tzname(const char* v, ...); 385const char* icalproperty_get_tzid(const icalproperty* prop);icalproperty* icalproperty_vanew_tzid(const char* v, ...);
322 386
@@ -325,3 +389,3 @@ icalproperty* icalproperty_new_tzname(const char* v);
325void icalproperty_set_tzname(icalproperty* prop, const char* v); 389void icalproperty_set_tzname(icalproperty* prop, const char* v);
326const char* icalproperty_get_tzname(icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...); 390const char* icalproperty_get_tzname(const icalproperty* prop);icalproperty* icalproperty_vanew_tzname(const char* v, ...);
327 391
@@ -330,3 +394,3 @@ icalproperty* icalproperty_new_tzoffsetfrom(int v);
330void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v); 394void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v);
331int icalproperty_get_tzoffsetfrom(icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetto(int v, ...); 395int icalproperty_get_tzoffsetfrom(const icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...);
332 396
@@ -335,3 +399,3 @@ icalproperty* icalproperty_new_tzoffsetto(int v);
335void icalproperty_set_tzoffsetto(icalproperty* prop, int v); 399void icalproperty_set_tzoffsetto(icalproperty* prop, int v);
336int icalproperty_get_tzoffsetto(icalproperty* prop);icalproperty* icalproperty_vanew_tzurl(const char* v, ...); 400int icalproperty_get_tzoffsetto(const icalproperty* prop);icalproperty* icalproperty_vanew_tzoffsetto(int v, ...);
337 401
@@ -340,3 +404,3 @@ icalproperty* icalproperty_new_tzurl(const char* v);
340void icalproperty_set_tzurl(icalproperty* prop, const char* v); 404void icalproperty_set_tzurl(icalproperty* prop, const char* v);
341const char* icalproperty_get_tzurl(icalproperty* prop);icalproperty* icalproperty_vanew_uid(const char* v, ...); 405const char* icalproperty_get_tzurl(const icalproperty* prop);icalproperty* icalproperty_vanew_tzurl(const char* v, ...);
342 406
@@ -345,3 +409,3 @@ icalproperty* icalproperty_new_uid(const char* v);
345void icalproperty_set_uid(icalproperty* prop, const char* v); 409void icalproperty_set_uid(icalproperty* prop, const char* v);
346const char* icalproperty_get_uid(icalproperty* prop);icalproperty* icalproperty_vanew_url(const char* v, ...); 410const char* icalproperty_get_uid(const icalproperty* prop);icalproperty* icalproperty_vanew_uid(const char* v, ...);
347 411
@@ -350,3 +414,3 @@ icalproperty* icalproperty_new_url(const char* v);
350void icalproperty_set_url(icalproperty* prop, const char* v); 414void icalproperty_set_url(icalproperty* prop, const char* v);
351const char* icalproperty_get_url(icalproperty* prop);icalproperty* icalproperty_vanew_version(const char* v, ...); 415const char* icalproperty_get_url(const icalproperty* prop);icalproperty* icalproperty_vanew_url(const char* v, ...);
352 416
@@ -355,3 +419,3 @@ icalproperty* icalproperty_new_version(const char* v);
355void icalproperty_set_version(icalproperty* prop, const char* v); 419void icalproperty_set_version(icalproperty* prop, const char* v);
356const char* icalproperty_get_version(icalproperty* prop);icalproperty* icalproperty_vanew_x(const char* v, ...); 420const char* icalproperty_get_version(const icalproperty* prop);icalproperty* icalproperty_vanew_version(const char* v, ...);
357 421
@@ -360,3 +424,8 @@ icalproperty* icalproperty_new_x(const char* v);
360void icalproperty_set_x(icalproperty* prop, const char* v); 424void icalproperty_set_x(icalproperty* prop, const char* v);
361const char* icalproperty_get_x(icalproperty* prop);icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...); 425const char* icalproperty_get_x(const icalproperty* prop);icalproperty* icalproperty_vanew_x(const char* v, ...);
426
427/* X-LIC-CLASS */
428icalproperty* icalproperty_new_xlicclass(enum icalproperty_xlicclass v);
429void icalproperty_set_xlicclass(icalproperty* prop, enum icalproperty_xlicclass v);
430enum icalproperty_xlicclass icalproperty_get_xlicclass(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicclass(enum icalproperty_xlicclass v, ...);
362 431
@@ -365,3 +434,3 @@ icalproperty* icalproperty_new_xlicclustercount(const char* v);
365void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v); 434void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v);
366const char* icalproperty_get_xlicclustercount(icalproperty* prop);icalproperty* icalproperty_vanew_xlicerror(const char* v, ...); 435const char* icalproperty_get_xlicclustercount(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...);
367 436
@@ -370,3 +439,3 @@ icalproperty* icalproperty_new_xlicerror(const char* v);
370void icalproperty_set_xlicerror(icalproperty* prop, const char* v); 439void icalproperty_set_xlicerror(icalproperty* prop, const char* v);
371const char* icalproperty_get_xlicerror(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...); 440const char* icalproperty_get_xlicerror(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicerror(const char* v, ...);
372 441
@@ -375,3 +444,3 @@ icalproperty* icalproperty_new_xlicmimecharset(const char* v);
375void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v); 444void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v);
376const char* icalproperty_get_xlicmimecharset(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...); 445const char* icalproperty_get_xlicmimecharset(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...);
377 446
@@ -380,3 +449,3 @@ icalproperty* icalproperty_new_xlicmimecid(const char* v);
380void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v); 449void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v);
381const char* icalproperty_get_xlicmimecid(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...); 450const char* icalproperty_get_xlicmimecid(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...);
382 451
@@ -385,3 +454,3 @@ icalproperty* icalproperty_new_xlicmimecontenttype(const char* v);
385void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v); 454void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v);
386const char* icalproperty_get_xlicmimecontenttype(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...); 455const char* icalproperty_get_xlicmimecontenttype(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...);
387 456
@@ -390,3 +459,3 @@ icalproperty* icalproperty_new_xlicmimeencoding(const char* v);
390void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v); 459void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v);
391const char* icalproperty_get_xlicmimeencoding(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...); 460const char* icalproperty_get_xlicmimeencoding(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...);
392 461
@@ -395,3 +464,3 @@ icalproperty* icalproperty_new_xlicmimefilename(const char* v);
395void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v); 464void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v);
396const char* icalproperty_get_xlicmimefilename(icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...); 465const char* icalproperty_get_xlicmimefilename(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...);
397 466
@@ -400,3 +469,4 @@ icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v);
400void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v); 469void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v);
401const char* icalproperty_get_xlicmimeoptinfo(icalproperty* prop); 470const char* icalproperty_get_xlicmimeoptinfo(const icalproperty* prop);icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...);
471
402 472
diff --git a/libical/src/libical/icalderivedvalue.c b/libical/src/libical/icalderivedvalue.c
index db762ea..8dbbe9e 100644
--- a/libical/src/libical/icalderivedvalue.c
+++ b/libical/src/libical/icalderivedvalue.c
@@ -49,6 +49,2 @@
49 49
50
51
52#define TMP_BUF_SIZE 1024
53
54struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind); 50struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind);
@@ -62,39 +58,42 @@ struct icalvalue_kind_map {
62 58
63extern struct icalvalue_kind_map value_map[]; 59static struct icalvalue_kind_map value_map[28]={
64 60 {ICAL_QUERY_VALUE,"QUERY"},
65const char* icalvalue_kind_to_string(icalvalue_kind kind) 61 {ICAL_DATE_VALUE,"DATE"},
66{ 62 {ICAL_ATTACH_VALUE,"ATTACH"},
67 int i; 63 {ICAL_GEO_VALUE,"GEO"},
68 64 {ICAL_STATUS_VALUE,"STATUS"},
69 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { 65 {ICAL_TRANSP_VALUE,"TRANSP"},
70 if (value_map[i].kind == kind) { 66 {ICAL_STRING_VALUE,"STRING"},
71 return value_map[i].name; 67 {ICAL_TEXT_VALUE,"TEXT"},
72 } 68 {ICAL_REQUESTSTATUS_VALUE,"REQUEST-STATUS"},
73 } 69 {ICAL_BINARY_VALUE,"BINARY"},
74 70 {ICAL_PERIOD_VALUE,"PERIOD"},
75 return 0; 71 {ICAL_FLOAT_VALUE,"FLOAT"},
76} 72 {ICAL_DATETIMEPERIOD_VALUE,"DATE-TIME-PERIOD"},
77 73 {ICAL_INTEGER_VALUE,"INTEGER"},
78icalvalue_kind icalvalue_string_to_kind(const char* str) 74 {ICAL_CLASS_VALUE,"CLASS"},
79{ 75 {ICAL_URI_VALUE,"URI"},
80 int i; 76 {ICAL_DURATION_VALUE,"DURATION"},
81 77 {ICAL_BOOLEAN_VALUE,"BOOLEAN"},
82 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { 78 {ICAL_X_VALUE,"X"},
83 if (strcmp(value_map[i].name,str) == 0) { 79 {ICAL_CALADDRESS_VALUE,"CAL-ADDRESS"},
84 return value_map[i].kind; 80 {ICAL_TRIGGER_VALUE,"TRIGGER"},
85 } 81 {ICAL_XLICCLASS_VALUE,"X-LIC-CLASS"},
86 } 82 {ICAL_RECUR_VALUE,"RECUR"},
87 83 {ICAL_ACTION_VALUE,"ACTION"},
88 return value_map[i].kind; 84 {ICAL_DATETIME_VALUE,"DATE-TIME"},
85 {ICAL_UTCOFFSET_VALUE,"UTC-OFFSET"},
86 {ICAL_METHOD_VALUE,"METHOD"},
87 {ICAL_NO_VALUE,""}
88};
89 89
90}
91 90
92icalvalue* icalvalue_new_x (const char* v){ 91icalvalue* icalvalue_new_query (const char* v){
93 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE); 92 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_QUERY_VALUE);
94 icalerror_check_arg_rz( (v!=0),"v"); 93 icalerror_check_arg_rz( (v!=0),"v");
95 94
96 icalvalue_set_x((icalvalue*)impl,v); 95 icalvalue_set_query((icalvalue*)impl,v);
97 return (icalvalue*)impl; 96 return (icalvalue*)impl;
98} 97}
99void icalvalue_set_x(icalvalue* value, const char* v) { 98void icalvalue_set_query(icalvalue* value, const char* v) {
100 struct icalvalue_impl* impl; 99 struct icalvalue_impl* impl;
@@ -103,8 +102,10 @@ void icalvalue_set_x(icalvalue* value, const char* v) {
103 102
103 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
104 impl = (struct icalvalue_impl*)value; 104 impl = (struct icalvalue_impl*)value;
105 if(impl->x_value!=0) {free((void*)impl->x_value);} 105 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
106 106
107 impl->x_value = icalmemory_strdup(v);
108 107
109 if (impl->x_value == 0){ 108 impl->data.v_string = icalmemory_strdup(v);
109
110 if (impl->data.v_string == 0){
110 errno = ENOMEM; 111 errno = ENOMEM;
@@ -112,46 +113,37 @@ void icalvalue_set_x(icalvalue* value, const char* v) {
112 113
113 } 114
114const char* icalvalue_get_x(icalvalue* value) { 115 icalvalue_reset_kind(impl);
116}
117const char* icalvalue_get_query(const icalvalue* value) {
115 118
116 icalerror_check_arg( (value!=0),"value"); 119 icalerror_check_arg( (value!=0),"value");
117 icalerror_check_value_type(value, ICAL_X_VALUE); 120 icalerror_check_value_type(value, ICAL_QUERY_VALUE);
118 return ((struct icalvalue_impl*)value)->x_value; 121 return ((struct icalvalue_impl*)value)->data.v_string;
119} 122}
120 123
121/* Attachment is a special case, so it is not auto generated. */
122icalvalue*
123icalvalue_new_attach (struct icalattachtype *v)
124{
125 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ATTACH_VALUE);
126
127 icalvalue_set_attach((icalvalue*)impl,v);
128 124
125
126icalvalue* icalvalue_new_date (struct icaltimetype v){
127 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATE_VALUE);
128
129 icalvalue_set_date((icalvalue*)impl,v);
129 return (icalvalue*)impl; 130 return (icalvalue*)impl;
130} 131}
131 132void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
132void
133icalvalue_set_attach(icalvalue* value, struct icalattachtype *v)
134{
135 struct icalvalue_impl* impl; 133 struct icalvalue_impl* impl;
136
137 icalerror_check_arg_rv( (value!=0),"value"); 134 icalerror_check_arg_rv( (value!=0),"value");
138 icalerror_check_value_type(value, ICAL_ATTACH_VALUE); 135
139 136 icalerror_check_value_type(value, ICAL_DATE_VALUE);
140 impl = (struct icalvalue_impl*)value; 137 impl = (struct icalvalue_impl*)value;
141 138
142 if (impl->data.v_attach != 0){
143 icalattachtype_free(impl->data.v_attach);
144 }
145 139
146 impl->data.v_attach = v; 140 impl->data.v_time = v;
147 icalattachtype_add_reference(v); 141
142 icalvalue_reset_kind(impl);
148} 143}
144struct icaltimetype icalvalue_get_date(const icalvalue* value) {
149 145
150struct icalattachtype*
151icalvalue_get_attach(icalvalue* value)
152{
153 icalerror_check_arg( (value!=0),"value"); 146 icalerror_check_arg( (value!=0),"value");
154 icalerror_check_value_type(value, ICAL_ATTACH_VALUE); 147 icalerror_check_value_type(value, ICAL_DATE_VALUE);
155 148 return ((struct icalvalue_impl*)value)->data.v_time;
156 return ((struct icalvalue_impl*)value)->data.v_attach;
157} 149}
@@ -159,46 +151,26 @@ icalvalue_get_attach(icalvalue* value)
159 151
160/* Recur is a special case, so it is not auto generated. */
161icalvalue*
162icalvalue_new_recur (struct icalrecurrencetype v)
163{
164 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE);
165
166 icalvalue_set_recur((icalvalue*)impl,v);
167 152
153icalvalue* icalvalue_new_geo (struct icalgeotype v){
154 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE);
155
156 icalvalue_set_geo((icalvalue*)impl,v);
168 return (icalvalue*)impl; 157 return (icalvalue*)impl;
169} 158}
170 159void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
171void
172icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v)
173{
174 struct icalvalue_impl* impl; 160 struct icalvalue_impl* impl;
175
176 icalerror_check_arg_rv( (value!=0),"value"); 161 icalerror_check_arg_rv( (value!=0),"value");
177 icalerror_check_value_type(value, ICAL_RECUR_VALUE); 162
178 163 icalerror_check_value_type(value, ICAL_GEO_VALUE);
179 impl = (struct icalvalue_impl*)value; 164 impl = (struct icalvalue_impl*)value;
180 165
181 if (impl->data.v_recur != 0){
182 free(impl->data.v_recur);
183 impl->data.v_recur = 0;
184 }
185 166
186 impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); 167 impl->data.v_geo = v;
187 168
188 if (impl->data.v_recur == 0){ 169 icalvalue_reset_kind(impl);
189 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
190 return;
191 } else {
192 memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
193 }
194
195} 170}
171struct icalgeotype icalvalue_get_geo(const icalvalue* value) {
196 172
197struct icalrecurrencetype
198icalvalue_get_recur(icalvalue* value)
199{
200 icalerror_check_arg( (value!=0),"value"); 173 icalerror_check_arg( (value!=0),"value");
201 icalerror_check_value_type(value, ICAL_RECUR_VALUE); 174 icalerror_check_value_type(value, ICAL_GEO_VALUE);
202 175 return ((struct icalvalue_impl*)value)->data.v_geo;
203 return *(((struct icalvalue_impl*)value)->data.v_recur);
204} 176}
@@ -207,120 +179,53 @@ icalvalue_get_recur(icalvalue* value)
207 179
208 180icalvalue* icalvalue_new_status (enum icalproperty_status v){
209icalvalue* 181 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STATUS_VALUE);
210icalvalue_new_trigger (struct icaltriggertype v) 182
211{ 183 icalvalue_set_status((icalvalue*)impl,v);
212 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
213
214 icalvalue_set_trigger((icalvalue*)impl,v);
215
216 return (icalvalue*)impl; 184 return (icalvalue*)impl;
217} 185}
218 186void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) {
219void
220icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
221{
222 struct icalvalue_impl* impl; 187 struct icalvalue_impl* impl;
223
224 icalerror_check_arg_rv( (value!=0),"value"); 188 icalerror_check_arg_rv( (value!=0),"value");
225 189
190 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
226 impl = (struct icalvalue_impl*)value; 191 impl = (struct icalvalue_impl*)value;
227 192
228 if(!icaltime_is_null_time(v.time)){
229 icalvalue_set_datetime((icalvalue*)impl,v.time);
230 impl->kind = ICAL_DATETIME_VALUE;
231 } else {
232 icalvalue_set_duration((icalvalue*)impl,v.duration);
233 impl->kind = ICAL_DURATION_VALUE;
234 }
235 193
236} 194 impl->data.v_enum = v;
237 195
238struct icaltriggertype 196 icalvalue_reset_kind(impl);
239icalvalue_get_trigger(icalvalue* value) 197}
240{ 198enum icalproperty_status icalvalue_get_status(const icalvalue* value) {
241 struct icalvalue_impl *impl = (struct icalvalue_impl*)value;
242 struct icaltriggertype tr;
243 199
244 icalerror_check_arg( (value!=0),"value"); 200 icalerror_check_arg( (value!=0),"value");
245 icalerror_check_arg( (value!=0),"value"); 201 icalerror_check_value_type(value, ICAL_STATUS_VALUE);
246 202 return ((struct icalvalue_impl*)value)->data.v_enum;
247 if(impl->kind == ICAL_DATETIME_VALUE){
248 tr.duration = icaldurationtype_from_int(0);
249 tr.time = impl->data.v_time;
250 } else if(impl->kind == ICAL_DURATION_VALUE){
251 tr.time = icaltime_null_time();
252 tr.duration = impl->data.v_duration;
253 } else {
254 tr.duration = icaldurationtype_from_int(0);
255 tr.time = icaltime_null_time();
256 icalerror_set_errno(ICAL_BADARG_ERROR);
257 }
258
259 return tr;
260} 203}
261 204
262/* DATE-TIME-PERIOD is a special case, and is not auto generated */
263
264icalvalue*
265icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
266{
267 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);
268 205
269 icalvalue_set_datetimeperiod((icalvalue*)impl,v);
270 206
207icalvalue* icalvalue_new_transp (enum icalproperty_transp v){
208 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRANSP_VALUE);
209
210 icalvalue_set_transp((icalvalue*)impl,v);
271 return (icalvalue*)impl; 211 return (icalvalue*)impl;
272} 212}
273 213void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
274void 214 struct icalvalue_impl* impl;
275icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v)
276{
277 struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
278
279 icalerror_check_arg_rv( (value!=0),"value"); 215 icalerror_check_arg_rv( (value!=0),"value");
280 216
281 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); 217 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
218 impl = (struct icalvalue_impl*)value;
282 219
283 if(!icaltime_is_null_time(v.time)){
284 if(!icaltime_is_valid_time(v.time)){
285 icalerror_set_errno(ICAL_BADARG_ERROR);
286 return;
287 }
288 impl->kind = ICAL_DATETIME_VALUE;
289 icalvalue_set_datetime(impl,v.time);
290 } else if (!icalperiodtype_is_null_period(v.period)) {
291 if(!icalperiodtype_is_valid_period(v.period)){
292 icalerror_set_errno(ICAL_BADARG_ERROR);
293 return;
294 }
295 impl->kind = ICAL_PERIOD_VALUE;
296 icalvalue_set_period(impl,v.period);
297 } else {
298 icalerror_set_errno(ICAL_BADARG_ERROR);
299 }
300}
301 220
302struct icaldatetimeperiodtype 221 impl->data.v_enum = v;
303icalvalue_get_datetimeperiod(icalvalue* value)
304{
305 struct icaldatetimeperiodtype dtp;
306
307 struct icalvalue_impl* impl = (struct icalvalue_impl*)value;
308 icalerror_check_arg( (value!=0),"value");
309 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
310
311 if(impl->kind == ICAL_DATETIME_VALUE){
312 dtp.period = icalperiodtype_null_period();
313 dtp.time = impl->data.v_time;
314 } else if(impl->kind == ICAL_PERIOD_VALUE) {
315 dtp.period = impl->data.v_period;
316 dtp.time = icaltime_null_time();
317 } else {
318 dtp.period = icalperiodtype_null_period();
319 dtp.time = icaltime_null_time();
320 icalerror_set_errno(ICAL_BADARG_ERROR);
321 }
322 222
323 return dtp; 223 icalvalue_reset_kind(impl);
324} 224}
225enum icalproperty_transp icalvalue_get_transp(const icalvalue* value) {
325 226
227 icalerror_check_arg( (value!=0),"value");
228 icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
229 return ((struct icalvalue_impl*)value)->data.v_enum;
230}
326 231
@@ -328,51 +233,10 @@ icalvalue_get_datetimeperiod(icalvalue* value)
328 233
329 234icalvalue* icalvalue_new_string (const char* v){
330 235 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STRING_VALUE);
331
332
333
334/* The remaining interfaces are 'new', 'set' and 'get' for each of the value
335 types */
336
337
338/* Everything below this line is machine generated. Do not edit. */
339static struct icalvalue_kind_map value_map[]={
340 {ICAL_QUERY_VALUE,"QUERY"},
341 {ICAL_TRIGGER_VALUE,"TRIGGER"},
342 {ICAL_STATUS_VALUE,"STATUS"},
343 {ICAL_TRANSP_VALUE,"TRANSP"},
344 {ICAL_CLASS_VALUE,"CLASS"},
345 {ICAL_DATE_VALUE,"DATE"},
346 {ICAL_STRING_VALUE,"STRING"},
347 {ICAL_INTEGER_VALUE,"INTEGER"},
348 {ICAL_PERIOD_VALUE,"PERIOD"},
349 {ICAL_TEXT_VALUE,"TEXT"},
350 {ICAL_DURATION_VALUE,"DURATION"},
351 {ICAL_BOOLEAN_VALUE,"BOOLEAN"},
352 {ICAL_URI_VALUE,"URI"},
353 {ICAL_DATETIMEPERIOD_VALUE,"DATE-TIME-PERIOD"},
354 {ICAL_GEO_VALUE,"GEO"},
355 {ICAL_DATETIME_VALUE,"DATE-TIME"},
356 {ICAL_UTCOFFSET_VALUE,"UTC-OFFSET"},
357 {ICAL_ATTACH_VALUE,"ATTACH"},
358 {ICAL_ACTION_VALUE,"ACTION"},
359 {ICAL_CALADDRESS_VALUE,"CAL-ADDRESS"},
360 {ICAL_X_VALUE,"X"},
361 {ICAL_FLOAT_VALUE,"FLOAT"},
362 {ICAL_REQUESTSTATUS_VALUE,"REQUEST-STATUS"},
363 {ICAL_METHOD_VALUE,"METHOD"},
364 {ICAL_BINARY_VALUE,"BINARY"},
365 {ICAL_RECUR_VALUE,"RECUR"},
366 {ICAL_NO_VALUE,""}
367};
368
369
370icalvalue* icalvalue_new_query (const char* v){
371 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_QUERY_VALUE);
372 icalerror_check_arg_rz( (v!=0),"v"); 236 icalerror_check_arg_rz( (v!=0),"v");
373 237
374 icalvalue_set_query((icalvalue*)impl,v); 238 icalvalue_set_string((icalvalue*)impl,v);
375 return (icalvalue*)impl; 239 return (icalvalue*)impl;
376} 240}
377void icalvalue_set_query(icalvalue* value, const char* v) { 241void icalvalue_set_string(icalvalue* value, const char* v) {
378 struct icalvalue_impl* impl; 242 struct icalvalue_impl* impl;
@@ -381,3 +245,3 @@ void icalvalue_set_query(icalvalue* value, const char* v) {
381 245
382 icalerror_check_value_type(value, ICAL_QUERY_VALUE); 246 icalerror_check_value_type(value, ICAL_STRING_VALUE);
383 impl = (struct icalvalue_impl*)value; 247 impl = (struct icalvalue_impl*)value;
@@ -395,6 +259,6 @@ void icalvalue_set_query(icalvalue* value, const char* v) {
395} 259}
396const char* icalvalue_get_query(icalvalue* value) { 260const char* icalvalue_get_string(const icalvalue* value) {
397 261
398 icalerror_check_arg( (value!=0),"value"); 262 icalerror_check_arg( (value!=0),"value");
399 icalerror_check_value_type(value, ICAL_QUERY_VALUE); 263 icalerror_check_value_type(value, ICAL_STRING_VALUE);
400 return ((struct icalvalue_impl*)value)->data.v_string; 264 return ((struct icalvalue_impl*)value)->data.v_string;
@@ -404,17 +268,25 @@ const char* icalvalue_get_query(icalvalue* value) {
404 268
405icalvalue* icalvalue_new_status (enum icalproperty_status v){ 269icalvalue* icalvalue_new_text (const char* v){
406 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STATUS_VALUE); 270 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TEXT_VALUE);
407 271 icalerror_check_arg_rz( (v!=0),"v");
408 icalvalue_set_status((icalvalue*)impl,v); 272
273 icalvalue_set_text((icalvalue*)impl,v);
409 return (icalvalue*)impl; 274 return (icalvalue*)impl;
410} 275}
411void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) { 276void icalvalue_set_text(icalvalue* value, const char* v) {
412 struct icalvalue_impl* impl; 277 struct icalvalue_impl* impl;
413 icalerror_check_arg_rv( (value!=0),"value"); 278 icalerror_check_arg_rv( (value!=0),"value");
414 279 icalerror_check_arg_rv( (v!=0),"v");
415 icalerror_check_value_type(value, ICAL_STATUS_VALUE); 280
281 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
416 impl = (struct icalvalue_impl*)value; 282 impl = (struct icalvalue_impl*)value;
283 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
417 284
418 285
419 impl->data.v_enum = v; 286 impl->data.v_string = icalmemory_strdup(v);
287
288 if (impl->data.v_string == 0){
289 errno = ENOMEM;
290 }
291
420 292
@@ -422,7 +294,7 @@ void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) {
422} 294}
423enum icalproperty_status icalvalue_get_status(icalvalue* value) { 295const char* icalvalue_get_text(const icalvalue* value) {
424 296
425 icalerror_check_arg( (value!=0),"value"); 297 icalerror_check_arg( (value!=0),"value");
426 icalerror_check_value_type(value, ICAL_STATUS_VALUE); 298 icalerror_check_value_type(value, ICAL_TEXT_VALUE);
427 return ((struct icalvalue_impl*)value)->data.v_enum; 299 return ((struct icalvalue_impl*)value)->data.v_string;
428} 300}
@@ -431,9 +303,9 @@ enum icalproperty_status icalvalue_get_status(icalvalue* value) {
431 303
432icalvalue* icalvalue_new_transp (enum icalproperty_transp v){ 304icalvalue* icalvalue_new_requeststatus (struct icalreqstattype v){
433 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRANSP_VALUE); 305 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_REQUESTSTATUS_VALUE);
434 306
435 icalvalue_set_transp((icalvalue*)impl,v); 307 icalvalue_set_requeststatus((icalvalue*)impl,v);
436 return (icalvalue*)impl; 308 return (icalvalue*)impl;
437} 309}
438void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) { 310void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) {
439 struct icalvalue_impl* impl; 311 struct icalvalue_impl* impl;
@@ -441,3 +313,3 @@ void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
441 313
442 icalerror_check_value_type(value, ICAL_TRANSP_VALUE); 314 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
443 impl = (struct icalvalue_impl*)value; 315 impl = (struct icalvalue_impl*)value;
@@ -445,3 +317,3 @@ void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
445 317
446 impl->data.v_enum = v; 318 impl->data.v_requeststatus = v;
447 319
@@ -449,7 +321,7 @@ void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
449} 321}
450enum icalproperty_transp icalvalue_get_transp(icalvalue* value) { 322struct icalreqstattype icalvalue_get_requeststatus(const icalvalue* value) {
451 323
452 icalerror_check_arg( (value!=0),"value"); 324 icalerror_check_arg( (value!=0),"value");
453 icalerror_check_value_type(value, ICAL_TRANSP_VALUE); 325 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
454 return ((struct icalvalue_impl*)value)->data.v_enum; 326 return ((struct icalvalue_impl*)value)->data.v_requeststatus;
455} 327}
@@ -458,17 +330,25 @@ enum icalproperty_transp icalvalue_get_transp(icalvalue* value) {
458 330
459icalvalue* icalvalue_new_class (enum icalproperty_class v){ 331icalvalue* icalvalue_new_binary (const char* v){
460 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE); 332 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_BINARY_VALUE);
461 333 icalerror_check_arg_rz( (v!=0),"v");
462 icalvalue_set_class((icalvalue*)impl,v); 334
335 icalvalue_set_binary((icalvalue*)impl,v);
463 return (icalvalue*)impl; 336 return (icalvalue*)impl;
464} 337}
465void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) { 338void icalvalue_set_binary(icalvalue* value, const char* v) {
466 struct icalvalue_impl* impl; 339 struct icalvalue_impl* impl;
467 icalerror_check_arg_rv( (value!=0),"value"); 340 icalerror_check_arg_rv( (value!=0),"value");
468 341 icalerror_check_arg_rv( (v!=0),"v");
469 icalerror_check_value_type(value, ICAL_CLASS_VALUE); 342
343 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
470 impl = (struct icalvalue_impl*)value; 344 impl = (struct icalvalue_impl*)value;
345 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
471 346
472 347
473 impl->data.v_enum = v; 348 impl->data.v_string = icalmemory_strdup(v);
349
350 if (impl->data.v_string == 0){
351 errno = ENOMEM;
352 }
353
474 354
@@ -476,7 +356,7 @@ void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) {
476} 356}
477enum icalproperty_class icalvalue_get_class(icalvalue* value) { 357const char* icalvalue_get_binary(const icalvalue* value) {
478 358
479 icalerror_check_arg( (value!=0),"value"); 359 icalerror_check_arg( (value!=0),"value");
480 icalerror_check_value_type(value, ICAL_CLASS_VALUE); 360 icalerror_check_value_type(value, ICAL_BINARY_VALUE);
481 return ((struct icalvalue_impl*)value)->data.v_enum; 361 return ((struct icalvalue_impl*)value)->data.v_string;
482} 362}
@@ -485,9 +365,9 @@ enum icalproperty_class icalvalue_get_class(icalvalue* value) {
485 365
486icalvalue* icalvalue_new_date (struct icaltimetype v){ 366icalvalue* icalvalue_new_period (struct icalperiodtype v){
487 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATE_VALUE); 367 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_PERIOD_VALUE);
488 368
489 icalvalue_set_date((icalvalue*)impl,v); 369 icalvalue_set_period((icalvalue*)impl,v);
490 return (icalvalue*)impl; 370 return (icalvalue*)impl;
491} 371}
492void icalvalue_set_date(icalvalue* value, struct icaltimetype v) { 372void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
493 struct icalvalue_impl* impl; 373 struct icalvalue_impl* impl;
@@ -495,3 +375,3 @@ void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
495 375
496 icalerror_check_value_type(value, ICAL_DATE_VALUE); 376 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
497 impl = (struct icalvalue_impl*)value; 377 impl = (struct icalvalue_impl*)value;
@@ -499,3 +379,3 @@ void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
499 379
500 impl->data.v_time = v; 380 impl->data.v_period = v;
501 381
@@ -503,7 +383,7 @@ void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
503} 383}
504struct icaltimetype icalvalue_get_date(icalvalue* value) { 384struct icalperiodtype icalvalue_get_period(const icalvalue* value) {
505 385
506 icalerror_check_arg( (value!=0),"value"); 386 icalerror_check_arg( (value!=0),"value");
507 icalerror_check_value_type(value, ICAL_DATE_VALUE); 387 icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
508 return ((struct icalvalue_impl*)value)->data.v_time; 388 return ((struct icalvalue_impl*)value)->data.v_period;
509} 389}
@@ -512,25 +392,17 @@ struct icaltimetype icalvalue_get_date(icalvalue* value) {
512 392
513icalvalue* icalvalue_new_string (const char* v){ 393icalvalue* icalvalue_new_float (float v){
514 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_STRING_VALUE); 394 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_FLOAT_VALUE);
515 icalerror_check_arg_rz( (v!=0),"v"); 395
516 396 icalvalue_set_float((icalvalue*)impl,v);
517 icalvalue_set_string((icalvalue*)impl,v);
518 return (icalvalue*)impl; 397 return (icalvalue*)impl;
519} 398}
520void icalvalue_set_string(icalvalue* value, const char* v) { 399void icalvalue_set_float(icalvalue* value, float v) {
521 struct icalvalue_impl* impl; 400 struct icalvalue_impl* impl;
522 icalerror_check_arg_rv( (value!=0),"value"); 401 icalerror_check_arg_rv( (value!=0),"value");
523 icalerror_check_arg_rv( (v!=0),"v"); 402
524 403 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
525 icalerror_check_value_type(value, ICAL_STRING_VALUE);
526 impl = (struct icalvalue_impl*)value; 404 impl = (struct icalvalue_impl*)value;
527 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
528 405
529 406
530 impl->data.v_string = icalmemory_strdup(v); 407 impl->data.v_float = v;
531
532 if (impl->data.v_string == 0){
533 errno = ENOMEM;
534 }
535
536 408
@@ -538,7 +410,7 @@ void icalvalue_set_string(icalvalue* value, const char* v) {
538} 410}
539const char* icalvalue_get_string(icalvalue* value) { 411float icalvalue_get_float(const icalvalue* value) {
540 412
541 icalerror_check_arg( (value!=0),"value"); 413 icalerror_check_arg( (value!=0),"value");
542 icalerror_check_value_type(value, ICAL_STRING_VALUE); 414 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
543 return ((struct icalvalue_impl*)value)->data.v_string; 415 return ((struct icalvalue_impl*)value)->data.v_float;
544} 416}
@@ -565,3 +437,3 @@ void icalvalue_set_integer(icalvalue* value, int v) {
565} 437}
566int icalvalue_get_integer(icalvalue* value) { 438int icalvalue_get_integer(const icalvalue* value) {
567 439
@@ -574,9 +446,9 @@ int icalvalue_get_integer(icalvalue* value) {
574 446
575icalvalue* icalvalue_new_period (struct icalperiodtype v){ 447icalvalue* icalvalue_new_class (enum icalproperty_class v){
576 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_PERIOD_VALUE); 448 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE);
577 449
578 icalvalue_set_period((icalvalue*)impl,v); 450 icalvalue_set_class((icalvalue*)impl,v);
579 return (icalvalue*)impl; 451 return (icalvalue*)impl;
580} 452}
581void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) { 453void icalvalue_set_class(icalvalue* value, enum icalproperty_class v) {
582 struct icalvalue_impl* impl; 454 struct icalvalue_impl* impl;
@@ -584,3 +456,3 @@ void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
584 456
585 icalerror_check_value_type(value, ICAL_PERIOD_VALUE); 457 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
586 impl = (struct icalvalue_impl*)value; 458 impl = (struct icalvalue_impl*)value;
@@ -588,3 +460,3 @@ void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
588 460
589 impl->data.v_period = v; 461 impl->data.v_enum = v;
590 462
@@ -592,7 +464,7 @@ void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
592} 464}
593struct icalperiodtype icalvalue_get_period(icalvalue* value) { 465enum icalproperty_class icalvalue_get_class(const icalvalue* value) {
594 466
595 icalerror_check_arg( (value!=0),"value"); 467 icalerror_check_arg( (value!=0),"value");
596 icalerror_check_value_type(value, ICAL_PERIOD_VALUE); 468 icalerror_check_value_type(value, ICAL_CLASS_VALUE);
597 return ((struct icalvalue_impl*)value)->data.v_period; 469 return ((struct icalvalue_impl*)value)->data.v_enum;
598} 470}
@@ -601,10 +473,10 @@ struct icalperiodtype icalvalue_get_period(icalvalue* value) {
601 473
602icalvalue* icalvalue_new_text (const char* v){ 474icalvalue* icalvalue_new_uri (const char* v){
603 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TEXT_VALUE); 475 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_URI_VALUE);
604 icalerror_check_arg_rz( (v!=0),"v"); 476 icalerror_check_arg_rz( (v!=0),"v");
605 477
606 icalvalue_set_text((icalvalue*)impl,v); 478 icalvalue_set_uri((icalvalue*)impl,v);
607 return (icalvalue*)impl; 479 return (icalvalue*)impl;
608} 480}
609void icalvalue_set_text(icalvalue* value, const char* v) { 481void icalvalue_set_uri(icalvalue* value, const char* v) {
610 struct icalvalue_impl* impl; 482 struct icalvalue_impl* impl;
@@ -613,3 +485,3 @@ void icalvalue_set_text(icalvalue* value, const char* v) {
613 485
614 icalerror_check_value_type(value, ICAL_TEXT_VALUE); 486 icalerror_check_value_type(value, ICAL_URI_VALUE);
615 impl = (struct icalvalue_impl*)value; 487 impl = (struct icalvalue_impl*)value;
@@ -627,6 +499,6 @@ void icalvalue_set_text(icalvalue* value, const char* v) {
627} 499}
628const char* icalvalue_get_text(icalvalue* value) { 500const char* icalvalue_get_uri(const icalvalue* value) {
629 501
630 icalerror_check_arg( (value!=0),"value"); 502 icalerror_check_arg( (value!=0),"value");
631 icalerror_check_value_type(value, ICAL_TEXT_VALUE); 503 icalerror_check_value_type(value, ICAL_URI_VALUE);
632 return ((struct icalvalue_impl*)value)->data.v_string; 504 return ((struct icalvalue_impl*)value)->data.v_string;
@@ -654,3 +526,3 @@ void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) {
654} 526}
655struct icaldurationtype icalvalue_get_duration(icalvalue* value) { 527struct icaldurationtype icalvalue_get_duration(const icalvalue* value) {
656 528
@@ -681,3 +553,3 @@ void icalvalue_set_boolean(icalvalue* value, int v) {
681} 553}
682int icalvalue_get_boolean(icalvalue* value) { 554int icalvalue_get_boolean(const icalvalue* value) {
683 555
@@ -690,10 +562,10 @@ int icalvalue_get_boolean(icalvalue* value) {
690 562
691icalvalue* icalvalue_new_uri (const char* v){ 563icalvalue* icalvalue_new_caladdress (const char* v){
692 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_URI_VALUE); 564 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE);
693 icalerror_check_arg_rz( (v!=0),"v"); 565 icalerror_check_arg_rz( (v!=0),"v");
694 566
695 icalvalue_set_uri((icalvalue*)impl,v); 567 icalvalue_set_caladdress((icalvalue*)impl,v);
696 return (icalvalue*)impl; 568 return (icalvalue*)impl;
697} 569}
698void icalvalue_set_uri(icalvalue* value, const char* v) { 570void icalvalue_set_caladdress(icalvalue* value, const char* v) {
699 struct icalvalue_impl* impl; 571 struct icalvalue_impl* impl;
@@ -702,3 +574,3 @@ void icalvalue_set_uri(icalvalue* value, const char* v) {
702 574
703 icalerror_check_value_type(value, ICAL_URI_VALUE); 575 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
704 impl = (struct icalvalue_impl*)value; 576 impl = (struct icalvalue_impl*)value;
@@ -716,6 +588,6 @@ void icalvalue_set_uri(icalvalue* value, const char* v) {
716} 588}
717const char* icalvalue_get_uri(icalvalue* value) { 589const char* icalvalue_get_caladdress(const icalvalue* value) {
718 590
719 icalerror_check_arg( (value!=0),"value"); 591 icalerror_check_arg( (value!=0),"value");
720 icalerror_check_value_type(value, ICAL_URI_VALUE); 592 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE);
721 return ((struct icalvalue_impl*)value)->data.v_string; 593 return ((struct icalvalue_impl*)value)->data.v_string;
@@ -725,9 +597,9 @@ const char* icalvalue_get_uri(icalvalue* value) {
725 597
726icalvalue* icalvalue_new_geo (struct icalgeotype v){ 598icalvalue* icalvalue_new_xlicclass (enum icalproperty_xlicclass v){
727 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE); 599 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_XLICCLASS_VALUE);
728 600
729 icalvalue_set_geo((icalvalue*)impl,v); 601 icalvalue_set_xlicclass((icalvalue*)impl,v);
730 return (icalvalue*)impl; 602 return (icalvalue*)impl;
731} 603}
732void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) { 604void icalvalue_set_xlicclass(icalvalue* value, enum icalproperty_xlicclass v) {
733 struct icalvalue_impl* impl; 605 struct icalvalue_impl* impl;
@@ -735,3 +607,3 @@ void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
735 607
736 icalerror_check_value_type(value, ICAL_GEO_VALUE); 608 icalerror_check_value_type(value, ICAL_XLICCLASS_VALUE);
737 impl = (struct icalvalue_impl*)value; 609 impl = (struct icalvalue_impl*)value;
@@ -739,3 +611,3 @@ void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
739 611
740 impl->data.v_geo = v; 612 impl->data.v_enum = v;
741 613
@@ -743,7 +615,34 @@ void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
743} 615}
744struct icalgeotype icalvalue_get_geo(icalvalue* value) { 616enum icalproperty_xlicclass icalvalue_get_xlicclass(const icalvalue* value) {
745 617
746 icalerror_check_arg( (value!=0),"value"); 618 icalerror_check_arg( (value!=0),"value");
747 icalerror_check_value_type(value, ICAL_GEO_VALUE); 619 icalerror_check_value_type(value, ICAL_XLICCLASS_VALUE);
748 return ((struct icalvalue_impl*)value)->data.v_geo; 620 return ((struct icalvalue_impl*)value)->data.v_enum;
621}
622
623
624
625icalvalue* icalvalue_new_action (enum icalproperty_action v){
626 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ACTION_VALUE);
627
628 icalvalue_set_action((icalvalue*)impl,v);
629 return (icalvalue*)impl;
630}
631void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
632 struct icalvalue_impl* impl;
633 icalerror_check_arg_rv( (value!=0),"value");
634
635 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
636 impl = (struct icalvalue_impl*)value;
637
638
639 impl->data.v_enum = v;
640
641 icalvalue_reset_kind(impl);
642}
643enum icalproperty_action icalvalue_get_action(const icalvalue* value) {
644
645 icalerror_check_arg( (value!=0),"value");
646 icalerror_check_value_type(value, ICAL_ACTION_VALUE);
647 return ((struct icalvalue_impl*)value)->data.v_enum;
749} 648}
@@ -770,3 +669,3 @@ void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) {
770} 669}
771struct icaltimetype icalvalue_get_datetime(icalvalue* value) { 670struct icaltimetype icalvalue_get_datetime(const icalvalue* value) {
772 671
@@ -797,3 +696,3 @@ void icalvalue_set_utcoffset(icalvalue* value, int v) {
797} 696}
798int icalvalue_get_utcoffset(icalvalue* value) { 697int icalvalue_get_utcoffset(const icalvalue* value) {
799 698
@@ -806,9 +705,9 @@ int icalvalue_get_utcoffset(icalvalue* value) {
806 705
807icalvalue* icalvalue_new_action (enum icalproperty_action v){ 706icalvalue* icalvalue_new_method (enum icalproperty_method v){
808 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_ACTION_VALUE); 707 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_METHOD_VALUE);
809 708
810 icalvalue_set_action((icalvalue*)impl,v); 709 icalvalue_set_method((icalvalue*)impl,v);
811 return (icalvalue*)impl; 710 return (icalvalue*)impl;
812} 711}
813void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) { 712void icalvalue_set_method(icalvalue* value, enum icalproperty_method v) {
814 struct icalvalue_impl* impl; 713 struct icalvalue_impl* impl;
@@ -816,3 +715,3 @@ void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
816 715
817 icalerror_check_value_type(value, ICAL_ACTION_VALUE); 716 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
818 impl = (struct icalvalue_impl*)value; 717 impl = (struct icalvalue_impl*)value;
@@ -824,6 +723,6 @@ void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
824} 723}
825enum icalproperty_action icalvalue_get_action(icalvalue* value) { 724enum icalproperty_method icalvalue_get_method(const icalvalue* value) {
826 725
827 icalerror_check_arg( (value!=0),"value"); 726 icalerror_check_arg( (value!=0),"value");
828 icalerror_check_value_type(value, ICAL_ACTION_VALUE); 727 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
829 return ((struct icalvalue_impl*)value)->data.v_enum; 728 return ((struct icalvalue_impl*)value)->data.v_enum;
@@ -832,23 +731,56 @@ enum icalproperty_action icalvalue_get_action(icalvalue* value) {
832 731
732int icalvalue_kind_is_valid(const icalvalue_kind kind)
733{
734 int i = 0;
735 do {
736 if (value_map[i].kind == kind)
737 return 1;
738 } while (value_map[i++].kind != ICAL_NO_VALUE);
833 739
834icalvalue* icalvalue_new_caladdress (const char* v){ 740 return 0;
835 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CALADDRESS_VALUE); 741}
742
743const char* icalvalue_kind_to_string(const icalvalue_kind kind)
744{
745 int i;
746
747 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
748 if (value_map[i].kind == kind) {
749 return value_map[i].name;
750 }
751 }
752
753 return 0;
754}
755
756icalvalue_kind icalvalue_string_to_kind(const char* str)
757{
758 int i;
759
760 for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
761 if (strcmp(value_map[i].name,str) == 0) {
762 return value_map[i].kind;
763 }
764 }
765
766 return value_map[i].kind;
767
768}
769
770icalvalue* icalvalue_new_x (const char* v){
771 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_X_VALUE);
836 icalerror_check_arg_rz( (v!=0),"v"); 772 icalerror_check_arg_rz( (v!=0),"v");
837 773
838 icalvalue_set_caladdress((icalvalue*)impl,v); 774 icalvalue_set_x((icalvalue*)impl,v);
839 return (icalvalue*)impl; 775 return (icalvalue*)impl;
840} 776}
841void icalvalue_set_caladdress(icalvalue* value, const char* v) { 777void icalvalue_set_x(icalvalue* impl, const char* v) {
842 struct icalvalue_impl* impl; 778 icalerror_check_arg_rv( (impl!=0),"value");
843 icalerror_check_arg_rv( (value!=0),"value");
844 icalerror_check_arg_rv( (v!=0),"v"); 779 icalerror_check_arg_rv( (v!=0),"v");
845 780
846 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); 781 if(impl->x_value!=0) {free((void*)impl->x_value);}
847 impl = (struct icalvalue_impl*)value;
848 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
849
850 782
851 impl->data.v_string = icalmemory_strdup(v); 783 impl->x_value = icalmemory_strdup(v);
852 784
853 if (impl->data.v_string == 0){ 785 if (impl->x_value == 0){
854 errno = ENOMEM; 786 errno = ENOMEM;
@@ -856,37 +788,50 @@ void icalvalue_set_caladdress(icalvalue* value, const char* v) {
856 788
857 789 }
858 icalvalue_reset_kind(impl); 790const char* icalvalue_get_x(const icalvalue* value) {
859}
860const char* icalvalue_get_caladdress(icalvalue* value) {
861 791
862 icalerror_check_arg( (value!=0),"value"); 792 icalerror_check_arg( (value!=0),"value");
863 icalerror_check_value_type(value, ICAL_CALADDRESS_VALUE); 793 icalerror_check_value_type(value, ICAL_X_VALUE);
864 return ((struct icalvalue_impl*)value)->data.v_string; 794 return value->x_value;
865} 795}
866 796
797/* Recur is a special case, so it is not auto generated. */
798icalvalue*
799icalvalue_new_recur (struct icalrecurrencetype v)
800{
801 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE);
802
803 icalvalue_set_recur((icalvalue*)impl,v);
867 804
868
869icalvalue* icalvalue_new_float (float v){
870 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_FLOAT_VALUE);
871
872 icalvalue_set_float((icalvalue*)impl,v);
873 return (icalvalue*)impl; 805 return (icalvalue*)impl;
874} 806}
875void icalvalue_set_float(icalvalue* value, float v) {
876 struct icalvalue_impl* impl;
877 icalerror_check_arg_rv( (value!=0),"value");
878
879 icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
880 impl = (struct icalvalue_impl*)value;
881 807
808void
809icalvalue_set_recur(icalvalue* impl, struct icalrecurrencetype v)
810{
811 icalerror_check_arg_rv( (impl!=0),"value");
812 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
882 813
883 impl->data.v_float = v; 814 if (impl->data.v_recur != 0){
815 free(impl->data.v_recur);
816 impl->data.v_recur = 0;
817 }
884 818
885 icalvalue_reset_kind(impl); 819 impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
820
821 if (impl->data.v_recur == 0){
822 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
823 return;
824 } else {
825 memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
826 }
827
886} 828}
887float icalvalue_get_float(icalvalue* value) {
888 829
830struct icalrecurrencetype
831icalvalue_get_recur(const icalvalue* value)
832{
889 icalerror_check_arg( (value!=0),"value"); 833 icalerror_check_arg( (value!=0),"value");
890 icalerror_check_value_type(value, ICAL_FLOAT_VALUE); 834 icalerror_check_value_type(value, ICAL_RECUR_VALUE);
891 return ((struct icalvalue_impl*)value)->data.v_float; 835
836 return *(value->data.v_recur);
892} 837}
@@ -895,87 +840,168 @@ float icalvalue_get_float(icalvalue* value) {
895 840
896icalvalue* icalvalue_new_requeststatus (struct icalreqstattype v){ 841
897 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_REQUESTSTATUS_VALUE); 842icalvalue*
898 843icalvalue_new_trigger (struct icaltriggertype v)
899 icalvalue_set_requeststatus((icalvalue*)impl,v); 844{
845 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
846
847 icalvalue_set_trigger((icalvalue*)impl,v);
848
900 return (icalvalue*)impl; 849 return (icalvalue*)impl;
901} 850}
902void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) { 851
903 struct icalvalue_impl* impl; 852void
853icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
854{
904 icalerror_check_arg_rv( (value!=0),"value"); 855 icalerror_check_arg_rv( (value!=0),"value");
905 856
906 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE); 857 if(!icaltime_is_null_time(v.time)){
907 impl = (struct icalvalue_impl*)value; 858 icalvalue_set_datetime(value,v.time);
859 value->kind = ICAL_DATETIME_VALUE;
860 } else {
861 icalvalue_set_duration(value,v.duration);
862 value->kind = ICAL_DURATION_VALUE;
863 }
864}
908 865
866struct icaltriggertype
867icalvalue_get_trigger(const icalvalue* impl)
868{
869 struct icaltriggertype tr;
909 870
910 impl->data.v_requeststatus = v; 871 icalerror_check_arg( (impl!=0),"value");
872 icalerror_check_arg( (impl!=0),"value");
911 873
912 icalvalue_reset_kind(impl); 874 if(impl->kind == ICAL_DATETIME_VALUE){
913} 875 tr.duration = icaldurationtype_from_int(0);
914struct icalreqstattype icalvalue_get_requeststatus(icalvalue* value) { 876 tr.time = impl->data.v_time;
877 } else if(impl->kind == ICAL_DURATION_VALUE){
878 tr.time = icaltime_null_time();
879 tr.duration = impl->data.v_duration;
880 } else {
881 tr.duration = icaldurationtype_from_int(0);
882 tr.time = icaltime_null_time();
883 icalerror_set_errno(ICAL_BADARG_ERROR);
884 }
915 885
916 icalerror_check_arg( (value!=0),"value"); 886 return tr;
917 icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
918 return ((struct icalvalue_impl*)value)->data.v_requeststatus;
919} 887}
920 888
889/* DATE-TIME-PERIOD is a special case, and is not auto generated */
921 890
891icalvalue*
892icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
893{
894 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);
895
896 icalvalue_set_datetimeperiod(impl,v);
922 897
923icalvalue* icalvalue_new_method (enum icalproperty_method v){
924 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_METHOD_VALUE);
925
926 icalvalue_set_method((icalvalue*)impl,v);
927 return (icalvalue*)impl; 898 return (icalvalue*)impl;
928} 899}
929void icalvalue_set_method(icalvalue* value, enum icalproperty_method v) {
930 struct icalvalue_impl* impl;
931 icalerror_check_arg_rv( (value!=0),"value");
932
933 icalerror_check_value_type(value, ICAL_METHOD_VALUE);
934 impl = (struct icalvalue_impl*)value;
935
936 900
937 impl->data.v_enum = v; 901void
902icalvalue_set_datetimeperiod(icalvalue* impl, struct icaldatetimeperiodtype v)
903{
904 icalerror_check_arg_rv( (impl!=0),"value");
905
906 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
938 907
939 icalvalue_reset_kind(impl); 908 if(!icaltime_is_null_time(v.time)){
909 if(!icaltime_is_valid_time(v.time)){
910 icalerror_set_errno(ICAL_BADARG_ERROR);
911 return;
912 }
913 impl->kind = ICAL_DATETIME_VALUE;
914 icalvalue_set_datetime(impl,v.time);
915 } else if (!icalperiodtype_is_null_period(v.period)) {
916 if(!icalperiodtype_is_valid_period(v.period)){
917 icalerror_set_errno(ICAL_BADARG_ERROR);
918 return;
919 }
920 impl->kind = ICAL_PERIOD_VALUE;
921 icalvalue_set_period(impl,v.period);
922 } else {
923 icalerror_set_errno(ICAL_BADARG_ERROR);
924 }
940} 925}
941enum icalproperty_method icalvalue_get_method(icalvalue* value) {
942 926
943 icalerror_check_arg( (value!=0),"value"); 927struct icaldatetimeperiodtype
944 icalerror_check_value_type(value, ICAL_METHOD_VALUE); 928icalvalue_get_datetimeperiod(const icalvalue* impl)
945 return ((struct icalvalue_impl*)value)->data.v_enum; 929{
946} 930 struct icaldatetimeperiodtype dtp;
931
932 icalerror_check_arg( (impl!=0),"value");
933 icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
934
935 if(impl->kind == ICAL_DATETIME_VALUE){
936 dtp.period = icalperiodtype_null_period();
937 dtp.time = impl->data.v_time;
938 } else if(impl->kind == ICAL_PERIOD_VALUE) {
939 dtp.period = impl->data.v_period;
940 dtp.time = icaltime_null_time();
941 } else {
942 dtp.period = icalperiodtype_null_period();
943 dtp.time = icaltime_null_time();
944 icalerror_set_errno(ICAL_BADARG_ERROR);
945 }
947 946
947 return dtp;
948}
948 949
949 950
950icalvalue* icalvalue_new_binary (const char* v){
951 struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_BINARY_VALUE);
952 icalerror_check_arg_rz( (v!=0),"v");
953 951
954 icalvalue_set_binary((icalvalue*)impl,v); 952icalvalue *
955 return (icalvalue*)impl; 953icalvalue_new_attach (icalattach *attach)
956} 954{
957void icalvalue_set_binary(icalvalue* value, const char* v) { 955 struct icalvalue_impl *impl;
958 struct icalvalue_impl* impl;
959 icalerror_check_arg_rv( (value!=0),"value");
960 icalerror_check_arg_rv( (v!=0),"v");
961 956
962 icalerror_check_value_type(value, ICAL_BINARY_VALUE); 957 icalerror_check_arg_rz ((attach != NULL), "attach");
963 impl = (struct icalvalue_impl*)value;
964 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
965 958
959 impl = icalvalue_new_impl (ICAL_ATTACH_VALUE);
960 if (!impl) {
961 errno = ENOMEM;
962 return NULL;
963 }
966 964
967 impl->data.v_string = icalmemory_strdup(v); 965 icalvalue_set_attach ((icalvalue *) impl, attach);
966 return (icalvalue *) impl;
967}
968 968
969 if (impl->data.v_string == 0){ 969void
970 errno = ENOMEM; 970icalvalue_set_attach (icalvalue *value, icalattach *attach)
971 } 971{
972 struct icalvalue_impl *impl;
973
974 icalerror_check_arg_rv ((value != NULL), "value");
975 icalerror_check_value_type (value, ICAL_ATTACH_VALUE);
976 icalerror_check_arg_rv ((attach != NULL), "attach");
977
978 impl = (struct icalvalue_impl *) value;
972 979
980 icalattach_ref (attach);
973 981
974 icalvalue_reset_kind(impl); 982 if (impl->data.v_attach)
983 icalattach_unref (impl->data.v_attach);
984
985 impl->data.v_attach = attach;
975} 986}
976const char* icalvalue_get_binary(icalvalue* value) {
977 987
978 icalerror_check_arg( (value!=0),"value"); 988icalattach *
979 icalerror_check_value_type(value, ICAL_BINARY_VALUE); 989icalvalue_get_attach (const icalvalue *value)
980 return ((struct icalvalue_impl*)value)->data.v_string; 990{
991 icalerror_check_arg_rz ((value != NULL), "value");
992 icalerror_check_value_type (value, ICAL_ATTACH_VALUE);
993
994 return value->data.v_attach;
981} 995}
996
997
998
999
1000
1001
1002
1003/* The remaining interfaces are 'new', 'set' and 'get' for each of the value
1004 types */
1005
1006
1007/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalderivedvalue.h b/libical/src/libical/icalderivedvalue.h
index 8324f04..7043ae7 100644
--- a/libical/src/libical/icalderivedvalue.h
+++ b/libical/src/libical/icalderivedvalue.h
@@ -36,4 +36,5 @@
36#include "icalperiod.h" 36#include "icalperiod.h"
37#include "icalattach.h"
37 38
38typedef void icalvalue; 39typedef struct icalvalue_impl icalvalue;
39 40
@@ -43,7 +44,3 @@ void icalvalue_set_x(icalvalue* value, const char* v);
43icalvalue* icalvalue_new_x(const char* v); 44icalvalue* icalvalue_new_x(const char* v);
44const char* icalvalue_get_x(icalvalue* value); 45const char* icalvalue_get_x(const icalvalue* value);
45
46icalvalue* icalvalue_new_attach (struct icalattachtype* v);
47void icalvalue_set_attach(icalvalue* value, struct icalattachtype* v);
48struct icalattachtype* icalvalue_get_attach(icalvalue* value);
49 46
@@ -51,3 +48,3 @@ icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
51void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); 48void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
52struct icalrecurrencetype icalvalue_get_recur(icalvalue* value); 49struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
53 50
@@ -55,3 +52,3 @@ icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
55void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); 52void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
56struct icaltriggertype icalvalue_get_trigger(icalvalue* value); 53struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
57 54
@@ -59,3 +56,7 @@ icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
59void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v); 56void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v);
60struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value); 57struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
58
59icalvalue *icalvalue_new_attach (icalattach *attach);
60void icalvalue_set_attach (icalvalue *value, icalattach *attach);
61icalattach *icalvalue_get_attach (const icalvalue *value);
61 62
@@ -63,3 +64,2 @@ void icalvalue_reset_kind(icalvalue* value);
63 64
64/* Everything below this line is machine generated. Do not edit. */
65typedef enum icalvalue_kind { 65typedef enum icalvalue_kind {
@@ -67,28 +67,29 @@ typedef enum icalvalue_kind {
67 ICAL_QUERY_VALUE=5001, 67 ICAL_QUERY_VALUE=5001,
68 ICAL_TRIGGER_VALUE=5002, 68 ICAL_DATE_VALUE=5002,
69 ICAL_STATUS_VALUE=5003, 69 ICAL_ATTACH_VALUE=5003,
70 ICAL_TRANSP_VALUE=5004, 70 ICAL_GEO_VALUE=5004,
71 ICAL_CLASS_VALUE=5005, 71 ICAL_STATUS_VALUE=5005,
72 ICAL_DATE_VALUE=5006, 72 ICAL_TRANSP_VALUE=5006,
73 ICAL_STRING_VALUE=5007, 73 ICAL_STRING_VALUE=5007,
74 ICAL_INTEGER_VALUE=5008, 74 ICAL_TEXT_VALUE=5008,
75 ICAL_PERIOD_VALUE=5009, 75 ICAL_REQUESTSTATUS_VALUE=5009,
76 ICAL_TEXT_VALUE=5010, 76 ICAL_BINARY_VALUE=5010,
77 ICAL_DURATION_VALUE=5011, 77 ICAL_PERIOD_VALUE=5011,
78 ICAL_BOOLEAN_VALUE=5012, 78 ICAL_FLOAT_VALUE=5012,
79 ICAL_URI_VALUE=5013, 79 ICAL_DATETIMEPERIOD_VALUE=5013,
80 ICAL_DATETIMEPERIOD_VALUE=5014, 80 ICAL_INTEGER_VALUE=5014,
81 ICAL_GEO_VALUE=5015, 81 ICAL_CLASS_VALUE=5015,
82 ICAL_DATETIME_VALUE=5016, 82 ICAL_URI_VALUE=5016,
83 ICAL_UTCOFFSET_VALUE=5017, 83 ICAL_DURATION_VALUE=5017,
84 ICAL_ATTACH_VALUE=5018, 84 ICAL_BOOLEAN_VALUE=5018,
85 ICAL_ACTION_VALUE=5019, 85 ICAL_X_VALUE=5019,
86 ICAL_CALADDRESS_VALUE=5020, 86 ICAL_CALADDRESS_VALUE=5020,
87 ICAL_X_VALUE=5021, 87 ICAL_TRIGGER_VALUE=5021,
88 ICAL_FLOAT_VALUE=5022, 88 ICAL_XLICCLASS_VALUE=5022,
89 ICAL_REQUESTSTATUS_VALUE=5023, 89 ICAL_RECUR_VALUE=5023,
90 ICAL_METHOD_VALUE=5024, 90 ICAL_ACTION_VALUE=5024,
91 ICAL_BINARY_VALUE=5025, 91 ICAL_DATETIME_VALUE=5025,
92 ICAL_RECUR_VALUE=5026, 92 ICAL_UTCOFFSET_VALUE=5026,
93 ICAL_NO_VALUE=5027 93 ICAL_METHOD_VALUE=5027,
94 ICAL_NO_VALUE=5028
94} icalvalue_kind ; 95} icalvalue_kind ;
@@ -150,7 +151,41 @@ typedef enum icalproperty_transp {
150 ICAL_TRANSP_OPAQUE = 10039, 151 ICAL_TRANSP_OPAQUE = 10039,
151 ICAL_TRANSP_TRANSPARENT = 10040, 152 ICAL_TRANSP_OPAQUENOCONFLICT = 10040,
152 ICAL_TRANSP_NONE = 10041 153 ICAL_TRANSP_TRANSPARENT = 10041,
154 ICAL_TRANSP_TRANSPARENTNOCONFLICT = 10042,
155 ICAL_TRANSP_NONE = 10043
153} icalproperty_transp; 156} icalproperty_transp;
154 157
155#define ICALPROPERTY_LAST_ENUM 10042 158typedef enum icalproperty_xlicclass {
159 ICAL_XLICCLASS_X = 10044,
160 ICAL_XLICCLASS_PUBLISHNEW = 10045,
161 ICAL_XLICCLASS_PUBLISHUPDATE = 10046,
162 ICAL_XLICCLASS_PUBLISHFREEBUSY = 10047,
163 ICAL_XLICCLASS_REQUESTNEW = 10048,
164 ICAL_XLICCLASS_REQUESTUPDATE = 10049,
165 ICAL_XLICCLASS_REQUESTRESCHEDULE = 10050,
166 ICAL_XLICCLASS_REQUESTDELEGATE = 10051,
167 ICAL_XLICCLASS_REQUESTNEWORGANIZER = 10052,
168 ICAL_XLICCLASS_REQUESTFORWARD = 10053,
169 ICAL_XLICCLASS_REQUESTSTATUS = 10054,
170 ICAL_XLICCLASS_REQUESTFREEBUSY = 10055,
171 ICAL_XLICCLASS_REPLYACCEPT = 10056,
172 ICAL_XLICCLASS_REPLYDECLINE = 10057,
173 ICAL_XLICCLASS_REPLYDELEGATE = 10058,
174 ICAL_XLICCLASS_REPLYCRASHERACCEPT = 10059,
175 ICAL_XLICCLASS_REPLYCRASHERDECLINE = 10060,
176 ICAL_XLICCLASS_ADDINSTANCE = 10061,
177 ICAL_XLICCLASS_CANCELEVENT = 10062,
178 ICAL_XLICCLASS_CANCELINSTANCE = 10063,
179 ICAL_XLICCLASS_CANCELALL = 10064,
180 ICAL_XLICCLASS_REFRESH = 10065,
181 ICAL_XLICCLASS_COUNTER = 10066,
182 ICAL_XLICCLASS_DECLINECOUNTER = 10067,
183 ICAL_XLICCLASS_MALFORMED = 10068,
184 ICAL_XLICCLASS_OBSOLETE = 10069,
185 ICAL_XLICCLASS_MISSEQUENCED = 10070,
186 ICAL_XLICCLASS_UNKNOWN = 10071,
187 ICAL_XLICCLASS_NONE = 10072
188} icalproperty_xlicclass;
189
190#define ICALPROPERTY_LAST_ENUM 10073
156 191
@@ -159,3 +194,3 @@ typedef enum icalproperty_transp {
159icalvalue* icalvalue_new_query(const char* v); 194icalvalue* icalvalue_new_query(const char* v);
160const char* icalvalue_get_query(icalvalue* value); 195const char* icalvalue_get_query(const icalvalue* value);
161void icalvalue_set_query(icalvalue* value, const char* v); 196void icalvalue_set_query(icalvalue* value, const char* v);
@@ -163,5 +198,17 @@ void icalvalue_set_query(icalvalue* value, const char* v);
163 198
199 /* DATE */
200icalvalue* icalvalue_new_date(struct icaltimetype v);
201struct icaltimetype icalvalue_get_date(const icalvalue* value);
202void icalvalue_set_date(icalvalue* value, struct icaltimetype v);
203
204
205 /* GEO */
206icalvalue* icalvalue_new_geo(struct icalgeotype v);
207struct icalgeotype icalvalue_get_geo(const icalvalue* value);
208void icalvalue_set_geo(icalvalue* value, struct icalgeotype v);
209
210
164 /* STATUS */ 211 /* STATUS */
165icalvalue* icalvalue_new_status(enum icalproperty_status v); 212icalvalue* icalvalue_new_status(enum icalproperty_status v);
166enum icalproperty_status icalvalue_get_status(icalvalue* value); 213enum icalproperty_status icalvalue_get_status(const icalvalue* value);
167void icalvalue_set_status(icalvalue* value, enum icalproperty_status v); 214void icalvalue_set_status(icalvalue* value, enum icalproperty_status v);
@@ -171,3 +218,3 @@ void icalvalue_set_status(icalvalue* value, enum icalproperty_status v);
171icalvalue* icalvalue_new_transp(enum icalproperty_transp v); 218icalvalue* icalvalue_new_transp(enum icalproperty_transp v);
172enum icalproperty_transp icalvalue_get_transp(icalvalue* value); 219enum icalproperty_transp icalvalue_get_transp(const icalvalue* value);
173void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v); 220void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v);
@@ -175,24 +222,24 @@ void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v);
175 222
176 /* CLASS */ 223 /* STRING */
177icalvalue* icalvalue_new_class(enum icalproperty_class v); 224icalvalue* icalvalue_new_string(const char* v);
178enum icalproperty_class icalvalue_get_class(icalvalue* value); 225const char* icalvalue_get_string(const icalvalue* value);
179void icalvalue_set_class(icalvalue* value, enum icalproperty_class v); 226void icalvalue_set_string(icalvalue* value, const char* v);
180 227
181 228
182 /* DATE */ 229 /* TEXT */
183icalvalue* icalvalue_new_date(struct icaltimetype v); 230icalvalue* icalvalue_new_text(const char* v);
184struct icaltimetype icalvalue_get_date(icalvalue* value); 231const char* icalvalue_get_text(const icalvalue* value);
185void icalvalue_set_date(icalvalue* value, struct icaltimetype v); 232void icalvalue_set_text(icalvalue* value, const char* v);
186 233
187 234
188 /* STRING */ 235 /* REQUEST-STATUS */
189icalvalue* icalvalue_new_string(const char* v); 236icalvalue* icalvalue_new_requeststatus(struct icalreqstattype v);
190const char* icalvalue_get_string(icalvalue* value); 237struct icalreqstattype icalvalue_get_requeststatus(const icalvalue* value);
191void icalvalue_set_string(icalvalue* value, const char* v); 238void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v);
192 239
193 240
194 /* INTEGER */ 241 /* BINARY */
195icalvalue* icalvalue_new_integer(int v); 242icalvalue* icalvalue_new_binary(const char* v);
196int icalvalue_get_integer(icalvalue* value); 243const char* icalvalue_get_binary(const icalvalue* value);
197void icalvalue_set_integer(icalvalue* value, int v); 244void icalvalue_set_binary(icalvalue* value, const char* v);
198 245
@@ -201,3 +248,3 @@ void icalvalue_set_integer(icalvalue* value, int v);
201icalvalue* icalvalue_new_period(struct icalperiodtype v); 248icalvalue* icalvalue_new_period(struct icalperiodtype v);
202struct icalperiodtype icalvalue_get_period(icalvalue* value); 249struct icalperiodtype icalvalue_get_period(const icalvalue* value);
203void icalvalue_set_period(icalvalue* value, struct icalperiodtype v); 250void icalvalue_set_period(icalvalue* value, struct icalperiodtype v);
@@ -205,18 +252,18 @@ void icalvalue_set_period(icalvalue* value, struct icalperiodtype v);
205 252
206 /* TEXT */ 253 /* FLOAT */
207icalvalue* icalvalue_new_text(const char* v); 254icalvalue* icalvalue_new_float(float v);
208const char* icalvalue_get_text(icalvalue* value); 255float icalvalue_get_float(const icalvalue* value);
209void icalvalue_set_text(icalvalue* value, const char* v); 256void icalvalue_set_float(icalvalue* value, float v);
210 257
211 258
212 /* DURATION */ 259 /* INTEGER */
213icalvalue* icalvalue_new_duration(struct icaldurationtype v); 260icalvalue* icalvalue_new_integer(int v);
214struct icaldurationtype icalvalue_get_duration(icalvalue* value); 261int icalvalue_get_integer(const icalvalue* value);
215void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v); 262void icalvalue_set_integer(icalvalue* value, int v);
216 263
217 264
218 /* BOOLEAN */ 265 /* CLASS */
219icalvalue* icalvalue_new_boolean(int v); 266icalvalue* icalvalue_new_class(enum icalproperty_class v);
220int icalvalue_get_boolean(icalvalue* value); 267enum icalproperty_class icalvalue_get_class(const icalvalue* value);
221void icalvalue_set_boolean(icalvalue* value, int v); 268void icalvalue_set_class(icalvalue* value, enum icalproperty_class v);
222 269
@@ -225,3 +272,3 @@ void icalvalue_set_boolean(icalvalue* value, int v);
225icalvalue* icalvalue_new_uri(const char* v); 272icalvalue* icalvalue_new_uri(const char* v);
226const char* icalvalue_get_uri(icalvalue* value); 273const char* icalvalue_get_uri(const icalvalue* value);
227void icalvalue_set_uri(icalvalue* value, const char* v); 274void icalvalue_set_uri(icalvalue* value, const char* v);
@@ -229,18 +276,24 @@ void icalvalue_set_uri(icalvalue* value, const char* v);
229 276
230 /* GEO */ 277 /* DURATION */
231icalvalue* icalvalue_new_geo(struct icalgeotype v); 278icalvalue* icalvalue_new_duration(struct icaldurationtype v);
232struct icalgeotype icalvalue_get_geo(icalvalue* value); 279struct icaldurationtype icalvalue_get_duration(const icalvalue* value);
233void icalvalue_set_geo(icalvalue* value, struct icalgeotype v); 280void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v);
234 281
235 282
236 /* DATE-TIME */ 283 /* BOOLEAN */
237icalvalue* icalvalue_new_datetime(struct icaltimetype v); 284icalvalue* icalvalue_new_boolean(int v);
238struct icaltimetype icalvalue_get_datetime(icalvalue* value); 285int icalvalue_get_boolean(const icalvalue* value);
239void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v); 286void icalvalue_set_boolean(icalvalue* value, int v);
240 287
241 288
242 /* UTC-OFFSET */ 289 /* CAL-ADDRESS */
243icalvalue* icalvalue_new_utcoffset(int v); 290icalvalue* icalvalue_new_caladdress(const char* v);
244int icalvalue_get_utcoffset(icalvalue* value); 291const char* icalvalue_get_caladdress(const icalvalue* value);
245void icalvalue_set_utcoffset(icalvalue* value, int v); 292void icalvalue_set_caladdress(icalvalue* value, const char* v);
293
294
295 /* X-LIC-CLASS */
296icalvalue* icalvalue_new_xlicclass(enum icalproperty_xlicclass v);
297enum icalproperty_xlicclass icalvalue_get_xlicclass(const icalvalue* value);
298void icalvalue_set_xlicclass(icalvalue* value, enum icalproperty_xlicclass v);
246 299
@@ -249,3 +302,3 @@ void icalvalue_set_utcoffset(icalvalue* value, int v);
249icalvalue* icalvalue_new_action(enum icalproperty_action v); 302icalvalue* icalvalue_new_action(enum icalproperty_action v);
250enum icalproperty_action icalvalue_get_action(icalvalue* value); 303enum icalproperty_action icalvalue_get_action(const icalvalue* value);
251void icalvalue_set_action(icalvalue* value, enum icalproperty_action v); 304void icalvalue_set_action(icalvalue* value, enum icalproperty_action v);
@@ -253,18 +306,12 @@ void icalvalue_set_action(icalvalue* value, enum icalproperty_action v);
253 306
254 /* CAL-ADDRESS */ 307 /* DATE-TIME */
255icalvalue* icalvalue_new_caladdress(const char* v); 308icalvalue* icalvalue_new_datetime(struct icaltimetype v);
256const char* icalvalue_get_caladdress(icalvalue* value); 309struct icaltimetype icalvalue_get_datetime(const icalvalue* value);
257void icalvalue_set_caladdress(icalvalue* value, const char* v); 310void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v);
258
259
260 /* FLOAT */
261icalvalue* icalvalue_new_float(float v);
262float icalvalue_get_float(icalvalue* value);
263void icalvalue_set_float(icalvalue* value, float v);
264 311
265 312
266 /* REQUEST-STATUS */ 313 /* UTC-OFFSET */
267icalvalue* icalvalue_new_requeststatus(struct icalreqstattype v); 314icalvalue* icalvalue_new_utcoffset(int v);
268struct icalreqstattype icalvalue_get_requeststatus(icalvalue* value); 315int icalvalue_get_utcoffset(const icalvalue* value);
269void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v); 316void icalvalue_set_utcoffset(icalvalue* value, int v);
270 317
@@ -273,11 +320,5 @@ void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v);
273icalvalue* icalvalue_new_method(enum icalproperty_method v); 320icalvalue* icalvalue_new_method(enum icalproperty_method v);
274enum icalproperty_method icalvalue_get_method(icalvalue* value); 321enum icalproperty_method icalvalue_get_method(const icalvalue* value);
275void icalvalue_set_method(icalvalue* value, enum icalproperty_method v); 322void icalvalue_set_method(icalvalue* value, enum icalproperty_method v);
276 323
277
278 /* BINARY */
279icalvalue* icalvalue_new_binary(const char* v);
280const char* icalvalue_get_binary(icalvalue* value);
281void icalvalue_set_binary(icalvalue* value, const char* v);
282
283#endif /*ICALVALUE_H*/ 324#endif /*ICALVALUE_H*/
diff --git a/libical/src/libical/icalduration.c b/libical/src/libical/icalduration.c
index 4468e0f..821a3b7 100644
--- a/libical/src/libical/icalduration.c
+++ b/libical/src/libical/icalduration.c
@@ -38,10 +38,5 @@
38 38
39#ifdef ICAL_NO_LIBICAL
40#define icalerror_set_errno(x)
41#define icalerror_check_arg_rv(x,y)
42#define icalerror_check_arg_re(x,y,z)
43#else
44#include "icalerror.h" 39#include "icalerror.h"
45#include "icalmemory.h" 40#include "icalmemory.h"
46#endif 41#include "icalvalue.h"
47 42
@@ -53,30 +48,28 @@ struct icaldurationtype icaldurationtype_from_int(int t)
53{ 48{
54 struct icaldurationtype dur; 49 struct icaldurationtype dur;
55 int used = 0; 50 int used = 0;
56 51
57 dur = icaldurationtype_null_duration(); 52 dur = icaldurationtype_null_duration();
58 53
59 if(t < 0){ 54 if(t < 0){
60 dur.is_neg = 1; 55 dur.is_neg = 1;
61 t = -t; 56 t = -t;
62 } 57 }
63 58
64 if (t % (60 * 60 * 24 * 7) == 0) { 59 if (t % (60 * 60 * 24 * 7) == 0) {
65 dur.weeks = t / (60 * 60 * 24 * 7); 60 dur.weeks = t / (60 * 60 * 24 * 7);
66 } else { 61 } else {
67 used += dur.weeks * (60 * 60 * 24 * 7); 62 used += dur.weeks * (60 * 60 * 24 * 7);
68 dur.days = (t - used) / (60 * 60 * 24); 63 dur.days = (t - used) / (60 * 60 * 24);
69 used += dur.days * (60 * 60 * 24); 64 used += dur.days * (60 * 60 * 24);
70 dur.hours = (t - used) / (60 * 60); 65 dur.hours = (t - used) / (60 * 60);
71 used += dur.hours * (60 * 60); 66 used += dur.hours * (60 * 60);
72 dur.minutes = (t - used) / (60); 67 dur.minutes = (t - used) / (60);
73 used += dur.minutes * (60); 68 used += dur.minutes * (60);
74 dur.seconds = (t - used); 69 dur.seconds = (t - used);
75 } 70 }
76 71
77 return dur; 72 return dur;
78} 73}
79 74
80#ifndef ICAL_NO_LIBICAL
81#include "icalvalue.h"
82struct icaldurationtype icaldurationtype_from_string(const char* str) 75struct icaldurationtype icaldurationtype_from_string(const char* str)
@@ -140,3 +133,3 @@ struct icaldurationtype icaldurationtype_from_string(const char* str)
140 /* Get all of the digits, not one at a time */ 133 /* Get all of the digits, not one at a time */
141 scan_size = sscanf((char*)(str+i),"%d",&digits); 134 scan_size = sscanf(&str[i],"%d",&digits);
142 if(scan_size == 0) goto error; 135 if(scan_size == 0) goto error;
@@ -189,5 +182,3 @@ struct icaldurationtype icaldurationtype_from_string(const char* str)
189 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 182 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
190 memset(&d, 0, sizeof(struct icaldurationtype)); 183 return icaldurationtype_bad_duration();
191 return d;
192
193} 184}
@@ -195,2 +186,3 @@ struct icaldurationtype icaldurationtype_from_string(const char* str)
195#define TMP_BUF_SIZE 1024 186#define TMP_BUF_SIZE 1024
187static
196void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size, 188void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size,
@@ -255,3 +247,3 @@ char* icaldurationtype_as_ical_string(struct icaldurationtype d)
255 } else { 247 } else {
256 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PTS0"); 248 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PT0S");
257 } 249 }
@@ -265,4 +257,2 @@ char* icaldurationtype_as_ical_string(struct icaldurationtype d)
265 257
266#endif
267
268 258
@@ -279,3 +269,3 @@ int icaldurationtype_as_int(struct icaldurationtype dur)
279 269
280struct icaldurationtype icaldurationtype_null_duration() 270struct icaldurationtype icaldurationtype_null_duration(void)
281{ 271{
@@ -297,2 +287,21 @@ int icaldurationtype_is_null_duration(struct icaldurationtype d)
297 287
288/* in icalvalue_new_from_string_with_error, we should not call
289 icaldurationtype_is_null_duration() to see if there is an error
290 condition. Null duration is perfectly valid for an alarm.
291 We cannot depend on the caller to check icalerrno either,
292 following the philosophy of unix errno. we set the is_neg
293 to -1 to indicate that this is a bad duration.
294*/
295struct icaldurationtype icaldurationtype_bad_duration()
296{
297 struct icaldurationtype d;
298 memset(&d,0,sizeof(struct icaldurationtype));
299 d.is_neg = -1;
300 return d;
301}
302
303int icaldurationtype_is_bad_duration(struct icaldurationtype d)
304{
305 return (d.is_neg == -1);
306}
298 307
@@ -318,3 +327,3 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
318 327
319 return icaldurationtype_from_int(t1t-t2t); 328 return icaldurationtype_from_int((int)(t1t-t2t));
320 329
diff --git a/libical/src/libical/icalduration.h b/libical/src/libical/icalduration.h
index dd6e311..0e64cad 100644
--- a/libical/src/libical/icalduration.h
+++ b/libical/src/libical/icalduration.h
@@ -47,4 +47,6 @@ int icaldurationtype_as_int(struct icaldurationtype duration);
47char* icaldurationtype_as_ical_string(struct icaldurationtype d); 47char* icaldurationtype_as_ical_string(struct icaldurationtype d);
48struct icaldurationtype icaldurationtype_null_duration(); 48struct icaldurationtype icaldurationtype_null_duration(void);
49struct icaldurationtype icaldurationtype_bad_duration(void);
49int icaldurationtype_is_null_duration(struct icaldurationtype d); 50int icaldurationtype_is_null_duration(struct icaldurationtype d);
51int icaldurationtype_is_bad_duration(struct icaldurationtype d);
50 52
diff --git a/libical/src/libical/icalenums.c b/libical/src/libical/icalenums.c
index 6751933..66c5ccd 100644
--- a/libical/src/libical/icalenums.c
+++ b/libical/src/libical/icalenums.c
@@ -36,6 +36,7 @@
36#include <assert.h> 36#include <assert.h>
37#include "icalmemory.h"
37 38
38 39/*** @brief Allowed request status values
39 40 */
40struct { 41static struct {
41 enum icalrequeststatus kind; 42 enum icalrequeststatus kind;
@@ -72,3 +73,7 @@ struct {
72 {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."}, 73 {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."},
74 {ICAL_3_15_INVCOMMAND, 3,15,"Invalid command."},
73 {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."}, 75 {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."},
76 {ICAL_4_1_STORE_ACCESS_DENIED, 4,1,"Store Access Denied."},
77 {ICAL_4_2_STORE_FAILED, 4,2,"Store Failed."},
78 {ICAL_4_3_STORE_NOT_FOUND, 4,3,"Store not found."},
74 {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."}, 79 {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."},
@@ -77,2 +82,4 @@ struct {
77 {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."}, 82 {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."},
83 {ICAL_6_1_CONTAINER_NOT_FOUND, 6,1,"Container not found."},
84 {ICAL_9_0_UNRECOGNIZED_COMMAND, 9,0,"An unrecognized command was received."},
78 {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"} 85 {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"}
@@ -81,5 +88,6 @@ struct {
81 88
89/*** @brief Return the descriptive text for a request status
90 */
82const char* icalenum_reqstat_desc(icalrequeststatus stat) 91const char* icalenum_reqstat_desc(icalrequeststatus stat)
83{ 92{
84
85 int i; 93 int i;
@@ -95,3 +103,22 @@ const char* icalenum_reqstat_desc(icalrequeststatus stat)
95 103
104/*** @brief Return the code for a request status
105 */
106char* icalenum_reqstat_code(icalrequeststatus stat)
107{
108 int i, major, minor;
109 char tmpbuf[36];
110
111 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
112 if ( request_status_map[i].kind == stat) {
113 major = request_status_map[i].major;
114 minor = request_status_map[i].minor;
115 sprintf(tmpbuf, "%i.%i", major, minor);
116 return icalmemory_tmp_copy(tmpbuf);
117 }
118 }
119 return NULL;
120}
96 121
122/*** @brief Return the major number for a request status
123 */
97short icalenum_reqstat_major(icalrequeststatus stat) 124short icalenum_reqstat_major(icalrequeststatus stat)
@@ -108,2 +135,4 @@ short icalenum_reqstat_major(icalrequeststatus stat)
108 135
136/*** @brief Return the minor number for a request status
137 */
109short icalenum_reqstat_minor(icalrequeststatus stat) 138short icalenum_reqstat_minor(icalrequeststatus stat)
@@ -121,2 +150,4 @@ short icalenum_reqstat_minor(icalrequeststatus stat)
121 150
151/*** @brief Return a request status for major/minor status numbers
152 */
122icalrequeststatus icalenum_num_to_reqstat(short major, short minor) 153icalrequeststatus icalenum_num_to_reqstat(short major, short minor)
diff --git a/libical/src/libical/icalenums.h b/libical/src/libical/icalenums.h
index 21031dd..b00907f 100644
--- a/libical/src/libical/icalenums.h
+++ b/libical/src/libical/icalenums.h
@@ -45,2 +45,3 @@ typedef enum icalcomponent_kind {
45 ICAL_VCALENDAR_COMPONENT, 45 ICAL_VCALENDAR_COMPONENT,
46 ICAL_VAGENDA_COMPONENT,
46 ICAL_VFREEBUSY_COMPONENT, 47 ICAL_VFREEBUSY_COMPONENT,
@@ -100,3 +101,7 @@ typedef enum icalrequeststatus {
100 ICAL_3_14_NOCAP_STATUS, 101 ICAL_3_14_NOCAP_STATUS,
102 ICAL_3_15_INVCOMMAND,
101 ICAL_4_0_BUSY_STATUS, 103 ICAL_4_0_BUSY_STATUS,
104 ICAL_4_1_STORE_ACCESS_DENIED,
105 ICAL_4_2_STORE_FAILED,
106 ICAL_4_3_STORE_NOT_FOUND,
102 ICAL_5_0_MAYBE_STATUS, 107 ICAL_5_0_MAYBE_STATUS,
@@ -104,3 +109,5 @@ typedef enum icalrequeststatus {
104 ICAL_5_2_NOSERVICE_STATUS, 109 ICAL_5_2_NOSERVICE_STATUS,
105 ICAL_5_3_NOSCHED_STATUS 110 ICAL_5_3_NOSCHED_STATUS,
111 ICAL_6_1_CONTAINER_NOT_FOUND,
112 ICAL_9_0_UNRECOGNIZED_COMMAND
106} icalrequeststatus; 113} icalrequeststatus;
@@ -112,2 +119,3 @@ short icalenum_reqstat_minor(icalrequeststatus stat);
112icalrequeststatus icalenum_num_to_reqstat(short major, short minor); 119icalrequeststatus icalenum_num_to_reqstat(short major, short minor);
120char* icalenum_reqstat_code(icalrequeststatus stat);
113 121
diff --git a/libical/src/libical/icalerror.c b/libical/src/libical/icalerror.c
index d44d37a..61043b2 100644
--- a/libical/src/libical/icalerror.c
+++ b/libical/src/libical/icalerror.c
@@ -31,9 +31,49 @@
31 31
32 #include <stdlib.h> /* for malloc() */
33 #include <string.h> /* for strcmp */
32#include "icalerror.h" 34#include "icalerror.h"
33 35
34#include <string.h> 36#ifdef HAVE_PTHREAD
37#include <pthread.h>
35 38
36icalerrorenum icalerrno; 39static pthread_key_t icalerrno_key;
40static pthread_once_t icalerrno_key_once = PTHREAD_ONCE_INIT;
41
42static void icalerrno_destroy(void* buf) {
43 free(buf);
44 pthread_setspecific(icalerrno_key, NULL);
45}
46
47static void icalerrno_key_alloc(void) {
48 pthread_key_create(&icalerrno_key, icalerrno_destroy);
49}
50
51icalerrorenum *icalerrno_return(void) {
52 icalerrorenum *_errno;
53
54 pthread_once(&icalerrno_key_once, icalerrno_key_alloc);
55
56 _errno = (icalerrorenum*) pthread_getspecific(icalerrno_key);
57
58 if (!_errno) {
59 _errno = malloc(sizeof(icalerrorenum));
60 *_errno = ICAL_NO_ERROR;
61 pthread_setspecific(icalerrno_key, _errno);
62 }
63 return _errno;
64}
65
66#else
67
68static icalerrorenum icalerrno_storage = ICAL_NO_ERROR;
69
70icalerrorenum *icalerrno_return(void) {
71 return &icalerrno_storage;
72}
73
74#endif
75
76
77static int foo;
37 78
38int foo;
39void icalerror_stop_here(void) 79void icalerror_stop_here(void)
@@ -81,3 +121,3 @@ struct icalerror_state {
81 121
82struct icalerror_state error_state_map[] = 122static struct icalerror_state error_state_map[] =
83{ 123{
@@ -85,2 +125,3 @@ struct icalerror_state error_state_map[] =
85 { ICAL_NEWFAILED_ERROR,ICAL_ERROR_DEFAULT}, 125 { ICAL_NEWFAILED_ERROR,ICAL_ERROR_DEFAULT},
126 { ICAL_ALLOCATION_ERROR,ICAL_ERROR_DEFAULT},
86 { ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_DEFAULT}, 127 { ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_DEFAULT},
@@ -106,2 +147,3 @@ static struct icalerror_string_map string_map[] =
106 { "NEWFAILED",ICAL_NEWFAILED_ERROR,"NEWFAILED: Failed to create a new object via a *_new() routine"}, 147 { "NEWFAILED",ICAL_NEWFAILED_ERROR,"NEWFAILED: Failed to create a new object via a *_new() routine"},
148 { "ALLOCATION",ICAL_ALLOCATION_ERROR,"ALLOCATION: Failed to allocate new memory"},
107 {"MALFORMEDDATA",ICAL_MALFORMEDDATA_ERROR,"MALFORMEDDATA: An input string was not correctly formed or a component has missing or extra properties"}, 149 {"MALFORMEDDATA",ICAL_MALFORMEDDATA_ERROR,"MALFORMEDDATA: An input string was not correctly formed or a component has missing or extra properties"},
@@ -170,3 +212,3 @@ void icalerror_set_error_state( icalerrorenum error,
170 212
171 for(i = ICAL_BADARG_ERROR; error_state_map[i].error!= ICAL_NO_ERROR;i++){ 213 for(i = 0; error_state_map[i].error!= ICAL_NO_ERROR;i++){
172 if(error_state_map[i].error == error){ 214 if(error_state_map[i].error == error){
@@ -181,3 +223,3 @@ icalerrorstate icalerror_get_error_state( icalerrorenum error)
181 223
182 for(i = ICAL_BADARG_ERROR; error_state_map[i].error!= ICAL_NO_ERROR;i++){ 224 for(i = 0; error_state_map[i].error!= ICAL_NO_ERROR;i++){
183 if(error_state_map[i].error == error){ 225 if(error_state_map[i].error == error){
diff --git a/libical/src/libical/icalerror.h b/libical/src/libical/icalerror.h
index 52f5ba9..826c8e8 100644
--- a/libical/src/libical/icalerror.h
+++ b/libical/src/libical/icalerror.h
@@ -40,3 +40,3 @@
40 40
41/* This routine is called before any error is triggered. It is called 41/** This routine is called before any error is triggered. It is called
42 by icalerror_set_errno, so it does not appear in all of the macros 42 by icalerror_set_errno, so it does not appear in all of the macros
@@ -48,3 +48,3 @@ void icalerror_crash_here(void);
48typedef enum icalerrorenum { 48typedef enum icalerrorenum {
49 49 ICAL_NO_ERROR, /* icalerrno may not be initialized - put it first so and pray that the compiler initialize things to zero */
50 ICAL_BADARG_ERROR, 50 ICAL_BADARG_ERROR,
@@ -58,4 +58,3 @@ typedef enum icalerrorenum {
58 ICAL_UNIMPLEMENTED_ERROR, 58 ICAL_UNIMPLEMENTED_ERROR,
59 ICAL_UNKNOWN_ERROR, /* Used for problems in input to icalerror_strerror()*/ 59 ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror()*/
60 ICAL_NO_ERROR
61 60
@@ -63,6 +62,10 @@ typedef enum icalerrorenum {
63 62
64/* The libical error enumeration, like errno*/ 63icalerrorenum * icalerrno_return(void);
65extern icalerrorenum icalerrno; 64#define icalerrno (*(icalerrno_return()))
66 65
67/* If true, libicl aborts after a call to icalerror_set_error*/ 66/** If true, libicl aborts after a call to icalerror_set_error
67 *
68 * @warning NOT THREAD SAFE -- recommended that you do not change
69 * this in a multithreaded program.
70 */
68extern int icalerror_errors_are_fatal; 71extern int icalerror_errors_are_fatal;
@@ -79,2 +82,3 @@ extern int icalerror_errors_are_fatal;
79void icalerror_clear_errno(void); 82void icalerror_clear_errno(void);
83void _icalerror_set_errno(icalerrorenum);
80 84
@@ -96,2 +100,3 @@ icalerrorstate icalerror_get_error_state( icalerrorenum error);
96icalerrno = x; \ 100icalerrno = x; \
101 fprintf(stderr,"Ical error # %d\n", x); \
97if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \ 102if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \
@@ -101,5 +106,5 @@ if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \
101 assert(0); \ 106 assert(0); \
102} 107}
103#else 108#else
104void icalerror_set_errno(icalerrorenum); 109void icalerror_set_errno(icalerrorenum x);
105#endif 110#endif
diff --git a/libical/src/libical/icallangbind.c b/libical/src/libical/icallangbind.c
index c079034..1a3ad48 100644
--- a/libical/src/libical/icallangbind.c
+++ b/libical/src/libical/icallangbind.c
@@ -24,7 +24,10 @@
24#include "icalmemory.h" 24#include "icalmemory.h"
25#include "icalvalue.h"
25#include <stdlib.h> 26#include <stdlib.h>
26#include <string.h> 27#include <string.h>
27#include <stdio.h>
28 28
29int snprintf(char *str, size_t n, char const *fmt, ...); 29#ifdef WIN32
30#define snprintf _snprintf
31#define strcasecmp stricmp
32#endif
30 33
@@ -43,7 +46,24 @@ int icallangbind_access_array(int* array, int index) {
43 46
47/** Iterators to fetch parameters given property */
44 48
49icalparameter* icallangbind_get_first_parameter(icalproperty *prop)
45 50
46/* LIke icalcomponent_get_first_component, buut takes a string for the 51{
52 icalparameter_kind kind = ICAL_ANY_PARAMETER;
53
54 return icalproperty_get_first_parameter(prop,kind);
55}
56
57icalparameter* icallangbind_get_next_parameter(icalproperty *prop)
58{
59 icalparameter_kind kind = ICAL_ANY_PARAMETER;
60
61 return icalproperty_get_next_parameter(prop,kind);
62}
63
64
65/** Like icalcomponent_get_first_component(), but takes a string for the
47 kind and can iterate over X properties as if each X name was a 66 kind and can iterate over X properties as if each X name was a
48 seperate kind */ 67 seperate kind */
68
49icalproperty* icallangbind_get_first_property(icalcomponent *c, 69icalproperty* icallangbind_get_first_property(icalcomponent *c,
@@ -134,2 +154,3 @@ icalcomponent* icallangbind_get_next_component(icalcomponent *c,
134 154
155
135const char* icallangbind_property_eval_string(icalproperty* prop, char* sep) 156const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
@@ -155,3 +176,3 @@ const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
155 APPENDC('\''); 176 APPENDC('\'');
156 APPENDS(icalenum_property_kind_to_string(icalproperty_isa(prop))); 177 APPENDS(icalproperty_kind_to_string(icalproperty_isa(prop)));
157 APPENDC('\''); 178 APPENDC('\'');
@@ -162,3 +183,3 @@ const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
162 APPENDC('\''); 183 APPENDC('\'');
163 APPENDS(icalenum_value_kind_to_string(icalvalue_isa(value))); 184 APPENDS(icalvalue_kind_to_string(icalvalue_isa(value)));
164 APPENDC('\''); 185 APPENDC('\'');
@@ -271,2 +292,3 @@ int icallangbind_string_to_open_flag(const char* str)
271 else if (strcmp(str,"w") == 0) {return O_WRONLY;} 292 else if (strcmp(str,"w") == 0) {return O_WRONLY;}
293 else if (strcmp(str,"w+") == 0) {return O_RDWR|O_CREAT;}
272 else if (strcmp(str,"a") == 0) {return O_WRONLY|O_APPEND;} 294 else if (strcmp(str,"a") == 0) {return O_WRONLY|O_APPEND;}
@@ -275 +297,16 @@ int icallangbind_string_to_open_flag(const char* str)
275 297
298
299const char* icallangbind_quote_as_ical(const char* str)
300{
301 size_t buf_size = 2 * strlen(str);
302
303 /* assume every char could be quoted */
304 char* buf = icalmemory_new_buffer(buf_size);
305 int result;
306
307 result = icalvalue_encode_ical_string(str, buf, buf_size);
308
309 icalmemory_add_tmp_buffer(buf);
310
311 return buf;
312}
diff --git a/libical/src/libical/icallangbind.h b/libical/src/libical/icallangbind.h
index 2ed5003..fed3626 100644
--- a/libical/src/libical/icallangbind.h
+++ b/libical/src/libical/icallangbind.h
@@ -43,2 +43,5 @@ icalcomponent* icallangbind_get_next_component(icalcomponent *c,
43 43
44icalparameter* icallangbind_get_first_parameter(icalproperty *prop);
45
46icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
44 47
@@ -48,2 +51,4 @@ const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
48int icallangbind_string_to_open_flag(const char* str); 51int icallangbind_string_to_open_flag(const char* str);
52
53const char* icallangbind_quote_as_ical(const char* str);
49#endif /*__ICALLANGBIND_H__*/ 54#endif /*__ICALLANGBIND_H__*/
diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c
index 297ead8..058ef37 100644
--- a/libical/src/libical/icalmemory.c
+++ b/libical/src/libical/icalmemory.c
@@ -34,3 +34,7 @@
34 34
35/* libical often passes strings back to the caller. To make these 35/**
36 * @file icalmemory.c
37 * @brief Common memory management routines.
38 *
39 * libical often passes strings back to the caller. To make these
36 * interfaces simple, I did not want the caller to have to pass in a 40 * interfaces simple, I did not want the caller to have to pass in a
@@ -43,3 +47,4 @@
43 * several buffers active simultaneously, which is handy when creating 47 * several buffers active simultaneously, which is handy when creating
44 * string representations of components. */ 48 * string representations of components.
49 */
45 50
@@ -62,29 +67,95 @@
62 67
63#define BUFFER_RING_SIZE 25 68#ifdef WIN32
69#include <windows.h>
70#endif
71
72#define BUFFER_RING_SIZE 2500
64#define MIN_BUFFER_SIZE 200 73#define MIN_BUFFER_SIZE 200
65 74
75
76/* HACK. Not threadsafe */
77
78typedef struct {
79 int pos;
80 void *ring[BUFFER_RING_SIZE];
81} buffer_ring;
82
66void icalmemory_free_tmp_buffer (void* buf); 83void icalmemory_free_tmp_buffer (void* buf);
84void icalmemory_free_ring_byval(buffer_ring *br);
67 85
86static buffer_ring* global_buffer_ring = 0;
68 87
69/* HACK. Not threadsafe */ 88#ifdef HAVE_PTHREAD
70void* buffer_ring[BUFFER_RING_SIZE]; 89#include <pthread.h>
71int buffer_pos = -1;
72int initialized = 0;
73 90
74/* Add an existing buffer to the buffer ring */ 91static pthread_key_t ring_key;
75void icalmemory_add_tmp_buffer(void* buf) 92static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT;
76{ 93
77 /* I don't think I need this -- I think static arrays are 94static void ring_destroy(void * buf) {
78 initialized to 0 as a standard part of C, but I am not sure. */ 95 if (buf) icalmemory_free_ring_byval((buffer_ring *) buf);
79 if (initialized == 0){ 96 pthread_setspecific(ring_key, NULL);
97}
98
99static void ring_key_alloc(void) {
100 pthread_key_create(&ring_key, ring_destroy);
101}
102#endif
103
104
105static buffer_ring * buffer_ring_new(void) {
106 buffer_ring *br;
80 int i; 107 int i;
108
109 br = (buffer_ring *)malloc(sizeof(buffer_ring));
110
81 for(i=0; i<BUFFER_RING_SIZE; i++){ 111 for(i=0; i<BUFFER_RING_SIZE; i++){
82 buffer_ring[i] = 0; 112 br->ring[i] = 0;
83 } 113 }
84 initialized = 1; 114 br->pos = 0;
115 return(br);
116}
117
118
119#ifdef HAVE_PTHREAD
120static buffer_ring* get_buffer_ring_pthread(void) {
121 buffer_ring *br;
122
123 pthread_once(&ring_key_once, ring_key_alloc);
124
125 br = pthread_getspecific(ring_key);
126
127 if (!br) {
128 br = buffer_ring_new();
129 pthread_setspecific(ring_key, br);
85 } 130 }
131 return(br);
132}
133#endif
134
135/* get buffer ring via a single global for a non-threaded program */
136static buffer_ring* get_buffer_ring_global(void) {
137 if (global_buffer_ring == 0) {
138 global_buffer_ring = buffer_ring_new();
139 }
140 return(global_buffer_ring);
141}
142
143static buffer_ring *get_buffer_ring(void) {
144#ifdef HAVE_PTHREAD
145 return(get_buffer_ring_pthread());
146#else
147 return get_buffer_ring_global();
148#endif
149}
150
151
152/** Add an existing buffer to the buffer ring */
153void icalmemory_add_tmp_buffer(void* buf)
154{
155 buffer_ring *br = get_buffer_ring();
156
86 157
87 /* Wrap around the ring */ 158 /* Wrap around the ring */
88 if(++buffer_pos == BUFFER_RING_SIZE){ 159 if(++(br->pos) == BUFFER_RING_SIZE){
89 buffer_pos = 0; 160 br->pos = 0;
90 } 161 }
@@ -92,5 +163,4 @@ void icalmemory_add_tmp_buffer(void* buf)
92 /* Free buffers as their slots are overwritten */ 163 /* Free buffers as their slots are overwritten */
93 if ( buffer_ring[buffer_pos] != 0){ 164 if ( br->ring[br->pos] != 0){
94 free( buffer_ring[buffer_pos]); 165 free( br->ring[br->pos]);
95 buffer_ring[buffer_pos] = 0;
96 } 166 }
@@ -98,7 +168,11 @@ void icalmemory_add_tmp_buffer(void* buf)
98 /* Assign the buffer to a slot */ 168 /* Assign the buffer to a slot */
99 buffer_ring[buffer_pos] = buf; 169 br->ring[br->pos] = buf;
100} 170}
101 171
102/* Create a new temporary buffer on the ring. Libical owns these and 172
103 wil deallocate them. */ 173/**
174 * Create a new temporary buffer on the ring. Libical owns these and
175 * will deallocate them.
176 */
177
104void* 178void*
@@ -126,15 +200,19 @@ icalmemory_tmp_buffer (size_t size)
126 200
127void icalmemory_free_ring() 201/** get rid of this buffer ring */
128{ 202void icalmemory_free_ring_byval(buffer_ring *br) {
129
130 int i; 203 int i;
131 for(i=0; i<BUFFER_RING_SIZE; i++){ 204 for(i=0; i<BUFFER_RING_SIZE; i++){
132 if ( buffer_ring[i] != 0){ 205 if ( br->ring[i] != 0){
133 free( buffer_ring[i]); 206 free( br->ring[i]);
134 } 207 }
135 buffer_ring[i] = 0; 208 }
136 } 209 free(br);
210}
137 211
138 initialized = 1; 212void icalmemory_free_ring()
213{
214 buffer_ring *br;
215 br = get_buffer_ring();
139 216
217 icalmemory_free_ring_byval(br);
140} 218}
@@ -143,3 +221,3 @@ void icalmemory_free_ring()
143 221
144/* Like strdup, but the buffer is on the ring. */ 222/** Like strdup, but the buffer is on the ring. */
145char* 223char*
@@ -172,4 +250,6 @@ icalmemory_free_tmp_buffer (void* buf)
172 250
173/* These buffer routines create memory the old fashioned way -- so the 251/*
174 caller will have to delocate the new memory */ 252 * These buffer routines create memory the old fashioned way -- so the
253 * caller will have to deallocate the new memory
254 */
175 255
diff --git a/libical/src/libical/icalmemory.h b/libical/src/libical/icalmemory.h
index f833c6c..7c42566 100644
--- a/libical/src/libical/icalmemory.h
+++ b/libical/src/libical/icalmemory.h
@@ -28,9 +28,7 @@
28 28
29#ifndef WIN32
29#include <sys/types.h> /* for size_t */ 30#include <sys/types.h> /* for size_t */
30 31#else
31// Eugen C. <eug@thekompany.com>
32#ifdef _WIN32
33#include <stddef.h> 32#include <stddef.h>
34#endif 33#endif
35// Eugen C. <eug@thekompany.com>
36 34
@@ -42,3 +40,3 @@ char* icalmemory_tmp_copy(const char* str);
42 40
43/* Add an externally allocated buffer to the ring. */ 41/** Add an externally allocated buffer to the ring. */
44void icalmemory_add_tmp_buffer(void*); 42void icalmemory_add_tmp_buffer(void*);
@@ -46,3 +44,3 @@ void icalmemory_add_tmp_buffer(void*);
46 44
47/* Free all memory used in the ring */ 45/** Free all memory used in the ring */
48void icalmemory_free_ring(void); 46void icalmemory_free_ring(void);
@@ -57,3 +55,4 @@ void icalmemory_free_buffer(void* buf);
57 55
58/* icalmemory_append_string will copy the string 'string' to the 56/**
57 icalmemory_append_string will copy the string 'string' to the
59 buffer 'buf' starting at position 'pos', reallocing 'buf' if it is 58 buffer 'buf' starting at position 'pos', reallocing 'buf' if it is
@@ -73,3 +72,3 @@ void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
73 72
74/* icalmemory_append_char is similar, but is appends a character instead of a string */ 73/** icalmemory_append_char is similar, but is appends a character instead of a string */
75void icalmemory_append_char(char** buf, char** pos, size_t* buf_size, 74void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
@@ -77,4 +76,4 @@ void icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
77 76
78/* A wrapper around strdup. Partly to trap calls to strdup, partly 77/** A wrapper around strdup. Partly to trap calls to strdup, partly
79 because in -ansi, gcc on Red Hat claims that strudup is undeclared */ 78 because in -ansi, gcc on Red Hat claims that strdup is undeclared */
80char* icalmemory_strdup(const char *s); 79char* icalmemory_strdup(const char *s);
diff --git a/libical/src/libical/icalmime.c b/libical/src/libical/icalmime.c
index 7021746..12443c3 100644
--- a/libical/src/libical/icalmime.c
+++ b/libical/src/libical/icalmime.c
@@ -36,4 +36,2 @@
36 36
37int snprintf(char *str, size_t n, char const *fmt, ...);
38
39#ifdef DMALLOC 37#ifdef DMALLOC
@@ -42,2 +40,6 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
42 40
41#ifdef WIN32
42#define snprintf _snprintf
43#define strcasecmp stricmp
44#endif
43 45
diff --git a/libical/src/libical/icalparameter.c b/libical/src/libical/icalparameter.c
index 156ecdb..759306f 100644
--- a/libical/src/libical/icalparameter.c
+++ b/libical/src/libical/icalparameter.c
@@ -80,7 +80,4 @@ icalparameter_new (icalparameter_kind kind)
80void 80void
81icalparameter_free (icalparameter* parameter) 81icalparameter_free (icalparameter* param)
82{ 82{
83 struct icalparameter_impl * impl;
84
85 impl = (struct icalparameter_impl*)parameter;
86 83
@@ -91,6 +88,6 @@ icalparameter_free (icalparameter* parameter)
91#ifdef ICAL_FREE_ON_LIST_IS_ERROR 88#ifdef ICAL_FREE_ON_LIST_IS_ERROR
92 icalerror_assert( (impl->parent ==0),"Tried to free a parameter that is still attached to a component. "); 89 icalerror_assert( (param->parent ==0),"Tried to free a parameter that is still attached to a component. ");
93 90
94#else 91#else
95 if(impl->parent !=0){ 92 if(param->parent !=0){
96 return; 93 return;
@@ -100,15 +97,15 @@ icalparameter_free (icalparameter* parameter)
100 97
101 if (impl->string != 0){ 98 if (param->string != 0){
102 free ((void*)impl->string); 99 free ((void*)param->string);
103 } 100 }
104 101
105 if (impl->x_name != 0){ 102 if (param->x_name != 0){
106 free ((void*)impl->x_name); 103 free ((void*)param->x_name);
107 } 104 }
108 105
109 memset(impl,0,sizeof(impl)); 106 memset(param,0,sizeof(param));
110 107
111 impl->parent = 0; 108 param->parent = 0;
112 impl->id[0] = 'X'; 109 param->id[0] = 'X';
113 free(impl); 110 free(param);
114} 111}
@@ -118,11 +115,9 @@ icalparameter_free (icalparameter* parameter)
118icalparameter* 115icalparameter*
119icalparameter_new_clone(icalparameter* param) 116icalparameter_new_clone(icalparameter* old)
120{ 117{
121 struct icalparameter_impl *old;
122 struct icalparameter_impl *new; 118 struct icalparameter_impl *new;
123 119
124 old = (struct icalparameter_impl *)param;
125 new = icalparameter_new_impl(old->kind); 120 new = icalparameter_new_impl(old->kind);
126 121
127 icalerror_check_arg_rz((param!=0),"param"); 122 icalerror_check_arg_rz((old!=0),"param");
128 123
@@ -199,6 +194,16 @@ icalparameter* icalparameter_new_from_string(const char *str)
199 194
195/**
196 * Return a string representation of the parameter according to RFC2445.
197 *
198 * param= param-name "=" param-value
199 * param-name= iana-token / x-token
200 * param-value= paramtext /quoted-string
201 * paramtext= *SAFE-SHARE
202 * quoted-string= DQUOTE *QSAFE-CHARE DQUOTE
203 * QSAFE-CHAR= any character except CTLs and DQUOTE
204 * SAFE-CHAR= any character except CTLs, DQUOTE. ";", ":", ","
205 */
200char* 206char*
201icalparameter_as_ical_string (icalparameter* parameter) 207icalparameter_as_ical_string (icalparameter* param)
202{ 208{
203 struct icalparameter_impl* impl;
204 size_t buf_size = 1024; 209 size_t buf_size = 1024;
@@ -209,3 +214,3 @@ icalparameter_as_ical_string (icalparameter* parameter)
209 214
210 icalerror_check_arg_rz( (parameter!=0), "parameter"); 215 icalerror_check_arg_rz( (param!=0), "parameter");
211 216
@@ -219,8 +224,7 @@ icalparameter_as_ical_string (icalparameter* parameter)
219 buf_ptr = buf; 224 buf_ptr = buf;
220 impl = (struct icalparameter_impl*)parameter;
221 225
222 if(impl->kind == ICAL_X_PARAMETER) { 226 if(param->kind == ICAL_X_PARAMETER) {
223 227
224 icalmemory_append_string(&buf, &buf_ptr, &buf_size, 228 icalmemory_append_string(&buf, &buf_ptr, &buf_size,
225 icalparameter_get_xname(impl)); 229 icalparameter_get_xname(param));
226 230
@@ -228,6 +232,6 @@ icalparameter_as_ical_string (icalparameter* parameter)
228 232
229 kind_string = icalparameter_kind_to_string(impl->kind); 233 kind_string = icalparameter_kind_to_string(param->kind);
230 234
231 if (impl->kind == ICAL_NO_PARAMETER || 235 if (param->kind == ICAL_NO_PARAMETER ||
232 impl->kind == ICAL_ANY_PARAMETER || 236 param->kind == ICAL_ANY_PARAMETER ||
233 kind_string == 0) 237 kind_string == 0)
@@ -246,6 +250,16 @@ icalparameter_as_ical_string (icalparameter* parameter)
246 250
247 if(impl->string !=0){ 251 if(param->string !=0){
248 icalmemory_append_string(&buf, &buf_ptr, &buf_size, impl->string); 252 int qm = 0;
249 } else if (impl->data != 0){ 253
250 const char* str = icalparameter_enum_to_string(impl->data); 254 /* Encapsulate the property in quotes if necessary */
255 if (strpbrk(param->string, ";:,") != 0) {
256 icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
257 qm = 1;
258 }
259 icalmemory_append_string(&buf, &buf_ptr, &buf_size, param->string);
260 if (qm == 1) {
261 icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"');
262 }
263 } else if (param->data != 0){
264 const char* str = icalparameter_enum_to_string(param->data);
251 icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); 265 icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
@@ -280,3 +294,3 @@ icalparameter_isa (icalparameter* parameter)
280 294
281 return ((struct icalparameter_impl *)parameter)->kind; 295 return parameter->kind;
282} 296}
@@ -304,3 +318,2 @@ icalparameter_set_xname (icalparameter* param, const char* v)
304{ 318{
305 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
306 icalerror_check_arg_rv( (param!=0),"param"); 319 icalerror_check_arg_rv( (param!=0),"param");
@@ -308,9 +321,9 @@ icalparameter_set_xname (icalparameter* param, const char* v)
308 321
309 if (impl->x_name != 0){ 322 if (param->x_name != 0){
310 free((void*)impl->x_name); 323 free((void*)param->x_name);
311 } 324 }
312 325
313 impl->x_name = icalmemory_strdup(v); 326 param->x_name = icalmemory_strdup(v);
314 327
315 if (impl->x_name == 0){ 328 if (param->x_name == 0){
316 errno = ENOMEM; 329 errno = ENOMEM;
@@ -323,6 +336,5 @@ icalparameter_get_xname (icalparameter* param)
323{ 336{
324 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
325 icalerror_check_arg_rz( (param!=0),"param"); 337 icalerror_check_arg_rz( (param!=0),"param");
326 338
327 return impl->x_name; 339 return param->x_name;
328} 340}
@@ -332,4 +344,2 @@ icalparameter_set_xvalue (icalparameter* param, const char* v)
332{ 344{
333 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
334
335 icalerror_check_arg_rv( (param!=0),"param"); 345 icalerror_check_arg_rv( (param!=0),"param");
@@ -337,9 +347,9 @@ icalparameter_set_xvalue (icalparameter* param, const char* v)
337 347
338 if (impl->string != 0){ 348 if (param->string != 0){
339 free((void*)impl->string); 349 free((void*)param->string);
340 } 350 }
341 351
342 impl->string = icalmemory_strdup(v); 352 param->string = icalmemory_strdup(v);
343 353
344 if (impl->string == 0){ 354 if (param->string == 0){
345 errno = ENOMEM; 355 errno = ENOMEM;
@@ -352,8 +362,5 @@ icalparameter_get_xvalue (icalparameter* param)
352{ 362{
353 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
354
355 icalerror_check_arg_rz( (param!=0),"param"); 363 icalerror_check_arg_rz( (param!=0),"param");
356 364
357 return impl->string; 365 return param->string;
358
359} 366}
@@ -363,7 +370,5 @@ void icalparameter_set_parent(icalparameter* param,
363{ 370{
364 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
365
366 icalerror_check_arg_rv( (param!=0),"param"); 371 icalerror_check_arg_rv( (param!=0),"param");
367 372
368 impl->parent = property; 373 param->parent = property;
369} 374}
@@ -372,7 +377,5 @@ icalproperty* icalparameter_get_parent(icalparameter* param)
372{ 377{
373 struct icalparameter_impl *impl = (struct icalparameter_impl*)param;
374
375 icalerror_check_arg_rz( (param!=0),"param"); 378 icalerror_check_arg_rz( (param!=0),"param");
376 379
377 return impl->parent; 380 return param->parent;
378} 381}
diff --git a/libical/src/libical/icalparameter.h b/libical/src/libical/icalparameter.h
index 3f3b59f..f3d64ab 100644
--- a/libical/src/libical/icalparameter.h
+++ b/libical/src/libical/icalparameter.h
@@ -34,3 +34,3 @@
34/* Declared in icalderivedparameter.h */ 34/* Declared in icalderivedparameter.h */
35/*typedef void icalparameter;*/ 35/*typedef struct icalparameter_impl icalparameter;*/
36 36
diff --git a/libical/src/libical/icalparser.c b/libical/src/libical/icalparser.c
index b5824d5..5c4296b 100644
--- a/libical/src/libical/icalparser.c
+++ b/libical/src/libical/icalparser.c
@@ -1,2 +1,2 @@
1/* -*- Mode: C -*- 1/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*-
2 ====================================================================== 2 ======================================================================
@@ -40,5 +40,3 @@
40 40
41#include "icalparser.h"
42#include "pvl.h" 41#include "pvl.h"
43#include "icalmemory.h"
44#include "icalerror.h" 42#include "icalerror.h"
@@ -54,9 +52,24 @@
54 52
55int snprintf(char *str, size_t n, char const *fmt, ...); 53#include "icalmemory.h"
54#include "icalparser.h"
55
56#ifdef HAVE_WCTYPE_H
57# include <wctype.h>
58/* Some systems have an imcomplete implementation on wctype (FreeBSD,
59 * Darwin). Cope with that. */
60# ifndef HAVE_ISWSPACE
61# define iswspace isspace
62# endif
63#else
64# ifndef HAVE_ISWSPACE
65# define iswspace isspace
66# endif
67#endif
56 68
57extern icalvalue* icalparser_yy_value; 69#ifdef WIN32
58void set_parser_value_state(icalvalue_kind kind); 70#define snprintf _snprintf
59int ical_yyparse(void); 71#define strcasecmp stricmp
72#endif
60 73
61char* icalparser_get_next_char(char c, char *str); 74char* icalparser_get_next_char(char c, char *str, int qm);
62char* icalparser_get_next_parameter(char* line,char** end); 75char* icalparser_get_next_parameter(char* line,char** end);
@@ -83,3 +96,3 @@ struct icalparser_impl
83 void *line_gen_data; 96 void *line_gen_data;
84 97
85}; 98};
@@ -102,2 +115,3 @@ icalparser* icalparser_new(void)
102 impl->buffer_full = 0; 115 impl->buffer_full = 0;
116 impl->continuation_line = 0;
103 impl->lineno = 0; 117 impl->lineno = 0;
@@ -112,10 +126,9 @@ void icalparser_free(icalparser* parser)
112{ 126{
113 struct icalparser_impl* impl = (struct icalparser_impl*)parser;
114 icalcomponent *c; 127 icalcomponent *c;
115 128
116 if (impl->root_component != 0){ 129 if (parser->root_component != 0){
117 icalcomponent_free(impl->root_component); 130 icalcomponent_free(parser->root_component);
118 } 131 }
119 132
120 while( (c=pvl_pop(impl->components)) != 0){ 133 while( (c=pvl_pop(parser->components)) != 0){
121 icalcomponent_free(c); 134 icalcomponent_free(c);
@@ -123,5 +136,5 @@ void icalparser_free(icalparser* parser)
123 136
124 pvl_free(impl->components); 137 pvl_free(parser->components);
125 138
126 free(impl); 139 free(parser);
127} 140}
@@ -130,5 +143,3 @@ void icalparser_set_gen_data(icalparser* parser, void* data)
130{ 143{
131 struct icalparser_impl* impl = (struct icalparser_impl*)parser; 144 parser->line_gen_data = data;
132
133 impl->line_gen_data = data;
134} 145}
@@ -142,3 +153,3 @@ icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind,
142 153
143char* icalparser_get_next_char(char c, char *str) 154char* icalparser_get_next_char(char c, char *str, int qm)
144{ 155{
@@ -146,19 +157,19 @@ char* icalparser_get_next_char(char c, char *str)
146 char* p; 157 char* p;
147
148 158
149 for(p=str; *p!=0; p++){ 159 for(p=str; *p!=0; p++){
150 160 if (qm == 1) {
151 if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){ 161 if ( quote_mode == 0 && *p=='"' && *(p-1) != '\\' ){
152 quote_mode =1; 162 quote_mode =1;
153 continue; 163 continue;
154 } 164 }
155 165
156 if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){ 166 if ( quote_mode == 1 && *p=='"' && *(p-1) != '\\' ){
157 quote_mode =0; 167 quote_mode =0;
158 continue; 168 continue;
159 } 169 }
160 170 }
161 if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){ 171
162 return p; 172 if (quote_mode == 0 && *p== c && *(p-1) != '\\' ){
163 } 173 return p;
174 }
164 175
@@ -169,6 +180,7 @@ char* icalparser_get_next_char(char c, char *str)
169 180
170/* make a new tmp buffer out of a substring */ 181
171char* make_segment(char* start, char* end) 182/** make a new tmp buffer out of a substring */
183static char* make_segment(char* start, char* end)
172{ 184{
173 char *buf; 185 char *buf, *tmp;
174 size_t size = (size_t)end - (size_t)start; 186 size_t size = (size_t)end - (size_t)start;
@@ -180,60 +192,13 @@ char* make_segment(char* start, char* end)
180 *(buf+size) = 0; 192 *(buf+size) = 0;
193
194 tmp = (buf+size);
195 while ( *tmp == '\0' || iswspace(*tmp) )
196 {
197 *tmp = 0;
198 tmp--;
199 }
181 200
182 return buf; 201 return buf;
183
184} 202}
185 203
186const char* input_buffer;
187const char* input_buffer_p;
188//#define min(a,b) ((a) < (b) ? (a) : (b))
189
190int icalparser_flex_input(char* buf, int max_size)
191{
192 int n = max_size; // = min(max_size,strlen(input_buffer_p));
193 if ( n < ((int )strlen(input_buffer_p)) )
194 n = strlen(input_buffer_p);
195 if (n > 0){
196 memcpy(buf, input_buffer_p, n);
197 input_buffer_p += n;
198 return n;
199 } else {
200 return 0;
201 }
202}
203
204void icalparser_clear_flex_input(void)
205{
206 input_buffer_p = input_buffer+strlen(input_buffer);
207}
208
209/* Call the flex/bison parser to parse a complex value */
210
211icalvalue* icalparser_parse_value(icalvalue_kind kind,
212 const char* str, icalproperty** error)
213{
214 int r;
215 input_buffer_p = input_buffer = str;
216
217 set_parser_value_state(kind);
218 icalparser_yy_value = 0;
219
220 r = ical_yyparse();
221
222 /* Error. Parse failed */
223 if( icalparser_yy_value == 0 || r != 0){
224
225 if(icalparser_yy_value !=0){
226 icalvalue_free(icalparser_yy_value);
227 icalparser_yy_value = 0;
228 }
229
230 return 0;
231 }
232
233 if (error != 0){
234 *error = 0;
235 }
236
237 return icalparser_yy_value;
238}
239 204
@@ -245,4 +210,4 @@ char* icalparser_get_prop_name(char* line, char** end)
245 210
246 p = icalparser_get_next_char(';',line); 211 p = icalparser_get_next_char(';',line,1);
247 v = icalparser_get_next_char(':',line); 212 v = icalparser_get_next_char(':',line,1);
248 if (p== 0 && v == 0) { 213 if (p== 0 && v == 0) {
@@ -264,5 +229,5 @@ char* icalparser_get_prop_name(char* line, char** end)
264 229
230
265char* icalparser_get_param_name(char* line, char **end) 231char* icalparser_get_param_name(char* line, char **end)
266{ 232{
267
268 char* next; 233 char* next;
@@ -270,3 +235,3 @@ char* icalparser_get_param_name(char* line, char **end)
270 235
271 next = icalparser_get_next_char('=',line); 236 next = icalparser_get_next_char('=',line,1);
272 237
@@ -278,9 +243,18 @@ char* icalparser_get_param_name(char* line, char **end)
278 *end = next+1; 243 *end = next+1;
244 if (**end == '"') {
245 *end = *end+1;
246 next = icalparser_get_next_char('"',*end,0);
247 if (next == 0) {
248 return 0;
249 }
250
251 *end = make_segment(*end,next);
252 }
253
279 return str; 254 return str;
280
281} 255}
282 256
257
283char* icalparser_get_next_paramvalue(char* line, char **end) 258char* icalparser_get_next_paramvalue(char* line, char **end)
284{ 259{
285
286 char* next; 260 char* next;
@@ -288,3 +262,3 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
288 262
289 next = icalparser_get_next_char(',',line); 263 next = icalparser_get_next_char(',',line,1);
290 264
@@ -301,6 +275,7 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
301 } 275 }
302
303} 276}
304 277
305/* A property may have multiple values, if the values are seperated by 278
279/**
280 A property may have multiple values, if the values are seperated by
306 commas in the content line. This routine will look for the next 281 commas in the content line. This routine will look for the next
@@ -320,3 +295,3 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
320 295
321 next = icalparser_get_next_char(',',p); 296 next = icalparser_get_next_char(',',p,1);
322 297
@@ -342,2 +317,11 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
342 } 317 }
318 /* ignore all , for query value. select dtstart, dtend etc ... */
319 else if( kind == ICAL_QUERY_VALUE) {
320 if ( next != 0) {
321 p = next+1;
322 continue;
323 }
324 else
325 break;
326 }
343 327
@@ -381,4 +365,4 @@ char* icalparser_get_next_parameter(char* line,char** end)
381 365
382 v = icalparser_get_next_char(':',line); 366 v = icalparser_get_next_char(':',line,1);
383 next = icalparser_get_next_char(';', line); 367 next = icalparser_get_next_char(';', line,1);
384 368
@@ -388,3 +372,3 @@ char* icalparser_get_next_parameter(char* line,char** end)
388 if (next == 0 || next > v) { 372 if (next == 0 || next > v) {
389 next = icalparser_get_next_char(':', line); 373 next = icalparser_get_next_char(':', line,1);
390 } 374 }
@@ -401,5 +385,7 @@ char* icalparser_get_next_parameter(char* line,char** end)
401 385
402/* Get a single property line, from the property name through the
403 final new line, and include any continuation lines */
404 386
387/**
388 * Get a single property line, from the property name through the
389 * final new line, and include any continuation lines
390 */
405char* icalparser_get_line(icalparser *parser, 391char* icalparser_get_line(icalparser *parser,
@@ -409,5 +395,3 @@ char* icalparser_get_line(icalparser *parser,
409 char *line_p; 395 char *line_p;
410 struct icalparser_impl* impl = (struct icalparser_impl*)parser; 396 size_t buf_size = parser->tmp_buf_size;
411 size_t buf_size = impl->tmp_buf_size;
412
413 397
@@ -417,3 +401,3 @@ char* icalparser_get_line(icalparser *parser,
417 /* Read lines by calling line_gen_func and putting the data into 401 /* Read lines by calling line_gen_func and putting the data into
418 impl->temp. If the line is a continuation line ( begins with a 402 parser->temp. If the line is a continuation line ( begins with a
419 space after a newline ) then append the data onto line and read 403 space after a newline ) then append the data onto line and read
@@ -431,3 +415,3 @@ char* icalparser_get_line(icalparser *parser,
431 output. This may be left over from a previous call */ 415 output. This may be left over from a previous call */
432 if (impl->temp[0] != '\0' ) { 416 if (parser->temp[0] != '\0' ) {
433 417
@@ -436,8 +420,8 @@ char* icalparser_get_line(icalparser *parser,
436 read later, because the line is not finished */ 420 read later, because the line is not finished */
437 if (impl->temp[impl->tmp_buf_size-1] == 0 && 421 if (parser->temp[parser->tmp_buf_size-1] == 0 &&
438 impl->temp[impl->tmp_buf_size-2] != '\n'&& 422 parser->temp[parser->tmp_buf_size-2] != '\n'&&
439 impl->temp[impl->tmp_buf_size-2] != 0 ){ 423 parser->temp[parser->tmp_buf_size-2] != 0 ){
440 impl->buffer_full = 1; 424 parser->buffer_full = 1;
441 } else { 425 } else {
442 impl->buffer_full = 0; 426 parser->buffer_full = 0;
443 } 427 }
@@ -445,5 +429,5 @@ char* icalparser_get_line(icalparser *parser,
445 /* Copy the temp to the output and clear the temp buffer. */ 429 /* Copy the temp to the output and clear the temp buffer. */
446 if(impl->continuation_line==1){ 430 if(parser->continuation_line==1){
447 /* back up the pointer to erase the continuation characters */ 431 /* back up the pointer to erase the continuation characters */
448 impl->continuation_line = 0; 432 parser->continuation_line = 0;
449 line_p--; 433 line_p--;
@@ -456,15 +440,15 @@ char* icalparser_get_line(icalparser *parser,
456 icalmemory_append_string(&line,&line_p,&buf_size, 440 icalmemory_append_string(&line,&line_p,&buf_size,
457 impl->temp+1); 441 parser->temp+1);
458 442
459 } else { 443 } else {
460 icalmemory_append_string(&line,&line_p,&buf_size,impl->temp); 444 icalmemory_append_string(&line,&line_p,&buf_size,parser->temp);
461 } 445 }
462 446
463 impl->temp[0] = '\0' ; 447 parser->temp[0] = '\0' ;
464 } 448 }
465 449
466 impl->temp[impl->tmp_buf_size-1] = 1; /* Mark end of buffer */ 450 parser->temp[parser->tmp_buf_size-1] = 1; /* Mark end of buffer */
467 451
468 /****** Here is where the routine gets string data ******************/ 452 /****** Here is where the routine gets string data ******************/
469 if ((*line_gen_func)(impl->temp,impl->tmp_buf_size,impl->line_gen_data) 453 if ((*line_gen_func)(parser->temp,parser->tmp_buf_size,parser->line_gen_data)
470 ==0){/* Get more data */ 454 ==0){/* Get more data */
@@ -473,3 +457,3 @@ char* icalparser_get_line(icalparser *parser,
473 any more data from the last call to line_ge_func*/ 457 any more data from the last call to line_ge_func*/
474 if (impl->temp[0] == '\0'){ 458 if (parser->temp[0] == '\0'){
475 459
@@ -492,8 +476,7 @@ char* icalparser_get_line(icalparser *parser,
492 476
493 if ( line_p > line+1 && *(line_p-1) == '\n' 477 if ( line_p > line+1 && *(line_p-1) == '\n' && parser->temp[0] == ' ') {
494 && (impl->temp[0] == ' ' || impl->temp[0] == '\t') ) {
495 478
496 impl->continuation_line = 1; 479 parser->continuation_line = 1;
497 480
498 } else if ( impl->buffer_full == 1 ) { 481 } else if ( parser->buffer_full == 1 ) {
499 482
@@ -521,2 +504,8 @@ char* icalparser_get_line(icalparser *parser,
521 504
505 while ( (*line_p == '\0' || iswspace(*line_p)) && line_p > line )
506 {
507 *line_p = '\0';
508 line_p--;
509 }
510
522 return line; 511 return line;
@@ -525,3 +514,3 @@ char* icalparser_get_line(icalparser *parser,
525 514
526void insert_error(icalcomponent* comp, char* text, 515static void insert_error(icalcomponent* comp, char* text,
527 char* message, icalparameter_xlicerrortype type) 516 char* message, icalparameter_xlicerrortype type)
@@ -544,3 +533,4 @@ void insert_error(icalcomponent* comp, char* text,
544 533
545int line_is_blank(char* line){ 534
535static int line_is_blank(char* line){
546 int i=0; 536 int i=0;
@@ -566,4 +556,4 @@ icalcomponent* icalparser_parse(icalparser *parser,
566 icalcomponent *root=0; 556 icalcomponent *root=0;
567 struct icalparser_impl *impl = (struct icalparser_impl*)parser;
568 icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); 557 icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
558 int cont;
569 559
@@ -582,4 +572,4 @@ icalcomponent* icalparser_parse(icalparser *parser,
582 572
583 assert(impl->root_component == 0); 573 assert(parser->root_component == 0);
584 assert(pvl_count(impl->components) ==0); 574 assert(pvl_count(parser->components) ==0);
585 575
@@ -608,6 +598,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
608 } 598 }
599 cont = 0;
609 if(line != 0){ 600 if(line != 0){
610 free(line); 601 free(line);
602 cont = 1;
611 } 603 }
612 } while ( line != 0); 604 } while ( cont );
613 605
@@ -623,3 +615,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
623{ 615{
624 char *p;
625 char *str; 616 char *str;
@@ -633,3 +624,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
633 624
634 struct icalparser_impl *impl = (struct icalparser_impl*)parser;
635 icalerror_check_arg_rz((parser != 0),"parser"); 625 icalerror_check_arg_rz((parser != 0),"parser");
@@ -639,3 +629,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
639 { 629 {
640 impl->state = ICALPARSER_ERROR; 630 parser->state = ICALPARSER_ERROR;
641 return 0; 631 return 0;
@@ -657,3 +647,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
657 /* Could not get a property name */ 647 /* Could not get a property name */
658 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 648 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
659 649
@@ -665,3 +655,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
665 tail = 0; 655 tail = 0;
666 impl->state = ICALPARSER_ERROR; 656 parser->state = ICALPARSER_ERROR;
667 return 0; 657 return 0;
@@ -675,2 +665,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
675 665
666
676 if(strcmp(str,"BEGIN") == 0){ 667 if(strcmp(str,"BEGIN") == 0){
@@ -679,3 +670,4 @@ icalcomponent* icalparser_add_line(icalparser* parser,
679 670
680 impl->level++; 671
672 parser->level++;
681 str = icalparser_get_next_value(end,&end, value_kind); 673 str = icalparser_get_next_value(end,&end, value_kind);
@@ -685,3 +677,6 @@ icalcomponent* icalparser_add_line(icalparser* parser,
685 677
678
686 if (comp_kind == ICAL_NO_COMPONENT){ 679 if (comp_kind == ICAL_NO_COMPONENT){
680
681
687 c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT); 682 c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);
@@ -699,5 +694,5 @@ icalcomponent* icalparser_add_line(icalparser* parser,
699 694
700 pvl_push(impl->components,c); 695 pvl_push(parser->components,c);
701 696
702 impl->state = ICALPARSER_BEGIN_COMP; 697 parser->state = ICALPARSER_BEGIN_COMP;
703 return 0; 698 return 0;
@@ -707,3 +702,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
707 702
708 impl->level--; 703 parser->level--;
709 str = icalparser_get_next_value(end,&end, value_kind); 704 str = icalparser_get_next_value(end,&end, value_kind);
@@ -711,8 +706,8 @@ icalcomponent* icalparser_add_line(icalparser* parser,
711 /* Pop last component off of list and add it to the second-to-last*/ 706 /* Pop last component off of list and add it to the second-to-last*/
712 impl->root_component = pvl_pop(impl->components); 707 parser->root_component = pvl_pop(parser->components);
713 708
714 tail = pvl_data(pvl_tail(impl->components)); 709 tail = pvl_data(pvl_tail(parser->components));
715 710
716 if(tail != 0){ 711 if(tail != 0){
717 icalcomponent_add_component(tail,impl->root_component); 712 icalcomponent_add_component(tail,parser->root_component);
718 } 713 }
@@ -722,17 +717,17 @@ icalcomponent* icalparser_add_line(icalparser* parser,
722 /* Return the component if we are back to the 0th level */ 717 /* Return the component if we are back to the 0th level */
723 if (impl->level == 0){ 718 if (parser->level == 0){
724 icalcomponent *rtrn; 719 icalcomponent *rtrn;
725 720
726 if(pvl_count(impl->components) != 0){ 721 if(pvl_count(parser->components) != 0){
727 /* There are still components on the stack -- this means 722 /* There are still components on the stack -- this means
728 that one of them did not have a proper "END" */ 723 that one of them did not have a proper "END" */
729 pvl_push(impl->components,impl->root_component); 724 pvl_push(parser->components,parser->root_component);
730 icalparser_clean(parser); /* may reset impl->root_component*/ 725 icalparser_clean(parser); /* may reset parser->root_component*/
731 } 726 }
732 727
733 assert(pvl_count(impl->components) == 0); 728 assert(pvl_count(parser->components) == 0);
734 729
735 impl->state = ICALPARSER_SUCCESS; 730 parser->state = ICALPARSER_SUCCESS;
736 rtrn = impl->root_component; 731 rtrn = parser->root_component;
737 impl->root_component = 0; 732 parser->root_component = 0;
738 return rtrn; 733 return rtrn;
@@ -740,3 +735,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
740 } else { 735 } else {
741 impl->state = ICALPARSER_END_COMP; 736 parser->state = ICALPARSER_END_COMP;
742 return 0; 737 return 0;
@@ -749,4 +744,4 @@ icalcomponent* icalparser_add_line(icalparser* parser,
749 744
750 if(pvl_data(pvl_tail(impl->components)) == 0){ 745 if(pvl_data(pvl_tail(parser->components)) == 0){
751 impl->state = ICALPARSER_ERROR; 746 parser->state = ICALPARSER_ERROR;
752 return 0; 747 return 0;
@@ -769,3 +764,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
769 if (prop != 0){ 764 if (prop != 0){
770 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 765 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
771 766
@@ -782,3 +777,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
782 } else { 777 } else {
783 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 778 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
784 779
@@ -788,3 +783,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
788 tail = 0; 783 tail = 0;
789 impl->state = ICALPARSER_ERROR; 784 parser->state = ICALPARSER_ERROR;
790 return 0; 785 return 0;
@@ -798,3 +793,2 @@ icalcomponent* icalparser_add_line(icalparser* parser,
798 793
799 p = 0;
800 while(1) { 794 while(1) {
@@ -816,3 +810,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
816 icalparameter_kind kind; 810 icalparameter_kind kind;
817 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 811 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
818 812
@@ -847,3 +841,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
847 tail = 0; 841 tail = 0;
848 impl->state = ICALPARSER_ERROR; 842 parser->state = ICALPARSER_ERROR;
849 return 0; 843 return 0;
@@ -857,3 +851,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
857 tail = 0; 851 tail = 0;
858 impl->state = ICALPARSER_ERROR; 852 parser->state = ICALPARSER_ERROR;
859 continue; 853 continue;
@@ -887,3 +881,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
887 tail = 0; 881 tail = 0;
888 impl->state = ICALPARSER_ERROR; 882 parser->state = ICALPARSER_ERROR;
889 return 0; 883 return 0;
@@ -921,3 +915,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
921 icalproperty* clone = icalproperty_new_clone(prop); 915 icalproperty* clone = icalproperty_new_clone(prop);
922 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 916 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
923 917
@@ -935,3 +929,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
935 icalproperty_kind prop_kind = icalproperty_isa(prop); 929 icalproperty_kind prop_kind = icalproperty_isa(prop);
936 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 930 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
937 931
@@ -949,3 +943,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
949 tail = 0; 943 tail = 0;
950 impl->state = ICALPARSER_ERROR; 944 parser->state = ICALPARSER_ERROR;
951 return 0; 945 return 0;
@@ -963,3 +957,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
963 icalproperty_kind prop_kind = icalproperty_isa(prop); 957 icalproperty_kind prop_kind = icalproperty_isa(prop);
964 icalcomponent *tail = pvl_data(pvl_tail(impl->components)); 958 icalcomponent *tail = pvl_data(pvl_tail(parser->components));
965 959
@@ -976,3 +970,3 @@ icalcomponent* icalparser_add_line(icalparser* parser,
976 tail = 0; 970 tail = 0;
977 impl->state = ICALPARSER_ERROR; 971 parser->state = ICALPARSER_ERROR;
978 return 0; 972 return 0;
@@ -989,10 +983,10 @@ icalcomponent* icalparser_add_line(icalparser* parser,
989 983
990 if (pvl_data(pvl_tail(impl->components)) == 0 && 984 if (pvl_data(pvl_tail(parser->components)) == 0 &&
991 impl->level == 0){ 985 parser->level == 0){
992 /* HACK. Does this clause ever get executed? */ 986 /* HACK. Does this clause ever get executed? */
993 impl->state = ICALPARSER_SUCCESS; 987 parser->state = ICALPARSER_SUCCESS;
994 assert(0); 988 assert(0);
995 return impl->root_component; 989 return parser->root_component;
996 } else { 990 } else {
997 impl->state = ICALPARSER_IN_PROGRESS; 991 parser->state = ICALPARSER_IN_PROGRESS;
998 return 0; 992 return 0;
@@ -1004,4 +998,3 @@ icalparser_state icalparser_get_state(icalparser* parser)
1004{ 998{
1005 struct icalparser_impl* impl = (struct icalparser_impl*) parser; 999 return parser->state;
1006 return impl->state;
1007 1000
@@ -1011,3 +1004,2 @@ icalcomponent* icalparser_clean(icalparser* parser)
1011{ 1004{
1012 struct icalparser_impl* impl = (struct icalparser_impl*) parser;
1013 icalcomponent *tail; 1005 icalcomponent *tail;
@@ -1019,3 +1011,3 @@ icalcomponent* icalparser_clean(icalparser* parser)
1019 1011
1020 while((tail=pvl_data(pvl_tail(impl->components))) != 0){ 1012 while((tail=pvl_data(pvl_tail(parser->components))) != 0){
1021 1013
@@ -1026,10 +1018,10 @@ icalcomponent* icalparser_clean(icalparser* parser)
1026 1018
1027 impl->root_component = pvl_pop(impl->components); 1019 parser->root_component = pvl_pop(parser->components);
1028 tail=pvl_data(pvl_tail(impl->components)); 1020 tail=pvl_data(pvl_tail(parser->components));
1029 1021
1030 if(tail != 0){ 1022 if(tail != 0){
1031 if(icalcomponent_get_parent(impl->root_component)!=0){ 1023 if(icalcomponent_get_parent(parser->root_component)!=0){
1032 icalerror_warn("icalparser_clean is trying to attach a component for the second time"); 1024 icalerror_warn("icalparser_clean is trying to attach a component for the second time");
1033 } else { 1025 } else {
1034 icalcomponent_add_component(tail,impl->root_component); 1026 icalcomponent_add_component(tail,parser->root_component);
1035 } 1027 }
@@ -1039,3 +1031,3 @@ icalcomponent* icalparser_clean(icalparser* parser)
1039 1031
1040 return impl->root_component; 1032 return parser->root_component;
1041 1033
@@ -1048,3 +1040,4 @@ struct slg_data {
1048 1040
1049char* string_line_generator(char *out, size_t buf_size, void *d) 1041
1042char* icalparser_string_line_generator(char *out, size_t buf_size, void *d)
1050{ 1043{
@@ -1102,3 +1095,3 @@ icalcomponent* icalparser_parse_string(const char* str)
1102 1095
1103 c = icalparser_parse(p,string_line_generator); 1096 c = icalparser_parse(p,icalparser_string_line_generator);
1104 1097
diff --git a/libical/src/libical/icalparser.h b/libical/src/libical/icalparser.h
index 5e1c88f..7773af4 100644
--- a/libical/src/libical/icalparser.h
+++ b/libical/src/libical/icalparser.h
@@ -35,12 +35,13 @@
35 35
36typedef void* icalparser; 36typedef struct icalparser_impl icalparser;
37 37
38 38
39/*********************************************************************** 39/**
40 * Line-oriented parsing. 40 * @file icalparser.h
41 * @brief Line-oriented parsing.
41 * 42 *
42 * Create a new parser via icalparse_new_parser, then add ines one at 43 * Create a new parser via icalparse_new_parser, then add lines one at
43 * a time with icalparse_add_line(). icalparser_add_line() will return 44 * a time with icalparse_add_line(). icalparser_add_line() will return
44 * non-zero when it has finished with a component. 45 * non-zero when it has finished with a component.
45 ***********************************************************************/ 46 */
46 47
@@ -61,3 +62,3 @@ void icalparser_free(icalparser* parser);
61 62
62/*********************************************************************** 63/**
63 * Message oriented parsing. icalparser_parse takes a string that 64 * Message oriented parsing. icalparser_parse takes a string that
@@ -66,9 +67,11 @@ void icalparser_free(icalparser* parser);
66 * pointer to a function that returns one content line per invocation 67 * pointer to a function that returns one content line per invocation
67 **********************************************************************/ 68 */
68 69
69icalcomponent* icalparser_parse(icalparser *parser, 70icalcomponent* icalparser_parse(icalparser *parser,
70 char* (*line_gen_func)(char *s, size_t size, void *d)); 71 char* (*line_gen_func)(char *s, size_t size, void *d));
71 72
72/* Set the data that icalparser_parse will give to the line_gen_func 73/**
73 as the parameter 'd'*/ 74 Set the data that icalparser_parse will give to the line_gen_func
75 as the parameter 'd'
76 */
74void icalparser_set_gen_data(icalparser* parser, void* data); 77void icalparser_set_gen_data(icalparser* parser, void* data);
@@ -83,3 +86,3 @@ icalcomponent* icalparser_parse_string(const char* str);
83 86
84/* Use the flex/bison parser to turn a string into a value type */ 87/** Use the flex/bison parser to turn a string into a value type */
85icalvalue* icalparser_parse_value(icalvalue_kind kind, 88icalvalue* icalparser_parse_value(icalvalue_kind kind,
@@ -87,6 +90,6 @@ icalvalue* icalparser_parse_value(icalvalue_kind kind,
87 90
88/* Given a line generator function, return a single iCal content line.*/ 91/** Given a line generator function, return a single iCal content line.*/
89char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d)); 92char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
90 93
91char* string_line_generator(char *out, size_t buf_size, void *d); 94char* icalparser_string_line_generator(char *out, size_t buf_size, void *d);
92 95
diff --git a/libical/src/libical/icalperiod.c b/libical/src/libical/icalperiod.c
index c74c157..0dfbe81 100644
--- a/libical/src/libical/icalperiod.c
+++ b/libical/src/libical/icalperiod.c
@@ -38,10 +38,4 @@
38 38
39#ifdef ICAL_NO_LIBICAL
40#define icalerror_set_errno(x)
41#define icalerror_check_arg_rv(x,y)
42#define icalerror_check_arg_re(x,y,z)
43#else
44#include "icalerror.h" 39#include "icalerror.h"
45#include "icalmemory.h" 40#include "icalmemory.h"
46#endif
47 41
@@ -99,2 +93,4 @@ struct icalperiodtype icalperiodtype_from_string (const char* str)
99 93
94 icalmemory_free_buffer(s);
95
100 return p; 96 return p;
@@ -103,2 +99,5 @@ struct icalperiodtype icalperiodtype_from_string (const char* str)
103 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 99 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
100
101 if (s)
102 icalmemory_free_buffer (s);
104 return null_p; 103 return null_p;
@@ -135,2 +134,3 @@ const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
135 134
135 icalmemory_add_tmp_buffer(buf);
136 136
@@ -141,3 +141,3 @@ const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
141 141
142struct icalperiodtype icalperiodtype_null_period() { 142struct icalperiodtype icalperiodtype_null_period(void) {
143 struct icalperiodtype p; 143 struct icalperiodtype p;
diff --git a/libical/src/libical/icalperiod.h b/libical/src/libical/icalperiod.h
index 64d5323..5f07dd4 100644
--- a/libical/src/libical/icalperiod.h
+++ b/libical/src/libical/icalperiod.h
@@ -44,8 +44,8 @@ struct icalperiodtype icalperiodtype_from_string (const char* str);
44const char* icalperiodtype_as_ical_string(struct icalperiodtype p); 44const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
45struct icalperiodtype icalperiodtype_null_period();
46int icalperiodtype_is_null_period(struct icalperiodtype p);
47int icalperiodtype_is_valid_period(struct icalperiodtype p);
48 45
46struct icalperiodtype icalperiodtype_null_period(void);
49 47
48int icalperiodtype_is_null_period(struct icalperiodtype p);
50 49
50int icalperiodtype_is_valid_period(struct icalperiodtype p);
51 51
diff --git a/libical/src/libical/icalproperty.c b/libical/src/libical/icalproperty.c
index 7f2cfa5..45d7a75 100644
--- a/libical/src/libical/icalproperty.c
+++ b/libical/src/libical/icalproperty.c
@@ -25,3 +25,2 @@
25======================================================================*/ 25======================================================================*/
26/*#line 27 "icalproperty.c.in"*/
27 26
@@ -47,5 +46,6 @@
47 46
48int snprintf(char *str, size_t n, char const *fmt, ...); 47#ifdef WIN32
49 48#define snprintf _snprintf
50#define TMP_BUF_SIZE 1024 49#define strcasecmp stricmp
50#endif
51 51
@@ -74,9 +74,6 @@ struct icalproperty_impl
74 74
75void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args) 75void icalproperty_add_parameters(icalproperty* prop, va_list args)
76{ 76{
77
78 void* vp; 77 void* vp;
79 78
80 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
81
82 while((vp = va_arg(args, void*)) != 0) { 79 while((vp = va_arg(args, void*)) != 0) {
@@ -86,6 +83,6 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
86 83
87 icalproperty_add_parameter((icalproperty*)impl, 84 icalproperty_add_parameter((icalproperty*)prop,
88 (icalparameter*)vp); 85 (icalparameter*)vp);
89 } else { 86 } else {
90 assert(0); 87 icalerror_set_errno(ICAL_BADARG_ERROR);
91 } 88 }
@@ -93,4 +90,2 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
93 } 90 }
94
95
96} 91}
@@ -98,9 +93,11 @@ void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args)
98 93
99struct icalproperty_impl* 94icalproperty*
100icalproperty_new_impl (icalproperty_kind kind) 95icalproperty_new_impl(icalproperty_kind kind)
101{ 96{
102 struct icalproperty_impl* prop; 97 icalproperty* prop;
98
99 if (!icalproperty_kind_is_valid(kind))
100 return NULL;
103 101
104 if ( ( prop = (struct icalproperty_impl*) 102 if ( ( prop = (icalproperty*) malloc(sizeof(icalproperty))) == 0) {
105 malloc(sizeof(struct icalproperty_impl))) == 0) {
106 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 103 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -125,3 +122,3 @@ icalproperty_new (icalproperty_kind kind)
125{ 122{
126 if(kind == ICAL_NO_PROPERTY){ 123 if (kind == ICAL_NO_PROPERTY){
127 return 0; 124 return 0;
@@ -134,9 +131,7 @@ icalproperty_new (icalproperty_kind kind)
134icalproperty* 131icalproperty*
135icalproperty_new_clone(icalproperty* prop) 132icalproperty_new_clone(icalproperty* old)
136{ 133{
137 struct icalproperty_impl *old = (struct icalproperty_impl*)prop; 134 icalproperty *new = icalproperty_new_impl(old->kind);
138 struct icalproperty_impl *new = icalproperty_new_impl(old->kind);
139 pvl_elem p; 135 pvl_elem p;
140 136
141 icalerror_check_arg_rz((prop!=0),"Prop");
142 icalerror_check_arg_rz((old!=0),"old"); 137 icalerror_check_arg_rz((old!=0),"old");
@@ -221,11 +216,7 @@ icalproperty* icalproperty_new_from_string(const char* str)
221void 216void
222icalproperty_free (icalproperty* prop) 217icalproperty_free (icalproperty* p)
223{ 218{
224 struct icalproperty_impl *p;
225
226 icalparameter* param; 219 icalparameter* param;
227 220
228 icalerror_check_arg_rv((prop!=0),"prop"); 221 icalerror_check_arg_rv((p!=0),"prop");
229
230 p = (struct icalproperty_impl*)prop;
231 222
@@ -267,52 +258,118 @@ icalproperty_free (icalproperty* prop)
267 258
268const char* 259/* This returns where the start of the next line should be. chars_left does
269icalproperty_as_ical_string (icalproperty* prop) 260 not include the trailing '\0'. */
270{ 261#define MAX_LINE_LEN 75
271 icalparameter *param; 262/*#define MAX_LINE_LEN 120*/
272 263
273 /* Create new buffer that we can append names, parameters and a 264static char*
274 value to, and reallocate as needed. Later, this buffer will be 265get_next_line_start (char *line_start, int chars_left)
275 copied to a icalmemory_tmp_buffer, which is managed internally 266{
276 by libical, so it can be given to the caller without fear of 267 char *pos;
277 the caller forgetting to free it */
278
279 const char* property_name = 0;
280 size_t buf_size = 1024;
281 char* buf = icalmemory_new_buffer(buf_size);
282 char* buf_ptr = buf;
283 icalvalue* value;
284 char *out_buf;
285 268
286 char newline[] = "\n"; 269 /* If we have 74 chars or less left, we can output all of them.
270 we return a pointer to the '\0' at the end of the string. */
271 if (chars_left < MAX_LINE_LEN) {
272 return line_start + chars_left;
273 }
287 274
288 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop; 275 /* Now we jump to the last possible character of the line, and step back
289 276 trying to find a ';' ':' or ' '. If we find one, we return the character
290 icalerror_check_arg_rz( (prop!=0),"prop"); 277 after it. */
278 pos = line_start + MAX_LINE_LEN - 2;
279 while (pos > line_start) {
280 if (*pos == ';' || *pos == ':' || *pos == ' ') {
281 return pos + 1;
282 }
283 pos--;
284 }
285 /* Now try to split on a UTF-8 boundary defined as a 7-bit
286 value or as a byte with the two high-most bits set:
287 11xxxxxx. See http://czyborra.com/utf/ */
291 288
289 pos = line_start + MAX_LINE_LEN - 1;
290 while (pos > line_start) {
291 /* plain ascii */
292 if ((*pos & 128) == 0)
293 return pos;
292 294
293 /* Append property name */ 295 /* utf8 escape byte */
296 if ((*pos & 192) == 192)
297 return pos;
294 298
295 if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){ 299 pos--;
296 property_name = impl->x_name;
297 } else {
298 property_name = icalproperty_kind_to_string(impl->kind);
299 } 300 }
300 301
301 if (property_name == 0 ) { 302 /* Give up, just break at 74 chars (the 75th char is the space at
302 icalerror_warn("Got a property of an unknown kind."); 303 the start of the line). */
303 icalmemory_free_buffer(buf); 304
304 return 0; 305 return line_start + MAX_LINE_LEN - 1;
305 306}
306 }
307 307
308 308
309 icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name); 309/** This splits the property into lines less than 75 octects long (as
310 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); 310 * specified in RFC2445). It tries to split after a ';' if it can.
311 * It returns a tmp buffer. NOTE: I'm not sure if it matters if we
312 * split a line in the middle of a UTF-8 character. It probably won't
313 * look nice in a text editor.
314 */
315static char*
316fold_property_line (char *text)
317{
318 size_t buf_size;
319 char *buf, *buf_ptr, *line_start, *next_line_start, *out_buf;
320 int len, chars_left, first_line;
321 char ch;
322
323 /* Start with a buffer twice the size of our property line, so we almost
324 certainly won't overflow it. */
325 len = strlen (text);
326 buf_size = len * 2;
327 buf = icalmemory_new_buffer (buf_size);
328 buf_ptr = buf;
329
330 /* Step through the text, finding each line to add to the output. */
331 line_start = text;
332 chars_left = len;
333 first_line = 1;
334 for (;;) {
335 if (chars_left <= 0)
336 break;
337
338 /* This returns the first character for the next line. */
339 next_line_start = get_next_line_start (line_start, chars_left);
340
341 /* If this isn't the first line, we need to output a newline and space
342 first. */
343 if (!first_line) {
344 icalmemory_append_string (&buf, &buf_ptr, &buf_size, "\n ");
345 }
346 first_line = 0;
347
348 /* This adds the line to our tmp buffer. We temporarily place a '\0'
349 in text, so we can copy the line in one go. */
350 ch = *next_line_start;
351 *next_line_start = '\0';
352 icalmemory_append_string (&buf, &buf_ptr, &buf_size, line_start);
353 *next_line_start = ch;
311 354
355 /* Now we move on to the next line. */
356 chars_left -= (next_line_start - line_start);
357 line_start = next_line_start;
358 }
359
360 /* Copy it to a temporary buffer, and then free it. */
361 out_buf = icalmemory_tmp_buffer (strlen (buf) + 1);
362 strcpy (out_buf, buf);
363 icalmemory_free_buffer (buf);
364
365 return out_buf;
366}
312 367
313 368
314 /* Determine what VALUE parameter to include. The VALUE parameters 369/* Determine what VALUE parameter to include. The VALUE parameters
315 are ignored in the normal parameter printing ( the block after 370 are ignored in the normal parameter printing ( the block after
316 this one, so we need to do it here */ 371 this one, so we need to do it here */
317 { 372static const char *
373icalproperty_get_value_kind(icalproperty *prop)
374{
318 const char* kind_string = 0; 375 const char* kind_string = 0;
@@ -322,3 +379,3 @@ icalproperty_as_ical_string (icalproperty* prop)
322 379
323 icalvalue *value = icalproperty_get_value(impl); 380 icalvalue *value = icalproperty_get_value(prop);
324 381
@@ -329,3 +386,3 @@ icalproperty_as_ical_string (icalproperty* prop)
329 icalvalue_kind default_kind 386 icalvalue_kind default_kind
330 = icalproperty_kind_to_value_kind(impl->kind); 387 = icalproperty_kind_to_value_kind(prop->kind);
331 388
@@ -356,10 +413,51 @@ icalproperty_as_ical_string (icalproperty* prop)
356 413
357 if(kind_string!=0){ 414 return kind_string;
358 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;"); 415}
359 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "VALUE="); 416
360 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); 417const char*
361 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); 418icalproperty_as_ical_string (icalproperty* prop)
362 } 419{
420 icalparameter *param;
421
422 /* Create new buffer that we can append names, parameters and a
423 value to, and reallocate as needed. Later, this buffer will be
424 copied to a icalmemory_tmp_buffer, which is managed internally
425 by libical, so it can be given to the caller without fear of
426 the caller forgetting to free it */
427
428 const char* property_name = 0;
429 size_t buf_size = 1024;
430 char* buf = icalmemory_new_buffer(buf_size);
431 char* buf_ptr = buf;
432 icalvalue* value;
433 char *out_buf;
434 const char* kind_string = 0;
435
436 char newline[] = "\n";
437
438
439 icalerror_check_arg_rz( (prop!=0),"prop");
440
441
442 /* Append property name */
443
444 if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){
445 property_name = prop->x_name;
446 } else {
447 property_name = icalproperty_kind_to_string(prop->kind);
448 }
449
450 if (property_name == 0 ) {
451 icalerror_warn("Got a property of an unknown kind.");
452 icalmemory_free_buffer(buf);
453 return 0;
363 454
455 }
364 456
457 icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name);
458
459 kind_string = icalproperty_get_value_kind(prop);
460 if(kind_string!=0){
461 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";VALUE=");
462 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
365 } 463 }
@@ -371,4 +469,4 @@ icalproperty_as_ical_string (icalproperty* prop)
371 469
372 char* kind_string = icalparameter_as_ical_string(param);
373 icalparameter_kind kind = icalparameter_isa(param); 470 icalparameter_kind kind = icalparameter_isa(param);
471 kind_string = icalparameter_as_ical_string(param);
374 472
@@ -379,5 +477,5 @@ icalproperty_as_ical_string (icalproperty* prop)
379 if (kind_string == 0 ) { 477 if (kind_string == 0 ) {
380 char temp[TMP_BUF_SIZE]; 478 icalerror_warn("Got a parameter of unknown kind for the following property");
381 snprintf(temp, TMP_BUF_SIZE,"Got a parameter of unknown kind in %s property",property_name); 479
382 icalerror_warn(temp); 480 icalerror_warn((property_name) ? property_name : "(NULL)");
383 continue; 481 continue;
@@ -385,6 +483,4 @@ icalproperty_as_ical_string (icalproperty* prop)
385 483
386 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " ;"); 484 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";");
387 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); 485 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
388 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
389
390 } 486 }
@@ -393,3 +489,3 @@ icalproperty_as_ical_string (icalproperty* prop)
393 489
394 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " :"); 490 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ":");
395 491
@@ -411,5 +507,4 @@ icalproperty_as_ical_string (icalproperty* prop)
411 507
412 508 /* We now use a function to fold the line properly every 75 characters. */
413 out_buf = icalmemory_tmp_buffer(strlen(buf)+1); 509 out_buf = fold_property_line (buf);
414 strcpy(out_buf, buf);
415 510
@@ -423,7 +518,5 @@ icalproperty_as_ical_string (icalproperty* prop)
423icalproperty_kind 518icalproperty_kind
424icalproperty_isa (icalproperty* property) 519icalproperty_isa (icalproperty* p)
425{ 520{
426 struct icalproperty_impl *p = (struct icalproperty_impl*)property; 521 if(p != 0){
427
428 if(property != 0){
429 return p->kind; 522 return p->kind;
@@ -437,6 +530,5 @@ icalproperty_isa_property (void* property)
437{ 530{
438 struct icalproperty_impl *impl = (struct icalproperty_impl*)property; 531 icalproperty *impl = (icalproperty *) property;
439 532
440 icalerror_check_arg_rz( (property!=0), "property"); 533 icalerror_check_arg_rz( (property!=0), "property");
441
442 if (strcmp(impl->id,"prop") == 0) { 534 if (strcmp(impl->id,"prop") == 0) {
@@ -450,7 +542,5 @@ icalproperty_isa_property (void* property)
450void 542void
451icalproperty_add_parameter (icalproperty* prop,icalparameter* parameter) 543icalproperty_add_parameter (icalproperty* p,icalparameter* parameter)
452{ 544{
453 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 545 icalerror_check_arg_rv( (p!=0),"prop");
454
455 icalerror_check_arg_rv( (prop!=0),"prop");
456 icalerror_check_arg_rv( (parameter!=0),"parameter"); 546 icalerror_check_arg_rv( (parameter!=0),"parameter");
@@ -470,4 +560,7 @@ icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter)
470 kind = icalparameter_isa(parameter); 560 kind = icalparameter_isa(parameter);
471 561 if (kind != ICAL_X_PARAMETER)
472 icalproperty_remove_parameter(prop,kind); 562 icalproperty_remove_parameter_by_kind(prop,kind);
563 else
564 icalproperty_remove_parameter_by_name(prop,
565 icalparameter_get_xname(parameter));
473 566
@@ -493,3 +586,3 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
493 } 586 }
494 587
495 param = icalparameter_new_from_value_string(kind,value); 588 param = icalparameter_new_from_value_string(kind,value);
@@ -501,2 +594,6 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
501 594
595 if(kind == ICAL_X_PARAMETER){
596 icalparameter_set_xname(param, name);
597 }
598
502 icalproperty_set_parameter(prop,param); 599 icalproperty_set_parameter(prop,param);
@@ -518,3 +615,3 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
518 615
519 if(kind == ICAL_NO_PROPERTY){ 616 if(kind == ICAL_NO_PARAMETER){
520 /* icalenum_string_to_parameter_kind will set icalerrno */ 617 /* icalenum_string_to_parameter_kind will set icalerrno */
@@ -522,4 +619,14 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
522 } 619 }
620
621 for(param = icalproperty_get_first_parameter(prop,kind);
622 param != 0;
623 param = icalproperty_get_next_parameter(prop,kind)) {
624 if (kind != ICAL_X_PARAMETER) {
625 break;
626 }
523 627
524 param = icalproperty_get_first_parameter(prop,kind); 628 if (strcmp(icalparameter_get_xname(param),name)==0) {
629 break;
630 }
631 }
525 632
@@ -529,2 +636,3 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
529 636
637
530 str = icalparameter_as_ical_string(param); 638 str = icalparameter_as_ical_string(param);
@@ -542,7 +650,29 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
542 650
651/** @see icalproperty_remove_parameter_by_kind()
652 *
653 * @deprecated Please use icalproperty_remove_parameter_by_kind()
654 * instead.
655 */
656
543void 657void
544icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind) 658icalproperty_remove_parameter(icalproperty* prop, icalparameter_kind kind)
659{
660 icalproperty_remove_parameter_by_kind(prop, kind);
661}
662
663
664/** @brief Remove all parameters with the specified kind.
665 *
666 * @param prop A valid icalproperty.
667 * @param kind The kind to remove (ex. ICAL_TZID_PARAMETER)
668 *
669 * See icalproperty_remove_parameter_by_name() and
670 * icalproperty_remove_parameter_by_ref() for alternate ways of
671 * removing parameters
672 */
673
674void
675icalproperty_remove_parameter_by_kind(icalproperty* prop, icalparameter_kind kind)
545{ 676{
546 pvl_elem p; 677 pvl_elem p;
547 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
548 678
@@ -550,7 +680,7 @@ icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind)
550 680
551 for(p=pvl_head(impl->parameters);p != 0; p = pvl_next(p)){ 681 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
552 icalparameter* param = (icalparameter *)pvl_data (p); 682 icalparameter* param = (icalparameter *)pvl_data (p);
553 if (icalparameter_isa(param) == kind) { 683 if (icalparameter_isa(param) == kind) {
554 pvl_remove (impl->parameters, p); 684 pvl_remove (prop->parameters, p);
555 icalparameter_free (param); 685 icalparameter_free(param);
556 break; 686 break;
@@ -561,9 +691,88 @@ icalproperty_remove_parameter (icalproperty* prop, icalparameter_kind kind)
561 691
562int 692/** @brief Remove all parameters with the specified name.
563icalproperty_count_parameters (icalproperty* prop) 693 *
694 * @param prop A valid icalproperty.
695 * @param name The name of the parameter to remove
696 *
697 * This function removes paramters with the given name. The name
698 * corresponds to either a built-in name (TZID, etc.) or the name of
699 * an extended parameter (X-FOO)
700 *
701 * See icalproperty_remove_parameter_by_kind() and
702 * icalproperty_remove_parameter_by_ref() for alternate ways of removing
703 * parameters
704 */
705
706
707void
708icalproperty_remove_parameter_by_name(icalproperty* prop, const char *name)
564{ 709{
565 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 710 pvl_elem p;
711
712 icalerror_check_arg_rv((prop!=0),"prop");
713
714 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
715 icalparameter* param = (icalparameter *)pvl_data (p);
716 const char * kind_string;
717
718 if (icalparameter_isa(param) == ICAL_X_PARAMETER)
719 kind_string = icalparameter_get_xname(param);
720 else
721 kind_string = icalparameter_kind_to_string(icalparameter_isa(param));
722
723 if (!kind_string)
724 continue;
566 725
726 if (0 == strcmp(kind_string, name)) {
727 pvl_remove (prop->parameters, p);
728 break;
729 }
730 }
731}
732
733
734/** @brief Remove the specified parameter reference from the property.
735 *
736 * @param prop A valid icalproperty.
737 * @param parameter A reference to a specific icalparameter.
738 *
739 * This function removes the specified parameter reference from the
740 * property.
741 */
742
743void
744icalproperty_remove_parameter_by_ref(icalproperty* prop, icalparameter* parameter)
745{
746 pvl_elem p;
747 icalparameter_kind kind;
748 const char *name;
749
750 icalerror_check_arg_rv((prop!=0),"prop");
751 icalerror_check_arg_rv((parameter!=0),"parameter");
752
753 kind = icalparameter_isa(parameter);
754 name = icalparameter_get_xname(parameter);
755
756 /*
757 * FIXME If it's an X- parameter, also compare the names. It would be nice
758 * to have a better abstraction like icalparameter_equals()
759 */
760 for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){
761 icalparameter* p_param = (icalparameter *)pvl_data (p);
762 if (icalparameter_isa(p_param) == kind &&
763 (kind != ICAL_X_PARAMETER ||
764 !strcmp(icalparameter_get_xname(p_param), name))) {
765 pvl_remove (prop->parameters, p);
766 icalparameter_free(p_param);
767 break;
768 }
769 }
770}
771
772
773int
774icalproperty_count_parameters (const icalproperty* prop)
775{
567 if(prop != 0){ 776 if(prop != 0){
568 return pvl_count(p->parameters); 777 return pvl_count(prop->parameters);
569 } 778 }
@@ -576,7 +785,5 @@ icalproperty_count_parameters (icalproperty* prop)
576icalparameter* 785icalparameter*
577icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind) 786icalproperty_get_first_parameter(icalproperty* p, icalparameter_kind kind)
578{ 787{
579 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 788 icalerror_check_arg_rz( (p!=0),"prop");
580
581 icalerror_check_arg_rz( (prop!=0),"prop");
582 789
@@ -604,7 +811,5 @@ icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind)
604icalparameter* 811icalparameter*
605icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind) 812icalproperty_get_next_parameter (icalproperty* p, icalparameter_kind kind)
606{ 813{
607 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 814 icalerror_check_arg_rz( (p!=0),"prop");
608
609 icalerror_check_arg_rz( (prop!=0),"prop");
610 815
@@ -630,7 +835,5 @@ icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind)
630void 835void
631icalproperty_set_value (icalproperty* prop, icalvalue* value) 836icalproperty_set_value (icalproperty* p, icalvalue* value)
632{ 837{
633 struct icalproperty_impl *p = (struct icalproperty_impl*)prop; 838 icalerror_check_arg_rv((p !=0),"prop");
634
635 icalerror_check_arg_rv((prop !=0),"prop");
636 icalerror_check_arg_rv((value !=0),"value"); 839 icalerror_check_arg_rv((value !=0),"value");
@@ -645,3 +848,3 @@ icalproperty_set_value (icalproperty* prop, icalvalue* value)
645 848
646 icalvalue_set_parent(value,prop); 849 icalvalue_set_parent(value,p);
647} 850}
@@ -693,12 +896,10 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* str,
693icalvalue* 896icalvalue*
694icalproperty_get_value (icalproperty* prop) 897icalproperty_get_value(const icalproperty* prop)
695{ 898{
696 struct icalproperty_impl *p = (struct icalproperty_impl*)prop;
697
698 icalerror_check_arg_rz( (prop!=0),"prop"); 899 icalerror_check_arg_rz( (prop!=0),"prop");
699 900
700 return p->value; 901 return prop->value;
701} 902}
702 903
703const char* icalproperty_get_value_as_string(icalproperty* prop) 904const char* icalproperty_get_value_as_string(const icalproperty* prop)
704{ 905{
@@ -706,7 +907,5 @@ const char* icalproperty_get_value_as_string(icalproperty* prop)
706 907
707 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
708
709 icalerror_check_arg_rz( (prop!=0),"prop"); 908 icalerror_check_arg_rz( (prop!=0),"prop");
710 909
711 value = impl->value; 910 value = prop->value;
712 911
@@ -718,4 +917,2 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
718{ 917{
719 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
720
721 icalerror_check_arg_rv( (name!=0),"name"); 918 icalerror_check_arg_rv( (name!=0),"name");
@@ -723,9 +920,9 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
723 920
724 if (impl->x_name != 0) { 921 if (prop->x_name != 0) {
725 free(impl->x_name); 922 free(prop->x_name);
726 } 923 }
727 924
728 impl->x_name = icalmemory_strdup(name); 925 prop->x_name = icalmemory_strdup(name);
729 926
730 if(impl->x_name == 0){ 927 if(prop->x_name == 0){
731 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 928 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -736,8 +933,5 @@ void icalproperty_set_x_name(icalproperty* prop, const char* name)
736const char* icalproperty_get_x_name(icalproperty* prop){ 933const char* icalproperty_get_x_name(icalproperty* prop){
737
738 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
739
740 icalerror_check_arg_rz( (prop!=0),"prop"); 934 icalerror_check_arg_rz( (prop!=0),"prop");
741 935
742 return impl->x_name; 936 return prop->x_name;
743} 937}
@@ -745,4 +939,11 @@ const char* icalproperty_get_x_name(icalproperty* prop){
745 939
746/* From Jonathan Yue <jonathan.yue@cp.net> */ 940const char* icalproperty_get_name(const icalproperty* prop)
747const char* icalproperty_get_name (icalproperty* prop) 941{
942#ifndef NO_WARN_DEPRECATED
943 icalerror_warn("icalproperty_get_name() is DEPRECATED, please use icalproperty_get_property_name() instead.");
944#endif
945 return icalproperty_get_property_name(prop);
946}
947
948const char* icalproperty_get_property_name(const icalproperty* prop)
748{ 949{
@@ -754,10 +955,8 @@ const char* icalproperty_get_name (icalproperty* prop)
754 955
755 struct icalproperty_impl *impl = (struct icalproperty_impl*)prop;
756
757 icalerror_check_arg_rz( (prop!=0),"prop"); 956 icalerror_check_arg_rz( (prop!=0),"prop");
758 957
759 if (impl->kind == ICAL_X_PROPERTY && impl->x_name != 0){ 958 if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){
760 property_name = impl->x_name; 959 property_name = prop->x_name;
761 } else { 960 } else {
762 property_name = icalproperty_kind_to_string(impl->kind); 961 property_name = icalproperty_kind_to_string(prop->kind);
763 } 962 }
@@ -787,24 +986,12 @@ void icalproperty_set_parent(icalproperty* property,
787{ 986{
788 struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
789
790 icalerror_check_arg_rv( (property!=0),"property"); 987 icalerror_check_arg_rv( (property!=0),"property");
791 988
792 impl->parent = component; 989 property->parent = component;
793} 990}
794 991
795icalcomponent* icalproperty_get_parent(icalproperty* property) 992icalcomponent* icalproperty_get_parent(const icalproperty* property)
796{ 993{
797 struct icalproperty_impl *impl = (struct icalproperty_impl*)property;
798
799 icalerror_check_arg_rz( (property!=0),"property"); 994 icalerror_check_arg_rz( (property!=0),"property");
800 995
801 return impl->parent; 996 return property->parent;
802} 997}
803
804
805
806
807
808
809
810/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalproperty.h b/libical/src/libical/icalproperty.h
index e39c6b5..472adb9 100644
--- a/libical/src/libical/icalproperty.h
+++ b/libical/src/libical/icalproperty.h
@@ -33,7 +33,3 @@
33#include <time.h> 33#include <time.h>
34 34#include <stdarg.h> /* for va_... */
35#ifdef _WIN32
36#include <stdio.h> /* for printf */
37#include <stdarg.h> /* for va_list, va_start, etc. */
38#endif
39 35
@@ -45,3 +41,3 @@
45/* Actually in icalderivedproperty.h: 41/* Actually in icalderivedproperty.h:
46 typedef void icalproperty; */ 42 typedef struct icalproperty_impl icalproperty; */
47 43
@@ -49,4 +45,2 @@
49 45
50// void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
51
52icalproperty* icalproperty_new(icalproperty_kind kind); 46icalproperty* icalproperty_new(icalproperty_kind kind);
@@ -64,2 +58,3 @@ int icalproperty_isa_property(void* property);
64 58
59void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args);
65void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter); 60void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter);
@@ -74,3 +69,14 @@ void icalproperty_remove_parameter(icalproperty* prop,
74 69
75int icalproperty_count_parameters(icalproperty* prop); 70void icalproperty_remove_parameter_by_kind(icalproperty* prop,
71 icalparameter_kind kind);
72
73void icalproperty_remove_parameter_by_name(icalproperty* prop,
74 const char *name);
75
76void icalproperty_remove_parameter_by_ref(icalproperty* prop,
77 icalparameter *param);
78
79
80
81int icalproperty_count_parameters(const icalproperty* prop);
76 82
@@ -85,4 +91,4 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* value, co
85 91
86icalvalue* icalproperty_get_value(icalproperty* prop); 92icalvalue* icalproperty_get_value(const icalproperty* prop);
87const char* icalproperty_get_value_as_string(icalproperty* prop); 93const char* icalproperty_get_value_as_string(const icalproperty* prop);
88 94
@@ -93,5 +99,7 @@ const char* icalproperty_get_x_name(icalproperty* prop);
93 99
94/* Return the name of the property -- the type name converted to a 100/** Return the name of the property -- the type name converted to a
95 string, or the value of _get_x_name if the type is and X property */ 101 * string, or the value of _get_x_name if the type is and X
96const char* icalproperty_get_name (icalproperty* prop); 102 * property
103 */
104const char* icalproperty_get_property_name (const icalproperty* prop);
97 105
@@ -102,3 +110,3 @@ icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
102icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind); 110icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);
103icalvalue_kind icalproperty_value_kind_to_kind(icalvalue_kind kind); 111icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind);
104const char* icalproperty_kind_to_string(icalproperty_kind kind); 112const char* icalproperty_kind_to_string(icalproperty_kind kind);
@@ -106,2 +114,5 @@ icalproperty_kind icalproperty_string_to_kind(const char* string);
106 114
115/** Check validity of a specific icalproperty_kind **/
116int icalproperty_kind_is_valid(const icalproperty_kind kind);
117
107icalproperty_method icalproperty_string_to_method(const char* str); 118icalproperty_method icalproperty_string_to_method(const char* str);
@@ -112,2 +123,3 @@ const char* icalproperty_enum_to_string(int e);
112int icalproperty_string_to_enum(const char* str); 123int icalproperty_string_to_enum(const char* str);
124int icalproperty_kind_and_string_to_enum(const int kind, const char* str);
113 125
diff --git a/libical/src/libical/icalrecur.c b/libical/src/libical/icalrecur.c
index 203ce70..d5a59c6 100644
--- a/libical/src/libical/icalrecur.c
+++ b/libical/src/libical/icalrecur.c
@@ -21,3 +21,7 @@
21 the License at http://www.mozilla.org/MPL/ 21 the License at http://www.mozilla.org/MPL/
22*/
22 23
24/**
25 @file icalrecur.c
26 @brief Implementation of routines for dealing with recurring time
23 27
@@ -132,11 +136,10 @@
132 136
137#ifdef HAVE_STDINT_H
138#include <stdint.h>
139#endif
140
133#include "icalrecur.h" 141#include "icalrecur.h"
134 142
135#ifdef ICAL_NO_LIBICAL
136#define icalerror_set_errno(x)
137#define icalerror_check_arg_rv(x,y)
138#else
139#include "icalerror.h" 143#include "icalerror.h"
140#include "icalmemory.h" 144#include "icalmemory.h"
141#endif
142 145
@@ -150,2 +153,6 @@
150 153
154/** This is the last year we will go up to, since 32-bit time_t values
155 only go up to the start of 2038. */
156 #define MAX_TIME_T_YEAR2037
157
151#define TEMP_MAX 1024 158#define TEMP_MAX 1024
@@ -172,3 +179,2 @@ icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str);
172 179
173
174/*********************** Rule parsing routines ************************/ 180/*********************** Rule parsing routines ************************/
@@ -255,3 +261,3 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
255 int sign = 1; 261 int sign = 1;
256 short v; 262 int v;
257 263
@@ -282,2 +288,4 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
282 t++; 288 t++;
289 } else {
290 sign = 1;
283 } 291 }
@@ -287,3 +295,3 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
287 295
288 array[i++] = v; 296 array[i++] = (short)v;
289 array[i] = ICAL_RECURRENCE_ARRAY_MAX; 297 array[i] = ICAL_RECURRENCE_ARRAY_MAX;
@@ -334,13 +342,10 @@ void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
334 342
335 weekno = 0;
336 /* Get Optional weekno */ 343 /* Get Optional weekno */
337 if( sscanf(t,"%d",&weekno) != 0){ 344 weekno = strtol(t,&t,10);
338 if (n != 0){ 345
339 int weeknolen = (n-t)-3; /* 3 -> one for \0, 2 for day name */ 346 /* Outlook/Exchange generate "BYDAY=MO, FR" and "BYDAY=2 TH".
340 /* could use abs(log10(weekno))+1, but that needs libm */ 347 * Cope with that.
341 t += weeknolen; 348 */
342 } else { 349 if (*t == ' ')
343 t = end -2; 350 t++;
344 }
345 }
346 351
@@ -348,3 +353,3 @@ void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
348 353
349 array[i++] = sign* ((int)wd + 8*weekno); 354 array[i++] = (short)(sign* (wd + 8*weekno));
350 array[i] = ICAL_RECURRENCE_ARRAY_MAX; 355 array[i] = ICAL_RECURRENCE_ARRAY_MAX;
@@ -389,2 +394,3 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
389 icalrecurrencetype_clear(&parser.rt); 394 icalrecurrencetype_clear(&parser.rt);
395 free(parser.copy);
390 return parser.rt; 396 return parser.rt;
@@ -399,3 +405,3 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
399 } else if (strcmp(name,"INTERVAL") == 0){ 405 } else if (strcmp(name,"INTERVAL") == 0){
400 parser.rt.interval = atoi(value); 406 parser.rt.interval = (short)atoi(value);
401 } else if (strcmp(name,"WKST") == 0){ 407 } else if (strcmp(name,"WKST") == 0){
@@ -431,2 +437,3 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
431 icalrecurrencetype_clear(&parser.rt); 437 icalrecurrencetype_clear(&parser.rt);
438 free(parser.copy);
432 return parser.rt; 439 return parser.rt;
@@ -442,5 +449,3 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
442 449
443#ifndef ICAL_NO_LIBICAL 450static struct { char* str;size_t offset; int limit; } recurmap[] =
444
445struct { char* str;size_t offset; short limit; } recurmap[] =
446{ 451{
@@ -459,2 +464,3 @@ struct { char* str;size_t offset; short limit; } recurmap[] =
459/* A private routine in icalvalue.c */ 464/* A private routine in icalvalue.c */
465void print_date_to_string(char* str, struct icaltimetype *data);
460void print_datetime_to_string(char* str, struct icaltimetype *data); 466void print_datetime_to_string(char* str, struct icaltimetype *data);
@@ -483,3 +489,6 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
483 temp[0] = 0; 489 temp[0] = 0;
484 print_datetime_to_string(temp,&(recur->until)); 490 if (recur->until.is_date)
491 print_date_to_string(temp,&(recur->until));
492 else
493 print_datetime_to_string(temp,&(recur->until));
485 494
@@ -503,3 +512,3 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
503 short* array = (short*)(recurmap[j].offset+ (size_t)recur); 512 short* array = (short*)(recurmap[j].offset+ (size_t)recur);
504 short limit = recurmap[j].limit; 513 int limit = recurmap[j].limit;
505 514
@@ -514,5 +523,5 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
514 if (j == 3) { /* BYDAY */ 523 if (j == 3) { /* BYDAY */
515 short dow = icalrecurrencetype_day_day_of_week(array[i]); 524 const char *daystr = icalrecur_weekday_to_string(
516 const char *daystr = icalrecur_weekday_to_string(dow); 525 icalrecurrencetype_day_day_of_week(array[i]));
517 short pos; 526 int pos;
518 527
@@ -542,4 +551,2 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
542} 551}
543#endif
544
545 552
@@ -575,6 +582,6 @@ struct icalrecur_iterator_impl {
575 short by_indices[9]; 582 short by_indices[9];
576 short orig_data[9]; /* 1 if there was data in the byrule */ 583 short orig_data[9]; /**< 1 if there was data in the byrule */
577 584
578 585
579 short *by_ptrs[9]; /* Pointers into the by_* array elements of the rule */ 586 short *by_ptrs[9]; /**< Pointers into the by_* array elements of the rule */
580 587
@@ -582,2 +589,4 @@ struct icalrecur_iterator_impl {
582 589
590static void increment_year(icalrecur_iterator* impl, int inc);
591
583int icalrecur_iterator_sizeof_byarray(short* byarray) 592int icalrecur_iterator_sizeof_byarray(short* byarray)
@@ -601,6 +610,9 @@ enum expand_table {
601 610
602/* The split map indicates, for a particular interval, wether a BY_* 611/**
603 rule part expands the number of instances in the occcurrence set or 612 * The split map indicates, for a particular interval, wether a BY_*
604 contracts it. 1=> contract, 2=>expand, and 3 means the pairing is 613 * rule part expands the number of instances in the occcurrence set or
605 not allowed. */ 614 * contracts it. 1=> contract, 2=>expand, and 3 means the pairing is
615 * not allowed.
616 */
617
606struct expand_split_map_struct 618struct expand_split_map_struct
@@ -615,3 +627,3 @@ struct expand_split_map_struct
615 627
616struct expand_split_map_struct expand_map[] = 628static struct expand_split_map_struct expand_map[] =
617{ 629{
@@ -630,4 +642,5 @@ struct expand_split_map_struct expand_map[] =
630 642
631/* Check that the rule has only the two given interday byrule parts. */ 643/** Check that the rule has only the two given interday byrule parts. */
632int icalrecur_two_byrule(struct icalrecur_iterator_impl* impl, 644static
645int icalrecur_two_byrule(icalrecur_iterator* impl,
633 enum byrule one,enum byrule two) 646 enum byrule one,enum byrule two)
@@ -638,3 +651,3 @@ int icalrecur_two_byrule(struct icalrecur_iterator_impl* impl,
638 651
639 memset(test_array,0,9); 652 memset(test_array,0,sizeof(test_array));
640 653
@@ -661,4 +674,4 @@ int icalrecur_two_byrule(struct icalrecur_iterator_impl* impl,
661 674
662/* Check that the rule has only the one given interdat byrule parts. */ 675/** Check that the rule has only the one given interdat byrule parts. */
663int icalrecur_one_byrule(struct icalrecur_iterator_impl* impl,enum byrule one) 676static int icalrecur_one_byrule(icalrecur_iterator* impl,enum byrule one)
664{ 677{
@@ -678,3 +691,3 @@ int icalrecur_one_byrule(struct icalrecur_iterator_impl* impl,enum byrule one)
678 691
679int count_byrules(struct icalrecur_iterator_impl* impl) 692static int count_byrules(icalrecur_iterator* impl)
680{ 693{
@@ -693,5 +706,5 @@ int count_byrules(struct icalrecur_iterator_impl* impl)
693 706
694void setup_defaults(struct icalrecur_iterator_impl* impl, 707static void setup_defaults(icalrecur_iterator* impl,
695 enum byrule byrule, icalrecurrencetype_frequency req, 708 enum byrule byrule, icalrecurrencetype_frequency req,
696 short deftime, int *timepart) 709 int deftime, int *timepart)
697{ 710{
@@ -706,3 +719,3 @@ void setup_defaults(struct icalrecur_iterator_impl* impl,
706 expand_map[freq].map[byrule] != CONTRACT){ 719 expand_map[freq].map[byrule] != CONTRACT){
707 impl->by_ptrs[byrule][0] = deftime; 720 impl->by_ptrs[byrule][0] = (short)deftime;
708 } 721 }
@@ -717,3 +730,3 @@ void setup_defaults(struct icalrecur_iterator_impl* impl,
717 730
718int has_by_data(struct icalrecur_iterator_impl* impl, enum byrule byrule){ 731static int has_by_data(icalrecur_iterator* impl, enum byrule byrule){
719 732
@@ -723,3 +736,3 @@ int has_by_data(struct icalrecur_iterator_impl* impl, enum byrule byrule){
723 736
724int expand_year_days(struct icalrecur_iterator_impl* impl,short year); 737static int expand_year_days(icalrecur_iterator* impl, int year);
725 738
@@ -729,9 +742,7 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
729{ 742{
730 struct icalrecur_iterator_impl* impl; 743 icalrecur_iterator* impl;
731 icalrecurrencetype_frequency freq; 744 icalrecurrencetype_frequency freq;
732 745
733 short days_in_month; 746 if ( ( impl = (icalrecur_iterator*)
734 747 malloc(sizeof(icalrecur_iterator))) == 0) {
735 if ( ( impl = (struct icalrecur_iterator_impl *)
736 malloc(sizeof(struct icalrecur_iterator_impl))) == 0) {
737 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 748 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -740,3 +751,3 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
740 751
741 memset(impl,0,sizeof(struct icalrecur_iterator_impl)); 752 memset(impl,0,sizeof(icalrecur_iterator));
742 753
@@ -762,3 +773,3 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
762 773
763 memset(impl->orig_data,0,9); 774 memset(impl->orig_data,0,9*sizeof(short));
764 775
@@ -770,19 +781,19 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
770 impl->orig_data[BY_MONTH] 781 impl->orig_data[BY_MONTH]
771 = (impl->rule.by_month[0]!=ICAL_RECURRENCE_ARRAY_MAX); 782 = (short)(impl->rule.by_month[0]!=ICAL_RECURRENCE_ARRAY_MAX);
772 impl->orig_data[BY_WEEK_NO] 783 impl->orig_data[BY_WEEK_NO]
773 =(impl->rule.by_week_no[0]!=ICAL_RECURRENCE_ARRAY_MAX); 784 =(short)(impl->rule.by_week_no[0]!=ICAL_RECURRENCE_ARRAY_MAX);
774 impl->orig_data[BY_YEAR_DAY] 785 impl->orig_data[BY_YEAR_DAY]
775 =(impl->rule.by_year_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); 786 =(short)(impl->rule.by_year_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
776 impl->orig_data[BY_MONTH_DAY] 787 impl->orig_data[BY_MONTH_DAY]
777 =(impl->rule.by_month_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); 788 =(short)(impl->rule.by_month_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
778 impl->orig_data[BY_DAY] 789 impl->orig_data[BY_DAY]
779 = (impl->rule.by_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); 790 = (short)(impl->rule.by_day[0]!=ICAL_RECURRENCE_ARRAY_MAX);
780 impl->orig_data[BY_HOUR] 791 impl->orig_data[BY_HOUR]
781 = (impl->rule.by_hour[0]!=ICAL_RECURRENCE_ARRAY_MAX); 792 = (short)(impl->rule.by_hour[0]!=ICAL_RECURRENCE_ARRAY_MAX);
782 impl->orig_data[BY_MINUTE] 793 impl->orig_data[BY_MINUTE]
783 = (impl->rule.by_minute[0]!=ICAL_RECURRENCE_ARRAY_MAX); 794 = (short)(impl->rule.by_minute[0]!=ICAL_RECURRENCE_ARRAY_MAX);
784 impl->orig_data[BY_SECOND] 795 impl->orig_data[BY_SECOND]
785 = (impl->rule.by_second[0]!=ICAL_RECURRENCE_ARRAY_MAX); 796 = (short)(impl->rule.by_second[0]!=ICAL_RECURRENCE_ARRAY_MAX);
786 impl->orig_data[BY_SET_POS] 797 impl->orig_data[BY_SET_POS]
787 = (impl->rule.by_set_pos[0]!=ICAL_RECURRENCE_ARRAY_MAX); 798 = (short)(impl->rule.by_set_pos[0]!=ICAL_RECURRENCE_ARRAY_MAX);
788 799
@@ -854,15 +865,20 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
854 865
855 setup_defaults(impl,BY_SECOND,ICAL_SECONDLY_RECURRENCE,impl->dtstart.second, 866 setup_defaults(impl,BY_SECOND,ICAL_SECONDLY_RECURRENCE,
867 impl->dtstart.second,
856 &(impl->last.second)); 868 &(impl->last.second));
857 869
858 setup_defaults(impl,BY_MINUTE,ICAL_MINUTELY_RECURRENCE,impl->dtstart.minute, 870 setup_defaults(impl,BY_MINUTE,ICAL_MINUTELY_RECURRENCE,
871 impl->dtstart.minute,
859 &(impl->last.minute)); 872 &(impl->last.minute));
860 873
861 setup_defaults(impl,BY_HOUR,ICAL_HOURLY_RECURRENCE,impl->dtstart.hour, 874 setup_defaults(impl,BY_HOUR,ICAL_HOURLY_RECURRENCE,
875 impl->dtstart.hour,
862 &(impl->last.hour)); 876 &(impl->last.hour));
863 877
864 setup_defaults(impl,BY_MONTH_DAY,ICAL_DAILY_RECURRENCE,impl->dtstart.day, 878 setup_defaults(impl,BY_MONTH_DAY,ICAL_DAILY_RECURRENCE,
879 impl->dtstart.day,
865 &(impl->last.day)); 880 &(impl->last.day));
866 881
867 setup_defaults(impl,BY_MONTH,ICAL_MONTHLY_RECURRENCE,impl->dtstart.month, 882 setup_defaults(impl,BY_MONTH,ICAL_MONTHLY_RECURRENCE,
883 impl->dtstart.month,
868 &(impl->last.month)); 884 &(impl->last.month));
@@ -876,3 +892,3 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
876 same day of the week as the start time . */ 892 same day of the week as the start time . */
877 impl->by_ptrs[BY_DAY][0] = icaltime_day_of_week(impl->dtstart); 893 impl->by_ptrs[BY_DAY][0] = (short)icaltime_day_of_week(impl->dtstart);
878 894
@@ -890,3 +906,3 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
890 906
891 short dow = impl->by_ptrs[BY_DAY][0]-icaltime_day_of_week(impl->last); 907 short dow = (short)(impl->by_ptrs[BY_DAY][0]-icaltime_day_of_week(impl->last));
892 908
@@ -903,6 +919,20 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
903 919
904 /* For YEARLY rule, begin by setting up the year days array */ 920 /* For YEARLY rule, begin by setting up the year days array . The
921 YEARLY rules work by expanding one year at a time. */
905 922
906 if(impl->rule.freq == ICAL_YEARLY_RECURRENCE){ 923 if(impl->rule.freq == ICAL_YEARLY_RECURRENCE){
907 expand_year_days(impl,impl->last.year); 924 struct icaltimetype next;
925
926 for (;;) {
927 expand_year_days(impl, impl->last.year);
928 if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX)
929 break; /* break when no days are expanded */
930 increment_year(impl,impl->rule.interval);
931 }
932
933 /* Copy the first day into last. */
934 next = icaltime_from_day_of_year(impl->days[0], impl->last.year);
935
936 impl->last.day = next.day;
937 impl->last.month = next.month;
908 } 938 }
@@ -916,9 +946,9 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
916 946
917 short dow = icalrecurrencetype_day_day_of_week( 947 int dow = icalrecurrencetype_day_day_of_week(
918 impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]); 948 impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]);
919 short pos = icalrecurrencetype_day_position( 949 int pos = icalrecurrencetype_day_position(
920 impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]); 950 impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]);
921 951
922 short poscount = 0; 952 int poscount = 0;
923 days_in_month = 953 int days_in_month =
924 icaltime_days_in_month(impl->last.month, impl->last.year); 954 icaltime_days_in_month(impl->last.month, impl->last.year);
@@ -971,9 +1001,5 @@ void icalrecur_iterator_free(icalrecur_iterator* i)
971{ 1001{
1002 icalerror_check_arg_rv((i!=0),"impl");
972 1003
973 struct icalrecur_iterator_impl* impl = 1004 free(i);
974 (struct icalrecur_iterator_impl*)i;
975
976 icalerror_check_arg_rv((impl!=0),"impl");
977
978 free(impl);
979 1005
@@ -981,4 +1007,3 @@ void icalrecur_iterator_free(icalrecur_iterator* i)
981 1007
982 1008static void increment_year(icalrecur_iterator* impl, int inc)
983void increment_year(struct icalrecur_iterator_impl* impl, int inc)
984{ 1009{
@@ -987,6 +1012,6 @@ void increment_year(struct icalrecur_iterator_impl* impl, int inc)
987 1012
988/* Increment month is different that the other incement_* routines -- 1013/** Increment month is different that the other incement_* routines --
989 it figures out the interval for itself, and uses BYMONTH data if 1014 it figures out the interval for itself, and uses BYMONTH data if
990 available. */ 1015 available. */
991void increment_month(struct icalrecur_iterator_impl* impl) 1016static void increment_month(icalrecur_iterator* impl)
992{ 1017{
@@ -1037,3 +1062,3 @@ void increment_month(struct icalrecur_iterator_impl* impl)
1037 1062
1038void increment_monthday(struct icalrecur_iterator_impl* impl, int inc) 1063static void increment_monthday(icalrecur_iterator* impl, int inc)
1039{ 1064{
@@ -1043,4 +1068,4 @@ void increment_monthday(struct icalrecur_iterator_impl* impl, int inc)
1043 1068
1044 short days_in_month = 1069 int days_in_month =
1045 icaltime_days_in_month(impl->last.month,impl->last.year); 1070 icaltime_days_in_month(impl->last.month, impl->last.year);
1046 1071
@@ -1056,5 +1081,5 @@ void increment_monthday(struct icalrecur_iterator_impl* impl, int inc)
1056 1081
1057void increment_hour(struct icalrecur_iterator_impl* impl, int inc) 1082static void increment_hour(icalrecur_iterator* impl, int inc)
1058{ 1083{
1059 short days; 1084 int days;
1060 1085
@@ -1070,5 +1095,5 @@ void increment_hour(struct icalrecur_iterator_impl* impl, int inc)
1070 1095
1071void increment_minute(struct icalrecur_iterator_impl* impl, int inc) 1096static void increment_minute(icalrecur_iterator* impl, int inc)
1072{ 1097{
1073 short hours; 1098 int hours;
1074 1099
@@ -1085,5 +1110,5 @@ void increment_minute(struct icalrecur_iterator_impl* impl, int inc)
1085 1110
1086void increment_second(struct icalrecur_iterator_impl* impl, int inc) 1111static void increment_second(icalrecur_iterator* impl, int inc)
1087{ 1112{
1088 short minutes; 1113 int minutes;
1089 1114
@@ -1104,3 +1129,3 @@ void test_increment()
1104{ 1129{
1105 struct icalrecur_iterator_impl impl; 1130 icalrecur_iterator impl;
1106 1131
@@ -1134,13 +1159,13 @@ void test_increment()
1134 1159
1135short next_second(struct icalrecur_iterator_impl* impl) 1160static int next_second(icalrecur_iterator* impl)
1136{ 1161{
1137 1162
1138 short has_by_data = (impl->by_ptrs[BY_SECOND][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1163 int has_by_second = (impl->by_ptrs[BY_SECOND][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1139 short this_frequency = (impl->rule.freq == ICAL_SECONDLY_RECURRENCE); 1164 int this_frequency = (impl->rule.freq == ICAL_SECONDLY_RECURRENCE);
1140 1165
1141 short end_of_data = 0; 1166 int end_of_data = 0;
1142 1167
1143 assert(has_by_data || this_frequency); 1168 assert(has_by_second || this_frequency);
1144 1169
1145 if( has_by_data ){ 1170 if( has_by_second ){
1146 /* Ignore the frequency and use the byrule data */ 1171 /* Ignore the frequency and use the byrule data */
@@ -1161,3 +1186,3 @@ short next_second(struct icalrecur_iterator_impl* impl)
1161 1186
1162 } else if( !has_by_data && this_frequency ){ 1187 } else if( !has_by_second && this_frequency ){
1163 /* Compute the next value from the last time and the frequency interval*/ 1188 /* Compute the next value from the last time and the frequency interval*/
@@ -1170,3 +1195,3 @@ short next_second(struct icalrecur_iterator_impl* impl)
1170 1195
1171 if(has_by_data && end_of_data && this_frequency ){ 1196 if(has_by_second && end_of_data && this_frequency ){
1172 increment_minute(impl,1); 1197 increment_minute(impl,1);
@@ -1178,11 +1203,11 @@ short next_second(struct icalrecur_iterator_impl* impl)
1178 1203
1179int next_minute(struct icalrecur_iterator_impl* impl) 1204static int next_minute(icalrecur_iterator* impl)
1180{ 1205{
1181 1206
1182 short has_by_data = (impl->by_ptrs[BY_MINUTE][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1207 int has_by_minute = (impl->by_ptrs[BY_MINUTE][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1183 short this_frequency = (impl->rule.freq == ICAL_MINUTELY_RECURRENCE); 1208 int this_frequency = (impl->rule.freq == ICAL_MINUTELY_RECURRENCE);
1184 1209
1185 short end_of_data = 0; 1210 int end_of_data = 0;
1186 1211
1187 assert(has_by_data || this_frequency); 1212 assert(has_by_minute || this_frequency);
1188 1213
@@ -1193,3 +1218,3 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1193 1218
1194 if( has_by_data ){ 1219 if( has_by_minute ){
1195 /* Ignore the frequency and use the byrule data */ 1220 /* Ignore the frequency and use the byrule data */
@@ -1209,3 +1234,3 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1209 1234
1210 } else if( !has_by_data && this_frequency ){ 1235 } else if( !has_by_minute && this_frequency ){
1211 /* Compute the next value from the last time and the frequency interval*/ 1236 /* Compute the next value from the last time and the frequency interval*/
@@ -1217,3 +1242,3 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1217 1242
1218 if(has_by_data && end_of_data && this_frequency ){ 1243 if(has_by_minute && end_of_data && this_frequency ){
1219 increment_hour(impl,1); 1244 increment_hour(impl,1);
@@ -1224,11 +1249,11 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1224 1249
1225int next_hour(struct icalrecur_iterator_impl* impl) 1250static int next_hour(icalrecur_iterator* impl)
1226{ 1251{
1227 1252
1228 short has_by_data = (impl->by_ptrs[BY_HOUR][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1253 int has_by_hour = (impl->by_ptrs[BY_HOUR][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1229 short this_frequency = (impl->rule.freq == ICAL_HOURLY_RECURRENCE); 1254 int this_frequency = (impl->rule.freq == ICAL_HOURLY_RECURRENCE);
1230 1255
1231 short end_of_data = 0; 1256 int end_of_data = 0;
1232 1257
1233 assert(has_by_data || this_frequency); 1258 assert(has_by_hour || this_frequency);
1234 1259
@@ -1238,3 +1263,3 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1238 1263
1239 if( has_by_data ){ 1264 if( has_by_hour ){
1240 /* Ignore the frequency and use the byrule data */ 1265 /* Ignore the frequency and use the byrule data */
@@ -1253,3 +1278,3 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1253 1278
1254 } else if( !has_by_data && this_frequency ){ 1279 } else if( !has_by_hour && this_frequency ){
1255 /* Compute the next value from the last time and the frequency interval*/ 1280 /* Compute the next value from the last time and the frequency interval*/
@@ -1262,3 +1287,3 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1262 1287
1263 if(has_by_data && end_of_data && this_frequency ){ 1288 if(has_by_hour && end_of_data && this_frequency ){
1264 increment_monthday(impl,1); 1289 increment_monthday(impl,1);
@@ -1270,9 +1295,9 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1270 1295
1271int next_day(struct icalrecur_iterator_impl* impl) 1296static int next_day(icalrecur_iterator* impl)
1272{ 1297{
1273 1298
1274 short has_by_data = (impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1299 int has_by_day = (impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1275 short this_frequency = (impl->rule.freq == ICAL_DAILY_RECURRENCE); 1300 int this_frequency = (impl->rule.freq == ICAL_DAILY_RECURRENCE);
1276 1301
1277 assert(has_by_data || this_frequency); 1302 assert(has_by_day || this_frequency);
1278 1303
@@ -1298,10 +1323,10 @@ int next_day(struct icalrecur_iterator_impl* impl)
1298 1323
1299int next_yearday(struct icalrecur_iterator_impl* impl) 1324static int next_yearday(icalrecur_iterator* impl)
1300{ 1325{
1301 1326
1302 short has_by_data = (impl->by_ptrs[BY_YEAR_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1327 int has_by_yearday = (impl->by_ptrs[BY_YEAR_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1303 1328
1304 short end_of_data = 0; 1329 int end_of_data = 0;
1305 1330
1306 assert(has_by_data ); 1331 assert(has_by_yearday );
1307 1332
@@ -1323,3 +1348,3 @@ int next_yearday(struct icalrecur_iterator_impl* impl)
1323 1348
1324 if(has_by_data && end_of_data){ 1349 if(has_by_yearday && end_of_data){
1325 increment_year(impl,1); 1350 increment_year(impl,1);
@@ -1331,58 +1356,11 @@ int next_yearday(struct icalrecur_iterator_impl* impl)
1331 1356
1332/* This routine is only called by next_week. It is certain that BY_DAY
1333has data */
1334
1335int next_weekday_by_week(struct icalrecur_iterator_impl* impl)
1336{
1337
1338 short end_of_data = 0;
1339 short start_of_week, dow;
1340 struct icaltimetype next;
1341
1342 if (next_hour(impl) == 0){
1343 return 0;
1344 }
1345
1346 assert( impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX);
1347
1348 while(1) {
1349
1350 impl->by_indices[BY_DAY]++; /* Look at next elem in BYDAY array */
1351
1352 /* Are we at the end of the BYDAY array? */
1353 if (impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]]
1354 ==ICAL_RECURRENCE_ARRAY_MAX){
1355
1356 impl->by_indices[BY_DAY] = 0; /* Reset to 0 */
1357 end_of_data = 1; /* Signal that we're at the end */
1358 }
1359
1360 /* Add the day of week offset to to the start of this week, and use
1361 that to get the next day */
1362 dow = impl->by_ptrs[BY_DAY][impl->by_indices[BY_DAY]];
1363 start_of_week = icaltime_start_doy_of_week(impl->last);
1364
1365 dow--; /*Sun is 1, not 0 */
1366
1367 if(dow+start_of_week <1 && !end_of_data){
1368 /* The selected date is in the previous year. */
1369 continue;
1370 }
1371
1372 next = icaltime_from_day_of_year(start_of_week + dow,impl->last.year);
1373
1374 impl->last.day = next.day;
1375 impl->last.month = next.month;
1376 impl->last.year = next.year;
1377
1378 return end_of_data;
1379 }
1380 1357
1381} 1358/* Returns the day of the month for the current month of t that is the
1359 pos'th instance of the day-of-week dow */
1382 1360
1383int nth_weekday(short dow, short pos, struct icaltimetype t){ 1361static int nth_weekday(int dow, int pos, struct icaltimetype t){
1384 1362
1385 short days_in_month = icaltime_days_in_month(t.month,t.year); 1363 int days_in_month = icaltime_days_in_month(t.month, t.year);
1386 short end_dow, start_dow; 1364 int end_dow, start_dow;
1387 short wd; 1365 int wd;
1388 1366
@@ -1430,4 +1408,21 @@ int nth_weekday(short dow, short pos, struct icaltimetype t){
1430 1408
1409static int is_day_in_byday(icalrecur_iterator* impl,struct icaltimetype tt){
1410
1411 int idx;
1431 1412
1432int next_month(struct icalrecur_iterator_impl* impl) 1413 for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){
1414 int dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]);
1415 int pos = icalrecurrencetype_day_position(BYDAYPTR[idx]);
1416 int this_dow = icaltime_day_of_week(tt);
1417
1418 if( (pos == 0 && dow == this_dow ) || /* Just a dow, like "TU" or "FR" */
1419 (nth_weekday(dow,pos,tt) == tt.day)){ /*pos+wod: "3FR" or -1TU" */
1420 return 1;
1421 }
1422 }
1423
1424 return 0;
1425}
1426
1427static int next_month(icalrecur_iterator* impl)
1433{ 1428{
@@ -1435,3 +1430,3 @@ int next_month(struct icalrecur_iterator_impl* impl)
1435 1430
1436 short this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE); 1431 int this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE);
1437 1432
@@ -1447,10 +1442,13 @@ int next_month(struct icalrecur_iterator_impl* impl)
1447 1442
1448
1449 /* Now iterate through the occurrences within a month -- by days, 1443 /* Now iterate through the occurrences within a month -- by days,
1450 weeks or weekdays. */ 1444 weeks or weekdays. */
1445
1446 /*
1447 * Case 1:
1448 * Rules Like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=13
1449 */
1451 1450
1452 if(has_by_data(impl,BY_DAY) && has_by_data(impl,BY_MONTH_DAY)){ 1451 if(has_by_data(impl,BY_DAY) && has_by_data(impl,BY_MONTH_DAY)){
1453 /* Cases like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=13 */ 1452 int day, idx,j;
1454 short day, idx,j; 1453 int days_in_month = icaltime_days_in_month(impl->last.month,
1455 short days_in_month = icaltime_days_in_month(impl->last.month,
1456 impl->last.year); 1454 impl->last.year);
@@ -1465,7 +1463,7 @@ int next_month(struct icalrecur_iterator_impl* impl)
1465 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){ 1463 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
1466 short dow = 1464 int dow =
1467 icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]); 1465 icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]);
1468 short pos = icalrecurrencetype_day_position(BYDAYPTR[idx]); 1466 int pos = icalrecurrencetype_day_position(BYDAYPTR[idx]);
1469 short mday = BYMDPTR[j]; 1467 int mday = BYMDPTR[j];
1470 short this_dow; 1468 int this_dow;
1471 1469
@@ -1490,5 +1488,9 @@ int next_month(struct icalrecur_iterator_impl* impl)
1490 1488
1491 1489
1490 /*
1491 * Case 2:
1492 * Rules Like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR
1493 */
1494
1492 } else if(has_by_data(impl,BY_DAY)){ 1495 } else if(has_by_data(impl,BY_DAY)){
1493 /* Cases like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR */
1494 /* For this case, the weekdays are relative to the 1496 /* For this case, the weekdays are relative to the
@@ -1496,27 +1498,18 @@ int next_month(struct icalrecur_iterator_impl* impl)
1496 1498
1497 short day, idx; 1499 /* This code iterates through the remaining days in the month
1498 short days_in_month = icaltime_days_in_month(impl->last.month, 1500 and checks if each day is listed in the BY_DAY array. This
1499 impl->last.year); 1501 seems very inneficient, but I think it is the simplest way to
1502 account for both BYDAY=1FR (First friday in month) and
1503 BYDAY=FR ( every friday in month ) */
1500 1504
1505 int day;
1506 int days_in_month = icaltime_days_in_month(impl->last.month,
1507 impl->last.year);
1501 assert( BYDAYPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX); 1508 assert( BYDAYPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
1502 1509
1503 /* Iterate through the remaining days in the month and check if
1504 each day is listed in the BY_DAY array. This seems very
1505 inneficient, but I think it is the simplest way to account
1506 for both BYDAY=1FR (First friday in month) and BYDAY=FR (
1507 every friday in month ) */
1508
1509 for(day = impl->last.day+1; day <= days_in_month; day++){ 1510 for(day = impl->last.day+1; day <= days_in_month; day++){
1510 for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){ 1511 impl->last.day = day;
1511 short dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]); 1512 if(is_day_in_byday(impl,impl->last)){
1512 short pos = icalrecurrencetype_day_position(BYDAYPTR[idx]); 1513 data_valid = 1;
1513 short this_dow; 1514 break;
1514
1515 impl->last.day = day;
1516 this_dow = icaltime_day_of_week(impl->last);
1517
1518 if( (pos == 0 && dow == this_dow ) ||
1519 (nth_weekday(dow,pos,impl->last) == day)){
1520 goto DEND;
1521 }
1522 } 1515 }
@@ -1524,4 +1517,2 @@ int next_month(struct icalrecur_iterator_impl* impl)
1524 1517
1525 DEND:
1526
1527 if ( day > days_in_month){ 1518 if ( day > days_in_month){
@@ -1529,8 +1520,21 @@ int next_month(struct icalrecur_iterator_impl* impl)
1529 increment_month(impl); 1520 increment_month(impl);
1530 data_valid = 0; /* signal that impl->last is invalid */ 1521
1522 /* Did moving to the next month put us on a valid date? if
1523 so, note that the new data is valid, if, not, mark it
1524 invalid */
1525
1526 if(is_day_in_byday(impl,impl->last)){
1527 data_valid = 1;
1528 } else {
1529 data_valid = 0; /* signal that impl->last is invalid */
1530 }
1531 } 1531 }
1532 1532
1533 /*
1534 * Case 3
1535 * Rules Like: FREQ=MONTHLY;COUNT=10;BYMONTHDAY=-3
1536 */
1537
1533 } else if (has_by_data(impl,BY_MONTH_DAY)) { 1538 } else if (has_by_data(impl,BY_MONTH_DAY)) {
1534 /* Cases like: FREQ=MONTHLY;COUNT=10;BYMONTHDAY=-3 */ 1539 int day;
1535 short day;
1536 1540
@@ -1550,4 +1554,3 @@ int next_month(struct icalrecur_iterator_impl* impl)
1550 if (day < 0) { 1554 if (day < 0) {
1551 day = icaltime_days_in_month(impl->last.month,impl->last.year)+ 1555 day = icaltime_days_in_month(impl->last.month, impl->last.year) + day + 1;
1552 day + 1;
1553 } 1556 }
@@ -1560,3 +1563,3 @@ int next_month(struct icalrecur_iterator_impl* impl)
1560 1563
1561 return data_valid; /* Signal that the data is valid */ 1564 return data_valid;
1562 1565
@@ -1564,10 +1567,64 @@ int next_month(struct icalrecur_iterator_impl* impl)
1564 1567
1568static int next_weekday_by_week(icalrecur_iterator* impl)
1569{
1570
1571 int end_of_data = 0;
1572 int start_of_week, dow;
1573 struct icaltimetype next;
1574
1575 if (next_hour(impl) == 0){
1576 return 0;
1577 }
1578
1579 if(!has_by_data(impl,BY_DAY)){
1580 return 1;
1581 }
1582
1583 /* If we get here, we need to step to tne next day */
1584
1585 for (;;) {
1586 struct icaltimetype tt = icaltime_null_time();
1587 BYDAYIDX++; /* Look at next elem in BYDAY array */
1588
1589 /* Are we at the end of the BYDAY array? */
1590 if (BYDAYPTR[BYDAYIDX]==ICAL_RECURRENCE_ARRAY_MAX){
1591 BYDAYIDX = 0; /* Reset to 0 */
1592 end_of_data = 1; /* Signal that we're at the end */
1593 }
1594
1595 /* Add the day of week offset to to the start of this week, and use
1596 that to get the next day */
1597 /* ignore position of dow ("4FR"), only use dow ("FR")*/
1598 dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[BYDAYIDX]);
1599 tt.year = impl->last.year;
1600 tt.day = impl->last.day;
1601 tt.month = impl->last.month;
1602
1603 start_of_week = icaltime_start_doy_of_week(tt);
1604
1605 dow--; /* Set Sunday to be 0 */
1606
1607 if(dow+start_of_week <1){
1608 /* The selected date is in the previous year. */
1609 if(!end_of_data){
1610 continue;
1611 }
1612 }
1613
1614 next = icaltime_from_day_of_year(start_of_week + dow,impl->last.year);
1615
1616 impl->last.day = next.day;
1617 impl->last.month = next.month;
1618 impl->last.year = next.year;
1619
1620 return end_of_data;
1621 }
1622
1623}
1565 1624
1566int next_week(struct icalrecur_iterator_impl* impl) 1625static int next_week(icalrecur_iterator* impl)
1567{ 1626{
1568 short has_by_data = (impl->by_ptrs[BY_WEEK_NO][0]!=ICAL_RECURRENCE_ARRAY_MAX); 1627 int end_of_data = 0;
1569 short this_frequency = (impl->rule.freq == ICAL_WEEKLY_RECURRENCE);
1570 short end_of_data = 0;
1571 1628
1572 /* Increment to the next week day */ 1629 /* Increment to the next week day, if there is data at a level less than a week */
1573 if (next_weekday_by_week(impl) == 0){ 1630 if (next_weekday_by_week(impl) == 0){
@@ -1579,4 +1636,4 @@ int next_week(struct icalrecur_iterator_impl* impl)
1579 1636
1580 1637 if( has_by_data(impl,BY_WEEK_NO)){
1581 if( has_by_data){ 1638 /*FREQ=WEEKLY;BYWEEK=20*/
1582 /* Use the Week Number byrule data */ 1639 /* Use the Week Number byrule data */
@@ -1604,4 +1661,4 @@ int next_week(struct icalrecur_iterator_impl* impl)
1604 1661
1605 } else if( !has_by_data && this_frequency ){ 1662 } else {
1606 /* If there is no BY_WEEK_NO data, just jump forward 7 days. */ 1663 /* Jump to the next week */
1607 increment_monthday(impl,7*impl->rule.interval); 1664 increment_monthday(impl,7*impl->rule.interval);
@@ -1609,4 +1666,3 @@ int next_week(struct icalrecur_iterator_impl* impl)
1609 1666
1610 1667 if( has_by_data(impl,BY_WEEK_NO) && end_of_data){
1611 if(has_by_data && end_of_data && this_frequency ){
1612 increment_year(impl,1); 1668 increment_year(impl,1);
@@ -1618,4 +1674,4 @@ int next_week(struct icalrecur_iterator_impl* impl)
1618 1674
1619/* Expand the BYDAY rule part and return a pointer to a newly allocated list of days. */ 1675/** Expand the BYDAY rule part and return a pointer to a newly allocated list of days. */
1620pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year) 1676static pvl_list expand_by_day(icalrecur_iterator* impl, int year)
1621{ 1677{
@@ -1625,3 +1681,3 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1625 1681
1626 short start_dow, end_dow, end_year_day, start_doy; 1682 int start_dow, end_dow, end_year_day;
1627 struct icaltimetype tmp = impl->last; 1683 struct icaltimetype tmp = impl->last;
@@ -1633,10 +1689,10 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1633 1689
1690 /* Find the day that 1st Jan falls on, 1 (Sun) to 7 (Sat). */
1634 start_dow = icaltime_day_of_week(tmp); 1691 start_dow = icaltime_day_of_week(tmp);
1635 start_doy = icaltime_start_doy_of_week(tmp);
1636 1692
1637 /* Get the last day of the year*/ 1693 /* Get the last day of the year*/
1638 tmp.year++; 1694 tmp.year= year;
1639 tmp = icaltime_normalize(tmp); 1695 tmp.month = 12;
1640 tmp.day--; 1696 tmp.day = 31;
1641 tmp = icaltime_normalize(tmp); 1697 tmp.is_date = 1;
1642 1698
@@ -1646,5 +1702,6 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1646 for(i = 0; BYDAYPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){ 1702 for(i = 0; BYDAYPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
1647 short dow = 1703 /* This is 1 (Sun) to 7 (Sat). */
1704 int dow =
1648 icalrecurrencetype_day_day_of_week(BYDAYPTR[i]); 1705 icalrecurrencetype_day_day_of_week(BYDAYPTR[i]);
1649 short pos = icalrecurrencetype_day_position(BYDAYPTR[i]); 1706 int pos = icalrecurrencetype_day_position(BYDAYPTR[i]);
1650 1707
@@ -1654,12 +1711,9 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1654 days of the year with this day-of-week*/ 1711 days of the year with this day-of-week*/
1655 int week; 1712 int doy, tmp_start_doy;
1656 for(week = 0; week < 52 ; week ++){
1657 short doy = start_doy + (week * 7) + dow-1;
1658 1713
1659 if(doy > end_year_day){ 1714 tmp_start_doy = ((dow + 7 - start_dow) % 7) + 1;
1660 break; 1715
1661 } else { 1716 for (doy = tmp_start_doy; doy <= end_year_day; doy += 7)
1662 pvl_push(days_list,(void*)(int)doy); 1717 pvl_push(days_list,(void*)(int)doy);
1663 } 1718
1664 }
1665 } else if ( pos > 0) { 1719 } else if ( pos > 0) {
@@ -1673,3 +1727,3 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1673 1727
1674 /* THen just multiple the position times 7 to get the pos'th day in the year */ 1728 /* Then just multiple the position times 7 to get the pos'th day in the year */
1675 pvl_push(days_list,(void*)(first+ (pos-1) * 7)); 1729 pvl_push(days_list,(void*)(first+ (pos-1) * 7));
@@ -1698,3 +1752,3 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1698 1752
1699int expand_year_days(struct icalrecur_iterator_impl* impl,short year) 1753static int expand_year_days(icalrecur_iterator* impl, int year)
1700{ 1754{
@@ -1705,3 +1759,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1705 1759
1706 t = icaltime_null_time(); 1760 t = icaltime_null_date();
1707 1761
@@ -1709,7 +1763,8 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1709 1763
1710 t.is_date = 1; /* Needed to make day_of_year routines work property */
1711
1712 memset(&t,0,sizeof(t));
1713 memset(impl->days,ICAL_RECURRENCE_ARRAY_MAX_BYTE,sizeof(impl->days)); 1764 memset(impl->days,ICAL_RECURRENCE_ARRAY_MAX_BYTE,sizeof(impl->days));
1714 1765
1766 /* The flags and the following switch statement select which code
1767 to use to expand the yers days, based on which BY-rules are
1768 present. */
1769
1715 flags = (HBD(BY_DAY) ? 1<<BY_DAY : 0) + 1770 flags = (HBD(BY_DAY) ? 1<<BY_DAY : 0) +
@@ -1725,3 +1780,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1725 /* FREQ=YEARLY; */ 1780 /* FREQ=YEARLY; */
1781 t = impl->dtstart;
1782 t.year = impl->last.year;
1726 1783
1784 impl->days[days_index++] = (short)icaltime_day_of_year(t);
1785
1727 break; 1786 break;
@@ -1732,5 +1791,4 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1732 for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ 1791 for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
1733 struct icaltimetype t; 1792 int month = impl->by_ptrs[BY_MONTH][j];
1734 short month = impl->by_ptrs[BY_MONTH][j]; 1793 int doy;
1735 short doy;
1736 1794
@@ -1743,3 +1801,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1743 1801
1744 impl->days[days_index++] = doy; 1802 impl->days[days_index++] = (short)doy;
1745 1803
@@ -1753,4 +1811,4 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1753 { 1811 {
1754 short month_day = impl->by_ptrs[BY_MONTH_DAY][k]; 1812 int month_day = impl->by_ptrs[BY_MONTH_DAY][k];
1755 short doy; 1813 int doy;
1756 1814
@@ -1763,3 +1821,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1763 1821
1764 impl->days[days_index++] = doy; 1822 impl->days[days_index++] = (short)doy;
1765 1823
@@ -1775,5 +1833,5 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1775 { 1833 {
1776 short month = impl->by_ptrs[BY_MONTH][j]; 1834 int month = impl->by_ptrs[BY_MONTH][j];
1777 short month_day = impl->by_ptrs[BY_MONTH_DAY][k]; 1835 int month_day = impl->by_ptrs[BY_MONTH_DAY][k];
1778 short doy; 1836 int doy;
1779 1837
@@ -1786,3 +1844,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1786 1844
1787 impl->days[days_index++] = doy; 1845 impl->days[days_index++] = (short)doy;
1788 1846
@@ -1797,4 +1855,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1797 1855
1798 struct icaltimetype t; 1856 int dow;
1799 short dow;
1800 1857
@@ -1821,3 +1878,2 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1821 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR*/ 1878 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR*/
1822 int days_index = 0;
1823 pvl_elem i; 1879 pvl_elem i;
@@ -1827,3 +1883,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1827 for(i=pvl_head(days);i!=0;i=pvl_next(i)){ 1883 for(i=pvl_head(days);i!=0;i=pvl_next(i)){
1828 short day = (short)(int)pvl_data(i); 1884 short day = (short)(*((int*)pvl_data(i)));
1829 impl->days[days_index++] = day; 1885 impl->days[days_index++] = day;
@@ -1839,27 +1895,55 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1839 1895
1840 int days_index = 0;
1841 pvl_elem itr;
1842 pvl_list days = expand_by_day(impl,year);
1843 1896
1844 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){ 1897 for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
1845 short doy = (short)(int)pvl_data(itr); 1898 int month = impl->by_ptrs[BY_MONTH][j];
1846 struct icaltimetype tt; 1899 int days_in_month = icaltime_days_in_month(month,year);
1847 short j; 1900 int first_dow, last_dow, doy_offset;
1848 1901
1849 tt = icaltime_from_day_of_year(doy,year); 1902 t.year = year;
1903 t.month = month;
1904 t.day = 1;
1905 t.is_date = 1;
1850 1906
1851 for(j=0; 1907 first_dow = icaltime_day_of_week(t);
1852 impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;
1853 j++){
1854 short month = impl->by_ptrs[BY_MONTH][j];
1855 1908
1856 if(tt.month == month){ 1909 /* This holds the day offset used to calculate the day of the year
1857 impl->days[days_index++] = doy; 1910 from the month day. Just add the month day to this. */
1858 } 1911 doy_offset = icaltime_day_of_year(t) - 1;
1859 }
1860 1912
1861 } 1913 t.day = days_in_month;
1914 last_dow = icaltime_day_of_week(t);
1862 1915
1863 pvl_free(days); 1916 for(k=0;impl->by_ptrs[BY_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++){
1917 short day_coded = impl->by_ptrs[BY_DAY][k];
1918 enum icalrecurrencetype_weekday dow =
1919 icalrecurrencetype_day_day_of_week(day_coded);
1920 int pos = icalrecurrencetype_day_position(day_coded);
1921 int first_matching_day, last_matching_day, day, month_day;
1922
1923 /* Calculate the first day in the month with the given weekday,
1924 and the last day. */
1925 first_matching_day = ((dow + 7 - first_dow) % 7) + 1;
1926 last_matching_day = days_in_month - ((last_dow + 7 - dow) % 7);
1927
1928 if (pos == 0) {
1929 /* Add all of instances of the weekday within the month. */
1930 for (day = first_matching_day; day <= days_in_month; day += 7)
1931 impl->days[days_index++] = (short)(doy_offset + day);
1932
1933 } else if (pos > 0) {
1934 /* Add the nth instance of the weekday within the month. */
1935 month_day = first_matching_day + (pos - 1) * 7;
1936
1937 if (month_day <= days_in_month)
1938 impl->days[days_index++] = (short)(doy_offset + month_day);
1864 1939
1940 } else {
1941 /* Add the -nth instance of the weekday within the month.*/
1942 month_day = last_matching_day + (pos + 1) * 7;
1943
1944 if (month_day > 0)
1945 impl->days[days_index++] = (short)(doy_offset + month_day);
1946 }
1947 }
1948 }
1865 break; 1949 break;
@@ -1870,3 +1954,2 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1870 1954
1871 int days_index = 0;
1872 pvl_elem itr; 1955 pvl_elem itr;
@@ -1875,5 +1958,4 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1875 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){ 1958 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
1876 short day = (short)(int)pvl_data(itr); 1959 short day = (short)(*((int*)pvl_data(itr)));
1877 struct icaltimetype tt; 1960 struct icaltimetype tt;
1878 short j;
1879 1961
@@ -1882,3 +1964,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1882 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){ 1964 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
1883 short mday = BYMDPTR[j]; 1965 int mday = BYMDPTR[j];
1884 1966
@@ -1899,3 +1981,2 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1899 1981
1900 int days_index = 0;
1901 pvl_elem itr; 1982 pvl_elem itr;
@@ -1904,5 +1985,5 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1904 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){ 1985 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
1905 short day = (short)(int)pvl_data(itr); 1986 short day = (short)(*((int*)pvl_data(itr)));
1906 struct icaltimetype tt; 1987 struct icaltimetype tt;
1907 short i,j; 1988 int i;
1908 1989
@@ -1912,4 +1993,4 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1912 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){ 1993 for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){
1913 short mday = BYMDPTR[j]; 1994 int mday = BYMDPTR[j];
1914 short month = BYMONPTR[i]; 1995 int month = BYMONPTR[i];
1915 1996
@@ -1932,3 +2013,2 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1932 2013
1933 int days_index = 0;
1934 pvl_elem itr; 2014 pvl_elem itr;
@@ -1937,5 +2017,5 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1937 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){ 2017 for(itr=pvl_head(days);itr!=0;itr=pvl_next(itr)){
1938 short day = (short)(int)pvl_data(itr); 2018 short day = (short)(*((int*)pvl_data(itr)));
1939 struct icaltimetype tt; 2019 struct icaltimetype tt;
1940 short i; 2020 int i;
1941 2021
@@ -1944,5 +2024,5 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1944 for(i = 0; BYWEEKPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){ 2024 for(i = 0; BYWEEKPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
1945 short weekno = BYWEEKPTR[i]; 2025 int weekno = BYWEEKPTR[i];
1946 2026 int this_weekno = icaltime_week_number(tt);
1947 if(weekno== icaltime_week_number(tt)){ 2027 if(weekno== this_weekno){
1948 impl->days[days_index++] = day; 2028 impl->days[days_index++] = day;
@@ -1965,4 +2045,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1965 for(j=0;impl->by_ptrs[BY_YEAR_DAY][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ 2045 for(j=0;impl->by_ptrs[BY_YEAR_DAY][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
1966 short doy = impl->by_ptrs[BY_YEAR_DAY][j]; 2046 impl->days[days_index++] = impl->by_ptrs[BY_YEAR_DAY][j];
1967 impl->days[days_index++] = doy;
1968 } 2047 }
@@ -1982,3 +2061,3 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1982 2061
1983int next_year(struct icalrecur_iterator_impl* impl) 2062static int next_year(icalrecur_iterator* impl)
1984{ 2063{
@@ -1986,5 +2065,4 @@ int next_year(struct icalrecur_iterator_impl* impl)
1986 2065
1987 /* Next_year does it's own interatio in days, so the next level down is hours */
1988 if (next_hour(impl) == 0){ 2066 if (next_hour(impl) == 0){
1989 return 1; 2067 return 0;
1990 } 2068 }
@@ -1993,11 +2071,12 @@ int next_year(struct icalrecur_iterator_impl* impl)
1993 impl->days_index = 0; 2071 impl->days_index = 0;
2072
2073 for (;;) {
1994 increment_year(impl,impl->rule.interval); 2074 increment_year(impl,impl->rule.interval);
1995 expand_year_days(impl,impl->last.year); 2075 expand_year_days(impl,impl->last.year);
2076 if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX)
2077 break;
1996 } 2078 }
1997
1998 if(impl->days[0] == ICAL_RECURRENCE_ARRAY_MAX) {
1999 return 0;
2000 } 2079 }
2001 2080
2002 next = icaltime_from_day_of_year(impl->days[impl->days_index],impl->last.year); 2081 next = icaltime_from_day_of_year(impl->days[impl->days_index], impl->last.year);
2003 2082
@@ -2009,4 +2088,4 @@ int next_year(struct icalrecur_iterator_impl* impl)
2009 2088
2010int icalrecur_check_rulepart(struct icalrecur_iterator_impl* impl, 2089int icalrecur_check_rulepart(icalrecur_iterator* impl,
2011 short v, enum byrule byrule) 2090 int v, enum byrule byrule)
2012{ 2091{
@@ -2025,4 +2104,4 @@ int icalrecur_check_rulepart(struct icalrecur_iterator_impl* impl,
2025 2104
2026int check_contract_restriction(struct icalrecur_iterator_impl* impl, 2105static int check_contract_restriction(icalrecur_iterator* impl,
2027 enum byrule byrule, short v) 2106 enum byrule byrule, int v)
2028{ 2107{
@@ -2050,18 +2129,18 @@ int check_contract_restriction(struct icalrecur_iterator_impl* impl,
2050 2129
2051int check_contracting_rules(struct icalrecur_iterator_impl* impl) 2130static int check_contracting_rules(icalrecur_iterator* impl)
2052{ 2131{
2053 2132
2054 int day_of_week=0; 2133 int day_of_week = icaltime_day_of_week(impl->last);
2055 int week_no=0; 2134 int week_no = icaltime_week_number(impl->last);
2056 int year_day=0; 2135 int year_day = icaltime_day_of_year(impl->last);
2057 2136
2058 if ( 2137 if (
2059 check_contract_restriction(impl,BY_SECOND,impl->last.second) && 2138 check_contract_restriction(impl,BY_SECOND, impl->last.second) &&
2060 check_contract_restriction(impl,BY_MINUTE,impl->last.minute) && 2139 check_contract_restriction(impl,BY_MINUTE, impl->last.minute) &&
2061 check_contract_restriction(impl,BY_HOUR,impl->last.hour) && 2140 check_contract_restriction(impl,BY_HOUR, impl->last.hour) &&
2062 check_contract_restriction(impl,BY_DAY,day_of_week) && 2141 check_contract_restriction(impl,BY_DAY, day_of_week) &&
2063 check_contract_restriction(impl,BY_WEEK_NO,week_no) && 2142 check_contract_restriction(impl,BY_WEEK_NO, week_no) &&
2064 check_contract_restriction(impl,BY_MONTH_DAY,impl->last.day) && 2143 check_contract_restriction(impl,BY_MONTH_DAY, impl->last.day) &&
2065 check_contract_restriction(impl,BY_MONTH,impl->last.month) && 2144 check_contract_restriction(impl,BY_MONTH, impl->last.month) &&
2066 check_contract_restriction(impl,BY_YEAR_DAY,year_day) ) 2145 check_contract_restriction(impl,BY_YEAR_DAY, year_day) )
2067 { 2146 {
@@ -2074,7 +2153,5 @@ int check_contracting_rules(struct icalrecur_iterator_impl* impl)
2074 2153
2075struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr) 2154struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *impl)
2076{ 2155{
2077 int valid = 1; 2156 int valid = 1;
2078 struct icalrecur_iterator_impl* impl =
2079 (struct icalrecur_iterator_impl*)itr;
2080 2157
@@ -2122,3 +2199,3 @@ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr)
2122 case ICAL_YEARLY_RECURRENCE:{ 2199 case ICAL_YEARLY_RECURRENCE:{
2123 valid = next_year(impl); 2200 next_year(impl);
2124 break; 2201 break;
@@ -2137,3 +2214,3 @@ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr)
2137 } while(!check_contracting_rules(impl) 2214 } while(!check_contracting_rules(impl)
2138 || icaltime_compare(impl->last,impl->dtstart) <= 0 2215 || icaltime_compare(impl->last,impl->dtstart) < 0
2139 || valid == 0); 2216 || valid == 0);
@@ -2168,12 +2245,11 @@ void icalrecurrencetype_clear(struct icalrecurrencetype *recur)
2168 2245
2169/* The 'day' element of icalrecurrencetype_weekday is encoded to allow 2246/** The 'day' element of icalrecurrencetype_weekday is encoded to
2170reporesentation of both the day of the week ( Monday, Tueday), but 2247 * allow representation of both the day of the week ( Monday, Tueday),
2171also the Nth day of the week ( First tuesday of the month, last 2248 * but also the Nth day of the week ( First tuesday of the month, last
2172thursday of the year) These routines decode the day values. 2249 * thursday of the year) These routines decode the day values.
2173 2250 *
2174The day's position in the period ( Nth-ness) and the numerical value 2251 * The day's position in the period ( Nth-ness) and the numerical
2175of the day are encoded together as: pos*7 + dow 2252 * value of the day are encoded together as: pos*7 + dow
2176 2253 *
2177A position of 0 means 'any' or 'every' 2254 * A position of 0 means 'any' or 'every'
2178
2179 */ 2255 */
@@ -2185,5 +2261,5 @@ enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
2185 2261
2186short icalrecurrencetype_day_position(short day) 2262int icalrecurrencetype_day_position(short day)
2187{ 2263{
2188 short wd, pos; 2264 int wd, pos;
2189 2265
@@ -2200,3 +2276,3 @@ short icalrecurrencetype_day_position(short day)
2200 2276
2201struct {icalrecurrencetype_weekday wd; const char * str; } 2277static struct {icalrecurrencetype_weekday wd; const char * str; }
2202wd_map[] = { 2278wd_map[] = {
@@ -2240,3 +2316,3 @@ icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str)
2240 2316
2241struct { 2317static struct {
2242 icalrecurrencetype_frequency kind; 2318 icalrecurrencetype_frequency kind;
@@ -2278,6 +2354,7 @@ icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str)
2278 2354
2279/* Fill an array with the 'count' number of occurrences generated by 2355/** Fill an array with the 'count' number of occurrences generated by
2280 the rrule. Note that the times are returned in UTC, but the times 2356 * the rrule. Note that the times are returned in UTC, but the times
2281 are calculated in local time. YOu will have to convert the results 2357 * are calculated in local time. YOu will have to convert the results
2282 back into local time before using them. */ 2358 * back into local time before using them.
2359 */
2283 2360
@@ -2294,3 +2371,3 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
2294 2371
2295 icstart = icaltime_from_timet(start,0); 2372 icstart = icaltime_from_timet_with_zone(start,0,0);
2296 2373
diff --git a/libical/src/libical/icalrecur.h b/libical/src/libical/icalrecur.h
index 5fcdc15..5f6ac55 100644
--- a/libical/src/libical/icalrecur.h
+++ b/libical/src/libical/icalrecur.h
@@ -18,2 +18,7 @@
18 the License at http://www.mozilla.org/MPL/ 18 the License at http://www.mozilla.org/MPL/
19*/
20
21/**
22@file icalrecur.h
23@brief Routines for dealing with recurring time
19 24
@@ -22,2 +27,4 @@ How to use:
221) Get a rule and a start time from a component 271) Get a rule and a start time from a component
28
29@code
23 icalproperty rrule; 30 icalproperty rrule;
@@ -29,12 +36,21 @@ How to use:
29 start = icalproperty_get_dtstart(dtstart); 36 start = icalproperty_get_dtstart(dtstart);
37@endcode
30 38
31Or, just make them up: 39Or, just make them up:
40
41@code
32 recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); 42 recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE");
33 dtstart = icaltime_from_string("19970101T123000") 43 dtstart = icaltime_from_string("19970101T123000")
44@endcode
34 45
352) Create an iterator 462) Create an iterator
47
48@code
36 icalrecur_iterator* ritr; 49 icalrecur_iterator* ritr;
37 ritr = icalrecur_iterator_new(recur,start); 50 ritr = icalrecur_iterator_new(recur,start);
51@endcode
38 52
393) Iterator over the occurrences 533) Iterator over the occurrences
54
55@code
40 struct icaltimetype next; 56 struct icaltimetype next;
@@ -44,2 +60,3 @@ Or, just make them up:
44 } 60 }
61@endcode
45 62
@@ -48,3 +65,3 @@ whatever timezone that dtstart is in.
48 65
49======================================================================*/ 66*/
50 67
@@ -56,5 +73,5 @@ whatever timezone that dtstart is in.
56 73
57/*********************************************************************** 74/*
58 * Recurrance enumerations 75 * Recurrance enumerations
59**********************************************************************/ 76 */
60 77
@@ -95,3 +112,5 @@ enum {
95 112
96/********************** Recurrence type routines **************/ 113/**
114 * Recurrence type routines
115 */
97 116
@@ -110,3 +129,3 @@ enum {
110 129
111/* Main struct for holding digested recurrence rules */ 130/** Main struct for holding digested recurrence rules */
112struct icalrecurrencetype 131struct icalrecurrencetype
@@ -147,19 +166,21 @@ void icalrecurrencetype_clear(struct icalrecurrencetype *r);
147 166
148/* The 'day' element of the by_day array is encoded to allow 167/**
149representation of both the day of the week ( Monday, Tueday), but also 168 * Array Encoding
150the Nth day of the week ( First tuesday of the month, last thursday of 169 *
151the year) These routines decode the day values */ 170 * The 'day' element of the by_day array is encoded to allow
171 * representation of both the day of the week ( Monday, Tueday), but also
172 * the Nth day of the week ( First tuesday of the month, last thursday of
173 * the year) These routines decode the day values
174 */
152 175
153/* 1 == Monday, etc. */ 176/** 1 == Monday, etc. */
154enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); 177enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
155 178
156/* 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ 179/** 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */
157short icalrecurrencetype_day_position(short day); 180int icalrecurrencetype_day_position(short day);
158 181
159 182
160/*********************************************************************** 183/** Recurrance rule parser */
161 * Recurrance rule parser
162**********************************************************************/
163 184
164/* Convert between strings ans recurrencetype structures. */ 185/** Convert between strings and recurrencetype structures. */
165struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); 186struct icalrecurrencetype icalrecurrencetype_from_string(const char* str);
@@ -168,7 +189,7 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
168 189
169/********** recurrence iteration routines ********************/ 190/** Recurrence iteration routines */
170 191
171typedef void icalrecur_iterator; 192typedef struct icalrecur_iterator_impl icalrecur_iterator;
172 193
173/* Create a new recurrence rule iterator */ 194/** Create a new recurrence rule iterator */
174icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, 195icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
@@ -176,10 +197,14 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
176 197
177/* Get the next occurrence from an iterator */ 198/** Get the next occurrence from an iterator */
178struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); 199struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*);
179 200
180/* Free the iterator */ 201void icalrecur_iterator_decrement_count(icalrecur_iterator*);
202
203/** Free the iterator */
181void icalrecur_iterator_free(icalrecur_iterator*); 204void icalrecur_iterator_free(icalrecur_iterator*);
182 205
183/* Fills array up with at most 'count' time_t values, each 206/**
184 representing an occurrence time in seconds past the POSIX epoch */ 207 * Fills array up with at most 'count' time_t values, each
208 * representing an occurrence time in seconds past the POSIX epoch
209 */
185int icalrecur_expand_recurrence(char* rule, time_t start, 210int icalrecur_expand_recurrence(char* rule, time_t start,
diff --git a/libical/src/libical/icalrestriction.c b/libical/src/libical/icalrestriction.c
index 0f863c4..3d2bd15 100644
--- a/libical/src/libical/icalrestriction.c
+++ b/libical/src/libical/icalrestriction.c
@@ -19,6 +19,9 @@
19 19
20int snprintf(char *str, size_t n, char const *fmt, ...);
21
22#define TMP_BUF_SIZE 1024 20#define TMP_BUF_SIZE 1024
23 21
22#ifdef WIN32
23 #define snprintf_snprintf
24 #define strcasecmpstricmp
25#endif
26
24 27
@@ -65,3 +68,3 @@ icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_
65 68
66/* The each row gives the result of comparing a restriction against a 69/** The each row gives the result of comparing a restriction against a
67 count. The columns in each row represent 0,1,2+. '-1' indicates 70 count. The columns in each row represent 0,1,2+. '-1' indicates
@@ -223,3 +226,3 @@ char* icalrestriction_must_have_duration(icalrestriction_property_record *rec,
223 226
224 return "Failed iTIP restrictions for STATUS property. This component must have a DURATION property"; 227 return "Failed iTIP restrictions. This component must have a DURATION property";
225 228
@@ -234,3 +237,3 @@ char* icalrestriction_must_have_repeat(icalrestriction_property_record *rec,
234 237
235 return "Failed iTIP restrictions for STATUS property. This component must have a REPEAT property"; 238 return "Failed iTIP restrictions. This component must have a REPEAT property";
236 239
@@ -251,5 +254,5 @@ char* icalrestriction_no_dtend(icalrestriction_property_record *rec,
251 254
252 if( !icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){ 255 if( icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){
253 256
254 return "Failed iTIP restrictions for STATUS property. The component must not have both DURATION and DTEND"; 257 return "Failed iTIP restrictions. The component must not have both DURATION and DTEND";
255 258
@@ -266,3 +269,17 @@ char* icalrestriction_no_duration(icalrestriction_property_record *rec,
266} 269}
270char* icalrestriction_must_be_email(
271 icalrestriction_property_record *rec,
272 icalcomponent* comp,
273 icalproperty* prop)
274{
275 icalproperty_status stat = icalproperty_get_action(prop);
267 276
277 if( !( stat == ICAL_ACTION_EMAIL)){
278
279 return "Failed iTIP restrictions for ACTION property. Value must be EMAIL.";
280
281 }
282
283 return 0;
284}
268 285
@@ -274,4 +291,3 @@ int icalrestriction_check_component(icalproperty_method method,
274 icalrestriction_kind restr; 291 icalrestriction_kind restr;
275 icalrestriction_property_record *prop_record = 0L; 292 icalrestriction_property_record *prop_record;
276 icalrestriction_component_record *comp_record = 0L;
277 char* funcr = 0; 293 char* funcr = 0;
@@ -465,4 +481,4 @@ icalrestriction_property_record icalrestriction_property_records[] = {
465 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 481 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
466 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 482 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration},
467 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 483 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_dtend},
468 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 484 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -483,2 +499,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
483 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 499 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
500 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
484 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 501 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
@@ -515,2 +532,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
515 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 532 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
533 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
516 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0}, 534 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -547,2 +565,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
547 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 565 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
566 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
548 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 567 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -562,3 +581,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
562 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 581 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration},
563 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 582 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_dtend},
564 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 583 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -579,2 +598,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
579 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 598 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
599 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
580 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 600 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -593,3 +613,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
593 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 613 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
594 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 614 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_dtend},
595 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 615 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -611,2 +631,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
611 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 631 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
632 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
612 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0}, 633 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -643,2 +664,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
643 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 664 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0},
665 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
644 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 666 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -658,3 +680,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
658 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 680 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration},
659 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 681 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_dtend},
660 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 682 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -675,2 +697,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
675 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 697 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
698 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
676 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 699 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -707,2 +730,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
707 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 730 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0},
731 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
708 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 732 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -748,3 +772,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
748 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 772 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
749 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 773 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
750 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 774 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -779,5 +803,6 @@ icalrestriction_property_record icalrestriction_property_records[] = {
779 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 803 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
804 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
780 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 805 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
781 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 806 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
782 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 807 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
783 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 808 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -811,2 +836,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
811 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 836 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
837 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
812 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 838 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
@@ -843,2 +869,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
843 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 869 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
870 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
844 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 871 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -875,2 +902,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
875 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 902 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
903 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
876 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 904 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -906,2 +934,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
906 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 934 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
935 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
907 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0}, 936 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -937,2 +966,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
937 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 966 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0},
967 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
938 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 968 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
@@ -969,2 +999,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
969 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 999 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1000 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
970 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 1001 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
@@ -1000,2 +1031,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1000 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1031 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1032 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1001 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1033 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -1073,2 +1105,42 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1073 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1105 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_REQUESTSTATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1106 {ICAL_METHOD_PUBLISH,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1107 {ICAL_METHOD_PUBLISH,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1108 {ICAL_METHOD_PUBLISH,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1109 {ICAL_METHOD_PUBLISH,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1110 {ICAL_METHOD_REQUEST,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1111 {ICAL_METHOD_REQUEST,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1112 {ICAL_METHOD_REQUEST,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1113 {ICAL_METHOD_REQUEST,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1114 {ICAL_METHOD_REPLY,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1115 {ICAL_METHOD_REPLY,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1116 {ICAL_METHOD_REPLY,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1117 {ICAL_METHOD_REPLY,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1118 {ICAL_METHOD_ADD,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1119 {ICAL_METHOD_ADD,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1120 {ICAL_METHOD_ADD,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1121 {ICAL_METHOD_ADD,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1122 {ICAL_METHOD_CANCEL,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1123 {ICAL_METHOD_CANCEL,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1124 {ICAL_METHOD_CANCEL,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1125 {ICAL_METHOD_CANCEL,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1126 {ICAL_METHOD_REFRESH,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1127 {ICAL_METHOD_REFRESH,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1128 {ICAL_METHOD_REFRESH,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1129 {ICAL_METHOD_REFRESH,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1130 {ICAL_METHOD_COUNTER,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1131 {ICAL_METHOD_COUNTER,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1132 {ICAL_METHOD_COUNTER,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1133 {ICAL_METHOD_COUNTER,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1134 {ICAL_METHOD_DECLINECOUNTER,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1135 {ICAL_METHOD_DECLINECOUNTER,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1136 {ICAL_METHOD_DECLINECOUNTER,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1137 {ICAL_METHOD_DECLINECOUNTER,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1138 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_ALLOWCONFLICT_PROPERTY,ICAL_RESTRICTION_ONE,0},
1139 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_CALMASTER_PROPERTY,ICAL_RESTRICTION_ONE,0},
1140 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_OWNER_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1141 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1142 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_TZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1143 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_DEFAULTCHARSET_PROPERTY,ICAL_RESTRICTION_ONE,0},
1144 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_DEFAULTLOCALE_PROPERTY,ICAL_RESTRICTION_ONE,0},
1145 {ICAL_METHOD_NONE,ICAL_VAGENDA_COMPONENT,ICAL_DEFAULTTZID_PROPERTY,ICAL_RESTRICTION_ONE,0},
1074 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1146 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1076,2 +1148,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1076 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1148 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1149 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1077 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CALSCALE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1150 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CALSCALE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -1136,3 +1209,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1136 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DUE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1209 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DUE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1137 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_duration}, 1210 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE,icalrestriction_no_dtend},
1138 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1211 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_EXDATE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -1169,2 +1242,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1169 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1242 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1243 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1170 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1244 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1217,2 +1291,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1217 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1291 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1292 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_RELCALID_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1218 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1293 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1553,3 +1628,3 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1553 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1628 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1554 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1629 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ACTION_PROPERTY,ICAL_RESTRICTION_ONE,icalrestriction_must_be_email},
1555 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1630 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -1649,2 +1724,5 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1649 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1724 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1725 {ICAL_METHOD_NONE,ICAL_VQUERY_COMPONENT,ICAL_QUERY_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1726 {ICAL_METHOD_NONE,ICAL_VQUERY_COMPONENT,ICAL_QUERYNAME_PROPERTY,ICAL_RESTRICTION_ONE,0},
1727 {ICAL_METHOD_NONE,ICAL_VQUERY_COMPONENT,ICAL_EXPAND_PROPERTY,ICAL_RESTRICTION_ONE,0},
1650 {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE} 1728 {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE}
@@ -1779,2 +1857,4 @@ icalrestriction_component_record icalrestriction_component_records[] = {
1779 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VTODO_COMPONENT,ICAL_RESTRICTION_ZERO,0}, 1857 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VTODO_COMPONENT,ICAL_RESTRICTION_ZERO,0},
1858 {ICAL_METHOD_NONE,ICAL_VTIMEZONE_COMPONENT,ICAL_XSTANDARD_COMPONENT,ICAL_RESTRICTION_ZEROPLUS,0},
1859 {ICAL_METHOD_NONE,ICAL_VTIMEZONE_COMPONENT,ICAL_XDAYLIGHT_COMPONENT,ICAL_RESTRICTION_ZEROPLUS,0},
1780 {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE} 1860 {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}
diff --git a/libical/src/libical/icaltime.c b/libical/src/libical/icaltime.c
index a04ca04..3aac74e 100644
--- a/libical/src/libical/icaltime.c
+++ b/libical/src/libical/icaltime.c
@@ -28,3 +28,3 @@
28#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
29#include <config.h> 29#include "config.h"
30#endif 30#endif
@@ -36,126 +36,207 @@
36#include <stdio.h> 36#include <stdio.h>
37#include <time.h>
37 38
38int snprintf(char *str, size_t n, char const *fmt, ...); 39 #include "astime.h" /* Julian data handling routines */
39 40
40#ifdef ICAL_NO_LIBICAL
41#define icalerror_set_errno(x)
42#define icalerror_check_arg_rv(x,y)
43#define icalerror_check_arg_re(x,y,z)
44#else
45#include "icalerror.h" 41#include "icalerror.h"
46#include "icalmemory.h" 42#include "icalmemory.h"
43
44#include "icaltimezone.h"
45#include "icalvalue.h"
46
47#ifdef WIN32
48#include <Windows.h>
49#define ERROR error
50#define snprintf _snprintf
51#define strcasecmp stricmp
47#endif 52#endif
48 53
54/*
55 * Function to convert a struct tm time specification
56 * to an ANSI time_t using the specified time zone.
57 * This is different from the standard mktime() function
58 * in that we dont want the automatic adjustments for
59 * local daylight savings time applied to the result.
60 * This function expects well-formed input.
61 */
62static time_t make_time(struct tm *tm, int tzm)
63{
64 time_t tim;
49 65
66 static int days[] = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 };
50 67
68 /* check that year specification within range */
51 69
52struct icaltimetype 70 if (tm->tm_year < 70 || tm->tm_year > 138)
53icaltime_from_timet(time_t tm, int is_date) 71 return((time_t) -1);
54{
55 struct icaltimetype tt = icaltime_null_time();
56 struct tm t;
57 72
58 t = *(gmtime(&tm)); 73 /* check that month specification within range */
59
60 if(is_date == 0){
61 tt.second = t.tm_sec;
62 tt.minute = t.tm_min;
63 tt.hour = t.tm_hour;
64 } else {
65 tt.second = tt.minute =tt.hour = 0 ;
66 }
67 74
68 tt.day = t.tm_mday; 75 if (tm->tm_mon < 0 || tm->tm_mon > 11)
69 tt.month = t.tm_mon + 1; 76 return((time_t) -1);
70 tt.year = t.tm_year+ 1900;
71
72 tt.is_utc = 1;
73 tt.is_date = is_date;
74 77
75 return tt; 78 /* check for upper bound of Jan 17, 2038 (to avoid possibility of
76} 79 32-bit arithmetic overflow) */
80
81 if (tm->tm_year == 138) {
82 if (tm->tm_mon > 0)
83 return((time_t) -1);
84 else if (tm->tm_mday > 17)
85 return((time_t) -1);
86 }
77 87
78/* Structure used by set_tz to hold an old value of TZ, and the new 88 /*
79 value, which is in memory we will have to free in unset_tz */ 89 * calculate elapsed days since start of the epoch (midnight Jan
80struct set_tz_save {char* orig_tzid; char* new_env_str;}; 90 * 1st, 1970 UTC) 17 = number of leap years between 1900 and 1970
91 * (number of leap days to subtract)
92 */
81 93
82/* Temporarily change the TZ environmental variable. */ 94 tim = (tm->tm_year - 70) * 365 + ((tm->tm_year - 1) / 4) - 17;
83struct set_tz_save set_tz(const char* tzid)
84{
85 95
86 char *orig_tzid = 0; 96 /* add number of days elapsed in the current year */
87 char *new_env_str;
88 struct set_tz_save savetz;
89 size_t tmp_sz;
90 97
91 savetz.orig_tzid = 0; 98 tim += days[tm->tm_mon];
92 savetz.new_env_str = 0;
93 99
94 if(getenv("TZ") != 0){ 100 /* check and adjust for leap years (the leap year check only valid
95 orig_tzid = (char*)icalmemory_strdup(getenv("TZ")); 101 during the 32-bit era */
96 102
97 if(orig_tzid == 0){ 103 if ((tm->tm_year & 3) == 0 && tm->tm_mon > 1)
98 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 104 tim += 1;
99 return savetz;
100 }
101 }
102 105
103 tmp_sz =strlen(tzid)+4; 106 /* elapsed days to current date */
104 new_env_str = (char*)malloc(tmp_sz);
105 107
106 if(new_env_str == 0){ 108 tim += tm->tm_mday;
107 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
108 return savetz;
109 }
110
111 /* Copy the TZid into a string with the form that putenv expects. */
112 strcpy(new_env_str,"TZ=");
113 strcpy(new_env_str+3,tzid);
114 109
115 putenv(new_env_str);
116 110
117 /* Old value of TZ and the string we will have to free later */ 111 /* calculate elapsed hours since start of the epoch */
118 savetz.orig_tzid = orig_tzid; 112
119 savetz.new_env_str = new_env_str; 113 tim = tim * 24 + tm->tm_hour;
120 return savetz; 114
115 /* calculate elapsed minutes since start of the epoch */
116
117 tim = tim * 60 + tm->tm_min;
118
119 /* adjust per time zone specification */
120
121 tim -= tzm;
122
123 /* calculate elapsed seconds since start of the epoch */
124
125 tim = tim * 60 + tm->tm_sec;
126
127 /* return number of seconds since start of the epoch */
128
129 return(tim);
121} 130}
122 131
123void unset_tz(struct set_tz_save savetz) 132 /**@brief Constructor (deprecated).
133 *
134 * Convert seconds past UNIX epoch to a timetype.
135 *
136 * @deprecated This constructor is deprecated and shouldn't be used in
137 * new software. Use icaltime_from_timet_with_zone(time_t, int,
138 * icaltimezone *) instead. In the meantime, calls to this method
139 * return a floating time, which can always be converted to a local
140 * time with an appropriate call to icaltime_convert_to_zone().
141 */
142
143struct icaltimetype
144icaltime_from_timet(const time_t tm, const int is_date)
124{ 145{
125 /* restore the original TZ environment */ 146#ifndef NO_WARN_DEPRECATED
147 icalerror_warn("icaltime_from_timet() is DEPRECATED, use icaltime_from_timet_with_zone() instead");
148#endif
126 149
127 char* orig_tzid = savetz.orig_tzid; 150 return icaltime_from_timet_with_zone(tm, is_date, 0);
151}
128 152
129 if(orig_tzid!=0){
130 size_t tmp_sz =strlen(orig_tzid)+4;
131 char* orig_env_str = (char*)icalmemory_tmp_buffer(tmp_sz);
132 153
133 if(orig_env_str == 0){ 154 /**@brief Constructor.
134 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 155 *
135 return; 156 *@param tm The time
136 } 157 *@param is_date Boolean: 1 means we should treat tm as a DATE
137 158 *@param zone The timezone tm is in, NULL means to treat tm as a
138 strcpy(orig_env_str,"TZ="); 159 * floating time
139 strcpy(orig_env_str+3,orig_tzid); 160 *
140#ifndef _WIN32 161 *Return a new icaltime instance, initialized to the given time
141 setenv("TZ", savetz.orig_tzid,1 ); 162 *expressed as seconds past UNIX epoch, optionally using the given
142#else 163 *timezone.
143 putenv("TZ=MEZ");//, savetz.orig_tzid ); 164 *
144#endif 165 *If the caller specifies the is_date param as TRUE, the returned
145 free(orig_tzid); 166 *object is of DATE type, otherwise the input is meant to be of
146 } else { 167 *DATE-TIME type.
147#ifdef __FreeBSD__ 168 *If the zone is not specified (NULL zone param) the time is taken
148 unsetenv("TZ"); 169 *to be floating, that is, valid in any timezone. Note that, in
170 *addition to the uses specified in [RFC2445], this can be used
171 *when doing simple math on couples of times.
172 *If the zone is specified (UTC or otherwise), it's stored in the
173 *object and it's used as the native timezone for this object.
174 *This means that the caller can convert this time to a different
175 *target timezone with no need to store the source timezone.
176 *
177 */
178struct icaltimetype
179icaltime_from_timet_with_zone(const time_t tm, const int is_date,
180 const icaltimezone *zone)
181{
182 struct icaltimetype tt = icaltime_null_time();
183 struct tm t;
184 icaltimezone *utc_zone;
185
186 /* Convert the time_t to a struct tm. We can trust gmtime for this. */
187#ifdef HAVE_GMTIME_R
188 gmtime_r(&tm, &t);
149#else 189#else
150 putenv("TZ"); /* Delete from environment */ 190 {
191 struct tm *t_ptr = gmtime(&tm);
192 t = *t_ptr;
193 }
151#endif 194#endif
152 }
153 195
154 if(savetz.new_env_str != 0){ 196 tt.year = t.tm_year + 1900;
155 free(savetz.new_env_str); 197 tt.month = t.tm_mon + 1;
198 tt.day = t.tm_mday;
199
200 if (is_date) {
201 tt.is_date = 1;
202 return tt;
156 } 203 }
204
205 tt.hour = t.tm_hour;
206 tt.minute = t.tm_min;
207 tt.second = t.tm_sec;
208
209 /* If it's a floating time, we don't do any conversion. */
210 if (zone == NULL) {
211 return tt;
212 }
213
214 utc_zone = icaltimezone_get_utc_timezone ();
215 tt.is_utc = (zone == utc_zone) ? 1 : 0;
216 tt.zone = zone;
217
218 return tt;
157} 219}
158 220
221 /**@brief Convenience constructor.
222 *
223 * Returns the current time in the given timezone, as an icaltimetype.
224 */
225struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone)
226{
227 return icaltime_from_timet_with_zone (time (NULL), 0, zone);
228}
159 229
160time_t icaltime_as_timet(struct icaltimetype tt) 230 /**@brief Convenience constructor.
231 *
232 * Returns the current day as an icaltimetype, with is_date set.
233 */
234struct icaltimetype icaltime_today(void)
235{
236 return icaltime_from_timet_with_zone (time (NULL), 1, NULL);
237}
238
239 /** @briefReturn the time as seconds past the UNIX epoch
240 */
241time_t icaltime_as_timet(const struct icaltimetype tt)
161{ 242{
@@ -164,5 +245,4 @@ time_t icaltime_as_timet(struct icaltimetype tt)
164 245
165 memset(&stm,0,sizeof( struct tm)); 246 /* If the time is the special null time, return 0. */
166 247 if (icaltime_is_null_time(tt)) {
167 if(icaltime_is_null_time(tt)) {
168 return 0; 248 return 0;
@@ -170,2 +250,5 @@ time_t icaltime_as_timet(struct icaltimetype tt)
170 250
251 /* Copy the icaltimetype to a struct tm. */
252 memset (&stm, 0, sizeof (struct tm));
253
171 stm.tm_sec = tt.second; 254 stm.tm_sec = tt.second;
@@ -178,9 +261,3 @@ time_t icaltime_as_timet(struct icaltimetype tt)
178 261
179 if(tt.is_utc == 1 || tt.is_date == 1){ 262 t = make_time(&stm, 0);
180 struct set_tz_save old_tz = set_tz("UTC");
181 t = mktime(&stm);
182 unset_tz(old_tz);
183 } else {
184 t = mktime(&stm);
185 }
186 263
@@ -190,3 +267,47 @@ time_t icaltime_as_timet(struct icaltimetype tt)
190 267
191char* icaltime_as_ical_string(struct icaltimetype tt) 268 /** @briefReturn the time as seconds past the UNIX epoch, using the
269 *given timezone.
270 *
271 *This convenience method combines a call to icaltime_convert() with
272 *a call to icaltime_as_timet().
273 *If the input timezone is null, no conversion is done; that is, the
274 *time is simply returned as time_t in its native timezone.
275 */
276time_t icaltime_as_timet_with_zone(const struct icaltimetype _tt,
277 const icaltimezone *zone)
278{
279 struct icaltimetype tt = _tt;
280 struct tm stm;
281 time_t t;
282
283 /* If the time is the special null time, return 0. */
284 if (icaltime_is_null_time(tt)) {
285 return 0;
286 }
287
288 if (zone != NULL) {
289 tt = icaltime_convert_to_zone(_tt, zone);
290 }
291
292 /* Copy the icaltimetype to a struct tm. */
293 memset (&stm, 0, sizeof (struct tm));
294
295 stm.tm_sec = tt.second;
296 stm.tm_min = tt.minute;
297 stm.tm_hour = tt.hour;
298 stm.tm_mday = tt.day;
299 stm.tm_mon = tt.month-1;
300 stm.tm_year = tt.year-1900;
301 stm.tm_isdst = -1;
302
303 t = make_time(&stm, 0);
304
305 return t;
306}
307
308/**
309 * Return a string represention of the time, in RFC2445 format. The
310 * string is owned by libical
311 */
312const char* icaltime_as_ical_string(const struct icaltimetype tt)
192{ 313{
@@ -214,97 +335,16 @@ char* icaltime_as_ical_string(struct icaltimetype tt)
214 335
215 336/**
216/* convert tt, of timezone tzid, into a utc time */ 337 *Reset all of the time components to be in their normal ranges. For
217struct icaltimetype icaltime_as_utc(struct icaltimetype tt,const char* tzid) 338 *instance, given a time with minutes=70, the minutes will be reduces
218{ 339 *to 10, and the hour incremented. This allows the caller to do
219 int tzid_offset; 340 *arithmetic on times without worrying about overflow or
220 341 *underflow.
221 if(tt.is_utc == 1 || tt.is_date == 1){ 342 *
222 return tt; 343 *Implementation note: we call icaltime_adjust() with no adjustment.
223 } 344 */
224 345struct icaltimetype icaltime_normalize(const struct icaltimetype tt)
225 tzid_offset = icaltime_utc_offset(tt,tzid);
226
227 tt.second -= tzid_offset;
228
229 tt.is_utc = 1;
230
231 return icaltime_normalize(tt);
232}
233
234/* convert tt, a time in UTC, into a time in timezone tzid */
235struct icaltimetype icaltime_as_zone(struct icaltimetype tt,const char* tzid)
236{ 346{
237 int tzid_offset; 347 struct icaltimetype ret = tt;
238 348 icaltime_adjust(&ret, 0, 0, 0, 0);
239 tzid_offset = icaltime_utc_offset(tt,tzid); 349 return ret;
240
241 tt.second += tzid_offset;
242
243 tt.is_utc = 0;
244
245 return icaltime_normalize(tt);
246
247}
248
249
250/* Return the offset of the named zone as seconds. tt is a time
251 indicating the date for which you want the offset */
252int icaltime_utc_offset(struct icaltimetype ictt, const char* tzid)
253{
254
255 time_t tt = icaltime_as_timet(ictt);
256 time_t offset_tt;
257 struct tm gtm;
258 struct set_tz_save old_tz;
259
260 if(tzid != 0){
261 old_tz = set_tz(tzid);
262 }
263
264 /* Mis-interpret a UTC broken out time as local time */
265 gtm = *(gmtime(&tt));
266 gtm.tm_isdst = localtime(&tt)->tm_isdst;
267 offset_tt = mktime(&gtm);
268
269 if(tzid != 0){
270 unset_tz(old_tz);
271 }
272
273 return tt-offset_tt;
274}
275
276
277
278/* Normalize by converting from localtime to utc and back to local
279 time. This uses localtime because localtime and mktime are inverses
280 of each other */
281
282struct icaltimetype icaltime_normalize(struct icaltimetype tt)
283{
284 struct tm stm;
285 time_t tut;
286
287 memset(&stm,0,sizeof( struct tm));
288
289 stm.tm_sec = tt.second;
290 stm.tm_min = tt.minute;
291 stm.tm_hour = tt.hour;
292 stm.tm_mday = tt.day;
293 stm.tm_mon = tt.month-1;
294 stm.tm_year = tt.year-1900;
295 stm.tm_isdst = -1; /* prevents mktime from changing hour based on
296 daylight savings */
297
298 tut = mktime(&stm);
299
300 stm = *(localtime(&tut));
301
302 tt.second = stm.tm_sec;
303 tt.minute = stm.tm_min;
304 tt.hour = stm.tm_hour;
305 tt.day = stm.tm_mday;
306 tt.month = stm.tm_mon +1;
307 tt.year = stm.tm_year+1900;
308
309 return tt;
310} 350}
@@ -312,5 +352,12 @@ struct icaltimetype icaltime_normalize(struct icaltimetype tt)
312 352
313#ifndef ICAL_NO_LIBICAL
314#include "icalvalue.h"
315 353
354 /**@brief Contructor.
355 *
356 * Create a time from an ISO format string.
357 *
358 * @todo If the given string specifies a DATE-TIME not in UTC, there
359 * is no way to know if this is a floating time or really refers to a
360 * timezone. We should probably add a new constructor:
361 * icaltime_from_string_with_zone()
362 */
316struct icaltimetype icaltime_from_string(const char* str) 363struct icaltimetype icaltime_from_string(const char* str)
@@ -328,10 +375,8 @@ struct icaltimetype icaltime_from_string(const char* str)
328 } else if (size == 16) { /* UTC time, ends in 'Z'*/ 375 } else if (size == 16) { /* UTC time, ends in 'Z'*/
376 if(str[15] != 'Z')
377 goto ERROR;
378
329 tt.is_utc = 1; 379 tt.is_utc = 1;
380 tt.zone = icaltimezone_get_utc_timezone();
330 tt.is_date = 0; 381 tt.is_date = 0;
331
332 if(str[15] != 'Z'){
333 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
334 return icaltime_null_time();
335 }
336
337 } else if (size == 8) { /* A DATE */ 382 } else if (size == 8) { /* A DATE */
@@ -340,4 +385,3 @@ struct icaltimetype icaltime_from_string(const char* str)
340 } else { /* error */ 385 } else { /* error */
341 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 386 goto ERROR;
342 return icaltime_null_time();
343 } 387 }
@@ -345,13 +389,12 @@ struct icaltimetype icaltime_from_string(const char* str)
345 if(tt.is_date == 1){ 389 if(tt.is_date == 1){
346 sscanf(str,"%04d%02d%02d",&tt.year,&tt.month,&tt.day); 390 if (sscanf(str,"%04d%02d%02d",&tt.year,&tt.month,&tt.day) < 3)
391 goto ERROR;
347 } else { 392 } else {
348 char tsep; 393 char tsep;
349 sscanf(str,"%04d%02d%02d%c%02d%02d%02d",&tt.year,&tt.month,&tt.day, 394 if (sscanf(str,"%04d%02d%02d%c%02d%02d%02d",&tt.year,&tt.month,&tt.day,
350 &tsep,&tt.hour,&tt.minute,&tt.second); 395 &tsep,&tt.hour,&tt.minute,&tt.second) < 7)
351 396 goto ERROR;
352 if(tsep != 'T'){
353 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
354 return icaltime_null_time();
355 }
356 397
398 if(tsep != 'T')
399 goto ERROR;
357 } 400 }
@@ -359,26 +402,27 @@ struct icaltimetype icaltime_from_string(const char* str)
359 return tt; 402 return tt;
403
404ERROR:
405 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
406 return icaltime_null_time();
360} 407}
361#endif
362 408
363char ctime_str[20];
364char* icaltime_as_ctime(struct icaltimetype t)
365{
366 time_t tt;
367
368 tt = icaltime_as_timet(t);
369 sprintf(ctime_str,"%s",ctime(&tt));
370 409
371 ctime_str[strlen(ctime_str)-1] = 0; 410/* Returns whether the specified year is a leap year. Year is the normal year,
411 e.g. 2001. */
412int
413icaltime_is_leap_year (const int year)
414{
372 415
373 return ctime_str; 416 if (year <= 1752)
417 return (year % 4 == 0);
418 else
419 return ( (year % 4==0) && (year % 100 !=0 )) || (year % 400 == 0);
374} 420}
375 421
422static int _days_in_month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
376 423
377short days_in_month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; 424int icaltime_days_in_month(const int month, const int year)
378
379short icaltime_days_in_month(short month,short year)
380{ 425{
381 426
382 int is_leap =0; 427 int days = _days_in_month[month];
383 int days = days_in_month[month];
384 428
@@ -387,9 +431,4 @@ short icaltime_days_in_month(short month,short year)
387 431
388 if( (year % 4 == 0 && year % 100 != 0) ||
389 year % 400 == 0){
390 is_leap =1;
391 }
392
393 if( month == 2){ 432 if( month == 2){
394 days += is_leap; 433 days += icaltime_is_leap_year(year);
395 } 434 }
@@ -400,104 +439,138 @@ short icaltime_days_in_month(short month,short year)
400/* 1-> Sunday, 7->Saturday */ 439/* 1-> Sunday, 7->Saturday */
401short icaltime_day_of_week(struct icaltimetype t){ 440int icaltime_day_of_week(const struct icaltimetype t){
441 UTinstant jt;
402 442
403 time_t tt = icaltime_as_timet(t); 443 memset(&jt,0,sizeof(UTinstant));
404 struct tm *tm;
405 444
406 if(t.is_utc == 1 || t.is_date == 1){ 445 jt.year = t.year;
407 tm = gmtime(&tt); 446 jt.month = t.month;
408 } else { 447 jt.day = t.day;
409 tm = localtime(&tt); 448 jt.i_hour = 0;
410 } 449 jt.i_minute = 0;
450 jt.i_second = 0;
451
452 juldat(&jt);
411 453
412 return tm->tm_wday+1; 454 return jt.weekday + 1;
413} 455}
414 456
415/* Day of the year that the first day of the week (Sunday) is on */ 457/** Day of the year that the first day of the week (Sunday) is on.
416short icaltime_start_doy_of_week(struct icaltimetype t){ 458 *
417 time_t tt = icaltime_as_timet(t); 459 * @todo Doesn't take into account different week start days.
418 time_t start_tt; 460 */
419 struct tm *stm; 461int icaltime_start_doy_of_week(const struct icaltimetype t){
420 int syear; 462 UTinstant jt;
421 463
422 stm = gmtime(&tt); 464 memset(&jt,0,sizeof(UTinstant));
423 syear = stm->tm_year;
424 465
425 start_tt = tt - stm->tm_wday*(60*60*24); 466 jt.year = t.year;
467 jt.month = t.month;
468 jt.day = t.day;
469 jt.i_hour = 0;
470 jt.i_minute = 0;
471 jt.i_second = 0;
426 472
427 stm = gmtime(&start_tt); 473 juldat(&jt);
428 474 caldat(&jt);
429 if(syear == stm->tm_year){
430 return stm->tm_yday+1;
431 } else {
432 /* return negative to indicate that start of week is in
433 previous year. */
434 int is_leap = 0;
435 int year = stm->tm_year;
436
437 if( (year % 4 == 0 && year % 100 != 0) ||
438 year % 400 == 0){
439 is_leap =1;
440 }
441 475
442 return (stm->tm_yday+1)-(365+is_leap); 476 return jt.day_of_year - jt.weekday;
443 }
444
445} 477}
446 478
447short icaltime_week_number(struct icaltimetype ictt) 479/**
480 * @todo Doesn't take into account the start day of the
481 * week. strftime assumes that weeks start on Monday.
482 */
483int icaltime_week_number(const struct icaltimetype ictt)
448{ 484{
449 char str[5]; 485 UTinstant jt;
450 time_t t = icaltime_as_timet(ictt);
451 int week_no;
452 486
453 strftime(str,5,"%V", gmtime(&t)); 487 memset(&jt,0,sizeof(UTinstant));
454 488
455 week_no = atoi(str); 489 jt.year = ictt.year;
490 jt.month = ictt.month;
491 jt.day = ictt.day;
492 jt.i_hour = 0;
493 jt.i_minute = 0;
494 jt.i_second = 0;
456 495
457 return week_no; 496 juldat(&jt);
497 caldat(&jt);
458 498
499 return (jt.day_of_year - jt.weekday) / 7;
459} 500}
460 501
502/* The first array is for non-leap years, the second for leap years*/
503static const int days_in_year[2][13] =
504{ /* jan feb mar apr may jun jul aug sep oct nov dec */
505 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
506 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
507};
461 508
462short icaltime_day_of_year(struct icaltimetype t){ 509/**
463 time_t tt; 510 *Returns the day of the year, counting from 1 (Jan 1st).
464 struct tm *stm; 511 */
465 struct set_tz_save old_tz; 512int icaltime_day_of_year(const struct icaltimetype t){
466 513 int is_leap = icaltime_is_leap_year (t.year);
467 tt = icaltime_as_timet(t);
468 514
469 old_tz = set_tz("UTC"); 515 return days_in_year[is_leap][t.month - 1] + t.day;
470 stm = localtime(&tt);
471 unset_tz(old_tz);
472
473 return stm->tm_yday+1;
474
475} 516}
476 517
518 /**@brief Contructor.
519 *
520 *Create a new time, given a day of year and a year.
521 */
477/* Jan 1 is day #1, not 0 */ 522/* Jan 1 is day #1, not 0 */
478struct icaltimetype icaltime_from_day_of_year(short doy, short year) 523struct icaltimetype icaltime_from_day_of_year(const int _doy, const int _year)
479{ 524{
480 struct tm stm; 525 struct icaltimetype tt = icaltime_null_date();
481 time_t tt; 526 int is_leap;
482 struct set_tz_save old_tz; 527 int month;
483 528 int doy = _doy;
484 /* Get the time of january 1 of this year*/ 529 int year = _year;
485 memset(&stm,0,sizeof(struct tm)); 530
486 stm.tm_year = year-1900; 531 is_leap = icaltime_is_leap_year(year);
487 stm.tm_mday = 1; 532
533 /* Zero and neg numbers represent days of the previous year */
534 if(doy <1){
535 year--;
536 is_leap = icaltime_is_leap_year(year);
537 doy += days_in_year[is_leap][12];
538 } else if(doy > days_in_year[is_leap][12]){
539 /* Move on to the next year*/
540 is_leap = icaltime_is_leap_year(year);
541 doy -= days_in_year[is_leap][12];
542 year++;
543 }
488 544
489 old_tz = set_tz("UTC"); 545 tt.year = year;
490 tt = mktime(&stm);
491 unset_tz(old_tz);
492 546
547 for (month = 11; month >= 0; month--) {
548 if (doy > days_in_year[is_leap][month]) {
549 tt.month = month + 1;
550 tt.day = doy - days_in_year[is_leap][month];
551 break;
552 }
553 }
493 554
494 /* Now add in the days */ 555 return tt;
556}
495 557
496 doy--; 558 /**@brief Constructor.
497 tt += doy *60*60*24; 559 *
560 *Return a null time, which indicates no time has been set.
561 *This time represents the beginning of the epoch.
562 */
563struct icaltimetype icaltime_null_time(void)
564{
565 struct icaltimetype t;
566 memset(&t,0,sizeof(struct icaltimetype));
498 567
499 return icaltime_from_timet(tt, 1); 568 return t;
500} 569}
501 570
502struct icaltimetype icaltime_null_time() 571 /**@brief Constructor.
572 *
573 *Return a null date, which indicates no time has been set.
574 */
575struct icaltimetype icaltime_null_date(void)
503{ 576{
@@ -506,2 +579,12 @@ struct icaltimetype icaltime_null_time()
506 579
580 t.is_date = 1;
581
582 /*
583 * Init to -1 to match what icalyacc.y used to do.
584 * Does anything depend on this?
585 */
586 t.hour = -1;
587 t.minute = -1;
588 t.second = -1;
589
507 return t; 590 return t;
@@ -510,3 +593,8 @@ struct icaltimetype icaltime_null_time()
510 593
511int icaltime_is_valid_time(struct icaltimetype t){ 594/**
595 *Returns false if the time is clearly invalid, but is not null. This
596 *is usually the result of creating a new time type buy not clearing
597 *it, or setting one of the flags to an illegal value.
598 */
599int icaltime_is_valid_time(const struct icaltimetype t){
512 if(t.is_utc > 1 || t.is_utc < 0 || 600 if(t.is_utc > 1 || t.is_utc < 0 ||
@@ -521,3 +609,22 @@ int icaltime_is_valid_time(struct icaltimetype t){
521 609
522int icaltime_is_null_time(struct icaltimetype t) 610 /**@brief Returns true if time is a DATE
611 */
612int icaltime_is_date(const struct icaltimetype t) {
613
614 return t.is_date;
615}
616
617 /**@brief Returns true if time is relative to UTC zone
618 *
619 *@todo We should only check the zone
620 */
621int icaltime_is_utc(const struct icaltimetype t) {
622
623 return t.is_utc;
624}
625
626/**
627 *Return true if the time is null.
628 */
629int icaltime_is_null_time(const struct icaltimetype t)
523{ 630{
@@ -531,40 +638,97 @@ int icaltime_is_null_time(struct icaltimetype t)
531 638
532int icaltime_compare(struct icaltimetype a,struct icaltimetype b) 639/**
533{ 640 *Return -1, 0, or 1 to indicate that a<b, a==b, or a>b.
534 time_t t1 = icaltime_as_timet(a); 641 * This calls icaltime_compare function after converting them to the utc
535 time_t t2 = icaltime_as_timet(b); 642 * timezone.
536 643 */
537 if (t1 > t2) {
538 return 1;
539 } else if (t1 < t2) {
540 return -1;
541 } else {
542 return 0;
543 }
544 644
645int icaltime_compare(const struct icaltimetype a_in, const struct icaltimetype b_in)
646{
647 int retval = 0;
648 struct icaltimetype a, b;
649
650 a = icaltime_convert_to_zone(a_in, icaltimezone_get_utc_timezone());
651 b = icaltime_convert_to_zone(b_in, icaltimezone_get_utc_timezone());
652
653 if (a.year > b.year)
654 retval = 1;
655 else if (a.year < b.year)
656 retval = -1;
657
658 else if (a.month > b.month)
659 retval = 1;
660 else if (a.month < b.month)
661 retval = -1;
662
663 else if (a.day > b.day)
664 retval = 1;
665 else if (a.day < b.day)
666 retval = -1;
667
668 /* if both are dates, we are done */
669 if (a.is_date && b.is_date)
670 return retval;
671
672 /* else, if we already found a difference, we are done */
673 else if (retval != 0)
674 return retval;
675
676 /* else, if only one is a date (and we already know the date part is equal),
677 then the other is greater */
678 else if (b.is_date)
679 retval = 1;
680 else if (a.is_date)
681 retval = -1;
682
683 else if (a.hour > b.hour)
684 retval = 1;
685 else if (a.hour < b.hour)
686 retval = -1;
687
688 else if (a.minute > b.minute)
689 retval = 1;
690 else if (a.minute < b.minute)
691 retval = -1;
692
693 else if (a.second > b.second)
694 retval = 1;
695 else if (a.second < b.second)
696 retval = -1;
697
698 return retval;
545} 699}
546 700
701/**
702 *like icaltime_compare, but only use the date parts.
703 */
704
547int 705int
548icaltime_compare_date_only (struct icaltimetype a, struct icaltimetype b) 706icaltime_compare_date_only(const struct icaltimetype a_in, const struct icaltimetype b_in)
549{ 707{
550 time_t t1; 708 int retval;
551 time_t t2; 709 struct icaltimetype a, b;
552 710
553 if (a.year == b.year && a.month == b.month && a.day == b.day) 711 a = icaltime_convert_to_zone(a_in, icaltimezone_get_utc_timezone());
554 return 0; 712 b = icaltime_convert_to_zone(b_in, icaltimezone_get_utc_timezone());
555 713
556 t1 = icaltime_as_timet (a); 714 if (a.year > b.year)
557 t2 = icaltime_as_timet (b); 715 retval = 1;
558 716 else if (a.year < b.year)
559 if (t1 > t2) 717 retval = -1;
560 return 1; 718
561 else if (t1 < t2) 719 else if (a.month > b.month)
562 return -1; 720 retval = 1;
563 else { 721 else if (a.month < b.month)
564 /* not reached */ 722 retval = -1;
565 assert (0); 723
566 return 0; 724 else if (a.day > b.day)
567 } 725 retval = 1;
568} 726 else if (a.day < b.day)
727 retval = -1;
569 728
729 else
730 retval = 0;
731
732 return retval;
733}
570 734
@@ -577 +741,275 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
577 741
742
743
744 /**@brief Internal, shouldn't be part of the public API
745 *
746 *Adds (or subtracts) a time from a icaltimetype.
747 *NOTE: This function is exactly the same as icaltimezone_adjust_change()
748 *except for the type of the first parameter.
749 */
750void
751icaltime_adjust(struct icaltimetype *tt, const int days, const int hours,
752 const int minutes, const int seconds) {
753
754 int second, minute, hour, day;
755 int minutes_overflow, hours_overflow, days_overflow, years_overflow;
756 int days_in_month;
757
758 /* Add on the seconds. */
759 second = tt->second + seconds;
760 tt->second = second % 60;
761 minutes_overflow = second / 60;
762 if (tt->second < 0) {
763 tt->second += 60;
764 minutes_overflow--;
765 }
766
767 /* Add on the minutes. */
768 minute = tt->minute + minutes + minutes_overflow;
769 tt->minute = minute % 60;
770 hours_overflow = minute / 60;
771 if (tt->minute < 0) {
772 tt->minute += 60;
773 hours_overflow--;
774 }
775
776 /* Add on the hours. */
777 hour = tt->hour + hours + hours_overflow;
778 tt->hour = hour % 24;
779 days_overflow = hour / 24;
780 if (tt->hour < 0) {
781 tt->hour += 24;
782 days_overflow--;
783 }
784
785 /* Normalize the month. We do this before handling the day since we may
786 need to know what month it is to get the number of days in it.
787 Note that months are 1 to 12, so we have to be a bit careful. */
788 if (tt->month >= 13) {
789 years_overflow = (tt->month - 1) / 12;
790 tt->year += years_overflow;
791 tt->month -= years_overflow * 12;
792 } else if (tt->month <= 0) {
793 /* 0 to -11 is -1 year out, -12 to -23 is -2 years. */
794 years_overflow = (tt->month / 12) - 1;
795 tt->year += years_overflow;
796 tt->month -= years_overflow * 12;
797 }
798
799 /* Add on the days. */
800 day = tt->day + days + days_overflow;
801 if (day > 0) {
802 for (;;) {
803 days_in_month = icaltime_days_in_month (tt->month, tt->year);
804 if (day <= days_in_month)
805 break;
806
807 tt->month++;
808 if (tt->month >= 13) {
809 tt->year++;
810 tt->month = 1;
811 }
812
813 day -= days_in_month;
814 }
815 } else {
816 while (day <= 0) {
817 if (tt->month == 1) {
818 tt->year--;
819 tt->month = 12;
820 } else {
821 tt->month--;
822 }
823
824 day += icaltime_days_in_month (tt->month, tt->year);
825 }
826 }
827 tt->day = day;
828}
829
830 /**@brief Convert time to a given timezone
831 *
832 *Convert a time from its native timezone to a given timezone.
833 *
834 *If tt is a date, the returned time is an exact
835 *copy of the input. If it's a floating time, the returned object
836 *represents the same time translated to the given timezone.
837 *Otherwise the time will be converted to the new
838 *time zone, and its native timezone set to the right timezone.
839 */
840struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
841 icaltimezone *zone) {
842
843 struct icaltimetype ret = tt;
844
845 /* If it's a date do nothing */
846 if (tt.is_date) {
847 return ret;
848 }
849
850 if (tt.zone == zone) {
851 return ret;
852 }
853
854 /* If it's a floating time we don't want to adjust the time */
855 if (tt.zone != NULL) {
856 icaltimezone_convert_time(&ret, tt.zone, zone);
857 }
858
859 ret.zone = zone;
860 if (zone == icaltimezone_get_utc_timezone()) {
861 ret.is_utc = 1;
862 } else {
863 ret.is_utc = 0;
864 }
865
866 return ret;
867}
868
869const icaltimezone *
870icaltime_get_timezone(const struct icaltimetype t) {
871
872 return t.zone;
873}
874
875char *
876icaltime_get_tzid(const struct icaltimetype t) {
877
878 if (t.zone != NULL) {
879 return icaltimezone_get_tzid(t.zone);
880 } else {
881 return NULL;
882 }
883}
884
885 /**@brief Set the timezone
886 *
887 *Force the icaltime to be interpreted relative to another timezone.
888 *If you need to do timezone conversion, applying offset adjustments,
889 *then you should use icaltime_convert_to_timezone instead.
890 */
891struct icaltimetype
892icaltime_set_timezone(struct icaltimetype *t, const icaltimezone *zone) {
893
894 /* If it's a date do nothing */
895 if (t->is_date) {
896 return *t;
897 }
898
899 if (t->zone == zone) {
900 return *t;
901 }
902
903 t->zone = zone;
904 if (zone == icaltimezone_get_utc_timezone()) {
905 t->is_utc = 1;
906 } else {
907 t->is_utc = 0;
908 }
909
910 return *t;
911}
912
913
914/**
915 * @brief builds an icaltimespan given a start time, end time and busy value.
916 *
917 * @param dtstart The beginning time of the span, can be a date-time
918 * or just a date.
919 * @param dtend The end time of the span.
920 * @param is_busy A boolean value, 0/1.
921 * @return A span using the supplied values.
922 *
923 * returned span contains times specified in UTC.
924 */
925
926icaltime_span icaltime_span_new(struct icaltimetype dtstart,
927 struct icaltimetype dtend,
928 int is_busy)
929{
930 icaltime_span span;
931
932 span.is_busy = is_busy;
933
934 span.start = icaltime_as_timet_with_zone(dtstart,
935 icaltimezone_get_utc_timezone());
936
937 if (icaltime_is_null_time(dtend)) {
938 if (!icaltime_is_date(dtstart)) {
939 /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION
940 it takes no time */
941 span.end = span.start;
942 return span;
943 } else {
944 dtend = dtstart;
945 }
946 }
947
948 span.end = icaltime_as_timet_with_zone(dtend, icaltimezone_get_utc_timezone());
949
950 if (icaltime_is_date(dtstart)) {
951 /* no time specified, go until the end of the day..*/
952 span.end += 60*60*24 - 1;
953 }
954 return span;
955}
956
957
958/** @brief Returns true if the two spans overlap
959 *
960 * @param s1 1st span to test
961 * @param s2 2nd span to test
962 * @return boolean value
963 *
964 * The result is calculated by testing if the start time of s1 is contained
965 * by the s2 span, or if the end time of s1 is contained by the s2 span.
966 *
967 * Also returns true if the spans are equal.
968 *
969 * Note, this will return false if the spans are adjacent.
970 */
971
972int icaltime_span_overlaps(icaltime_span *s1,
973 icaltime_span *s2)
974{
975 /* s1->start in s2 */
976 if (s1->start > s2->start && s1->start < s2->end)
977 return 1;
978
979 /* s1->end in s2 */
980 if (s1->end > s2->start && s1->end < s2->end)
981 return 1;
982
983 /* s2->start in s1 */
984 if (s2->start > s1->start && s2->start < s1->end)
985 return 1;
986
987 /* s2->end in s1 */
988 if (s2->end > s1->start && s2->end < s1->end)
989 return 1;
990
991 if (s1->start == s2->start && s1->end == s2->end)
992 return 1;
993
994 return 0;
995}
996
997/** @brief Returns true if the span is totally within the containing
998 * span
999 *
1000 * @param s The span to test for.
1001 * @param container The span to test against.
1002 * @return boolean value.
1003 *
1004 */
1005
1006int icaltime_span_contains(icaltime_span *s,
1007 icaltime_span *container)
1008{
1009
1010 if ((s->start >= container->start && s->start < container->end) &&
1011 (s->end <= container->end && s->end > container->start))
1012 return 1;
1013
1014 return 0;
1015}
diff --git a/libical/src/libical/icaltime.h b/libical/src/libical/icaltime.h
index 0f0379b..ce1696a 100644
--- a/libical/src/libical/icaltime.h
+++ b/libical/src/libical/icaltime.h
@@ -28,2 +28,66 @@
28 28
29 /**@file icaltime.h
30 *@brief struct icaltimetype is a pseudo-object that abstracts time
31 *handling.
32 *
33 *It can represent either a DATE or a DATE-TIME (floating, UTC or in a
34 *given timezone), and it keeps track internally of its native timezone.
35 *
36 *The typical usage is to call the correct constructor specifying the
37 *desired timezone. If this is not known until a later time, the
38 *correct behavior is to specify a NULL timezone and call
39 *icaltime_convert_to_zone() at a later time.
40 *
41 *There are several ways to create a new icaltimetype:
42 *
43 *- icaltime_null_time()
44 *- icaltime_null_date()
45 *- icaltime_current_time_with_zone()
46 *- icaltime_today()
47 *- icaltime_from_timet_with_zone(time_t tm, int is_date,
48 * icaltimezone *zone)
49 * - icaltime_from_string_with_zone(const char* str, icaltimezone *zone)
50 *- icaltime_from_day_of_year(int doy, int year)
51 *- icaltime_from_week_number(int week_number, int year)
52 *
53 *italtimetype objects can be converted to different formats:
54 *
55 *- icaltime_as_timet(struct icaltimetype tt)
56 *- icaltime_as_timet_with_zone(struct icaltimetype tt,
57 * icaltimezone *zone)
58 *- icaltime_as_ical_string(struct icaltimetype tt)
59 *
60 *Accessor methods include:
61 *
62 *- icaltime_get_timezone(struct icaltimetype t)
63 *- icaltime_get_tzid(struct icaltimetype t)
64 *- icaltime_set_timezone(struct icaltimetype t, const icaltimezone *zone)
65 *- icaltime_day_of_year(struct icaltimetype t)
66 *- icaltime_day_of_week(struct icaltimetype t)
67 *- icaltime_start_doy_of_week(struct icaltimetype t)
68 *- icaltime_week_number(struct icaltimetype t)
69 *
70 *Query methods include:
71 *
72 *- icaltime_is_null_time(struct icaltimetype t)
73 *- icaltime_is_valid_time(struct icaltimetype t)
74 *- icaltime_is_date(struct icaltimetype t)
75 *- icaltime_is_utc(struct icaltimetype t)
76 *- icaltime_is_floating(struct icaltimetype t)
77 *
78 *Modify, compare and utility methods include:
79 *
80 *- icaltime_add(struct icaltimetype t, struct icaldurationtype d)
81 *- icaltime_subtract(struct icaltimetype t1, struct icaltimetype t2)
82 * - icaltime_compare_with_zone(struct icaltimetype a,struct icaltimetype b)
83 *- icaltime_compare(struct icaltimetype a,struct icaltimetype b)
84 *- icaltime_compare_date_only(struct icaltimetype a,
85 * struct icaltimetype b)
86 *- icaltime_adjust(struct icaltimetype *tt, int days, int hours,
87 * int minutes, int seconds);
88 *- icaltime_normalize(struct icaltimetype t);
89 *- icaltime_convert_to_zone(const struct icaltimetype tt,
90 * icaltimezone *zone);
91 */
92
29#ifndef ICALTIME_H 93#ifndef ICALTIME_H
@@ -33,14 +97,28 @@
33 97
34/* icaltime_span is returned by icalcomponent_get_span() */ 98/* An opaque struct representing a timezone. We declare this here to avoid
99 a circular dependancy. */
100#ifndef ICALTIMEZONE_DEFINED
101#define ICALTIMEZONE_DEFINED
102 typedef struct _icaltimezone icaltimezone;
103#endif
104
105/** icaltime_span is returned by icalcomponent_get_span() */
35struct icaltime_span { 106struct icaltime_span {
36 time_t start; /* in UTC */ 107 time_t start; /**< in UTC */
37 time_t end; /* in UTC */ 108 time_t end; /**< in UTC */
38 int is_busy; /* 1->busy time, 0-> free time */ 109 int is_busy; /**< 1->busy time, 0-> free time */
39}; 110};
40 111
112typedef struct icaltime_span icaltime_span;
41 113
114/*
115 *FIXME
116 *
117 *is_utc is redundant, and might be considered a minor optimization.
118 *It might be deprecated, so you should use icaltime_is_utc() instead.
119 */
42struct icaltimetype 120struct icaltimetype
43{ 121{
44 int year; 122 int year;/**< Actual year, e.g. 2001. */
45 int month; 123 int month;/**< 1 (Jan) to 12 (Dec). */
46 int day; 124 int day;
@@ -50,95 +128,145 @@ struct icaltimetype
50 128
51 int is_utc; /* 1-> time is in UTC timezone */ 129 int is_utc; /**< 1-> time is in UTC timezone */
52 130
53 int is_date; /* 1 -> interpret this as date. */ 131 int is_date; /**< 1 -> interpret this as date. */
54 132
55 const char* zone; /*Ptr to Olsen placename. Libical does not own mem*/ 133 int is_daylight; /**< 1 -> time is in daylight savings time. */
134
135 const icaltimezone *zone;/**< timezone */
56 }; 136 };
57 137
58/* Convert seconds past UNIX epoch to a timetype*/ 138typedef struct icaltimetype icaltimetype;
59struct icaltimetype icaltime_from_timet(time_t v, int is_date);
60 139
61/* Return the time as seconds past the UNIX epoch */ 140/** Return a null time, which indicates no time has been set.
62time_t icaltime_as_timet(struct icaltimetype); 141 This time represent the beginning of the epoch */
142struct icaltimetype icaltime_null_time(void);
63 143
64/* Return a string represention of the time, in RFC2445 format. The 144/** Return a null date */
65 string is owned by libical */ 145struct icaltimetype icaltime_null_date(void);
66char* icaltime_as_ical_string(struct icaltimetype tt); 146
147/** Returns the current time in the given timezone, as an icaltimetype. */
148struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone);
149
150/** Returns the current day as an icaltimetype, with is_date set. */
151struct icaltimetype icaltime_today(void);
67 152
68/* Like icaltime_from_timet(), except that the input may be in seconds 153/** Convert seconds past UNIX epoch to a timetype*/
69 past the epoch in floating time. This routine is deprecated */ 154struct icaltimetype icaltime_from_timet(const time_t v, const int is_date);
70struct icaltimetype icaltime_from_int(int v, int is_date, int is_utc);
71 155
72/* Like icaltime_as_timet, but in a floating epoch. This routine is deprecated */ 156/** Convert seconds past UNIX epoch to a timetype, using timezones. */
73int icaltime_as_int(struct icaltimetype); 157struct icaltimetype icaltime_from_timet_with_zone(const time_t tm,
158 const int is_date, const icaltimezone *zone);
74 159
75/* create a time from an ISO format string */ 160/** create a time from an ISO format string */
76struct icaltimetype icaltime_from_string(const char* str); 161struct icaltimetype icaltime_from_string(const char* str);
77 162
78/* Routines for handling timezones */ 163/** create a time from an ISO format string */
79/* Return the offset of the named zone as seconds. tt is a time 164struct icaltimetype icaltime_from_string_with_zone(const char* str,
80 indicating the date for which you want the offset */ 165 const icaltimezone *zone);
81int icaltime_utc_offset(struct icaltimetype tt, const char* tzid);
82 166
83/* convert tt, of timezone tzid, into a utc time. Does nothing if the 167/** Create a new time, given a day of year and a year. */
84 time is already UTC. */ 168struct icaltimetype icaltime_from_day_of_year(const int doy,
85struct icaltimetype icaltime_as_utc(struct icaltimetype tt, 169 const int year);
86 const char* tzid);
87 170
88/* convert tt, a time in UTC, into a time in timezone tzid */ 171 /**@brief Contructor (TODO).
89struct icaltimetype icaltime_as_zone(struct icaltimetype tt, 172 * Create a new time from a weeknumber and a year. */
90 const char* tzid); 173struct icaltimetype icaltime_from_week_number(const int week_number,
174 const int year);
91 175
92/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */ 176/** Return the time as seconds past the UNIX epoch */
93struct icaltimetype icaltime_null_time(void); 177time_t icaltime_as_timet(const struct icaltimetype);
178
179/** Return the time as seconds past the UNIX epoch, using timezones. */
180time_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
181 const icaltimezone *zone);
182
183/** Return a string represention of the time, in RFC2445 format. The
184 string is owned by libical */
185const char* icaltime_as_ical_string(const struct icaltimetype tt);
186
187/** @brief Return the timezone */
188const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
94 189
95/* Return true of the time is null. */ 190/** @brief Return the tzid, or NULL for a floating time */
96int icaltime_is_null_time(struct icaltimetype t); 191char *icaltime_get_tzid(const struct icaltimetype t);
97 192
98/* Returns false if the time is clearly invalid, but is not null. This 193/** @brief Set the timezone */
194struct icaltimetype icaltime_set_timezone(struct icaltimetype *t,
195 const icaltimezone *zone);
196
197/** Return the day of the year of the given time */
198int icaltime_day_of_year(const struct icaltimetype t);
199
200/** Return the day of the week of the given time. Sunday is 1 */
201int icaltime_day_of_week(const struct icaltimetype t);
202
203/** Return the day of the year for the Sunday of the week that the
204 given time is within. */
205int icaltime_start_doy_of_week(const struct icaltimetype t);
206
207/** Return the week number for the week the given time is within */
208int icaltime_week_number(const struct icaltimetype t);
209
210/** Return true of the time is null. */
211int icaltime_is_null_time(const struct icaltimetype t);
212
213/** Returns false if the time is clearly invalid, but is not null. This
99 is usually the result of creating a new time type buy not clearing 214 is usually the result of creating a new time type buy not clearing
100 it, or setting one of the flags to an illegal value. */ 215 it, or setting one of the flags to an illegal value. */
101int icaltime_is_valid_time(struct icaltimetype t); 216int icaltime_is_valid_time(const struct icaltimetype t);
102 217
103/* Reset all of the time components to be in their normal ranges. For 218/** @brief Returns true if time is of DATE type, false if DATE-TIME */
104 instance, given a time with minutes=70, the minutes will be reduces 219int icaltime_is_date(const struct icaltimetype t);
105 to 10, and the hour incremented. This allows the caller to do
106 arithmetic on times without worrying about overflow or
107 underflow. */
108struct icaltimetype icaltime_normalize(struct icaltimetype t);
109 220
110/* Return the day of the year of the given time */ 221/** @brief Returns true if time is relative to UTC zone */
111short icaltime_day_of_year(struct icaltimetype t); 222int icaltime_is_utc(const struct icaltimetype t);
112 223
113/* Create a new time, given a day of year and a year. */ 224/** @brief Returns true if time is a floating time */
114struct icaltimetype icaltime_from_day_of_year(short doy, short year); 225int icaltime_is_floating(const struct icaltimetype t);
115 226
116/* Return the day of the week of the given time. Sunday is 1 */ 227/** Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
117short icaltime_day_of_week(struct icaltimetype t); 228int icaltime_compare_with_zone(const struct icaltimetype a,
229 const struct icaltimetype b);
118 230
119/* Return the day of the year for the Sunday of the week that the 231/** Return -1, 0, or 1 to indicate that a<b, a==b or a>b */
120 given time is within. */ 232int icaltime_compare(const struct icaltimetype a,
121short icaltime_start_doy_of_week(struct icaltimetype t); 233 const struct icaltimetype b);
122 234
123/* Return a string with the time represented in the same format as ctime(). THe string is owned by libical */ 235/** like icaltime_compare, but only use the date parts. */
124char* icaltime_as_ctime(struct icaltimetype); 236int icaltime_compare_date_only(const struct icaltimetype a,
237 const struct icaltimetype b);
125 238
126/* Return the week number for the week the given time is within */ 239/** Adds or subtracts a number of days, hours, minutes and seconds. */
127short icaltime_week_number(struct icaltimetype t); 240void icaltime_adjust(struct icaltimetype *tt, const int days,
241 const int hours, const int minutes, const int seconds);
128 242
129/* Create a new time from a weeknumber and a year. */ 243/** Normalize the icaltime, so that all fields are within the normal range. */
130struct icaltimetype icaltime_from_week_number(short week_number, short year); 244struct icaltimetype icaltime_normalize(const struct icaltimetype t);
131 245
132/* Return -1, 0, or 1 to indicate that a<b, a==b or a>b */ 246/** convert tt, of timezone tzid, into a utc time. Does nothing if the
133int icaltime_compare(struct icaltimetype a,struct icaltimetype b); 247 time is already UTC. */
248struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt,
249 icaltimezone *zone);
134 250
135/* like icaltime_compare, but only use the date parts. */ 251/** Return the number of days in the given month */
136int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b); 252int icaltime_days_in_month(const int month, const int year);
137 253
138/* Return the number of days in the given month */
139short icaltime_days_in_month(short month,short year);
140 254
255/** @brief calculate an icaltimespan given a start and end time. */
256struct icaltime_span icaltime_span_new(struct icaltimetype dtstart,
257 struct icaltimetype dtend,
258 int is_busy);
141 259
142#endif /* !ICALTIME_H */ 260/** @brief Returns true if the two spans overlap **/
261int icaltime_span_overlaps(icaltime_span *s1,
262 icaltime_span *s2);
143 263
264/** @brief Returns true if the span is totally within the containing
265 * span
266 */
267int icaltime_span_contains(icaltime_span *s,
268 icaltime_span *container);
269
270
271#endif /* !ICALTIME_H */
144 272
diff --git a/libical/src/libical/icaltimezone.c b/libical/src/libical/icaltimezone.c
new file mode 100644
index 0000000..fdb6b91
--- a/dev/null
+++ b/libical/src/libical/icaltimezone.c
@@ -0,0 +1,1672 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/*======================================================================
3 FILE: icaltimezone.c
4 CREATOR: Damon Chaplin 15 March 2001
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2001, Damon Chaplin
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22
23======================================================================*/
24
25/** @file icaltimezone.c
26 * @brief implementation of timezone handling routines
27 **/
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include "icalproperty.h"
37#include "icalarray.h"
38#include "icalerror.h"
39#include "icalparser.h"
40#include "icaltimezone.h"
41
42#ifdef WIN32
43#define snprintf _snprintf
44#define PACKAGE_DATA_DIR "/Projects/libical"
45#endif
46
47/** This is the toplevel directory where the timezone data is installed in. */
48#define ZONEINFO_DIRECTORY "/zoneinfo"
49
50/** The prefix we use to uniquely identify TZIDs. */
51 #define TZID_PREFIX "/softwarestudio.org/"
52 #define TZID_PREFIX_LEN 20
53
54/** This is the filename of the file containing the city names and
55 coordinates of all the builtin timezones. */
56 #define ZONES_TAB_FILENAME"zones.tab"
57
58/** This is the number of years of extra coverage we do when expanding
59 the timezone changes. */
60 #define ICALTIMEZONE_EXTRA_COVERAGE5
61
62/** This is the maximum year we will expand to. time_t values only go up to
63 somewhere around 2037. */
64 #define ICALTIMEZONE_MAX_YEAR 2035
65
66struct _icaltimezone {
67 char *tzid;
68 /**< The unique ID of this timezone,
69 e.g. "/softwarestudio.org/Olson_20010601_1/Africa/Banjul".
70 This should only be used to identify a VTIMEZONE. It is not
71 meant to be displayed to the user in any form. */
72
73 char *location;
74 /**< The location for the timezone, e.g. "Africa/Accra" for the
75 Olson database. We look for this in the "LOCATION" or
76 "X-LIC-LOCATION" properties of the VTIMEZONE component. It
77 isn't a standard property yet. This will be NULL if no location
78 is found in the VTIMEZONE. */
79
80 char *tznames;
81 /**< This will be set to a combination of the TZNAME properties
82 from the last STANDARD and DAYLIGHT components in the
83 VTIMEZONE, e.g. "EST/EDT". If they both use the same TZNAME,
84 or only one type of component is found, then only one TZNAME
85 will appear, e.g. "AZOT". If no TZNAME is found this will be
86 NULL. */
87
88 double latitude;
89 double longitude;
90 /**< The coordinates of the city, in degrees. */
91
92 icalcomponent*component;
93 /**< The toplevel VTIMEZONE component loaded from the .ics file for this
94 timezone. If we need to regenerate the changes data we need this. */
95
96 icaltimezone*builtin_timezone;
97 /**< If this is not NULL it points to the builtin icaltimezone
98 that the above TZID refers to. This icaltimezone should be used
99 instead when accessing the timezone changes data, so that the
100 expanded timezone changes data is shared between calendar
101 components. */
102
103 int end_year;
104 /**< This is the last year for which we have expanded the data to.
105 If we need to calculate a date past this we need to expand the
106 timezone component data from scratch. */
107
108 icalarray *changes;
109 /**< A dynamically-allocated array of time zone changes, sorted by the
110 time of the change in local time. So we can do fast binary-searches
111 to convert from local time to UTC. */
112};
113
114 typedef struct _icaltimezonechangeicaltimezonechange;
115
116struct _icaltimezonechange {
117 int utc_offset;
118 /**< The offset to add to UTC to get local time, in seconds. */
119
120 int prev_utc_offset;
121 /**< The offset to add to UTC, before this change, in seconds. */
122
123 int year; /**< Actual year, e.g. 2001. */
124 int month; /**< 1 (Jan) to 12 (Dec). */
125 int day;
126 int hour;
127 int minute;
128 int second;
129 /**< The time that the change came into effect, in UTC.
130 Note that the prev_utc_offset applies to this local time,
131 since we haven't changed to the new offset yet. */
132
133 int is_daylight;
134 /**< Whether this is STANDARD or DAYLIGHT time. */
135};
136
137
138/** An array of icaltimezones for the builtin timezones. */
139static icalarray *builtin_timezones = NULL;
140
141/** This is the special UTC timezone, which isn't in builtin_timezones. */
142static icaltimezone utc_timezone = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
143
144static char* zone_files_directory = NULL;
145
146 static void icaltimezone_reset (icaltimezone *zone);
147static char* icaltimezone_get_location_from_vtimezone (icalcomponent *component);
148static char* icaltimezone_get_tznames_from_vtimezone (icalcomponent *component);
149 static void icaltimezone_expand_changes (icaltimezone*zone,
150 int end_year);
151 static void icaltimezone_expand_vtimezone (icalcomponent*comp,
152 int end_year,
153 icalarray*changes);
154 static int icaltimezone_compare_change_fn (const void*elem1,
155 const void*elem2);
156
157 static int icaltimezone_find_nearby_change (icaltimezone*zone,
158 icaltimezonechange *change);
159
160 static void icaltimezone_adjust_change (icaltimezonechange *tt,
161 int days,
162 int hours,
163 int minutes,
164 int seconds);
165
166 static void icaltimezone_init (icaltimezone*zone);
167
168/** Gets the TZID, LOCATION/X-LIC-LOCATION, and TZNAME properties from the
169 VTIMEZONE component and places them in the icaltimezone. It returns 1 on
170 success, or 0 if the TZID can't be found. */
171static int icaltimezone_get_vtimezone_properties (icaltimezone *zone,
172 icalcomponent *component);
173
174
175 static void icaltimezone_load_builtin_timezone (icaltimezone*zone);
176
177 static void icaltimezone_ensure_coverage (icaltimezone*zone,
178 int end_year);
179
180
181static void icaltimezone_init_builtin_timezones(void);
182
183 static void icaltimezone_parse_zone_tab(void);
184
185 static char* icaltimezone_load_get_line_fn (char *s,
186 size_t size,
187 void *data);
188
189 static void format_utc_offset (int utc_offset,
190 char *buffer);
191
192static char* get_zone_directory(void);
193
194
195/** Creates a new icaltimezone. */
196icaltimezone*
197 icaltimezone_new (void)
198{
199 icaltimezone *zone;
200
201 zone = (icaltimezone*) malloc (sizeof (icaltimezone));
202 if (!zone) {
203 icalerror_set_errno (ICAL_NEWFAILED_ERROR);
204 return NULL;
205 }
206
207 icaltimezone_init (zone);
208
209 return zone;
210}
211
212
213/** Frees all memory used for the icaltimezone. */
214void
215 icaltimezone_free (icaltimezone *zone,
216 int free_struct)
217{
218 icaltimezone_reset (zone);
219 if (free_struct)
220 free (zone);
221}
222
223
224/** Resets the icaltimezone to the initial state, freeing most of the fields. */
225static void
226 icaltimezone_reset (icaltimezone *zone)
227{
228 if (zone->tzid)
229 free (zone->tzid);
230 if (zone->location)
231 free (zone->location);
232 if (zone->tznames)
233 free (zone->tznames);
234 if (zone->component)
235 icalcomponent_free (zone->component);
236 if (zone->changes)
237 icalarray_free (zone->changes);
238
239 icaltimezone_init (zone);
240}
241
242
243/** Initializes an icaltimezone. */
244static void
245 icaltimezone_init (icaltimezone*zone)
246{
247 zone->tzid = NULL;
248 zone->location = NULL;
249 zone->tznames = NULL;
250 zone->latitude = 0.0;
251 zone->longitude = 0.0;
252 zone->component = NULL;
253 zone->builtin_timezone = NULL;
254 zone->end_year = 0;
255 zone->changes = NULL;
256}
257
258
259/** Gets the TZID, LOCATION/X-LIC-LOCATION and TZNAME properties of
260 the VTIMEZONE component and stores them in the icaltimezone. It
261 returns 1 on success, or 0 if the TZID can't be found. Note that
262 it expects the zone to be initialized or reset - it doesn't free
263 any old values. */
264static int
265 icaltimezone_get_vtimezone_properties (icaltimezone*zone,
266 icalcomponent*component)
267{
268 icalproperty *prop;
269 const char *tzid;
270
271 prop = icalcomponent_get_first_property (component, ICAL_TZID_PROPERTY);
272 if (!prop)
273 return 0;
274
275 /* A VTIMEZONE MUST have a TZID, or a lot of our code won't work. */
276 tzid = icalproperty_get_tzid (prop);
277 if (!tzid)
278 return 0;
279
280 zone->tzid = strdup (tzid);
281 zone->component = component;
282 if ( zone->location != 0 ) free ( zone->location );
283 zone->location = icaltimezone_get_location_from_vtimezone (component);
284 zone->tznames = icaltimezone_get_tznames_from_vtimezone (component);
285
286 return 1;
287}
288
289/** Gets the LOCATION or X-LIC-LOCATION property from a VTIMEZONE. */
290static char*
291icaltimezone_get_location_from_vtimezone (icalcomponent *component)
292{
293 icalproperty *prop;
294 const char *location;
295 const char *name;
296
297 prop = icalcomponent_get_first_property (component,
298 ICAL_LOCATION_PROPERTY);
299 if (prop) {
300 location = icalproperty_get_location (prop);
301 if (location)
302 return strdup (location);
303 }
304
305 prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY);
306 while (prop) {
307 name = icalproperty_get_x_name (prop);
308 if (name && !strcmp (name, "X-LIC-LOCATION")) {
309 location = icalproperty_get_x (prop);
310 if (location)
311 return strdup (location);
312 }
313 prop = icalcomponent_get_next_property (component,
314 ICAL_X_PROPERTY);
315 }
316
317 return NULL;
318}
319
320
321/** Gets the TZNAMEs used for the last STANDARD & DAYLIGHT components
322 in a VTIMEZONE. If both STANDARD and DAYLIGHT components use the
323 same TZNAME, it returns that. If they use different TZNAMEs, it
324 formats them like "EST/EDT". The returned string should be freed by
325 the caller. */
326static char*
327icaltimezone_get_tznames_from_vtimezone (icalcomponent *component)
328{
329 icalcomponent *comp;
330 icalcomponent_kind type;
331 icalproperty *prop;
332 struct icaltimetype dtstart;
333 struct icaldatetimeperiodtype rdate;
334 const char *current_tzname;
335 const char *standard_tzname = NULL, *daylight_tzname = NULL;
336 struct icaltimetype standard_max_date, daylight_max_date;
337 struct icaltimetype current_max_date;
338
339 standard_max_date = icaltime_null_time();
340 daylight_max_date = icaltime_null_time();
341
342 /* Step through the STANDARD & DAYLIGHT subcomponents. */
343 comp = icalcomponent_get_first_component (component, ICAL_ANY_COMPONENT);
344 while (comp) {
345 type = icalcomponent_isa (comp);
346 if (type == ICAL_XSTANDARD_COMPONENT
347 || type == ICAL_XDAYLIGHT_COMPONENT) {
348 current_max_date = icaltime_null_time ();
349 current_tzname = NULL;
350
351 /* Step through the properties. We want to find the TZNAME, and
352 the largest DTSTART or RDATE. */
353 prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
354 while (prop) {
355 switch (icalproperty_isa (prop)) {
356 case ICAL_TZNAME_PROPERTY:
357 current_tzname = icalproperty_get_tzname (prop);
358 break;
359
360 case ICAL_DTSTART_PROPERTY:
361 dtstart = icalproperty_get_dtstart (prop);
362 if (icaltime_compare (dtstart, current_max_date) > 0)
363 current_max_date = dtstart;
364
365 break;
366
367 case ICAL_RDATE_PROPERTY:
368 rdate = icalproperty_get_rdate (prop);
369 if (icaltime_compare (rdate.time, current_max_date) > 0)
370 current_max_date = rdate.time;
371
372 break;
373
374 default:
375 break;
376 }
377
378 prop = icalcomponent_get_next_property (comp,
379 ICAL_ANY_PROPERTY);
380 }
381
382 if (current_tzname) {
383 if (type == ICAL_XSTANDARD_COMPONENT) {
384 if (!standard_tzname
385 || icaltime_compare (current_max_date,
386 standard_max_date) > 0) {
387 standard_max_date = current_max_date;
388 standard_tzname = current_tzname;
389 }
390 } else {
391 if (!daylight_tzname
392 || icaltime_compare (current_max_date,
393 daylight_max_date) > 0) {
394 daylight_max_date = current_max_date;
395 daylight_tzname = current_tzname;
396 }
397 }
398 }
399 }
400
401 comp = icalcomponent_get_next_component (component,
402 ICAL_ANY_COMPONENT);
403 }
404
405 /* Outlook (2000) places "Standard Time" and "Daylight Time" in the TZNAME
406 strings, which is totally useless. So we return NULL in that case. */
407 if (standard_tzname && !strcmp (standard_tzname, "Standard Time"))
408 return NULL;
409
410 /* If both standard and daylight TZNAMEs were found, if they are the same
411 we return just one, else we format them like "EST/EDT". */
412 if (standard_tzname && daylight_tzname) {
413 unsigned int standard_len, daylight_len;
414 char *tznames;
415
416 if (!strcmp (standard_tzname, daylight_tzname))
417 return strdup (standard_tzname);
418
419 standard_len = strlen (standard_tzname);
420 daylight_len = strlen (daylight_tzname);
421 tznames = malloc (standard_len + daylight_len + 2);
422 strcpy (tznames, standard_tzname);
423 tznames[standard_len] = '/';
424 strcpy (tznames + standard_len + 1, daylight_tzname);
425 return tznames;
426 } else {
427 const char *tznames;
428
429 /* If either of the TZNAMEs was found just return that, else NULL. */
430 tznames = standard_tzname ? standard_tzname : daylight_tzname;
431 return tznames ? strdup (tznames) : NULL;
432 }
433}
434
435
436static void
437 icaltimezone_ensure_coverage (icaltimezone*zone,
438 int end_year)
439{
440 /* When we expand timezone changes we always expand at least up to this
441 year, plus ICALTIMEZONE_EXTRA_COVERAGE. */
442 static int icaltimezone_minimum_expansion_year = -1;
443
444 int changes_end_year;
445
446 if (!zone->component)
447 icaltimezone_load_builtin_timezone (zone);
448
449 if (icaltimezone_minimum_expansion_year == -1) {
450 struct icaltimetype today = icaltime_today();
451 icaltimezone_minimum_expansion_year = today.year;
452 }
453
454 changes_end_year = end_year;
455 if (changes_end_year < icaltimezone_minimum_expansion_year)
456 changes_end_year = icaltimezone_minimum_expansion_year;
457
458 changes_end_year += ICALTIMEZONE_EXTRA_COVERAGE;
459
460 if (changes_end_year > ICALTIMEZONE_MAX_YEAR)
461 changes_end_year = ICALTIMEZONE_MAX_YEAR;
462
463 if (!zone->changes || zone->end_year < end_year)
464 icaltimezone_expand_changes (zone, changes_end_year);
465}
466
467
468static void
469 icaltimezone_expand_changes (icaltimezone*zone,
470 int end_year)
471{
472 icalarray *changes;
473 icalcomponent *comp;
474
475#if 0
476 printf ("\nExpanding changes for: %s to year: %i\n", zone->tzid, end_year);
477#endif
478
479 changes = icalarray_new (sizeof (icaltimezonechange), 32);
480 if (!changes)
481 return;
482
483 /* Scan the STANDARD and DAYLIGHT subcomponents. */
484 comp = icalcomponent_get_first_component (zone->component,
485 ICAL_ANY_COMPONENT);
486 while (comp) {
487 icaltimezone_expand_vtimezone (comp, end_year, changes);
488 comp = icalcomponent_get_next_component (zone->component,
489 ICAL_ANY_COMPONENT);
490 }
491
492 /* Sort the changes. We may have duplicates but I don't think it will
493 matter. */
494 icalarray_sort (changes, icaltimezone_compare_change_fn);
495
496 if (zone->changes)
497 icalarray_free (zone->changes);
498
499 zone->changes = changes;
500 zone->end_year = end_year;
501}
502
503
504static void
505 icaltimezone_expand_vtimezone (icalcomponent*comp,
506 int end_year,
507 icalarray*changes)
508{
509 icaltimezonechange change;
510 icalproperty *prop;
511 struct icaltimetype dtstart, occ;
512 struct icalrecurrencetype rrule;
513 icalrecur_iterator* rrule_iterator;
514 struct icaldatetimeperiodtype rdate;
515 int found_dtstart = 0, found_tzoffsetto = 0, found_tzoffsetfrom = 0;
516 int has_recurrence = 0;
517
518 /* First we check if it is a STANDARD or DAYLIGHT component, and
519 just return if it isn't. */
520 if (icalcomponent_isa (comp) == ICAL_XSTANDARD_COMPONENT)
521 change.is_daylight = 0;
522 else if (icalcomponent_isa (comp) == ICAL_XDAYLIGHT_COMPONENT)
523 change.is_daylight = 1;
524 else
525 return;
526
527 /* Step through each of the properties to find the DTSTART,
528 TZOFFSETFROM and TZOFFSETTO. We can't expand recurrences here
529 since we need these properties before we can do that. */
530 prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
531 while (prop) {
532 switch (icalproperty_isa (prop)) {
533 case ICAL_DTSTART_PROPERTY:
534 dtstart = icalproperty_get_dtstart (prop);
535 found_dtstart = 1;
536 break;
537 case ICAL_TZOFFSETTO_PROPERTY:
538 change.utc_offset = icalproperty_get_tzoffsetto (prop);
539 /*printf ("Found TZOFFSETTO: %i\n", change.utc_offset);*/
540 found_tzoffsetto = 1;
541 break;
542 case ICAL_TZOFFSETFROM_PROPERTY:
543 change.prev_utc_offset = icalproperty_get_tzoffsetfrom (prop);
544 /*printf ("Found TZOFFSETFROM: %i\n", change.prev_utc_offset);*/
545 found_tzoffsetfrom = 1;
546 break;
547 case ICAL_RDATE_PROPERTY:
548 case ICAL_RRULE_PROPERTY:
549 has_recurrence = 1;
550 break;
551 default:
552 /* Just ignore any other properties. */
553 break;
554 }
555
556 prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
557 }
558
559 /* If we didn't find a DTSTART, TZOFFSETTO and TZOFFSETFROM we have to
560 ignore the component. FIXME: Add an error property? */
561 if (!found_dtstart || !found_tzoffsetto || !found_tzoffsetfrom)
562 return;
563
564#if 0
565 printf ("\n Expanding component DTSTART (Y/M/D): %i/%i/%i %i:%02i:%02i\n",
566 dtstart.year, dtstart.month, dtstart.day,
567 dtstart.hour, dtstart.minute, dtstart.second);
568#endif
569
570 /* If the STANDARD/DAYLIGHT component has no recurrence data, we just add
571 a single change for the DTSTART. */
572 if (!has_recurrence) {
573 change.year = dtstart.year;
574 change.month = dtstart.month;
575 change.day = dtstart.day;
576 change.hour = dtstart.hour;
577 change.minute = dtstart.minute;
578 change.second = dtstart.second;
579
580 /* Convert to UTC. */
581 icaltimezone_adjust_change (&change, 0, 0, 0, -change.prev_utc_offset);
582
583#if 0
584 printf (" Appending single DTSTART (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
585 change.year, change.month, change.day,
586 change.hour, change.minute, change.second);
587#endif
588
589 /* Add the change to the array. */
590 icalarray_append (changes, &change);
591 return;
592 }
593
594 /* The component has recurrence data, so we expand that now. */
595 prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
596 while (prop) {
597#if 0
598 printf ("Expanding property...\n");
599#endif
600 switch (icalproperty_isa (prop)) {
601 case ICAL_RDATE_PROPERTY:
602 rdate = icalproperty_get_rdate (prop);
603 change.year = rdate.time.year;
604 change.month = rdate.time.month;
605 change.day = rdate.time.day;
606 /* RDATEs with a DATE value inherit the time from
607 the DTSTART. */
608 if (icaltime_is_date(rdate.time)) {
609 change.hour = dtstart.hour;
610 change.minute = dtstart.minute;
611 change.second = dtstart.second;
612 } else {
613 change.hour = rdate.time.hour;
614 change.minute = rdate.time.minute;
615 change.second = rdate.time.second;
616
617 /* The spec was a bit vague about whether RDATEs were in local
618 time or UTC so we support both to be safe. So if it is in
619 UTC we have to add the UTC offset to get a local time. */
620 if (!icaltime_is_utc(rdate.time))
621 icaltimezone_adjust_change (&change, 0, 0, 0,
622 -change.prev_utc_offset);
623 }
624
625#if 0
626 printf (" Appending RDATE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
627 change.year, change.month, change.day,
628 change.hour, change.minute, change.second);
629#endif
630
631 icalarray_append (changes, &change);
632 break;
633 case ICAL_RRULE_PROPERTY:
634 rrule = icalproperty_get_rrule (prop);
635
636 /* If the rrule UNTIL value is set and is in UTC, we convert it to
637 a local time, since the recurrence code has no way to convert
638 it itself. */
639 if (!icaltime_is_null_time (rrule.until) && rrule.until.is_utc) {
640#if 0
641 printf (" Found RRULE UNTIL in UTC.\n");
642#endif
643
644 /* To convert from UTC to a local time, we use the TZOFFSETFROM
645 since that is the offset from UTC that will be in effect
646 when each of the RRULE occurrences happens. */
647 icaltime_adjust (&rrule.until, 0, 0, 0,
648 change.prev_utc_offset);
649 rrule.until.is_utc = 0;
650 }
651
652 rrule_iterator = icalrecur_iterator_new (rrule, dtstart);
653 for (;;) {
654 occ = icalrecur_iterator_next (rrule_iterator);
655 if (occ.year > end_year || icaltime_is_null_time (occ))
656 break;
657
658 change.year = occ.year;
659 change.month = occ.month;
660 change.day = occ.day;
661 change.hour = occ.hour;
662 change.minute = occ.minute;
663 change.second = occ.second;
664
665#if 0
666 printf (" Appending RRULE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n",
667 change.year, change.month, change.day,
668 change.hour, change.minute, change.second);
669#endif
670
671 icaltimezone_adjust_change (&change, 0, 0, 0,
672 -change.prev_utc_offset);
673
674 icalarray_append (changes, &change);
675 }
676
677 icalrecur_iterator_free (rrule_iterator);
678 break;
679 default:
680 break;
681 }
682
683 prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
684 }
685}
686
687
688/** A function to compare 2 icaltimezonechange elements, used for qsort(). */
689static int
690 icaltimezone_compare_change_fn (const void*elem1,
691 const void*elem2)
692{
693 const icaltimezonechange *change1, *change2;
694 int retval;
695
696 change1 = elem1;
697 change2 = elem2;
698
699 if (change1->year < change2->year)
700 retval = -1;
701 else if (change1->year > change2->year)
702 retval = 1;
703
704 else if (change1->month < change2->month)
705 retval = -1;
706 else if (change1->month > change2->month)
707 retval = 1;
708
709 else if (change1->day < change2->day)
710 retval = -1;
711 else if (change1->day > change2->day)
712 retval = 1;
713
714 else if (change1->hour < change2->hour)
715 retval = -1;
716 else if (change1->hour > change2->hour)
717 retval = 1;
718
719 else if (change1->minute < change2->minute)
720 retval = -1;
721 else if (change1->minute > change2->minute)
722 retval = 1;
723
724 else if (change1->second < change2->second)
725 retval = -1;
726 else if (change1->second > change2->second)
727 retval = 1;
728
729 else
730 retval = 0;
731
732 return retval;
733}
734
735
736
737void
738 icaltimezone_convert_time (struct icaltimetype *tt,
739 icaltimezone*from_zone,
740 icaltimezone*to_zone)
741{
742 int utc_offset, is_daylight;
743
744 /* If the time is a DATE value or both timezones are the same, or we are
745 converting a floating time, we don't need to do anything. */
746 if (icaltime_is_date(*tt) || from_zone == to_zone || from_zone == NULL)
747 return;
748
749 /* Convert the time to UTC by getting the UTC offset and subtracting it. */
750 utc_offset = icaltimezone_get_utc_offset (from_zone, tt, NULL);
751 icaltime_adjust (tt, 0, 0, 0, -utc_offset);
752
753 /* Now we convert the time to the new timezone by getting the UTC offset
754 of our UTC time and adding it. */
755 utc_offset = icaltimezone_get_utc_offset_of_utc_time (to_zone, tt,
756 &is_daylight);
757 tt->is_daylight = is_daylight;
758 icaltime_adjust (tt, 0, 0, 0, utc_offset);
759}
760
761
762
763
764/** @deprecated This API wasn't updated when we changed icaltimetype to contain its own
765 timezone. Also, this takes a pointer instead of the struct. */
766/* Calculates the UTC offset of a given local time in the given
767 timezone. It is the number of seconds to add to UTC to get local
768 time. The is_daylight flag is set to 1 if the time is in
769 daylight-savings time. */
770int
771 icaltimezone_get_utc_offset (icaltimezone*zone,
772 struct icaltimetype*tt,
773 int *is_daylight)
774{
775 icaltimezonechange *zone_change, *prev_zone_change, tt_change, tmp_change;
776 int change_num, step, utc_offset_change, cmp;
777 int change_num_to_use;
778 int want_daylight;
779
780 if (tt == NULL)
781 return 0;
782
783 if (is_daylight)
784 *is_daylight = 0;
785
786 /* For local times and UTC return 0. */
787 if (zone == NULL || zone == &utc_timezone)
788 return 0;
789
790 /* Use the builtin icaltimezone if possible. */
791 if (zone->builtin_timezone)
792 zone = zone->builtin_timezone;
793
794 /* Make sure the changes array is expanded up to the given time. */
795 icaltimezone_ensure_coverage (zone, tt->year);
796
797 if (!zone->changes || zone->changes->num_elements == 0)
798 return 0;
799
800 /* Copy the time parts of the icaltimetype to an icaltimezonechange so we
801 can use our comparison function on it. */
802 tt_change.year = tt->year;
803 tt_change.month = tt->month;
804 tt_change.day = tt->day;
805 tt_change.hour = tt->hour;
806 tt_change.minute = tt->minute;
807 tt_change.second = tt->second;
808
809 /* This should find a change close to the time, either the change before
810 it or the change after it. */
811 change_num = icaltimezone_find_nearby_change (zone, &tt_change);
812
813 /* Sanity check. */
814 icalerror_assert (change_num >= 0,
815 "Negative timezone change index");
816 icalerror_assert (change_num < zone->changes->num_elements,
817 "Timezone change index out of bounds");
818
819 /* Now move backwards or forwards to find the timezone change that applies
820 to tt. It should only have to do 1 or 2 steps. */
821 zone_change = icalarray_element_at (zone->changes, change_num);
822 step = 1;
823 change_num_to_use = -1;
824 for (;;) {
825 /* Copy the change, so we can adjust it. */
826 tmp_change = *zone_change;
827
828 /* If the clock is going backward, check if it is in the region of time
829 that is used twice. If it is, use the change with the daylight
830 setting which matches tt, or use standard if we don't know. */
831 if (tmp_change.utc_offset < tmp_change.prev_utc_offset) {
832 /* If the time change is at 2:00AM local time and the clock is
833 going back to 1:00AM we adjust the change to 1:00AM. We may
834 have the wrong change but we'll figure that out later. */
835 icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
836 tmp_change.utc_offset);
837 } else {
838 icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
839 tmp_change.prev_utc_offset);
840 }
841
842 cmp = icaltimezone_compare_change_fn (&tt_change, &tmp_change);
843
844 /* If the given time is on or after this change, then this change may
845 apply, but we continue as a later change may be the right one.
846 If the given time is before this change, then if we have already
847 found a change which applies we can use that, else we need to step
848 backwards. */
849 if (cmp >= 0)
850 change_num_to_use = change_num;
851 else
852 step = -1;
853
854 /* If we are stepping backwards through the changes and we have found
855 a change that applies, then we know this is the change to use so
856 we exit the loop. */
857 if (step == -1 && change_num_to_use != -1)
858 break;
859
860 change_num += step;
861
862 /* If we go past the start of the changes array, then we have no data
863 for this time so we return a UTC offset of 0. */
864 if (change_num < 0)
865 return 0;
866
867 if (change_num >= zone->changes->num_elements)
868 break;
869
870 zone_change = icalarray_element_at (zone->changes, change_num);
871 }
872
873 /* If we didn't find a change to use, then we have a bug! */
874 icalerror_assert (change_num_to_use != -1,
875 "No applicable timezone change found");
876
877 /* Now we just need to check if the time is in the overlapped region of
878 time when clocks go back. */
879 zone_change = icalarray_element_at (zone->changes, change_num_to_use);
880
881 utc_offset_change = zone_change->utc_offset - zone_change->prev_utc_offset;
882 if (utc_offset_change < 0 && change_num_to_use > 0) {
883 tmp_change = *zone_change;
884 icaltimezone_adjust_change (&tmp_change, 0, 0, 0,
885 tmp_change.prev_utc_offset);
886
887 if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) < 0) {
888 /* The time is in the overlapped region, so we may need to use
889 either the current zone_change or the previous one. If the
890 time has the is_daylight field set we use the matching change,
891 else we use the change with standard time. */
892 prev_zone_change = icalarray_element_at (zone->changes,
893 change_num_to_use - 1);
894
895 /* I was going to add an is_daylight flag to struct icaltimetype,
896 but iCalendar doesn't let us distinguish between standard and
897 daylight time anyway, so there's no point. So we just use the
898 standard time instead. */
899 want_daylight = (tt->is_daylight == 1) ? 1 : 0;
900
901#if 0
902 if (zone_change->is_daylight == prev_zone_change->is_daylight)
903 printf (" **** Same is_daylight setting\n");
904#endif
905
906 if (zone_change->is_daylight != want_daylight
907 && prev_zone_change->is_daylight == want_daylight)
908 zone_change = prev_zone_change;
909 }
910 }
911
912 /* Now we know exactly which timezone change applies to the time, so
913 we can return the UTC offset and whether it is a daylight time. */
914 if (is_daylight)
915 *is_daylight = zone_change->is_daylight;
916 return zone_change->utc_offset;
917}
918
919
920/** @deprecated This API wasn't updated when we changed icaltimetype to contain its own
921 timezone. Also, this takes a pointer instead of the struct. */
922/** Calculates the UTC offset of a given UTC time in the given
923 timezone. It is the number of seconds to add to UTC to get local
924 time. The is_daylight flag is set to 1 if the time is in
925 daylight-savings time. */
926int
927 icaltimezone_get_utc_offset_of_utc_time (icaltimezone*zone,
928 struct icaltimetype*tt,
929 int *is_daylight)
930{
931 icaltimezonechange *zone_change, tt_change, tmp_change;
932 int change_num, step, change_num_to_use;
933
934 if (is_daylight)
935 *is_daylight = 0;
936
937 /* For local times and UTC return 0. */
938 if (zone == NULL || zone == &utc_timezone)
939 return 0;
940
941 /* Use the builtin icaltimezone if possible. */
942 if (zone->builtin_timezone)
943 zone = zone->builtin_timezone;
944
945 /* Make sure the changes array is expanded up to the given time. */
946 icaltimezone_ensure_coverage (zone, tt->year);
947
948 if (!zone->changes || zone->changes->num_elements == 0)
949 return 0;
950
951 /* Copy the time parts of the icaltimetype to an icaltimezonechange so we
952 can use our comparison function on it. */
953 tt_change.year = tt->year;
954 tt_change.month = tt->month;
955 tt_change.day = tt->day;
956 tt_change.hour = tt->hour;
957 tt_change.minute = tt->minute;
958 tt_change.second = tt->second;
959
960 /* This should find a change close to the time, either the change before
961 it or the change after it. */
962 change_num = icaltimezone_find_nearby_change (zone, &tt_change);
963
964 /* Sanity check. */
965 icalerror_assert (change_num >= 0,
966 "Negative timezone change index");
967 icalerror_assert (change_num < zone->changes->num_elements,
968 "Timezone change index out of bounds");
969
970 /* Now move backwards or forwards to find the timezone change that applies
971 to tt. It should only have to do 1 or 2 steps. */
972 zone_change = icalarray_element_at (zone->changes, change_num);
973 step = 1;
974 change_num_to_use = -1;
975 for (;;) {
976 /* Copy the change and adjust it to UTC. */
977 tmp_change = *zone_change;
978
979 /* If the given time is on or after this change, then this change may
980 apply, but we continue as a later change may be the right one.
981 If the given time is before this change, then if we have already
982 found a change which applies we can use that, else we need to step
983 backwards. */
984 if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) >= 0)
985 change_num_to_use = change_num;
986 else
987 step = -1;
988
989 /* If we are stepping backwards through the changes and we have found
990 a change that applies, then we know this is the change to use so
991 we exit the loop. */
992 if (step == -1 && change_num_to_use != -1)
993 break;
994
995 change_num += step;
996
997 /* If we go past the start of the changes array, then we have no data
998 for this time so we return a UTC offset of 0. */
999 if (change_num < 0)
1000 return 0;
1001
1002 if (change_num >= zone->changes->num_elements)
1003 break;
1004
1005 zone_change = icalarray_element_at (zone->changes, change_num);
1006 }
1007
1008 /* If we didn't find a change to use, then we have a bug! */
1009 icalerror_assert (change_num_to_use != -1,
1010 "No applicable timezone change found");
1011
1012 /* Now we know exactly which timezone change applies to the time, so
1013 we can return the UTC offset and whether it is a daylight time. */
1014 zone_change = icalarray_element_at (zone->changes, change_num_to_use);
1015 if (is_daylight)
1016 *is_daylight = zone_change->is_daylight;
1017
1018 return zone_change->utc_offset;
1019}
1020
1021
1022/** Returns the index of a timezone change which is close to the time
1023 given in change. */
1024static int
1025 icaltimezone_find_nearby_change (icaltimezone *zone,
1026 icaltimezonechange*change)
1027{
1028 icaltimezonechange *zone_change;
1029 int lower, upper, middle, cmp;
1030
1031 /* Do a simple binary search. */
1032 lower = middle = 0;
1033 upper = zone->changes->num_elements;
1034
1035 while (lower < upper) {
1036 middle = (lower + upper) / 2;
1037 zone_change = icalarray_element_at (zone->changes, middle);
1038 cmp = icaltimezone_compare_change_fn (change, zone_change);
1039 if (cmp == 0)
1040 break;
1041 else if (cmp < 0)
1042 upper = middle;
1043 else
1044 lower = middle + 1;
1045 }
1046
1047 return middle;
1048}
1049
1050
1051
1052
1053/** Adds (or subtracts) a time from a icaltimezonechange. NOTE: This
1054 function is exactly the same as icaltime_adjust() except for the
1055 type of the first parameter. */
1056static void
1057 icaltimezone_adjust_change (icaltimezonechange *tt,
1058 int days,
1059 int hours,
1060 int minutes,
1061 int seconds)
1062{
1063 int second, minute, hour, day;
1064 int minutes_overflow, hours_overflow, days_overflow;
1065 int days_in_month;
1066
1067 /* Add on the seconds. */
1068 second = tt->second + seconds;
1069 tt->second = second % 60;
1070 minutes_overflow = second / 60;
1071 if (tt->second < 0) {
1072 tt->second += 60;
1073 minutes_overflow--;
1074 }
1075
1076 /* Add on the minutes. */
1077 minute = tt->minute + minutes + minutes_overflow;
1078 tt->minute = minute % 60;
1079 hours_overflow = minute / 60;
1080 if (tt->minute < 0) {
1081 tt->minute += 60;
1082 hours_overflow--;
1083 }
1084
1085 /* Add on the hours. */
1086 hour = tt->hour + hours + hours_overflow;
1087 tt->hour = hour % 24;
1088 days_overflow = hour / 24;
1089 if (tt->hour < 0) {
1090 tt->hour += 24;
1091 days_overflow--;
1092 }
1093
1094 /* Add on the days. */
1095 day = tt->day + days + days_overflow;
1096 if (day > 0) {
1097 for (;;) {
1098 days_in_month = icaltime_days_in_month (tt->month, tt->year);
1099 if (day <= days_in_month)
1100 break;
1101
1102 tt->month++;
1103 if (tt->month >= 13) {
1104 tt->year++;
1105 tt->month = 1;
1106 }
1107
1108 day -= days_in_month;
1109 }
1110 } else {
1111 while (day <= 0) {
1112 if (tt->month == 1) {
1113 tt->year--;
1114 tt->month = 12;
1115 } else {
1116 tt->month--;
1117 }
1118
1119 day += icaltime_days_in_month (tt->month, tt->year);
1120 }
1121 }
1122 tt->day = day;
1123}
1124
1125
1126char*
1127 icaltimezone_get_tzid (icaltimezone*zone)
1128{
1129 /* If this is a floating time, without a timezone, return NULL. */
1130 if (!zone)
1131 return NULL;
1132
1133 if (!zone->tzid)
1134 icaltimezone_load_builtin_timezone (zone);
1135
1136 return zone->tzid;
1137}
1138
1139
1140char*
1141 icaltimezone_get_location (icaltimezone*zone)
1142{
1143 /* If this is a floating time, without a timezone, return NULL. */
1144 if (!zone)
1145 return NULL;
1146
1147 /* Note that for builtin timezones this comes from zones.tab so we don't
1148 need to check the timezone is loaded here. */
1149 return zone->location;
1150}
1151
1152
1153char*
1154 icaltimezone_get_tznames (icaltimezone*zone)
1155{
1156 /* If this is a floating time, without a timezone, return NULL. */
1157 if (!zone)
1158 return NULL;
1159
1160 if (!zone->component)
1161 icaltimezone_load_builtin_timezone (zone);
1162
1163 return zone->tznames;
1164}
1165
1166
1167/** Returns the latitude of a builtin timezone. */
1168double
1169 icaltimezone_get_latitude (icaltimezone*zone)
1170{
1171 /* If this is a floating time, without a timezone, return 0. */
1172 if (!zone)
1173 return 0.0;
1174
1175 /* Note that for builtin timezones this comes from zones.tab so we don't
1176 need to check the timezone is loaded here. */
1177 return zone->latitude;
1178}
1179
1180
1181/** Returns the longitude of a builtin timezone. */
1182double
1183 icaltimezone_get_longitude (icaltimezone*zone)
1184{
1185 /* If this is a floating time, without a timezone, return 0. */
1186 if (!zone)
1187 return 0.0;
1188
1189 /* Note that for builtin timezones this comes from zones.tab so we don't
1190 need to check the timezone is loaded here. */
1191 return zone->longitude;
1192}
1193
1194
1195/** Returns the VTIMEZONE component of a timezone. */
1196icalcomponent*
1197 icaltimezone_get_component (icaltimezone*zone)
1198{
1199 /* If this is a floating time, without a timezone, return NULL. */
1200 if (!zone)
1201 return NULL;
1202
1203 if (!zone->component)
1204 icaltimezone_load_builtin_timezone (zone);
1205
1206 return zone->component;
1207}
1208
1209
1210/** Sets the VTIMEZONE component of an icaltimezone, initializing the
1211 tzid, location & tzname fields. It returns 1 on success or 0 on
1212 failure, i.e. no TZID was found. */
1213int
1214 icaltimezone_set_component (icaltimezone*zone,
1215 icalcomponent*comp)
1216{
1217 icaltimezone_reset (zone);
1218 return icaltimezone_get_vtimezone_properties (zone, comp);
1219}
1220
1221
1222icalarray*
1223 icaltimezone_array_new (void)
1224{
1225 return icalarray_new (sizeof (icaltimezone), 16);
1226}
1227
1228
1229void
1230 icaltimezone_array_append_from_vtimezone (icalarray*timezones,
1231 icalcomponent*child)
1232{
1233 icaltimezone zone;
1234
1235 icaltimezone_init (&zone);
1236 if (icaltimezone_get_vtimezone_properties (&zone, child))
1237 icalarray_append (timezones, &zone);
1238}
1239
1240
1241void
1242 icaltimezone_array_free (icalarray*timezones)
1243{
1244 icaltimezone *zone;
1245 int i;
1246
1247 if ( timezones )
1248 {
1249 for (i = 0; i < timezones->num_elements; i++) {
1250 zone = icalarray_element_at (timezones, i);
1251 icaltimezone_free (zone, 0);
1252 }
1253
1254 icalarray_free (timezones);
1255 }
1256}
1257
1258
1259/*
1260 * BUILTIN TIMEZONE HANDLING
1261 */
1262
1263
1264/** Returns an icalarray of icaltimezone structs, one for each builtin
1265 timezone. This will load and parse the zones.tab file to get the
1266 timezone names and their coordinates. It will not load the
1267 VTIMEZONE data for any timezones. */
1268icalarray*
1269 icaltimezone_get_builtin_timezones(void)
1270{
1271 if (!builtin_timezones)
1272 icaltimezone_init_builtin_timezones ();
1273
1274 return builtin_timezones;
1275}
1276
1277/** Release builtin timezone memory */
1278void
1279icaltimezone_free_builtin_timezones(void)
1280{
1281 icaltimezone_array_free(builtin_timezones);
1282}
1283
1284
1285/** Returns a single builtin timezone, given its Olson city name. */
1286icaltimezone*
1287 icaltimezone_get_builtin_timezone(const char *location)
1288{
1289 icaltimezone *zone;
1290 int lower, upper, middle, cmp;
1291 char *zone_location;
1292
1293 if (!location || !location[0])
1294 return NULL;
1295
1296 if (!strcmp (location, "UTC"))
1297 return &utc_timezone;
1298
1299 if (!builtin_timezones)
1300 icaltimezone_init_builtin_timezones ();
1301
1302 /* Do a simple binary search. */
1303 lower = middle = 0;
1304 upper = builtin_timezones->num_elements;
1305
1306 while (lower < upper) {
1307 middle = (lower + upper) / 2;
1308 zone = icalarray_element_at (builtin_timezones, middle);
1309 zone_location = icaltimezone_get_location (zone);
1310 cmp = strcmp (location, zone_location);
1311 if (cmp == 0)
1312 return zone;
1313 else if (cmp < 0)
1314 upper = middle;
1315 else
1316 lower = middle + 1;
1317 }
1318
1319 return NULL;
1320}
1321
1322
1323/** Returns a single builtin timezone, given its TZID. */
1324icaltimezone*
1325icaltimezone_get_builtin_timezone_from_tzid (const char *tzid)
1326{
1327 int num_slashes = 0;
1328 const char *p, *zone_tzid;
1329 icaltimezone *zone;
1330
1331 if (!tzid || !tzid[0])
1332 return NULL;
1333
1334 /* Check that the TZID starts with our unique prefix. */
1335 if (strncmp (tzid, TZID_PREFIX, TZID_PREFIX_LEN))
1336 return NULL;
1337
1338 /* Get the location, which is after the 3rd '/' character. */
1339 p = tzid;
1340 for (p = tzid; *p; p++) {
1341 if (*p == '/') {
1342 num_slashes++;
1343 if (num_slashes == 3)
1344 break;
1345 }
1346 }
1347
1348 if (num_slashes != 3)
1349 return NULL;
1350
1351 p++;
1352
1353 /* Now we can use the function to get the builtin timezone from the
1354 location string. */
1355 zone = icaltimezone_get_builtin_timezone (p);
1356 if (!zone)
1357 return NULL;
1358
1359 /* Check that the builtin TZID matches exactly. We don't want to return
1360 a different version of the VTIMEZONE. */
1361 zone_tzid = icaltimezone_get_tzid (zone);
1362 if (!strcmp (zone_tzid, tzid))
1363 return zone;
1364 else
1365 return NULL;
1366}
1367
1368
1369/** Returns the special UTC timezone. */
1370icaltimezone*
1371 icaltimezone_get_utc_timezone (void)
1372{
1373 if (!builtin_timezones)
1374 icaltimezone_init_builtin_timezones ();
1375
1376 return &utc_timezone;
1377}
1378
1379
1380
1381/** This initializes the builtin timezone data, i.e. the
1382 builtin_timezones array and the special UTC timezone. It should be
1383 called before any code that uses the timezone functions. */
1384static void
1385 icaltimezone_init_builtin_timezones(void)
1386{
1387 /* Initialize the special UTC timezone. */
1388 utc_timezone.tzid = "UTC";
1389
1390 icaltimezone_parse_zone_tab ();
1391}
1392
1393
1394/** This parses the zones.tab file containing the names and locations
1395 of the builtin timezones. It creates the builtin_timezones array
1396 which is an icalarray of icaltimezone structs. It only fills in the
1397 location, latitude and longtude fields; the rest are left
1398 blank. The VTIMEZONE component is loaded later if it is needed. The
1399 timezones in the zones.tab file are sorted by their name, which is
1400 useful for binary searches. */
1401static void
1402 icaltimezone_parse_zone_tab (void)
1403{
1404 char *filename;
1405 FILE *fp;
1406 char buf[1024]; /* Used to store each line of zones.tab as it is read. */
1407 char location[1024]; /* Stores the city name when parsing buf. */
1408 unsigned int filename_len;
1409 int latitude_degrees, latitude_minutes, latitude_seconds;
1410 int longitude_degrees, longitude_minutes, longitude_seconds;
1411 icaltimezone zone;
1412
1413 icalerror_assert (builtin_timezones == NULL,
1414 "Parsing zones.tab file multiple times");
1415
1416 builtin_timezones = icalarray_new (sizeof (icaltimezone), 32);
1417
1418 filename_len = strlen (get_zone_directory()) + strlen (ZONES_TAB_FILENAME)
1419 + 2;
1420
1421 filename = (char*) malloc (filename_len);
1422 if (!filename) {
1423 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1424 return;
1425 }
1426
1427 snprintf (filename, filename_len, "%s/%s", get_zone_directory(),
1428 ZONES_TAB_FILENAME);
1429
1430 fp = fopen (filename, "r");
1431 free (filename);
1432 if (!fp) {
1433 icalerror_set_errno(ICAL_FILE_ERROR);
1434 return;
1435 }
1436
1437 while (fgets (buf, sizeof(buf), fp)) {
1438 if (*buf == '#') continue;
1439
1440 /* The format of each line is: "latitude longitude location". */
1441 if (sscanf (buf, "%4d%2d%2d %4d%2d%2d %s",
1442 &latitude_degrees, &latitude_minutes,
1443 &latitude_seconds,
1444 &longitude_degrees, &longitude_minutes,
1445 &longitude_seconds,
1446 location) != 7) {
1447 fprintf (stderr, "Invalid timezone description line: %s\n", buf);
1448 continue;
1449 }
1450
1451 icaltimezone_init (&zone);
1452 zone.location = strdup (location);
1453
1454 if (latitude_degrees >= 0)
1455 zone.latitude = (double) latitude_degrees
1456 + (double) latitude_minutes / 60
1457 + (double) latitude_seconds / 3600;
1458 else
1459 zone.latitude = (double) latitude_degrees
1460 - (double) latitude_minutes / 60
1461 - (double) latitude_seconds / 3600;
1462
1463 if (longitude_degrees >= 0)
1464 zone.longitude = (double) longitude_degrees
1465 + (double) longitude_minutes / 60
1466 + (double) longitude_seconds / 3600;
1467 else
1468 zone.longitude = (double) longitude_degrees
1469 - (double) longitude_minutes / 60
1470 - (double) longitude_seconds / 3600;
1471
1472 icalarray_append (builtin_timezones, &zone);
1473
1474#if 0
1475 printf ("Found zone: %s %f %f\n",
1476 location, zone.latitude, zone.longitude);
1477#endif
1478 }
1479
1480 fclose (fp);
1481}
1482
1483
1484/** Loads the builtin VTIMEZONE data for the given timezone. */
1485static void
1486 icaltimezone_load_builtin_timezone (icaltimezone*zone)
1487{
1488 char *filename;
1489 unsigned int filename_len;
1490 FILE *fp;
1491 icalparser *parser;
1492 icalcomponent *comp, *subcomp;
1493
1494 /* If the location isn't set, it isn't a builtin timezone. */
1495 if (!zone->location || !zone->location[0])
1496 return;
1497
1498 filename_len = strlen (get_zone_directory()) + strlen (zone->location) + 6;
1499
1500 filename = (char*) malloc (filename_len);
1501 if (!filename) {
1502 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
1503 return;
1504 }
1505
1506 snprintf (filename, filename_len, "%s/%s.ics", get_zone_directory(),
1507 zone->location);
1508
1509 fp = fopen (filename, "r");
1510 free (filename);
1511 if (!fp) {
1512 icalerror_set_errno(ICAL_FILE_ERROR);
1513 return;
1514 }
1515
1516
1517 /* ##### B.# Sun, 11 Nov 2001 04:04:29 +1100
1518 this is where the MALFORMEDDATA error is being set, after the call to 'icalparser_parse'
1519 fprintf(stderr, "** WARNING ** %s: %d %s\n", __FILE__, __LINE__, icalerror_strerror(icalerrno));
1520 */
1521
1522 parser = icalparser_new ();
1523 icalparser_set_gen_data (parser, fp);
1524 comp = icalparser_parse (parser, icaltimezone_load_get_line_fn);
1525 icalparser_free (parser);
1526 fclose (fp);
1527
1528
1529
1530 /* Find the VTIMEZONE component inside the VCALENDAR. There should be 1. */
1531 subcomp = icalcomponent_get_first_component (comp,
1532 ICAL_VTIMEZONE_COMPONENT);
1533 if (!subcomp) {
1534 icalerror_set_errno(ICAL_PARSE_ERROR);
1535 return;
1536 }
1537
1538 icaltimezone_get_vtimezone_properties (zone, subcomp);
1539
1540 icalcomponent_remove_component(comp,subcomp);
1541
1542 icalcomponent_free(comp);
1543
1544}
1545
1546
1547/** Callback used from icalparser_parse() */
1548static char *
1549 icaltimezone_load_get_line_fn (char *s,
1550 size_t size,
1551 void *data)
1552{
1553 return fgets (s, size, (FILE*) data);
1554}
1555
1556
1557
1558
1559/*
1560 * DEBUGGING
1561 */
1562
1563/**
1564 * This outputs a list of timezone changes for the given timezone to the
1565 * given file, up to the maximum year given. We compare this output with the
1566 * output from 'vzic --dump-changes' to make sure that we are consistent.
1567 * (vzic is the Olson timezone database to VTIMEZONE converter.)
1568 *
1569 * The output format is:
1570 *
1571 *Zone-Name [tab] Date [tab] Time [tab] UTC-Offset
1572 *
1573 * The Date and Time fields specify the time change in UTC.
1574 *
1575 * The UTC Offset is for local (wall-clock) time. It is the amount of time
1576 * to add to UTC to get local time.
1577 */
1578int
1579 icaltimezone_dump_changes (icaltimezone*zone,
1580 int max_year,
1581 FILE *fp)
1582{
1583 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1584 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
1585 icaltimezonechange *zone_change;
1586 int change_num;
1587 char buffer[8];
1588
1589 /* Make sure the changes array is expanded up to the given time. */
1590 icaltimezone_ensure_coverage (zone, max_year);
1591
1592#if 0
1593 printf ("Num changes: %i\n", zone->changes->num_elements);
1594#endif
1595
1596 change_num = 0;
1597 for (change_num = 0; change_num < zone->changes->num_elements; change_num++) {
1598 zone_change = icalarray_element_at (zone->changes, change_num);
1599
1600 if (zone_change->year > max_year)
1601 break;
1602
1603 fprintf (fp, "%s\t%2i %s %04i\t%2i:%02i:%02i",
1604 zone->location,
1605 zone_change->day, months[zone_change->month - 1],
1606 zone_change->year,
1607 zone_change->hour, zone_change->minute, zone_change->second);
1608
1609 /* Wall Clock Time offset from UTC. */
1610 format_utc_offset (zone_change->utc_offset, buffer);
1611 fprintf (fp, "\t%s", buffer);
1612
1613 fprintf (fp, "\n");
1614 }
1615 return 1;
1616}
1617
1618
1619/** This formats a UTC offset as "+HHMM" or "+HHMMSS".
1620 buffer should have space for 8 characters. */
1621static void
1622 format_utc_offset (int utc_offset,
1623 char *buffer)
1624{
1625 char *sign = "+";
1626 int hours, minutes, seconds;
1627
1628 if (utc_offset < 0) {
1629 utc_offset = -utc_offset;
1630 sign = "-";
1631 }
1632
1633 hours = utc_offset / 3600;
1634 minutes = (utc_offset % 3600) / 60;
1635 seconds = utc_offset % 60;
1636
1637 /* Sanity check. Standard timezone offsets shouldn't be much more than 12
1638 hours, and daylight saving shouldn't change it by more than a few hours.
1639 (The maximum offset is 15 hours 56 minutes at present.) */
1640 if (hours < 0 || hours >= 24 || minutes < 0 || minutes >= 60
1641 || seconds < 0 || seconds >= 60) {
1642 fprintf (stderr, "Warning: Strange timezone offset: H:%i M:%i S:%i\n",
1643 hours, minutes, seconds);
1644 }
1645
1646 if (seconds == 0)
1647 sprintf (buffer, "%s%02i%02i", sign, hours, minutes);
1648 else
1649 sprintf (buffer, "%s%02i%02i%02i", sign, hours, minutes, seconds);
1650}
1651
1652static char* get_zone_directory(void)
1653{
1654 return zone_files_directory == NULL ? ZONEINFO_DIRECTORY : zone_files_directory;
1655}
1656
1657void set_zone_directory(char *path)
1658{
1659 zone_files_directory = malloc(strlen(path)+1);
1660 if ( zone_files_directory != NULL )
1661 {
1662 strcpy(zone_files_directory,path);
1663 }
1664}
1665
1666void free_zone_directory(void)
1667{
1668 if ( zone_files_directory != NULL )
1669 {
1670 free(zone_files_directory);
1671 }
1672}
diff --git a/libical/src/libical/icaltimezone.h b/libical/src/libical/icaltimezone.h
new file mode 100644
index 0000000..08af2c1
--- a/dev/null
+++ b/libical/src/libical/icaltimezone.h
@@ -0,0 +1,167 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/*======================================================================
3 FILE: icaltimezone.h
4 CREATOR: Damon Chaplin 15 March 2001
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2001, Damon Chaplin
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23
24======================================================================*/
25/**
26 * @file icaltimezone.h
27 * @brief timezone handling routines
28 */
29
30#ifndef ICALTIMEZONE_H
31#define ICALTIMEZONE_H
32
33#include <stdio.h> /* For FILE* */
34#include "icaltime.h"
35#include "icalarray.h"
36#include "icalcomponent.h"
37
38
39#ifndef ICALTIMEZONE_DEFINED
40#define ICALTIMEZONE_DEFINED
41/** @brief An opaque struct representing a timezone.
42 * We declare this here to avoid a circular dependancy.
43 */
44 typedef struct _icaltimezone icaltimezone;
45#endif
46
47/**
48 * @par Creating/Destroying individual icaltimezones.
49 */
50
51/** Creates a new icaltimezone. */
52 icaltimezone *icaltimezone_new (void);
53
54/** Frees all memory used for the icaltimezone. Set free_struct to free the
55 icaltimezone struct as well. */
56 void icaltimezone_free (icaltimezone *zone,
57 int free_struct);
58
59
60/**
61 * @par Accessing timezones.
62 */
63
64/** Free any builtin timezone information **/
65void icaltimezone_free_builtin_timezones(void);
66
67/** Returns the array of builtin icaltimezones. */
68 icalarray* icaltimezone_get_builtin_timezones(void);
69
70/** Returns a single builtin timezone, given its Olson city name. */
71 icaltimezone* icaltimezone_get_builtin_timezone(const char *location);
72
73/** Returns a single builtin timezone, given its TZID. */
74icaltimezone* icaltimezone_get_builtin_timezone_from_tzid (const char *tzid);
75
76/** Returns the UTC timezone. */
77 icaltimezone* icaltimezone_get_utc_timezone(void);
78
79/** Returns the TZID of a timezone. */
80 char* icaltimezone_get_tzid (icaltimezone*zone);
81
82/** Returns the city name of a timezone. */
83 char* icaltimezone_get_location (icaltimezone*zone);
84
85/** Returns the TZNAME properties used in the latest STANDARD and DAYLIGHT
86 components. If they are the same it will return just one, e.g. "LMT".
87 If they are different it will format them like "EST/EDT". Note that this
88 may also return NULL. */
89 char* icaltimezone_get_tznames (icaltimezone*zone);
90
91/** Returns the latitude of a builtin timezone. */
92 double icaltimezone_get_latitude (icaltimezone*zone);
93
94/** Returns the longitude of a builtin timezone. */
95 double icaltimezone_get_longitude (icaltimezone*zone);
96
97/** Returns the VTIMEZONE component of a timezone. */
98 icalcomponent* icaltimezone_get_component (icaltimezone*zone);
99
100/** Sets the VTIMEZONE component of an icaltimezone, initializing the tzid,
101 location & tzname fields. It returns 1 on success or 0 on failure, i.e.
102 no TZID was found. */
103 int icaltimezone_set_component (icaltimezone*zone,
104 icalcomponent*comp);
105
106/**
107 * @par Converting times between timezones.
108 */
109
110 void icaltimezone_convert_time (struct icaltimetype *tt,
111 icaltimezone*from_zone,
112 icaltimezone*to_zone);
113
114
115/**
116 * @par Getting offsets from UTC.
117 */
118
119/** Calculates the UTC offset of a given local time in the given
120 timezone. It is the number of seconds to add to UTC to get local
121 time. The is_daylight flag is set to 1 if the time is in
122 daylight-savings time. */
123 int icaltimezone_get_utc_offset (icaltimezone*zone,
124 struct icaltimetype *tt,
125 int *is_daylight);
126
127/** Calculates the UTC offset of a given UTC time in the given
128 timezone. It is the number of seconds to add to UTC to get local
129 time. The is_daylight flag is set to 1 if the time is in
130 daylight-savings time. */
131 int icaltimezone_get_utc_offset_of_utc_time (icaltimezone*zone,
132 struct icaltimetype *tt,
133 int *is_daylight);
134
135
136
137/*
138 * Handling arrays of timezones. Mainly for internal use.
139 */
140 icalarray* icaltimezone_array_new (void);
141
142 void icaltimezone_array_append_from_vtimezone (icalarray *timezones,
143 icalcomponent *child);
144 void icaltimezone_array_free (icalarray*timezones);
145
146
147/*
148 * @par Handling the default location the timezone files
149 */
150
151/** Set the directory to look for the zonefiles */
152void set_zone_directory(char *path);
153
154/** Free memory dedicated to the zonefile directory */
155void free_zone_directory(void);
156
157/*
158 * @par Debugging Output.
159 */
160
161/** Dumps information about changes in the timezone up to and including
162 max_year. */
163 int icaltimezone_dump_changes (icaltimezone*zone,
164 int max_year,
165 FILE *fp);
166
167#endif /* ICALTIMEZONE_H */
diff --git a/libical/src/libical/icaltypes.c b/libical/src/libical/icaltypes.c
index 8c67deb..19719f8 100644
--- a/libical/src/libical/icaltypes.c
+++ b/libical/src/libical/icaltypes.c
@@ -37,3 +37,6 @@
37 37
38int snprintf(char *str, size_t n, char const *fmt, ...); 38#ifdef WIN32
39#define snprintf _snprintf
40#define strcasecmp stricmp
41#endif
39 42
@@ -41,129 +44,32 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
41 44
42void*
43icalattachtype_get_data (struct icalattachtype* type);
44 45
45struct icalattachtype* 46int icaltriggertype_is_null_trigger(struct icaltriggertype tr)
46icalattachtype_new()
47{ 47{
48 struct icalattachtype* v; 48 if(icaltime_is_null_time(tr.time) &&
49 49 icaldurationtype_is_null_duration(tr.duration)){
50 if ( ( v = (struct icalattachtype*) 50 return 1;
51 malloc(sizeof(struct icalattachtype))) == 0) {
52 errno = ENOMEM;
53 return 0;
54 } 51 }
55 52
56 v->refcount = 1; 53 return 0;
57
58 v->binary = 0;
59 v->owns_binary = 0;
60 v->base64 = 0;
61 //fprintf(stderr,"setting base 64 to 0 \n");
62
63 v->owns_base64 = 0;
64
65 v->url = 0;
66
67 return v;
68} 54}
69
70
71void
72icalattachtype_free(struct icalattachtype* v)
73{
74 icalerror_check_arg( (v!=0),"v");
75 55
76 v->refcount--; 56int icaltriggertype_is_bad_trigger(struct icaltriggertype tr)
77
78 if (v->refcount <= 0){
79
80 if (v->base64 != 0 && v->owns_base64 != 0){
81 int val = v->base64 ;
82 if ( val < 255 ) {
83 fprintf(stderr,"Possible error in attachment processing (%d)\nPocssible solution: Remove attachment from file.\n",val );
84 }
85 free(v->base64);
86 }
87
88 if (v->binary != 0 && v->owns_binary != 0){
89 free(v->binary);
90 }
91
92 if (v->url != 0){
93 free(v->url);
94 }
95
96 free(v);
97 }
98}
99
100void icalattachtype_add_reference(struct icalattachtype* v)
101{
102 icalerror_check_arg( (v!=0),"v");
103 v->refcount++;
104}
105
106void icalattachtype_set_url(struct icalattachtype* v, char* url)
107{ 57{
108 icalerror_check_arg( (v!=0),"v"); 58 if(icaldurationtype_is_bad_duration(tr.duration)){
109 59 return 1;
110 if (v->url != 0){
111 free (v->url);
112 } 60 }
113 61
114 v->url = icalmemory_strdup(url); 62 return 0;
115
116 /* HACK This routine should do something if icalmemory_strdup returns NULL */
117
118}
119
120char* icalattachtype_get_url(struct icalattachtype* v)
121{
122 icalerror_check_arg( (v!=0),"v");
123 return v->url;
124}
125
126void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
127 int owns)
128{
129 //fprintf(stderr,"1setbase64 %d \n", base64 );
130 icalerror_check_arg( (v!=0),"v");
131 //fprintf(stderr,"setbase64 %d \n", base64 );
132 v->base64 = base64;
133 v->owns_base64 = !(owns != 0 );
134
135}
136
137char* icalattachtype_get_base64(struct icalattachtype* v)
138{
139 icalerror_check_arg( (v!=0),"v");
140 return v->base64;
141} 63}
142 64
143void icalattachtype_set_binary(struct icalattachtype* v, char* binary, 65struct icaltriggertype icaltriggertype_from_int(const int reltime)
144 int owns)
145{ 66{
146 icalerror_check_arg( (v!=0),"v"); 67 struct icaltriggertype tr;
147 68
148 v->binary = binary; 69 tr.time= icaltime_null_time();
149 v->owns_binary = !(owns != 0 ); 70 tr.duration = icaldurationtype_from_int(reltime);
150 71
72 return tr;
151} 73}
152 74
153void* icalattachtype_get_binary(struct icalattachtype* v)
154{
155 icalerror_check_arg( (v!=0),"v");
156 return v->binary;
157}
158
159int icaltriggertype_is_null_trigger(struct icaltriggertype tr)
160{
161 if(icaltime_is_null_time(tr.time) &&
162 icaldurationtype_is_null_duration(tr.duration)){
163 return 1;
164 }
165
166 return 0;
167}
168
169struct icaltriggertype icaltriggertype_from_string(const char* str) 75struct icaltriggertype icaltriggertype_from_string(const char* str)
@@ -183,3 +89,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
183 89
184 /* Surpress errors so a failure in icaltime_from_string() does not cause an abort */ 90 /* Suppress errors so a failure in icaltime_from_string() does not cause an abort */
185 es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); 91 es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR);
@@ -195,3 +101,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
195 101
196 if(icaldurationtype_as_int(tr.duration) == 0) goto error; 102 if (icaldurationtype_is_bad_duration(tr.duration)) goto error;
197 } 103 }
@@ -205,3 +111,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
205 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 111 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
206 return null_tr; 112 return tr;
207 113
@@ -214,3 +120,3 @@ struct icalreqstattype icalreqstattype_from_string(const char* str)
214 struct icalreqstattype stat; 120 struct icalreqstattype stat;
215 int major, minor; 121 short major=0, minor=0;
216 122
@@ -224,3 +130,3 @@ struct icalreqstattype icalreqstattype_from_string(const char* str)
224 130
225 sscanf(str, "%d.%d",&major, &minor); 131 sscanf(str, "%hd.%hd",&major, &minor);
226 132
diff --git a/libical/src/libical/icaltypes.h b/libical/src/libical/icaltypes.h
index d61b9f3..1e5c5e0 100644
--- a/libical/src/libical/icaltypes.h
+++ b/libical/src/libical/icaltypes.h
@@ -33,35 +33,2 @@
33 33
34/* This type type should probably be an opaque type... */
35struct icalattachtype
36{
37 void* binary;
38 int owns_binary;
39
40 char* base64;
41 int owns_base64;
42
43 char* url;
44
45 int refcount;
46
47};
48
49/* converts base64 to binary, fetches url and stores as binary, or
50 just returns data */
51
52struct icalattachtype* icalattachtype_new(void);
53void icalattachtype_add_reference(struct icalattachtype* v);
54void icalattachtype_free(struct icalattachtype* v);
55
56void icalattachtype_set_url(struct icalattachtype* v, char* url);
57char* icalattachtype_get_url(struct icalattachtype* v);
58
59void icalattachtype_set_base64(struct icalattachtype* v, char* base64,
60 int owns);
61char* icalattachtype_get_base64(struct icalattachtype* v);
62
63void icalattachtype_set_binary(struct icalattachtype* v, char* binary,
64 int owns);
65void* icalattachtype_get_binary(struct icalattachtype* v);
66
67struct icalgeotype 34struct icalgeotype
@@ -86,2 +53,3 @@ struct icaltriggertype
86 53
54struct icaltriggertype icaltriggertype_from_int(const int reltime);
87struct icaltriggertype icaltriggertype_from_string(const char* str); 55struct icaltriggertype icaltriggertype_from_string(const char* str);
@@ -89,2 +57,3 @@ struct icaltriggertype icaltriggertype_from_string(const char* str);
89int icaltriggertype_is_null_trigger(struct icaltriggertype tr); 57int icaltriggertype_is_null_trigger(struct icaltriggertype tr);
58int icaltriggertype_is_bad_trigger(struct icaltriggertype tr);
90 59
diff --git a/libical/src/libical/icalvalue.c b/libical/src/libical/icalvalue.c
index eb5476e..4c67136 100644
--- a/libical/src/libical/icalvalue.c
+++ b/libical/src/libical/icalvalue.c
@@ -1,2 +1,3 @@
1/* -*- Mode: C -*- */ 1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* vi:set ts=4 sts=4 sw=4 expandtab : */
2/*====================================================================== 3/*======================================================================
@@ -48,3 +49,6 @@
48 49
49int snprintf(char *str, size_t n, char const *fmt, ...); 50#ifdef WIN32
51#define snprintf _snprintf
52#define strcasecmp stricmp
53#endif
50 54
@@ -56,6 +60,5 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
56 60
57void print_datetime_to_string(char* str, struct icaltimetype *data); 61void print_datetime_to_string(char* str, const struct icaltimetype *data);
58void print_date_to_string(char* str, struct icaltimetype *data); 62void print_date_to_string(char* str, const struct icaltimetype *data);
59void print_time_to_string(char* str, struct icaltimetype *data); 63void print_time_to_string(char* str, const struct icaltimetype *data);
60void print_recur_to_string(char* str, struct icaltimetype *data);
61 64
@@ -66,2 +69,5 @@ struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind){
66 69
70 if (!icalvalue_kind_is_valid(kind))
71 return NULL;
72
67 if ( ( v = (struct icalvalue_impl*) 73 if ( ( v = (struct icalvalue_impl*)
@@ -92,6 +98,4 @@ icalvalue_new (icalvalue_kind kind)
92 98
93icalvalue* icalvalue_new_clone(icalvalue* value){ 99icalvalue* icalvalue_new_clone(const icalvalue* old) {
94
95 struct icalvalue_impl* new; 100 struct icalvalue_impl* new;
96 struct icalvalue_impl* old = (struct icalvalue_impl*)value;
97 101
@@ -103,3 +107,2 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
103 107
104
105 strcpy(new->id, old->id); 108 strcpy(new->id, old->id);
@@ -109,5 +112,2 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
109 switch (new->kind){ 112 switch (new->kind){
110
111 /* The contents of the attach value may or may not be owned by the
112 * library. */
113 case ICAL_ATTACH_VALUE: 113 case ICAL_ATTACH_VALUE:
@@ -115,5 +115,13 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
115 { 115 {
116 /* HACK ugh. I don't feel like impleenting this */ 116 /* Hmm. We just ref the attach value, which may not be the right
117 } 117 * thing to do. We cannot quite copy the data, anyways, since we
118 * don't know how long it is.
119 */
120 new->data.v_attach = old->data.v_attach;
121 if (new->data.v_attach)
122 icalattach_ref (new->data.v_attach);
118 123
124 break;
125 }
126 case ICAL_QUERY_VALUE:
119 case ICAL_STRING_VALUE: 127 case ICAL_STRING_VALUE:
@@ -148,2 +156,15 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
148 156
157 case ICAL_X_VALUE:
158 {
159 if (old->x_value != 0) {
160 new->x_value=icalmemory_strdup(old->x_value);
161
162 if (new->x_value == 0) {
163 return 0;
164 }
165 }
166
167 break;
168 }
169
149 default: 170 default:
@@ -160,3 +181,3 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
160 181
161char* icalmemory_strdup_and_dequote(const char* str) 182static char* icalmemory_strdup_and_dequote(const char* str)
162{ 183{
@@ -185,2 +206,3 @@ char* icalmemory_strdup_and_dequote(const char* str)
185 case 'n': 206 case 'n':
207 case 'N':
186 { 208 {
@@ -189,10 +211,30 @@ char* icalmemory_strdup_and_dequote(const char* str)
189 } 211 }
190 case 'N': 212 case 't':
213 case 'T':
191 { 214 {
192 *pout = '\n'; 215 *pout = '\t';
216 break;
217 }
218 case 'r':
219 case 'R':
220 {
221 *pout = '\r';
222 break;
223 }
224 case 'b':
225 case 'B':
226 {
227 *pout = '\b';
228 break;
229 }
230 case 'f':
231 case 'F':
232 {
233 *pout = '\f';
193 break; 234 break;
194 } 235 }
195 case '\\':
196 case ',':
197 case ';': 236 case ';':
237 case ',':
238 case '"':
239 case '\\':
198 { 240 {
@@ -219,5 +261,12 @@ char* icalmemory_strdup_and_dequote(const char* str)
219 261
262/*
263 * FIXME
264 *
265 * This is a bad API, as it forces callers to specify their own X type.
266 * This function should take care of this by itself.
267 */
268static
220icalvalue* icalvalue_new_enum(icalvalue_kind kind, int x_type, const char* str) 269icalvalue* icalvalue_new_enum(icalvalue_kind kind, int x_type, const char* str)
221{ 270{
222 int e = icalproperty_string_to_enum(str); 271 int e = icalproperty_kind_and_string_to_enum(kind, str);
223 struct icalvalue_impl *value; 272 struct icalvalue_impl *value;
@@ -244,3 +293,2 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
244 struct icalvalue_impl *value = 0; 293 struct icalvalue_impl *value = 0;
245 struct icalattachtype *attach = 0;
246 294
@@ -255,8 +303,15 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
255 case ICAL_ATTACH_VALUE: 303 case ICAL_ATTACH_VALUE:
256 attach = icalattachtype_new(); 304 {
257 value = icalvalue_new_attach( attach ); 305 icalattach *attach;
258 icalattachtype_free( attach ); 306
259 icalattachtype_set_url( value->data.v_attach, str ); 307 attach = icalattach_new_from_url (str);
260 break; 308 if (!attach)
261 case ICAL_BINARY_VALUE: 309 break;
310
311 value = icalvalue_new_attach (attach);
312 icalattach_unref (attach);
313 break;
314 }
315
316 case ICAL_BINARY_VALUE:
262 case ICAL_BOOLEAN_VALUE: 317 case ICAL_BOOLEAN_VALUE:
@@ -269,3 +324,3 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
269 sprintf(temp,"%s Values are not implemented", 324 sprintf(temp,"%s Values are not implemented",
270 icalparameter_kind_to_string(kind)); 325 icalvalue_kind_to_string(kind));
271 *error = icalproperty_vanew_xlicerror( 326 *error = icalproperty_vanew_xlicerror(
@@ -281,15 +336,20 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
281 case ICAL_TRANSP_VALUE: 336 case ICAL_TRANSP_VALUE:
282 value = icalvalue_new_enum(kind, ICAL_TRANSP_X,str); 337 value = icalvalue_new_enum(kind, (int)ICAL_TRANSP_X,str);
283 break; 338 break;
284 case ICAL_METHOD_VALUE: 339 case ICAL_METHOD_VALUE:
285 value = icalvalue_new_enum(kind, ICAL_METHOD_X,str); 340 value = icalvalue_new_enum(kind, (int)ICAL_METHOD_X,str);
286 break; 341 break;
287 case ICAL_STATUS_VALUE: 342 case ICAL_STATUS_VALUE:
288 value = icalvalue_new_enum(kind, ICAL_STATUS_X,str); 343 value = icalvalue_new_enum(kind, (int)ICAL_STATUS_X,str);
289 break; 344 break;
290 case ICAL_ACTION_VALUE: 345 case ICAL_ACTION_VALUE:
291 value = icalvalue_new_enum(kind, ICAL_ACTION_X,str); 346 value = icalvalue_new_enum(kind, (int)ICAL_ACTION_X,str);
292 break; 347 break;
348
349 case ICAL_QUERY_VALUE:
350 value = icalvalue_new_query(str);
351 break;
352
293 case ICAL_CLASS_VALUE: 353 case ICAL_CLASS_VALUE:
294 value = icalvalue_new_enum(kind, ICAL_CLASS_X,str); 354 value = icalvalue_new_enum(kind, (int)ICAL_CLASS_X,str);
295 break; 355 break;
@@ -298,16 +358,24 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
298 case ICAL_INTEGER_VALUE: 358 case ICAL_INTEGER_VALUE:
299 {
300 value = icalvalue_new_integer(atoi(str)); 359 value = icalvalue_new_integer(atoi(str));
301 break; 360 break;
302 }
303 361
304 case ICAL_FLOAT_VALUE: 362 case ICAL_FLOAT_VALUE:
305 { 363 value = icalvalue_new_float((float)atof(str));
306 value = icalvalue_new_float((float )atof(str));
307 break; 364 break;
308 } 365
309
310 case ICAL_UTCOFFSET_VALUE: 366 case ICAL_UTCOFFSET_VALUE:
311 { 367 {
312 value = icalparser_parse_value(kind,str,(icalcomponent*)0); 368 int t,utcoffset, hours, minutes, seconds;
369 /* treat the UTCOFSET string a a decimal number, disassemble its digits
370 and reconstruct it as sections */
371 t = strtol(str,0,10);
372 /* add phantom seconds field */
373 if(abs(t)<9999){t *= 100; }
374 hours = (t/10000);
375 minutes = (t-hours*10000)/100;
376 seconds = (t-hours*10000-minutes*100);
377 utcoffset = hours*3600+minutes*60+seconds;
378
379 value = icalvalue_new_utcoffset(utcoffset);
380
313 break; 381 break;
@@ -323,24 +391,15 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
323 391
324
325 case ICAL_STRING_VALUE: 392 case ICAL_STRING_VALUE:
326 {
327 value = icalvalue_new_string(str); 393 value = icalvalue_new_string(str);
328 break; 394 break;
329 }
330 395
331 case ICAL_CALADDRESS_VALUE: 396 case ICAL_CALADDRESS_VALUE:
332 {
333 value = icalvalue_new_caladdress(str); 397 value = icalvalue_new_caladdress(str);
334 break; 398 break;
335 }
336 399
337 case ICAL_URI_VALUE: 400 case ICAL_URI_VALUE:
338 {
339 value = icalvalue_new_uri(str); 401 value = icalvalue_new_uri(str);
340 break; 402 break;
341 }
342
343 403
344 case ICAL_GEO_VALUE: 404 case ICAL_GEO_VALUE:
345 {
346 value = 0; 405 value = 0;
@@ -352,12 +411,11 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
352 *error = icalproperty_vanew_xlicerror( 411 *error = icalproperty_vanew_xlicerror(
353 temp, 412 temp,
354 icalparameter_new_xlicerrortype( 413 icalparameter_new_xlicerrortype(
355 ICAL_XLICERRORTYPE_VALUEPARSEERROR), 414 ICAL_XLICERRORTYPE_VALUEPARSEERROR),
356 0); 415 0);
357 } 416 }
358 417
359 /*icalerror_warn("Parsing GEO properties is unimplmeneted");*/ 418 /*icalerror_warn("Parsing GEO properties is unimplmeneted");*/
360 419
361 break; 420 break;
362 }
363 421
@@ -393,10 +451,13 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
393 tt = icaltime_from_string(str); 451 tt = icaltime_from_string(str);
394 p = icalperiodtype_from_string(str); 452
395
396 if(!icaltime_is_null_time(tt)){ 453 if(!icaltime_is_null_time(tt)){
397 value = icalvalue_new_datetime(tt); 454 value = icalvalue_new_datetime(tt);
398 } else if (!icalperiodtype_is_null_period(p)){ 455 break;
456 }
457
458 p = icalperiodtype_from_string(str);
459 if (!icalperiodtype_is_null_period(p)){
399 value = icalvalue_new_period(p); 460 value = icalvalue_new_period(p);
400 } 461 }
401 462
402 break; 463 break;
@@ -408,5 +469,3 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
408 469
409 if(icaldurationtype_is_null_duration(dur)){ 470 if (!icaldurationtype_is_bad_duration(dur)) { /* failed to parse */
410 value = 0;
411 } else {
412 value = icalvalue_new_duration(dur); 471 value = icalvalue_new_duration(dur);
@@ -431,3 +490,3 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
431 struct icaltriggertype tr = icaltriggertype_from_string(str); 490 struct icaltriggertype tr = icaltriggertype_from_string(str);
432 if (!icaltriggertype_is_null_trigger(tr)){ 491 if (!icaltriggertype_is_bad_trigger(tr)) {
433 value = icalvalue_new_trigger(tr); 492 value = icalvalue_new_trigger(tr);
@@ -446,5 +505,13 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
446 } 505 }
506
507 case ICAL_X_VALUE:
508 {
509 char* dequoted_str = icalmemory_strdup_and_dequote(str);
510 value = icalvalue_new_x(dequoted_str);
511 free(dequoted_str);
512 }
513 break;
514
447 default: 515 default:
448 { 516 {
449
450 if (error != 0 ){ 517 if (error != 0 ){
@@ -486,3 +553,3 @@ icalvalue* icalvalue_new_from_string(icalvalue_kind kind,const char* str)
486{ 553{
487 return icalvalue_new_from_string_with_error(kind,str,(icalproperty*)0); 554 return icalvalue_new_from_string_with_error(kind,str,(icalproperty**)0);
488} 555}
@@ -492,7 +559,5 @@ icalvalue* icalvalue_new_from_string(icalvalue_kind kind,const char* str)
492void 559void
493icalvalue_free (icalvalue* value) 560icalvalue_free (icalvalue* v)
494{ 561{
495 struct icalvalue_impl* v = (struct icalvalue_impl*)value; 562 icalerror_check_arg_rv((v != 0),"value");
496
497 icalerror_check_arg_rv((value != 0),"value");
498 563
@@ -512,7 +577,10 @@ icalvalue_free (icalvalue* value)
512 switch (v->kind){ 577 switch (v->kind){
513 case ICAL_ATTACH_VALUE: 578 case ICAL_BINARY_VALUE:
514 icalattachtype_free( v->data.v_attach ); 579 case ICAL_ATTACH_VALUE: {
580 if (v->data.v_attach) {
581 icalattach_unref (v->data.v_attach);
582 v->data.v_attach = NULL;
583 }
584
515 break; 585 break;
516 case ICAL_BINARY_VALUE: {
517 /* HACK ugh. This will be tough to implement */
518 } 586 }
@@ -521,2 +589,3 @@ icalvalue_free (icalvalue* value)
521 case ICAL_URI_VALUE: 589 case ICAL_URI_VALUE:
590 case ICAL_QUERY_VALUE:
522 { 591 {
@@ -552,6 +621,4 @@ icalvalue_free (icalvalue* value)
552int 621int
553icalvalue_is_valid (icalvalue* value) 622icalvalue_is_valid (const icalvalue* value)
554{ 623{
555 /*struct icalvalue_impl* v = (struct icalvalue_impl*)value;*/
556
557 if(value == 0){ 624 if(value == 0){
@@ -563,3 +630,3 @@ icalvalue_is_valid (icalvalue* value)
563 630
564char* icalvalue_binary_as_ical_string(icalvalue* value) { 631static char* icalvalue_binary_as_ical_string(const icalvalue* value) {
565 632
@@ -577,6 +644,6 @@ char* icalvalue_binary_as_ical_string(icalvalue* value) {
577 644
578#ifndef _WIN32 645
579#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign*/ 646#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign*/
580char* icalvalue_int_as_ical_string(icalvalue* value) {
581 647
648static char* icalvalue_int_as_ical_string(const icalvalue* value) {
582 int data; 649 int data;
@@ -592,22 +659,4 @@ char* icalvalue_int_as_ical_string(icalvalue* value) {
592} 659}
593#else
594// snprintf not working on wintendo
595 660
596#define MAX_INT_DIGITS 32 /* Enough for 2^32 + sign*/ 661static char* icalvalue_utcoffset_as_ical_string(const icalvalue* value)
597char* icalvalue_int_as_ical_string(icalvalue* value) {
598
599 int data;
600 char* str = (char*)icalmemory_tmp_buffer(MAX_INT_DIGITS);
601
602 icalerror_check_arg_rz( (value!=0),"value");
603
604 data = icalvalue_get_integer(value);
605
606 sprintf(str,"%d",data);
607
608 return str;
609}
610
611#endif
612char* icalvalue_utcoffset_as_ical_string(icalvalue* value)
613{ 662{
@@ -631,3 +680,6 @@ char* icalvalue_utcoffset_as_ical_string(icalvalue* value)
631 680
632 sprintf(str,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s)); 681 if (s > 0)
682 sprintf(str,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s));
683 else
684 sprintf(str,"%c%02d%02d",sign,abs(h),abs(m));
633 685
@@ -636,3 +688,3 @@ char* icalvalue_utcoffset_as_ical_string(icalvalue* value)
636 688
637char* icalvalue_string_as_ical_string(icalvalue* value) { 689static char* icalvalue_string_as_ical_string(const icalvalue* value) {
638 690
@@ -641,4 +693,3 @@ char* icalvalue_string_as_ical_string(icalvalue* value) {
641 icalerror_check_arg_rz( (value!=0),"value"); 693 icalerror_check_arg_rz( (value!=0),"value");
642 694 data = value->data.v_string;
643 data = ((struct icalvalue_impl*)value)->data.v_string;
644 695
@@ -652,6 +703,5 @@ char* icalvalue_string_as_ical_string(icalvalue* value) {
652 703
653char* icalvalue_recur_as_ical_string(icalvalue* value) 704static char* icalvalue_recur_as_ical_string(const icalvalue* value)
654{ 705{
655 struct icalvalue_impl *impl = (struct icalvalue_impl*)value; 706 struct icalrecurrencetype *recur = value->data.v_recur;
656 struct icalrecurrencetype *recur = impl->data.v_recur;
657 707
@@ -660,4 +710,9 @@ char* icalvalue_recur_as_ical_string(icalvalue* value)
660 710
661char* icalvalue_text_as_ical_string(icalvalue* value) { 711 /* @todo This is not RFC2445 compliant.
712 * The RFC only allows:
713 * TSAFE-CHAR = %x20-21 / %x23-2B / %x2D-39 / %x3C-5B / %x5D-7E / NON-US-ASCII
714 * As such, \t\r\b\f are not allowed, not even escaped
715 */
662 716
717static char* icalvalue_text_as_ical_string(const icalvalue* value) {
663 char *str; 718 char *str;
@@ -667,7 +722,4 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
667 size_t buf_sz; 722 size_t buf_sz;
668 int line_length;
669
670 line_length = 0;
671 723
672 buf_sz = strlen(((struct icalvalue_impl*)value)->data.v_string)+1; 724 buf_sz = strlen(value->data.v_string)+1;
673 725
@@ -679,3 +731,3 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
679 731
680 for(p=((struct icalvalue_impl*)value)->data.v_string; *p!=0; p++){ 732 for(p=value->data.v_string; *p!=0; p++){
681 733
@@ -684,3 +736,2 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
684 icalmemory_append_string(&str,&str_p,&buf_sz,"\\n"); 736 icalmemory_append_string(&str,&str_p,&buf_sz,"\\n");
685 line_length+=3;
686 break; 737 break;
@@ -690,3 +741,2 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
690 icalmemory_append_string(&str,&str_p,&buf_sz,"\\t"); 741 icalmemory_append_string(&str,&str_p,&buf_sz,"\\t");
691 line_length+=3;
692 break; 742 break;
@@ -695,3 +745,2 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
695 icalmemory_append_string(&str,&str_p,&buf_sz,"\\r"); 745 icalmemory_append_string(&str,&str_p,&buf_sz,"\\r");
696 line_length+=3;
697 break; 746 break;
@@ -700,3 +749,2 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
700 icalmemory_append_string(&str,&str_p,&buf_sz,"\\b"); 749 icalmemory_append_string(&str,&str_p,&buf_sz,"\\b");
701 line_length+=3;
702 break; 750 break;
@@ -705,3 +753,2 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
705 icalmemory_append_string(&str,&str_p,&buf_sz,"\\f"); 753 icalmemory_append_string(&str,&str_p,&buf_sz,"\\f");
706 line_length+=3;
707 break; 754 break;
@@ -710,6 +757,7 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
710 case ';': 757 case ';':
711 case ',':{ 758 case ',':
759 case '"':
760 case '\\':{
712 icalmemory_append_char(&str,&str_p,&buf_sz,'\\'); 761 icalmemory_append_char(&str,&str_p,&buf_sz,'\\');
713 icalmemory_append_char(&str,&str_p,&buf_sz,*p); 762 icalmemory_append_char(&str,&str_p,&buf_sz,*p);
714 line_length+=3;
715 break; 763 break;
@@ -719,17 +767,4 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
719 icalmemory_append_char(&str,&str_p,&buf_sz,*p); 767 icalmemory_append_char(&str,&str_p,&buf_sz,*p);
720 line_length++;
721 } 768 }
722 } 769 }
723
724 if (line_length > 65 && *p == ' '){
725 icalmemory_append_string(&str,&str_p,&buf_sz,"\n ");
726 line_length=0;
727 }
728
729
730 if (line_length > 75){
731 icalmemory_append_string(&str,&str_p,&buf_sz,"\n ");
732 line_length=0;
733 }
734
735 } 770 }
@@ -751,5 +786,6 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
751 786
752char* icalvalue_attach_as_ical_string(icalvalue* value) { 787static char*
753 788icalvalue_attach_as_ical_string(const icalvalue* value)
754 struct icalattachtype *a; 789{
790 icalattach *a;
755 char * str; 791 char * str;
@@ -760,17 +796,11 @@ char* icalvalue_attach_as_ical_string(icalvalue* value) {
760 796
761 if (a->binary != 0) { 797 if (icalattach_get_is_url (a)) {
762 return icalvalue_binary_as_ical_string(value); 798 const char *url;
763 } else if (a->base64 != 0) { 799
764 str = (char*)icalmemory_tmp_buffer(strlen(a->base64)+1); 800 url = icalattach_get_url (a);
765 strcpy(str,a->base64); 801 str = icalmemory_tmp_buffer (strlen (url) + 1);
802 strcpy (str, url);
766 return str; 803 return str;
767 } else if (a->url != 0){ 804 } else
768 icalvalue *v = icalvalue_new_text( a->url ); 805 return icalvalue_binary_as_ical_string (value);
769 char *icalstring = icalvalue_string_as_ical_string(v);
770 icalvalue_free( v );
771 return icalstring;
772 } else {
773 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
774 return 0;
775 }
776} 806}
@@ -778,3 +808,3 @@ char* icalvalue_attach_as_ical_string(icalvalue* value) {
778 808
779char* icalvalue_duration_as_ical_string(icalvalue* value) { 809static char* icalvalue_duration_as_ical_string(const icalvalue* value) {
780 810
@@ -788,3 +818,3 @@ char* icalvalue_duration_as_ical_string(icalvalue* value) {
788 818
789void print_time_to_string(char* str, struct icaltimetype *data) 819void print_time_to_string(char* str, const struct icaltimetype *data)
790{ 820{
@@ -792,3 +822,3 @@ void print_time_to_string(char* str, struct icaltimetype *data)
792 822
793 if (data->is_utc == 1){ 823 if (icaltime_is_utc(*data)){
794 sprintf(temp,"%02d%02d%02dZ",data->hour,data->minute,data->second); 824 sprintf(temp,"%02d%02d%02dZ",data->hour,data->minute,data->second);
@@ -802,3 +832,3 @@ void print_time_to_string(char* str, struct icaltimetype *data)
802 832
803void print_date_to_string(char* str, struct icaltimetype *data) 833void print_date_to_string(char* str, const struct icaltimetype *data)
804{ 834{
@@ -811,3 +841,3 @@ void print_date_to_string(char* str, struct icaltimetype *data)
811 841
812char* icalvalue_date_as_ical_string(icalvalue* value) { 842static char* icalvalue_date_as_ical_string(const icalvalue* value) {
813 843
@@ -826,3 +856,3 @@ char* icalvalue_date_as_ical_string(icalvalue* value) {
826 856
827void print_datetime_to_string(char* str, struct icaltimetype *data) 857void print_datetime_to_string(char* str, const struct icaltimetype *data)
828{ 858{
@@ -831,6 +861,5 @@ void print_datetime_to_string(char* str, struct icaltimetype *data)
831 print_time_to_string(str,data); 861 print_time_to_string(str,data);
832
833} 862}
834 863
835const char* icalvalue_datetime_as_ical_string(icalvalue* value) { 864static const char* icalvalue_datetime_as_ical_string(const icalvalue* value) {
836 865
@@ -861,3 +890,3 @@ const char* icalvalue_datetime_as_ical_string(icalvalue* value) {
861 890
862char* icalvalue_float_as_ical_string(icalvalue* value) { 891static char* icalvalue_float_as_ical_string(const icalvalue* value) {
863 892
@@ -875,3 +904,3 @@ char* icalvalue_float_as_ical_string(icalvalue* value) {
875 904
876char* icalvalue_geo_as_ical_string(icalvalue* value) { 905static char* icalvalue_geo_as_ical_string(const icalvalue* value) {
877 906
@@ -890,3 +919,3 @@ char* icalvalue_geo_as_ical_string(icalvalue* value) {
890 919
891const char* icalvalue_datetimeperiod_as_ical_string(icalvalue* value) { 920static const char* icalvalue_datetimeperiod_as_ical_string(const icalvalue* value) {
892 struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value); 921 struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value);
@@ -902,3 +931,3 @@ const char* icalvalue_datetimeperiod_as_ical_string(icalvalue* value) {
902 931
903const char* icalvalue_period_as_ical_string(icalvalue* value) { 932static const char* icalvalue_period_as_ical_string(const icalvalue* value) {
904 struct icalperiodtype data; 933 struct icalperiodtype data;
@@ -911,3 +940,3 @@ const char* icalvalue_period_as_ical_string(icalvalue* value) {
911 940
912char* icalvalue_trigger_as_ical_string(icalvalue* value) { 941static const char* icalvalue_trigger_as_ical_string(const icalvalue* value) {
913 942
@@ -927,8 +956,4 @@ char* icalvalue_trigger_as_ical_string(icalvalue* value) {
927const char* 956const char*
928icalvalue_as_ical_string (icalvalue* value) 957icalvalue_as_ical_string(const icalvalue* value)
929{ 958{
930 struct icalvalue_impl* v = (struct icalvalue_impl*)value;
931
932 v=v;
933
934 if(value == 0){ 959 if(value == 0){
@@ -937,3 +962,3 @@ icalvalue_as_ical_string (icalvalue* value)
937 962
938 switch (v->kind){ 963 switch (value->kind){
939 964
@@ -955,2 +980,5 @@ icalvalue_as_ical_string (icalvalue* value)
955 980
981 case ICAL_QUERY_VALUE:
982 return icalvalue_string_as_ical_string(value);
983
956 case ICAL_STRING_VALUE: 984 case ICAL_STRING_VALUE:
@@ -985,3 +1013,3 @@ icalvalue_as_ical_string (icalvalue* value)
985 case ICAL_REQUESTSTATUS_VALUE: 1013 case ICAL_REQUESTSTATUS_VALUE:
986 return icalreqstattype_as_string(v->data.v_requeststatus); 1014 return icalreqstattype_as_string(value->data.v_requeststatus);
987 1015
@@ -992,10 +1020,13 @@ icalvalue_as_ical_string (icalvalue* value)
992 case ICAL_CLASS_VALUE: 1020 case ICAL_CLASS_VALUE:
993 if(v->x_value !=0){ 1021 if(value->x_value !=0){
994 return icalmemory_tmp_copy(v->x_value); 1022 return icalmemory_tmp_copy(value->x_value);
995 } 1023 }
996 1024
997 return icalproperty_enum_to_string(v->data.v_enum); 1025 return icalproperty_enum_to_string(value->data.v_enum);
998 1026
999 case ICAL_X_VALUE: 1027 case ICAL_X_VALUE:
1000 return icalmemory_tmp_copy(v->x_value); 1028 if (value->x_value != 0)
1029 return icalmemory_tmp_copy(value->x_value);
1030
1031 /* FALLTHRU */
1001 1032
@@ -1011,6 +1042,4 @@ icalvalue_as_ical_string (icalvalue* value)
1011icalvalue_kind 1042icalvalue_kind
1012icalvalue_isa (icalvalue* value) 1043icalvalue_isa (const icalvalue* value)
1013{ 1044{
1014 struct icalvalue_impl* v = (struct icalvalue_impl*)value;
1015
1016 if(value == 0){ 1045 if(value == 0){
@@ -1019,3 +1048,3 @@ icalvalue_isa (icalvalue* value)
1019 1048
1020 return v->kind; 1049 return value->kind;
1021} 1050}
@@ -1038,3 +1067,3 @@ icalvalue_isa_value (void* value)
1038 1067
1039int icalvalue_is_time(icalvalue* a) { 1068static int icalvalue_is_time(const icalvalue* a) {
1040 icalvalue_kind kind = icalvalue_isa(a); 1069 icalvalue_kind kind = icalvalue_isa(a);
@@ -1050,7 +1079,10 @@ int icalvalue_is_time(icalvalue* a) {
1050 1079
1080/*
1081 * In case of error, this function returns 0. This is partly bogus, as 0 is
1082 * not part of the returned enum.
1083 * FIXME We should probably add an error value to the enum.
1084 */
1051icalparameter_xliccomparetype 1085icalparameter_xliccomparetype
1052icalvalue_compare(icalvalue* a, icalvalue *b) 1086icalvalue_compare(const icalvalue* a, const icalvalue *b)
1053{ 1087{
1054 struct icalvalue_impl *impla = (struct icalvalue_impl *)a;
1055 struct icalvalue_impl *implb = (struct icalvalue_impl *)b;
1056 1088
@@ -1068,3 +1100,25 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1068 case ICAL_ATTACH_VALUE: 1100 case ICAL_ATTACH_VALUE:
1069 case ICAL_BINARY_VALUE: 1101 {
1102 if (icalattach_get_is_url(a->data.v_attach) &&
1103 icalattach_get_is_url(b->data.v_attach)) {
1104 if (strcasecmp(icalattach_get_url(a->data.v_attach),
1105 icalattach_get_url(b->data.v_attach)) == 0)
1106 return ICAL_XLICCOMPARETYPE_EQUAL;
1107 else
1108 return ICAL_XLICCOMPARETYPE_NOTEQUAL;
1109 }
1110 else {
1111 if (a->data.v_attach == b->data.v_attach)
1112 return ICAL_XLICCOMPARETYPE_EQUAL;
1113 else
1114 return ICAL_XLICCOMPARETYPE_NOTEQUAL;
1115 }
1116 }
1117 case ICAL_BINARY_VALUE:
1118 {
1119 if (a->data.v_attach == b->data.v_attach)
1120 return ICAL_XLICCOMPARETYPE_EQUAL;
1121 else
1122 return ICAL_XLICCOMPARETYPE_NOTEQUAL;
1123 }
1070 1124
@@ -1081,5 +1135,5 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1081 { 1135 {
1082 if (impla->data.v_float > implb->data.v_float){ 1136 if (a->data.v_float > b->data.v_float){
1083 return ICAL_XLICCOMPARETYPE_GREATER; 1137 return ICAL_XLICCOMPARETYPE_GREATER;
1084 } else if (impla->data.v_float < implb->data.v_float){ 1138 } else if (a->data.v_float < b->data.v_float){
1085 return ICAL_XLICCOMPARETYPE_LESS; 1139 return ICAL_XLICCOMPARETYPE_LESS;
@@ -1093,5 +1147,5 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1093 { 1147 {
1094 if (impla->data.v_int > implb->data.v_int){ 1148 if (a->data.v_int > b->data.v_int){
1095 return ICAL_XLICCOMPARETYPE_GREATER; 1149 return ICAL_XLICCOMPARETYPE_GREATER;
1096 } else if (impla->data.v_int < implb->data.v_int){ 1150 } else if (a->data.v_int < b->data.v_int){
1097 return ICAL_XLICCOMPARETYPE_LESS; 1151 return ICAL_XLICCOMPARETYPE_LESS;
@@ -1104,8 +1158,8 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1104 { 1158 {
1105 int a = icaldurationtype_as_int(impla->data.v_duration); 1159 int dur_a = icaldurationtype_as_int(a->data.v_duration);
1106 int b = icaldurationtype_as_int(implb->data.v_duration); 1160 int dur_b = icaldurationtype_as_int(b->data.v_duration);
1107 1161
1108 if (a > b){ 1162 if (dur_a > dur_b){
1109 return ICAL_XLICCOMPARETYPE_GREATER; 1163 return ICAL_XLICCOMPARETYPE_GREATER;
1110 } else if (a < b){ 1164 } else if (dur_a < dur_b){
1111 return ICAL_XLICCOMPARETYPE_LESS; 1165 return ICAL_XLICCOMPARETYPE_LESS;
@@ -1124,2 +1178,4 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1124 case ICAL_DATETIMEPERIOD_VALUE: 1178 case ICAL_DATETIMEPERIOD_VALUE:
1179 case ICAL_QUERY_VALUE:
1180 case ICAL_RECUR_VALUE:
1125 { 1181 {
@@ -1161,5 +1217,22 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1161 1217
1218 case ICAL_TRANSP_VALUE:
1219 {
1220 if (icalvalue_get_transp(a) == icalvalue_get_transp(b)){
1221 return ICAL_XLICCOMPARETYPE_EQUAL;
1222 } else {
1223 return ICAL_XLICCOMPARETYPE_NOTEQUAL;
1224 }
1225 }
1226
1227 case ICAL_ACTION_VALUE:
1228 {
1229 if (icalvalue_get_action(a) == icalvalue_get_action(b)){
1230 return ICAL_XLICCOMPARETYPE_EQUAL;
1231 } else {
1232 return ICAL_XLICCOMPARETYPE_NOTEQUAL;
1233 }
1234 }
1235
1162 case ICAL_PERIOD_VALUE: 1236 case ICAL_PERIOD_VALUE:
1163 case ICAL_GEO_VALUE: 1237 case ICAL_GEO_VALUE:
1164 case ICAL_RECUR_VALUE:
1165 case ICAL_NO_VALUE: 1238 case ICAL_NO_VALUE:
@@ -1168,3 +1241,3 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1168 icalerror_warn("Comparison not implemented for value type"); 1241 icalerror_warn("Comparison not implemented for value type");
1169 return ICAL_XLICCOMPARETYPE_REGEX+1; /* HACK */ 1242 return 0;
1170 } 1243 }
@@ -1174,14 +1247,15 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1174 1247
1175/* Examine the value and possiby chage the kind to agree with the value */ 1248/** Examine the value and possibly change the kind to agree with the
1249 * value
1250 */
1251
1176void icalvalue_reset_kind(icalvalue* value) 1252void icalvalue_reset_kind(icalvalue* value)
1177{ 1253{
1178 struct icalvalue_impl* impl = (struct icalvalue_impl*)value; 1254 if( (value->kind==ICAL_DATETIME_VALUE || value->kind==ICAL_DATE_VALUE )&&
1179 1255 !icaltime_is_null_time(value->data.v_time) ) {
1180 if( (impl->kind==ICAL_DATETIME_VALUE || impl->kind==ICAL_DATE_VALUE )&&
1181 !icaltime_is_null_time(impl->data.v_time) ) {
1182 1256
1183 if( impl->data.v_time.is_date == 1){ 1257 if(icaltime_is_date(value->data.v_time)){
1184 impl->kind = ICAL_DATE_VALUE; 1258 value->kind = ICAL_DATE_VALUE;
1185 } else { 1259 } else {
1186 impl->kind = ICAL_DATETIME_VALUE; 1260 value->kind = ICAL_DATETIME_VALUE;
1187 } 1261 }
@@ -1194,6 +1268,3 @@ void icalvalue_set_parent(icalvalue* value,
1194{ 1268{
1195 struct icalvalue_impl* v = (struct icalvalue_impl*)value; 1269 value->parent = property;
1196
1197 v->parent = property;
1198
1199} 1270}
@@ -1202,9 +1273,35 @@ icalproperty* icalvalue_get_parent(icalvalue* value)
1202{ 1273{
1203 struct icalvalue_impl* v = (struct icalvalue_impl*)value; 1274 return value->parent;
1275}
1204 1276
1205 1277
1206 return v->parent; 1278int icalvalue_encode_ical_string(const char *szText, char *szEncText, int nMaxBufferLen)
1207} 1279{
1280 char *ptr;
1281 icalvalue *value = 0;
1282
1283 if ((szText == 0) || (szEncText == 0))
1284 return 0;
1285
1286 value = icalvalue_new_from_string(ICAL_STRING_VALUE, szText);
1287
1288 if (value == 0)
1289 return 0;
1290
1291 ptr = icalvalue_text_as_ical_string(value);
1292 if (ptr == 0)
1293 return 0;
1294
1295 if ((int)strlen(ptr) >= nMaxBufferLen)
1296 {
1297 icalvalue_free (value);
1298 return 0;
1299 }
1208 1300
1301 strcpy(szEncText, ptr);
1209 1302
1303 icalvalue_free ((icalvalue*)value);
1304
1305 return 1;
1306}
1210 1307
@@ -1212,4 +1309 @@ icalproperty* icalvalue_get_parent(icalvalue* value)
1212 types */ types */
1213
1214
1215/* Everything below this line is machine generated. Do not edit. */
diff --git a/libical/src/libical/icalvalue.h b/libical/src/libical/icalvalue.h
index 6983c23..851e723 100644
--- a/libical/src/libical/icalvalue.h
+++ b/libical/src/libical/icalvalue.h
@@ -9,4 +9,2 @@
9 9
10
11
12 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -42,3 +40,3 @@
42/* Defined in icalderivedvalue.h */ 40/* Defined in icalderivedvalue.h */
43/*typedef void icalvalue;*/ 41/*typedef struct icalvalue_impl icalvalue;*/
44 42
@@ -46,3 +44,3 @@ icalvalue* icalvalue_new(icalvalue_kind kind);
46 44
47icalvalue* icalvalue_new_clone(icalvalue* value); 45icalvalue* icalvalue_new_clone(const icalvalue* value);
48 46
@@ -52,7 +50,7 @@ void icalvalue_free(icalvalue* value);
52 50
53int icalvalue_is_valid(icalvalue* value); 51int icalvalue_is_valid(const icalvalue* value);
54 52
55const char* icalvalue_as_ical_string(icalvalue* value); 53const char* icalvalue_as_ical_string(const icalvalue* value);
56 54
57icalvalue_kind icalvalue_isa(icalvalue* value); 55icalvalue_kind icalvalue_isa(const icalvalue* value);
58 56
@@ -60,3 +58,3 @@ int icalvalue_isa_value(void*);
60 58
61icalparameter_xliccomparetype icalvalue_compare(icalvalue* a, icalvalue *b); 59icalparameter_xliccomparetype icalvalue_compare(const icalvalue* a, const icalvalue *b);
62 60
@@ -67,3 +65,3 @@ icalvalue* icalvalue_new_recur (struct icalrecurrencetype v);
67void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); 65void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v);
68struct icalrecurrencetype icalvalue_get_recur(icalvalue* value); 66struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value);
69 67
@@ -71,3 +69,3 @@ icalvalue* icalvalue_new_trigger (struct icaltriggertype v);
71void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); 69void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v);
72struct icaltriggertype icalvalue_get_trigger(icalvalue* value); 70struct icaltriggertype icalvalue_get_trigger(const icalvalue* value);
73 71
@@ -76,3 +74,3 @@ void icalvalue_set_datetimeperiod(icalvalue* value,
76 struct icaldatetimeperiodtype v); 74 struct icaldatetimeperiodtype v);
77struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value); 75struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value);
78 76
@@ -81,4 +79,9 @@ struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(icalvalue* value);
81icalvalue_kind icalvalue_string_to_kind(const char* str); 79icalvalue_kind icalvalue_string_to_kind(const char* str);
82const char* icalvalue_kind_to_string(icalvalue_kind kind); 80const char* icalvalue_kind_to_string(const icalvalue_kind kind);
81
82/** Check validity of a specific icalvalue_kind **/
83int icalvalue_kind_is_valid(const icalvalue_kind kind);
83 84
85/** Encode a character string in ical format, esacpe certain characters, etc. */
86int icalvalue_encode_ical_string(const char *szText, char *szEncText, int MaxBufferLen);
84 87
diff --git a/libical/src/libical/icalvalueimpl.h b/libical/src/libical/icalvalueimpl.h
index 116535d..d1ba786 100644
--- a/libical/src/libical/icalvalueimpl.h
+++ b/libical/src/libical/icalvalueimpl.h
@@ -37,2 +37,4 @@
37#include "icalenums.h" 37#include "icalenums.h"
38#include "icalproperty.h"
39#include "icalderivedvalue.h"
38 40
@@ -45,6 +47,6 @@ struct icalvalue_impl {
45 icalproperty* parent; 47 icalproperty* parent;
46 const char* x_value; 48 char* x_value;
47 49
48 union data { 50 union data {
49 struct icalattachtype *v_attach; 51 icalattach *v_attach;
50 /* void *v_binary; */ /* use v_attach */ 52 /* void *v_binary; */ /* use v_attach */
diff --git a/libical/src/libical/icalversion.h b/libical/src/libical/icalversion.h
index beae8e0..c4b1d15 100644
--- a/libical/src/libical/icalversion.h
+++ b/libical/src/libical/icalversion.h
@@ -4,3 +4,3 @@
4#define ICAL_PACKAGE "libical" 4#define ICAL_PACKAGE "libical"
5#define ICAL_VERSION "0.23" 5#define ICAL_VERSION "0.24"
6 6
diff --git a/libical/src/libical/libical.pro b/libical/src/libical/libical.pro
index 9cc3983..4ef11ef 100644
--- a/libical/src/libical/libical.pro
+++ b/libical/src/libical/libical.pro
@@ -1,68 +1,68 @@
1include(../../../variables.pri) 1######################################################################
2 2# Automatically generated by qmake (1.07a) Sun Jun 27 22:44:35 2004
3 TEMPLATE= lib 3######################################################################
4
5TARGET = ical
6DESTDIR = ../../lib
7
8win32: DEFINES += _WIN32
9 4
5TEMPLATE = lib
6INCLUDEPATH += .
10 CONFIG += staticlib 7 CONFIG += staticlib
8DESTDIR = ../../lib
9TARGET = ical
10# Input
11HEADERS += astime.h \
12 ical.h \
13 icalarray.h \
14 icalattach.h \
15 icalattachimpl.h \
16 icalcomponent.h \
17 icalderivedparameter.h \
18 icalderivedproperty.h \
19 icalderivedvalue.h \
20 icalduration.h \
21 icalenums.h \
22 icalerror.h \
23 icallangbind.h \
24 icalmemory.h \
25 icalmime.h \
26 icalparameter.h \
27 icalparameterimpl.h \
28 icalparser.h \
29 icalperiod.h \
30 icalproperty.h \
31 icalrecur.h \
32 icalrestriction.h \
33 icaltime.h \
34 icaltimezone.h \
35 icaltypes.h \
36 icalvalue.h \
37 icalvalueimpl.h \
38 icalversion.h \
39 pvl.h \
40 sspm.h
41SOURCES += caldate.c \
42 icalarray.c \
43 icalattach.c \
44 icalcomponent.c \
45 icalderivedparameter.c \
46 icalderivedproperty.c \
47 icalderivedvalue.c \
48 icalduration.c \
49 icalenums.c \
50 icalerror.c \
51 icallangbind.c \
52 icalmemory.c \
53 icalmime.c \
54 icalparameter.c \
55 icalparser.c \
56 icalperiod.c \
57 icalproperty.c \
58 icalrecur.c \
59 icalrestriction.c \
60 icaltime.c \
61 icaltimezone.c \
62 icaltypes.c \
63 icalvalue.c \
64 pvl.c \
65 sspm.c
11 66
12 HEADERS = \
13 icalattendee.h \
14 icalcomponent.h \
15 icalderivedparameter.h \
16 icalderivedproperty.h \
17 icalderivedvalue.h \
18 icalduration.h \
19 icalenums.h \
20 icalerror.h \
21 icallangbind.h \
22 icalmemory.h \
23 icalmime.h \
24 icalparameter.h \
25 icalparameterimpl.h \
26 icalparser.h \
27 icalperiod.h \
28 icalproperty.h \
29 icalrecur.h \
30 icalrestriction.h \
31 icaltime.h \
32 icaltypes.h \
33 icalvalue.h \
34 icalvalueimpl.h \
35 icalversion.h \
36 icalyacc.h \
37 pvl.h \
38 sspm.h
39
40 SOURCES = icalattendee.c \
41 icalcomponent.c \
42 icalderivedparameter.c \
43 icalderivedproperty.c \
44 icalderivedvalue.c \
45 icalduration.c \
46 icalenums.c \
47 icalerror.c \
48 icallangbind.c \
49 icallexer.c \
50 icalmemory.c \
51 icalmime.c \
52 icalparameter.c \
53 icalparser.c \
54 icalperiod.c \
55 icalproperty.c \
56 icalrecur.c \
57 icalrestriction.c \
58 icaltime.c \
59 icaltypes.c \
60 icalvalue.c \
61 icalyacc.c \
62 pvl.c \
63 sspm.c \
64 vsnprintf.c
65
66 INTERFACES=
67 67
68INCLUDEPATH += . 68# vsnprintf.c
diff --git a/libical/src/libical/libicalE.pro b/libical/src/libical/libicalE.pro
index 2b9b720..1c79e18 100644
--- a/libical/src/libical/libicalE.pro
+++ b/libical/src/libical/libicalE.pro
@@ -1,5 +1,8 @@
1 TEMPLATE= lib 1######################################################################
2 CONFIG = warn_on staticlib 2# Automatically generated by qmake (1.07a) Sun Jun 27 22:44:35 2004
3######################################################################
3 4
4INCLUDEPATH += . 5TEMPLATE = lib
6INCLUDEPATH += .
7 CONFIG += staticlib
5OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
@@ -8,59 +11,60 @@ DESTDIR=../../lib/$(PLATFORM)
8TARGET = ical 11TARGET = ical
9INTERFACES = \ 12# Input
13HEADERS += astime.h \
14 ical.h \
15 icalarray.h \
16 icalattach.h \
17 icalattachimpl.h \
18 icalcomponent.h \
19 icalderivedparameter.h \
20 icalderivedproperty.h \
21 icalderivedvalue.h \
22 icalduration.h \
23 icalenums.h \
24 icalerror.h \
25 icallangbind.h \
26 icalmemory.h \
27 icalmime.h \
28 icalparameter.h \
29 icalparameterimpl.h \
30 icalparser.h \
31 icalperiod.h \
32 icalproperty.h \
33 icalrecur.h \
34 icalrestriction.h \
35 icaltime.h \
36 icaltimezone.h \
37 icaltypes.h \
38 icalvalue.h \
39 icalvalueimpl.h \
40 icalversion.h \
41 pvl.h \
42 sspm.h
43SOURCES += caldate.c \
44 icalarray.c \
45 icalattach.c \
46 icalcomponent.c \
47 icalderivedparameter.c \
48 icalderivedproperty.c \
49 icalderivedvalue.c \
50 icalduration.c \
51 icalenums.c \
52 icalerror.c \
53 icallangbind.c \
54 icalmemory.c \
55 icalmime.c \
56 icalparameter.c \
57 icalparser.c \
58 icalperiod.c \
59 icalproperty.c \
60 icalrecur.c \
61 icalrestriction.c \
62 icaltime.c \
63 icaltimezone.c \
64 icaltypes.c \
65 icalvalue.c \
66 pvl.c \
67 sspm.c
10 68
11HEADERS = \
12 ical.h \
13 icalattendee.h \
14 icalcomponent.h \
15 icalderivedparameter.h \
16 icalderivedproperty.h \
17 icalderivedvalue.h \
18 icalduration.h \
19 icalenums.h \
20 icalerror.h \
21 icallangbind.h \
22 icalmemory.h \
23 icalmime.h \
24 icalparameter.h \
25 icalparameterimpl.h \
26 icalparser.h \
27 icalperiod.h \
28 icalproperty.h \
29 icalrecur.h \
30 icalrestriction.h \
31 icaltime.h \
32 icaltypes.h \
33 icalvalue.h \
34 icalvalueimpl.h \
35 icalversion.h \
36 icalyacc.h \
37 pvl.h \
38 sspm.h \
39
40SOURCES = \
41 icalattendee.c \
42 icalcomponent.c \
43 icalderivedparameter.c \
44 icalderivedproperty.c \
45 icalderivedvalue.c \
46 icalduration.c \
47 icalenums.c \
48 icalerror.c \
49 icallangbind.c \
50 icallexer.c \
51 icalmemory.c \
52 icalmime.c \
53 icalparameter.c \
54 icalparser.c \
55 icalperiod.c \
56 icalproperty.c \
57 icalrecur.c \
58 icalrestriction.c \
59 icaltime.c \
60 icaltypes.c \
61 icalvalue.c \
62 icalyacc.c \
63 pvl.c \
64 sspm.c \
65 vsnprintf.c \
66 69
70# vsnprintf.c
diff --git a/libical/src/libical/pvl.c b/libical/src/libical/pvl.c
index 2a733e8..9c271ce 100644
--- a/libical/src/libical/pvl.c
+++ b/libical/src/libical/pvl.c
@@ -17,5 +17,3 @@
17 17
18 18/**
19
20/*
21 struct pvl_list_t 19 struct pvl_list_t
@@ -30,7 +28,7 @@ typedef struct pvl_list_t
30{ 28{
31 int MAGIC; /* Magic Identifier */ 29 int MAGIC; /**< Magic Identifier */
32 struct pvl_elem_t *head;/* Head of list */ 30 struct pvl_elem_t *head;/**< Head of list */
33 struct pvl_elem_t *tail;/* Tail of list */ 31 struct pvl_elem_t *tail;/**< Tail of list */
34 int count; /* Number of items in the list */ 32 int count; /**< Number of items in the list */
35 struct pvl_elem_t *p; /* Pointer used for iterators */ 33 struct pvl_elem_t *p; /**< Pointer used for iterators */
36} pvl_list_t; 34} pvl_list_t;
@@ -40,4 +38,6 @@ typedef struct pvl_list_t
40 38
41/* This global is incremented for each call to pvl_new_element(); it gives each 39/**
42 * list a unique identifer */ 40 * This global is incremented for each call to pvl_new_element(); it gives each
41 * list a unique identifer
42 */
43 43
@@ -47,14 +47,7 @@ int pvl_list_count = 0;
47 47
48/*---------------------------------------------------------------------- 48/**
49 Function: pvl_list pvl_newlist() 49 * @brief Creates a new list, clears the pointers and assigns a magic number
50 50 *
51 Purpose: 51 * @return Pointer to the new list, 0 if there is no available memory.
52 52 */
53 Creates a new list, clears the pointers and assigns a magic number
54
55 Returns:
56
57 Pointer to the new list
58 0 if there is no available memory.
59 *----------------------------------------------------------------------*/
60 53
@@ -91,28 +84,19 @@ pvl_free(pvl_list l)
91 84
92/*---------------------------------------------------------------------- 85/**
93 Function: pvl_new_element(void *d, struct pvl_elem_t *next,struct pvl_elem_t *prior) 86 * @brief Creates a new list element, assigns a magic number, and assigns
94 87 * the next and previous pointers.
95 Purpose: 88 *
96 Creates a new list element, assigns a magic number, and assigns 89 * Passing in the next and previous points may seem odd, but it allos the user
97 the next and previous pointers. 90 * to set them while keeping the internal data hidden. In nearly all cases,
98 91 * the user is the pvl library itself.
99 Passing in the next and previous points may seem odd, but it allos the user 92 *
100 to set them while keeping the internal data hidden. In nearly all cases, 93 * @param dThe data item to be stored in the list
101 the user is the pvl library itself. 94 * @param next Pointer value to assign to the member "next"
102 95 * @param prior Pointer value to assign to the member "prior"
103 Parameters: 96 *
104 97 * @return A pointer to the new element, 0 if there is no memory available.
105 dThe data item to be stored in the list 98 */
106 next Pointer value to assign to the member "next"
107 prior Pointer value to assign to the member "prior"
108
109 Returns:
110
111 A pointer to the new element.
112 0 if there is no memory available.
113
114 *----------------------------------------------------------------------*/
115 99
116pvl_elem 100pvl_elem
117pvl_new_element(void *d, pvl_elem next,pvl_elem prior) 101pvl_new_element(void *d, pvl_elem next, pvl_elem prior)
118{ 102{
@@ -134,21 +118,12 @@ pvl_new_element(void *d, pvl_elem next,pvl_elem prior)
134 118
135/*---------------------------------------------------------------------- 119/**
136 Function: pvl_unshift(pvl_list l,void *d) 120 * @brief Add a new element to the from of the list
137 121 *
138 Purpose: 122 * @param LThe list to add the item to
139 123 * @param dPointer to the item to add
140 Add a new element to the from of the list 124 */
141
142 Parameters:
143
144 lThe list to add the item to
145 dPointer to the item to add
146
147 Returns:
148 *----------------------------------------------------------------------*/
149 125
150void 126void
151pvl_unshift(pvl_list l,void *d) 127pvl_unshift(pvl_list L,void *d)
152{ 128{
153 struct pvl_list_t *L = (struct pvl_list_t *)l;
154 struct pvl_elem_t *E = pvl_new_element(d,L->head,0); 129 struct pvl_elem_t *E = pvl_new_element(d,L->head,0);
@@ -174,21 +149,13 @@ pvl_unshift(pvl_list l,void *d)
174 149
175/*---------------------------------------------------------------------- 150/**
176 Function: pvl_shift(pvl_list l) 151 * @brief Remove an element from the front of the list
177 152 *
178 Purpose: 153 * @param LThe list to operate on
179 154 *
180 Remove an element from the front of the list 155 * @return the entry on the front of the list
181 156 */
182 Parameters:
183
184 lThe list to operate on
185
186 Returns:
187 *----------------------------------------------------------------------*/
188 157
189void* 158void*
190pvl_shift(pvl_list l) 159pvl_shift(pvl_list L)
191{ 160{
192 struct pvl_list_t *L = (struct pvl_list_t *)l;
193
194 if (L->head == 0) 161 if (L->head == 0)
@@ -198,3 +165,3 @@ pvl_shift(pvl_list l)
198 165
199 return pvl_remove(l,(void*)L->head); 166 return pvl_remove(L,(void*)L->head);
200 167
@@ -202,21 +169,13 @@ pvl_shift(pvl_list l)
202 169
203/*---------------------------------------------------------------------- 170/**
204 Function: void pvl_push(pvl_list l,void *d) 171 * @brief Add a new item to the tail of the list
205 172 *
206 Purpose: 173 * @param LThe list to operate on
207 174 * @param dPointer to the item to add
208 Add a new item to the tail of the list 175 *
209 176 */
210 Paramters:
211
212 lThe list to operate on
213 dPointer to the item to add
214
215 Returns:
216 *----------------------------------------------------------------------*/
217 177
218void 178void
219pvl_push(pvl_list l,void *d) 179pvl_push(pvl_list L,void *d)
220{ 180{
221 struct pvl_list_t *L = (struct pvl_list_t *)l;
222 struct pvl_elem_t *E = pvl_new_element(d,0,L->tail); 181 struct pvl_elem_t *E = pvl_new_element(d,0,L->tail);
@@ -244,22 +203,11 @@ pvl_push(pvl_list l,void *d)
244 203
245/*---------------------------------------------------------------------- 204/**
246 Function: void* pvl_pop(pvl_list l) 205 * @brief Remove an element from the tail of the list
247 206 *
248 Purpose: 207 * @param LThe list to operate on
249 208 */
250 Remove an element from the tail of the list
251
252 Paramters:
253
254 lThe list to operate on
255
256 Returns:
257 *----------------------------------------------------------------------*/
258 209
259void* 210void*
260pvl_pop(pvl_list l) 211pvl_pop(pvl_list L)
261{ 212{
262
263 struct pvl_list_t *L = (struct pvl_list_t *)l;
264
265 if ( L->tail == 0) 213 if ( L->tail == 0)
@@ -269,3 +217,3 @@ pvl_pop(pvl_list l)
269 217
270 return pvl_remove(l,(void*) L->tail);; 218 return pvl_remove(L,(void*) L->tail);;
271 219
@@ -274,25 +222,14 @@ pvl_pop(pvl_list l)
274 222
275/*---------------------------------------------------------------------- 223/**
276 Function: void pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d) 224 * Add a new item to a list that is ordered by a comparison function.
277 225 * This routine assumes that the list is properly ordered.
278 Purpose: 226 *
279 227 * @param LThe list to operate on
280 Add a new item to a list that is ordered by a comparison function. 228 * @param fPointer to a comparison function
281 This routine assumes that the list is properly ordered. 229 * @param d Pointer to data to pass to the comparison function
282 230 */
283 lThe list to operate on
284 fPointer to a comparison function
285 d Pointer to data to pass to the comparison function
286
287 Returns:
288
289 void
290
291 *----------------------------------------------------------------------*/
292 231
293void 232void
294pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d) 233pvl_insert_ordered(pvl_list L,pvl_comparef f,void *d)
295{ 234{
296 struct pvl_list_t *L = (struct pvl_list_t *)l;
297
298 struct pvl_elem_t *P; 235 struct pvl_elem_t *P;
@@ -305,3 +242,3 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
305 { 242 {
306 pvl_unshift(l,d); 243 pvl_unshift(L,d);
307 return; 244 return;
@@ -313,3 +250,3 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
313 { 250 {
314 pvl_unshift(l,d); 251 pvl_unshift(L,d);
315 return; 252 return;
@@ -320,3 +257,3 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
320 { 257 {
321 pvl_push(l,d); 258 pvl_push(L,d);
322 return; 259 return;
@@ -331,3 +268,3 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
331 { 268 {
332 pvl_insert_before(l,P,d); 269 pvl_insert_before(L,P,d);
333 return; 270 return;
@@ -337,31 +274,17 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
337 /* badness, choke */ 274 /* badness, choke */
338 275#ifndef lint
339 assert(0); 276 assert(0);
340 277#endif
341} 278}
342 279
343/*---------------------------------------------------------------------- 280/**
344 Function: void pvl_insert_after(pvl_list l,pvl_elem p,void *d) 281 * @brief Add a new item after the referenced element.
345 282 * @param LThe list to operate on
346 Purpose: 283 * @param PThe list element to add the item after
347 284 * @param dPointer to the item to add.
348 Add a new item after the referenced element. 285 */
349
350 Parameters:
351
352 lThe list to operate on
353 pThe list element to add the item after
354 dPointer to the item to add.
355
356 Returns:
357
358 void
359
360 *----------------------------------------------------------------------*/
361 286
362void 287void
363pvl_insert_after(pvl_list l,pvl_elem p,void *d) 288pvl_insert_after(pvl_list L,pvl_elem P,void *d)
364{ 289{
365 struct pvl_list_t *L = (struct pvl_list_t *)l;
366 struct pvl_elem_t *P = (struct pvl_elem_t *)p;
367 struct pvl_elem_t *E = 0; 290 struct pvl_elem_t *E = 0;
@@ -372,3 +295,3 @@ pvl_insert_after(pvl_list l,pvl_elem p,void *d)
372 { 295 {
373 pvl_unshift(l,d); 296 pvl_unshift(L,d);
374 return; 297 return;
@@ -390,23 +313,13 @@ pvl_insert_after(pvl_list l,pvl_elem p,void *d)
390 313
391/*---------------------------------------------------------------------- 314/**
392 Function: void pvl_insert_before(pvl_list l,pvl_elem p,void *d) 315 * @brief Add an item after a referenced item
393 316 *
394 Purpose: 317 * @param LThe list to operate on
395 318 * @param PThe list element to add the item before
396 Add an item after a referenced item 319 * @param dPointer to the data to be added.
397 320 */
398 Parameters:
399
400 lThe list to operate on
401 pThe list element to add the item before
402 dPointer to the data to be added.
403
404 Returns:
405 *----------------------------------------------------------------------*/
406 321
407void 322void
408pvl_insert_before(pvl_list l,pvl_elem p,void *d) 323pvl_insert_before(pvl_list L,pvl_elem P,void *d)
409{ 324{
410 struct pvl_list_t *L = (struct pvl_list_t *)l;
411 struct pvl_elem_t *P = (struct pvl_elem_t *)p;
412 struct pvl_elem_t *E = 0; 325 struct pvl_elem_t *E = 0;
@@ -417,3 +330,3 @@ pvl_insert_before(pvl_list l,pvl_elem p,void *d)
417 { 330 {
418 pvl_unshift(l,d); 331 pvl_unshift(L,d);
419 return; 332 return;
@@ -435,25 +348,15 @@ pvl_insert_before(pvl_list l,pvl_elem p,void *d)
435 348
436/*---------------------------------------------------------------------- 349/**
437 Function: void pvl_remove(pvl_list l,pvl_elem e) 350 * @brief Remove the referenced item from the list.
438 351 *
439 Purpose: 352 * This routine will free the element, but not the data item that the
440 353 * element contains.
441 Remove the referenced item from the list 354 *
442 355 * @param LThe list to operate on
443 This routine will free the element, but not the data item that the 356 * @param EThe element to remove.
444 element contains. 357 */
445
446 Parameters:
447
448 lThe list to operate on
449 eThe element to remove.
450
451 Returns:
452 *----------------------------------------------------------------------*/
453 358
454void* 359void*
455pvl_remove(pvl_list l,pvl_elem e) 360pvl_remove(pvl_list L,pvl_elem E)
456{ 361{
457 struct pvl_list_t *L = (struct pvl_list_t *)l;
458 struct pvl_elem_t *E = (struct pvl_elem_t *)e;
459 void* data; 362 void* data;
@@ -506,24 +409,15 @@ pvl_remove(pvl_list l,pvl_elem e)
506 409
507/*---------------------------------------------------------------------- 410/**
508 Function: pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v) 411 * @brief Return a pointer to data that satisfies a function.
509 412 *
510 Purpose: 413 * This routine will interate through the entire list and call the
511 414 * find function for each item. It will break and return a pointer to the
512 Return a pointer to data that satisfies a function 415 * data that causes the find function to return 1.
513 416 *
514 This routine will interate through the entire list and call the 417 * @param lThe list to operate on
515 find function for each item. It will break and return a pointer to the 418 * @param fPointer to the find function
516 data that causes the find function to return 1. 419 * @param vPointer to constant data to pass into the function
517 420 *
518 Parameters: 421 * @return Pointer to the element that the find function found.
519 422 */
520 lThe list to operate on
521 fPointer to the find function
522 vPointer to constant data to pass into the function
523
524 Returns:
525
526 Pointer to the element that the find function found.
527
528 *----------------------------------------------------------------------*/
529 423
@@ -547,21 +441,13 @@ pvl_find(pvl_list l,pvl_findf f,void* v)
547} 441}
548/*----------------------------------------------------------------------
549 Function: void* pvl_find_next(pvl_list l,pvl_findf f,void* v)
550
551 Purpose:
552
553 Like pvl_find(), but continues the search where the last find() or
554 find_next() left off
555 442
556 Parameters: 443/**
557 444 * @brief Like pvl_find(), but continues the search where the last find() or
558 lThe list to operate on 445 * find_next() left off.
559 fPointer to the find function 446 *
560 vPointer to constant data to pass into the function 447 * @param lThe list to operate on
561 448 * @param fPointer to the find function
562 Returns: 449 * @param vPointer to constant data to pass into the function
563 450 *
564 Pointer to the element that the find function found. 451 * @return Pointer to the element that the find function found.
565 452 */
566 *----------------------------------------------------------------------*/
567 453
@@ -587,13 +473,6 @@ pvl_find_next(pvl_list l,pvl_findf f,void* v)
587 473
588/*---------------------------------------------------------------------- 474/**
589 Function: void pvl_clear(pvl_list l) 475 * @brief Remove the all the elements in the list. The does not free
590 476 * the data items the elements hold.
591 Purpose: 477 */
592
593 Remove the all the elements in the list. The does not free the data items
594 the elements hold.
595
596
597 Returns:
598 *----------------------------------------------------------------------*/
599 478
@@ -617,17 +496,10 @@ pvl_clear(pvl_list l)
617 496
618/*----------------------------------------------------------------------
619 Function: int pvl_count(pvl_list l)
620
621 Purpose:
622
623 Returns the number of items in the list.
624 497
625 Returns: 498/**
626 *----------------------------------------------------------------------*/ 499 * @brief Returns the number of items in the list.
500 */
627 501
628int 502int
629pvl_count(pvl_list l) 503pvl_count(pvl_list L)
630{ 504{
631 struct pvl_list_t *L = (struct pvl_list_t *)l;
632
633 return L->count; 505 return L->count;
@@ -636,16 +508,9 @@ pvl_count(pvl_list l)
636 508
637/*---------------------------------------------------------------------- 509/**
638 Function: pvl_elem pvl_next(pvl_elem e) 510 * @brief Returns a pointer to the given element
639 511 */
640 Purpose:
641 Returns a pointer to the given element
642
643 Returns:
644 *----------------------------------------------------------------------*/
645 512
646pvl_elem 513pvl_elem
647pvl_next(pvl_elem e) 514pvl_next(pvl_elem E)
648{ 515{
649 struct pvl_elem_t *E = (struct pvl_elem_t *)e;
650
651 if (E == 0){ 516 if (E == 0){
@@ -657,17 +522,10 @@ pvl_next(pvl_elem e)
657 522
658/*----------------------------------------------------------------------
659 Function: pvl_elem pvl_prior(pvl_elem e)
660 523
661 Purpose: 524/**
662 525 * @brief Returns a pointer to the element previous to the element given.
663 Returns a pointer to the element previous to the element given. 526 */
664
665 Returns:
666 *----------------------------------------------------------------------*/
667 527
668pvl_elem 528pvl_elem
669pvl_prior(pvl_elem e) 529pvl_prior(pvl_elem E)
670{ 530{
671 struct pvl_elem_t *E = (struct pvl_elem_t *)e;
672
673 return (pvl_elem)E->prior; 531 return (pvl_elem)E->prior;
@@ -675,16 +533,10 @@ pvl_prior(pvl_elem e)
675 533
676/*----------------------------------------------------------------------
677 Function: pvl_elem pvl_head(pvl_list l )
678
679 Purpose:
680
681 Returns a pointer to the first item in the list.
682 534
683 Returns: 535/**
684 *----------------------------------------------------------------------*/ 536 * @brief Returns a pointer to the first item in the list.
537 */
538
685pvl_elem 539pvl_elem
686pvl_head(pvl_list l ) 540pvl_head(pvl_list L )
687{ 541{
688 struct pvl_list_t *L = (struct pvl_list_t *)l;
689
690 return (pvl_elem)L->head; 542 return (pvl_elem)L->head;
@@ -692,15 +544,8 @@ pvl_head(pvl_list l )
692 544
693/*---------------------------------------------------------------------- 545/**
694 Function: pvl_elem pvl_tail(pvl_list l) 546 * @brief Returns a pointer to the last item in the list.
695 547 */
696 Purpose:
697
698 Returns a pointer to the last item in the list.
699
700 Returns:
701 *----------------------------------------------------------------------*/
702pvl_elem 548pvl_elem
703pvl_tail(pvl_list l) 549pvl_tail(pvl_list L)
704{ 550{
705 struct pvl_list_t *L = (struct pvl_list_t *)l;
706 return (pvl_elem)L->tail; 551 return (pvl_elem)L->tail;
@@ -708,19 +553,7 @@ pvl_tail(pvl_list l)
708 553
709/*----------------------------------------------------------------------
710 Function:
711
712
713 Purpose:
714
715
716 Returns:
717 *----------------------------------------------------------------------*/
718
719#ifndef PVL_USE_MACROS 554#ifndef PVL_USE_MACROS
720void* 555void*
721pvl_data(pvl_elem e) 556pvl_data(pvl_elem E)
722{ 557{
723 struct pvl_elem_t *E = (struct pvl_elem_t *)e; 558 if ( E == 0){
724
725 if ( e == 0){
726 return 0; 559 return 0;
@@ -732,19 +565,9 @@ pvl_data(pvl_elem e)
732 565
733/*---------------------------------------------------------------------- 566/**
734 Function: void pvl_apply(pvl_list l,pvl_applyf f, void *v) 567 * @brief Call a function for every item in the list.
735 568 *
736 Purpose: 569 * @param lThe list to operate on
737 570 * @param fPointer to the function to call
738 Call a function for every item in the list. 571 * @param vData to pass to the function on every iteration
739 572 */
740 Paramters:
741
742 lThe list to operate on
743 fPointer to the function to call
744 vData to pass to the function on every iteration
745
746 Returns:
747
748 void
749 *----------------------------------------------------------------------*/
750 573
diff --git a/libical/src/libical/pvl.h b/libical/src/libical/pvl.h
index 14a15a1..92ec546 100644
--- a/libical/src/libical/pvl.h
+++ b/libical/src/libical/pvl.h
@@ -12,19 +12,17 @@
12 12
13typedef void* pvl_list; 13typedef struct pvl_list_t* pvl_list;
14typedef void* pvl_elem; 14typedef struct pvl_elem_t* pvl_elem;
15 15
16/* 16/**
17 struct pvl_elem_t 17 * This type is private. Always use pvl_elem instead. The struct would
18 * not even appear in this header except to make code in the USE_MACROS
19 * blocks work
20 */
18 21
19 This type is private. Always use pvl_elem instead. The struct would
20 not even appear in this header except to make code in the USE_MACROS
21 blocks work
22
23 */
24typedef struct pvl_elem_t 22typedef struct pvl_elem_t
25{ 23{
26 int MAGIC; /* Magic Identifier */ 24 int MAGIC; /**< Magic Identifier */
27 void *d; /* Pointer to data user is storing */ 25 void *d; /**< Pointer to data user is storing */
28 struct pvl_elem_t *next;/* Next element */ 26 struct pvl_elem_t *next;/**< Next element */
29 struct pvl_elem_t *prior;/* prior element */ 27 struct pvl_elem_t *prior;/**< Prior element */
30} pvl_elem_t; 28} pvl_elem_t;
@@ -33,4 +31,6 @@ typedef struct pvl_elem_t
33 31
34/* This global is incremented for each call to pvl_new_element(); it gives each 32/**
35 * list a unique identifer */ 33 * This global is incremented for each call to pvl_new_element(); it gives each
34 * list a unique identifer
35 */
36 36
@@ -83,4 +83,7 @@ pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v);
83 83
84/* Pass each element in the list to a function */ 84/**
85typedef void (*pvl_applyf)(void* a, void* b); /*a is list elem, b is other data*/ 85 * Pass each element in the list to a function
86 * a is list elem, b is other data
87 */
88typedef void (*pvl_applyf)(void* a, void* b);
86void pvl_apply(pvl_list l,pvl_applyf f, void *v); 89void pvl_apply(pvl_list l,pvl_applyf f, void *v);
diff --git a/libical/src/libical/sspm.c b/libical/src/libical/sspm.c
index 2df581b..17f12ee 100644
--- a/libical/src/libical/sspm.c
+++ b/libical/src/libical/sspm.c
@@ -43,10 +43,2 @@
43 43
44// Eugen C. <eug@thekompany.com>
45#ifdef _WIN32
46#define strcasecmp _stricmp
47#endif
48// Eugen C. <eug@thekompany.com>
49
50int snprintf(char *str, size_t n, char const *fmt, ...);
51
52#ifdef DMALLOC 44#ifdef DMALLOC
@@ -55,2 +47,7 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
55 47
48#ifdef WIN32
49#define snprintf _snprintf
50#define strcasecmp stricmp
51#endif
52
56#define TMP_BUF_SIZE 1024 53#define TMP_BUF_SIZE 1024
@@ -95,3 +92,3 @@ char* sspm_strdup(char* str){
95 92
96struct major_content_type_map 93static struct major_content_type_map
97{ 94{
@@ -114,3 +111,3 @@ struct major_content_type_map
114 111
115struct minor_content_type_map 112static struct minor_content_type_map
116{ 113{
@@ -243,3 +240,3 @@ char* sspm_value(char* line)
243 240
244char *mime_headers[] = { 241static char *mime_headers[] = {
245 "Content-Type", 242 "Content-Type",
@@ -368,3 +365,3 @@ enum line_type {
368 365
369enum line_type get_line_type(char* line){ 366static enum line_type get_line_type(char* line){
370 367
@@ -392,3 +389,3 @@ enum line_type get_line_type(char* line){
392 389
393struct sspm_action_map get_action(struct mime_impl *impl, 390static struct sspm_action_map get_action(struct mime_impl *impl,
394 enum sspm_major_type major, 391 enum sspm_major_type major,
diff --git a/libical/src/libical/vsnprintf.c b/libical/src/libical/vsnprintf.c
index 88a8c63..982920b 100644
--- a/libical/src/libical/vsnprintf.c
+++ b/libical/src/libical/vsnprintf.c
@@ -1,2 +1,5 @@
1#ifdef __osf__ 1#ifndef WIN32
2#include "config.h"
3#endif
4#ifndef HAVE_SNPRINTF
2/* 5/*
@@ -27,10 +30,10 @@
27 30
28#include <sys/types.h> 31#ifndef WIN32
29#include <stdio.h>
30
31#include <unistd.h>
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/mman.h> 33#include <sys/mman.h>
34#include <unistd.h>
35#endif
36#include <sys/types.h>
34#include <signal.h> 37#include <signal.h>
35 38#include <stdio.h>
36#include <string.h> 39#include <string.h>
@@ -159,16 +162,5 @@ snprintf(str, n, fmt, va_alist)
159 162
160#elif defined ( _WIN32 )
161
162#include <stdio.h>
163#include <stdarg.h>
164
165int snprintf(char *str, size_t n, char const *fmt, ...)
166{
167 va_list ap;
168 va_start(ap, fmt);
169
170 return _snprintf(str, n, fmt, ap);
171}
172 163
173#else 164#else
165
174/* ANSI C forbids an empty source file... */ 166/* ANSI C forbids an empty source file... */
diff --git a/libical/src/libicalss/icalcalendar.c b/libical/src/libicalss/icalcalendar.c
new file mode 100644
index 0000000..1f24f88
--- a/dev/null
+++ b/libical/src/libicalss/icalcalendar.c
@@ -0,0 +1,263 @@
1/*======================================================================
2 FILE: icalcalendar.c
3 CREATOR: eric 23 December 1999
4
5 $Id$
6 $Locker$
7
8 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
12
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
15
16 Or:
17
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
20
21 ======================================================================*/
22
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28
29#include "icalcalendar.h"
30#include "icalset.h"
31#include "icalfileset.h"
32#include "icaldirset.h"
33#include <limits.h>
34#include <sys/stat.h> /* For mkdir, stat */
35#include <sys/types.h> /* For mkdir */
36#include <fcntl.h> /* For mkdir */
37
38#ifndef WIN32
39#include <unistd.h> /* For mkdir, stat */
40#endif
41
42#ifndef PATH_MAX
43#define PATH_MAX 512
44#endif
45
46
47#include <stdlib.h> /* for malloc */
48#include <string.h> /* for strcat */
49#include <errno.h>
50
51#define BOOKED_DIR "booked"
52#define INCOMING_FILE "incoming.ics"
53#define PROP_FILE "properties.ics"
54#define FBLIST_FILE "freebusy.ics"
55
56struct icalcalendar_impl
57{
58 char* dir;
59 icalset* freebusy;
60 icalset* properties;
61 icalset* booked;
62 icalset* incoming;
63};
64
65struct icalcalendar_impl* icalcalendar_new_impl(void)
66{
67 struct icalcalendar_impl* impl;
68
69 if ( ( impl = (struct icalcalendar_impl*)
70 malloc(sizeof(struct icalcalendar_impl))) == 0) {
71 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
72 return 0;
73 }
74
75 return impl;
76}
77
78
79icalerrorenum icalcalendar_create(struct icalcalendar_impl* impl)
80{
81 char path[PATH_MAX];
82 struct stat sbuf;
83 int r;
84
85 icalerror_check_arg_re((impl != 0),"impl",ICAL_BADARG_ERROR);
86
87 path[0] = '\0';
88 strcpy(path,impl->dir);
89 strcat(path,"/");
90 strcat(path,BOOKED_DIR);
91
92 r = stat(path,&sbuf);
93
94 if( r != 0 && errno == ENOENT){
95
96 if(mkdir(path,0777)!=0){
97 icalerror_set_errno(ICAL_FILE_ERROR);
98 return ICAL_FILE_ERROR;
99 }
100 }
101
102 return ICAL_NO_ERROR;
103}
104
105icalcalendar* icalcalendar_new(char* dir)
106{
107 struct icalcalendar_impl* impl;
108
109 icalerror_check_arg_rz((dir != 0),"dir");
110
111 impl = icalcalendar_new_impl();
112
113 if (impl == 0){
114 return 0;
115 }
116
117 impl->dir = (char*)strdup(dir);
118 impl->freebusy = 0;
119 impl->properties = 0;
120 impl->booked = 0;
121 impl->incoming = 0;
122
123 if (icalcalendar_create(impl) != ICAL_NO_ERROR){
124 free(impl);
125 return 0;
126 }
127
128 return impl;
129}
130
131void icalcalendar_free(icalcalendar* impl)
132{
133 if (impl->dir !=0){
134 free(impl->dir);
135 }
136
137 if (impl->freebusy !=0){
138 icalset_free(impl->booked);
139 }
140
141 if (impl->properties !=0){
142 icalset_free(impl->properties);
143 }
144
145 if (impl->booked !=0){
146 icalset_free(impl->booked);
147 }
148
149 if (impl->incoming !=0){
150 icalset_free(impl->incoming);
151 }
152
153 impl->dir = 0;
154 impl->freebusy = 0;
155 impl->properties = 0;
156 impl->booked = 0;
157 impl->incoming = 0;
158
159
160 free(impl);
161}
162
163
164int icalcalendar_lock(icalcalendar* impl)
165{
166 icalerror_check_arg_rz((impl != 0),"impl");
167 return 0;
168}
169
170int icalcalendar_unlock(icalcalendar* impl)
171{
172 icalerror_check_arg_rz((impl != 0),"impl");
173 return 0;
174}
175
176int icalcalendar_islocked(icalcalendar* impl)
177{
178 icalerror_check_arg_rz((impl != 0),"impl");
179 return 0;
180}
181
182int icalcalendar_ownlock(icalcalendar* impl)
183{
184 icalerror_check_arg_rz((impl != 0),"impl");
185 return 0;
186}
187
188icalset* icalcalendar_get_booked(icalcalendar* impl)
189{
190 char dir[PATH_MAX];
191
192 icalerror_check_arg_rz((impl != 0),"impl");
193
194 dir[0] = '\0';
195 strcpy(dir,impl->dir);
196 strcat(dir,"/");
197 strcat(dir,BOOKED_DIR);
198
199 if (impl->booked == 0){
200 icalerror_clear_errno();
201 impl->booked = icaldirset_new(dir);
202 assert(icalerrno == ICAL_NO_ERROR);
203 }
204
205 return impl->booked;
206
207}
208
209icalset* icalcalendar_get_incoming(icalcalendar* impl)
210{
211 char path[PATH_MAX];
212 icalerror_check_arg_rz((impl != 0),"impl");
213
214 path[0] = '\0';
215 strcpy(path,impl->dir);
216 strcat(path,"/");
217 strcat(path,INCOMING_FILE);
218
219 if (impl->properties == 0){
220 impl->properties = icalfileset_new(path);
221 }
222
223 return impl->properties;
224}
225
226icalset* icalcalendar_get_properties(icalcalendar* impl)
227{
228 char path[PATH_MAX];
229 icalerror_check_arg_rz((impl != 0),"impl");
230
231 path[0] = '\0';
232 strcpy(path,impl->dir);
233 strcat(path,"/");
234 strcat(path,PROP_FILE);
235
236 if (impl->properties == 0){
237 impl->properties = icalfileset_new(path);
238 }
239
240 return impl->properties;
241}
242
243icalset* icalcalendar_get_freebusy(icalcalendar* impl)
244{
245 char path[PATH_MAX];
246 icalerror_check_arg_rz((impl != 0),"impl");
247
248 path[0] = '\0';
249 strcpy(path,impl->dir);
250 strcat(path,"/");
251 strcat(path,FBLIST_FILE);
252
253
254 if (impl->freebusy == 0){
255 impl->freebusy = icalfileset_new(path);
256 }
257
258 return impl->freebusy;
259}
260
261
262
263
diff --git a/libical/src/libicalss/icalcalendar.h b/libical/src/libicalss/icalcalendar.h
index f07457c..2a0c151 100644
--- a/libical/src/libicalss/icalcalendar.h
+++ b/libical/src/libicalss/icalcalendar.h
@@ -40,3 +40,3 @@
40 40
41typedef void icalcalendar; 41typedef struct icalcalendar_impl icalcalendar;
42 42
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c
index c029309..61ddbd3 100644
--- a/libical/src/libicalss/icalclassify.c
+++ b/libical/src/libicalss/icalclassify.c
@@ -28,3 +28,2 @@
28 28
29#include "icalerror.h"
30#include "ical.h" 29#include "ical.h"
@@ -32,2 +31,3 @@
32#include "icalmemory.h" 31#include "icalmemory.h"
32
33#include <ctype.h> /* For tolower() */ 33#include <ctype.h> /* For tolower() */
@@ -148,3 +148,3 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
148 { 148 {
149 const char* this_attendee 149 char* this_attendee
150 = icalclassify_lowercase(icalproperty_get_attendee(p)); 150 = icalclassify_lowercase(icalproperty_get_attendee(p));
@@ -159,2 +159,4 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
159 if(strcmp(this_upn,upn)==0){ 159 if(strcmp(this_upn,upn)==0){
160 free(lattendee);
161 free(this_attendee);
160 return p; 162 return p;
@@ -162,3 +164,5 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
162 164
165 free(this_attendee);
163 } 166 }
167 free(lattendee);
164 168
@@ -286,3 +290,3 @@ int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b)
286 290
287 if( (p1!=0)^(p1!=0) ){ 291 if( (p1!=0)^(p2!=0) ){
288 /* Return true if the property exists in one component and not 292 /* Return true if the property exists in one component and not
@@ -548,3 +552,2 @@ int icalclassify_reply_crasher_decline(
548{ 552{
549 icalparameter_partstat partstat;
550 icalproperty* attendee; 553 icalproperty* attendee;
@@ -644,33 +647,33 @@ struct icalclassify_map {
644 int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); 647 int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user);
645 ical_class class; 648 icalproperty_xlicclass class;
646} icalclassify_map[] = 649} icalclassify_map[] =
647{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS}, 650{ {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_XLICCLASS_PUBLISHNEW},
648 {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS}, 651 {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_XLICCLASS_PUBLISHUPDATE},
649 {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS}, 652 {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_XLICCLASS_PUBLISHFREEBUSY},
650 {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS}, 653 {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_XLICCLASS_REQUESTDELEGATE},
651 {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS}, 654 {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_XLICCLASS_REQUESTNEW},
652 {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS}, 655 {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_XLICCLASS_REQUESTUPDATE},
653 {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS}, 656 {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_XLICCLASS_REQUESTRESCHEDULE},
654 657
655 {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS}, 658 {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_XLICCLASS_REQUESTNEWORGANIZER},
656 {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS}, 659 {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_XLICCLASS_REQUESTFORWARD},
657 {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS}, 660 {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_XLICCLASS_REQUESTSTATUS},
658 {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS}, 661 {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_XLICCLASS_REQUESTFREEBUSY},
659 662
660 {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS}, 663 {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_XLICCLASS_REPLYACCEPT},
661 {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS}, 664 {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_XLICCLASS_REPLYDECLINE},
662 {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_REPLY_DELEGATE_CLASS}, 665 {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_XLICCLASS_REPLYDELEGATE},
663 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS}, 666 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_XLICCLASS_REPLYCRASHERACCEPT},
664 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS}, 667 {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_XLICCLASS_REPLYCRASHERDECLINE},
665 668
666 {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS}, 669 {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_XLICCLASS_ADDINSTANCE},
667 670
668 {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS}, 671 {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_XLICCLASS_CANCELEVENT},
669 {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS}, 672 {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_XLICCLASS_CANCELINSTANCE},
670 {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS}, 673 {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_XLICCLASS_CANCELALL},
671 674
672 {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS}, 675 {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_XLICCLASS_REFRESH},
673 {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS}, 676 {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_XLICCLASS_COUNTER},
674 {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS}, 677 {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_XLICCLASS_DECLINECOUNTER},
675 {ICAL_METHOD_NONE,0,ICAL_NO_CLASS} 678 {ICAL_METHOD_NONE,0,ICAL_XLICCLASS_NONE}
676}; 679};
@@ -678,3 +681,3 @@ struct icalclassify_map {
678 681
679ical_class icalclassify(icalcomponent* c,icalcomponent* match, 682icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
680 const char* user) 683 const char* user)
@@ -684,3 +687,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
684 icalproperty_method method; 687 icalproperty_method method;
685 ical_class class = ICAL_UNKNOWN_CLASS; 688 icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN;
686 689
@@ -694,3 +697,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
694 if (inner == 0) { 697 if (inner == 0) {
695 return ICAL_NO_CLASS; 698 return ICAL_XLICCLASS_NONE;
696 } 699 }
@@ -711,3 +714,4 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
711 /* comp has a smaller sequence and a later DTSTAMP */ 714 /* comp has a smaller sequence and a later DTSTAMP */
712 return ICAL_MISSEQUENCED_CLASS; 715 class = ICAL_XLICCLASS_MISSEQUENCED;
716 goto CLEANUP;
713 } 717 }
@@ -720,3 +724,4 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
720 724
721 return ICAL_OBSOLETE_CLASS; 725 class = ICAL_XLICCLASS_OBSOLETE;
726 goto CLEANUP;
722 } 727 }
@@ -727,3 +732,4 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
727 if (p == 0) { 732 if (p == 0) {
728 return ICAL_UNKNOWN_CLASS; 733 class = ICAL_XLICCLASS_UNKNOWN;
734 goto CLEANUP;
729 } 735 }
@@ -740,2 +746,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
740 746
747CLEANUP:
741 icalssutil_free_parts(&comp_parts); 748 icalssutil_free_parts(&comp_parts);
@@ -747,46 +754 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
747 754
748struct class_map {
749 ical_class class;
750 char *str;
751} class_map[] = {
752 {ICAL_NO_CLASS,"No class"},
753 {ICAL_PUBLISH_NEW_CLASS,"New Publish"},
754 {ICAL_PUBLISH_UPDATE_CLASS,"Publish Update"},
755 {ICAL_PUBLISH_FREEBUSY_CLASS,"Publish freebusy"},
756 {ICAL_REQUEST_NEW_CLASS,"New request"},
757 {ICAL_REQUEST_UPDATE_CLASS,"Update"},
758 {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"},
759 {ICAL_REQUEST_DELEGATE_CLASS,"Delegate request"},
760 {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"},
761 {ICAL_REQUEST_FORWARD_CLASS,"Forward"},
762 {ICAL_REQUEST_STATUS_CLASS,"Status request"},
763 {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"},
764 {ICAL_REPLY_DECLINE_CLASS,"Decline reply"},
765 {ICAL_REPLY_DELEGATE_CLASS,"Delegation reply"},
766 {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"},
767 {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"},
768 {ICAL_ADD_INSTANCE_CLASS,"Add instance"},
769 {ICAL_CANCEL_EVENT_CLASS,"Cancel event"},
770 {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"},
771 {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"},
772 {ICAL_REFRESH_CLASS,"Refresh"},
773 {ICAL_COUNTER_CLASS,"Counter"},
774 {ICAL_DECLINECOUNTER_CLASS,"Decline counter"},
775 {ICAL_MALFORMED_CLASS,"Malformed"},
776 {ICAL_OBSOLETE_CLASS,"Obsolete"},
777 {ICAL_MISSEQUENCED_CLASS,"Missequenced"},
778 {ICAL_UNKNOWN_CLASS,"Unknown"}
779};
780
781char* icalclassify_class_to_string(ical_class class)
782{
783 int i;
784
785 for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){
786 if (class_map[i].class == class){
787 return class_map[i].str;
788 }
789 }
790
791 return "Unknown";
792}
diff --git a/libical/src/libicalss/icalclassify.h b/libical/src/libicalss/icalclassify.h
index 81188b3..aceabc0 100644
--- a/libical/src/libicalss/icalclassify.h
+++ b/libical/src/libicalss/icalclassify.h
@@ -31,35 +31,3 @@
31 31
32 32icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
33typedef enum icalclass {
34 ICAL_NO_CLASS,
35 ICAL_PUBLISH_NEW_CLASS,
36 ICAL_PUBLISH_UPDATE_CLASS,
37 ICAL_PUBLISH_FREEBUSY_CLASS,
38 ICAL_REQUEST_NEW_CLASS,
39 ICAL_REQUEST_UPDATE_CLASS,
40 ICAL_REQUEST_RESCHEDULE_CLASS,
41 ICAL_REQUEST_DELEGATE_CLASS,
42 ICAL_REQUEST_NEW_ORGANIZER_CLASS,
43 ICAL_REQUEST_FORWARD_CLASS,
44 ICAL_REQUEST_STATUS_CLASS,
45 ICAL_REQUEST_FREEBUSY_CLASS,
46 ICAL_REPLY_ACCEPT_CLASS,
47 ICAL_REPLY_DECLINE_CLASS,
48 ICAL_REPLY_DELEGATE_CLASS,
49 ICAL_REPLY_CRASHER_ACCEPT_CLASS,
50 ICAL_REPLY_CRASHER_DECLINE_CLASS,
51 ICAL_ADD_INSTANCE_CLASS,
52 ICAL_CANCEL_EVENT_CLASS,
53 ICAL_CANCEL_INSTANCE_CLASS,
54 ICAL_CANCEL_ALL_CLASS,
55 ICAL_REFRESH_CLASS,
56 ICAL_COUNTER_CLASS,
57 ICAL_DECLINECOUNTER_CLASS,
58 ICAL_MALFORMED_CLASS,
59 ICAL_OBSOLETE_CLASS, /* 21 */
60 ICAL_MISSEQUENCED_CLASS, /* 22 */
61 ICAL_UNKNOWN_CLASS /* 23 */
62} ical_class;
63
64ical_class icalclassify(icalcomponent* c,icalcomponent* match,
65 const char* user); 33 const char* user);
@@ -68,3 +36,3 @@ icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
68 36
69char* icalclassify_class_to_string(ical_class iclass); 37char* icalclassify_class_to_string(icalproperty_xlicclass c);
70 38
diff --git a/libical/src/libicalss/icalcluster.c b/libical/src/libicalss/icalcluster.c
new file mode 100644
index 0000000..6d11078
--- a/dev/null
+++ b/libical/src/libicalss/icalcluster.c
@@ -0,0 +1,245 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalcluster.c
4 CREATOR: acampi 13 March 2002
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2002, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The Original Code is eric. The Initial Developer of the Original
23 Code is Eric Busboom
24
25
26 ======================================================================*/
27
28
29/**
30 *
31 * icalcluster is an utility class design to manage clusters of
32 * icalcomponents on behalf of an implementation of icalset. This is
33 * done in order to split out common behavior different classes might
34 * need.
35 * The definition of what exactly a cluster will contain depends on the
36 * icalset subclass. At the basic level, an icluster is just a tuple,
37 * with anything as key and an icalcomponent as value.
38 */
39
40
41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
45#include <stdlib.h>
46#include <string.h>
47
48#if 0
49#include <errno.h>
50#include <sys/stat.h> /* for stat */
51#ifndef WIN32
52#include <unistd.h> /* for stat, getpid */
53#else
54#include <io.h>
55#include <share.h>
56#endif
57#include <fcntl.h> /* for fcntl */
58#endif
59
60#include "icalcluster.h"
61#include "icalclusterimpl.h"
62#include "icalgauge.h"
63
64#ifdef WIN32
65 #define snprintf_snprintf
66 #define strcasecmpstricmp
67#endif
68
69
70icalcluster * icalcluster_new_impl(void) {
71
72 struct icalcluster_impl* impl;
73
74 if ((impl = (struct icalcluster_impl*)malloc(
75 sizeof(struct icalcluster_impl))) == 0) {
76 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
77 return 0;
78 }
79
80 memset(impl, 0, sizeof(struct icalcluster_impl));
81 strcpy(impl->id,ICALCLUSTER_ID);
82
83 return impl;
84}
85
86/**
87 * Create a cluster with a key/value pair.
88 *
89 * @todo Always do a deep copy.
90 */
91
92icalcluster * icalcluster_new(const char* key, icalcomponent *data) {
93 struct icalcluster_impl *impl = icalcluster_new_impl();
94 assert(impl->data == 0);
95
96 impl->key= strdup(key);
97 impl->changed= 0;
98 impl->data= 0;
99
100 if (data != NULL) {
101 if (icalcomponent_isa(data) != ICAL_XROOT_COMPONENT) {
102 impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
103 icalcomponent_add_component(impl->data, data);
104 } else {
105 impl->data = icalcomponent_new_clone(data);
106 }
107 } else {
108 impl->data = icalcomponent_new(ICAL_XROOT_COMPONENT);
109 }
110
111 return impl;
112}
113
114/**
115 * Deep clone an icalcluster to a new one
116 */
117
118icalcluster *icalcluster_new_clone(const icalcluster *data) {
119 struct icalcluster_impl *old = (struct icalcluster_impl *)data;
120 struct icalcluster_impl *impl = icalcluster_new_impl();
121
122 impl->key= strdup(old->key);
123 impl->data= icalcomponent_new_clone(old->data);
124 impl->changed= 0;
125
126 return impl;
127}
128
129
130void icalcluster_free(icalcluster *impl) {
131 icalerror_check_arg_rv((impl!=0),"cluster");
132
133 if (impl->key != 0){
134 free(impl->key);
135 impl->key = 0;
136 }
137
138 if (impl->data != 0){
139 icalcomponent_free(impl->data);
140 impl->data = 0;
141 }
142
143 free(impl);
144}
145
146
147const char *icalcluster_key(icalcluster *impl) {
148 icalerror_check_arg_rz((impl!=0),"cluster");
149
150 return impl->key;
151}
152
153
154int icalcluster_is_changed(icalcluster *impl) {
155 icalerror_check_arg_rz((impl!=0),"cluster");
156
157 return impl->changed;
158}
159
160
161void icalcluster_mark(icalcluster *impl) {
162 icalerror_check_arg_rv((impl!=0),"cluster");
163
164 impl->changed = 1;
165}
166
167
168void icalcluster_commit(icalcluster *impl) {
169 icalerror_check_arg_rv((impl!=0),"cluster");
170
171 impl->changed = 0;
172}
173
174
175icalcomponent *icalcluster_get_component(icalcluster *impl) {
176
177 icalerror_check_arg_rz((impl!=0),"cluster");
178
179 if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) {
180 icalerror_warn("The top component is not an XROOT");
181 fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data));
182 abort();
183 }
184
185 return impl->data;
186}
187
188
189icalerrorenum icalcluster_add_component(icalcluster *impl, icalcomponent* child) {
190
191 icalerror_check_arg_re((impl!=0),"cluster", ICAL_BADARG_ERROR);
192 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
193
194 icalcomponent_add_component(impl->data, child);
195 icalcluster_mark(impl);
196
197 return ICAL_NO_ERROR;
198}
199
200
201icalerrorenum icalcluster_remove_component(icalcluster *impl, icalcomponent* child) {
202
203 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
204 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
205
206 icalcomponent_remove_component(impl->data,child);
207 icalcluster_mark(impl);
208
209 return ICAL_NO_ERROR;
210}
211
212
213int icalcluster_count_components(icalcluster *impl, icalcomponent_kind kind) {
214
215 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
216
217 return icalcomponent_count_components(impl->data, kind);
218}
219
220
221/** Iterate through components **/
222icalcomponent *icalcluster_get_current_component(icalcluster* impl) {
223
224 icalerror_check_arg_rz((impl!=0),"cluster");
225
226 return icalcomponent_get_current_component(impl->data);
227}
228
229
230icalcomponent *icalcluster_get_first_component(icalcluster* impl) {
231
232 icalerror_check_arg_rz((impl!=0),"cluster");
233
234 return icalcomponent_get_first_component(impl->data,
235 ICAL_ANY_COMPONENT);
236}
237
238
239icalcomponent *icalcluster_get_next_component(icalcluster* impl) {
240
241 icalerror_check_arg_rz((impl!=0),"cluster");
242
243 return icalcomponent_get_next_component(impl->data,
244 ICAL_ANY_COMPONENT);
245}
diff --git a/libical/src/libicalss/icalcluster.h b/libical/src/libicalss/icalcluster.h
new file mode 100644
index 0000000..f4eb041
--- a/dev/null
+++ b/libical/src/libicalss/icalcluster.h
@@ -0,0 +1,61 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalcluster.h
4 CREATOR: eric 23 December 1999
5
6
7 $Id$
8 $Locker$
9
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
14
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
17
18 Or:
19
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
22
23 The Original Code is eric. The Initial Developer of the Original
24 Code is Eric Busboom
25
26
27======================================================================*/
28
29#ifndef ICALCLUSTER_H
30#define ICALCLUSTER_H
31
32#include "ical.h"
33#include "icalset.h"
34
35typedef struct icalcluster_impl icalcluster;
36
37icalcluster* icalcluster_new(const char *key, icalcomponent *data);
38icalcluster* icalcluster_new_clone(const icalcluster *cluster);
39
40void icalcluster_free(icalcluster *cluster);
41
42const char* icalcluster_key(icalcluster *cluster);
43int icalcluster_is_changed(icalcluster *cluster);
44void icalcluster_mark(icalcluster *cluster);
45void icalcluster_commit(icalcluster *cluster);
46
47icalcomponent* icalcluster_get_component(icalcluster* cluster);
48int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
49icalerrorenum icalcluster_add_component(icalcluster* cluster,
50 icalcomponent* child);
51icalerrorenum icalcluster_remove_component(icalcluster* cluster,
52 icalcomponent* child);
53
54icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
55icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
56icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
57
58#endif /* !ICALCLUSTER_H */
59
60
61
diff --git a/libical/src/libicalss/icalclusterimpl.h b/libical/src/libicalss/icalclusterimpl.h
new file mode 100644
index 0000000..ef80e1a
--- a/dev/null
+++ b/libical/src/libicalss/icalclusterimpl.h
@@ -0,0 +1,45 @@
1/* -*- Mode: C -*-
2 ======================================================================
3 FILE: icalfilesetimpl.h
4 CREATOR: eric 23 December 1999
5
6 $Id$
7 $Locker$
8
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The Original Code is eric. The Initial Developer of the Original
23 Code is Eric Busboom
24
25
26 ======================================================================*/
27
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33/* This definition is in its own file so it can be kept out of the
34 main header file, but used by "friend classes" like icaldirset*/
35
36#define ICALCLUSTER_ID "clus"
37
38struct icalcluster_impl {
39
40 char id[5]; /* clus */
41
42 char *key;
43 icalcomponent *data;
44 int changed;
45};
diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c
index b6cb673..4a20fe1 100644
--- a/libical/src/libicalss/icaldirset.c
+++ b/libical/src/libicalss/icaldirset.c
@@ -28,5 +28,6 @@
28 28
29/* 29/**
30 @file icaldirset.c
30 31
31 icaldirset manages a database of ical components and offers 32 @brief icaldirset manages a database of ical components and offers
32 interfaces for reading, writting and searching for components. 33 interfaces for reading, writting and searching for components.
@@ -38,8 +39,9 @@
38 39
39 The primary interfaces are icaldirset_first and icaldirset_next. These 40 The primary interfaces are icaldirset__get_first_component and
40 routine iterate through all of the components in the store, subject 41 icaldirset_get_next_component. These routine iterate through all of
41 to the current gauge. A gauge is an icalcomponent that is tested 42 the components in the store, subject to the current gauge. A gauge
42 against other componets for a match. If a gauge has been set with 43 is an icalcomponent that is tested against other componets for a
43 icaldirset_select, icaldirset_first and icaldirset_next will only 44 match. If a gauge has been set with icaldirset_select,
44 return componentes that match the gauge. 45 icaldirset_first and icaldirset_next will only return componentes
46 that match the gauge.
45 47
@@ -57,7 +59,4 @@
57 59
58#include "icalerror.h"
59#include "ical.h" 60#include "ical.h"
60#include "icaldirset.h" 61#include "icaldirset.h"
61#include "pvl.h"
62#include "icalparser.h"
63#include "icaldirset.h" 62#include "icaldirset.h"
@@ -65,2 +64,3 @@
65#include "icalfilesetimpl.h" 64#include "icalfilesetimpl.h"
65#include "icalcluster.h"
66#include "icalgauge.h" 66#include "icalgauge.h"
@@ -68,17 +68,13 @@
68#include <limits.h> /* For PATH_MAX */ 68#include <limits.h> /* For PATH_MAX */
69#include <errno.h> 69#ifndef WIN32
70#include <sys/types.h> /* for opendir() */
71#include <sys/stat.h> /* for stat */
72
73int snprintf(char *str, size_t n, char const *fmt, ...);
74
75// Eugen C. <eug@thekompany.com>
76#include <defines.h>
77#ifndef _QTWIN_
78#include <dirent.h> /* for opendir() */ 70#include <dirent.h> /* for opendir() */
79#include <unistd.h> 71#include <unistd.h> /* for stat, getpid */
80#include <sys/utsname.h> /* for uname */ 72#include <sys/utsname.h> /* for uname */
73#else
74#include <io.h>
75#include <process.h>
81#endif 76#endif
82// Eugen C. <eug@thekompany.com> 77#include <errno.h>
83 78#include <sys/types.h> /* for opendir() */
79#include <sys/stat.h> /* for stat */
84#include <time.h> /* for clock() */ 80#include <time.h> /* for clock() */
@@ -89,30 +85,29 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
89 85
90struct icaldirset_impl* icaldirset_new_impl() 86#ifdef WIN32
91{ 87 #define snprintf_snprintf
92 struct icaldirset_impl* impl; 88 #define strcasecmpstricmp
93 89
94 if ( ( impl = (struct icaldirset_impl*) 90#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
95 malloc(sizeof(struct icaldirset_impl))) == 0) { 91
96 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 92#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
97 return 0; 93#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
98 } 94#endif
99 95
100 strcpy(impl->id,ICALDIRSET_ID); 96/** Default options used when NULL is passed to icalset_new() **/
97icaldirset_options icaldirset_options_default = {O_RDWR|O_CREAT};
101 98
102 return impl;
103}
104 99
105const char* icaldirset_path(icaldirset* cluster) 100const char* icaldirset_path(icalset* set)
106{ 101{
107 struct icaldirset_impl *impl = icaldirset_new_impl(); 102 icaldirset *dset = (icaldirset*)set;
108
109 return impl->dir;
110 103
104 return dset->dir;
111} 105}
112 106
113void icaldirset_mark(icaldirset* store) 107
108void icaldirset_mark(icalset* set)
114{ 109{
115 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 110 icaldirset *dset = (icaldirset*)set;
116 111
117 icalfileset_mark(impl->cluster); 112 icalcluster_mark(dset->cluster);
118} 113}
@@ -120,8 +115,16 @@ void icaldirset_mark(icaldirset* store)
120 115
121icalerrorenum icaldirset_commit(icaldirset* store) 116icalerrorenum icaldirset_commit(icalset* set)
122{ 117{
123 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 118 icaldirset *dset = (icaldirset*)set;
119 icalset *fileset;
120 icalfileset_options options = icalfileset_options_default;
124 121
125 return icalfileset_commit(impl->cluster); 122 options.cluster = dset->cluster;
126 123
124 fileset = icalset_new(ICAL_FILE_SET, icalcluster_key(dset->cluster), &options);
125
126 fileset->commit(fileset);
127 fileset->free(fileset);
128
129 return ICAL_NO_ERROR;
127} 130}
@@ -138,12 +141,12 @@ void icaldirset_unlock(const char* dir)
138/* Load the contents of the store directory into the store's internal directory list*/ 141/* Load the contents of the store directory into the store's internal directory list*/
139icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl) 142icalerrorenum icaldirset_read_directory(icaldirset *dset)
140{ 143{
141#ifndef _QTWIN_ 144 char *str;
145#ifndef WIN32
142 struct dirent *de; 146 struct dirent *de;
143 DIR* dp; 147 DIR* dp;
144 char *str;
145 148
146 dp = opendir(impl->dir); 149 dp = opendir(dset->dir);
147 150
148 if ( dp == 0) { 151 if (dp == 0) {
149 icalerror_set_errno(ICAL_FILE_ERROR); 152 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -153,3 +156,3 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
153 /* clear contents of directory list */ 156 /* clear contents of directory list */
154 while((str = pvl_pop(impl->directory))){ 157 while((str = pvl_pop(dset->directory))){
155 free(str); 158 free(str);
@@ -168,3 +171,3 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
168 171
169 pvl_push(impl->directory, (void*)strdup(de->d_name)); 172 pvl_push(dset->directory, (void*)strdup(de->d_name));
170 } 173 }
@@ -172,20 +175,44 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
172 closedir(dp); 175 closedir(dp);
173
174 return ICAL_NO_ERROR;
175#else 176#else
176 icalerror_set_errno(ICAL_FILE_ERROR); 177 struct _finddata_t c_file;
177 return ICAL_FILE_ERROR; 178 long hFile;
179
180 /* Find first .c file in current directory */
181 if( (hFile = _findfirst( "*", &c_file )) == -1L ) {
182 icalerror_set_errno(ICAL_FILE_ERROR);
183 return ICAL_FILE_ERROR;
184 } else {
185 while((str = pvl_pop(dset->directory))){
186 free(str);
187 }
188
189 /* load all of the cluster names in the directory list */
190 do {
191 /* Remove known directory names '.' and '..'*/
192 if (strcmp(c_file.name,".") == 0 ||
193 strcmp(c_file.name,"..") == 0 ){
194 continue;
195 }
196
197 pvl_push(dset->directory, (void*)strdup(c_file.name));
198 }
199 while ( _findnext( hFile, &c_file ) == 0 );
200
201 _findclose( hFile );
202 }
203
178#endif 204#endif
205
206 return ICAL_NO_ERROR;
179} 207}
180 208
181icaldirset* icaldirset_new(const char* dir) 209
210icalset* icaldirset_init(icalset* set, const char* dir, void* options_in)
182{ 211{
183 struct icaldirset_impl *impl = icaldirset_new_impl(); 212 icaldirset *dset = (icaldirset*)set;
213 icaldirset_options *options = options_in;
184 struct stat sbuf; 214 struct stat sbuf;
185 215
186 if (impl == 0){
187 return 0;
188 }
189
190 icalerror_check_arg_rz( (dir!=0), "dir"); 216 icalerror_check_arg_rz( (dir!=0), "dir");
217 icalerror_check_arg_rz( (set!=0), "set");
191 218
@@ -196,3 +223,2 @@ icaldirset* icaldirset_new(const char* dir)
196 223
197#ifndef _QTWIN_
198 /* dir is not the name of a direectory*/ 224 /* dir is not the name of a direectory*/
@@ -202,3 +228,2 @@ icaldirset* icaldirset_new(const char* dir)
202 } 228 }
203#endif
204 229
@@ -206,41 +231,61 @@ icaldirset* icaldirset_new(const char* dir)
206 231
207 impl = icaldirset_new_impl(); 232 dset->dir = (char*)strdup(dir);
233 dset->options = *options;
234 dset->directory = pvl_newlist();
235 dset->directory_iterator = 0;
236 dset->gauge = 0;
237 dset->first_component = 0;
238 dset->cluster = 0;
239
240 return set;
241}
242
243icalset* icaldirset_new(const char* dir)
244{
245 return icalset_new(ICAL_DIR_SET, dir, &icaldirset_options_default);
246}
208 247
209 if (impl ==0){
210 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
211 return 0;
212 }
213 248
214 impl->directory = pvl_newlist(); 249icalset* icaldirset_new_reader(const char* dir)
215 impl->directory_iterator = 0; 250{
216 impl->dir = (char*)strdup(dir); 251 icaldirset_options reader_options = icaldirset_options_default;
217 impl->gauge = 0;
218 impl->first_component = 0;
219 impl->cluster = 0;
220 252
221 icaldirset_read_directory(impl); 253 reader_options.flags = O_RDONLY;
222 254
223 return (icaldirset*) impl; 255 return icalset_new(ICAL_DIR_SET, dir, &reader_options);
224} 256}
225 257
226void icaldirset_free(icaldirset* s) 258
259icalset* icaldirset_new_writer(const char* dir)
227{ 260{
228 struct icaldirset_impl *impl = (struct icaldirset_impl*)s; 261 icaldirset_options writer_options = icaldirset_options_default;
262
263 writer_options.flags = O_RDWR|O_CREAT;
264
265 return icalset_new(ICAL_DIR_SET, dir, &writer_options);
266}
267
268
269void icaldirset_free(icalset* s)
270{
271 icaldirset *dset = (icaldirset*)s;
229 char* str; 272 char* str;
230 273
231 icaldirset_unlock(impl->dir); 274 icaldirset_unlock(dset->dir);
232 275
233 if(impl->dir !=0){ 276 if(dset->dir !=0){
234 free(impl->dir); 277 free(dset->dir);
278 dset->dir = 0;
235 } 279 }
236 280
237 if(impl->gauge !=0){ 281 if(dset->gauge !=0){
238 icalcomponent_free(impl->gauge); 282 icalgauge_free(dset->gauge);
283 dset->gauge = 0;
239 } 284 }
240 285
241 if(impl->cluster !=0){ 286 if(dset->cluster !=0){
242 icalfileset_free(impl->cluster); 287 icalcluster_free(dset->cluster);
243 } 288 }
244 289
245 while(impl->directory !=0 && (str=pvl_pop(impl->directory)) != 0){ 290 while(dset->directory !=0 && (str=pvl_pop(dset->directory)) != 0){
246 free(str); 291 free(str);
@@ -248,16 +293,12 @@ void icaldirset_free(icaldirset* s)
248 293
249 if(impl->directory != 0){ 294 if(dset->directory != 0){
250 pvl_free(impl->directory); 295 pvl_free(dset->directory);
296 dset->directory = 0;
251 } 297 }
252 298
253 impl->directory = 0; 299 dset->directory_iterator = 0;
254 impl->directory_iterator = 0; 300 dset->first_component = 0;
255 impl->dir = 0;
256 impl->gauge = 0;
257 impl->first_component = 0;
258
259 free(impl);
260
261} 301}
262 302
303
263/* icaldirset_next_uid_number updates a serial number in the Store 304/* icaldirset_next_uid_number updates a serial number in the Store
@@ -265,5 +306,4 @@ void icaldirset_free(icaldirset* s)
265 306
266int icaldirset_next_uid_number(icaldirset* store) 307int icaldirset_next_uid_number(icaldirset* dset)
267{ 308{
268 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
269 char sequence = 0; 309 char sequence = 0;
@@ -275,12 +315,8 @@ int icaldirset_next_uid_number(icaldirset* store)
275 315
276 icalerror_check_arg_rz( (store!=0), "store"); 316 icalerror_check_arg_rz( (dset!=0), "dset");
277 317
278 sprintf(filename,"%s/%s",impl->dir,"SEQUENCE"); 318 sprintf(filename,"%s/%s",dset->dir,"SEQUENCE");
279 319
280 /* Create the file if it does not exist.*/ 320 /* Create the file if it does not exist.*/
281#ifndef _QTWIN_
282 if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){ 321 if (stat(filename,&sbuf) == -1 || !S_ISREG(sbuf.st_mode)){
283#else
284 if (stat(filename,&sbuf) == -1){
285#endif
286 322
@@ -294,3 +330,2 @@ int icaldirset_next_uid_number(icaldirset* store)
294 } 330 }
295
296 } 331 }
@@ -320,11 +355,9 @@ int icaldirset_next_uid_number(icaldirset* store)
320 } 355 }
321
322} 356}
323 357
324icalerrorenum icaldirset_next_cluster(icaldirset* store) 358icalerrorenum icaldirset_next_cluster(icaldirset* dset)
325{ 359{
326 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
327 char path[ICAL_PATH_MAX]; 360 char path[ICAL_PATH_MAX];
328 361
329 if (impl->directory_iterator == 0){ 362 if (dset->directory_iterator == 0){
330 icalerror_set_errno(ICAL_INTERNAL_ERROR); 363 icalerror_set_errno(ICAL_INTERNAL_ERROR);
@@ -332,9 +365,9 @@ icalerrorenum icaldirset_next_cluster(icaldirset* store)
332 } 365 }
333 impl->directory_iterator = pvl_next(impl->directory_iterator); 366 dset->directory_iterator = pvl_next(dset->directory_iterator);
334 367
335 if (impl->directory_iterator == 0){ 368 if (dset->directory_iterator == 0){
336 /* There are no more clusters */ 369 /* There are no more clusters */
337 if(impl->cluster != 0){ 370 if(dset->cluster != 0){
338 icalfileset_free(impl->cluster); 371 icalcluster_free(dset->cluster);
339 impl->cluster = 0; 372 dset->cluster = 0;
340 } 373 }
@@ -343,7 +376,6 @@ icalerrorenum icaldirset_next_cluster(icaldirset* store)
343 376
344 sprintf(path,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); 377 sprintf(path,"%s/%s", dset->dir,(char*)pvl_data(dset->directory_iterator));
345 378
346 icalfileset_free(impl->cluster); 379 icalcluster_free(dset->cluster);
347 380 dset->cluster = icalfileset_produce_icalcluster(path);
348 impl->cluster = icalfileset_new(path);
349 381
@@ -352,11 +384,10 @@ icalerrorenum icaldirset_next_cluster(icaldirset* store)
352 384
353void icaldirset_add_uid(icaldirset* store, icaldirset* comp) 385static void icaldirset_add_uid(icalcomponent* comp)
354{ 386{
355#ifndef _QTWIN_
356
357 char uidstring[ICAL_PATH_MAX]; 387 char uidstring[ICAL_PATH_MAX];
358 icalproperty *uid; 388 icalproperty *uid;
389#ifndef WIN32
359 struct utsname unamebuf; 390 struct utsname unamebuf;
391#endif
360 392
361 icalerror_check_arg_rv( (store!=0), "store");
362 icalerror_check_arg_rv( (comp!=0), "comp"); 393 icalerror_check_arg_rv( (comp!=0), "comp");
@@ -367,2 +398,3 @@ void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
367 398
399#ifndef WIN32
368 uname(&unamebuf); 400 uname(&unamebuf);
@@ -370,2 +402,5 @@ void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
370 sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename); 402 sprintf(uidstring,"%d-%s",(int)getpid(),unamebuf.nodename);
403#else
404 sprintf(uidstring,"%d-%s",(int)getpid(),"WINDOWS"); /* FIX: There must be an easy get the system name */
405#endif
371 406
@@ -374,7 +409,4 @@ void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
374 } else { 409 } else {
375
376 strcpy(uidstring,icalproperty_get_uid(uid)); 410 strcpy(uidstring,icalproperty_get_uid(uid));
377 } 411 }
378
379#endif
380} 412}
@@ -382,11 +414,12 @@ void icaldirset_add_uid(icaldirset* store, icaldirset* comp)
382 414
383/* This assumes that the top level component is a VCALENDAR, and there 415/**
416 This assumes that the top level component is a VCALENDAR, and there
384 is an inner component of type VEVENT, VTODO or VJOURNAL. The inner 417 is an inner component of type VEVENT, VTODO or VJOURNAL. The inner
385 component must have a DTAMP property */ 418 component must have a DSTAMP property
419*/
386 420
387icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp) 421icalerrorenum icaldirset_add_component(icalset* set, icalcomponent* comp)
388{ 422{
389 struct icaldirset_impl *impl;
390 char clustername[ICAL_PATH_MAX]; 423 char clustername[ICAL_PATH_MAX];
391 icalproperty *dt; 424 icalproperty *dt = 0;
392 icalvalue *v; 425 icalvalue *v;
@@ -395,10 +428,8 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
395 icalcomponent *inner; 428 icalcomponent *inner;
429 icaldirset *dset = (icaldirset*) set;
396 430
397 impl = (struct icaldirset_impl*)store; 431 icalerror_check_arg_rz( (dset!=0), "dset");
398 icalerror_check_arg_rz( (store!=0), "store");
399 icalerror_check_arg_rz( (comp!=0), "comp"); 432 icalerror_check_arg_rz( (comp!=0), "comp");
400 433
401 errno = 0; 434 icaldirset_add_uid(comp);
402
403 icaldirset_add_uid(store,comp);
404 435
@@ -412,9 +443,7 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
412 443
413 if (dt != 0){ 444 if (dt != 0)
414 break; 445 break;
415 } 446 }
416 }
417
418 if (dt == 0){
419 447
448 if (dt == 0) {
420 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT); 449 for(inner = icalcomponent_get_first_component(comp,ICAL_ANY_COMPONENT);
@@ -425,3 +454,3 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
425 454
426 if (dt != 0){ 455 if (dt != 0)
427 break; 456 break;
@@ -430,7 +459,3 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
430 459
431 }
432
433 if (dt == 0){ 460 if (dt == 0){
434
435
436 icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store"); 461 icalerror_warn("The component does not have a DTSTAMP or DTSTART property, so it cannot be added to the store");
@@ -441,19 +466,17 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
441 v = icalproperty_get_value(dt); 466 v = icalproperty_get_value(dt);
442
443 tm = icalvalue_get_datetime(v); 467 tm = icalvalue_get_datetime(v);
444 468
445 snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",impl->dir,tm.year,tm.month); 469 snprintf(clustername,ICAL_PATH_MAX,"%s/%04d%02d",dset->dir, tm.year, tm.month);
446 470
447 /* Load the cluster and insert the object */ 471 /* Load the cluster and insert the object */
448 472 if(dset->cluster != 0 &&
449 if(impl->cluster != 0 && 473 strcmp(clustername,icalcluster_key(dset->cluster)) != 0 ){
450 strcmp(clustername,icalfileset_path(impl->cluster)) != 0 ){ 474 icalcluster_free(dset->cluster);
451 icalfileset_free(impl->cluster); 475 dset->cluster = 0;
452 impl->cluster = 0;
453 } 476 }
454 477
455 if (impl->cluster == 0){ 478 if (dset->cluster == 0){
456 impl->cluster = icalfileset_new(clustername); 479 dset->cluster = icalfileset_produce_icalcluster(clustername);
457 480
458 if (impl->cluster == 0){ 481 if (dset->cluster == 0){
459 error = icalerrno; 482 error = icalerrno;
@@ -468,6 +491,5 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
468 /* Add the component to the cluster */ 491 /* Add the component to the cluster */
469 492 icalcluster_add_component(dset->cluster,comp);
470 icalfileset_add_component(impl->cluster,comp);
471 493
472 icalfileset_mark(impl->cluster); 494 /* icalcluster_mark(impl->cluster); */
473 495
@@ -476,14 +498,13 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
476 498
477/* Remove a component in the current cluster. HACK. This routine is a 499/**
500 Remove a component in the current cluster. HACK. This routine is a
478 "friend" of icalfileset, and breaks its encapsulation. It was 501 "friend" of icalfileset, and breaks its encapsulation. It was
479 either do it this way, or add several layers of interfaces that had 502 either do it this way, or add several layers of interfaces that had
480 no other use. */ 503 no other use.
481icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp) 504 */
482{
483 struct icaldirset_impl *impl = (struct icaldirset_impl*)store;
484
485 struct icalfileset_impl *filesetimpl =
486 (struct icalfileset_impl*)impl->cluster;
487 505
488 icalcomponent *filecomp = filesetimpl->cluster; 506icalerrorenum icaldirset_remove_component(icalset* set, icalcomponent* comp)
507{
508 icaldirset *dset = (icaldirset*)set;
509 icalcomponent *filecomp = icalcluster_get_component(dset->cluster);
489 510
@@ -492,5 +513,5 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
492 513
493 icalerror_check_arg_re((store!=0),"store",ICAL_BADARG_ERROR); 514 icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR);
494 icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR); 515 icalerror_check_arg_re((comp!=0),"comp",ICAL_BADARG_ERROR);
495 icalerror_check_arg_re((impl->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR); 516 icalerror_check_arg_re((dset->cluster!=0),"Cluster pointer",ICAL_USAGE_ERROR);
496 517
@@ -513,13 +534,12 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
513 534
514 icalfileset_remove_component(impl->cluster,comp); 535 icalcluster_remove_component(dset->cluster,comp);
515 536
516 icalfileset_mark(impl->cluster); 537 /* icalcluster_mark(impl->cluster); */
517 538
518 /* If the removal emptied the fileset, get the next fileset */ 539 /* If the removal emptied the fileset, get the next fileset */
519 if( icalfileset_count_components(impl->cluster,ICAL_ANY_COMPONENT)==0){ 540 if( icalcluster_count_components(dset->cluster,ICAL_ANY_COMPONENT)==0){
520 541 icalerrorenum error = icaldirset_next_cluster(dset);
521 icalerrorenum error = icaldirset_next_cluster(store);
522 542
523 if(impl->cluster != 0 && error == ICAL_NO_ERROR){ 543 if(dset->cluster != 0 && error == ICAL_NO_ERROR){
524 icalfileset_get_first_component(impl->cluster); 544 icalcluster_get_first_component(dset->cluster);
525 } else { 545 } else {
@@ -537,3 +557,3 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
537 557
538int icaldirset_count_components(icaldirset* store, 558int icaldirset_count_components(icalset* store,
539 icalcomponent_kind kind) 559 icalcomponent_kind kind)
@@ -541,3 +561,2 @@ int icaldirset_count_components(icaldirset* store,
541 /* HACK, not implemented */ 561 /* HACK, not implemented */
542
543 assert(0); 562 assert(0);
@@ -548,3 +567,3 @@ int icaldirset_count_components(icaldirset* store,
548 567
549icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c) 568icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c)
550{ 569{
@@ -552,2 +571,3 @@ icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c)
552 assert(0); 571 assert(0);
572 return 0;
553} 573}
@@ -555,33 +575,25 @@ icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c)
555 575
556icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid) 576icalcomponent* icaldirset_fetch(icalset* set, const char* uid)
557{ 577{
558 icalcomponent *gauge; 578 icaldirset *dset = (icaldirset*)set;
559 icalcomponent *old_gauge; 579 icalgauge *gauge;
580 icalgauge *old_gauge;
560 icalcomponent *c; 581 icalcomponent *c;
561 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 582 char sql[256];
562 583
563 icalerror_check_arg_rz( (store!=0), "store"); 584 icalerror_check_arg_rz( (set!=0), "set");
564 icalerror_check_arg_rz( (uid!=0), "uid"); 585 icalerror_check_arg_rz( (uid!=0), "uid");
565 586
566 gauge = 587 snprintf(sql, 256, "SELECT * FROM VEVENT WHERE UID = \"%s\"", uid);
567 icalcomponent_vanew( 588
568 ICAL_VCALENDAR_COMPONENT, 589 gauge = icalgauge_new_from_sql(sql, 0);
569 icalcomponent_vanew(
570 ICAL_VEVENT_COMPONENT,
571 icalproperty_vanew_uid(
572 uid,
573 icalparameter_new_xliccomparetype(
574 ICAL_XLICCOMPARETYPE_EQUAL),
575 0),
576 0),
577 0);
578 590
579 old_gauge = impl->gauge; 591 old_gauge = dset->gauge;
580 impl->gauge = gauge; 592 dset->gauge = gauge;
581 593
582 c= icaldirset_get_first_component(store); 594 c= icaldirset_get_first_component(set);
583 595
584 impl->gauge = old_gauge; 596 dset->gauge = old_gauge;
585 597
586 icalcomponent_free(gauge); 598 icalgauge_free(gauge);
587 599
@@ -591,3 +603,3 @@ icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid)
591 603
592int icaldirset_has_uid(icaldirset* store, const char* uid) 604int icaldirset_has_uid(icalset* set, const char* uid)
593{ 605{
@@ -595,3 +607,3 @@ int icaldirset_has_uid(icaldirset* store, const char* uid)
595 607
596 icalerror_check_arg_rz( (store!=0), "store"); 608 icalerror_check_arg_rz( (set!=0), "set");
597 icalerror_check_arg_rz( (uid!=0), "uid"); 609 icalerror_check_arg_rz( (uid!=0), "uid");
@@ -601,3 +613,3 @@ int icaldirset_has_uid(icaldirset* store, const char* uid)
601 around */ 613 around */
602 c = icaldirset_fetch(store,uid); 614 c = icaldirset_fetch(set,uid);
603 615
@@ -608,14 +620,10 @@ int icaldirset_has_uid(icaldirset* store, const char* uid)
608 620
609icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge) 621icalerrorenum icaldirset_select(icalset* set, icalgauge* gauge)
610 { 622{
611 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 623 icaldirset *dset = (icaldirset*)set;
612 624
613 icalerror_check_arg_re( (store!=0), "store",ICAL_BADARG_ERROR); 625 icalerror_check_arg_re( (set!=0), "set",ICAL_BADARG_ERROR);
614 icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR); 626 icalerror_check_arg_re( (gauge!=0), "gauge",ICAL_BADARG_ERROR);
615 627
616 if (!icalcomponent_is_valid(gauge)){ 628 dset->gauge = gauge;
617 return ICAL_BADARG_ERROR;
618 }
619
620 impl->gauge = gauge;
621 629
@@ -625,3 +633,4 @@ icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge)
625 633
626icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old, 634icalerrorenum icaldirset_modify(icalset* set,
635 icalcomponent *old,
627 icalcomponent *new) 636 icalcomponent *new)
@@ -634,3 +643,3 @@ icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
634 643
635void icaldirset_clear(icaldirset* store) 644void icaldirset_clear(icalset* set)
636{ 645{
@@ -642,12 +651,14 @@ void icaldirset_clear(icaldirset* store)
642 651
643icalcomponent* icaldirset_get_current_component(icaldirset* store) 652icalcomponent* icaldirset_get_current_component(icalset* set)
644{ 653{
645 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 654 icaldirset *dset = (icaldirset*)set;
646 655
647 if(impl->cluster == 0){ 656 if (dset->cluster == 0){
648 icaldirset_get_first_component(store); 657 icaldirset_get_first_component(set);
658 }
659 if(dset->cluster == 0){
660 return 0;
649 } 661 }
650 662
651 return icalfileset_get_current_component(impl->cluster); 663 return icalcluster_get_current_component(dset->cluster);
652
653} 664}
@@ -655,5 +666,6 @@ icalcomponent* icaldirset_get_current_component(icaldirset* store)
655 666
656icalcomponent* icaldirset_get_first_component(icaldirset* store) 667icalcomponent* icaldirset_get_first_component(icalset* set)
657{ 668{
658 struct icaldirset_impl *impl = (struct icaldirset_impl*)store; 669 icaldirset *dset = (icaldirset*)set;
670
659 icalerrorenum error; 671 icalerrorenum error;
@@ -661,3 +673,3 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
661 673
662 error = icaldirset_read_directory(impl); 674 error = icaldirset_read_directory(dset);
663 675
@@ -668,5 +680,5 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
668 680
669 impl->directory_iterator = pvl_head(impl->directory); 681 dset->directory_iterator = pvl_head(dset->directory);
670 682
671 if (impl->directory_iterator == 0){ 683 if (dset->directory_iterator == 0){
672 icalerror_set_errno(error); 684 icalerror_set_errno(error);
@@ -675,3 +687,5 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
675 687
676 snprintf(path,ICAL_PATH_MAX,"%s/%s",impl->dir,(char*)pvl_data(impl->directory_iterator)); 688 snprintf(path,ICAL_PATH_MAX,"%s/%s",
689 dset->dir,
690 (char*)pvl_data(dset->directory_iterator));
677 691
@@ -680,11 +694,11 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
680 694
681 if(impl->cluster != 0 && strcmp(path,icalfileset_path(impl->cluster)) != 0 ){ 695 if(dset->cluster != 0 && strcmp(path,icalcluster_key(dset->cluster)) != 0 ){
682 icalfileset_free(impl->cluster); 696 icalcluster_free(dset->cluster);
683 impl->cluster = 0; 697 dset->cluster = 0;
684 } 698 }
685 699
686 if (impl->cluster == 0){ 700 if (dset->cluster == 0){
687 impl->cluster = icalfileset_new(path); 701 dset->cluster = icalfileset_produce_icalcluster(path);
688 702
689 if (impl->cluster == 0){ 703 if (dset->cluster == 0){
690 error = icalerrno; 704 error = icalerrno;
@@ -698,10 +712,11 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
698 712
699 impl->first_component = 1; 713 dset->first_component = 1;
700 714
701 return icaldirset_get_next_component(store); 715 return icaldirset_get_next_component(set);
702} 716}
703 717
704icalcomponent* icaldirset_get_next_component(icaldirset* store) 718
719icalcomponent* icaldirset_get_next_component(icalset* set)
705{ 720{
706 struct icaldirset_impl *impl; 721 icaldirset *dset = (icaldirset*)set;
707 icalcomponent *c; 722 icalcomponent *c;
@@ -709,8 +724,6 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
709 724
710 icalerror_check_arg_rz( (store!=0), "store"); 725 icalerror_check_arg_rz( (set!=0), "set");
711
712 impl = (struct icaldirset_impl*)store;
713 726
714 if(impl->cluster == 0){
715 727
728 if(dset->cluster == 0){
716 icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first"); 729 icalerror_warn("icaldirset_get_next_component called with a NULL cluster (Caller must call icaldirset_get_first_component first");
@@ -722,15 +735,14 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
722 /* Set the component iterator for the following for loop */ 735 /* Set the component iterator for the following for loop */
723 if (impl->first_component == 1){ 736 if (dset->first_component == 1){
724 icalfileset_get_first_component(impl->cluster); 737 icalcluster_get_first_component(dset->cluster);
725 impl->first_component = 0; 738 dset->first_component = 0;
726 } else { 739 } else {
727 icalfileset_get_next_component(impl->cluster); 740 icalcluster_get_next_component(dset->cluster);
728 } 741 }
729 742
730
731 while(1){ 743 while(1){
732 /* Iterate through all of the objects in the cluster*/ 744 /* Iterate through all of the objects in the cluster*/
733 for( c = icalfileset_get_current_component(impl->cluster); 745 for( c = icalcluster_get_current_component(dset->cluster);
734 c != 0; 746 c != 0;
735 c = icalfileset_get_next_component(impl->cluster)){ 747 c = icalcluster_get_next_component(dset->cluster)){
736 748
@@ -739,9 +751,6 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
739 751
740#if 0 /* HACK */ 752 if (dset->gauge != 0 && icalgauge_compare(dset->gauge,c) == 0){
741 if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){
742 continue; 753 continue;
743 } 754 }
744#else 755
745 assert(0); /* icalgauge_test needs to be fixed */
746#endif
747 /* Either there is no gauge, or the component passed the 756 /* Either there is no gauge, or the component passed the
@@ -755,5 +764,5 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
755 764
756 error = icaldirset_next_cluster(store); 765 error = icaldirset_next_cluster(dset);
757 766
758 if(impl->cluster == 0 || error != ICAL_NO_ERROR){ 767 if(dset->cluster == 0 || error != ICAL_NO_ERROR){
759 /* No more clusters */ 768 /* No more clusters */
@@ -761,3 +770,3 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
761 } else { 770 } else {
762 c = icalfileset_get_first_component(impl->cluster); 771 c = icalcluster_get_first_component(dset->cluster);
763 772
@@ -771,7 +780,26 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
771 780
772 781icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
782{
783 icalsetiter itr = icalsetiter_null;
784 icaldirset *fset = (icaldirset*) set;
773 785
786 icalerror_check_arg_re((fset!=0), "set", icalsetiter_null);
774 787
788 itr.iter.kind = kind;
789 itr.gauge = gauge;
775 790
791 /* TO BE IMPLEMENTED */
792 return icalsetiter_null;
793}
776 794
777 795icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i)
796{
797 /* TO BE IMPLEMENTED */
798 return NULL;
799}
800
801icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i)
802{
803 /* TO BE IMPLEMENTED */
804 return NULL;
805}
diff --git a/libical/src/libicalss/icaldirset.h b/libical/src/libicalss/icaldirset.h
index 7d205ec..a2d577d 100644
--- a/libical/src/libicalss/icaldirset.h
+++ b/libical/src/libicalss/icaldirset.h
@@ -32,2 +32,5 @@
32#include "ical.h" 32#include "ical.h"
33#include "icalset.h"
34#include "icalcluster.h"
35#include "icalgauge.h"
33 36
@@ -36,10 +39,14 @@
36 39
37typedef void icaldirset; 40typedef struct icaldirset_impl icaldirset;
38 41
42icalset* icaldirset_new(const char* path);
39 43
40icaldirset* icaldirset_new(const char* path); 44icalset* icaldirset_new_reader(const char* path);
45icalset* icaldirset_new_writer(const char* path);
41 46
42void icaldirset_free(icaldirset* store);
43 47
44const char* icaldirset_path(icaldirset* store); 48icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
49void icaldirset_free(icalset* set);
50
51const char* icaldirset_path(icalset* set);
45 52
@@ -47,9 +54,9 @@ const char* icaldirset_path(icaldirset* store);
47 is freed. Commit writes to disk immediately*/ 54 is freed. Commit writes to disk immediately*/
48void icaldirset_mark(icaldirset* store); 55void icaldirset_mark(icalset* set);
49icalerrorenum icaldirset_commit(icaldirset* store); 56icalerrorenum icaldirset_commit(icalset* set);
50 57
51icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); 58icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
52icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); 59icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
53 60
54int icaldirset_count_components(icaldirset* store, 61int icaldirset_count_components(icalset* store,
55 icalcomponent_kind kind); 62 icalcomponent_kind kind);
@@ -58,9 +65,9 @@ int icaldirset_count_components(icaldirset* store,
58 that pass the gauge. _clear removes the gauge. */ 65 that pass the gauge. _clear removes the gauge. */
59icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); 66icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
60void icaldirset_clear(icaldirset* store); 67void icaldirset_clear(icalset* store);
61 68
62/* Get a component by uid */ 69/* Get a component by uid */
63icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); 70icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
64int icaldirset_has_uid(icaldirset* store, const char* uid); 71int icaldirset_has_uid(icalset* store, const char* uid);
65icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); 72icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c);
66 73
@@ -68,11 +75,20 @@ icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c);
68 the currently selected components. */ 75 the currently selected components. */
69icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, 76icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
70 icalcomponent *newc); 77 icalcomponent *newc);
71 78
72/* Iterate through the components. If a guage has been defined, these 79/* Iterate through the components. If a gauge has been defined, these
73 will skip over components that do not pass the gauge */ 80 will skip over components that do not pass the gauge */
74 81
75icalcomponent* icaldirset_get_current_component(icaldirset* store); 82icalcomponent* icaldirset_get_current_component(icalset* store);
76icalcomponent* icaldirset_get_first_component(icaldirset* store); 83icalcomponent* icaldirset_get_first_component(icalset* store);
77icalcomponent* icaldirset_get_next_component(icaldirset* store); 84icalcomponent* icaldirset_get_next_component(icalset* store);
85
86/* External iterator for thread safety */
87icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
88icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
89icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
90
91typedef struct icaldirset_options {
92 int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
93} icaldirset_options;
78 94
diff --git a/libical/src/libicalss/icaldirsetimpl.h b/libical/src/libicalss/icaldirsetimpl.h
index 0e69ba2..332a369 100644
--- a/libical/src/libicalss/icaldirsetimpl.h
+++ b/libical/src/libicalss/icaldirsetimpl.h
@@ -32,2 +32,4 @@
32 32
33#include "icalcluster.h"
34
33/* This definition is in its own file so it can be kept out of the 35/* This definition is in its own file so it can be kept out of the
@@ -35,13 +37,12 @@
35 37
36#define ICALDIRSET_ID "dset"
37
38struct icaldirset_impl 38struct icaldirset_impl
39{ 39{
40 char id[5]; /* "dset" */ 40 icalset super; /**< parent class */
41 char* dir; 41 char* dir; /**< directory containing ics files */
42 icalcomponent* gauge; 42 icaldirset_options options;/**< copy of options passed to icalset_new() */
43 icaldirset* cluster; 43 icalcluster* cluster; /**< cluster containing data */
44 int first_component; 44 icalgauge* gauge; /**< gauge for filtering out data */
45 pvl_list directory; 45 int first_component; /**< ??? */
46 pvl_elem directory_iterator; 46 pvl_list directory; /**< ??? */
47 pvl_elem directory_iterator;/**< ??? */
47}; 48};
diff --git a/libical/src/libicalss/icalfileset.c b/libical/src/libicalss/icalfileset.c
index 943071d..3ae6c54 100644
--- a/libical/src/libicalss/icalfileset.c
+++ b/libical/src/libicalss/icalfileset.c
@@ -32,27 +32,37 @@
32 32
33#include "icalfileset.h"
34#include "icalgauge.h"
33#include <errno.h> 35#include <errno.h>
34 36#include <sys/stat.h> /* for stat */
37#ifndef WIN32
38#include <unistd.h> /* for stat, getpid */
39#else
40#include <io.h>
41#include <share.h>
42#endif
35#include <stdlib.h> 43#include <stdlib.h>
36#include <stdio.h>
37#include <string.h> 44#include <string.h>
45#include <fcntl.h> /* for fcntl */
46#include "icalfilesetimpl.h"
47#include "icalclusterimpl.h"
38 48
39#include <fcntl.h> /* For open() flags and mode */ 49#ifdef WIN32
40#include <sys/types.h> /* For open() flags and mode */ 50 #define snprintf_snprintf
41#include <sys/stat.h> /* For open() flags and mode */ 51 #define strcasecmpstricmp
42 52
43#include "icalfileset.h" 53#define _S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
44#include "icalfilesetimpl.h"
45 54
46// Eugen C. <eug@thekompany.com> 55#define S_ISDIR(mode) _S_ISTYPE((mode), _S_IFDIR)
47#include <defines.h> 56#define S_ISREG(mode) _S_ISTYPE((mode), _S_IFREG)
48// 57#endif
49 58
50int snprintf(char *str, size_t n, char const *fmt, ...); 59extern int errno;
51 60
52//extern int errno; 61/** Default options used when NULL is passed to icalset_new() **/
62icalfileset_options icalfileset_options_default = {O_RDWR|O_CREAT, 0644, 0, 0};
53 63
54int icalfileset_lock(icalfileset *cluster); 64int icalfileset_lock(icalfileset *set);
55int icalfileset_unlock(icalfileset *cluster); 65int icalfileset_unlock(icalfileset *set);
56icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode); 66icalerrorenum icalfileset_read_file(icalfileset* set, mode_t mode);
57int icalfileset_filesize(icalfileset* cluster); 67int icalfileset_filesize(icalfileset* set);
58 68
@@ -60,59 +70,64 @@ icalerrorenum icalfileset_create_cluster(const char *path);
60 70
61icalfileset* icalfileset_new_impl() 71icalset* icalfileset_new(const char* path)
62{ 72{
63 struct icalfileset_impl* impl; 73 return icalset_new(ICAL_FILE_SET, path, &icalfileset_options_default);
64
65 if ( ( impl = (struct icalfileset_impl*)
66 malloc(sizeof(struct icalfileset_impl))) == 0) {
67 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
68 errno = ENOMEM;
69 return 0;
70 }
71
72 memset(impl,0,sizeof(struct icalfileset_impl));
73
74 strcpy(impl->id,ICALFILESET_ID);
75
76 return impl;
77} 74}
78 75
79 76icalset* icalfileset_new_reader(const char* path)
80icalfileset* icalfileset_new(const char* path)
81{ 77{
82 return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664); 78 icalfileset_options reader_options = icalfileset_options_default;
79 reader_options.flags = O_RDONLY;
80
81 return icalset_new(ICAL_FILE_SET, path, &reader_options);
83} 82}
84 83
85icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode) 84icalset* icalfileset_new_writer(const char* path)
86{ 85{
87 struct icalfileset_impl *impl = icalfileset_new_impl(); 86 icalfileset_options writer_options = icalfileset_options_default;
88 struct icaltimetype tt; 87 writer_options.flags = O_RDONLY;
89 off_t cluster_file_size;
90 88
91 memset(&tt,0,sizeof(struct icaltimetype)); 89 return icalset_new(ICAL_FILE_SET, path, &writer_options);
90}
92 91
93 icalerror_clear_errno(); 92icalset* icalfileset_init(icalset *set, const char* path, void* options_in)
94 icalerror_check_arg_rz( (path!=0), "path"); 93{
94 icalfileset_options *options = (options_in) ? options_in : &icalfileset_options_default;
95 icalfileset *fset = (icalfileset*) set;
96 int flags;
97 mode_t mode;
98 off_t cluster_file_size;
95 99
96 if (impl == 0){ 100 icalerror_clear_errno();
97 return 0; 101 icalerror_check_arg_rz( (path!=0), "path");
98 } 102 icalerror_check_arg_rz( (fset!=0), "fset");
99 103
100 impl->path = strdup(path); 104 fset->path = strdup(path);
105 fset->options = *options;
101 106
102 cluster_file_size = icalfileset_filesize(impl); 107 flags = options->flags;
103 108 mode = options->mode;
104 if(cluster_file_size < 0){ 109
105 icalfileset_free(impl); 110 cluster_file_size = icalfileset_filesize(fset);
106 return 0; 111
107 } 112 if(cluster_file_size < 0){
113 icalfileset_free(set);
114 return 0;
115 }
108 116
109 impl->fd = open(impl->path,flags, mode); 117#ifndef WIN32
118 fset->fd = open(fset->path, flags, mode);
119#else
120 fset->fd = open(fset->path, flags, mode);
121 /* fset->fd = sopen(fset->path,flags, _SH_DENYWR, _S_IREAD | _S_IWRITE); */
122#endif
110 123
111 if (impl->fd < 0){ 124 if (fset->fd < 0){
112 icalerror_set_errno(ICAL_FILE_ERROR); 125 icalerror_set_errno(ICAL_FILE_ERROR);
113 icalfileset_free(impl); 126 icalfileset_free(set);
114 return 0; 127 return 0;
115 } 128 }
116 129
117 icalfileset_lock(impl); 130#ifndef WIN32
131 icalfileset_lock(fset);
132#endif
118 133
@@ -120,5 +135,5 @@ icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
120 icalerrorenum error; 135 icalerrorenum error;
121 if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){ 136 if((error = icalfileset_read_file(fset,mode))!= ICAL_NO_ERROR){
122 icalfileset_free(impl); 137 icalfileset_free(set);
123 return 0; 138 return 0;
124 } 139 }
@@ -126,12 +141,42 @@ icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
126 141
127 if(impl->cluster == 0){ 142 if (options->cluster) {
128 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); 143 fset->cluster = icalcomponent_new_clone(icalcluster_get_component(options->cluster));
129 } 144 fset->changed = 1;
145 }
146
147 if (fset->cluster == 0) {
148 fset->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
149 }
150
151 return set;
152}
153
154
155icalcluster* icalfileset_produce_icalcluster(const char *path) {
156 icalset *fileset;
157 icalcluster *ret;
158
159 int errstate = icalerror_errors_are_fatal;
160 icalerror_errors_are_fatal = 0;
130 161
131 return impl; 162 fileset = icalfileset_new_reader(path);
163
164
165 if (fileset == 0 && icalerrno == ICAL_FILE_ERROR) {
166 /* file does not exist */
167 ret = icalcluster_new(path, NULL);
168 } else {
169 ret = icalcluster_new(path, ((icalfileset*)fileset)->cluster);
170 icalfileset_free(fileset);
171 }
172
173 icalerror_errors_are_fatal = errstate;
174 icalerror_set_errno(ICAL_NO_ERROR);
175 return ret;
132} 176}
133 177
178
179
134char* icalfileset_read_from_file(char *s, size_t size, void *d) 180char* icalfileset_read_from_file(char *s, size_t size, void *d)
135{ 181{
136
137 char* p = s; 182 char* p = s;
@@ -160,25 +205,23 @@ char* icalfileset_read_from_file(char *s, size_t size, void *d)
160 205
161icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode) 206icalerrorenum icalfileset_read_file(icalfileset* set,mode_t mode)
162{ 207{
163
164 icalparser *parser; 208 icalparser *parser;
165 209
166 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
167
168 parser = icalparser_new(); 210 parser = icalparser_new();
169 icalparser_set_gen_data(parser,(void*)impl->fd); 211
170 impl->cluster = icalparser_parse(parser,icalfileset_read_from_file); 212 icalparser_set_gen_data(parser,(void*)set->fd);
213 set->cluster = icalparser_parse(parser,icalfileset_read_from_file);
171 icalparser_free(parser); 214 icalparser_free(parser);
172 215
173 if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){ 216 if (set->cluster == 0 || icalerrno != ICAL_NO_ERROR){
174 icalerror_set_errno(ICAL_PARSE_ERROR); 217 icalerror_set_errno(ICAL_PARSE_ERROR);
175 return ICAL_PARSE_ERROR; 218 /*return ICAL_PARSE_ERROR;*/
176 } 219 }
177 220
178 if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){ 221 if (icalcomponent_isa(set->cluster) != ICAL_XROOT_COMPONENT){
179 /* The parser got a single component, so it did not put it in 222 /* The parser got a single component, so it did not put it in
180 an XROOT. */ 223 an XROOT. */
181 icalcomponent *cl = impl->cluster; 224 icalcomponent *cl = set->cluster;
182 impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT); 225 set->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
183 icalcomponent_add_component(impl->cluster,cl); 226 icalcomponent_add_component(set->cluster,cl);
184 } 227 }
@@ -186,12 +229,10 @@ icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode)
186 return ICAL_NO_ERROR; 229 return ICAL_NO_ERROR;
187
188} 230}
189 231
190int icalfileset_filesize(icalfileset* cluster) 232int icalfileset_filesize(icalfileset* fset)
191{ 233{
192 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
193 int cluster_file_size; 234 int cluster_file_size;
194 struct stat sbuf; 235 struct stat sbuf;
195 236
196 if (stat(impl->path,&sbuf) != 0){ 237 if (stat(fset->path,&sbuf) != 0){
197 238
@@ -211,3 +252,2 @@ int icalfileset_filesize(icalfileset* cluster)
211 252
212#ifndef _QTWIN_
213 if (!S_ISREG(sbuf.st_mode)){ 253 if (!S_ISREG(sbuf.st_mode)){
@@ -219,7 +259,3 @@ int icalfileset_filesize(icalfileset* cluster)
219 return sbuf.st_size; 259 return sbuf.st_size;
220 } 260 }
221#else
222 return sbuf.st_size;
223#endif
224
225 } 261 }
@@ -229,34 +265,35 @@ int icalfileset_filesize(icalfileset* cluster)
229 265
230void icalfileset_free(icalfileset* cluster) 266void icalfileset_free(icalset* set)
231{ 267{
232 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 268 icalfileset *fset = (icalfileset*) set;
233 269
234 icalerror_check_arg_rv((cluster!=0),"cluster"); 270 icalerror_check_arg_rv((set!=0),"set");
235 271
236 if (impl->cluster != 0){ 272 if (fset->cluster != 0){
237 icalfileset_commit(cluster); 273 icalfileset_commit(set);
238 icalcomponent_free(impl->cluster); 274 icalcomponent_free(fset->cluster);
239 impl->cluster=0; 275 fset->cluster=0;
240 } 276 }
241 277
242 if(impl->fd > 0){ 278 if (fset->gauge != 0){
243 icalfileset_unlock(impl); 279 icalgauge_free(fset->gauge);
244 close(impl->fd); 280 fset->gauge=0;
245 impl->fd = -1;
246 } 281 }
247 282
248 if(impl->path != 0){ 283 if(fset->fd > 0){
249 free(impl->path); 284 icalfileset_unlock(fset);
250 impl->path = 0; 285 close(fset->fd);
286 fset->fd = -1;
251 } 287 }
252 288
253 free(impl); 289 if(fset->path != 0){
290 free(fset->path);
291 fset->path = 0;
292 }
254} 293}
255 294
256const char* icalfileset_path(icalfileset* cluster) 295const char* icalfileset_path(icalset* set) {
257{ 296 icalerror_check_arg_rz((set!=0),"set");
258 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
259 icalerror_check_arg_rz((cluster!=0),"cluster");
260 297
261 return impl->path; 298 return ((icalfileset*)set)->path;
262} 299}
@@ -264,6 +301,5 @@ const char* icalfileset_path(icalfileset* cluster)
264 301
265int icalfileset_lock(icalfileset *cluster) 302int icalfileset_lock(icalfileset *set)
266{ 303{
267#ifndef _WIN32 304#ifndef WIN32
268 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
269 struct flock lock; 305 struct flock lock;
@@ -271,3 +307,3 @@ int icalfileset_lock(icalfileset *cluster)
271 307
272 icalerror_check_arg_rz((impl->fd>0),"impl->fd"); 308 icalerror_check_arg_rz((set->fd>0),"set->fd");
273 errno = 0; 309 errno = 0;
@@ -278,3 +314,3 @@ int icalfileset_lock(icalfileset *cluster)
278 314
279 rtrn = fcntl(impl->fd, F_SETLKW, &lock); 315 rtrn = fcntl(set->fd, F_SETLKW, &lock);
280 316
@@ -282,3 +318,3 @@ int icalfileset_lock(icalfileset *cluster)
282#else 318#else
283 return -1; 319 return 0;
284#endif 320#endif
@@ -286,8 +322,7 @@ int icalfileset_lock(icalfileset *cluster)
286 322
287int icalfileset_unlock(icalfileset *cluster) 323int icalfileset_unlock(icalfileset *set)
288{ 324{
289#ifndef _WIN32 325#ifndef WIN32
290 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
291 struct flock lock; 326 struct flock lock;
292 icalerror_check_arg_rz((impl->fd>0),"impl->fd"); 327 icalerror_check_arg_rz((set->fd>0),"set->fd");
293 328
@@ -298,5 +333,5 @@ int icalfileset_unlock(icalfileset *cluster)
298 333
299 return (fcntl(impl->fd, F_UNLCK, &lock)); 334 return (fcntl(set->fd, F_UNLCK, &lock));
300#else 335#else
301 return -1; 336 return 0;
302#endif 337#endif
@@ -304,9 +339,3 @@ int icalfileset_unlock(icalfileset *cluster)
304 339
305#ifdef ICAL_SAFESAVES 340icalerrorenum icalfileset_commit(icalset* set)
306int icalfileset_safe_saves=1;
307#else
308int icalfileset_safe_saves=0;
309#endif
310
311icalerrorenum icalfileset_commit(icalfileset* cluster)
312{ 341{
@@ -316,11 +345,10 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
316 off_t write_size=0; 345 off_t write_size=0;
346 icalfileset *fset = (icalfileset*) set;
347
348 icalerror_check_arg_re((fset!=0),"set",ICAL_BADARG_ERROR);
317 349
318 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 350 icalerror_check_arg_re((fset->fd>0),"set->fd is invalid",
319
320 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
321
322 icalerror_check_arg_re((impl->fd>0),"impl->fd is invalid",
323 ICAL_INTERNAL_ERROR) ; 351 ICAL_INTERNAL_ERROR) ;
324 352
325 if (impl->changed == 0 ){ 353 if (fset->changed == 0 ){
326 return ICAL_NO_ERROR; 354 return ICAL_NO_ERROR;
@@ -328,4 +356,8 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
328 356
329 if(icalfileset_safe_saves == 1){ 357 if (fset->options.safe_saves == 1) {
330 snprintf(tmp,ICAL_PATH_MAX,"cp %s %s.bak",impl->path,impl->path); 358#ifndef WIN32
359 snprintf(tmp,ICAL_PATH_MAX,"cp '%s' '%s.bak'",fset->path, fset->path);
360#else
361 snprintf(tmp,ICAL_PATH_MAX,"copy %s %s.bak", fset->path, fset->path);
362#endif
331 363
@@ -337,3 +369,3 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
337 369
338 if(lseek(impl->fd,SEEK_SET,0) < 0){ 370 if(lseek(fset->fd, 0, SEEK_SET) < 0){
339 icalerror_set_errno(ICAL_FILE_ERROR); 371 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -342,5 +374,5 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
342 374
343 for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT); 375 for(c = icalcomponent_get_first_component(fset->cluster,ICAL_ANY_COMPONENT);
344 c != 0; 376 c != 0;
345 c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){ 377 c = icalcomponent_get_next_component(fset->cluster,ICAL_ANY_COMPONENT)){
346 int sz; 378 int sz;
@@ -349,3 +381,3 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
349 381
350 sz=write(impl->fd,str,strlen(str)); 382 sz=write(fset->fd,str,strlen(str));
351 383
@@ -360,8 +392,10 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
360 392
361 impl->changed = 0; 393 fset->changed = 0;
362 394
363#ifndef _QTWIN_ 395#ifndef WIN32
364 if(ftruncate(impl->fd,write_size) < 0){ 396 if(ftruncate(fset->fd,write_size) < 0){
365 return ICAL_FILE_ERROR; 397 return ICAL_FILE_ERROR;
366 } 398 }
399#else
400 chsize( fset->fd, tell( fset->fd ) );
367#endif 401#endif
@@ -369,21 +403,15 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
369 return ICAL_NO_ERROR; 403 return ICAL_NO_ERROR;
370
371} 404}
372 405
373void icalfileset_mark(icalfileset* cluster){ 406void icalfileset_mark(icalset* set) {
374 407 icalerror_check_arg_rv((set!=0),"set");
375 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
376
377 icalerror_check_arg_rv((impl!=0),"cluster");
378
379 impl->changed = 1;
380 408
409 ((icalfileset*)set)->changed = 1;
381} 410}
382 411
383icalcomponent* icalfileset_get_component(icalfileset* cluster){ 412icalcomponent* icalfileset_get_component(icalset* set){
384 struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster; 413 icalfileset *fset = (icalfileset*) set;
414 icalerror_check_arg_rz((set!=0),"set");
385 415
386 icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR); 416 return fset->cluster;
387
388 return impl->cluster;
389} 417}
@@ -391,31 +419,30 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster){
391 419
392/* manipulate the components in the cluster */ 420/* manipulate the components in the set */
393 421
394icalerrorenum icalfileset_add_component(icalfileset *cluster, 422icalerrorenum icalfileset_add_component(icalset *set,
395 icalcomponent* child) 423 icalcomponent* child)
396{ 424{
397 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 425 icalfileset *fset = (icalfileset*) set;
398 426
399 icalerror_check_arg_re((cluster!=0),"cluster", ICAL_BADARG_ERROR); 427 icalerror_check_arg_re((set!=0),"set", ICAL_BADARG_ERROR);
400 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); 428 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
401 429
402 icalcomponent_add_component(impl->cluster,child); 430 icalcomponent_add_component(fset->cluster,child);
403 431
404 icalfileset_mark(cluster); 432 icalfileset_mark(set);
405 433
406 return ICAL_NO_ERROR; 434 return ICAL_NO_ERROR;
407
408} 435}
409 436
410icalerrorenum icalfileset_remove_component(icalfileset *cluster, 437icalerrorenum icalfileset_remove_component(icalset *set,
411 icalcomponent* child) 438 icalcomponent* child)
412{ 439{
413 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 440 icalfileset *fset = (icalfileset*) set;
414 441
415 icalerror_check_arg_re((cluster!=0),"cluster",ICAL_BADARG_ERROR); 442 icalerror_check_arg_re((set!=0),"set",ICAL_BADARG_ERROR);
416 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR); 443 icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
417 444
418 icalcomponent_remove_component(impl->cluster,child); 445 icalcomponent_remove_component(fset->cluster,child);
419 446
420 icalfileset_mark(cluster); 447 icalfileset_mark(set);
421 448
@@ -424,8 +451,8 @@ icalerrorenum icalfileset_remove_component(icalfileset *cluster,
424 451
425int icalfileset_count_components(icalfileset *cluster, 452int icalfileset_count_components(icalset *set,
426 icalcomponent_kind kind) 453 icalcomponent_kind kind)
427{ 454{
428 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 455 icalfileset *fset = (icalfileset*) set;
429 456
430 if(cluster == 0){ 457 if (set == 0){
431 icalerror_set_errno(ICAL_BADARG_ERROR); 458 icalerror_set_errno(ICAL_BADARG_ERROR);
@@ -434,12 +461,12 @@ int icalfileset_count_components(icalfileset *cluster,
434 461
435 return icalcomponent_count_components(impl->cluster,kind); 462 return icalcomponent_count_components(fset->cluster,kind);
436} 463}
437 464
438icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge) 465icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge)
439{ 466{
440 struct icalfileset_impl* impl = (struct icalfileset_impl*)set; 467 icalfileset *fset = (icalfileset*) set;
441 468
442 icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR); 469 icalerror_check_arg_re(gauge!=0,"gauge",ICAL_BADARG_ERROR);
443 470
444 impl->gauge = gauge; 471 fset->gauge = gauge;
445 472
@@ -448,37 +475,46 @@ icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge)
448 475
449void icalfileset_clear(icalfileset* gauge) 476void icalfileset_clear(icalset* set)
450{ 477{
451 struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge; 478 icalfileset *fset = (icalfileset*) set;
452 479
453 impl->gauge = 0; 480 icalerror_check_arg_rv(set!=0,"set");
454 481
482 fset->gauge = 0;
455} 483}
456 484
457icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid) 485icalcomponent* icalfileset_fetch(icalset* set,const char* uid)
458{ 486{
487 icalfileset *fset = (icalfileset*) set;
459 icalcompiter i; 488 icalcompiter i;
460 struct icalfileset_impl* impl = (struct icalfileset_impl*)store; 489
490 icalerror_check_arg_rz(set!=0,"set");
461 491
462 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); 492 for(i = icalcomponent_begin_component(fset->cluster,ICAL_ANY_COMPONENT);
463 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 493 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
464 494
465 icalcomponent *this = icalcompiter_deref(&i); 495 icalcomponent *this = icalcompiter_deref(&i);
466 icalcomponent *inner = icalcomponent_get_first_real_component(this); 496 icalcomponent *inner;
467 icalcomponent *p; 497 icalproperty *p;
468 const char *this_uid; 498 const char *this_uid;
469 499
470 if(inner != 0){ 500 for(inner = icalcomponent_get_first_component(this,ICAL_ANY_COMPONENT);
471 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); 501 inner != 0;
472 this_uid = icalproperty_get_uid(p); 502 inner = icalcomponent_get_next_component(this,ICAL_ANY_COMPONENT)){
473 503
474 if(this_uid==0){ 504 p = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
475 icalerror_warn("icalfileset_fetch found a component with no UID"); 505 if ( p )
476 continue; 506 {
477 } 507 this_uid = icalproperty_get_uid(p);
478 508
479 if (strcmp(uid,this_uid)==0){ 509 if(this_uid==0){
480 return this; 510 icalerror_warn("icalfileset_fetch found a component with no UID");
481 } 511 continue;
512 }
513
514 if (strcmp(uid,this_uid)==0){
515 return this;
516 }
517 }
518 }
482 } 519 }
483 }
484 520
@@ -487,3 +523,3 @@ icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid)
487 523
488int icalfileset_has_uid(icalfileset* store,const char* uid) 524int icalfileset_has_uid(icalset* set,const char* uid)
489{ 525{
@@ -510,8 +546,7 @@ void icalfileset_id_free(struct icalfileset_id *id)
510 } 546 }
511
512} 547}
513 548
549
514struct icalfileset_id icalfileset_get_id(icalcomponent* comp) 550struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
515{ 551{
516
517 icalcomponent *inner; 552 icalcomponent *inner;
@@ -551,2 +586,3 @@ struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
551 586
587
552/* Find the component that is related to the given 588/* Find the component that is related to the given
@@ -554,5 +590,5 @@ struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
554 RECURRENCE-ID */ 590 RECURRENCE-ID */
555icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp) 591icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *comp)
556{ 592{
557 struct icalfileset_impl* impl = (struct icalfileset_impl*)set; 593 icalfileset *fset = (icalfileset*) set;
558 icalcompiter i; 594 icalcompiter i;
@@ -563,3 +599,3 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
563 599
564 for(i = icalcomponent_begin_component(impl->cluster,ICAL_ANY_COMPONENT); 600 for(i = icalcomponent_begin_component(fset->cluster,ICAL_ANY_COMPONENT);
565 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 601 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
@@ -591,5 +627,7 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
591 627
592icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old, 628icalerrorenum icalfileset_modify(icalset* set, icalcomponent *old,
593 icalcomponent *new) 629 icalcomponent *new)
594{ 630{
631 icalfileset *fset = (icalfileset*) set;
632
595 assert(0); /* HACK, not implemented */ 633 assert(0); /* HACK, not implemented */
@@ -600,9 +638,9 @@ icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old,
600/* Iterate through components */ 638/* Iterate through components */
601icalcomponent* icalfileset_get_current_component (icalfileset* cluster) 639icalcomponent* icalfileset_get_current_component (icalset* set)
602{ 640{
603 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 641 icalfileset *fset = (icalfileset*) set;
604 642
605 icalerror_check_arg_rz((cluster!=0),"cluster"); 643 icalerror_check_arg_rz((set!=0),"set");
606 644
607 return icalcomponent_get_current_component(impl->cluster); 645 return icalcomponent_get_current_component(fset->cluster);
608} 646}
@@ -610,8 +648,8 @@ icalcomponent* icalfileset_get_current_component (icalfileset* cluster)
610 648
611icalcomponent* icalfileset_get_first_component(icalfileset* cluster) 649icalcomponent* icalfileset_get_first_component(icalset* set)
612{ 650{
613 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
614 icalcomponent *c=0; 651 icalcomponent *c=0;
652 icalfileset *fset = (icalfileset*) set;
615 653
616 icalerror_check_arg_rz((cluster!=0),"cluster"); 654 icalerror_check_arg_rz((set!=0),"set");
617 655
@@ -619,6 +657,6 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
619 if (c == 0){ 657 if (c == 0){
620 c = icalcomponent_get_first_component(impl->cluster, 658 c = icalcomponent_get_first_component(fset->cluster,
621 ICAL_ANY_COMPONENT); 659 ICAL_ANY_COMPONENT);
622 } else { 660 } else {
623 c = icalcomponent_get_next_component(impl->cluster, 661 c = icalcomponent_get_next_component(fset->cluster,
624 ICAL_ANY_COMPONENT); 662 ICAL_ANY_COMPONENT);
@@ -626,4 +664,4 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
626 664
627 if(c != 0 && (impl->gauge == 0 || 665 if(c != 0 && (fset->gauge == 0 ||
628 icalgauge_compare(impl->gauge,c) == 1)){ 666 icalgauge_compare(fset->gauge, c) == 1)){
629 return c; 667 return c;
@@ -637,15 +675,15 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
637 675
638icalcomponent* icalfileset_get_next_component(icalfileset* cluster) 676icalcomponent* icalfileset_get_next_component(icalset* set)
639{ 677{
640 struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster; 678 icalfileset *fset = (icalfileset*) set;
641 icalcomponent *c; 679 icalcomponent *c;
642 680
643 icalerror_check_arg_rz((cluster!=0),"cluster"); 681 icalerror_check_arg_rz((set!=0),"set");
644 682
645 do { 683 do {
646 c = icalcomponent_get_next_component(impl->cluster, 684 c = icalcomponent_get_next_component(fset->cluster,
647 ICAL_ANY_COMPONENT); 685 ICAL_ANY_COMPONENT);
648 686
649 if(c != 0 && (impl->gauge == 0 || 687 if(c != 0 && (fset->gauge == 0 ||
650 icalgauge_compare(impl->gauge,c) == 1)){ 688 icalgauge_compare(fset->gauge,c) == 1)){
651 return c; 689 return c;
@@ -658,2 +696,239 @@ icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
658} 696}
697/*
698icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
699{
700 icalsetiter itr = icalsetiter_null;
701 icalcomponent* comp = NULL;
702 icalcompiter citr;
703 icalfileset *fset = (icalfileset*) set;
704
705 icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
706
707 itr.gauge = gauge;
708
709 citr = icalcomponent_begin_component(fset->cluster, kind);
710 comp = icalcompiter_deref(&citr);
711
712 while (comp != 0) {
713 comp = icalcompiter_deref(&citr);
714 if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
715 itr.iter = citr;
716 return itr;
717 }
718 comp = icalcompiter_next(&citr);
719 }
720
721 return icalsetiter_null;
722}
723*/
724
725icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge)
726{
727 icalsetiter itr = icalsetiter_null;
728 icalcomponent* comp = NULL;
729 icalcompiter citr;
730 icalfileset *fset = (icalfileset*) set;
731 struct icaltimetype start, next;
732 icalproperty *dtstart, *rrule, *prop, *due;
733 struct icalrecurrencetype recur;
734 int g = 0;
735
736 icalerror_check_arg_re((set!=0), "set", icalsetiter_null);
737
738 itr.gauge = gauge;
739
740 citr = icalcomponent_begin_component(fset->cluster, kind);
741 comp = icalcompiter_deref(&citr);
742
743 if (gauge == 0) {
744 itr.iter = citr;
745 return itr;
746 }
747
748 while (comp != 0) {
749
750 /* check if it is a recurring component and with guage expand, if so
751 we need to add recurrence-id property to the given component */
752 rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
753 g = icalgauge_get_expand(gauge);
754
755 if (rrule != 0
756 && g == 1) {
757
758 recur = icalproperty_get_rrule(rrule);
759 if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
760 dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
761 if (dtstart)
762 start = icalproperty_get_dtstart(dtstart);
763 } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
764 due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
765 if (due)
766 start = icalproperty_get_due(due);
767 }
768
769 if (itr.last_component == NULL) {
770 itr.ritr = icalrecur_iterator_new(recur, start);
771 next = icalrecur_iterator_next(itr.ritr);
772 itr.last_component = comp;
773 }
774 else {
775 next = icalrecur_iterator_next(itr.ritr);
776 if (icaltime_is_null_time(next)){
777 itr.last_component = NULL;
778 icalrecur_iterator_free(itr.ritr);
779 itr.ritr = NULL;
780 return icalsetiter_null;
781 } else {
782 itr.last_component = comp;
783 }
784 }
785
786 /* add recurrence-id to the component
787 if there is a recurrence-id already, remove it, then add the new one */
788 if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
789 icalcomponent_remove_property(comp, prop);
790 icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
791
792 }
793
794 if (gauge == 0 || icalgauge_compare(itr.gauge, comp) == 1) {
795 /* matches and returns */
796 itr.iter = citr;
797 return itr;
798 }
799
800 /* if there is no previous component pending, then get the next component */
801 if (itr.last_component == NULL)
802 comp = icalcompiter_next(&citr);
803 }
804
805 return icalsetiter_null;
806}
807icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr)
808{
809 icalcomponent* comp = NULL;
810 struct icaltimetype start, next;
811 icalproperty *dtstart, *rrule, *prop, *due;
812 struct icalrecurrencetype recur;
813
814 comp = itr->last_component;
815
816 if (comp == NULL || itr->gauge == NULL) {
817 return NULL;
818 }
819
820 rrule = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
821
822 recur = icalproperty_get_rrule(rrule);
823
824 if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT) {
825 dtstart = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
826 if (dtstart)
827 start = icalproperty_get_dtstart(dtstart);
828 } else if (icalcomponent_isa(comp) == ICAL_VTODO_COMPONENT) {
829 due = icalcomponent_get_first_property(comp, ICAL_DUE_PROPERTY);
830 if (due)
831 start = icalproperty_get_due(due);
832 }
833
834 if (itr->ritr == NULL) {
835 itr->ritr = icalrecur_iterator_new(recur, start);
836 next = icalrecur_iterator_next(itr->ritr);
837 itr->last_component = comp;
838 } else {
839 next = icalrecur_iterator_next(itr->ritr);
840 if (icaltime_is_null_time(next)){
841 /* no more recurrence, returns */
842 itr->last_component = NULL;
843 icalrecur_iterator_free(itr->ritr);
844 itr->ritr = NULL;
845 return NULL;
846 } else {
847 itr->last_component = comp;
848 }
849 }
850
851 /* add recurrence-id to the component
852 * if there is a recurrence-id already, remove it, then add the new one */
853 if (prop = icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
854 icalcomponent_remove_property(comp, prop);
855 icalcomponent_add_property(comp, icalproperty_new_recurrenceid(next));
856
857 if (itr->gauge == 0 || icalgauge_compare(itr->gauge, comp) == 1) {
858 /* matches and returns */
859 return comp;
860 }
861 /* not matched */
862 return NULL;
863
864}
865icalcomponent* icalfilesetiter_to_next(icalset* set, icalsetiter* i)
866{
867
868 icalcomponent* c = NULL;
869 icalfileset *fset = (icalfileset*) set;
870 struct icaltimetype start, next;
871 icalproperty *dtstart, *rrule, *prop, *due;
872 struct icalrecurrencetype recur;
873 int g = 0;
874
875
876 do {
877 c = icalcompiter_next(&(i->iter));
878
879 if (c == 0) continue;
880 if (i->gauge == 0) return c;
881
882
883 rrule = icalcomponent_get_first_property(c, ICAL_RRULE_PROPERTY);
884 g = icalgauge_get_expand(i->gauge);
885
886 /* a recurring component with expand query */
887 if (rrule != 0
888 && g == 1) {
889
890 recur = icalproperty_get_rrule(rrule);
891
892 if (icalcomponent_isa(c) == ICAL_VEVENT_COMPONENT) {
893 dtstart = icalcomponent_get_first_property(c, ICAL_DTSTART_PROPERTY);
894 if (dtstart)
895 start = icalproperty_get_dtstart(dtstart);
896 } else if (icalcomponent_isa(c) == ICAL_VTODO_COMPONENT) {
897 due = icalcomponent_get_first_property(c, ICAL_DUE_PROPERTY);
898 if (due)
899 start = icalproperty_get_due(due);
900 }
901
902 if (i->ritr == NULL) {
903 i->ritr = icalrecur_iterator_new(recur, start);
904 next = icalrecur_iterator_next(i->ritr);
905 i->last_component = c;
906 } else {
907 next = icalrecur_iterator_next(i->ritr);
908 if (icaltime_is_null_time(next)) {
909 /* no more recurrence, returns */
910 i->last_component = NULL;
911 icalrecur_iterator_free(i->ritr);
912 i->ritr = NULL;
913 return NULL;
914 } else {
915 i->last_component = c;
916 }
917 }
918 }
919
920 /* add recurrence-id to the component
921 * if there is a recurrence-id already, remove it, then add the new one */
922 if (prop = icalcomponent_get_first_property(c, ICAL_RECURRENCEID_PROPERTY))
923 icalcomponent_remove_property(c, prop);
924 icalcomponent_add_property(c, icalproperty_new_recurrenceid(next));
925
926 if(c != 0 && (i->gauge == 0 ||
927 icalgauge_compare(i->gauge, c) == 1)){
928 return c;
929 }
930 } while (c != 0);
931
932 return 0;
659 933
934}
diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h
index 51254d2..dc044ea 100644
--- a/libical/src/libicalss/icalfileset.h
+++ b/libical/src/libicalss/icalfileset.h
@@ -31,31 +31,31 @@
31 31
32#include "icalerror.h"
33#include "ical.h" 32#include "ical.h"
34#include "icalset.h" 33#include "icalset.h"
34#include "icalcluster.h"
35#include "icalgauge.h" 35#include "icalgauge.h"
36#include <sys/types.h> /* For open() flags and mode */
37#include <sys/stat.h> /* For open() flags and mode */
38#include <fcntl.h> /* For open() flags and mode */
36 39
37extern int icalfileset_safe_saves; 40#ifdef WIN32
38 41#define mode_t int
39typedef void icalfileset; 42#endif
40 43
44extern int icalfileset_safe_saves;
41 45
42/* icalfileset 46typedef struct icalfileset_impl icalfileset;
43 icalfilesetfile
44 icalfilesetdir
45*/
46 47
48icalset* icalfileset_new(const char* path);
49icalset* icalfileset_new_reader(const char* path);
50icalset* icalfileset_new_writer(const char* path);
47 51
48icalfileset* icalfileset_new(const char* path); 52icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
49 53
50#ifdef _WIN32 54icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
51#define mode_t int
52#endif
53 55
54/* Like _new, but takes open() flags for opening the file */ 56icalcluster* icalfileset_produce_icalcluster(const char *path);
55icalfileset* icalfileset_new_open(const char* path,
56 int flags, mode_t mode);
57 57
58void icalfileset_free(icalfileset* cluster); 58void icalfileset_free(icalset* cluster);
59 59
60const char* icalfileset_path(icalfileset* cluster); 60const char* icalfileset_path(icalset* cluster);
61 61
@@ -63,41 +63,68 @@ const char* icalfileset_path(icalfileset* cluster);
63 is freed. Commit writes to disk immediately. */ 63 is freed. Commit writes to disk immediately. */
64void icalfileset_mark(icalfileset* cluster); 64void icalfileset_mark(icalset* set);
65icalerrorenum icalfileset_commit(icalfileset* cluster); 65icalerrorenum icalfileset_commit(icalset* set);
66 66
67icalerrorenum icalfileset_add_component(icalfileset* cluster, 67icalerrorenum icalfileset_add_component(icalset* set,
68 icalcomponent* child); 68 icalcomponent* child);
69 69
70icalerrorenum icalfileset_remove_component(icalfileset* cluster, 70icalerrorenum icalfileset_remove_component(icalset* set,
71 icalcomponent* child); 71 icalcomponent* child);
72 72
73int icalfileset_count_components(icalfileset* cluster, 73int icalfileset_count_components(icalset* set,
74 icalcomponent_kind kind); 74 icalcomponent_kind kind);
75 75
76/* Restrict the component returned by icalfileset_first, _next to those 76/**
77 that pass the gauge. _clear removes the gauge */ 77 * Restrict the component returned by icalfileset_first, _next to those
78icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge); 78 * that pass the gauge. _clear removes the gauge
79void icalfileset_clear(icalfileset* store); 79 */
80icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
81
82/** clear the gauge **/
83void icalfileset_clear(icalset* set);
80 84
81/* Get and search for a component by uid */ 85/** Get and search for a component by uid **/
82icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); 86icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
83int icalfileset_has_uid(icalfileset* cluster, const char* uid); 87int icalfileset_has_uid(icalset* set, const char* uid);
84icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c); 88icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
85 89
86 90
87/* Modify components according to the MODIFY method of CAP. Works on 91/**
88 the currently selected components. */ 92 * Modify components according to the MODIFY method of CAP. Works on the
89icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, 93 * currently selected components.
94 */
95icalerrorenum icalfileset_modify(icalset* set,
96 icalcomponent *oldcomp,
90 icalcomponent *newcomp); 97 icalcomponent *newcomp);
91 98
92/* Iterate through components. If a guage has been defined, these 99/* Iterate through components. If a gauge has been defined, these
93 will skip over components that do not pass the gauge */ 100 will skip over components that do not pass the gauge */
94 101
95icalcomponent* icalfileset_get_current_component (icalfileset* cluster); 102icalcomponent* icalfileset_get_current_component (icalset* cluster);
96icalcomponent* icalfileset_get_first_component(icalfileset* cluster); 103icalcomponent* icalfileset_get_first_component(icalset* cluster);
97icalcomponent* icalfileset_get_next_component(icalfileset* cluster); 104icalcomponent* icalfileset_get_next_component(icalset* cluster);
98/* Return a reference to the internal component. You probably should 105
106/* External iterator for thread safety */
107icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
108icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
109icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
110
111/** Return a reference to the internal component. You probably should
99 not be using this. */ 112 not be using this. */
100 113
101icalcomponent* icalfileset_get_component(icalfileset* cluster); 114icalcomponent* icalfileset_get_component(icalset* cluster);
115
116/**
117 * @brief options for opening an icalfileset.
118 *
119 * These options should be passed to the icalset_new() function
120 */
121
122typedef struct icalfileset_options {
123 int flags; /**< flags for open() O_RDONLY, etc */
124 mode_t mode; /**< file mode */
125 int safe_saves;/**< to lock or not */
126 icalcluster *cluster;/**< use this cluster to initialize data */
127} icalfileset_options;
102 128
129extern icalfileset_options icalfileset_options_default;
103 130
diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h
index fcd3415..fe39604 100644
--- a/libical/src/libicalss/icalfilesetimpl.h
+++ b/libical/src/libicalss/icalfilesetimpl.h
@@ -27,2 +27,4 @@
27 27
28#ifndef ICALFILESETIMPL_H
29#define ICALFILESETIMPL_H
28 30
@@ -40,10 +42,12 @@
40struct icalfileset_impl { 42struct icalfileset_impl {
41 43 icalset super; /**< parent class */
42 char id[5]; /*fset*/ 44 char *path; /**< pathname of file */
43 char *path; 45 icalfileset_options options; /**< copy of options passed to icalset_new() */
44 icalcomponent* cluster; 46
45 icalgauge* gauge; 47 icalcomponent* cluster;/**< cluster containing data */
46 int changed; 48 icalgauge* gauge; /**< gauge for filtering out data */
47 int fd; /* file descriptor */ 49 int changed; /**< boolean flag, 1 if data has changed */
50 int fd; /**< file descriptor */
48}; 51};
49 52
53#endif
diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c
index b958ecf..f4854c7 100644
--- a/libical/src/libicalss/icalgauge.c
+++ b/libical/src/libicalss/icalgauge.c
@@ -33,11 +33,13 @@
33 33
34extern char* input_buffer; 34#include "icalssyacc.h"
35extern char* input_buffer_p;
36int ssparse(void);
37 35
38struct icalgauge_impl *icalss_yy_gauge; 36typedef void* yyscan_t;
39 37
40icalgauge* icalgauge_new_from_sql(char* sql) 38int ssparse(yyscan_t );
39
40
41icalgauge* icalgauge_new_from_sql(char* sql, int expand)
41{ 42{
42 struct icalgauge_impl *impl; 43 struct icalgauge_impl *impl;
44 yyscan_t yy_globals = NULL;
43 45
@@ -54,11 +56,27 @@ icalgauge* icalgauge_new_from_sql(char* sql)
54 impl->where = pvl_newlist(); 56 impl->where = pvl_newlist();
57 impl->expand = expand;
58
59 sslex_init(&yy_globals);
60
61 ssset_extra(impl, yy_globals);
55 62
56 icalss_yy_gauge = impl; 63 ss_scan_string(sql, yy_globals);
57 64
58 input_buffer_p = input_buffer = sql; 65 r = ssparse(yy_globals);
59 r = ssparse(); 66 sslex_destroy(yy_globals);
60 67
61 return impl; 68 if (r == 0) {
69 return impl;
70 }
71 else {
72 icalgauge_free(impl);
73 return NULL;
74 }
62} 75}
63 76
77int icalgauge_get_expand(icalgauge* gauge)
78{
79return (gauge->expand);
80
81}
64 82
@@ -66,11 +84,10 @@ void icalgauge_free(icalgauge* gauge)
66{ 84{
67 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
68 struct icalgauge_where *w; 85 struct icalgauge_where *w;
69 86
70 assert(impl->select != 0); 87 assert(gauge->select != 0);
71 assert(impl->where != 0); 88 assert(gauge->where != 0);
72 assert(impl->from != 0); 89 assert(gauge->from != 0);
73 90
74 if(impl->select){ 91 if(gauge->select){
75 while( (w=pvl_pop(impl->select)) != 0){ 92 while( (w=pvl_pop(gauge->select)) != 0){
76 if(w->value != 0){ 93 if(w->value != 0){
@@ -80,7 +97,8 @@ void icalgauge_free(icalgauge* gauge)
80 } 97 }
81 pvl_free(impl->select); 98 pvl_free(gauge->select);
99 gauge->select = 0;
82 } 100 }
83 101
84 if(impl->where){ 102 if(gauge->where){
85 while( (w=pvl_pop(impl->where)) != 0){ 103 while( (w=pvl_pop(gauge->where)) != 0){
86 104
@@ -91,8 +109,12 @@ void icalgauge_free(icalgauge* gauge)
91 } 109 }
92 pvl_free(impl->where); 110 pvl_free(gauge->where);
111 gauge->where = 0;
93 } 112 }
94 113
95 if(impl->from){ 114 if(gauge->from){
96 pvl_free(impl->from); 115 pvl_free(gauge->from);
116 gauge->from = 0;
97 } 117 }
118
119 free(gauge);
98 120
@@ -100,6 +122,8 @@ void icalgauge_free(icalgauge* gauge)
100 122
101/* Convert a VQUERY component into a gauge */ 123
124/** Convert a VQUERY component into a gauge */
102icalcomponent* icalgauge_make_gauge(icalcomponent* query); 125icalcomponent* icalgauge_make_gauge(icalcomponent* query);
103 126
104/* icaldirset_test compares a component against a gauge, and returns 127/**
128 icaldirset_test compares a component against a gauge, and returns
105 true if the component passes the test 129 true if the component passes the test
@@ -107,3 +131,3 @@ icalcomponent* icalgauge_make_gauge(icalcomponent* query);
107 The gauge is a VCALENDAR component that specifies how to test the 131 The gauge is a VCALENDAR component that specifies how to test the
108 target components. The guage holds a collection of VEVENT, VTODO or 132 target components. The gauge holds a collection of VEVENT, VTODO or
109 VJOURNAL sub-components. Each of the sub-components has a 133 VJOURNAL sub-components. Each of the sub-components has a
@@ -254,3 +278,2 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
254 278
255 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
256 icalcomponent *inner; 279 icalcomponent *inner;
@@ -259,2 +282,6 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
259 pvl_elem e; 282 pvl_elem e;
283 icalcomponent_kind kind;
284 icalproperty *rrule;
285 int compare_recur = 0;
286
260 287
@@ -263,2 +290,4 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
263 290
291 if (gauge == 0 || comp == 0) return 0;
292
264 inner = icalcomponent_get_first_real_component(comp); 293 inner = icalcomponent_get_first_real_component(comp);
@@ -266,10 +295,24 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
266 if(inner == 0){ 295 if(inner == 0){
267 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 296 /* Wally Yau: our component is not always wrapped with
268 return 0; 297 * a <VCALENDAR>. It's not an error.
298 * icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
299 * return 0; */
300 kind = icalcomponent_isa(comp);
301 if(kind == ICAL_VEVENT_COMPONENT ||
302 kind == ICAL_VTODO_COMPONENT ||
303 kind == ICAL_VJOURNAL_COMPONENT ||
304 kind == ICAL_VQUERY_COMPONENT ||
305 kind == ICAL_VAGENDA_COMPONENT){
306 inner = comp;
307 }
308 else {
309 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
310 return 0;
311 }
312 inner = comp;
269 } 313 }
270 314
271
272 /* Check that this component is one of the FROM types */ 315 /* Check that this component is one of the FROM types */
273 local_pass = 0; 316 local_pass = 0;
274 for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){ 317 for(e = pvl_head(gauge->from);e!=0;e=pvl_next(e)){
275 icalcomponent_kind k = (icalcomponent_kind)pvl_data(e); 318 icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
@@ -286,4 +329,4 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
286 329
287 /* Check each where clause against the component */ 330 /**** Check each where clause against the component ****/
288 for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){ 331 for(e = pvl_head(gauge->where);e!=0;e=pvl_next(e)){
289 struct icalgauge_where *w = pvl_data(e); 332 struct icalgauge_where *w = pvl_data(e);
@@ -303,3 +346,3 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
303 if(vk == ICAL_NO_VALUE){ 346 if(vk == ICAL_NO_VALUE){
304 icalerror_set_errno(ICAL_INTERNAL_ERROR); 347 icalerror_set_errno(ICAL_INTERNAL_ERROR);
305 return 0; 348 return 0;
@@ -307,3 +350,6 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
307 350
308 v = icalvalue_new_from_string(vk,w->value); 351 if (w->compare == ICALGAUGECOMPARE_ISNULL || w->compare == ICALGAUGECOMPARE_ISNOTNULL)
352 v = icalvalue_new(vk);
353 else
354 v = icalvalue_new_from_string(vk,w->value);
309 355
@@ -326,4 +372,21 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
326 372
373 /* check if it is a recurring */
374 rrule = icalcomponent_get_first_property(sub_comp,ICAL_RRULE_PROPERTY);
375
376 if (gauge->expand
377 && rrule) {
378
379 if (w->prop == ICAL_DTSTART_PROPERTY ||
380 w->prop == ICAL_DTEND_PROPERTY ||
381 w->prop == ICAL_DUE_PROPERTY){
382 /** needs to use recurrence-id to do comparison */
383 compare_recur = 1;
384 }
385
386 }
387
388
327 this_clause = 0; 389 this_clause = 0;
328 local_pass = 0; 390 local_pass = (w->compare == ICALGAUGECOMPARE_ISNULL) ? 1 : 0;
391
329 for(prop = icalcomponent_get_first_property(sub_comp,w->prop); 392 for(prop = icalcomponent_get_first_property(sub_comp,w->prop);
@@ -334,2 +397,17 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
334 397
398 if (w->compare == ICALGAUGECOMPARE_ISNULL) {
399 local_pass = 0;
400 break;
401 }
402
403 if (w->compare == ICALGAUGECOMPARE_ISNOTNULL) {
404 local_pass = 1;
405 break;
406 }
407
408 if (compare_recur) {
409 icalproperty *p = icalcomponent_get_first_property(sub_comp, ICAL_RECURRENCEID_PROPERTY);
410 prop_value = icalproperty_get_value(p);
411 }
412 else /* prop value from this component */
335 prop_value = icalproperty_get_value(prop); 413 prop_value = icalproperty_get_value(prop);
@@ -357,4 +435,6 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
357 435
436
358 this_clause = local_pass > 0 ? 1 : 0; 437 this_clause = local_pass > 0 ? 1 : 0;
359 438
439
360 /* Now look at the logic operator for this clause to see how 440 /* Now look at the logic operator for this clause to see how
@@ -364,3 +444,3 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
364 last_clause = this_clause && last_clause; 444 last_clause = this_clause && last_clause;
365 } else if(w->logic == ICALGAUGELOGIC_AND) { 445 } else if(w->logic == ICALGAUGELOGIC_OR) {
366 last_clause = this_clause || last_clause; 446 last_clause = this_clause || last_clause;
@@ -369,3 +449,6 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
369 } 449 }
370 } 450
451 icalvalue_free(v);
452
453 }/**** check next one in where clause ****/
371 454
@@ -375,12 +458,13 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
375 458
459/** @brief Debug
460 * Print gauge information to stdout.
461 */
376 462
377void icalgauge_dump(icalcomponent* gauge) 463void icalgauge_dump(icalgauge* gauge)
378{ 464{
379 465
380 pvl_elem *p; 466 pvl_elem p;
381 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
382
383 467
384 printf("--- Select ---\n"); 468 printf("--- Select ---\n");
385 for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){ 469 for(p = pvl_head(gauge->select);p!=0;p=pvl_next(p)){
386 struct icalgauge_where *w = pvl_data(p); 470 struct icalgauge_where *w = pvl_data(p);
@@ -409,3 +493,3 @@ void icalgauge_dump(icalcomponent* gauge)
409 printf("--- From ---\n"); 493 printf("--- From ---\n");
410 for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){ 494 for(p = pvl_head(gauge->from);p!=0;p=pvl_next(p)){
411 icalcomponent_kind k = (icalcomponent_kind)pvl_data(p); 495 icalcomponent_kind k = (icalcomponent_kind)pvl_data(p);
@@ -416,3 +500,3 @@ void icalgauge_dump(icalcomponent* gauge)
416 printf("--- Where ---\n"); 500 printf("--- Where ---\n");
417 for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){ 501 for(p = pvl_head(gauge->where);p!=0;p=pvl_next(p)){
418 struct icalgauge_where *w = pvl_data(p); 502 struct icalgauge_where *w = pvl_data(p);
@@ -443,4 +527,2 @@ void icalgauge_dump(icalcomponent* gauge)
443 } 527 }
444
445
446} 528}
diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h
index 1caf0ac..c35b4f7 100644
--- a/libical/src/libicalss/icalgauge.h
+++ b/libical/src/libicalss/icalgauge.h
@@ -31,5 +31,11 @@
31 31
32typedef void icalgauge; 32/** @file icalgauge.h
33 * @brief Routines implementing a filter for ical components
34 */
33 35
34icalgauge* icalgauge_new_from_sql(char* sql); 36typedef struct icalgauge_impl icalgauge;
37
38icalgauge* icalgauge_new_from_sql(char* sql, int expand);
39
40int icalgauge_get_expand(icalgauge* gauge);
35 41
@@ -39,11 +45,15 @@ char* icalgauge_as_sql(icalcomponent* gauge);
39 45
40void icalgauge_dump(icalcomponent* gauge); 46void icalgauge_dump(icalgauge* gauge);
47
41 48
42/* Return true is comp matches the gauge. The component must be in 49/** @brief Return true if comp matches the gauge.
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL 50 *
44 sub component */ 51 * The component must be in
52 * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
53 * sub component
54 */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp); 55int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46 56
47/* Clone the component, but only return the properties specified in 57/** Clone the component, but only return the properties
48 the gauge */ 58 * specified in the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); 59icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h
index 73a2813..e56b1c0 100644
--- a/libical/src/libicalss/icalgaugeimpl.h
+++ b/libical/src/libicalss/icalgaugeimpl.h
@@ -26,4 +26,2 @@
26 26
27#include "pvl.h"
28
29typedef enum icalgaugecompare { 27typedef enum icalgaugecompare {
@@ -36,2 +34,4 @@ typedef enum icalgaugecompare {
36 ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX, 34 ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
35 ICALGAUGECOMPARE_ISNULL=ICAL_XLICCOMPARETYPE_ISNULL,
36 ICALGAUGECOMPARE_ISNOTNULL=ICAL_XLICCOMPARETYPE_ISNOTNULL,
37 ICALGAUGECOMPARE_NONE=0 37 ICALGAUGECOMPARE_NONE=0
@@ -56,6 +56,6 @@ struct icalgauge_impl
56{ 56{
57 57 pvl_list select; /**< Of icalgaugecompare, using only prop and comp fields*/
58 pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/ 58 pvl_list from; /**< List of component_kinds, as integers */
59 pvl_list from; /* List of component_kinds, as integers */ 59 pvl_list where; /**< List of icalgaugecompare */
60 pvl_list where; /* List of icalgaugecompare */ 60 int expand;
61}; 61};
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c
index d5c57c1..731a2c7 100644
--- a/libical/src/libicalss/icalmessage.c
+++ b/libical/src/libicalss/icalmessage.c
@@ -42,3 +42,3 @@ icalcomponent* icalmessage_get_inner(icalcomponent* comp)
42 42
43char* lowercase(const char* str) 43static char* lowercase(const char* str)
44{ 44{
@@ -160,4 +160,9 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
160 160
161#ifndef WIN32
161 sprintf(tmp, 162 sprintf(tmp,
162 "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION); 163 "-//SoftwareStudio//NONSGML %s %s //EN",PACKAGE,VERSION);
164#else
165 sprintf(tmp,
166 "-//SoftwareStudio//NONSGML %s %s //EN",ICAL_PACKAGE,ICAL_VERSION);
167#endif
163 icalcomponent_add_property(reply,icalproperty_new_prodid(tmp)); 168 icalcomponent_add_property(reply,icalproperty_new_prodid(tmp));
@@ -232,3 +237,3 @@ icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
232 237
233 reply = icalcomponent_new_clone(newc); 238 reply = icalmessage_new_reply_base(newc,user,msg);
234 239
@@ -236,3 +241,3 @@ icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
236 241
237 return newc; 242 return reply;
238 243
diff --git a/libical/src/libicalss/icalset.c b/libical/src/libicalss/icalset.c
index 2120609..0ad2269 100644
--- a/libical/src/libicalss/icalset.c
+++ b/libical/src/libicalss/icalset.c
@@ -43,29 +43,22 @@
43#include <stdlib.h> 43#include <stdlib.h>
44/*#include "icalheapset.h"*/ 44#include <string.h>
45/*#include "icalmysqlset.h"*/ 45#include <errno.h>
46 46
47#define ICALSET_ID "set " 47#ifdef WITH_BDB4
48 48#include "icalbdbset.h"
49struct icalset_fp { 49#include "icalbdbsetimpl.h"
50 void (*free)(icalset* set); 50#endif
51 const char* (*path)(icalset* set); 51
52 void (*mark)(icalset* set); 52/* #define _DLOPEN_TEST */
53 icalerrorenum (*commit)(icalset* set); 53#ifdef _DLOPEN_TEST
54 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp); 54#include <sys/types.h>
55 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp); 55#include <dlfcn.h>
56 int (*count_components)(icalset* set, 56#include <dirent.h>
57 icalcomponent_kind kind); 57#endif
58 icalerrorenum (*select)(icalset* set, icalcomponent* gauge); 58
59 void (*clear)(icalset* set); 59static icalset icalset_dirset_init = {
60 icalcomponent* (*fetch)(icalset* set, const char* uid); 60 ICAL_DIR_SET,
61 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp); 61 sizeof(icaldirset),
62 int (*has_uid)(icalset* set, const char* uid); 62 NULL,
63 icalerrorenum (*modify)(icalset* set, icalcomponent *old, 63 icaldirset_init,
64 icalcomponent *new);
65 icalcomponent* (*get_current_component)(icalset* set);
66 icalcomponent* (*get_first_component)(icalset* set);
67 icalcomponent* (*get_next_component)(icalset* set);
68};
69
70struct icalset_fp icalset_dirset_fp = {
71 icaldirset_free, 64 icaldirset_free,
@@ -85,3 +78,6 @@ struct icalset_fp icalset_dirset_fp = {
85 icaldirset_get_first_component, 78 icaldirset_get_first_component,
86 icaldirset_get_next_component 79 icaldirset_get_next_component,
80 icaldirset_begin_component,
81 icaldirsetiter_to_next,
82 icaldirsetiter_to_prior
87}; 83};
@@ -89,3 +85,7 @@ struct icalset_fp icalset_dirset_fp = {
89 85
90struct icalset_fp icalset_fileset_fp = { 86static icalset icalset_fileset_init = {
87 ICAL_FILE_SET,
88 sizeof(icalfileset),
89 NULL,
90 icalfileset_init,
91 icalfileset_free, 91 icalfileset_free,
@@ -105,158 +105,262 @@ struct icalset_fp icalset_fileset_fp = {
105 icalfileset_get_first_component, 105 icalfileset_get_first_component,
106 icalfileset_get_next_component 106 icalfileset_get_next_component,
107 icalfileset_begin_component,
108 icalfilesetiter_to_next,
109 NULL
107}; 110};
108 111
109struct icalset_impl { 112#ifdef WITH_BDB4
113static icalset icalset_bdbset_init = {
114 ICAL_BDB_SET,
115 sizeof(icalbdbset),
116 NULL,
117 icalbdbset_init,
118 icalbdbset_free,
119 icalbdbset_path,
120 icalbdbset_mark,
121 icalbdbset_commit,
122 icalbdbset_add_component,
123 icalbdbset_remove_component,
124 icalbdbset_count_components,
125 icalbdbset_select,
126 icalbdbset_clear,
127 icalbdbset_fetch,
128 icalbdbset_fetch_match,
129 icalbdbset_has_uid,
130 icalbdbset_modify,
131 icalbdbset_get_current_component,
132 icalbdbset_get_first_component,
133 icalbdbset_get_next_component,
134 icalbdbset_begin_component,
135 icalbdbsetiter_to_next,
136 NULL
137};
138#endif
110 139
111 char id[5]; /* "set " */ 140#ifdef _DLOPEN_TEST
141 static inticalset_init_done = 0;
142static pvl_list icalset_kinds = 0;
112 143
113 void *derived_impl; 144typedef icalset *(*fptr)(void);
114 struct icalset_fp *fp;
115};
116 145
117/* Figure out what was actually passed in as the set. This could be a 146/**
118 set or and of the derived types such as dirset or fileset. Note 147 * Try to load the file and register any icalset found within.
119 this routine returns a value, not a reference, to avoid memory 148 */
120 leaks in the methods */ 149static int load(const char *file) {
121struct icalset_impl icalset_get_impl(icalset* set) 150
122{ 151 void *modh;
123 struct icalset_impl impl; 152 fptr inith;
124 153 icalset *icalset_init_ptr;
125 memset(&impl,0,sizeof(impl)); 154
126 icalerror_check_arg_re( (set!=0),"set",impl); 155 if ((modh = dlopen(file, RTLD_NOW)) == 0) {
127 156 perror("dlopen");
128 if(strcmp((char*)set,ICALSET_ID)==0) { 157 return 0;
129 /* It is actually a set, so just sent the reference back out. */ 158 }
130 return *(struct icalset_impl*)set; 159
131 } else if(strcmp((char*)set,ICALFILESET_ID)==0) { 160 if ((inith = (fptr)dlsym(modh, "InitModule")) == 0) {
132 /* Make a new set from the fileset */ 161 perror("dlsym");
133 impl.fp = &icalset_fileset_fp; 162 return 0;
134 impl.derived_impl = set; 163 }
135 strcpy(impl.id,ICALFILESET_ID);/* HACK. Is this necessary? */ 164
136 return impl; 165 while ((icalset_init_ptr = ((inith)())) != 0) {
137 } else if(strcmp((char*)set,ICALDIRSET_ID)==0) { 166 pvl_push(icalset_kinds, &icalset_init_ptr);
138 /* Make a new set from the dirset */ 167 }
139 impl.fp = &icalset_dirset_fp; 168
140 impl.derived_impl = set; 169 return 1;
141 strcpy(impl.id,ICALDIRSET_ID);/* HACK. Is this necessary? */
142 return impl;
143 } else {
144 /* The type of set is unknown, so throw an error */
145 icalerror_assert((0),"Unknown set type");
146 return impl;
147 }
148} 170}
149 171
172/**
173 * Look in the given directory for files called mod_*.o and try to
174 * load them.
175 */
176int icalset_loaddir(const char *path) {
177 DIR *d;
178 struct dirent *dp;
179 char buf[PATH_MAX],
180 *bufptr;
181 int tot = 0;
150 182
151struct icalset_impl* icalset_new_impl() 183 strcpy(buf, path);
152{ 184 bufptr = buf + strlen(buf);
153
154 struct icalset_impl* impl;
155 185
156 if ( ( impl = (struct icalset_impl*) 186 if (*(bufptr-1) != '/')
157 malloc(sizeof(struct icalset_impl))) == 0) { 187 *bufptr++ = '/';
158 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
159 return 0;
160 }
161 188
162 strcpy(impl->id,ICALSET_ID); 189 if ((d = opendir(path)) == 0) {
190 perror("opendir");
191 return 0;
192 }
163 193
164 impl->derived_impl = 0; 194 while ((dp = readdir(d)) != 0) {
165 impl->fp = 0; 195 if (strncmp(dp->d_name, "mod_", 4)) continue;
166 196
167 return impl; 197 strcpy(bufptr, dp->d_name);
168}
169 198
170struct icalset_impl* icalset_new_file_from_ref(icalfileset *fset) 199 load(buf);
171{ 200 tot++;
172 struct icalset_impl *impl = icalset_new_impl(); 201 }
202 (void)closedir(d);
173 203
174 icalerror_check_arg_rz( (fset!=0),"fset"); 204 return 1;
205}
175 206
176 if(impl == 0){ 207int icalset_register_class(icalset *set);
177 free(impl);
178 return 0;
179 }
180 208
181 impl->derived_impl = fset; 209static void icalset_init(void) {
210 assert(icalset_kinds == 0);
211 icalset_kinds = pvl_newlist();
182 212
183 if (impl->derived_impl == 0){ 213 pvl_push(icalset_kinds, &icalset_fileset_init);
184 free(impl); 214 pvl_push(icalset_kinds, &icalset_dirset_init);
185 return 0; 215#ifdef WITH_BDB4
186 } 216 pvl_push(icalset_kinds, &icalset_bdb4set_init);
217#endif
187 218
188 impl->fp = &icalset_fileset_fp; 219#ifdef EXT_PATH
220 icalset_loaddir(EXT_PATH);
221#endif
189 222
190 return (struct icalset_impl*)impl; 223 icalset_init_done++;
191} 224}
192 225
193icalset* icalset_new_file(const char* path) 226int icalset_register_class(icalset *set) {
194{
195 icalfileset *fset = icalfileset_new(path);
196 227
197 if(fset == 0){ 228 if (!icalset_init_done)
198 return 0; 229 icalset_init();
199 }
200 230
201 return (icalset*)icalset_new_file_from_ref(fset); 231 pvl_push(icalset_kinds, set);
232 return 1;
202} 233}
203 234
204icalset* icalset_new_dir_from_ref(icaldirset *dset) 235#endif
205{
206 236
207 struct icalset_impl *impl = icalset_new_impl(); 237icalset* icalset_new(icalset_kind kind, const char* dsn, void* options) {
238 icalset *data = NULL;
239 icalset *ret = NULL;
208 240
209 icalerror_check_arg_rz( (dset!=0),"dset"); 241#ifdef _DLOPEN_TEST
242 pvl_eleme;
243 icalset *impl;
210 244
211 if(impl == 0){ 245 if (!icalset_init_done)
212 return 0; 246 icalset_init();
247
248 for(e = pvl_head(icalset_kinds); e!=0; e = pvl_next(e)) {
249 impl = (icalset*)pvl_data(e);
250 if (impl->kind == kind)
251 break;
252 }
253 if (e == 0) {
254 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
255 return(NULL);
213 } 256 }
214 257
215 impl->derived_impl = dset; 258 data = (icalset*)malloc(impl->size);
259 if (data == 0) {
260 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
261 errno = ENOMEM;
262 return 0;
263 }
216 264
217 if (impl->derived_impl == 0){ 265 /* The first member of the derived class must be an icalset. */
218 free(impl); 266 memset(data,0,impl->size);
267 /* *data = *impl; */
268 memcpy(data, impl, sizeof(icalset));
269
270 data->dsn = strdup(dsn);
271#else
272 switch(kind) {
273 case ICAL_FILE_SET:
274 data = (icalset*) malloc(sizeof(icalfileset));
275 if (data == 0) {
276 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
277 errno = ENOMEM;
278 return 0;
279 }
280 memset(data,0,sizeof(icalfileset));
281 *data = icalset_fileset_init;
282 break;
283 case ICAL_DIR_SET:
284 data = (icalset*) malloc(sizeof(icaldirset));
285 if (data == 0) {
286 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
287 errno = ENOMEM;
288 return 0;
289 }
290 memset(data,0,sizeof(icaldirset));
291 *data = icalset_dirset_init;
292 break;
293#ifdef WITH_BDB4
294 case ICAL_BDB_SET:
295 data = (icalset*) malloc(sizeof(icalbdbset));
296 if (data == 0) {
297 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
298 errno = ENOMEM;
219 return 0; 299 return 0;
220 } 300 }
301 memset(data,0,sizeof(icalbdbset));
302 *data = icalset_bdbset_init;
303 break;
304#endif
305
306 default:
307 icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
308 /** unimplemented **/
309 return(NULL);
310 }
311
312 if ( data == 0) {
313 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
314 return 0;
315 }
316 data->kind = kind;
317 data->dsn = strdup(dsn);
318#endif
221 319
222 impl->fp = &icalset_dirset_fp; 320 /** call the implementation specific initializer **/
321 if ((ret = data->init(data, dsn, options)) == NULL)
322 icalset_free(data);
223 323
224 return impl; 324 return ret;
225} 325}
226 326
227icalset* icalset_new_dir(const char* path) 327icalset* icalset_new_file(const char* path)
228{ 328{
229 icaldirset *dset = icaldirset_new(path); 329 return icalset_new(ICAL_FILE_SET, path, NULL);
230 330}
231 if(dset == 0){
232 return 0;
233 }
234 331
235 return icalset_new_dir_from_ref(dset); 332icalset* icalset_new_file_writer(const char* path)
333{
334 return icalfileset_new_writer(path);
236} 335}
237 336
238icalset* icalset_new_heap(void) 337icalset* icalset_new_file_reader(const char* path)
239{ 338{
240 struct icalset_impl *impl = icalset_new_impl(); 339 return icalfileset_new_reader(path);
340}
241 341
242 342
243 if(impl == 0){ 343icalset* icalset_new_dir(const char* path)
244 free(impl); 344{
245 return 0; 345 return icalset_new(ICAL_DIR_SET, path, NULL);
246 } 346}
247 347
248 return 0; 348icalset* icalset_new_dir_writer(const char* path)
349{
350 return icaldirset_new_writer(path);
249} 351}
250 352
251icalset* icalset_new_mysql(const char* path) 353icalset* icalset_new_dir_reader(const char* path)
252{ 354{
253 struct icalset_impl *impl = icalset_new_impl(); 355 return icaldirset_new_reader(path);
356}
254 357
255 if(impl == 0){
256 free(impl);
257 return 0;
258 }
259 358
260 return 0; 359
261} 360/* Functions for built-in methods */
361
362/**
363 * free memory associated with this icalset
364 * automatically calls the implementation specific free routine
365 */
262 366
@@ -264,75 +368,54 @@ void icalset_free(icalset* set)
264{ 368{
265 struct icalset_impl impl = icalset_get_impl(set); 369 if (set->free)
266 (*(impl.fp->free))(impl.derived_impl); 370 set->free(set);
267 371
268 if(strcmp((char*)set,ICALSET_ID)) { 372 if (set->dsn)
269 free(set); 373 free(set->dsn);
270 }
271}
272 374
273const char* icalset_path(icalset* set) 375 free(set);
274{
275 struct icalset_impl impl = icalset_get_impl(set);
276 return (*(impl.fp->path))(impl.derived_impl);
277} 376}
278 377
279void icalset_mark(icalset* set) 378
280{ 379const char* icalset_path(icalset* set) {
281 struct icalset_impl impl = icalset_get_impl(set); 380 return set->path(set);
282 (*(impl.fp->mark))(impl.derived_impl);
283} 381}
284 382
285icalerrorenum icalset_commit(icalset* set) 383void icalset_mark(icalset* set) {
286{ 384 set->mark(set);
287 struct icalset_impl impl = icalset_get_impl(set);
288 return (*(impl.fp->commit))(impl.derived_impl);
289} 385}
290 386
291icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) 387icalerrorenum icalset_commit(icalset* set) {
292{ 388 return set->commit(set);
293 struct icalset_impl impl = icalset_get_impl(set);
294 return (*(impl.fp->add_component))(impl.derived_impl,comp);
295} 389}
296 390
297icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp) 391icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp) {
298{ 392 return set->add_component(set,comp);
299 struct icalset_impl impl = icalset_get_impl(set);
300 return (*(impl.fp->remove_component))(impl.derived_impl,comp);
301} 393}
302 394
303int icalset_count_components(icalset* set,icalcomponent_kind kind) 395icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp) {
304{ 396 return set->remove_component(set,comp);
305 struct icalset_impl impl = icalset_get_impl(set);
306 return (*(impl.fp->count_components))(impl.derived_impl,kind);
307} 397}
308 398
309icalerrorenum icalset_select(icalset* set, icalcomponent* gauge) 399int icalset_count_components(icalset* set,icalcomponent_kind kind) {
310{ 400 return set->count_components(set,kind);
311 struct icalset_impl impl = icalset_get_impl(set);
312 return (*(impl.fp->select))(impl.derived_impl,gauge);
313} 401}
314 402
315void icalset_clear(icalset* set) 403icalerrorenum icalset_select(icalset* set, icalgauge* gauge) {
316{ 404 return set->select(set, gauge);
317 struct icalset_impl impl = icalset_get_impl(set);
318 (*(impl.fp->clear))(impl.derived_impl);
319} 405}
320 406
321icalcomponent* icalset_fetch(icalset* set, const char* uid) 407void icalset_clear(icalset* set) {
322{ 408 set->clear(set);
323 struct icalset_impl impl = icalset_get_impl(set);
324 return (*(impl.fp->fetch))(impl.derived_impl,uid);
325} 409}
326 410
327icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) 411icalcomponent* icalset_fetch(icalset* set, const char* uid) {
328{ 412 return set->fetch(set, uid);
329 struct icalset_impl impl = icalset_get_impl(set);
330 return (*(impl.fp->fetch_match))(impl.derived_impl,comp);
331} 413}
332 414
415icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *comp) {
416 return set->fetch_match(set, comp);
417}
333 418
334int icalset_has_uid(icalset* set, const char* uid) 419int icalset_has_uid(icalset* set, const char* uid) {
335{ 420 return set->has_uid(set, uid);
336 struct icalset_impl impl = icalset_get_impl(set);
337 return (*(impl.fp->has_uid))(impl.derived_impl,uid);
338} 421}
@@ -340,28 +423,71 @@ int icalset_has_uid(icalset* set, const char* uid)
340icalerrorenum icalset_modify(icalset* set, icalcomponent *old, 423icalerrorenum icalset_modify(icalset* set, icalcomponent *old,
341 icalcomponent *new) 424 icalcomponent *new) {
342{ 425 return set->modify(set, old, new);
343 struct icalset_impl impl = icalset_get_impl(set);
344 return (*(impl.fp->modify))(impl.derived_impl,old,new);
345} 426}
346 427
347icalcomponent* icalset_get_current_component(icalset* set) 428icalcomponent* icalset_get_current_component(icalset* set) {
348{ 429 return set->get_current_component(set);
349 struct icalset_impl impl = icalset_get_impl(set);
350 return (*(impl.fp->get_current_component))(impl.derived_impl);
351} 430}
352 431
353icalcomponent* icalset_get_first_component(icalset* set) 432icalcomponent* icalset_get_first_component(icalset* set) {
354{ 433 return set->get_first_component(set);
355 struct icalset_impl impl = icalset_get_impl(set);
356 return (*(impl.fp->get_first_component))(impl.derived_impl);
357} 434}
358 435
359icalcomponent* icalset_get_next_component(icalset* set) 436icalcomponent* icalset_get_next_component(icalset* set) {
360{ 437 return set->get_next_component(set);
361 struct icalset_impl impl = icalset_get_impl(set); 438}
362 return (*(impl.fp->get_next_component))(impl.derived_impl); 439
440icalsetiter icalsetiter_null = {{ICAL_NO_COMPONENT, 0}, 0};
441
442icalsetiter icalset_begin_component(icalset* set,
443 icalcomponent_kind kind, icalgauge* gauge) {
444 return set->icalset_begin_component(set, kind, gauge);
445}
446
447icalcomponent* icalsetiter_next(icalsetiter* itr) {
448
449 icalcomponent* c = 0;
450 icalerror_check_arg_rz( (itr != NULL), "i");
451
452 do {
453 c = icalcompiter_next(&(itr->iter));
454 if(c != 0 && (itr->gauge == 0 ||
455 icalgauge_compare(itr->gauge, c) == 1)){
456 return c;
457 }
458 } while (c != 0);
459
460 return 0;
363} 461}
364 462
463icalcomponent* icalsetiter_prior(icalsetiter* i) {
464
465 icalcomponent* c = 0;
466 icalerror_check_arg_rz( (i != NULL), "i" );
467
468 do {
469 c = icalcompiter_prior(&(i->iter));
470 if(c != 0 && (i->gauge == 0 ||
471 icalgauge_compare(i->gauge, c) == 1)){
472 return c;
473 }
474 } while (c != 0);
475
476 return 0;
477}
365 478
479icalcomponent* icalsetiter_deref(icalsetiter* i) {
480 icalerror_check_arg_rz( (i != NULL), "i" );
481 return (icalcompiter_deref(&(i->iter)));
482}
366 483
484/* for subclasses that use multiple clusters that require specialized cluster traversal */
485icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i)
486{
487 return set->icalsetiter_to_next(set, i);
488}
367 489
490icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i)
491{
492 return set->icalsetiter_to_prior(set, i);
493}
diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h
index 7b083da..4008c62 100644
--- a/libical/src/libicalss/icalset.h
+++ b/libical/src/libicalss/icalset.h
@@ -1,6 +1,5 @@
1/* -*- Mode: C -*- */ 1/* -*- Mode: C -*- */
2/*====================================================================== 2/**
3 FILE: icalset.h 3 @file icalset.h
4 CREATOR: eric 28 November 1999 4 @author eric 28 November 1999
5
6 5
@@ -9,7 +8,10 @@
9 8
10 icalfileset Store componetns in a single file 9 icalfileset Store components in a single file
11 icaldirset Store components in multiple files in a directory 10 icaldirset Store components in multiple files in a directory
11 icalbdbset Store components in a Berkeley DB File
12 icalheapset Store components on the heap 12 icalheapset Store components on the heap
13 icalmysqlset Store components in a mysql database. 13 icalmysqlset Store components in a mysql database.
14**/
14 15
16/*
15 $Id$ 17 $Id$
@@ -41,3 +43,3 @@
41#include "ical.h" 43#include "ical.h"
42#include "icalerror.h" 44#include "icalgauge.h"
43 45
@@ -50,5 +52,3 @@
50 52
51 53typedef struct icalset_impl icalset;
52
53typedef void icalset;
54 54
@@ -57,14 +57,67 @@ typedef enum icalset_kind {
57 ICAL_DIR_SET, 57 ICAL_DIR_SET,
58 ICAL_HEAP_SET, 58 ICAL_BDB_SET
59 ICAL_MYSQL_SET,
60 ICAL_CAP_SET
61} icalset_kind; 59} icalset_kind;
62 60
61typedef struct icalsetiter
62{
63 icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
64 icalgauge* gauge;
65 icalrecur_iterator* ritr; /*the last iterator*/
66 icalcomponent* last_component; /*the pending recurring component to be processed */
67 const char* tzid; /* the calendar's timezone id */
68} icalsetiter;
69
70struct icalset_impl {
71 icalset_kind kind;
72 int size;
73 char *dsn;
74 icalset* (*init)(icalset* set, const char *dsn, void *options);
75 void (*free)(icalset* set);
76 const char* (*path)(icalset* set);
77 void (*mark)(icalset* set);
78 icalerrorenum (*commit)(icalset* set);
79 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
80 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
81 int (*count_components)(icalset* set,
82 icalcomponent_kind kind);
83 icalerrorenum (*select)(icalset* set, icalgauge* gauge);
84 void (*clear)(icalset* set);
85 icalcomponent* (*fetch)(icalset* set, const char* uid);
86 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
87 int (*has_uid)(icalset* set, const char* uid);
88 icalerrorenum (*modify)(icalset* set, icalcomponent *old,
89 icalcomponent *newc);
90 icalcomponent* (*get_current_component)(icalset* set);
91 icalcomponent* (*get_first_component)(icalset* set);
92 icalcomponent* (*get_next_component)(icalset* set);
93 icalsetiter (*icalset_begin_component)(icalset* set,
94 icalcomponent_kind kind, icalgauge* gauge);
95 icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
96 icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
97};
98
99/** @brief Register a new derived class */
100int icalset_register_class(icalset *set);
101
102
103/** @brief Generic icalset constructor
104 *
105 * @param kind The type of icalset to create
106 * @param dsn Data Source Name - usually a pathname or DB handle
107 * @param options Any implementation specific options
108 *
109 * @return A valid icalset reference or NULL if error.
110 *
111 * This creates any of the icalset types available.
112 */
113
114icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
63 115
64/* Create a specific derived type of set */
65icalset* icalset_new_file(const char* path); 116icalset* icalset_new_file(const char* path);
117icalset* icalset_new_file_reader(const char* path);
118icalset* icalset_new_file_writer(const char* path);
119
66icalset* icalset_new_dir(const char* path); 120icalset* icalset_new_dir(const char* path);
67icalset* icalset_new_heap(void); 121icalset* icalset_new_file_reader(const char* path);
68icalset* icalset_new_mysql(const char* path); 122icalset* icalset_new_file_writer(const char* path);
69/*icalset* icalset_new_cap(icalcstp* cstp);*/
70 123
@@ -74,5 +127,7 @@ const char* icalset_path(icalset* set);
74 127
75/* Mark the cluster as changed, so it will be written to disk when it 128/** Mark the cluster as changed, so it will be written to disk when it
76 is freed. Commit writes to disk immediately*/ 129 is freed. **/
77void icalset_mark(icalset* set); 130void icalset_mark(icalset* set);
131
132/** Write changes to disk immediately */
78icalerrorenum icalset_commit(icalset* set); 133icalerrorenum icalset_commit(icalset* set);
@@ -85,9 +140,12 @@ int icalset_count_components(icalset* set,
85 140
86/* Restrict the component returned by icalset_first, _next to those 141/** Restrict the component returned by icalset_first, _next to those
87 that pass the gauge. _clear removes the gauge. */ 142 that pass the gauge. */
88icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); 143icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
144
145/** Clears the gauge defined by icalset_select() */
89void icalset_clear_select(icalset* set); 146void icalset_clear_select(icalset* set);
90 147
91/* Get a component by uid */ 148/** Get a component by uid */
92icalcomponent* icalset_fetch(icalset* set, const char* uid); 149icalcomponent* icalset_fetch(icalset* set, const char* uid);
150
93int icalset_has_uid(icalset* set, const char* uid); 151int icalset_has_uid(icalset* set, const char* uid);
@@ -95,3 +153,3 @@ icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
95 153
96/* Modify components according to the MODIFY method of CAP. Works on 154/** Modify components according to the MODIFY method of CAP. Works on
97 the currently selected components. */ 155 the currently selected components. */
@@ -100,3 +158,3 @@ icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
100 158
101/* Iterate through the components. If a guage has been defined, these 159/** Iterate through the components. If a guage has been defined, these
102 will skip over components that do not pass the gauge */ 160 will skip over components that do not pass the gauge */
@@ -107,2 +165,17 @@ icalcomponent* icalset_get_next_component(icalset* set);
107 165
166/** External Iterator with gauge - for thread safety */
167extern icalsetiter icalsetiter_null;
168
169icalsetiter icalset_begin_component(icalset* set,
170 icalcomponent_kind kind, icalgauge* gauge);
171
172/** Default _next, _prior, _deref for subclasses that use single cluster */
173icalcomponent* icalsetiter_next(icalsetiter* i);
174icalcomponent* icalsetiter_prior(icalsetiter* i);
175icalcomponent* icalsetiter_deref(icalsetiter* i);
176
177/** for subclasses that use multiple clusters that require specialized cluster traversal */
178icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
179icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
180
108#endif /* !ICALSET_H */ 181#endif /* !ICALSET_H */
diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c
index cab6a81..f42ff41 100644
--- a/libical/src/libicalss/icalspanlist.c
+++ b/libical/src/libicalss/icalspanlist.c
@@ -30,10 +30,23 @@
30#include "icalspanlist.h" 30#include "icalspanlist.h"
31#include "pvl.h" 31
32#include <stdlib.h> /* for free and malloc */ 32#include <stdlib.h> /* for free and malloc */
33#include <string.h>
33 34
34struct icalspanlist_impl { 35struct icalspanlist_impl {
35 pvl_list spans; 36 pvl_list spans; /**< list of icaltime_span data **/
37 struct icaltimetype start; /**< start time of span **/
38 struct icaltimetype end;/**< end time of span **/
36}; 39};
37 40
38int compare_span(void* a, void* b) 41/** @brief Internal comparison function for two spans
42 *
43 * @param a a spanlist.
44 * @param b another spanlist.
45 *
46 * @return -1, 0, 1 depending on the comparison of the start times.
47 *
48 * Used to insert spans into the tree in sorted order.
49 */
50
51static int compare_span(void* a, void* b)
39{ 52{
@@ -51,16 +64,48 @@ int compare_span(void* a, void* b)
51 64
52icalcomponent* icalspanlist_get_inner(icalcomponent* comp) 65
66/** @brief callback function for collecting spanlists of a
67 * series of events.
68 *
69 * @param comp A valid icalcomponent.
70 * @param span The span to insert into data.
71 * @param data The actual spanlist to insert into
72 *
73 * This callback is used by icalcomponent_foreach_recurrence()
74 * to build up a spanlist.
75 */
76
77static void icalspanlist_new_callback(icalcomponent *comp,
78 struct icaltime_span *span,
79 void *data)
53{ 80{
54 if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ 81 icaltime_span *s;
55 return icalcomponent_get_first_real_component(comp); 82 icalspanlist *sl = (icalspanlist*) data;
56 } else { 83
57 return comp; 84 if (span->is_busy == 0)
58 } 85 return;
86
87 if ((s=(icaltime_span *) malloc(sizeof(icaltime_span))) == 0) {
88 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
89 return;
90 }
91
92 /** copy span data into allocated memory.. **/
93 *s = *span;
94 pvl_insert_ordered(sl->spans, compare_span, (void*)s);
59} 95}
96
60 97
61 98
62void print_span(int c, struct icaltime_span span ); 99/** @brief Make a free list from a set of VEVENT components.
100 *
101 * @param set A valid icalset containing VEVENTS
102 * @param start The free list starts at this date/time
103 * @param end The free list ends at this date/time
104 *
105 * @return A spanlist corresponding to the VEVENTS
106 *
107 * Given a set of components, a start time and an end time
108 * return a spanlist that contains the free/busy times.
109 */
63 110
64
65/* Make a free list from a set of component */
66icalspanlist* icalspanlist_new(icalset *set, 111icalspanlist* icalspanlist_new(icalset *set,
@@ -73,3 +118,3 @@ icalspanlist* icalspanlist_new(icalset *set,
73 icalcomponent_kind kind, inner_kind; 118 icalcomponent_kind kind, inner_kind;
74 struct icalspanlist_impl *sl; 119 icalspanlist *sl;
75 struct icaltime_span *freetime; 120 struct icaltime_span *freetime;
@@ -83,2 +128,4 @@ icalspanlist* icalspanlist_new(icalset *set,
83 sl->spans = pvl_newlist(); 128 sl->spans = pvl_newlist();
129 sl->start = start;
130 sl->end = end;
84 131
@@ -87,6 +134,2 @@ icalspanlist* icalspanlist_new(icalset *set,
87 134
88 printf("Range start: %s",ctime(&range.start));
89 printf("Range end : %s",ctime(&range.end));
90
91
92 /* Get a list of spans of busy time from the events in the set 135 /* Get a list of spans of busy time from the events in the set
@@ -98,4 +141,2 @@ icalspanlist* icalspanlist_new(icalset *set,
98 141
99 struct icaltime_span span;
100
101 kind = icalcomponent_isa(c); 142 kind = icalcomponent_isa(c);
@@ -115,27 +156,8 @@ icalspanlist* icalspanlist_new(icalset *set,
115 icalerror_clear_errno(); 156 icalerror_clear_errno();
116 157
117 span = icalcomponent_get_span(c); 158 icalcomponent_foreach_recurrence(c, start, end,
118 span.is_busy = 1; 159 icalspanlist_new_callback,
119 160 (void*)sl);
120 if(icalerrno != ICAL_NO_ERROR){ 161
121 continue; 162 }
122 }
123
124 if ((range.start < span.end && icaltime_is_null_time(end)) ||
125 (range.start < span.end && range.end > span.start )){
126
127 struct icaltime_span *s;
128
129 if ((s=(struct icaltime_span *)
130 malloc(sizeof(struct icaltime_span))) == 0){
131 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
132 return 0;
133 }
134
135 memcpy(s,&span,sizeof(span));
136
137 pvl_insert_ordered(sl->spans,compare_span,(void*)s);
138
139 }
140 }
141 163
@@ -150,3 +172,3 @@ icalspanlist* icalspanlist_new(icalset *set,
150 { 172 {
151 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 173 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
152 174
@@ -180,3 +202,3 @@ icalspanlist* icalspanlist_new(icalset *set,
180 202
181 last_span = pvl_data(pvl_tail(sl->spans)); 203 last_span = (struct icaltime_span*)pvl_data(pvl_tail(sl->spans));
182 204
@@ -199,5 +221,10 @@ icalspanlist* icalspanlist_new(icalset *set,
199 return sl; 221 return sl;
200
201} 222}
202 223
224/** @brief Destructor.
225 * @param s A valid icalspanlist
226 *
227 * Free memory associated with the spanlist
228 */
229
203void icalspanlist_free(icalspanlist* s) 230void icalspanlist_free(icalspanlist* s)
@@ -205,5 +232,7 @@ void icalspanlist_free(icalspanlist* s)
205 struct icaltime_span *span; 232 struct icaltime_span *span;
206 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)s; 233
207 234 if (s == NULL)
208 while( (span=pvl_pop(impl->spans)) != 0){ 235 return;
236
237 while( (span=pvl_pop(s->spans)) != 0){
209 free(span); 238 free(span);
@@ -211,5 +240,7 @@ void icalspanlist_free(icalspanlist* s)
211 240
212 pvl_free(impl->spans); 241 pvl_free(s->spans);
213 242
214 impl->spans = 0; 243 s->spans = 0;
244
245 free(s);
215} 246}
@@ -217,6 +248,8 @@ void icalspanlist_free(icalspanlist* s)
217 248
218void icalspanlist_dump(icalspanlist* s){ 249/** @brief (Debug) print out spanlist to stdout.
250 * @param sl A valid icalspanlist.
251 */
219 252
253void icalspanlist_dump(icalspanlist* sl){
220 int i = 0; 254 int i = 0;
221 struct icalspanlist_impl* sl = (struct icalspanlist_impl*)s;
222 pvl_elem itr; 255 pvl_elem itr;
@@ -227,3 +260,3 @@ void icalspanlist_dump(icalspanlist* s){
227 { 260 {
228 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 261 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
229 262
@@ -238,2 +271,12 @@ icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
238 271
272
273/** @brief Find next free time span in a spanlist.
274 *
275 * @param sl The spanlist to search.
276 * @param t The time to start looking.
277 *
278 * Given a spanlist and a time, find the next period of time
279 * that is free
280 */
281
239struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 282struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
@@ -241,3 +284,2 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
241{ 284{
242 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl;
243 pvl_elem itr; 285 pvl_elem itr;
@@ -251,6 +293,4 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
251 293
252 /* Is the reference time before the first span? If so, assume 294 itr = pvl_head(sl->spans);
253 that the reference time is free */ 295 s = (struct icaltime_span *)pvl_data(itr);
254 itr = pvl_head(impl->spans);
255 s = (icalproperty*)pvl_data(itr);
256 296
@@ -261,2 +301,4 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
261 301
302 /* Is the reference time before the first span? If so, assume
303 that the reference time is free */
262 if(rangett <s->start ){ 304 if(rangett <s->start ){
@@ -266,3 +308,3 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
266 308
267 if (s->is_busy == 0){ 309 if (s->is_busy == 1){
268 period.end = icaltime_from_timet(s->start,0); 310 period.end = icaltime_from_timet(s->start,0);
@@ -277,4 +319,3 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
277 reference time. */ 319 reference time. */
278 320 for( itr = pvl_head(sl->spans);
279 for( itr = pvl_head(impl->spans);
280 itr != 0; 321 itr != 0;
@@ -282,3 +323,3 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
282 { 323 {
283 s = (icalproperty*)pvl_data(itr); 324 s = (struct icaltime_span *)pvl_data(itr);
284 325
@@ -309 +350,218 @@ struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
309 350
351
352/** @brief Returns an hour-by-hour array of free/busy times over a
353 * given period.
354 *
355 * @param sl A valid icalspanlist
356 * @param delta_t The time slice to divide by, in seconds. Default 3600.
357 *
358 * @return A pointer to an array of integers containing the number of
359 * busy events in each delta_t time period. The final entry
360 * contains the value -1.
361 *
362 * This calculation is somewhat tricky. This is due to the fact that
363 * the time range contains the start time, but does not contain the
364 * end time. To perform a proper calculation we subtract one second
365 * off the end times to get a true containing time.
366 *
367 * Also note that if you supplying a spanlist that does not start or
368 * end on a time boundary divisible by delta_t you may get results
369 * that are not quite what you expect.
370 */
371
372int* icalspanlist_as_freebusy_matrix(icalspanlist* sl, int delta_t) {
373 pvl_elem itr;
374 int spanduration_secs;
375 int *matrix;
376 int matrix_slots;
377 time_t sl_start, sl_end;
378
379 icalerror_check_arg_rz( (sl!=0), "spanlist");
380
381 if (!delta_t)
382 delta_t = 3600;
383
384 /** calculate the start and end time as time_t **/
385 sl_start = icaltime_as_timet_with_zone(sl->start, icaltimezone_get_utc_timezone());
386 sl_end = icaltime_as_timet_with_zone(sl->end, icaltimezone_get_utc_timezone());
387
388
389 /** insure that the time period falls on a time boundary divisable
390 by delta_t */
391
392 sl_start /= delta_t;
393 sl_start *= delta_t;
394
395 sl_end /= delta_t;
396 sl_end *= delta_t;
397
398
399 /** find the duration of this spanlist **/
400 spanduration_secs = sl_end - sl_start;
401
402
403 /** malloc our matrix, add one extra slot for a final -1 **/
404 matrix_slots = spanduration_secs/delta_t + 1;
405
406 matrix = (int*) malloc(sizeof(int) * matrix_slots);
407 if (matrix == NULL) {
408 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
409 return NULL;
410 }
411 memset(matrix, 0, sizeof(int) * matrix_slots);
412 matrix[matrix_slots-1] = -1;
413
414 /* loop through each span and mark the slots in the array */
415
416 for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
417 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
418
419 if (s->is_busy == 1) {
420 int offset_start = s->start/delta_t - sl_start/delta_t;
421 int offset_end = (s->end - 1) /delta_t - sl_start/delta_t + 1;
422 int i;
423
424 if (offset_end >= matrix_slots)
425 offset_end = matrix_slots - 1;
426
427 i = offset_start;
428 for (i=offset_start; i < offset_end; i++) {
429 matrix[i]++;
430 }
431 }
432 }
433 return matrix;
434}
435
436
437/** @brief Return a VFREEBUSY component for the corresponding spanlist
438 *
439 * @param sl A valid icalspanlist, from icalspanlist_new()
440 * @param organizer The organizer specified as MAILTO:user@domain
441 * @param attendee The attendee specified as MAILTO:user@domain
442 *
443 * @return A valid icalcomponent or NULL.
444 *
445 * This function returns a VFREEBUSY component for the given spanlist.
446 * The start time is mapped to DTSTART, the end time to DTEND.
447 * Each busy span is represented as a separate FREEBUSY entry.
448 * An attendee parameter is required, and organizer parameter is
449 * optional.
450 */
451
452icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* sl,
453 const char* organizer,
454 const char* attendee) {
455 icalcomponent *comp;
456 icalproperty *p;
457 struct icaltimetype atime = icaltime_from_timet( time(0),0);
458 pvl_elem itr;
459 icaltimezone *utc_zone;
460 icalparameter *param;
461
462 if (!attendee) {
463 icalerror_set_errno(ICAL_USAGE_ERROR);
464 return 0;
465 }
466
467 utc_zone = icaltimezone_get_utc_timezone ();
468
469 comp = icalcomponent_new_vfreebusy();
470
471 icalcomponent_add_property(comp, icalproperty_new_dtstart(sl->start));
472 icalcomponent_add_property(comp, icalproperty_new_dtend(sl->end));
473 icalcomponent_add_property(comp, icalproperty_new_dtstamp(atime));
474
475 if (organizer) {
476 icalcomponent_add_property(comp, icalproperty_new_organizer(organizer));
477 }
478 icalcomponent_add_property(comp, icalproperty_new_attendee(attendee));
479
480 /* now add the freebusy sections.. */
481
482 for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) {
483 struct icalperiodtype period;
484 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
485
486 if (s->is_busy == 1) {
487
488 period.start = icaltime_from_timet_with_zone (s->start, 0, utc_zone);
489 period.end = icaltime_from_timet_with_zone (s->end, 0, utc_zone);
490 period.duration = icaldurationtype_null_duration();
491
492
493 p = icalproperty_new_freebusy(period);
494 param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSY);
495 icalproperty_add_parameter(p, param);
496
497 icalcomponent_add_property(comp, p);
498 }
499
500 }
501
502 return comp;
503}
504
505
506/** @brief Return a spanlist corresponding to the VFREEBUSY portion of
507 * an icalcomponent.
508 *
509 * @param c A valid icalcomponent.
510 *
511 * @return A valid icalspanlist or NULL if no VFREEBUSY section.
512 *
513 */
514
515
516icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* comp)
517{
518 icalcomponent *inner;
519 icalproperty *prop;
520 icalspanlist *sl;
521
522 icalerror_check_arg_rz((comp != NULL), "comp");
523
524 inner = icalcomponent_get_inner(comp);
525 if (!inner) return NULL;
526
527 if ( ( sl = (icalspanlist*) malloc(sizeof(icalspanlist))) == 0) {
528 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
529 return 0;
530 }
531 sl->spans = pvl_newlist();
532
533 /* cycle through each FREEBUSY property, adding to the spanlist */
534 for (prop = icalcomponent_get_first_property(inner, ICAL_FREEBUSY_PROPERTY);
535 prop != NULL;
536 prop = icalcomponent_get_next_property(inner, ICAL_FREEBUSY_PROPERTY)) {
537 icaltime_span *s = (icaltime_span *) malloc(sizeof(icaltime_span));
538 icalparameter *param;
539 struct icalperiodtype period;
540 icalparameter_fbtype fbtype;
541
542 if (s == 0) {
543 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
544 return 0;
545 }
546
547 param = icalproperty_get_first_parameter(prop, ICAL_FBTYPE_PARAMETER);
548 fbtype = (param) ? icalparameter_get_fbtype(param) : ICAL_FBTYPE_BUSY;
549
550 switch (fbtype) {
551 case ICAL_FBTYPE_FREE:
552 case ICAL_FBTYPE_NONE:
553 case ICAL_FBTYPE_X:
554 s->is_busy = 1;
555 default:
556 s->is_busy = 0;
557 }
558
559 period = icalproperty_get_freebusy(prop);
560 s->start = icaltime_as_timet_with_zone(period.start, icaltimezone_get_utc_timezone());
561 s->end = icaltime_as_timet_with_zone(period.end, icaltimezone_get_utc_timezone());
562;
563 pvl_insert_ordered(sl->spans, compare_span, (void*)s);
564 }
565 /** @todo calculate start/end limits.. fill in holes? **/
566 return sl;
567}
diff --git a/libical/src/libicalss/icalspanlist.h b/libical/src/libicalss/icalspanlist.h
index 83cb1c8..91f0acb 100644
--- a/libical/src/libicalss/icalspanlist.h
+++ b/libical/src/libicalss/icalspanlist.h
@@ -30,5 +30,13 @@
30 30
31typedef void icalspanlist; 31/** @file icalspanlist.h
32 * @brief Code that supports collections of free/busy spans of time
33 */
34
35typedef struct icalspanlist_impl icalspanlist;
36
37
38/** @brief Constructor
39 * Make a free list from a set of component. Start and end should be in UTC
40 */
32 41
33/* Make a free list from a set of component. Start and end should be in UTC */
34icalspanlist* icalspanlist_new(icalset *set, 42icalspanlist* icalspanlist_new(icalset *set,
@@ -37,4 +45,7 @@ icalspanlist* icalspanlist_new(icalset *set,
37 45
46/** @brief Destructor
47 */
38void icalspanlist_free(icalspanlist* spl); 48void icalspanlist_free(icalspanlist* spl);
39 49
50/* Unimplemented functions */
40icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 51icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
@@ -42,5 +53,6 @@ icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
42 53
43/* Get first free or busy time after time t. all times are in UTC */ 54/** Get first next free time after time t. all times are in UTC. */
44struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 55struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
45 struct icaltimetype t); 56 struct icaltimetype t);
57/** Get first next busy time after time t. all times are in UTC. */
46struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 58struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
@@ -50,2 +62,13 @@ void icalspanlist_dump(icalspanlist* s);
50 62
63/** @brief Return a valid VFREEBUSY component for this span */
64icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
65 const char* organizer,
66 const char* attendee);
67
68/** @brief Return an integer matrix of total events per delta_t timespan */
69int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
70
71/** @brief Construct an icalspanlist from a VFREEBUSY component */
72icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
73
51#endif 74#endif
diff --git a/libical/src/libicalss/icalss.h b/libical/src/libicalss/icalss.h
index cd07919..8930e11 100644
--- a/libical/src/libicalss/icalss.h
+++ b/libical/src/libicalss/icalss.h
@@ -1 +1,7 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4/*
5 $Id$
6*/
1/* -*- Mode: C -*- */ 7/* -*- Mode: C -*- */
@@ -6,4 +12,2 @@
6 12
7 $Id$
8 $Locker$
9 13
@@ -31,5 +35,11 @@
31 35
32typedef void icalgauge; 36/** @file icalgauge.h
37 * @brief Routines implementing a filter for ical components
38 */
33 39
34icalgauge* icalgauge_new_from_sql(char* sql); 40typedef struct icalgauge_impl icalgauge;
41
42icalgauge* icalgauge_new_from_sql(char* sql, int expand);
43
44int icalgauge_get_expand(icalgauge* gauge);
35 45
@@ -39,11 +49,15 @@ char* icalgauge_as_sql(icalcomponent* gauge);
39 49
40void icalgauge_dump(icalcomponent* gauge); 50void icalgauge_dump(icalgauge* gauge);
51
41 52
42/* Return true is comp matches the gauge. The component must be in 53/** @brief Return true if comp matches the gauge.
43 cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL 54 *
44 sub component */ 55 * The component must be in
56 * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
57 * sub component
58 */
45int icalgauge_compare(icalgauge* g, icalcomponent* comp); 59int icalgauge_compare(icalgauge* g, icalcomponent* comp);
46 60
47/* Clone the component, but only return the properties specified in 61/** Clone the component, but only return the properties
48 the gauge */ 62 * specified in the gauge */
49icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); 63icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
@@ -52,6 +66,5 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
52/* -*- Mode: C -*- */ 66/* -*- Mode: C -*- */
53/*====================================================================== 67/**
54 FILE: icalset.h 68 @file icalset.h
55 CREATOR: eric 28 November 1999 69 @author eric 28 November 1999
56
57 70
@@ -60,9 +73,10 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
60 73
61 icalfileset Store componetns in a single file 74 icalfileset Store components in a single file
62 icaldirset Store components in multiple files in a directory 75 icaldirset Store components in multiple files in a directory
76 icalbdbset Store components in a Berkeley DB File
63 icalheapset Store components on the heap 77 icalheapset Store components on the heap
64 icalmysqlset Store components in a mysql database. 78 icalmysqlset Store components in a mysql database.
79**/
65 80
66 $Id$ 81/*
67 $Locker$
68 82
@@ -99,9 +113,3 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
99 113
100#ifdef _WIN32 114typedef struct icalset_impl icalset;
101#define mode_t int
102#endif
103
104
105
106typedef void icalset;
107 115
@@ -110,14 +118,67 @@ typedef enum icalset_kind {
110 ICAL_DIR_SET, 118 ICAL_DIR_SET,
111 ICAL_HEAP_SET, 119 ICAL_BDB_SET
112 ICAL_MYSQL_SET,
113 ICAL_CAP_SET
114} icalset_kind; 120} icalset_kind;
115 121
122typedef struct icalsetiter
123{
124 icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */
125 icalgauge* gauge;
126 icalrecur_iterator* ritr; /*the last iterator*/
127 icalcomponent* last_component; /*the pending recurring component to be processed */
128 const char* tzid; /* the calendar's timezone id */
129} icalsetiter;
130
131struct icalset_impl {
132 icalset_kind kind;
133 int size;
134 char *dsn;
135 icalset* (*init)(icalset* set, const char *dsn, void *options);
136 void (*free)(icalset* set);
137 const char* (*path)(icalset* set);
138 void (*mark)(icalset* set);
139 icalerrorenum (*commit)(icalset* set);
140 icalerrorenum (*add_component)(icalset* set, icalcomponent* comp);
141 icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp);
142 int (*count_components)(icalset* set,
143 icalcomponent_kind kind);
144 icalerrorenum (*select)(icalset* set, icalgauge* gauge);
145 void (*clear)(icalset* set);
146 icalcomponent* (*fetch)(icalset* set, const char* uid);
147 icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp);
148 int (*has_uid)(icalset* set, const char* uid);
149 icalerrorenum (*modify)(icalset* set, icalcomponent *old,
150 icalcomponent *newc);
151 icalcomponent* (*get_current_component)(icalset* set);
152 icalcomponent* (*get_first_component)(icalset* set);
153 icalcomponent* (*get_next_component)(icalset* set);
154 icalsetiter (*icalset_begin_component)(icalset* set,
155 icalcomponent_kind kind, icalgauge* gauge);
156 icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i);
157 icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i);
158};
159
160/** @brief Register a new derived class */
161int icalset_register_class(icalset *set);
162
163
164/** @brief Generic icalset constructor
165 *
166 * @param kind The type of icalset to create
167 * @param dsn Data Source Name - usually a pathname or DB handle
168 * @param options Any implementation specific options
169 *
170 * @return A valid icalset reference or NULL if error.
171 *
172 * This creates any of the icalset types available.
173 */
174
175icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
116 176
117/* Create a specific derived type of set */
118icalset* icalset_new_file(const char* path); 177icalset* icalset_new_file(const char* path);
178icalset* icalset_new_file_reader(const char* path);
179icalset* icalset_new_file_writer(const char* path);
180
119icalset* icalset_new_dir(const char* path); 181icalset* icalset_new_dir(const char* path);
120icalset* icalset_new_heap(void); 182icalset* icalset_new_file_reader(const char* path);
121icalset* icalset_new_mysql(const char* path); 183icalset* icalset_new_file_writer(const char* path);
122/*icalset* icalset_new_cap(icalcstp* cstp);*/
123 184
@@ -127,5 +188,7 @@ const char* icalset_path(icalset* set);
127 188
128/* Mark the cluster as changed, so it will be written to disk when it 189/** Mark the cluster as changed, so it will be written to disk when it
129 is freed. Commit writes to disk immediately*/ 190 is freed. **/
130void icalset_mark(icalset* set); 191void icalset_mark(icalset* set);
192
193/** Write changes to disk immediately */
131icalerrorenum icalset_commit(icalset* set); 194icalerrorenum icalset_commit(icalset* set);
@@ -138,9 +201,12 @@ int icalset_count_components(icalset* set,
138 201
139/* Restrict the component returned by icalset_first, _next to those 202/** Restrict the component returned by icalset_first, _next to those
140 that pass the gauge. _clear removes the gauge. */ 203 that pass the gauge. */
141icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); 204icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
205
206/** Clears the gauge defined by icalset_select() */
142void icalset_clear_select(icalset* set); 207void icalset_clear_select(icalset* set);
143 208
144/* Get a component by uid */ 209/** Get a component by uid */
145icalcomponent* icalset_fetch(icalset* set, const char* uid); 210icalcomponent* icalset_fetch(icalset* set, const char* uid);
211
146int icalset_has_uid(icalset* set, const char* uid); 212int icalset_has_uid(icalset* set, const char* uid);
@@ -148,3 +214,3 @@ icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c);
148 214
149/* Modify components according to the MODIFY method of CAP. Works on 215/** Modify components according to the MODIFY method of CAP. Works on
150 the currently selected components. */ 216 the currently selected components. */
@@ -153,3 +219,3 @@ icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
153 219
154/* Iterate through the components. If a guage has been defined, these 220/** Iterate through the components. If a guage has been defined, these
155 will skip over components that do not pass the gauge */ 221 will skip over components that do not pass the gauge */
@@ -160,2 +226,17 @@ icalcomponent* icalset_get_next_component(icalset* set);
160 226
227/** External Iterator with gauge - for thread safety */
228extern icalsetiter icalsetiter_null;
229
230icalsetiter icalset_begin_component(icalset* set,
231 icalcomponent_kind kind, icalgauge* gauge);
232
233/** Default _next, _prior, _deref for subclasses that use single cluster */
234icalcomponent* icalsetiter_next(icalsetiter* i);
235icalcomponent* icalsetiter_prior(icalsetiter* i);
236icalcomponent* icalsetiter_deref(icalsetiter* i);
237
238/** for subclasses that use multiple clusters that require specialized cluster traversal */
239icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
240icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
241
161#endif /* !ICALSET_H */ 242#endif /* !ICALSET_H */
@@ -166,2 +247,59 @@ icalcomponent* icalset_get_next_component(icalset* set);
166/*====================================================================== 247/*======================================================================
248 FILE: icalcluster.h
249 CREATOR: eric 23 December 1999
250
251
252
253 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
254
255 This program is free software; you can redistribute it and/or modify
256 it under the terms of either:
257
258 The LGPL as published by the Free Software Foundation, version
259 2.1, available at: http://www.fsf.org/copyleft/lesser.html
260
261 Or:
262
263 The Mozilla Public License Version 1.0. You may obtain a copy of
264 the License at http://www.mozilla.org/MPL/
265
266 The Original Code is eric. The Initial Developer of the Original
267 Code is Eric Busboom
268
269
270======================================================================*/
271
272#ifndef ICALCLUSTER_H
273#define ICALCLUSTER_H
274
275
276typedef struct icalcluster_impl icalcluster;
277
278icalcluster* icalcluster_new(const char *key, icalcomponent *data);
279icalcluster* icalcluster_new_clone(const icalcluster *cluster);
280
281void icalcluster_free(icalcluster *cluster);
282
283const char* icalcluster_key(icalcluster *cluster);
284int icalcluster_is_changed(icalcluster *cluster);
285void icalcluster_mark(icalcluster *cluster);
286void icalcluster_commit(icalcluster *cluster);
287
288icalcomponent* icalcluster_get_component(icalcluster* cluster);
289int icalcluster_count_components(icalcluster *cluster, icalcomponent_kind kind);
290icalerrorenum icalcluster_add_component(icalcluster* cluster,
291 icalcomponent* child);
292icalerrorenum icalcluster_remove_component(icalcluster* cluster,
293 icalcomponent* child);
294
295icalcomponent* icalcluster_get_current_component(icalcluster* cluster);
296icalcomponent* icalcluster_get_first_component(icalcluster* cluster);
297icalcomponent* icalcluster_get_next_component(icalcluster* cluster);
298
299#endif /* !ICALCLUSTER_H */
300
301
302
303/* -*- Mode: C -*- */
304/*======================================================================
167 FILE: icalfileset.h 305 FILE: icalfileset.h
@@ -170,4 +308,2 @@ icalcomponent* icalset_get_next_component(icalset* set);
170 308
171 $Id$
172 $Locker$
173 309
@@ -199,22 +335,23 @@ icalcomponent* icalset_get_next_component(icalset* set);
199 335
200extern int icalfileset_safe_saves; 336#ifdef WIN32
337#define mode_t int
338#endif
201 339
202typedef void icalfileset; 340extern int icalfileset_safe_saves;
203 341
342typedef struct icalfileset_impl icalfileset;
204 343
205/* icalfileset 344icalset* icalfileset_new(const char* path);
206 icalfilesetfile 345icalset* icalfileset_new_reader(const char* path);
207 icalfilesetdir 346icalset* icalfileset_new_writer(const char* path);
208*/
209 347
348icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
210 349
211icalfileset* icalfileset_new(const char* path); 350icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
212 351
213/* Like _new, but takes open() flags for opening the file */ 352icalcluster* icalfileset_produce_icalcluster(const char *path);
214icalfileset* icalfileset_new_open(const char* path,
215 int flags, mode_t mode);
216 353
217void icalfileset_free(icalfileset* cluster); 354void icalfileset_free(icalset* cluster);
218 355
219const char* icalfileset_path(icalfileset* cluster); 356const char* icalfileset_path(icalset* cluster);
220 357
@@ -222,41 +359,68 @@ const char* icalfileset_path(icalfileset* cluster);
222 is freed. Commit writes to disk immediately. */ 359 is freed. Commit writes to disk immediately. */
223void icalfileset_mark(icalfileset* cluster); 360void icalfileset_mark(icalset* set);
224icalerrorenum icalfileset_commit(icalfileset* cluster); 361icalerrorenum icalfileset_commit(icalset* set);
225 362
226icalerrorenum icalfileset_add_component(icalfileset* cluster, 363icalerrorenum icalfileset_add_component(icalset* set,
227 icalcomponent* child); 364 icalcomponent* child);
228 365
229icalerrorenum icalfileset_remove_component(icalfileset* cluster, 366icalerrorenum icalfileset_remove_component(icalset* set,
230 icalcomponent* child); 367 icalcomponent* child);
231 368
232int icalfileset_count_components(icalfileset* cluster, 369int icalfileset_count_components(icalset* set,
233 icalcomponent_kind kind); 370 icalcomponent_kind kind);
234 371
235/* Restrict the component returned by icalfileset_first, _next to those 372/**
236 that pass the gauge. _clear removes the gauge */ 373 * Restrict the component returned by icalfileset_first, _next to those
237icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge); 374 * that pass the gauge. _clear removes the gauge
238void icalfileset_clear(icalfileset* store); 375 */
376icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
239 377
240/* Get and search for a component by uid */ 378/** clear the gauge **/
241icalcomponent* icalfileset_fetch(icalfileset* cluster, const char* uid); 379void icalfileset_clear(icalset* set);
242int icalfileset_has_uid(icalfileset* cluster, const char* uid);
243icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *c);
244 380
381/** Get and search for a component by uid **/
382icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
383int icalfileset_has_uid(icalset* set, const char* uid);
384icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
245 385
246/* Modify components according to the MODIFY method of CAP. Works on 386
247 the currently selected components. */ 387/**
248icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *oldcomp, 388 * Modify components according to the MODIFY method of CAP. Works on the
389 * currently selected components.
390 */
391icalerrorenum icalfileset_modify(icalset* set,
392 icalcomponent *oldcomp,
249 icalcomponent *newcomp); 393 icalcomponent *newcomp);
250 394
251/* Iterate through components. If a guage has been defined, these 395/* Iterate through components. If a gauge has been defined, these
252 will skip over components that do not pass the gauge */ 396 will skip over components that do not pass the gauge */
253 397
254icalcomponent* icalfileset_get_current_component (icalfileset* cluster); 398icalcomponent* icalfileset_get_current_component (icalset* cluster);
255icalcomponent* icalfileset_get_first_component(icalfileset* cluster); 399icalcomponent* icalfileset_get_first_component(icalset* cluster);
256icalcomponent* icalfileset_get_next_component(icalfileset* cluster); 400icalcomponent* icalfileset_get_next_component(icalset* cluster);
257/* Return a reference to the internal component. You probably should 401
402/* External iterator for thread safety */
403icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
404icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
405icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
406
407/** Return a reference to the internal component. You probably should
258 not be using this. */ 408 not be using this. */
259 409
260icalcomponent* icalfileset_get_component(icalfileset* cluster); 410icalcomponent* icalfileset_get_component(icalset* cluster);
411
412/**
413 * @brief options for opening an icalfileset.
414 *
415 * These options should be passed to the icalset_new() function
416 */
261 417
418typedef struct icalfileset_options {
419 int flags; /**< flags for open() O_RDONLY, etc */
420 mode_t mode; /**< file mode */
421 int safe_saves;/**< to lock or not */
422 icalcluster *cluster;/**< use this cluster to initialize data */
423} icalfileset_options;
424
425extern icalfileset_options icalfileset_options_default;
262 426
@@ -272,4 +436,2 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
272 436
273 $Id$
274 $Locker$
275 437
@@ -301,10 +463,14 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
301 463
302typedef void icaldirset; 464typedef struct icaldirset_impl icaldirset;
303 465
466icalset* icaldirset_new(const char* path);
304 467
305icaldirset* icaldirset_new(const char* path); 468icalset* icaldirset_new_reader(const char* path);
469icalset* icaldirset_new_writer(const char* path);
306 470
307void icaldirset_free(icaldirset* store);
308 471
309const char* icaldirset_path(icaldirset* store); 472icalset* icaldirset_init(icalset* set, const char *dsn, void *options);
473void icaldirset_free(icalset* set);
474
475const char* icaldirset_path(icalset* set);
310 476
@@ -312,9 +478,9 @@ const char* icaldirset_path(icaldirset* store);
312 is freed. Commit writes to disk immediately*/ 478 is freed. Commit writes to disk immediately*/
313void icaldirset_mark(icaldirset* store); 479void icaldirset_mark(icalset* set);
314icalerrorenum icaldirset_commit(icaldirset* store); 480icalerrorenum icaldirset_commit(icalset* set);
315 481
316icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent* comp); 482icalerrorenum icaldirset_add_component(icalset* store, icalcomponent* comp);
317icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent* comp); 483icalerrorenum icaldirset_remove_component(icalset* store, icalcomponent* comp);
318 484
319int icaldirset_count_components(icaldirset* store, 485int icaldirset_count_components(icalset* store,
320 icalcomponent_kind kind); 486 icalcomponent_kind kind);
@@ -323,9 +489,9 @@ int icaldirset_count_components(icaldirset* store,
323 that pass the gauge. _clear removes the gauge. */ 489 that pass the gauge. _clear removes the gauge. */
324icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge); 490icalerrorenum icaldirset_select(icalset* store, icalgauge* gauge);
325void icaldirset_clear(icaldirset* store); 491void icaldirset_clear(icalset* store);
326 492
327/* Get a component by uid */ 493/* Get a component by uid */
328icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid); 494icalcomponent* icaldirset_fetch(icalset* store, const char* uid);
329int icaldirset_has_uid(icaldirset* store, const char* uid); 495int icaldirset_has_uid(icalset* store, const char* uid);
330icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c); 496icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c);
331 497
@@ -333,11 +499,20 @@ icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c);
333 the currently selected components. */ 499 the currently selected components. */
334icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc, 500icalerrorenum icaldirset_modify(icalset* store, icalcomponent *oldc,
335 icalcomponent *newc); 501 icalcomponent *newc);
336 502
337/* Iterate through the components. If a guage has been defined, these 503/* Iterate through the components. If a gauge has been defined, these
338 will skip over components that do not pass the gauge */ 504 will skip over components that do not pass the gauge */
339 505
340icalcomponent* icaldirset_get_current_component(icaldirset* store); 506icalcomponent* icaldirset_get_current_component(icalset* store);
341icalcomponent* icaldirset_get_first_component(icaldirset* store); 507icalcomponent* icaldirset_get_first_component(icalset* store);
342icalcomponent* icaldirset_get_next_component(icaldirset* store); 508icalcomponent* icaldirset_get_next_component(icalset* store);
509
510/* External iterator for thread safety */
511icalsetiter icaldirset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
512icalcomponent* icaldirsetiter_to_next(icalset* set, icalsetiter* i);
513icalcomponent* icaldirsetiter_to_prior(icalset* set, icalsetiter* i);
514
515typedef struct icaldirset_options {
516 int flags; /**< flags corresponding to the open() system call O_RDWR, etc. */
517} icaldirset_options;
343 518
@@ -353,4 +528,2 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
353 528
354 $Id$
355 $Locker$
356 529
@@ -385,3 +558,3 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
385 558
386typedef void icalcalendar; 559typedef struct icalcalendar_impl icalcalendar;
387 560
@@ -418,4 +591,2 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
418 591
419 $Id$
420 $Locker$
421 592
@@ -441,35 +612,3 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
441 612
442 613icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
443typedef enum icalclass {
444 ICAL_NO_CLASS,
445 ICAL_PUBLISH_NEW_CLASS,
446 ICAL_PUBLISH_UPDATE_CLASS,
447 ICAL_PUBLISH_FREEBUSY_CLASS,
448 ICAL_REQUEST_NEW_CLASS,
449 ICAL_REQUEST_UPDATE_CLASS,
450 ICAL_REQUEST_RESCHEDULE_CLASS,
451 ICAL_REQUEST_DELEGATE_CLASS,
452 ICAL_REQUEST_NEW_ORGANIZER_CLASS,
453 ICAL_REQUEST_FORWARD_CLASS,
454 ICAL_REQUEST_STATUS_CLASS,
455 ICAL_REQUEST_FREEBUSY_CLASS,
456 ICAL_REPLY_ACCEPT_CLASS,
457 ICAL_REPLY_DECLINE_CLASS,
458 ICAL_REPLY_DELEGATE_CLASS,
459 ICAL_REPLY_CRASHER_ACCEPT_CLASS,
460 ICAL_REPLY_CRASHER_DECLINE_CLASS,
461 ICAL_ADD_INSTANCE_CLASS,
462 ICAL_CANCEL_EVENT_CLASS,
463 ICAL_CANCEL_INSTANCE_CLASS,
464 ICAL_CANCEL_ALL_CLASS,
465 ICAL_REFRESH_CLASS,
466 ICAL_COUNTER_CLASS,
467 ICAL_DECLINECOUNTER_CLASS,
468 ICAL_MALFORMED_CLASS,
469 ICAL_OBSOLETE_CLASS, /* 21 */
470 ICAL_MISSEQUENCED_CLASS, /* 22 */
471 ICAL_UNKNOWN_CLASS /* 23 */
472} ical_class;
473
474ical_class icalclassify(icalcomponent* c,icalcomponent* match,
475 const char* user); 614 const char* user);
@@ -478,3 +617,3 @@ icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp);
478 617
479char* icalclassify_class_to_string(ical_class iclass); 618char* icalclassify_class_to_string(icalproperty_xlicclass c);
480 619
@@ -493,4 +632,2 @@ char* icalclassify_class_to_string(ical_class iclass);
493 632
494 $Id$
495 $Locker$
496 633
@@ -515,5 +652,13 @@ char* icalclassify_class_to_string(ical_class iclass);
515 652
516typedef void icalspanlist; 653/** @file icalspanlist.h
654 * @brief Code that supports collections of free/busy spans of time
655 */
656
657typedef struct icalspanlist_impl icalspanlist;
658
659
660/** @brief Constructor
661 * Make a free list from a set of component. Start and end should be in UTC
662 */
517 663
518/* Make a free list from a set of component. Start and end should be in UTC */
519icalspanlist* icalspanlist_new(icalset *set, 664icalspanlist* icalspanlist_new(icalset *set,
@@ -522,4 +667,7 @@ icalspanlist* icalspanlist_new(icalset *set,
522 667
668/** @brief Destructor
669 */
523void icalspanlist_free(icalspanlist* spl); 670void icalspanlist_free(icalspanlist* spl);
524 671
672/* Unimplemented functions */
525icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 673icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
@@ -527,5 +675,6 @@ icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl);
527 675
528/* Get first free or busy time after time t. all times are in UTC */ 676/** Get first next free time after time t. all times are in UTC. */
529struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl, 677struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
530 struct icaltimetype t); 678 struct icaltimetype t);
679/** Get first next busy time after time t. all times are in UTC. */
531struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 680struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
@@ -535,2 +684,13 @@ void icalspanlist_dump(icalspanlist* s);
535 684
685/** @brief Return a valid VFREEBUSY component for this span */
686icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* s_in,
687 const char* organizer,
688 const char* attendee);
689
690/** @brief Return an integer matrix of total events per delta_t timespan */
691int *icalspanlist_as_freebusy_matrix(icalspanlist* span, int delta_t);
692
693/** @brief Construct an icalspanlist from a VFREEBUSY component */
694icalspanlist *icalspanlist_from_vfreebusy(icalcomponent* c);
695
536#endif 696#endif
@@ -545,4 +705,2 @@ void icalspanlist_dump(icalspanlist* s);
545 705
546 $Id$
547 $Locker$
548 706
@@ -609,277 +767,4 @@ icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
609#endif /* ICALMESSAGE_H*/ 767#endif /* ICALMESSAGE_H*/
610/* -*- Mode: C -*- */ 768#ifdef __cplusplus
611/*======================================================================
612 FILE: icalcstp.h
613 CREATOR: eric 20 April 1999
614
615 $Id$
616
617
618 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
619
620 This program is free software; you can redistribute it and/or modify
621 it under the terms of either:
622
623 The LGPL as published by the Free Software Foundation, version
624 2.1, available at: http://www.fsf.org/copyleft/lesser.html
625
626 Or:
627
628 The Mozilla Public License Version 1.0. You may obtain a copy of
629 the License at http://www.mozilla.org/MPL/
630
631 The original code is icalcstp.h
632
633======================================================================*/
634
635
636#ifndef ICALCSTP_H
637#define ICALCSTP_H
638
639
640
641/* Connection state, from the state machine in RFC2445 */
642enum cstps_state {
643 NO_STATE,
644 CONNECTED,
645 AUTHENTICATED,
646 IDENTIFIED,
647 DISCONNECTED,
648 RECEIVE
649};
650
651/* CSTP Commands that a client can issue to a server */
652typedef enum icalcstp_command {
653 ICAL_ABORT_COMMAND,
654 ICAL_AUTHENTICATE_COMMAND,
655 ICAL_CAPABILITY_COMMAND,
656 ICAL_CONTINUE_COMMAND,
657 ICAL_CALIDEXPAND_COMMAND,
658 ICAL_IDENTIFY_COMMAND,
659 ICAL_DISCONNECT_COMMAND,
660 ICAL_SENDDATA_COMMAND,
661 ICAL_STARTTLS_COMMAND,
662 ICAL_UPNEXPAND_COMMAND,
663 ICAL_COMPLETE_COMMAND,
664 ICAL_UNKNOWN_COMMAND
665} icalcstp_command;
666
667
668
669/* A statement is a combination of command or response code and a
670 component that the server and client exchage with each other. */
671struct icalcstp_statement {
672 icalcstp_command command;
673 char* str_data; /* If non-NUll use as arguments to command */
674 int int_data; /* If non-NULL use as arguments to command */
675
676 icalrequeststatus code;
677
678 icalcomponent* data;
679}; 769};
680 770#endif
681const char* icalcstp_command_to_string(icalcstp_command command);
682icalcstp_command icalcstp_string_to_command(const char* str);
683
684#endif /* !ICALCSTP_H */
685
686
687
688/* -*- Mode: C -*- */
689/*======================================================================
690 FILE: icalcstpclient.h
691 CREATOR: eric 4 Feb 01
692
693 $Id$
694
695
696 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
697
698 This program is free software; you can redistribute it and/or modify
699 it under the terms of either:
700
701 The LGPL as published by the Free Software Foundation, version
702 2.1, available at: http://www.fsf.org/copyleft/lesser.html
703
704 Or:
705
706 The Mozilla Public License Version 1.0. You may obtain a copy of
707 the License at http://www.mozilla.org/MPL/
708
709 The original code is icalcstp.h
710
711======================================================================*/
712
713
714#ifndef ICALCSTPC_H
715#define ICALCSTPC_H
716
717
718/********************** Client (Sender) Interfaces **************************/
719
720/* How to use:
721
722 1) Construct a new icalcstpc
723 2) Issue a command by calling one of the command routines.
724 3) Repeat until both call icalcstpc_next_output and
725 icalcstpc_next_input return 0:
726 3a) Call icalcstpc_next_output. Send string to server.
727 3b) Get string from server, & give to icalcstp_next_input()
728 4) Iterate with icalcstpc_first_response & icalcstp_next_response to
729 get the servers responses
730 5) Repeat at #2
731*/
732
733
734typedef void icalcstpc;
735
736/* Response code sent by the server. */
737 typedef struct icalcstpc_response {
738 icalrequeststatus code;
739 char *arg; /* These strings are owned by libical */
740 char *debug_text;
741 char *more_text;
742 void* result;
743} icalcstpc_response;
744
745
746icalcstpc* icalcstpc_new();
747
748void icalcstpc_free(icalcstpc* cstpc);
749
750int icalcstpc_set_timeout(icalcstpc* cstp, int sec);
751
752
753/* Get the next string to send to the server */
754char* icalcstpc_next_output(icalcstpc* cstp, char* line);
755
756/* process the next string from the server */
757int icalcstpc_next_input(icalcstpc* cstp, char * line);
758
759/* After icalcstpc_next_input returns a 0, there are responses
760 ready. use these to get them */
761icalcstpc_response icalcstpc_first_response(icalcstpc* cstp);
762icalcstpc_response icalcstpc_next_response(icalcstpc* cstp);
763
764/* Issue a command */
765icalerrorenum icalcstpc_abort(icalcstpc* cstp);
766icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
767 char* init_data, char* f(char*) );
768icalerrorenum icalcstpc_capability(icalcstpc* cstp);
769icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid);
770icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time);
771icalerrorenum icalcstpc_disconnect(icalcstpc* cstp);
772icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id);
773icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
774 char* init_data, char* f(char*));
775icalerrorenum icalcstpc_senddata(icalcstpc* cstp, unsigned int time,
776 icalcomponent *comp);
777icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid);
778icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
779 icalcomponent *comp);
780
781
782#endif /* !ICALCSTPC_H */
783
784
785
786/* -*- Mode: C -*- */
787/*======================================================================
788 FILE: icalcstpserver.h
789 CREATOR: eric 13 Feb 01
790
791 $Id$
792
793
794 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
795
796 This program is free software; you can redistribute it and/or modify
797 it under the terms of either:
798
799 The LGPL as published by the Free Software Foundation, version
800 2.1, available at: http://www.fsf.org/copyleft/lesser.html
801
802 Or:
803
804 The Mozilla Public License Version 1.0. You may obtain a copy of
805 the License at http://www.mozilla.org/MPL/
806
807 The original code is icalcstp.h
808
809======================================================================*/
810
811
812#ifndef ICALCSTPS_H
813#define ICALCSTPS_H
814
815
816
817/********************** Server (Reciever) Interfaces *************************/
818
819/* On the server side, the caller will recieve data from the incoming
820 socket and pass it to icalcstps_next_input. The caller then takes
821 the return from icalcstps_next_outpu and sends it out through the
822 socket. This gives the caller a point of control. If the cstp code
823 connected to the socket itself, it would be hard for the caller to
824 do anything else after the cstp code was started.
825
826 All of the server and client command routines will generate
827 response codes. On the server side, these responses will be turned
828 into text and sent to the client. On the client side, the reponse
829 is the one sent from the server.
830
831 Since each command can return multiple responses, the responses are
832 stored in the icalcstps object and are accesses by
833 icalcstps_first_response() and icalcstps_next_response()
834
835 How to use:
836
837 1) Construct a new icalcstps, bound to your code via stubs
838 2) Repeat forever:
839 2a) Get string from client & give to icalcstps_next_input()
840 2b) Repeat until icalcstp_next_output returns 0:
841 2b1) Call icalcstps_next_output.
842 2b2) Send string to client.
843*/
844
845
846
847typedef void icalcstps;
848
849/* Pointers to the rountines that
850 icalcstps_process_incoming will call when it recognizes a CSTP
851 command in the data. BTW, the CONTINUE command is named 'cont'
852 because 'continue' is a C keyword */
853
854struct icalcstps_commandfp {
855 icalerrorenum (*abort)(icalcstps* cstp);
856 icalerrorenum (*authenticate)(icalcstps* cstp, char* mechanism,
857 char* data);
858 icalerrorenum (*calidexpand)(icalcstps* cstp, char* calid);
859 icalerrorenum (*capability)(icalcstps* cstp);
860 icalerrorenum (*cont)(icalcstps* cstp, unsigned int time);
861 icalerrorenum (*identify)(icalcstps* cstp, char* id);
862 icalerrorenum (*disconnect)(icalcstps* cstp);
863 icalerrorenum (*sendata)(icalcstps* cstp, unsigned int time,
864 icalcomponent *comp);
865 icalerrorenum (*starttls)(icalcstps* cstp, char* command,
866 char* data);
867 icalerrorenum (*upnexpand)(icalcstps* cstp, char* upn);
868 icalerrorenum (*unknown)(icalcstps* cstp, char* command, char* data);
869};
870
871
872
873icalcstps* icalcstps_new(struct icalcstps_commandfp stubs);
874
875void icalcstps_free(icalcstps* cstp);
876
877int icalcstps_set_timeout(icalcstps* cstp, int sec);
878
879/* Get the next string to send to the client */
880char* icalcstps_next_output(icalcstps* cstp);
881
882/* process the next string from the client */
883int icalcstps_next_input(icalcstps* cstp);
884
885#endif /* ICALCSTPS */
diff --git a/libical/src/libicalss/icalsslexer.c b/libical/src/libicalss/icalsslexer.c
index e10bcd3..28d1b66 100644
--- a/libical/src/libicalss/icalsslexer.c
+++ b/libical/src/libicalss/icalsslexer.c
@@ -1 +1,10 @@
1#define YY_REENTRANT 1
2#define YY_TEXT_IS_ARRAY
3#define YY_REENTRANT_BISON_PURE 1
4#ifndef YY_REENTRANT
5#define yytext sstext
6#define yyleng ssleng
7#define yyin ssin
8#define yyout ssout
9#endif
1#define yy_create_buffer ss_create_buffer 10#define yy_create_buffer ss_create_buffer
@@ -10,16 +19,29 @@
10#define yy_switch_to_buffer ss_switch_to_buffer 19#define yy_switch_to_buffer ss_switch_to_buffer
11#define yyin ssin
12#define yyleng ssleng
13#define yylex sslex 20#define yylex sslex
14#define yyout ssout
15#define yyrestart ssrestart 21#define yyrestart ssrestart
16#define yytext sstext 22#define yylex_init sslex_init
23#define yylex_destroy sslex_destroy
24#define yyget_extra ssget_extra
25#define yyset_extra ssset_extra
26#define yyget_in ssget_in
27#define yyset_in ssset_in
28#define yyget_out ssget_out
29#define yyset_out ssset_out
30#define yyget_leng ssget_leng
31#define yyget_text ssget_text
32#define yyget_lineno ssget_lineno
33#define yyset_lineno ssset_lineno
34#ifdef YY_REENTRANT_BISON_PURE
35#define yyget_lval ssget_lval
36#define yyset_lval ssset_lval
37#ifdef YYLTYPE
38#define yyget_lloc ssget_lloc
39#define yyset_lloc ssset_lloc
40#endif
41#endif
17#define yywrap sswrap 42#define yywrap sswrap
18 43
44/* -*-C-*- */
19/* A lexical scanner generated by flex */ 45/* A lexical scanner generated by flex */
20 46
21/* Scanner skeleton version:
22 * $Header$
23 */
24
25#define FLEX_SCANNER 47#define FLEX_SCANNER
@@ -28,20 +50,10 @@
28 50
51/* %- */
52/* begin standard C headers. */
29#include <stdio.h> 53#include <stdio.h>
30// Eugen C. <eug@thekompany.com> 54#include <errno.h>
31#include <defines.h> 55#include <stdlib.h>
32#ifndef _QTWIN_ 56/* end standard C headers. */
33#include <unistd.h> 57/* %+ */
34#else 58/* %* */
35#include <io.h>
36#endif
37// Eugen C. <eug@thekompany.com>
38
39
40/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
41#ifdef c_plusplus
42#ifndef __cplusplus
43#define __cplusplus
44#endif
45#endif
46
47 59
@@ -49,3 +61,4 @@
49 61
50#include <stdlib.h> 62/* %+ */
63/* %* */
51 64
@@ -67,11 +80,2 @@
67 80
68#ifdef __TURBOC__
69 #pragma warn -rch
70 #pragma warn -use
71#include <io.h>
72#include <stdlib.h>
73#define YY_USE_CONST
74#define YY_USE_PROTOS
75#endif
76
77#ifdef YY_USE_CONST 81#ifdef YY_USE_CONST
@@ -99,2 +103,51 @@
99 103
104
105#ifdef YY_REENTRANT
106
107/* An opaque pointer. */
108#ifndef YY_TYPEDEF_YY_SCANNER_T
109#define YY_TYPEDEF_YY_SCANNER_T
110typedef void* yyscan_t;
111#endif
112
113/* For use wherever a Global is accessed or assigned. */
114#define YY_G(var) (((struct yy_globals_t*)yy_globals)->var)
115
116/* For use in function prototypes to append the additional argument. */
117#ifdef YY_USE_PROTOS
118#define YY_LAST_ARG , yyscan_t yy_globals
119#define YY_ONLY_ARG yyscan_t yy_globals
120#else
121#define YY_LAST_ARG , yy_globals
122#define YY_ONLY_ARG yy_globals
123#define YY_DECL_LAST_ARG yyscan_t yy_globals;
124#endif
125
126/* For use in function calls to pass the additional argument. */
127#define YY_CALL_LAST_ARG , yy_globals
128#define YY_CALL_ONLY_ARG yy_globals
129
130/* For convenience, these vars (plus the bison vars far below)
131 are macros in the reentrant scanner. */
132#define yyin YY_G(yyin_r)
133#define yyout YY_G(yyout_r)
134#define yyextra YY_G(yyextra_r)
135#define yyleng YY_G(yyleng_r)
136#define yytext YY_G(yytext_r)
137#define yylineno YY_G(yylineno_r)
138
139int yylex_init YY_PROTO((yyscan_t* scanner));
140int yylex_destroy YY_PROTO((yyscan_t scanner));
141
142#else /* not YY_REENTRANT */
143
144 /* Define these macros to be no-ops. */
145#define YY_G(var) (var)
146#define YY_LAST_ARG
147#define YY_ONLY_ARG void
148#define YY_CALL_LAST_ARG
149#define YY_CALL_ONLY_ARG
150#define YY_DECL_LAST_ARG
151#endif
152
100/* Enter a start condition. This macro really ought to take a parameter, 153/* Enter a start condition. This macro really ought to take a parameter,
@@ -103,3 +156,3 @@
103 */ 156 */
104#define BEGIN yy_start = 1 + 2 * 157#define BEGIN YY_G(yy_start) = 1 + 2 *
105 158
@@ -109,3 +162,3 @@
109 */ 162 */
110#define YY_START ((yy_start - 1) / 2) 163#define YY_START ((YY_G(yy_start) - 1) / 2)
111#define YYSTATE YY_START 164#define YYSTATE YY_START
@@ -116,3 +169,3 @@
116/* Special action meaning "start processing a new file". */ 169/* Special action meaning "start processing a new file". */
117#define YY_NEW_FILE yyrestart( yyin ) 170#define YY_NEW_FILE yyrestart( yyin YY_CALL_LAST_ARG )
118 171
@@ -123,6 +176,17 @@
123 176
177
178#ifndef YY_TYPEDEF_YY_BUFFER_STATE
179#define YY_TYPEDEF_YY_BUFFER_STATE
124typedef struct yy_buffer_state *YY_BUFFER_STATE; 180typedef struct yy_buffer_state *YY_BUFFER_STATE;
181#endif
182
183#ifndef YY_REENTRANT
184extern size_t yyleng;
185#endif
125 186
126extern int yyleng; 187/* %- */
188#ifndef YY_REENTRANT
127extern FILE *yyin, *yyout; 189extern FILE *yyin, *yyout;
190#endif
191/* %* */
128 192
@@ -152,5 +216,5 @@ extern FILE *yyin, *yyout;
152 /* Undo effects of setting up yytext. */ \ 216 /* Undo effects of setting up yytext. */ \
153 *yy_cp = yy_hold_char; \ 217 *yy_cp = YY_G(yy_hold_char); \
154 YY_RESTORE_YY_MORE_OFFSET \ 218 YY_RESTORE_YY_MORE_OFFSET \
155 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ 219 YY_G(yy_c_buf_p) = yy_cp = yy_bp + n - YY_MORE_ADJ; \
156 YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 220 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
@@ -159,3 +223,3 @@ extern FILE *yyin, *yyout;
159 223
160#define unput(c) yyunput( c, yytext_ptr ) 224#define unput(c) yyunput( c, YY_G(yytext_ptr) YY_CALL_LAST_ARG )
161 225
@@ -165,8 +229,16 @@ extern FILE *yyin, *yyout;
165 */ 229 */
166typedef unsigned int yy_size_t;
167 230
231#ifndef YY_TYPEDEF_YY_SIZE_T
232#define YY_TYPEDEF_YY_SIZE_T
233typedef unsigned int yy_size_t;
234#endif
168 235
236#ifndef YY_STRUCT_YY_BUFFER_STATE
237#define YY_STRUCT_YY_BUFFER_STATE
169struct yy_buffer_state 238struct yy_buffer_state
170 { 239 {
240/* %- */
171 FILE *yy_input_file; 241 FILE *yy_input_file;
242/* %+ */
243/* %* */
172 244
@@ -224,4 +296,13 @@ struct yy_buffer_state
224 }; 296 };
297#endif /* !YY_STRUCT_YY_BUFFER_STATE */
225 298
299/* %- Standard (non-C++) definition */
300/* %c */
301#ifndef ssIN_HEADER
302#ifndef YY_REENTRANT
226static YY_BUFFER_STATE yy_current_buffer = 0; 303static YY_BUFFER_STATE yy_current_buffer = 0;
304#endif
305/* %e */
306#endif /* !ssIN_HEADER */
307/* %* */
227 308
@@ -234,2 +315,7 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
234 315
316/* %- Standard (non-C++) definition */
317
318#ifndef YY_REENTRANT
319/* %c */
320#ifndef ssIN_HEADER
235/* yy_hold_char holds the character lost when yytext is formed. */ 321/* yy_hold_char holds the character lost when yytext is formed. */
@@ -240,3 +326,3 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */
240 326
241int yyleng; 327size_t yyleng;
242 328
@@ -251,20 +337,31 @@ static int yy_start = 0; /* start state number */
251static int yy_did_buffer_switch_on_eof; 337static int yy_did_buffer_switch_on_eof;
338/* %e */
339#endif /* !ssIN_HEADER */
340#endif /* end !YY_REENTRANT */
341
342void yyrestart YY_PROTO(( FILE *input_file YY_LAST_ARG ));
343
344
345void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer YY_LAST_ARG ));
346void yy_load_buffer_state YY_PROTO(( YY_ONLY_ARG ));
347YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size YY_LAST_ARG ));
348void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
349void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG ));
350void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b YY_LAST_ARG ));
252 351
253void yyrestart YY_PROTO(( FILE *input_file )); 352#define YY_FLUSH_BUFFER yy_flush_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG)
254 353
255void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); 354YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size YY_LAST_ARG ));
256void yy_load_buffer_state YY_PROTO(( void )); 355YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str YY_LAST_ARG ));
257YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); 356YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len YY_LAST_ARG ));
258void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
259void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
260void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
261#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
262 357
263YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); 358/* %* */
264YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
265YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
266 359
267static void *yy_flex_alloc YY_PROTO(( yy_size_t )); 360/* %c */
268static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); 361#ifndef ssIN_HEADER
269static void yy_flex_free YY_PROTO(( void * )); 362static void *yy_flex_alloc YY_PROTO(( yy_size_t YY_LAST_ARG ));
363static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t YY_LAST_ARG ));
364static void yy_flex_free YY_PROTO(( void * YY_LAST_ARG ));
365/* %e */
366#endif /* !ssIN_HEADER */
270 367
@@ -274,5 +371,6 @@ static void yy_flex_free YY_PROTO(( void * ));
274 { \ 371 { \
275 if ( ! yy_current_buffer ) \ 372 if ( ! YY_G(yy_current_buffer) ) \
276 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ 373 YY_G(yy_current_buffer) = \
277 yy_current_buffer->yy_is_interactive = is_interactive; \ 374 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
375 YY_G(yy_current_buffer)->yy_is_interactive = is_interactive; \
278 } 376 }
@@ -281,19 +379,34 @@ static void yy_flex_free YY_PROTO(( void * ));
281 { \ 379 { \
282 if ( ! yy_current_buffer ) \ 380 if ( ! YY_G(yy_current_buffer) ) \
283 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ 381 YY_G(yy_current_buffer) = \
284 yy_current_buffer->yy_at_bol = at_bol; \ 382 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
383 YY_G(yy_current_buffer)->yy_at_bol = at_bol; \
285 } 384 }
286 385
287#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) 386#define YY_AT_BOL() (YY_G(yy_current_buffer)->yy_at_bol)
288 387
388/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
389/* Begin user sect3 */
390#ifndef ssIN_HEADER
289typedef unsigned char YY_CHAR; 391typedef unsigned char YY_CHAR;
392#endif /* !ssIN_HEADER */
393#ifndef ssIN_HEADER
394#ifndef YY_REENTRANT
290FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; 395FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
396#endif
397#endif /* !ssIN_HEADER */
398#ifndef ssIN_HEADER
291typedef int yy_state_type; 399typedef int yy_state_type;
292extern char yytext[]; 400#endif /* !ssIN_HEADER */
293 401
294 402/* %- Standard (non-C++) definition */
295static yy_state_type yy_get_previous_state YY_PROTO(( void )); 403/* %c */
296static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); 404#ifndef ssIN_HEADER
297static int yy_get_next_buffer YY_PROTO(( void )); 405static yy_state_type yy_get_previous_state YY_PROTO(( YY_ONLY_ARG ));
406static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state YY_LAST_ARG));
407static int yy_get_next_buffer YY_PROTO(( YY_ONLY_ARG ));
298static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); 408static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
409/* %e */
410#endif /* !ssIN_HEADER */
411/* %* */
299 412
@@ -303,20 +416,28 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
303#define YY_DO_BEFORE_ACTION \ 416#define YY_DO_BEFORE_ACTION \
304 yytext_ptr = yy_bp; \ 417 YY_G(yytext_ptr) = yy_bp; \
305 yyleng = (int) (yy_cp - yy_bp); \ 418/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
306 yy_hold_char = *yy_cp; \ 419 yyleng = (size_t) (yy_cp - yy_bp); \
420 YY_G(yy_hold_char) = *yy_cp; \
307 *yy_cp = '\0'; \ 421 *yy_cp = '\0'; \
422/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
308 if ( yyleng >= YYLMAX ) \ 423 if ( yyleng >= YYLMAX ) \
309 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ 424 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
310 yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \ 425 yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \
311 yy_c_buf_p = yy_cp; 426 YY_G(yy_c_buf_p) = yy_cp;
312 427
313#define YY_NUM_RULES 19 428/* %* */
314#define YY_END_OF_BUFFER 20 429
315static yyconst short int yy_accept[47] = 430/* %c */
431#ifndef ssIN_HEADER
432/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
433#define YY_NUM_RULES 23
434#define YY_END_OF_BUFFER 24
435static yyconst short int yy_accept[56] =
316 { 0, 436 { 0,
317 0, 0, 0, 0, 0, 0, 20, 18, 14, 14, 437 0, 0, 0, 0, 0, 0, 24, 22, 18, 18,
318 18, 13, 17, 4, 15, 7, 5, 8, 17, 17, 438 22, 17, 21, 4, 19, 8, 5, 9, 21, 21,
319 17, 17, 17, 14, 6, 0, 17, 9, 10, 17, 439 21, 21, 21, 21, 21, 18, 7, 0, 21, 10,
320 17, 12, 17, 17, 16, 11, 17, 17, 17, 2, 440 6, 11, 21, 21, 14, 21, 21, 13, 21, 21,
321 17, 17, 17, 3, 1, 0 441 20, 12, 21, 15, 21, 21, 21, 2, 16, 21,
442 21, 21, 3, 1, 0
322 } ; 443 } ;
@@ -328,13 +449,13 @@ static yyconst int yy_ec[256] =
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 449 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 2, 4, 1, 1, 1, 1, 1, 5, 1, 450 1, 4, 5, 1, 1, 1, 1, 1, 6, 1,
330 1, 6, 1, 7, 6, 6, 1, 6, 6, 6, 451 1, 7, 1, 8, 7, 7, 1, 7, 7, 7,
331 6, 6, 6, 6, 6, 6, 6, 1, 8, 9, 452 7, 7, 7, 7, 7, 7, 7, 9, 10, 11,
332 10, 11, 1, 1, 12, 6, 13, 14, 15, 16, 453 12, 13, 1, 7, 14, 7, 15, 16, 17, 18,
333 6, 17, 6, 6, 6, 18, 19, 20, 21, 6, 454 7, 19, 20, 7, 7, 21, 22, 23, 24, 7,
334 6, 22, 23, 24, 6, 6, 25, 6, 6, 6, 455 7, 25, 26, 27, 28, 7, 29, 7, 7, 7,
335 1, 1, 1, 1, 1, 1, 12, 6, 13, 14, 456 1, 1, 1, 1, 1, 1, 14, 7, 15, 16,
336 457
337 15, 16, 6, 17, 6, 6, 6, 18, 19, 20, 458 17, 18, 7, 19, 20, 7, 7, 21, 22, 23,
338 21, 6, 6, 22, 23, 24, 6, 6, 25, 6, 459 24, 7, 7, 25, 26, 27, 28, 7, 29, 7,
339 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 460 7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -355,40 +476,45 @@ static yyconst int yy_ec[256] =
355 476
356static yyconst int yy_meta[26] = 477static yyconst int yy_meta[30] =
357 { 0, 478 { 0,
358 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 479 1, 1, 1, 2, 1, 1, 3, 1, 2, 1,
359 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 480 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
360 2, 2, 2, 2, 2 481 3, 3, 3, 3, 3, 3, 3, 3, 3
361 } ; 482 } ;
362 483
363static yyconst short int yy_base[49] = 484static yyconst short int yy_base[58] =
364 { 0, 485 { 0,
365 0, 0, 0, 0, 0, 0, 53, 54, 24, 26, 486 0, 0, 0, 0, 0, 0, 68, 69, 28, 31,
366 42, 0, 0, 54, 54, 41, 54, 40, 29, 26, 487 55, 0, 0, 69, 69, 54, 53, 52, 40, 37,
367 25, 31, 28, 28, 54, 39, 0, 54, 54, 29, 488 35, 12, 35, 42, 39, 35, 69, 51, 0, 69,
368 21, 0, 23, 25, 54, 0, 20, 23, 15, 0, 489 69, 69, 40, 31, 0, 27, 32, 0, 31, 34,
369 23, 20, 10, 0, 0, 54, 31, 30 490 69, 0, 28, 0, 28, 31, 22, 0, 0, 31,
491 28, 17, 0, 0, 69, 39, 40
370 } ; 492 } ;
371 493
372static yyconst short int yy_def[49] = 494static yyconst short int yy_def[58] =
373 { 0, 495 { 0,
374 46, 1, 1, 1, 1, 1, 46, 46, 46, 46, 496 55, 1, 1, 1, 1, 1, 55, 55, 55, 55,
375 46, 47, 48, 46, 46, 46, 46, 46, 48, 48, 497 55, 56, 57, 55, 55, 55, 55, 55, 57, 57,
376 48, 48, 48, 46, 46, 47, 48, 46, 46, 48, 498 57, 57, 57, 57, 57, 55, 55, 56, 57, 55,
377 48, 48, 48, 48, 46, 48, 48, 48, 48, 48, 499 55, 55, 57, 57, 57, 57, 57, 57, 57, 57,
378 48, 48, 48, 48, 48, 0, 46, 46 500 55, 57, 57, 57, 57, 57, 57, 57, 57, 57,
501 57, 57, 57, 57, 0, 55, 55
379 } ; 502 } ;
380 503
381static yyconst short int yy_nxt[80] = 504static yyconst short int yy_nxt[99] =
382 { 0, 505 { 0,
383 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 506 8, 9, 10, 9, 11, 12, 13, 14, 8, 15,
384 18, 19, 13, 13, 13, 20, 13, 13, 13, 13, 507 16, 17, 18, 19, 13, 13, 13, 20, 13, 21,
385 21, 13, 22, 13, 23, 24, 24, 24, 24, 24, 508 13, 13, 22, 23, 13, 24, 13, 13, 25, 26,
386 24, 27, 26, 45, 44, 43, 42, 41, 40, 39, 509 26, 26, 26, 26, 26, 36, 26, 26, 26, 37,
387 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 510 28, 28, 29, 54, 53, 52, 51, 50, 49, 48,
388 28, 25, 46, 7, 46, 46, 46, 46, 46, 46, 511 47, 46, 45, 44, 43, 42, 41, 40, 39, 38,
389 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 512 35, 34, 33, 32, 31, 30, 27, 55, 7, 55,
390 46, 46, 46, 46, 46, 46, 46, 46, 46 513 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
514 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
515 55, 55, 55, 55, 55, 55, 55, 55
516
391 } ; 517 } ;
392 518
393static yyconst short int yy_chk[80] = 519static yyconst short int yy_chk[99] =
394 { 0, 520 { 0,
@@ -396,12 +522,12 @@ static yyconst short int yy_chk[80] =
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 522 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 9, 9, 10, 10, 24, 523 1, 1, 1, 1, 1, 1, 1, 1, 1, 9,
398 24, 48, 47, 43, 42, 41, 39, 38, 37, 34, 524 9, 9, 10, 10, 10, 22, 26, 26, 26, 22,
399 33, 31, 30, 26, 23, 22, 21, 20, 19, 18, 525 56, 56, 57, 52, 51, 50, 47, 46, 45, 43,
400 16, 11, 7, 46, 46, 46, 46, 46, 46, 46, 526 40, 39, 37, 36, 34, 33, 28, 25, 24, 23,
401 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 527 21, 20, 19, 18, 17, 16, 11, 7, 55, 55,
402 46, 46, 46, 46, 46, 46, 46, 46, 46 528 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
403 } ; 529 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
530 55, 55, 55, 55, 55, 55, 55, 55
404 531
405static yy_state_type yy_last_accepting_state; 532 } ;
406static char *yy_last_accepting_cpos;
407 533
@@ -418,4 +544,6 @@ static char *yy_last_accepting_cpos;
418 544
545#ifndef YY_REENTRANT
419char yytext[YYLMAX]; 546char yytext[YYLMAX];
420char *yytext_ptr; 547char *yytext_ptr;
548#endif
421#line 1 "icalsslexer.l" 549#line 1 "icalsslexer.l"
@@ -457,7 +585,4 @@ char *yytext_ptr;
457 585
458int icalparser_flex_input(char* buf, int max_size); 586#undef YYPURE
459void icalparser_clear_flex_input(); 587#define YYPURE
460
461#undef YY_INPUT
462#define YY_INPUT(b,r,ms) ( r= icalparser_flex_input(b,ms))
463 588
@@ -466,3 +591,2 @@ void icalparser_clear_flex_input();
466 591
467
468#define sql 1 592#define sql 1
@@ -470,3 +594,146 @@ void icalparser_clear_flex_input();
470 594
471#line 465 "icalsslexer.c" 595#line 596 "lex.ss.c"
596/* %e */
597#endif /* !ssIN_HEADER */
598
599/* Special case for "unistd.h", since it is non-ANSI. We include it way
600 * down here because we want the user's section 1 to have been scanned first.
601 * The user has a chance to override it with an option.
602 */
603#ifndef YY_NO_UNISTD_H
604/* %- */
605#include <unistd.h>
606/* %+ */
607/* %* */
608#endif /* !YY_NO_UNISTD_H */
609
610
611#ifndef YY_EXTRA_TYPE
612#define YY_EXTRA_TYPE void *
613#endif
614
615/* %- Reentrant structure and macros (non-C++). */
616#ifdef YY_REENTRANT
617
618/* %c */
619#ifndef ssIN_HEADER
620struct yy_globals_t
621 {
622
623 /* User-defined. Not touched by flex. */
624 YY_EXTRA_TYPE yyextra_r;
625
626 /* The rest are the same as the globals declared in the non-reentrant scanner. */
627 FILE *yyin_r, *yyout_r;
628 YY_BUFFER_STATE yy_current_buffer;
629 char yy_hold_char;
630 int yy_n_chars;
631 int yyleng_r;
632 char *yy_c_buf_p;
633 int yy_init;
634 int yy_start;
635 int yy_did_buffer_switch_on_eof;
636 int yy_start_stack_ptr;
637 int yy_start_stack_depth;
638 int *yy_start_stack;
639 yy_state_type yy_last_accepting_state;
640 char* yy_last_accepting_cpos;
641
642 int yylineno_r;
643
644#ifdef YY_TEXT_IS_ARRAY
645 char yytext_r[YYLMAX];
646 char *yytext_ptr;
647 int yy_more_offset;
648 int yy_prev_more_offset;
649#else
650 char *yytext_r;
651 int yy_more_flag;
652 int yy_more_len;
653#endif
654
655#ifdef YY_REENTRANT_BISON_PURE
656 YYSTYPE * yylval_r;
657#ifdef YYLTYPE
658 YYLTYPE * yylloc_r;
659#endif
660#endif
661
662 };
663/* %e */
664#endif /* !ssIN_HEADER */
665
666/* %c */
667#ifndef ssIN_HEADER
668static int yy_init_globals YY_PROTO(( yyscan_t ));
669/* %e */
670#endif /* !ssIN_HEADER */
671
672/* This must go here because YYSTYPE and YYLSTYPE are included
673 * from bison output in section 1.*/
674#ifdef YY_REENTRANT_BISON_PURE
675# define yylval YY_G(yylval_r)
676# ifdef YYLTYPE
677# define yylloc YY_G(yylloc_r)
678# endif
679#endif /* YY_REENTRANT_BISON_PURE */
680
681#endif /* end if YY_REENTRANT */
682
683/* Accessor methods to globals.
684 These are made visible to non-reentrant scanners for convenience. */
685#ifndef YY_NO_GET_EXTRA
686YY_EXTRA_TYPE yyget_extra YY_PROTO(( YY_ONLY_ARG ));
687#endif
688
689#ifndef YY_NO_SET_EXTRA
690void yyset_extra YY_PROTO(( YY_EXTRA_TYPE user_defined YY_LAST_ARG ));
691#endif
692
693#ifndef YY_NO_GET_IN
694FILE *yyget_in YY_PROTO(( YY_ONLY_ARG ));
695#endif
696
697#ifndef YY_NO_SET_IN
698void yyset_in YY_PROTO(( FILE * in_str YY_LAST_ARG ));
699#endif
700
701#ifndef YY_NO_GET_OUT
702FILE *yyget_out YY_PROTO(( YY_ONLY_ARG ));
703#endif
704
705#ifndef YY_NO_SET_OUT
706void yyset_out YY_PROTO(( FILE * out_str YY_LAST_ARG ));
707#endif
708
709#ifndef YY_NO_GET_LENG
710int yyget_leng YY_PROTO(( YY_ONLY_ARG ));
711#endif
712
713#ifndef YY_NO_GET_TEXT
714char *yyget_text YY_PROTO(( YY_ONLY_ARG ));
715#endif
716
717#ifndef YY_NO_GET_LINENO
718int yyget_lineno YY_PROTO(( YY_ONLY_ARG ));
719#endif
720
721#ifndef YY_NO_SET_LINENO
722void yyset_lineno YY_PROTO(( int line_number YY_LAST_ARG ));
723#endif
724
725#ifdef YY_REENTRANT_BISON_PURE
726#ifndef YY_NO_GET_LVAL
727YYSTYPE * yyget_lval YY_PROTO(( YY_ONLY_ARG ));
728#endif
729void yyset_lval YY_PROTO(( YYSTYPE * yylvalp YY_LAST_ARG ));
730#ifdef YYLTYPE
731#ifndef YY_NO_GET_LLOC
732 YYLTYPE *yyget_lloc YY_PROTO(( YY_ONLY_ARG ));
733#endif
734#ifndef YY_NO_SET_LLOC
735 void yyset_lloc YY_PROTO(( YYLTYPE * yyllocp YY_LAST_ARG ));
736#endif
737#endif /* YYLTYPE */
738#endif /* YY_REENTRANT_BISON_PURE */
472 739
@@ -478,5 +745,5 @@ void icalparser_clear_flex_input();
478#ifdef __cplusplus 745#ifdef __cplusplus
479extern "C" int yywrap YY_PROTO(( void )); 746extern "C" int yywrap YY_PROTO(( YY_ONLY_ARG ));
480#else 747#else
481extern int yywrap YY_PROTO(( void )); 748extern int yywrap YY_PROTO(( YY_ONLY_ARG ));
482#endif 749#endif
@@ -484,8 +751,14 @@ extern int yywrap YY_PROTO(( void ));
484 751
752/* %- */
753/* %c */
754#ifndef ssIN_HEADER
485#ifndef YY_NO_UNPUT 755#ifndef YY_NO_UNPUT
486static void yyunput YY_PROTO(( int c, char *buf_ptr )); 756static void yyunput YY_PROTO(( int c, char *buf_ptr YY_LAST_ARG));
487#endif 757#endif
758/* %e */
759#endif /* !ssIN_HEADER */
760/* %* */
488 761
489#ifndef yytext_ptr 762#ifndef yytext_ptr
490static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); 763static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int YY_LAST_ARG));
491#endif 764#endif
@@ -493,3 +766,3 @@ static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
493#ifdef YY_NEED_STRLEN 766#ifdef YY_NEED_STRLEN
494static int yy_flex_strlen YY_PROTO(( yyconst char * )); 767static int yy_flex_strlen YY_PROTO(( yyconst char * YY_LAST_ARG));
495#endif 768#endif
@@ -497,7 +770,13 @@ static int yy_flex_strlen YY_PROTO(( yyconst char * ));
497#ifndef YY_NO_INPUT 770#ifndef YY_NO_INPUT
771/* %- Standard (non-C++) definition */
772/* %c */
773#ifndef ssIN_HEADER
498#ifdef __cplusplus 774#ifdef __cplusplus
499static int yyinput YY_PROTO(( void )); 775static int yyinput YY_PROTO(( YY_ONLY_ARG ));
500#else 776#else
501static int input YY_PROTO(( void )); 777static int input YY_PROTO(( YY_ONLY_ARG ));
502#endif 778#endif
779/* %e */
780#endif /* !ssIN_HEADER */
781/* %* */
503#endif 782#endif
@@ -505,2 +784,5 @@ static int input YY_PROTO(( void ));
505#if YY_STACK_USED 784#if YY_STACK_USED
785#ifndef YY_REENTRANT
786/* %c */
787#ifndef ssIN_HEADER
506static int yy_start_stack_ptr = 0; 788static int yy_start_stack_ptr = 0;
@@ -508,10 +790,13 @@ static int yy_start_stack_depth = 0;
508static int *yy_start_stack = 0; 790static int *yy_start_stack = 0;
791/* %e */
792#endif /* !ssIN_HEADER */
793#endif
509#ifndef YY_NO_PUSH_STATE 794#ifndef YY_NO_PUSH_STATE
510static void yy_push_state YY_PROTO(( int new_state )); 795static void yy_push_state YY_PROTO(( int new_state YY_LAST_ARG));
511#endif 796#endif
512#ifndef YY_NO_POP_STATE 797#ifndef YY_NO_POP_STATE
513static void yy_pop_state YY_PROTO(( void )); 798static void yy_pop_state YY_PROTO(( YY_ONLY_ARG ));
514#endif 799#endif
515#ifndef YY_NO_TOP_STATE 800#ifndef YY_NO_TOP_STATE
516static int yy_top_state YY_PROTO(( void )); 801static int yy_top_state YY_PROTO(( YY_ONLY_ARG ));
517#endif 802#endif
@@ -524,17 +809,2 @@ static int yy_top_state YY_PROTO(( void ));
524 809
525#ifdef YY_MALLOC_DECL
526YY_MALLOC_DECL
527#else
528#if __STDC__
529#ifndef __cplusplus
530#include <stdlib.h>
531#endif
532#else
533/* Just try to get by without declaring the routines. This will fail
534 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
535 * or sizeof(void*) != sizeof(int).
536 */
537#endif
538#endif
539
540/* Amount of stuff to slurp up with each read. */ 810/* Amount of stuff to slurp up with each read. */
@@ -547,2 +817,3 @@ YY_MALLOC_DECL
547#ifndef ECHO 817#ifndef ECHO
818/* %- Standard (non-C++) definition */
548/* This used to be an fputs(), but since the string might contain NUL's, 819/* This used to be an fputs(), but since the string might contain NUL's,
@@ -551,2 +822,4 @@ YY_MALLOC_DECL
551#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) 822#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
823/* %+ C++ definition */
824/* %* */
552#endif 825#endif
@@ -558,5 +831,7 @@ YY_MALLOC_DECL
558#define YY_INPUT(buf,result,max_size) \ 831#define YY_INPUT(buf,result,max_size) \
559 if ( yy_current_buffer->yy_is_interactive ) \ 832/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
833 if ( YY_G(yy_current_buffer)->yy_is_interactive ) \
560 { \ 834 { \
561 int c = '*', n; \ 835 int c = '*'; \
836 size_t n; \
562 for ( n = 0; n < max_size && \ 837 for ( n = 0; n < max_size && \
@@ -570,5 +845,18 @@ YY_MALLOC_DECL
570 } \ 845 } \
571 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ 846 else \
572 && ferror( yyin ) ) \ 847 { \
573 YY_FATAL_ERROR( "input in flex scanner failed" ); 848 errno=0; \
849 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
850 { \
851 if( errno != EINTR) \
852 { \
853 YY_FATAL_ERROR( "input in flex scanner failed" ); \
854 break; \
855 } \
856 errno=0; \
857 clearerr(yyin); \
858 } \
859 }
860/* %+ C++ definition \ */\
861/* %* */
574#endif 862#endif
@@ -590,3 +878,6 @@ YY_MALLOC_DECL
590#ifndef YY_FATAL_ERROR 878#ifndef YY_FATAL_ERROR
879/* %- */
591#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 880#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
881/* %+ */
882/* %* */
592#endif 883#endif
@@ -597,3 +888,37 @@ YY_MALLOC_DECL
597#ifndef YY_DECL 888#ifndef YY_DECL
598#define YY_DECL int yylex YY_PROTO(( void )) 889/* %- Standard (non-C++) definition */
890
891/* If the bison pure parser is used, then bison will provide
892 one or two additional arguments. */
893
894#ifdef YY_REENTRANT_BISON_PURE
895# ifdef YYLTYPE
896# ifdef YY_USE_PROTOS
897# define YY_LEX_ARGS (YYSTYPE * yylvalp, YYLTYPE * yyllocp YY_LAST_ARG)
898# else
899# define YY_LEX_ARGS (yylvalp, yyllocp YY_LAST_ARG) \
900 YYSTYPE * yylvalp; YYLTYPE * yyllocp; YY_DECL_LAST_ARG
901# endif
902# else
903# ifdef YY_USE_PROTOS
904# define YY_LEX_ARGS (YYSTYPE * yylvalp YY_LAST_ARG)
905# else
906# define YY_LEX_ARGS (yylvalp YY_LAST_ARG) \
907 YYSTYPE * yylvalp; YY_DECL_LAST_ARG
908# endif
909# endif
910#else
911# ifdef YY_USE_PROTOS
912# define YY_LEX_ARGS (YY_ONLY_ARG)
913# else
914# define YY_LEX_ARGS (YY_ONLY_ARG) YY_DECL_LAST_ARG
915# endif
916#endif
917
918
919extern int yylex YY_PROTO( YY_LEX_ARGS );
920
921#define YY_DECL int yylex YY_LEX_ARGS
922/* %+ C++ definition */
923/* %* */
599#endif 924#endif
@@ -612,2 +937,3 @@ YY_MALLOC_DECL
612 937
938/* %% [6.0] YY_RULE_SETUP definition goes here */
613#define YY_RULE_SETUP \ 939#define YY_RULE_SETUP \
@@ -615,2 +941,4 @@ YY_MALLOC_DECL
615 941
942/* %c */
943#ifndef ssIN_HEADER
616YY_DECL 944YY_DECL
@@ -618,6 +946,8 @@ YY_DECL
618 register yy_state_type yy_current_state; 946 register yy_state_type yy_current_state;
619 register char *yy_cp = NULL, *yy_bp = NULL; 947 register char *yy_cp, *yy_bp;
620 register int yy_act; 948 register int yy_act;
621 949
622#line 69 "icalsslexer.l" 950/* %% [7.0] user's declarations go here */
951#line 66 "icalsslexer.l"
952
623 953
@@ -627,8 +957,14 @@ YY_DECL
627 957
958#line 959 "lex.ss.c"
628 959
629#line 623 "icalsslexer.c" 960#ifdef YY_REENTRANT_BISON_PURE
961 yylval = yylvalp;
962#ifdef YYLTYPE
963 yylloc = yyllocp;
964#endif
965#endif
630 966
631 if ( yy_init ) 967 if ( YY_G(yy_init) )
632 { 968 {
633 yy_init = 0; 969 YY_G(yy_init) = 0;
634 970
@@ -638,16 +974,22 @@ YY_DECL
638 974
639 if ( ! yy_start ) 975 if ( ! YY_G(yy_start) )
640 yy_start = 1;/* first start state */ 976 YY_G(yy_start) = 1;/* first start state */
641 977
642 if ( ! yyin ) 978 if ( ! yyin )
979/* %- */
643 yyin = stdin; 980 yyin = stdin;
981/* %+ */
982/* %* */
644 983
645 if ( ! yyout ) 984 if ( ! yyout )
985/* %- */
646 yyout = stdout; 986 yyout = stdout;
987/* %+ */
988/* %* */
647 989
648 if ( ! yy_current_buffer ) 990 if ( ! YY_G(yy_current_buffer) )
649 yy_current_buffer = 991 YY_G(yy_current_buffer) =
650 yy_create_buffer( yyin, YY_BUF_SIZE ); 992 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
651 993
652 yy_load_buffer_state(); 994 yy_load_buffer_state( YY_CALL_ONLY_ARG );
653 } 995 }
@@ -656,6 +998,7 @@ YY_DECL
656 { 998 {
657 yy_cp = yy_c_buf_p; 999/* %% [8.0] yymore()-related code goes here */
1000 yy_cp = YY_G(yy_c_buf_p);
658 1001
659 /* Support of yytext. */ 1002 /* Support of yytext. */
660 *yy_cp = yy_hold_char; 1003 *yy_cp = YY_G(yy_hold_char);
661 1004
@@ -666,3 +1009,4 @@ YY_DECL
666 1009
667 yy_current_state = yy_start; 1010/* %% [9.0] code to set up and find next match goes here */
1011 yy_current_state = YY_G(yy_start);
668yy_match: 1012yy_match:
@@ -673,4 +1017,4 @@ yy_match:
673 { 1017 {
674 yy_last_accepting_state = yy_current_state; 1018 YY_G(yy_last_accepting_state) = yy_current_state;
675 yy_last_accepting_cpos = yy_cp; 1019 YY_G(yy_last_accepting_cpos) = yy_cp;
676 } 1020 }
@@ -679,3 +1023,3 @@ yy_match:
679 yy_current_state = (int) yy_def[yy_current_state]; 1023 yy_current_state = (int) yy_def[yy_current_state];
680 if ( yy_current_state >= 47 ) 1024 if ( yy_current_state >= 56 )
681 yy_c = yy_meta[(unsigned int) yy_c]; 1025 yy_c = yy_meta[(unsigned int) yy_c];
@@ -685,5 +1029,6 @@ yy_match:
685 } 1029 }
686 while ( yy_base[yy_current_state] != 54 ); 1030 while ( yy_base[yy_current_state] != 69 );
687 1031
688yy_find_action: 1032yy_find_action:
1033/* %% [10.0] code to find the action number goes here */
689 yy_act = yy_accept[yy_current_state]; 1034 yy_act = yy_accept[yy_current_state];
@@ -691,4 +1036,4 @@ yy_find_action:
691 { /* have to back up */ 1036 { /* have to back up */
692 yy_cp = yy_last_accepting_cpos; 1037 yy_cp = YY_G(yy_last_accepting_cpos);
693 yy_current_state = yy_last_accepting_state; 1038 yy_current_state = YY_G(yy_last_accepting_state);
694 yy_act = yy_accept[yy_current_state]; 1039 yy_act = yy_accept[yy_current_state];
@@ -698,2 +1043,3 @@ yy_find_action:
698 1043
1044/* %% [11.0] code for yylineno update goes here */
699 1045
@@ -701,2 +1047,3 @@ do_action: /* This label is used only to access EOF actions. */
701 1047
1048/* %% [12.0] debug code goes here */
702 1049
@@ -704,7 +1051,8 @@ do_action: /* This label is used only to access EOF actions. */
704 { /* beginning of action switch */ 1051 { /* beginning of action switch */
1052/* %% [13.0] actions go here */
705 case 0: /* must back up */ 1053 case 0: /* must back up */
706 /* undo the effects of YY_DO_BEFORE_ACTION */ 1054 /* undo the effects of YY_DO_BEFORE_ACTION */
707 *yy_cp = yy_hold_char; 1055 *yy_cp = YY_G(yy_hold_char);
708 yy_cp = yy_last_accepting_cpos; 1056 yy_cp = YY_G(yy_last_accepting_cpos);
709 yy_current_state = yy_last_accepting_state; 1057 yy_current_state = YY_G(yy_last_accepting_state);
710 goto yy_find_action; 1058 goto yy_find_action;
@@ -713,3 +1061,3 @@ case 1:
713YY_RULE_SETUP 1061YY_RULE_SETUP
714#line 75 "icalsslexer.l" 1062#line 72 "icalsslexer.l"
715{ return SELECT; } 1063{ return SELECT; }
@@ -718,3 +1066,3 @@ case 2:
718YY_RULE_SETUP 1066YY_RULE_SETUP
719#line 76 "icalsslexer.l" 1067#line 73 "icalsslexer.l"
720{ return FROM; } 1068{ return FROM; }
@@ -723,3 +1071,3 @@ case 3:
723YY_RULE_SETUP 1071YY_RULE_SETUP
724#line 77 "icalsslexer.l" 1072#line 74 "icalsslexer.l"
725{ return WHERE; } 1073{ return WHERE; }
@@ -728,3 +1076,3 @@ case 4:
728YY_RULE_SETUP 1076YY_RULE_SETUP
729#line 78 "icalsslexer.l" 1077#line 75 "icalsslexer.l"
730{ return COMMA; } 1078{ return COMMA; }
@@ -733,3 +1081,3 @@ case 5:
733YY_RULE_SETUP 1081YY_RULE_SETUP
734#line 79 "icalsslexer.l" 1082#line 76 "icalsslexer.l"
735{ return EQUALS; } 1083{ return EQUALS; }
@@ -738,4 +1086,4 @@ case 6:
738YY_RULE_SETUP 1086YY_RULE_SETUP
739#line 80 "icalsslexer.l" 1087#line 77 "icalsslexer.l"
740{ return NOTEQUALS; } 1088{ return EQUALS; }
741 YY_BREAK 1089 YY_BREAK
@@ -743,4 +1091,4 @@ case 7:
743YY_RULE_SETUP 1091YY_RULE_SETUP
744#line 81 "icalsslexer.l" 1092#line 78 "icalsslexer.l"
745{ return LESS; } 1093{ return NOTEQUALS; }
746 YY_BREAK 1094 YY_BREAK
@@ -748,4 +1096,4 @@ case 8:
748YY_RULE_SETUP 1096YY_RULE_SETUP
749#line 82 "icalsslexer.l" 1097#line 79 "icalsslexer.l"
750{ return GREATER; } 1098{ return LESS; }
751 YY_BREAK 1099 YY_BREAK
@@ -753,4 +1101,4 @@ case 9:
753YY_RULE_SETUP 1101YY_RULE_SETUP
754#line 83 "icalsslexer.l" 1102#line 80 "icalsslexer.l"
755{ return LESSEQUALS; } 1103{ return GREATER; }
756 YY_BREAK 1104 YY_BREAK
@@ -758,4 +1106,4 @@ case 10:
758YY_RULE_SETUP 1106YY_RULE_SETUP
759#line 84 "icalsslexer.l" 1107#line 81 "icalsslexer.l"
760{ return GREATEREQUALS; } 1108{ return LESSEQUALS; }
761 YY_BREAK 1109 YY_BREAK
@@ -763,4 +1111,4 @@ case 11:
763YY_RULE_SETUP 1111YY_RULE_SETUP
764#line 85 "icalsslexer.l" 1112#line 82 "icalsslexer.l"
765{ return AND; } 1113{ return GREATEREQUALS; }
766 YY_BREAK 1114 YY_BREAK
@@ -768,4 +1116,4 @@ case 12:
768YY_RULE_SETUP 1116YY_RULE_SETUP
769#line 86 "icalsslexer.l" 1117#line 83 "icalsslexer.l"
770{ return OR; } 1118{ return AND; }
771 YY_BREAK 1119 YY_BREAK
@@ -773,4 +1121,4 @@ case 13:
773YY_RULE_SETUP 1121YY_RULE_SETUP
774#line 87 "icalsslexer.l" 1122#line 84 "icalsslexer.l"
775{ return QUOTE; } 1123{ return OR; }
776 YY_BREAK 1124 YY_BREAK
@@ -778,4 +1126,4 @@ case 14:
778YY_RULE_SETUP 1126YY_RULE_SETUP
779#line 88 "icalsslexer.l" 1127#line 85 "icalsslexer.l"
780 ; 1128{ return IS; }
781 YY_BREAK 1129 YY_BREAK
@@ -783,4 +1131,4 @@ case 15:
783YY_RULE_SETUP 1131YY_RULE_SETUP
784#line 89 "icalsslexer.l" 1132#line 86 "icalsslexer.l"
785{ return EOL; } 1133{ return NOT; }
786 YY_BREAK 1134 YY_BREAK
@@ -788,8 +1136,28 @@ case 16:
788YY_RULE_SETUP 1136YY_RULE_SETUP
1137#line 87 "icalsslexer.l"
1138{ return SQLNULL; }
1139 YY_BREAK
1140case 17:
1141YY_RULE_SETUP
1142#line 88 "icalsslexer.l"
1143{ return QUOTE; }
1144 YY_BREAK
1145case 18:
1146YY_RULE_SETUP
1147#line 89 "icalsslexer.l"
1148 ;
1149 YY_BREAK
1150case 19:
1151YY_RULE_SETUP
789#line 90 "icalsslexer.l" 1152#line 90 "icalsslexer.l"
1153{ return EOL; }
1154 YY_BREAK
1155case 20:
1156YY_RULE_SETUP
1157#line 92 "icalsslexer.l"
790{ 1158{
791 int c = input(); 1159 int c = input(yy_globals);
792 unput(c); 1160 unput(c);
793 if(c!='\''){ 1161 if(c!='\''){
794 sslval.v_string= icalmemory_tmp_copy(sstext); 1162 yylvalp->v_string= icalmemory_tmp_copy(yytext);
795 return STRING; 1163 return STRING;
@@ -800,19 +1168,21 @@ YY_RULE_SETUP
800 YY_BREAK 1168 YY_BREAK
801case 17: 1169case 21:
802YY_RULE_SETUP 1170YY_RULE_SETUP
803#line 101 "icalsslexer.l" 1171#line 103 "icalsslexer.l"
804{ sslval.v_string= icalmemory_tmp_copy(sstext); 1172{
805 return STRING; } 1173 yylval->v_string= icalmemory_tmp_copy(yytext);
1174 return STRING;
1175}
806 YY_BREAK 1176 YY_BREAK
807case 18: 1177case 22:
808YY_RULE_SETUP 1178YY_RULE_SETUP
809#line 105 "icalsslexer.l" 1179#line 109 "icalsslexer.l"
810{ return yytext[0]; } 1180{ return yytext[0]; }
811 YY_BREAK 1181 YY_BREAK
812case 19: 1182case 23:
813YY_RULE_SETUP 1183YY_RULE_SETUP
814#line 107 "icalsslexer.l" 1184#line 111 "icalsslexer.l"
815ECHO; 1185ECHO;
816 YY_BREAK 1186 YY_BREAK
817#line 811 "icalsslexer.c" 1187#line 1188 "lex.ss.c"
818case YY_STATE_EOF(INITIAL): 1188case YY_STATE_EOF(INITIAL):
@@ -825,9 +1195,9 @@ case YY_STATE_EOF(string_value):
825 /* Amount of text matched not including the EOB char. */ 1195 /* Amount of text matched not including the EOB char. */
826 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; 1196 int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1;
827 1197
828 /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1198 /* Undo the effects of YY_DO_BEFORE_ACTION. */
829 *yy_cp = yy_hold_char; 1199 *yy_cp = YY_G(yy_hold_char);
830 YY_RESTORE_YY_MORE_OFFSET 1200 YY_RESTORE_YY_MORE_OFFSET
831 1201
832 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) 1202 if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_NEW )
833 { 1203 {
@@ -842,5 +1212,5 @@ case YY_STATE_EOF(string_value):
842 */ 1212 */
843 yy_n_chars = yy_current_buffer->yy_n_chars; 1213 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
844 yy_current_buffer->yy_input_file = yyin; 1214 YY_G(yy_current_buffer)->yy_input_file = yyin;
845 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; 1215 YY_G(yy_current_buffer)->yy_buffer_status = YY_BUFFER_NORMAL;
846 } 1216 }
@@ -854,3 +1224,3 @@ case YY_STATE_EOF(string_value):
854 */ 1224 */
855 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1225 if ( YY_G(yy_c_buf_p) <= &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
856 { /* This was really a NUL. */ 1226 { /* This was really a NUL. */
@@ -858,5 +1228,5 @@ case YY_STATE_EOF(string_value):
858 1228
859 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; 1229 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text;
860 1230
861 yy_current_state = yy_get_previous_state(); 1231 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
862 1232
@@ -871,5 +1241,5 @@ case YY_STATE_EOF(string_value):
871 1241
872 yy_next_state = yy_try_NUL_trans( yy_current_state ); 1242 yy_next_state = yy_try_NUL_trans( yy_current_state YY_CALL_LAST_ARG);
873 1243
874 yy_bp = yytext_ptr + YY_MORE_ADJ; 1244 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
875 1245
@@ -878,3 +1248,3 @@ case YY_STATE_EOF(string_value):
878 /* Consume the NUL. */ 1248 /* Consume the NUL. */
879 yy_cp = ++yy_c_buf_p; 1249 yy_cp = ++YY_G(yy_c_buf_p);
880 yy_current_state = yy_next_state; 1250 yy_current_state = yy_next_state;
@@ -885,3 +1255,4 @@ case YY_STATE_EOF(string_value):
885 { 1255 {
886 yy_cp = yy_c_buf_p; 1256/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
1257 yy_cp = YY_G(yy_c_buf_p);
887 goto yy_find_action; 1258 goto yy_find_action;
@@ -890,3 +1261,3 @@ case YY_STATE_EOF(string_value):
890 1261
891 else switch ( yy_get_next_buffer() ) 1262 else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
892 { 1263 {
@@ -894,5 +1265,5 @@ case YY_STATE_EOF(string_value):
894 { 1265 {
895 yy_did_buffer_switch_on_eof = 0; 1266 YY_G(yy_did_buffer_switch_on_eof) = 0;
896 1267
897 if ( yywrap() ) 1268 if ( yywrap( YY_CALL_ONLY_ARG ) )
898 { 1269 {
@@ -907,3 +1278,3 @@ case YY_STATE_EOF(string_value):
907 */ 1278 */
908 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; 1279 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ;
909 1280
@@ -915,3 +1286,3 @@ case YY_STATE_EOF(string_value):
915 { 1286 {
916 if ( ! yy_did_buffer_switch_on_eof ) 1287 if ( ! YY_G(yy_did_buffer_switch_on_eof) )
917 YY_NEW_FILE; 1288 YY_NEW_FILE;
@@ -922,9 +1293,9 @@ case YY_STATE_EOF(string_value):
922 case EOB_ACT_CONTINUE_SCAN: 1293 case EOB_ACT_CONTINUE_SCAN:
923 yy_c_buf_p = 1294 YY_G(yy_c_buf_p) =
924 yytext_ptr + yy_amount_of_matched_text; 1295 YY_G(yytext_ptr) + yy_amount_of_matched_text;
925 1296
926 yy_current_state = yy_get_previous_state(); 1297 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
927 1298
928 yy_cp = yy_c_buf_p; 1299 yy_cp = YY_G(yy_c_buf_p);
929 yy_bp = yytext_ptr + YY_MORE_ADJ; 1300 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
930 goto yy_match; 1301 goto yy_match;
@@ -932,9 +1303,9 @@ case YY_STATE_EOF(string_value):
932 case EOB_ACT_LAST_MATCH: 1303 case EOB_ACT_LAST_MATCH:
933 yy_c_buf_p = 1304 YY_G(yy_c_buf_p) =
934 &yy_current_buffer->yy_ch_buf[yy_n_chars]; 1305 &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)];
935 1306
936 yy_current_state = yy_get_previous_state(); 1307 yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
937 1308
938 yy_cp = yy_c_buf_p; 1309 yy_cp = YY_G(yy_c_buf_p);
939 yy_bp = yytext_ptr + YY_MORE_ADJ; 1310 yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
940 goto yy_find_action; 1311 goto yy_find_action;
@@ -950,3 +1321,10 @@ case YY_STATE_EOF(string_value):
950 } /* end of yylex */ 1321 } /* end of yylex */
951 1322/* %e */
1323#endif /* !ssIN_HEADER */
1324/* %+ */
1325/* %c */
1326#ifndef ssIN_HEADER
1327/* %e */
1328#endif /* !ssIN_HEADER */
1329/* %* */
952 1330
@@ -960,6 +1338,16 @@ case YY_STATE_EOF(string_value):
960 1338
961static int yy_get_next_buffer() 1339/* %- */
1340/* %c */
1341#ifndef ssIN_HEADER
1342#ifdef YY_USE_PROTOS
1343static int yy_get_next_buffer(YY_ONLY_ARG)
1344#else
1345static int yy_get_next_buffer(YY_ONLY_ARG)
1346YY_DECL_LAST_ARG
1347#endif
1348/* %+ */
1349/* %* */
962 { 1350 {
963 register char *dest = yy_current_buffer->yy_ch_buf; 1351 register char *dest = YY_G(yy_current_buffer)->yy_ch_buf;
964 register char *source = yytext_ptr; 1352 register char *source = YY_G(yytext_ptr);
965 register int number_to_move, i; 1353 register int number_to_move, i;
@@ -967,3 +1355,3 @@ static int yy_get_next_buffer()
967 1355
968 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) 1356 if ( YY_G(yy_c_buf_p) > &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] )
969 YY_FATAL_ERROR( 1357 YY_FATAL_ERROR(
@@ -971,5 +1359,5 @@ static int yy_get_next_buffer()
971 1359
972 if ( yy_current_buffer->yy_fill_buffer == 0 ) 1360 if ( YY_G(yy_current_buffer)->yy_fill_buffer == 0 )
973 { /* Don't try to fill the buffer, so this is an EOF. */ 1361 { /* Don't try to fill the buffer, so this is an EOF. */
974 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) 1362 if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 )
975 { 1363 {
@@ -993,3 +1381,3 @@ static int yy_get_next_buffer()
993 /* First move last chars to start of buffer. */ 1381 /* First move last chars to start of buffer. */
994 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; 1382 number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
995 1383
@@ -998,3 +1386,3 @@ static int yy_get_next_buffer()
998 1386
999 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1387 if ( YY_G(yy_current_buffer)->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1000 /* don't do the read, it's not guaranteed to return an EOF, 1388 /* don't do the read, it's not guaranteed to return an EOF,
@@ -1002,3 +1390,3 @@ static int yy_get_next_buffer()
1002 */ 1390 */
1003 yy_current_buffer->yy_n_chars = yy_n_chars = 0; 1391 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars) = 0;
1004 1392
@@ -1006,4 +1394,4 @@ static int yy_get_next_buffer()
1006 { 1394 {
1007 int num_to_read = 1395 size_t num_to_read =
1008 yy_current_buffer->yy_buf_size - number_to_move - 1; 1396 YY_G(yy_current_buffer)->yy_buf_size - number_to_move - 1;
1009 1397
@@ -1017,6 +1405,6 @@ static int yy_get_next_buffer()
1017 /* just a shorter name for the current buffer */ 1405 /* just a shorter name for the current buffer */
1018 YY_BUFFER_STATE b = yy_current_buffer; 1406 YY_BUFFER_STATE b = YY_G(yy_current_buffer);
1019 1407
1020 int yy_c_buf_p_offset = 1408 int yy_c_buf_p_offset =
1021 (int) (yy_c_buf_p - b->yy_ch_buf); 1409 (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf);
1022 1410
@@ -1034,3 +1422,3 @@ static int yy_get_next_buffer()
1034 yy_flex_realloc( (void *) b->yy_ch_buf, 1422 yy_flex_realloc( (void *) b->yy_ch_buf,
1035 b->yy_buf_size + 2 ); 1423 b->yy_buf_size + 2 YY_CALL_LAST_ARG );
1036 } 1424 }
@@ -1044,5 +1432,5 @@ static int yy_get_next_buffer()
1044 1432
1045 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; 1433 YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1046 1434
1047 num_to_read = yy_current_buffer->yy_buf_size - 1435 num_to_read = YY_G(yy_current_buffer)->yy_buf_size -
1048 number_to_move - 1; 1436 number_to_move - 1;
@@ -1055,9 +1443,9 @@ static int yy_get_next_buffer()
1055 /* Read in more data. */ 1443 /* Read in more data. */
1056 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), 1444 YY_INPUT( (&YY_G(yy_current_buffer)->yy_ch_buf[number_to_move]),
1057 yy_n_chars, num_to_read ); 1445 YY_G(yy_n_chars), num_to_read );
1058 1446
1059 yy_current_buffer->yy_n_chars = yy_n_chars; 1447 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
1060 } 1448 }
1061 1449
1062 if ( yy_n_chars == 0 ) 1450 if ( YY_G(yy_n_chars) == 0 )
1063 { 1451 {
@@ -1066,3 +1454,3 @@ static int yy_get_next_buffer()
1066 ret_val = EOB_ACT_END_OF_FILE; 1454 ret_val = EOB_ACT_END_OF_FILE;
1067 yyrestart( yyin ); 1455 yyrestart( yyin YY_CALL_LAST_ARG);
1068 } 1456 }
@@ -1072,3 +1460,3 @@ static int yy_get_next_buffer()
1072 ret_val = EOB_ACT_LAST_MATCH; 1460 ret_val = EOB_ACT_LAST_MATCH;
1073 yy_current_buffer->yy_buffer_status = 1461 YY_G(yy_current_buffer)->yy_buffer_status =
1074 YY_BUFFER_EOF_PENDING; 1462 YY_BUFFER_EOF_PENDING;
@@ -1080,7 +1468,7 @@ static int yy_get_next_buffer()
1080 1468
1081 yy_n_chars += number_to_move; 1469 YY_G(yy_n_chars) += number_to_move;
1082 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; 1470 YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1083 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; 1471 YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1084 1472
1085 yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; 1473 YY_G(yytext_ptr) = &YY_G(yy_current_buffer)->yy_ch_buf[0];
1086 1474
@@ -1088,3 +1476,4 @@ static int yy_get_next_buffer()
1088 } 1476 }
1089 1477/* %e */
1478#endif /* !ssIN_HEADER */
1090 1479
@@ -1092,3 +1481,13 @@ static int yy_get_next_buffer()
1092 1481
1093static yy_state_type yy_get_previous_state() 1482/* %- */
1483/* %c */
1484#ifndef ssIN_HEADER
1485#ifdef YY_USE_PROTOS
1486static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
1487#else
1488static yy_state_type yy_get_previous_state(YY_ONLY_ARG)
1489YY_DECL_LAST_ARG
1490#endif
1491/* %+ */
1492/* %* */
1094 { 1493 {
@@ -1097,6 +1496,8 @@ static yy_state_type yy_get_previous_state()
1097 1496
1098 yy_current_state = yy_start; 1497/* %% [15.0] code to get the start state into yy_current_state goes here */
1498 yy_current_state = YY_G(yy_start);
1099 1499
1100 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) 1500 for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp )
1101 { 1501 {
1502/* %% [16.0] code to find the next state goes here */
1102 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1503 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
@@ -1104,4 +1505,4 @@ static yy_state_type yy_get_previous_state()
1104 { 1505 {
1105 yy_last_accepting_state = yy_current_state; 1506 YY_G(yy_last_accepting_state) = yy_current_state;
1106 yy_last_accepting_cpos = yy_cp; 1507 YY_G(yy_last_accepting_cpos) = yy_cp;
1107 } 1508 }
@@ -1110,3 +1511,3 @@ static yy_state_type yy_get_previous_state()
1110 yy_current_state = (int) yy_def[yy_current_state]; 1511 yy_current_state = (int) yy_def[yy_current_state];
1111 if ( yy_current_state >= 47 ) 1512 if ( yy_current_state >= 56 )
1112 yy_c = yy_meta[(unsigned int) yy_c]; 1513 yy_c = yy_meta[(unsigned int) yy_c];
@@ -1126,11 +1527,16 @@ static yy_state_type yy_get_previous_state()
1126 1527
1528/* %- */
1127#ifdef YY_USE_PROTOS 1529#ifdef YY_USE_PROTOS
1128static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) 1530static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state YY_LAST_ARG )
1129#else 1531#else
1130static yy_state_type yy_try_NUL_trans( yy_current_state ) 1532static yy_state_type yy_try_NUL_trans( yy_current_state YY_LAST_ARG )
1131yy_state_type yy_current_state; 1533yy_state_type yy_current_state;
1534YY_DECL_LAST_ARG
1132#endif 1535#endif
1536/* %+ */
1537/* %* */
1133 { 1538 {
1134 register int yy_is_jam; 1539 register int yy_is_jam;
1135 register char *yy_cp = yy_c_buf_p; 1540/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1541 register char *yy_cp = YY_G(yy_c_buf_p);
1136 1542
@@ -1139,4 +1545,4 @@ yy_state_type yy_current_state;
1139 { 1545 {
1140 yy_last_accepting_state = yy_current_state; 1546 YY_G(yy_last_accepting_state) = yy_current_state;
1141 yy_last_accepting_cpos = yy_cp; 1547 YY_G(yy_last_accepting_cpos) = yy_cp;
1142 } 1548 }
@@ -1145,3 +1551,3 @@ yy_state_type yy_current_state;
1145 yy_current_state = (int) yy_def[yy_current_state]; 1551 yy_current_state = (int) yy_def[yy_current_state];
1146 if ( yy_current_state >= 47 ) 1552 if ( yy_current_state >= 56 )
1147 yy_c = yy_meta[(unsigned int) yy_c]; 1553 yy_c = yy_meta[(unsigned int) yy_c];
@@ -1149,3 +1555,3 @@ yy_state_type yy_current_state;
1149 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1555 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1150 yy_is_jam = (yy_current_state == 46); 1556 yy_is_jam = (yy_current_state == 55);
1151 1557
@@ -1155,26 +1561,30 @@ yy_state_type yy_current_state;
1155 1561
1562/* %- */
1156#ifndef YY_NO_UNPUT 1563#ifndef YY_NO_UNPUT
1157#ifdef YY_USE_PROTOS 1564#ifdef YY_USE_PROTOS
1158static void yyunput( int c, register char *yy_bp ) 1565static void yyunput( int c, register char *yy_bp YY_LAST_ARG )
1159#else 1566#else
1160static void yyunput( c, yy_bp ) 1567static void yyunput( c, yy_bp YY_LAST_ARG)
1161int c; 1568int c;
1162register char *yy_bp; 1569register char *yy_bp;
1570YY_DECL_LAST_ARG
1163#endif 1571#endif
1572/* %+ */
1573/* %* */
1164 { 1574 {
1165 register char *yy_cp = yy_c_buf_p; 1575 register char *yy_cp = YY_G(yy_c_buf_p);
1166 1576
1167 /* undo effects of setting up yytext */ 1577 /* undo effects of setting up yytext */
1168 *yy_cp = yy_hold_char; 1578 *yy_cp = YY_G(yy_hold_char);
1169 1579
1170 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1580 if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
1171 { /* need to shift things up to make room */ 1581 { /* need to shift things up to make room */
1172 /* +2 for EOB chars. */ 1582 /* +2 for EOB chars. */
1173 register int number_to_move = yy_n_chars + 2; 1583 register int number_to_move = YY_G(yy_n_chars) + 2;
1174 register char *dest = &yy_current_buffer->yy_ch_buf[ 1584 register char *dest = &YY_G(yy_current_buffer)->yy_ch_buf[
1175 yy_current_buffer->yy_buf_size + 2]; 1585 YY_G(yy_current_buffer)->yy_buf_size + 2];
1176 register char *source = 1586 register char *source =
1177 &yy_current_buffer->yy_ch_buf[number_to_move]; 1587 &YY_G(yy_current_buffer)->yy_ch_buf[number_to_move];
1178 1588
1179 while ( source > yy_current_buffer->yy_ch_buf ) 1589 while ( source > YY_G(yy_current_buffer)->yy_ch_buf )
1180 *--dest = *--source; 1590 *--dest = *--source;
@@ -1183,6 +1593,6 @@ register char *yy_bp;
1183 yy_bp += (int) (dest - source); 1593 yy_bp += (int) (dest - source);
1184 yy_current_buffer->yy_n_chars = 1594 YY_G(yy_current_buffer)->yy_n_chars =
1185 yy_n_chars = yy_current_buffer->yy_buf_size; 1595 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_buf_size;
1186 1596
1187 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) 1597 if ( yy_cp < YY_G(yy_current_buffer)->yy_ch_buf + 2 )
1188 YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1598 YY_FATAL_ERROR( "flex scanner push-back overflow" );
@@ -1192,15 +1602,27 @@ register char *yy_bp;
1192 1602
1603/* %% [18.0] update yylineno here */
1193 1604
1194 yytext_ptr = yy_bp; 1605 YY_G(yytext_ptr) = yy_bp;
1195 yy_hold_char = *yy_cp; 1606 YY_G(yy_hold_char) = *yy_cp;
1196 yy_c_buf_p = yy_cp; 1607 YY_G(yy_c_buf_p) = yy_cp;
1197 } 1608 }
1609/* %- */
1198 #endif/* ifndef YY_NO_UNPUT */ 1610 #endif/* ifndef YY_NO_UNPUT */
1611/* %* */
1199 1612
1200 1613
1614/* %- */
1615#ifndef YY_NO_INPUT
1201#ifdef __cplusplus 1616#ifdef __cplusplus
1202static int yyinput() 1617static int yyinput(YY_ONLY_ARG)
1203#else 1618#else
1204static int input() 1619#ifdef YY_USE_PROTOS
1620static int input(YY_ONLY_ARG)
1621#else
1622static int input(YY_ONLY_ARG)
1623 YY_DECL_LAST_ARG
1624#endif
1205#endif 1625#endif
1626/* %+ */
1627/* %* */
1206 { 1628 {
@@ -1208,5 +1630,5 @@ static int input()
1208 1630
1209 *yy_c_buf_p = yy_hold_char; 1631 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
1210 1632
1211 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) 1633 if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1212 { 1634 {
@@ -1216,5 +1638,5 @@ static int input()
1216 */ 1638 */
1217 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) 1639 if ( YY_G(yy_c_buf_p) < &YY_G(yy_current_buffer)->yy_ch_buf[YY_G(yy_n_chars)] )
1218 /* This was really a NUL. */ 1640 /* This was really a NUL. */
1219 *yy_c_buf_p = '\0'; 1641 *YY_G(yy_c_buf_p) = '\0';
1220 1642
@@ -1222,6 +1644,6 @@ static int input()
1222 { /* need more input */ 1644 { /* need more input */
1223 int offset = yy_c_buf_p - yytext_ptr; 1645 int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);
1224 ++yy_c_buf_p; 1646 ++YY_G(yy_c_buf_p);
1225 1647
1226 switch ( yy_get_next_buffer() ) 1648 switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
1227 { 1649 {
@@ -1239,3 +1661,3 @@ static int input()
1239 /* Reset buffer status. */ 1661 /* Reset buffer status. */
1240 yyrestart( yyin ); 1662 yyrestart( yyin YY_CALL_LAST_ARG);
1241 1663
@@ -1245,11 +1667,11 @@ static int input()
1245 { 1667 {
1246 if ( yywrap() ) 1668 if ( yywrap( YY_CALL_ONLY_ARG ) )
1247 return EOF; 1669 return EOF;
1248 1670
1249 if ( ! yy_did_buffer_switch_on_eof ) 1671 if ( ! YY_G(yy_did_buffer_switch_on_eof) )
1250 YY_NEW_FILE; 1672 YY_NEW_FILE;
1251#ifdef __cplusplus 1673#ifdef __cplusplus
1252 return yyinput(); 1674 return yyinput(YY_CALL_ONLY_ARG);
1253#else 1675#else
1254 return input(); 1676 return input(YY_CALL_ONLY_ARG);
1255#endif 1677#endif
@@ -1258,3 +1680,3 @@ static int input()
1258 case EOB_ACT_CONTINUE_SCAN: 1680 case EOB_ACT_CONTINUE_SCAN:
1259 yy_c_buf_p = yytext_ptr + offset; 1681 YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset;
1260 break; 1682 break;
@@ -1264,6 +1686,7 @@ static int input()
1264 1686
1265 c = *(unsigned char *) yy_c_buf_p;/* cast for 8-bit char's */ 1687 c = *(unsigned char *) YY_G(yy_c_buf_p);/* cast for 8-bit char's */
1266 *yy_c_buf_p = '\0';/* preserve yytext */ 1688 *YY_G(yy_c_buf_p) = '\0';/* preserve yytext */
1267 yy_hold_char = *++yy_c_buf_p; 1689 YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p);
1268 1690
1691/* %% [19.0] update BOL and yylineno */
1269 1692
@@ -1271,16 +1694,23 @@ static int input()
1271 } 1694 }
1695/* %- */
1696 #endif/* ifndef YY_NO_INPUT */
1697/* %* */
1272 1698
1273 1699/* %- */
1274#ifdef YY_USE_PROTOS 1700#ifdef YY_USE_PROTOS
1275void yyrestart( FILE *input_file ) 1701void yyrestart( FILE *input_file YY_LAST_ARG)
1276#else 1702#else
1277void yyrestart( input_file ) 1703void yyrestart( input_file YY_LAST_ARG)
1278FILE *input_file; 1704FILE *input_file;
1705YY_DECL_LAST_ARG
1279#endif 1706#endif
1707/* %+ */
1708/* %* */
1280 { 1709 {
1281 if ( ! yy_current_buffer ) 1710 if ( ! YY_G(yy_current_buffer) )
1282 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); 1711 YY_G(yy_current_buffer) =
1712 yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
1283 1713
1284 yy_init_buffer( yy_current_buffer, input_file ); 1714 yy_init_buffer( YY_G(yy_current_buffer), input_file YY_CALL_LAST_ARG);
1285 yy_load_buffer_state(); 1715 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1286 } 1716 }
@@ -1288,22 +1718,26 @@ FILE *input_file;
1288 1718
1719/* %- */
1289#ifdef YY_USE_PROTOS 1720#ifdef YY_USE_PROTOS
1290void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) 1721void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer YY_LAST_ARG )
1291#else 1722#else
1292void yy_switch_to_buffer( new_buffer ) 1723void yy_switch_to_buffer( new_buffer YY_LAST_ARG )
1293YY_BUFFER_STATE new_buffer; 1724YY_BUFFER_STATE new_buffer;
1725YY_DECL_LAST_ARG
1294#endif 1726#endif
1727/* %+ */
1728/* %* */
1295 { 1729 {
1296 if ( yy_current_buffer == new_buffer ) 1730 if ( YY_G(yy_current_buffer) == new_buffer )
1297 return; 1731 return;
1298 1732
1299 if ( yy_current_buffer ) 1733 if ( YY_G(yy_current_buffer) )
1300 { 1734 {
1301 /* Flush out information for old buffer. */ 1735 /* Flush out information for old buffer. */
1302 *yy_c_buf_p = yy_hold_char; 1736 *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
1303 yy_current_buffer->yy_buf_pos = yy_c_buf_p; 1737 YY_G(yy_current_buffer)->yy_buf_pos = YY_G(yy_c_buf_p);
1304 yy_current_buffer->yy_n_chars = yy_n_chars; 1738 YY_G(yy_current_buffer)->yy_n_chars = YY_G(yy_n_chars);
1305 } 1739 }
1306 1740
1307 yy_current_buffer = new_buffer; 1741 YY_G(yy_current_buffer) = new_buffer;
1308 yy_load_buffer_state(); 1742 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1309 1743
@@ -1314,3 +1748,3 @@ YY_BUFFER_STATE new_buffer;
1314 */ 1748 */
1315 yy_did_buffer_switch_on_eof = 1; 1749 YY_G(yy_did_buffer_switch_on_eof) = 1;
1316 } 1750 }
@@ -1318,12 +1752,16 @@ YY_BUFFER_STATE new_buffer;
1318 1752
1753/* %- */
1319#ifdef YY_USE_PROTOS 1754#ifdef YY_USE_PROTOS
1320void yy_load_buffer_state( void ) 1755void yy_load_buffer_state( YY_ONLY_ARG )
1321#else 1756#else
1322void yy_load_buffer_state() 1757void yy_load_buffer_state(YY_ONLY_ARG )
1758YY_DECL_LAST_ARG
1323#endif 1759#endif
1760/* %+ */
1761/* %* */
1324 { 1762 {
1325 yy_n_chars = yy_current_buffer->yy_n_chars; 1763 YY_G(yy_n_chars) = YY_G(yy_current_buffer)->yy_n_chars;
1326 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; 1764 YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_G(yy_current_buffer)->yy_buf_pos;
1327 yyin = yy_current_buffer->yy_input_file; 1765 yyin = YY_G(yy_current_buffer)->yy_input_file;
1328 yy_hold_char = *yy_c_buf_p; 1766 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
1329 } 1767 }
@@ -1331,9 +1769,13 @@ void yy_load_buffer_state()
1331 1769
1770/* %- */
1332#ifdef YY_USE_PROTOS 1771#ifdef YY_USE_PROTOS
1333YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) 1772YY_BUFFER_STATE yy_create_buffer( FILE *file, int size YY_LAST_ARG)
1334#else 1773#else
1335YY_BUFFER_STATE yy_create_buffer( file, size ) 1774YY_BUFFER_STATE yy_create_buffer( file, size YY_LAST_ARG)
1336FILE *file; 1775FILE *file;
1337int size; 1776int size;
1777YY_DECL_LAST_ARG
1338#endif 1778#endif
1779/* %+ */
1780/* %* */
1339 { 1781 {
@@ -1341,3 +1783,3 @@ int size;
1341 1783
1342 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1784 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
1343 if ( ! b ) 1785 if ( ! b )
@@ -1350,3 +1792,3 @@ int size;
1350 */ 1792 */
1351 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); 1793 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
1352 if ( ! b->yy_ch_buf ) 1794 if ( ! b->yy_ch_buf )
@@ -1356,3 +1798,3 @@ int size;
1356 1798
1357 yy_init_buffer( b, file ); 1799 yy_init_buffer( b, file YY_CALL_LAST_ARG);
1358 1800
@@ -1362,8 +1804,12 @@ int size;
1362 1804
1805/* %- */
1363#ifdef YY_USE_PROTOS 1806#ifdef YY_USE_PROTOS
1364void yy_delete_buffer( YY_BUFFER_STATE b ) 1807void yy_delete_buffer( YY_BUFFER_STATE b YY_LAST_ARG)
1365#else 1808#else
1366void yy_delete_buffer( b ) 1809void yy_delete_buffer( b YY_LAST_ARG)
1367YY_BUFFER_STATE b; 1810YY_BUFFER_STATE b;
1811YY_DECL_LAST_ARG
1368#endif 1812#endif
1813/* %+ */
1814/* %* */
1369 { 1815 {
@@ -1372,9 +1818,9 @@ YY_BUFFER_STATE b;
1372 1818
1373 if ( b == yy_current_buffer ) 1819 if ( b == YY_G(yy_current_buffer) )
1374 yy_current_buffer = (YY_BUFFER_STATE) 0; 1820 YY_G(yy_current_buffer) = (YY_BUFFER_STATE) 0;
1375 1821
1376 if ( b->yy_is_our_buffer ) 1822 if ( b->yy_is_our_buffer )
1377 yy_flex_free( (void *) b->yy_ch_buf ); 1823 yy_flex_free( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
1378 1824
1379 yy_flex_free( (void *) b ); 1825 yy_flex_free( (void *) b YY_CALL_LAST_ARG );
1380 } 1826 }
@@ -1382,14 +1828,29 @@ YY_BUFFER_STATE b;
1382 1828
1829/* %- */
1830#ifndef YY_ALWAYS_INTERACTIVE
1831#ifndef YY_NEVER_INTERACTIVE
1832#ifdef __cplusplus
1833extern "C" int isatty YY_PROTO(( int ));
1834#else
1835extern int isatty YY_PROTO(( int ));
1836#endif /* __cplusplus */
1837#endif /* !YY_NEVER_INTERACTIVE */
1838#endif /* !YY_ALWAYS_INTERACTIVE */
1383 1839
1384#ifdef YY_USE_PROTOS 1840#ifdef YY_USE_PROTOS
1385void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) 1841void yy_init_buffer( YY_BUFFER_STATE b, FILE *file YY_LAST_ARG)
1386#else 1842#else
1387void yy_init_buffer( b, file ) 1843void yy_init_buffer( b, file YY_LAST_ARG)
1388YY_BUFFER_STATE b; 1844YY_BUFFER_STATE b;
1389FILE *file; 1845FILE *file;
1846YY_DECL_LAST_ARG
1390#endif 1847#endif
1391 1848
1849/* %+ */
1850/* %* */
1392 1851
1393 { 1852 {
1394 yy_flush_buffer( b ); 1853 int oerrno = errno;
1854
1855 yy_flush_buffer( b YY_CALL_LAST_ARG);
1395 1856
@@ -1398,2 +1859,3 @@ FILE *file;
1398 1859
1860/* %- */
1399#if YY_ALWAYS_INTERACTIVE 1861#if YY_ALWAYS_INTERACTIVE
@@ -1404,11 +1866,8 @@ FILE *file;
1404#else 1866#else
1405
1406#ifdef _QTWIN_
1407 b->yy_is_interactive = file ? (_isatty( fileno(file) ) > 0) : 0;
1408#else
1409 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1867 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1410#endif 1868#endif
1411
1412#endif
1413#endif 1869#endif
1870/* %+ */
1871/* %* */
1872 errno = oerrno;
1414 } 1873 }
@@ -1416,9 +1875,13 @@ FILE *file;
1416 1875
1876/* %- */
1417#ifdef YY_USE_PROTOS 1877#ifdef YY_USE_PROTOS
1418void yy_flush_buffer( YY_BUFFER_STATE b ) 1878void yy_flush_buffer( YY_BUFFER_STATE b YY_LAST_ARG )
1419#else 1879#else
1420void yy_flush_buffer( b ) 1880void yy_flush_buffer( b YY_LAST_ARG )
1421YY_BUFFER_STATE b; 1881YY_BUFFER_STATE b;
1882YY_DECL_LAST_ARG
1422#endif 1883#endif
1423 1884
1885/* %+ */
1886/* %* */
1424 { 1887 {
@@ -1441,5 +1904,6 @@ YY_BUFFER_STATE b;
1441 1904
1442 if ( b == yy_current_buffer ) 1905 if ( b == YY_G(yy_current_buffer) )
1443 yy_load_buffer_state(); 1906 yy_load_buffer_state( YY_CALL_ONLY_ARG );
1444 } 1907 }
1908/* %* */
1445 1909
@@ -1447,8 +1911,10 @@ YY_BUFFER_STATE b;
1447#ifndef YY_NO_SCAN_BUFFER 1911#ifndef YY_NO_SCAN_BUFFER
1912/* %- */
1448#ifdef YY_USE_PROTOS 1913#ifdef YY_USE_PROTOS
1449YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) 1914YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size YY_LAST_ARG )
1450#else 1915#else
1451YY_BUFFER_STATE yy_scan_buffer( base, size ) 1916YY_BUFFER_STATE yy_scan_buffer( base, size YY_LAST_ARG )
1452char *base; 1917char *base;
1453yy_size_t size; 1918yy_size_t size;
1919YY_DECL_LAST_ARG
1454#endif 1920#endif
@@ -1463,3 +1929,3 @@ yy_size_t size;
1463 1929
1464 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); 1930 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
1465 if ( ! b ) 1931 if ( ! b )
@@ -1477,3 +1943,3 @@ yy_size_t size;
1477 1943
1478 yy_switch_to_buffer( b ); 1944 yy_switch_to_buffer( b YY_CALL_LAST_ARG );
1479 1945
@@ -1481,2 +1947,3 @@ yy_size_t size;
1481 } 1947 }
1948/* %* */
1482#endif 1949#endif
@@ -1485,7 +1952,9 @@ yy_size_t size;
1485#ifndef YY_NO_SCAN_STRING 1952#ifndef YY_NO_SCAN_STRING
1953/* %- */
1486#ifdef YY_USE_PROTOS 1954#ifdef YY_USE_PROTOS
1487YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) 1955YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str YY_LAST_ARG )
1488#else 1956#else
1489YY_BUFFER_STATE yy_scan_string( yy_str ) 1957YY_BUFFER_STATE yy_scan_string( yy_str YY_LAST_ARG)
1490yyconst char *yy_str; 1958yyconst char *yy_str;
1959YY_DECL_LAST_ARG
1491#endif 1960#endif
@@ -1496,4 +1965,5 @@ yyconst char *yy_str;
1496 1965
1497 return yy_scan_bytes( yy_str, len ); 1966 return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG);
1498 } 1967 }
1968/* %* */
1499#endif 1969#endif
@@ -1502,7 +1972,9 @@ yyconst char *yy_str;
1502#ifndef YY_NO_SCAN_BYTES 1972#ifndef YY_NO_SCAN_BYTES
1973/* %- */
1503#ifdef YY_USE_PROTOS 1974#ifdef YY_USE_PROTOS
1504YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) 1975YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len YY_LAST_ARG)
1505#else 1976#else
1506YY_BUFFER_STATE yy_scan_bytes( bytes, len ) 1977YY_BUFFER_STATE yy_scan_bytes( bytes, len YY_LAST_ARG)
1507yyconst char *bytes; 1978yyconst char *bytes;
1979YY_DECL_LAST_ARG
1508int len; 1980int len;
@@ -1517,3 +1989,3 @@ int len;
1517 n = len + 2; 1989 n = len + 2;
1518 buf = (char *) yy_flex_alloc( n ); 1990 buf = (char *) yy_flex_alloc( n YY_CALL_LAST_ARG );
1519 if ( ! buf ) 1991 if ( ! buf )
@@ -1526,3 +1998,3 @@ int len;
1526 1998
1527 b = yy_scan_buffer( buf, n ); 1999 b = yy_scan_buffer( buf, n YY_CALL_LAST_ARG);
1528 if ( ! b ) 2000 if ( ! b )
@@ -1537,2 +2009,3 @@ int len;
1537 } 2009 }
2010/* %* */
1538#endif 2011#endif
@@ -1541,10 +2014,14 @@ int len;
1541#ifndef YY_NO_PUSH_STATE 2014#ifndef YY_NO_PUSH_STATE
2015/* %- */
1542#ifdef YY_USE_PROTOS 2016#ifdef YY_USE_PROTOS
1543static void yy_push_state( int new_state ) 2017static void yy_push_state( int new_state YY_LAST_ARG)
1544#else 2018#else
1545static void yy_push_state( new_state ) 2019static void yy_push_state( new_state YY_LAST_ARG)
1546int new_state; 2020int new_state;
2021YY_DECL_LAST_ARG
1547#endif 2022#endif
2023/* %+ */
2024/* %* */
1548 { 2025 {
1549 if ( yy_start_stack_ptr >= yy_start_stack_depth ) 2026 if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
1550 { 2027 {
@@ -1552,13 +2029,13 @@ int new_state;
1552 2029
1553 yy_start_stack_depth += YY_START_STACK_INCR; 2030 YY_G(yy_start_stack_depth) += YY_START_STACK_INCR;
1554 new_size = yy_start_stack_depth * sizeof( int ); 2031 new_size = YY_G(yy_start_stack_depth) * sizeof( int );
1555 2032
1556 if ( ! yy_start_stack ) 2033 if ( ! YY_G(yy_start_stack) )
1557 yy_start_stack = (int *) yy_flex_alloc( new_size ); 2034 YY_G(yy_start_stack) = (int *) yy_flex_alloc( new_size YY_CALL_LAST_ARG );
1558 2035
1559 else 2036 else
1560 yy_start_stack = (int *) yy_flex_realloc( 2037 YY_G(yy_start_stack) = (int *) yy_flex_realloc(
1561 (void *) yy_start_stack, new_size ); 2038 (void *) YY_G(yy_start_stack), new_size YY_CALL_LAST_ARG );
1562 2039
1563 if ( ! yy_start_stack ) 2040 if ( ! YY_G(yy_start_stack) )
1564 YY_FATAL_ERROR( 2041 YY_FATAL_ERROR(
@@ -1567,3 +2044,3 @@ int new_state;
1567 2044
1568 yy_start_stack[yy_start_stack_ptr++] = YY_START; 2045 YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
1569 2046
@@ -1575,8 +2052,16 @@ int new_state;
1575#ifndef YY_NO_POP_STATE 2052#ifndef YY_NO_POP_STATE
1576static void yy_pop_state() 2053/* %- */
2054#ifdef YY_USE_PROTOS
2055static void yy_pop_state( YY_ONLY_ARG )
2056#else
2057static void yy_pop_state( YY_ONLY_ARG )
2058YY_DECL_LAST_ARG
2059#endif
2060/* %+ */
2061/* %* */
1577 { 2062 {
1578 if ( --yy_start_stack_ptr < 0 ) 2063 if ( --YY_G(yy_start_stack_ptr) < 0 )
1579 YY_FATAL_ERROR( "start-condition stack underflow" ); 2064 YY_FATAL_ERROR( "start-condition stack underflow" );
1580 2065
1581 BEGIN(yy_start_stack[yy_start_stack_ptr]); 2066 BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
1582 } 2067 }
@@ -1586,5 +2071,13 @@ static void yy_pop_state()
1586#ifndef YY_NO_TOP_STATE 2071#ifndef YY_NO_TOP_STATE
1587static int yy_top_state() 2072/* %- */
2073#ifdef YY_USE_PROTOS
2074static int yy_top_state( YY_ONLY_ARG )
2075#else
2076static int yy_top_state( YY_ONLY_ARG )
2077YY_DECL_LAST_ARG
2078#endif
2079/* %+ */
2080/* %* */
1588 { 2081 {
1589 return yy_start_stack[yy_start_stack_ptr - 1]; 2082 return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
1590 } 2083 }
@@ -1596,8 +2089,4 @@ static int yy_top_state()
1596 2089
1597#ifdef YY_USE_PROTOS 2090/* %- */
1598static void yy_fatal_error( yyconst char msg[] ) 2091static void yy_fatal_error( yyconst char msg[] )
1599#else
1600static void yy_fatal_error( msg )
1601char msg[];
1602#endif
1603 { 2092 {
@@ -1607,2 +2096,4 @@ char msg[];
1607 2096
2097/* %+ */
2098/* %* */
1608 2099
@@ -1616,6 +2107,6 @@ char msg[];
1616 /* Undo effects of setting up yytext. */ \ 2107 /* Undo effects of setting up yytext. */ \
1617 yytext[yyleng] = yy_hold_char; \ 2108 yytext[yyleng] = YY_G(yy_hold_char); \
1618 yy_c_buf_p = yytext + n; \ 2109 YY_G(yy_c_buf_p) = yytext + n; \
1619 yy_hold_char = *yy_c_buf_p; \ 2110 YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
1620 *yy_c_buf_p = '\0'; \ 2111 *YY_G(yy_c_buf_p) = '\0'; \
1621 yyleng = n; \ 2112 yyleng = n; \
@@ -1625,2 +2116,264 @@ char msg[];
1625 2116
2117
2118#ifdef YY_REENTRANT
2119
2120/* Accessor methods (get/set functions) to struct members. */
2121
2122#ifndef YY_NO_GET_EXTRA
2123#ifdef YY_USE_PROTOS
2124YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
2125#else
2126YY_EXTRA_TYPE yyget_extra( YY_ONLY_ARG )
2127 YY_DECL_LAST_ARG
2128#endif
2129{
2130 return yyextra;
2131}
2132#endif /* !YY_NO_GET_EXTRA */
2133
2134#ifndef YY_NO_GET_LINENO
2135# ifdef YY_USE_PROTOS
2136int yyget_lineno( YY_ONLY_ARG )
2137# else
2138int yyget_lineno( YY_ONLY_ARG )
2139 YY_DECL_LAST_ARG
2140# endif
2141{
2142 return yylineno;
2143}
2144#endif /* !YY_NO_GET_LINENO */
2145
2146#ifndef YY_NO_GET_IN
2147#ifdef YY_USE_PROTOS
2148FILE *yyget_in( YY_ONLY_ARG )
2149#else
2150FILE *yyget_in( YY_ONLY_ARG )
2151 YY_DECL_LAST_ARG
2152#endif
2153{
2154 return yyin;
2155}
2156#endif /* !YY_NO_GET_IN */
2157
2158#ifndef YY_NO_GET_OUT
2159#ifdef YY_USE_PROTOS
2160FILE *yyget_out( YY_ONLY_ARG )
2161#else
2162FILE *yyget_out( YY_ONLY_ARG )
2163 YY_DECL_LAST_ARG
2164#endif
2165{
2166 return yyout;
2167}
2168#endif /* !YY_NO_GET_OUT */
2169
2170#ifndef YY_NO_GET_LENG
2171#ifdef YY_USE_PROTOS
2172int yyget_leng( YY_ONLY_ARG )
2173#else
2174int yyget_leng( YY_ONLY_ARG )
2175 YY_DECL_LAST_ARG
2176#endif
2177{
2178 return yyleng;
2179}
2180#endif /* !YY_NO_GET_LENG */
2181
2182#ifndef YY_NO_GET_TEXT
2183#ifdef YY_USE_PROTOS
2184char *yyget_text( YY_ONLY_ARG )
2185#else
2186char *yyget_text( YY_ONLY_ARG )
2187 YY_DECL_LAST_ARG
2188#endif
2189{
2190 return yytext;
2191}
2192#endif /* !YY_NO_GET_TEXT */
2193
2194#ifndef YY_NO_SET_EXTRA
2195#ifdef YY_USE_PROTOS
2196void yyset_extra( YY_EXTRA_TYPE user_defined YY_LAST_ARG )
2197#else
2198void yyset_extra( user_defined YY_LAST_ARG )
2199 YY_EXTRA_TYPE user_defined;
2200 YY_DECL_LAST_ARG
2201#endif
2202{
2203 yyextra = user_defined ;
2204}
2205#endif /* !YY_NO_SET_EXTRA */
2206
2207#ifndef YY_NO_SET_LINENO
2208# ifdef YY_USE_PROTOS
2209void yyset_lineno( int line_number YY_LAST_ARG )
2210# else
2211void yyset_lineno( line_number YY_LAST_ARG )
2212 int line_number;
2213 YY_DECL_LAST_ARG
2214# endif
2215{
2216 yylineno = line_number;
2217}
2218#endif /* !YY_NO_SET_LINENO */
2219
2220
2221#ifndef YY_NO_SET_IN
2222#ifdef YY_USE_PROTOS
2223void yyset_in( FILE * in_str YY_LAST_ARG )
2224#else
2225void yyset_in( in_str YY_LAST_ARG )
2226 FILE * in_str;
2227 YY_DECL_LAST_ARG
2228#endif
2229{
2230 yyin = in_str ;
2231}
2232#endif /* !YY_NO_SET_IN */
2233
2234#ifndef YY_NO_SET_OUT
2235#ifdef YY_USE_PROTOS
2236void yyset_out( FILE * out_str YY_LAST_ARG )
2237#else
2238void yyset_out( out_str YY_LAST_ARG )
2239 FILE * out_str;
2240 YY_DECL_LAST_ARG
2241#endif
2242{
2243 yyout = out_str ;
2244}
2245#endif /* !YY_NO_SET_OUT */
2246
2247/* Accessor methods for yylval and yylloc */
2248
2249#ifdef YY_REENTRANT_BISON_PURE
2250#ifndef YY_NO_GET_LVAL
2251#ifdef YY_USE_PROTOS
2252YYSTYPE * yyget_lval( YY_ONLY_ARG )
2253#else
2254YYSTYPE * yyget_lval( YY_ONLY_ARG )
2255 YY_DECL_LAST_ARG
2256#endif
2257{
2258 return yylval;
2259}
2260#endif /* !YY_NO_GET_LVAL */
2261
2262#ifndef YY_NO_SET_LVAL
2263#ifdef YY_USE_PROTOS
2264void yyset_lval( YYSTYPE * yylvalp YY_LAST_ARG )
2265#else
2266void yyset_lval( yylvalp YY_LAST_ARG )
2267 YYSTYPE * yylvalp;
2268 YY_DECL_LAST_ARG
2269#endif
2270{
2271 yylval = yylvalp;
2272}
2273#endif /* !YY_NO_SET_LVAL */
2274
2275#ifdef YYLTYPE
2276#ifndef YY_NO_GET_LLOC
2277#ifdef YY_USE_PROTOS
2278YYLTYPE *yyget_lloc( YY_ONLY_ARG )
2279#else
2280YYLTYPE *yyget_lloc( YY_ONLY_ARG )
2281 YY_DECL_LAST_ARG
2282#endif
2283{
2284 return yylloc;
2285}
2286#endif /* !YY_NO_GET_LLOC */
2287
2288#ifndef YY_NO_SET_LLOC
2289#ifdef YY_USE_PROTOS
2290void yyset_lloc( YYLTYPE * yyllocp YY_LAST_ARG )
2291#else
2292void yyset_lloc( yyllocp YY_LAST_ARG )
2293 YYLTYPE * yyllocp;
2294 YY_DECL_LAST_ARG
2295#endif
2296{
2297 yylloc = yyllocp;
2298}
2299#endif /* !YY_NO_SET_LLOC */
2300
2301#endif /* YYLTYPE */
2302#endif /* YY_REENTRANT_BISON_PURE */
2303
2304
2305#ifdef YY_USE_PROTOS
2306static int yy_init_globals( yyscan_t yy_globals)
2307#else
2308static int yy_init_globals( yy_globals )
2309 yyscan_t yy_globals;
2310#endif
2311 {
2312 /* Initialization is the same as for the non-reentrant scanner.
2313 This function is called once per scanner lifetime. */
2314
2315 /* We do not touch yylineno unless the option is enabled. */
2316#ifdef YY_USE_LINENO
2317 yylineno = 1;
2318#endif
2319 YY_G(yy_current_buffer) = 0;
2320 YY_G(yy_c_buf_p) = (char *) 0;
2321 YY_G(yy_init) = 1;
2322 YY_G(yy_start) = 0;
2323 YY_G(yy_start_stack_ptr) = 0;
2324 YY_G(yy_start_stack_depth) = 0;
2325 YY_G(yy_start_stack) = (int *) 0;
2326
2327/* Defined in main.c */
2328#ifdef YY_STDINIT
2329 yyin = stdin;
2330 yyout = stdout;
2331#else
2332 yyin = (FILE *) 0;
2333 yyout = (FILE *) 0;
2334#endif
2335 return 0;
2336 }
2337
2338/* User-visible API */
2339#ifdef YY_USE_PROTOS
2340int yylex_init( yyscan_t* ptr_yy_globals)
2341#else
2342int yylex_init( ptr_yy_globals )
2343 yyscan_t* ptr_yy_globals;
2344#endif
2345 {
2346 *ptr_yy_globals = (yyscan_t) yy_flex_alloc ( sizeof( struct yy_globals_t ), NULL );
2347 yy_init_globals ( *ptr_yy_globals );
2348 return 0;
2349 }
2350
2351#ifdef YY_USE_PROTOS
2352int yylex_destroy( yyscan_t yy_globals )
2353#else
2354int yylex_destroy( yy_globals )
2355 yyscan_t yy_globals;
2356#endif
2357 {
2358 if( yy_globals )
2359 {
2360
2361 /* Destroy the current (main) buffer. */
2362 yy_delete_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG );
2363 YY_G(yy_current_buffer) = NULL;
2364
2365 /* Destroy the start condition stack. */
2366 if( YY_G(yy_start_stack) ) {
2367 yy_flex_free( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
2368 YY_G(yy_start_stack) = NULL;
2369 }
2370
2371 /* Destroy the main struct. */
2372 yy_flex_free ( yy_globals YY_CALL_LAST_ARG );
2373 }
2374 return 0;
2375 }
2376
2377#endif /* End YY_REENTRANT */
2378
1626/* Internal utility routines. */ 2379/* Internal utility routines. */
@@ -1629,5 +2382,5 @@ char msg[];
1629#ifdef YY_USE_PROTOS 2382#ifdef YY_USE_PROTOS
1630static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) 2383static void yy_flex_strncpy( char *s1, yyconst char *s2, int n YY_LAST_ARG)
1631#else 2384#else
1632static void yy_flex_strncpy( s1, s2, n ) 2385static void yy_flex_strncpy( s1, s2, n YY_LAST_ARG)
1633char *s1; 2386char *s1;
@@ -1635,2 +2388,3 @@ yyconst char *s2;
1635int n; 2388int n;
2389YY_DECL_LAST_ARG
1636#endif 2390#endif
@@ -1645,6 +2399,7 @@ int n;
1645#ifdef YY_USE_PROTOS 2399#ifdef YY_USE_PROTOS
1646static int yy_flex_strlen( yyconst char *s ) 2400static int yy_flex_strlen( yyconst char *s YY_LAST_ARG)
1647#else 2401#else
1648static int yy_flex_strlen( s ) 2402static int yy_flex_strlen( s YY_LAST_ARG)
1649yyconst char *s; 2403yyconst char *s;
2404YY_DECL_LAST_ARG
1650#endif 2405#endif
@@ -1661,6 +2416,7 @@ yyconst char *s;
1661#ifdef YY_USE_PROTOS 2416#ifdef YY_USE_PROTOS
1662static void *yy_flex_alloc( yy_size_t size ) 2417static void *yy_flex_alloc( yy_size_t size YY_LAST_ARG )
1663#else 2418#else
1664static void *yy_flex_alloc( size ) 2419static void *yy_flex_alloc( size YY_LAST_ARG )
1665yy_size_t size; 2420yy_size_t size;
2421YY_DECL_LAST_ARG
1666#endif 2422#endif
@@ -1671,7 +2427,8 @@ yy_size_t size;
1671#ifdef YY_USE_PROTOS 2427#ifdef YY_USE_PROTOS
1672static void *yy_flex_realloc( void *ptr, yy_size_t size ) 2428static void *yy_flex_realloc( void *ptr, yy_size_t size YY_LAST_ARG )
1673#else 2429#else
1674static void *yy_flex_realloc( ptr, size ) 2430static void *yy_flex_realloc( ptr, size YY_LAST_ARG )
1675void *ptr; 2431void *ptr;
1676yy_size_t size; 2432yy_size_t size;
2433YY_DECL_LAST_ARG
1677#endif 2434#endif
@@ -1689,9 +2446,10 @@ yy_size_t size;
1689#ifdef YY_USE_PROTOS 2446#ifdef YY_USE_PROTOS
1690static void yy_flex_free( void *ptr ) 2447static void yy_flex_free( void *ptr YY_LAST_ARG )
1691#else 2448#else
1692static void yy_flex_free( ptr ) 2449static void yy_flex_free( ptr YY_LAST_ARG )
1693void *ptr; 2450void *ptr;
2451YY_DECL_LAST_ARG
1694#endif 2452#endif
1695 { 2453 {
1696 free( ptr ); 2454 free( (char *) ptr );/* see yy_flex_realloc() for (char *) cast */
1697 } 2455 }
@@ -1701,3 +2459,13 @@ int main()
1701 { 2459 {
2460
2461#ifdef YY_REENTRANT
2462 yyscan_t lexer;
2463 yylex_init(&lexer);
2464 yylex( lexer );
2465 yylex_destroy( lexer);
2466
2467#else
1702 yylex(); 2468 yylex();
2469#endif
2470
1703 return 0; 2471 return 0;
@@ -1705,6 +2473,9 @@ int main()
1705#endif 2473#endif
1706#line 107 "icalsslexer.l" 2474/* %e */
2475#endif /* !ssIN_HEADER */
2476#line 111 "icalsslexer.l"
2477#ifndef ssIN_HEADER
1707 2478
1708 2479
1709int sswrap() 2480int yywrap(yyscan_t yy_globals)
1710{ 2481{
@@ -1713 +2484,2 @@ int sswrap()
1713 2484
2485#endif /* !ssIN_HEADER */
diff --git a/libical/src/libicalss/icalssyacc.c b/libical/src/libicalss/icalssyacc.c
index 943123e..3d8cdc1 100644
--- a/libical/src/libicalss/icalssyacc.c
+++ b/libical/src/libicalss/icalssyacc.c
@@ -1,3 +1,3 @@
1/* A Bison parser, made from icalssyacc.y 1/* A Bison parser, made from icalssyacc.y
2 by GNU bison 1.35. */ 2 by GNU bison 1.34. */
3 3
@@ -28,4 +28,7 @@
28 # define END272 28 # define END272
29 # define IS273
30 # define NOT274
31 # define SQLNULL275
29 32
30#line 1 "icalssyacc.y" 33#line 3 "icalssyacc.y"
31 34
@@ -58,3 +61,3 @@
58 ======================================================================*/ 61 ======================================================================*/
59 62/*#define YYDEBUG 1*/
60#include <stdlib.h> 63#include <stdlib.h>
@@ -63,3 +66,2 @@
63#include "ical.h" 66#include "ical.h"
64#include "pvl.h"
65#include "icalgauge.h" 67#include "icalgauge.h"
@@ -68,15 +70,18 @@
68 70
69extern struct icalgauge_impl *icalss_yy_gauge; 71#define YYPARSE_PARAM yy_globals
70 72#define YYLEX_PARAM yy_globals
71void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, 73#define YY_EXTRA_TYPE icalgauge_impl*
72 icalgaugecompare compare , char* value); 74 /* ick...*/
73void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); 75#define yyextra ((struct icalgauge_impl*)ssget_extra(yy_globals))
74void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
75void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
76void sserror(char *s); /* Don't know why I need this.... */
77 76
78 77
78static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
79 icalgaugecompare compare , char* value);
80static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
81static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
82static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
83void sserror(char *s); /* Don't know why I need this.... */
79 84
80 85
81#line 52 "icalssyacc.y" 86#line 56 "icalssyacc.y"
82#ifndef YYSTYPE 87#ifndef YYSTYPE
@@ -86,3 +91,2 @@ typedef union {
86# define YYSTYPE yystype 91# define YYSTYPE yystype
87# define YYSTYPE_IS_TRIVIAL 1
88#endif 92#endif
@@ -94,8 +98,8 @@ typedef union {
94 98
95 #define YYFINAL 34 99 #define YYFINAL 38
96 #define YYFLAG -32768 100 #define YYFLAG -32768
97 #define YYNTBASE19 101 #define YYNTBASE22
98 102
99/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ 103/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
100#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 24) 104#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 27)
101 105
@@ -131,3 +135,3 @@ static const char yytranslate[] =
131 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 135 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
132 16, 17, 18 136 16, 17, 18, 19, 20, 21
133}; 137};
@@ -137,4 +141,4 @@ static const short yyprhs[] =
137{ 141{
138 0, 0, 7, 9, 11, 15, 17, 21, 22, 26, 142 0, 0, 7, 12, 14, 16, 20, 22, 26, 27,
139 30, 34, 38, 42, 46, 48, 52 143 31, 35, 40, 44, 48, 52, 56, 60, 62, 66
140}; 144};
@@ -142,8 +146,9 @@ static const short yyrhs[] =
142{ 146{
143 4, 20, 5, 21, 6, 23, 0, 1, 0, 3, 147 4, 23, 5, 24, 6, 26, 0, 4, 23, 5,
144 0, 20, 7, 3, 0, 3, 0, 21, 7, 3, 148 24, 0, 1, 0, 3, 0, 23, 7, 3, 0,
145 0, 0, 3, 9, 3, 0, 3, 10, 3, 0, 149 3, 0, 24, 7, 3, 0, 0, 3, 9, 3,
146 3, 11, 3, 0, 3, 12, 3, 0, 3, 13, 150 0, 3, 19, 21, 0, 3, 19, 20, 21, 0,
147 3, 0, 3, 14, 3, 0, 22, 0, 23, 15, 151 3, 10, 3, 0, 3, 11, 3, 0, 3, 12,
148 22, 0, 23, 16, 22, 0 152 3, 0, 3, 13, 3, 0, 3, 14, 3, 0,
153 25, 0, 26, 15, 25, 0, 26, 16, 25, 0
149}; 154};
@@ -156,4 +161,4 @@ static const short yyrline[] =
156{ 161{
157 0, 63, 64, 70, 72, 76, 78, 81, 83, 85, 162 0, 67, 68, 69, 75, 77, 81, 83, 86, 88,
158 86, 87, 88, 89, 92, 94, 95 163 89, 90, 91, 92, 93, 94, 95, 98, 100, 101
159}; 164};
@@ -169,4 +174,4 @@ static const char *const yytname[] =
169 "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS", 174 "QUOTE", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "LESSEQUALS",
170 "GREATEREQUALS", "AND", "OR", "EOL", "END", "query_min", "select_list", 175 "GREATEREQUALS", "AND", "OR", "EOL", "END", "IS", "NOT", "SQLNULL",
171 "from_list", "where_clause", "where_list", 0 176 "query_min", "select_list", "from_list", "where_clause", "where_list", 0
172}; 177};
@@ -177,4 +182,4 @@ static const short yyr1[] =
177{ 182{
178 0, 19, 19, 20, 20, 21, 21, 22, 22, 22, 183 0, 22, 22, 22, 23, 23, 24, 24, 25, 25,
179 22, 22, 22, 22, 23, 23, 23 184 25, 25, 25, 25, 25, 25, 25, 26, 26, 26
180}; 185};
@@ -184,4 +189,4 @@ static const short yyr2[] =
184{ 189{
185 0, 6, 1, 1, 3, 1, 3, 0, 3, 3, 190 0, 6, 4, 1, 1, 3, 1, 3, 0, 3,
186 3, 3, 3, 3, 1, 3, 3 191 3, 4, 3, 3, 3, 3, 3, 1, 3, 3
187}; 192};
@@ -193,6 +198,6 @@ static const short yydefact[] =
193{ 198{
194 0, 2, 0, 3, 0, 0, 0, 5, 0, 4, 199 0, 3, 0, 4, 0, 0, 0, 6, 2, 5,
195 7, 0, 0, 14, 1, 6, 0, 0, 0, 0, 200 8, 0, 0, 17, 1, 7, 0, 0, 0, 0,
196 0, 0, 7, 7, 8, 9, 10, 11, 12, 13, 201 0, 0, 0, 8, 8, 9, 12, 13, 14, 15,
197 15, 16, 0, 0, 0 202 16, 0, 10, 18, 19, 11, 0, 0, 0
198}; 203};
@@ -201,3 +206,3 @@ static const short yydefgoto[] =
201{ 206{
202 32, 4, 8, 13, 14 207 36, 4, 8, 13, 14
203}; 208};
@@ -206,6 +211,6 @@ static const short yypact[] =
206{ 211{
207 5,-32768, 4,-32768, 3, 8, 15,-32768, 6,-32768, 212 5,-32768, 9,-32768, 6, 17, 18,-32768, 1,-32768,
208 16, 17, -9,-32768, -1,-32768, 18, 19, 20, 21, 213 19, 20, -9,-32768, -1,-32768, 21, 22, 23, 24,
209 22, 23, 16, 16,-32768,-32768,-32768,-32768,-32768,-32768, 214 25, 26, -4, 19, 19,-32768,-32768,-32768,-32768,-32768,
210 -32768,-32768, 27, 28,-32768 215 -32768, 10,-32768,-32768,-32768,-32768, 30, 32,-32768
211}; 216};
@@ -214,3 +219,3 @@ static const short yypgoto[] =
214{ 219{
215 -32768,-32768,-32768, -6,-32768 220 -32768,-32768,-32768, -5,-32768
216}; 221};
@@ -218,3 +223,3 @@ static const short yypgoto[] =
218 223
219 #define YYLAST 28 224 #define YYLAST 32
220 225
@@ -223,5 +228,6 @@ static const short yytable[] =
223{ 228{
224 16, 17, 18, 19, 20, 21, 1, 3, 5, 2, 229 16, 17, 18, 19, 20, 21, 1, 10, 11, 2,
225 6, 7, 10, 11, 22, 23, 30, 31, 9, 12, 230 22, 5, 3, 6, 23, 24, 31, 32, 33, 34,
226 15, 24, 25, 26, 27, 28, 29, 33, 34 231 7, 9, 12, 15, 25, 26, 27, 28, 29, 30,
232 37, 35, 38
227}; 233};
@@ -230,8 +236,11 @@ static const short yycheck[] =
230{ 236{
231 9, 10, 11, 12, 13, 14, 1, 3, 5, 4, 237 9, 10, 11, 12, 13, 14, 1, 6, 7, 4,
232 7, 3, 6, 7, 15, 16, 22, 23, 3, 3, 238 19, 5, 3, 7, 15, 16, 20, 21, 23, 24,
233 3, 3, 3, 3, 3, 3, 3, 0, 0 239 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
240 0, 21, 0
234}; 241};
242#define YYPURE 1
243
235/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 244/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
236#line 3 "/usr/share/bison/bison.simple" 245#line 3 "/usr/local/share/bison/bison.simple"
237 246
@@ -303,8 +312,2 @@ static const short yycheck[] =
303# endif 312# endif
304#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
305
306
307#if (! defined (yyoverflow) \
308 && (! defined (__cplusplus) \
309 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
310 313
@@ -335,21 +338,3 @@ union yyalloc
335 338
336/* Copy COUNT objects from FROM to TO. The source and destination do 339/* Relocate the TYPE STACK from its old location to the new one. The
337 not overlap. */
338# ifndef YYCOPY
339# if 1 < __GNUC__
340# define YYCOPY(To, From, Count) \
341 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
342# else
343 # define YYCOPY(To, From, Count) \
344 do \
345 { \
346 register YYSIZE_T yyi; \
347 for (yyi = 0; yyi < (Count); yyi++)\
348 (To)[yyi] = (From)[yyi]; \
349 } \
350 while (0)
351# endif
352# endif
353
354/* Relocate STACK from its old location to the new one. The
355 local variables YYSIZE and YYSTACKSIZE give the old and new number of 340 local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -358,3 +343,3 @@ union yyalloc
358 stack. */ 343 stack. */
359 # define YYSTACK_RELOCATE(Stack) \ 344 # define YYSTACK_RELOCATE(Type, Stack) \
360 do \ 345 do \
@@ -362,5 +347,6 @@ union yyalloc
362 YYSIZE_T yynewbytes; \ 347 YYSIZE_T yynewbytes; \
363 YYCOPY (&yyptr->Stack, Stack, yysize); \ 348 yymemcpy ((char *) yyptr, (char *) (Stack), \
349 yysize * (YYSIZE_T) sizeof (Type)); \
364 Stack = &yyptr->Stack; \ 350 Stack = &yyptr->Stack; \
365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;\ 351 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;\
366 yyptr += yynewbytes / sizeof (*yyptr); \ 352 yyptr += yynewbytes / sizeof (*yyptr); \
@@ -369,3 +355,3 @@ union yyalloc
369 355
370#endif 356#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
371 357
@@ -496,2 +482,29 @@ int yydebug;
496 482
483#if ! defined (yyoverflow) && ! defined (yymemcpy)
484 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
485# define yymemcpy __builtin_memcpy
486 # else /* not GNU C or C++ */
487
488/* This is the most reliable way to avoid incompatibilities
489 in available built-in functions on various systems. */
490static void
491# if defined (__STDC__) || defined (__cplusplus)
492yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
493# else
494yymemcpy (yyto, yyfrom, yycount)
495 char *yyto;
496 const char *yyfrom;
497 YYSIZE_T yycount;
498# endif
499{
500 register const char *yyf = yyfrom;
501 register char *yyt = yyto;
502 register YYSIZE_T yyi = yycount;
503
504 while (yyi-- != 0)
505 *yyt++ = *yyf++;
506}
507# endif
508#endif
509
497#ifdef YYERROR_VERBOSE 510#ifdef YYERROR_VERBOSE
@@ -548,3 +561,3 @@ yystpcpy (yydest, yysrc)
548 561
549#line 315 "/usr/share/bison/bison.simple" 562#line 319 "/usr/local/share/bison/bison.simple"
550 563
@@ -738,5 +751,2 @@ yyparse (YYPARSE_PARAM_ARG)
738#else /* no yyoverflow */ 751#else /* no yyoverflow */
739# ifndef YYSTACK_RELOCATE
740 goto yyoverflowlab;
741# else
742 /* Extend the stack our own way. */ 752 /* Extend the stack our own way. */
@@ -754,6 +764,6 @@ yyparse (YYPARSE_PARAM_ARG)
754 goto yyoverflowlab; 764 goto yyoverflowlab;
755 YYSTACK_RELOCATE (yyss); 765 YYSTACK_RELOCATE (short, yyss);
756 YYSTACK_RELOCATE (yyvs); 766 YYSTACK_RELOCATE (YYSTYPE, yyvs);
757# if YYLSP_NEEDED 767# if YYLSP_NEEDED
758 YYSTACK_RELOCATE (yyls); 768 YYSTACK_RELOCATE (YYLTYPE, yyls);
759# endif 769# endif
@@ -763,3 +773,2 @@ yyparse (YYPARSE_PARAM_ARG)
763 } 773 }
764# endif
765#endif /* no yyoverflow */ 774#endif /* no yyoverflow */
@@ -941,16 +950,12 @@ yyreduce:
941 950
942case 2: 951case 3:
943#line 64 "icalssyacc.y" 952#line 69 "icalssyacc.y"
944{ 953{
945 icalparser_clear_flex_input();
946 yyclearin; 954 yyclearin;
955 YYABORT;
947 } 956 }
948 break; 957 break;
949case 3:
950#line 71 "icalssyacc.y"
951{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);}
952 break;
953case 4: 958case 4:
954#line 72 "icalssyacc.y" 959#line 76 "icalssyacc.y"
955{ssyacc_add_select(icalss_yy_gauge,yyvsp[0].v_string);} 960{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
956 break; 961 break;
@@ -958,31 +963,31 @@ case 5:
958#line 77 "icalssyacc.y" 963#line 77 "icalssyacc.y"
959{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} 964{ssyacc_add_select(yyextra,yyvsp[0].v_string);}
960 break; 965 break;
961case 6: 966case 6:
962#line 78 "icalssyacc.y" 967#line 82 "icalssyacc.y"
963{ssyacc_add_from(icalss_yy_gauge,yyvsp[0].v_string);} 968{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
964 break; 969 break;
965case 8: 970case 7:
966#line 83 "icalssyacc.y" 971#line 83 "icalssyacc.y"
967{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); } 972{ssyacc_add_from(yyextra,yyvsp[0].v_string);}
968 break; 973 break;
969case 9: 974case 9:
970#line 85 "icalssyacc.y" 975#line 88 "icalssyacc.y"
971{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); } 976{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_EQUAL,yyvsp[0].v_string); }
972 break; 977 break;
973case 10: 978case 10:
974#line 86 "icalssyacc.y" 979#line 89 "icalssyacc.y"
975{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); } 980{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_ISNULL,""); }
976 break; 981 break;
977case 11: 982case 11:
978#line 87 "icalssyacc.y" 983#line 90 "icalssyacc.y"
979{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); } 984{ssyacc_add_where(yyextra,yyvsp[-3].v_string,ICALGAUGECOMPARE_ISNOTNULL,""); }
980 break; 985 break;
981case 12: 986case 12:
982#line 88 "icalssyacc.y" 987#line 91 "icalssyacc.y"
983{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); } 988{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_NOTEQUAL,yyvsp[0].v_string); }
984 break; 989 break;
985case 13: 990case 13:
986#line 89 "icalssyacc.y" 991#line 92 "icalssyacc.y"
987{ssyacc_add_where(icalss_yy_gauge,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); } 992{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESS,yyvsp[0].v_string); }
988 break; 993 break;
@@ -990,3 +995,3 @@ case 14:
990#line 93 "icalssyacc.y" 995#line 93 "icalssyacc.y"
991{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);} 996{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATER,yyvsp[0].v_string); }
992 break; 997 break;
@@ -994,3 +999,3 @@ case 15:
994#line 94 "icalssyacc.y" 999#line 94 "icalssyacc.y"
995{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);} 1000{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_LESSEQUAL,yyvsp[0].v_string); }
996 break; 1001 break;
@@ -998,3 +1003,15 @@ case 16:
998#line 95 "icalssyacc.y" 1003#line 95 "icalssyacc.y"
999{set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} 1004{ssyacc_add_where(yyextra,yyvsp[-2].v_string,ICALGAUGECOMPARE_GREATEREQUAL,yyvsp[0].v_string); }
1005 break;
1006case 17:
1007#line 99 "icalssyacc.y"
1008{set_logic(yyextra,ICALGAUGELOGIC_NONE);}
1009 break;
1010case 18:
1011#line 100 "icalssyacc.y"
1012{set_logic(yyextra,ICALGAUGELOGIC_AND);}
1013 break;
1014case 19:
1015#line 101 "icalssyacc.y"
1016{set_logic(yyextra,ICALGAUGELOGIC_OR);}
1000 break; 1017 break;
@@ -1002,3 +1019,3 @@ case 16:
1002 1019
1003#line 705 "/usr/share/bison/bison.simple" 1020#line 705 "/usr/local/share/bison/bison.simple"
1004 1021
@@ -1233,6 +1250,6 @@ yyreturn:
1233} 1250}
1234#line 99 "icalssyacc.y" 1251#line 105 "icalssyacc.y"
1235 1252
1236 1253
1237void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, 1254static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1238 icalgaugecompare compare , char* value_str) 1255 icalgaugecompare compare , char* value_str)
@@ -1298,3 +1315,3 @@ void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1298 1315
1299void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) 1316static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1300{ 1317{
@@ -1309,3 +1326,3 @@ void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1309 1326
1310void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) 1327static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1311{ 1328{
@@ -1355,5 +1372,5 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1355 if(where->prop == ICAL_NO_PROPERTY){ 1372 if(where->prop == ICAL_NO_PROPERTY){
1356 icalgauge_free(where); 1373 free(where);
1357 icalerror_set_errno(ICAL_BADARG_ERROR); 1374 icalerror_set_errno(ICAL_BADARG_ERROR);
1358 return; 1375 return;
1359 } 1376 }
@@ -1363,3 +1380,3 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1363 1380
1364void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) 1381static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1365{ 1382{
@@ -1379,3 +1396,4 @@ void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1379void sserror(char *s){ 1396void sserror(char *s){
1380 fprintf(stderr,"Parse error \'%s\'\n", s); 1397 fprintf(stderr,"Parse error \'%s\'\n", s);
1398 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
1381} 1399}
diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h
index 7d42f3c..6d03a0f 100644
--- a/libical/src/libicalss/icalssyacc.h
+++ b/libical/src/libicalss/icalssyacc.h
@@ -1,3 +1,3 @@
1#ifndef BISON_ICALSSYACC_H 1#ifndef BISON_Y_TAB_H
2# define BISON_ICALSSYACC_H 2# define BISON_Y_TAB_H
3 3
@@ -8,3 +8,2 @@ typedef union {
8# define YYSTYPE yystype 8# define YYSTYPE yystype
9# define YYSTYPE_IS_TRIVIAL 1
10#endif 9#endif
@@ -26,6 +25,7 @@ typedef union {
26 # define END272 25 # define END272
26 # define IS273
27 # define NOT274
28 # define SQLNULL275
27 29
28 30
29extern YYSTYPE sslval; 31#endif /* not BISON_Y_TAB_H */
30
31#endif /* not BISON_ICALSSYACC_H */
diff --git a/libical/src/libicalss/libicalss.pro b/libical/src/libicalss/libicalss.pro
index a5cc80c..64b7094 100644
--- a/libical/src/libicalss/libicalss.pro
+++ b/libical/src/libicalss/libicalss.pro
@@ -1,2 +1,5 @@
1include(../../../variables.pri) 1######################################################################
2# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
3######################################################################
4
2 5
@@ -7,37 +10,34 @@ DESTDIR = ../../lib
7 CONFIG += staticlib 10 CONFIG += staticlib
8win32: DEFINES += _WIN32 _QTWIN_
9 HEADERS = icalcalendar.h \
10 icalclassify.h \
11 icalcstp.h \
12 icalcstpclient.h \
13 icalcstpserver.h \
14 icaldirset.h \
15 icaldirsetimpl.h \
16 icalfileset.h \
17 icalfilesetimpl.h \
18 icalgauge.h \
19 icalgaugeimpl.h \
20 icalmessage.h \
21 icalset.h \
22 icalspanlist.h \
23 icalssyacc.h \
24 config.h
25
26 SOURCES = icalclassify.c \
27 icalcstp.c \
28 icalcstpclient.c \
29 icalcstpserver.c \
30 icaldirset.c \
31 icalfileset.c \
32 icalgauge.c \
33 icalmessage.c \
34 icalset.c \
35 icalspanlist.c \
36 icalsslexer.c \
37 icalssyacc.c
38
39 INTERFACES=
40 11
41INCLUDEPATH += ../libical 12INCLUDEPATH += . ../libical
13# Input
14win32 {
15DEFINES += YY_NO_UNISTD_H
42 16
43DEFINES += HAVE_CONFIG_H 17}
18HEADERS += icalcalendar.h \
19 icalclassify.h \
20 icalcluster.h \
21 icalclusterimpl.h \
22 icaldirset.h \
23 icaldirsetimpl.h \
24 icalfileset.h \
25 icalfilesetimpl.h \
26 icalgauge.h \
27 icalgaugeimpl.h \
28 icalmessage.h \
29 icalset.h \
30 icalspanlist.h \
31 icalss.h \
32 icalssyacc.h
33SOURCES += icalcalendar.c \
34 icalclassify.c \
35 icalcluster.c \
36 icaldirset.c \
37 icalfileset.c \
38 icalgauge.c \
39 icalmessage.c \
40 icalset.c \
41 icalspanlist.c \
42 icalsslexer.c \
43 icalssyacc.c
diff --git a/libical/src/libicalss/libicalssE.pro b/libical/src/libicalss/libicalssE.pro
index 57d60bd..84ccf47 100644
--- a/libical/src/libicalss/libicalssE.pro
+++ b/libical/src/libicalss/libicalssE.pro
@@ -1,45 +1,41 @@
1 TEMPLATE= lib 1######################################################################
2 CONFIG += warn_on staticlib 2# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
3INCLUDEPATH += ../libical 3######################################################################
4INCLUDEPATH += .
5DEFINES += HAVE_CONFIG_H
6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=../../lib/$(PLATFORM)
9TARGET = icalss
10 4
11INTERFACES = \
12 5
13HEADERS = \ 6 TEMPLATE= lib
14 config.h \
15 icalcalendar.h \
16 icalclassify.h \
17 icalcstp.h \
18 icalcstpclient.h \
19 icalcstpserver.h \
20 icaldirset.h \
21 icaldirsetimpl.h \
22 icalfileset.h \
23 icalfilesetimpl.h \
24 icalgauge.h \
25 icalgaugeimpl.h \
26 icalmessage.h \
27 icalset.h \
28 icalspanlist.h \
29 icalss.h \
30 icalssyacc.h \
31 7
32SOURCES = \ 8TARGET = icalss
33 icalclassify.c \ 9 CONFIG += staticlib
34 icalcstp.c \
35 icalcstpclient.c \
36 icalcstpserver.c \
37 icaldirset.c \
38 icalfileset.c \
39 icalgauge.c \
40 icalmessage.c \
41 icalset.c \
42 icalspanlist.c \
43 icalsslexer.c \
44 icalssyacc.c \
45 10
11OBJECTS_DIR = obj/$(PLATFORM)
12MOC_DIR = moc/$(PLATFORM)
13DESTDIR=../../lib/$(PLATFORM)
14INCLUDEPATH += . ../libical
15# Input
16HEADERS += icalcalendar.h \
17 icalclassify.h \
18 icalcluster.h \
19 icalclusterimpl.h \
20 icaldirset.h \
21 icaldirsetimpl.h \
22 icalfileset.h \
23 icalfilesetimpl.h \
24 icalgauge.h \
25 icalgaugeimpl.h \
26 icalmessage.h \
27 icalset.h \
28 icalspanlist.h \
29 icalss.h \
30 icalssyacc.h
31SOURCES += icalcalendar.c \
32 icalclassify.c \
33 icalcluster.c \
34 icaldirset.c \
35 icalfileset.c \
36 icalgauge.c \
37 icalmessage.c \
38 icalset.c \
39 icalspanlist.c \
40 icalsslexer.c \
41 icalssyacc.c