summaryrefslogtreecommitdiff
path: root/server/src/transactionparser.cc
diff options
context:
space:
mode:
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);
+}