diff options
Diffstat (limited to 'server/src/saxparser.cc')
-rw-r--r-- | server/src/saxparser.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc index e8e9eb4..5580e5b 100644 --- a/server/src/saxparser.cc +++ b/server/src/saxparser.cc @@ -90,10 +90,8 @@ int SAXParser::parse() do { len = readData(buf, sizeof(buf) - 1); if (! XML_Parse(p, buf, len, len == 0)) { - fprintf(stderr, "Parse error at line %d:\n%s\n", - (int)XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); - return -1; + parseError(buf, len, XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p)); + return 1; } memset(buf, 0, sizeof(buf)); @@ -102,6 +100,16 @@ int SAXParser::parse() return 0; } +void SAXParser::parseError(char *buf, size_t len, std::string error, int lineno) +{ + fprintf(stderr, "SAXParser error at line %d: %s\n", lineno, error.c_str()); + fprintf(stderr, "\tBuffer %u bytes: [", len); + if(fwrite(buf, len, 1, stderr) != len) {} + fprintf(stderr, "]\n"); + fflush(stderr); +} + + #ifdef TEST_SAXPARSER /** * Compile with: g++ -DTEST_SAXPARSER sax_parser.cc -lexpat -otext_saxparser |