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@civicknowledge.com>
6
7 This library is free software; you can redistribute it and/or modify
8 it under the terms of either:
9
10 The LGPL as published by the Free Software Foundation, version
11 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html
12
13 Or:
14
15 The Mozilla Public License Version 2.0. You may obtain a copy of
16 the License at https://www.mozilla.org/MPL/
17========================================================================*/
18
66#ifndef ICALRECUR_H
67#define ICALRECUR_H
68
69#include "libical_ical_export.h"
70#include "icalarray.h"
71#include "icaltime.h"
72
73/*
74 * Recurrence enumerations
75 */
76
77typedef enum icalrecurrencetype_frequency
78{
79 /* These enums are used to index an array, so don't change the
80 order or the integers */
81
82 ICAL_SECONDLY_RECURRENCE = 0,
83 ICAL_MINUTELY_RECURRENCE = 1,
84 ICAL_HOURLY_RECURRENCE = 2,
85 ICAL_DAILY_RECURRENCE = 3,
86 ICAL_WEEKLY_RECURRENCE = 4,
87 ICAL_MONTHLY_RECURRENCE = 5,
88 ICAL_YEARLY_RECURRENCE = 6,
89 ICAL_NO_RECURRENCE = 7
90} icalrecurrencetype_frequency;
91
92typedef enum icalrecurrencetype_weekday
93{
94 ICAL_NO_WEEKDAY,
95 ICAL_SUNDAY_WEEKDAY,
96 ICAL_MONDAY_WEEKDAY,
97 ICAL_TUESDAY_WEEKDAY,
98 ICAL_WEDNESDAY_WEEKDAY,
99 ICAL_THURSDAY_WEEKDAY,
100 ICAL_FRIDAY_WEEKDAY,
101 ICAL_SATURDAY_WEEKDAY
102} icalrecurrencetype_weekday;
103
104typedef enum icalrecurrencetype_skip
105{
106 ICAL_SKIP_BACKWARD = 0,
107 ICAL_SKIP_FORWARD,
108 ICAL_SKIP_OMIT,
109 ICAL_SKIP_UNDEFINED
110} icalrecurrencetype_skip;
111
112enum icalrecurrence_array_max_values
113{
114 ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f,
115 ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f
116};
117
118/*
119 * Recurrence enumerations conversion routines.
120 */
121
122LIBICAL_ICAL_EXPORT icalrecurrencetype_frequency icalrecur_string_to_freq(const char *str);
123LIBICAL_ICAL_EXPORT const char *icalrecur_freq_to_string(icalrecurrencetype_frequency kind);
124
125LIBICAL_ICAL_EXPORT icalrecurrencetype_skip icalrecur_string_to_skip(const char *str);
126LIBICAL_ICAL_EXPORT const char *icalrecur_skip_to_string(icalrecurrencetype_skip kind);
127
128LIBICAL_ICAL_EXPORT const char *icalrecur_weekday_to_string(icalrecurrencetype_weekday kind);
129LIBICAL_ICAL_EXPORT icalrecurrencetype_weekday icalrecur_string_to_weekday(const char *str);
130
135/* See RFC 5545 Section 3.3.10, RECUR Value, and RFC 7529
136 * for an explanation of the values and fields in struct icalrecurrencetype.
137 *
138 * The maximums below are based on lunisolar leap years (13 months)
139 */
140#define ICAL_BY_SECOND_SIZE 62 /* 0 to 60 */
141#define ICAL_BY_MINUTE_SIZE 61 /* 0 to 59 */
142#define ICAL_BY_HOUR_SIZE 25 /* 0 to 23 */
143#define ICAL_BY_MONTH_SIZE 14 /* 1 to 13 */
144#define ICAL_BY_MONTHDAY_SIZE 32 /* 1 to 31 */
145#define ICAL_BY_WEEKNO_SIZE 56 /* 1 to 55 */
146#define ICAL_BY_YEARDAY_SIZE 386 /* 1 to 385 */
147#define ICAL_BY_SETPOS_SIZE ICAL_BY_YEARDAY_SIZE /* 1 to N */
148#define ICAL_BY_DAY_SIZE 7*(ICAL_BY_WEEKNO_SIZE-1)+1 /* 1 to N */
149
152{
153 icalrecurrencetype_frequency freq;
154
155 /* until and count are mutually exclusive. */
156 struct icaltimetype until;
157 int count;
158
159 short interval;
160
161 icalrecurrencetype_weekday week_start;
162
163 /* The BY* parameters can each take a list of values. Here I
164 * assume that the list of values will not be larger than the
165 * range of the value -- that is, the client will not name a
166 * value more than once.
167
168 * Each of the lists is terminated with the value
169 * ICAL_RECURRENCE_ARRAY_MAX unless the list is full.
170 */
171
172 short by_second[ICAL_BY_SECOND_SIZE];
173 short by_minute[ICAL_BY_MINUTE_SIZE];
174 short by_hour[ICAL_BY_HOUR_SIZE];
175 short by_day[ICAL_BY_DAY_SIZE];
185 short by_month_day[ICAL_BY_MONTHDAY_SIZE];
186 short by_year_day[ICAL_BY_YEARDAY_SIZE];
187 short by_week_no[ICAL_BY_WEEKNO_SIZE];
188 short by_month[ICAL_BY_MONTH_SIZE];
196 short by_set_pos[ICAL_BY_SETPOS_SIZE];
197
198 /* For RSCALE extension (RFC 7529) */
199 char *rscale;
200 icalrecurrencetype_skip skip;
201};
202
203LIBICAL_ICAL_EXPORT int icalrecurrencetype_rscale_is_supported(void);
204
205LIBICAL_ICAL_EXPORT icalarray *icalrecurrencetype_rscale_supported_calendars(void);
206
207LIBICAL_ICAL_EXPORT void icalrecurrencetype_clear(struct icalrecurrencetype *r);
208
209/*
210 * Routines to decode the day values of the by_day array
211 */
212
226LIBICAL_ICAL_EXPORT enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
227
234LIBICAL_ICAL_EXPORT int icalrecurrencetype_day_position(short day);
235
236/*
237 * Routines to decode the 'month' element of the by_month array
238 */
239
240LIBICAL_ICAL_EXPORT int icalrecurrencetype_month_is_leap(short month);
241
242LIBICAL_ICAL_EXPORT int icalrecurrencetype_month_month(short month);
243
244/*
245 * Recurrence rule parser
246 */
247
249LIBICAL_ICAL_EXPORT struct icalrecurrencetype icalrecurrencetype_from_string(const char *str);
250
251LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
252
253LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur);
254
255/*
256 * Recurrence iteration routines
257 */
258
260
262LIBICAL_ICAL_EXPORT icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype rule,
263 struct icaltimetype dtstart);
264
272LIBICAL_ICAL_EXPORT int icalrecur_iterator_set_start(icalrecur_iterator *impl,
273 struct icaltimetype start);
274
276LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *);
277
279LIBICAL_ICAL_EXPORT void icalrecur_iterator_free(icalrecur_iterator *);
280
291LIBICAL_ICAL_EXPORT int icalrecur_expand_recurrence(const char *rule, time_t start,
292 int count, time_t *array);
293
294#endif
An array of arbitrarily-sized elements which grows dynamically as elements are added.
int icalrecur_expand_recurrence(const char *rule, time_t start, int count, time_t *array)
Fills an array with the 'count' number of occurrences generated by the rrule.
Definition: icalrecur.c:3184
struct icalrecurrencetype icalrecurrencetype_from_string(const char *str)
Definition: icalrecur.c:555
void icalrecur_iterator_free(icalrecur_iterator *)
Definition: icalrecur.c:2031
struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *)
Definition: icalrecur.c:2900
icalrecur_iterator * icalrecur_iterator_new(struct icalrecurrencetype rule, struct icaltimetype dtstart)
Definition: icalrecur.c:1918
enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
Decodes a day to a weekday.
Definition: icalrecur.c:3150
int icalrecurrencetype_day_position(short day)
Decodes a day to a position of the weekday.
Definition: icalrecur.c:3155
int icalrecur_iterator_set_start(icalrecur_iterator *impl, struct icaltimetype start)
Definition: icalrecur.c:3108
#define ICAL_BY_SECOND_SIZE
Definition: icalrecur.h:140
struct icaltimetype is a pseudo-object that abstracts time handling.
Definition: icalarray.h:36
Definition: icalrecur.c:925
Definition: icalrecur.h:152
short by_day[7 *(56 -1)+1]
Encoded value.
Definition: icalrecur.h:175
short by_month[14]
Encoded value.
Definition: icalrecur.h:188
Definition: icaltime.h:105
int month
Definition: icaltime.h:107