ne_xml.h | ne_xml.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
#include "ne_defs.h" | #include "ne_defs.h" | |||
BEGIN_NEON_DECLS | BEGIN_NEON_DECLS | |||
/* The neon XML interface filters a streamed XML tree through a stack | /* The neon XML interface filters a streamed XML tree through a stack | |||
* of SAX "handlers". A handler is made up of three callbacks | * of SAX "handlers". A handler is made up of three callbacks | |||
* (start-element, char-data, end-element). Each start-element event | * (start-element, char-data, end-element). Each start-element event | |||
* is passed to each handler in the stack in turn until one until one | * is passed to each handler in the stack in turn until one until one | |||
* accepts the element. This handler then receives subsequent | * accepts the element. This handler then receives subsequent | |||
* char-data and end-element events. | * char-data and end-element events for the element. | |||
* | * | |||
* For each new start-element, the search up the handler stack begins | * For each new start-element event, the search up the handler stack | |||
* with the handler for the parent element (for the root element, at | * begins with the handler for the parent element (for the root | |||
* the base of the stack). | * element, at the base of the stack). | |||
* | * | |||
* For each accepted element, a "state" integer is stored, which is | * For each accepted element, a "state" integer is stored, which is | |||
* passed to the corresponding char-data and end-element callbacks for | * passed to the corresponding char-data and end-element callbacks for | |||
* the element. This integer is also passed to the start-element | * the element. This integer is also passed to the start-element | |||
* callback of child elements so they can determine context. | * callback of child elements so they can determine context. | |||
* | * | |||
* If no handler in the stack accepts a particular element, it (and | * If no handler in the stack accepts a particular element, it (and | |||
* its children, if any) is ignored. */ | * its children, if any) is ignored. */ | |||
#define NE_XML_DECLINE (0) | #define NE_XML_DECLINE (0) | |||
#define NE_XML_ABORT (-1) | #define NE_XML_ABORT (-1) | |||
/* The startelm callback may return: | /* A start-element callback for element with given namespace/name. | |||
* <0 => abort the parse (NE_XML_ABORT) | * The callback may return: | |||
* 0 => decline this element (NE_XML_DECLINE) | * <0 => abort the parse (NE_XML_ABORT) | |||
* >0 => accept this element; value is state for this element. | * 0 => decline this element (NE_XML_DECLINE) | |||
* >0 => accept this element; value is state for this element. | ||||
* | ||||
* The 'parent' integer is the state returned by the handler of the | * The 'parent' integer is the state returned by the handler of the | |||
* parent element. */ | * parent element. The attributes array gives name/value pairs | |||
* in atts[n] and atts[n+1] from n=0 up to atts[n]==NULL. */ | ||||
typedef int ne_xml_startelm_cb(void *userdata, int parent, | typedef int ne_xml_startelm_cb(void *userdata, int parent, | |||
const char *nspace, const char *name, | const char *nspace, const char *name, | |||
const char **atts); | const char **atts); | |||
/* state for the root element */ | /* state for the root element */ | |||
#define NE_XML_STATEROOT (0) | #define NE_XML_STATEROOT (0) | |||
/* Character data callback; may return non-zero to abort the parse. */ | /* Character data callback; may return non-zero to abort the parse. */ | |||
typedef int ne_xml_cdata_cb(void *userdata, int state, | typedef int ne_xml_cdata_cb(void *userdata, int state, | |||
const char *cdata, size_t len); | const char *cdata, size_t len); | |||
skipping to change at line 105 | skipping to change at line 108 | |||
* to be NUL-terminated. */ | * to be NUL-terminated. */ | |||
void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len); | void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len); | |||
/* As above, casting (ne_xml_parser *)userdata internally. | /* As above, casting (ne_xml_parser *)userdata internally. | |||
* (This function can be passed to ne_add_response_body_reader) */ | * (This function can be passed to ne_add_response_body_reader) */ | |||
void ne_xml_parse_v(void *userdata, const char *block, size_t len); | void ne_xml_parse_v(void *userdata, const char *block, size_t len); | |||
/* Return current parse line for errors */ | /* Return current parse line for errors */ | |||
int ne_xml_currentline(ne_xml_parser *p); | int ne_xml_currentline(ne_xml_parser *p); | |||
/* Set error message for parser */ | /* Set error string for parser. */ | |||
void ne_xml_set_error(ne_xml_parser *p, const char *msg); | void ne_xml_set_error(ne_xml_parser *p, const char *msg); | |||
/* Return the error string for the parser and never NULL. */ | ||||
const char *ne_xml_get_error(ne_xml_parser *p); | const char *ne_xml_get_error(ne_xml_parser *p); | |||
/* From a start_element callback which was passed 'attrs' using given | /* From a start_element callback which was passed 'attrs' using given | |||
* parser, return attribute of given name and namespace. If nspace is | * parser, return attribute of given name and namespace. If nspace is | |||
* NULL, no namespace resolution is performed. */ | * NULL, no namespace resolution is performed. */ | |||
const char *ne_xml_get_attr(ne_xml_parser *parser, | const char *ne_xml_get_attr(ne_xml_parser *parser, | |||
const char **attrs, const char *nspace, | const char **attrs, const char *nspace, | |||
const char *name); | const char *name); | |||
/* Return the encoding of the document being parsed. May return NULL | /* Return the encoding of the document being parsed. May return NULL | |||
* if no encoding is defined or if the XML declaration has not been | * if no encoding is defined or if the XML declaration has not yet | |||
* parsed. */ | * been parsed. */ | |||
const char *ne_xml_doc_encoding(const ne_xml_parser *p); | const char *ne_xml_doc_encoding(const ne_xml_parser *p); | |||
/* A utility interface for mapping {nspace, name} onto an int. */ | /* A utility interface for mapping {nspace, name} onto an integer. */ | |||
struct ne_xml_idmap { | struct ne_xml_idmap { | |||
const char *nspace, *name; | const char *nspace, *name; | |||
int id; | int id; | |||
}; | }; | |||
/* Return the size of an idmap array */ | /* Return the size of an idmap array */ | |||
#define NE_XML_MAPLEN(map) (sizeof(map) / sizeof(struct ne_xml_idmap)) | #define NE_XML_MAPLEN(map) (sizeof(map) / sizeof(struct ne_xml_idmap)) | |||
/* Return the 'id' corresponding to {nspace, name}, or zero. */ | /* Return the 'id' corresponding to {nspace, name}, or zero. */ | |||
int ne_xml_mapid(const struct ne_xml_idmap map[], size_t maplen, | int ne_xml_mapid(const struct ne_xml_idmap map[], size_t maplen, | |||
End of changes. 8 change blocks. | ||||
13 lines changed or deleted | 17 lines changed or added | |||