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