bb9eff8ff4e7c76e700ade4d1e2bc6f7a6928bde
[iotcloud.git] / iotcloud.cpp
1 #include <iostream>
2 #include "iotquery.h"
3
4 using namespace std;
5
6
7 int main(void) {
8         // Backup the stdio streambufs
9         streambuf * cin_streambuf  = cin.rdbuf();
10         streambuf * cout_streambuf = cout.rdbuf();
11         streambuf * cerr_streambuf = cerr.rdbuf();
12
13         FCGX_Request request;
14
15         FCGX_Init();
16         FCGX_InitRequest(&request, 0, 0);
17
18         while (FCGX_Accept_r(&request) == 0) {
19                 fcgi_streambuf cin_fcgi_streambuf(request.in);
20                 fcgi_streambuf cout_fcgi_streambuf(request.out);
21                 fcgi_streambuf cerr_fcgi_streambuf(request.err);
22
23                 cin.rdbuf(&cin_fcgi_streambuf);
24                 cout.rdbuf(&cout_fcgi_streambuf);
25                 cerr.rdbuf(&cerr_fcgi_streambuf);
26
27                 IoTQuery * iotquery=new IoTQuery(&request);
28                 iotquery->processQuery();
29
30                 delete iotquery;
31         }
32
33         // restore stdio streambufs
34         cin.rdbuf(cin_streambuf);
35         cout.rdbuf(cout_streambuf);
36         cerr.rdbuf(cerr_streambuf);
37
38         return 0;
39 }
40