正在显示
2 个修改的文件
包含
91 行增加
和
47 行删除
... | ... | @@ -130,10 +130,10 @@ add_executable(dmap_spserv |
130 | 130 | |
131 | 131 | add_executable(dmap_serv |
132 | 132 | dmap_serv.cpp |
133 | - # dmpapacheserverrequest.h | |
134 | - # dmpapacheserverresponse.h | |
135 | - # dmpapacheserverrequest.cpp | |
136 | - # dmpapacheserverresponse.cpp | |
133 | + dmpapacheserverrequest.h | |
134 | + dmpapacheserverresponse.h | |
135 | + dmpapacheserverrequest.cpp | |
136 | + dmpapacheserverresponse.cpp | |
137 | 137 | ) |
138 | 138 | |
139 | 139 | target_link_libraries(dmap_spserv |
... | ... | @@ -141,9 +141,9 @@ target_link_libraries(dmap_spserv |
141 | 141 | dmap_server |
142 | 142 | ) |
143 | 143 | |
144 | -# target_link_libraries(dmap_serv | |
145 | -# dmap_server | |
146 | -# ) | |
144 | +target_link_libraries(dmap_serv | |
145 | + dmap_server | |
146 | +) | |
147 | 147 | |
148 | 148 | INCLUDE_DIRECTORIES( |
149 | 149 | ${CMAKE_SOURCE_DIR}/pgsql/include | ... | ... |
... | ... | @@ -9,52 +9,96 @@ |
9 | 9 | #include <string.h> |
10 | 10 | #include <signal.h> |
11 | 11 | #include <assert.h> |
12 | -#include <sys/types.h> | |
13 | -#include <unistd.h> | |
12 | + | |
14 | 13 | #include <fcgi_stdio.h> |
14 | +#include "dmpapacheserverrequest.h" | |
15 | +#include "dmpapacheserverresponse.h" | |
16 | +#include "dmpmainserver.h" | |
17 | +#include "dmpapplication.h" | |
15 | 18 | |
19 | +void CreateEnv(CgiENV& env) | |
20 | +{ | |
21 | + env.HTTP_HOST="localhost"; | |
22 | + env.HTTP_CONNECTION="keep-alive"; | |
23 | + 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"; | |
24 | + 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"; | |
25 | + env.HTTP_ACCEPT_ENCODING="gzip, deflate, br"; | |
26 | + env.HTTP_ACCEPT_LANGUAGE="zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"; | |
27 | + env.PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; | |
28 | + env.SERVER_NAME="localhost"; | |
29 | + env.SERVER_ADDR="::1"; | |
30 | + env.SERVER_PORT="80"; | |
31 | + env.REMOTE_ADDR="::1"; | |
32 | + env.REQUEST_METHOD="GET"; | |
33 | + env.QUERY_STRING="REQUEST=GetCapabilities"; | |
34 | + env.REQUEST_URI="/DMap/Services/GDMap1/MapServer/WMTSServer"; | |
35 | +} | |
36 | +void InitCgiEnv(CgiENV& env) | |
37 | +{ | |
38 | + //FCGX_GetParam("REMOTE_ADDR", ); | |
39 | + env.HTTP_HOST="localhost"; | |
40 | + env.HTTP_CONNECTION="keep-alive"; | |
41 | + 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"; | |
42 | + 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"; | |
43 | + env.HTTP_ACCEPT_ENCODING="gzip, deflate, br"; | |
44 | + env.HTTP_ACCEPT_LANGUAGE="zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"; | |
45 | + env.PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; | |
46 | + env.SERVER_NAME="localhost"; | |
47 | + env.SERVER_ADDR="::1"; | |
48 | + env.SERVER_PORT="80"; | |
49 | + env.REMOTE_ADDR="::1"; | |
50 | + env.REQUEST_METHOD="GET"; | |
51 | + env.QUERY_STRING="REQUEST=GetCapabilities"; | |
52 | + env.REQUEST_URI="/DMap/Services/GDMap1/MapServer/WMTSServer"; | |
53 | +} | |
16 | 54 | |
17 | 55 | int main(int argc,char * argv[] ) |
18 | 56 | { |
19 | - extern char **environ; | |
20 | - int nlen = 0; | |
21 | - int i; | |
22 | - char *psz_content = NULL; | |
23 | - char **pp_env; | |
24 | - | |
25 | - setuid(geteuid()); //设置实际用户id为有效用户id | |
26 | - | |
27 | - while(FCGI_Accept() >= 0) | |
57 | + DmpApplication::Instance()->initialize(); | |
58 | + DmpMainServer dmpServer; | |
59 | + extern char **environ; | |
60 | + int nlen=0; | |
61 | + int i; | |
62 | + char *psz_content = NULL; | |
63 | + char **pp_env; | |
64 | + | |
65 | + setuid(geteuid()); | |
66 | + const char *display = getenv( "DISPLAY" ); | |
67 | + bool withDisplay = true; | |
68 | + if ( !display ) | |
28 | 69 | { |
29 | - printf("Content-type: text/html\n\n"); | |
30 | - | |
31 | - for ( pp_env = environ; *pp_env; pp_env++ ) | |
32 | - printf("%s<br>", *pp_env); | |
33 | - | |
34 | - if ( strcmp("GET", getenv("REQUEST_METHOD")) == 0 ) | |
35 | - { | |
36 | - char buf[128]; | |
37 | - printf("<p>%s</p>", getenv("QUERY_STRING")); | |
38 | - | |
39 | - sprintf(buf, "mkdir -p /var/www/cgi-bin/%s", getenv("QUERY_STRING")); | |
40 | - printf("%s\n", buf); | |
41 | - system(buf); | |
42 | - } | |
43 | - else | |
44 | - { | |
45 | - nlen = atoi(getenv("CONTENT_LENGTH")); | |
46 | - psz_content = ( char * )malloc( nlen + 1 ); | |
47 | - memset( psz_content, 0, nlen + 1 ); | |
48 | - printf("<p>char value:</p><p>"); | |
49 | - for (i = 0; i < nlen; i++ ) | |
50 | - { | |
51 | - psz_content[i] = fgetc(stdin); | |
52 | - printf( "%c", psz_content[i] ); | |
53 | - } | |
54 | - printf("</p><p>string value: %s</p>", psz_content); | |
55 | - } | |
56 | - } | |
57 | - return 0; | |
70 | + withDisplay = false; | |
71 | + | |
72 | + } | |
73 | + while(FCGI_Accept()>=0) | |
74 | + { | |
75 | + // printf("Content-type: text/html\n\n"); | |
76 | + if(strcmp("GET",getenv("REQUEST_METHOD"))==0) | |
77 | + { | |
78 | + // printf("REQUEST_METHOD=GET\n"); | |
79 | + CgiENV env; | |
80 | + CreateEnv(env); | |
81 | + DmpApacheServerRequest dmpRequest(env); | |
82 | + DmpApacheServerResponse dmpResponse; | |
83 | + dmpServer.HandleRequest(dmpRequest, dmpResponse); | |
84 | + // printf("REQUEST_METHOD=GET END\n"); | |
85 | + } | |
86 | + else | |
87 | + { | |
88 | + nlen=atoi(getenv("CONTENT_LENGTH")); | |
89 | + psz_content=(char *)malloc(nlen+1); | |
90 | + memset(psz_content,0,nlen+1); | |
91 | + printf("<p>char value:</p><p>"); | |
92 | + for(i=0;i<nlen;i++) | |
93 | + { | |
94 | + //psz_content[i]=fgetc(stdin); | |
95 | + //printf("%c",psz_content[i]); | |
96 | + } | |
97 | + printf("</p><p>string value:%s</p>",psz_content); | |
98 | + | |
99 | + } | |
100 | + } | |
101 | + return 0; | |
58 | 102 | } |
59 | 103 | |
60 | 104 | ... | ... |
请
注册
或
登录
后发表评论