Libical API Documentation 4.0
Loading...
Searching...
No Matches
icalrecur.h
Go to the documentation of this file.
1/*======================================================================
2 FILE: icalrecur.h
3 CREATOR: eric 20 March 2000
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
8
9========================================================================*/
10
65
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#include <stdbool.h>
74
75/*
76 * Recurrence enumerations
77 */
78
79typedef enum icalrecurrencetype_frequency
80{
81 /* These enums are used to index an array, so don't change the
82 order or the integers */
83
84 ICAL_SECONDLY_RECURRENCE = 0,
85 ICAL_MINUTELY_RECURRENCE = 1,
86 ICAL_HOURLY_RECURRENCE = 2,
87 ICAL_DAILY_RECURRENCE = 3,
88 ICAL_WEEKLY_RECURRENCE = 4,
89 ICAL_MONTHLY_RECURRENCE = 5,
90 ICAL_YEARLY_RECURRENCE = 6,
91 ICAL_NO_RECURRENCE = 7
92} icalrecurrencetype_frequency;
93
94typedef enum icalrecurrencetype_weekday
95{
96 ICAL_NO_WEEKDAY,
97 ICAL_SUNDAY_WEEKDAY,
98 ICAL_MONDAY_WEEKDAY,
99 ICAL_TUESDAY_WEEKDAY,
100 ICAL_WEDNESDAY_WEEKDAY,
101 ICAL_THURSDAY_WEEKDAY,
102 ICAL_FRIDAY_WEEKDAY,
103 ICAL_SATURDAY_WEEKDAY
104} icalrecurrencetype_weekday;
105
106typedef enum icalrecurrencetype_skip
107{
108 ICAL_SKIP_BACKWARD = 0,
109 ICAL_SKIP_FORWARD,
110 ICAL_SKIP_OMIT,
111 ICAL_SKIP_UNDEFINED
112} icalrecurrencetype_skip;
113
114typedef enum icalrecurrencetype_byrule
115{
116 ICAL_BYRULE_NO_CONTRACTION = -1,
117 ICAL_BY_MONTH = 0,
118 ICAL_BY_WEEK_NO = 1,
119 ICAL_BY_YEAR_DAY = 2,
120 ICAL_BY_MONTH_DAY = 3,
121 ICAL_BY_DAY = 4,
122 ICAL_BY_HOUR = 5,
123 ICAL_BY_MINUTE = 6,
124 ICAL_BY_SECOND = 7,
125 ICAL_BY_SET_POS = 8,
126
127 ICAL_BY_NUM_PARTS = 9
128} icalrecurrencetype_byrule;
129
130/*
131 * Recurrence enumerations conversion routines.
132 */
133
134LIBICAL_ICAL_EXPORT icalrecurrencetype_frequency icalrecur_string_to_freq(const char *str);
135LIBICAL_ICAL_EXPORT const char *icalrecur_freq_to_string(icalrecurrencetype_frequency kind);
136
137LIBICAL_ICAL_EXPORT icalrecurrencetype_skip icalrecur_string_to_skip(const char *str);
138LIBICAL_ICAL_EXPORT const char *icalrecur_skip_to_string(icalrecurrencetype_skip kind);
139
140LIBICAL_ICAL_EXPORT const char *icalrecur_weekday_to_string(icalrecurrencetype_weekday kind);
141LIBICAL_ICAL_EXPORT icalrecurrencetype_weekday icalrecur_string_to_weekday(const char *str);
142
146
147/* See RFC 5545 Section 3.3.10, RECUR Value, and RFC 7529
148 * for an explanation of the values and fields in struct icalrecurrencetype.
149 *
150 * The maximums below are based on lunisolar leap years (13 months)
151 */
152#define ICAL_BY_SECOND_SIZE 62 /* 0 to 60 */
153#define ICAL_BY_MINUTE_SIZE 61 /* 0 to 59 */
154#define ICAL_BY_HOUR_SIZE 25 /* 0 to 23 */
155#define ICAL_BY_MONTH_SIZE 14 /* 1 to 13 */
156#define ICAL_BY_MONTHDAY_SIZE 32 /* 1 to 31 */
157#define ICAL_BY_WEEKNO_SIZE 56 /* 1 to 55 */
158#define ICAL_BY_YEARDAY_SIZE 386 /* 1 to 385 */
159#define ICAL_BY_SETPOS_SIZE ICAL_BY_YEARDAY_SIZE /* 1 to N */
160#define ICAL_BY_DAY_SIZE 7 * (ICAL_BY_WEEKNO_SIZE - 1) + 1 /* 1 to N */
161
162typedef struct
163{
164 short *data;
165 short size;
167
170 /* Reference count */
171 int refcount;
172
173 icalrecurrencetype_frequency freq;
174
175 /* until and count are mutually exclusive. */
176 struct icaltimetype until;
177 int count;
178
179 short interval;
180
181 icalrecurrencetype_weekday week_start;
182
199 icalrecurrence_by_data by[ICAL_BY_NUM_PARTS];
200
201 /* For RSCALE extension (RFC 7529) */
202 char *rscale;
203 icalrecurrencetype_skip skip;
204};
205
211LIBICAL_ICAL_EXPORT struct icalrecurrencetype *icalrecurrencetype_new(void);
212
216LIBICAL_ICAL_EXPORT void icalrecurrencetype_ref(struct icalrecurrencetype *recur);
217
222LIBICAL_ICAL_EXPORT void icalrecurrencetype_unref(struct icalrecurrencetype *recur);
223
224LIBICAL_ICAL_EXPORT bool icalrecurrencetype_rscale_is_supported(void);
225
226LIBICAL_ICAL_EXPORT icalarray *icalrecurrencetype_rscale_supported_calendars(void);
227
232LIBICAL_ICAL_EXPORT struct icalrecurrencetype *icalrecurrencetype_clone(struct icalrecurrencetype *r);
233
239LIBICAL_ICAL_EXPORT bool icalrecur_resize_by(icalrecurrence_by_data *by, short size);
240
241/*
242 * Routines to decode the day values of the by[ICAL_BY_DAY] array
243 */
244
260LIBICAL_ICAL_EXPORT enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
261
268LIBICAL_ICAL_EXPORT int icalrecurrencetype_day_position(short day);
269
275LIBICAL_ICAL_EXPORT short icalrecurrencetype_encode_day(enum icalrecurrencetype_weekday weekday,
276 int position);
277
278/*
279 * Routines to decode the 'month' element of the by[ICAL_BY_MONTH] array
280 */
281
289LIBICAL_ICAL_EXPORT bool icalrecurrencetype_month_is_leap(short month);
290
291LIBICAL_ICAL_EXPORT int icalrecurrencetype_month_month(short month);
292
298LIBICAL_ICAL_EXPORT short icalrecurrencetype_encode_month(int month, bool is_leap);
299
300/*
301 * Recurrence rule parser
302 */
303
305LIBICAL_ICAL_EXPORT struct icalrecurrencetype *icalrecurrencetype_new_from_string(const char *str);
306
307LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
308
309LIBICAL_ICAL_EXPORT char *icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur);
310
311/*
312 * Recurrence iteration routines
313 */
314
315typedef struct icalrecur_iterator_impl icalrecur_iterator;
316
322LIBICAL_ICAL_EXPORT icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype *rule,
323 struct icaltimetype dtstart);
324
332LIBICAL_ICAL_EXPORT bool icalrecur_iterator_set_start(icalrecur_iterator *impl,
333 struct icaltimetype start);
334
338LIBICAL_ICAL_EXPORT bool icalrecur_iterator_set_end(icalrecur_iterator *impl,
339 struct icaltimetype end);
340
358LIBICAL_ICAL_EXPORT bool icalrecur_iterator_set_range(icalrecur_iterator *impl,
359 struct icaltimetype from,
360 struct icaltimetype to);
361
365LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *);
366
371LIBICAL_ICAL_EXPORT struct icaltimetype icalrecur_iterator_prev(icalrecur_iterator *);
372
374LIBICAL_ICAL_EXPORT void icalrecur_iterator_free(icalrecur_iterator *);
375
386LIBICAL_ICAL_EXPORT bool icalrecur_expand_recurrence(const char *rule, icaltime_t start,
387 int count, icaltime_t *array);
388
389/* ical_invalid_rrule_handling :
390 * How should the ICAL library handle RRULEs with invalid BYxxx part combos?
391 */
392typedef enum ical_invalid_rrule_handling
393{
394 ICAL_RRULE_TREAT_AS_ERROR = 0,
395 ICAL_RRULE_IGNORE_INVALID = 1
396} ical_invalid_rrule_handling;
397
398LIBICAL_ICAL_EXPORT ical_invalid_rrule_handling ical_get_invalid_rrule_handling_setting(void);
399
400LIBICAL_ICAL_EXPORT void ical_set_invalid_rrule_handling_setting(
401 ical_invalid_rrule_handling newSetting);
402
403#endif /* ICALRECUR_H */
An array of arbitrarily-sized elements which grows dynamically as elements are added.
struct _icalarray icalarray
A struct representing an icalarray object.
Definition icalarray.h:28
bool icalrecur_iterator_set_start(icalrecur_iterator *impl, struct icaltimetype start)
Definition icalrecur.c:3707
struct icalrecurrencetype * icalrecurrencetype_new_from_string(const char *str)
Definition icalrecur.c:777
void icalrecurrencetype_ref(struct icalrecurrencetype *recur)
Increases the reference counter by 1.
Definition icalrecur.c:691
void icalrecur_iterator_free(icalrecur_iterator *)
Definition icalrecur.c:2258
bool icalrecur_iterator_set_end(icalrecur_iterator *impl, struct icaltimetype end)
Definition icalrecur.c:3732
short icalrecurrencetype_encode_month(int month, bool is_leap)
Definition icalrecur.c:3854
short icalrecurrencetype_encode_day(enum icalrecurrencetype_weekday weekday, int position)
Definition icalrecur.c:3837
bool icalrecurrencetype_month_is_leap(short month)
Definition icalrecur.c:3844
bool icalrecur_resize_by(icalrecurrence_by_data *by, short size)
Resizes the buffer backing the 'by' array to the specified size, if different. Frees the buffer if th...
Definition icalrecur.c:310
struct icalrecurrencetype * icalrecurrencetype_new(void)
Allocates and initializes a new instance of icalrecurrencetype. The new instance is returned with a r...
Definition icalrecur.c:654
bool icalrecur_iterator_set_range(icalrecur_iterator *impl, struct icaltimetype from, struct icaltimetype to)
Definition icalrecur.c:3743
enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day)
Decodes a day to a weekday.
Definition icalrecur.c:3821
int icalrecurrencetype_day_position(short day)
Decodes a day to a position of the weekday.
Definition icalrecur.c:3826
bool icalrecur_expand_recurrence(const char *rule, icaltime_t start, int count, icaltime_t *array)
Fills an array with the 'count' number of occurrences generated by the rrule.
Definition icalrecur.c:3859
void icalrecurrencetype_unref(struct icalrecurrencetype *recur)
Decreases the reference counter by 1. If it goes to 0, the instance and all referenced memory (i....
Definition icalrecur.c:699
icalrecur_iterator * icalrecur_iterator_new(struct icalrecurrencetype *rule, struct icaltimetype dtstart)
Definition icalrecur.c:2140
struct icalrecurrencetype * icalrecurrencetype_clone(struct icalrecurrencetype *r)
Creates a deep copy of the given recurrence rule. The new instance is returned with a refcount of 1.
Definition icalrecur.c:740
struct icaltimetype is a pseudo-object that abstracts time handling.
Definition icalrecur.c:1088
Definition icalrecur.h:163
Definition icalrecur.h:169
icalrecurrencetype_weekday week_start
Encoded value.
Definition icalrecur.h:181
Definition icaltime.h:98