more code
[iotcloud.git] / src / server / 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       IoTQuery * iotquery=new IoTQuery(&request);
27       iotquery->processQuery();
28       delete iotquery;
29     } 
30
31     // restore stdio streambufs
32     cin.rdbuf(cin_streambuf);
33     cout.rdbuf(cout_streambuf);
34     cerr.rdbuf(cerr_streambuf);
35
36     return 0;
37 }
38