summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
authordeva <deva>2008-08-04 10:31:45 +0000
committerdeva <deva>2008-08-04 10:31:45 +0000
commit98b90925d863531c3a6c75de15fb686b1fb1891f (patch)
tree9e6e54df55f4b7e30c4b9c9d447dcd4fe150ff35 /server/src/server.cc
parentbd8221d2791718f02ab1d067c797c62b29da9106 (diff)
Made server able to run (compile-time) without postgres and the uploadserver. Fixed problems in the exclusion of pentominos support. Fixed bug in db query field iteration.
Diffstat (limited to 'server/src/server.cc')
-rw-r--r--server/src/server.cc63
1 files changed, 29 insertions, 34 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 6f875b8..353708f 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -123,39 +123,6 @@ static void connection(TCPSocket &socket)
Template *templ = tp.getTemplate();
-#ifndef WITHOUT_PENTOMINOS
- // Send the queries to Pentominos (if any)
- TCPSocket s;
- s.connect(Conf::pentominos_addr, Conf::pentominos_port);
- QueryHandler qh(&s, transaction.cpr);
-
- std::vector< Macro >::iterator mi = templ->course.macroes.begin();
- while(mi != templ->course.macroes.end()) {
- Macro &macro = (*mi);
- if(macro.attributes["name"] == request.macro) {
-
- std::vector< Query >::iterator qi = m->queries.begin();
- while(qi != m->queries.end()) {
- qh.addQuery(*qi);
- qi++;
- }
- }
- mi++;
- }
- std::string result = qh.exec();
-
- printf("Got result: [%s]\n", result.c_str());
-#else
- std::string result = "";
-#endif/*WITHOUT_PENTOMINOS*/
-
- // Parse the result from the queries to pentominos
- QueryParser qp(result);
- qp.parse();
-
- // Map the results
- LUAQueryMapper lqm(qp.result);
-
answer += " <course name=\"";
answer += templ->course.attributes["name"];
answer += "\">\n";
@@ -172,6 +139,15 @@ static void connection(TCPSocket &socket)
else answer += "\"false\"";
answer += ">\n";
+ ///////////////////////////////
+ // Send the queries to Pentominos (if any)
+ TCPSocket s;
+#ifndef WITHOUT_PENTOMINOS
+ s.connect(Conf::pentominos_addr, Conf::pentominos_port);
+#endif/*WITHOUT_PENTOMINOS*/
+ QueryHandler qh(&s, transaction.cpr);
+ ///////////////////////////////
+
if(macro.attributes["name"] == request.macro) {
foundmacro = true;
@@ -180,7 +156,17 @@ static void connection(TCPSocket &socket)
mp.parse();
Macro *m = mp.getMacro();
- // Handle lua programs
+ ////////////////////////
+ std::vector< Query >::iterator qi = m->queries.begin();
+ while(qi != m->queries.end()) {
+ qh.addQuery(*qi);
+ qi++;
+ }
+ std::string result = qh.exec();
+ printf("Got result: [%s]\n", result.c_str());
+ /////////////////////////
+
+ // Handle scripts
if(m->scripts.size()) {
answer += " <scripts>\n";
@@ -194,6 +180,15 @@ static void connection(TCPSocket &socket)
}
answer += " </scripts>\n";
}
+
+ /////////////////////////
+ // Parse the result from the queries to pentominos
+ QueryParser qp(result);
+ qp.parse();
+ // Map the results
+ LUAQueryMapper lqm(qp.result);
+ ////////////////////////
+
answer += widgetgenerator(*m, lqm, db);
}
answer += " </macro>\n";