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 "fcgi_stdio.h" |
---|
34 | #include <libintl.h> |
---|
35 | #include <locale.h> |
---|
36 | #define _(String) dgettext ("zoo-kernel",String) |
---|
37 | #define _ss(String) dgettext ("zoo-services",String) |
---|
38 | |
---|
39 | #include <sys/stat.h> |
---|
40 | #include <sys/types.h> |
---|
41 | #include "cgic.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 "service.h" |
---|
61 | #include <openssl/sha.h> |
---|
62 | #include <openssl/md5.h> |
---|
63 | #include <openssl/hmac.h> |
---|
64 | #include <openssl/evp.h> |
---|
65 | #include <openssl/bio.h> |
---|
66 | #include <openssl/buffer.h> |
---|
67 | |
---|
68 | #include "ulinet.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 | #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 int nbNs=0; |
---|
92 | |
---|
93 | int getServiceFromYAML(maps*,char*,service**,char *name); |
---|
94 | int readServiceFile(maps*, char*,service**,char *); |
---|
95 | |
---|
96 | |
---|
97 | void printHeaders(maps*); |
---|
98 | void unhandleStatus(maps*); |
---|
99 | int _updateStatus(maps*); |
---|
100 | char* getStatus(int); |
---|
101 | |
---|
102 | #ifdef USE_JS |
---|
103 | char* JSValToChar(JSContext*,jsval*); |
---|
104 | JSBool JSUpdateStatus(JSContext*,uintN,jsval *); |
---|
105 | #endif |
---|
106 | |
---|
107 | void URLDecode(char *); |
---|
108 | char *url_encode(char *); |
---|
109 | char *url_decode(char *); |
---|
110 | char* getEncoding(maps*); |
---|
111 | |
---|
112 | int zooXmlSearchForNs(const char*); |
---|
113 | int zooXmlAddNs(xmlNodePtr,const char*,const char*); |
---|
114 | void zooXmlCleanupNs(); |
---|
115 | |
---|
116 | void printExceptionReportResponse(maps*,map*); |
---|
117 | xmlNodePtr createExceptionReportNode(maps*,map*,int); |
---|
118 | void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*); |
---|
119 | xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,const char*,maps*); |
---|
120 | void printGetCapabilitiesForProcess(maps*,xmlNodePtr,service*); |
---|
121 | xmlNodePtr printDescribeProcessHeader(xmlDocPtr,const char*,maps*); |
---|
122 | void printDescribeProcessForProcess(maps*,xmlNodePtr,service*); |
---|
123 | void printFullDescription(elements*,const char*,xmlNsPtr,xmlNodePtr); |
---|
124 | void printDocument(maps*,xmlDocPtr,int); |
---|
125 | void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*); |
---|
126 | void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
127 | map* parseBoundingBox(const char*); |
---|
128 | void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); |
---|
129 | void printBoundingBoxDocument(maps*,maps*,FILE*); |
---|
130 | void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
131 | |
---|
132 | void outputResponse(service*,maps*,maps*,map*,int,maps*,int); |
---|
133 | |
---|
134 | char *base64(const char*,int); |
---|
135 | char *base64d(const char*,int,int*); |
---|
136 | void ensureDecodedBase64(maps**); |
---|
137 | |
---|
138 | char* addDefaultValues(maps**,elements*,maps*,int); |
---|
139 | |
---|
140 | int errorException(maps *, const char *, const char *, const char*); |
---|
141 | |
---|
142 | int checkForSoapEnvelope(xmlDocPtr); |
---|
143 | |
---|
144 | void addToCache(maps*,char*,char*,char*,int); |
---|
145 | char* isInCache(maps*,char*); |
---|
146 | int loadRemoteFile(maps**,map**,HINTERNET,char*); |
---|
147 | |
---|
148 | #ifdef USE_MS |
---|
149 | char *readVSIFile(maps*,const char*); |
---|
150 | #endif |
---|
151 | void parseIdentifier(maps*,char*,char*,char*); |
---|
152 | int updateStatus( maps*,const int,const char*); |
---|
153 | char* getInputValue( maps*,const char*,size_t*); |
---|
154 | int setOutputValue( maps*, const char*, char*, size_t); |
---|
155 | |
---|
156 | #ifdef __cplusplus |
---|
157 | } |
---|
158 | #endif |
---|
159 | |
---|
160 | #endif |
---|