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