From 198b0d886817f2c5bc97cfd11857d4b314dffae3 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 10 Jun 2010 07:03:06 +0000 Subject: Add transaction support on database pr. pracro session. Makes it possible to discard all edited macros. --- server/src/sessionparser.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server/src/sessionparser.cc') diff --git a/server/src/sessionparser.cc b/server/src/sessionparser.cc index ba3693d..0edb26a 100644 --- a/server/src/sessionparser.cc +++ b/server/src/sessionparser.cc @@ -34,6 +34,7 @@ SessionParser::SessionParser() done = false; totalbytes = 0; inresume = false; + indatabase = false; } SessionParser::~SessionParser() @@ -45,6 +46,10 @@ void SessionParser::characterData(std::string &data) if(inresume) { entries[entries.size()-1].resume += data; } + + if(indatabase) { + database += data; + } } void SessionParser::startTag(std::string name, @@ -61,6 +66,11 @@ void SessionParser::startTag(std::string name, userid = attributes["userid"]; } + if(name == "database") { + dbtype = attributes["type"]; + indatabase = true; + } + if(name == "entry") { Entry e; e.index = atoi(attributes["index"].c_str()); @@ -78,6 +88,9 @@ void SessionParser::endTag(std::string name) if(name == "resume") { inresume = false; } + if(name == "database") { + indatabase = false; + } } void SessionParser::parseError(const char *buf, size_t len, @@ -87,11 +100,13 @@ void SessionParser::parseError(const char *buf, size_t len, lineno, error.c_str()); std::string xml; - xml.append(buf, len); + if(buf && len) xml.append(buf, len); PRACRO_ERR(sessionparser, "\tBuffer %u bytes: [%s]\n", len, xml.c_str()); + fflush(stderr); + throw std::exception(); } -- cgit v1.2.3