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