]> diplodocus.org Git - nmh/blob - h/icalendar.h
Fix file descriptor leak in ruserpass()
[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 charstring_t unexpected; /* Accumulate unexpected characters in input. */
43
44 cr_indicator cr_before_lf; /* To support CR before LF. If the first
45 line of the input has a CR before its LF,
46 assume that all output lines need to.
47 Only used in root node. */
48
49 struct contentline *next; /* Next node in list of content lines. */
50 struct contentline *last; /* Last node of list. Only used in root node. */
51 } contentline;
52
53
54 /*
55 * List of vevents, each of which is a list of contentlines.
56 */
57 typedef struct vevent {
58 contentline *contentlines;
59 struct vevent *next;
60 /* The following is only used in the root node. */
61 struct vevent *last;
62 } vevent;
63
64
65 /*
66 * Exported functions.
67 */
68 void remove_contentline (contentline *);
69 contentline *add_contentline (contentline *, const char *);
70 void add_param_name (contentline *, char *);
71 void add_param_value (contentline *, char *);
72 void remove_value (value_list *);
73 struct contentline *find_contentline (contentline *, const char *,
74 const char *) PURE;
75 void free_contentlines (contentline *);
76
77 /*
78 * The following provide access to, and by, the iCalendar parser.
79 */
80
81 /* This YYSTYPE definition prevents problems with Solaris yacc, which
82 has declarations of two variables of type YYSTYPE * in one
83 statement. */
84 typedef char *charptr;
85 #define YYSTYPE charptr
86
87 extern int icaldebug;
88 int icalparse (void);
89 extern vevent vevents;
90 int icallex (void);
91 extern int parser_status;
92
93 /* And this is for the icalendar scanner. */
94 extern YYSTYPE icallval;
95
96 /*
97 * For directing the scanner to use files other than stdin/stdout.
98 * These don't use the accessors provided by modern flex because
99 * flex 2.5.4 doesn't supply them.
100 */
101 void icalset_inputfile (FILE *);
102 void icalset_outputfile (FILE *);