]> diplodocus.org Git - nmh/blob - h/icalendar.h
Makefile.am: Add test/inc/test-eom-align to XFAIL_TESTS.
[nmh] / h / icalendar.h
1 /* icalendar.h -- data structures and common code for icalendar scanner,
2 * parser, and application code
3 *
4 * This code is Copyright (c) 2014, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
7 */
8
9 /*
10 * Types used in struct contentline below.
11 */
12 typedef struct value_list {
13 char *value;
14 struct value_list *next;
15 } value_list;
16
17 typedef struct param_list {
18 char *param_name; /* Name of property parameter. */
19 struct value_list *values; /* List of its values. */
20 struct param_list *next; /* Next node in list of property parameters. */
21 } param_list;
22
23 typedef enum cr_indicator {
24 CR_UNSET = 0,
25 LF_ONLY,
26 CR_BEFORE_LF
27 } cr_indicator;
28
29 /*
30 * Each (unfolded) line in the .ics file is represented by a struct
31 * contentline.
32 */
33 typedef struct contentline {
34 char *name; /* The name of the property, calprops,
35 or BEGIN. */
36 struct param_list *params; /* List parameters. */
37 char *value; /* Everything after the ':'. */
38
39 char *input_line; /* The (unfolded) input line. */
40 size_t input_line_len; /* Amount of text stored in input_line. */
41 size_t input_line_size; /* Size of allocated input_line. */
42
43 cr_indicator cr_before_lf; /* To support CR before LF. If the first
44 line of the input has a CR before its LF,
45 assume that all output lines need to.
46 Only used in root node. */
47
48 struct contentline *next; /* Next node in list of content lines. */
49 struct contentline *last; /* Last node of list. Only used in root node. */
50 } contentline;
51
52
53 /*
54 * List of vevents, each of which is a list of contentlines.
55 */
56 typedef struct vevent {
57 contentline *contentlines;
58 struct vevent *next;
59 /* The following is only used in the root node. */
60 struct vevent *last;
61 } vevent;
62
63
64 /*
65 * Exported functions.
66 */
67 void remove_contentline (contentline *);
68 contentline *add_contentline (contentline *, const char *);
69 void add_param_name (contentline *, char *);
70 void add_param_value (contentline *, char *);
71 void remove_value (value_list *);
72 struct contentline *find_contentline (contentline *, const char *,
73 const char *);
74 void free_contentlines (contentline *);
75
76 typedef struct tzdesc *tzdesc_t;
77 tzdesc_t load_timezones (const contentline *);
78 void free_timezones (tzdesc_t);
79 char *format_datetime (tzdesc_t, const contentline *);
80
81 /*
82 * The following provide access to, and by, the iCalendar parser.
83 */
84
85 /* This YYSTYPE definition prevents problems with Solaris yacc, which
86 has declarations of two variables of type YYSTYPE * in one
87 statement. */
88 typedef char *charptr;
89 #define YYSTYPE charptr
90
91 extern int icaldebug;
92 int icalparse (void);
93 extern vevent vevents;
94 int icallex (void);
95
96 /* And this is for the icalendar scanner. */
97 extern YYSTYPE icallval;
98
99 /*
100 * For directing the scanner to use a files other than stdin/stdout.
101 * These don't use the accessors provided by modern flex because
102 * flex 2.5.4 doesn't supply them.
103 */
104 void icalset_inputfile (FILE *);
105 void icalset_outputfile (FILE *);