summaryrefslogtreecommitdiff
path: root/src/ne_xml.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-17 13:06:00 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-17 13:06:00 +0000
commitd01dd904918f1628e2708b5dc7595089cc688bc0 (patch)
tree5f055655de6ec0f568c5b5f4769a62e7cb9e6b03 /src/ne_xml.c
parent3aa536fc208b12a335be934350b2d5c7b17a6d22 (diff)
downloadneon-d01dd904918f1628e2708b5dc7595089cc688bc0.tar.gz
* src/ne_xml.h (ne_xml_parse): Returns an error if parsing fails.
(ne_xml_failed): Redefine in terms of ne_xml_parse return value. * src/ne_xml.c (ne_xml_parse): Return p->failure. (ne_xml_parse_v): Pass through return value from ne_xml_parse. * test/xml.c (parse_match): Check ne_xml_parse() return value; handle match_chunked test mode. (matches): Test for UTF-8 BOM handling in chunked mode. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@315 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_xml.c')
-rw-r--r--src/ne_xml.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/ne_xml.c b/src/ne_xml.c
index 0ef4325..008f1d6 100644
--- a/src/ne_xml.c
+++ b/src/ne_xml.c
@@ -467,24 +467,19 @@ void ne_xml_push_handler(ne_xml_parser *p,
int ne_xml_parse_v(void *userdata, const char *block, size_t len)
{
ne_xml_parser *p = userdata;
- /* FIXME: The two XML parsers break all our nice abstraction by
- * choosing different char *'s. The swine. This cast will come
- * back and bite us someday, no doubt. */
- ne_xml_parse(p, block, len);
- return 0;
+ return ne_xml_parse(p, (const ne_xml_char *)block, len);
}
#define BOM_UTF8 "\xEF\xBB\xBF" /* UTF-8 BOM */
-/* Parse the given block of input of length len */
-void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len)
+int ne_xml_parse(ne_xml_parser *p, const char *block, size_t len)
{
int ret, flag;
/* duck out if it's broken */
if (p->failure) {
NE_DEBUG(NE_DBG_XML, "Not parsing %" NE_FMT_SIZE_T " bytes.\n",
len);
- return;
+ return p->failure;
}
if (len == 0) {
flag = -1;
@@ -504,13 +499,12 @@ void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len)
p->bom_pos++;
}
if (len == 0)
- return;
+ return 0;
if (p->bom_pos == 0) {
p->bom_pos = 3; /* no BOM */
} else if (p->bom_pos > 0 && p->bom_pos < 3) {
strcpy(p->error, _("Invalid Byte Order Mark"));
- p->failure = 1;
- return;
+ return p->failure = 1;
}
}
@@ -538,6 +532,7 @@ void ne_xml_parse(ne_xml_parser *p, const char *block, size_t len)
NE_DEBUG(NE_DBG_XMLPARSE, "XML parse error: %s\n", p->error);
}
#endif
+ return p->failure;
}
int ne_xml_failed(ne_xml_parser *p)