summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/server.cc')
-rw-r--r--server/src/server.cc32
1 files changed, 15 insertions, 17 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 9708f9f..2ea782d 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -115,6 +115,8 @@ static void connection(TCPSocket &socket)
while(i != transaction.requests.end()) {
Request &request = *i;
+ std::string answer;
+
MacroParser mp(request.macro);
mp.parse();
Macro *m = mp.getMacro();
@@ -156,51 +158,47 @@ static void connection(TCPSocket &socket)
// Map the results
LUAQueryMapper lqm(qp.result);
- socket.write(" <course name=\"");
- socket.write(templ->course.attributes["name"]);
- socket.write("\">\n");
+ answer += " <course name=\"";
+ answer += templ->course.attributes["name"];
+ answer += "\">\n";
// Generate the macro and return it to the client
std::vector< Macro >::iterator mi2 = templ->course.macroes.begin();
while(mi2 != templ->course.macroes.end()) {
Macro &macro = (*mi2);
- socket.write(" <macro name=\"");
- socket.write(macro.attributes["name"]);
- socket.write("\">\n");
+ answer += " <macro name=\"" + macro.attributes["name"] + "\">\n";
if(macro.attributes["name"] == request.macro) {
// Handle lua programs
if(m->luaprograms.size()) {
- socket.write(" <luaprograms>\n");
+ answer += " <luaprograms>\n";
std::vector< LUAProgram >::iterator lpi = m->luaprograms.begin();
while(lpi != m->luaprograms.end()) {
- socket.write(" <luaprogram name=\"");
- socket.write(lpi->attributes["name"]);
- socket.write("\">\n");
+ answer += " <luaprogram name=\"" + lpi->attributes["name"] + "\">\n";
- socket.write(lpi->attributes["lua"]);
+ answer += lpi->attributes["lua"];
- socket.write("\n </luaprogram>\n");
+ answer += "\n </luaprogram>\n";
lpi++;
}
- socket.write(" </luaprograms>\n");
+ answer += " </luaprograms>\n";
}
- widgetgenerator(socket, *m, lqm, db);
+ answer += widgetgenerator(*m, lqm, db);
}
- socket.write(" </macro>\n");
+ answer += " </macro>\n";
mi2++;
}
- socket.write(" </course>\n");
-
+ answer += " </course>\n";
+ socket.write(answer);
i++;
}
} catch(std::exception &e) {