Back to index

lightning-sunbird  0.9+nobinonly
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, http://www.softwarestudio.org
00008 
00009  This program is free software; you can redistribute it and/or modify
00010  it under the terms of either: 
00011 
00012     The LGPL as published by the Free Software Foundation, version
00013     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00014 
00015   Or:
00016 
00017     The Mozilla Public License Version 1.0. You may obtain a copy of
00018     the License at http://www.mozilla.org/MPL/
00019 */
00020 
00068 #ifndef ICALRECUR_H
00069 #define ICALRECUR_H
00070 
00071 #include <time.h>
00072 #include "icaltime.h"
00073 
00074 /*
00075  * Recurrance enumerations
00076  */
00077 
00078 typedef enum icalrecurrencetype_frequency
00079 {
00080     /* These enums are used to index an array, so don't change the
00081        order or the integers */
00082 
00083     ICAL_SECONDLY_RECURRENCE=0,
00084     ICAL_MINUTELY_RECURRENCE=1,
00085     ICAL_HOURLY_RECURRENCE=2,
00086     ICAL_DAILY_RECURRENCE=3,
00087     ICAL_WEEKLY_RECURRENCE=4,
00088     ICAL_MONTHLY_RECURRENCE=5,
00089     ICAL_YEARLY_RECURRENCE=6,
00090     ICAL_NO_RECURRENCE=7
00091 
00092 } icalrecurrencetype_frequency;
00093 
00094 typedef enum icalrecurrencetype_weekday
00095 {
00096     ICAL_NO_WEEKDAY,
00097     ICAL_SUNDAY_WEEKDAY,
00098     ICAL_MONDAY_WEEKDAY,
00099     ICAL_TUESDAY_WEEKDAY,
00100     ICAL_WEDNESDAY_WEEKDAY,
00101     ICAL_THURSDAY_WEEKDAY,
00102     ICAL_FRIDAY_WEEKDAY,
00103     ICAL_SATURDAY_WEEKDAY
00104 } icalrecurrencetype_weekday;
00105 
00106 enum {
00107     ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f,
00108     ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f
00109 };
00110 
00111 
00112 
00117 /* See RFC 2445 Section 4.3.10, RECUR Value, for an explanation of
00118    the values and fields in struct icalrecurrencetype */
00119 
00120 #define ICAL_BY_SECOND_SIZE 61
00121 #define ICAL_BY_MINUTE_SIZE 61
00122 #define ICAL_BY_HOUR_SIZE 25
00123 #define ICAL_BY_DAY_SIZE 364 /* 7 days * 52 weeks */
00124 #define ICAL_BY_MONTHDAY_SIZE 32
00125 #define ICAL_BY_YEARDAY_SIZE 367
00126 #define ICAL_BY_WEEKNO_SIZE 54
00127 #define ICAL_BY_MONTH_SIZE 13
00128 #define ICAL_BY_SETPOS_SIZE 367
00129 
00131 struct icalrecurrencetype 
00132 {
00133        icalrecurrencetype_frequency freq;
00134 
00135 
00136        /* until and count are mutually exclusive. */
00137               struct icaltimetype until; 
00138        int count;
00139 
00140        short interval;
00141        
00142        icalrecurrencetype_weekday week_start;
00143        
00144        /* The BY* parameters can each take a list of values. Here I
00145         * assume that the list of values will not be larger than the
00146         * range of the value -- that is, the client will not name a
00147         * value more than once. 
00148         
00149         * Each of the lists is terminated with the value
00150         * ICAL_RECURRENCE_ARRAY_MAX unless the the list is full.
00151         */
00152 
00153        short by_second[ICAL_BY_SECOND_SIZE];
00154        short by_minute[ICAL_BY_MINUTE_SIZE];
00155        short by_hour[ICAL_BY_HOUR_SIZE];
00156        short by_day[ICAL_BY_DAY_SIZE]; /* Encoded value, see below */
00157        short by_month_day[ICAL_BY_MONTHDAY_SIZE];
00158        short by_year_day[ ICAL_BY_YEARDAY_SIZE];
00159        short by_week_no[ICAL_BY_WEEKNO_SIZE];
00160        short by_month[ICAL_BY_MONTH_SIZE];
00161        short by_set_pos[ICAL_BY_SETPOS_SIZE];
00162 };
00163 
00164 
00165 void icalrecurrencetype_clear(struct icalrecurrencetype *r);
00166 
00177 enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
00178 
00180 int icalrecurrencetype_day_position(short day);
00181 
00182 icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str);
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