summaryrefslogtreecommitdiff
path: root/server/src/queryhandler.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/queryhandler.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/queryhandler.cc')
-rw-r--r--server/src/queryhandler.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/server/src/queryhandler.cc b/server/src/queryhandler.cc
index cd96b03..573ce3a 100644
--- a/server/src/queryhandler.cc
+++ b/server/src/queryhandler.cc
@@ -153,7 +153,11 @@ std::string QueryHandler::exec()
" xmlns:pentominos=\"http://www.aasimon.org/pentominos\"\n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:schemaLocation=\"http://www.aasimon.org/pentominos schema.xsd\">\n";
+#ifndef WITHOUT_PENTOMINOS
socket->write(header, strlen(header));
+#else
+ printf(header);
+#endif/*WITHOUT_PENTOMINOS*/
sprintf(buf, " <pentominos:entry cpr=\"%s\"\n"
" src_addr=\"%s\"\n"
@@ -161,11 +165,20 @@ std::string QueryHandler::exec()
" timestamp=\"%d\"\n"
" uid=\"%s\"/>\n",
cpr.c_str(),
+#ifndef WITHOUT_PENTOMINOS
socket->srcaddr().c_str(),
socket->dstaddr().c_str(),
+#else
+ "127.0.0.1",
+ "127.0.0.1",
+#endif/*WITHOUT_PENTOMINOS*/
(unsigned int)timestamp,
uid.c_str());
+#ifndef WITHOUT_PENTOMINOS
socket->write(buf, strlen(buf));
+#else
+ printf(buf);
+#endif/*WITHOUT_PENTOMINOS*/
std::vector< Query >::iterator j = queries.begin();
while(j != queries.end()) {
@@ -179,27 +192,38 @@ std::string QueryHandler::exec()
query.attributes["class"].c_str(),
query.attributes["class"].c_str());
+#ifndef WITHOUT_PENTOMINOS
socket->write(buf, strlen(buf));
+#else
+ printf(buf);
+#endif/*WITHOUT_PENTOMINOS*/
j++;
}
sprintf(buf, "</artefact>\n");
- socket->write(buf, strlen(buf));
+#ifndef WITHOUT_PENTOMINOS
+ socket->write(buf, strlen(buf));
// Terminate
char term[] = "\0";
socket->write(term, 1);
+#else
+ printf(buf);
+#endif/*WITHOUT_PENTOMINOS*/
+ std::string answer;
+
+#ifndef WITHOUT_PENTOMINOS
// Wait for answer
char abuf[64];
int res;
- std::string answer;
do {
memset(abuf, 0, sizeof(abuf));
res = socket->read(abuf, sizeof(abuf) - 1);
answer += abuf;
} while(res);
+#endif/*WITHOUT_PENTOMINOS*/
return answer;
}