2 /*======================================================================
4 CREATOR: eric 20 April 1999
9 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of either:
14 The LGPL as published by the Free Software Foundation, version
15 2.1, available at: http://www.fsf.org/copyleft/lesser.html
19 The Mozilla Public License Version 1.0. You may obtain a copy of
20 the License at http://www.mozilla.org/MPL/
22 The original code is icalparser.h
24 ======================================================================*/
30 #include "icalenums.h"
31 #include "icaltypes.h"
32 #include"icalcomponent.h"
34 #include <stdio.h> /* For FILE* */
36 typedef void* icalparser;
39 /***********************************************************************
40 * Line-oriented parsing.
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 ***********************************************************************/
47 typedef enum icalparser_state {
50 ICALPARSER_BEGIN_COMP,
52 ICALPARSER_IN_PROGRESS
55 icalparser* icalparser_new(void);
56 icalcomponent* icalparser_add_line(icalparser* parser, char* str );
57 icalcomponent* icalparser_clean(icalparser* parser);
58 icalparser_state icalparser_get_state(icalparser* parser);
59 void icalparser_free(icalparser* parser);
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 **********************************************************************/
69 icalcomponent* icalparser_parse(icalparser *parser,
70 char* (*line_gen_func)(char *s, size_t size, void *d));
72 /* Set the data that icalparser_parse will give to the line_gen_func
73 as the parameter 'd'*/
74 void icalparser_set_gen_data(icalparser* parser, void* data);
77 icalcomponent* icalparser_parse_string(const char* str);
80 /***********************************************************************
81 * Parser support functions
82 ***********************************************************************/
84 /* Use the flex/bison parser to turn a string into a value type */
85 icalvalue* icalparser_parse_value(icalvalue_kind kind,
86 const char* str, icalcomponent** errors);
88 /* Given a line generator function, return a single iCal content line.*/
89 char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
91 char* string_line_generator(char *out, size_t buf_size, void *d);
93 #endif /* !ICALPARSE_H */