summaryrefslogtreecommitdiff
path: root/server/src/transactionparser.cc
diff options
context:
space:
mode:
authordeva <deva>2008-09-23 08:10:37 +0000
committerdeva <deva>2008-09-23 08:10:37 +0000
commitefb0b27f5bc659a49e330fb7970a9b1b6ae0f398 (patch)
tree4872d87d301ea5d31c7b2e7f0435ec9318222086 /server/src/transactionparser.cc
parent587f685b6f7cbc63a8ee8dc8b3d5c590144db045 (diff)
Made fix for the 'multiple xml buffers in single network buffer' problem.
Diffstat (limited to 'server/src/transactionparser.cc')
-rw-r--r--server/src/transactionparser.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc
index 1dbeb39..2ba4fc4 100644
--- a/server/src/transactionparser.cc
+++ b/server/src/transactionparser.cc
@@ -37,6 +37,7 @@ TransactionParser::TransactionParser(Transaction *transaction)
{
this->transaction = transaction;
done = false;
+ totalbytes = 0;
}
TransactionParser::~TransactionParser()
@@ -83,18 +84,25 @@ int TransactionParser::readData(char *data, size_t size)
bool TransactionParser::parse(std::string data)
{
+ bufferbytes = data.length();
+ totalbytes += bufferbytes;
+
if(! XML_Parse(p, (char*)data.c_str(), data.size(), false) ) {
+ if(XML_GetErrorCode(p) == XML_ERROR_JUNK_AFTER_DOC_ELEMENT) return true;
parseError((char*)data.c_str(), data.size(), XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p));
return false;
}
if(done) {
if(! XML_Parse(p, (char*)data.c_str(), 0, true) ) {
+ if(XML_GetErrorCode(p) == XML_ERROR_JUNK_AFTER_DOC_ELEMENT) return true;
parseError((char*)data.c_str(), 0, XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p));
return false;
}
}
+ printf("Got END_OF_TEMPLATE at %ld\n", XML_GetCurrentByteIndex(p));
+
return done;
}
@@ -106,3 +114,8 @@ void TransactionParser::parseError(char *buf, size_t len, std::string error, int
fprintf(stderr, "]\n");
fflush(stderr);
}
+
+unsigned int TransactionParser::usedBytes()
+{
+ return bufferbytes + (XML_GetCurrentByteIndex(p) - totalbytes);
+}