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 | #endif |
---|
84 | #include <libxml/parser.h> |
---|
85 | #include <libxml/xpath.h> |
---|
86 | |
---|
87 | static char* SERVICE_URL; |
---|
88 | static xmlNsPtr usedNs[10]; |
---|
89 | static char* nsName[10]; |
---|
90 | static xmlDocPtr iDocs[10]; |
---|
91 | static int nbNs=0; |
---|
92 | static int nbDocs=0; |
---|
93 | |
---|
94 | int getServiceFromYAML(maps*,char*,service**,char *name); |
---|
95 | int readServiceFile(maps*, char*,service**,char *); |
---|
96 | int isValidLang(maps*,const char*); |
---|
97 | |
---|
98 | void printHeaders(maps*); |
---|
99 | void unhandleStatus(maps*); |
---|
100 | int _updateStatus(maps*); |
---|
101 | char* getStatus(int); |
---|
102 | |
---|
103 | #ifdef USE_JS |
---|
104 | char* JSValToChar(JSContext*,jsval*); |
---|
105 | JSBool JSUpdateStatus(JSContext*,uintN,jsval *); |
---|
106 | #endif |
---|
107 | |
---|
108 | void URLDecode(char *); |
---|
109 | char *url_encode(char *); |
---|
110 | char *url_decode(char *); |
---|
111 | char* getEncoding(maps*); |
---|
112 | |
---|
113 | int zooXmlSearchForNs(const char*); |
---|
114 | int zooXmlAddNs(xmlNodePtr,const char*,const char*); |
---|
115 | void zooXmlCleanupNs(); |
---|
116 | |
---|
117 | int zooXmlAddDoc(xmlNodePtr,const char*,const char*); |
---|
118 | void zooXmlCleanupDocs(); |
---|
119 | |
---|
120 | void printExceptionReportResponse(maps*,map*); |
---|
121 | xmlNodePtr createExceptionReportNode(maps*,map*,int); |
---|
122 | void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*); |
---|
123 | xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,const char*,maps*); |
---|
124 | void printGetCapabilitiesForProcess(maps*,xmlNodePtr,service*); |
---|
125 | xmlNodePtr printDescribeProcessHeader(xmlDocPtr,const char*,maps*); |
---|
126 | void printDescribeProcessForProcess(maps*,xmlNodePtr,service*); |
---|
127 | void printFullDescription(int,elements*,const char*,xmlNsPtr,xmlNodePtr); |
---|
128 | void printDocument(maps*,xmlDocPtr,int); |
---|
129 | void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*); |
---|
130 | void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
131 | map* parseBoundingBox(const char*); |
---|
132 | void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); |
---|
133 | void printBoundingBoxDocument(maps*,maps*,FILE*); |
---|
134 | void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); |
---|
135 | |
---|
136 | void outputResponse(service*,maps*,maps*,map*,int,maps*,int); |
---|
137 | |
---|
138 | char *base64(const char*,int); |
---|
139 | char *base64d(const char*,int,int*); |
---|
140 | void ensureDecodedBase64(maps**); |
---|
141 | |
---|
142 | char* addDefaultValues(maps**,elements*,maps*,int); |
---|
143 | |
---|
144 | int errorException(maps *, const char *, const char *, const char*); |
---|
145 | |
---|
146 | int checkForSoapEnvelope(xmlDocPtr); |
---|
147 | |
---|
148 | void addToCache(maps*,char*,char*,char*,int); |
---|
149 | char* isInCache(maps*,char*); |
---|
150 | int runHttpRequests(maps**,maps**,HINTERNET*); |
---|
151 | int loadRemoteFile(maps**,map**,HINTERNET*,char*); |
---|
152 | |
---|
153 | char *readVSIFile(maps*,const char*); |
---|
154 | void parseIdentifier(maps*,char*,char*,char*); |
---|
155 | int updateStatus( maps*,const int,const char*); |
---|
156 | char* getInputValue( maps*,const char*,size_t*); |
---|
157 | int setOutputValue( maps*, const char*, char*, size_t); |
---|
158 | |
---|
159 | #ifdef __cplusplus |
---|
160 | } |
---|
161 | #endif |
---|
162 | |
---|
163 | #endif |
---|