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_SERVICE_INTERNAL_H |
---|
26 | #define ZOO_SERVICE_INTERNAL_H 1 |
---|
27 | |
---|
28 | #pragma once |
---|
29 | |
---|
30 | #define DEFAULT_SERVICE_URL "http://www.zoo-project.org/" |
---|
31 | #define TIME_SIZE 40 |
---|
32 | |
---|
33 | #include <libintl.h> |
---|
34 | #include <locale.h> |
---|
35 | #define _(String) dgettext ("zoo-kernel",String) |
---|
36 | #define _ss(String) dgettext ("zoo-services",String) |
---|
37 | |
---|
38 | #include <sys/stat.h> |
---|
39 | #include <sys/types.h> |
---|
40 | //#include "cgic.h" |
---|
41 | #include <fcgiapp.h> |
---|
42 | #ifndef WIN32 |
---|
43 | #include <sys/ipc.h> |
---|
44 | #include <sys/shm.h> |
---|
45 | #else |
---|
46 | #include <direct.h> |
---|
47 | #endif |
---|
48 | #include <stdio.h> |
---|
49 | #include <time.h> |
---|
50 | #include <ctype.h> |
---|
51 | #ifdef WIN32 |
---|
52 | #ifndef USE_RUBY |
---|
53 | #include <unistd.h> |
---|
54 | #endif |
---|
55 | #endif |
---|
56 | #ifndef WIN32 |
---|
57 | #include <xlocale.h> |
---|
58 | #endif |
---|
59 | #include <dirent.h> |
---|
60 | #include "ulinet.h" |
---|
61 | |
---|
62 | #include "service.h" |
---|
63 | #include <openssl/sha.h> |
---|
64 | #include <openssl/md5.h> |
---|
65 | #include <openssl/hmac.h> |
---|
66 | #include <openssl/evp.h> |
---|
67 | #include <openssl/bio.h> |
---|
68 | #include <openssl/buffer.h> |
---|
69 | |
---|
70 | extern int conf_read (const char *, maps *); |
---|
71 | |
---|
72 | #ifdef USE_JS |
---|
73 | #ifdef WIN32 |
---|
74 | #define XP_WIN 1 |
---|
75 | #else |
---|
76 | #define XP_UNIX 0 |
---|
77 | #endif |
---|
78 | #include "service_internal_js.h" |
---|
79 | #endif |
---|
80 | |
---|
81 | |
---|
82 | #ifdef __cplusplus |
---|
83 | extern "C" |
---|
84 | { |
---|
85 | #endif |
---|
86 | #include <libxml/parser.h> |
---|
87 | #include <libxml/xpath.h> |
---|
88 | |
---|
89 | static char *SERVICE_URL; |
---|
90 | static xmlNsPtr usedNs[10]; |
---|
91 | static char *nsName[10]; |
---|
92 | static xmlDocPtr iDocs[10]; |
---|
93 | static int nbNs = 0; |
---|
94 | static int nbDocs = 0; |
---|
95 | |
---|
96 | int getServiceFromYAML (maps *, char *, service **, char *name); |
---|
97 | int readServiceFile (maps *, char *, service **, char *); |
---|
98 | int isValidLang (maps *, const char *); |
---|
99 | |
---|
100 | void printHeaders (maps *); |
---|
101 | void unhandleStatus (maps *); |
---|
102 | int _updateStatus (maps *); |
---|
103 | char *getStatus (int); |
---|
104 | |
---|
105 | #ifdef USE_JS |
---|
106 | char *JSValToChar (JSContext *, jsval *); |
---|
107 | JSBool JSUpdateStatus (JSContext *, uintN, jsval *); |
---|
108 | #endif |
---|
109 | |
---|
110 | void URLDecode (char *); |
---|
111 | char *url_encode (char *); |
---|
112 | char *url_decode (char *); |
---|
113 | char *getEncoding (maps *); |
---|
114 | |
---|
115 | int zooXmlSearchForNs (const char *); |
---|
116 | int zooXmlAddNs (xmlNodePtr, const char *, const char *); |
---|
117 | void zooXmlCleanupNs (); |
---|
118 | |
---|
119 | int zooXmlAddDoc (xmlNodePtr, const char *, const char *); |
---|
120 | void zooXmlCleanupDocs (); |
---|
121 | void addPrefix (maps * conf, map * level, service * serv); |
---|
122 | void printExceptionReportResponse (maps *, map *,FCGX_Stream * out); |
---|
123 | xmlNodePtr createExceptionReportNode (maps *, map *, int); |
---|
124 | void printProcessResponse (maps *, map *, int, service *, const char *, int, |
---|
125 | maps *, maps *,FCGX_Stream *); |
---|
126 | xmlNodePtr printGetCapabilitiesHeader (xmlDocPtr, const char *, maps *); |
---|
127 | void printGetCapabilitiesForProcess (maps *, xmlNodePtr, service *); |
---|
128 | xmlNodePtr printDescribeProcessHeader (xmlDocPtr, const char *, maps *); |
---|
129 | void printDescribeProcessForProcess (maps *, xmlNodePtr, service *); |
---|
130 | void printFullDescription (int, elements *, const char *, xmlNsPtr, |
---|
131 | xmlNodePtr); |
---|
132 | void printDocument (maps *, xmlDocPtr, int, FCGX_Stream *); |
---|
133 | void printDescription (xmlNodePtr, xmlNsPtr, const char *, map *); |
---|
134 | void printIOType (xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, xmlNsPtr, |
---|
135 | elements *, maps *, const char *); |
---|
136 | map *parseBoundingBox (const char *); |
---|
137 | void printBoundingBox (xmlNsPtr, xmlNodePtr, map *); |
---|
138 | void printBoundingBoxDocument (maps *, maps *, FILE *); |
---|
139 | void printOutputDefinitions1 (xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, |
---|
140 | elements *, maps *, const char *); |
---|
141 | |
---|
142 | void outputResponse (service *, maps *, maps *, map *, int, maps *, int,FCGX_Stream *,FCGX_Stream *); |
---|
143 | |
---|
144 | char *base64 (const char *, int); |
---|
145 | char *base64d (const char *, int, int *); |
---|
146 | void ensureDecodedBase64 (maps **); |
---|
147 | |
---|
148 | char *addDefaultValues (maps **, elements *, maps *, int); |
---|
149 | |
---|
150 | int errorException (maps *, const char *, const char *, const char *,FCGX_Stream *); |
---|
151 | |
---|
152 | int checkForSoapEnvelope (xmlDocPtr); |
---|
153 | |
---|
154 | void addToCache (maps *, char *, char *, char *, int); |
---|
155 | char *isInCache (maps *, char *); |
---|
156 | int runHttpRequests (maps **, maps **, HINTERNET *); |
---|
157 | int loadRemoteFile (maps **, map **, HINTERNET *, char *); |
---|
158 | |
---|
159 | char *readVSIFile (maps *, const char *); |
---|
160 | void parseIdentifier (maps *, char *, char *, char *); |
---|
161 | int updateStatus (maps *, const int, const char *); |
---|
162 | char *getInputValue (maps *, const char *, size_t *); |
---|
163 | int setOutputValue (maps *, const char *, char *, size_t); |
---|
164 | |
---|
165 | #ifdef __cplusplus |
---|
166 | } |
---|
167 | #endif |
---|
168 | |
---|
169 | #endif |
---|