Libical API Documentation  3.0
icalrecur.h
Go to the documentation of this file.
1 /*======================================================================
2  FILE: icalrecur.h
3  CREATOR: eric 20 March 2000
4 
5  (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
6  http://www.softwarestudio.org
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of either:
10 
11  The LGPL as published by the Free Software Foundation, version
12  2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
13 
14  Or:
15 
16  The Mozilla Public License Version 2.0. You may obtain a copy of
17  the License at http://www.mozilla.org/MPL/
18 ========================================================================*/
19 
67 #ifndef ICALRECUR_H
68 #define ICALRECUR_H
69 
70 #include "libical_ical_export.h"
71 #include "icalarray.h"
72 #include "icaltime.h"
73 
74 /*
75  * Recurrence enumerations
76  */
77 
78 typedef enum icalrecurrencetype_frequency
79 {
80  /* These enums are used to index an array, so don't change the
81  order or the integers */
82 
83  ICAL_SECONDLY_RECURRENCE = 0,
84  ICAL_MINUTELY_RECURRENCE = 1,
85  ICAL_HOURLY_RECURRENCE = 2,
86  ICAL_DAILY_RECURRENCE = 3,
87  ICAL_WEEKLY_RECURRENCE = 4,
88  ICAL_MONTHLY_RECURRENCE = 5,
89  ICAL_YEARLY_RECURRENCE = 6,
90  ICAL_NO_RECURRENCE = 7
91 } icalrecurrencetype_frequency;
92 
93 typedef enum icalrecurrencetype_weekday
94 {
95  ICAL_NO_WEEKDAY,
96  ICAL_SUNDAY_WEEKDAY,
97  ICAL_MONDAY_WEEKDAY,
98  ICAL_TUESDAY_WEEKDAY,
99  ICAL_WEDNESDAY_WEEKDAY,
100  ICAL_THURSDAY_WEEKDAY,
101  ICAL_FRIDAY_WEEKDAY,
102  ICAL_SATURDAY_WEEKDAY
103 } icalrecurrencetype_weekday;
104 
105 typedef enum icalrecurrencetype_skip
106 {
107  ICAL_SKIP_BACKWARD = 0,
108  ICAL_SKIP_FORWARD,
109  ICAL_SKIP_OMIT,
110  ICAL_SKIP_UNDEFINED
111 } icalrecurrencetype_skip;
112 
113 enum icalrecurrence_array_max_values
114 {
115  ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f,
116  ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f
117 };
118 
119 /*
120  * Recurrence enumerations conversion routines.
121  */
122 
123 LIBICAL_ICAL_EXPORT icalrecurrencetype_frequency icalrecur_string_to_freq(const char *str);
124 LIBICAL_ICAL_EXPORT const char *icalrecur_freq_to_string(icalrecurrencetype_frequency kind);
125 
126 LIBICAL_ICAL_EXPORT icalrecurrencetype_skip icalrecur_string_to_skip(const char *str);
127 LIBICAL_ICAL_EXPORT const char *icalrecur_skip_to_string(icalrecurrencetype_skip kind);
128 
129 LIBICAL_ICAL_EXPORT const char *icalrecur_weekday_to_string(icalrecurrencetype_weekday kind);
130 LIBICAL_ICAL_EXPORT icalrecurrencetype_weekday icalrecur_string_to_weekday(const char *str);
131 
136 /* See RFC 5545 Section 3.3.10, RECUR Value, and RFC 7529
137  * for an explanation of the values and fields in struct icalrecurrencetype.
138  *
139  * The maximums below are based on lunisolar leap years (13 months)
140  */
141 #define ICAL_BY_SECOND_SIZE 62 /* 0 to 60 */
142 #define ICAL_BY_MINUTE_SIZE 61 /* 0 to 59 */
143 #define ICAL_BY_HOUR_SIZE 25 /* 0 to 23 */
144 #define ICAL_BY_MONTH_SIZE 14 /* 1 to 13 */
145 #define ICAL_BY_MONTHDAY_SIZE 32 /* 1 to 31 */
146 #define ICAL_BY_WEEKNO_SIZE 56 /* 1 to 55 */
147 #define ICAL_BY_YEARDAY_SIZE 386 /* 1 to 385 */
148 #define ICAL_BY_SETPOS_SIZE ICAL_BY_YEARDAY_SIZE /* 1 to N */
149 #define ICAL_BY_DAY_SIZE 7*(ICAL_BY_WEEKNO_SIZE-1)+1 /* 1 to N */
150 
153 {
154  icalrecurrencetype_frequency freq;
155 
156  /* until and count are mutually exclusive. */
157  struct icaltimetype until;
158  int count;
159 
160  short interval;
161 
162  icalrecurrencetype_weekday week_start;
163 
164  /* The BY* parameters can each take a list of values. Here I
165  * assume that the list of values will not be larger than the
166  * range of the value -- that is, the client will not name a
167  * value more than once.
168 
169  * Each of the lists is terminated with the value
170  * ICAL_RECURRENCE_ARRAY_MAX unless the list is full.
171  */
172 
173  short by_second[ICAL_BY_SECOND_SIZE];
174  short by_minute[ICAL_BY_MINUTE_SIZE];
175  short by_hour[ICAL_BY_HOUR_SIZE];
176  short by_day[ICAL_BY_DAY_SIZE]; /* Encoded value, see below */
177  short by_month_day[ICAL_BY_MONTHDAY_SIZE];
178  short by_year_day[ICAL_BY_YEARDAY_SIZE];
179  short by_week_no[ICAL_BY_WEEKNO_SIZE];
180  short by_month[ICAL_BY_MONTH_SIZE];
181  short by_set_pos[ICAL_BY_SETPOS_SIZE];
182 
183  /* For RSCALE extension (RFC 7529) */
184  char *rscale;
185  icalrecurrencetype_skip skip;
186 };
187 
188 LIBICAL_ICAL_EXPORT int icalrecurrencetype_rscale_is_supported(void);
189 
190 LIBICAL_ICAL_EXPORT icalarray *icalrecurrencetype_rscale_supported_calendars(void);
191 
192 LIBICAL_ICAL_EXPORT void icalrecurrencetype_clear(struct icalrecurrencetype *r);
193 
204 LIBICAL_ICAL_EXPORT enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
205 
207 LIBICAL_ICAL_EXPORT int icalrecurrencetype_day_position(short day);
208 
215 LIBICAL_ICAL_EXPORT int icalrecurrencetype_month_is_leap(short month);
216 
217 LIBICAL_ICAL_EXPORT int icalrecurrencetype_month_month(short month);
218 
222 LIBICAL_ICAL_EXPORT struct icalrecurrencetype icalrecurrencetype_from_string(const char *str);
223 
224 LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
225 
226 LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur);
227 
231 
233 LIBICAL_ICAL_EXPORT icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype rule,
234  struct icaltimetype dtstart);
235 
241 LIBICAL_ICAL_EXPORT int icalrecur_iterator_set_start(icalrecur_iterator *impl,
242  struct icaltimetype start);
243 
245 LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *);
246 
248 LIBICAL_ICAL_EXPORT void icalrecur_iterator_free(icalrecur_iterator *);
249 
254 LIBICAL_ICAL_EXPORT int icalrecur_expand_recurrence(const char *rule, time_t start,
255  int count, time_t *array);
256 
257 #endif
struct icalrecurrencetype icalrecurrencetype_from_string(const char *str)
Definition: icalrecur.c:545
int icalrecur_expand_recurrence(const char *rule, time_t start, int count, time_t *array)
Definition: icalrecur.c:3046
void icalrecur_iterator_free(icalrecur_iterator *)
Definition: icalrecur.c:1907
struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *)
Definition: icalrecur.c:2750
struct icaltimetype is a pseudo-object that abstracts time handling.
Definition: icalarray.h:35
#define ICAL_BY_SECOND_SIZE
Definition: icalrecur.h:141
int icalrecur_iterator_set_start(icalrecur_iterator *impl, struct icaltimetype start)
Definition: icalrecur.c:2953
int month
Definition: icaltime.h:108
enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
Definition: icalrecur.c:3006
Definition: icaltime.h:105
icalrecur_iterator * icalrecur_iterator_new(struct icalrecurrencetype rule, struct icaltimetype dtstart)
Definition: icalrecur.c:1794
Definition: icalrecur.h:152
int icalrecurrencetype_day_position(short day)
Definition: icalrecur.c:3011
An array of arbitrarily-sized elements which grows dynamically as elements are added.
Definition: icalrecur.c:825
int icalrecurrencetype_month_is_leap(short month)
Definition: icalrecur.c:3030