Libical API Documentation 3.0
|
Line-oriented parsing. More...
Go to the source code of this file.
Typedefs | |
typedef struct icalparser_impl | icalparser |
typedef char *(* | icalparser_line_gen_func) (char *s, size_t size, void *d) |
typedef enum icalparser_state | icalparser_state |
Enumerations | |
enum | icalparser_ctrl { ICALPARSER_CTRL_KEEP , ICALPARSER_CTRL_OMIT , ICALPARSER_CTRL_ERROR } |
Defines how to handle invalid CONTROL characters in content lines. More... | |
enum | icalparser_state { ICALPARSER_ERROR , ICALPARSER_SUCCESS , ICALPARSER_BEGIN_COMP , ICALPARSER_END_COMP , ICALPARSER_IN_PROGRESS } |
Represents the current state of the parser. More... | |
Functions | |
icalcomponent * | icalparser_add_line (icalparser *parser, char *str) |
Adds a single line to be parsed by the icalparser. | |
icalcomponent * | icalparser_clean (icalparser *parser) |
Cleans out an icalparser and returns whatever it has parsed so far. | |
void | icalparser_free (icalparser *parser) |
Frees an icalparser object. | |
enum icalparser_ctrl | icalparser_get_ctrl (void) |
Get the current parser setting how to handle CONTROL characters. | |
char * | icalparser_get_line (icalparser *parser, icalparser_line_gen_func line_gen_func) |
Given a line generator function, returns a single iCal content line. | |
icalparser_state | icalparser_get_state (icalparser *parser) |
Returns current state of the icalparser. | |
icalparser * | icalparser_new (void) |
Creates a new icalparser. | |
icalcomponent * | icalparser_parse (icalparser *parser, icalparser_line_gen_func line_gen_func) |
Message oriented parsing. | |
icalcomponent * | icalparser_parse_string (const char *str) |
Parses a string and returns the parsed icalcomponent. | |
void | icalparser_set_ctrl (enum icalparser_ctrl ctrl) |
Set the parser setting how to handle CONTROL characters. | |
void | icalparser_set_gen_data (icalparser *parser, void *data) |
Sets the data that icalparser_parse will give to the line_gen_func as the parameter 'd'. | |
char * | icalparser_string_line_generator (char *out, size_t buf_size, void *d) |
Line-oriented parsing.
This file provides methods to parse iCalendar-formatted data into the structures provided by this library.
Implementation of the icalparser struct, which holds the state for the current parsing operation.
enum icalparser_ctrl |
enum icalparser_state |
Represents the current state of the parser.
icalcomponent * icalparser_add_line | ( | icalparser * | parser, |
char * | str | ||
) |
Adds a single line to be parsed by the icalparser.
parser | The parser to use |
str | A string representing a single line of RFC5545-formatted iCalendar data |
NULL
. NULL
, it returns NULL
and sets icalerrno to ICAL_BADARG_ERROR.NULL
NULL
, it returns NULL
and sets the parser's icalparser_state to ICALPARSER_ERROR.free()
d with the appropriate method after it's no longer needed.icalcomponent * icalparser_clean | ( | icalparser * | parser | ) |
Cleans out an icalparser and returns whatever it has parsed so far.
parser | The icalparser to clean |
NULL
, it returns NULL
and sets icalerrno to ICAL_BADARG_ERROR. For parsing errors, it inserts an X-LIC-ERROR
property into the affected components.This will parse components even if it hasn't encountered a proper END
tag for it yet and return them, as well as clearing any intermediate state resulting from being in the middle of parsing something so the parser can be used to parse something new.
void icalparser_free | ( | icalparser * | parser | ) |
Frees an icalparser object.
parser | The icalparser to be freed. |
enum icalparser_ctrl icalparser_get_ctrl | ( | void | ) |
Get the current parser setting how to handle CONTROL characters.
char * icalparser_get_line | ( | icalparser * | parser, |
icalparser_line_gen_func | line_gen_func | ||
) |
Given a line generator function, returns a single iCal content line.
NULL
if it reached end of file reading from the line_gen_func. Note that the pointer returned is owned by libical and must not be free()
d by the user. parser | The parser object to use |
line_gen_func | The function to use for reading data |
This function uses the supplied line_gen_func to read data in, until it has read a full line, and returns the full line. It includes any continuation lines, which start with a space after a newline. To supply arbitrary data (as the parameter d) to your line_gen_func, call icalparser_set_gen_data().
icalparser_state icalparser_get_state | ( | icalparser * | parser | ) |
Returns current state of the icalparser.
parser | The (valid, non-NULL ) parser object |
icalparser_free(parser);
icalparser * icalparser_new | ( | void | ) |
Creates a new icalparser.
NULL
and sets icalerrno to ICAL_NEWFAILED_ERROR.icalcomponent * icalparser_parse | ( | icalparser * | parser, |
icalparser_line_gen_func | line_gen_func | ||
) |
Message oriented parsing.
parser | The parser to use |
line_gen_func | A function that returns one content line per invocation |
Reads an icalcomponent using the supplied line_gen_func, returning the parsed component (or NULL
on error).
NULL
, it returns NULL
and sets icalerrno to ICAL_BADARG_ERROR.NULL
NULL
, it returns NULL
and sets the parser's icalparser_state to ICALPARSER_ERROR.free()
d with the appropriate method when no longer needed.icalcomponent * icalparser_parse_string | ( | const char * | str | ) |
Parses a string and returns the parsed icalcomponent.
str | The iCal formatted data to be parsed |
NULL
and sets icalerrnovoid icalparser_set_ctrl | ( | enum icalparser_ctrl | ctrl | ) |
Set the parser setting how to handle CONTROL characters.
ctrl | The setting to use |
void icalparser_set_gen_data | ( | icalparser * | parser, |
void * | data | ||
) |
Sets the data that icalparser_parse will give to the line_gen_func as the parameter 'd'.
parser | The icalparser this applies to |
data | The pointer which will be passed to the line_gen_func as argument d |
If you use any of the icalparser_parser() or icalparser_get_line() functions, the line_gen_func that they expect has a third void *d
argument. This function sets what will be passed to your line_gen_function as such argument.