2 /*======================================================================
4 CREATOR: eric 20 April 1999
6 $Id: icalparser.h,v 1.9 2008-01-15 23:17:41 dothebart Exp $
9 (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
10 http://www.softwarestudio.org
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
23 The original code is icalparser.h
25 ======================================================================*/
31 #include "icalenums.h"
32 #include "icaltypes.h"
33 #include"icalcomponent.h"
35 #include <stdio.h> /* For FILE* */
37 typedef struct icalparser_impl icalparser;
42 * @brief Line-oriented parsing.
44 * Create a new parser via icalparse_new_parser, then add lines one at
45 * a time with icalparse_add_line(). icalparser_add_line() will return
46 * non-zero when it has finished with a component.
49 typedef enum icalparser_state {
52 ICALPARSER_BEGIN_COMP,
54 ICALPARSER_IN_PROGRESS
57 icalparser* icalparser_new(void);
58 icalcomponent* icalparser_add_line(icalparser* parser, char* str );
59 icalcomponent* icalparser_clean(icalparser* parser);
60 icalparser_state icalparser_get_state(icalparser* parser);
61 void icalparser_free(icalparser* parser);
65 * Message oriented parsing. icalparser_parse takes a string that
66 * holds the text ( in RFC 2445 format ) and returns a pointer to an
67 * icalcomponent. The caller owns the memory. line_gen_func is a
68 * pointer to a function that returns one content line per invocation
71 icalcomponent* icalparser_parse(icalparser *parser,
72 char* (*line_gen_func)(char *s, size_t size, void *d));
75 Set the data that icalparser_parse will give to the line_gen_func
78 void icalparser_set_gen_data(icalparser* parser, void* data);
81 icalcomponent* icalparser_parse_string(const char* str);
84 /***********************************************************************
85 * Parser support functions
86 ***********************************************************************/
88 /** Use the flex/bison parser to turn a string into a value type */
89 icalvalue* icalparser_parse_value(icalvalue_kind kind,
90 const char* str, icalcomponent** errors);
92 /** Given a line generator function, return a single iCal content line.*/
93 char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d));
95 char* icalparser_string_line_generator(char *out, size_t buf_size, void *d);
97 #endif /* !ICALPARSE_H */