1 /* -*- Mode: C -*- */ 2 /*====================================================================== 3 FILE: icalparser.h 4 CREATOR: eric 20 April 1999 5 6 $Id: icalparser.h,v 1.9 2008-01-15 23:17:41 dothebart Exp $ 7 8 9 (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org> 10 http://www.softwarestudio.org 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of either: 14 15 The LGPL as published by the Free Software Foundation, version 16 2.1, available at: http://www.fsf.org/copyleft/lesser.html 17 18 Or: 19 20 The Mozilla Public License Version 1.0. You may obtain a copy of 21 the License at http://www.mozilla.org/MPL/ 22 23 The original code is icalparser.h 24 25 ======================================================================*/ 26 27 28 #ifndef ICALPARSER_H 29 #define ICALPARSER_H 30 31 #include "icalenums.h" 32 #include "icaltypes.h" 33 #include"icalcomponent.h" 34 35 #include <stdio.h> /* For FILE* */ 36 37 typedef struct icalparser_impl icalparser; 38 39 40 /** 41 * @file icalparser.h 42 * @brief Line-oriented parsing. 43 * 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. 47 */ 48 49 typedef enum icalparser_state { 50 ICALPARSER_ERROR, 51 ICALPARSER_SUCCESS, 52 ICALPARSER_BEGIN_COMP, 53 ICALPARSER_END_COMP, 54 ICALPARSER_IN_PROGRESS 55 } icalparser_state; 56 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); 62 63 64 /** 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 69 */ 70 71 icalcomponent* icalparser_parse(icalparser *parser, 72 char* (*line_gen_func)(char *s, size_t size, void *d)); 73 74 /** 75 Set the data that icalparser_parse will give to the line_gen_func 76 as the parameter 'd' 77 */ 78 void icalparser_set_gen_data(icalparser* parser, void* data); 79 80 81 icalcomponent* icalparser_parse_string(const char* str); 82 83 84 /*********************************************************************** 85 * Parser support functions 86 ***********************************************************************/ 87 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); 91 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)); 94 95 char* icalparser_string_line_generator(char *out, size_t buf_size, void *d); 96 97 #endif /* !ICALPARSE_H */ 98