icalparser.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*======================================================================
  2. FILE: icalparser.h
  3. CREATOR: eric 20 April 1999
  4. (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
  5. http://www.softwarestudio.org
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of either:
  8. The LGPL as published by the Free Software Foundation, version
  9. 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
  10. Or:
  11. The Mozilla Public License Version 1.0. You may obtain a copy of
  12. the License at http://www.mozilla.org/MPL/
  13. The original code is icalparser.h
  14. ======================================================================*/
  15. #ifndef ICALPARSER_H
  16. #define ICALPARSER_H
  17. #include "libical_ical_export.h"
  18. #include "icalcomponent.h"
  19. typedef struct icalparser_impl icalparser;
  20. /**
  21. * @file icalparser.h
  22. * @brief Line-oriented parsing.
  23. *
  24. * Create a new parser via icalparse_new_parser, then add lines one at
  25. * a time with icalparse_add_line(). icalparser_add_line() will return
  26. * non-zero when it has finished with a component.
  27. */
  28. typedef enum icalparser_state
  29. {
  30. ICALPARSER_ERROR,
  31. ICALPARSER_SUCCESS,
  32. ICALPARSER_BEGIN_COMP,
  33. ICALPARSER_END_COMP,
  34. ICALPARSER_IN_PROGRESS
  35. } icalparser_state;
  36. LIBICAL_ICAL_EXPORT icalparser *icalparser_new(void);
  37. LIBICAL_ICAL_EXPORT icalcomponent *icalparser_add_line(icalparser *parser, char *str);
  38. LIBICAL_ICAL_EXPORT icalcomponent *icalparser_clean(icalparser *parser);
  39. LIBICAL_ICAL_EXPORT icalparser_state icalparser_get_state(icalparser *parser);
  40. LIBICAL_ICAL_EXPORT void icalparser_free(icalparser *parser);
  41. /**
  42. * Message oriented parsing. icalparser_parse takes a string that
  43. * holds the text ( in RFC 5545 format ) and returns a pointer to an
  44. * icalcomponent. The caller owns the memory. line_gen_func is a
  45. * pointer to a function that returns one content line per invocation
  46. */
  47. LIBICAL_ICAL_EXPORT icalcomponent *icalparser_parse(icalparser *parser,
  48. char *(*line_gen_func) (char *s,
  49. size_t size, void *d));
  50. /**
  51. Set the data that icalparser_parse will give to the line_gen_func
  52. as the parameter 'd'
  53. */
  54. LIBICAL_ICAL_EXPORT void icalparser_set_gen_data(icalparser *parser, void *data);
  55. LIBICAL_ICAL_EXPORT icalcomponent *icalparser_parse_string(const char *str);
  56. /***********************************************************************
  57. * Parser support functions
  58. ***********************************************************************/
  59. /** Use the flex/bison parser to turn a string into a value type */
  60. LIBICAL_ICAL_EXPORT icalvalue *icalparser_parse_value(icalvalue_kind kind,
  61. const char *str, icalcomponent ** errors);
  62. /** Given a line generator function, return a single iCal content line.*/
  63. LIBICAL_ICAL_EXPORT char *icalparser_get_line(icalparser *parser,
  64. char *(*line_gen_func) (char *s,
  65. size_t size, void *d));
  66. LIBICAL_ICAL_EXPORT char *icalparser_string_line_generator(char *out, size_t buf_size, void *d);
  67. #endif /* !ICALPARSE_H */