* Fix a crash in Alpine due to incorrectly formated date in an ical
[alpine.git] / pith / icaltype.h
blob23e3cafd731b38df297e652bec5b1fef5f689b66
1 #ifndef ICALTYPE_INCLUDED
2 #define ICALTYPE_INCLUDED
4 /* Due to the line by line processing algorithm, not all information
5 * is available when process some lines. In particular, when we
6 * process anything that has to do with time, we do not know if
7 * we are processing a date in daylight savings time or not. We
8 * solve this by creating a new value for tm_isdst, called
9 * ICAL_DST_UNKNOWN, which is a positive integer. We set this
10 * when the date comes in GMT. Once we process it, we either
11 * change it to 0, which means it is not dst, or change it
12 * to a different value, ICAL_DST_SET which means we know the date
13 * is DST
15 #define ICAL_DATE_TIME (0x00001)
16 #define ICAL_DATE (0x00010)
17 #define ICAL_DATE_TIME_GMT (0x00100)
18 #define ICAL_DST_UNKNOWN (0x01000)
19 #define ICAL_DST_SET (0x10000)
22 /* this is the PARAMETER struct from mail.h, but with possibility of
23 * extension */
24 typedef struct ical_param_s {
25 char *name;
26 char *value;
27 struct ical_param_s *next;
28 } ICAL_PARAMETER_S;
30 #define ICAL_S struct ical_s
32 ICAL_S {
33 char *comp; /* component name */
34 void *value;
35 ICAL_S *branch; /* component in same level */
36 ICAL_S *next; /* component at next level */
39 typedef struct icline_s {
40 char *token;
41 ICAL_PARAMETER_S *param;
42 char *value; /* this could need further processing, so consider this a raw value */
43 } ICLINE_S;
45 typedef struct gen_icline_s {
46 ICLINE_S *cline;
47 struct gen_icline_s *next;
48 } GEN_ICLINE_S;
50 typedef enum {FSecondly, FMinutely, FHourly, FDaily, FWeekly,
51 FMonthly, FYearly, FUnknown} Freq_value;
53 /* believe it or not, I did not need to copy these values from
54 * RFC 5545! */
55 typedef enum {Sunday, Monday, Tuesday, Wednesday, Thursday,
56 Friday, Saturday} Weekday;
58 typedef struct ical_weekday_s {
59 int value; /* number value being parsed */
60 Weekday wd;
61 struct ical_weekday_s *next;
62 } BYWKDY_S;
64 typedef struct ical_rrule_s {
65 #if 0
66 Freq_value freq; /* required, at most one */
67 ICLINE_S *until; /* optional, must not occur with count */
68 ICLINE_S *count; /* optional, must not occur with until */
69 unsigned long interval; /* optional, at most one */
70 BYWKDY_S *bysecond; /* optional, at most one */
71 ICLINE_S *byminute; /* optional, at most one */
72 ICLINE_S *byhour; /* optional, at most one */
73 BYWKDY_S *byday; /* optional, at most one */
74 ICLINE_S *bymonthday; /* optional, at most one */
75 ICLINE_S *byyearday; /* optional, at most one */
76 ICLINE_S *byweekno; /* optional, at most one */
77 BYWKDY_S *bymonth; /* optional, at most one, only use value */
78 ICLINE_S *bysetpos; /* optional, at most one */
79 ICLINE_S *wkst; /* optional, at most one */
80 #endif /* if 0 */
81 void **prop; /* the list of properties of a recurring rule */
82 ICAL_PARAMETER_S *param;
83 } RRULE_S;
85 typedef struct valarm_s {
86 #if 0
87 ICLINE_S *action; /* required, at most one */
88 ICLINE_S *trigger; /* required, at most one */
89 ICLINE_S *duration; /* audio,display,email.optional, at most one. Must occur with repeat */
90 ICLINE_S *repeat; /* audio,display,email.optional, at most one. Must occur with duration */
91 ICLINE_S *description; /* display,email.required, at most one */
92 ICLINE_S *summary; /* email.required, at most one */
93 GEN_ICLINE_S *attach; /* audio.optional, at most one;email.optional, may occur more than once */
94 GEN_ICLINE_S *attendee; /* email.required, may occur more than once */
95 #endif /* if 0 */
96 void **prop; /* an array of all properties of an alarm */
97 GEN_ICLINE_S *uk_prop; /* optional, may occur more than once */
98 struct valarm_s *next;
99 } VALARM_S;
101 typedef struct vevent_s {
102 #if 0
103 ICLINE_S *dtstamp; /* required, at most one */
104 ICLINE_S *uid; /* required, at most one */
105 ICLINE_S *dtstart; /* required if METHOD not specified, at most one */
106 ICLINE_S *class; /* optional, at most one */
107 ICLINE_S *created; /* optional, at most one */
108 ICLINE_S *description;/* optional, at most one */
109 ICLINE_S *geo; /* optional, at most one */
110 ICLINE_S *lastmod; /* optional, at most one */
111 ICLINE_S *location; /* optional, at most one */
112 ICLINE_S *organizer; /* optional, at most one */
113 ICLINE_S *priority; /* optional, at most one */
114 ICLINE_S *seq; /* optional, at most one */
115 ICLINE_S *status; /* optional, at most one */
116 ICLINE_S *summary; /* optional, at most one */
117 ICLINE_S *transp; /* optional, at most one */
118 ICLINE_S *url; /* optional, at most one */
119 ICLINE_S *recurid; /* optional, at most one */
120 RRULE_S *rrule; /* optional, at most one */
121 ICLINE_S *dtend; /* optional, at most one, exclude duration */
122 ICLINE_S *duration; /* optional, at most one, exclude dtend */
123 GEN_ICLINE_S *attach; /* optional, may occur more than once */
124 GEN_ICLINE_S *attendee; /* optional, may occur more than once */
125 GEN_ICLINE_S *categories; /* optional, may occur more than once */
126 GEN_ICLINE_S *comment; /* optional, may occur more than once */
127 GEN_ICLINE_S *contact; /* optional, may occur more than once */
128 GEN_ICLINE_S *exdate; /* optional, may occur more than once */
129 GEN_ICLINE_S *rstatus; /* optional, may occur more than once */
130 GEN_ICLINE_S *related; /* optional, may occur more than once */
131 GEN_ICLINE_S *resources; /* optional, may occur more than once */
132 GEN_ICLINE_S *rdate; /* optional, may occur more than once */
133 #endif /* if 0 */
134 void **prop; /* the properties of an event component */
135 GEN_ICLINE_S *uk_prop; /* unknown values */
136 VALARM_S *valarm; /* possible valarm */
137 struct vevent_s *next; /* calendar of method publish has many events */
138 } VEVENT_S;
140 typedef struct vtodo_s {
141 ICLINE_S *dtstamp; /* required, at most one */
142 ICLINE_S *uid; /* required, at most one */
143 ICLINE_S *class; /* optional, at most one */
144 ICLINE_S *completed; /* optional, at most one */
145 ICLINE_S *created; /* optional, at most one */
146 ICLINE_S *description;/* optional, at most one */
147 ICLINE_S *dtstart; /* optional, at most one */
148 ICLINE_S *geo; /* optional, at most one */
149 ICLINE_S *lastmod; /* optional, at most one */
150 ICLINE_S *location; /* optional, at most one */
151 ICLINE_S *organizer; /* optional, at most one */
152 ICLINE_S *percent; /* optional, at most one */
153 ICLINE_S *priority; /* optional, at most one */
154 ICLINE_S *recurid; /* optional, at most one */
155 ICLINE_S *seq; /* optional, at most one */
156 ICLINE_S *status; /* optional, at most one */
157 ICLINE_S *summary; /* optional, at most one */
158 ICLINE_S *url; /* optional, at most one */
159 RRULE_S *rrule; /* optional, at most one */
160 ICLINE_S *due; /* optional, at most one, but exclude duration */
161 ICLINE_S *duration; /* optional, at most one, but exclude due, and add dtstart */
162 ICLINE_S *attach; /* optional, can appear more than once */
163 ICLINE_S *attendee; /* optional, can appear more than once */
164 ICLINE_S *categories; /* optional, can appear more than once */
165 ICLINE_S *comment; /* optional, can appear more than once */
166 ICLINE_S *contact; /* optional, can appear more than once */
167 ICLINE_S *exdate; /* optional, can appear more than once */
168 ICLINE_S *rstatus; /* optional, can appear more than once */
169 ICLINE_S *related; /* optional, can appear more than once */
170 ICLINE_S *resources; /* optional, can appear more than once */
171 ICLINE_S *rdate; /* optional, can appear more than once */
172 ICAL_PARAMETER_S *unknown; /* unknown values */
173 VALARM_S *valarm; /* optional valarm */
174 } VTODO_S;
176 typedef struct journal_s {
177 ICLINE_S *dtstamp; /* required, at most one */
178 ICLINE_S *uid; /* required, at most one */
179 ICLINE_S *class; /* optional, at most one */
180 ICLINE_S *created; /* optional, at most one */
181 ICLINE_S *dtstart; /* optional, at most one */
182 ICLINE_S *lastmod; /* optional, at most one */
183 ICLINE_S *organizer; /* optional, at most one */
184 ICLINE_S *recurid; /* optional, at most one */
185 ICLINE_S *seq; /* optional, at most one */
186 ICLINE_S *status; /* optional, at most one */
187 ICLINE_S *summary; /* optional, at most one */
188 ICLINE_S *url; /* optional, at most one */
189 RRULE_S *rrule; /* optional, at most one */
190 ICLINE_S *attach; /* optional, may occur more than once */
191 ICLINE_S *attendee; /* optional, may occur more than once */
192 ICLINE_S *categories; /* optional, may occur more than once */
193 ICLINE_S *comment; /* optional, may occur more than once */
194 ICLINE_S *contact; /* optional, may occur more than once */
195 ICLINE_S *description;/* optional, may occur more than once */
196 ICLINE_S *exdate; /* optional, may occur more than once */
197 ICLINE_S *related; /* optional, may occur more than once */
198 ICLINE_S *rdate; /* optional, may occur more than once */
199 ICLINE_S *rstatus; /* optional, may occur more than once */
200 ICAL_PARAMETER_S *unknown; /* unknown values */
201 } VJOURNAL_S;
203 typedef struct freebusy_s {
204 ICLINE_S *dtstamp; /* required, at most one */
205 ICLINE_S *uid; /* required, at most one */
206 ICLINE_S *contact; /* optional, at most one */
207 ICLINE_S *dtstart; /* optional, at most one */
208 ICLINE_S *dtend; /* optional, at most one */
209 ICLINE_S *organizer; /* optional, at most one */
210 ICLINE_S *url; /* optional, at most one */
211 ICLINE_S *attendee; /* optional, may appear more than oncece */
212 ICLINE_S *comment; /* optional, may appear more than oncece */
213 ICLINE_S *freebusy; /* optional, may appear more than oncece */
214 ICLINE_S *rstatus; /* optional, may appear more than once */
215 ICAL_PARAMETER_S *unknown; /* unknown values */
216 } VFREEBUSY_S;
218 typedef struct ical_tzprop_s {
219 #if 0
220 struct tm dtstart; /* required, at most one */
221 int tzoffsetto; /* required, at most one */
222 int tzoffsetfrom; /* required, at most one */
223 RRULE_S *rrule; /* optional, at most one */
224 GEN_ICLINE_S *comment; /* optional, may appear more than once */
225 GEN_ICLINE_S *rdate; /* optional, may appear more than once */
226 GEN_ICLINE_S *tzname; /* optional, may appear more than once */
227 #endif /* if 0 */
228 void **prop; /* the bunch of timezone properties */
229 GEN_ICLINE_S *uk_prop; /* optional, may appear more than once */
230 struct ical_tzprop_s *next;
231 } ICAL_TZPROP_S;
233 typedef struct vtimezone_s {
234 #if 0
235 ICLINE_S *tzid; /* required, at most one */
236 ICLINE_S *last_mod; /* optional, at most one */
237 ICLINE_S *tzurl; /* optional, at most one */
238 #endif /* if 0 */
239 void **prop; /* array of timezone properties */
240 ICAL_TZPROP_S *standardc; /* optional, may appear more than once */
241 ICAL_TZPROP_S *daylightc; /* optional, may appear more than once */
242 GEN_ICLINE_S *uk_prop; /* optional, may appear more than once */
243 } VTIMEZONE_S;
245 typedef struct vcalendar_s {
246 ICLINE_S *prodid; /* required, at most one */
247 ICLINE_S *version; /* required, at most one */
248 ICLINE_S *calscale; /* optional, at most one */
249 ICLINE_S *method; /* optional, at most one */
250 GEN_ICLINE_S *uk_prop;/* in case there is an unknown property */
251 void **comp; /* an array with the components of a calendar */
252 ICAL_S *uk_comp; /* in case there is an unknown component */
253 unsigned short encoding; /* save the original encoding. */
254 } VCALENDAR_S;
257 typedef enum {Individual, Group, Resource, Room, CUUnknown} CUType;
258 typedef enum {EventNeedsAction, EventAccepted, EventDeclined, EventTentative,
259 EventDelegated, EventUnknown,
260 TodoNeedsAction, TodoAccepted, TodoDeclined, TodoTentative,
261 TodoDelegated, TodoCompleted, TodoInProgress, TodoUnknown,
262 JournalNeedsAction, JournalAccepted, JournalDeclined,
263 JournalUnknown} PartStat;
264 typedef enum {RelBegin, RelEnd, RelUnknown} Related;
265 typedef enum {Parent, Child, Sibling} RelType;
266 typedef enum {ReqPart, Chair, OptPart, NonPart, RoleUnknown} Role;
267 typedef enum {RSVPFalse, RSVPTrue, RSVPUnknown} RSVP;
268 typedef enum {Binary, _Boolean, CalAddress, Date, DateTime, _Duration,
269 Float, Integer, Period, Recur, _Text, Time, Uri,
270 UtcOffset, ValueUnknown} Value;
272 typedef struct icalpar_s {
273 ICLINE_S *altrep; /* altrep uri, inside dquote RFC 2392, RFC 2616 and RFC 2818 */
274 ICLINE_S *cn; /* common name */
275 CUType cutype; /* calendar user type: individual, group, resource, room, unknown */
276 ADDRESS *delegated_from; /* person(s) who delegated their participation */
277 ADDRESS *delegated_to; /* person that was delegated participation */
278 ICLINE_S *dir; /* reference to a directory entry associated with the calendar user specified by the property. */
279 unsigned short encoding; /* encoding, either 8bit or base64 */
280 unsigned short type; /* type for FMTTYPE */
281 ICLINE_S *subtype; /* subtype for FMTTYPE */
282 ICLINE_S *fbtype; /* FreeBusy type */
283 ICLINE_S *language; /* language */
284 ADDRESS *member; /* group or list membership of the calendar user specified by the property */
285 PartStat partstat; /* participation status for the calendar user specified by the property. */
286 ICLINE_S *range; /* this and future */
287 Related related; /* relationship of the alarm trigger with respect to the start or end of the calendar component. */
288 RelType reltype; /* type of hierarchical relationship associated with the calendar component specified by the property. */
289 Role role; /* participation role for the calendar user specified by the property. */
290 RSVP rsvp; /* whether there is an expectation of a favor of a reply from the calendar user specified by the property value. */
291 ADDRESS *sentby; /* the calendar user that is acting on behalf of the calendar user specified by the property. */
292 ICLINE_S *tzid; /* the identifier for the time zone definition for a time component in the property value. */
293 Value value; /* specify the value type format for a property value. */
294 } ICALPAR_S;
296 typedef struct ical_duration_s {
297 unsigned sign:1; /* sign = 0 for positive, sign = 1 for negative */
298 unsigned weeks;
299 unsigned days;
300 unsigned hours;
301 unsigned minutes;
302 unsigned seconds;
303 struct ical_duration_s *next; /* another duration */
304 } ICAL_DURATION_S;
306 /* altrepparam = "ALTREP" "=" DQUOTE uri DQUOTE
307 * cnparam = "CN" "=" param-value
308 * cutypeparam = "CUTYPE" "="
309 ("INDIVIDUAL" ; An individual
310 / "GROUP" ; A group of individuals
311 / "RESOURCE" ; A physical resource
312 / "ROOM" ; A room resource
313 / "UNKNOWN" ; Otherwise not known
314 / x-name ; Experimental type
315 / iana-token) ; Other IANA-registered
316 ; type
317 * delfromparam = "DELEGATED-FROM" "=" DQUOTE cal-address
318 DQUOTE *("," DQUOTE cal-address DQUOTE)
320 * deltoparam = "DELEGATED-TO" "=" DQUOTE cal-address DQUOTE
321 *("," DQUOTE cal-address DQUOTE)
323 * dirparam = "DIR" "=" DQUOTE uri DQUOTE
325 * encodingparam = "ENCODING" "="
326 ( "8BIT"
327 ; "8bit" text encoding is defined in [RFC2045]
328 / "BASE64"
329 ; "BASE64" binary encoding format is defined in [RFC4648]
331 * fmttypeparam = "FMTTYPE" "=" type-name "/" subtype-name
332 ; Where "type-name" and "subtype-name" are
333 ; defined in Section 4.2 of [RFC4288].
335 * fbtypeparam = "FBTYPE" "=" ("FREE" / "BUSY"
336 / "BUSY-UNAVAILABLE" / "BUSY-TENTATIVE"
337 / x-name
338 ; Some experimental iCalendar free/busy type.
339 / iana-token)
340 ; Some other IANA-registered iCalendar free/busy type.
342 * languageparam = "LANGUAGE" "=" language
344 language = Language-Tag
345 ; As defined in [RFC5646].
347 * memberparam = "MEMBER" "=" DQUOTE cal-address DQUOTE
348 *("," DQUOTE cal-address DQUOTE)
350 * partstatparam = "PARTSTAT" "="
351 (partstat-event
352 / partstat-todo
353 / partstat-jour)
355 partstat-event = ("NEEDS-ACTION" ; Event needs action
356 / "ACCEPTED" ; Event accepted
357 / "DECLINED" ; Event declined
358 / "TENTATIVE" ; Event tentatively
359 ; accepted
360 / "DELEGATED" ; Event delegated
361 / x-name ; Experimental status
362 / iana-token) ; Other IANA-registered
363 ; status
364 ; These are the participation statuses for a "VEVENT".
365 ; Default is NEEDS-ACTION.
367 partstat-todo = ("NEEDS-ACTION" ; To-do needs action
368 / "ACCEPTED" ; To-do accepted
369 / "DECLINED" ; To-do declined
370 / "TENTATIVE" ; To-do tentatively
371 ; accepted
372 / "DELEGATED" ; To-do delegated
373 / "COMPLETED" ; To-do completed
374 ; COMPLETED property has
375 ; DATE-TIME completed
376 / "IN-PROCESS" ; To-do in process of
377 ; being completed
378 / x-name ; Experimental status
379 / iana-token) ; Other IANA-registered
380 ; status
381 ; These are the participation statuses for a "VTODO".
382 ; Default is NEEDS-ACTION.
386 partstat-jour = ("NEEDS-ACTION" ; Journal needs action
387 / "ACCEPTED" ; Journal accepted
388 / "DECLINED" ; Journal declined
389 / x-name ; Experimental status
390 / iana-token) ; Other IANA-registered
391 ; status
392 ; These are the participation statuses for a "VJOURNAL".
393 ; Default is NEEDS-ACTION.
395 * rangeparam = "RANGE" "=" "THISANDFUTURE"
396 ; To specify the instance specified by the recurrence identifier
397 ; and all subsequent recurrence instances.
399 * trigrelparam = "RELATED" "="
400 ("START" ; Trigger off of start
401 / "END") ; Trigger off of end
403 * reltypeparam = "RELTYPE" "="
404 ("PARENT" ; Parent relationship - Default
405 / "CHILD" ; Child relationship
406 / "SIBLING" ; Sibling relationship
407 / iana-token ; Some other IANA-registered
408 ; iCalendar relationship type
409 / x-name) ; A non-standard, experimental
410 ; relationship type
412 * roleparam = "ROLE" "="
413 ("CHAIR" ; Indicates chair of the
414 ; calendar entity
415 / "REQ-PARTICIPANT" ; Indicates a participant whose
416 ; participation is required
417 / "OPT-PARTICIPANT" ; Indicates a participant whose
418 ; participation is optional
419 / "NON-PARTICIPANT" ; Indicates a participant who
420 ; is copied for information
421 ; purposes only
422 / x-name ; Experimental role
423 / iana-token) ; Other IANA role
424 ; Default is REQ-PARTICIPANT
426 * rsvpparam = "RSVP" "=" ("TRUE" / "FALSE")
427 ; Default is FALSE
429 * sentbyparam = "SENT-BY" "=" DQUOTE cal-address DQUOTE
431 * tzidparam = "TZID" "=" [tzidprefix] paramtext
433 tzidprefix = "/"
437 typedef struct vevent_summary_s {
438 int cancel:1;
439 int priority;
440 char *class;
441 char *summary;
442 char *sender;
443 char *organizer;
444 char *location;
445 char *evstart;
446 char *evend;
447 char *dtstamp;
448 char **duration;
449 char **attendee;
450 unsigned char *description;
451 struct vevent_summary_s *next;
452 } VEVENT_SUMMARY_S;
454 typedef enum {VCalendar = 0, VTimeZone, VEvent, VTodo, VJournal,
455 VAlarm, VFreeBusy, VUnknown} Cal_comp;
457 typedef enum {EvDtstamp = 0, EvUid, EvDtstart, EvClass, EvCreated,
458 EvDescription, EvGeo, EvLastMod, EvLocation,
459 EvOrganizer, EvPriority, EvSequence, EvStatus,
460 EvSummary, EvTransp, EvUrl, EvRecurrence, EvRrule,
461 EvDtend, EvDuration, EvAttach, EvAttendee, EvCategories,
462 EvComment, EvContact, EvExdate, EvRstatus, EvRelated,
463 EvResources, EvRdate,
464 EvUnknown} Event_prop;
466 typedef enum {TZCid = 0, TZCLastMod, TZCUrl, TZCUnknown} TZ_comp;
468 typedef enum {TZPDtstart = 0, TZPOffsetto, TZPOffsetfrom,
469 TZPRrule, TZPComment, TZPRdate, TZPTzname, TZPUnknown} TZ_prop;
471 typedef enum {AlAction = 0, AlTrigger, AlDuration, AlRepeat,
472 AlDescription, AlSummary, AlAttach, AlAttendee,
473 AlUnknown} Alarm_prop;
475 typedef enum {RRFreq, RRUntil, RRCount, RRInterval,
476 RRBysecond, RRByminute, RRByhour, RRByday,
477 RRByweekno, RRBymonth, RRBysetpos, RRWkst,
478 RRBymonthday, RRByyearday,
479 RRUnknown} RRule_prop;
481 #endif /* ifndef ICALTYPE_INCLUDED */