summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/icalparser.h
Unidiff
Diffstat (limited to 'libical/src/libical/icalparser.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalparser.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/libical/src/libical/icalparser.h b/libical/src/libical/icalparser.h
new file mode 100644
index 0000000..5e1c88f
--- a/dev/null
+++ b/libical/src/libical/icalparser.h
@@ -0,0 +1,93 @@
1/* -*- Mode: C -*- */
2/*======================================================================
3 FILE: icalparser.h
4 CREATOR: eric 20 April 1999
5
6 $Id$
7
8
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
13
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
16
17 Or:
18
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
21
22 The original code is icalparser.h
23
24======================================================================*/
25
26
27#ifndef ICALPARSER_H
28#define ICALPARSER_H
29
30#include "icalenums.h"
31#include "icaltypes.h"
32#include"icalcomponent.h"
33
34#include <stdio.h> /* For FILE* */
35
36typedef void* icalparser;
37
38
39/***********************************************************************
40 * Line-oriented parsing.
41 *
42 * Create a new parser via icalparse_new_parser, then add ines one at
43 * a time with icalparse_add_line(). icalparser_add_line() will return
44 * non-zero when it has finished with a component.
45 ***********************************************************************/
46
47typedef enum icalparser_state {
48 ICALPARSER_ERROR,
49 ICALPARSER_SUCCESS,
50 ICALPARSER_BEGIN_COMP,
51 ICALPARSER_END_COMP,
52 ICALPARSER_IN_PROGRESS
53} icalparser_state;
54
55icalparser* icalparser_new(void);
56icalcomponent* icalparser_add_line(icalparser* parser, char* str );
57icalcomponent* icalparser_clean(icalparser* parser);
58icalparser_state icalparser_get_state(icalparser* parser);
59void icalparser_free(icalparser* parser);
60
61
62/***********************************************************************
63 * Message oriented parsing. icalparser_parse takes a string that
64 * holds the text ( in RFC 2445 format ) and returns a pointer to an
65 * icalcomponent. The caller owns the memory. line_gen_func is a
66 * pointer to a function that returns one content line per invocation
67 **********************************************************************/
68
69icalcomponent* icalparser_parse(icalparser *parser,
70 char* (*line_gen_func)(char *s, size_t size, void *d));
71
72/* Set the data that icalparser_parse will give to the line_gen_func
73 as the parameter 'd'*/
74void icalparser_set_gen_data(icalparser* parser, void* data);
75
76
77icalcomponent* icalparser_parse_string(const char* str);
78
79
80/***********************************************************************
81 * Parser support functions
82 ***********************************************************************/
83
84/* Use the flex/bison parser to turn a string into a value type */
85icalvalue* icalparser_parse_value(icalvalue_kind kind,
86 const char* str, icalcomponent** errors);
87
88/* Given a line generator function, return a single iCal content line.*/
89char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
90
91char* string_line_generator(char *out, size_t buf_size, void *d);
92
93#endif /* !ICALPARSE_H */