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.cc42
1 files changed, 38 insertions, 4 deletions
diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc
index 0e64944..3d3024c 100644
--- a/server/src/transactionparser.cc
+++ b/server/src/transactionparser.cc
@@ -33,13 +33,16 @@
#include <string>
#include <map>
-TransactionParser::TransactionParser(TCPSocket &socket, Transaction &transaction)
+TransactionParser::TransactionParser(Transaction *transaction)
{
- this->transaction = &transaction;
- this->socket = &socket;
+ this->transaction = transaction;
done = false;
}
+TransactionParser::~TransactionParser()
+{
+}
+
void TransactionParser::startTag(std::string name, std::map< std::string, std::string> attributes)
{
if(name == "pracro") {
@@ -74,8 +77,39 @@ void TransactionParser::endTag(std::string name)
int TransactionParser::readData(char *data, size_t size)
{
+ printf("readData is not uasble with transaction parser!.\nUse parse(std::string) instead.\n");
+ return 0;
+/*
if(done) return 0;
- return socket->read(data, size);
+
+ int ret;
+
+ // while((ret = socket->read(data, size, 1000)) == 0) { }
+
+ if(ret == -1) {
+ printf("Transaction parser was interrupted.\n");
+ return 0;
+ }
+
+ return ret;
+*/
+}
+
+bool TransactionParser::parse(std::string data)
+{
+ if(! XML_Parse(p, (char*)data.c_str(), data.size(), false) ) {
+ parseError((char*)data.c_str(), data.size(), XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p));
+ return false;
+ }
+
+ if(done) {
+ if(! XML_Parse(p, "", 0, true) ) {
+ parseError("", 0, XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p));
+ return false;
+ }
+ }
+
+ return done;
}
void TransactionParser::parseError(char *buf, size_t len, std::string error, int lineno)