comparison libpurple/protocols/jabber/parser.c @ 23427:0eca6c183d60

xmlParseChunk() never returns less than 0. It retusn an error code from the xmlParserErrors enum. Success is indicated by XML_ERR_OK, which is 0 and is why this 'error check' coincidentally always passed. We now properly debug log xmlParseChunk()-returns errors and disconnect with the XML Parse error if there is a failure. Refinements to follow.
author Evan Schoenberg <evan.s@dreskin.net>
date Fri, 04 Jul 2008 16:07:20 +0000
parents 1b3aea146613
children ce361cc8e43b
comparison
equal deleted inserted replaced
23426:1b3aea146613 23427:0eca6c183d60
197 } 197 }
198 } 198 }
199 199
200 void jabber_parser_process(JabberStream *js, const char *buf, int len) 200 void jabber_parser_process(JabberStream *js, const char *buf, int len)
201 { 201 {
202 int ret;
203
202 if (js->context == NULL) { 204 if (js->context == NULL) {
203 /* libxml inconsistently starts parsing on creating the 205 /* libxml inconsistently starts parsing on creating the
204 * parser, so do a ParseChunk right afterwards to force it. */ 206 * parser, so do a ParseChunk right afterwards to force it. */
205 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL); 207 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL);
206 xmlParseChunk(js->context, "", 0, 0); 208 xmlParseChunk(js->context, "", 0, 0);
207 } else if (xmlParseChunk(js->context, buf, len, 0) < 0) { 209 } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) {
210 purple_debug_error("jabber", "xmlParseChunk returned error %i", ret);
211
208 purple_connection_error_reason (js->gc, 212 purple_connection_error_reason (js->gc,
209 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 213 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
210 _("XML Parse error")); 214 _("XML Parse error"));
211 } 215 }
212 } 216 }