summaryrefslogtreecommitdiffabout
path: root/libical
Unidiff
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,8 +1,129 @@
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
2#define ICAL_VERSION_H 123#define ICAL_VERSION_H
3 124
4#define ICAL_PACKAGE "libical" 125#define ICAL_PACKAGE "libical"
5#define ICAL_VERSION "0.23" 126#define ICAL_VERSION "0.24"
6 127
7#endif 128#endif
8/* -*- Mode: C -*- */ 129/* -*- Mode: C -*- */
@@ -11,8 +132,6 @@
11 CREATOR: eric 02 June 2000 132 CREATOR: eric 02 June 2000
12 133
13 134
14 $Id$
15 $Locker$
16 135
17 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 136 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
18 137
@@ -33,121 +152,249 @@
33 152
34======================================================================*/ 153======================================================================*/
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
37#define ICALTIME_H 220#define ICALTIME_H
38 221
39#include <time.h> 222#include <time.h>
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;
54 int hour; 251 int hour;
55 int minute; 252 int minute;
56 int second; 253 int second;
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
152 399
153/* -*- Mode: C -*- */ 400/* -*- Mode: C -*- */
@@ -156,8 +403,6 @@ short icaltime_days_in_month(short month,short year);
156 CREATOR: eric 26 Jan 2001 403 CREATOR: eric 26 Jan 2001
157 404
158 405
159 $Id$
160 $Locker$
161 406
162 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 407 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
163 408
@@ -196,8 +441,10 @@ struct icaldurationtype icaldurationtype_from_int(int t);
196struct icaldurationtype icaldurationtype_from_string(const char*); 441struct icaldurationtype icaldurationtype_from_string(const char*);
197int icaldurationtype_as_int(struct icaldurationtype duration); 442int 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
202struct icaltimetype icaltime_add(struct icaltimetype t, 449struct icaltimetype icaltime_add(struct icaltimetype t,
203 struct icaldurationtype d); 450 struct icaldurationtype d);
@@ -215,8 +462,6 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
215 CREATOR: eric 26 Jan 2001 462 CREATOR: eric 26 Jan 2001
216 463
217 464
218 $Id$
219 $Locker$
220 465
221 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 466 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
222 467
@@ -251,12 +496,12 @@ struct icalperiodtype
251struct icalperiodtype icalperiodtype_from_string (const char* str); 496struct icalperiodtype icalperiodtype_from_string (const char* str);
252 497
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
261#endif /* !ICALTIME_H */ 506#endif /* !ICALTIME_H */
262 507
@@ -307,6 +552,7 @@ typedef enum icalcomponent_kind {
307 ICAL_VTODO_COMPONENT, 552 ICAL_VTODO_COMPONENT,
308 ICAL_VJOURNAL_COMPONENT, 553 ICAL_VJOURNAL_COMPONENT,
309 ICAL_VCALENDAR_COMPONENT, 554 ICAL_VCALENDAR_COMPONENT,
555 ICAL_VAGENDA_COMPONENT,
310 ICAL_VFREEBUSY_COMPONENT, 556 ICAL_VFREEBUSY_COMPONENT,
311 ICAL_VALARM_COMPONENT, 557 ICAL_VALARM_COMPONENT,
312 ICAL_XAUDIOALARM_COMPONENT, 558 ICAL_XAUDIOALARM_COMPONENT,
@@ -362,11 +608,17 @@ typedef enum icalrequeststatus {
362 ICAL_3_12_UNKCOMP_STATUS, 608 ICAL_3_12_UNKCOMP_STATUS,
363 ICAL_3_13_BADCOMP_STATUS, 609 ICAL_3_13_BADCOMP_STATUS,
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,
367 ICAL_5_1_UNAVAIL_STATUS, 617 ICAL_5_1_UNAVAIL_STATUS,
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;
371 623
372 624
@@ -374,6 +626,7 @@ const char* icalenum_reqstat_desc(icalrequeststatus stat);
374short icalenum_reqstat_major(icalrequeststatus stat); 626short icalenum_reqstat_major(icalrequeststatus stat);
375short icalenum_reqstat_minor(icalrequeststatus stat); 627short 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
378/*********************************************************************** 631/***********************************************************************
379 * Conversion functions 632 * Conversion functions
@@ -448,39 +701,6 @@ icalrequeststatus icalenum_num_to_reqstat(short major, short minor);
448#include <time.h> 701#include <time.h>
449 702
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
485{ 705{
486 float lat; 706 float lat;
@@ -501,9 +721,11 @@ struct icaltriggertype
501 struct icaldurationtype duration; 721 struct icaldurationtype duration;
502}; 722};
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);
505 726
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
508/* struct icalreqstattype. This struct contains two string pointers, 730/* struct icalreqstattype. This struct contains two string pointers,
509but don't try to free either of them. The "desc" string is a pointer 731but don't try to free either of them. The "desc" string is a pointer
@@ -571,10 +793,17 @@ void icaltimezonetype_free(struct icaltimezonetype tzt);
571 793
572 The Mozilla Public License Version 1.0. You may obtain a copy of 794 The Mozilla Public License Version 1.0. You may obtain a copy of
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
575How to use: 802How to use:
576 803
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;
579 struct icalrecurrencetype recur; 808 struct icalrecurrencetype recur;
580 struct icaltimetype dtstart; 809 struct icaltimetype dtstart;
@@ -582,35 +811,45 @@ How to use:
582 rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); 811 rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY);
583 recur = icalproperty_get_rrule(rrule); 812 recur = icalproperty_get_rrule(rrule);
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;
596 while (next = icalrecur_iterator_next(ritr) 834 while (next = icalrecur_iterator_next(ritr)
597 && !icaltime_is_null_time(next){ 835 && !icaltime_is_null_time(next){
598 Do something with next 836 Do something with next
599 } 837 }
838@endcode
600 839
601Note that that the time returned by icalrecur_iterator_next is in 840Note that that the time returned by icalrecur_iterator_next is in
602whatever timezone that dtstart is in. 841whatever timezone that dtstart is in.
603 842
604======================================================================*/ 843*/
605 844
606#ifndef ICALRECUR_H 845#ifndef ICALRECUR_H
607#define ICALRECUR_H 846#define ICALRECUR_H
608 847
609#include <time.h> 848#include <time.h>
610 849
611/*********************************************************************** 850/*
612 * Recurrance enumerations 851 * Recurrance enumerations
613**********************************************************************/ 852 */
614 853
615typedef enum icalrecurrencetype_frequency 854typedef enum icalrecurrencetype_frequency
616{ 855{
@@ -647,7 +886,9 @@ enum {
647 886
648 887
649 888
650/********************** Recurrence type routines **************/ 889/**
890 * Recurrence type routines
891 */
651 892
652/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of 893/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of
653 the values and fields in struct icalrecurrencetype */ 894 the values and fields in struct icalrecurrencetype */
@@ -662,7 +903,7 @@ enum {
662#define ICAL_BY_MONTH_SIZE 13 903#define ICAL_BY_MONTH_SIZE 13
663#define ICAL_BY_SETPOS_SIZE 367 904#define ICAL_BY_SETPOS_SIZE 367
664 905
665/* Main struct for holding digested recurrence rules */ 906/** Main struct for holding digested recurrence rules */
666struct icalrecurrencetype 907struct icalrecurrencetype
667{ 908{
668 icalrecurrencetype_frequency freq; 909 icalrecurrencetype_frequency freq;
@@ -699,43 +940,49 @@ struct icalrecurrencetype
699 940
700void icalrecurrencetype_clear(struct icalrecurrencetype *r); 941void 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);
720char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); 963char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
721 964
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,
729 struct icaltimetype dtstart); 972 struct icaltimetype dtstart);
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,
740 int count, time_t* array); 987 int count, time_t* array);
741 988
@@ -743,12 +990,70 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
743#endif 990#endif
744/* -*- Mode: C -*- */ 991/* -*- Mode: C -*- */
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
747 CREATOR: eric 20 March 1999 1054 CREATOR: eric 20 March 1999
748 1055
749 1056
750 $Id$
751 $Locker$
752 1057
753 1058
754 1059
@@ -773,62 +1078,62 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
773#define ICALDERIVEDVALUE_H 1078#define ICALDERIVEDVALUE_H
774 1079
775 1080
776typedef void icalvalue; 1081typedef struct icalvalue_impl icalvalue;
777 1082
778 1083
779 1084
780void icalvalue_set_x(icalvalue* value, const char* v); 1085void 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
788icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); 1089icalvalue* 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
792icalvalue* icalvalue_new_trigger (struct icaltriggertype v); 1093icalvalue* 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
796icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); 1097icalvalue* 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
800void icalvalue_reset_kind(icalvalue* value); 1105void 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 {
804 ICAL_ANY_VALUE=5000, 1108 ICAL_ANY_VALUE=5000,
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 ;
833 1138
834#define ICALPROPERTY_FIRST_ENUM 10000 1139#define ICALPROPERTY_FIRST_ENUM 10000
@@ -886,138 +1191,178 @@ typedef enum icalproperty_status {
886typedef enum icalproperty_transp { 1191typedef enum icalproperty_transp {
887 ICAL_TRANSP_X = 10038, 1192 ICAL_TRANSP_X = 10038,
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
895 1234
896 /* QUERY */ 1235 /* QUERY */
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);
900 1239
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);
906 1257
907 1258
908 /* TRANSP */ 1259 /* TRANSP */
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);
912 1263
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
937 1288
938 /* PERIOD */ 1289 /* PERIOD */
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);
942 1293
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
961 1312
962 /* URI */ 1313 /* URI */
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);
966 1317
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
985 1342
986 /* ACTION */ 1343 /* ACTION */
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);
990 1347
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
1009 1360
1010 /* METHOD */ 1361 /* METHOD */
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*/
1022/* -*- Mode: C -*- */ 1367/* -*- Mode: C -*- */
1023/*====================================================================== 1368/*======================================================================
@@ -1025,8 +1370,6 @@ void icalvalue_set_binary(icalvalue* value, const char* v);
1025 CREATOR: eric 20 March 1999 1370 CREATOR: eric 20 March 1999
1026 1371
1027 1372
1028 $Id$
1029 $Locker$
1030 1373
1031 1374
1032 1375
@@ -1051,12 +1394,11 @@ void icalvalue_set_binary(icalvalue* value, const char* v);
1051#define ICALDERIVEDPARAMETER_H 1394#define ICALDERIVEDPARAMETER_H
1052 1395
1053 1396
1054typedef void icalparameter; 1397typedef struct icalparameter_impl icalparameter;
1055 1398
1056const char* icalparameter_enum_to_string(int e); 1399const char* icalparameter_enum_to_string(int e);
1057int icalparameter_string_to_enum(const char* str); 1400int 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 {
1061 ICAL_ANY_PARAMETER = 0, 1403 ICAL_ANY_PARAMETER = 0,
1062 ICAL_ALTREP_PARAMETER, 1404 ICAL_ALTREP_PARAMETER,
@@ -1135,7 +1477,7 @@ typedef enum icalparameter_range {
1135typedef enum icalparameter_related { 1477typedef enum icalparameter_related {
1136 ICAL_RELATED_X = 20030, 1478 ICAL_RELATED_X = 20030,
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
1140} icalparameter_related; 1482} icalparameter_related;
1141 1483
@@ -1191,147 +1533,294 @@ typedef enum icalparameter_xliccomparetype {
1191 ICAL_XLICCOMPARETYPE_LESSEQUAL = 20070, 1533 ICAL_XLICCOMPARETYPE_LESSEQUAL = 20070,
1192 ICAL_XLICCOMPARETYPE_GREATEREQUAL = 20071, 1534 ICAL_XLICCOMPARETYPE_GREATEREQUAL = 20071,
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;
1196 1540
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
1242/* RELTYPE */ 1567/* RELTYPE */
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
1267/* VALUE */ 1597/* VALUE */
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
1292/* X-LIC-ERRORTYPE */ 1632/* X-LIC-ERRORTYPE */
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
1317/* FBTYPE */ 1657/* FBTYPE */
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
1327#endif /*ICALPARAMETER_H*/ 1672#endif /*ICALPARAMETER_H*/
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 -*-
1330 ====================================================================== 1820 ======================================================================
1331 FILE: icalderivedproperties.{c,h} 1821 FILE: icalderivedproperties.{c,h}
1332 CREATOR: eric 09 May 1999 1822 CREATOR: eric 09 May 1999
1333 1823
1334 $Id$
1335 1824
1336 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 1825 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
1337 ======================================================================*/ 1826 ======================================================================*/
@@ -1342,22 +1831,28 @@ void icalparameter_set_tzid(icalparameter* value, const char* v);
1342 1831
1343#include <time.h> 1832#include <time.h>
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 {
1350 ICAL_ANY_PROPERTY = 0, 1837 ICAL_ANY_PROPERTY = 0,
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,
1356 ICAL_CLASS_PROPERTY, 1847 ICAL_CLASS_PROPERTY,
1357 ICAL_COMMENT_PROPERTY, 1848 ICAL_COMMENT_PROPERTY,
1358 ICAL_COMPLETED_PROPERTY, 1849 ICAL_COMPLETED_PROPERTY,
1359 ICAL_CONTACT_PROPERTY, 1850 ICAL_CONTACT_PROPERTY,
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,
1362 ICAL_DTEND_PROPERTY, 1857 ICAL_DTEND_PROPERTY,
1363 ICAL_DTSTAMP_PROPERTY, 1858 ICAL_DTSTAMP_PROPERTY,
@@ -1365,6 +1860,7 @@ typedef enum icalproperty_kind {
1365 ICAL_DUE_PROPERTY, 1860 ICAL_DUE_PROPERTY,
1366 ICAL_DURATION_PROPERTY, 1861 ICAL_DURATION_PROPERTY,
1367 ICAL_EXDATE_PROPERTY, 1862 ICAL_EXDATE_PROPERTY,
1863 ICAL_EXPAND_PROPERTY,
1368 ICAL_EXRULE_PROPERTY, 1864 ICAL_EXRULE_PROPERTY,
1369 ICAL_FREEBUSY_PROPERTY, 1865 ICAL_FREEBUSY_PROPERTY,
1370 ICAL_GEO_PROPERTY, 1866 ICAL_GEO_PROPERTY,
@@ -1374,6 +1870,7 @@ typedef enum icalproperty_kind {
1374 ICAL_MAXRESULTSSIZE_PROPERTY, 1870 ICAL_MAXRESULTSSIZE_PROPERTY,
1375 ICAL_METHOD_PROPERTY, 1871 ICAL_METHOD_PROPERTY,
1376 ICAL_ORGANIZER_PROPERTY, 1872 ICAL_ORGANIZER_PROPERTY,
1873 ICAL_OWNER_PROPERTY,
1377 ICAL_PERCENTCOMPLETE_PROPERTY, 1874 ICAL_PERCENTCOMPLETE_PROPERTY,
1378 ICAL_PRIORITY_PROPERTY, 1875 ICAL_PRIORITY_PROPERTY,
1379 ICAL_PRODID_PROPERTY, 1876 ICAL_PRODID_PROPERTY,
@@ -1382,6 +1879,7 @@ typedef enum icalproperty_kind {
1382 ICAL_RDATE_PROPERTY, 1879 ICAL_RDATE_PROPERTY,
1383 ICAL_RECURRENCEID_PROPERTY, 1880 ICAL_RECURRENCEID_PROPERTY,
1384 ICAL_RELATEDTO_PROPERTY, 1881 ICAL_RELATEDTO_PROPERTY,
1882 ICAL_RELCALID_PROPERTY,
1385 ICAL_REPEAT_PROPERTY, 1883 ICAL_REPEAT_PROPERTY,
1386 ICAL_REQUESTSTATUS_PROPERTY, 1884 ICAL_REQUESTSTATUS_PROPERTY,
1387 ICAL_RESOURCES_PROPERTY, 1885 ICAL_RESOURCES_PROPERTY,
@@ -1402,6 +1900,7 @@ typedef enum icalproperty_kind {
1402 ICAL_URL_PROPERTY, 1900 ICAL_URL_PROPERTY,
1403 ICAL_VERSION_PROPERTY, 1901 ICAL_VERSION_PROPERTY,
1404 ICAL_X_PROPERTY, 1902 ICAL_X_PROPERTY,
1903 ICAL_XLICCLASS_PROPERTY,
1405 ICAL_XLICCLUSTERCOUNT_PROPERTY, 1904 ICAL_XLICCLUSTERCOUNT_PROPERTY,
1406 ICAL_XLICERROR_PROPERTY, 1905 ICAL_XLICERROR_PROPERTY,
1407 ICAL_XLICMIMECHARSET_PROPERTY, 1906 ICAL_XLICMIMECHARSET_PROPERTY,
@@ -1413,472 +1912,385 @@ typedef enum icalproperty_kind {
1413 ICAL_NO_PROPERTY 1912 ICAL_NO_PROPERTY
1414} icalproperty_kind; 1913} icalproperty_kind;
1415 1914
1416icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
1417 1915
1418/* ACTION */ 1916/* ACTION */
1419icalproperty* icalproperty_new_action(enum icalproperty_action v); 1917icalproperty* 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
1428/* ATTENDEE */ 1931/* ATTENDEE */
1429icalproperty* icalproperty_new_attendee(const char* v); 1932icalproperty* 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
1433/* CALSCALE */ 1946/* CALSCALE */
1434icalproperty* icalproperty_new_calscale(const char* v); 1947icalproperty* 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
1438/* CATEGORIES */ 1956/* CATEGORIES */
1439icalproperty* icalproperty_new_categories(const char* v); 1957icalproperty* 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
1448/* COMMENT */ 1966/* COMMENT */
1449icalproperty* icalproperty_new_comment(const char* v); 1967icalproperty* 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
1453/* COMPLETED */ 1971/* COMPLETED */
1454icalproperty* icalproperty_new_completed(struct icaltimetype v); 1972icalproperty* 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
1458/* CONTACT */ 1976/* CONTACT */
1459icalproperty* icalproperty_new_contact(const char* v); 1977icalproperty* 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
1463/* CREATED */ 1981/* CREATED */
1464icalproperty* icalproperty_new_created(struct icaltimetype v); 1982icalproperty* 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
1468/* DESCRIPTION */ 2006/* DESCRIPTION */
1469icalproperty* icalproperty_new_description(const char* v); 2007icalproperty* 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
1473/* DTEND */ 2011/* DTEND */
1474icalproperty* icalproperty_new_dtend(struct icaltimetype v); 2012icalproperty* 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
1478/* DTSTAMP */ 2016/* DTSTAMP */
1479icalproperty* icalproperty_new_dtstamp(struct icaltimetype v); 2017icalproperty* 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
1483/* DTSTART */ 2021/* DTSTART */
1484icalproperty* icalproperty_new_dtstart(struct icaltimetype v); 2022icalproperty* 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
1488/* DUE */ 2026/* DUE */
1489icalproperty* icalproperty_new_due(struct icaltimetype v); 2027icalproperty* 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
1493/* DURATION */ 2031/* DURATION */
1494icalproperty* icalproperty_new_duration(struct icaldurationtype v); 2032icalproperty* 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
1498/* EXDATE */ 2036/* EXDATE */
1499icalproperty* icalproperty_new_exdate(struct icaltimetype v); 2037icalproperty* 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
1503/* EXRULE */ 2046/* EXRULE */
1504icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v); 2047icalproperty* 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
1508/* FREEBUSY */ 2051/* FREEBUSY */
1509icalproperty* icalproperty_new_freebusy(struct icalperiodtype v); 2052icalproperty* 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
1513/* GEO */ 2056/* GEO */
1514icalproperty* icalproperty_new_geo(struct icalgeotype v); 2057icalproperty* 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
1518/* LAST-MODIFIED */ 2061/* LAST-MODIFIED */
1519icalproperty* icalproperty_new_lastmodified(struct icaltimetype v); 2062icalproperty* 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
1523/* LOCATION */ 2066/* LOCATION */
1524icalproperty* icalproperty_new_location(const char* v); 2067icalproperty* 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
1528/* MAXRESULTS */ 2071/* MAXRESULTS */
1529icalproperty* icalproperty_new_maxresults(int v); 2072icalproperty* 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
1533/* MAXRESULTSSIZE */ 2076/* MAXRESULTSSIZE */
1534icalproperty* icalproperty_new_maxresultssize(int v); 2077icalproperty* 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
1538/* METHOD */ 2081/* METHOD */
1539icalproperty* icalproperty_new_method(enum icalproperty_method v); 2082icalproperty* 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
1543/* ORGANIZER */ 2086/* ORGANIZER */
1544icalproperty* icalproperty_new_organizer(const char* v); 2087icalproperty* 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
1548/* PERCENT-COMPLETE */ 2096/* PERCENT-COMPLETE */
1549icalproperty* icalproperty_new_percentcomplete(int v); 2097icalproperty* 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
1553/* PRIORITY */ 2101/* PRIORITY */
1554icalproperty* icalproperty_new_priority(int v); 2102icalproperty* 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
1558/* PRODID */ 2106/* PRODID */
1559icalproperty* icalproperty_new_prodid(const char* v); 2107icalproperty* 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
1563/* QUERY */ 2111/* QUERY */
1564icalproperty* icalproperty_new_query(const char* v); 2112icalproperty* 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
1568/* QUERYNAME */ 2116/* QUERYNAME */
1569icalproperty* icalproperty_new_queryname(const char* v); 2117icalproperty* 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
1573/* RDATE */ 2121/* RDATE */
1574icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v); 2122icalproperty* 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
1578/* RECURRENCE-ID */ 2126/* RECURRENCE-ID */
1579icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v); 2127icalproperty* 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
1583/* RELATED-TO */ 2131/* RELATED-TO */
1584icalproperty* icalproperty_new_relatedto(const char* v); 2132icalproperty* 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
1588/* REPEAT */ 2141/* REPEAT */
1589icalproperty* icalproperty_new_repeat(int v); 2142icalproperty* 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
1593/* REQUEST-STATUS */ 2146/* REQUEST-STATUS */
1594icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v); 2147icalproperty* 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
1598/* RESOURCES */ 2151/* RESOURCES */
1599icalproperty* icalproperty_new_resources(const char* v); 2152icalproperty* 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
1603/* RRULE */ 2156/* RRULE */
1604icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v); 2157icalproperty* 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
1608/* SCOPE */ 2161/* SCOPE */
1609icalproperty* icalproperty_new_scope(const char* v); 2162icalproperty* 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
1613/* SEQUENCE */ 2166/* SEQUENCE */
1614icalproperty* icalproperty_new_sequence(int v); 2167icalproperty* 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
1618/* STATUS */ 2171/* STATUS */
1619icalproperty* icalproperty_new_status(enum icalproperty_status v); 2172icalproperty* 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
1623/* SUMMARY */ 2176/* SUMMARY */
1624icalproperty* icalproperty_new_summary(const char* v); 2177icalproperty* 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
1628/* TARGET */ 2181/* TARGET */
1629icalproperty* icalproperty_new_target(const char* v); 2182icalproperty* 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
1638/* TRIGGER */ 2191/* TRIGGER */
1639icalproperty* icalproperty_new_trigger(struct icaltriggertype v); 2192icalproperty* 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
1643/* TZID */ 2196/* TZID */
1644icalproperty* icalproperty_new_tzid(const char* v); 2197icalproperty* 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
1648/* TZNAME */ 2201/* TZNAME */
1649icalproperty* icalproperty_new_tzname(const char* v); 2202icalproperty* 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
1653/* TZOFFSETFROM */ 2206/* TZOFFSETFROM */
1654icalproperty* icalproperty_new_tzoffsetfrom(int v); 2207icalproperty* 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
1658/* TZOFFSETTO */ 2211/* TZOFFSETTO */
1659icalproperty* icalproperty_new_tzoffsetto(int v); 2212icalproperty* 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
1663/* TZURL */ 2216/* TZURL */
1664icalproperty* icalproperty_new_tzurl(const char* v); 2217icalproperty* 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
1668/* UID */ 2221/* UID */
1669icalproperty* icalproperty_new_uid(const char* v); 2222icalproperty* 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
1673/* URL */ 2226/* URL */
1674icalproperty* icalproperty_new_url(const char* v); 2227icalproperty* 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
1678/* VERSION */ 2231/* VERSION */
1679icalproperty* icalproperty_new_version(const char* v); 2232icalproperty* 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
1683/* X */ 2236/* X */
1684icalproperty* icalproperty_new_x(const char* v); 2237icalproperty* 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
1688/* X-LIC-CLUSTERCOUNT */ 2246/* X-LIC-CLUSTERCOUNT */
1689icalproperty* icalproperty_new_xlicclustercount(const char* v); 2247icalproperty* 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
1693/* X-LIC-ERROR */ 2251/* X-LIC-ERROR */
1694icalproperty* icalproperty_new_xlicerror(const char* v); 2252icalproperty* 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
1698/* X-LIC-MIMECHARSET */ 2256/* X-LIC-MIMECHARSET */
1699icalproperty* icalproperty_new_xlicmimecharset(const char* v); 2257icalproperty* 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
1703/* X-LIC-MIMECID */ 2261/* X-LIC-MIMECID */
1704icalproperty* icalproperty_new_xlicmimecid(const char* v); 2262icalproperty* 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
1708/* X-LIC-MIMECONTENTTYPE */ 2266/* X-LIC-MIMECONTENTTYPE */
1709icalproperty* icalproperty_new_xlicmimecontenttype(const char* v); 2267icalproperty* 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
1713/* X-LIC-MIMEENCODING */ 2271/* X-LIC-MIMEENCODING */
1714icalproperty* icalproperty_new_xlicmimeencoding(const char* v); 2272icalproperty* 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
1718/* X-LIC-MIMEFILENAME */ 2276/* X-LIC-MIMEFILENAME */
1719icalproperty* icalproperty_new_xlicmimefilename(const char* v); 2277icalproperty* 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
1723/* X-LIC-MIMEOPTINFO */ 2281/* X-LIC-MIMEOPTINFO */
1724icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v); 2282icalproperty* 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 -*- */
1875/*====================================================================== 2289/*======================================================================
1876 FILE: icalproperty.h 2290 FILE: icalproperty.h
1877 CREATOR: eric 20 March 1999 2291 CREATOR: eric 20 March 1999
1878 2292
1879 2293
1880 $Id$
1881 $Locker$
1882 2294
1883 2295
1884 2296
@@ -1904,12 +2316,12 @@ icalparameter_kind icalparameter_string_to_kind(const char* string);
1904#define ICALPROPERTY_H 2316#define ICALPROPERTY_H
1905 2317
1906#include <time.h> 2318#include <time.h>
1907 2319#include <stdarg.h> /* for va_... */
1908 2320
1909 2321
1910 2322
1911/* Actually in icalderivedproperty.h: 2323/* Actually in icalderivedproperty.h:
1912 typedef void icalproperty; */ 2324 typedef struct icalproperty_impl icalproperty; */
1913 2325
1914 2326
1915icalproperty* icalproperty_new(icalproperty_kind kind); 2327icalproperty* icalproperty_new(icalproperty_kind kind);
@@ -1925,6 +2337,7 @@ void icalproperty_free(icalproperty* prop);
1925icalproperty_kind icalproperty_isa(icalproperty* property); 2337icalproperty_kind icalproperty_isa(icalproperty* property);
1926int icalproperty_isa_property(void* property); 2338int 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);
1929void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter); 2342void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter);
1930void icalproperty_set_parameter_from_string(icalproperty* prop, 2343void icalproperty_set_parameter_from_string(icalproperty* prop,
@@ -1935,7 +2348,18 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
1935void icalproperty_remove_parameter(icalproperty* prop, 2348void icalproperty_remove_parameter(icalproperty* prop,
1936 icalparameter_kind kind); 2349 icalparameter_kind kind);
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
1940/* Iterate through the parameters */ 2364/* Iterate through the parameters */
1941icalparameter* icalproperty_get_first_parameter(icalproperty* prop, 2365icalparameter* icalproperty_get_first_parameter(icalproperty* prop,
@@ -1946,33 +2370,39 @@ icalparameter* icalproperty_get_next_parameter(icalproperty* prop,
1946void icalproperty_set_value(icalproperty* prop, icalvalue* value); 2370void icalproperty_set_value(icalproperty* prop, icalvalue* value);
1947void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind); 2371void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind);
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
1952/* Deal with X properties */ 2376/* Deal with X properties */
1953 2377
1954void icalproperty_set_x_name(icalproperty* prop, const char* name); 2378void icalproperty_set_x_name(icalproperty* prop, const char* name);
1955const char* icalproperty_get_x_name(icalproperty* prop); 2379const 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
1961icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value); 2387icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
1962 2388
1963/* Convert kinds to string and get default value type */ 2389/* Convert kinds to string and get default value type */
1964 2390
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);
1968icalproperty_kind icalproperty_string_to_kind(const char* string); 2394icalproperty_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);
1971const char* icalproperty_method_to_string(icalproperty_method method); 2400const char* icalproperty_method_to_string(icalproperty_method method);
1972 2401
1973 2402
1974const char* icalproperty_enum_to_string(int e); 2403const 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
1977const char* icalproperty_status_to_string(icalproperty_status); 2407const char* icalproperty_status_to_string(icalproperty_status);
1978icalproperty_status icalproperty_string_to_status(const char* string); 2408icalproperty_status icalproperty_string_to_status(const char* string);
@@ -1983,68 +2413,6 @@ int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e);
1983 2413
1984 2414
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/*======================================================================
2049 FILE: pvl.h 2417 FILE: pvl.h
2050 CREATOR: eric November, 1995 2418 CREATOR: eric November, 1995
@@ -2057,29 +2425,29 @@ struct icalattendeetype icalattendeetype_new_clone(struct icalattendeetype a);
2057#ifndef __PVL_H__ 2425#ifndef __PVL_H__
2058#define __PVL_H__ 2426#define __PVL_H__
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;
2078 2444
2079 2445
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
2084extern int pvl_elem_count; 2452extern int pvl_elem_count;
2085extern int pvl_list_count; 2453extern int pvl_list_count;
@@ -2128,8 +2496,11 @@ typedef int (*pvl_findf)(void* a, void* b); /*a is list elem, b is other data*/
2128pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v); 2496pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v);
2129pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v); 2497pvl_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);
2134 2505
2135 2506
@@ -2139,6 +2510,67 @@ void pvl_apply(pvl_list l,pvl_applyf f, void *v);
2139 2510
2140 2511
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 -*- */
2143/*====================================================================== 2575/*======================================================================
2144 FILE: icalcomponent.h 2576 FILE: icalcomponent.h
@@ -2166,7 +2598,16 @@ void pvl_apply(pvl_list l,pvl_applyf f, void *v);
2166#define ICALCOMPONENT_H 2598#define ICALCOMPONENT_H
2167 2599
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
2171/* This is exposed so that callers will not have to allocate and 2612/* This is exposed so that callers will not have to allocate and
2172 deallocate iterators. Pretend that you can't see it. */ 2613 deallocate iterators. Pretend that you can't see it. */
@@ -2187,7 +2628,7 @@ char* icalcomponent_as_ical_string(icalcomponent* component);
2187 2628
2188int icalcomponent_is_valid(icalcomponent* component); 2629int icalcomponent_is_valid(icalcomponent* component);
2189 2630
2190icalcomponent_kind icalcomponent_isa(icalcomponent* component); 2631icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
2191 2632
2192int icalcomponent_isa_component (void* component); 2633int icalcomponent_isa_component (void* component);
2193 2634
@@ -2233,6 +2674,14 @@ void icalcomponent_remove_component(icalcomponent* parent,
2233int icalcomponent_count_components(icalcomponent* component, 2674int icalcomponent_count_components(icalcomponent* component,
2234 icalcomponent_kind kind); 2675 icalcomponent_kind kind);
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
2237external. The internal ones came first, and are almost completely 2686external. The internal ones came first, and are almost completely
2238sufficient, but they fail badly when you want to construct a loop that 2687sufficient, but they fail badly when you want to construct a loop that
@@ -2257,16 +2706,20 @@ icalcomponent* icalcompiter_prior(icalcompiter* i);
2257icalcomponent* icalcompiter_deref(icalcompiter* i); 2706icalcomponent* icalcompiter_deref(icalcompiter* i);
2258 2707
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);
2271 2724
2272/* Internal operations. They are private, and you should not be using them. */ 2725/* Internal operations. They are private, and you should not be using them. */
@@ -2274,7 +2727,9 @@ icalcomponent* icalcomponent_get_parent(icalcomponent* component);
2274void icalcomponent_set_parent(icalcomponent* component, 2727void icalcomponent_set_parent(icalcomponent* component,
2275 icalcomponent* parent); 2728 icalcomponent* parent);
2276 2729
2277/* Kind conversion routiens */ 2730/* Kind conversion routines */
2731
2732int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
2278 2733
2279icalcomponent_kind icalcomponent_string_to_kind(const char* string); 2734icalcomponent_kind icalcomponent_string_to_kind(const char* string);
2280 2735
@@ -2287,11 +2742,11 @@ If the code was in an OO language, the remaining routines would be
2287members of classes derived from icalcomponent. Don't call them on the 2742members of classes derived from icalcomponent. Don't call them on the
2288wrong component subtypes. */ 2743wrong 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 */
2292icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c); 2747icalcomponent* 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 */
2296struct icaltime_span icalcomponent_get_span(icalcomponent* comp); 2751struct icaltime_span icalcomponent_get_span(icalcomponent* comp);
2297 2752
@@ -2313,6 +2768,9 @@ struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp);
2313struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp); 2768struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
2314void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v); 2769void 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,
2317 struct icaldurationtype v); 2775 struct icaldurationtype v);
2318struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp); 2776struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
@@ -2323,7 +2781,6 @@ icalproperty_method icalcomponent_get_method(icalcomponent* comp);
2323struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp); 2781struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp);
2324void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v); 2782void 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);
2328const char* icalcomponent_get_summary(icalcomponent* comp); 2785const char* icalcomponent_get_summary(icalcomponent* comp);
2329 2786
@@ -2333,27 +2790,48 @@ const char* icalcomponent_get_comment(icalcomponent* comp);
2333void icalcomponent_set_uid(icalcomponent* comp, const char* v); 2790void icalcomponent_set_uid(icalcomponent* comp, const char* v);
2334const char* icalcomponent_get_uid(icalcomponent* comp); 2791const 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,
2337 struct icaltimetype v); 2797 struct icaltimetype v);
2338struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp); 2798struct 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
2358 2836
2359/*************** Type Specific routines ***************/ 2837/*************** Type Specific routines ***************/
@@ -2367,19 +2845,177 @@ icalcomponent* icalcomponent_new_vfreebusy();
2367icalcomponent* icalcomponent_new_vtimezone(); 2845icalcomponent* icalcomponent_new_vtimezone();
2368icalcomponent* icalcomponent_new_xstandard(); 2846icalcomponent* 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 -*- */
2378/*====================================================================== 3015/*======================================================================
2379 FILE: icalparser.h 3016 FILE: icalparser.h
2380 CREATOR: eric 20 April 1999 3017 CREATOR: eric 20 April 1999
2381 3018
2382 $Id$
2383 3019
2384 3020
2385 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 3021 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -2406,16 +3042,17 @@ icalcomponent* icalcomponent_new_xdaylight();
2406 3042
2407#include <stdio.h> /* For FILE* */ 3043#include <stdio.h> /* For FILE* */
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
2420typedef enum icalparser_state { 3057typedef enum icalparser_state {
2421 ICALPARSER_ERROR, 3058 ICALPARSER_ERROR,
@@ -2432,18 +3069,20 @@ icalparser_state icalparser_get_state(icalparser* parser);
2432void icalparser_free(icalparser* parser); 3069void icalparser_free(icalparser* parser);
2433 3070
2434 3071
2435/*********************************************************************** 3072/**
2436 * Message oriented parsing. icalparser_parse takes a string that 3073 * Message oriented parsing. icalparser_parse takes a string that
2437 * holds the text ( in RFC 2445 format ) and returns a pointer to an 3074 * holds the text ( in RFC 2445 format ) and returns a pointer to an
2438 * icalcomponent. The caller owns the memory. line_gen_func is a 3075 * icalcomponent. The caller owns the memory. line_gen_func is a
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);
2448 3087
2449 3088
@@ -2454,14 +3093,14 @@ icalcomponent* icalparser_parse_string(const char* str);
2454 * Parser support functions 3093 * Parser support functions
2455 ***********************************************************************/ 3094 ***********************************************************************/
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,
2459 const char* str, icalcomponent** errors); 3098 const char* str, icalcomponent** errors);
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
2466#endif /* !ICALPARSE_H */ 3105#endif /* !ICALPARSE_H */
2467/* -*- Mode: C -*- */ 3106/* -*- Mode: C -*- */
@@ -2470,8 +3109,6 @@ char* string_line_generator(char *out, size_t buf_size, void *d);
2470 CREATOR: eric 30 June 1999 3109 CREATOR: eric 30 June 1999
2471 3110
2472 3111
2473 $Id$
2474 $Locker$
2475 3112
2476 This program is free software; you can redistribute it and/or modify 3113 This program is free software; you can redistribute it and/or modify
2477 it under the terms of either: 3114 it under the terms of either:
@@ -2492,8 +3129,11 @@ char* string_line_generator(char *out, size_t buf_size, void *d);
2492#ifndef ICALMEMORY_H 3129#ifndef ICALMEMORY_H
2493#define ICALMEMORY_H 3130#define ICALMEMORY_H
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
2498/* Tmp buffers are managed by ical. References can be returned to the 3138/* Tmp buffers are managed by ical. References can be returned to the
2499 caller, although the caller will not own the memory. */ 3139 caller, although the caller will not own the memory. */
@@ -2501,11 +3141,11 @@ char* string_line_generator(char *out, size_t buf_size, void *d);
2501void* icalmemory_tmp_buffer(size_t size); 3141void* icalmemory_tmp_buffer(size_t size);
2502char* icalmemory_tmp_copy(const char* str); 3142char* 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*);
2506 3146
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);
2510 3150
2511/* Non-tmp buffers must be freed. These are mostly wrappers around 3151/* Non-tmp buffers must be freed. These are mostly wrappers around
@@ -2516,7 +3156,8 @@ void* icalmemory_new_buffer(size_t size);
2516void* icalmemory_resize_buffer(void* buf, size_t size); 3156void* icalmemory_resize_buffer(void* buf, size_t size);
2517void icalmemory_free_buffer(void* buf); 3157void 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
2521 too small. 'buf_size' is the size of 'buf' and will be changed if 3162 too small. 'buf_size' is the size of 'buf' and will be changed if
2522 'buf' is reallocated. 'pos' will point to the last byte of the new 3163 'buf' is reallocated. 'pos' will point to the last byte of the new
@@ -2532,12 +3173,12 @@ void icalmemory_free_buffer(void* buf);
2532void icalmemory_append_string(char** buf, char** pos, size_t* buf_size, 3173void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
2533 const char* string); 3174 const char* string);
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,
2537 char ch); 3178 char ch);
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);
2542 3183
2543#endif /* !ICALMEMORY_H */ 3184#endif /* !ICALMEMORY_H */
@@ -2549,7 +3190,6 @@ char* icalmemory_strdup(const char *s);
2549 FILE: icalerror.h 3190 FILE: icalerror.h
2550 CREATOR: eric 09 May 1999 3191 CREATOR: eric 09 May 1999
2551 3192
2552 $Id$
2553 3193
2554 3194
2555 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 3195 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -2578,13 +3218,12 @@ char* icalmemory_strdup(const char *s);
2578 3218
2579 3219
2580#ifdef HAVE_CONFIG_H 3220#ifdef HAVE_CONFIG_H
2581#include "config.h"
2582#endif 3221#endif
2583 3222
2584#define ICAL_SETERROR_ISFUNC 3223#define ICAL_SETERROR_ISFUNC
2585 3224
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
2589 below */ 3228 below */
2590void icalerror_stop_here(void); 3229void icalerror_stop_here(void);
@@ -2592,7 +3231,7 @@ void icalerror_stop_here(void);
2592void icalerror_crash_here(void); 3231void icalerror_crash_here(void);
2593 3232
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,
2597 ICAL_NEWFAILED_ERROR, 3236 ICAL_NEWFAILED_ERROR,
2598 ICAL_ALLOCATION_ERROR, 3237 ICAL_ALLOCATION_ERROR,
@@ -2602,15 +3241,18 @@ typedef enum icalerrorenum {
2602 ICAL_FILE_ERROR, 3241 ICAL_FILE_ERROR,
2603 ICAL_USAGE_ERROR, 3242 ICAL_USAGE_ERROR,
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
2608} icalerrorenum; 3246} 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;
2615 3257
2616/* Warning messages */ 3258/* Warning messages */
@@ -2623,6 +3265,7 @@ extern int icalerror_errors_are_fatal;
2623 3265
2624 3266
2625void icalerror_clear_errno(void); 3267void icalerror_clear_errno(void);
3268void _icalerror_set_errno(icalerrorenum);
2626 3269
2627/* Make an individual error fatal or non-fatal. */ 3270/* Make an individual error fatal or non-fatal. */
2628typedef enum icalerrorstate { 3271typedef enum icalerrorstate {
@@ -2647,7 +3290,7 @@ if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \
2647 assert(0); \ 3290 assert(0); \
2648} 3291}
2649#else 3292#else
2650void icalerror_set_errno(icalerrorenum); 3293void icalerror_set_errno(icalerrorenum x);
2651#endif 3294#endif
2652 3295
2653#ifdef ICAL_ERRORS_ARE_FATAL 3296#ifdef ICAL_ERRORS_ARE_FATAL
@@ -2705,7 +3348,6 @@ void icalerror_restore(const char* error, icalerrorstate es);
2705 FILE: icalrestriction.h 3348 FILE: icalrestriction.h
2706 CREATOR: eric 24 April 1999 3349 CREATOR: eric 24 April 1999
2707 3350
2708 $Id$
2709 3351
2710 3352
2711 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 3353 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -2766,8 +3408,6 @@ int icalrestriction_check(icalcomponent* comp);
2766 FILE: sspm.h Mime Parser 3408 FILE: sspm.h Mime Parser
2767 CREATOR: eric 25 June 2000 3409 CREATOR: eric 25 June 2000
2768 3410
2769 $Id$
2770 $Locker$
2771 3411
2772 The contents of this file are subject to the Mozilla Public License 3412 The contents of this file are subject to the Mozilla Public License
2773 Version 1.0 (the "License"); you may not use this file except in 3413 Version 1.0 (the "License"); you may not use this file except in
@@ -2910,8 +3550,6 @@ int sspm_write_mime(struct sspm_part *parts,size_t num_parts,
2910 CREATOR: eric 26 July 2000 3550 CREATOR: eric 26 July 2000
2911 3551
2912 3552
2913 $Id$
2914 $Locker$
2915 3553
2916 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 3554 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
2917 3555
@@ -2952,8 +3590,6 @@ char* icalmime_as_mime_string(char* component);
2952 3590
2953 DESCRIPTION: 3591 DESCRIPTION:
2954 3592
2955 $Id$
2956 $Locker$
2957 3593
2958 (C) COPYRIGHT 1999 Eric Busboom 3594 (C) COPYRIGHT 1999 Eric Busboom
2959 http://www.softwarestudio.org 3595 http://www.softwarestudio.org
@@ -2988,9 +3624,17 @@ icalcomponent* icallangbind_get_first_component(icalcomponent *c,
2988icalcomponent* icallangbind_get_next_component(icalcomponent *c, 3624icalcomponent* icallangbind_get_next_component(icalcomponent *c,
2989 const char* comp); 3625 const char* comp);
2990 3626
3627icalparameter* icallangbind_get_first_parameter(icalproperty *prop);
3628
3629icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
2991 3630
2992const char* icallangbind_property_eval_string(icalproperty* prop, char* sep); 3631const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
2993 3632
2994 3633
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
@@ -4,7 +4,6 @@
4 4
5 $Id$ 5 $Id$
6 6
7
8 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 7 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
9 8
10 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
@@ -33,18 +32,20 @@
33#include "icalmemory.h" 32#include "icalmemory.h"
34#include "icalenums.h" 33#include "icalenums.h"
35#include "icaltime.h" 34#include "icaltime.h"
35#include "icalarray.h"
36#include "icaltimezone.h"
36#include "icalduration.h" 37#include "icalduration.h"
37#include "icalperiod.h" 38#include "icalperiod.h"
38#include "icalparser.h" 39#include "icalparser.h"
40#include "icalrestriction.h"
39 41
40#include <stdlib.h> /* for malloc */ 42#include <stdlib.h> /* for malloc */
41#include <stdarg.h> /* for va_list, etc */ 43#include <stdarg.h> /* for va_list, etc */
42#include <errno.h> 44#include <errno.h>
43#include <assert.h> 45#include <assert.h>
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
49struct icalcomponent_impl 50struct icalcomponent_impl
50{ 51{
@@ -56,18 +57,42 @@ struct icalcomponent_impl
56 pvl_list components; 57 pvl_list components;
57 pvl_elem component_iterator; 58 pvl_elem component_iterator;
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};
60 68
61/* icalproperty functions that only components get to use */ 69/* icalproperty functions that only components get to use */
62void icalproperty_set_parent(icalproperty* property, 70void icalproperty_set_parent(icalproperty* property,
63 icalcomponent* component); 71 icalcomponent* component);
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{
72 void* vp; 97 void* vp;
73 98
@@ -77,25 +102,23 @@ void icalcomponent_add_children(struct icalcomponent_impl *impl,va_list args)
77 icalproperty_isa_property(vp) != 0 ) ; 102 icalproperty_isa_property(vp) != 0 ) ;
78 103
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 }
89 } 110 }
90} 111}
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);
100 return 0; 123 return 0;
101 } 124 }
@@ -109,22 +132,28 @@ icalcomponent_new_impl (icalcomponent_kind kind)
109 comp->component_iterator = 0; 132 comp->component_iterator = 0;
110 comp->x_name = 0; 133 comp->x_name = 0;
111 comp->parent = 0; 134 comp->parent = 0;
135 comp->timezones = NULL;
136 comp->timezones_sorted = 1;
112 137
113 return comp; 138 return comp;
114} 139}
115 140
141/** @brief Constructor
142 */
116icalcomponent* 143icalcomponent*
117icalcomponent_new (icalcomponent_kind kind) 144icalcomponent_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*
123icalcomponent_vanew (icalcomponent_kind kind, ...) 152icalcomponent_vanew (icalcomponent_kind kind, ...)
124{ 153{
125 va_list args; 154 va_list args;
126 155
127 struct icalcomponent_impl *impl = icalcomponent_new_impl(kind); 156 icalcomponent *impl = icalcomponent_new_impl(kind);
128 157
129 if (impl == 0){ 158 if (impl == 0){
130 return 0; 159 return 0;
@@ -134,23 +163,26 @@ icalcomponent_vanew (icalcomponent_kind kind, ...)
134 icalcomponent_add_children(impl, args); 163 icalcomponent_add_children(impl, args);
135 va_end(args); 164 va_end(args);
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)
141{ 172{
142 return icalparser_parse_string(str); 173 return icalparser_parse_string(str);
143} 174}
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;
150 icalcomponent *c; 182 icalcomponent *c;
151 pvl_elem itr; 183 pvl_elem itr;
152 184
153 icalerror_check_arg_rz( (component!=0), "component"); 185 icalerror_check_arg_rz( (old!=0), "component");
154 186
155 new = icalcomponent_new_impl(old->kind); 187 new = icalcomponent_new_impl(old->kind);
156 188
@@ -180,15 +212,15 @@ icalcomponent* icalcomponent_new_clone(icalcomponent* component)
180 212
181} 213}
182 214
183 215/*** @brief Destructor
216 */
184void 217void
185icalcomponent_free (icalcomponent* component) 218icalcomponent_free (icalcomponent* c)
186{ 219{
187 icalproperty* prop; 220 icalproperty* prop;
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
193#ifdef ICAL_FREE_ON_LIST_IS_ERROR 225#ifdef ICAL_FREE_ON_LIST_IS_ERROR
194 icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component"); 226 icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component");
@@ -198,19 +230,22 @@ icalcomponent_free (icalcomponent* component)
198 } 230 }
199#endif 231#endif
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
211 while( (comp=pvl_data(pvl_head(c->components))) != 0){ 246 while( (comp=pvl_data(pvl_head(c->components))) != 0){
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);
215 } 250 }
216 251
@@ -220,6 +255,9 @@ icalcomponent_free (icalcomponent* component)
220 free(c->x_name); 255 free(c->x_name);
221 } 256 }
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;
224 c->properties = 0; 262 c->properties = 0;
225 c->property_iterator = 0; 263 c->property_iterator = 0;
@@ -227,36 +265,41 @@ icalcomponent_free (icalcomponent* component)
227 c->component_iterator = 0; 265 c->component_iterator = 0;
228 c->x_name = 0; 266 c->x_name = 0;
229 c->id[0] = 'X'; 267 c->id[0] = 'X';
268 c->timezones = NULL;
230 269
231 free(c); 270 free(c);
232 } 271 }
233} 272}
234 273
235char* 274char*
236icalcomponent_as_ical_string (icalcomponent* component) 275icalcomponent_as_ical_string (icalcomponent* impl)
237{ 276{
238 char* buf, *out_buf; 277 char* buf, *out_buf;
239 const char* tmp_buf; 278 const char* tmp_buf;
240 size_t buf_size = 1024; 279 size_t buf_size = 1024;
241 char* buf_ptr = 0; 280 char* buf_ptr = 0;
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
254 const char* kind_string; 297 const char* kind_string;
255 298
256 buf = icalmemory_new_buffer(buf_size); 299 buf = icalmemory_new_buffer(buf_size);
257 buf_ptr = buf; 300 buf_ptr = buf;
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");
261 304
262 kind_string = icalcomponent_kind_to_string(kind); 305 kind_string = icalcomponent_kind_to_string(kind);
@@ -267,13 +310,12 @@ icalcomponent_as_ical_string (icalcomponent* component)
267 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); 310 icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
268 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); 311 icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
269 312
270 313
314
271 for( itr = pvl_head(impl->properties); 315 for( itr = pvl_head(impl->properties);
272 itr != 0; 316 itr != 0;
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);
278 320
279 icalerror_assert((p!=0),"Got a null property"); 321 icalerror_assert((p!=0),"Got a null property");
@@ -286,19 +328,19 @@ icalcomponent_as_ical_string (icalcomponent* component)
286 for( itr = pvl_head(impl->components); 328 for( itr = pvl_head(impl->components);
287 itr != 0; 329 itr != 0;
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);
292 333
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);
295 337
296 } 338 }
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
303 out_buf = icalmemory_tmp_copy(buf); 345 out_buf = icalmemory_tmp_copy(buf);
304 free(buf); 346 free(buf);
@@ -310,11 +352,8 @@ icalcomponent_as_ical_string (icalcomponent* component)
310int 352int
311icalcomponent_is_valid (icalcomponent* component) 353icalcomponent_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;
319 } else { 358 } else {
320 return 0; 359 return 0;
@@ -324,14 +363,13 @@ icalcomponent_is_valid (icalcomponent* component)
324 363
325 364
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
332 if(component != 0) 370 if(component != 0)
333 { 371 {
334 return impl->kind; 372 return component->kind;
335 } 373 }
336 374
337 return ICAL_NO_COMPONENT; 375 return ICAL_NO_COMPONENT;
@@ -341,7 +379,7 @@ icalcomponent_isa (icalcomponent* component)
341int 379int
342icalcomponent_isa_component (void* component) 380icalcomponent_isa_component (void* component)
343{ 381{
344 struct icalcomponent_impl *impl = (struct icalcomponent_impl *)component; 382 icalcomponent *impl = component;
345 383
346 icalerror_check_arg_rz( (component!=0), "component"); 384 icalerror_check_arg_rz( (component!=0), "component");
347 385
@@ -353,63 +391,32 @@ icalcomponent_isa_component (void* component)
353 391
354} 392}
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
372icalcomponent_add_property (icalcomponent* component, icalproperty* property) 395icalcomponent_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");
377 icalerror_check_arg_rv( (property!=0), "property"); 398 icalerror_check_arg_rv( (property!=0), "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");
382 401
383 icalproperty_set_parent(property,component); 402 icalproperty_set_parent(property,component);
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}
393 406
394 407
395void 408void
396icalcomponent_remove_property (icalcomponent* component, icalproperty* property) 409icalcomponent_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
402 icalerror_check_arg_rv( (component!=0), "component"); 413 icalerror_check_arg_rv( (component!=0), "component");
403 icalerror_check_arg_rv( (property!=0), "property"); 414 icalerror_check_arg_rv( (property!=0), "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");
410 417
411 418
412 for( itr = pvl_head(impl->properties); 419 for( itr = pvl_head(component->properties);
413 itr != 0; 420 itr != 0;
414 itr = next_itr) 421 itr = next_itr)
415 { 422 {
@@ -417,11 +424,11 @@ icalcomponent_remove_property (icalcomponent* component, icalproperty* property)
417 424
418 if( pvl_data(itr) == (void*)property ){ 425 if( pvl_data(itr) == (void*)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);
426 } 433 }
427 } 434 }
@@ -433,11 +440,10 @@ icalcomponent_count_properties (icalcomponent* component,
433{ 440{
434 int count=0; 441 int count=0;
435 pvl_elem itr; 442 pvl_elem itr;
436 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
437 443
438 icalerror_check_arg_rz( (component!=0), "component"); 444 icalerror_check_arg_rz( (component!=0), "component");
439 445
440 for( itr = pvl_head(impl->properties); 446 for( itr = pvl_head(component->properties);
441 itr != 0; 447 itr != 0;
442 itr = pvl_next(itr)) 448 itr = pvl_next(itr))
443 { 449 {
@@ -454,23 +460,19 @@ icalcomponent_count_properties (icalcomponent* component,
454 460
455icalproperty* icalcomponent_get_current_property (icalcomponent* component) 461icalproperty* 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;
463 } 467 }
464 468
465 return (icalproperty*) pvl_data(c->property_iterator); 469 return (icalproperty*) pvl_data(component->property_iterator);
466
467} 470}
468 471
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
475 for( c->property_iterator = pvl_head(c->properties); 477 for( c->property_iterator = pvl_head(c->properties);
476 c->property_iterator != 0; 478 c->property_iterator != 0;
@@ -487,10 +489,9 @@ icalcomponent_get_first_property (icalcomponent* component, icalproperty_kind ki
487} 489}
488 490
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
495 if (c->property_iterator == 0){ 496 if (c->property_iterator == 0){
496 return 0; 497 return 0;
@@ -519,37 +520,57 @@ icalcomponent_get_properties (icalcomponent* component, icalproperty_kind kind);
519void 520void
520icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) 521icalcomponent_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");
525 icalerror_check_arg_rv( (child!=0), "child"); 524 icalerror_check_arg_rv( (child!=0), "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);
532 } 528 }
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}
538 547
539 548
540void 549void
541icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child) 550icalcomponent_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;
545 553
546 icalerror_check_arg_rv( (parent!=0), "parent"); 554 icalerror_check_arg_rv( (parent!=0), "parent");
547 icalerror_check_arg_rv( (child!=0), "child"); 555 icalerror_check_arg_rv( (child!=0), "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;
554 itr = next_itr) 575 itr = next_itr)
555 { 576 {
@@ -557,16 +578,16 @@ icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child)
557 578
558 if( pvl_data(itr) == (void*)child ){ 579 if( pvl_data(itr) == (void*)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 */
562 583
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;
571 } 592 }
572 } 593 }
@@ -579,11 +600,10 @@ icalcomponent_count_components (icalcomponent* component,
579{ 600{
580 int count=0; 601 int count=0;
581 pvl_elem itr; 602 pvl_elem itr;
582 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
583 603
584 icalerror_check_arg_rz( (component!=0), "component"); 604 icalerror_check_arg_rz( (component!=0), "component");
585 605
586 for( itr = pvl_head(impl->components); 606 for( itr = pvl_head(component->components);
587 itr != 0; 607 itr != 0;
588 itr = pvl_next(itr)) 608 itr = pvl_next(itr))
589 { 609 {
@@ -599,24 +619,20 @@ icalcomponent_count_components (icalcomponent* component,
599icalcomponent* 619icalcomponent*
600icalcomponent_get_current_component(icalcomponent* component) 620icalcomponent_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;
608 } 626 }
609 627
610 return (icalcomponent*) pvl_data(c->component_iterator); 628 return (icalcomponent*) pvl_data(component->component_iterator);
611} 629}
612 630
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
621 for( c->component_iterator = pvl_head(c->components); 637 for( c->component_iterator = pvl_head(c->components);
622 c->component_iterator != 0; 638 c->component_iterator != 0;
@@ -635,11 +651,9 @@ icalcomponent_get_first_component (icalcomponent* component,
635 651
636 652
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
644 if (c->component_iterator == 0){ 658 if (c->component_iterator == 0){
645 return 0; 659 return 0;
@@ -673,83 +687,52 @@ icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c)
673 if(kind == ICAL_VEVENT_COMPONENT || 687 if(kind == ICAL_VEVENT_COMPONENT ||
674 kind == ICAL_VTODO_COMPONENT || 688 kind == ICAL_VTODO_COMPONENT ||
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;
678 } 694 }
679 } 695 }
680 return 0; 696 return 0;
681} 697}
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
743 span.start = 0; 725 span.start = 0;
744 span.end = 0; 726 span.end = 0;
745 span.is_busy= 1; 727 span.is_busy= 1;
746 728
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){
754 inner = icalcomponent_get_first_real_component(comp); 737 inner = icalcomponent_get_first_real_component(comp);
755 738
@@ -781,67 +764,329 @@ struct icaltime_span icalcomponent_get_span(icalcomponent* comp)
781 764
782 } 765 }
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
846int icalcomponent_count_errors(icalcomponent* component) 1091int icalcomponent_count_errors(icalcomponent* component)
847{ 1092{
@@ -849,9 +1094,8 @@ int icalcomponent_count_errors(icalcomponent* component)
849 icalproperty *p; 1094 icalproperty *p;
850 icalcomponent *c; 1095 icalcomponent *c;
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;
856 itr = pvl_next(itr)) 1100 itr = pvl_next(itr))
857 { 1101 {
@@ -864,7 +1108,7 @@ int icalcomponent_count_errors(icalcomponent* component)
864 } 1108 }
865 1109
866 1110
867 for( itr = pvl_head(impl->components); 1111 for( itr = pvl_head(component->components);
868 itr != 0; 1112 itr != 0;
869 itr = pvl_next(itr)) 1113 itr = pvl_next(itr))
870 { 1114 {
@@ -883,9 +1127,8 @@ void icalcomponent_strip_errors(icalcomponent* component)
883 icalproperty *p; 1127 icalproperty *p;
884 icalcomponent *c; 1128 icalcomponent *c;
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;
890 itr = next_itr) 1133 itr = next_itr)
891 { 1134 {
@@ -898,7 +1141,7 @@ void icalcomponent_strip_errors(icalcomponent* component)
898 } 1141 }
899 } 1142 }
900 1143
901 for( itr = pvl_head(impl->components); 1144 for( itr = pvl_head(component->components);
902 itr != 0; 1145 itr != 0;
903 itr = pvl_next(itr)) 1146 itr = pvl_next(itr))
904 { 1147 {
@@ -952,6 +1195,7 @@ void icalcomponent_convert_errors(icalcomponent* component)
952 } 1195 }
953 1196
954 default: { 1197 default: {
1198 break;
955 } 1199 }
956 } 1200 }
957 if (rst.code != ICAL_UNKNOWN_STATUS){ 1201 if (rst.code != ICAL_UNKNOWN_STATUS){
@@ -976,16 +1220,12 @@ void icalcomponent_convert_errors(icalcomponent* component)
976 1220
977icalcomponent* icalcomponent_get_parent(icalcomponent* component) 1221icalcomponent* 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}
983 1225
984void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent) 1226void 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}
990 1230
991icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0}; 1231icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0};
@@ -1004,6 +1244,7 @@ static struct icalcomponent_kind_map component_map[] =
1004 { ICAL_VTODO_COMPONENT, "VTODO" }, 1244 { ICAL_VTODO_COMPONENT, "VTODO" },
1005 { ICAL_VJOURNAL_COMPONENT, "VJOURNAL" }, 1245 { ICAL_VJOURNAL_COMPONENT, "VJOURNAL" },
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" },
1008 { ICAL_VTIMEZONE_COMPONENT, "VTIMEZONE" }, 1249 { ICAL_VTIMEZONE_COMPONENT, "VTIMEZONE" },
1009 { ICAL_VALARM_COMPONENT, "VALARM" }, 1250 { ICAL_VALARM_COMPONENT, "VALARM" },
@@ -1028,6 +1269,16 @@ static struct icalcomponent_kind_map component_map[] =
1028}; 1269};
1029 1270
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
1032const char* icalcomponent_kind_to_string(icalcomponent_kind kind) 1283const char* icalcomponent_kind_to_string(icalcomponent_kind kind)
1033{ 1284{
@@ -1065,15 +1316,15 @@ icalcomponent_kind icalcomponent_string_to_kind(const char* string)
1065icalcompiter 1316icalcompiter
1066icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind) 1317icalcomponent_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;
1071 1321
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
1078 icalcomponent *c = (icalcomponent*) pvl_data(i); 1329 icalcomponent *c = (icalcomponent*) pvl_data(i);
1079 1330
@@ -1091,15 +1342,14 @@ icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind)
1091icalcompiter 1342icalcompiter
1092icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind) 1343icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind)
1093{ 1344{
1094 struct icalcomponent_impl *impl = (struct icalcomponent_impl*)component;
1095 icalcompiter itr; 1345 icalcompiter itr;
1096 pvl_elem i; 1346 pvl_elem i;
1097 1347
1098 itr.kind = kind; 1348 itr.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
1104 icalcomponent *c = (icalcomponent*) pvl_data(i); 1354 icalcomponent *c = (icalcomponent*) pvl_data(i);
1105 1355
@@ -1180,140 +1430,231 @@ icalcomponent* icalcomponent_get_inner(icalcomponent* comp)
1180 } 1430 }
1181} 1431}
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
1192 if (prop == 0){ 1488 if (prop == 0){
1193 prop = icalproperty_new_dtstart(v); 1489 prop = icalproperty_new_dtstart(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 }
1196 1494
1197 icalproperty_set_dtstart(prop,v); 1495 icalproperty_set_dtstart(prop,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)
1203{ 1542{
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){
1209 return icaltime_null_time(); 1548 return icaltime_null_time();
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)
1217{ 1567{
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 =
1234 icalcomponent_get_dtstart(inner); 1580 icalcomponent_get_dtstart(inner);
1235 struct icaldurationtype duration = 1581 struct icaldurationtype duration =
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 }
1284} 1624}
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,
1287 struct icaldurationtype v) 1636 struct icaldurationtype v)
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 }
1315} 1651}
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)
1318{ 1659{
1319 icalcomponent *inner = icalcomponent_get_inner(comp); 1660 icalcomponent *inner = icalcomponent_get_inner(comp);
@@ -1324,131 +1665,329 @@ struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp)
1324 icalproperty *dur_prop 1665 icalproperty *dur_prop
1325 = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); 1666 = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);
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 {
1346 /* Error, both duration and dtend have been specified */ 1686 /* Error, both duration and dtend have been specified */
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
1365} 1704}
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
1394} 1755}
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
1432 if (prop == 0){ 1816 if (prop == 0){
1433 return 0; 1817 return 0;
1434 } 1818 }
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
1453icalcomponent* icalcomponent_new_vcalendar() 1992icalcomponent* icalcomponent_new_vcalendar()
1454{ 1993{
@@ -1486,3 +2025,571 @@ icalcomponent* icalcomponent_new_xdaylight()
1486{ 2025{
1487 return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT); 2026 return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT);
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
@@ -27,10 +27,18 @@
27#include "icalproperty.h" 27#include "icalproperty.h"
28#include "icalvalue.h" 28#include "icalvalue.h"
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
35/* This is exposed so that callers will not have to allocate and 43/* This is exposed so that callers will not have to allocate and
36 deallocate iterators. Pretend that you can't see it. */ 44 deallocate iterators. Pretend that you can't see it. */
@@ -51,7 +59,7 @@ char* icalcomponent_as_ical_string(icalcomponent* component);
51 59
52int icalcomponent_is_valid(icalcomponent* component); 60int icalcomponent_is_valid(icalcomponent* component);
53 61
54icalcomponent_kind icalcomponent_isa(icalcomponent* component); 62icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
55 63
56int icalcomponent_isa_component (void* component); 64int icalcomponent_isa_component (void* component);
57 65
@@ -97,6 +105,14 @@ void icalcomponent_remove_component(icalcomponent* parent,
97int icalcomponent_count_components(icalcomponent* component, 105int icalcomponent_count_components(icalcomponent* component,
98 icalcomponent_kind kind); 106 icalcomponent_kind kind);
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
101external. The internal ones came first, and are almost completely 117external. The internal ones came first, and are almost completely
102sufficient, but they fail badly when you want to construct a loop that 118sufficient, but they fail badly when you want to construct a loop that
@@ -121,16 +137,20 @@ icalcomponent* icalcompiter_prior(icalcompiter* i);
121icalcomponent* icalcompiter_deref(icalcompiter* i); 137icalcomponent* icalcompiter_deref(icalcompiter* i);
122 138
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);
135 155
136/* Internal operations. They are private, and you should not be using them. */ 156/* Internal operations. They are private, and you should not be using them. */
@@ -138,7 +158,9 @@ icalcomponent* icalcomponent_get_parent(icalcomponent* component);
138void icalcomponent_set_parent(icalcomponent* component, 158void icalcomponent_set_parent(icalcomponent* component,
139 icalcomponent* parent); 159 icalcomponent* parent);
140 160
141/* Kind conversion routiens */ 161/* Kind conversion routines */
162
163int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
142 164
143icalcomponent_kind icalcomponent_string_to_kind(const char* string); 165icalcomponent_kind icalcomponent_string_to_kind(const char* string);
144 166
@@ -151,11 +173,11 @@ If the code was in an OO language, the remaining routines would be
151members of classes derived from icalcomponent. Don't call them on the 173members of classes derived from icalcomponent. Don't call them on the
152wrong component subtypes. */ 174wrong 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 */
156icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c); 178icalcomponent* 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 */
160struct icaltime_span icalcomponent_get_span(icalcomponent* comp); 182struct icaltime_span icalcomponent_get_span(icalcomponent* comp);
161 183
@@ -177,6 +199,9 @@ struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp);
177struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp); 199struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
178void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v); 200void 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,
181 struct icaldurationtype v); 206 struct icaldurationtype v);
182struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp); 207struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
@@ -187,7 +212,6 @@ icalproperty_method icalcomponent_get_method(icalcomponent* comp);
187struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp); 212struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp);
188void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v); 213void 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);
192const char* icalcomponent_get_summary(icalcomponent* comp); 216const char* icalcomponent_get_summary(icalcomponent* comp);
193 217
@@ -197,27 +221,48 @@ const char* icalcomponent_get_comment(icalcomponent* comp);
197void icalcomponent_set_uid(icalcomponent* comp, const char* v); 221void icalcomponent_set_uid(icalcomponent* comp, const char* v);
198const char* icalcomponent_get_uid(icalcomponent* comp); 222const 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,
201 struct icaltimetype v); 228 struct icaltimetype v);
202struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp); 229struct 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
222 267
223/*************** Type Specific routines ***************/ 268/*************** Type Specific routines ***************/
@@ -231,10 +276,7 @@ icalcomponent* icalcomponent_new_vfreebusy();
231icalcomponent* icalcomponent_new_vtimezone(); 276icalcomponent* icalcomponent_new_vtimezone();
232icalcomponent* icalcomponent_new_xstandard(); 277icalcomponent* 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
@@ -55,45 +55,6 @@ struct icalparameter_kind_map {
55 55
56}; 56};
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
98 the kinds of VALUEs. */ 59 the kinds of VALUEs. */
99 60
@@ -102,24 +63,6 @@ struct icalparameter_value_kind_map {
102 icalvalue_kind kind; 63 icalvalue_kind kind;
103}; 64};
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 */
124 67
125struct icalparameter_map { 68struct icalparameter_map {
@@ -129,87 +72,8 @@ struct icalparameter_map {
129}; 72};
130 73
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},
214 {ICAL_VALUE_BOOLEAN,ICAL_BOOLEAN_VALUE}, 78 {ICAL_VALUE_BOOLEAN,ICAL_BOOLEAN_VALUE},
215 {ICAL_VALUE_DATE,ICAL_DATE_VALUE}, 79 {ICAL_VALUE_DATE,ICAL_DATE_VALUE},
@@ -227,7 +91,7 @@ struct icalparameter_value_kind_map value_kind_map[] = {
227 {ICAL_VALUE_NONE,ICAL_NO_VALUE} 91 {ICAL_VALUE_NONE,ICAL_NO_VALUE}
228}; 92};
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"},
232 {ICAL_CN_PARAMETER,"CN"}, 96 {ICAL_CN_PARAMETER,"CN"},
233 {ICAL_CUTYPE_PARAMETER,"CUTYPE"}, 97 {ICAL_CUTYPE_PARAMETER,"CUTYPE"},
@@ -277,7 +141,7 @@ static struct icalparameter_map icalparameter_map[] = {
277 {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDPRIOR,"THISANDPRIOR"}, 141 {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDPRIOR,"THISANDPRIOR"},
278 {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDFUTURE,"THISANDFUTURE"}, 142 {ICAL_RANGE_PARAMETER,ICAL_RANGE_THISANDFUTURE,"THISANDFUTURE"},
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"},
282 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_CHILD,"CHILD"}, 146 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_CHILD,"CHILD"},
283 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_SIBLING,"SIBLING"}, 147 {ICAL_RELTYPE_PARAMETER,ICAL_RELTYPE_SIBLING,"SIBLING"},
@@ -308,6 +172,8 @@ static struct icalparameter_map icalparameter_map[] = {
308 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESSEQUAL,"LESSEQUAL"}, 172 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_LESSEQUAL,"LESSEQUAL"},
309 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATEREQUAL,"GREATEREQUAL"}, 173 {ICAL_XLICCOMPARETYPE_PARAMETER,ICAL_XLICCOMPARETYPE_GREATEREQUAL,"GREATEREQUAL"},
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"},
312 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PROPERTYPARSEERROR,"PROPERTY-PARSE-ERROR"}, 178 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PROPERTYPARSEERROR,"PROPERTY-PARSE-ERROR"},
313 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR,"PARAMETER-NAME-PARSE-ERROR"}, 179 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR,"PARAMETER-NAME-PARSE-ERROR"},
@@ -316,20 +182,21 @@ static struct icalparameter_map icalparameter_map[] = {
316 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_INVALIDITIP,"INVALID-ITIP"}, 182 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_INVALIDITIP,"INVALID-ITIP"},
317 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR,"UNKNOWN-VCAL-PROP-ERROR"}, 183 {ICAL_XLICERRORTYPE_PARAMETER,ICAL_XLICERRORTYPE_UNKNOWNVCALPROPERROR,"UNKNOWN-VCAL-PROP-ERROR"},
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{
324 struct icalparameter_impl *impl; 191 struct icalparameter_impl *impl;
325 icalerror_clear_errno(); 192 icalerror_clear_errno();
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) {
329 return 0; 196 return 0;
330 } 197 }
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) {
334 icalparameter_free((icalparameter*) impl); 201 icalparameter_free((icalparameter*) impl);
335 return 0; 202 return 0;
@@ -338,14 +205,14 @@ icalparameter* icalparameter_new_delegatedfrom(const char* v)
338 return (icalparameter*) impl; 205 return (icalparameter*) impl;
339} 206}
340 207
341const char* icalparameter_get_delegatedfrom(icalparameter* param) 208const char* icalparameter_get_language(const icalparameter* param)
342{ 209{
343 icalerror_clear_errno(); 210 icalerror_clear_errno();
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{
350 icalerror_check_arg_rv( (v!=0),"v"); 217 icalerror_check_arg_rv( (v!=0),"v");
351 icalerror_check_arg_rv( (param!=0), "param"); 218 icalerror_check_arg_rv( (param!=0), "param");
@@ -354,18 +221,18 @@ void icalparameter_set_delegatedfrom(icalparameter* param, const char* v)
354 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 221 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
355} 222}
356 223
357/* DELEGATED-TO */ 224/* DIR */
358icalparameter* icalparameter_new_delegatedto(const char* v) 225icalparameter* icalparameter_new_dir(const char* v)
359{ 226{
360 struct icalparameter_impl *impl; 227 struct icalparameter_impl *impl;
361 icalerror_clear_errno(); 228 icalerror_clear_errno();
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) {
365 return 0; 232 return 0;
366 } 233 }
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) {
370 icalparameter_free((icalparameter*) impl); 237 icalparameter_free((icalparameter*) impl);
371 return 0; 238 return 0;
@@ -374,14 +241,14 @@ icalparameter* icalparameter_new_delegatedto(const char* v)
374 return (icalparameter*) impl; 241 return (icalparameter*) impl;
375} 242}
376 243
377const char* icalparameter_get_delegatedto(icalparameter* param) 244const char* icalparameter_get_dir(const icalparameter* param)
378{ 245{
379 icalerror_clear_errno(); 246 icalerror_clear_errno();
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{
386 icalerror_check_arg_rv( (v!=0),"v"); 253 icalerror_check_arg_rv( (v!=0),"v");
387 icalerror_check_arg_rv( (param!=0), "param"); 254 icalerror_check_arg_rv( (param!=0), "param");
@@ -390,19 +257,19 @@ void icalparameter_set_delegatedto(icalparameter* param, const char* v)
390 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 257 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
391} 258}
392 259
393/* RANGE */ 260/* RELTYPE */
394icalparameter* icalparameter_new_range(icalparameter_range v) 261icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
395{ 262{
396 struct icalparameter_impl *impl; 263 struct icalparameter_impl *impl;
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) {
402 return 0; 269 return 0;
403 } 270 }
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) {
407 icalparameter_free((icalparameter*) impl); 274 icalparameter_free((icalparameter*) impl);
408 return 0; 275 return 0;
@@ -411,37 +278,39 @@ icalparameter* icalparameter_new_range(icalparameter_range v)
411 return (icalparameter*) impl; 278 return (icalparameter*) impl;
412} 279}
413 280
414icalparameter_range icalparameter_get_range(icalparameter* param) 281icalparameter_reltype icalparameter_get_reltype(const icalparameter* param)
415{ 282{
416 icalerror_clear_errno(); 283 icalerror_clear_errno();
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");
427 icalerror_clear_errno(); 297 icalerror_clear_errno();
428 298
429 ((struct icalparameter_impl*)param)->data = (int)v; 299 ((struct icalparameter_impl*)param)->data = (int)v;
430} 300}
431 301
432/* ENCODING */ 302/* FMTTYPE */
433icalparameter* icalparameter_new_encoding(icalparameter_encoding v) 303icalparameter* icalparameter_new_fmttype(const char* v)
434{ 304{
435 struct icalparameter_impl *impl; 305 struct icalparameter_impl *impl;
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) {
441 return 0; 310 return 0;
442 } 311 }
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) {
446 icalparameter_free((icalparameter*) impl); 315 icalparameter_free((icalparameter*) impl);
447 return 0; 316 return 0;
@@ -450,40 +319,71 @@ icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
450 return (icalparameter*) impl; 319 return (icalparameter*) impl;
451} 320}
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");
469 icalerror_clear_errno(); 369 icalerror_clear_errno();
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{
477 struct icalparameter_impl *impl; 377 struct icalparameter_impl *impl;
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) {
483 return 0; 383 return 0;
484 } 384 }
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) {
488 icalparameter_free((icalparameter*) impl); 388 icalparameter_free((icalparameter*) impl);
489 return 0; 389 return 0;
@@ -492,37 +392,36 @@ icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
492 return (icalparameter*) impl; 392 return (icalparameter*) impl;
493} 393}
494 394
495icalparameter_rsvp icalparameter_get_rsvp(icalparameter* param) 395icalparameter_range icalparameter_get_range(const icalparameter* param)
496{ 396{
497 icalerror_clear_errno(); 397 icalerror_clear_errno();
498icalerror_check_arg( (param!=0), "param"); 398icalerror_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");
508 icalerror_clear_errno(); 408 icalerror_clear_errno();
509 409
510 ((struct icalparameter_impl*)param)->data = (int)v; 410 ((struct icalparameter_impl*)param)->data = (int)v;
511} 411}
512 412
513/* PARTSTAT */ 413/* DELEGATED-TO */
514icalparameter* icalparameter_new_partstat(icalparameter_partstat v) 414icalparameter* icalparameter_new_delegatedto(const char* v)
515{ 415{
516 struct icalparameter_impl *impl; 416 struct icalparameter_impl *impl;
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) {
522 return 0; 421 return 0;
523 } 422 }
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) {
527 icalparameter_free((icalparameter*) impl); 426 icalparameter_free((icalparameter*) impl);
528 return 0; 427 return 0;
@@ -531,40 +430,71 @@ icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
531 return (icalparameter*) impl; 430 return (icalparameter*) impl;
532} 431}
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");
550 icalerror_clear_errno(); 480 icalerror_clear_errno();
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{
558 struct icalparameter_impl *impl; 488 struct icalparameter_impl *impl;
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) {
564 return 0; 494 return 0;
565 } 495 }
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) {
569 icalparameter_free((icalparameter*) impl); 499 icalparameter_free((icalparameter*) impl);
570 return 0; 500 return 0;
@@ -573,40 +503,40 @@ icalparameter* icalparameter_new_reltype(icalparameter_reltype v)
573 return (icalparameter*) impl; 503 return (icalparameter*) impl;
574} 504}
575 505
576icalparameter_reltype icalparameter_get_reltype(icalparameter* param) 506icalparameter_value icalparameter_get_value(const icalparameter* param)
577{ 507{
578 icalerror_clear_errno(); 508 icalerror_clear_errno();
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");
592 icalerror_clear_errno(); 522 icalerror_clear_errno();
593 523
594 ((struct icalparameter_impl*)param)->data = (int)v; 524 ((struct icalparameter_impl*)param)->data = (int)v;
595} 525}
596 526
597/* CUTYPE */ 527/* X-LIC-COMPARETYPE */
598icalparameter* icalparameter_new_cutype(icalparameter_cutype v) 528icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v)
599{ 529{
600 struct icalparameter_impl *impl; 530 struct icalparameter_impl *impl;
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) {
606 return 0; 536 return 0;
607 } 537 }
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) {
611 icalparameter_free((icalparameter*) impl); 541 icalparameter_free((icalparameter*) impl);
612 return 0; 542 return 0;
@@ -615,39 +545,36 @@ icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
615 return (icalparameter*) impl; 545 return (icalparameter*) impl;
616} 546}
617 547
618icalparameter_cutype icalparameter_get_cutype(icalparameter* param) 548icalparameter_xliccomparetype icalparameter_get_xliccomparetype(const icalparameter* param)
619{ 549{
620 icalerror_clear_errno(); 550 icalerror_clear_errno();
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");
634 icalerror_clear_errno(); 561 icalerror_clear_errno();
635 562
636 ((struct icalparameter_impl*)param)->data = (int)v; 563 ((struct icalparameter_impl*)param)->data = (int)v;
637} 564}
638 565
639/* MEMBER */ 566/* X */
640icalparameter* icalparameter_new_member(const char* v) 567icalparameter* icalparameter_new_x(const char* v)
641{ 568{
642 struct icalparameter_impl *impl; 569 struct icalparameter_impl *impl;
643 icalerror_clear_errno(); 570 icalerror_clear_errno();
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) {
647 return 0; 574 return 0;
648 } 575 }
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) {
652 icalparameter_free((icalparameter*) impl); 579 icalparameter_free((icalparameter*) impl);
653 return 0; 580 return 0;
@@ -656,14 +583,14 @@ icalparameter* icalparameter_new_member(const char* v)
656 return (icalparameter*) impl; 583 return (icalparameter*) impl;
657} 584}
658 585
659const char* icalparameter_get_member(icalparameter* param) 586const char* icalparameter_get_x(const icalparameter* param)
660{ 587{
661 icalerror_clear_errno(); 588 icalerror_clear_errno();
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{
668 icalerror_check_arg_rv( (v!=0),"v"); 595 icalerror_check_arg_rv( (v!=0),"v");
669 icalerror_check_arg_rv( (param!=0), "param"); 596 icalerror_check_arg_rv( (param!=0), "param");
@@ -672,18 +599,18 @@ void icalparameter_set_member(icalparameter* param, const char* v)
672 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 599 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
673} 600}
674 601
675/* FMTTYPE */ 602/* SENT-BY */
676icalparameter* icalparameter_new_fmttype(const char* v) 603icalparameter* icalparameter_new_sentby(const char* v)
677{ 604{
678 struct icalparameter_impl *impl; 605 struct icalparameter_impl *impl;
679 icalerror_clear_errno(); 606 icalerror_clear_errno();
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) {
683 return 0; 610 return 0;
684 } 611 }
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) {
688 icalparameter_free((icalparameter*) impl); 615 icalparameter_free((icalparameter*) impl);
689 return 0; 616 return 0;
@@ -692,14 +619,14 @@ icalparameter* icalparameter_new_fmttype(const char* v)
692 return (icalparameter*) impl; 619 return (icalparameter*) impl;
693} 620}
694 621
695const char* icalparameter_get_fmttype(icalparameter* param) 622const char* icalparameter_get_sentby(const icalparameter* param)
696{ 623{
697 icalerror_clear_errno(); 624 icalerror_clear_errno();
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{
704 icalerror_check_arg_rv( (v!=0),"v"); 631 icalerror_check_arg_rv( (v!=0),"v");
705 icalerror_check_arg_rv( (param!=0), "param"); 632 icalerror_check_arg_rv( (param!=0), "param");
@@ -708,18 +635,18 @@ void icalparameter_set_fmttype(icalparameter* param, const char* v)
708 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 635 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
709} 636}
710 637
711/* SENT-BY */ 638/* MEMBER */
712icalparameter* icalparameter_new_sentby(const char* v) 639icalparameter* icalparameter_new_member(const char* v)
713{ 640{
714 struct icalparameter_impl *impl; 641 struct icalparameter_impl *impl;
715 icalerror_clear_errno(); 642 icalerror_clear_errno();
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) {
719 return 0; 646 return 0;
720 } 647 }
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) {
724 icalparameter_free((icalparameter*) impl); 651 icalparameter_free((icalparameter*) impl);
725 return 0; 652 return 0;
@@ -728,14 +655,14 @@ icalparameter* icalparameter_new_sentby(const char* v)
728 return (icalparameter*) impl; 655 return (icalparameter*) impl;
729} 656}
730 657
731const char* icalparameter_get_sentby(icalparameter* param) 658const char* icalparameter_get_member(const icalparameter* param)
732{ 659{
733 icalerror_clear_errno(); 660 icalerror_clear_errno();
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{
740 icalerror_check_arg_rv( (v!=0),"v"); 667 icalerror_check_arg_rv( (v!=0),"v");
741 icalerror_check_arg_rv( (param!=0), "param"); 668 icalerror_check_arg_rv( (param!=0), "param");
@@ -744,19 +671,19 @@ void icalparameter_set_sentby(icalparameter* param, const char* v)
744 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 671 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
745} 672}
746 673
747/* VALUE */ 674/* RSVP */
748icalparameter* icalparameter_new_value(icalparameter_value v) 675icalparameter* icalparameter_new_rsvp(icalparameter_rsvp v)
749{ 676{
750 struct icalparameter_impl *impl; 677 struct icalparameter_impl *impl;
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) {
756 return 0; 683 return 0;
757 } 684 }
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) {
761 icalparameter_free((icalparameter*) impl); 688 icalparameter_free((icalparameter*) impl);
762 return 0; 689 return 0;
@@ -765,39 +692,37 @@ icalparameter* icalparameter_new_value(icalparameter_value v)
765 return (icalparameter*) impl; 692 return (icalparameter*) impl;
766} 693}
767 694
768icalparameter_value icalparameter_get_value(icalparameter* param) 695icalparameter_rsvp icalparameter_get_rsvp(const icalparameter* param)
769{ 696{
770 icalerror_clear_errno(); 697 icalerror_clear_errno();
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");
784 icalerror_clear_errno(); 708 icalerror_clear_errno();
785 709
786 ((struct icalparameter_impl*)param)->data = (int)v; 710 ((struct icalparameter_impl*)param)->data = (int)v;
787} 711}
788 712
789/* ALTREP */ 713/* CUTYPE */
790icalparameter* icalparameter_new_altrep(const char* v) 714icalparameter* icalparameter_new_cutype(icalparameter_cutype v)
791{ 715{
792 struct icalparameter_impl *impl; 716 struct icalparameter_impl *impl;
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) {
797 return 0; 722 return 0;
798 } 723 }
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) {
802 icalparameter_free((icalparameter*) impl); 727 icalparameter_free((icalparameter*) impl);
803 return 0; 728 return 0;
@@ -806,34 +731,40 @@ icalparameter* icalparameter_new_altrep(const char* v)
806 return (icalparameter*) impl; 731 return (icalparameter*) impl;
807} 732}
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");
820 icalerror_clear_errno(); 750 icalerror_clear_errno();
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{
828 struct icalparameter_impl *impl; 758 struct icalparameter_impl *impl;
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) {
833 return 0; 764 return 0;
834 } 765 }
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) {
838 icalparameter_free((icalparameter*) impl); 769 icalparameter_free((icalparameter*) impl);
839 return 0; 770 return 0;
@@ -842,20 +773,22 @@ icalparameter* icalparameter_new_dir(const char* v)
842 return (icalparameter*) impl; 773 return (icalparameter*) impl;
843} 774}
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");
856 icalerror_clear_errno(); 789 icalerror_clear_errno();
857 790
858 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 791 ((struct icalparameter_impl*)param)->data = (int)v;
859} 792}
860 793
861/* RELATED */ 794/* RELATED */
@@ -879,12 +812,12 @@ icalparameter* icalparameter_new_related(icalparameter_related v)
879 return (icalparameter*) impl; 812 return (icalparameter*) impl;
880} 813}
881 814
882icalparameter_related icalparameter_get_related(icalparameter* param) 815icalparameter_related icalparameter_get_related(const icalparameter* param)
883{ 816{
884 icalerror_clear_errno(); 817 icalerror_clear_errno();
885icalerror_check_arg( (param!=0), "param"); 818icalerror_check_arg( (param!=0), "param");
886 819
887return (icalparameter_related)((struct icalparameter_impl*)param)->data; 820return (icalparameter_related)(param->data);
888} 821}
889 822
890void icalparameter_set_related(icalparameter* param, icalparameter_related v) 823void icalparameter_set_related(icalparameter* param, icalparameter_related v)
@@ -897,18 +830,19 @@ void icalparameter_set_related(icalparameter* param, icalparameter_related v)
897 ((struct icalparameter_impl*)param)->data = (int)v; 830 ((struct icalparameter_impl*)param)->data = (int)v;
898} 831}
899 832
900/* CN */ 833/* ENCODING */
901icalparameter* icalparameter_new_cn(const char* v) 834icalparameter* icalparameter_new_encoding(icalparameter_encoding v)
902{ 835{
903 struct icalparameter_impl *impl; 836 struct icalparameter_impl *impl;
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) {
908 return 0; 842 return 0;
909 } 843 }
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) {
913 icalparameter_free((icalparameter*) impl); 847 icalparameter_free((icalparameter*) impl);
914 return 0; 848 return 0;
@@ -917,35 +851,39 @@ icalparameter* icalparameter_new_cn(const char* v)
917 return (icalparameter*) impl; 851 return (icalparameter*) impl;
918} 852}
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");
931 icalerror_clear_errno(); 870 icalerror_clear_errno();
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{
939 struct icalparameter_impl *impl; 878 struct icalparameter_impl *impl;
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) {
945 return 0; 883 return 0;
946 } 884 }
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) {
950 icalparameter_free((icalparameter*) impl); 888 icalparameter_free((icalparameter*) impl);
951 return 0; 889 return 0;
@@ -954,36 +892,34 @@ icalparameter* icalparameter_new_xlicerrortype(icalparameter_xlicerrortype v)
954 return (icalparameter*) impl; 892 return (icalparameter*) impl;
955} 893}
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");
970 icalerror_clear_errno(); 906 icalerror_clear_errno();
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{
978 struct icalparameter_impl *impl; 914 struct icalparameter_impl *impl;
979 icalerror_clear_errno(); 915 icalerror_clear_errno();
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) {
983 return 0; 919 return 0;
984 } 920 }
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) {
988 icalparameter_free((icalparameter*) impl); 924 icalparameter_free((icalparameter*) impl);
989 return 0; 925 return 0;
@@ -992,14 +928,14 @@ icalparameter* icalparameter_new_x(const char* v)
992 return (icalparameter*) impl; 928 return (icalparameter*) impl;
993} 929}
994 930
995const char* icalparameter_get_x(icalparameter* param) 931const char* icalparameter_get_delegatedfrom(const icalparameter* param)
996{ 932{
997 icalerror_clear_errno(); 933 icalerror_clear_errno();
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{
1004 icalerror_check_arg_rv( (v!=0),"v"); 940 icalerror_check_arg_rv( (v!=0),"v");
1005 icalerror_check_arg_rv( (param!=0), "param"); 941 icalerror_check_arg_rv( (param!=0), "param");
@@ -1008,18 +944,19 @@ void icalparameter_set_x(icalparameter* param, const char* v)
1008 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 944 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);
1009} 945}
1010 946
1011/* LANGUAGE */ 947/* FBTYPE */
1012icalparameter* icalparameter_new_language(const char* v) 948icalparameter* icalparameter_new_fbtype(icalparameter_fbtype v)
1013{ 949{
1014 struct icalparameter_impl *impl; 950 struct icalparameter_impl *impl;
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) {
1019 return 0; 956 return 0;
1020 } 957 }
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) {
1024 icalparameter_free((icalparameter*) impl); 961 icalparameter_free((icalparameter*) impl);
1025 return 0; 962 return 0;
@@ -1028,20 +965,25 @@ icalparameter* icalparameter_new_language(const char* v)
1028 return (icalparameter*) impl; 965 return (icalparameter*) impl;
1029} 966}
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");
1042 icalerror_clear_errno(); 984 icalerror_clear_errno();
1043 985
1044 ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v); 986 ((struct icalparameter_impl*)param)->data = (int)v;
1045} 987}
1046 988
1047/* ROLE */ 989/* ROLE */
@@ -1065,15 +1007,15 @@ icalparameter* icalparameter_new_role(icalparameter_role v)
1065 return (icalparameter*) impl; 1007 return (icalparameter*) impl;
1066} 1008}
1067 1009
1068icalparameter_role icalparameter_get_role(icalparameter* param) 1010icalparameter_role icalparameter_get_role(const icalparameter* param)
1069{ 1011{
1070 icalerror_clear_errno(); 1012 icalerror_clear_errno();
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;
1074 } 1016 }
1075 1017
1076return (icalparameter_role)((struct icalparameter_impl*)param)->data; 1018return (icalparameter_role)(param->data);
1077} 1019}
1078 1020
1079void icalparameter_set_role(icalparameter* param, icalparameter_role v) 1021void icalparameter_set_role(icalparameter* param, icalparameter_role v)
@@ -1086,19 +1028,19 @@ void icalparameter_set_role(icalparameter* param, icalparameter_role v)
1086 ((struct icalparameter_impl*)param)->data = (int)v; 1028 ((struct icalparameter_impl*)param)->data = (int)v;
1087} 1029}
1088 1030
1089/* X-LIC-COMPARETYPE */ 1031/* PARTSTAT */
1090icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v) 1032icalparameter* icalparameter_new_partstat(icalparameter_partstat v)
1091{ 1033{
1092 struct icalparameter_impl *impl; 1034 struct icalparameter_impl *impl;
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) {
1098 return 0; 1040 return 0;
1099 } 1041 }
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) {
1103 icalparameter_free((icalparameter*) impl); 1045 icalparameter_free((icalparameter*) impl);
1104 return 0; 1046 return 0;
@@ -1107,99 +1049,154 @@ icalparameter* icalparameter_new_xliccomparetype(icalparameter_xliccomparetype v
1107 return (icalparameter*) impl; 1049 return (icalparameter*) impl;
1108} 1050}
1109 1051
1110icalparameter_xliccomparetype icalparameter_get_xliccomparetype(icalparameter* param) 1052icalparameter_partstat icalparameter_get_partstat(const icalparameter* param)
1111{ 1053{
1112 icalerror_clear_errno(); 1054 icalerror_clear_errno();
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");
1123 icalerror_clear_errno(); 1068 icalerror_clear_errno();
1124 1069
1125 ((struct icalparameter_impl*)param)->data = (int)v; 1070 ((struct icalparameter_impl*)param)->data = (int)v;
1126} 1071}
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
@@ -30,12 +30,11 @@
30#define ICALDERIVEDPARAMETER_H 30#define ICALDERIVEDPARAMETER_H
31 31
32 32
33typedef void icalparameter; 33typedef struct icalparameter_impl icalparameter;
34 34
35const char* icalparameter_enum_to_string(int e); 35const char* icalparameter_enum_to_string(int e);
36int icalparameter_string_to_enum(const char* str); 36int 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 {
40 ICAL_ANY_PARAMETER = 0, 39 ICAL_ANY_PARAMETER = 0,
41 ICAL_ALTREP_PARAMETER, 40 ICAL_ALTREP_PARAMETER,
@@ -114,7 +113,7 @@ typedef enum icalparameter_range {
114typedef enum icalparameter_related { 113typedef enum icalparameter_related {
115 ICAL_RELATED_X = 20030, 114 ICAL_RELATED_X = 20030,
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
119} icalparameter_related; 118} icalparameter_related;
120 119
@@ -170,138 +169,142 @@ typedef enum icalparameter_xliccomparetype {
170 ICAL_XLICCOMPARETYPE_LESSEQUAL = 20070, 169 ICAL_XLICCOMPARETYPE_LESSEQUAL = 20070,
171 ICAL_XLICCOMPARETYPE_GREATEREQUAL = 20071, 170 ICAL_XLICCOMPARETYPE_GREATEREQUAL = 20071,
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;
175 176
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
221/* RELTYPE */ 203/* RELTYPE */
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
246/* VALUE */ 233/* VALUE */
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
271/* X-LIC-ERRORTYPE */ 268/* X-LIC-ERRORTYPE */
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
296/* FBTYPE */ 293/* FBTYPE */
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
306#endif /*ICALPARAMETER_H*/ 308#endif /*ICALPARAMETER_H*/
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
@@ -43,10 +43,9 @@
43#include <stdio.h> /* for printf */ 43#include <stdio.h> /* for printf */
44#include <stdarg.h> /* for va_list, va_start, etc. */ 44#include <stdarg.h> /* for va_list, va_start, etc. */
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
51/* This map associates the property kinds with the string 50/* This map associates the property kinds with the string
52 representation of the property name and the kind of VALUE that the 51 representation of the property name and the kind of VALUE that the
@@ -59,76 +58,6 @@ struct icalproperty_map {
59 58
60}; 59};
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
133 property that they are used in and the string representation of the 62 property that they are used in and the string representation of the
134 enumeration */ 63 enumeration */
@@ -139,127 +68,27 @@ struct icalproperty_enum_map {
139 const char* str; 68 const char* str;
140}; 69};
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},
254{ICAL_ATTACH_PROPERTY,"ATTACH",ICAL_ATTACH_VALUE}, 76{ICAL_ATTACH_PROPERTY,"ATTACH",ICAL_ATTACH_VALUE},
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},
260{ICAL_COMPLETED_PROPERTY,"COMPLETED",ICAL_DATETIME_VALUE}, 85{ICAL_COMPLETED_PROPERTY,"COMPLETED",ICAL_DATETIME_VALUE},
261{ICAL_CONTACT_PROPERTY,"CONTACT",ICAL_TEXT_VALUE}, 86{ICAL_CONTACT_PROPERTY,"CONTACT",ICAL_TEXT_VALUE},
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},
264{ICAL_DTEND_PROPERTY,"DTEND",ICAL_DATETIME_VALUE}, 93{ICAL_DTEND_PROPERTY,"DTEND",ICAL_DATETIME_VALUE},
265{ICAL_DTSTAMP_PROPERTY,"DTSTAMP",ICAL_DATETIME_VALUE}, 94{ICAL_DTSTAMP_PROPERTY,"DTSTAMP",ICAL_DATETIME_VALUE},
@@ -267,6 +96,7 @@ static struct icalproperty_map property_map[] = {
267{ICAL_DUE_PROPERTY,"DUE",ICAL_DATETIME_VALUE}, 96{ICAL_DUE_PROPERTY,"DUE",ICAL_DATETIME_VALUE},
268{ICAL_DURATION_PROPERTY,"DURATION",ICAL_DURATION_VALUE}, 97{ICAL_DURATION_PROPERTY,"DURATION",ICAL_DURATION_VALUE},
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},
271{ICAL_FREEBUSY_PROPERTY,"FREEBUSY",ICAL_PERIOD_VALUE}, 101{ICAL_FREEBUSY_PROPERTY,"FREEBUSY",ICAL_PERIOD_VALUE},
272{ICAL_GEO_PROPERTY,"GEO",ICAL_GEO_VALUE}, 102{ICAL_GEO_PROPERTY,"GEO",ICAL_GEO_VALUE},
@@ -276,6 +106,7 @@ static struct icalproperty_map property_map[] = {
276{ICAL_MAXRESULTSSIZE_PROPERTY,"MAXRESULTSSIZE",ICAL_INTEGER_VALUE}, 106{ICAL_MAXRESULTSSIZE_PROPERTY,"MAXRESULTSSIZE",ICAL_INTEGER_VALUE},
277{ICAL_METHOD_PROPERTY,"METHOD",ICAL_METHOD_VALUE}, 107{ICAL_METHOD_PROPERTY,"METHOD",ICAL_METHOD_VALUE},
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},
280{ICAL_PRIORITY_PROPERTY,"PRIORITY",ICAL_INTEGER_VALUE}, 111{ICAL_PRIORITY_PROPERTY,"PRIORITY",ICAL_INTEGER_VALUE},
281{ICAL_PRODID_PROPERTY,"PRODID",ICAL_TEXT_VALUE}, 112{ICAL_PRODID_PROPERTY,"PRODID",ICAL_TEXT_VALUE},
@@ -284,6 +115,7 @@ static struct icalproperty_map property_map[] = {
284{ICAL_RDATE_PROPERTY,"RDATE",ICAL_DATETIMEPERIOD_VALUE}, 115{ICAL_RDATE_PROPERTY,"RDATE",ICAL_DATETIMEPERIOD_VALUE},
285{ICAL_RECURRENCEID_PROPERTY,"RECURRENCE-ID",ICAL_DATETIME_VALUE}, 116{ICAL_RECURRENCEID_PROPERTY,"RECURRENCE-ID",ICAL_DATETIME_VALUE},
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},
288{ICAL_REQUESTSTATUS_PROPERTY,"REQUEST-STATUS",ICAL_REQUESTSTATUS_VALUE}, 120{ICAL_REQUESTSTATUS_PROPERTY,"REQUEST-STATUS",ICAL_REQUESTSTATUS_VALUE},
289{ICAL_RESOURCES_PROPERTY,"RESOURCES",ICAL_TEXT_VALUE}, 121{ICAL_RESOURCES_PROPERTY,"RESOURCES",ICAL_TEXT_VALUE},
@@ -293,7 +125,7 @@ static struct icalproperty_map property_map[] = {
293{ICAL_STATUS_PROPERTY,"STATUS",ICAL_STATUS_VALUE}, 125{ICAL_STATUS_PROPERTY,"STATUS",ICAL_STATUS_VALUE},
294{ICAL_SUMMARY_PROPERTY,"SUMMARY",ICAL_TEXT_VALUE}, 126{ICAL_SUMMARY_PROPERTY,"SUMMARY",ICAL_TEXT_VALUE},
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},
298{ICAL_TZID_PROPERTY,"TZID",ICAL_TEXT_VALUE}, 130{ICAL_TZID_PROPERTY,"TZID",ICAL_TEXT_VALUE},
299{ICAL_TZNAME_PROPERTY,"TZNAME",ICAL_TEXT_VALUE}, 131{ICAL_TZNAME_PROPERTY,"TZNAME",ICAL_TEXT_VALUE},
@@ -303,7 +135,8 @@ static struct icalproperty_map property_map[] = {
303{ICAL_UID_PROPERTY,"UID",ICAL_TEXT_VALUE}, 135{ICAL_UID_PROPERTY,"UID",ICAL_TEXT_VALUE},
304{ICAL_URL_PROPERTY,"URL",ICAL_URI_VALUE}, 136{ICAL_URL_PROPERTY,"URL",ICAL_URI_VALUE},
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},
308{ICAL_XLICERROR_PROPERTY,"X-LIC-ERROR",ICAL_TEXT_VALUE}, 141{ICAL_XLICERROR_PROPERTY,"X-LIC-ERROR",ICAL_TEXT_VALUE},
309{ICAL_XLICMIMECHARSET_PROPERTY,"X-LIC-MIMECHARSET",ICAL_STRING_VALUE}, 142{ICAL_XLICMIMECHARSET_PROPERTY,"X-LIC-MIMECHARSET",ICAL_STRING_VALUE},
@@ -314,7 +147,7 @@ static struct icalproperty_map property_map[] = {
314{ICAL_XLICMIMEOPTINFO_PROPERTY,"X-LIC-MIMEOPTINFO",ICAL_STRING_VALUE}, 147{ICAL_XLICMIMEOPTINFO_PROPERTY,"X-LIC-MIMEOPTINFO",ICAL_STRING_VALUE},
315{ICAL_NO_PROPERTY,"",ICAL_NO_VALUE}}; 148{ICAL_NO_PROPERTY,"",ICAL_NO_VALUE}};
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*/
319 {ICAL_ACTION_PROPERTY,ICAL_ACTION_AUDIO,"AUDIO" }, /*10001*/ 152 {ICAL_ACTION_PROPERTY,ICAL_ACTION_AUDIO,"AUDIO" }, /*10001*/
320 {ICAL_ACTION_PROPERTY,ICAL_ACTION_DISPLAY,"DISPLAY" }, /*10002*/ 153 {ICAL_ACTION_PROPERTY,ICAL_ACTION_DISPLAY,"DISPLAY" }, /*10002*/
@@ -355,8 +188,39 @@ static struct icalproperty_enum_map enum_map[] = {
355 {ICAL_STATUS_PROPERTY,ICAL_STATUS_NONE,"" }, /*10037*/ 188 {ICAL_STATUS_PROPERTY,ICAL_STATUS_NONE,"" }, /*10037*/
356 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_X,"" }, /*10038*/ 189 {ICAL_TRANSP_PROPERTY,ICAL_TRANSP_X,"" }, /*10038*/
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,""}
361}; 225};
362 226
@@ -369,6 +233,7 @@ icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...){
369 va_end(args); 233 va_end(args);
370 return (icalproperty*)impl; 234 return (icalproperty*)impl;
371} 235}
236
372/* ACTION */ 237/* ACTION */
373icalproperty* icalproperty_new_action(enum icalproperty_action v) { 238icalproperty* icalproperty_new_action(enum icalproperty_action v) {
374 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ACTION_PROPERTY); 239 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ACTION_PROPERTY);
@@ -381,11 +246,40 @@ void icalproperty_set_action(icalproperty* prop, enum icalproperty_action v){
381 icalerror_check_arg_rv( (prop!=0),"prop"); 246 icalerror_check_arg_rv( (prop!=0),"prop");
382 icalproperty_set_value(prop,icalvalue_new_action(v)); 247 icalproperty_set_value(prop,icalvalue_new_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");
386 return icalvalue_get_action(icalproperty_get_value(prop)); 251 return icalvalue_get_action(icalproperty_get_value(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;
390 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 284 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTACH_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
391 285
@@ -395,21 +289,22 @@ icalproperty* icalproperty_vanew_attach(struct icalattachtype* v, ...){
395 va_end(args); 289 va_end(args);
396 return (icalproperty*)impl; 290 return (icalproperty*)impl;
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");
401 296
402 icalproperty_set_attach((icalproperty*)impl,v); 297 icalproperty_set_attach((icalproperty*)impl,v);
403 return (icalproperty*)impl; 298 return (icalproperty*)impl;
404} 299}
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");
408 303
409 icalerror_check_arg_rv( (prop!=0),"prop"); 304 icalerror_check_arg_rv( (prop!=0),"prop");
410 icalproperty_set_value(prop,icalvalue_new_attach(v)); 305 icalproperty_set_value(prop,icalvalue_new_attach(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");
414 return icalvalue_get_attach(icalproperty_get_value(prop)); 309 return icalvalue_get_attach(icalproperty_get_value(prop));
415} 310}
@@ -423,6 +318,7 @@ icalproperty* icalproperty_vanew_attendee(const char* v, ...){
423 va_end(args); 318 va_end(args);
424 return (icalproperty*)impl; 319 return (icalproperty*)impl;
425} 320}
321
426/* ATTENDEE */ 322/* ATTENDEE */
427icalproperty* icalproperty_new_attendee(const char* v) { 323icalproperty* icalproperty_new_attendee(const char* v) {
428 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTENDEE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 324 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ATTENDEE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -437,10 +333,68 @@ void icalproperty_set_attendee(icalproperty* prop, const char* v){
437 icalerror_check_arg_rv( (prop!=0),"prop"); 333 icalerror_check_arg_rv( (prop!=0),"prop");
438 icalproperty_set_value(prop,icalvalue_new_caladdress(v)); 334 icalproperty_set_value(prop,icalvalue_new_caladdress(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");
442 return icalvalue_get_caladdress(icalproperty_get_value(prop)); 338 return icalvalue_get_caladdress(icalproperty_get_value(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, ...){
445 va_list args; 399 va_list args;
446 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALSCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 400 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALSCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -451,6 +405,7 @@ icalproperty* icalproperty_vanew_calscale(const char* v, ...){
451 va_end(args); 405 va_end(args);
452 return (icalproperty*)impl; 406 return (icalproperty*)impl;
453} 407}
408
454/* CALSCALE */ 409/* CALSCALE */
455icalproperty* icalproperty_new_calscale(const char* v) { 410icalproperty* icalproperty_new_calscale(const char* v) {
456 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALSCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 411 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CALSCALE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -465,7 +420,36 @@ void icalproperty_set_calscale(icalproperty* prop, const char* v){
465 icalerror_check_arg_rv( (prop!=0),"prop"); 420 icalerror_check_arg_rv( (prop!=0),"prop");
466 icalproperty_set_value(prop,icalvalue_new_text(v)); 421 icalproperty_set_value(prop,icalvalue_new_text(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");
470 return icalvalue_get_text(icalproperty_get_value(prop)); 454 return icalvalue_get_text(icalproperty_get_value(prop));
471} 455}
@@ -479,6 +463,7 @@ icalproperty* icalproperty_vanew_categories(const char* v, ...){
479 va_end(args); 463 va_end(args);
480 return (icalproperty*)impl; 464 return (icalproperty*)impl;
481} 465}
466
482/* CATEGORIES */ 467/* CATEGORIES */
483icalproperty* icalproperty_new_categories(const char* v) { 468icalproperty* icalproperty_new_categories(const char* v) {
484 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CATEGORIES_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 469 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CATEGORIES_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -493,37 +478,35 @@ void icalproperty_set_categories(icalproperty* prop, const char* v){
493 icalerror_check_arg_rv( (prop!=0),"prop"); 478 icalerror_check_arg_rv( (prop!=0),"prop");
494 icalproperty_set_value(prop,icalvalue_new_text(v)); 479 icalproperty_set_value(prop,icalvalue_new_text(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");
498 return icalvalue_get_text(icalproperty_get_value(prop)); 483 return icalvalue_get_text(icalproperty_get_value(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);
505 va_start(args,v); 489 va_start(args,v);
506 icalproperty_add_parameters(impl, args); 490 icalproperty_add_parameters(impl, args);
507 va_end(args); 491 va_end(args);
508 return (icalproperty*)impl; 492 return (icalproperty*)impl;
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);
515 return (icalproperty*)impl; 499 return (icalproperty*)impl;
516} 500}
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}
528icalproperty* icalproperty_vanew_comment(const char* v, ...){ 511icalproperty* icalproperty_vanew_comment(const char* v, ...){
529 va_list args; 512 va_list args;
@@ -535,6 +518,7 @@ icalproperty* icalproperty_vanew_comment(const char* v, ...){
535 va_end(args); 518 va_end(args);
536 return (icalproperty*)impl; 519 return (icalproperty*)impl;
537} 520}
521
538/* COMMENT */ 522/* COMMENT */
539icalproperty* icalproperty_new_comment(const char* v) { 523icalproperty* icalproperty_new_comment(const char* v) {
540 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_COMMENT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 524 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_COMMENT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -549,7 +533,7 @@ void icalproperty_set_comment(icalproperty* prop, const char* v){
549 icalerror_check_arg_rv( (prop!=0),"prop"); 533 icalerror_check_arg_rv( (prop!=0),"prop");
550 icalproperty_set_value(prop,icalvalue_new_text(v)); 534 icalproperty_set_value(prop,icalvalue_new_text(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");
554 return icalvalue_get_text(icalproperty_get_value(prop)); 538 return icalvalue_get_text(icalproperty_get_value(prop));
555} 539}
@@ -562,6 +546,7 @@ icalproperty* icalproperty_vanew_completed(struct icaltimetype v, ...){
562 va_end(args); 546 va_end(args);
563 return (icalproperty*)impl; 547 return (icalproperty*)impl;
564} 548}
549
565/* COMPLETED */ 550/* COMPLETED */
566icalproperty* icalproperty_new_completed(struct icaltimetype v) { 551icalproperty* icalproperty_new_completed(struct icaltimetype v) {
567 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_COMPLETED_PROPERTY); 552 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_COMPLETED_PROPERTY);
@@ -574,7 +559,7 @@ void icalproperty_set_completed(icalproperty* prop, struct icaltimetype v){
574 icalerror_check_arg_rv( (prop!=0),"prop"); 559 icalerror_check_arg_rv( (prop!=0),"prop");
575 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 560 icalproperty_set_value(prop,icalvalue_new_datetime(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");
579 return icalvalue_get_datetime(icalproperty_get_value(prop)); 564 return icalvalue_get_datetime(icalproperty_get_value(prop));
580} 565}
@@ -588,6 +573,7 @@ icalproperty* icalproperty_vanew_contact(const char* v, ...){
588 va_end(args); 573 va_end(args);
589 return (icalproperty*)impl; 574 return (icalproperty*)impl;
590} 575}
576
591/* CONTACT */ 577/* CONTACT */
592icalproperty* icalproperty_new_contact(const char* v) { 578icalproperty* icalproperty_new_contact(const char* v) {
593 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CONTACT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 579 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CONTACT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -602,7 +588,7 @@ void icalproperty_set_contact(icalproperty* prop, const char* v){
602 icalerror_check_arg_rv( (prop!=0),"prop"); 588 icalerror_check_arg_rv( (prop!=0),"prop");
603 icalproperty_set_value(prop,icalvalue_new_text(v)); 589 icalproperty_set_value(prop,icalvalue_new_text(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");
607 return icalvalue_get_text(icalproperty_get_value(prop)); 593 return icalvalue_get_text(icalproperty_get_value(prop));
608} 594}
@@ -615,6 +601,7 @@ icalproperty* icalproperty_vanew_created(struct icaltimetype v, ...){
615 va_end(args); 601 va_end(args);
616 return (icalproperty*)impl; 602 return (icalproperty*)impl;
617} 603}
604
618/* CREATED */ 605/* CREATED */
619icalproperty* icalproperty_new_created(struct icaltimetype v) { 606icalproperty* icalproperty_new_created(struct icaltimetype v) {
620 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CREATED_PROPERTY); 607 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_CREATED_PROPERTY);
@@ -627,10 +614,126 @@ void icalproperty_set_created(icalproperty* prop, struct icaltimetype v){
627 icalerror_check_arg_rv( (prop!=0),"prop"); 614 icalerror_check_arg_rv( (prop!=0),"prop");
628 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 615 icalproperty_set_value(prop,icalvalue_new_datetime(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");
632 return icalvalue_get_datetime(icalproperty_get_value(prop)); 619 return icalvalue_get_datetime(icalproperty_get_value(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, ...){
635 va_list args; 738 va_list args;
636 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DESCRIPTION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 739 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DESCRIPTION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -641,6 +744,7 @@ icalproperty* icalproperty_vanew_description(const char* v, ...){
641 va_end(args); 744 va_end(args);
642 return (icalproperty*)impl; 745 return (icalproperty*)impl;
643} 746}
747
644/* DESCRIPTION */ 748/* DESCRIPTION */
645icalproperty* icalproperty_new_description(const char* v) { 749icalproperty* icalproperty_new_description(const char* v) {
646 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DESCRIPTION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 750 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DESCRIPTION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -655,7 +759,7 @@ void icalproperty_set_description(icalproperty* prop, const char* v){
655 icalerror_check_arg_rv( (prop!=0),"prop"); 759 icalerror_check_arg_rv( (prop!=0),"prop");
656 icalproperty_set_value(prop,icalvalue_new_text(v)); 760 icalproperty_set_value(prop,icalvalue_new_text(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");
660 return icalvalue_get_text(icalproperty_get_value(prop)); 764 return icalvalue_get_text(icalproperty_get_value(prop));
661} 765}
@@ -668,6 +772,7 @@ icalproperty* icalproperty_vanew_dtend(struct icaltimetype v, ...){
668 va_end(args); 772 va_end(args);
669 return (icalproperty*)impl; 773 return (icalproperty*)impl;
670} 774}
775
671/* DTEND */ 776/* DTEND */
672icalproperty* icalproperty_new_dtend(struct icaltimetype v) { 777icalproperty* icalproperty_new_dtend(struct icaltimetype v) {
673 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTEND_PROPERTY); 778 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTEND_PROPERTY);
@@ -676,11 +781,16 @@ icalproperty* icalproperty_new_dtend(struct icaltimetype v) {
676} 781}
677 782
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");
685 return icalvalue_get_datetime(icalproperty_get_value(prop)); 795 return icalvalue_get_datetime(icalproperty_get_value(prop));
686} 796}
@@ -693,6 +803,7 @@ icalproperty* icalproperty_vanew_dtstamp(struct icaltimetype v, ...){
693 va_end(args); 803 va_end(args);
694 return (icalproperty*)impl; 804 return (icalproperty*)impl;
695} 805}
806
696/* DTSTAMP */ 807/* DTSTAMP */
697icalproperty* icalproperty_new_dtstamp(struct icaltimetype v) { 808icalproperty* icalproperty_new_dtstamp(struct icaltimetype v) {
698 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTSTAMP_PROPERTY); 809 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTSTAMP_PROPERTY);
@@ -705,7 +816,7 @@ void icalproperty_set_dtstamp(icalproperty* prop, struct icaltimetype v){
705 icalerror_check_arg_rv( (prop!=0),"prop"); 816 icalerror_check_arg_rv( (prop!=0),"prop");
706 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 817 icalproperty_set_value(prop,icalvalue_new_datetime(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");
710 return icalvalue_get_datetime(icalproperty_get_value(prop)); 821 return icalvalue_get_datetime(icalproperty_get_value(prop));
711} 822}
@@ -718,6 +829,7 @@ icalproperty* icalproperty_vanew_dtstart(struct icaltimetype v, ...){
718 va_end(args); 829 va_end(args);
719 return (icalproperty*)impl; 830 return (icalproperty*)impl;
720} 831}
832
721/* DTSTART */ 833/* DTSTART */
722icalproperty* icalproperty_new_dtstart(struct icaltimetype v) { 834icalproperty* icalproperty_new_dtstart(struct icaltimetype v) {
723 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTSTART_PROPERTY); 835 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DTSTART_PROPERTY);
@@ -726,11 +838,16 @@ icalproperty* icalproperty_new_dtstart(struct icaltimetype v) {
726} 838}
727 839
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");
735 return icalvalue_get_datetime(icalproperty_get_value(prop)); 852 return icalvalue_get_datetime(icalproperty_get_value(prop));
736} 853}
@@ -743,6 +860,7 @@ icalproperty* icalproperty_vanew_due(struct icaltimetype v, ...){
743 va_end(args); 860 va_end(args);
744 return (icalproperty*)impl; 861 return (icalproperty*)impl;
745} 862}
863
746/* DUE */ 864/* DUE */
747icalproperty* icalproperty_new_due(struct icaltimetype v) { 865icalproperty* icalproperty_new_due(struct icaltimetype v) {
748 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DUE_PROPERTY); 866 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DUE_PROPERTY);
@@ -751,11 +869,16 @@ icalproperty* icalproperty_new_due(struct icaltimetype v) {
751} 869}
752 870
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");
760 return icalvalue_get_datetime(icalproperty_get_value(prop)); 883 return icalvalue_get_datetime(icalproperty_get_value(prop));
761} 884}
@@ -768,6 +891,7 @@ icalproperty* icalproperty_vanew_duration(struct icaldurationtype v, ...){
768 va_end(args); 891 va_end(args);
769 return (icalproperty*)impl; 892 return (icalproperty*)impl;
770} 893}
894
771/* DURATION */ 895/* DURATION */
772icalproperty* icalproperty_new_duration(struct icaldurationtype v) { 896icalproperty* icalproperty_new_duration(struct icaldurationtype v) {
773 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DURATION_PROPERTY); 897 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_DURATION_PROPERTY);
@@ -780,7 +904,7 @@ void icalproperty_set_duration(icalproperty* prop, struct icaldurationtype v){
780 icalerror_check_arg_rv( (prop!=0),"prop"); 904 icalerror_check_arg_rv( (prop!=0),"prop");
781 icalproperty_set_value(prop,icalvalue_new_duration(v)); 905 icalproperty_set_value(prop,icalvalue_new_duration(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");
785 return icalvalue_get_duration(icalproperty_get_value(prop)); 909 return icalvalue_get_duration(icalproperty_get_value(prop));
786} 910}
@@ -793,6 +917,7 @@ icalproperty* icalproperty_vanew_exdate(struct icaltimetype v, ...){
793 va_end(args); 917 va_end(args);
794 return (icalproperty*)impl; 918 return (icalproperty*)impl;
795} 919}
920
796/* EXDATE */ 921/* EXDATE */
797icalproperty* icalproperty_new_exdate(struct icaltimetype v) { 922icalproperty* icalproperty_new_exdate(struct icaltimetype v) {
798 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXDATE_PROPERTY); 923 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXDATE_PROPERTY);
@@ -801,14 +926,45 @@ icalproperty* icalproperty_new_exdate(struct icaltimetype v) {
801} 926}
802 927
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");
810 return icalvalue_get_datetime(icalproperty_get_value(prop)); 940 return icalvalue_get_datetime(icalproperty_get_value(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, ...){
813 va_list args; 969 va_list args;
814 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXRULE_PROPERTY); 970 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXRULE_PROPERTY);
@@ -818,6 +974,7 @@ icalproperty* icalproperty_vanew_exrule(struct icalrecurrencetype v, ...){
818 va_end(args); 974 va_end(args);
819 return (icalproperty*)impl; 975 return (icalproperty*)impl;
820} 976}
977
821/* EXRULE */ 978/* EXRULE */
822icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v) { 979icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v) {
823 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXRULE_PROPERTY); 980 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_EXRULE_PROPERTY);
@@ -830,7 +987,7 @@ void icalproperty_set_exrule(icalproperty* prop, struct icalrecurrencetype v){
830 icalerror_check_arg_rv( (prop!=0),"prop"); 987 icalerror_check_arg_rv( (prop!=0),"prop");
831 icalproperty_set_value(prop,icalvalue_new_recur(v)); 988 icalproperty_set_value(prop,icalvalue_new_recur(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");
835 return icalvalue_get_recur(icalproperty_get_value(prop)); 992 return icalvalue_get_recur(icalproperty_get_value(prop));
836} 993}
@@ -843,6 +1000,7 @@ icalproperty* icalproperty_vanew_freebusy(struct icalperiodtype v, ...){
843 va_end(args); 1000 va_end(args);
844 return (icalproperty*)impl; 1001 return (icalproperty*)impl;
845} 1002}
1003
846/* FREEBUSY */ 1004/* FREEBUSY */
847icalproperty* icalproperty_new_freebusy(struct icalperiodtype v) { 1005icalproperty* icalproperty_new_freebusy(struct icalperiodtype v) {
848 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_FREEBUSY_PROPERTY); 1006 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_FREEBUSY_PROPERTY);
@@ -855,7 +1013,7 @@ void icalproperty_set_freebusy(icalproperty* prop, struct icalperiodtype v){
855 icalerror_check_arg_rv( (prop!=0),"prop"); 1013 icalerror_check_arg_rv( (prop!=0),"prop");
856 icalproperty_set_value(prop,icalvalue_new_period(v)); 1014 icalproperty_set_value(prop,icalvalue_new_period(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");
860 return icalvalue_get_period(icalproperty_get_value(prop)); 1018 return icalvalue_get_period(icalproperty_get_value(prop));
861} 1019}
@@ -868,6 +1026,7 @@ icalproperty* icalproperty_vanew_geo(struct icalgeotype v, ...){
868 va_end(args); 1026 va_end(args);
869 return (icalproperty*)impl; 1027 return (icalproperty*)impl;
870} 1028}
1029
871/* GEO */ 1030/* GEO */
872icalproperty* icalproperty_new_geo(struct icalgeotype v) { 1031icalproperty* icalproperty_new_geo(struct icalgeotype v) {
873 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_GEO_PROPERTY); 1032 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_GEO_PROPERTY);
@@ -880,7 +1039,7 @@ void icalproperty_set_geo(icalproperty* prop, struct icalgeotype v){
880 icalerror_check_arg_rv( (prop!=0),"prop"); 1039 icalerror_check_arg_rv( (prop!=0),"prop");
881 icalproperty_set_value(prop,icalvalue_new_geo(v)); 1040 icalproperty_set_value(prop,icalvalue_new_geo(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");
885 return icalvalue_get_geo(icalproperty_get_value(prop)); 1044 return icalvalue_get_geo(icalproperty_get_value(prop));
886} 1045}
@@ -893,6 +1052,7 @@ icalproperty* icalproperty_vanew_lastmodified(struct icaltimetype v, ...){
893 va_end(args); 1052 va_end(args);
894 return (icalproperty*)impl; 1053 return (icalproperty*)impl;
895} 1054}
1055
896/* LAST-MODIFIED */ 1056/* LAST-MODIFIED */
897icalproperty* icalproperty_new_lastmodified(struct icaltimetype v) { 1057icalproperty* icalproperty_new_lastmodified(struct icaltimetype v) {
898 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_LASTMODIFIED_PROPERTY); 1058 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_LASTMODIFIED_PROPERTY);
@@ -905,7 +1065,7 @@ void icalproperty_set_lastmodified(icalproperty* prop, struct icaltimetype v){
905 icalerror_check_arg_rv( (prop!=0),"prop"); 1065 icalerror_check_arg_rv( (prop!=0),"prop");
906 icalproperty_set_value(prop,icalvalue_new_datetime(v)); 1066 icalproperty_set_value(prop,icalvalue_new_datetime(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");
910 return icalvalue_get_datetime(icalproperty_get_value(prop)); 1070 return icalvalue_get_datetime(icalproperty_get_value(prop));
911} 1071}
@@ -919,6 +1079,7 @@ icalproperty* icalproperty_vanew_location(const char* v, ...){
919 va_end(args); 1079 va_end(args);
920 return (icalproperty*)impl; 1080 return (icalproperty*)impl;
921} 1081}
1082
922/* LOCATION */ 1083/* LOCATION */
923icalproperty* icalproperty_new_location(const char* v) { 1084icalproperty* icalproperty_new_location(const char* v) {
924 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_LOCATION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1085 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_LOCATION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -933,7 +1094,7 @@ void icalproperty_set_location(icalproperty* prop, const char* v){
933 icalerror_check_arg_rv( (prop!=0),"prop"); 1094 icalerror_check_arg_rv( (prop!=0),"prop");
934 icalproperty_set_value(prop,icalvalue_new_text(v)); 1095 icalproperty_set_value(prop,icalvalue_new_text(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");
938 return icalvalue_get_text(icalproperty_get_value(prop)); 1099 return icalvalue_get_text(icalproperty_get_value(prop));
939} 1100}
@@ -946,6 +1107,7 @@ icalproperty* icalproperty_vanew_maxresults(int v, ...){
946 va_end(args); 1107 va_end(args);
947 return (icalproperty*)impl; 1108 return (icalproperty*)impl;
948} 1109}
1110
949/* MAXRESULTS */ 1111/* MAXRESULTS */
950icalproperty* icalproperty_new_maxresults(int v) { 1112icalproperty* icalproperty_new_maxresults(int v) {
951 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_MAXRESULTS_PROPERTY); 1113 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_MAXRESULTS_PROPERTY);
@@ -958,7 +1120,7 @@ void icalproperty_set_maxresults(icalproperty* prop, int v){
958 icalerror_check_arg_rv( (prop!=0),"prop"); 1120 icalerror_check_arg_rv( (prop!=0),"prop");
959 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1121 icalproperty_set_value(prop,icalvalue_new_integer(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");
963 return icalvalue_get_integer(icalproperty_get_value(prop)); 1125 return icalvalue_get_integer(icalproperty_get_value(prop));
964} 1126}
@@ -971,6 +1133,7 @@ icalproperty* icalproperty_vanew_maxresultssize(int v, ...){
971 va_end(args); 1133 va_end(args);
972 return (icalproperty*)impl; 1134 return (icalproperty*)impl;
973} 1135}
1136
974/* MAXRESULTSSIZE */ 1137/* MAXRESULTSSIZE */
975icalproperty* icalproperty_new_maxresultssize(int v) { 1138icalproperty* icalproperty_new_maxresultssize(int v) {
976 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_MAXRESULTSSIZE_PROPERTY); 1139 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_MAXRESULTSSIZE_PROPERTY);
@@ -983,7 +1146,7 @@ void icalproperty_set_maxresultssize(icalproperty* prop, int v){
983 icalerror_check_arg_rv( (prop!=0),"prop"); 1146 icalerror_check_arg_rv( (prop!=0),"prop");
984 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1147 icalproperty_set_value(prop,icalvalue_new_integer(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");
988 return icalvalue_get_integer(icalproperty_get_value(prop)); 1151 return icalvalue_get_integer(icalproperty_get_value(prop));
989} 1152}
@@ -996,6 +1159,7 @@ icalproperty* icalproperty_vanew_method(enum icalproperty_method v, ...){
996 va_end(args); 1159 va_end(args);
997 return (icalproperty*)impl; 1160 return (icalproperty*)impl;
998} 1161}
1162
999/* METHOD */ 1163/* METHOD */
1000icalproperty* icalproperty_new_method(enum icalproperty_method v) { 1164icalproperty* icalproperty_new_method(enum icalproperty_method v) {
1001 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_METHOD_PROPERTY); 1165 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_METHOD_PROPERTY);
@@ -1008,7 +1172,7 @@ void icalproperty_set_method(icalproperty* prop, enum icalproperty_method v){
1008 icalerror_check_arg_rv( (prop!=0),"prop"); 1172 icalerror_check_arg_rv( (prop!=0),"prop");
1009 icalproperty_set_value(prop,icalvalue_new_method(v)); 1173 icalproperty_set_value(prop,icalvalue_new_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");
1013 return icalvalue_get_method(icalproperty_get_value(prop)); 1177 return icalvalue_get_method(icalproperty_get_value(prop));
1014} 1178}
@@ -1022,6 +1186,7 @@ icalproperty* icalproperty_vanew_organizer(const char* v, ...){
1022 va_end(args); 1186 va_end(args);
1023 return (icalproperty*)impl; 1187 return (icalproperty*)impl;
1024} 1188}
1189
1025/* ORGANIZER */ 1190/* ORGANIZER */
1026icalproperty* icalproperty_new_organizer(const char* v) { 1191icalproperty* icalproperty_new_organizer(const char* v) {
1027 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ORGANIZER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1192 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_ORGANIZER_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1036,10 +1201,39 @@ void icalproperty_set_organizer(icalproperty* prop, const char* v){
1036 icalerror_check_arg_rv( (prop!=0),"prop"); 1201 icalerror_check_arg_rv( (prop!=0),"prop");
1037 icalproperty_set_value(prop,icalvalue_new_caladdress(v)); 1202 icalproperty_set_value(prop,icalvalue_new_caladdress(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");
1041 return icalvalue_get_caladdress(icalproperty_get_value(prop)); 1206 return icalvalue_get_caladdress(icalproperty_get_value(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, ...){
1044 va_list args; 1238 va_list args;
1045 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PERCENTCOMPLETE_PROPERTY); 1239 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PERCENTCOMPLETE_PROPERTY);
@@ -1049,6 +1243,7 @@ icalproperty* icalproperty_vanew_percentcomplete(int v, ...){
1049 va_end(args); 1243 va_end(args);
1050 return (icalproperty*)impl; 1244 return (icalproperty*)impl;
1051} 1245}
1246
1052/* PERCENT-COMPLETE */ 1247/* PERCENT-COMPLETE */
1053icalproperty* icalproperty_new_percentcomplete(int v) { 1248icalproperty* icalproperty_new_percentcomplete(int v) {
1054 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PERCENTCOMPLETE_PROPERTY); 1249 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PERCENTCOMPLETE_PROPERTY);
@@ -1061,7 +1256,7 @@ void icalproperty_set_percentcomplete(icalproperty* prop, int v){
1061 icalerror_check_arg_rv( (prop!=0),"prop"); 1256 icalerror_check_arg_rv( (prop!=0),"prop");
1062 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1257 icalproperty_set_value(prop,icalvalue_new_integer(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");
1066 return icalvalue_get_integer(icalproperty_get_value(prop)); 1261 return icalvalue_get_integer(icalproperty_get_value(prop));
1067} 1262}
@@ -1074,6 +1269,7 @@ icalproperty* icalproperty_vanew_priority(int v, ...){
1074 va_end(args); 1269 va_end(args);
1075 return (icalproperty*)impl; 1270 return (icalproperty*)impl;
1076} 1271}
1272
1077/* PRIORITY */ 1273/* PRIORITY */
1078icalproperty* icalproperty_new_priority(int v) { 1274icalproperty* icalproperty_new_priority(int v) {
1079 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PRIORITY_PROPERTY); 1275 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PRIORITY_PROPERTY);
@@ -1086,7 +1282,7 @@ void icalproperty_set_priority(icalproperty* prop, int v){
1086 icalerror_check_arg_rv( (prop!=0),"prop"); 1282 icalerror_check_arg_rv( (prop!=0),"prop");
1087 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1283 icalproperty_set_value(prop,icalvalue_new_integer(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");
1091 return icalvalue_get_integer(icalproperty_get_value(prop)); 1287 return icalvalue_get_integer(icalproperty_get_value(prop));
1092} 1288}
@@ -1100,6 +1296,7 @@ icalproperty* icalproperty_vanew_prodid(const char* v, ...){
1100 va_end(args); 1296 va_end(args);
1101 return (icalproperty*)impl; 1297 return (icalproperty*)impl;
1102} 1298}
1299
1103/* PRODID */ 1300/* PRODID */
1104icalproperty* icalproperty_new_prodid(const char* v) { 1301icalproperty* icalproperty_new_prodid(const char* v) {
1105 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PRODID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1302 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_PRODID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1114,7 +1311,7 @@ void icalproperty_set_prodid(icalproperty* prop, const char* v){
1114 icalerror_check_arg_rv( (prop!=0),"prop"); 1311 icalerror_check_arg_rv( (prop!=0),"prop");
1115 icalproperty_set_value(prop,icalvalue_new_text(v)); 1312 icalproperty_set_value(prop,icalvalue_new_text(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");
1119 return icalvalue_get_text(icalproperty_get_value(prop)); 1316 return icalvalue_get_text(icalproperty_get_value(prop));
1120} 1317}
@@ -1128,6 +1325,7 @@ icalproperty* icalproperty_vanew_query(const char* v, ...){
1128 va_end(args); 1325 va_end(args);
1129 return (icalproperty*)impl; 1326 return (icalproperty*)impl;
1130} 1327}
1328
1131/* QUERY */ 1329/* QUERY */
1132icalproperty* icalproperty_new_query(const char* v) { 1330icalproperty* icalproperty_new_query(const char* v) {
1133 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_QUERY_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1331 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_QUERY_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1142,7 +1340,7 @@ void icalproperty_set_query(icalproperty* prop, const char* v){
1142 icalerror_check_arg_rv( (prop!=0),"prop"); 1340 icalerror_check_arg_rv( (prop!=0),"prop");
1143 icalproperty_set_value(prop,icalvalue_new_query(v)); 1341 icalproperty_set_value(prop,icalvalue_new_query(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");
1147 return icalvalue_get_query(icalproperty_get_value(prop)); 1345 return icalvalue_get_query(icalproperty_get_value(prop));
1148} 1346}
@@ -1156,6 +1354,7 @@ icalproperty* icalproperty_vanew_queryname(const char* v, ...){
1156 va_end(args); 1354 va_end(args);
1157 return (icalproperty*)impl; 1355 return (icalproperty*)impl;
1158} 1356}
1357
1159/* QUERYNAME */ 1358/* QUERYNAME */
1160icalproperty* icalproperty_new_queryname(const char* v) { 1359icalproperty* icalproperty_new_queryname(const char* v) {
1161 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_QUERYNAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1360 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_QUERYNAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1170,7 +1369,7 @@ void icalproperty_set_queryname(icalproperty* prop, const char* v){
1170 icalerror_check_arg_rv( (prop!=0),"prop"); 1369 icalerror_check_arg_rv( (prop!=0),"prop");
1171 icalproperty_set_value(prop,icalvalue_new_text(v)); 1370 icalproperty_set_value(prop,icalvalue_new_text(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");
1175 return icalvalue_get_text(icalproperty_get_value(prop)); 1374 return icalvalue_get_text(icalproperty_get_value(prop));
1176} 1375}
@@ -1183,6 +1382,7 @@ icalproperty* icalproperty_vanew_rdate(struct icaldatetimeperiodtype v, ...){
1183 va_end(args); 1382 va_end(args);
1184 return (icalproperty*)impl; 1383 return (icalproperty*)impl;
1185} 1384}
1385
1186/* RDATE */ 1386/* RDATE */
1187icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v) { 1387icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v) {
1188 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RDATE_PROPERTY); 1388 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RDATE_PROPERTY);
@@ -1195,7 +1395,7 @@ void icalproperty_set_rdate(icalproperty* prop, struct icaldatetimeperiodtype v)
1195 icalerror_check_arg_rv( (prop!=0),"prop"); 1395 icalerror_check_arg_rv( (prop!=0),"prop");
1196 icalproperty_set_value(prop,icalvalue_new_datetimeperiod(v)); 1396 icalproperty_set_value(prop,icalvalue_new_datetimeperiod(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");
1200 return icalvalue_get_datetimeperiod(icalproperty_get_value(prop)); 1400 return icalvalue_get_datetimeperiod(icalproperty_get_value(prop));
1201} 1401}
@@ -1208,6 +1408,7 @@ icalproperty* icalproperty_vanew_recurrenceid(struct icaltimetype v, ...){
1208 va_end(args); 1408 va_end(args);
1209 return (icalproperty*)impl; 1409 return (icalproperty*)impl;
1210} 1410}
1411
1211/* RECURRENCE-ID */ 1412/* RECURRENCE-ID */
1212icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v) { 1413icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v) {
1213 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RECURRENCEID_PROPERTY); 1414 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RECURRENCEID_PROPERTY);
@@ -1216,11 +1417,16 @@ icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v) {
1216} 1417}
1217 1418
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");
1225 return icalvalue_get_datetime(icalproperty_get_value(prop)); 1431 return icalvalue_get_datetime(icalproperty_get_value(prop));
1226} 1432}
@@ -1234,6 +1440,7 @@ icalproperty* icalproperty_vanew_relatedto(const char* v, ...){
1234 va_end(args); 1440 va_end(args);
1235 return (icalproperty*)impl; 1441 return (icalproperty*)impl;
1236} 1442}
1443
1237/* RELATED-TO */ 1444/* RELATED-TO */
1238icalproperty* icalproperty_new_relatedto(const char* v) { 1445icalproperty* icalproperty_new_relatedto(const char* v) {
1239 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RELATEDTO_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1446 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RELATEDTO_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1248,7 +1455,36 @@ void icalproperty_set_relatedto(icalproperty* prop, const char* v){
1248 icalerror_check_arg_rv( (prop!=0),"prop"); 1455 icalerror_check_arg_rv( (prop!=0),"prop");
1249 icalproperty_set_value(prop,icalvalue_new_text(v)); 1456 icalproperty_set_value(prop,icalvalue_new_text(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");
1253 return icalvalue_get_text(icalproperty_get_value(prop)); 1489 return icalvalue_get_text(icalproperty_get_value(prop));
1254} 1490}
@@ -1261,6 +1497,7 @@ icalproperty* icalproperty_vanew_repeat(int v, ...){
1261 va_end(args); 1497 va_end(args);
1262 return (icalproperty*)impl; 1498 return (icalproperty*)impl;
1263} 1499}
1500
1264/* REPEAT */ 1501/* REPEAT */
1265icalproperty* icalproperty_new_repeat(int v) { 1502icalproperty* icalproperty_new_repeat(int v) {
1266 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_REPEAT_PROPERTY); 1503 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_REPEAT_PROPERTY);
@@ -1273,7 +1510,7 @@ void icalproperty_set_repeat(icalproperty* prop, int v){
1273 icalerror_check_arg_rv( (prop!=0),"prop"); 1510 icalerror_check_arg_rv( (prop!=0),"prop");
1274 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1511 icalproperty_set_value(prop,icalvalue_new_integer(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");
1278 return icalvalue_get_integer(icalproperty_get_value(prop)); 1515 return icalvalue_get_integer(icalproperty_get_value(prop));
1279} 1516}
@@ -1286,6 +1523,7 @@ icalproperty* icalproperty_vanew_requeststatus(struct icalreqstattype v, ...){
1286 va_end(args); 1523 va_end(args);
1287 return (icalproperty*)impl; 1524 return (icalproperty*)impl;
1288} 1525}
1526
1289/* REQUEST-STATUS */ 1527/* REQUEST-STATUS */
1290icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v) { 1528icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v) {
1291 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_REQUESTSTATUS_PROPERTY); 1529 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_REQUESTSTATUS_PROPERTY);
@@ -1298,7 +1536,7 @@ void icalproperty_set_requeststatus(icalproperty* prop, struct icalreqstattype v
1298 icalerror_check_arg_rv( (prop!=0),"prop"); 1536 icalerror_check_arg_rv( (prop!=0),"prop");
1299 icalproperty_set_value(prop,icalvalue_new_requeststatus(v)); 1537 icalproperty_set_value(prop,icalvalue_new_requeststatus(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");
1303 return icalvalue_get_requeststatus(icalproperty_get_value(prop)); 1541 return icalvalue_get_requeststatus(icalproperty_get_value(prop));
1304} 1542}
@@ -1312,6 +1550,7 @@ icalproperty* icalproperty_vanew_resources(const char* v, ...){
1312 va_end(args); 1550 va_end(args);
1313 return (icalproperty*)impl; 1551 return (icalproperty*)impl;
1314} 1552}
1553
1315/* RESOURCES */ 1554/* RESOURCES */
1316icalproperty* icalproperty_new_resources(const char* v) { 1555icalproperty* icalproperty_new_resources(const char* v) {
1317 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RESOURCES_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1556 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RESOURCES_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1326,7 +1565,7 @@ void icalproperty_set_resources(icalproperty* prop, const char* v){
1326 icalerror_check_arg_rv( (prop!=0),"prop"); 1565 icalerror_check_arg_rv( (prop!=0),"prop");
1327 icalproperty_set_value(prop,icalvalue_new_text(v)); 1566 icalproperty_set_value(prop,icalvalue_new_text(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");
1331 return icalvalue_get_text(icalproperty_get_value(prop)); 1570 return icalvalue_get_text(icalproperty_get_value(prop));
1332} 1571}
@@ -1339,6 +1578,7 @@ icalproperty* icalproperty_vanew_rrule(struct icalrecurrencetype v, ...){
1339 va_end(args); 1578 va_end(args);
1340 return (icalproperty*)impl; 1579 return (icalproperty*)impl;
1341} 1580}
1581
1342/* RRULE */ 1582/* RRULE */
1343icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v) { 1583icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v) {
1344 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RRULE_PROPERTY); 1584 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_RRULE_PROPERTY);
@@ -1351,7 +1591,7 @@ void icalproperty_set_rrule(icalproperty* prop, struct icalrecurrencetype v){
1351 icalerror_check_arg_rv( (prop!=0),"prop"); 1591 icalerror_check_arg_rv( (prop!=0),"prop");
1352 icalproperty_set_value(prop,icalvalue_new_recur(v)); 1592 icalproperty_set_value(prop,icalvalue_new_recur(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");
1356 return icalvalue_get_recur(icalproperty_get_value(prop)); 1596 return icalvalue_get_recur(icalproperty_get_value(prop));
1357} 1597}
@@ -1365,6 +1605,7 @@ icalproperty* icalproperty_vanew_scope(const char* v, ...){
1365 va_end(args); 1605 va_end(args);
1366 return (icalproperty*)impl; 1606 return (icalproperty*)impl;
1367} 1607}
1608
1368/* SCOPE */ 1609/* SCOPE */
1369icalproperty* icalproperty_new_scope(const char* v) { 1610icalproperty* icalproperty_new_scope(const char* v) {
1370 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SCOPE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1611 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SCOPE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1379,7 +1620,7 @@ void icalproperty_set_scope(icalproperty* prop, const char* v){
1379 icalerror_check_arg_rv( (prop!=0),"prop"); 1620 icalerror_check_arg_rv( (prop!=0),"prop");
1380 icalproperty_set_value(prop,icalvalue_new_text(v)); 1621 icalproperty_set_value(prop,icalvalue_new_text(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");
1384 return icalvalue_get_text(icalproperty_get_value(prop)); 1625 return icalvalue_get_text(icalproperty_get_value(prop));
1385} 1626}
@@ -1392,6 +1633,7 @@ icalproperty* icalproperty_vanew_sequence(int v, ...){
1392 va_end(args); 1633 va_end(args);
1393 return (icalproperty*)impl; 1634 return (icalproperty*)impl;
1394} 1635}
1636
1395/* SEQUENCE */ 1637/* SEQUENCE */
1396icalproperty* icalproperty_new_sequence(int v) { 1638icalproperty* icalproperty_new_sequence(int v) {
1397 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SEQUENCE_PROPERTY); 1639 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SEQUENCE_PROPERTY);
@@ -1404,7 +1646,7 @@ void icalproperty_set_sequence(icalproperty* prop, int v){
1404 icalerror_check_arg_rv( (prop!=0),"prop"); 1646 icalerror_check_arg_rv( (prop!=0),"prop");
1405 icalproperty_set_value(prop,icalvalue_new_integer(v)); 1647 icalproperty_set_value(prop,icalvalue_new_integer(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");
1409 return icalvalue_get_integer(icalproperty_get_value(prop)); 1651 return icalvalue_get_integer(icalproperty_get_value(prop));
1410} 1652}
@@ -1417,6 +1659,7 @@ icalproperty* icalproperty_vanew_status(enum icalproperty_status v, ...){
1417 va_end(args); 1659 va_end(args);
1418 return (icalproperty*)impl; 1660 return (icalproperty*)impl;
1419} 1661}
1662
1420/* STATUS */ 1663/* STATUS */
1421icalproperty* icalproperty_new_status(enum icalproperty_status v) { 1664icalproperty* icalproperty_new_status(enum icalproperty_status v) {
1422 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_STATUS_PROPERTY); 1665 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_STATUS_PROPERTY);
@@ -1429,7 +1672,7 @@ void icalproperty_set_status(icalproperty* prop, enum icalproperty_status v){
1429 icalerror_check_arg_rv( (prop!=0),"prop"); 1672 icalerror_check_arg_rv( (prop!=0),"prop");
1430 icalproperty_set_value(prop,icalvalue_new_status(v)); 1673 icalproperty_set_value(prop,icalvalue_new_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");
1434 return icalvalue_get_status(icalproperty_get_value(prop)); 1677 return icalvalue_get_status(icalproperty_get_value(prop));
1435} 1678}
@@ -1443,6 +1686,7 @@ icalproperty* icalproperty_vanew_summary(const char* v, ...){
1443 va_end(args); 1686 va_end(args);
1444 return (icalproperty*)impl; 1687 return (icalproperty*)impl;
1445} 1688}
1689
1446/* SUMMARY */ 1690/* SUMMARY */
1447icalproperty* icalproperty_new_summary(const char* v) { 1691icalproperty* icalproperty_new_summary(const char* v) {
1448 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SUMMARY_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1692 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_SUMMARY_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1457,7 +1701,7 @@ void icalproperty_set_summary(icalproperty* prop, const char* v){
1457 icalerror_check_arg_rv( (prop!=0),"prop"); 1701 icalerror_check_arg_rv( (prop!=0),"prop");
1458 icalproperty_set_value(prop,icalvalue_new_text(v)); 1702 icalproperty_set_value(prop,icalvalue_new_text(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");
1462 return icalvalue_get_text(icalproperty_get_value(prop)); 1706 return icalvalue_get_text(icalproperty_get_value(prop));
1463} 1707}
@@ -1471,6 +1715,7 @@ icalproperty* icalproperty_vanew_target(const char* v, ...){
1471 va_end(args); 1715 va_end(args);
1472 return (icalproperty*)impl; 1716 return (icalproperty*)impl;
1473} 1717}
1718
1474/* TARGET */ 1719/* TARGET */
1475icalproperty* icalproperty_new_target(const char* v) { 1720icalproperty* icalproperty_new_target(const char* v) {
1476 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TARGET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1721 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TARGET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1485,37 +1730,35 @@ void icalproperty_set_target(icalproperty* prop, const char* v){
1485 icalerror_check_arg_rv( (prop!=0),"prop"); 1730 icalerror_check_arg_rv( (prop!=0),"prop");
1486 icalproperty_set_value(prop,icalvalue_new_caladdress(v)); 1731 icalproperty_set_value(prop,icalvalue_new_caladdress(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");
1490 return icalvalue_get_caladdress(icalproperty_get_value(prop)); 1735 return icalvalue_get_caladdress(icalproperty_get_value(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);
1497 va_start(args,v); 1741 va_start(args,v);
1498 icalproperty_add_parameters(impl, args); 1742 icalproperty_add_parameters(impl, args);
1499 va_end(args); 1743 va_end(args);
1500 return (icalproperty*)impl; 1744 return (icalproperty*)impl;
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);
1507 return (icalproperty*)impl; 1751 return (icalproperty*)impl;
1508} 1752}
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}
1520icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...){ 1763icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...){
1521 va_list args; 1764 va_list args;
@@ -1526,6 +1769,7 @@ icalproperty* icalproperty_vanew_trigger(struct icaltriggertype v, ...){
1526 va_end(args); 1769 va_end(args);
1527 return (icalproperty*)impl; 1770 return (icalproperty*)impl;
1528} 1771}
1772
1529/* TRIGGER */ 1773/* TRIGGER */
1530icalproperty* icalproperty_new_trigger(struct icaltriggertype v) { 1774icalproperty* icalproperty_new_trigger(struct icaltriggertype v) {
1531 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRIGGER_PROPERTY); 1775 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TRIGGER_PROPERTY);
@@ -1538,7 +1782,7 @@ void icalproperty_set_trigger(icalproperty* prop, struct icaltriggertype v){
1538 icalerror_check_arg_rv( (prop!=0),"prop"); 1782 icalerror_check_arg_rv( (prop!=0),"prop");
1539 icalproperty_set_value(prop,icalvalue_new_trigger(v)); 1783 icalproperty_set_value(prop,icalvalue_new_trigger(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");
1543 return icalvalue_get_trigger(icalproperty_get_value(prop)); 1787 return icalvalue_get_trigger(icalproperty_get_value(prop));
1544} 1788}
@@ -1552,6 +1796,7 @@ icalproperty* icalproperty_vanew_tzid(const char* v, ...){
1552 va_end(args); 1796 va_end(args);
1553 return (icalproperty*)impl; 1797 return (icalproperty*)impl;
1554} 1798}
1799
1555/* TZID */ 1800/* TZID */
1556icalproperty* icalproperty_new_tzid(const char* v) { 1801icalproperty* icalproperty_new_tzid(const char* v) {
1557 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1802 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1566,7 +1811,7 @@ void icalproperty_set_tzid(icalproperty* prop, const char* v){
1566 icalerror_check_arg_rv( (prop!=0),"prop"); 1811 icalerror_check_arg_rv( (prop!=0),"prop");
1567 icalproperty_set_value(prop,icalvalue_new_text(v)); 1812 icalproperty_set_value(prop,icalvalue_new_text(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");
1571 return icalvalue_get_text(icalproperty_get_value(prop)); 1816 return icalvalue_get_text(icalproperty_get_value(prop));
1572} 1817}
@@ -1580,6 +1825,7 @@ icalproperty* icalproperty_vanew_tzname(const char* v, ...){
1580 va_end(args); 1825 va_end(args);
1581 return (icalproperty*)impl; 1826 return (icalproperty*)impl;
1582} 1827}
1828
1583/* TZNAME */ 1829/* TZNAME */
1584icalproperty* icalproperty_new_tzname(const char* v) { 1830icalproperty* icalproperty_new_tzname(const char* v) {
1585 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZNAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1831 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZNAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1594,7 +1840,7 @@ void icalproperty_set_tzname(icalproperty* prop, const char* v){
1594 icalerror_check_arg_rv( (prop!=0),"prop"); 1840 icalerror_check_arg_rv( (prop!=0),"prop");
1595 icalproperty_set_value(prop,icalvalue_new_text(v)); 1841 icalproperty_set_value(prop,icalvalue_new_text(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");
1599 return icalvalue_get_text(icalproperty_get_value(prop)); 1845 return icalvalue_get_text(icalproperty_get_value(prop));
1600} 1846}
@@ -1607,6 +1853,7 @@ icalproperty* icalproperty_vanew_tzoffsetfrom(int v, ...){
1607 va_end(args); 1853 va_end(args);
1608 return (icalproperty*)impl; 1854 return (icalproperty*)impl;
1609} 1855}
1856
1610/* TZOFFSETFROM */ 1857/* TZOFFSETFROM */
1611icalproperty* icalproperty_new_tzoffsetfrom(int v) { 1858icalproperty* icalproperty_new_tzoffsetfrom(int v) {
1612 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZOFFSETFROM_PROPERTY); 1859 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZOFFSETFROM_PROPERTY);
@@ -1619,7 +1866,7 @@ void icalproperty_set_tzoffsetfrom(icalproperty* prop, int v){
1619 icalerror_check_arg_rv( (prop!=0),"prop"); 1866 icalerror_check_arg_rv( (prop!=0),"prop");
1620 icalproperty_set_value(prop,icalvalue_new_utcoffset(v)); 1867 icalproperty_set_value(prop,icalvalue_new_utcoffset(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");
1624 return icalvalue_get_utcoffset(icalproperty_get_value(prop)); 1871 return icalvalue_get_utcoffset(icalproperty_get_value(prop));
1625} 1872}
@@ -1632,6 +1879,7 @@ icalproperty* icalproperty_vanew_tzoffsetto(int v, ...){
1632 va_end(args); 1879 va_end(args);
1633 return (icalproperty*)impl; 1880 return (icalproperty*)impl;
1634} 1881}
1882
1635/* TZOFFSETTO */ 1883/* TZOFFSETTO */
1636icalproperty* icalproperty_new_tzoffsetto(int v) { 1884icalproperty* icalproperty_new_tzoffsetto(int v) {
1637 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZOFFSETTO_PROPERTY); 1885 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZOFFSETTO_PROPERTY);
@@ -1644,7 +1892,7 @@ void icalproperty_set_tzoffsetto(icalproperty* prop, int v){
1644 icalerror_check_arg_rv( (prop!=0),"prop"); 1892 icalerror_check_arg_rv( (prop!=0),"prop");
1645 icalproperty_set_value(prop,icalvalue_new_utcoffset(v)); 1893 icalproperty_set_value(prop,icalvalue_new_utcoffset(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");
1649 return icalvalue_get_utcoffset(icalproperty_get_value(prop)); 1897 return icalvalue_get_utcoffset(icalproperty_get_value(prop));
1650} 1898}
@@ -1658,6 +1906,7 @@ icalproperty* icalproperty_vanew_tzurl(const char* v, ...){
1658 va_end(args); 1906 va_end(args);
1659 return (icalproperty*)impl; 1907 return (icalproperty*)impl;
1660} 1908}
1909
1661/* TZURL */ 1910/* TZURL */
1662icalproperty* icalproperty_new_tzurl(const char* v) { 1911icalproperty* icalproperty_new_tzurl(const char* v) {
1663 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZURL_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1912 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_TZURL_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1672,7 +1921,7 @@ void icalproperty_set_tzurl(icalproperty* prop, const char* v){
1672 icalerror_check_arg_rv( (prop!=0),"prop"); 1921 icalerror_check_arg_rv( (prop!=0),"prop");
1673 icalproperty_set_value(prop,icalvalue_new_uri(v)); 1922 icalproperty_set_value(prop,icalvalue_new_uri(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");
1677 return icalvalue_get_uri(icalproperty_get_value(prop)); 1926 return icalvalue_get_uri(icalproperty_get_value(prop));
1678} 1927}
@@ -1686,6 +1935,7 @@ icalproperty* icalproperty_vanew_uid(const char* v, ...){
1686 va_end(args); 1935 va_end(args);
1687 return (icalproperty*)impl; 1936 return (icalproperty*)impl;
1688} 1937}
1938
1689/* UID */ 1939/* UID */
1690icalproperty* icalproperty_new_uid(const char* v) { 1940icalproperty* icalproperty_new_uid(const char* v) {
1691 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_UID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1941 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_UID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1700,7 +1950,7 @@ void icalproperty_set_uid(icalproperty* prop, const char* v){
1700 icalerror_check_arg_rv( (prop!=0),"prop"); 1950 icalerror_check_arg_rv( (prop!=0),"prop");
1701 icalproperty_set_value(prop,icalvalue_new_text(v)); 1951 icalproperty_set_value(prop,icalvalue_new_text(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");
1705 return icalvalue_get_text(icalproperty_get_value(prop)); 1955 return icalvalue_get_text(icalproperty_get_value(prop));
1706} 1956}
@@ -1714,6 +1964,7 @@ icalproperty* icalproperty_vanew_url(const char* v, ...){
1714 va_end(args); 1964 va_end(args);
1715 return (icalproperty*)impl; 1965 return (icalproperty*)impl;
1716} 1966}
1967
1717/* URL */ 1968/* URL */
1718icalproperty* icalproperty_new_url(const char* v) { 1969icalproperty* icalproperty_new_url(const char* v) {
1719 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_URL_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1970 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_URL_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1728,7 +1979,7 @@ void icalproperty_set_url(icalproperty* prop, const char* v){
1728 icalerror_check_arg_rv( (prop!=0),"prop"); 1979 icalerror_check_arg_rv( (prop!=0),"prop");
1729 icalproperty_set_value(prop,icalvalue_new_uri(v)); 1980 icalproperty_set_value(prop,icalvalue_new_uri(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");
1733 return icalvalue_get_uri(icalproperty_get_value(prop)); 1984 return icalvalue_get_uri(icalproperty_get_value(prop));
1734} 1985}
@@ -1742,6 +1993,7 @@ icalproperty* icalproperty_vanew_version(const char* v, ...){
1742 va_end(args); 1993 va_end(args);
1743 return (icalproperty*)impl; 1994 return (icalproperty*)impl;
1744} 1995}
1996
1745/* VERSION */ 1997/* VERSION */
1746icalproperty* icalproperty_new_version(const char* v) { 1998icalproperty* icalproperty_new_version(const char* v) {
1747 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_VERSION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 1999 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_VERSION_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1756,7 +2008,7 @@ void icalproperty_set_version(icalproperty* prop, const char* v){
1756 icalerror_check_arg_rv( (prop!=0),"prop"); 2008 icalerror_check_arg_rv( (prop!=0),"prop");
1757 icalproperty_set_value(prop,icalvalue_new_text(v)); 2009 icalproperty_set_value(prop,icalvalue_new_text(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");
1761 return icalvalue_get_text(icalproperty_get_value(prop)); 2013 return icalvalue_get_text(icalproperty_get_value(prop));
1762} 2014}
@@ -1770,6 +2022,7 @@ icalproperty* icalproperty_vanew_x(const char* v, ...){
1770 va_end(args); 2022 va_end(args);
1771 return (icalproperty*)impl; 2023 return (icalproperty*)impl;
1772} 2024}
2025
1773/* X */ 2026/* X */
1774icalproperty* icalproperty_new_x(const char* v) { 2027icalproperty* icalproperty_new_x(const char* v) {
1775 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_X_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2028 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_X_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1782,11 +2035,37 @@ void icalproperty_set_x(icalproperty* prop, const char* v){
1782 icalerror_check_arg_rv( (v!=0),"v"); 2035 icalerror_check_arg_rv( (v!=0),"v");
1783 2036
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}
1791icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...){ 2070icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...){
1792 va_list args; 2071 va_list args;
@@ -1798,6 +2077,7 @@ icalproperty* icalproperty_vanew_xlicclustercount(const char* v, ...){
1798 va_end(args); 2077 va_end(args);
1799 return (icalproperty*)impl; 2078 return (icalproperty*)impl;
1800} 2079}
2080
1801/* X-LIC-CLUSTERCOUNT */ 2081/* X-LIC-CLUSTERCOUNT */
1802icalproperty* icalproperty_new_xlicclustercount(const char* v) { 2082icalproperty* icalproperty_new_xlicclustercount(const char* v) {
1803 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2083 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICCLUSTERCOUNT_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1812,7 +2092,7 @@ void icalproperty_set_xlicclustercount(icalproperty* prop, const char* v){
1812 icalerror_check_arg_rv( (prop!=0),"prop"); 2092 icalerror_check_arg_rv( (prop!=0),"prop");
1813 icalproperty_set_value(prop,icalvalue_new_string(v)); 2093 icalproperty_set_value(prop,icalvalue_new_string(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");
1817 return icalvalue_get_string(icalproperty_get_value(prop)); 2097 return icalvalue_get_string(icalproperty_get_value(prop));
1818} 2098}
@@ -1826,6 +2106,7 @@ icalproperty* icalproperty_vanew_xlicerror(const char* v, ...){
1826 va_end(args); 2106 va_end(args);
1827 return (icalproperty*)impl; 2107 return (icalproperty*)impl;
1828} 2108}
2109
1829/* X-LIC-ERROR */ 2110/* X-LIC-ERROR */
1830icalproperty* icalproperty_new_xlicerror(const char* v) { 2111icalproperty* icalproperty_new_xlicerror(const char* v) {
1831 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2112 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICERROR_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1840,7 +2121,7 @@ void icalproperty_set_xlicerror(icalproperty* prop, const char* v){
1840 icalerror_check_arg_rv( (prop!=0),"prop"); 2121 icalerror_check_arg_rv( (prop!=0),"prop");
1841 icalproperty_set_value(prop,icalvalue_new_text(v)); 2122 icalproperty_set_value(prop,icalvalue_new_text(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");
1845 return icalvalue_get_text(icalproperty_get_value(prop)); 2126 return icalvalue_get_text(icalproperty_get_value(prop));
1846} 2127}
@@ -1854,6 +2135,7 @@ icalproperty* icalproperty_vanew_xlicmimecharset(const char* v, ...){
1854 va_end(args); 2135 va_end(args);
1855 return (icalproperty*)impl; 2136 return (icalproperty*)impl;
1856} 2137}
2138
1857/* X-LIC-MIMECHARSET */ 2139/* X-LIC-MIMECHARSET */
1858icalproperty* icalproperty_new_xlicmimecharset(const char* v) { 2140icalproperty* icalproperty_new_xlicmimecharset(const char* v) {
1859 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECHARSET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2141 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECHARSET_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1868,7 +2150,7 @@ void icalproperty_set_xlicmimecharset(icalproperty* prop, const char* v){
1868 icalerror_check_arg_rv( (prop!=0),"prop"); 2150 icalerror_check_arg_rv( (prop!=0),"prop");
1869 icalproperty_set_value(prop,icalvalue_new_string(v)); 2151 icalproperty_set_value(prop,icalvalue_new_string(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");
1873 return icalvalue_get_string(icalproperty_get_value(prop)); 2155 return icalvalue_get_string(icalproperty_get_value(prop));
1874} 2156}
@@ -1882,6 +2164,7 @@ icalproperty* icalproperty_vanew_xlicmimecid(const char* v, ...){
1882 va_end(args); 2164 va_end(args);
1883 return (icalproperty*)impl; 2165 return (icalproperty*)impl;
1884} 2166}
2167
1885/* X-LIC-MIMECID */ 2168/* X-LIC-MIMECID */
1886icalproperty* icalproperty_new_xlicmimecid(const char* v) { 2169icalproperty* icalproperty_new_xlicmimecid(const char* v) {
1887 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2170 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECID_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1896,7 +2179,7 @@ void icalproperty_set_xlicmimecid(icalproperty* prop, const char* v){
1896 icalerror_check_arg_rv( (prop!=0),"prop"); 2179 icalerror_check_arg_rv( (prop!=0),"prop");
1897 icalproperty_set_value(prop,icalvalue_new_string(v)); 2180 icalproperty_set_value(prop,icalvalue_new_string(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");
1901 return icalvalue_get_string(icalproperty_get_value(prop)); 2184 return icalvalue_get_string(icalproperty_get_value(prop));
1902} 2185}
@@ -1910,6 +2193,7 @@ icalproperty* icalproperty_vanew_xlicmimecontenttype(const char* v, ...){
1910 va_end(args); 2193 va_end(args);
1911 return (icalproperty*)impl; 2194 return (icalproperty*)impl;
1912} 2195}
2196
1913/* X-LIC-MIMECONTENTTYPE */ 2197/* X-LIC-MIMECONTENTTYPE */
1914icalproperty* icalproperty_new_xlicmimecontenttype(const char* v) { 2198icalproperty* icalproperty_new_xlicmimecontenttype(const char* v) {
1915 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECONTENTTYPE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2199 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMECONTENTTYPE_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1924,7 +2208,7 @@ void icalproperty_set_xlicmimecontenttype(icalproperty* prop, const char* v){
1924 icalerror_check_arg_rv( (prop!=0),"prop"); 2208 icalerror_check_arg_rv( (prop!=0),"prop");
1925 icalproperty_set_value(prop,icalvalue_new_string(v)); 2209 icalproperty_set_value(prop,icalvalue_new_string(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");
1929 return icalvalue_get_string(icalproperty_get_value(prop)); 2213 return icalvalue_get_string(icalproperty_get_value(prop));
1930} 2214}
@@ -1938,6 +2222,7 @@ icalproperty* icalproperty_vanew_xlicmimeencoding(const char* v, ...){
1938 va_end(args); 2222 va_end(args);
1939 return (icalproperty*)impl; 2223 return (icalproperty*)impl;
1940} 2224}
2225
1941/* X-LIC-MIMEENCODING */ 2226/* X-LIC-MIMEENCODING */
1942icalproperty* icalproperty_new_xlicmimeencoding(const char* v) { 2227icalproperty* icalproperty_new_xlicmimeencoding(const char* v) {
1943 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEENCODING_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2228 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEENCODING_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1952,7 +2237,7 @@ void icalproperty_set_xlicmimeencoding(icalproperty* prop, const char* v){
1952 icalerror_check_arg_rv( (prop!=0),"prop"); 2237 icalerror_check_arg_rv( (prop!=0),"prop");
1953 icalproperty_set_value(prop,icalvalue_new_string(v)); 2238 icalproperty_set_value(prop,icalvalue_new_string(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");
1957 return icalvalue_get_string(icalproperty_get_value(prop)); 2242 return icalvalue_get_string(icalproperty_get_value(prop));
1958} 2243}
@@ -1966,6 +2251,7 @@ icalproperty* icalproperty_vanew_xlicmimefilename(const char* v, ...){
1966 va_end(args); 2251 va_end(args);
1967 return (icalproperty*)impl; 2252 return (icalproperty*)impl;
1968} 2253}
2254
1969/* X-LIC-MIMEFILENAME */ 2255/* X-LIC-MIMEFILENAME */
1970icalproperty* icalproperty_new_xlicmimefilename(const char* v) { 2256icalproperty* icalproperty_new_xlicmimefilename(const char* v) {
1971 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEFILENAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2257 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEFILENAME_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -1980,7 +2266,7 @@ void icalproperty_set_xlicmimefilename(icalproperty* prop, const char* v){
1980 icalerror_check_arg_rv( (prop!=0),"prop"); 2266 icalerror_check_arg_rv( (prop!=0),"prop");
1981 icalproperty_set_value(prop,icalvalue_new_string(v)); 2267 icalproperty_set_value(prop,icalvalue_new_string(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");
1985 return icalvalue_get_string(icalproperty_get_value(prop)); 2271 return icalvalue_get_string(icalproperty_get_value(prop));
1986} 2272}
@@ -1994,6 +2280,7 @@ icalproperty* icalproperty_vanew_xlicmimeoptinfo(const char* v, ...){
1994 va_end(args); 2280 va_end(args);
1995 return (icalproperty*)impl; 2281 return (icalproperty*)impl;
1996} 2282}
2283
1997/* X-LIC-MIMEOPTINFO */ 2284/* X-LIC-MIMEOPTINFO */
1998icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v) { 2285icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v) {
1999 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEOPTINFO_PROPERTY); icalerror_check_arg_rz( (v!=0),"v"); 2286 struct icalproperty_impl *impl = icalproperty_new_impl(ICAL_XLICMIMEOPTINFO_PROPERTY); icalerror_check_arg_rz( (v!=0),"v");
@@ -2008,7 +2295,220 @@ void icalproperty_set_xlicmimeoptinfo(icalproperty* prop, const char* v){
2008 icalerror_check_arg_rv( (prop!=0),"prop"); 2295 icalerror_check_arg_rv( (prop!=0),"prop");
2009 icalproperty_set_value(prop,icalvalue_new_string(v)); 2296 icalproperty_set_value(prop,icalvalue_new_string(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");
2013 return icalvalue_get_string(icalproperty_get_value(prop)); 2300 return icalvalue_get_string(icalproperty_get_value(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
@@ -17,22 +17,28 @@
17#include "icalderivedvalue.h" 17#include "icalderivedvalue.h"
18#include "icalrecur.h" 18#include "icalrecur.h"
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 {
25 ICAL_ANY_PROPERTY = 0, 23 ICAL_ANY_PROPERTY = 0,
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,
31 ICAL_CLASS_PROPERTY, 33 ICAL_CLASS_PROPERTY,
32 ICAL_COMMENT_PROPERTY, 34 ICAL_COMMENT_PROPERTY,
33 ICAL_COMPLETED_PROPERTY, 35 ICAL_COMPLETED_PROPERTY,
34 ICAL_CONTACT_PROPERTY, 36 ICAL_CONTACT_PROPERTY,
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,
37 ICAL_DTEND_PROPERTY, 43 ICAL_DTEND_PROPERTY,
38 ICAL_DTSTAMP_PROPERTY, 44 ICAL_DTSTAMP_PROPERTY,
@@ -40,6 +46,7 @@ typedef enum icalproperty_kind {
40 ICAL_DUE_PROPERTY, 46 ICAL_DUE_PROPERTY,
41 ICAL_DURATION_PROPERTY, 47 ICAL_DURATION_PROPERTY,
42 ICAL_EXDATE_PROPERTY, 48 ICAL_EXDATE_PROPERTY,
49 ICAL_EXPAND_PROPERTY,
43 ICAL_EXRULE_PROPERTY, 50 ICAL_EXRULE_PROPERTY,
44 ICAL_FREEBUSY_PROPERTY, 51 ICAL_FREEBUSY_PROPERTY,
45 ICAL_GEO_PROPERTY, 52 ICAL_GEO_PROPERTY,
@@ -49,6 +56,7 @@ typedef enum icalproperty_kind {
49 ICAL_MAXRESULTSSIZE_PROPERTY, 56 ICAL_MAXRESULTSSIZE_PROPERTY,
50 ICAL_METHOD_PROPERTY, 57 ICAL_METHOD_PROPERTY,
51 ICAL_ORGANIZER_PROPERTY, 58 ICAL_ORGANIZER_PROPERTY,
59 ICAL_OWNER_PROPERTY,
52 ICAL_PERCENTCOMPLETE_PROPERTY, 60 ICAL_PERCENTCOMPLETE_PROPERTY,
53 ICAL_PRIORITY_PROPERTY, 61 ICAL_PRIORITY_PROPERTY,
54 ICAL_PRODID_PROPERTY, 62 ICAL_PRODID_PROPERTY,
@@ -57,6 +65,7 @@ typedef enum icalproperty_kind {
57 ICAL_RDATE_PROPERTY, 65 ICAL_RDATE_PROPERTY,
58 ICAL_RECURRENCEID_PROPERTY, 66 ICAL_RECURRENCEID_PROPERTY,
59 ICAL_RELATEDTO_PROPERTY, 67 ICAL_RELATEDTO_PROPERTY,
68 ICAL_RELCALID_PROPERTY,
60 ICAL_REPEAT_PROPERTY, 69 ICAL_REPEAT_PROPERTY,
61 ICAL_REQUESTSTATUS_PROPERTY, 70 ICAL_REQUESTSTATUS_PROPERTY,
62 ICAL_RESOURCES_PROPERTY, 71 ICAL_RESOURCES_PROPERTY,
@@ -77,6 +86,7 @@ typedef enum icalproperty_kind {
77 ICAL_URL_PROPERTY, 86 ICAL_URL_PROPERTY,
78 ICAL_VERSION_PROPERTY, 87 ICAL_VERSION_PROPERTY,
79 ICAL_X_PROPERTY, 88 ICAL_X_PROPERTY,
89 ICAL_XLICCLASS_PROPERTY,
80 ICAL_XLICCLUSTERCOUNT_PROPERTY, 90 ICAL_XLICCLUSTERCOUNT_PROPERTY,
81 ICAL_XLICERROR_PROPERTY, 91 ICAL_XLICERROR_PROPERTY,
82 ICAL_XLICMIMECHARSET_PROPERTY, 92 ICAL_XLICMIMECHARSET_PROPERTY,
@@ -88,316 +98,376 @@ typedef enum icalproperty_kind {
88 ICAL_NO_PROPERTY 98 ICAL_NO_PROPERTY
89} icalproperty_kind; 99} icalproperty_kind;
90 100
91icalproperty* icalproperty_vanew_action(enum icalproperty_action v, ...);
92 101
93/* ACTION */ 102/* ACTION */
94icalproperty* icalproperty_new_action(enum icalproperty_action v); 103icalproperty* 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
103/* ATTENDEE */ 117/* ATTENDEE */
104icalproperty* icalproperty_new_attendee(const char* v); 118icalproperty* 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
108/* CALSCALE */ 132/* CALSCALE */
109icalproperty* icalproperty_new_calscale(const char* v); 133icalproperty* 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
113/* CATEGORIES */ 142/* CATEGORIES */
114icalproperty* icalproperty_new_categories(const char* v); 143icalproperty* 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
123/* COMMENT */ 152/* COMMENT */
124icalproperty* icalproperty_new_comment(const char* v); 153icalproperty* 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
128/* COMPLETED */ 157/* COMPLETED */
129icalproperty* icalproperty_new_completed(struct icaltimetype v); 158icalproperty* 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
133/* CONTACT */ 162/* CONTACT */
134icalproperty* icalproperty_new_contact(const char* v); 163icalproperty* 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
138/* CREATED */ 167/* CREATED */
139icalproperty* icalproperty_new_created(struct icaltimetype v); 168icalproperty* 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
143/* DESCRIPTION */ 192/* DESCRIPTION */
144icalproperty* icalproperty_new_description(const char* v); 193icalproperty* 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
148/* DTEND */ 197/* DTEND */
149icalproperty* icalproperty_new_dtend(struct icaltimetype v); 198icalproperty* 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
153/* DTSTAMP */ 202/* DTSTAMP */
154icalproperty* icalproperty_new_dtstamp(struct icaltimetype v); 203icalproperty* 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
158/* DTSTART */ 207/* DTSTART */
159icalproperty* icalproperty_new_dtstart(struct icaltimetype v); 208icalproperty* 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
163/* DUE */ 212/* DUE */
164icalproperty* icalproperty_new_due(struct icaltimetype v); 213icalproperty* 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
168/* DURATION */ 217/* DURATION */
169icalproperty* icalproperty_new_duration(struct icaldurationtype v); 218icalproperty* 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
173/* EXDATE */ 222/* EXDATE */
174icalproperty* icalproperty_new_exdate(struct icaltimetype v); 223icalproperty* 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
178/* EXRULE */ 232/* EXRULE */
179icalproperty* icalproperty_new_exrule(struct icalrecurrencetype v); 233icalproperty* 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
183/* FREEBUSY */ 237/* FREEBUSY */
184icalproperty* icalproperty_new_freebusy(struct icalperiodtype v); 238icalproperty* 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
188/* GEO */ 242/* GEO */
189icalproperty* icalproperty_new_geo(struct icalgeotype v); 243icalproperty* 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
193/* LAST-MODIFIED */ 247/* LAST-MODIFIED */
194icalproperty* icalproperty_new_lastmodified(struct icaltimetype v); 248icalproperty* 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
198/* LOCATION */ 252/* LOCATION */
199icalproperty* icalproperty_new_location(const char* v); 253icalproperty* 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
203/* MAXRESULTS */ 257/* MAXRESULTS */
204icalproperty* icalproperty_new_maxresults(int v); 258icalproperty* 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
208/* MAXRESULTSSIZE */ 262/* MAXRESULTSSIZE */
209icalproperty* icalproperty_new_maxresultssize(int v); 263icalproperty* 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
213/* METHOD */ 267/* METHOD */
214icalproperty* icalproperty_new_method(enum icalproperty_method v); 268icalproperty* 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
218/* ORGANIZER */ 272/* ORGANIZER */
219icalproperty* icalproperty_new_organizer(const char* v); 273icalproperty* 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
223/* PERCENT-COMPLETE */ 282/* PERCENT-COMPLETE */
224icalproperty* icalproperty_new_percentcomplete(int v); 283icalproperty* 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
228/* PRIORITY */ 287/* PRIORITY */
229icalproperty* icalproperty_new_priority(int v); 288icalproperty* 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
233/* PRODID */ 292/* PRODID */
234icalproperty* icalproperty_new_prodid(const char* v); 293icalproperty* 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
238/* QUERY */ 297/* QUERY */
239icalproperty* icalproperty_new_query(const char* v); 298icalproperty* 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
243/* QUERYNAME */ 302/* QUERYNAME */
244icalproperty* icalproperty_new_queryname(const char* v); 303icalproperty* 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
248/* RDATE */ 307/* RDATE */
249icalproperty* icalproperty_new_rdate(struct icaldatetimeperiodtype v); 308icalproperty* 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
253/* RECURRENCE-ID */ 312/* RECURRENCE-ID */
254icalproperty* icalproperty_new_recurrenceid(struct icaltimetype v); 313icalproperty* 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
258/* RELATED-TO */ 317/* RELATED-TO */
259icalproperty* icalproperty_new_relatedto(const char* v); 318icalproperty* 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
263/* REPEAT */ 327/* REPEAT */
264icalproperty* icalproperty_new_repeat(int v); 328icalproperty* 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
268/* REQUEST-STATUS */ 332/* REQUEST-STATUS */
269icalproperty* icalproperty_new_requeststatus(struct icalreqstattype v); 333icalproperty* 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
273/* RESOURCES */ 337/* RESOURCES */
274icalproperty* icalproperty_new_resources(const char* v); 338icalproperty* 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
278/* RRULE */ 342/* RRULE */
279icalproperty* icalproperty_new_rrule(struct icalrecurrencetype v); 343icalproperty* 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
283/* SCOPE */ 347/* SCOPE */
284icalproperty* icalproperty_new_scope(const char* v); 348icalproperty* 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
288/* SEQUENCE */ 352/* SEQUENCE */
289icalproperty* icalproperty_new_sequence(int v); 353icalproperty* 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
293/* STATUS */ 357/* STATUS */
294icalproperty* icalproperty_new_status(enum icalproperty_status v); 358icalproperty* 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
298/* SUMMARY */ 362/* SUMMARY */
299icalproperty* icalproperty_new_summary(const char* v); 363icalproperty* 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
303/* TARGET */ 367/* TARGET */
304icalproperty* icalproperty_new_target(const char* v); 368icalproperty* 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
313/* TRIGGER */ 377/* TRIGGER */
314icalproperty* icalproperty_new_trigger(struct icaltriggertype v); 378icalproperty* 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
318/* TZID */ 382/* TZID */
319icalproperty* icalproperty_new_tzid(const char* v); 383icalproperty* 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
323/* TZNAME */ 387/* TZNAME */
324icalproperty* icalproperty_new_tzname(const char* v); 388icalproperty* 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
328/* TZOFFSETFROM */ 392/* TZOFFSETFROM */
329icalproperty* icalproperty_new_tzoffsetfrom(int v); 393icalproperty* 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
333/* TZOFFSETTO */ 397/* TZOFFSETTO */
334icalproperty* icalproperty_new_tzoffsetto(int v); 398icalproperty* 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
338/* TZURL */ 402/* TZURL */
339icalproperty* icalproperty_new_tzurl(const char* v); 403icalproperty* 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
343/* UID */ 407/* UID */
344icalproperty* icalproperty_new_uid(const char* v); 408icalproperty* 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
348/* URL */ 412/* URL */
349icalproperty* icalproperty_new_url(const char* v); 413icalproperty* 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
353/* VERSION */ 417/* VERSION */
354icalproperty* icalproperty_new_version(const char* v); 418icalproperty* 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
358/* X */ 422/* X */
359icalproperty* icalproperty_new_x(const char* v); 423icalproperty* 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
363/* X-LIC-CLUSTERCOUNT */ 432/* X-LIC-CLUSTERCOUNT */
364icalproperty* icalproperty_new_xlicclustercount(const char* v); 433icalproperty* 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
368/* X-LIC-ERROR */ 437/* X-LIC-ERROR */
369icalproperty* icalproperty_new_xlicerror(const char* v); 438icalproperty* 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
373/* X-LIC-MIMECHARSET */ 442/* X-LIC-MIMECHARSET */
374icalproperty* icalproperty_new_xlicmimecharset(const char* v); 443icalproperty* 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
378/* X-LIC-MIMECID */ 447/* X-LIC-MIMECID */
379icalproperty* icalproperty_new_xlicmimecid(const char* v); 448icalproperty* 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
383/* X-LIC-MIMECONTENTTYPE */ 452/* X-LIC-MIMECONTENTTYPE */
384icalproperty* icalproperty_new_xlicmimecontenttype(const char* v); 453icalproperty* 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
388/* X-LIC-MIMEENCODING */ 457/* X-LIC-MIMEENCODING */
389icalproperty* icalproperty_new_xlicmimeencoding(const char* v); 458icalproperty* 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
393/* X-LIC-MIMEFILENAME */ 462/* X-LIC-MIMEFILENAME */
394icalproperty* icalproperty_new_xlicmimefilename(const char* v); 463icalproperty* 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
398/* X-LIC-MIMEOPTINFO */ 467/* X-LIC-MIMEOPTINFO */
399icalproperty* icalproperty_new_xlicmimeoptinfo(const char* v); 468icalproperty* 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
403#endif /*ICALPROPERTY_H*/ 473#endif /*ICALPROPERTY_H*/
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
@@ -47,10 +47,6 @@
47#include <stdlib.h> /* for atoi and atof */ 47#include <stdlib.h> /* for atoi and atof */
48#include <limits.h> /* for SHRT_MAX */ 48#include <limits.h> /* for SHRT_MAX */
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);
55 51
56/* This map associates each of the value types with its string 52/* This map associates each of the value types with its string
@@ -60,326 +56,194 @@ struct icalvalue_kind_map {
60 char name[20]; 56 char name[20];
61}; 57};
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;
101 icalerror_check_arg_rv( (value!=0),"value"); 100 icalerror_check_arg_rv( (value!=0),"value");
102 icalerror_check_arg_rv( (v!=0),"v"); 101 icalerror_check_arg_rv( (v!=0),"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;
111 } 112 }
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}
158 150
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}
205 177
206 178
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
327 232
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;
379 icalerror_check_arg_rv( (value!=0),"value"); 243 icalerror_check_arg_rv( (value!=0),"value");
380 icalerror_check_arg_rv( (v!=0),"v"); 244 icalerror_check_arg_rv( (v!=0),"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;
384 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} 248 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
385 249
@@ -393,154 +257,162 @@ void icalvalue_set_query(icalvalue* value, const char* v) {
393 257
394 icalvalue_reset_kind(impl); 258 icalvalue_reset_kind(impl);
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;
401} 265}
402 266
403 267
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
421 icalvalue_reset_kind(impl); 293 icalvalue_reset_kind(impl);
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}
429 301
430 302
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;
440 icalerror_check_arg_rv( (value!=0),"value"); 312 icalerror_check_arg_rv( (value!=0),"value");
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;
444 316
445 317
446 impl->data.v_enum = v; 318 impl->data.v_requeststatus = v;
447 319
448 icalvalue_reset_kind(impl); 320 icalvalue_reset_kind(impl);
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}
456 328
457 329
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
475 icalvalue_reset_kind(impl); 355 icalvalue_reset_kind(impl);
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}
483 363
484 364
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;
494 icalerror_check_arg_rv( (value!=0),"value"); 374 icalerror_check_arg_rv( (value!=0),"value");
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;
498 378
499 379
500 impl->data.v_time = v; 380 impl->data.v_period = v;
501 381
502 icalvalue_reset_kind(impl); 382 icalvalue_reset_kind(impl);
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}
510 390
511 391
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
537 icalvalue_reset_kind(impl); 409 icalvalue_reset_kind(impl);
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}
545 417
546 418
@@ -563,7 +435,7 @@ void icalvalue_set_integer(icalvalue* value, int v) {
563 435
564 icalvalue_reset_kind(impl); 436 icalvalue_reset_kind(impl);
565} 437}
566int icalvalue_get_integer(icalvalue* value) { 438int icalvalue_get_integer(const icalvalue* value) {
567 439
568 icalerror_check_arg( (value!=0),"value"); 440 icalerror_check_arg( (value!=0),"value");
569 icalerror_check_value_type(value, ICAL_INTEGER_VALUE); 441 icalerror_check_value_type(value, ICAL_INTEGER_VALUE);
@@ -572,46 +444,46 @@ int icalvalue_get_integer(icalvalue* value) {
572 444
573 445
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;
583 icalerror_check_arg_rv( (value!=0),"value"); 455 icalerror_check_arg_rv( (value!=0),"value");
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;
587 459
588 460
589 impl->data.v_period = v; 461 impl->data.v_enum = v;
590 462
591 icalvalue_reset_kind(impl); 463 icalvalue_reset_kind(impl);
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}
599 471
600 472
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;
611 icalerror_check_arg_rv( (value!=0),"value"); 483 icalerror_check_arg_rv( (value!=0),"value");
612 icalerror_check_arg_rv( (v!=0),"v"); 484 icalerror_check_arg_rv( (v!=0),"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;
616 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} 488 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
617 489
@@ -625,10 +497,10 @@ void icalvalue_set_text(icalvalue* value, const char* v) {
625 497
626 icalvalue_reset_kind(impl); 498 icalvalue_reset_kind(impl);
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;
633} 505}
634 506
@@ -652,7 +524,7 @@ void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) {
652 524
653 icalvalue_reset_kind(impl); 525 icalvalue_reset_kind(impl);
654} 526}
655struct icaldurationtype icalvalue_get_duration(icalvalue* value) { 527struct icaldurationtype icalvalue_get_duration(const icalvalue* value) {
656 528
657 icalerror_check_arg( (value!=0),"value"); 529 icalerror_check_arg( (value!=0),"value");
658 icalerror_check_value_type(value, ICAL_DURATION_VALUE); 530 icalerror_check_value_type(value, ICAL_DURATION_VALUE);
@@ -679,7 +551,7 @@ void icalvalue_set_boolean(icalvalue* value, int v) {
679 551
680 icalvalue_reset_kind(impl); 552 icalvalue_reset_kind(impl);
681} 553}
682int icalvalue_get_boolean(icalvalue* value) { 554int icalvalue_get_boolean(const icalvalue* value) {
683 555
684 icalerror_check_arg( (value!=0),"value"); 556 icalerror_check_arg( (value!=0),"value");
685 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE); 557 icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
@@ -688,19 +560,19 @@ int icalvalue_get_boolean(icalvalue* value) {
688 560
689 561
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;
700 icalerror_check_arg_rv( (value!=0),"value"); 572 icalerror_check_arg_rv( (value!=0),"value");
701 icalerror_check_arg_rv( (v!=0),"v"); 573 icalerror_check_arg_rv( (v!=0),"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;
705 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);} 577 if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}
706 578
@@ -714,38 +586,65 @@ void icalvalue_set_uri(icalvalue* value, const char* v) {
714 586
715 icalvalue_reset_kind(impl); 587 icalvalue_reset_kind(impl);
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;
722} 594}
723 595
724 596
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;
734 icalerror_check_arg_rv( (value!=0),"value"); 606 icalerror_check_arg_rv( (value!=0),"value");
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;
738 610
739 611
740 impl->data.v_geo = v; 612 impl->data.v_enum = v;
741 613
742 icalvalue_reset_kind(impl); 614 icalvalue_reset_kind(impl);
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}
750 649
751 650
@@ -768,7 +667,7 @@ void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) {
768 667
769 icalvalue_reset_kind(impl); 668 icalvalue_reset_kind(impl);
770} 669}
771struct icaltimetype icalvalue_get_datetime(icalvalue* value) { 670struct icaltimetype icalvalue_get_datetime(const icalvalue* value) {
772 671
773 icalerror_check_arg( (value!=0),"value"); 672 icalerror_check_arg( (value!=0),"value");
774 icalerror_check_value_type(value, ICAL_DATETIME_VALUE); 673 icalerror_check_value_type(value, ICAL_DATETIME_VALUE);
@@ -795,7 +694,7 @@ void icalvalue_set_utcoffset(icalvalue* value, int v) {
795 694
796 icalvalue_reset_kind(impl); 695 icalvalue_reset_kind(impl);
797} 696}
798int icalvalue_get_utcoffset(icalvalue* value) { 697int icalvalue_get_utcoffset(const icalvalue* value) {
799 698
800 icalerror_check_arg( (value!=0),"value"); 699 icalerror_check_arg( (value!=0),"value");
801 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE); 700 icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
@@ -804,17 +703,17 @@ int icalvalue_get_utcoffset(icalvalue* value) {
804 703
805 704
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;
815 icalerror_check_arg_rv( (value!=0),"value"); 714 icalerror_check_arg_rv( (value!=0),"value");
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;
819 718
820 719
@@ -822,160 +721,287 @@ void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
822 721
823 icalvalue_reset_kind(impl); 722 icalvalue_reset_kind(impl);
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;
830} 729}
831 730
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;
855 } 787 }
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}
893 838
894 839
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
@@ -34,63 +34,64 @@
34#include "icaltime.h" 34#include "icaltime.h"
35#include "icalduration.h" 35#include "icalduration.h"
36#include "icalperiod.h" 36#include "icalperiod.h"
37#include "icalattach.h"
37 38
38typedef void icalvalue; 39typedef struct icalvalue_impl icalvalue;
39 40
40 41
41 42
42void icalvalue_set_x(icalvalue* value, const char* v); 43void 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
50icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); 47icalvalue* 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
54icalvalue* icalvalue_new_trigger (struct icaltriggertype v); 51icalvalue* 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
58icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); 55icalvalue* 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
62void icalvalue_reset_kind(icalvalue* value); 63void 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 {
66 ICAL_ANY_VALUE=5000, 66 ICAL_ANY_VALUE=5000,
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 ;
95 96
96#define ICALPROPERTY_FIRST_ENUM 10000 97#define ICALPROPERTY_FIRST_ENUM 10000
@@ -148,136 +149,176 @@ typedef enum icalproperty_status {
148typedef enum icalproperty_transp { 149typedef enum icalproperty_transp {
149 ICAL_TRANSP_X = 10038, 150 ICAL_TRANSP_X = 10038,
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
157 192
158 /* QUERY */ 193 /* QUERY */
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);
162 197
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);
168 215
169 216
170 /* TRANSP */ 217 /* TRANSP */
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);
174 221
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
199 246
200 /* PERIOD */ 247 /* PERIOD */
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);
204 251
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
223 270
224 /* URI */ 271 /* URI */
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);
228 275
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
247 300
248 /* ACTION */ 301 /* ACTION */
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);
252 305
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
271 318
272 /* METHOD */ 319 /* METHOD */
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
@@ -36,14 +36,9 @@
36#include <stdlib.h> 36#include <stdlib.h>
37#include <stdio.h> 37#include <stdio.h>
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
48 43
49 44
@@ -51,34 +46,32 @@
51/* From Seth Alves, <alves@hungry.com> */ 46/* From Seth Alves, <alves@hungry.com> */
52struct icaldurationtype icaldurationtype_from_int(int t) 47struct 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)
83{ 76{
84 77
@@ -138,7 +131,7 @@ struct icaldurationtype icaldurationtype_from_string(const char* str)
138 131
139 if (begin_flag == 0) goto error; 132 if (begin_flag == 0) goto error;
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;
143 break; 136 break;
144 } 137 }
@@ -187,12 +180,11 @@ struct icaldurationtype icaldurationtype_from_string(const char* str)
187 180
188 error: 181 error:
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}
194 185
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,
197 char* sep, unsigned int value) { 189 char* sep, unsigned int value) {
198 190
@@ -253,7 +245,7 @@ char* icaldurationtype_as_ical_string(struct icaldurationtype d)
253 245
254 } 246 }
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 }
258 250
259 output_line = icalmemory_tmp_copy(buf); 251 output_line = icalmemory_tmp_copy(buf);
@@ -263,8 +255,6 @@ char* icaldurationtype_as_ical_string(struct icaldurationtype d)
263 255
264} 256}
265 257
266#endif
267
268 258
269/* From Russel Steinthal */ 259/* From Russel Steinthal */
270int icaldurationtype_as_int(struct icaldurationtype dur) 260int icaldurationtype_as_int(struct icaldurationtype dur)
@@ -277,7 +267,7 @@ int icaldurationtype_as_int(struct icaldurationtype dur)
277 * (dur.is_neg==1? -1 : 1) ) ; 267 * (dur.is_neg==1? -1 : 1) ) ;
278} 268}
279 269
280struct icaldurationtype icaldurationtype_null_duration() 270struct icaldurationtype icaldurationtype_null_duration(void)
281{ 271{
282 struct icaldurationtype d; 272 struct icaldurationtype d;
283 273
@@ -295,6 +285,25 @@ int icaldurationtype_is_null_duration(struct icaldurationtype d)
295 } 285 }
296} 286}
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
299 308
300struct icaltimetype icaltime_add(struct icaltimetype t, 309struct icaltimetype icaltime_add(struct icaltimetype t,
@@ -316,7 +325,7 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
316 time_t t1t = icaltime_as_timet(t1); 325 time_t t1t = icaltime_as_timet(t1);
317 time_t t2t = icaltime_as_timet(t2); 326 time_t t2t = icaltime_as_timet(t2);
318 327
319 return icaldurationtype_from_int(t1t-t2t); 328 return icaldurationtype_from_int((int)(t1t-t2t));
320 329
321 330
322} 331}
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
@@ -45,8 +45,10 @@ struct icaldurationtype icaldurationtype_from_int(int t);
45struct icaldurationtype icaldurationtype_from_string(const char*); 45struct icaldurationtype icaldurationtype_from_string(const char*);
46int icaldurationtype_as_int(struct icaldurationtype duration); 46int 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
51struct icaltimetype icaltime_add(struct icaltimetype t, 53struct icaltimetype icaltime_add(struct icaltimetype t,
52 struct icaldurationtype d); 54 struct icaldurationtype d);
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
@@ -34,10 +34,11 @@
34#include <stdio.h> /* For stderr */ 34#include <stdio.h> /* For stderr */
35#include <string.h> /* For strncmp */ 35#include <string.h> /* For strncmp */
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;
42 int major; 43 int major;
43 int minor; 44 int minor;
@@ -70,18 +71,25 @@ struct {
70 {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."}, 71 {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."},
71 {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"}, 72 {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"},
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."},
75 {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."}, 80 {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."},
76 {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."}, 81 {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."},
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"}
79}; 86};
80 87
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;
86 94
87 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { 95 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
@@ -93,7 +101,26 @@ const char* icalenum_reqstat_desc(icalrequeststatus stat)
93 return 0; 101 return 0;
94} 102}
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)
98{ 125{
99 int i; 126 int i;
@@ -106,6 +133,8 @@ short icalenum_reqstat_major(icalrequeststatus stat)
106 return -1; 133 return -1;
107} 134}
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)
110{ 139{
111 int i; 140 int i;
@@ -119,6 +148,8 @@ short icalenum_reqstat_minor(icalrequeststatus stat)
119} 148}
120 149
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)
123{ 154{
124 int i; 155 int i;
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
@@ -43,6 +43,7 @@ typedef enum icalcomponent_kind {
43 ICAL_VTODO_COMPONENT, 43 ICAL_VTODO_COMPONENT,
44 ICAL_VJOURNAL_COMPONENT, 44 ICAL_VJOURNAL_COMPONENT,
45 ICAL_VCALENDAR_COMPONENT, 45 ICAL_VCALENDAR_COMPONENT,
46 ICAL_VAGENDA_COMPONENT,
46 ICAL_VFREEBUSY_COMPONENT, 47 ICAL_VFREEBUSY_COMPONENT,
47 ICAL_VALARM_COMPONENT, 48 ICAL_VALARM_COMPONENT,
48 ICAL_XAUDIOALARM_COMPONENT, 49 ICAL_XAUDIOALARM_COMPONENT,
@@ -98,11 +99,17 @@ typedef enum icalrequeststatus {
98 ICAL_3_12_UNKCOMP_STATUS, 99 ICAL_3_12_UNKCOMP_STATUS,
99 ICAL_3_13_BADCOMP_STATUS, 100 ICAL_3_13_BADCOMP_STATUS,
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,
103 ICAL_5_1_UNAVAIL_STATUS, 108 ICAL_5_1_UNAVAIL_STATUS,
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;
107 114
108 115
@@ -110,6 +117,7 @@ const char* icalenum_reqstat_desc(icalrequeststatus stat);
110short icalenum_reqstat_major(icalrequeststatus stat); 117short icalenum_reqstat_major(icalrequeststatus stat);
111short icalenum_reqstat_minor(icalrequeststatus stat); 118short 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
114/*********************************************************************** 122/***********************************************************************
115 * Conversion functions 123 * Conversion functions
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
@@ -29,13 +29,53 @@
29#include "config.h" 29#include "config.h"
30#endif 30#endif
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)
40{ 80{
41 foo++; /* Keep optimizers from removing routine */ 81 foo++; /* Keep optimizers from removing routine */
@@ -79,10 +119,11 @@ struct icalerror_state {
79 icalerrorstate state; 119 icalerrorstate state;
80}; 120};
81 121
82struct icalerror_state error_state_map[] = 122static struct icalerror_state error_state_map[] =
83{ 123{
84 { ICAL_BADARG_ERROR,ICAL_ERROR_DEFAULT}, 124 { ICAL_BADARG_ERROR,ICAL_ERROR_DEFAULT},
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},
87 { ICAL_PARSE_ERROR,ICAL_ERROR_DEFAULT}, 128 { ICAL_PARSE_ERROR,ICAL_ERROR_DEFAULT},
88 { ICAL_INTERNAL_ERROR,ICAL_ERROR_DEFAULT}, 129 { ICAL_INTERNAL_ERROR,ICAL_ERROR_DEFAULT},
@@ -104,6 +145,7 @@ static struct icalerror_string_map string_map[] =
104{ 145{
105 {"BADARG",ICAL_BADARG_ERROR,"BADARG: Bad argument to function"}, 146 {"BADARG",ICAL_BADARG_ERROR,"BADARG: Bad argument to function"},
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"},
108 { "PARSE",ICAL_PARSE_ERROR,"PARSE: Failed to parse a part of an iCal component"}, 150 { "PARSE",ICAL_PARSE_ERROR,"PARSE: Failed to parse a part of an iCal component"},
109 {"INTERNAL",ICAL_INTERNAL_ERROR,"INTERNAL: Random internal error. This indicates an error in the library code, not an error in use"}, 151 {"INTERNAL",ICAL_INTERNAL_ERROR,"INTERNAL: Random internal error. This indicates an error in the library code, not an error in use"},
@@ -168,7 +210,7 @@ void icalerror_set_error_state( icalerrorenum error,
168{ 210{
169 int i; 211 int i;
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){
173 error_state_map[i].state = state; 215 error_state_map[i].state = state;
174 } 216 }
@@ -179,7 +221,7 @@ icalerrorstate icalerror_get_error_state( icalerrorenum error)
179{ 221{
180 int i; 222 int i;
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){
184 return error_state_map[i].state; 226 return error_state_map[i].state;
185 } 227 }
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
@@ -38,7 +38,7 @@
38#define ICAL_SETERROR_ISFUNC 38#define ICAL_SETERROR_ISFUNC
39 39
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
43 below */ 43 below */
44void icalerror_stop_here(void); 44void icalerror_stop_here(void);
@@ -46,7 +46,7 @@ void icalerror_stop_here(void);
46void icalerror_crash_here(void); 46void icalerror_crash_here(void);
47 47
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,
51 ICAL_NEWFAILED_ERROR, 51 ICAL_NEWFAILED_ERROR,
52 ICAL_ALLOCATION_ERROR, 52 ICAL_ALLOCATION_ERROR,
@@ -56,15 +56,18 @@ typedef enum icalerrorenum {
56 ICAL_FILE_ERROR, 56 ICAL_FILE_ERROR,
57 ICAL_USAGE_ERROR, 57 ICAL_USAGE_ERROR,
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
62} icalerrorenum; 61} 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;
69 72
70/* Warning messages */ 73/* Warning messages */
@@ -77,6 +80,7 @@ extern int icalerror_errors_are_fatal;
77 80
78 81
79void icalerror_clear_errno(void); 82void icalerror_clear_errno(void);
83void _icalerror_set_errno(icalerrorenum);
80 84
81/* Make an individual error fatal or non-fatal. */ 85/* Make an individual error fatal or non-fatal. */
82typedef enum icalerrorstate { 86typedef enum icalerrorstate {
@@ -94,14 +98,15 @@ icalerrorstate icalerror_get_error_state( icalerrorenum error);
94#ifndef ICAL_SETERROR_ISFUNC 98#ifndef ICAL_SETERROR_ISFUNC
95#define icalerror_set_errno(x) \ 99#define icalerror_set_errno(x) \
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 || \
98 (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \ 103 (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \
99 icalerror_errors_are_fatal == 1 )){ \ 104 icalerror_errors_are_fatal == 1 )){ \
100 icalerror_warn(icalerror_strerror(x)); \ 105 icalerror_warn(icalerror_strerror(x)); \
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
106 111
107#ifdef ICAL_ERRORS_ARE_FATAL 112#ifdef ICAL_ERRORS_ARE_FATAL
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
@@ -22,11 +22,14 @@
22#include "icalproperty.h" 22#include "icalproperty.h"
23#include "icalerror.h" 23#include "icalerror.h"
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
31int* icallangbind_new_array(int size){ 34int* icallangbind_new_array(int size){
32 int* p = (int*)malloc(size*sizeof(int)); 35 int* p = (int*)malloc(size*sizeof(int));
@@ -41,11 +44,28 @@ int icallangbind_access_array(int* array, int index) {
41 return array[index]; 44 return array[index];
42} 45}
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,
50 const char* prop) 70 const char* prop)
51{ 71{
@@ -132,6 +152,7 @@ icalcomponent* icallangbind_get_next_component(icalcomponent *c,
132 152
133#define APPENDC(x) icalmemory_append_char(&buf, &buf_ptr, &buf_size, x); 153#define APPENDC(x) icalmemory_append_char(&buf, &buf_ptr, &buf_size, x);
134 154
155
135const char* icallangbind_property_eval_string(icalproperty* prop, char* sep) 156const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
136{ 157{
137 char tmp[25]; 158 char tmp[25];
@@ -153,14 +174,14 @@ const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
153 APPENDS(" 'name' "); 174 APPENDS(" 'name' ");
154 APPENDS(sep); 175 APPENDS(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('\'');
158 179
159 if(value){ 180 if(value){
160 APPENDS(", 'value_type' "); 181 APPENDS(", 'value_type' ");
161 APPENDS(sep); 182 APPENDS(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('\'');
165 } 186 }
166 187
@@ -269,7 +290,23 @@ int icallangbind_string_to_open_flag(const char* str)
269 if (strcmp(str,"r") == 0) {return O_RDONLY;} 290 if (strcmp(str,"r") == 0) {return O_RDONLY;}
270 else if (strcmp(str,"r+") == 0) {return O_RDWR;} 291 else if (strcmp(str,"r+") == 0) {return O_RDWR;}
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;}
273 else return -1; 295 else return -1;
274} 296}
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
@@ -41,9 +41,14 @@ icalcomponent* icallangbind_get_first_component(icalcomponent *c,
41icalcomponent* icallangbind_get_next_component(icalcomponent *c, 41icalcomponent* icallangbind_get_next_component(icalcomponent *c,
42 const char* comp); 42 const char* comp);
43 43
44icalparameter* icallangbind_get_first_parameter(icalproperty *prop);
45
46icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
44 47
45const char* icallangbind_property_eval_string(icalproperty* prop, char* sep); 48const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
46 49
47 50
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
@@ -32,7 +32,11 @@
32 32
33 ======================================================================*/ 33 ======================================================================*/
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
37 * memory buffer, but having libical pass out newly allocated memory 41 * memory buffer, but having libical pass out newly allocated memory
38 * makes it difficult to de-allocate the memory. 42 * makes it difficult to de-allocate the memory.
@@ -41,7 +45,8 @@
41 * out references to memory which the caller does not own, and be able 45 * out references to memory which the caller does not own, and be able
42 * to de-allocate the memory later. The ring allows libical to have 46 * to de-allocate the memory later. The ring allows libical to have
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
46#define ICALMEMORY_C 51#define ICALMEMORY_C
47 52
@@ -60,47 +65,116 @@
60#include <stdlib.h> /* for malloc, realloc */ 65#include <stdlib.h> /* for malloc, realloc */
61#include <string.h> /* for memset(), strdup */ 66#include <string.h> /* for memset(), strdup */
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 }
91 162
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 }
97 167
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*
105icalmemory_tmp_buffer (size_t size) 179icalmemory_tmp_buffer (size_t size)
106{ 180{
@@ -124,24 +198,28 @@ icalmemory_tmp_buffer (size_t size)
124 return buf; 198 return buf;
125} 199}
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}
141 219
142 220
143 221
144/* Like strdup, but the buffer is on the ring. */ 222/** Like strdup, but the buffer is on the ring. */
145char* 223char*
146icalmemory_tmp_copy(const char* str) 224icalmemory_tmp_copy(const char* str)
147{ 225{
@@ -170,8 +248,10 @@ icalmemory_free_tmp_buffer (void* buf)
170} 248}
171 249
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
176void* icalmemory_new_buffer(size_t size) 256void* icalmemory_new_buffer(size_t size)
177{ 257{
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
@@ -26,13 +26,11 @@
26#ifndef ICALMEMORY_H 26#ifndef ICALMEMORY_H
27#define ICALMEMORY_H 27#define ICALMEMORY_H
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
37/* Tmp buffers are managed by ical. References can be returned to the 35/* Tmp buffers are managed by ical. References can be returned to the
38 caller, although the caller will not own the memory. */ 36 caller, although the caller will not own the memory. */
@@ -40,11 +38,11 @@
40void* icalmemory_tmp_buffer(size_t size); 38void* icalmemory_tmp_buffer(size_t size);
41char* icalmemory_tmp_copy(const char* str); 39char* 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*);
45 43
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);
49 47
50/* Non-tmp buffers must be freed. These are mostly wrappers around 48/* Non-tmp buffers must be freed. These are mostly wrappers around
@@ -55,7 +53,8 @@ void* icalmemory_new_buffer(size_t size);
55void* icalmemory_resize_buffer(void* buf, size_t size); 53void* icalmemory_resize_buffer(void* buf, size_t size);
56void icalmemory_free_buffer(void* buf); 54void 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
60 too small. 'buf_size' is the size of 'buf' and will be changed if 59 too small. 'buf_size' is the size of 'buf' and will be changed if
61 'buf' is reallocated. 'pos' will point to the last byte of the new 60 'buf' is reallocated. 'pos' will point to the last byte of the new
@@ -71,12 +70,12 @@ void icalmemory_free_buffer(void* buf);
71void icalmemory_append_string(char** buf, char** pos, size_t* buf_size, 70void icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
72 const char* string); 71 const char* string);
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,
76 char ch); 75 char ch);
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);
81 80
82#endif /* !ICALMEMORY_H */ 81#endif /* !ICALMEMORY_H */
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
@@ -34,12 +34,14 @@
34#include <string.h> /* For strdup */ 34#include <string.h> /* For strdup */
35#include <stdio.h> /* for snprintf*/ 35#include <stdio.h> /* for snprintf*/
36 36
37int snprintf(char *str, size_t n, char const *fmt, ...);
38
39#ifdef DMALLOC 37#ifdef DMALLOC
40#include "dmalloc.h" 38#include "dmalloc.h"
41#endif 39#endif
42 40
41#ifdef WIN32
42#define snprintf _snprintf
43#define strcasecmp stricmp
44#endif
43 45
44/* These *_part routines are called by the MIME parser via the 46/* These *_part routines are called by the MIME parser via the
45 local_action_map */ 47 local_action_map */
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
@@ -78,53 +78,48 @@ icalparameter_new (icalparameter_kind kind)
78} 78}
79 79
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
87/* HACK. This always triggers, even when parameter is non-zero 84/* HACK. This always triggers, even when parameter is non-zero
88 icalerror_check_arg_rv((parameter==0),"parameter");*/ 85 icalerror_check_arg_rv((parameter==0),"parameter");*/
89 86
90 87
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;
97 } 94 }
98#endif 95#endif
99 96
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}
115 112
116 113
117 114
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
129 if (new == 0){ 124 if (new == 0){
130 return 0; 125 return 0;
@@ -197,17 +192,27 @@ icalparameter* icalparameter_new_from_string(const char *str)
197 192
198} 193}
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;
205 char* buf; 210 char* buf;
206 char* buf_ptr; 211 char* buf_ptr;
207 char *out_buf; 212 char *out_buf;
208 const char *kind_string; 213 const char *kind_string;
209 214
210 icalerror_check_arg_rz( (parameter!=0), "parameter"); 215 icalerror_check_arg_rz( (param!=0), "parameter");
211 216
212 /* Create new buffer that we can append names, parameters and a 217 /* Create new buffer that we can append names, parameters and a
213 value to, and reallocate as needed. Later, this buffer will be 218 value to, and reallocate as needed. Later, this buffer will be
@@ -217,19 +222,18 @@ icalparameter_as_ical_string (icalparameter* parameter)
217 222
218 buf = icalmemory_new_buffer(buf_size); 223 buf = icalmemory_new_buffer(buf_size);
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
227 } else { 231 } else {
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)
234 { 238 {
235 icalerror_set_errno(ICAL_BADARG_ERROR); 239 icalerror_set_errno(ICAL_BADARG_ERROR);
@@ -244,10 +248,20 @@ icalparameter_as_ical_string (icalparameter* parameter)
244 248
245 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "="); 249 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "=");
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);
252 } else { 266 } else {
253 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 267 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
@@ -278,7 +292,7 @@ icalparameter_isa (icalparameter* parameter)
278 return ICAL_NO_PARAMETER; 292 return ICAL_NO_PARAMETER;
279 } 293 }
280 294
281 return ((struct icalparameter_impl *)parameter)->kind; 295 return parameter->kind;
282} 296}
283 297
284 298
@@ -302,17 +316,16 @@ icalparameter_isa_parameter (void* parameter)
302void 316void
303icalparameter_set_xname (icalparameter* param, const char* v) 317icalparameter_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");
307 icalerror_check_arg_rv( (v!=0),"v"); 320 icalerror_check_arg_rv( (v!=0),"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;
317 } 330 }
318 331
@@ -321,27 +334,24 @@ icalparameter_set_xname (icalparameter* param, const char* v)
321const char* 334const char*
322icalparameter_get_xname (icalparameter* param) 335icalparameter_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}
329 341
330void 342void
331icalparameter_set_xvalue (icalparameter* param, const char* v) 343icalparameter_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");
336 icalerror_check_arg_rv( (v!=0),"v"); 346 icalerror_check_arg_rv( (v!=0),"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;
346 } 356 }
347 357
@@ -350,31 +360,24 @@ icalparameter_set_xvalue (icalparameter* param, const char* v)
350const char* 360const char*
351icalparameter_get_xvalue (icalparameter* param) 361icalparameter_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}
360 367
361void icalparameter_set_parent(icalparameter* param, 368void icalparameter_set_parent(icalparameter* param,
362 icalproperty* property) 369 icalproperty* property)
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}
370 375
371icalproperty* icalparameter_get_parent(icalparameter* param) 376icalproperty* 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}
379 382
380 383
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
@@ -32,7 +32,7 @@
32#include "icalderivedparameter.h" 32#include "icalderivedparameter.h"
33 33
34/* Declared in icalderivedparameter.h */ 34/* Declared in icalderivedparameter.h */
35/*typedef void icalparameter;*/ 35/*typedef struct icalparameter_impl icalparameter;*/
36 36
37icalparameter* icalparameter_new(icalparameter_kind kind); 37icalparameter* icalparameter_new(icalparameter_kind kind);
38icalparameter* icalparameter_new_clone(icalparameter* p); 38icalparameter* icalparameter_new_clone(icalparameter* p);
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,4 +1,4 @@
1/* -*- Mode: C -*- 1/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*-
2 ====================================================================== 2 ======================================================================
3 FILE: icalparser.c 3 FILE: icalparser.c
4 CREATOR: eric 04 August 1999 4 CREATOR: eric 04 August 1999
@@ -38,9 +38,7 @@
38#endif 38#endif
39 39
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"
45#include "icalvalue.h" 43#include "icalvalue.h"
46#include "icalderivedparameter.h" 44#include "icalderivedparameter.h"
@@ -52,13 +50,28 @@
52#include <stdio.h> /* For FILE and fgets and sprintf */ 50#include <stdio.h> /* For FILE and fgets and sprintf */
53#include <stdlib.h> /* for free */ 51#include <stdlib.h> /* for free */
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);
63char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind); 76char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind);
64char* icalparser_get_prop_name(char* line, char** end); 77char* icalparser_get_prop_name(char* line, char** end);
@@ -81,7 +94,7 @@ struct icalparser_impl
81 pvl_list components; 94 pvl_list components;
82 95
83 void *line_gen_data; 96 void *line_gen_data;
84 97
85}; 98};
86 99
87 100
@@ -100,6 +113,7 @@ icalparser* icalparser_new(void)
100 impl->state = ICALPARSER_SUCCESS; 113 impl->state = ICALPARSER_SUCCESS;
101 impl->tmp_buf_size = TMP_BUF_SIZE; 114 impl->tmp_buf_size = TMP_BUF_SIZE;
102 impl->buffer_full = 0; 115 impl->buffer_full = 0;
116 impl->continuation_line = 0;
103 impl->lineno = 0; 117 impl->lineno = 0;
104 impl->continuation_line = 0; 118 impl->continuation_line = 0;
105 memset(impl->temp,0, TMP_BUF_SIZE); 119 memset(impl->temp,0, TMP_BUF_SIZE);
@@ -110,27 +124,24 @@ icalparser* icalparser_new(void)
110 124
111void icalparser_free(icalparser* parser) 125void 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);
122 } 135 }
123 136
124 pvl_free(impl->components); 137 pvl_free(parser->components);
125 138
126 free(impl); 139 free(parser);
127} 140}
128 141
129void icalparser_set_gen_data(icalparser* parser, void* data) 142void 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}
135 146
136 147
@@ -140,37 +151,38 @@ icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind,
140 151
141 152
142 153
143char* icalparser_get_next_char(char c, char *str) 154char* icalparser_get_next_char(char c, char *str, int qm)
144{ 155{
145 int quote_mode = 0; 156 int quote_mode = 0;
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
165 } 176 }
166 177
167 return 0; 178 return 0;
168} 179}
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;
175 187
176 buf = icalmemory_tmp_buffer(size+1); 188 buf = icalmemory_tmp_buffer(size+1);
@@ -178,64 +190,17 @@ char* make_segment(char* start, char* end)
178 190
179 strncpy(buf,start,size); 191 strncpy(buf,start,size);
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
240char* icalparser_get_prop_name(char* line, char** end) 205char* icalparser_get_prop_name(char* line, char** end)
241{ 206{
@@ -243,8 +208,8 @@ char* icalparser_get_prop_name(char* line, char** end)
243 char* v; 208 char* v;
244 char *str; 209 char *str;
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) {
249 return 0; 214 return 0;
250 } 215 }
@@ -262,13 +227,13 @@ char* icalparser_get_prop_name(char* line, char** end)
262 return str; 227 return str;
263} 228}
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;
269 char *str; 234 char *str;
270 235
271 next = icalparser_get_next_char('=',line); 236 next = icalparser_get_next_char('=',line,1);
272 237
273 if (next == 0) { 238 if (next == 0) {
274 return 0; 239 return 0;
@@ -276,17 +241,26 @@ char* icalparser_get_param_name(char* line, char **end)
276 241
277 str = make_segment(line,next); 242 str = make_segment(line,next);
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;
287 char *str; 261 char *str;
288 262
289 next = icalparser_get_next_char(',',line); 263 next = icalparser_get_next_char(',',line,1);
290 264
291 if (next == 0){ 265 if (next == 0){
292 next = (char*)(size_t)line+(size_t)strlen(line);\ 266 next = (char*)(size_t)line+(size_t)strlen(line);\
@@ -299,10 +273,11 @@ char* icalparser_get_next_paramvalue(char* line, char **end)
299 *end = next+1; 273 *end = next+1;
300 return str; 274 return str;
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
307 comma after line and will set the next place to start searching in 282 comma after line and will set the next place to start searching in
308 end. */ 283 end. */
@@ -318,7 +293,7 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
318 p = line; 293 p = line;
319 while(1){ 294 while(1){
320 295
321 next = icalparser_get_next_char(',',p); 296 next = icalparser_get_next_char(',',p,1);
322 297
323 /* Unforunately, RFC2445 says that for the RECUR value, COMMA 298 /* Unforunately, RFC2445 says that for the RECUR value, COMMA
324 can both seperate digits in a list, and it can seperate 299 can both seperate digits in a list, and it can seperate
@@ -340,6 +315,15 @@ char* icalparser_get_next_value(char* line, char **end, icalvalue_kind kind)
340 continue; 315 continue;
341 } 316 }
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
344 /* If the comma is preceeded by a '\', then it is a literal and 328 /* If the comma is preceeded by a '\', then it is a literal and
345 not a value seperator*/ 329 not a value seperator*/
@@ -379,14 +363,14 @@ char* icalparser_get_next_parameter(char* line,char** end)
379 char *v; 363 char *v;
380 char *str; 364 char *str;
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
385 /* There is no ';' or, it is after the ':' that marks the beginning of 369 /* There is no ';' or, it is after the ':' that marks the beginning of
386 the value */ 370 the value */
387 371
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 }
391 375
392 if (next != 0) { 376 if (next != 0) {
@@ -399,23 +383,23 @@ char* icalparser_get_next_parameter(char* line,char** end)
399 } 383 }
400} 384}
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,
406 char* (*line_gen_func)(char *s, size_t size, void *d)) 392 char* (*line_gen_func)(char *s, size_t size, void *d))
407{ 393{
408 char *line; 394 char *line;
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
414 line_p = line = icalmemory_new_buffer(buf_size); 398 line_p = line = icalmemory_new_buffer(buf_size);
415 line[0] = '\0'; 399 line[0] = '\0';
416 400
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
420 again. Otherwise, exit the loop. */ 404 again. Otherwise, exit the loop. */
421 405
@@ -429,23 +413,23 @@ char* icalparser_get_line(icalparser *parser,
429 413
430 /* The tmp buffer is not clear, so transfer the data in it to the 414 /* The tmp buffer is not clear, so transfer the data in it to the
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
434 /* If the last position in the temp buffer is occupied, 418 /* If the last position in the temp buffer is occupied,
435 mark the buffer as full. The means we will do another 419 mark the buffer as full. The means we will do another
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 }
444 428
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--;
450 434
451 if ( *(line_p-1) == '\r'){ 435 if ( *(line_p-1) == '\r'){
@@ -454,24 +438,24 @@ char* icalparser_get_line(icalparser *parser,
454 438
455 /* copy one space up to eliminate the leading space*/ 439 /* copy one space up to eliminate the leading space*/
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 */
471 455
472 /* If the first position is clear, it means we didn't get 456 /* If the first position is clear, it means we didn't get
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
476 if(line[0] != '\0'){ 460 if(line[0] != '\0'){
477 /* There is data in the output, so fall trhough and process it*/ 461 /* There is data in the output, so fall trhough and process it*/
@@ -490,12 +474,11 @@ char* icalparser_get_line(icalparser *parser,
490 begins with a ' ', then the buffer holds a continuation 474 begins with a ' ', then the buffer holds a continuation
491 line, so keep reading. */ 475 line, so keep reading. */
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
500 /* The buffer was filled on the last read, so read again */ 483 /* The buffer was filled on the last read, so read again */
501 484
@@ -519,11 +502,17 @@ char* icalparser_get_line(icalparser *parser,
519 *(line_p) = '\0'; 502 *(line_p) = '\0';
520 } 503 }
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;
523 512
524} 513}
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)
528{ 517{
529 char temp[1024]; 518 char temp[1024];
@@ -542,7 +531,8 @@ void insert_error(icalcomponent* comp, char* text,
542 0)); 531 0));
543} 532}
544 533
545int line_is_blank(char* line){ 534
535static int line_is_blank(char* line){
546 int i=0; 536 int i=0;
547 537
548 for(i=0; *(line+i)!=0; i++){ 538 for(i=0; *(line+i)!=0; i++){
@@ -564,8 +554,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
564 char* line; 554 char* line;
565 icalcomponent *c=0; 555 icalcomponent *c=0;
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
570 icalerror_check_arg_rz((parser !=0),"parser"); 560 icalerror_check_arg_rz((parser !=0),"parser");
571 561
@@ -580,8 +570,8 @@ icalcomponent* icalparser_parse(icalparser *parser,
580 /* This is bad news... assert? */ 570 /* This is bad news... assert? */
581 } 571 }
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
586 if (root == 0){ 576 if (root == 0){
587 /* Just one component */ 577 /* Just one component */
@@ -606,10 +596,12 @@ icalcomponent* icalparser_parse(icalparser *parser,
606 c = 0; 596 c = 0;
607 597
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
614 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); 606 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
615 607
@@ -621,7 +613,6 @@ icalcomponent* icalparser_parse(icalparser *parser,
621icalcomponent* icalparser_add_line(icalparser* parser, 613icalcomponent* icalparser_add_line(icalparser* parser,
622 char* line) 614 char* line)
623{ 615{
624 char *p;
625 char *str; 616 char *str;
626 char *end; 617 char *end;
627 int vcount = 0; 618 int vcount = 0;
@@ -631,13 +622,12 @@ icalcomponent* icalparser_add_line(icalparser* parser,
631 icalvalue_kind value_kind = ICAL_NO_VALUE; 622 icalvalue_kind value_kind = ICAL_NO_VALUE;
632 623
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");
636 626
637 627
638 if (line == 0) 628 if (line == 0)
639 { 629 {
640 impl->state = ICALPARSER_ERROR; 630 parser->state = ICALPARSER_ERROR;
641 return 0; 631 return 0;
642 } 632 }
643 633
@@ -655,7 +645,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
655 645
656 if (str == 0 || strlen(str) == 0 ){ 646 if (str == 0 || strlen(str) == 0 ){
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
660 if (tail){ 650 if (tail){
661 insert_error(tail,line, 651 insert_error(tail,line,
@@ -663,7 +653,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
663 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); 653 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
664 } 654 }
665 tail = 0; 655 tail = 0;
666 impl->state = ICALPARSER_ERROR; 656 parser->state = ICALPARSER_ERROR;
667 return 0; 657 return 0;
668 } 658 }
669 659
@@ -673,17 +663,22 @@ icalcomponent* icalparser_add_line(icalparser* parser,
673 /* If the property name is BEGIN or END, we are actually 663 /* If the property name is BEGIN or END, we are actually
674 starting or ending a new component */ 664 starting or ending a new component */
675 665
666
676 if(strcmp(str,"BEGIN") == 0){ 667 if(strcmp(str,"BEGIN") == 0){
677 icalcomponent *c; 668 icalcomponent *c;
678 icalcomponent_kind comp_kind; 669 icalcomponent_kind comp_kind;
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);
682 674
683 675
684 comp_kind = icalenum_string_to_component_kind(str); 676 comp_kind = icalenum_string_to_component_kind(str);
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);
688 insert_error(c,str,"Parse error in component name", 683 insert_error(c,str,"Parse error in component name",
689 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); 684 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
@@ -697,48 +692,48 @@ icalcomponent* icalparser_add_line(icalparser* parser,
697 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); 692 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
698 } 693 }
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;
704 699
705 } else if (strcmp(str,"END") == 0 ) { 700 } else if (strcmp(str,"END") == 0 ) {
706 icalcomponent* tail; 701 icalcomponent* tail;
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);
710 705
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 }
719 714
720 tail = 0; 715 tail = 0;
721 716
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;
739 734
740 } else { 735 } else {
741 impl->state = ICALPARSER_END_COMP; 736 parser->state = ICALPARSER_END_COMP;
742 return 0; 737 return 0;
743 } 738 }
744 } 739 }
@@ -747,8 +742,8 @@ icalcomponent* icalparser_add_line(icalparser* parser,
747 /* There is no point in continuing if we have not seen a 742 /* There is no point in continuing if we have not seen a
748 component yet */ 743 component yet */
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;
753 } 748 }
754 749
@@ -767,7 +762,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
767 prop = icalproperty_new(prop_kind); 762 prop = icalproperty_new(prop_kind);
768 763
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
772 if(prop_kind==ICAL_X_PROPERTY){ 767 if(prop_kind==ICAL_X_PROPERTY){
773 icalproperty_set_x_name(prop,str); 768 icalproperty_set_x_name(prop,str);
@@ -780,13 +775,13 @@ icalcomponent* icalparser_add_line(icalparser* parser,
780 value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop)); 775 value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop));
781 776
782 } else { 777 } else {
783 icalcomponent* tail = pvl_data(pvl_tail(impl->components)); 778 icalcomponent* tail = pvl_data(pvl_tail(parser->components));
784 779
785 insert_error(tail,str,"Parse error in property name", 780 insert_error(tail,str,"Parse error in property name",
786 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR); 781 ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);
787 782
788 tail = 0; 783 tail = 0;
789 impl->state = ICALPARSER_ERROR; 784 parser->state = ICALPARSER_ERROR;
790 return 0; 785 return 0;
791 } 786 }
792 787
@@ -796,7 +791,6 @@ icalcomponent* icalparser_add_line(icalparser* parser,
796 791
797 /* Now, add any parameters to the last property */ 792 /* Now, add any parameters to the last property */
798 793
799 p = 0;
800 while(1) { 794 while(1) {
801 795
802 if (*(end-1) == ':'){ 796 if (*(end-1) == ':'){
@@ -814,7 +808,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
814 808
815 icalparameter *param = 0; 809 icalparameter *param = 0;
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
819 name = icalparser_get_param_name(str,&pvalue); 813 name = icalparser_get_param_name(str,&pvalue);
820 814
@@ -845,7 +839,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
845 insert_error(tail, str, "Cant parse parameter name", 839 insert_error(tail, str, "Cant parse parameter name",
846 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR); 840 ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
847 tail = 0; 841 tail = 0;
848 impl->state = ICALPARSER_ERROR; 842 parser->state = ICALPARSER_ERROR;
849 return 0; 843 return 0;
850 } 844 }
851 845
@@ -855,7 +849,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
855 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR); 849 ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);
856 850
857 tail = 0; 851 tail = 0;
858 impl->state = ICALPARSER_ERROR; 852 parser->state = ICALPARSER_ERROR;
859 continue; 853 continue;
860 } 854 }
861 855
@@ -885,7 +879,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
885 879
886 icalparameter_free(param); 880 icalparameter_free(param);
887 tail = 0; 881 tail = 0;
888 impl->state = ICALPARSER_ERROR; 882 parser->state = ICALPARSER_ERROR;
889 return 0; 883 return 0;
890 } 884 }
891 } 885 }
@@ -919,7 +913,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
919 if (vcount > 0){ 913 if (vcount > 0){
920 /* Actually, only clone after the second value */ 914 /* Actually, only clone after the second value */
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
924 icalcomponent_add_property(tail, clone); 918 icalcomponent_add_property(tail, clone);
925 prop = clone; 919 prop = clone;
@@ -933,7 +927,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
933 char temp[200]; /* HACK */ 927 char temp[200]; /* HACK */
934 928
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
938 sprintf(temp,"Cant parse as %s value in %s property. Removing entire property", 932 sprintf(temp,"Cant parse as %s value in %s property. Removing entire property",
939 icalvalue_kind_to_string(value_kind), 933 icalvalue_kind_to_string(value_kind),
@@ -947,7 +941,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
947 icalproperty_free(prop); 941 icalproperty_free(prop);
948 prop = 0; 942 prop = 0;
949 tail = 0; 943 tail = 0;
950 impl->state = ICALPARSER_ERROR; 944 parser->state = ICALPARSER_ERROR;
951 return 0; 945 return 0;
952 946
953 } else { 947 } else {
@@ -961,7 +955,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
961 char temp[200]; /* HACK */ 955 char temp[200]; /* HACK */
962 956
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
966 sprintf(temp,"No value for %s property. Removing entire property", 960 sprintf(temp,"No value for %s property. Removing entire property",
967 icalproperty_kind_to_string(prop_kind)); 961 icalproperty_kind_to_string(prop_kind));
@@ -974,7 +968,7 @@ icalcomponent* icalparser_add_line(icalparser* parser,
974 icalproperty_free(prop); 968 icalproperty_free(prop);
975 prop = 0; 969 prop = 0;
976 tail = 0; 970 tail = 0;
977 impl->state = ICALPARSER_ERROR; 971 parser->state = ICALPARSER_ERROR;
978 return 0; 972 return 0;
979 } else { 973 } else {
980 974
@@ -987,14 +981,14 @@ icalcomponent* icalparser_add_line(icalparser* parser,
987 * End of component parsing. 981 * End of component parsing.
988 *****************************************************************/ 982 *****************************************************************/
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;
999 } 993 }
1000 994
@@ -1002,14 +996,12 @@ icalcomponent* icalparser_add_line(icalparser* parser,
1002 996
1003icalparser_state icalparser_get_state(icalparser* parser) 997icalparser_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
1008} 1001}
1009 1002
1010icalcomponent* icalparser_clean(icalparser* parser) 1003icalcomponent* icalparser_clean(icalparser* parser)
1011{ 1004{
1012 struct icalparser_impl* impl = (struct icalparser_impl*) parser;
1013 icalcomponent *tail; 1005 icalcomponent *tail;
1014 1006
1015 icalerror_check_arg_rz((parser != 0 ),"parser"); 1007 icalerror_check_arg_rz((parser != 0 ),"parser");
@@ -1017,27 +1009,27 @@ icalcomponent* icalparser_clean(icalparser* parser)
1017 /* We won't get a clean exit if some components did not have an 1009 /* We won't get a clean exit if some components did not have an
1018 "END" tag. Clear off any component that may be left in the list */ 1010 "END" tag. Clear off any component that may be left in the list */
1019 1011
1020 while((tail=pvl_data(pvl_tail(impl->components))) != 0){ 1012 while((tail=pvl_data(pvl_tail(parser->components))) != 0){
1021 1013
1022 insert_error(tail," ", 1014 insert_error(tail," ",
1023 "Missing END tag for this component. Closing component at end of input.", 1015 "Missing END tag for this component. Closing component at end of input.",
1024 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); 1016 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);
1025 1017
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 }
1036 } 1028 }
1037 1029
1038 } 1030 }
1039 1031
1040 return impl->root_component; 1032 return parser->root_component;
1041 1033
1042} 1034}
1043 1035
@@ -1046,7 +1038,8 @@ struct slg_data {
1046 const char* str; 1038 const char* str;
1047}; 1039};
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{
1051 char *n; 1044 char *n;
1052 size_t size; 1045 size_t size;
@@ -1100,7 +1093,7 @@ icalcomponent* icalparser_parse_string(const char* str)
1100 1093
1101 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); 1094 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL);
1102 1095
1103 c = icalparser_parse(p,string_line_generator); 1096 c = icalparser_parse(p,icalparser_string_line_generator);
1104 1097
1105 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); 1098 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
1106 1099
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
@@ -33,16 +33,17 @@
33 33
34#include <stdio.h> /* For FILE* */ 34#include <stdio.h> /* For FILE* */
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
47typedef enum icalparser_state { 48typedef enum icalparser_state {
48 ICALPARSER_ERROR, 49 ICALPARSER_ERROR,
@@ -59,18 +60,20 @@ icalparser_state icalparser_get_state(icalparser* parser);
59void icalparser_free(icalparser* parser); 60void icalparser_free(icalparser* parser);
60 61
61 62
62/*********************************************************************** 63/**
63 * Message oriented parsing. icalparser_parse takes a string that 64 * Message oriented parsing. icalparser_parse takes a string that
64 * holds the text ( in RFC 2445 format ) and returns a pointer to an 65 * holds the text ( in RFC 2445 format ) and returns a pointer to an
65 * icalcomponent. The caller owns the memory. line_gen_func is a 66 * icalcomponent. The caller owns the memory. line_gen_func is a
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);
75 78
76 79
@@ -81,13 +84,13 @@ icalcomponent* icalparser_parse_string(const char* str);
81 * Parser support functions 84 * Parser support functions
82 ***********************************************************************/ 85 ***********************************************************************/
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,
86 const char* str, icalcomponent** errors); 89 const char* str, icalcomponent** errors);
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
93#endif /* !ICALPARSE_H */ 96#endif /* !ICALPARSE_H */
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
@@ -36,14 +36,8 @@
36#include <stdlib.h> 36#include <stdlib.h>
37#include <stdio.h> 37#include <stdio.h>
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
48 42
49 43
@@ -97,10 +91,15 @@ struct icalperiodtype icalperiodtype_from_string (const char* str)
97 91
98 icalerrno = e; 92 icalerrno = e;
99 93
94 icalmemory_free_buffer(s);
95
100 return p; 96 return p;
101 97
102 error: 98 error:
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;
105} 104}
106 105
@@ -133,13 +132,14 @@ const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
133 132
134 icalmemory_append_string(&buf, &buf_ptr, &buf_size, end); 133 icalmemory_append_string(&buf, &buf_ptr, &buf_size, end);
135 134
135 icalmemory_add_tmp_buffer(buf);
136 136
137 return buf; 137 return buf;
138} 138}
139 139
140 140
141 141
142struct icalperiodtype icalperiodtype_null_period() { 142struct icalperiodtype icalperiodtype_null_period(void) {
143 struct icalperiodtype p; 143 struct icalperiodtype p;
144 p.start = icaltime_null_time(); 144 p.start = icaltime_null_time();
145 p.end = icaltime_null_time(); 145 p.end = icaltime_null_time();
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
@@ -42,12 +42,12 @@ struct icalperiodtype
42struct icalperiodtype icalperiodtype_from_string (const char* str); 42struct icalperiodtype icalperiodtype_from_string (const char* str);
43 43
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
52#endif /* !ICALTIME_H */ 52#endif /* !ICALTIME_H */
53 53
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
@@ -23,7 +23,6 @@
23 The original code is icalproperty.c 23 The original code is icalproperty.c
24 24
25======================================================================*/ 25======================================================================*/
26/*#line 27 "icalproperty.c.in"*/
27 26
28#ifdef HAVE_CONFIG_H 27#ifdef HAVE_CONFIG_H
29#include <config.h> 28#include <config.h>
@@ -45,9 +44,10 @@
45#include <stdio.h> /* for printf */ 44#include <stdio.h> /* for printf */
46#include <stdarg.h> /* for va_list, va_start, etc. */ 45#include <stdarg.h> /* for va_list, va_start, etc. */
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
52/* Private routines for icalproperty */ 52/* Private routines for icalproperty */
53void icalvalue_set_parent(icalvalue* value, 53void icalvalue_set_parent(icalvalue* value,
@@ -72,37 +72,34 @@ struct icalproperty_impl
72 icalcomponent *parent; 72 icalcomponent *parent;
73}; 73};
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) {
83 80
84 if (icalvalue_isa_value(vp) != 0 ){ 81 if (icalvalue_isa_value(vp) != 0 ){
85 } else if (icalparameter_isa_parameter(vp) != 0 ){ 82 } else if (icalparameter_isa_parameter(vp) != 0 ){
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 }
92 89
93 } 90 }
94
95
96} 91}
97 92
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);
107 return 0; 104 return 0;
108 } 105 }
@@ -123,7 +120,7 @@ icalproperty_new_impl (icalproperty_kind kind)
123icalproperty* 120icalproperty*
124icalproperty_new (icalproperty_kind kind) 121icalproperty_new (icalproperty_kind kind)
125{ 122{
126 if(kind == ICAL_NO_PROPERTY){ 123 if (kind == ICAL_NO_PROPERTY){
127 return 0; 124 return 0;
128 } 125 }
129 126
@@ -132,13 +129,11 @@ icalproperty_new (icalproperty_kind kind)
132 129
133 130
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");
143 icalerror_check_arg_rz((new!=0),"new"); 138 icalerror_check_arg_rz((new!=0),"new");
144 139
@@ -219,15 +214,11 @@ icalproperty* icalproperty_new_from_string(const char* str)
219} 214}
220 215
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
232#ifdef ICAL_FREE_ON_LIST_IS_ERROR 223#ifdef ICAL_FREE_ON_LIST_IS_ERROR
233 icalerror_assert( (p->parent ==0),"Tried to free a property that is still attached to a component. "); 224 icalerror_assert( (p->parent ==0),"Tried to free a property that is still attached to a component. ");
@@ -265,69 +256,135 @@ icalproperty_free (icalproperty* prop)
265} 256}
266 257
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;
319 376
320 icalparameter *orig_val_param 377 icalparameter *orig_val_param
321 = icalproperty_get_first_parameter(prop,ICAL_VALUE_PARAMETER); 378 = icalproperty_get_first_parameter(prop,ICAL_VALUE_PARAMETER);
322 379
323 icalvalue *value = icalproperty_get_value(impl); 380 icalvalue *value = icalproperty_get_value(prop);
324 381
325 icalvalue_kind orig_kind = ICAL_NO_VALUE; 382 icalvalue_kind orig_kind = ICAL_NO_VALUE;
326 383
327 icalvalue_kind this_kind = ICAL_NO_VALUE; 384 icalvalue_kind this_kind = ICAL_NO_VALUE;
328 385
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
332 if(orig_val_param){ 389 if(orig_val_param){
333 orig_kind = (icalvalue_kind)icalparameter_get_value(orig_val_param); 390 orig_kind = (icalvalue_kind)icalparameter_get_value(orig_val_param);
@@ -354,14 +411,55 @@ icalproperty_as_ical_string (icalproperty* prop)
354 /* Don'tinclude the VALUE parameter at all */ 411 /* Don'tinclude the VALUE parameter at all */
355 } 412 }
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 }
366 464
367 /* Append parameters */ 465 /* Append parameters */
@@ -369,29 +467,27 @@ icalproperty_as_ical_string (icalproperty* prop)
369 param != 0; 467 param != 0;
370 param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) { 468 param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) {
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
375 if(kind==ICAL_VALUE_PARAMETER){ 473 if(kind==ICAL_VALUE_PARAMETER){
376 continue; 474 continue;
377 } 475 }
378 476
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;
384 } 482 }
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 }
391 487
392 /* Append value */ 488 /* Append value */
393 489
394 icalmemory_append_string(&buf, &buf_ptr, &buf_size, " :"); 490 icalmemory_append_string(&buf, &buf_ptr, &buf_size, ":");
395 491
396 value = icalproperty_get_value(prop); 492 value = icalproperty_get_value(prop);
397 493
@@ -409,9 +505,8 @@ icalproperty_as_ical_string (icalproperty* prop)
409 /* Now, copy the buffer to a tmp_buffer, which is safe to give to 505 /* Now, copy the buffer to a tmp_buffer, which is safe to give to
410 the caller without worring about de-allocating it. */ 506 the caller without worring about de-allocating it. */
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
416 icalmemory_free_buffer(buf); 511 icalmemory_free_buffer(buf);
417 512
@@ -421,11 +516,9 @@ icalproperty_as_ical_string (icalproperty* prop)
421 516
422 517
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;
430 } 523 }
431 524
@@ -435,10 +528,9 @@ icalproperty_isa (icalproperty* property)
435int 528int
436icalproperty_isa_property (void* property) 529icalproperty_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) {
443 return 1; 535 return 1;
444 } else { 536 } else {
@@ -448,11 +540,9 @@ icalproperty_isa_property (void* property)
448 540
449 541
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");
457 547
458 pvl_push(p->parameters, parameter); 548 pvl_push(p->parameters, parameter);
@@ -468,8 +558,11 @@ icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter)
468 icalerror_check_arg_rv( (parameter!=0),"parameter"); 558 icalerror_check_arg_rv( (parameter!=0),"parameter");
469 559
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
474 icalproperty_add_parameter(prop,parameter); 567 icalproperty_add_parameter(prop,parameter);
475} 568}
@@ -491,7 +584,7 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
491 icalerror_set_errno(ICAL_BADARG_ERROR); 584 icalerror_set_errno(ICAL_BADARG_ERROR);
492 return; 585 return;
493 } 586 }
494 587
495 param = icalparameter_new_from_value_string(kind,value); 588 param = icalparameter_new_from_value_string(kind,value);
496 589
497 if (param == 0){ 590 if (param == 0){
@@ -499,6 +592,10 @@ void icalproperty_set_parameter_from_string(icalproperty* prop,
499 return; 592 return;
500 } 593 }
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);
503 600
504} 601}
@@ -516,17 +613,28 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
516 613
517 kind = icalparameter_string_to_kind(name); 614 kind = icalparameter_string_to_kind(name);
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 */
521 return 0; 618 return 0;
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
526 if (param == 0){ 633 if (param == 0){
527 return 0; 634 return 0;
528 } 635 }
529 636
637
530 str = icalparameter_as_ical_string(param); 638 str = icalparameter_as_ical_string(param);
531 639
532 pv = strchr(str,'='); 640 pv = strchr(str,'=');
@@ -540,32 +648,133 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
540 648
541} 649}
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
549 icalerror_check_arg_rv((prop!=0),"prop"); 679 icalerror_check_arg_rv((prop!=0),"prop");
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;
557 } 687 }
558 } 688 }
559} 689}
560 690
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 }
570 779
571 icalerror_set_errno(ICAL_USAGE_ERROR); 780 icalerror_set_errno(ICAL_USAGE_ERROR);
@@ -574,11 +783,9 @@ icalproperty_count_parameters (icalproperty* prop)
574 783
575 784
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
583 p->parameter_iterator = pvl_head(p->parameters); 790 p->parameter_iterator = pvl_head(p->parameters);
584 791
@@ -602,11 +809,9 @@ icalproperty_get_first_parameter (icalproperty* prop, icalparameter_kind kind)
602 809
603 810
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
611 if (p->parameter_iterator == 0) { 816 if (p->parameter_iterator == 0) {
612 return 0; 817 return 0;
@@ -628,11 +833,9 @@ icalproperty_get_next_parameter (icalproperty* prop, icalparameter_kind kind)
628} 833}
629 834
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");
637 840
638 if (p->value != 0){ 841 if (p->value != 0){
@@ -643,7 +846,7 @@ icalproperty_set_value (icalproperty* prop, icalvalue* value)
643 846
644 p->value = value; 847 p->value = value;
645 848
646 icalvalue_set_parent(value,prop); 849 icalvalue_set_parent(value,p);
647} 850}
648 851
649 852
@@ -691,24 +894,20 @@ void icalproperty_set_value_from_string(icalproperty* prop,const char* str,
691} 894}
692 895
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{
705 icalvalue *value; 906 icalvalue *value;
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
713 return icalvalue_as_ical_string(value); 912 return icalvalue_as_ical_string(value);
714} 913}
@@ -716,35 +915,37 @@ const char* icalproperty_get_value_as_string(icalproperty* prop)
716 915
717void icalproperty_set_x_name(icalproperty* prop, const char* name) 916void 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");
722 icalerror_check_arg_rv( (prop!=0),"prop"); 919 icalerror_check_arg_rv( (prop!=0),"prop");
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);
732 } 929 }
733 930
734} 931}
735 932
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}
744 938
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{
749 950
750 const char* property_name = 0; 951 const char* property_name = 0;
@@ -752,14 +953,12 @@ const char* icalproperty_get_name (icalproperty* prop)
752 char* buf = icalmemory_new_buffer(buf_size); 953 char* buf = icalmemory_new_buffer(buf_size);
753 char* buf_ptr = buf; 954 char* buf_ptr = buf;
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 }
764 963
765 if (property_name == 0 ) { 964 if (property_name == 0 ) {
@@ -785,26 +984,14 @@ const char* icalproperty_get_name (icalproperty* prop)
785void icalproperty_set_parent(icalproperty* property, 984void icalproperty_set_parent(icalproperty* property,
786 icalcomponent* component) 985 icalcomponent* component)
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
@@ -31,11 +31,7 @@
31#define ICALPROPERTY_H 31#define ICALPROPERTY_H
32 32
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
40#include "icalderivedparameter.h" 36#include "icalderivedparameter.h"
41 37
@@ -43,12 +39,10 @@
43#include "icalrecur.h" 39#include "icalrecur.h"
44 40
45/* Actually in icalderivedproperty.h: 41/* Actually in icalderivedproperty.h:
46 typedef void icalproperty; */ 42 typedef struct icalproperty_impl icalproperty; */
47 43
48#include "icalderivedproperty.h" /* To get icalproperty_kind enumerations */ 44#include "icalderivedproperty.h" /* To get icalproperty_kind enumerations */
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);
53 47
54icalproperty* icalproperty_new_clone(icalproperty * prop); 48icalproperty* icalproperty_new_clone(icalproperty * prop);
@@ -62,6 +56,7 @@ void icalproperty_free(icalproperty* prop);
62icalproperty_kind icalproperty_isa(icalproperty* property); 56icalproperty_kind icalproperty_isa(icalproperty* property);
63int icalproperty_isa_property(void* property); 57int 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);
66void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter); 61void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter);
67void icalproperty_set_parameter_from_string(icalproperty* prop, 62void icalproperty_set_parameter_from_string(icalproperty* prop,
@@ -72,7 +67,18 @@ const char* icalproperty_get_parameter_as_string(icalproperty* prop,
72void icalproperty_remove_parameter(icalproperty* prop, 67void icalproperty_remove_parameter(icalproperty* prop,
73 icalparameter_kind kind); 68 icalparameter_kind kind);
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
77/* Iterate through the parameters */ 83/* Iterate through the parameters */
78icalparameter* icalproperty_get_first_parameter(icalproperty* prop, 84icalparameter* icalproperty_get_first_parameter(icalproperty* prop,
@@ -83,33 +89,39 @@ icalparameter* icalproperty_get_next_parameter(icalproperty* prop,
83void icalproperty_set_value(icalproperty* prop, icalvalue* value); 89void icalproperty_set_value(icalproperty* prop, icalvalue* value);
84void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind); 90void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind);
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
89/* Deal with X properties */ 95/* Deal with X properties */
90 96
91void icalproperty_set_x_name(icalproperty* prop, const char* name); 97void icalproperty_set_x_name(icalproperty* prop, const char* name);
92const char* icalproperty_get_x_name(icalproperty* prop); 98const 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
98icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value); 106icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
99 107
100/* Convert kinds to string and get default value type */ 108/* Convert kinds to string and get default value type */
101 109
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);
105icalproperty_kind icalproperty_string_to_kind(const char* string); 113icalproperty_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);
108const char* icalproperty_method_to_string(icalproperty_method method); 119const char* icalproperty_method_to_string(icalproperty_method method);
109 120
110 121
111const char* icalproperty_enum_to_string(int e); 122const 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
114const char* icalproperty_status_to_string(icalproperty_status); 126const char* icalproperty_status_to_string(icalproperty_status);
115icalproperty_status icalproperty_string_to_status(const char* string); 127icalproperty_status icalproperty_string_to_status(const char* string);
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
@@ -19,7 +19,11 @@
19 19
20 The Mozilla Public License Version 1.0. You may obtain a copy of 20 The Mozilla Public License Version 1.0. You may obtain a copy of
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
24 How this code works: 28 How this code works:
25 29
@@ -130,15 +134,14 @@
130#include "config.h" 134#include "config.h"
131#endif 135#endif
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
143#include <stdlib.h> /* for malloc */ 146#include <stdlib.h> /* for malloc */
144#include <errno.h> /* for errno */ 147#include <errno.h> /* for errno */
@@ -148,6 +151,10 @@
148 151
149#include "pvl.h" 152#include "pvl.h"
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
152 159
153 160
@@ -170,7 +177,6 @@ const char* icalrecur_weekday_to_string(icalrecurrencetype_weekday kind);
170icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str); 177icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str);
171 178
172 179
173
174/*********************** Rule parsing routines ************************/ 180/*********************** Rule parsing routines ************************/
175 181
176struct icalrecur_parser { 182struct icalrecur_parser {
@@ -253,7 +259,7 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
253 char *t, *n; 259 char *t, *n;
254 int i=0; 260 int i=0;
255 int sign = 1; 261 int sign = 1;
256 short v; 262 int v;
257 263
258 n = vals; 264 n = vals;
259 265
@@ -280,12 +286,14 @@ void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array,
280 } else if (*t == '+'){ 286 } else if (*t == '+'){
281 sign = 1; 287 sign = 1;
282 t++; 288 t++;
289 } else {
290 sign = 1;
283 } 291 }
284 292
285 v = atoi(t) * sign ; 293 v = atoi(t) * sign ;
286 294
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;
290 298
291 } 299 }
@@ -332,21 +340,18 @@ void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals)
332 sign = 1; 340 sign = 1;
333 } 341 }
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
347 wd = icalrecur_string_to_weekday(t); 352 wd = icalrecur_string_to_weekday(t);
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;
351 356
352 } 357 }
@@ -387,6 +392,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
387 if(name == 0){ 392 if(name == 0){
388 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 393 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
389 icalrecurrencetype_clear(&parser.rt); 394 icalrecurrencetype_clear(&parser.rt);
395 free(parser.copy);
390 return parser.rt; 396 return parser.rt;
391 } 397 }
392 398
@@ -397,7 +403,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
397 } else if (strcmp(name,"UNTIL") == 0){ 403 } else if (strcmp(name,"UNTIL") == 0){
398 parser.rt.until = icaltime_from_string(value); 404 parser.rt.until = icaltime_from_string(value);
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){
402 parser.rt.week_start = icalrecur_string_to_weekday(value); 408 parser.rt.week_start = icalrecur_string_to_weekday(value);
403 } else if (strcmp(name,"BYSECOND") == 0){ 409 } else if (strcmp(name,"BYSECOND") == 0){
@@ -429,6 +435,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
429 } else { 435 } else {
430 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 436 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
431 icalrecurrencetype_clear(&parser.rt); 437 icalrecurrencetype_clear(&parser.rt);
438 free(parser.copy);
432 return parser.rt; 439 return parser.rt;
433 } 440 }
434 441
@@ -440,9 +447,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char* str)
440 447
441} 448}
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{
447 {";BYSECOND=",offsetof(struct icalrecurrencetype,by_second),60}, 452 {";BYSECOND=",offsetof(struct icalrecurrencetype,by_second),60},
448 {";BYMINUTE=",offsetof(struct icalrecurrencetype,by_minute),60}, 453 {";BYMINUTE=",offsetof(struct icalrecurrencetype,by_minute),60},
@@ -457,6 +462,7 @@ struct { char* str;size_t offset; short limit; } recurmap[] =
457}; 462};
458 463
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);
461 467
462char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur) 468char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
@@ -481,7 +487,10 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
481 if(recur->until.year != 0){ 487 if(recur->until.year != 0){
482 488
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
486 icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL="); 495 icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL=");
487 icalmemory_append_string(&str,&str_p,&buf_sz, temp); 496 icalmemory_append_string(&str,&str_p,&buf_sz, temp);
@@ -501,7 +510,7 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
501 510
502 for(j =0; recurmap[j].str != 0; j++){ 511 for(j =0; recurmap[j].str != 0; j++){
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
506 /* Skip unused arrays */ 515 /* Skip unused arrays */
507 if( array[0] != ICAL_RECURRENCE_ARRAY_MAX ) { 516 if( array[0] != ICAL_RECURRENCE_ARRAY_MAX ) {
@@ -512,9 +521,9 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
512 i< limit && array[i] != ICAL_RECURRENCE_ARRAY_MAX; 521 i< limit && array[i] != ICAL_RECURRENCE_ARRAY_MAX;
513 i++){ 522 i++){
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
519 pos = icalrecurrencetype_day_position(array[i]); 528 pos = icalrecurrencetype_day_position(array[i]);
520 529
@@ -540,8 +549,6 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
540 549
541 return str; 550 return str;
542} 551}
543#endif
544
545 552
546 553
547/************************* occurrence iteration routiens ******************/ 554/************************* occurrence iteration routiens ******************/
@@ -573,13 +580,15 @@ struct icalrecur_iterator_impl {
573 580
574 enum byrule byrule; 581 enum byrule byrule;
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
581}; 588};
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)
584{ 593{
585 int array_itr; 594 int array_itr;
@@ -599,10 +608,13 @@ enum expand_table {
599 ILLEGAL=3 608 ILLEGAL=3
600}; 609};
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
607{ 619{
608 icalrecurrencetype_frequency frequency; 620 icalrecurrencetype_frequency frequency;
@@ -613,7 +625,7 @@ struct expand_split_map_struct
613 short map[8]; 625 short map[8];
614}; 626};
615 627
616struct expand_split_map_struct expand_map[] = 628static struct expand_split_map_struct expand_map[] =
617{ 629{
618 {ICAL_SECONDLY_RECURRENCE,{1,1,1,1,1,1,1,1}}, 630 {ICAL_SECONDLY_RECURRENCE,{1,1,1,1,1,1,1,1}},
619 {ICAL_MINUTELY_RECURRENCE,{2,1,1,1,1,1,1,1}}, 631 {ICAL_MINUTELY_RECURRENCE,{2,1,1,1,1,1,1,1}},
@@ -628,15 +640,16 @@ struct expand_split_map_struct expand_map[] =
628 640
629 641
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)
634{ 647{
635 short test_array[9]; 648 short test_array[9];
636 enum byrule itr; 649 enum byrule itr;
637 int passes = 0; 650 int passes = 0;
638 651
639 memset(test_array,0,9); 652 memset(test_array,0,sizeof(test_array));
640 653
641 test_array[one] = 1; 654 test_array[one] = 1;
642 test_array[two] = 1; 655 test_array[two] = 1;
@@ -659,8 +672,8 @@ int icalrecur_two_byrule(struct icalrecur_iterator_impl* impl,
659 672
660} 673}
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{
665 int passes = 1; 678 int passes = 1;
666 enum byrule itr; 679 enum byrule itr;
@@ -676,7 +689,7 @@ int icalrecur_one_byrule(struct icalrecur_iterator_impl* impl,enum byrule one)
676 return passes; 689 return passes;
677} 690}
678 691
679int count_byrules(struct icalrecur_iterator_impl* impl) 692static int count_byrules(icalrecur_iterator* impl)
680{ 693{
681 int count = 0; 694 int count = 0;
682 enum byrule itr; 695 enum byrule itr;
@@ -691,9 +704,9 @@ int count_byrules(struct icalrecur_iterator_impl* impl)
691} 704}
692 705
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{
698 711
699 icalrecurrencetype_frequency freq; 712 icalrecurrencetype_frequency freq;
@@ -704,7 +717,7 @@ void setup_defaults(struct icalrecur_iterator_impl* impl,
704 717
705 if(impl->by_ptrs[byrule][0] == ICAL_RECURRENCE_ARRAY_MAX && 718 if(impl->by_ptrs[byrule][0] == ICAL_RECURRENCE_ARRAY_MAX &&
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 }
709 722
710 /* Initialize the first occurence */ 723 /* Initialize the first occurence */
@@ -715,30 +728,28 @@ void setup_defaults(struct icalrecur_iterator_impl* impl,
715 728
716} 729}
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
720 return (impl->orig_data[byrule] == 1); 733 return (impl->orig_data[byrule] == 1);
721} 734}
722 735
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
726 739
727icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, 740icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
728 struct icaltimetype dtstart) 741 struct icaltimetype dtstart)
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);
738 return 0; 749 return 0;
739 } 750 }
740 751
741 memset(impl,0,sizeof(struct icalrecur_iterator_impl)); 752 memset(impl,0,sizeof(icalrecur_iterator));
742 753
743 impl->rule = rule; 754 impl->rule = rule;
744 impl->last = dtstart; 755 impl->last = dtstart;
@@ -760,7 +771,7 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
760 impl->by_ptrs[BY_SECOND]=impl->rule.by_second; 771 impl->by_ptrs[BY_SECOND]=impl->rule.by_second;
761 impl->by_ptrs[BY_SET_POS]=impl->rule.by_set_pos; 772 impl->by_ptrs[BY_SET_POS]=impl->rule.by_set_pos;
762 773
763 memset(impl->orig_data,0,9); 774 memset(impl->orig_data,0,9*sizeof(short));
764 775
765 /* Note which by rules had data in them when the iterator was 776 /* Note which by rules had data in them when the iterator was
766 created. We can't use the actuall by_x arrays, because the 777 created. We can't use the actuall by_x arrays, because the
@@ -768,23 +779,23 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
768 routine. The orig_data array will be used later in has_by_data */ 779 routine. The orig_data array will be used later in has_by_data */
769 780
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
789 800
790 /* Check if the recurrence rule is legal */ 801 /* Check if the recurrence rule is legal */
@@ -852,19 +863,24 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
852 BY_* array is empty */ 863 BY_* array is empty */
853 864
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));
869 885
870 886
@@ -874,7 +890,7 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
874 890
875 /* Weekly recurrences with no BY_DAY data should occur on the 891 /* Weekly recurrences with no BY_DAY data should occur on the
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
879 } else { 895 } else {
880 /* If there is BY_DAY data, then we need to move the initial 896 /* If there is BY_DAY data, then we need to move the initial
@@ -888,7 +904,7 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
888 /* This is probably a HACK. There should be some more 904 /* This is probably a HACK. There should be some more
889 general way to solve this problem */ 905 general way to solve this problem */
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
893 if(dow < 0) { 909 if(dow < 0) {
894 /* initial time is after first day of BY_DAY data */ 910 /* initial time is after first day of BY_DAY data */
@@ -901,10 +917,24 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
901 917
902 } 918 }
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 }
909 939
910 940
@@ -914,13 +944,13 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
914 if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE && 944 if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE &&
915 has_by_data(impl,BY_DAY)) { 945 has_by_data(impl,BY_DAY)) {
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);
925 955
926 if(pos >= 0){ 956 if(pos >= 0){
@@ -969,26 +999,21 @@ icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule,
969 999
970void icalrecur_iterator_free(icalrecur_iterator* i) 1000void 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
980} 1006}
981 1007
982 1008static void increment_year(icalrecur_iterator* impl, int inc)
983void increment_year(struct icalrecur_iterator_impl* impl, int inc)
984{ 1009{
985 impl->last.year+=inc; 1010 impl->last.year+=inc;
986} 1011}
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{
993 int years; 1018 int years;
994 1019
@@ -1035,14 +1060,14 @@ void increment_month(struct icalrecur_iterator_impl* impl)
1035 } 1060 }
1036} 1061}
1037 1062
1038void increment_monthday(struct icalrecur_iterator_impl* impl, int inc) 1063static void increment_monthday(icalrecur_iterator* impl, int inc)
1039{ 1064{
1040 int i; 1065 int i;
1041 1066
1042 for(i=0; i<inc; i++){ 1067 for(i=0; i<inc; i++){
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
1047 impl->last.day++; 1072 impl->last.day++;
1048 1073
@@ -1054,9 +1079,9 @@ void increment_monthday(struct icalrecur_iterator_impl* impl, int inc)
1054} 1079}
1055 1080
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
1061 impl->last.hour+=inc; 1086 impl->last.hour+=inc;
1062 1087
@@ -1068,9 +1093,9 @@ void increment_hour(struct icalrecur_iterator_impl* impl, int inc)
1068 } 1093 }
1069} 1094}
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
1075 impl->last.minute+=inc; 1100 impl->last.minute+=inc;
1076 1101
@@ -1083,9 +1108,9 @@ void increment_minute(struct icalrecur_iterator_impl* impl, int inc)
1083 1108
1084} 1109}
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
1090 impl->last.second+=inc; 1115 impl->last.second+=inc;
1091 1116
@@ -1102,7 +1127,7 @@ void increment_second(struct icalrecur_iterator_impl* impl, int inc)
1102#include "ical.h" 1127#include "ical.h"
1103void test_increment() 1128void test_increment()
1104{ 1129{
1105 struct icalrecur_iterator_impl impl; 1130 icalrecur_iterator impl;
1106 1131
1107 impl.last = icaltime_from_string("20000101T000000Z"); 1132 impl.last = icaltime_from_string("20000101T000000Z");
1108 1133
@@ -1132,17 +1157,17 @@ void test_increment()
1132 1157
1133#endif 1158#endif
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 */
1147 1172
1148 impl->by_indices[BY_SECOND]++; 1173 impl->by_indices[BY_SECOND]++;
@@ -1159,7 +1184,7 @@ short next_second(struct icalrecur_iterator_impl* impl)
1159 impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]]; 1184 impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]];
1160 1185
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*/
1164 increment_second(impl, impl->rule.interval); 1189 increment_second(impl, impl->rule.interval);
1165 1190
@@ -1168,7 +1193,7 @@ short next_second(struct icalrecur_iterator_impl* impl)
1168 /* If we have gone through all of the seconds on the BY list, then we 1193 /* If we have gone through all of the seconds on the BY list, then we
1169 need to move to the next minute */ 1194 need to move to the next minute */
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);
1173 } 1198 }
1174 1199
@@ -1176,22 +1201,22 @@ short next_second(struct icalrecur_iterator_impl* impl)
1176 1201
1177} 1202}
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
1189 1214
1190 if (next_second(impl) == 0){ 1215 if (next_second(impl) == 0){
1191 return 0; 1216 return 0;
1192 } 1217 }
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 */
1196 1221
1197 impl->by_indices[BY_MINUTE]++; 1222 impl->by_indices[BY_MINUTE]++;
@@ -1207,7 +1232,7 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1207 impl->last.minute = 1232 impl->last.minute =
1208 impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]]; 1233 impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]];
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*/
1212 increment_minute(impl,impl->rule.interval); 1237 increment_minute(impl,impl->rule.interval);
1213 } 1238 }
@@ -1215,28 +1240,28 @@ int next_minute(struct icalrecur_iterator_impl* impl)
1215/* If we have gone through all of the minutes on the BY list, then we 1240/* If we have gone through all of the minutes on the BY list, then we
1216 need to move to the next hour */ 1241 need to move to the next hour */
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);
1220 } 1245 }
1221 1246
1222 return end_of_data; 1247 return end_of_data;
1223} 1248}
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
1235 if (next_minute(impl) == 0){ 1260 if (next_minute(impl) == 0){
1236 return 0; 1261 return 0;
1237 } 1262 }
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 */
1241 1266
1242 impl->by_indices[BY_HOUR]++; 1267 impl->by_indices[BY_HOUR]++;
@@ -1251,7 +1276,7 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1251 impl->last.hour = 1276 impl->last.hour =
1252 impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]]; 1277 impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]];
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*/
1256 increment_hour(impl,impl->rule.interval); 1281 increment_hour(impl,impl->rule.interval);
1257 1282
@@ -1260,7 +1285,7 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1260 /* If we have gone through all of the hours on the BY list, then we 1285 /* If we have gone through all of the hours on the BY list, then we
1261 need to move to the next day */ 1286 need to move to the next day */
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);
1265 } 1290 }
1266 1291
@@ -1268,13 +1293,13 @@ int next_hour(struct icalrecur_iterator_impl* impl)
1268 1293
1269} 1294}
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
1279 if (next_hour(impl) == 0){ 1304 if (next_hour(impl) == 0){
1280 return 0; 1305 return 0;
@@ -1296,14 +1321,14 @@ int next_day(struct icalrecur_iterator_impl* impl)
1296} 1321}
1297 1322
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
1308 if (next_hour(impl) == 0){ 1333 if (next_hour(impl) == 0){
1309 return 0; 1334 return 0;
@@ -1321,7 +1346,7 @@ int next_yearday(struct icalrecur_iterator_impl* impl)
1321 impl->last.day = 1346 impl->last.day =
1322 impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]]; 1347 impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]];
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);
1326 } 1351 }
1327 1352
@@ -1329,62 +1354,15 @@ int next_yearday(struct icalrecur_iterator_impl* impl)
1329 1354
1330} 1355}
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
1389 if(pos >= 0){ 1367 if(pos >= 0){
1390 t.day = 1; 1368 t.day = 1;
@@ -1428,12 +1406,29 @@ int nth_weekday(short dow, short pos, struct icaltimetype t){
1428 return wd; 1406 return wd;
1429} 1407}
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{
1434 int data_valid = 1; 1429 int data_valid = 1;
1435 1430
1436 short this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE); 1431 int this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE);
1437 1432
1438 assert( has_by_data(impl,BY_MONTH) || this_frequency); 1433 assert( has_by_data(impl,BY_MONTH) || this_frequency);
1439 1434
@@ -1445,14 +1440,17 @@ int next_month(struct icalrecur_iterator_impl* impl)
1445 return data_valid; /* Signal that the data is valid */ 1440 return data_valid; /* Signal that the data is valid */
1446 } 1441 }
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);
1457 /* Iterate through the remaining days in the month and check if 1455 /* Iterate through the remaining days in the month and check if
1458 each day is listed in the BY_DAY array and in the BY_MONTHDAY 1456 each day is listed in the BY_DAY array and in the BY_MONTHDAY
@@ -1463,11 +1461,11 @@ int next_month(struct icalrecur_iterator_impl* impl)
1463 for(day = impl->last.day+1; day <= days_in_month; day++){ 1461 for(day = impl->last.day+1; day <= days_in_month; day++){
1464 for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){ 1462 for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){
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
1472 impl->last.day = day; 1470 impl->last.day = day;
1473 this_dow = icaltime_day_of_week(impl->last); 1471 this_dow = icaltime_day_of_week(impl->last);
@@ -1488,51 +1486,57 @@ int next_month(struct icalrecur_iterator_impl* impl)
1488 data_valid = 0; /* signal that impl->last is invalid */ 1486 data_valid = 0; /* signal that impl->last is invalid */
1489 } 1487 }
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
1495 month. BYDAY=FR -> First Friday in month, etc. */ 1497 month. BYDAY=FR -> First Friday in month, etc. */
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 }
1523 } 1516 }
1524 1517
1525 DEND:
1526
1527 if ( day > days_in_month){ 1518 if ( day > days_in_month){
1528 impl->last.day = 1; 1519 impl->last.day = 1;
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
1537 assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX); 1541 assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX);
1538 1542
@@ -1548,8 +1552,7 @@ int next_month(struct icalrecur_iterator_impl* impl)
1548 day = BYMDPTR[BYMDIDX]; 1552 day = BYMDPTR[BYMDIDX];
1549 1553
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 }
1554 1557
1555 impl->last.day = day; 1558 impl->last.day = day;
@@ -1558,18 +1561,72 @@ int next_month(struct icalrecur_iterator_impl* impl)
1558 increment_month(impl); 1561 increment_month(impl);
1559 } 1562 }
1560 1563
1561 return data_valid; /* Signal that the data is valid */ 1564 return data_valid;
1562 1565
1563} 1566}
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){
1574 return 0; /* Have not reached end of week yet */ 1631 return 0; /* Have not reached end of week yet */
1575 } 1632 }
@@ -1577,8 +1634,8 @@ int next_week(struct icalrecur_iterator_impl* impl)
1577 /* If we get here, we have incremented through the entire week, and 1634 /* If we get here, we have incremented through the entire week, and
1578 can increment to the next week */ 1635 can increment to the next week */
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 */
1583 int week_no; 1640 int week_no;
1584 struct icaltimetype t; 1641 struct icaltimetype t;
@@ -1602,13 +1659,12 @@ int next_week(struct icalrecur_iterator_impl* impl)
1602 1659
1603 impl->last = icaltime_normalize(impl->last); 1660 impl->last = icaltime_normalize(impl->last);
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);
1608 } 1665 }
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);
1613 } 1669 }
1614 1670
@@ -1616,14 +1672,14 @@ int next_week(struct icalrecur_iterator_impl* impl)
1616 1672
1617} 1673}
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{
1622 /* Try to calculate each of the occurrences. */ 1678 /* Try to calculate each of the occurrences. */
1623 int i; 1679 int i;
1624 pvl_list days_list = pvl_newlist(); 1680 pvl_list days_list = pvl_newlist();
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;
1628 1684
1629 tmp.year= year; 1685 tmp.year= year;
@@ -1631,37 +1687,35 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1631 tmp.day = 1; 1687 tmp.day = 1;
1632 tmp.is_date = 1; 1688 tmp.is_date = 1;
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
1643 end_dow = icaltime_day_of_week(tmp); 1699 end_dow = icaltime_day_of_week(tmp);
1644 end_year_day = icaltime_day_of_year(tmp); 1700 end_year_day = icaltime_day_of_year(tmp);
1645 1701
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
1651 if(pos == 0){ 1708 if(pos == 0){
1652 /* The day was specified without a position -- it is just 1709 /* The day was specified without a position -- it is just
1653 a bare day of the week ( BYDAY=SU) so add all of the 1710 a bare day of the week ( BYDAY=SU) so add all of the
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) {
1666 int first; 1720 int first;
1667 /* First occurrence of dow in year */ 1721 /* First occurrence of dow in year */
@@ -1671,7 +1725,7 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1671 first = dow - start_dow + 8; 1725 first = dow - start_dow + 8;
1672 } 1726 }
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));
1676 1730
1677 } else { /* pos < 0 */ 1731 } else { /* pos < 0 */
@@ -1696,22 +1750,23 @@ pvl_list expand_by_day(struct icalrecur_iterator_impl* impl,short year)
1696 list all of the days of the current year that are specified in this 1750 list all of the days of the current year that are specified in this
1697 rule. */ 1751 rule. */
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{
1701 int j,k; 1755 int j,k;
1702 int days_index=0; 1756 int days_index=0;
1703 struct icaltimetype t; 1757 struct icaltimetype t;
1704 int flags; 1758 int flags;
1705 1759
1706 t = icaltime_null_time(); 1760 t = icaltime_null_date();
1707 1761
1708#define HBD(x) has_by_data(impl,x) 1762#define HBD(x) has_by_data(impl,x)
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) +
1716 (HBD(BY_WEEK_NO) ? 1<<BY_WEEK_NO : 0) + 1771 (HBD(BY_WEEK_NO) ? 1<<BY_WEEK_NO : 0) +
1717 (HBD(BY_MONTH_DAY) ? 1<<BY_MONTH_DAY : 0) + 1772 (HBD(BY_MONTH_DAY) ? 1<<BY_MONTH_DAY : 0) +
@@ -1723,16 +1778,19 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1723 1778
1724 case 0: { 1779 case 0: {
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;
1728 } 1787 }
1729 case 1<<BY_MONTH: { 1788 case 1<<BY_MONTH: {
1730 /* FREQ=YEARLY; BYMONTH=3,11*/ 1789 /* FREQ=YEARLY; BYMONTH=3,11*/
1731 1790
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
1737 t = impl->dtstart; 1795 t = impl->dtstart;
1738 t.year = year; 1796 t.year = year;
@@ -1741,7 +1799,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1741 1799
1742 doy = icaltime_day_of_year(t); 1800 doy = icaltime_day_of_year(t);
1743 1801
1744 impl->days[days_index++] = doy; 1802 impl->days[days_index++] = (short)doy;
1745 1803
1746 } 1804 }
1747 break; 1805 break;
@@ -1751,8 +1809,8 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1751 /* FREQ=YEARLY; BYMONTHDAY=1,15*/ 1809 /* FREQ=YEARLY; BYMONTHDAY=1,15*/
1752 for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++) 1810 for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++)
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
1757 t = impl->dtstart; 1815 t = impl->dtstart;
1758 t.day = month_day; 1816 t.day = month_day;
@@ -1761,7 +1819,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1761 1819
1762 doy = icaltime_day_of_year(t); 1820 doy = icaltime_day_of_year(t);
1763 1821
1764 impl->days[days_index++] = doy; 1822 impl->days[days_index++] = (short)doy;
1765 1823
1766 } 1824 }
1767 break; 1825 break;
@@ -1773,9 +1831,9 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1773 for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ 1831 for(j=0;impl->by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){
1774 for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++) 1832 for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++)
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
1780 t.day = month_day; 1838 t.day = month_day;
1781 t.month = month; 1839 t.month = month;
@@ -1784,7 +1842,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1784 1842
1785 doy = icaltime_day_of_year(t); 1843 doy = icaltime_day_of_year(t);
1786 1844
1787 impl->days[days_index++] = doy; 1845 impl->days[days_index++] = (short)doy;
1788 1846
1789 } 1847 }
1790 } 1848 }
@@ -1795,8 +1853,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1795 case 1<<BY_WEEK_NO: { 1853 case 1<<BY_WEEK_NO: {
1796 /* FREQ=YEARLY; BYWEEKNO=20,50 */ 1854 /* FREQ=YEARLY; BYWEEKNO=20,50 */
1797 1855
1798 struct icaltimetype t; 1856 int dow;
1799 short dow;
1800 1857
1801 t.day = impl->dtstart.day; 1858 t.day = impl->dtstart.day;
1802 t.month = impl->dtstart.month; 1859 t.month = impl->dtstart.month;
@@ -1819,13 +1876,12 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1819 1876
1820 case 1<<BY_DAY: { 1877 case 1<<BY_DAY: {
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;
1824 pvl_list days = expand_by_day(impl,year); 1880 pvl_list days = expand_by_day(impl,year);
1825 1881
1826 1882
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;
1830 } 1886 }
1831 1887
@@ -1837,50 +1893,76 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1837 case (1<<BY_DAY)+(1<<BY_MONTH): { 1893 case (1<<BY_DAY)+(1<<BY_MONTH): {
1838 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTH = 12*/ 1894 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTH = 12*/
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;
1866 } 1950 }
1867 1951
1868 case (1<<BY_DAY) + (1<<BY_MONTH_DAY) : { 1952 case (1<<BY_DAY) + (1<<BY_MONTH_DAY) : {
1869 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=1,15*/ 1953 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=1,15*/
1870 1954
1871 int days_index = 0;
1872 pvl_elem itr; 1955 pvl_elem itr;
1873 pvl_list days = expand_by_day(impl,year); 1956 pvl_list days = expand_by_day(impl,year);
1874 1957
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
1880 tt = icaltime_from_day_of_year(day,year); 1962 tt = icaltime_from_day_of_year(day,year);
1881 1963
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
1885 if(tt.day == mday){ 1967 if(tt.day == mday){
1886 impl->days[days_index++] = day; 1968 impl->days[days_index++] = day;
@@ -1897,21 +1979,20 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1897 case (1<<BY_DAY) + (1<<BY_MONTH_DAY) + (1<<BY_MONTH): { 1979 case (1<<BY_DAY) + (1<<BY_MONTH_DAY) + (1<<BY_MONTH): {
1898 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=10; MYMONTH=6,11*/ 1980 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTHDAY=10; MYMONTH=6,11*/
1899 1981
1900 int days_index = 0;
1901 pvl_elem itr; 1982 pvl_elem itr;
1902 pvl_list days = expand_by_day(impl,year); 1983 pvl_list days = expand_by_day(impl,year);
1903 1984
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
1909 tt = icaltime_from_day_of_year(day,year); 1990 tt = icaltime_from_day_of_year(day,year);
1910 1991
1911 for(i = 0; BYMONPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){ 1992 for(i = 0; BYMONPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){
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
1916 if(tt.month == month && tt.day == mday){ 1997 if(tt.month == month && tt.day == mday){
1917 impl->days[days_index++] = day; 1998 impl->days[days_index++] = day;
@@ -1930,21 +2011,20 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1930 case (1<<BY_DAY) + (1<<BY_WEEK_NO) : { 2011 case (1<<BY_DAY) + (1<<BY_WEEK_NO) : {
1931 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; WEEKNO=20,50*/ 2012 /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; WEEKNO=20,50*/
1932 2013
1933 int days_index = 0;
1934 pvl_elem itr; 2014 pvl_elem itr;
1935 pvl_list days = expand_by_day(impl,year); 2015 pvl_list days = expand_by_day(impl,year);
1936 2016
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
1942 tt = icaltime_from_day_of_year(day,year); 2022 tt = icaltime_from_day_of_year(day,year);
1943 2023
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;
1949 } 2029 }
1950 } 2030 }
@@ -1963,8 +2043,7 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1963 2043
1964 case 1<<BY_YEAR_DAY: { 2044 case 1<<BY_YEAR_DAY: {
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 }
1969 break; 2048 break;
1970 } 2049 }
@@ -1980,26 +2059,26 @@ int expand_year_days(struct icalrecur_iterator_impl* impl,short year)
1980} 2059}
1981 2060
1982 2061
1983int next_year(struct icalrecur_iterator_impl* impl) 2062static int next_year(icalrecur_iterator* impl)
1984{ 2063{
1985 struct icaltimetype next; 2064 struct icaltimetype next;
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 }
1991 2069
1992 if (impl->days[++impl->days_index] == ICAL_RECURRENCE_ARRAY_MAX){ 2070 if (impl->days[++impl->days_index] == ICAL_RECURRENCE_ARRAY_MAX){
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
2004 impl->last.day = next.day; 2083 impl->last.day = next.day;
2005 impl->last.month = next.month; 2084 impl->last.month = next.month;
@@ -2007,8 +2086,8 @@ int next_year(struct icalrecur_iterator_impl* impl)
2007 return 1; 2086 return 1;
2008} 2087}
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{
2013 int itr; 2092 int itr;
2014 2093
@@ -2023,8 +2102,8 @@ int icalrecur_check_rulepart(struct icalrecur_iterator_impl* impl,
2023 return 0; 2102 return 0;
2024} 2103}
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{
2029 int pass = 0; 2108 int pass = 0;
2030 int itr; 2109 int itr;
@@ -2048,22 +2127,22 @@ int check_contract_restriction(struct icalrecur_iterator_impl* impl,
2048} 2127}
2049 2128
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 {
2068 2147
2069 return 1; 2148 return 1;
@@ -2072,11 +2151,9 @@ int check_contracting_rules(struct icalrecur_iterator_impl* impl)
2072 } 2151 }
2073} 2152}
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
2081 if( (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) || 2158 if( (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) ||
2082 (!icaltime_is_null_time(impl->rule.until) && 2159 (!icaltime_is_null_time(impl->rule.until) &&
@@ -2120,7 +2197,7 @@ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr)
2120 break; 2197 break;
2121 } 2198 }
2122 case ICAL_YEARLY_RECURRENCE:{ 2199 case ICAL_YEARLY_RECURRENCE:{
2123 valid = next_year(impl); 2200 next_year(impl);
2124 break; 2201 break;
2125 } 2202 }
2126 default:{ 2203 default:{
@@ -2135,7 +2212,7 @@ struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *itr)
2135 } 2212 }
2136 2213
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);
2140 2217
2141 2218
@@ -2166,16 +2243,15 @@ void icalrecurrencetype_clear(struct icalrecurrencetype *recur)
2166 recur->count = 0; 2243 recur->count = 0;
2167} 2244}
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 */
2180 2256
2181enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day) 2257enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
@@ -2183,9 +2259,9 @@ enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
2183 return abs(day)%8; 2259 return abs(day)%8;
2184} 2260}
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
2190 wd = icalrecurrencetype_day_day_of_week(day); 2266 wd = icalrecurrencetype_day_day_of_week(day);
2191 2267
@@ -2198,7 +2274,7 @@ short icalrecurrencetype_day_position(short day)
2198 2274
2199/****************** Enumeration Routines ******************/ 2275/****************** Enumeration Routines ******************/
2200 2276
2201struct {icalrecurrencetype_weekday wd; const char * str; } 2277static struct {icalrecurrencetype_weekday wd; const char * str; }
2202wd_map[] = { 2278wd_map[] = {
2203 {ICAL_SUNDAY_WEEKDAY,"SU"}, 2279 {ICAL_SUNDAY_WEEKDAY,"SU"},
2204 {ICAL_MONDAY_WEEKDAY,"MO"}, 2280 {ICAL_MONDAY_WEEKDAY,"MO"},
@@ -2238,7 +2314,7 @@ icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str)
2238 2314
2239 2315
2240 2316
2241struct { 2317static struct {
2242 icalrecurrencetype_frequency kind; 2318 icalrecurrencetype_frequency kind;
2243 const char* str; 2319 const char* str;
2244} freq_map[] = { 2320} freq_map[] = {
@@ -2276,10 +2352,11 @@ icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str)
2276 return ICAL_NO_RECURRENCE; 2352 return ICAL_NO_RECURRENCE;
2277} 2353}
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
2284int icalrecur_expand_recurrence(char* rule, time_t start, 2361int icalrecur_expand_recurrence(char* rule, time_t start,
2285 int count, time_t* array) 2362 int count, time_t* array)
@@ -2292,7 +2369,7 @@ int icalrecur_expand_recurrence(char* rule, time_t start,
2292 2369
2293 memset(array, 0, count*sizeof(time_t)); 2370 memset(array, 0, count*sizeof(time_t));
2294 2371
2295 icstart = icaltime_from_timet(start,0); 2372 icstart = icaltime_from_timet_with_zone(start,0,0);
2296 2373
2297 recur = icalrecurrencetype_from_string(rule); 2374 recur = icalrecurrencetype_from_string(rule);
2298 2375
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
@@ -16,10 +16,17 @@
16 16
17 The Mozilla Public License Version 1.0. You may obtain a copy of 17 The Mozilla Public License Version 1.0. You may obtain a copy of
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
20How to use: 25How to use:
21 26
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;
24 struct icalrecurrencetype recur; 31 struct icalrecurrencetype recur;
25 struct icaltimetype dtstart; 32 struct icaltimetype dtstart;
@@ -27,26 +34,36 @@ How to use:
27 rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); 34 rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY);
28 recur = icalproperty_get_rrule(rrule); 35 recur = icalproperty_get_rrule(rrule);
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;
41 while (next = icalrecur_iterator_next(ritr) 57 while (next = icalrecur_iterator_next(ritr)
42 && !icaltime_is_null_time(next){ 58 && !icaltime_is_null_time(next){
43 Do something with next 59 Do something with next
44 } 60 }
61@endcode
45 62
46Note that that the time returned by icalrecur_iterator_next is in 63Note that that the time returned by icalrecur_iterator_next is in
47whatever timezone that dtstart is in. 64whatever timezone that dtstart is in.
48 65
49======================================================================*/ 66*/
50 67
51#ifndef ICALRECUR_H 68#ifndef ICALRECUR_H
52#define ICALRECUR_H 69#define ICALRECUR_H
@@ -54,9 +71,9 @@ whatever timezone that dtstart is in.
54#include <time.h> 71#include <time.h>
55#include "icaltime.h" 72#include "icaltime.h"
56 73
57/*********************************************************************** 74/*
58 * Recurrance enumerations 75 * Recurrance enumerations
59**********************************************************************/ 76 */
60 77
61typedef enum icalrecurrencetype_frequency 78typedef enum icalrecurrencetype_frequency
62{ 79{
@@ -93,7 +110,9 @@ enum {
93 110
94 111
95 112
96/********************** Recurrence type routines **************/ 113/**
114 * Recurrence type routines
115 */
97 116
98/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of 117/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of
99 the values and fields in struct icalrecurrencetype */ 118 the values and fields in struct icalrecurrencetype */
@@ -108,7 +127,7 @@ enum {
108#define ICAL_BY_MONTH_SIZE 13 127#define ICAL_BY_MONTH_SIZE 13
109#define ICAL_BY_SETPOS_SIZE 367 128#define ICAL_BY_SETPOS_SIZE 367
110 129
111/* Main struct for holding digested recurrence rules */ 130/** Main struct for holding digested recurrence rules */
112struct icalrecurrencetype 131struct icalrecurrencetype
113{ 132{
114 icalrecurrencetype_frequency freq; 133 icalrecurrencetype_frequency freq;
@@ -145,43 +164,49 @@ struct icalrecurrencetype
145 164
146void icalrecurrencetype_clear(struct icalrecurrencetype *r); 165void 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);
166char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); 187char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
167 188
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,
175 struct icaltimetype dtstart); 196 struct icaltimetype dtstart);
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,
186 int count, time_t* array); 211 int count, time_t* array);
187 212
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
@@ -17,10 +17,13 @@
17#include <assert.h> 17#include <assert.h>
18#include <stdio.h> /* For snprintf */ 18#include <stdio.h> /* For snprintf */
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
25/* Define the structs for the restrictions. these data are filled out 28/* Define the structs for the restrictions. these data are filled out
26in machine generated code below */ 29in machine generated code below */
@@ -63,7 +66,7 @@ icalrestriction_property_record null_prop_record = {ICAL_METHOD_NONE,ICAL_NO_C
63icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0}; 66icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0};
64 67
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
68 'invalid, 'don't care' or 'needs more analysis' So, for 71 'invalid, 'don't care' or 'needs more analysis' So, for
69 ICAL_RESTRICTION_ONE, if there is 1 of a property with that 72 ICAL_RESTRICTION_ONE, if there is 1 of a property with that
@@ -221,7 +224,7 @@ char* icalrestriction_must_have_duration(icalrestriction_property_record *rec,
221 224
222 if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){ 225 if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){
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
226 } 229 }
227 230
@@ -232,7 +235,7 @@ char* icalrestriction_must_have_repeat(icalrestriction_property_record *rec,
232 icalproperty* prop){ 235 icalproperty* prop){
233 if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){ 236 if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){
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
237 } 240 }
238 241
@@ -249,9 +252,9 @@ char* icalrestriction_no_dtend(icalrestriction_property_record *rec,
249 icalcomponent* comp, 252 icalcomponent* comp,
250 icalproperty* prop){ 253 icalproperty* prop){
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
256 } 259 }
257 260
@@ -264,7 +267,21 @@ char* icalrestriction_no_duration(icalrestriction_property_record *rec,
264 /* _no_dtend takes care of this one */ 267 /* _no_dtend takes care of this one */
265 return 0; 268 return 0;
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
269int icalrestriction_check_component(icalproperty_method method, 286int icalrestriction_check_component(icalproperty_method method,
270 icalcomponent* comp) 287 icalcomponent* comp)
@@ -272,8 +289,7 @@ int icalrestriction_check_component(icalproperty_method method,
272 icalproperty_kind kind; 289 icalproperty_kind kind;
273 icalcomponent_kind comp_kind; 290 icalcomponent_kind comp_kind;
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;
278 icalproperty *prop; 294 icalproperty *prop;
279 295
@@ -463,8 +479,8 @@ icalrestriction_property_record icalrestriction_property_records[] = {
463 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_CONTACT_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 479 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_CONTACT_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
464 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 480 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
469 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 485 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
470 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 486 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -481,6 +497,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
481 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 497 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
482 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 498 {ICAL_METHOD_PUBLISH,ICAL_VEVENT_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
485 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 502 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
486 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0}, 503 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -513,6 +530,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
513 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 530 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
514 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 531 {ICAL_METHOD_REQUEST,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
517 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 535 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
518 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 536 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -545,6 +563,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
545 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 563 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
546 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 564 {ICAL_METHOD_REPLY,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
549 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0}, 568 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
550 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 569 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -560,7 +579,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
560 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 579 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
561 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 580 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
565 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 584 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
566 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 585 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -577,6 +596,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
577 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 596 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
578 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_RECURRENCEID_PROPERTY,ICAL_RESTRICTION_ZERO,icalrestriction_must_be_recurring}, 597 {ICAL_METHOD_ADD,ICAL_VEVENT_COMPONENT,ICAL_RECURRENCEID_PROPERTY,ICAL_RESTRICTION_ZERO,icalrestriction_must_be_recurring},
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},
581 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 601 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
582 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 602 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -591,7 +611,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
591 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 611 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
592 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE ,icalrestriction_no_duration}, 612 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONEEXCLUSIVE ,icalrestriction_no_duration},
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},
596 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 616 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
597 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 617 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -609,6 +629,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
609 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 629 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
610 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 630 {ICAL_METHOD_CANCEL,ICAL_VEVENT_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
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},
613 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 634 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
614 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 635 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -641,6 +662,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
641 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 662 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZERO,0},
642 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 663 {ICAL_METHOD_REFRESH,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
645 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0}, 667 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
646 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 668 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -656,7 +678,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
656 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 678 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_CREATED_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
657 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 679 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_DESCRIPTION_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
661 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 683 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
662 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 684 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_GEO_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -673,6 +695,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
673 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 695 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
674 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 696 {ICAL_METHOD_COUNTER,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
677 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 700 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
678 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0}, 701 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -705,6 +728,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
705 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 728 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZERO,0},
706 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 729 {ICAL_METHOD_DECLINECOUNTER,ICAL_VEVENT_COMPONENT,ICAL_TRANSP_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
709 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0}, 733 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
710 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONE,0}, 734 {ICAL_METHOD_PUBLISH,ICAL_VFREEBUSY_COMPONENT,ICAL_DTEND_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -746,7 +770,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
746 {ICAL_METHOD_REPLY,ICAL_VFREEBUSY_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 770 {ICAL_METHOD_REPLY,ICAL_VFREEBUSY_COMPONENT,ICAL_DURATION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
747 {ICAL_METHOD_REPLY,ICAL_VFREEBUSY_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 771 {ICAL_METHOD_REPLY,ICAL_VFREEBUSY_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
751 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0}, 775 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0},
752 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 776 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -777,9 +801,10 @@ icalrestriction_property_record icalrestriction_property_records[] = {
777 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 801 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
778 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 802 {ICAL_METHOD_PUBLISH,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
784 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0}, 809 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0},
785 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 810 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
@@ -809,6 +834,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
809 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 834 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
810 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 835 {ICAL_METHOD_REQUEST,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
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},
813 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 839 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
814 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 840 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -841,6 +867,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
841 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 867 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_SUMMARY_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
842 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 868 {ICAL_METHOD_REPLY,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
845 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 872 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
846 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0}, 873 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_PRIORITY_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -873,6 +900,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
873 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 900 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
874 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_RECURRENCEID_PROPERTY,ICAL_RESTRICTION_ZERO,icalrestriction_must_be_recurring}, 901 {ICAL_METHOD_ADD,ICAL_VTODO_COMPONENT,ICAL_RECURRENCEID_PROPERTY,ICAL_RESTRICTION_ZERO,icalrestriction_must_be_recurring},
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},
877 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0}, 905 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0},
878 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 906 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -904,6 +932,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
904 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 932 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
905 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 933 {ICAL_METHOD_CANCEL,ICAL_VTODO_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
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},
908 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 937 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
909 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0}, 938 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_UID_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -935,6 +964,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
935 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 964 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_SEQUENCE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
936 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 965 {ICAL_METHOD_REFRESH,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
939 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 969 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
940 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 970 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -967,6 +997,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
967 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZEROORONE,icalrestriction_may_be_comp_need_process}, 997 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZEROORONE,icalrestriction_may_be_comp_need_process},
968 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 998 {ICAL_METHOD_COUNTER,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
971 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1002 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
972 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1003 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_ORGANIZER_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -998,6 +1029,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
998 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1029 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_STATUS_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
999 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1030 {ICAL_METHOD_DECLINECOUNTER,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
1002 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1034 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ONE,0},
1003 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0}, 1035 {ICAL_METHOD_PUBLISH,ICAL_VJOURNAL_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ONE,0},
@@ -1071,9 +1103,50 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1071 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1103 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1072 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1104 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_X_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
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},
1075 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1147 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
1078 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CATEGORIES_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1151 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CATEGORIES_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1079 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CLASS_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1152 {ICAL_METHOD_NONE,ICAL_VCALENDAR_COMPONENT,ICAL_CLASS_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1134,7 +1207,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1134 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1207 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DTSTAMP_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1135 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1208 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_DTSTART_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
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},
1139 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1212 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_EXRULE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1140 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_FREEBUSY_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1213 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_FREEBUSY_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1167,6 +1240,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1167 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1240 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1168 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1241 {ICAL_METHOD_NONE,ICAL_VEVENT_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
1171 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1245 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1172 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1246 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -1215,6 +1289,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1215 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0}, 1289 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZEROORONE,0},
1216 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1290 {ICAL_METHOD_NONE,ICAL_VTODO_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
1219 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1294 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ATTACH_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
1220 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0}, 1295 {ICAL_METHOD_NONE,ICAL_VJOURNAL_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ZEROPLUS,0},
@@ -1551,7 +1626,7 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1551 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1626 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1552 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1627 {ICAL_METHOD_NONE,ICAL_XDISPLAYALARM_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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},
1556 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0}, 1631 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_ATTENDEE_PROPERTY,ICAL_RESTRICTION_ONEPLUS,0},
1557 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_CALSCALE_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1632 {ICAL_METHOD_NONE,ICAL_XEMAILALARM_COMPONENT,ICAL_CALSCALE_PROPERTY,ICAL_RESTRICTION_ZERO,0},
@@ -1647,6 +1722,9 @@ icalrestriction_property_record icalrestriction_property_records[] = {
1647 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1722 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_URL_PROPERTY,ICAL_RESTRICTION_ZERO,0},
1648 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0}, 1723 {ICAL_METHOD_NONE,ICAL_XPROCEDUREALARM_COMPONENT,ICAL_VERSION_PROPERTY,ICAL_RESTRICTION_ZERO,0},
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}
1651}; 1729};
1652icalrestriction_component_record icalrestriction_component_records[] = { 1730icalrestriction_component_record icalrestriction_component_records[] = {
@@ -1777,5 +1855,7 @@ icalrestriction_component_record icalrestriction_component_records[] = {
1777 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VEVENT_COMPONENT,ICAL_RESTRICTION_ZERO,0}, 1855 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VEVENT_COMPONENT,ICAL_RESTRICTION_ZERO,0},
1778 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VFREEBUSY_COMPONENT,ICAL_RESTRICTION_ZERO,0}, 1856 {ICAL_METHOD_CANCEL,ICAL_VJOURNAL_COMPONENT,ICAL_VFREEBUSY_COMPONENT,ICAL_RESTRICTION_ZERO,0},
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}
1781}; 1861};
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
@@ -26,7 +26,7 @@
26 ======================================================================*/ 26 ======================================================================*/
27 27
28#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
29#include <config.h> 29#include "config.h"
30#endif 30#endif
31 31
32#include "icaltime.h" 32#include "icaltime.h"
@@ -34,140 +34,223 @@
34#include <string.h> 34#include <string.h>
35#include <stdlib.h> 35#include <stdlib.h>
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{
162 struct tm stm; 243 struct tm stm;
163 time_t t; 244 time_t t;
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;
169 } 249 }
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;
172 stm.tm_min = tt.minute; 255 stm.tm_min = tt.minute;
173 stm.tm_hour = tt.hour; 256 stm.tm_hour = tt.hour;
@@ -176,19 +259,57 @@ time_t icaltime_as_timet(struct icaltimetype tt)
176 stm.tm_year = tt.year-1900; 259 stm.tm_year = tt.year-1900;
177 stm.tm_isdst = -1; 260 stm.tm_isdst = -1;
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
187 return t; 264 return t;
188 265
189} 266}
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{
193 size_t size = 17; 314 size_t size = 17;
194 char* buf = icalmemory_new_buffer(size); 315 char* buf = icalmemory_new_buffer(size);
@@ -212,107 +333,33 @@ char* icaltime_as_ical_string(struct icaltimetype tt)
212 333
213} 334}
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}
311 351
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)
317{ 364{
318 struct icaltimetype tt = icaltime_null_time(); 365 struct icaltimetype tt = icaltime_null_time();
@@ -326,189 +373,230 @@ struct icaltimetype icaltime_from_string(const char* str)
326 tt.is_utc = 0; 373 tt.is_utc = 0;
327 tt.is_date = 0; 374 tt.is_date = 0;
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 */
338 tt.is_utc = 1; 383 tt.is_utc = 1;
339 tt.is_date = 1; 384 tt.is_date = 1;
340 } else { /* error */ 385 } else { /* error */
341 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 386 goto ERROR;
342 return icaltime_null_time();
343 } 387 }
344 388
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 }
358 401
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
385 assert(month > 0); 429 assert(month > 0);
386 assert(month <= 12); 430 assert(month <= 12);
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 }
396 435
397 return days; 436 return days;
398} 437}
399 438
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{
504 struct icaltimetype t; 577 struct icaltimetype t;
505 memset(&t,0,sizeof(struct icaltimetype)); 578 memset(&t,0,sizeof(struct icaltimetype));
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;
508} 591}
509 592
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 ||
513 t.year < 0 || t.year > 3000 || 601 t.year < 0 || t.year > 3000 ||
514 t.is_date > 1 || t.is_date < 0){ 602 t.is_date > 1 || t.is_date < 0){
@@ -519,7 +607,26 @@ int icaltime_is_valid_time(struct icaltimetype t){
519 607
520} 608}
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{
524 if (t.second +t.minute+t.hour+t.day+t.month+t.year == 0){ 631 if (t.second +t.minute+t.hour+t.day+t.month+t.year == 0){
525 return 1; 632 return 1;
@@ -529,44 +636,101 @@ int icaltime_is_null_time(struct icaltimetype t)
529 636
530} 637}
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
571/* These are defined in icalduration.c: 735/* These are defined in icalduration.c:
572struct icaltimetype icaltime_add(struct icaltimetype t, 736struct icaltimetype icaltime_add(struct icaltimetype t,
@@ -575,3 +739,277 @@ struct icaldurationtype icaltime_subtract(struct icaltimetype t1,
575 struct icaltimetype t2) 739 struct icaltimetype t2)
576*/ 740*/
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
@@ -26,120 +26,248 @@
26 26
27======================================================================*/ 27======================================================================*/
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
30#define ICALTIME_H 94#define ICALTIME_H
31 95
32#include <time.h> 96#include <time.h>
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;
47 int hour; 125 int hour;
48 int minute; 126 int minute;
49 int second; 127 int second;
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
145 273
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
@@ -35,137 +35,43 @@
35#include <string.h> /* for icalmemory_strdup */ 35#include <string.h> /* for icalmemory_strdup */
36#include <assert.h> 36#include <assert.h>
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
40#define TEMP_MAX 1024 43#define TEMP_MAX 1024
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)
170{ 76{
171 77
@@ -181,7 +87,7 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
181 87
182 if(str == 0) goto error; 88 if(str == 0) goto error;
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);
186 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); 92 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL);
187 e = icalerrno; 93 e = icalerrno;
@@ -193,7 +99,7 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
193 99
194 tr.duration = icaldurationtype_from_string(str); 100 tr.duration = icaldurationtype_from_string(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 }
198 104
199 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); 105 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
@@ -203,7 +109,7 @@ struct icaltriggertype icaltriggertype_from_string(const char* str)
203 error: 109 error:
204 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); 110 icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
205 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 111 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
206 return null_tr; 112 return tr;
207 113
208} 114}
209 115
@@ -212,7 +118,7 @@ struct icalreqstattype icalreqstattype_from_string(const char* str)
212{ 118{
213 const char *p1,*p2; 119 const char *p1,*p2;
214 struct icalreqstattype stat; 120 struct icalreqstattype stat;
215 int major, minor; 121 short major=0, minor=0;
216 122
217 icalerror_check_arg((str != 0),"str"); 123 icalerror_check_arg((str != 0),"str");
218 124
@@ -222,7 +128,7 @@ struct icalreqstattype icalreqstattype_from_string(const char* str)
222 128
223 /* Get the status numbers */ 129 /* Get the status numbers */
224 130
225 sscanf(str, "%d.%d",&major, &minor); 131 sscanf(str, "%hd.%hd",&major, &minor);
226 132
227 if (major <= 0 || minor < 0){ 133 if (major <= 0 || minor < 0){
228 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); 134 icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
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
@@ -31,39 +31,6 @@
31#include "icalperiod.h" 31#include "icalperiod.h"
32 32
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
68{ 35{
69 float lat; 36 float lat;
@@ -84,9 +51,11 @@ struct icaltriggertype
84 struct icaldurationtype duration; 51 struct icaldurationtype duration;
85}; 52};
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);
88 56
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
91/* struct icalreqstattype. This struct contains two string pointers, 60/* struct icalreqstattype. This struct contains two string pointers,
92but don't try to free either of them. The "desc" string is a pointer 61but don't try to free either of them. The "desc" string is a pointer
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,4 +1,5 @@
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/*======================================================================
3 FILE: icalvalue.c 4 FILE: icalvalue.c
4 CREATOR: eric 02 May 1999 5 CREATOR: eric 02 May 1999
@@ -46,7 +47,10 @@
46#include <stdlib.h> /* for atoi and atof */ 47#include <stdlib.h> /* for atoi and atof */
47#include <limits.h> /* for SHRT_MAX */ 48#include <limits.h> /* for SHRT_MAX */
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
51#if _MAC_OS_ 55#if _MAC_OS_
52#include "icalmemory_strdup.h" 56#include "icalmemory_strdup.h"
@@ -54,16 +58,18 @@ int snprintf(char *str, size_t n, char const *fmt, ...);
54 58
55#define TMP_BUF_SIZE 1024 59#define TMP_BUF_SIZE 1024
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
62 65
63struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind){ 66struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind){
64 67
65 struct icalvalue_impl* v; 68 struct icalvalue_impl* v;
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*)
68 malloc(sizeof(struct icalvalue_impl))) == 0) { 74 malloc(sizeof(struct icalvalue_impl))) == 0) {
69 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 75 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
@@ -90,10 +96,8 @@ icalvalue_new (icalvalue_kind kind)
90 return (icalvalue*)icalvalue_new_impl(kind); 96 return (icalvalue*)icalvalue_new_impl(kind);
91} 97}
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
98 new = icalvalue_new_impl(old->kind); 102 new = icalvalue_new_impl(old->kind);
99 103
@@ -101,21 +105,25 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
101 return 0; 105 return 0;
102 } 106 }
103 107
104
105 strcpy(new->id, old->id); 108 strcpy(new->id, old->id);
106 new->kind = old->kind; 109 new->kind = old->kind;
107 new->size = old->size; 110 new->size = old->size;
108 111
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:
114 case ICAL_BINARY_VALUE: 114 case ICAL_BINARY_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:
120 case ICAL_TEXT_VALUE: 128 case ICAL_TEXT_VALUE:
121 case ICAL_CALADDRESS_VALUE: 129 case ICAL_CALADDRESS_VALUE:
@@ -146,6 +154,19 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
146 break; 154 break;
147 } 155 }
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:
150 { 171 {
151 /* all of the other types are stored as values, not 172 /* all of the other types are stored as values, not
@@ -158,7 +179,7 @@ icalvalue* icalvalue_new_clone(icalvalue* value){
158 return new; 179 return new;
159} 180}
160 181
161char* icalmemory_strdup_and_dequote(const char* str) 182static char* icalmemory_strdup_and_dequote(const char* str)
162{ 183{
163 const char* p; 184 const char* p;
164 char* out = (char*)malloc(sizeof(char) * strlen(str) +1); 185 char* out = (char*)malloc(sizeof(char) * strlen(str) +1);
@@ -183,18 +204,39 @@ char* icalmemory_strdup_and_dequote(const char* str)
183 204
184 } 205 }
185 case 'n': 206 case 'n':
207 case 'N':
186 { 208 {
187 *pout = '\n'; 209 *pout = '\n';
188 break; 210 break;
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 {
199 *pout = *p; 241 *pout = *p;
200 break; 242 break;
@@ -217,9 +259,16 @@ char* icalmemory_strdup_and_dequote(const char* str)
217 return out; 259 return out;
218} 260}
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;
224 273
225 if(e != 0 && icalproperty_enum_belongs_to_property( 274 if(e != 0 && icalproperty_enum_belongs_to_property(
@@ -242,7 +291,6 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
242{ 291{
243 292
244 struct icalvalue_impl *value = 0; 293 struct icalvalue_impl *value = 0;
245 struct icalattachtype *attach = 0;
246 294
247 icalerror_check_arg_rz(str!=0,"str"); 295 icalerror_check_arg_rz(str!=0,"str");
248 296
@@ -253,12 +301,19 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
253 switch (kind){ 301 switch (kind){
254 302
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:
263 { 318 {
264 /* HACK */ 319 /* HACK */
@@ -267,7 +322,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
267 if (error != 0){ 322 if (error != 0){
268 char temp[TMP_BUF_SIZE]; 323 char temp[TMP_BUF_SIZE];
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(
272 temp, 327 temp,
273 icalparameter_new_xlicerrortype( 328 icalparameter_new_xlicerrortype(
@@ -279,37 +334,50 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
279 334
280 335
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;
296 356
297 357
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;
314 } 382 }
315 383
@@ -321,28 +389,19 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
321 break; 389 break;
322 } 390 }
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;
347 /* HACK */ 406 /* HACK */
348 407
@@ -350,16 +409,15 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
350 char temp[TMP_BUF_SIZE]; 409 char temp[TMP_BUF_SIZE];
351 sprintf(temp,"GEO Values are not implemented"); 410 sprintf(temp,"GEO Values are not implemented");
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
364 case ICAL_RECUR_VALUE: 422 case ICAL_RECUR_VALUE:
365 { 423 {
@@ -391,14 +449,17 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
391 struct icaltimetype tt; 449 struct icaltimetype tt;
392 struct icalperiodtype p; 450 struct icalperiodtype p;
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;
403 } 464 }
404 465
@@ -406,9 +467,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
406 { 467 {
407 struct icaldurationtype dur = icaldurationtype_from_string(str); 468 struct icaldurationtype dur = icaldurationtype_from_string(str);
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);
413 } 472 }
414 473
@@ -429,7 +488,7 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
429 case ICAL_TRIGGER_VALUE: 488 case ICAL_TRIGGER_VALUE:
430 { 489 {
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);
434 } 493 }
435 break; 494 break;
@@ -444,9 +503,17 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
444 break; 503 break;
445 504
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 ){
451 char temp[TMP_BUF_SIZE]; 518 char temp[TMP_BUF_SIZE];
452 519
@@ -484,17 +551,15 @@ icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char*
484 551
485icalvalue* icalvalue_new_from_string(icalvalue_kind kind,const char* str) 552icalvalue* 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}
489 556
490 557
491 558
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
499#ifdef ICAL_FREE_ON_LIST_IS_ERROR 564#ifdef ICAL_FREE_ON_LIST_IS_ERROR
500 icalerror_assert( (v->parent ==0),"This value is still attached to a property"); 565 icalerror_assert( (v->parent ==0),"This value is still attached to a property");
@@ -510,15 +575,19 @@ icalvalue_free (icalvalue* value)
510 } 575 }
511 576
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 }
519 case ICAL_TEXT_VALUE: 587 case ICAL_TEXT_VALUE:
520 case ICAL_CALADDRESS_VALUE: 588 case ICAL_CALADDRESS_VALUE:
521 case ICAL_URI_VALUE: 589 case ICAL_URI_VALUE:
590 case ICAL_QUERY_VALUE:
522 { 591 {
523 if (v->data.v_string != 0) { 592 if (v->data.v_string != 0) {
524 free((void*)v->data.v_string); 593 free((void*)v->data.v_string);
@@ -550,10 +619,8 @@ icalvalue_free (icalvalue* value)
550} 619}
551 620
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){
558 return 0; 625 return 0;
559 } 626 }
@@ -561,7 +628,7 @@ icalvalue_is_valid (icalvalue* value)
561 return 1; 628 return 1;
562} 629}
563 630
564char* icalvalue_binary_as_ical_string(icalvalue* value) { 631static char* icalvalue_binary_as_ical_string(const icalvalue* value) {
565 632
566 const char* data; 633 const char* data;
567 char* str; 634 char* str;
@@ -575,10 +642,10 @@ char* icalvalue_binary_as_ical_string(icalvalue* value) {
575 return str; 642 return str;
576} 643}
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;
583 char* str = (char*)icalmemory_tmp_buffer(MAX_INT_DIGITS); 650 char* str = (char*)icalmemory_tmp_buffer(MAX_INT_DIGITS);
584 651
@@ -590,26 +657,8 @@ char* icalvalue_int_as_ical_string(icalvalue* value) {
590 657
591 return str; 658 return str;
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{
614 int data,h,m,s; 663 int data,h,m,s;
615 char sign; 664 char sign;
@@ -629,18 +678,20 @@ char* icalvalue_utcoffset_as_ical_string(icalvalue* value)
629 m = (data - (h*3600))/ 60; 678 m = (data - (h*3600))/ 60;
630 s = (data - (h*3600) - (m*60)); 679 s = (data - (h*3600) - (m*60));
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
634 return str; 686 return str;
635} 687}
636 688
637char* icalvalue_string_as_ical_string(icalvalue* value) { 689static char* icalvalue_string_as_ical_string(const icalvalue* value) {
638 690
639 const char* data; 691 const char* data;
640 char* str = 0; 692 char* str = 0;
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
645 str = (char*)icalmemory_tmp_buffer(strlen(data)+1); 696 str = (char*)icalmemory_tmp_buffer(strlen(data)+1);
646 697
@@ -650,26 +701,27 @@ char* icalvalue_string_as_ical_string(icalvalue* value) {
650} 701}
651 702
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
658 return icalrecurrencetype_as_string(recur); 708 return icalrecurrencetype_as_string(recur);
659} 709}
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;
664 char *str_p; 719 char *str_p;
665 char *rtrn; 720 char *rtrn;
666 const char *p; 721 const char *p;
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
674 str_p = str = (char*)icalmemory_new_buffer(buf_sz); 726 str_p = str = (char*)icalmemory_new_buffer(buf_sz);
675 727
@@ -677,61 +729,44 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
677 return 0; 729 return 0;
678 } 730 }
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
682 switch(*p){ 734 switch(*p){
683 case '\n': { 735 case '\n': {
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;
687 } 738 }
688 739
689 case '\t': { 740 case '\t': {
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;
693 } 743 }
694 case '\r': { 744 case '\r': {
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;
698 } 747 }
699 case '\b': { 748 case '\b': {
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;
703 } 751 }
704 case '\f': { 752 case '\f': {
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;
708 } 755 }
709 756
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;
716 } 764 }
717 765
718 default: { 766 default: {
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 }
736 771
737 /* Assume the last character is not a '\0' and add one. We could 772 /* Assume the last character is not a '\0' and add one. We could
@@ -749,34 +784,29 @@ char* icalvalue_text_as_ical_string(icalvalue* value) {
749} 784}
750 785
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;
756 792
757 icalerror_check_arg_rz( (value!=0),"value"); 793 icalerror_check_arg_rz( (value!=0),"value");
758 794
759 a = icalvalue_get_attach(value); 795 a = icalvalue_get_attach(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}
777 807
778 808
779char* icalvalue_duration_as_ical_string(icalvalue* value) { 809static char* icalvalue_duration_as_ical_string(const icalvalue* value) {
780 810
781 struct icaldurationtype data; 811 struct icaldurationtype data;
782 812
@@ -786,11 +816,11 @@ char* icalvalue_duration_as_ical_string(icalvalue* value) {
786 return icaldurationtype_as_ical_string(data); 816 return icaldurationtype_as_ical_string(data);
787} 817}
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{
791 char temp[20]; 821 char temp[20];
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);
795 } else { 825 } else {
796 sprintf(temp,"%02d%02d%02d",data->hour,data->minute,data->second); 826 sprintf(temp,"%02d%02d%02d",data->hour,data->minute,data->second);
@@ -800,7 +830,7 @@ void print_time_to_string(char* str, struct icaltimetype *data)
800} 830}
801 831
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{
805 char temp[20]; 835 char temp[20];
806 836
@@ -809,7 +839,7 @@ void print_date_to_string(char* str, struct icaltimetype *data)
809 strcat(str,temp); 839 strcat(str,temp);
810} 840}
811 841
812char* icalvalue_date_as_ical_string(icalvalue* value) { 842static char* icalvalue_date_as_ical_string(const icalvalue* value) {
813 843
814 struct icaltimetype data; 844 struct icaltimetype data;
815 char* str; 845 char* str;
@@ -824,15 +854,14 @@ char* icalvalue_date_as_ical_string(icalvalue* value) {
824 return str; 854 return str;
825} 855}
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{
829 print_date_to_string(str,data); 859 print_date_to_string(str,data);
830 strcat(str,"T"); 860 strcat(str,"T");
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
837 struct icaltimetype data; 866 struct icaltimetype data;
838 char* str; 867 char* str;
@@ -859,7 +888,7 @@ const char* icalvalue_datetime_as_ical_string(icalvalue* value) {
859 888
860} 889}
861 890
862char* icalvalue_float_as_ical_string(icalvalue* value) { 891static char* icalvalue_float_as_ical_string(const icalvalue* value) {
863 892
864 float data; 893 float data;
865 char* str; 894 char* str;
@@ -873,7 +902,7 @@ char* icalvalue_float_as_ical_string(icalvalue* value) {
873 return str; 902 return str;
874} 903}
875 904
876char* icalvalue_geo_as_ical_string(icalvalue* value) { 905static char* icalvalue_geo_as_ical_string(const icalvalue* value) {
877 906
878 struct icalgeotype data; 907 struct icalgeotype data;
879 char* str; 908 char* str;
@@ -888,7 +917,7 @@ char* icalvalue_geo_as_ical_string(icalvalue* value) {
888 return str; 917 return str;
889} 918}
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);
893 922
894 icalerror_check_arg_rz( (value!=0),"value"); 923 icalerror_check_arg_rz( (value!=0),"value");
@@ -900,7 +929,7 @@ const char* icalvalue_datetimeperiod_as_ical_string(icalvalue* value) {
900 } 929 }
901} 930}
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;
905 icalerror_check_arg_rz( (value!=0),"value"); 934 icalerror_check_arg_rz( (value!=0),"value");
906 data = icalvalue_get_period(value); 935 data = icalvalue_get_period(value);
@@ -909,7 +938,7 @@ const char* icalvalue_period_as_ical_string(icalvalue* value) {
909 938
910} 939}
911 940
912char* icalvalue_trigger_as_ical_string(icalvalue* value) { 941static const char* icalvalue_trigger_as_ical_string(const icalvalue* value) {
913 942
914 struct icaltriggertype data; 943 struct icaltriggertype data;
915 944
@@ -925,17 +954,13 @@ char* icalvalue_trigger_as_ical_string(icalvalue* value) {
925} 954}
926 955
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){
935 return 0; 960 return 0;
936 } 961 }
937 962
938 switch (v->kind){ 963 switch (value->kind){
939 964
940 case ICAL_ATTACH_VALUE: 965 case ICAL_ATTACH_VALUE:
941 return icalvalue_attach_as_ical_string(value); 966 return icalvalue_attach_as_ical_string(value);
@@ -953,6 +978,9 @@ icalvalue_as_ical_string (icalvalue* value)
953 case ICAL_TEXT_VALUE: 978 case ICAL_TEXT_VALUE:
954 return icalvalue_text_as_ical_string(value); 979 return icalvalue_text_as_ical_string(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:
957 case ICAL_URI_VALUE: 985 case ICAL_URI_VALUE:
958 case ICAL_CALADDRESS_VALUE: 986 case ICAL_CALADDRESS_VALUE:
@@ -983,21 +1011,24 @@ icalvalue_as_ical_string (icalvalue* value)
983 return icalvalue_trigger_as_ical_string(value); 1011 return icalvalue_trigger_as_ical_string(value);
984 1012
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
988 case ICAL_ACTION_VALUE: 1016 case ICAL_ACTION_VALUE:
989 case ICAL_METHOD_VALUE: 1017 case ICAL_METHOD_VALUE:
990 case ICAL_STATUS_VALUE: 1018 case ICAL_STATUS_VALUE:
991 case ICAL_TRANSP_VALUE: 1019 case ICAL_TRANSP_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
1002 case ICAL_NO_VALUE: 1033 case ICAL_NO_VALUE:
1003 default: 1034 default:
@@ -1009,15 +1040,13 @@ icalvalue_as_ical_string (icalvalue* value)
1009 1040
1010 1041
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){
1017 return ICAL_NO_VALUE; 1046 return ICAL_NO_VALUE;
1018 } 1047 }
1019 1048
1020 return v->kind; 1049 return value->kind;
1021} 1050}
1022 1051
1023 1052
@@ -1036,7 +1065,7 @@ icalvalue_isa_value (void* value)
1036} 1065}
1037 1066
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);
1041 1070
1042 if(kind == ICAL_DATETIME_VALUE || 1071 if(kind == ICAL_DATETIME_VALUE ||
@@ -1048,11 +1077,14 @@ int icalvalue_is_time(icalvalue* a) {
1048 1077
1049} 1078}
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
1057 icalerror_check_arg_rz( (a!=0), "a"); 1089 icalerror_check_arg_rz( (a!=0), "a");
1058 icalerror_check_arg_rz( (b!=0), "b"); 1090 icalerror_check_arg_rz( (b!=0), "b");
@@ -1066,7 +1098,29 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1066 switch (icalvalue_isa(a)){ 1098 switch (icalvalue_isa(a)){
1067 1099
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
1071 case ICAL_BOOLEAN_VALUE: 1125 case ICAL_BOOLEAN_VALUE:
1072 { 1126 {
@@ -1079,9 +1133,9 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1079 1133
1080 case ICAL_FLOAT_VALUE: 1134 case ICAL_FLOAT_VALUE:
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;
1086 } else { 1140 } else {
1087 return ICAL_XLICCOMPARETYPE_EQUAL; 1141 return ICAL_XLICCOMPARETYPE_EQUAL;
@@ -1091,9 +1145,9 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1091 case ICAL_INTEGER_VALUE: 1145 case ICAL_INTEGER_VALUE:
1092 case ICAL_UTCOFFSET_VALUE: 1146 case ICAL_UTCOFFSET_VALUE:
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;
1098 } else { 1152 } else {
1099 return ICAL_XLICCOMPARETYPE_EQUAL; 1153 return ICAL_XLICCOMPARETYPE_EQUAL;
@@ -1102,12 +1156,12 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1102 1156
1103 case ICAL_DURATION_VALUE: 1157 case ICAL_DURATION_VALUE:
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;
1112 } else { 1166 } else {
1113 return ICAL_XLICCOMPARETYPE_EQUAL; 1167 return ICAL_XLICCOMPARETYPE_EQUAL;
@@ -1122,6 +1176,8 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1122 case ICAL_DATE_VALUE: 1176 case ICAL_DATE_VALUE:
1123 case ICAL_DATETIME_VALUE: 1177 case ICAL_DATETIME_VALUE:
1124 case ICAL_DATETIMEPERIOD_VALUE: 1178 case ICAL_DATETIMEPERIOD_VALUE:
1179 case ICAL_QUERY_VALUE:
1180 case ICAL_RECUR_VALUE:
1125 { 1181 {
1126 int r; 1182 int r;
1127 1183
@@ -1159,31 +1215,49 @@ icalvalue_compare(icalvalue* a, icalvalue *b)
1159 1215
1160 } 1216 }
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:
1166 default: 1239 default:
1167 { 1240 {
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 }
1171 } 1244 }
1172 1245
1173} 1246}
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 }
1188 } 1262 }
1189 1263
@@ -1192,24 +1266,44 @@ void icalvalue_reset_kind(icalvalue* value)
1192void icalvalue_set_parent(icalvalue* value, 1266void icalvalue_set_parent(icalvalue* value,
1193 icalproperty* property) 1267 icalproperty* property)
1194{ 1268{
1195 struct icalvalue_impl* v = (struct icalvalue_impl*)value; 1269 value->parent = property;
1196
1197 v->parent = property;
1198
1199} 1270}
1200 1271
1201icalproperty* icalvalue_get_parent(icalvalue* value) 1272icalproperty* 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
1211/* The remaining interfaces are 'new', 'set' and 'get' for each of the value 1308/* The remaining interfaces are 'new', 'set' and 'get' for each of the value
1212 types */ 1309 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
@@ -7,8 +7,6 @@
7 $Id$ 7 $Id$
8 $Locker$ 8 $Locker$
9 9
10
11
12 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
13 11
14 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
@@ -40,46 +38,51 @@
40#include "icalderivedvalue.h" 38#include "icalderivedvalue.h"
41 39
42/* Defined in icalderivedvalue.h */ 40/* Defined in icalderivedvalue.h */
43/*typedef void icalvalue;*/ 41/*typedef struct icalvalue_impl icalvalue;*/
44 42
45icalvalue* icalvalue_new(icalvalue_kind kind); 43icalvalue* icalvalue_new(icalvalue_kind kind);
46 44
47icalvalue* icalvalue_new_clone(icalvalue* value); 45icalvalue* icalvalue_new_clone(const icalvalue* value);
48 46
49icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str); 47icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str);
50 48
51void icalvalue_free(icalvalue* value); 49void 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
59int icalvalue_isa_value(void*); 57int 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
63 61
64/* Special, non autogenerated value accessors */ 62/* Special, non autogenerated value accessors */
65 63
66icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); 64icalvalue* 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
70icalvalue* icalvalue_new_trigger (struct icaltriggertype v); 68icalvalue* 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
74icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); 72icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v);
75void icalvalue_set_datetimeperiod(icalvalue* value, 73void 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
79/* Convert enumerations */ 77/* Convert enumerations */
80 78
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
85#endif /*ICALVALUE_H*/ 88#endif /*ICALVALUE_H*/
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
@@ -35,6 +35,8 @@
35#define ICALVALUEIMPL_H 35#define ICALVALUEIMPL_H
36 36
37#include "icalenums.h" 37#include "icalenums.h"
38#include "icalproperty.h"
39#include "icalderivedvalue.h"
38 40
39 41
40struct icalvalue_impl { 42struct icalvalue_impl {
@@ -43,10 +45,10 @@ struct icalvalue_impl {
43 char id[5]; 45 char id[5];
44 int size; 46 int size;
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 */
51 const char *v_string; 53 const char *v_string;
52 /*char *v_text;*/ 54 /*char *v_text;*/
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
@@ -2,6 +2,6 @@
2#define ICAL_VERSION_H 2#define ICAL_VERSION_H
3 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
7#endif 7#endif
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,66 +1,70 @@
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)
6MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
7DESTDIR=../../lib/$(PLATFORM) 10DESTDIR=../../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
@@ -15,9 +15,7 @@
15#include <assert.h> 15#include <assert.h>
16#include <stdlib.h> 16#include <stdlib.h>
17 17
18 18/**
19
20/*
21 struct pvl_list_t 19 struct pvl_list_t
22 20
23 The list structure. This is the hanlde for the entire list 21 The list structure. This is the hanlde for the entire list
@@ -28,35 +26,30 @@
28 26
29typedef struct pvl_list_t 27typedef 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;
37 35
38 36
39 37
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
44int pvl_elem_count = 0; 44int pvl_elem_count = 0;
45int pvl_list_count = 0; 45int pvl_list_count = 0;
46 46
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
61pvl_list 54pvl_list
62pvl_newlist() 55pvl_newlist()
@@ -89,32 +82,23 @@ pvl_free(pvl_list l)
89 free(L); 82 free(L);
90} 83}
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{
119 struct pvl_elem_t *E; 103 struct pvl_elem_t *E;
120 104
@@ -132,25 +116,16 @@ pvl_new_element(void *d, pvl_elem next,pvl_elem prior)
132 return (pvl_elem)E; 116 return (pvl_elem)E;
133} 117}
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);
155 130
156 if (E->next != 0) 131 if (E->next != 0)
@@ -172,53 +147,37 @@ pvl_unshift(pvl_list l,void *d)
172 L->count++; 147 L->count++;
173} 148}
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)
195 { 162 {
196 return 0; 163 return 0;
197 } 164 }
198 165
199 return pvl_remove(l,(void*)L->head); 166 return pvl_remove(L,(void*)L->head);
200 167
201} 168}
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);
223 182
224 /* These are done in pvl_new_element 183 /* These are done in pvl_new_element
@@ -242,59 +201,37 @@ pvl_push(pvl_list l,void *d)
242 201
243} 202}
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)
266 { 214 {
267 return 0; 215 return 0;
268 } 216 }
269 217
270 return pvl_remove(l,(void*) L->tail);; 218 return pvl_remove(L,(void*) L->tail);;
271 219
272} 220}
273 221
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;
299 236
300 L->count++; 237 L->count++;
@@ -303,7 +240,7 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
303 240
304 if(L->head == 0) 241 if(L->head == 0)
305 { 242 {
306 pvl_unshift(l,d); 243 pvl_unshift(L,d);
307 return; 244 return;
308 } 245 }
309 246
@@ -311,14 +248,14 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
311 248
312 if ( ((*f)(d,L->head->d)) <= 0) 249 if ( ((*f)(d,L->head->d)) <= 0)
313 { 250 {
314 pvl_unshift(l,d); 251 pvl_unshift(L,d);
315 return; 252 return;
316 } 253 }
317 254
318 /* larger than tail, add to tail */ 255 /* larger than tail, add to tail */
319 if ( (*f)(d,L->tail->d) >= 0) 256 if ( (*f)(d,L->tail->d) >= 0)
320 { 257 {
321 pvl_push(l,d); 258 pvl_push(L,d);
322 return; 259 return;
323 } 260 }
324 261
@@ -329,48 +266,34 @@ pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d)
329 { 266 {
330 if ( (*f)(P->d,d) >= 0) 267 if ( (*f)(P->d,d) >= 0)
331 { 268 {
332 pvl_insert_before(l,P,d); 269 pvl_insert_before(L,P,d);
333 return; 270 return;
334 } 271 }
335 } 272 }
336 273
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;
368 291
369 L->count++; 292 L->count++;
370 293
371 if (P == 0) 294 if (P == 0)
372 { 295 {
373 pvl_unshift(l,d); 296 pvl_unshift(L,d);
374 return; 297 return;
375 } 298 }
376 299
@@ -388,34 +311,24 @@ pvl_insert_after(pvl_list l,pvl_elem p,void *d)
388 } 311 }
389} 312}
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;
413 326
414 L->count++; 327 L->count++;
415 328
416 if (P == 0) 329 if (P == 0)
417 { 330 {
418 pvl_unshift(l,d); 331 pvl_unshift(L,d);
419 return; 332 return;
420 } 333 }
421 334
@@ -433,29 +346,19 @@ pvl_insert_before(pvl_list l,pvl_elem p,void *d)
433 } 346 }
434} 347}
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;
460 363
461 if (E == L->head) 364 if (E == L->head)
@@ -504,28 +407,19 @@ pvl_remove(pvl_list l,pvl_elem e)
504 407
505} 408}
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
530pvl_elem 424pvl_elem
531pvl_find(pvl_list l,pvl_findf f,void* v) 425pvl_find(pvl_list l,pvl_findf f,void* v)
@@ -545,25 +439,17 @@ pvl_find(pvl_list l,pvl_findf f,void* v)
545 return 0; 439 return 0;
546 440
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
568pvl_elem 454pvl_elem
569pvl_find_next(pvl_list l,pvl_findf f,void* v) 455pvl_find_next(pvl_list l,pvl_findf f,void* v)
@@ -585,17 +471,10 @@ pvl_find_next(pvl_list l,pvl_findf f,void* v)
585 471
586} 472}
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
600void 479void
601pvl_clear(pvl_list l) 480pvl_clear(pvl_list l)
@@ -615,39 +494,25 @@ pvl_clear(pvl_list l)
615 } 494 }
616} 495}
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;
634} 506}
635 507
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){
652 return 0; 517 return 0;
653 } 518 }
@@ -655,74 +520,42 @@ pvl_next(pvl_elem e)
655 return (pvl_elem)E->next; 520 return (pvl_elem)E->next;
656} 521}
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;
674} 532}
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;
691} 543}
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;
707} 552}
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;
727 } 560 }
728 561
@@ -730,23 +563,13 @@ pvl_data(pvl_elem e)
730} 563}
731#endif 564#endif
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
751void 574void
752pvl_apply(pvl_list l,pvl_applyf f, void *v) 575pvl_apply(pvl_list l,pvl_applyf f, void *v)
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
@@ -10,29 +10,29 @@
10#ifndef __PVL_H__ 10#ifndef __PVL_H__
11#define __PVL_H__ 11#define __PVL_H__
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;
31 29
32 30
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
37extern int pvl_elem_count; 37extern int pvl_elem_count;
38extern int pvl_list_count; 38extern int pvl_list_count;
@@ -81,8 +81,11 @@ typedef int (*pvl_findf)(void* a, void* b); /*a is list elem, b is other data*/
81pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v); 81pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v);
82pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v); 82pvl_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);
87 90
88 91
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
@@ -41,18 +41,15 @@
41#include <stdlib.h> /* for malloc, free */ 41#include <stdlib.h> /* for malloc, free */
42#include <string.h> /* for strcasecmp */ 42#include <string.h> /* for strcasecmp */
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
53#include "dmalloc.h" 45#include "dmalloc.h"
54#endif 46#endif
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
57 54
58 55
@@ -93,7 +90,7 @@ char* sspm_strdup(char* str){
93} 90}
94 91
95 92
96struct major_content_type_map 93static struct major_content_type_map
97{ 94{
98 enum sspm_major_type type; 95 enum sspm_major_type type;
99 char* str; 96 char* str;
@@ -112,7 +109,7 @@ struct major_content_type_map
112 {SSPM_UNKNOWN_MAJOR_TYPE,"" }, 109 {SSPM_UNKNOWN_MAJOR_TYPE,"" },
113}; 110};
114 111
115struct minor_content_type_map 112static struct minor_content_type_map
116{ 113{
117 enum sspm_minor_type type; 114 enum sspm_minor_type type;
118 char* str; 115 char* str;
@@ -241,7 +238,7 @@ char* sspm_value(char* line)
241 238
242} 239}
243 240
244char *mime_headers[] = { 241static char *mime_headers[] = {
245 "Content-Type", 242 "Content-Type",
246 "Content-Transfer-Encoding", 243 "Content-Transfer-Encoding",
247 "Content-Disposition", 244 "Content-Disposition",
@@ -366,7 +363,7 @@ enum line_type {
366}; 363};
367 364
368 365
369enum line_type get_line_type(char* line){ 366static enum line_type get_line_type(char* line){
370 367
371 if (line == 0){ 368 if (line == 0){
372 return EMPTY; 369 return EMPTY;
@@ -390,7 +387,7 @@ enum line_type get_line_type(char* line){
390} 387}
391 388
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,
395 enum sspm_minor_type minor) 392 enum sspm_minor_type minor)
396{ 393{
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,4 +1,7 @@
1#ifdef __osf__ 1#ifndef WIN32
2#include "config.h"
3#endif
4#ifndef HAVE_SNPRINTF
2/* 5/*
3 * Revision 12: http://theos.com/~deraadt/snprintf.c 6 * Revision 12: http://theos.com/~deraadt/snprintf.c
4 * 7 *
@@ -25,14 +28,14 @@
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 29 */
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>
37#if __STDC__ 40#if __STDC__
38#include <stdarg.h> 41#include <stdarg.h>
@@ -157,20 +160,9 @@ snprintf(str, n, fmt, va_alist)
157 va_end(ap); 160 va_end(ap);
158} 161}
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... */
175 167
176static void vsnprintf_dummy_func() { 168static void vsnprintf_dummy_func() {
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
@@ -38,7 +38,7 @@
38 * components. It also has interfaces to access the free/busy list 38 * components. It also has interfaces to access the free/busy list
39 * and a list of calendar properties */ 39 * and a list of calendar properties */
40 40
41typedef void icalcalendar; 41typedef struct icalcalendar_impl icalcalendar;
42 42
43icalcalendar* icalcalendar_new(char* dir); 43icalcalendar* icalcalendar_new(char* dir);
44 44
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
@@ -26,10 +26,10 @@
26#include "config.h" 26#include "config.h"
27#endif 27#endif
28 28
29#include "icalerror.h"
30#include "ical.h" 29#include "ical.h"
31#include "icalclassify.h" 30#include "icalclassify.h"
32#include "icalmemory.h" 31#include "icalmemory.h"
32
33#include <ctype.h> /* For tolower() */ 33#include <ctype.h> /* For tolower() */
34#include <string.h> /* for index() */ 34#include <string.h> /* for index() */
35#include <stdlib.h> /* for malloc and free */ 35#include <stdlib.h> /* for malloc and free */
@@ -146,7 +146,7 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
146 p != 0; 146 p != 0;
147 p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) 147 p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY))
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));
151 char* this_upn = strchr(this_attendee,':'); 151 char* this_upn = strchr(this_attendee,':');
152 152
@@ -157,10 +157,14 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c,
157 } 157 }
158 158
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;
161 } 163 }
162 164
165 free(this_attendee);
163 } 166 }
167 free(lattendee);
164 168
165 return 0; 169 return 0;
166 170
@@ -284,7 +288,7 @@ int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b)
284 p1 = icalcomponent_get_first_property(i1,kind_array[i]); 288 p1 = icalcomponent_get_first_property(i1,kind_array[i]);
285 p2 = icalcomponent_get_first_property(i2,kind_array[i]); 289 p2 = icalcomponent_get_first_property(i2,kind_array[i]);
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
289 the other */ 293 the other */
290 return 1; 294 return 1;
@@ -546,7 +550,6 @@ int icalclassify_reply_crasher_decline(
546 struct icalclassify_parts *match, 550 struct icalclassify_parts *match,
547 const char* user) 551 const char* user)
548{ 552{
549 icalparameter_partstat partstat;
550 icalproperty* attendee; 553 icalproperty* attendee;
551 icalclassify_pre; 554 icalclassify_pre;
552 555
@@ -642,47 +645,47 @@ int icalclassify_delinecounter(
642struct icalclassify_map { 645struct icalclassify_map {
643 icalproperty_method method; 646 icalproperty_method method;
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};
677 680
678 681
679ical_class icalclassify(icalcomponent* c,icalcomponent* match, 682icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match,
680 const char* user) 683 const char* user)
681{ 684{
682 icalcomponent *inner; 685 icalcomponent *inner;
683 icalproperty *p; 686 icalproperty *p;
684 icalproperty_method method; 687 icalproperty_method method;
685 ical_class class = ICAL_UNKNOWN_CLASS; 688 icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN;
686 689
687 int i; 690 int i;
688 691
@@ -692,7 +695,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
692 inner = icalcomponent_get_first_real_component(c); 695 inner = icalcomponent_get_first_real_component(c);
693 696
694 if (inner == 0) { 697 if (inner == 0) {
695 return ICAL_NO_CLASS; 698 return ICAL_XLICCLASS_NONE;
696 } 699 }
697 700
698 icalssutil_get_parts(c,&comp_parts); 701 icalssutil_get_parts(c,&comp_parts);
@@ -709,7 +712,8 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
709 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0) 712 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
710 { 713 {
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 }
714 718
715 if( (comp_parts.sequence<match_parts.sequence ) 719 if( (comp_parts.sequence<match_parts.sequence )
@@ -718,14 +722,16 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
718 ( comp_parts.sequence == match_parts.sequence && 722 ( comp_parts.sequence == match_parts.sequence &&
719 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){ 723 icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){
720 724
721 return ICAL_OBSOLETE_CLASS; 725 class = ICAL_XLICCLASS_OBSOLETE;
726 goto CLEANUP;
722 } 727 }
723 728
724 } 729 }
725 730
726 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); 731 p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
727 if (p == 0) { 732 if (p == 0) {
728 return ICAL_UNKNOWN_CLASS; 733 class = ICAL_XLICCLASS_UNKNOWN;
734 goto CLEANUP;
729 } 735 }
730 method = icalproperty_get_method(p); 736 method = icalproperty_get_method(p);
731 737
@@ -738,6 +744,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
738 } 744 }
739 } 745 }
740 746
747CLEANUP:
741 icalssutil_free_parts(&comp_parts); 748 icalssutil_free_parts(&comp_parts);
742 icalssutil_free_parts(&match_parts); 749 icalssutil_free_parts(&match_parts);
743 750
@@ -745,48 +752,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match,
745 752
746} 753}
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
@@ -29,44 +29,12 @@
29#include "ical.h" 29#include "ical.h"
30#include "icalset.h" 30#include "icalset.h"
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);
66 34
67icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); 35icalcomponent* 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
71 39
72#endif /* ICALCLASSIFY_H*/ 40#endif /* ICALCLASSIFY_H*/
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
@@ -26,9 +26,10 @@
26 ======================================================================*/ 26 ======================================================================*/
27 27
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.
33 34
34 icaldirset groups components in to clusters based on their DTSTAMP 35 icaldirset groups components in to clusters based on their DTSTAMP
@@ -36,12 +37,13 @@
36 together in a single file. All files in a sotre are kept in a single 37 together in a single file. All files in a sotre are kept in a single
37 directory. 38 directory.
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
46 The Store generated UIDs for all objects that are stored if they do 48 The Store generated UIDs for all objects that are stored if they do
47 not already have a UID. The UID is the name of the cluster (month & 49 not already have a UID. The UID is the name of the cluster (month &
@@ -55,75 +57,76 @@
55#endif 57#endif
56 58
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"
64#include "icalfileset.h" 63#include "icalfileset.h"
65#include "icalfilesetimpl.h" 64#include "icalfilesetimpl.h"
65#include "icalcluster.h"
66#include "icalgauge.h" 66#include "icalgauge.h"
67 67
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() */
85#include <stdlib.h> /* for rand(), srand() */ 81#include <stdlib.h> /* for rand(), srand() */
86#include <string.h> /* for strdup */ 82#include <string.h> /* for strdup */
87#include "icaldirsetimpl.h" 83#include "icaldirsetimpl.h"
88 84
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}
119 114
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}
128 131
129void icaldirset_lock(const char* dir) 132void icaldirset_lock(const char* dir)
@@ -136,22 +139,22 @@ void icaldirset_unlock(const char* dir)
136} 139}
137 140
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);
150 return ICAL_FILE_ERROR; 153 return ICAL_FILE_ERROR;
151 } 154 }
152 155
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);
156 } 159 }
157 160
@@ -166,106 +169,143 @@ icalerrorenum icaldirset_read_directory(struct icaldirset_impl* impl)
166 continue; 169 continue;
167 } 170 }
168 171
169 pvl_push(impl->directory, (void*)strdup(de->d_name)); 172 pvl_push(dset->directory, (void*)strdup(de->d_name));
170 } 173 }
171 174
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
192 if (stat(dir,&sbuf) != 0){ 219 if (stat(dir,&sbuf) != 0){
193 icalerror_set_errno(ICAL_FILE_ERROR); 220 icalerror_set_errno(ICAL_FILE_ERROR);
194 return 0; 221 return 0;
195 } 222 }
196 223
197#ifndef _QTWIN_
198 /* dir is not the name of a direectory*/ 224 /* dir is not the name of a direectory*/
199 if (!S_ISDIR(sbuf.st_mode)){ 225 if (!S_ISDIR(sbuf.st_mode)){
200 icalerror_set_errno(ICAL_USAGE_ERROR); 226 icalerror_set_errno(ICAL_USAGE_ERROR);
201 return 0; 227 return 0;
202 } 228 }
203#endif
204 229
205 icaldirset_lock(dir); 230 icaldirset_lock(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);
247 } 292 }
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
264 directory in a file called SEQUENCE */ 305 directory in a file called SEQUENCE */
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;
270 char temp[128]; 310 char temp[128];
271 char filename[ICAL_PATH_MAX]; 311 char filename[ICAL_PATH_MAX];
@@ -273,16 +313,12 @@ int icaldirset_next_uid_number(icaldirset* store)
273 FILE *f; 313 FILE *f;
274 struct stat sbuf; 314 struct stat sbuf;
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
287 f = fopen(filename,"w"); 323 f = fopen(filename,"w");
288 if (f != 0){ 324 if (f != 0){
@@ -292,7 +328,6 @@ int icaldirset_next_uid_number(icaldirset* store)
292 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); 328 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
293 return 0; 329 return 0;
294 } 330 }
295
296 } 331 }
297 332
298 if ( (f = fopen(filename,"r+")) != 0){ 333 if ( (f = fopen(filename,"r+")) != 0){
@@ -318,89 +353,85 @@ int icaldirset_next_uid_number(icaldirset* store)
318 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number"); 353 icalerror_warn("Can't create SEQUENCE file in icaldirset_next_uid_number");
319 return 0; 354 return 0;
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);
331 return ICAL_INTERNAL_ERROR; 364 return ICAL_INTERNAL_ERROR;
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 }
341 return ICAL_NO_ERROR; 374 return ICAL_NO_ERROR;
342 } 375 }
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
350 return icalerrno; 382 return icalerrno;
351} 383}
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");
363 394
364 uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY); 395 uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
365 396
366 if (uid == 0) { 397 if (uid == 0) {
367 398
399#ifndef WIN32
368 uname(&unamebuf); 400 uname(&unamebuf);
369 401
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
372 uid = icalproperty_new_uid(uidstring); 407 uid = icalproperty_new_uid(uidstring);
373 icalcomponent_add_property(comp,uid); 408 icalcomponent_add_property(comp,uid);
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}
381 413
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;
393 struct icaltimetype tm; 426 struct icaltimetype tm;
394 icalerrorenum error = ICAL_NO_ERROR; 427 icalerrorenum error = ICAL_NO_ERROR;
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
405 /* Determine which cluster this object belongs in. This is a HACK */ 436 /* Determine which cluster this object belongs in. This is a HACK */
406 437
@@ -410,52 +441,44 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
410 441
411 dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); 442 dt = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);
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);
421 inner != 0; 450 inner != 0;
422 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){ 451 inner = icalcomponent_get_next_component(comp,ICAL_ANY_COMPONENT)){
423 452
424 dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); 453 dt = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
425 454
426 if (dt != 0){ 455 if (dt != 0)
427 break; 456 break;
428 } 457 }
429 } 458 }
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");
437 icalerror_set_errno(ICAL_BADARG_ERROR); 462 icalerror_set_errno(ICAL_BADARG_ERROR);
438 return ICAL_BADARG_ERROR; 463 return ICAL_BADARG_ERROR;
439 } 464 }
440 465
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;
460 } 483 }
461 } 484 }
@@ -466,33 +489,31 @@ icalerrorenum icaldirset_add_component(icaldirset* store, icaldirset* comp)
466 } 489 }
467 490
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
474 return ICAL_NO_ERROR; 496 return ICAL_NO_ERROR;
475} 497}
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
490 icalcompiter i; 511 icalcompiter i;
491 int found = 0; 512 int found = 0;
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
497 for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT); 518 for(i = icalcomponent_begin_component(filecomp,ICAL_ANY_COMPONENT);
498 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){ 519 icalcompiter_deref(&i)!= 0; icalcompiter_next(&i)){
@@ -511,17 +532,16 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
511 return ICAL_USAGE_ERROR; 532 return ICAL_USAGE_ERROR;
512 } 533 }
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 {
526 /* HACK. Not strictly correct for impl->cluster==0 */ 546 /* HACK. Not strictly correct for impl->cluster==0 */
527 return error; 547 return error;
@@ -535,95 +555,84 @@ icalerrorenum icaldirset_remove_component(icaldirset* store, icaldirset* comp)
535 555
536 556
537 557
538int icaldirset_count_components(icaldirset* store, 558int icaldirset_count_components(icalset* store,
539 icalcomponent_kind kind) 559 icalcomponent_kind kind)
540{ 560{
541 /* HACK, not implemented */ 561 /* HACK, not implemented */
542
543 assert(0); 562 assert(0);
544 563
545 return 0; 564 return 0;
546} 565}
547 566
548 567
549icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c) 568icalcomponent* icaldirset_fetch_match(icalset* set, icalcomponent *c)
550{ 569{
551 fprintf(stderr," icaldirset_fetch_match is not implemented\n"); 570 fprintf(stderr," icaldirset_fetch_match is not implemented\n");
552 assert(0); 571 assert(0);
572 return 0;
553} 573}
554 574
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
588 return c; 600 return c;
589} 601}
590 602
591 603
592int icaldirset_has_uid(icaldirset* store, const char* uid) 604int icaldirset_has_uid(icalset* set, const char* uid)
593{ 605{
594 icalcomponent *c; 606 icalcomponent *c;
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");
598 610
599 /* HACK. This is a temporary implementation. _has_uid should use a 611 /* HACK. This is a temporary implementation. _has_uid should use a
600 database, and _fetch should use _has_uid, not the other way 612 database, and _fetch should use _has_uid, not the other way
601 around */ 613 around */
602 c = icaldirset_fetch(store,uid); 614 c = icaldirset_fetch(set,uid);
603 615
604 return c!=0; 616 return c!=0;
605 617
606} 618}
607 619
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
622 return ICAL_NO_ERROR; 630 return ICAL_NO_ERROR;
623} 631}
624 632
625 633
626icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old, 634icalerrorenum icaldirset_modify(icalset* set,
635 icalcomponent *old,
627 icalcomponent *new) 636 icalcomponent *new)
628{ 637{
629 assert(0); 638 assert(0);
@@ -632,7 +641,7 @@ icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *old,
632} 641}
633 642
634 643
635void icaldirset_clear(icaldirset* store) 644void icaldirset_clear(icalset* set)
636{ 645{
637 646
638 assert(0); 647 assert(0);
@@ -640,53 +649,58 @@ void icaldirset_clear(icaldirset* store)
640 /* HACK, not implemented */ 649 /* HACK, not implemented */
641} 650}
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}
654 665
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;
660 char path[ICAL_PATH_MAX]; 672 char path[ICAL_PATH_MAX];
661 673
662 error = icaldirset_read_directory(impl); 674 error = icaldirset_read_directory(dset);
663 675
664 if (error != ICAL_NO_ERROR){ 676 if (error != ICAL_NO_ERROR){
665 icalerror_set_errno(error); 677 icalerror_set_errno(error);
666 return 0; 678 return 0;
667 } 679 }
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);
673 return 0; 685 return 0;
674 } 686 }
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
678 /* If the next cluster we need is different than the current cluster, 692 /* If the next cluster we need is different than the current cluster,
679 delete the current one and get a new one */ 693 delete the current one and get a new one */
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;
691 } 705 }
692 } 706 }
@@ -696,23 +710,22 @@ icalcomponent* icaldirset_get_first_component(icaldirset* store)
696 return 0; 710 return 0;
697 } 711 }
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;
708 icalerrorenum error; 723 icalerrorenum error;
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");
717 icalerror_set_errno(ICAL_USAGE_ERROR); 730 icalerror_set_errno(ICAL_USAGE_ERROR);
718 return 0; 731 return 0;
@@ -720,30 +733,26 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
720 } 733 }
721 734
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
737 /* If there is a gauge defined and the component does not 749 /* If there is a gauge defined and the component does not
738 pass the gauge, skip the rest of the loop */ 750 pass the gauge, skip the rest of the loop */
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
748 gauge, so return it*/ 757 gauge, so return it*/
749 758
@@ -753,13 +762,13 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
753 /* Fell through the loop, so the component we want is not 762 /* Fell through the loop, so the component we want is not
754 in this cluster. Load a new cluster and try again.*/ 763 in this cluster. Load a new cluster and try again.*/
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 */
760 return 0; 769 return 0;
761 } else { 770 } else {
762 c = icalfileset_get_first_component(impl->cluster); 771 c = icalcluster_get_first_component(dset->cluster);
763 772
764 return c; 773 return c;
765 } 774 }
@@ -769,9 +778,28 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
769 return 0; /* Should never get here */ 778 return 0; /* Should never get here */
770} 779}
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
@@ -30,51 +30,67 @@
30#define ICALDIRSET_H 30#define ICALDIRSET_H
31 31
32#include "ical.h" 32#include "ical.h"
33#include "icalset.h"
34#include "icalcluster.h"
35#include "icalgauge.h"
33 36
34/* icaldirset Routines for storing, fetching, and searching for ical 37/* icaldirset Routines for storing, fetching, and searching for ical
35 * objects in a database */ 38 * objects in a database */
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
46/* Mark the cluster as changed, so it will be written to disk when it 53/* Mark the cluster as changed, so it will be written to disk when it
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);
56 63
57/* Restrict the component returned by icaldirset_first, _next to those 64/* Restrict the component returned by icaldirset_first, _next to those
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
67/* Modify components according to the MODIFY method of CAP. Works on 74/* Modify components according to the MODIFY method of CAP. Works on
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
79#endif /* !ICALDIRSET_H */ 95#endif /* !ICALDIRSET_H */
80 96
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
@@ -30,18 +30,19 @@
30#include "config.h" 30#include "config.h"
31#endif 31#endif
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
34 main header file, but used by "friend classes" like icalset*/ 36 main header file, but used by "friend classes" like icalset*/
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
@@ -30,110 +30,155 @@
30#include "config.h" 30#include "config.h"
31#endif 31#endif
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
59icalerrorenum icalfileset_create_cluster(const char *path); 69icalerrorenum 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
119 if(cluster_file_size > 0 ){ 134 if(cluster_file_size > 0 ){
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 }
125 } 140 }
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;
138 int fd = (int)d; 183 int fd = (int)d;
139 184
@@ -158,42 +203,38 @@ char* icalfileset_read_from_file(char *s, size_t size, void *d)
158} 203}
159 204
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 }
185 228
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
198 /* A file by the given name does not exist, or there was 239 /* A file by the given name does not exist, or there was
199 another error */ 240 another error */
@@ -209,7 +250,6 @@ int icalfileset_filesize(icalfileset* cluster)
209 } else { 250 } else {
210 /* A file by the given name exists, but is it a regular file? */ 251 /* A file by the given name exists, but is it a regular file? */
211 252
212#ifndef _QTWIN_
213 if (!S_ISREG(sbuf.st_mode)){ 253 if (!S_ISREG(sbuf.st_mode)){
214 /* Nope, not a regular file */ 254 /* Nope, not a regular file */
215 icalerror_set_errno(ICAL_FILE_ERROR); 255 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -217,117 +257,109 @@ int icalfileset_filesize(icalfileset* cluster)
217 } else { 257 } else {
218 /* Lets assume that it is a file of the right type */ 258 /* Lets assume that it is a file of the right type */
219 return sbuf.st_size; 259 return sbuf.st_size;
220 } 260 }
221#else
222 return sbuf.st_size;
223#endif
224
225 } 261 }
226 262
227 /*return -1; not reached*/ 263 /*return -1; not reached*/
228} 264}
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}
263 300
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;
270 int rtrn; 306 int rtrn;
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;
274 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ 310 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
275 lock.l_start = 0; /* byte offset relative to l_whence */ 311 lock.l_start = 0; /* byte offset relative to l_whence */
276 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ 312 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
277 lock.l_len = 0; /* #bytes (0 means to EOF) */ 313 lock.l_len = 0; /* #bytes (0 means to EOF) */
278 314
279 rtrn = fcntl(impl->fd, F_SETLKW, &lock); 315 rtrn = fcntl(set->fd, F_SETLKW, &lock);
280 316
281 return rtrn; 317 return rtrn;
282#else 318#else
283 return -1; 319 return 0;
284#endif 320#endif
285} 321}
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
294 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */ 329 lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
295 lock.l_start = 0; /* byte offset relative to l_whence */ 330 lock.l_start = 0; /* byte offset relative to l_whence */
296 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */ 331 lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
297 lock.l_len = 0; /* #bytes (0 means to EOF) */ 332 lock.l_len = 0; /* #bytes (0 means to EOF) */
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
303} 338}
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{
313 char tmp[ICAL_PATH_MAX]; 342 char tmp[ICAL_PATH_MAX];
314 char *str; 343 char *str;
315 icalcomponent *c; 344 icalcomponent *c;
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;
327 } 355 }
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
332 if(system(tmp) < 0){ 364 if(system(tmp) < 0){
333 icalerror_set_errno(ICAL_FILE_ERROR); 365 icalerror_set_errno(ICAL_FILE_ERROR);
@@ -335,19 +367,19 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
335 } 367 }
336 } 368 }
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);
340 return ICAL_FILE_ERROR; 372 return ICAL_FILE_ERROR;
341 } 373 }
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;
347 379
348 str = icalcomponent_as_ical_string(c); 380 str = icalcomponent_as_ical_string(c);
349 381
350 sz=write(impl->fd,str,strlen(str)); 382 sz=write(fset->fd,str,strlen(str));
351 383
352 if ( sz != strlen(str)){ 384 if ( sz != strlen(str)){
353 perror("write"); 385 perror("write");
@@ -358,134 +390,138 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
358 write_size += sz; 390 write_size += sz;
359 } 391 }
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
368 402
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}
390 418
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
422 return ICAL_NO_ERROR; 449 return ICAL_NO_ERROR;
423} 450}
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);
432 return -1; 459 return -1;
433 } 460 }
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
446 return ICAL_NO_ERROR; 473 return ICAL_NO_ERROR;
447} 474}
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
485 return 0; 521 return 0;
486} 522}
487 523
488int icalfileset_has_uid(icalfileset* store,const char* uid) 524int icalfileset_has_uid(icalset* set,const char* uid)
489{ 525{
490 assert(0); /* HACK, not implemented */ 526 assert(0); /* HACK, not implemented */
491 return 0; 527 return 0;
@@ -508,12 +544,11 @@ void icalfileset_id_free(struct icalfileset_id *id)
508 if(id->uid != 0){ 544 if(id->uid != 0){
509 free(id->uid); 545 free(id->uid);
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;
518 struct icalfileset_id id; 553 struct icalfileset_id id;
519 icalproperty *p; 554 icalproperty *p;
@@ -549,19 +584,20 @@ struct icalfileset_id icalfileset_get_id(icalcomponent* comp)
549 return id; 584 return id;
550} 585}
551 586
587
552/* Find the component that is related to the given 588/* Find the component that is related to the given
553 component. Currently, it just matches based on UID and 589 component. Currently, it just matches based on UID and
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;
559 595
560 struct icalfileset_id comp_id, match_id; 596 struct icalfileset_id comp_id, match_id;
561 597
562 comp_id = icalfileset_get_id(comp); 598 comp_id = icalfileset_get_id(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)){
566 602
567 icalcomponent *match = icalcompiter_deref(&i); 603 icalcomponent *match = icalcompiter_deref(&i);
@@ -589,43 +625,45 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
589} 625}
590 626
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 */
596 return ICAL_NO_ERROR; 634 return ICAL_NO_ERROR;
597} 635}
598 636
599 637
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}
609 647
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
618 do { 656 do {
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);
625 } 663 }
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;
630 } 668 }
631 669
@@ -635,19 +673,19 @@ icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
635 return 0; 673 return 0;
636} 674}
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;
652 } 690 }
653 691
@@ -656,4 +694,241 @@ icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
656 694
657 return 0; 695 return 0;
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
@@ -29,77 +29,104 @@
29#ifndef ICALFILESET_H 29#ifndef ICALFILESET_H
30#define ICALFILESET_H 30#define ICALFILESET_H
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
62/* Mark the cluster as changed, so it will be written to disk when it 62/* Mark the cluster as changed, so it will be written to disk when it
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
104#endif /* !ICALFILESET_H */ 131#endif /* !ICALFILESET_H */
105 132
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
@@ -25,6 +25,8 @@
25 25
26 ======================================================================*/ 26 ======================================================================*/
27 27
28#ifndef ICALFILESETIMPL_H
29#define ICALFILESETIMPL_H
28 30
29#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
30#include "config.h" 32#include "config.h"
@@ -38,12 +40,14 @@
38#define ICALFILESET_ID "fset" 40#define ICALFILESET_ID "fset"
39 41
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
@@ -31,15 +31,17 @@
31#include "icalgaugeimpl.h" 31#include "icalgaugeimpl.h"
32#include <stdlib.h> 32#include <stdlib.h>
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
44 int r; 46 int r;
45 47
@@ -52,60 +54,82 @@ icalgauge* icalgauge_new_from_sql(char* sql)
52 impl->select = pvl_newlist(); 54 impl->select = pvl_newlist();
53 impl->from = pvl_newlist(); 55 impl->from = pvl_newlist();
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
65void icalgauge_free(icalgauge* gauge) 83void 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){
77 free(w->value); 94 free(w->value);
78 } 95 }
79 free(w); 96 free(w);
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
87 if(w->value != 0){ 105 if(w->value != 0){
88 free(w->value); 106 free(w->value);
89 } 107 }
90 free(w); 108 free(w);
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
99} 121}
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
106 130
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
110 collection of properties that are compared to corresponding 134 collection of properties that are compared to corresponding
111 properties in the target component, according to the 135 properties in the target component, according to the
@@ -252,26 +276,45 @@ int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
252int icalgauge_compare(icalgauge* gauge,icalcomponent* comp) 276int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
253{ 277{
254 278
255 struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
256 icalcomponent *inner; 279 icalcomponent *inner;
257 int local_pass = 0; 280 int local_pass = 0;
258 int last_clause = 1, this_clause = 1; 281 int last_clause = 1, this_clause = 1;
259 pvl_elem e; 282 pvl_elem e;
283 icalcomponent_kind kind;
284 icalproperty *rrule;
285 int compare_recur = 0;
286
260 287
261 icalerror_check_arg_rz( (comp!=0), "comp"); 288 icalerror_check_arg_rz( (comp!=0), "comp");
262 icalerror_check_arg_rz( (gauge!=0), "gauge"); 289 icalerror_check_arg_rz( (gauge!=0), "gauge");
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);
265 294
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);
276 319
277 if(k == icalcomponent_isa(inner)){ 320 if(k == icalcomponent_isa(inner)){
@@ -284,8 +327,8 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
284 } 327 }
285 328
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);
290 icalcomponent *sub_comp; 333 icalcomponent *sub_comp;
291 icalvalue *v; 334 icalvalue *v;
@@ -301,11 +344,14 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
301 vk = icalenum_property_kind_to_value_kind(w->prop); 344 vk = icalenum_property_kind_to_value_kind(w->prop);
302 345
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;
306 } 349 }
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
310 if (v == 0){ 356 if (v == 0){
311 /* Keep error set by icalvalue_from-string*/ 357 /* Keep error set by icalvalue_from-string*/
@@ -324,14 +370,46 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
324 } 370 }
325 } 371 }
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);
330 prop != 0; 393 prop != 0;
331 prop = icalcomponent_get_next_property(sub_comp,w->prop)){ 394 prop = icalcomponent_get_next_property(sub_comp,w->prop)){
332 icalvalue* prop_value; 395 icalvalue* prop_value;
333 icalgaugecompare relation; 396 icalgaugecompare relation;
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);
336 414
337 relation = (icalgaugecompare)icalvalue_compare(prop_value,v); 415 relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
@@ -355,34 +433,40 @@ int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
355 } 433 }
356 } 434 }
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
361 the value should be merge with the previous clause */ 441 the value should be merge with the previous clause */
362 442
363 if(w->logic == ICALGAUGELOGIC_AND){ 443 if(w->logic == ICALGAUGELOGIC_AND){
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;
367 } else { 447 } else {
368 last_clause = this_clause; 448 last_clause = this_clause;
369 } 449 }
370 } 450
451 icalvalue_free(v);
452
453 }/**** check next one in where clause ****/
371 454
372 return last_clause; 455 return last_clause;
373 456
374} 457}
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);
387 471
388 if(w->comp != ICAL_NO_COMPONENT){ 472 if(w->comp != ICAL_NO_COMPONENT){
@@ -407,14 +491,14 @@ void icalgauge_dump(icalcomponent* gauge)
407 } 491 }
408 492
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);
412 496
413 printf("%s\n",icalenum_component_kind_to_string(k)); 497 printf("%s\n",icalenum_component_kind_to_string(k));
414 } 498 }
415 499
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);
419 503
420 if(w->logic != ICALGAUGELOGIC_NONE){ 504 if(w->logic != ICALGAUGELOGIC_NONE){
@@ -441,7 +525,5 @@ void icalgauge_dump(icalcomponent* gauge)
441 525
442 printf("\n"); 526 printf("\n");
443 } 527 }
444
445
446} 528}
447 529
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
@@ -29,23 +29,33 @@
29#ifndef ICALGAUGE_H 29#ifndef ICALGAUGE_H
30#define ICALGAUGE_H 30#define ICALGAUGE_H
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
36void icalgauge_free(icalgauge* gauge); 42void icalgauge_free(icalgauge* gauge);
37 43
38char* icalgauge_as_sql(icalcomponent* gauge); 44char* 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);
50 60
51#endif /* ICALGAUGE_H*/ 61#endif /* ICALGAUGE_H*/
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
@@ -24,8 +24,6 @@
24 24
25#include "ical.h" 25#include "ical.h"
26 26
27#include "pvl.h"
28
29typedef enum icalgaugecompare { 27typedef enum icalgaugecompare {
30 ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL, 28 ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
31 ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS, 29 ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
@@ -34,6 +32,8 @@ typedef enum icalgaugecompare {
34 ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL, 32 ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
35 ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL, 33 ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
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
38} icalgaugecompare; 38} icalgaugecompare;
39 39
@@ -54,10 +54,10 @@ struct icalgauge_where {
54 54
55struct icalgauge_impl 55struct 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};
62 62
63 63
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
@@ -40,7 +40,7 @@ icalcomponent* icalmessage_get_inner(icalcomponent* comp)
40 } 40 }
41} 41}
42 42
43char* lowercase(const char* str) 43static char* lowercase(const char* str)
44{ 44{
45 char* p = 0; 45 char* p = 0;
46 char* n = icalmemory_strdup(str); 46 char* n = icalmemory_strdup(str);
@@ -158,8 +158,13 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
158 158
159 icalcomponent_add_property(reply,icalproperty_new_version("2.0")); 159 icalcomponent_add_property(reply,icalproperty_new_version("2.0"));
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));
164 169
165 return reply; 170 return reply;
@@ -230,11 +235,11 @@ icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
230 icalerror_check_arg_rz(oldc,"oldc"); 235 icalerror_check_arg_rz(oldc,"oldc");
231 icalerror_check_arg_rz(newc,"newc"); 236 icalerror_check_arg_rz(newc,"newc");
232 237
233 reply = icalcomponent_new_clone(newc); 238 reply = icalmessage_new_reply_base(newc,user,msg);
234 239
235 icalcomponent_set_method(reply,ICAL_METHOD_COUNTER); 240 icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
236 241
237 return newc; 242 return reply;
238 243
239} 244}
240 245
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
@@ -41,33 +41,26 @@
41#include "icaldirset.h" 41#include "icaldirset.h"
42#include "icaldirsetimpl.h" 42#include "icaldirsetimpl.h"
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,
72 icaldirset_path, 65 icaldirset_path,
73 icaldirset_mark, 66 icaldirset_mark,
@@ -83,11 +76,18 @@ struct icalset_fp icalset_dirset_fp = {
83 icaldirset_modify, 76 icaldirset_modify,
84 icaldirset_get_current_component, 77 icaldirset_get_current_component,
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};
88 84
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,
92 icalfileset_path, 92 icalfileset_path,
93 icalfileset_mark, 93 icalfileset_mark,
@@ -103,265 +103,391 @@ struct icalset_fp icalset_fileset_fp = {
103 icalfileset_modify, 103 icalfileset_modify,
104 icalfileset_get_current_component, 104 icalfileset_get_current_component,
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
263void icalset_free(icalset* set) 367void 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}
339 422
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,17 +1,19 @@
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
7 Icalset is the "base class" for representations of a collection of 6 Icalset is the "base class" for representations of a collection of
8 iCal components. Derived classes (actually delegatees) include: 7 iCal components. Derived classes (actually delegatees) include:
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$
16 $Locker$ 18 $Locker$
17 19
@@ -39,7 +41,7 @@
39 41
40#include <limits.h> /* For PATH_MAX */ 42#include <limits.h> /* For PATH_MAX */
41#include "ical.h" 43#include "ical.h"
42#include "icalerror.h" 44#include "icalgauge.h"
43 45
44#ifdef PATH_MAX 46#ifdef PATH_MAX
45#define ICAL_PATH_MAX PATH_MAX 47#define ICAL_PATH_MAX PATH_MAX
@@ -48,33 +50,86 @@
48#endif 50#endif
49 51
50 52
51 53typedef struct icalset_impl icalset;
52
53typedef void icalset;
54 54
55typedef enum icalset_kind { 55typedef enum icalset_kind {
56 ICAL_FILE_SET, 56 ICAL_FILE_SET,
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
71void icalset_free(icalset* set); 124void icalset_free(icalset* set);
72 125
73const char* icalset_path(icalset* set); 126const 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);
79 134
80icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); 135icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -83,28 +138,46 @@ icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
83int icalset_count_components(icalset* set, 138int icalset_count_components(icalset* set,
84 icalcomponent_kind kind); 139 icalcomponent_kind kind);
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);
94icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); 152icalcomponent* 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. */
98icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, 156icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
99 icalcomponent *newc); 157 icalcomponent *newc);
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 */
103 161
104icalcomponent* icalset_get_current_component(icalset* set); 162icalcomponent* icalset_get_current_component(icalset* set);
105icalcomponent* icalset_get_first_component(icalset* set); 163icalcomponent* icalset_get_first_component(icalset* set);
106icalcomponent* icalset_get_next_component(icalset* set); 164icalcomponent* 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 */
109 182
110 183
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
@@ -28,14 +28,27 @@
28 28
29#include "ical.h" 29#include "ical.h"
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{
40 struct icaltime_span *span_a = (struct icaltime_span *)a ; 53 struct icaltime_span *span_a = (struct icaltime_span *)a ;
41 struct icaltime_span *span_b = (struct icaltime_span *)b ; 54 struct icaltime_span *span_b = (struct icaltime_span *)b ;
@@ -49,20 +62,52 @@ int compare_span(void* a, void* b)
49 } 62 }
50} 63}
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,
67 struct icaltimetype start, 112 struct icaltimetype start,
68 struct icaltimetype end) 113 struct icaltimetype end)
@@ -71,7 +116,7 @@ icalspanlist* icalspanlist_new(icalset *set,
71 pvl_elem itr; 116 pvl_elem itr;
72 icalcomponent *c,*inner; 117 icalcomponent *c,*inner;
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;
76 121
77 if ( ( sl = (struct icalspanlist_impl*) 122 if ( ( sl = (struct icalspanlist_impl*)
@@ -81,14 +126,12 @@ icalspanlist* icalspanlist_new(icalset *set,
81 } 126 }
82 127
83 sl->spans = pvl_newlist(); 128 sl->spans = pvl_newlist();
129 sl->start = start;
130 sl->end = end;
84 131
85 range.start = icaltime_as_timet(start); 132 range.start = icaltime_as_timet(start);
86 range.end = icaltime_as_timet(end); 133 range.end = icaltime_as_timet(end);
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
93 and order the spans based on the start time */ 136 and order the spans based on the start time */
94 137
@@ -96,8 +139,6 @@ icalspanlist* icalspanlist_new(icalset *set,
96 c != 0; 139 c != 0;
97 c = icalset_get_next_component(set)){ 140 c = icalset_get_next_component(set)){
98 141
99 struct icaltime_span span;
100
101 kind = icalcomponent_isa(c); 142 kind = icalcomponent_isa(c);
102 inner = icalcomponent_get_inner(c); 143 inner = icalcomponent_get_inner(c);
103 144
@@ -113,31 +154,12 @@ icalspanlist* icalspanlist_new(icalset *set,
113 } 154 }
114 155
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
142 /* Now Fill in the free time spans. loop through the spans. if the 164 /* Now Fill in the free time spans. loop through the spans. if the
143 start of the range is not within the span, create a free entry 165 start of the range is not within the span, create a free entry
@@ -148,7 +170,7 @@ icalspanlist* icalspanlist_new(icalset *set,
148 itr != 0; 170 itr != 0;
149 itr = pvl_next(itr)) 171 itr = pvl_next(itr))
150 { 172 {
151 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 173 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
152 174
153 if ((freetime=(struct icaltime_span *) 175 if ((freetime=(struct icaltime_span *)
154 malloc(sizeof(struct icaltime_span))) == 0){ 176 malloc(sizeof(struct icaltime_span))) == 0){
@@ -178,7 +200,7 @@ icalspanlist* icalspanlist_new(icalset *set,
178 if( icaltime_is_null_time(end)){ 200 if( icaltime_is_null_time(end)){
179 struct icaltime_span* last_span; 201 struct icaltime_span* last_span;
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
183 if (last_span != 0){ 205 if (last_span != 0){
184 206
@@ -197,35 +219,46 @@ icalspanlist* icalspanlist_new(icalset *set,
197 219
198 220
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)
204{ 231{
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);
210 } 239 }
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}
216 247
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;
223 256
224 for( itr = pvl_head(sl->spans); 257 for( itr = pvl_head(sl->spans);
225 itr != 0; 258 itr != 0;
226 itr = pvl_next(itr)) 259 itr = pvl_next(itr))
227 { 260 {
228 struct icaltime_span *s = (icalproperty*)pvl_data(itr); 261 struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr);
229 262
230 printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start)); 263 printf("#%02d %d start: %s",++i,s->is_busy,ctime(&s->start));
231 printf(" end : %s",ctime(&s->end)); 264 printf(" end : %s",ctime(&s->end));
@@ -236,10 +269,19 @@ void icalspanlist_dump(icalspanlist* s){
236icalcomponent* icalspanlist_make_free_list(icalspanlist* sl); 269icalcomponent* icalspanlist_make_free_list(icalspanlist* sl);
237icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 270icalcomponent* 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,
240 struct icaltimetype t) 283 struct icaltimetype t)
241{ 284{
242 struct icalspanlist_impl* impl = (struct icalspanlist_impl*)sl;
243 pvl_elem itr; 285 pvl_elem itr;
244 struct icalperiodtype period; 286 struct icalperiodtype period;
245 struct icaltime_span *s; 287 struct icaltime_span *s;
@@ -249,22 +291,22 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
249 period.start = icaltime_null_time(); 291 period.start = icaltime_null_time();
250 period.end = icaltime_null_time(); 292 period.end = icaltime_null_time();
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
257 if (s == 0){ 297 if (s == 0){
258 /* No elements in span */ 298 /* No elements in span */
259 return period; 299 return period;
260 } 300 }
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 ){
263 /* End of period is start of first span if span is busy, end 305 /* End of period is start of first span if span is busy, end
264 of the span if it is free */ 306 of the span if it is free */
265 period.start = t; 307 period.start = t;
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);
269 } else { 311 } else {
270 period.end = icaltime_from_timet(s->end,0); 312 period.end = icaltime_from_timet(s->end,0);
@@ -275,12 +317,11 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
275 317
276 /* Otherwise, find the first free span that contains the 318 /* Otherwise, find the first free span that contains the
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;
281 itr = pvl_next(itr)) 322 itr = pvl_next(itr))
282 { 323 {
283 s = (icalproperty*)pvl_data(itr); 324 s = (struct icaltime_span *)pvl_data(itr);
284 325
285 if(s->is_busy == 0 && s->start >= rangett && 326 if(s->is_busy == 0 && s->start >= rangett &&
286 ( rangett < s->end || s->end == s->start)){ 327 ( rangett < s->end || s->end == s->start)){
@@ -307,3 +348,220 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
307struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl, 348struct icalperiodtype icalspanlist_next_busy_time(icalspanlist* sl,
308 struct icaltimetype t); 349 struct icaltimetype t);
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
@@ -28,26 +28,49 @@
28#include "ical.h" 28#include "ical.h"
29#include "icalset.h" 29#include "icalset.h"
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,
35 struct icaltimetype start, 43 struct icaltimetype start,
36 struct icaltimetype end); 44 struct icaltimetype end);
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);
41icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 52icalcomponent* 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,
47 struct icaltimetype t); 59 struct icaltimetype t);
48 60
49void icalspanlist_dump(icalspanlist* s); 61void 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
52 75
53 76
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,11 +1,15 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4/*
5 $Id$
6*/
1/* -*- Mode: C -*- */ 7/* -*- Mode: C -*- */
2/*====================================================================== 8/*======================================================================
3 FILE: icalgauge.h 9 FILE: icalgauge.h
4 CREATOR: eric 23 December 1999 10 CREATOR: eric 23 December 1999
5 11
6 12
7 $Id$
8 $Locker$
9 13
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 14 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11 15
@@ -29,42 +33,52 @@
29#ifndef ICALGAUGE_H 33#ifndef ICALGAUGE_H
30#define ICALGAUGE_H 34#define ICALGAUGE_H
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
36void icalgauge_free(icalgauge* gauge); 46void icalgauge_free(icalgauge* gauge);
37 47
38char* icalgauge_as_sql(icalcomponent* gauge); 48char* 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);
50 64
51#endif /* ICALGAUGE_H*/ 65#endif /* ICALGAUGE_H*/
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
58 Icalset is the "base class" for representations of a collection of 71 Icalset is the "base class" for representations of a collection of
59 iCal components. Derived classes (actually delegatees) include: 72 iCal components. Derived classes (actually delegatees) include:
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
69 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 83 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
70 84
@@ -97,37 +111,86 @@ icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
97#endif 111#endif
98 112
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
108typedef enum icalset_kind { 116typedef enum icalset_kind {
109 ICAL_FILE_SET, 117 ICAL_FILE_SET,
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
124void icalset_free(icalset* set); 185void icalset_free(icalset* set);
125 186
126const char* icalset_path(icalset* set); 187const 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);
132 195
133icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); 196icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
@@ -136,40 +199,113 @@ icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
136int icalset_count_components(icalset* set, 199int icalset_count_components(icalset* set,
137 icalcomponent_kind kind); 200 icalcomponent_kind kind);
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);
147icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); 213icalcomponent* 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. */
151icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, 217icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc,
152 icalcomponent *newc); 218 icalcomponent *newc);
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 */
156 222
157icalcomponent* icalset_get_current_component(icalset* set); 223icalcomponent* icalset_get_current_component(icalset* set);
158icalcomponent* icalset_get_first_component(icalset* set); 224icalcomponent* icalset_get_first_component(icalset* set);
159icalcomponent* icalset_get_next_component(icalset* set); 225icalcomponent* 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 */
162 243
163 244
164 245
165/* -*- Mode: C -*- */ 246/* -*- Mode: C -*- */
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
168 CREATOR: eric 23 December 1999 306 CREATOR: eric 23 December 1999
169 307
170 308
171 $Id$
172 $Locker$
173 309
174 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 310 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
175 311
@@ -197,68 +333,96 @@ icalcomponent* icalset_get_next_component(icalset* set);
197#include <sys/stat.h> /* For open() flags and mode */ 333#include <sys/stat.h> /* For open() flags and mode */
198#include <fcntl.h> /* For open() flags and mode */ 334#include <fcntl.h> /* For open() flags and mode */
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
221/* Mark the cluster as changed, so it will be written to disk when it 358/* Mark the cluster as changed, so it will be written to disk when it
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
263#endif /* !ICALFILESET_H */ 427#endif /* !ICALFILESET_H */
264 428
@@ -270,8 +434,6 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
270 CREATOR: eric 28 November 1999 434 CREATOR: eric 28 November 1999
271 435
272 436
273 $Id$
274 $Locker$
275 437
276 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 438 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
277 439
@@ -299,47 +461,60 @@ icalcomponent* icalfileset_get_component(icalfileset* cluster);
299/* icaldirset Routines for storing, fetching, and searching for ical 461/* icaldirset Routines for storing, fetching, and searching for ical
300 * objects in a database */ 462 * objects in a database */
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
311/* Mark the cluster as changed, so it will be written to disk when it 477/* Mark the cluster as changed, so it will be written to disk when it
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);
321 487
322/* Restrict the component returned by icaldirset_first, _next to those 488/* Restrict the component returned by icaldirset_first, _next to those
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
332/* Modify components according to the MODIFY method of CAP. Works on 498/* Modify components according to the MODIFY method of CAP. Works on
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
344#endif /* !ICALDIRSET_H */ 519#endif /* !ICALDIRSET_H */
345 520
@@ -351,8 +526,6 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
351 CREATOR: eric 23 December 1999 526 CREATOR: eric 23 December 1999
352 527
353 528
354 $Id$
355 $Locker$
356 529
357 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 530 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
358 531
@@ -383,7 +556,7 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store);
383 * components. It also has interfaces to access the free/busy list 556 * components. It also has interfaces to access the free/busy list
384 * and a list of calendar properties */ 557 * and a list of calendar properties */
385 558
386typedef void icalcalendar; 559typedef struct icalcalendar_impl icalcalendar;
387 560
388icalcalendar* icalcalendar_new(char* dir); 561icalcalendar* icalcalendar_new(char* dir);
389 562
@@ -416,8 +589,6 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
416 CREATOR: eric 21 Aug 2000 589 CREATOR: eric 21 Aug 2000
417 590
418 591
419 $Id$
420 $Locker$
421 592
422 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 593 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
423 594
@@ -439,44 +610,12 @@ icalset* icalcalendar_get_freebusy(icalcalendar* calendar);
439#define ICALCLASSIFY_H 610#define ICALCLASSIFY_H
440 611
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);
476 615
477icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); 616icalcomponent* 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
481 620
482#endif /* ICALCLASSIFY_H*/ 621#endif /* ICALCLASSIFY_H*/
@@ -491,8 +630,6 @@ char* icalclassify_class_to_string(ical_class iclass);
491 CREATOR: eric 21 Aug 2000 630 CREATOR: eric 21 Aug 2000
492 631
493 632
494 $Id$
495 $Locker$
496 633
497 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 634 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
498 635
@@ -513,26 +650,49 @@ char* icalclassify_class_to_string(ical_class iclass);
513#define ICALSPANLIST_H 650#define ICALSPANLIST_H
514 651
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,
520 struct icaltimetype start, 665 struct icaltimetype start,
521 struct icaltimetype end); 666 struct icaltimetype end);
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);
526icalcomponent* icalspanlist_make_busy_list(icalspanlist* sl); 674icalcomponent* 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,
532 struct icaltimetype t); 681 struct icaltimetype t);
533 682
534void icalspanlist_dump(icalspanlist* s); 683void 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
537 697
538 698
@@ -543,8 +703,6 @@ void icalspanlist_dump(icalspanlist* s);
543 CREATOR: eric 07 Nov 2000 703 CREATOR: eric 07 Nov 2000
544 704
545 705
546 $Id$
547 $Locker$
548 706
549 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org 707 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
550 708
@@ -607,279 +765,6 @@ icalcomponent* icalmessage_new_error_reply(icalcomponent* c,
607 765
608 766
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,3 +1,12 @@
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
2#define yy_delete_buffer ss_delete_buffer 11#define yy_delete_buffer ss_delete_buffer
3#define yy_scan_buffer ss_scan_buffer 12#define yy_scan_buffer ss_scan_buffer
@@ -8,46 +17,50 @@
8#define yy_flush_buffer ss_flush_buffer 17#define yy_flush_buffer ss_flush_buffer
9#define yy_load_buffer_state ss_load_buffer_state 18#define yy_load_buffer_state ss_load_buffer_state
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
26#define YY_FLEX_MAJOR_VERSION 2 48#define YY_FLEX_MAJOR_VERSION 2
27#define YY_FLEX_MINOR_VERSION 5 49#define YY_FLEX_MINOR_VERSION 5
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
48#ifdef __cplusplus 60#ifdef __cplusplus
49 61
50#include <stdlib.h> 62/* %+ */
63/* %* */
51 64
52/* Use prototypes in function declarations. */ 65/* Use prototypes in function declarations. */
53#define YY_USE_PROTOS 66#define YY_USE_PROTOS
@@ -65,15 +78,6 @@
65 #endif/* __STDC__ */ 78 #endif/* __STDC__ */
66 #endif/* ! __cplusplus */ 79 #endif/* ! __cplusplus */
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
78#define yyconst const 82#define yyconst const
79#else 83#else
@@ -97,34 +101,94 @@
97 */ 101 */
98#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 102#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
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,
101 * but we do it the disgusting crufty way forced on us by the ()-less 154 * but we do it the disgusting crufty way forced on us by the ()-less
102 * definition of BEGIN. 155 * definition of BEGIN.
103 */ 156 */
104#define BEGIN yy_start = 1 + 2 * 157#define BEGIN YY_G(yy_start) = 1 + 2 *
105 158
106/* Translate the current start state into a value that can be later handed 159/* Translate the current start state into a value that can be later handed
107 * to BEGIN to return to the state. The YYSTATE alias is for lex 160 * to BEGIN to return to the state. The YYSTATE alias is for lex
108 * compatibility. 161 * compatibility.
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
112 165
113/* Action number for EOF rule of a given start state. */ 166/* Action number for EOF rule of a given start state. */
114#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 167#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
115 168
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
119#define YY_END_OF_BUFFER_CHAR 0 172#define YY_END_OF_BUFFER_CHAR 0
120 173
121/* Size of default input buffer. */ 174/* Size of default input buffer. */
122#define YY_BUF_SIZE 16384 175#define YY_BUF_SIZE 16384
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
129#define EOB_ACT_CONTINUE_SCAN 0 193#define EOB_ACT_CONTINUE_SCAN 0
130#define EOB_ACT_END_OF_FILE 1 194#define EOB_ACT_END_OF_FILE 1
@@ -150,25 +214,33 @@ extern FILE *yyin, *yyout;
150 do \ 214 do \
151 { \ 215 { \
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 */ \
157 } \ 221 } \
158 while ( 0 ) 222 while ( 0 )
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
162/* The following is because we cannot portably get our hands on size_t 226/* The following is because we cannot portably get our hands on size_t
163 * (without autoconf's help, which isn't available because we want 227 * (without autoconf's help, which isn't available because we want
164 * flex-generated scanners to compile on their own). 228 * flex-generated scanners to compile on their own).
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
173 char *yy_ch_buf; /* input buffer */ 245 char *yy_ch_buf; /* input buffer */
174 char *yy_buf_pos; /* current position in input buffer */ 246 char *yy_buf_pos; /* current position in input buffer */
@@ -222,8 +294,17 @@ struct yy_buffer_state
222 */ 294 */
223#define YY_BUFFER_EOF_PENDING 2 295#define YY_BUFFER_EOF_PENDING 2
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
228/* We provide macros for accessing buffer states in case in the 309/* We provide macros for accessing buffer states in case in the
229 * future we want to put the buffer states in a more general 310 * future we want to put the buffer states in a more general
@@ -232,13 +313,18 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
232#define YY_CURRENT_BUFFER yy_current_buffer 313#define YY_CURRENT_BUFFER yy_current_buffer
233 314
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. */
236static char yy_hold_char; 322static char yy_hold_char;
237 323
238 static int yy_n_chars; /* number of characters read into yy_ch_buf */ 324 static int yy_n_chars; /* number of characters read into yy_ch_buf */
239 325
240 326
241int yyleng; 327size_t yyleng;
242 328
243/* Points to current character in buffer. */ 329/* Points to current character in buffer. */
244static char *yy_c_buf_p = (char *) 0; 330static char *yy_c_buf_p = (char *) 0;
@@ -249,76 +335,111 @@ static int yy_start = 0; /* start state number */
249 * instead of setting up a fresh yyin. A bit of a hack ... 335 * instead of setting up a fresh yyin. A bit of a hack ...
250 */ 336 */
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
271#define yy_new_buffer yy_create_buffer 368#define yy_new_buffer yy_create_buffer
272 369
273#define yy_set_interactive(is_interactive) \ 370#define yy_set_interactive(is_interactive) \
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 }
279 377
280#define yy_set_bol(at_bol) \ 378#define yy_set_bol(at_bol) \
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
300/* Done after the current pattern has been matched and before the 413/* Done after the current pattern has been matched and before the
301 * corresponding action - sets up yytext. 414 * corresponding action - sets up yytext.
302 */ 415 */
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 } ;
323 444
324static yyconst int yy_ec[256] = 445static yyconst int yy_ec[256] =
@@ -326,17 +447,17 @@ static yyconst int yy_ec[256] =
326 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 447 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
327 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 448 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
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,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 462 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -353,57 +474,62 @@ static yyconst int yy_ec[256] =
353 1, 1, 1, 1, 1 474 1, 1, 1, 1, 1
354 } ; 475 } ;
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,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 521 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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
408/* The intent behind this definition is that it'll catch 534/* The intent behind this definition is that it'll catch
409 * any uses of REJECT which flex missed. 535 * any uses of REJECT which flex missed.
@@ -416,8 +542,10 @@ static char *yy_last_accepting_cpos;
416#define YYLMAX 8192 542#define YYLMAX 8192
417#endif 543#endif
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"
422#define INITIAL 0 550#define INITIAL 0
423#line 2 "icalsslexer.l" 551#line 2 "icalsslexer.l"
@@ -455,20 +583,159 @@ char *yytext_ptr;
455 583
456#include <string.h> /* For strdup() */ 584#include <string.h> /* For strdup() */
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
464#undef SS_FATAL_ERROR 589#undef SS_FATAL_ERROR
465#define SS_FATAL_ERROR(msg) sserror(msg) 590#define SS_FATAL_ERROR(msg) sserror(msg)
466 591
467
468#define sql 1 592#define sql 1
469#define string_value 2 593#define string_value 2
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
473/* Macros after this point can all be overridden by user definitions in 740/* Macros after this point can all be overridden by user definitions in
474 * section 1. 741 * section 1.
@@ -476,44 +743,62 @@ void icalparser_clear_flex_input();
476 743
477#ifndef YY_SKIP_YYWRAP 744#ifndef YY_SKIP_YYWRAP
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
483#endif 750#endif
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
492 765
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
496 769
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
504 783
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;
507static int yy_start_stack_depth = 0; 789static 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
518 803
519#else 804#else
@@ -522,21 +807,6 @@ static int yy_top_state YY_PROTO(( void ));
522#define YY_NO_TOP_STATE 1 807#define YY_NO_TOP_STATE 1
523#endif 808#endif
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. */
541#ifndef YY_READ_BUF_SIZE 811#ifndef YY_READ_BUF_SIZE
542#define YY_READ_BUF_SIZE 8192 812#define YY_READ_BUF_SIZE 8192
@@ -545,10 +815,13 @@ YY_MALLOC_DECL
545/* Copy whatever the last rule matched to the standard output. */ 815/* Copy whatever the last rule matched to the standard output. */
546 816
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,
549 * we now use fwrite(). 820 * we now use fwrite().
550 */ 821 */
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
553 826
554/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 827/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -556,9 +829,11 @@ YY_MALLOC_DECL
556 */ 829 */
557#ifndef YY_INPUT 830#ifndef YY_INPUT
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 && \
563 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 838 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
564 buf[n] = (char) c; \ 839 buf[n] = (char) c; \
@@ -568,9 +843,22 @@ YY_MALLOC_DECL
568 YY_FATAL_ERROR( "input in flex scanner failed" ); \ 843 YY_FATAL_ERROR( "input in flex scanner failed" ); \
569 result = n; \ 844 result = n; \
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
575 863
576/* No semi-colon after return; correct usage is to write "yyterminate();" - 864/* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -588,14 +876,51 @@ YY_MALLOC_DECL
588 876
589/* Report a fatal error. */ 877/* Report a fatal error. */
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
593 884
594/* Default declaration of generated scanner - a define so the user can 885/* Default declaration of generated scanner - a define so the user can
595 * easily add parameters. 886 * easily add parameters.
596 */ 887 */
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
600 925
601/* Code executed at the beginning of each rule, after yytext and yyleng 926/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -610,211 +935,256 @@ YY_MALLOC_DECL
610#define YY_BREAK break; 935#define YY_BREAK break;
611#endif 936#endif
612 937
938/* %% [6.0] YY_RULE_SETUP definition goes here */
613#define YY_RULE_SETUP \ 939#define YY_RULE_SETUP \
614 YY_USER_ACTION 940 YY_USER_ACTION
615 941
942/* %c */
943#ifndef ssIN_HEADER
616YY_DECL 944YY_DECL
617 { 945 {
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
624 954
625 955
626 956
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
635#ifdef YY_USER_INIT 971#ifdef YY_USER_INIT
636 YY_USER_INIT; 972 YY_USER_INIT;
637#endif 973#endif
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 }
654 996
655 while ( 1 ) /* loops until end-of-file is reached */ 997 while ( 1 ) /* loops until end-of-file is reached */
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
662 /* yy_bp points to the position in yy_ch_buf of the start of 1005 /* yy_bp points to the position in yy_ch_buf of the start of
663 * the current run. 1006 * the current run.
664 */ 1007 */
665 yy_bp = yy_cp; 1008 yy_bp = yy_cp;
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:
669 do 1013 do
670 { 1014 {
671 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 1015 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
672 if ( yy_accept[yy_current_state] ) 1016 if ( yy_accept[yy_current_state] )
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 }
677 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1021 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
678 { 1022 {
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];
682 } 1026 }
683 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1027 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
684 ++yy_cp; 1028 ++yy_cp;
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];
690 if ( yy_act == 0 ) 1035 if ( yy_act == 0 )
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];
695 } 1040 }
696 1041
697 YY_DO_BEFORE_ACTION; 1042 YY_DO_BEFORE_ACTION;
698 1043
1044/* %% [11.0] code for yylineno update goes here */
699 1045
700 do_action:/* This label is used only to access EOF actions. */ 1046 do_action:/* This label is used only to access EOF actions. */
701 1047
1048/* %% [12.0] debug code goes here */
702 1049
703 switch ( yy_act ) 1050 switch ( yy_act )
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;
711 1059
712case 1: 1060case 1:
713YY_RULE_SETUP 1061YY_RULE_SETUP
714#line 75 "icalsslexer.l" 1062#line 72 "icalsslexer.l"
715{ return SELECT; } 1063{ return SELECT; }
716 YY_BREAK 1064 YY_BREAK
717case 2: 1065case 2:
718YY_RULE_SETUP 1066YY_RULE_SETUP
719#line 76 "icalsslexer.l" 1067#line 73 "icalsslexer.l"
720{ return FROM; } 1068{ return FROM; }
721 YY_BREAK 1069 YY_BREAK
722case 3: 1070case 3:
723YY_RULE_SETUP 1071YY_RULE_SETUP
724#line 77 "icalsslexer.l" 1072#line 74 "icalsslexer.l"
725{ return WHERE; } 1073{ return WHERE; }
726 YY_BREAK 1074 YY_BREAK
727case 4: 1075case 4:
728YY_RULE_SETUP 1076YY_RULE_SETUP
729#line 78 "icalsslexer.l" 1077#line 75 "icalsslexer.l"
730{ return COMMA; } 1078{ return COMMA; }
731 YY_BREAK 1079 YY_BREAK
732case 5: 1080case 5:
733YY_RULE_SETUP 1081YY_RULE_SETUP
734#line 79 "icalsslexer.l" 1082#line 76 "icalsslexer.l"
735{ return EQUALS; } 1083{ return EQUALS; }
736 YY_BREAK 1084 YY_BREAK
737case 6: 1085case 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
742case 7: 1090case 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
747case 8: 1095case 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
752case 9: 1100case 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
757case 10: 1105case 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
762case 11: 1110case 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
767case 12: 1115case 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
772case 13: 1120case 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
777case 14: 1125case 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
782case 15: 1130case 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
787case 16: 1135case 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;
796 } else { 1164 } else {
797 /*ssmore();*/ 1165 /*ssmore();*/
798 } 1166 }
799} 1167}
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):
819case YY_STATE_EOF(sql): 1189case YY_STATE_EOF(sql):
820case YY_STATE_EOF(string_value): 1190case YY_STATE_EOF(string_value):
@@ -823,13 +1193,13 @@ case YY_STATE_EOF(string_value):
823 case YY_END_OF_BUFFER: 1193 case YY_END_OF_BUFFER:
824 { 1194 {
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 {
834 /* We're scanning a new file or input source. It's 1204 /* We're scanning a new file or input source. It's
835 * possible that this happened because the user 1205 * possible that this happened because the user
@@ -840,9 +1210,9 @@ case YY_STATE_EOF(string_value):
840 * this is the first action (other than possibly a 1210 * this is the first action (other than possibly a
841 * back-up) that will match for the new input source. 1211 * back-up) that will match for the new input source.
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 }
847 1217
848 /* Note that here we test for yy_c_buf_p "<=" to the position 1218 /* Note that here we test for yy_c_buf_p "<=" to the position
@@ -852,13 +1222,13 @@ case YY_STATE_EOF(string_value):
852 * end-of-buffer state). Contrast this with the test 1222 * end-of-buffer state). Contrast this with the test
853 * in input(). 1223 * in input().
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. */
857 yy_state_type yy_next_state; 1227 yy_state_type yy_next_state;
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
863 /* Okay, we're now positioned to make the NUL 1233 /* Okay, we're now positioned to make the NUL
864 * transition. We couldn't have 1234 * transition. We couldn't have
@@ -869,32 +1239,33 @@ case YY_STATE_EOF(string_value):
869 * will run more slowly). 1239 * will run more slowly).
870 */ 1240 */
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
876 if ( yy_next_state ) 1246 if ( yy_next_state )
877 { 1247 {
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;
881 goto yy_match; 1251 goto yy_match;
882 } 1252 }
883 1253
884 else 1254 else
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;
888 } 1259 }
889 } 1260 }
890 1261
891 else switch ( yy_get_next_buffer() ) 1262 else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
892 { 1263 {
893 case EOB_ACT_END_OF_FILE: 1264 case EOB_ACT_END_OF_FILE:
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 {
899 /* Note: because we've taken care in 1270 /* Note: because we've taken care in
900 * yy_get_next_buffer() to have set up 1271 * yy_get_next_buffer() to have set up
@@ -905,7 +1276,7 @@ case YY_STATE_EOF(string_value):
905 * YY_NULL, it'll still work - another 1276 * YY_NULL, it'll still work - another
906 * YY_NULL will get returned. 1277 * YY_NULL will get returned.
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
910 yy_act = YY_STATE_EOF(YY_START); 1281 yy_act = YY_STATE_EOF(YY_START);
911 goto do_action; 1282 goto do_action;
@@ -913,30 +1284,30 @@ case YY_STATE_EOF(string_value):
913 1284
914 else 1285 else
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;
918 } 1289 }
919 break; 1290 break;
920 } 1291 }
921 1292
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;
931 1302
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;
941 } 1312 }
942 break; 1313 break;
@@ -948,7 +1319,14 @@ case YY_STATE_EOF(string_value):
948 } /* end of action switch */ 1319 } /* end of action switch */
949 } /* end of scanning one token */ 1320 } /* end of scanning one token */
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
953/* yy_get_next_buffer - try to read in a new buffer 1331/* yy_get_next_buffer - try to read in a new buffer
954 * 1332 *
@@ -958,20 +1336,30 @@ case YY_STATE_EOF(string_value):
958 *EOB_ACT_END_OF_FILE - end of file 1336 *EOB_ACT_END_OF_FILE - end of file
959 */ 1337 */
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;
966 int ret_val; 1354 int ret_val;
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(
970 "fatal flex scanner internal error--end of buffer missed" ); 1358 "fatal flex scanner internal error--end of buffer missed" );
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 {
976 /* We matched a single character, the EOB, so 1364 /* We matched a single character, the EOB, so
977 * treat this as a final EOF. 1365 * treat this as a final EOF.
@@ -991,21 +1379,21 @@ static int yy_get_next_buffer()
991 /* Try to read more data. */ 1379 /* Try to read more data. */
992 1380
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
996 for ( i = 0; i < number_to_move; ++i ) 1384 for ( i = 0; i < number_to_move; ++i )
997 *(dest++) = *(source++); 1385 *(dest++) = *(source++);
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,
1001 * just force an EOF 1389 * just force an EOF
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
1005 else 1393 else
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
1010 while ( num_to_read <= 0 ) 1398 while ( num_to_read <= 0 )
1011 { /* Not enough room in the buffer - grow it. */ 1399 { /* Not enough room in the buffer - grow it. */
@@ -1015,10 +1403,10 @@ static int yy_get_next_buffer()
1015#else 1403#else
1016 1404
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
1023 if ( b->yy_is_our_buffer ) 1411 if ( b->yy_is_our_buffer )
1024 { 1412 {
@@ -1032,7 +1420,7 @@ static int yy_get_next_buffer()
1032 b->yy_ch_buf = (char *) 1420 b->yy_ch_buf = (char *)
1033 /* Include room in for 2 EOB chars. */ 1421 /* Include room in for 2 EOB chars. */
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 }
1037 else 1425 else
1038 /* Can't grow it, we don't own it. */ 1426 /* Can't grow it, we don't own it. */
@@ -1042,9 +1430,9 @@ static int yy_get_next_buffer()
1042 YY_FATAL_ERROR( 1430 YY_FATAL_ERROR(
1043 "fatal error - scanner input buffer overflow" ); 1431 "fatal error - scanner input buffer overflow" );
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;
1049#endif 1437#endif
1050 } 1438 }
@@ -1053,24 +1441,24 @@ static int yy_get_next_buffer()
1053 num_to_read = YY_READ_BUF_SIZE; 1441 num_to_read = YY_READ_BUF_SIZE;
1054 1442
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 {
1064 if ( number_to_move == YY_MORE_ADJ ) 1452 if ( number_to_move == YY_MORE_ADJ )
1065 { 1453 {
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 }
1069 1457
1070 else 1458 else
1071 { 1459 {
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;
1075 } 1463 }
1076 } 1464 }
@@ -1078,37 +1466,50 @@ static int yy_get_next_buffer()
1078 else 1466 else
1079 ret_val = EOB_ACT_CONTINUE_SCAN; 1467 ret_val = EOB_ACT_CONTINUE_SCAN;
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
1087 return ret_val; 1475 return ret_val;
1088 } 1476 }
1089 1477/* %e */
1478#endif /* !ssIN_HEADER */
1090 1479
1091/* yy_get_previous_state - get the state just before the EOB char was reached */ 1480/* yy_get_previous_state - get the state just before the EOB char was reached */
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 {
1095 register yy_state_type yy_current_state; 1494 register yy_state_type yy_current_state;
1096 register char *yy_cp; 1495 register char *yy_cp;
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);
1103 if ( yy_accept[yy_current_state] ) 1504 if ( yy_accept[yy_current_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 }
1108 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1509 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1109 { 1510 {
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];
1113 } 1514 }
1114 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1515 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1124,106 +1525,127 @@ static yy_state_type yy_get_previous_state()
1124 *next_state = yy_try_NUL_trans( current_state ); 1525 *next_state = yy_try_NUL_trans( current_state );
1125 */ 1526 */
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
1137 register YY_CHAR yy_c = 1; 1543 register YY_CHAR yy_c = 1;
1138 if ( yy_accept[yy_current_state] ) 1544 if ( yy_accept[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 }
1143 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1549 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1144 { 1550 {
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];
1148 } 1554 }
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
1152 return yy_is_jam ? 0 : yy_current_state; 1558 return yy_is_jam ? 0 : yy_current_state;
1153 } 1559 }
1154 1560
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;
1181 1591
1182 yy_cp += (int) (dest - source); 1592 yy_cp += (int) (dest - source);
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" );
1189 } 1599 }
1190 1600
1191 *--yy_cp = (char) c; 1601 *--yy_cp = (char) c;
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 {
1207 int c; 1629 int c;
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 {
1213 /* yy_c_buf_p now points to the character we want to return. 1635 /* yy_c_buf_p now points to the character we want to return.
1214 * If this occurs *before* the EOB characters, then it's a 1636 * If this occurs *before* the EOB characters, then it's a
1215 * valid NUL; if not, then we've hit the end of the buffer. 1637 * valid NUL; if not, then we've hit the end of the buffer.
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
1221 else 1643 else
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 {
1228 case EOB_ACT_LAST_MATCH: 1650 case EOB_ACT_LAST_MATCH:
1229 /* This happens because yy_g_n_b() 1651 /* This happens because yy_g_n_b()
@@ -1237,109 +1659,129 @@ static int input()
1237 */ 1659 */
1238 1660
1239 /* Reset buffer status. */ 1661 /* Reset buffer status. */
1240 yyrestart( yyin ); 1662 yyrestart( yyin YY_CALL_LAST_ARG);
1241 1663
1242 /* fall through */ 1664 /* fall through */
1243 1665
1244 case EOB_ACT_END_OF_FILE: 1666 case EOB_ACT_END_OF_FILE:
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
1256 } 1678 }
1257 1679
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;
1261 } 1683 }
1262 } 1684 }
1263 } 1685 }
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
1270 return c; 1693 return c;
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 }
1287 1717
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
1310 /* We don't actually know whether we did this switch during 1744 /* We don't actually know whether we did this switch during
1311 * EOF (yywrap()) processing, but the only time this flag 1745 * EOF (yywrap()) processing, but the only time this flag
1312 * is looked at is after yywrap() is called, so it's safe 1746 * is looked at is after yywrap() is called, so it's safe
1313 * to go ahead and always set it. 1747 * to go ahead and always set it.
1314 */ 1748 */
1315 yy_did_buffer_switch_on_eof = 1; 1749 YY_G(yy_did_buffer_switch_on_eof) = 1;
1316 } 1750 }
1317 1751
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 }
1330 1768
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 {
1340 YY_BUFFER_STATE b; 1782 YY_BUFFER_STATE b;
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 )
1344 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1786 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1345 1787
@@ -1348,79 +1790,100 @@ int size;
1348 /* yy_ch_buf has to be 2 characters longer than the size given because 1790 /* yy_ch_buf has to be 2 characters longer than the size given because
1349 * we need to put in 2 end-of-buffer characters. 1791 * we need to put in 2 end-of-buffer characters.
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 )
1353 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 1795 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1354 1796
1355 b->yy_is_our_buffer = 1; 1797 b->yy_is_our_buffer = 1;
1356 1798
1357 yy_init_buffer( b, file ); 1799 yy_init_buffer( b, file YY_CALL_LAST_ARG);
1358 1800
1359 return b; 1801 return b;
1360 } 1802 }
1361 1803
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 {
1370 if ( ! b ) 1816 if ( ! b )
1371 return; 1817 return;
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 }
1381 1827
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
1396 b->yy_input_file = file; 1857 b->yy_input_file = file;
1397 b->yy_fill_buffer = 1; 1858 b->yy_fill_buffer = 1;
1398 1859
1860/* %- */
1399#if YY_ALWAYS_INTERACTIVE 1861#if YY_ALWAYS_INTERACTIVE
1400 b->yy_is_interactive = 1; 1862 b->yy_is_interactive = 1;
1401#else 1863#else
1402#if YY_NEVER_INTERACTIVE 1864#if YY_NEVER_INTERACTIVE
1403 b->yy_is_interactive = 0; 1865 b->yy_is_interactive = 0;
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 }
1415 1874
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 {
1425 if ( ! b ) 1888 if ( ! b )
1426 return; 1889 return;
@@ -1439,18 +1902,21 @@ YY_BUFFER_STATE b;
1439 b->yy_at_bol = 1; 1902 b->yy_at_bol = 1;
1440 b->yy_buffer_status = YY_BUFFER_NEW; 1903 b->yy_buffer_status = YY_BUFFER_NEW;
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
1446 1910
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
1455 { 1921 {
1456 YY_BUFFER_STATE b; 1922 YY_BUFFER_STATE b;
@@ -1461,7 +1927,7 @@ yy_size_t size;
1461 /* They forgot to leave room for the EOB's. */ 1927 /* They forgot to leave room for the EOB's. */
1462 return 0; 1928 return 0;
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 )
1466 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 1932 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1467 1933
@@ -1475,36 +1941,42 @@ yy_size_t size;
1475 b->yy_fill_buffer = 0; 1941 b->yy_fill_buffer = 0;
1476 b->yy_buffer_status = YY_BUFFER_NEW; 1942 b->yy_buffer_status = YY_BUFFER_NEW;
1477 1943
1478 yy_switch_to_buffer( b ); 1944 yy_switch_to_buffer( b YY_CALL_LAST_ARG );
1479 1945
1480 return b; 1946 return b;
1481 } 1947 }
1948/* %* */
1482#endif 1949#endif
1483 1950
1484 1951
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
1492 { 1961 {
1493 int len; 1962 int len;
1494 for ( len = 0; yy_str[len]; ++len ) 1963 for ( len = 0; yy_str[len]; ++len )
1495 ; 1964 ;
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
1500 1970
1501 1971
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;
1509#endif 1981#endif
1510 { 1982 {
@@ -1515,7 +1987,7 @@ int len;
1515 1987
1516 /* Get memory for full buffer, including space for trailing EOB's. */ 1988 /* Get memory for full buffer, including space for trailing EOB's. */
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 )
1520 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 1992 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1521 1993
@@ -1524,7 +1996,7 @@ int len;
1524 1996
1525 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; 1997 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
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 )
1529 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2001 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1530 2002
@@ -1535,37 +2007,42 @@ int len;
1535 2007
1536 return b; 2008 return b;
1537 } 2009 }
2010/* %* */
1538#endif 2011#endif
1539 2012
1540 2013
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 {
1551 yy_size_t new_size; 2028 yy_size_t new_size;
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(
1565 "out of memory expanding start-condition stack" ); 2042 "out of memory expanding start-condition stack" );
1566 } 2043 }
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
1570 BEGIN(new_state); 2047 BEGIN(new_state);
1571 } 2048 }
@@ -1573,20 +2050,36 @@ int new_state;
1573 2050
1574 2051
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 }
1583#endif 2068#endif
1584 2069
1585 2070
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 }
1591#endif 2084#endif
1592 2085
@@ -1594,17 +2087,15 @@ static int yy_top_state()
1594#define YY_EXIT_FAILURE 2 2087#define YY_EXIT_FAILURE 2
1595#endif 2088#endif
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 {
1604 (void) fprintf( stderr, "%s\n", msg ); 2093 (void) fprintf( stderr, "%s\n", msg );
1605 exit( YY_EXIT_FAILURE ); 2094 exit( YY_EXIT_FAILURE );
1606 } 2095 }
1607 2096
2097/* %+ */
2098/* %* */
1608 2099
1609 2100
1610/* Redefine yyless() so it works in section 3 code. */ 2101/* Redefine yyless() so it works in section 3 code. */
@@ -1614,25 +2105,288 @@ char msg[];
1614 do \ 2105 do \
1615 { \ 2106 { \
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; \
1622 } \ 2113 } \
1623 while ( 0 ) 2114 while ( 0 )
1624 2115
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. */
1627 2380
1628#ifndef yytext_ptr 2381#ifndef yytext_ptr
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;
1634yyconst char *s2; 2387yyconst char *s2;
1635int n; 2388int n;
2389YY_DECL_LAST_ARG
1636#endif 2390#endif
1637 { 2391 {
1638 register int i; 2392 register int i;
@@ -1643,10 +2397,11 @@ int n;
1643 2397
1644#ifdef YY_NEED_STRLEN 2398#ifdef YY_NEED_STRLEN
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
1651 { 2406 {
1652 register int n; 2407 register int n;
@@ -1659,21 +2414,23 @@ yyconst char *s;
1659 2414
1660 2415
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
1667 { 2423 {
1668 return (void *) malloc( size ); 2424 return (void *) malloc( size );
1669 } 2425 }
1670 2426
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
1678 { 2435 {
1679 /* The cast to (char *) in the following accommodates both 2436 /* The cast to (char *) in the following accommodates both
@@ -1687,27 +2444,42 @@ yy_size_t size;
1687 } 2444 }
1688 2445
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 }
1698 2456
1699#if YY_MAIN 2457#if YY_MAIN
1700int main() 2458int 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;
1704 } 2472 }
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{
1711 return 1; 2482 return 1;
1712} 2483}
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,5 +1,5 @@
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
4#define YYBISON 1 /* Identify Bison output. */ 4#define YYBISON 1 /* Identify Bison output. */
5 5
@@ -26,8 +26,11 @@
26 # define OR270 26 # define OR270
27 # define EOL271 27 # define EOL271
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
32/* -*- Mode: C -*- 35/* -*- Mode: C -*-
33 ====================================================================== 36 ======================================================================
@@ -56,35 +59,36 @@
56 Code is Eric Busboom 59 Code is Eric Busboom
57 60
58 ======================================================================*/ 61 ======================================================================*/
59 62/*#define YYDEBUG 1*/
60#include <stdlib.h> 63#include <stdlib.h>
61#include <string.h> /* for strdup() */ 64#include <string.h> /* for strdup() */
62#include <limits.h> /* for SHRT_MAX*/ 65#include <limits.h> /* for SHRT_MAX*/
63#include "ical.h" 66#include "ical.h"
64#include "pvl.h"
65#include "icalgauge.h" 67#include "icalgauge.h"
66#include "icalgaugeimpl.h" 68#include "icalgaugeimpl.h"
67 69
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
83typedef union { 88typedef union {
84 char* v_string; 89 char* v_string;
85} yystype; 90} yystype;
86# define YYSTYPE yystype 91# define YYSTYPE yystype
87# define YYSTYPE_IS_TRIVIAL 1
88#endif 92#endif
89#ifndef YYDEBUG 93#ifndef YYDEBUG
90# define YYDEBUG 0 94# define YYDEBUG 0
@@ -92,12 +96,12 @@ typedef union {
92 96
93 97
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
102/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ 106/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
103static const char yytranslate[] = 107static const char yytranslate[] =
@@ -129,23 +133,24 @@ static const char yytranslate[] =
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 134 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
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};
134 138
135#if YYDEBUG 139#if YYDEBUG
136static const short yyprhs[] = 140static 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};
141static const short yyrhs[] = 145static 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};
150 155
151#endif 156#endif
@@ -154,8 +159,8 @@ static const short yyrhs[] =
154/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 159/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
155static const short yyrline[] = 160static 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};
160#endif 165#endif
161 166
@@ -167,23 +172,23 @@ static const char *const yytname[] =
167{ 172{
168 "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA", 173 "$", "error", "$undefined.", "STRING", "SELECT", "FROM", "WHERE", "COMMA",
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};
173#endif 178#endif
174 179
175/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 180/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
176static const short yyr1[] = 181static 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};
181 186
182/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 187/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
183static const short yyr2[] = 188static 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};
188 193
189/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE 194/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@@ -191,49 +196,53 @@ static const short yyr2[] =
191 error. */ 196 error. */
192static const short yydefact[] = 197static 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};
199 204
200static const short yydefgoto[] = 205static const short yydefgoto[] =
201{ 206{
202 32, 4, 8, 13, 14 207 36, 4, 8, 13, 14
203}; 208};
204 209
205static const short yypact[] = 210static 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};
212 217
213static const short yypgoto[] = 218static const short yypgoto[] =
214{ 219{
215 -32768,-32768,-32768, -6,-32768 220 -32768,-32768,-32768, -5,-32768
216}; 221};
217 222
218 223
219 #define YYLAST 28 224 #define YYLAST 32
220 225
221 226
222static const short yytable[] = 227static 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};
228 234
229static const short yycheck[] = 235static 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
238/* Skeleton output parser for bison, 247/* Skeleton output parser for bison,
239 248
@@ -301,12 +310,6 @@ static const short yycheck[] =
301# define YYSTACK_ALLOC malloc 310# define YYSTACK_ALLOC malloc
302# define YYSTACK_FREE free 311# define YYSTACK_FREE free
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
311/* A type that is properly aligned for any stack member. */ 314/* A type that is properly aligned for any stack member. */
312union yyalloc 315union yyalloc
@@ -333,41 +336,24 @@ union yyalloc
333 + YYSTACK_GAP_MAX) 336 + YYSTACK_GAP_MAX)
334# endif 337# endif
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
356 elements in the stack, and YYPTR gives the new location of the 341 elements in the stack, and YYPTR gives the new location of the
357 stack. Advance YYPTR to a properly aligned location for the next 342 stack. Advance YYPTR to a properly aligned location for the next
358 stack. */ 343 stack. */
359 # define YYSTACK_RELOCATE(Stack) \ 344 # define YYSTACK_RELOCATE(Type, Stack) \
360 do \ 345 do \
361 { \ 346 { \
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); \
367 } \ 353 } \
368 while (0) 354 while (0)
369 355
370#endif 356#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
371 357
372 358
373#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 359#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -494,6 +480,33 @@ int yydebug;
494# define YYMAXDEPTH 10000 480# define YYMAXDEPTH 10000
495#endif 481#endif
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
498 511
499# ifndef yystrlen 512# ifndef yystrlen
@@ -546,7 +559,7 @@ yystpcpy (yydest, yysrc)
546# endif 559# endif
547#endif 560#endif
548 561
549#line 315 "/usr/share/bison/bison.simple" 562#line 319 "/usr/local/share/bison/bison.simple"
550 563
551 564
552/* The user can define YYPARSE_PARAM as the name of an argument to be passed 565/* The user can define YYPARSE_PARAM as the name of an argument to be passed
@@ -736,9 +749,6 @@ yyparse (YYPARSE_PARAM_ARG)
736 yyvs = yyvs1; 749 yyvs = yyvs1;
737 } 750 }
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. */
743 if (yystacksize >= YYMAXDEPTH) 753 if (yystacksize >= YYMAXDEPTH)
744 goto yyoverflowlab; 754 goto yyoverflowlab;
@@ -752,16 +762,15 @@ yyparse (YYPARSE_PARAM_ARG)
752 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 762 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
753 if (! yyptr) 763 if (! yyptr)
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
760# undef YYSTACK_RELOCATE 770# undef YYSTACK_RELOCATE
761 if (yyss1 != yyssa) 771 if (yyss1 != yyssa)
762 YYSTACK_FREE (yyss1); 772 YYSTACK_FREE (yyss1);
763 } 773 }
764# endif
765#endif /* no yyoverflow */ 774#endif /* no yyoverflow */
766 775
767 yyssp = yyss + yysize - 1; 776 yyssp = yyss + yysize - 1;
@@ -939,68 +948,76 @@ yyreduce:
939 948
940 switch (yyn) { 949 switch (yyn) {
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;
957case 5: 962case 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;
989case 14: 994case 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;
993case 15: 998case 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;
997case 16: 1002case 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;
1001} 1018}
1002 1019
1003#line 705 "/usr/share/bison/bison.simple" 1020#line 705 "/usr/local/share/bison/bison.simple"
1004 1021
1005 1022
1006 yyvsp -= yylen; 1023 yyvsp -= yylen;
@@ -1231,10 +1248,10 @@ yyreturn:
1231#endif 1248#endif
1232 return yyresult; 1249 return yyresult;
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)
1239{ 1256{
1240 1257
@@ -1296,7 +1313,7 @@ void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
1296 pvl_push(impl->where,where); 1313 pvl_push(impl->where,where);
1297} 1314}
1298 1315
1299void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) 1316static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1300{ 1317{
1301 pvl_elem e = pvl_tail(impl->where); 1318 pvl_elem e = pvl_tail(impl->where);
1302 struct icalgauge_where *where = pvl_data(e); 1319 struct icalgauge_where *where = pvl_data(e);
@@ -1307,7 +1324,7 @@ void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
1307 1324
1308 1325
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{
1312 char *c, *compstr, *propstr; 1329 char *c, *compstr, *propstr;
1313 struct icalgauge_where *where; 1330 struct icalgauge_where *where;
@@ -1353,15 +1370,15 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
1353 1370
1354 1371
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 }
1360 1377
1361 pvl_push(impl->select,where); 1378 pvl_push(impl->select,where);
1362} 1379}
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{
1366 icalcomponent_kind ckind; 1383 icalcomponent_kind ckind;
1367 1384
@@ -1377,5 +1394,6 @@ void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
1377 1394
1378 1395
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,12 +1,11 @@
1#ifndef BISON_ICALSSYACC_H 1#ifndef BISON_Y_TAB_H
2# define BISON_ICALSSYACC_H 2# define BISON_Y_TAB_H
3 3
4#ifndef YYSTYPE 4#ifndef YYSTYPE
5typedef union { 5typedef union {
6 char* v_string; 6 char* v_string;
7} yystype; 7} yystype;
8# define YYSTYPE yystype 8# define YYSTYPE yystype
9# define YYSTYPE_IS_TRIVIAL 1
10#endif 9#endif
11 # define STRING257 10 # define STRING257
12 # define SELECT258 11 # define SELECT258
@@ -24,8 +23,9 @@ typedef union {
24 # define OR270 23 # define OR270
25 # define EOL271 24 # define EOL271
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,43 +1,43 @@
1include(../../../variables.pri) 1######################################################################
2# Automatically generated by qmake (1.07a) Sun Jun 27 23:03:36 2004
3######################################################################
4
2 5
3 TEMPLATE= lib 6 TEMPLATE= lib
4 7
5TARGET = icalss 8TARGET = icalss
6DESTDIR = ../../lib 9DESTDIR = ../../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