dmap_serv.cpp
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2007 Stephen Liu
* For license terms, see the file COPYING along with this library.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <assert.h>
#include <fcgi_stdio.h>
#include "dmpapacheserverrequest.h"
#include "dmpapacheserverresponse.h"
#include "dmpmainserver.h"
#include "dmpapplication.h"
void CreateEnv(CgiENV& env)
{
env.HTTP_HOST="localhost";
env.HTTP_CONNECTION="keep-alive";
env.HTTP_USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53";
env.HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
env.HTTP_ACCEPT_ENCODING="gzip, deflate, br";
env.HTTP_ACCEPT_LANGUAGE="zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6";
env.PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
env.SERVER_NAME="localhost";
env.SERVER_ADDR="::1";
env.SERVER_PORT="80";
env.REMOTE_ADDR="::1";
env.REQUEST_METHOD="GET";
env.QUERY_STRING="REQUEST=GetCapabilities";
env.REQUEST_URI="/DMap/Services/GDMap1/MapServer/WMTSServer";
}
void InitCgiEnv(CgiENV& env)
{
//FCGX_GetParam("REMOTE_ADDR", );
env.HTTP_HOST="localhost";
env.HTTP_CONNECTION="keep-alive";
env.HTTP_USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53";
env.HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
env.HTTP_ACCEPT_ENCODING="gzip, deflate, br";
env.HTTP_ACCEPT_LANGUAGE="zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6";
env.PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
env.SERVER_NAME="localhost";
env.SERVER_ADDR="::1";
env.SERVER_PORT="80";
env.REMOTE_ADDR="::1";
env.REQUEST_METHOD="GET";
env.QUERY_STRING="REQUEST=GetCapabilities";
env.REQUEST_URI="/DMap/Services/GDMap1/MapServer/WMTSServer";
}
int main(int argc,char * argv[] )
{
DmpApplication::Instance()->initialize();
DmpMainServer dmpServer;
extern char **environ;
int nlen=0;
int i;
char *psz_content = NULL;
char **pp_env;
setuid(geteuid());
const char *display = getenv( "DISPLAY" );
bool withDisplay = true;
if ( !display )
{
withDisplay = false;
}
while(FCGI_Accept()>=0)
{
// printf("Content-type: text/html\n\n");
if(strcmp("GET",getenv("REQUEST_METHOD"))==0)
{
// printf("REQUEST_METHOD=GET\n");
CgiENV env;
CreateEnv(env);
DmpApacheServerRequest dmpRequest(env);
DmpApacheServerResponse dmpResponse;
dmpServer.HandleRequest(dmpRequest, dmpResponse);
// printf("REQUEST_METHOD=GET END\n");
}
else
{
nlen=atoi(getenv("CONTENT_LENGTH"));
psz_content=(char *)malloc(nlen+1);
memset(psz_content,0,nlen+1);
printf("<p>char value:</p><p>");
for(i=0;i<nlen;i++)
{
//psz_content[i]=fgetc(stdin);
//printf("%c",psz_content[i]);
}
printf("</p><p>string value:%s</p>",psz_content);
}
}
return 0;
}