libkcal

icalrecur.h

Go to the documentation of this file.
00001 /* -*- Mode: C -*- */
00002 /*======================================================================
00003  FILE: icalrecur.h
00004  CREATOR: eric 20 March 2000
00005 
00006 
00007  (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
00008      http://www.softwarestudio.org
00009 
00010  This program is free software; you can redistribute it and/or modify
00011  it under the terms of either: 
00012 
00013     The LGPL as published by the Free Software Foundation, version
00014     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00015 
00016   Or:
00017 
00018     The Mozilla Public License Version 1.0. You may obtain a copy of
00019     the License at http://www.mozilla.org/MPL/
00020 */
00021 
00069 #ifndef ICALRECUR_H
00070 #define ICALRECUR_H
00071 
00072 #include <time.h>
00073 #include "icaltime.h"
00074 
00075 /*
00076  * Recurrance enumerations
00077  */
00078 
00079 typedef enum icalrecurrencetype_frequency
00080 {
00081     /* These enums are used to index an array, so don't change the
00082        order or the integers */
00083 
00084     ICAL_SECONDLY_RECURRENCE=0,
00085     ICAL_MINUTELY_RECURRENCE=1,
00086     ICAL_HOURLY_RECURRENCE=2,
00087     ICAL_DAILY_RECURRENCE=3,
00088     ICAL_WEEKLY_RECURRENCE=4,
00089     ICAL_MONTHLY_RECURRENCE=5,
00090     ICAL_YEARLY_RECURRENCE=6,
00091     ICAL_NO_RECURRENCE=7
00092 
00093 } icalrecurrencetype_frequency;
00094 
00095 typedef enum icalrecurrencetype_weekday
00096 {
00097     ICAL_NO_WEEKDAY,
00098     ICAL_SUNDAY_WEEKDAY,
00099     ICAL_MONDAY_WEEKDAY,
00100     ICAL_TUESDAY_WEEKDAY,
00101     ICAL_WEDNESDAY_WEEKDAY,
00102     ICAL_THURSDAY_WEEKDAY,
00103     ICAL_FRIDAY_WEEKDAY,
00104     ICAL_SATURDAY_WEEKDAY
00105 } icalrecurrencetype_weekday;
00106 
00107 enum {
00108     ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f,
00109     ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f
00110 };
00111 
00112 
00113 
00118 /* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of
00119    the values and fields in struct icalrecurrencetype */
00120 
00121 #define ICAL_BY_SECOND_SIZE 61
00122 #define ICAL_BY_MINUTE_SIZE 61
00123 #define ICAL_BY_HOUR_SIZE 25
00124 #define ICAL_BY_DAY_SIZE 364 /* 7 days * 52 weeks */
00125 #define ICAL_BY_MONTHDAY_SIZE 32
00126 #define ICAL_BY_YEARDAY_SIZE 367
00127 #define ICAL_BY_WEEKNO_SIZE 54
00128 #define ICAL_BY_MONTH_SIZE 13
00129 #define ICAL_BY_SETPOS_SIZE 367
00130 
00132 struct icalrecurrencetype 
00133 {
00134     icalrecurrencetype_frequency freq;
00135 
00136 
00137     /* until and count are mutually exclusive. */
00138         struct icaltimetype until; 
00139     int count;
00140 
00141     short interval;
00142     
00143     icalrecurrencetype_weekday week_start;
00144     
00145     /* The BY* parameters can each take a list of values. Here I
00146      * assume that the list of values will not be larger than the
00147      * range of the value -- that is, the client will not name a
00148      * value more than once. 
00149      
00150      * Each of the lists is terminated with the value
00151      * ICAL_RECURRENCE_ARRAY_MAX unless the the list is full.
00152      */
00153 
00154     short by_second[ICAL_BY_SECOND_SIZE];
00155     short by_minute[ICAL_BY_MINUTE_SIZE];
00156     short by_hour[ICAL_BY_HOUR_SIZE];
00157     short by_day[ICAL_BY_DAY_SIZE]; /* Encoded value, see below */
00158     short by_month_day[ICAL_BY_MONTHDAY_SIZE];
00159     short by_year_day[ ICAL_BY_YEARDAY_SIZE];
00160     short by_week_no[ICAL_BY_WEEKNO_SIZE];
00161     short by_month[ICAL_BY_MONTH_SIZE];
00162     short by_set_pos[ICAL_BY_SETPOS_SIZE];
00163 };
00164 
00165 
00166 void icalrecurrencetype_clear(struct icalrecurrencetype *r);
00167 
00178 enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
00179 
00181 int icalrecurrencetype_day_position(short day);
00182 
00183 
00187 struct icalrecurrencetype icalrecurrencetype_from_string(const char* str);
00188 char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur);
00189 
00190 
00193 typedef struct icalrecur_iterator_impl  icalrecur_iterator;
00194 
00196 icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, 
00197                                            struct icaltimetype dtstart);
00198 
00200 struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*);
00201 
00202 void icalrecur_iterator_decrement_count(icalrecur_iterator*);
00203 
00205 void icalrecur_iterator_free(icalrecur_iterator*);
00206 
00211 int icalrecur_expand_recurrence(char* rule, time_t start, 
00212                 int count, time_t* array);
00213 
00214 
00215 #endif