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