1 | /* |
---|
2 | * Author : Gérald FENOY |
---|
3 | * |
---|
4 | * Copyright (c) 2009-2013 GeoLabs SARL |
---|
5 | * |
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
7 | * of this software and associated documentation files (the "Software"), to deal |
---|
8 | * in the Software without restriction, including without limitation the rights |
---|
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
10 | * copies of the Software, and to permit persons to whom the Software is |
---|
11 | * furnished to do so, subject to the following conditions: |
---|
12 | * |
---|
13 | * The above copyright notice and this permission notice shall be included in |
---|
14 | * all copies or substantial portions of the Software. |
---|
15 | * |
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
22 | * THE SOFTWARE. |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef ZOO_RESPONSE_PRINT_H |
---|
26 | #define ZOO_RESPONSE_PRINT_H 1 |
---|
27 | |
---|
28 | #pragma once |
---|
29 | |
---|
30 | /** |
---|
31 | * The default service url (overriden by serverAddress) |
---|
32 | */ |
---|
33 | #define DEFAULT_SERVICE_URL "http://www.zoo-project.org/" |
---|
34 | /** |
---|
35 | * The time size |
---|
36 | */ |
---|
37 | #define TIME_SIZE 40 |
---|
38 | |
---|
39 | #include <libintl.h> |
---|
40 | #include <locale.h> |
---|
41 | /** |
---|
42 | * ZOO-Kernel internal messages translation function |
---|
43 | */ |
---|
44 | #define _(String) dgettext ("zoo-kernel",String) |
---|
45 | /** |
---|
46 | * ZOO-Services messages translation function |
---|
47 | */ |
---|
48 | #define _ss(String) dgettext ("zoo-services",String) |
---|
49 | |
---|
50 | /** |
---|
51 | * ZOO-Kernel was unable to create a lock |
---|
52 | */ |
---|
53 | #define ZOO_LOCK_CREATE_FAILED -4 |
---|
54 | /** |
---|
55 | * ZOO-Kernel was unable to acquire a lock |
---|
56 | */ |
---|
57 | #define ZOO_LOCK_ACQUIRE_FAILED -5 |
---|
58 | /** |
---|
59 | * ZOO-Kernel was unable to release a lock |
---|
60 | */ |
---|
61 | #define ZOO_LOCK_RELEASE_FAILED -6 |
---|
62 | |
---|
63 | #include <sys/stat.h> |
---|
64 | #include <sys/types.h> |
---|
65 | #include "cgic.h" |
---|
66 | #ifndef WIN32 |
---|
67 | #include <sys/ipc.h> |
---|
68 | #include <sys/shm.h> |
---|
69 | #include <sys/sem.h> |
---|
70 | #else |
---|
71 | #include <direct.h> |
---|
72 | #endif |
---|
73 | #include <stdio.h> |
---|
74 | #include <time.h> |
---|
75 | #include <ctype.h> |
---|
76 | #ifdef WIN32 |
---|
77 | #ifndef USE_RUBY |
---|
78 | #include <unistd.h> |
---|
79 | #endif |
---|
80 | #endif |
---|
81 | #ifndef WIN32 |
---|
82 | #include <xlocale.h> |
---|
83 | #endif |
---|
84 | #include "ulinet.h" |
---|
85 | |
---|
86 | #include "service.h" |
---|
87 | #include <openssl/sha.h> |
---|
88 | #include <openssl/md5.h> |
---|
89 | #include <openssl/hmac.h> |
---|
90 | #include <openssl/evp.h> |
---|
91 | #include <openssl/bio.h> |
---|
92 | #include <openssl/buffer.h> |
---|
93 | |
---|
94 | #ifdef __cplusplus |
---|
95 | extern "C" { |
---|
96 | #endif |
---|
97 | #include <libxml/parser.h> |
---|
98 | #include <libxml/xpath.h> |
---|
99 | |
---|
100 | /** |
---|
101 | * Maximum number of XML namespaces |
---|
102 | */ |
---|
103 | #define ZOO_NS_MAX 10 |
---|
104 | /** |
---|
105 | * Maximum number of XML docs |
---|
106 | */ |
---|
107 | #define ZOO_DOC_MAX 20 |
---|
108 | |
---|
109 | /** |
---|
110 | * Global char* to store the serverAddress value of the [main] section |
---|
111 | */ |
---|
112 | static char* SERVICE_URL; |
---|
113 | |
---|
114 | /** |
---|
115 | * Array of xmlNsPtr storing all used XML namespace |
---|
116 | */ |
---|
117 | static xmlNsPtr usedNs[ZOO_NS_MAX]; |
---|
118 | /** |
---|
119 | * Array storing names of the used XML namespace |
---|
120 | */ |
---|
121 | static char* nsName[ZOO_NS_MAX]; |
---|
122 | /** |
---|
123 | * Number of XML namespaces |
---|
124 | */ |
---|
125 | static int nbNs=0; |
---|
126 | /** |
---|
127 | * Array of xmlDocPtr storing XML docs |
---|
128 | */ |
---|
129 | static xmlDocPtr iDocs[ZOO_DOC_MAX]; |
---|
130 | /** |
---|
131 | * Number of XML docs |
---|
132 | */ |
---|
133 | static int nbDocs=0; |
---|
134 | |
---|
135 | /** |
---|
136 | * Definitions of schemas depending on the WPS version |
---|
137 | */ |
---|
138 | static const char* schemas[2][5]={ |
---|
139 | {"1.0.0","http://www.opengis.net/ows/1.1","http://www.opengis.net/wps/1.0.0","http://schemas.opengis.net/wps/1.0.0","%s %s/wps%s_response.xsd"}, |
---|
140 | {"2.0.0","http://www.opengis.net/ows/2.0","http://www.opengis.net/wps/2.0","http://schemas.opengis.net/wps/2.0","%s %s/wps%s.xsd"}, |
---|
141 | }; |
---|
142 | /** |
---|
143 | * Definitions of support requests (depending on the WPS version) |
---|
144 | */ |
---|
145 | static int nbSupportedRequests=7; |
---|
146 | /** |
---|
147 | * Definitions of requests depending on the WPS version |
---|
148 | */ |
---|
149 | static const char* requests[2][7]={ |
---|
150 | {"GetCapabilities","DescribeProcess","Execute",NULL}, |
---|
151 | {"GetCapabilities","DescribeProcess","Execute","GetStatus","GetResult","Dismiss",NULL}, |
---|
152 | }; |
---|
153 | /** |
---|
154 | * Definitions of root node for response depending on the request and the WPS version |
---|
155 | */ |
---|
156 | static const char* root_nodes[2][6]={ |
---|
157 | {"ProcessOfferings","ProcessDescriptions",NULL}, |
---|
158 | {"Contents","ProcessOfferings",NULL} |
---|
159 | }; |
---|
160 | |
---|
161 | /** |
---|
162 | * Name and corresponding attributes depending on the WPS version |
---|
163 | */ |
---|
164 | static const char* capabilities[2][7]={ |
---|
165 | { |
---|
166 | "Process", |
---|
167 | "processVersion","1", |
---|
168 | "storeSupported","true", |
---|
169 | "statusSupported","true" |
---|
170 | }, |
---|
171 | { |
---|
172 | "ProcessSummary", |
---|
173 | "processVersion","1.0.0", |
---|
174 | "jobControlOptions","sync-execute async-execute dismiss", |
---|
175 | "outputTransmission","value reference" |
---|
176 | } |
---|
177 | }; |
---|
178 | |
---|
179 | void addLangAttr(xmlNodePtr,maps*); |
---|
180 | |
---|
181 | void printHeaders(maps*); |
---|
182 | |
---|
183 | int zooXmlSearchForNs(const char*); |
---|
184 | int zooXmlAddNs(xmlNodePtr,const char*,const char*); |
---|
185 | void zooXmlCleanupNs(); |
---|
186 | |
---|
187 | int zooXmlAddDoc(xmlNodePtr,const char*,const char*); |
---|
188 | void zooXmlCleanupDocs(); |
---|
189 | |
---|
190 | void printExceptionReportResponse(maps*,map*); |
---|
191 | xmlNodePtr createExceptionReportNode(maps*,map*,int); |
---|
192 | void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*); |
---|
193 | xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*,const char*,int); |
---|
194 | xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*,const char*); |
---|
195 | void printGetCapabilitiesForProcess(maps*,xmlNodePtr,service*); |
---|
196 | void printDescribeProcessForProcess(maps*,xmlNodePtr,service*); |
---|
197 | void printFullDescription(int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int); |
---|
198 | void printDocument(maps*,xmlDocPtr,int); |
---|
199 | void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int); |
---|
200 | void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
201 | map* parseBoundingBox(const char*); |
---|
202 | void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); |
---|
203 | void printBoundingBoxDocument(maps*,maps*,FILE*); |
---|
204 | void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
205 | |
---|
206 | void outputResponse(service*,maps*,maps*,map*,int,maps*,int); |
---|
207 | |
---|
208 | int errorException(maps *, const char *, const char *, const char*); |
---|
209 | |
---|
210 | xmlNodePtr soapEnvelope(maps*,xmlNodePtr); |
---|
211 | int checkForSoapEnvelope(xmlDocPtr); |
---|
212 | |
---|
213 | #ifdef __cplusplus |
---|
214 | } |
---|
215 | #endif |
---|
216 | |
---|
217 | #endif |
---|