|
|
tical.h - ics2txt - convert icalendar .ics file to plain text |
|
|
 |
git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ics2txt (git://bitreich.org) |
|
|
 |
Log |
|
|
 |
Files |
|
|
 |
Refs |
|
|
 |
Tags |
|
|
 |
README |
|
|
|
--- |
|
|
|
tical.h (1806B) |
|
|
|
--- |
|
|
|
1 #ifndef ICAL_H |
|
|
|
2 #define ICAL_H |
|
|
|
3 |
|
|
|
4 #include <stdio.h> |
|
|
|
5 #include <time.h> |
|
|
|
6 |
|
|
|
7 #include "map.h" |
|
|
|
8 |
|
|
|
9 #define ICAL_NESTED_MAX 4 |
|
|
|
10 |
|
|
|
11 enum ical_err { |
|
|
|
12 ICAL_ERR_OK, |
|
|
|
13 ICAL_ERR_SYSTEM, |
|
|
|
14 ICAL_ERR_END_MISMATCH, |
|
|
|
15 ICAL_ERR_MISSING_BEGIN, |
|
|
|
16 ICAL_ERR_MISSING_COLUMN, |
|
|
|
17 ICAL_ERR_MISSING_SEMICOLUMN, |
|
|
|
18 ICAL_ERR_MISSING_EQUAL, |
|
|
|
19 ICAL_ERR_MIN_NESTED, |
|
|
|
20 ICAL_ERR_MAX_NESTED, |
|
|
|
21 |
|
|
|
22 ICAL_ERR_LENGTH, |
|
|
|
23 }; |
|
|
|
24 |
|
|
|
25 /* global propoerties for an iCalendar document as well as parsing state */ |
|
|
|
26 |
|
|
|
27 struct ical_vcalendar { |
|
|
|
28 time_t tzid; |
|
|
|
29 struct ical_vnode *root; |
|
|
|
30 struct ical_vnode *nested[ICAL_NESTED_MAX + 1]; |
|
|
|
31 struct ical_vnode *current; |
|
|
|
32 }; |
|
|
|
33 |
|
|
|
34 /* element part of an iCalendar document with eventual nested childs */ |
|
|
|
35 |
|
|
|
36 struct ical_vnode { |
|
|
|
37 char name[32]; |
|
|
|
38 struct map values; /*(struct ical_value *)*/ |
|
|
|
39 struct map childs; /*(struct ical_vnode *)*/ |
|
|
|
40 struct ical_vnode *next; |
|
|
|
41 }; |
|
|
|
42 |
|
|
|
43 /* one line whith the whole content unfolded */ |
|
|
|
44 |
|
|
|
45 struct ical_value { |
|
|
|
46 char *name, *value; |
|
|
|
47 struct map param; |
|
|
|
48 struct ical_value *next; |
|
|
|
49 char buf[]; |
|
|
|
50 }; |
|
|
|
51 |
|
|
|
52 /** src/ical.c **/ |
|
|
|
53 int ical_getline(char **line, char **ln, size_t *sz, FILE *fp); |
|
|
|
54 char * ical_strerror(int i); |
|
|
|
55 struct ical_value * ical_new_value(char const *line); |
|
|
|
56 void ical_free_value(struct ical_value *value); |
|
|
|
57 int ical_parse_value(struct ical_value *value); |
|
|
|
58 struct ical_vnode * ical_new_vnode(char const *name); |
|
|
|
59 void ical_free_vnode(struct ical_vnode *node); |
|
|
|
60 int ical_push_nested(struct ical_vcalendar *vcal, struct ical_vnode *new); |
|
|
|
61 struct ical_vnode * ical_pop_nested(struct ical_vcalendar *vcal); |
|
|
|
62 int ical_begin_vnode(struct ical_vcalendar *vcal, char const *name); |
|
|
|
63 int ical_end_vnode(struct ical_vcalendar *vcal, char const *name); |
|
|
|
64 int ical_push_value(struct ical_vcalendar *vcal, struct ical_value *new); |
|
|
|
65 void ical_free_vcalendar(struct ical_vcalendar *vcal); |
|
|
|
66 int ical_read_vcalendar(struct ical_vcalendar *vcal, FILE *fp); |
|
|
|
67 |
|
|
|
68 #endif |
|