Changeset 217
- Timestamp:
- May 31, 2011, 3:30:49 AM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 27 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/thirds/cgic206/cgic.c
r98 r217 68 68 char *cgiUserAgent; 69 69 char *cgiReferrer; 70 char *cgiSid; 70 71 71 72 FILE *cgiIn; … … 143 144 cgiGetenv(&cgiScriptName, "SCRIPT_NAME"); 144 145 cgiGetenv(&cgiQueryString, "QUERY_STRING"); 146 cgiSid=NULL; 145 147 if(strcmp(cgiQueryString,"")==0 && argc>=2){ 146 148 cgiQueryString=argv[1]; 149 if(argc>2){ 150 cgiSid=argv[2]; 151 } 147 152 } 148 153 cgiGetenv(&cgiRemoteHost, "REMOTE_HOST"); -
branches/branch-1.2/thirds/cgic206/cgic.h
r98 r217 124 124 #endif 125 125 char *cgiCookie; 126 127 extern 128 #ifdef __cplusplus 129 "C" 130 #endif 131 char *cgiSid; 126 132 127 133 /* A macro providing the same incorrect spelling that is -
branches/branch-1.2/thirds/cgic206/makefile.vc
r1 r217 9 9 -I $(GEODIR)/include 10 10 11 all: libcgic.lib cgictest.exe capture.exe11 all: libcgic.lib #cgictest.exe capture.exe 12 12 13 13 install: libcgic.lib … … 24 24 25 25 cgictest.exe: cgictest.obj 26 link cgictest.obj $(LIBS 1) /out:cgictest.exe26 link cgictest.obj $(LIBS) /out:cgictest.exe 27 27 28 28 cgic.obj: … … 30 30 31 31 capture.exe: capture.obj libcgic.lib 32 $(CC) $(CFLAGS) capture.c $(LIBS 1)32 $(CC) $(CFLAGS) capture.c $(LIBS) 33 33 34 34 clean: -
branches/branch-1.2/zoo-api/js/ZOO-api.js
r101 r217 21 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 22 * THE SOFTWARE. 23 */ 24 25 /** 26 * Copyright 2005-2010 OpenLayers Contributors, released under the Clear BSD 27 * license. Please see http://svn.openlayers.org/trunk/openlayers/license.txt 28 * for the full text of the license. 23 29 */ 24 30 … … 3198 3204 }, 3199 3205 /** 3200 * Method: parseGeometry. polygon3206 * Method: parseGeometry.envelope 3201 3207 * Given a GML node representing an envelope, create a 3202 3208 * ZOO polygon geometry. … … 4090 4096 * Method: calculateBounds 4091 4097 * Recalculate the bounds by iterating through the components and 4092 * calling callingextendBounds() on each item.4098 * calling extendBounds() on each item. 4093 4099 */ 4094 4100 calculateBounds: function() { … … 4247 4253 * the earth. 4248 4254 * 4255 * Parameters: 4249 4256 * projection - {<ZOO.Projection>} The spatial reference system 4250 4257 * for the geometry coordinates. If not provided, Geographic/WGS84 is -
branches/branch-1.2/zoo-api/js/ZOO-proj4js.js
r85 r217 21 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 22 * THE SOFTWARE. 23 */ 24 25 /** 26 * Author: Mike Adair madairATdmsolutions.ca 27 * Richard Greenwood rich@greenwoodmap.com 28 * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html 29 * $Id: Proj.js 2956 2007-07-09 12:17:52Z steven $ 23 30 */ 24 31 -
branches/branch-1.2/zoo-kernel/Makefile.in
r77 r217 93 93 94 94 zoo_service_loader.o: zoo_service_loader.c service.h 95 g++ -g -O2 -Wall${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o95 g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o 96 96 97 97 zoo_loader.cgi: zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} 98 g++ -g -O2 -Wall${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o98 g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 99 99 g++ ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -lcurl -L../thirds/cgic206 -lcgic -lcurl ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MACOS_LD_FLAGS} 100 100 -
branches/branch-1.2/zoo-kernel/configure.ac
r110 r217 119 119 120 120 AC_ARG_WITH([python], 121 [AS_HELP_STRING([--with-python=PATH], [To enable dpython support or specify an alternative directory for python installation, disabled by default])],121 [AS_HELP_STRING([--with-python=PATH], [To enable python support or specify an alternative directory for python installation, disabled by default])], 122 122 [PYTHON_PATH="$withval"; PYTHON_ENABLED="-DUSE_PYTHON"], [PYTHON_ENABLED=""]) 123 123 … … 164 164 165 165 AC_ARG_WITH([php], 166 [AS_HELP_STRING([--with-php=PATH], [To enable dphp support or specify an alternative directory for php installation, disabled by default])],166 [AS_HELP_STRING([--with-php=PATH], [To enable php support or specify an alternative directory for php installation, disabled by default])], 167 167 [PHP_PATH="$withval"; PHP_ENABLED="-DUSE_PHP"], [PHP_ENABLED=""]) 168 168 … … 209 209 210 210 AC_ARG_WITH([perl], 211 [AS_HELP_STRING([--with-perl=PATH], [To enable dperl support or specify an alternative directory for perl installation, disabled by default])],211 [AS_HELP_STRING([--with-perl=PATH], [To enable perl support or specify an alternative directory for perl installation, disabled by default])], 212 212 [PERL_PATH="$withval"; PERL_ENABLED="-DUSE_PERL"], [PERL_ENABLED=""]) 213 213 … … 217 217 PERL_FILE="" 218 218 else 219 PERLCONFIG="$PERL_PATH/bin/perl" 220 PHP_FILE="service_internal_perl.o" 219 PERL_FILE="service_internal_perl.o" 221 220 if test "$PERL_PATH" = "yes" 222 221 then 223 # P HPwas not specified, so search within the current path222 # Perl was not specified, so search within the current path 224 223 AC_PATH_PROG([PERLCONFIG], [perl]) 225 224 else … … 249 248 250 249 AC_ARG_WITH([java], 251 [AS_HELP_STRING([--with-java=PATH], [To enable djava support, specify a JDK_HOME, disabled by default])],250 [AS_HELP_STRING([--with-java=PATH], [To enable java support, specify a JDK_HOME, disabled by default])], 252 251 [JDKHOME="$withval"; JAVA_ENABLED="-DUSE_JAVA"], [JAVA_ENABLED=""]) 253 252 … … 308 307 309 308 AC_ARG_WITH([js], 310 [AS_HELP_STRING([--with-js=PATH], [specify --with-js=path-to-js to enable djs support, specify --with-js on linux debian like, js support is disabled by default ])],309 [AS_HELP_STRING([--with-js=PATH], [specify --with-js=path-to-js to enable js support, specify --with-js on linux debian like, js support is disabled by default ])], 311 310 [JSHOME="$withval";JS_ENABLED="-DUSE_JS"], [JS_ENABLED=""]) 312 311 -
branches/branch-1.2/zoo-kernel/main_conf_read.y
r9 r217 25 25 using namespace std; 26 26 27 extern void crerror(c har *s);27 extern void crerror(const char *s); 28 28 29 29 void usage(void) ; … … 304 304 /* fonction qui affiche l erreur si il y en a une */ 305 305 //====================================================== 306 void crerror(c har *s)306 void crerror(const char *s) 307 307 { 308 308 if(debug) … … 314 314 /* fonction principale : entrée dans le programme */ 315 315 //====================================================== 316 int conf_read(c har* file,maps* my_map){316 int conf_read(const char* file,maps* my_map){ 317 317 318 318 crin = fopen(file,"r"); … … 335 335 336 336 fclose(crin); 337 #ifndef WIN32 337 338 crlex_destroy(); 339 #endif 338 340 339 341 return resultatYYParse; -
branches/branch-1.2/zoo-kernel/makefile.vc
r1 r217 1 GEODIR=c:/OSGeo4W 2 DESTDIR=c:/OSGeo4W 3 TPATH=..\..\..\tools 4 TOOLS=$(TPATH)\bin 5 CFLAGS=/EHa /nologo /MT /W3 /GX /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I./ -I..\thirds\dirent-win32 -IC:\OSGeo4W\apps\Python25\include -I$(GEODIR)/include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG 6 CC=cl $(CFLAGS) 7 CPP=cl /TP $(CFLAGS) 1 # WIN32 Makefile tested using VC-9.0 2 # Don't forget to set your PATH using the following command : 3 # c:\Progam Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat 4 # set PATH=%PATH%;$(TOOLS) 5 # using value for TOOLS relative to your local installation 6 # 8 7 9 all: service_loader 8 !INCLUDE nmake.opt 10 9 11 service_loader: service.h lex.sr.obj service_conf.tab.obj service_conf.y service_internal_python.obj service_loader.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj 12 cl $(CFLAGS) lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj service_internal_python.obj service_loader.obj -o service_loader -ldl `python-config --libs` `xml2-config --libs` -lfl -lcurl 10 all: zoo_loader.cgi 13 11 14 12 main_conf_read.tab.c: main_conf_read.y service.h … … 54 52 $(CPP) /EHsc /c $(CFLAGS) zoo_loader.c 55 53 54 dirent.obj: 55 $(CPP) /EHsc /c $(CFLAGS) ..\thirds\dirent-win32\dirent.c 56 56 57 zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj service_internal_python.obj ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj dirent.obj 57 link zoo_loader.obj dirent.obj service_internal.obj service_internal_python.obj ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj /out:zoo_loader.cgi $(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_imp.lib $(GEODIR)/apps/Python25/libs/python25.lib $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/libcgic.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)\..\lib\libeay32.dll.a $(TOOLS)\..\lib\libcrypto.a $(TOOLS)\..\lib\libssl32.dll.a /machine:i38658 link zoo_loader.obj dirent.obj service_internal.obj service_internal_python.obj ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj /out:zoo_loader.cgi $(LDFLAGS) 58 59 59 60 clean: 60 erase -f *. obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling61 erase -f *.cgi *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling -
branches/branch-1.2/zoo-kernel/service.h
r109 r217 28 28 #pragma once 29 29 30 #ifdef WIN32 31 #define strncasecmp strnicmp 32 #define strcasecmp stricmp 33 #define snprintf sprintf_s 34 #endif 35 30 36 #ifdef __cplusplus 31 37 extern "C" { … … 55 61 #define SHMSZ 27 56 62 63 64 /** 65 * \struct map 66 * \brief KVP linked list 67 * 68 * Deal with WPS KVP (name,value). 69 * A map is defined as: 70 * - name : a key, 71 * - value: a value, 72 * - next : a pointer to the next map if any. 73 */ 74 typedef struct map{ 75 char* name; 76 char* value; 77 struct map* next; 78 } map; 79 80 #ifdef WIN32 81 #define NULLMAP ((map*) 0) 82 #else 83 #define NULLMAP NULL 84 #endif 85 57 86 /** 58 87 * \struct maps … … 60 89 * 61 90 * Small object to store WPS KVP set. 91 * Maps is defined as: 92 * - a name, 93 * - a content map, 94 * - a pointer to the next maps if any. 62 95 */ 63 96 typedef struct maps{ … … 68 101 69 102 /** 70 * \struct map 71 * \brief KVP linked list 72 * 73 * Deal with WPS KVP (name,value). 103 * \brief Dump a map on stderr 74 104 */ 75 typedef struct map{76 char* name; /* The key */77 char* value; /* The value */78 struct map* next; /* Next couple */79 } map;80 81 #ifdef WIN3282 #define NULLMAP ((map*) 0)83 #else84 #define NULLMAP NULL85 #endif86 87 105 static void _dumpMap(map* t){ 88 106 if(t!=NULL){ … … 181 199 } 182 200 183 static map* getMapFromMaps(maps* m,char* key,char* subkey){ 201 static map* getLastMap(map* m){ 202 map* tmp=m; 203 while(tmp!=NULL){ 204 if(tmp->next==NULL){ 205 return tmp; 206 } 207 tmp=tmp->next; 208 } 209 return NULL; 210 } 211 212 static map* getMapFromMaps(maps* m,const char* key,const char* subkey){ 184 213 maps* _tmpm=getMaps(m,key); 185 214 if(_tmpm!=NULL){ … … 189 218 else return NULL; 190 219 } 220 221 static char* getMapsAsKVP(maps* m,int length,int type){ 222 char *dataInputsKVP=(char*) malloc(length*sizeof(char)); 223 maps* curs=m; 224 int i=0; 225 while(curs!=NULL){ 226 if(i==0) 227 if(type==0) 228 sprintf(dataInputsKVP,"%s=",curs->name); 229 else 230 sprintf(dataInputsKVP,"%s",curs->name); 231 else{ 232 char *temp=strdup(dataInputsKVP); 233 if(type==0) 234 sprintf(dataInputsKVP,"%s;%s=",temp,curs->name); 235 else 236 sprintf(dataInputsKVP,"%s;%s",temp,curs->name); 237 free(temp); 238 } 239 map* icurs=curs->content; 240 if(type==0){ 241 map* tmp=getMap(curs->content,"value"); 242 char *temp=strdup(dataInputsKVP); 243 if(getMap(m->content,"xlink:href")!=NULL) 244 sprintf(dataInputsKVP,"%sReference",temp); 245 else 246 sprintf(dataInputsKVP,"%s%s",temp,icurs->value); 247 free(temp); 248 } 249 int j=0; 250 while(icurs!=NULL){ 251 if(strcasecmp(icurs->name,"value")!=0 && 252 strcasecmp(icurs->name,"Reference")!=0 && 253 strcasecmp(icurs->name,"minOccurs")!=0 && 254 strcasecmp(icurs->name,"maxOccurs")!=0 && 255 strcasecmp(icurs->name,"inRequest")!=0){ 256 char *itemp=strdup(dataInputsKVP); 257 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value); 258 free(itemp); 259 } 260 icurs=icurs->next; 261 } 262 curs=curs->next; 263 i++; 264 } 265 return dataInputsKVP; 266 } 267 191 268 192 269 static void freeMap(map** mo){ … … 224 301 } 225 302 303 /** 304 * \brief Not named linked list 305 * 306 * Used to store informations about formats, such as mimeType, encoding ... 307 * 308 * An iotype is defined as : 309 * - a content map, 310 * - a pointer to the next iotype if any. 311 */ 226 312 typedef struct iotype{ 227 313 struct map* content; … … 229 315 } iotype; 230 316 317 /** 318 * \brief Metadata information about input or output. 319 * 320 * The elements are used to store metadata informations defined in the ZCFG. 321 * 322 * An elements is defined as : 323 * - a name, 324 * - a content map, 325 * - a metadata map, 326 * - a format (possible values are LiteralData, ComplexData or 327 * BoundingBoxData), 328 * - a default iotype, 329 * - a pointer to the next elements id any. 330 */ 231 331 typedef struct elements{ 232 332 char* name; … … 252 352 } services; 253 353 254 static bool hasElement(elements* e,c har* key){354 static bool hasElement(elements* e,const char* key){ 255 355 elements* tmp=e; 256 356 while(tmp!=NULL){ … … 476 576 477 577 478 static void setMapInMaps(maps* m,c har* key,char* subkey,char *value){578 static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){ 479 579 maps* _tmpm=getMaps(m,key); 480 580 if(_tmpm!=NULL){ 481 581 map* _ztmpm=getMap(_tmpm->content,subkey); 482 582 if(_ztmpm!=NULL){ 483 free(_ztmpm->value); 583 if(_ztmpm->value!=NULL) 584 free(_ztmpm->value); 484 585 _ztmpm->value=strdup(value); 485 586 }else{ -
branches/branch-1.2/zoo-kernel/service_conf.l
r100 r217 41 41 42 42 attname [a-zA-Z0-9_\-]+ 43 attvalue1 [\^\*\+,;@a-zA-Z0-9_\-::.:" "\"\'/\\\(\) ]+43 attvalue1 [\^\*\+,;@a-zA-Z0-9_\-::.:" "\"\'/\\\(\)\t\|]+ 44 44 45 45 attvalue \"[^"]*\"|\'[^']*\'\(\) 46 46 47 whitespace [ ]{0,}48 whitesp [ ]47 whitespace [\t]{0,}|[ ]{0,} 48 whitesp [\t]|[ ] 49 49 newline [\r\n]|[\n] 50 50 newlines [\r\n]{1,}|[\n]{1,} -
branches/branch-1.2/zoo-kernel/service_conf.y
r104 r217 36 36 static int previous_data=0; 37 37 static int current_data=0; 38 static char* myFinalObjectAsJSON="{";39 38 // namespace 40 39 using namespace std; … … 42 41 43 42 // srerror 44 void srerror(c har *s);43 void srerror(const char *s); 45 44 //====================================================== 46 45 … … 713 712 /* fonction qui affiche l erreur si il y en a une */ 714 713 //====================================================== 715 void srerror(c har *s)714 void srerror(const char *s) 716 715 { 717 716 if(debug) … … 724 723 * definition file. 725 724 */ 726 int getServiceFromFile(c har* file,service** service){725 int getServiceFromFile(const char* file,service** service){ 727 726 728 727 freeMap(&previous_content); … … 802 801 *service=my_service; 803 802 803 #ifndef WIN32 804 804 srlex_destroy(); 805 #endif 805 806 return resultatYYParse; 806 807 } -
branches/branch-1.2/zoo-kernel/service_internal.c
r94 r217 25 25 #include "service_internal.h" 26 26 27 void *addLangAttr(xmlNodePtr n,maps *m){ 27 #ifdef WIN32 28 char * 29 strtok_r (char *s1, const char *s2, char **lasts) 30 { 31 char *ret; 32 if (s1 == NULL) 33 s1 = *lasts; 34 while (*s1 && strchr(s2, *s1)) 35 ++s1; 36 if (*s1 == '\0') 37 return NULL; 38 ret = s1; 39 while (*s1 && !strchr(s2, *s1)) 40 ++s1; 41 if (*s1) 42 *s1++ = '\0'; 43 *lasts = s1; 44 return ret; 45 } 46 #endif 47 48 void addLangAttr(xmlNodePtr n,maps *m){ 28 49 map *tmpLmap=getMapFromMaps(m,"main","language"); 29 50 if(tmpLmap!=NULL) … … 44 65 } 45 66 46 void* unhandleStatus(maps *conf){ 67 #ifdef WIN32 68 69 #include <windows.h> 70 #include <stdio.h> 71 #include <conio.h> 72 #include <tchar.h> 73 74 #define SHMEMSIZE 4096 75 76 static LPVOID lpvMemG = NULL; // pointer to shared memory 77 static HANDLE hMapObjectG = NULL; // handle to file mapping 78 79 void updateStatus(maps *conf){ 80 fprintf(stderr,"OK Final 1 \n"); 81 fflush(stderr); 82 LPWSTR lpszTmp; 83 BOOL fInit; 84 char *s=NULL; 85 map *tmpMap=getMapFromMaps(conf,"lenv","sid"); 86 fprintf(stderr,"OK Final 11 \n"); 87 fflush(stderr); 88 if(hMapObjectG==NULL) 89 hMapObjectG = CreateFileMapping( 90 INVALID_HANDLE_VALUE, // use paging file 91 NULL, // default security attributes 92 PAGE_READWRITE, // read/write access 93 0, // size: high 32-bits 94 SHMEMSIZE, // size: low 32-bits 95 TEXT(tmpMap->value)); // name of map object 96 if (hMapObjectG == NULL){ 97 fprintf(stderr,"Unable to create share memory segment %s !! \n",tmpMap->value); 98 return ; 99 } 100 fprintf(stderr,"OK Final 2 \n"); 101 fflush(stderr); 102 fInit = (GetLastError() != ERROR_ALREADY_EXISTS); 103 if(lpvMemG==NULL) 104 lpvMemG = MapViewOfFile( 105 hMapObjectG, // object to map view of 106 FILE_MAP_WRITE, // read/write access 107 0, // high offset: map from 108 0, // low offset: beginning 109 0); // default: map entire file 110 if (lpvMemG == NULL){ 111 fprintf(stderr,"Unable to create or access the shared memory segment %s !! \n",tmpMap->value); 112 return ; 113 } 114 fprintf(stderr,"OK Final 3 \n"); 115 fflush(stderr); 116 if (fInit) 117 memset(lpvMemG, '\0', SHMEMSIZE); 118 fprintf(stderr,"OK Final 4 \n"); 119 fflush(stderr); 120 tmpMap=getMapFromMaps(conf,"lenv","status"); 121 lpszTmp = (LPWSTR) lpvMemG; 122 for(s=tmpMap->value;*s!=NULL;s++) 123 *lpszTmp++ = *s; 124 *lpszTmp = '\0'; 125 } 126 127 char* getStatus(int pid){ 128 LPWSTR lpszBuf=NULL; 129 LPWSTR lpszTmp=NULL; 130 LPVOID lpvMem = NULL; 131 HANDLE hMapObject = NULL; 132 BOOL fIgnore,fInit; 133 char tmp[100]; 134 sprintf(tmp,"%i",pid); 135 if(hMapObject==NULL) 136 hMapObject = CreateFileMapping( 137 INVALID_HANDLE_VALUE, // use paging file 138 NULL, // default security attributes 139 PAGE_READWRITE, // read/write access 140 0, // size: high 32-bits 141 4096, // size: low 32-bits 142 TEXT(tmp)); // name of map object 143 if (hMapObject == NULL) 144 return FALSE; 145 if((GetLastError() != ERROR_ALREADY_EXISTS)){ 146 fIgnore = UnmapViewOfFile(lpvMem); 147 fIgnore = CloseHandle(hMapObject); 148 return "-1"; 149 } 150 fInit=TRUE; 151 if(lpvMem==NULL) 152 lpvMem = MapViewOfFile( 153 hMapObject, // object to map view of 154 FILE_MAP_READ, // read/write access 155 0, // high offset: map from 156 0, // low offset: beginning 157 0); // default: map entire file 158 if (lpvMem == NULL) 159 return "-1"; 160 lpszTmp = (LPWSTR) lpvMem; 161 while (*lpszTmp!=NULL) 162 *lpszBuf++ = *lpszTmp++; 163 *lpszBuf = '\0'; 164 fIgnore = UnmapViewOfFile(lpvMem); 165 fIgnore = CloseHandle(hMapObject); 166 return (char*)lpszBuf; 167 } 168 169 void unhandleStatus(maps *conf){ 170 BOOL fIgnore; 171 fIgnore = UnmapViewOfFile(lpvMemG); 172 fIgnore = CloseHandle(hMapObjectG); 173 } 174 #else 175 void unhandleStatus(maps *conf){ 47 176 int shmid,i; 48 177 key_t key; … … 69 198 } 70 199 } 200 201 void updateStatus(maps *conf){ 202 int shmid,i; 203 key_t key; 204 char *shm,*s,*s1; 205 map *tmpMap=NULL; 206 tmpMap=getMapFromMaps(conf,"lenv","sid"); 207 if(tmpMap!=NULL){ 208 key=atoi(tmpMap->value); 209 if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) { 210 #ifdef DEBUG 211 fprintf(stderr,"shmget failed to update value\n"); 212 #endif 213 }else{ 214 if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) { 215 #ifdef DEBUG 216 fprintf(stderr,"shmat failed to update value\n"); 217 #endif 218 } 219 else{ 220 tmpMap=getMapFromMaps(conf,"lenv","status"); 221 s1=shm; 222 for(s=tmpMap->value;s!=NULL;s++) 223 *s1++=*s; 224 shmdt((void *)shm); 225 } 226 } 227 } 228 } 229 230 char* getStatus(int pid){ 231 int shmid,i; 232 key_t key; 233 void *shm; 234 char *s; 235 key=pid; 236 if ((shmid = shmget(key, SHMSZ, 0666)) < 0) { 237 #ifdef DEBUG 238 fprintf(stderr,"shmget failed in getStatus\n"); 239 #endif 240 }else{ 241 if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) { 242 #ifdef DEBUG 243 fprintf(stderr,"shmat failed in getStatus\n"); 244 #endif 245 }else{ 246 return (char*)shm; 247 } 248 } 249 return "-1"; 250 } 251 252 #endif 71 253 72 254 #ifdef USE_JS … … 109 291 #endif 110 292 111 void* updateStatus(maps *conf){112 int shmid,i;113 key_t key;114 char *shm,*s,*s1;115 map *tmpMap=NULL;116 tmpMap=getMapFromMaps(conf,"lenv","sid");117 if(tmpMap!=NULL){118 key=atoi(tmpMap->value);119 if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {120 #ifdef DEBUG121 fprintf(stderr,"shmget failed to update value\n");122 #endif123 }else{124 if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {125 #ifdef DEBUG126 fprintf(stderr,"shmat failed to update value\n");127 #endif128 }129 else{130 tmpMap=getMapFromMaps(conf,"lenv","status");131 s1=shm;132 for(s=tmpMap->value;*s!=NULL;s++)133 *s1++=*s;134 shmdt((void *)shm);135 }136 }137 }138 }139 140 char* getStatus(int pid){141 int shmid,i;142 key_t key;143 void *shm;144 char *s;145 key=pid;146 if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {147 #ifdef DEBUG148 fprintf(stderr,"shmget failed in getStatus\n");149 #endif150 }else{151 if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {152 #ifdef DEBUG153 fprintf(stderr,"shmat failed in getStatus\n");154 #endif155 }else{156 return (char*)shm;157 }158 }159 return "-1";160 }161 293 162 294 … … 216 348 217 349 218 int zooXmlSearchForNs(c har* name){350 int zooXmlSearchForNs(const char* name){ 219 351 int i; 220 352 int res=-1; … … 227 359 } 228 360 229 int zooXmlAddNs(xmlNodePtr nr,c har* url,char* name){361 int zooXmlAddNs(xmlNodePtr nr,const char* url,const char* name){ 230 362 #ifdef DEBUG 231 363 fprintf(stderr,"zooXmlAddNs %d \n",nbNs); … … 266 398 } 267 399 268 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr doc,c har* service,maps* m){400 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr doc,const char* service,maps* m){ 269 401 270 402 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; … … 618 750 } 619 751 620 xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,c har* service,maps* m){752 xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,const char* service,maps* m){ 621 753 622 754 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; … … 711 843 } 712 844 713 void printFullDescription(elements *elem,c har* type,xmlNsPtr ns_ows,xmlNodePtr nc1){845 void printFullDescription(elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){ 714 846 char *orderedFields[7]; 715 847 orderedFields[0]="mimeType"; … … 957 1089 } 958 1090 959 void printProcessResponse(maps* m,map* request, int pid,service* serv,c har* service,int status,maps* inputs,maps* outputs){1091 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){ 960 1092 xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi; 961 1093 xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor; … … 1192 1324 int buffersize; 1193 1325 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "UTF-8", 1); 1194 fwrite(xmlbuff,1, strlen(xmlbuff)*sizeof(char),output);1326 fwrite(xmlbuff,1,xmlStrlen(xmlbuff)*sizeof(char),output); 1195 1327 xmlFree(xmlbuff); 1196 1328 fclose(output); … … 1204 1336 1205 1337 void printDocument(maps* m, xmlDocPtr doc,int pid){ 1206 rewind(stdout);1207 1338 char *encoding=getEncoding(m); 1208 1339 if(pid==getpid()){ … … 1217 1348 */ 1218 1349 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1); 1219 printf( (char *)xmlbuff);1220 //fflush(stdout);1350 printf("%s",xmlbuff); 1351 fflush(stdout); 1221 1352 /* 1222 1353 * Free associated memory. … … 1228 1359 } 1229 1360 1230 void printOutputDefinitions1(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,c har* type){1361 void printOutputDefinitions1(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,const char* type){ 1231 1362 xmlNodePtr nc1; 1232 1363 nc1=xmlNewNode(ns_wps, BAD_CAST type); … … 1260 1391 } 1261 1392 1262 void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,c har* type){1393 void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,const char* type){ 1263 1394 xmlNodePtr nc1,nc2,nc3; 1264 1395 nc1=xmlNewNode(ns_wps, BAD_CAST type); … … 1288 1419 } 1289 1420 1290 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,c har* type){1421 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type){ 1291 1422 xmlNodePtr nc1,nc2,nc3; 1292 1423 nc1=xmlNewNode(ns_wps, BAD_CAST type); … … 1443 1574 } 1444 1575 1445 void printDescription(xmlNodePtr root,xmlNsPtr ns_ows,c har* identifier,map* amap){1576 void printDescription(xmlNodePtr root,xmlNsPtr ns_ows,const char* identifier,map* amap){ 1446 1577 xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "Identifier"); 1447 1578 xmlAddChild(nc2,xmlNewText(BAD_CAST identifier)); … … 1527 1658 maps* tmpMap=getMaps(m,"main"); 1528 1659 1529 int nsid=zooXmlAddNs(NULL, BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST"ows");1660 int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows"); 1530 1661 ns=usedNs[nsid]; 1531 1662 n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); … … 1708 1839 freeMap(&errormap); 1709 1840 free(errormap); 1710 return 1;1841 return; 1711 1842 } 1712 1843 char mime[1024]; … … 1757 1888 } 1758 1889 1759 char *base64(const unsignedchar *input, int length)1890 char *base64(const char *input, int length) 1760 1891 { 1761 1892 BIO *bmem, *b64; … … 1779 1910 } 1780 1911 1781 char *base64d( unsignedchar *input, int length,int* red)1912 char *base64d(const char *input, int length,int* red) 1782 1913 { 1783 1914 BIO *b64, *bmem; … … 1788 1919 b64 = BIO_new(BIO_f_base64()); 1789 1920 if(b64){ 1790 bmem = BIO_new_mem_buf( input,length);1921 bmem = BIO_new_mem_buf((unsigned char*)input,length); 1791 1922 bmem = BIO_push(b64, bmem); 1792 1923 *red=BIO_read(bmem, buffer, length); … … 1972 2103 * Note : support only 2D bounding box. 1973 2104 */ 1974 map* parseBoundingBox(c har* value){2105 map* parseBoundingBox(const char* value){ 1975 2106 map *res=NULL; 1976 2107 if(value!=NULL){ 1977 2108 char *cv,*cvp; 1978 cv=strtok_r( value,",",&cvp);2109 cv=strtok_r((char*) value,",",&cvp); 1979 2110 int cnt=0; 1980 2111 int icnt=0; … … 2078 2209 ns_ows=usedNs[owsId]; 2079 2210 n = xmlNewNode(ns_ows, BAD_CAST "BoundingBox"); 2080 xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1", "ows");2211 xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows"); 2081 2212 int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi"); 2082 2213 ns_xsi=usedNs[xsiId]; … … 2089 2220 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1); 2090 2221 if(file==NULL) 2091 printf( (char *)xmlbuff);2222 printf("%s",xmlbuff); 2092 2223 else{ 2093 2224 fprintf(file,"%s",xmlbuff); -
branches/branch-1.2/zoo-kernel/service_internal.h
r88 r217 38 38 #include <sys/stat.h> 39 39 #include <sys/types.h> 40 #ifndef WIN32 40 41 #include <sys/ipc.h> 41 42 #include <sys/shm.h> 43 #else 44 #include <direct.h> 45 #endif 42 46 #include <stdio.h> 43 47 #include <unistd.h> … … 54 58 #include <openssl/buffer.h> 55 59 56 extern int getServiceFromFile(c har*,service**);57 extern int conf_read(c har*,maps*);60 extern int getServiceFromFile(const char*,service**); 61 extern int conf_read(const char*,maps*); 58 62 59 63 #ifdef USE_JS … … 71 75 static int nbNs=0; 72 76 73 void *unhandleStatus(maps*);74 void *updateStatus(maps*);77 void unhandleStatus(maps*); 78 void updateStatus(maps*); 75 79 char* getStatus(int); 76 80 … … 84 88 char* getEncoding(maps*); 85 89 86 int zooXmlSearchForNs(c har*);87 int zooXmlAddNs(xmlNodePtr,c har*,char*);90 int zooXmlSearchForNs(const char*); 91 int zooXmlAddNs(xmlNodePtr,const char*,const char*); 88 92 void zooXmlCleanupNs(); 89 93 90 94 void printExceptionReportResponse(maps*,map*); 91 95 xmlNodePtr createExceptionReportNode(maps*,map*,int); 92 void printProcessResponse(maps*,map*,int,service*,c har*,int,maps*,maps*);93 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,c har*,maps*);96 void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*); 97 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,const char*,maps*); 94 98 void printGetCapabilitiesForProcess(maps*,xmlNodePtr,service*); 95 xmlNodePtr printDescribeProcessHeader(xmlDocPtr,c har*,maps*);99 xmlNodePtr printDescribeProcessHeader(xmlDocPtr,const char*,maps*); 96 100 void printDescribeProcessForProcess(maps*,xmlNodePtr,service*,int); 97 void printFullDescription(elements*,c har*,xmlNsPtr,xmlNodePtr);101 void printFullDescription(elements*,const char*,xmlNsPtr,xmlNodePtr); 98 102 void printDocument(maps*,xmlDocPtr,int); 99 void printDescription(xmlNodePtr,xmlNsPtr,c har*,map*);100 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,c har*);101 map* parseBoundingBox(c har*);103 void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*); 104 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); 105 map* parseBoundingBox(const char*); 102 106 void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); 103 107 void printBoundingBoxDocument(maps*,maps*,FILE*); 104 void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,c har*);108 void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); 105 109 106 110 void outputResponse(service*,maps*,maps*,map*,int,maps*,int); 107 111 108 char *base64(const unsignedchar*,int);109 char *base64d( unsignedchar*,int,int*);112 char *base64(const char*,int); 113 char *base64d(const char*,int,int*); 110 114 void ensureDecodedBase64(maps**); 111 115 -
branches/branch-1.2/zoo-kernel/service_internal_java.c
r68 r217 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 0GeoLabs SARL4 * Copyright (c) 2009-2011 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 118 118 119 119 pValue=(*env)->CallStaticIntMethod(env,cls,pmid,arg1,arg2,arg3); 120 if (pValue != NULL){120 if (pValue != (jint)NULL){ 121 121 res=pValue; 122 122 m=mapsFromHashMap(env,arg1,scHashMapClass); … … 233 233 jobject scObject,scObject1; 234 234 if(scHashMapClass==NULL){ 235 #ifdef DEBUG 235 236 fprintf(stderr,"Unable to load java.util.HashMap\n"); 237 #endif 236 238 return NULL; 237 239 } … … 239 241 containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z"); 240 242 get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 243 241 244 if(containsKey_mid==0){ 245 #ifdef DEBUG 242 246 fprintf(stderr,"unable to load containsKey from HashMap object (%d) \n",entrySet_mid); 247 #endif 248 return NULL; 243 249 } 244 250 if(get_mid==0){ 251 #ifdef DEBUG 245 252 fprintf(stderr,"unable to load get from HashMap object (%d) \n",entrySet_mid); 253 #endif 254 return NULL; 246 255 } 247 256 if(entrySet_mid==0){ 257 #ifdef DEBUG 248 258 fprintf(stderr,"unable to load entrySet from HashMap object (%d) \n",entrySet_mid); 259 #endif 249 260 return NULL; 250 261 } … … 296 307 if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){ 297 308 jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size")); 298 jstringsizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL);309 const char* sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL); 299 310 size=atoi(sizeVS); 300 311 fprintf(stderr,"SIZE : %s\n",sizeVS); 312 (*env)->ReleaseStringUTFChars(env, sizeV, sizeVS); 301 313 } 302 314 … … 306 318 jobject jv=(*env)->CallObjectMethod(env,tmp1,getValue_mid); 307 319 308 jstringjkd=(*env)->GetStringUTFChars(env, jk, NULL);320 const char* jkd=(*env)->GetStringUTFChars(env, jk, NULL); 309 321 if(size>=0 && strcmp(jkd,"value")==0){ 310 fprintf(stderr,"%s\n",jkd);311 322 jobject value=(*env)->GetByteArrayElements(env, jv, NULL); 312 323 if(res==NULL){ … … 315 326 addToMap(res,jkd,""); 316 327 } 317 fprintf(stderr,"/%s\n",jkd);318 328 map* tmpR=getMap(res,"value"); 319 329 free(tmpR->value); … … 321 331 memmove(tmpR->value,value,size*sizeof(char)); 322 332 tmpR->value[size]=0; 323 fprintf(stderr,"/%s\n",jkd); 333 char tmp[128]; 334 sprintf(tmp,"%d",size); 335 addToMap(res,"size",tmp); 324 336 } 325 337 else{ 326 jstringjvd=(*env)->GetStringUTFChars(env, jv, NULL);338 const char* jvd=(*env)->GetStringUTFChars(env, jv, NULL); 327 339 if(res==NULL){ 328 340 res=createMap(jkd,jvd); … … 330 342 addToMap(res,jkd,jvd); 331 343 } 332 (*env)->ReleaseString Chars(env, jv, jvd);344 (*env)->ReleaseStringUTFChars(env, jv, jvd); 333 345 } 334 346 335 #ifdef DEBUG 336 fprintf(stderr,"%s %s\n",jkd,jvd); 337 #endif 338 339 (*env)->ReleaseStringChars(env, jk, jkd); 347 (*env)->ReleaseStringUTFChars(env, jk, jkd); 340 348 341 349 } -
branches/branch-1.2/zoo-kernel/service_internal_python.c
r108 r217 86 86 } 87 87 pModule = PyImport_Import(pName); 88 int i;89 88 int res=SERVICE_FAILED; 90 int cpid=getpid();91 89 if (pModule != NULL) { 92 90 pFunc=PyObject_GetAttrString(pModule,s->name); 93 91 if (pFunc && PyCallable_Check(pFunc)){ 92 PyObject *pValue; 94 93 PyDictObject* arg1=PyDict_FromMaps(m); 95 94 PyDictObject* arg2=PyDict_FromMaps(inputs); 96 95 PyDictObject* arg3=PyDict_FromMaps(outputs); 97 96 PyObject *pArgs=PyTuple_New(3); 98 PyObject *pValue; 97 if (!pArgs) 98 return -1; 99 99 PyTuple_SetItem(pArgs, 0, (PyObject *)arg1); 100 100 PyTuple_SetItem(pArgs, 1, (PyObject *)arg2); … … 130 130 PyErr_Fetch(&ptype, &pvalue, &ptraceback); 131 131 PyObject *trace=PyObject_Str(pvalue); 132 char tb[1024];133 132 char pbt[10240]; 134 133 if(PyString_Check(trace)) … … 145 144 else 146 145 fprintf(stderr,"EMPTY TRACE ?"); 147 PyObject *t;148 146 pName = PyString_FromString("traceback"); 149 147 pModule = PyImport_Import(pName); … … 302 300 int nb=PyList_Size(list); 303 301 int i; 304 int sizeValue=-1;305 302 for(i=0;i<nb;i++){ 306 303 PyObject* key=PyList_GetItem(list,i); -
branches/branch-1.2/zoo-kernel/zoo_loader.c
r99 r217 26 26 #define MALLOC_CHECK 0 27 27 28 #ifdef WIN32 29 #include "windows.h" 30 #endif 28 31 /** 29 32 * Specific includes … … 45 48 } 46 49 47 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,c har*);50 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*); 48 51 int runRequest(map*); 49 52 … … 64 67 /* ************************************************************************* */ 65 68 66 #ifndef STRTOK_R67 char *68 strtok_r (char *s1, const char *s2, char **lasts)69 {70 char *ret;71 72 if (s1 == NULL)73 s1 = *lasts;74 while (*s1 && strchr(s2, *s1))75 ++s1;76 if (*s1 == '\0')77 return NULL;78 ret = s1;79 while (*s1 && !strchr(s2, *s1))80 ++s1;81 if (*s1)82 *s1++ = '\0';83 *lasts = s1;84 return ret;85 }86 87 #endif88 69 89 70 #define TRUE 1 … … 192 173 addToMap(tmpMap,"language",tval); 193 174 194 c har* requests[3];175 const char* requests[3]; 195 176 requests[0]="GetCapabilities"; 196 177 requests[1]="DescribeProcess"; … … 206 187 #endif 207 188 if(req!=NULL && req->nodeNr==1){ 208 t1->value= requests[j];189 t1->value=strdup(requests[j]); 209 190 j=2; 210 191 } -
branches/branch-1.2/zoo-kernel/zoo_service_loader.c
r109 r217 94 94 } 95 95 96 xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,c har* search){96 xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,const char* search){ 97 97 xmlXPathContextPtr xpathCtx; 98 98 xmlXPathObjectPtr xpathObj; … … 110 110 void sig_handler(int sig){ 111 111 char tmp[100]; 112 c har *ssig;112 const char *ssig; 113 113 switch(sig){ 114 114 case SIGSEGV: … … 153 153 map* r_inputs=NULL; 154 154 #ifndef WIN32 155 getcwd(ntmp,1024);155 char* pntmp=getcwd(ntmp,1024); 156 156 #else 157 157 _getcwd(ntmp,1024); … … 203 203 #endif 204 204 if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){ 205 #ifdef WIN32206 //Strange return value needed here !207 return 1;208 #endif209 205 r_inputs=getMap(request_inputs,"Identifier"); 210 206 char fname[1024]; … … 284 280 #endif 285 281 } 282 #ifdef WIN32 283 *ioutputs=dupMaps(&request_output_real_format); 284 FreeLibrary(so); 285 #else 286 286 dlclose(so); 287 #endif 287 288 } else { 288 289 /** … … 345 346 } 346 347 *myMap=m; 348 #ifndef WIN32 347 349 *ioutputs=request_output_real_format; 350 #endif 348 351 } 352 353 #ifdef WIN32 354 /** 355 * createProcess function: create a new process after setting some env variables 356 */ 357 void createProcess(maps* m,map* request_inputs,service* s1,char* opts,int cpid, maps* inputs,maps* outputs){ 358 STARTUPINFO si; 359 PROCESS_INFORMATION pi; 360 ZeroMemory( &si, sizeof(si) ); 361 si.cb = sizeof(si); 362 ZeroMemory( &pi, sizeof(pi) ); 363 char *tmp=(char *)malloc((1024+cgiContentLength)*sizeof(char)); 364 char *tmpq=(char *)malloc((1024+cgiContentLength)*sizeof(char)); 365 map *req=getMap(request_inputs,"request"); 366 map *id=getMap(request_inputs,"identifier"); 367 map *di=getMap(request_inputs,"DataInputs"); 368 369 char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0); 370 char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1); 371 fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP); 372 fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP); 373 map *sid=getMapFromMaps(m,"lenv","sid"); 374 map* r_inputs=getMapFromMaps(m,"main","tmpPath"); 375 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 376 map* r_inputs2=getMap(s1->content,"ResponseDocument"); 377 if(r_inputs2==NULL) 378 r_inputs2=getMap(s1->content,"RawDataOutput"); 379 map *tmpPath=getMapFromMaps(m,"lenv","cwd"); 380 381 if(r_inputs2!=NULL){ 382 sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value); 383 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP); 384 } 385 else{ 386 sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value); 387 sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value); 388 } 389 390 char *tmp1=strdup(tmp); 391 sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value); 392 393 free(dataInputsKVP); 394 free(dataOutputsKVP); 395 fprintf(stderr,"REQUEST IS : %s \n",tmp); 396 SetEnvironmentVariable("CGISID",TEXT(sid->value)); 397 SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq)); 398 char clen[1000]; 399 sprintf(clen,"%d",strlen(tmpq)); 400 SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen)); 401 402 if( !CreateProcess( NULL, // No module name (use command line) 403 TEXT(tmp), // Command line 404 NULL, // Process handle not inheritable 405 NULL, // Thread handle not inheritable 406 FALSE, // Set handle inheritance to FALSE 407 CREATE_NO_WINDOW, // Apache won't wait until the end 408 NULL, // Use parent's environment block 409 NULL, // Use parent's starting directory 410 &si, // Pointer to STARTUPINFO struct 411 &pi ) // Pointer to PROCESS_INFORMATION struct 412 ) 413 { 414 fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() ); 415 return ; 416 }else{ 417 fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() ); 418 } 419 CloseHandle( pi.hProcess ); 420 CloseHandle( pi.hThread ); 421 fprintf(stderr,"CreateProcess finished !\n"); 422 } 423 #endif 349 424 350 425 int runRequest(map* request_inputs) … … 360 435 #endif 361 436 362 map* r_inputs=NULL ,*tmps=NULL;437 map* r_inputs=NULL; 363 438 maps* m=NULL; 364 int argc=count(request_inputs);365 439 366 440 char* REQUEST=NULL; … … 374 448 char ntmp[1024]; 375 449 #ifndef WIN32 376 getcwd(ntmp,1024);450 char *pntmp=getcwd(ntmp,1024); 377 451 #else 378 452 _getcwd(ntmp,1024); … … 470 544 } 471 545 472 map* outputs=NULL;473 546 maps* request_output_real_format=NULL; 474 547 map* tmpm=getMapFromMaps(m,"main","serverAddress"); … … 478 551 SERVICE_URL=strdup(DEFAULT_SERVICE_URL); 479 552 480 service* s[100];481 553 service* s1; 482 554 int scount=0; … … 497 569 498 570 if(strncasecmp(REQUEST,"GetCapabilities",15)==0){ 499 int i=0;500 571 struct dirent *dp; 501 572 #ifdef DEBUG … … 510 581 r_inputs=getMap(request_inputs,"ServiceProvider"); 511 582 xmlNodePtr n; 512 //dumpMap(request_inputs);513 583 if(r_inputs!=NULL) 514 584 n = printGetCapabilitiesHeader(doc,r_inputs->value,m); … … 516 586 n = printGetCapabilitiesHeader(doc,"",m); 517 587 /** 518 * Strange, here we need to close stdout to ensure that no uneeded519 * char will be printed (parser issue ?)588 * Here we need to close stdout to ensure that not supported chars 589 * has been found in the zcfg and then printed on stdout 520 590 */ 521 591 int saved_stdout = dup(fileno(stdout)); … … 595 665 char buff[256]; 596 666 char buff1[1024]; 597 int i=0;598 int j=0;599 int end=-1;600 667 int saved_stdout = dup(fileno(stdout)); 601 668 dup2(fileno(stderr),fileno(stdout)); … … 611 678 memset(buff1,0,1024); 612 679 snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name); 613 //s1=(service*)malloc(sizeof(service*));614 680 s1=(service*)calloc(1,SERVICE_SIZE); 615 681 if(s1 == NULL){ … … 640 706 free(SERVICE_URL); 641 707 fflush(stdout); 642 //xmlFree(n);643 708 #ifndef LINUX_FREE_ISSUE 644 709 if(s1) … … 654 719 #endif 655 720 closedir(dirp); 656 free(s);657 721 return 0; 658 722 } … … 682 746 #endif 683 747 int saved_stdout = dup(fileno(stdout)); 684 dup2(fileno(stderr),fileno(stdout));748 dup2(fileno(stderr),fileno(stdout)); 685 749 t=getServiceFromFile(tmps1,&s1); 686 750 fflush(stdout); 687 751 dup2(saved_stdout,fileno(stdout)); 688 752 if(t<0){ 689 char tmpMsg[2048+strlen(r_inputs->value)]; 753 char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value)); 754 690 755 sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value); 691 756 errorException(m, tmpMsg, "InvalidParameterValue"); 757 free(tmpMsg); 692 758 freeService(&s1); 693 759 free(s1); … … 698 764 return 0; 699 765 } 700 close(saved_stdout);766 //close(saved_stdout); 701 767 702 768 #ifdef DEBUG 703 769 dumpService(s1); 704 770 #endif 705 map* inputs=NULL;706 elements* c_inputs=s1->inputs;707 771 int j; 708 772 … … 747 811 fprintf(stderr,"OUTPUT Parsing start now ... \n"); 748 812 #endif 749 char current_output_as_string[10240];750 813 char cursor_output[10240]; 751 814 char *cotmp=strdup(r_inputs->value); … … 753 816 free(cotmp); 754 817 j=0; 755 map* request_kvp_outputs=NULL;756 818 757 819 /** … … 834 896 fflush(stderr); 835 897 #endif 836 //tmp_output=tmp_output->next;837 898 free(tmp); 838 899 } … … 848 909 fprintf(stderr,"DATA INPUTS [%s]\n",r_inputs->value); 849 910 #endif 850 char current_input_as_string[40960];851 911 char cursor_input[40960]; 852 912 if(r_inputs!=NULL) … … 864 924 } 865 925 j=0; 866 map* request_kvp_inputs=NULL;867 926 868 927 /** … … 905 964 char tmpn[256]; 906 965 memset(tmpn,0,256); 907 strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char)); 908 tmpn[strlen(tmpc)-strlen(tmpv)]=0; 909 int cnt=0; 966 if(tmpv!=NULL){ 967 strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char)); 968 tmpn[strlen(tmpc)-strlen(tmpv)]=0; 969 } 970 else{ 971 strncpy(tmpn,tmpc,strlen(tmpc)*sizeof(char)); 972 tmpn[strlen(tmpc)]=0; 973 } 910 974 #ifdef DEBUG 911 975 fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1); … … 917 981 } 918 982 tmpmaps->name=strdup(tmpn); 919 tmpmaps->content=createMap("value",tmpv+1); 983 if(tmpv!=NULL) 984 tmpmaps->content=createMap("value",tmpv+1); 985 else 986 tmpmaps->content=createMap("value","Reference"); 920 987 tmpmaps->next=NULL; 921 988 } … … 931 998 char tmpn1[1024]; 932 999 memset(tmpn1,0,1024); 933 strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1)); 934 tmpn1[strlen(tmpc)-strlen(tmpv1)]=0; 1000 if(tmpv1!=NULL){ 1001 strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1)); 1002 tmpn1[strlen(tmpc)-strlen(tmpv1)]=0; 1003 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 1004 } 1005 else{ 1006 strncpy(tmpn1,tmpc,strlen(tmpc)); 1007 tmpn1[strlen(tmpc)]=0; 1008 map* lmap=getLastMap(tmpmaps->content); 1009 char *tmpValue=(char*)calloc((strlen(lmap->value)+strlen(tmpc)+1),sizeof(char)); 1010 sprintf(tmpValue,"%s@%s",lmap->value,tmpc); 1011 free(lmap->value); 1012 lmap->value=strdup(tmpValue); 1013 free(tmpValue); 1014 dumpMap(tmpmaps->content); 1015 tmpc=strtok(NULL,"@"); 1016 continue; 1017 } 935 1018 #ifdef DEBUG 936 1019 fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1); … … 939 1022 if(strcmp(tmpn1,"xlink:href")!=0) 940 1023 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 941 else{ 942 #ifdef DEBUG 943 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1024 else 1025 if(tmpv1!=NULL){ 1026 if(strncasecmp(tmpv1+1,"http://",7)!=0 && 1027 strncasecmp(tmpv1+1,"ftp://",6)!=0){ 1028 char emsg[1024]; 1029 sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1); 1030 errorException(m,emsg,"InternalError"); 1031 freeMaps(&m); 1032 free(m); 1033 free(REQUEST); 1034 free(SERVICE_URL); 1035 InternetCloseHandle(hInternet); 1036 freeService(&s1); 1037 free(s1); 1038 return 0; 1039 } 1040 #ifdef DEBUG 1041 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 944 1042 #endif 945 1043 #ifndef WIN32 946 if(CHECK_INET_HANDLE(hInternet)) 947 #endif 948 { 949 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 950 INTERNET_FLAG_NO_CACHE_WRITE,0); 951 #ifdef DEBUG 952 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 953 tmpv1+1,res.nDataAlloc,res.nDataLen); 954 #endif 955 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 956 if(tmpContent == NULL){ 957 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1044 if(CHECK_INET_HANDLE(hInternet)) 1045 #endif 1046 { 1047 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1048 INTERNET_FLAG_NO_CACHE_WRITE,0); 1049 #ifdef DEBUG 1050 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1051 tmpv1+1,res.nDataAlloc,res.nDataLen); 1052 #endif 1053 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1054 if(tmpContent == NULL){ 1055 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1056 } 1057 size_t dwRead; 1058 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 1059 map* tmpMap=getMap(tmpmaps->content,"value"); 1060 if(tmpMap!=NULL){ 1061 free(tmpMap->value); 1062 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 1063 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 1064 tmpMap->value[res.nDataLen]=0; 1065 if(strlen(tmpContent)!=res.nDataLen){ 1066 char tmp[256]; 1067 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 1068 addToMap(tmpmaps->content,"size",tmp); 1069 } 1070 } 1071 free(tmpContent); 958 1072 } 959 size_t dwRead; 960 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 961 map* tmpMap=getMap(tmpmaps->content,"value"); 962 if(tmpMap!=NULL){ 963 free(tmpMap->value); 964 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 965 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 966 tmpMap->value[res.nDataLen]=0; 967 if(strlen(tmpContent)!=res.nDataLen){ 968 char tmp[256]; 969 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 970 addToMap(tmpmaps->content,"size",tmp); 971 } 972 } 973 free(tmpContent); 974 } 975 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 976 addToMap(tmpmaps->content,"Reference",tmpv1+1); 977 } 1073 char *tmpx=url_encode(tmpv1+1); 1074 addToMap(tmpmaps->content,tmpn1,tmpx); 1075 free(tmpx); 1076 addToMap(tmpmaps->content,"Reference",tmpv1+1); 1077 dumpMap(tmpmaps->content); 1078 } 978 1079 tmpc=strtok(NULL,"@"); 979 1080 } … … 1010 1111 fflush(stderr); 1011 1112 #endif 1012 xmlNodePtr cur = xmlDocGetRootElement(doc);1013 1113 /** 1014 1114 * Parse every Input in DataInputs node. 1015 1115 */ 1016 maps* tempMaps=NULL;1017 1116 xmlXPathObjectPtr tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='Input']"); 1018 1117 xmlNodeSet* tmps=tmpsptr->nodesetval; … … 1064 1163 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1065 1164 } 1066 tmpmaps->name= "missingIndetifier";1165 tmpmaps->name=strdup("missingIndetifier"); 1067 1166 tmpmaps->content=createMap((char*)cur2->name,(char*)val); 1068 1167 tmpmaps->next=NULL; … … 1093 1192 fprintf(stderr,"REFERENCE\n"); 1094 1193 #endif 1095 map* referenceMap=NULL; 1096 char *refs[5]; 1194 const char *refs[5]; 1097 1195 refs[0]="mimeType"; 1098 1196 refs[1]="encoding"; … … 1100 1198 refs[3]="method"; 1101 1199 refs[4]="href"; 1102 char*url;1103 1200 for(int l=0;l<5;l++){ 1104 1201 #ifdef DEBUG … … 1141 1238 hInternet.header=NULL; 1142 1239 while(cur3){ 1240 while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE) 1241 cur2=cur3->next; 1143 1242 if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){ 1144 xmlNodePtr cur4=cur3; 1145 char *tmp=new char[cgiContentLength]; 1146 char *ha[2]; 1243 const char *ha[2]; 1147 1244 ha[0]="key"; 1148 1245 ha[1]="value"; … … 1170 1267 } 1171 1268 hInternet.header=curl_slist_append(hInternet.header, has); 1172 //free(has);1269 free(has); 1173 1270 } 1174 1271 else{ … … 1184 1281 xmlNodePtr cur4=cur3->children; 1185 1282 while(cur4!=NULL){ 1283 while(cur4->type!=XML_ELEMENT_NODE) 1284 cur4=cur4->next; 1186 1285 xmlDocPtr bdoc = xmlNewDoc(BAD_CAST "1.0"); 1187 1286 bdoc->encoding = xmlCharStrdup ("UTF-8"); … … 1302 1401 * dataType , uom 1303 1402 */ 1304 char *li ts[2];1305 li ts[0]="dataType";1306 li ts[1]="uom";1403 char *list[2]; 1404 list[0]=strdup("dataType"); 1405 list[1]=strdup("uom"); 1307 1406 for(int l=0;l<2;l++){ 1308 1407 #ifdef DEBUG 1309 fprintf(stderr,"*** LiteralData %s ***",li ts[l]);1310 #endif 1311 xmlChar *val=xmlGetProp(cur4,BAD_CAST li ts[l]);1408 fprintf(stderr,"*** LiteralData %s ***",list[l]); 1409 #endif 1410 xmlChar *val=xmlGetProp(cur4,BAD_CAST list[l]); 1312 1411 if(val!=NULL && strlen((char*)val)>0){ 1313 1412 if(tmpmaps->content!=NULL) 1314 addToMap(tmpmaps->content,li ts[l],(char*)val);1413 addToMap(tmpmaps->content,list[l],(char*)val); 1315 1414 else 1316 tmpmaps->content=createMap(li ts[l],(char*)val);1415 tmpmaps->content=createMap(list[l],(char*)val); 1317 1416 } 1318 1417 #ifdef DEBUG … … 1320 1419 #endif 1321 1420 xmlFree(val); 1421 free(list[l]); 1322 1422 } 1323 1423 } … … 1327 1427 * mimeType, encoding, schema 1328 1428 */ 1329 c har *coms[3];1429 const char *coms[3]; 1330 1430 coms[0]="mimeType"; 1331 1431 coms[1]="encoding"; … … 1368 1468 char *res=NULL; 1369 1469 char *curs=tmpv->value; 1370 int i=0;1371 1470 for(int i=0;i<=strlen(tmpv->value)/64;i++) { 1372 1471 if(res==NULL) … … 1421 1520 #endif 1422 1521 xmlXPathFreeObject(tmpsptr); 1423 //xmlFree(tmps);1424 1522 1425 1523 tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='ResponseDocument']"); … … 1439 1537 else 1440 1538 addToMap(request_inputs,"ResponseDocument",""); 1441 request_output_real_format;1442 1539 maps *tmpmaps=NULL; 1443 1540 xmlNodePtr cur=tmps->nodeTab[k]; … … 1451 1548 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1452 1549 } 1453 tmpmaps->name= "unknownIdentifier";1550 tmpmaps->name=strdup("unknownIdentifier"); 1454 1551 tmpmaps->next=NULL; 1455 1552 } … … 1458 1555 * storeExecuteResponse, lineage, status 1459 1556 */ 1460 c har *ress[3];1557 const char *ress[3]; 1461 1558 ress[0]="storeExecuteResponse"; 1462 1559 ress[1]="lineage"; … … 1487 1584 * mimeType, encoding, schema, uom, asReference 1488 1585 */ 1489 c har *outs[5];1586 const char *outs[5]; 1490 1587 outs[0]="mimeType"; 1491 1588 outs[1]="encoding"; … … 1543 1640 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1544 1641 } 1545 tmpmaps->name= "missingIndetifier";1642 tmpmaps->name=strdup("missingIndetifier"); 1546 1643 tmpmaps->content=createMap((char*)cur2->name,(char*)val); 1547 1644 tmpmaps->next=NULL; … … 1563 1660 } 1564 1661 } 1565 //xmlFree(cur);1566 1662 if(request_output_real_format==NULL) 1567 1663 request_output_real_format=dupMaps(&tmpmaps); … … 1576 1672 1577 1673 xmlXPathFreeObject(tmpsptr); 1578 //xmlFree(tmps);1579 1674 xmlCleanupParser(); 1580 1675 } … … 1710 1805 _tmpMaps->next=NULL; 1711 1806 addToMap(_tmpMaps->content,"status","0"); 1807 addToMap(_tmpMaps->content,"cwd",ntmp); 1712 1808 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1713 1809 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1); … … 1735 1831 dumpMap(request_inputs); 1736 1832 #endif 1737 1833 #ifdef WIN32 1834 char *cgiSidL=NULL; 1835 if(getenv("CGISID")!=NULL) 1836 addToMap(request_inputs,"cgiSid",getenv("CGISID")); 1837 map* test1=getMap(request_inputs,"cgiSid"); 1838 if(test1!=NULL){ 1839 cgiSid=test1->value; 1840 } 1841 if(cgiSid!=NULL){ 1842 addToMap(request_inputs,"storeExecuteResponse","true"); 1843 addToMap(request_inputs,"status","true"); 1844 status=getMap(request_inputs,"status"); 1845 dumpMap(request_inputs); 1846 fprintf(stderr,"cgiSID : %s",cgiSid); 1847 } 1848 #endif 1738 1849 if(status!=NULL) 1739 1850 if(strcasecmp(status->value,"false")==0) … … 1751 1862 pid = fork (); 1752 1863 #else 1753 pid = 0; 1864 if(cgiSid==NULL){ 1865 addToMap(request_inputs,"cgSid",cgiSid); 1866 createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format); 1867 pid = cpid; 1868 }else{ 1869 pid=0; 1870 cpid=atoi(cgiSid); 1871 } 1872 fflush(stderr); 1754 1873 #endif 1755 1874 if (pid > 0) { … … 1778 1897 fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value); 1779 1898 #endif 1899 freopen(flog,"w+",stderr); 1780 1900 freopen(fbkp , "w+", stdout); 1781 1901 fclose(stdin); 1782 freopen(flog,"w+",stderr);1783 1902 free(fbkp); 1784 1903 free(flog); … … 1791 1910 updateStatus(m); 1792 1911 printProcessResponse(m,request_inputs,cpid, 1793 s1,r_inputs1->value,SERVICE_STARTED, 1794 request_input_real_format, 1795 request_output_real_format); 1912 s1,r_inputs1->value,SERVICE_STARTED, 1913 request_input_real_format, 1914 request_output_real_format); 1915 #ifndef WIN32 1796 1916 fflush(stdout); 1797 1917 rewind(stdout); 1918 #endif 1798 1919 1799 1920 loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres); … … 1811 1932 #ifdef DEBUG 1812 1933 dumpMaps(request_output_real_format); 1813 fprintf(stderr,"Function loaded and returned %d\n", eres);1934 fprintf(stderr,"Function loaded and returned %d\n",*eres); 1814 1935 fflush(stderr); 1815 1936 #endif … … 1818 1939 request_output_real_format,request_inputs, 1819 1940 cpid,m,eres); 1941 fflush(stdout); 1820 1942 /** 1821 1943 * Ensure that if error occurs when freeing memory, no signal will return -
branches/branch-1.2/zoo-services/arithmetics/cgi-env/Multiply.zcfg
r106 r217 5 5 storeSupported = true 6 6 statusSupported = true 7 serviceProvider = demo_service.zo7 serviceProvider = test_service.zo 8 8 serviceType = C 9 9 <MetaData> -
branches/branch-1.2/zoo-services/arithmetics/makefile.vc
r1 r217 1 1 GEODIR=c:/OSGeo4W/ 2 2 TOOLS=c:/Users/djay/GeoLabs/tools/ 3 CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../ ../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG3 CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG -DWIN32 4 4 CPP=cl /TP 5 5 6 cgi-env/ service.zo:service.c7 $(CPP) $(CFLAGS) /c service.c8 link /dll /out:cgi-env/ ogr_service.zso ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a6 cgi-env/test_service.zo: test_service.c 7 $(CPP) $(CFLAGS) /c test_service.c 8 link /dll /out:cgi-env/test_service.zo ../../zoo-kernel/service_internal.obj ./test_service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a $(TOOLS)/lib/libintl.lib 9 9 10 10 clean: 11 rm -f cgi-env/ogr_service.zso11 erase cgi-env\demo_service.* -
branches/branch-1.2/zoo-services/arithmetics/test_service.c
r1 r217 3 3 extern "C" { 4 4 5 #ifdef WIN32 6 __declspec(dllexport) 7 #endif 5 8 int Multiply(maps*& conf,maps*& inputs,maps*& outputs){ 6 9 fprintf(stderr,"\nService internal print\n"); -
branches/branch-1.2/zoo-services/cgal/Makefile
r1 r217 1 CFLAGS=-I../../zoo-kernel -svn/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG1 CFLAGS=-I../../zoo-kernel/ -I./ `xml2-config --cflags` `python-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG 2 2 CC=gcc 3 3 4 cgi-env/ service.zo: service.c5 g++ ${CFLAGS} -shared -fpic -o cgi-env/ service.zo ./service.c -lgdal4 cgi-env/cgal_service.zo: service.c 5 g++ ${CFLAGS} -shared -fpic -o cgi-env/cgal_service.zo ./service.c -lgdal -lCGAL 6 6 7 7 clean: 8 rm -f *.zo *.o *.tab.c *.tab.h *.sr.c* service_loader lex.* *.lreg *.sibling8 rm -f cgi-env/*.zo *.o *.tab.c *.tab.h *.sr.c* service_loader lex.* *.lreg *.sibling 9 9 rm -rf service_loader.dSYM -
branches/branch-1.2/zoo-services/cgal/service.c
r1 r217 46 46 void printExceptionReportResponse(maps*,map*); 47 47 48 char *base64(const unsigned char *input, int length){ 49 BIO *bmem, *b64; 50 BUF_MEM *bptr; 51 52 b64 = BIO_new(BIO_f_base64()); 53 bmem = BIO_new(BIO_s_mem()); 54 b64 = BIO_push(b64, bmem); 55 BIO_write(b64, input, length); 56 BIO_flush(b64); 57 BIO_get_mem_ptr(b64, &bptr); 58 59 char *buff = (char *)malloc(bptr->length+1); 60 memcpy(buff, bptr->data, bptr->length); 61 buff[bptr->length] = 0; 62 63 BIO_free_all(b64); 64 65 return buff; 66 } 67 68 OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){ 69 xmlInitParser(); 70 xmlDocPtr doc = xmlParseMemory(inputStr,strlen(inputStr)); 71 xmlChar *xmlbuff; 72 int buffersize; 73 xmlXPathContextPtr xpathCtx; 74 xmlXPathObjectPtr xpathObj; 75 char * xpathExpr="/*/*/*/*/*[local-name()='Polygon' or local-name()='MultiPolygon']"; 76 xpathCtx = xmlXPathNewContext(doc); 77 xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx); 78 if(!xpathObj->nodesetval){ 79 map* tmp=createMap("text","Unable to parse Input Polygon"); 80 addToMap(tmp,"code","InvalidParameterValue"); 81 printExceptionReportResponse(conf,tmp); 82 exit(0); 83 } 84 int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0; 85 /** 86 * Create a temporary XML document 87 */ 88 xmlDocPtr ndoc = xmlNewDoc(BAD_CAST "1.0"); 89 /** 90 * Only one polygon should be provided so we use it as the root node. 91 */ 92 for(int k=size-1;k>=0;k--){ 93 xmlDocSetRootElement(ndoc, xpathObj->nodesetval->nodeTab[k]); 94 } 95 xmlDocDumpFormatMemory(ndoc, &xmlbuff, &buffersize, 1); 96 char *tmp=strdup(strstr((char*)xmlbuff,"?>")+2); 97 xmlXPathFreeObject(xpathObj); 98 xmlXPathFreeContext(xpathCtx); 99 xmlFree(xmlbuff); 100 xmlFreeDoc(doc); 101 xmlCleanupParser(); 102 fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ..."); 103 OGRGeometryH res=OGR_G_CreateFromGML(tmp); 104 if(res==NULL){ 105 map* tmp=createMap("text","Unable to call OGR_G_CreatFromGML"); 106 addToMap(tmp,"code","NoApplicableCode"); 107 printExceptionReportResponse(conf,tmp); 108 exit(0); 109 } 110 else 111 return OGR_G_CreateFromGML(tmp); 112 } 113 114 115 int Delaunay(maps*& conf,maps*& inputs,maps*& outputs){ 48 int Voronoi(maps*& conf,maps*& inputs,maps*& outputs){ 49 #ifdef DEBUG 116 50 fprintf(stderr,"\nService internal print\nStarting\n"); 51 #endif 117 52 maps* cursor=inputs; 118 53 OGRGeometryH geometry,res; … … 121 56 map* tmpm=NULL; 122 57 tmpm=getMapFromMaps(inputs,"InputPoints","value"); 123 58 124 59 xmlInitParser(); 125 60 xmlDocPtr doc = … … 135 70 xpathObj = xmlXPathEvalExpression(BAD_CAST "/*/*[local-name()='featureMember']/*/*/*[local-name()='Point']/*[local-name()='coordinates']",xpathCtx); 136 71 xmlXPathFreeContext(xpathCtx); 137 xmlNodeSet* toto=xpathObj->nodesetval; 138 139 if(toto==NULL) 140 fprintf(stderr,"IMPOSSIBLE DE CONTINUER !!!!\n"); 72 xmlNodeSet* nSet=xpathObj->nodesetval; 73 74 if(nSet==NULL){ 75 setMapInMaps(conf,"lenv","message","Unable to continue !!!"); 76 return SERVICE_FAILED; 77 } 141 78 char filepath[2048]; 142 79 map* tmpMap=getMapFromMaps(conf,"main","tmpPath"); … … 145 82 } 146 83 FILE *fo=fopen(filepath,"w"); 147 fprintf(stderr,"File Creation (%s) OK\nPrinting %d Points.\n",filepath,toto->nodeNr); 148 for(int k=0;k<toto->nodeNr;k++){ 149 xmlNodePtr cur=toto->nodeTab[k]; 84 #ifdef DEBUG 85 fprintf(stderr,"File Creation (%s) OK\nPrinting %d Points.\n",filepath,nSet->nodeNr); 86 #endif 87 for(int k=0;k<nSet->nodeNr;k++){ 88 xmlNodePtr cur=nSet->nodeTab[k]; 150 89 char *val= 151 90 (char*)xmlNodeListGetString(doc,cur->xmlChildrenNode,1); … … 159 98 } 160 99 fclose(fo); 100 #ifdef DEBUG 161 101 fprintf(stderr,"File Close (%s) OK\n",filepath); 102 #endif 162 103 163 104 std::ifstream in(filepath); 164 165 std::istream_iterator<Point1> begin(in); 166 std::istream_iterator<Point1> end; 167 168 DelaunayTriangulation dt1; 169 dt1.insert(begin, end); 105 std::istream_iterator<Point> begin(in); 106 std::istream_iterator<Point> end; 107 Triangulation T; 108 T.insert(begin, end); 170 109 171 110 OGRRegisterAll(); … … 180 119 181 120 tmpMap=getMapFromMaps(outputs,"Result","mimeType"); 182 c har *oDriver=(char*)malloc(7*sizeof(char));121 const char *oDriver; 183 122 oDriver="GeoJSON"; 184 123 if(tmpMap!=NULL){ 185 124 if(strcmp(tmpMap->value,"text/xml")==0){ 186 fprintf(stderr,"USEING GML \n");187 125 oDriver="GML"; 188 126 } … … 212 150 sprintf( emessage, "%s -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() ); 213 151 } 214 215 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage); 216 exit( 1 ); 152 153 setMapInMaps(conf,"lenv","message",emessage); 154 return SERVICE_FAILED; 155 217 156 } 218 157 … … 221 160 sprintf( emessage, "%s driver does not support data source creation.\n", 222 161 "json" ); 223 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage); 224 exit( 1 ); 225 } 226 227 /* -------------------------------------------------------------------- */ 228 /* Create the output data source. */ 229 /* -------------------------------------------------------------------- */ 230 map* tpath=getMapFromMaps(conf,"main","tmpPath"); 231 char *pszDestDataSource=(char*)malloc(strlen(tpath->value)+20); 232 char **papszDSCO=NULL; 233 sprintf(pszDestDataSource,"%s/result_%d.json",tpath->value,getpid()); 234 fprintf(stderr,"\n *%s* \n",pszDestDataSource); 235 poODS = poDriver->CreateDataSource( pszDestDataSource, papszDSCO ); 236 if( poODS == NULL ){ 237 char emessage[1024]; 238 sprintf( emessage, "%s driver failed to create %s\n", 239 "json", pszDestDataSource ); 240 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage); 241 exit( 1 ); 242 } 243 244 /* -------------------------------------------------------------------- */ 245 /* Create the layer. */ 246 /* -------------------------------------------------------------------- */ 247 if( !poODS->TestCapability( ODsCCreateLayer ) ) 248 { 249 char emessage[1024]; 250 sprintf( emessage, 251 "Layer %s not found, and CreateLayer not supported by driver.", 252 "Result" ); 253 fprintf(stderr,"{\"type\": \"error\",\"message\": \"%s\"}",emessage); 254 return FALSE; 255 } 256 257 CPLErrorReset(); 258 259 OGRLayer *poDstLayer = poODS->CreateLayer( "Result", NULL,wkbLineString,NULL); 260 if( poDstLayer == NULL ){ 261 fprintf( stderr,"Layer creation failed.\n" ); 262 exit( 1 ); 263 } 264 265 Vertex_circulator vc = dt1.incident_vertices(dt1.infinite_vertex()), 266 done(vc); 267 if (vc != 0) { 268 do {std::cout << vc->point() << std::endl;}while(++vc != done); 269 } 270 271 DelaunayTriangulation::Edge_iterator eit=dt1.edges_begin(); 272 int i=0; 273 for ( ; eit !=dt1.edges_end(); ++eit) { 274 fprintf(stderr,"Edge %d\n",i); 275 i++; 276 /*CGAL::Object o = dt1.dual(eit); 277 if (const K::Segment_2 *tmp=CGAL::object_cast<K::Segment_2>(&o)) { 278 const K::Point_2 p1=tmp->source(); 279 const K::Point_2 p2=tmp->target(); 280 //#ifdef DEBUG 281 fprintf(stderr,"P1 %d %d | P2 %d %d\n",p1.x(),p1.y(),p2.x(),p2.y()); 282 //#endif 283 }*/ 284 /*if (const K::Segment_3 *tmp=CGAL::object_cast<K::Segment_3>(eit)) { 285 const K::Point_3 p1=tmp->source(); 286 const K::Point_3 p2=tmp->target(); 287 #ifdef DEBUG 288 fprintf(stderr,"P1 %d %d | P2 %d %d\n",p1.x(),p1.y(),p2.x(),p2.y()); 289 #endif 290 OGRFeatureH hFeature = OGR_F_Create( OGR_L_GetLayerDefn( poDstLayer ) ); 291 OGRGeometryH currLine=OGR_G_CreateGeometry(wkbLineString); 292 OGR_G_AddPoint_2D(currLine,p1.x(),p1.y()); 293 OGR_G_AddPoint_2D(currLine,p2.x(),p2.y()); 294 OGR_F_SetGeometry( hFeature, currLine ); 295 OGR_G_DestroyGeometry(currLine); 296 if( OGR_L_CreateFeature( poDstLayer, hFeature ) != OGRERR_NONE ){ 297 fprintf( stderr,"Failed to create feature in file.\n" ); 298 exit( 1 ); 299 } 300 OGR_F_Destroy( hFeature );*/ 301 } 302 303 int idg=0; 304 for (DelaunayTriangulation::Face_iterator fit = dt1.faces_begin(); fit!= 305 dt1.faces_end(); ++fit) { 306 int idx = 0; 307 int i0, i1, i2; 308 309 OGRFeatureH hFeature = OGR_F_Create( OGR_L_GetLayerDefn( poDstLayer ) ); 310 OGRGeometryH currLine=OGR_G_CreateGeometry(wkbLineString); 311 312 for(i0=0;i0<3;i0++){ 313 if(!dt1.is_infinite((*fit).vertex(i0))) 314 OGR_G_AddPoint_2D(currLine,(*fit).vertex(i0)->point().x(), 315 (*fit).vertex(i0)->point().y()); 316 if(i0==2 && !dt1.is_infinite((*fit).vertex(0))) 317 OGR_G_AddPoint_2D(currLine,(*fit).vertex(0)->point().x(), 318 (*fit).vertex(0)->point().y()); 319 } 320 OGR_F_SetGeometry( hFeature, currLine ); 321 OGR_G_DestroyGeometry(currLine); 322 if( OGR_L_CreateFeature( poDstLayer, hFeature ) != OGRERR_NONE ){ 323 fprintf( stderr,"Failed to create feature in file.\n" ); 324 exit( 1 ); 325 } 326 OGR_F_Destroy( hFeature ); 327 328 /*OGRFeatureH hFeature=NULL; 329 OGRGeometryH currLine=NULL; 330 if(idg==0) { 331 hFeature = OGR_F_Create( OGR_L_GetLayerDefn( poDstLayer ) ); 332 currLine=OGR_G_CreateGeometry(wkbLineString); 333 }*/ 334 335 for (DelaunayTriangulation::Vertex_iterator vit = dt1.vertices_begin(); vit!= 336 dt1.vertices_end(); ++vit) { 337 idx++; 338 /*if(idg==0) 339 OGR_G_AddPoint_2D(currLine,(*vit).point().x(), 340 (*vit).point().y());*/ 341 342 343 if ((*vit).point() == (*fit).vertex(0)->point()){ 344 i0 = idx; 345 /*OGR_G_AddPoint_2D(currLine,(*fit).vertex(i0)->point().x(), 346 (*fit).vertex(i0)->point().y());**/ 347 } 348 if ((*vit).point() == (*fit).vertex(1)->point()){ 349 i1 = idx; 350 /*OGR_G_AddPoint_2D(currLine,(*fit).vertex(i1)->point().x(), 351 (*fit).vertex(i1)->point().y());*/ 352 } 353 if ((*vit).point() == (*fit).vertex(2)->point()){ 354 i2 = idx; 355 /*OGR_G_AddPoint_2D(currLine,(*fit).vertex(i2)->point().x(), 356 (*fit).vertex(i2)->point().y());*/ 357 } 358 } 359 /*if(idg==0){ 360 OGR_F_SetGeometry( hFeature, currLine ); 361 OGR_G_DestroyGeometry(currLine); 362 if( OGR_L_CreateFeature( poDstLayer, hFeature ) != OGRERR_NONE ){ 363 fprintf( stderr,"Failed to create feature in file.\n" ); 364 exit( 1 ); 365 } 366 OGR_F_Destroy( hFeature ); 367 idg++; 368 }*/ 369 370 std::cerr << "f " << i0 << " " << dt1.triangle(fit) << std::endl; 371 372 } 373 OGR_DS_Destroy( poODS ); 374 OGRCleanupAll(); 375 376 377 char tmp1[1024]; 378 outputs=(maps*)malloc(sizeof(maps*)); 379 outputs->name="Result"; 380 381 FILE * fichier=fopen(pszDestDataSource,"r"); 382 struct stat file_status; 383 stat(pszDestDataSource, &file_status); 384 fprintf(stderr,"%s (%d)",pszDestDataSource,file_status.st_size); 385 char *res1=(char *)malloc(file_status.st_size*sizeof(char)); 386 if(fichier==NULL) 387 fprintf(stderr,"Failed to open file %s for reading purpose.\n",pszDestDataSource); 388 fread(res1,1,(file_status.st_size)*sizeof(char),fichier); 389 res1[strlen(res1)]=0; 390 fclose(fichier); 391 //unlink(pszDestDataSource); 392 //fprintf(stderr,"Read (%s).\n",res1); 393 394 outputs->content=createMap("value",res1); 395 396 if(strcmp(oDriver,"GML")==0) 397 addMapToMap(&outputs->content,createMap("mimeType","text/xml")); 398 else 399 addMapToMap(&outputs->content,createMap("mimeType","text/plain")); 400 401 addMapToMap(&outputs->content,createMap("encoding","UTF-8")); 402 outputs->next=NULL; 403 fprintf(stderr,"\nService internal print\n===\n"); 404 xmlCleanupParser(); 405 406 return SERVICE_SUCCEEDED; 407 } 408 409 410 int Voronoi(maps*& conf,maps*& inputs,maps*& outputs){ 411 fprintf(stderr,"\nService internal print\nStarting\n"); 412 maps* cursor=inputs; 413 OGRGeometryH geometry,res; 414 int bufferDistance; 415 xmlInitParser(); 416 map* tmpm=NULL; 417 tmpm=getMapFromMaps(inputs,"InputPoints","value"); 418 419 xmlInitParser(); 420 xmlDocPtr doc = 421 xmlParseMemory(tmpm->value,strlen(tmpm->value)); 422 xmlNodePtr cur = xmlDocGetRootElement(doc); 423 /** 424 * Parse every Input in DataInputs node. 425 */ 426 maps* tempMaps=NULL; 427 xmlXPathContextPtr xpathCtx; 428 xmlXPathObjectPtr xpathObj; 429 xpathCtx = xmlXPathNewContext(doc); 430 xpathObj = xmlXPathEvalExpression(BAD_CAST "/*/*[local-name()='featureMember']/*/*/*[local-name()='Point']/*[local-name()='coordinates']",xpathCtx); 431 xmlXPathFreeContext(xpathCtx); 432 xmlNodeSet* toto=xpathObj->nodesetval; 433 434 if(toto==NULL) 435 fprintf(stderr,"IMPOSSIBLE DE CONTINUER !!!!\n"); 436 char filepath[2048]; 437 map* tmpMap=getMapFromMaps(conf,"main","tmpPath"); 438 if(tmpMap!=NULL){ 439 sprintf(filepath,"%s/varonoi_%d.tmp",tmpMap->value,getpid()); 440 } 441 FILE *fo=fopen(filepath,"w"); 442 fprintf(stderr,"File Creation (%s) OK\nPrinting %d Points.\n",filepath,toto->nodeNr); 443 for(int k=0;k<toto->nodeNr;k++){ 444 xmlNodePtr cur=toto->nodeTab[k]; 445 char *val= 446 (char*)xmlNodeListGetString(doc,cur->xmlChildrenNode,1); 447 char *tmp=strstr(val,","); 448 char tmp1[1024]; 449 strncpy(tmp1,val,strlen(val)-strlen(tmp)); 450 tmp1[strlen(val)-strlen(tmp)]=0; 451 char buff[1024]; 452 sprintf(buff,"%s %s\n",tmp1,tmp+1); 453 fwrite(buff,1,strlen(buff)*sizeof(char),fo); 454 } 455 fclose(fo); 456 fprintf(stderr,"File Close (%s) OK\n",filepath); 457 458 std::ifstream in(filepath); 459 std::istream_iterator<Point> begin(in); 460 std::istream_iterator<Point> end; 461 Triangulation T; 462 T.insert(begin, end); 463 464 OGRRegisterAll(); 465 /* -------------------------------------------------------------------- */ 466 /* Try opening the output datasource as an existing, writable */ 467 /* -------------------------------------------------------------------- */ 468 OGRDataSource *poODS; 469 470 OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar(); 471 OGRSFDriver *poDriver = NULL; 472 int iDriver; 473 474 tmpMap=getMapFromMaps(outputs,"Result","mimeType"); 475 char *oDriver=(char*)malloc(7*sizeof(char)); 476 oDriver="GeoJSON"; 477 if(tmpMap!=NULL){ 478 if(strcmp(tmpMap->value,"text/xml")==0){ 479 fprintf(stderr,"USEING GML \n"); 480 oDriver="GML"; 481 } 482 } 483 484 for( iDriver = 0; 485 iDriver < poR->GetDriverCount() && poDriver == NULL; 486 iDriver++ ) 487 { 488 #ifdef DEBUG 489 fprintf(stderr,"D:%s\n",poR->GetDriver(iDriver)->GetName()); 490 #endif 491 if( EQUAL(poR->GetDriver(iDriver)->GetName(),oDriver) ) 492 { 493 poDriver = poR->GetDriver(iDriver); 494 } 495 } 496 497 if( poDriver == NULL ) 498 { 499 char emessage[8192]; 500 sprintf( emessage, "Unable to find driver `%s'.\n", oDriver ); 501 sprintf( emessage, "%sThe following drivers are available:\n",emessage ); 502 503 for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ ) 504 { 505 sprintf( emessage, "%s -> `%s'\n", emessage, poR->GetDriver(iDriver)->GetName() ); 506 } 507 508 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage); 509 exit( 1 ); 510 } 511 512 if( !poDriver->TestCapability( ODrCCreateDataSource ) ){ 513 char emessage[1024]; 514 sprintf( emessage, "%s driver does not support data source creation.\n", 515 "json" ); 516 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage); 517 exit( 1 ); 162 setMapInMaps(conf,"lenv","message",emessage); 163 return SERVICE_FAILED; 518 164 } 519 165 … … 530 176 sprintf( emessage, "%s driver failed to create %s\n", 531 177 "json", pszDestDataSource ); 532 fprintf(stderr,"{\"type\": \"error\", \"%s\"}",emessage);533 exit( 1 );178 setMapInMaps(conf,"lenv","message",emessage); 179 return SERVICE_FAILED; 534 180 } 535 181 … … 543 189 "Layer %s not found, and CreateLayer not supported by driver.", 544 190 "Result" ); 545 fprintf(stderr,"{\"type\": \"error\",\"message\": \"%s\"}",emessage);546 return FALSE;191 setMapInMaps(conf,"lenv","message",emessage); 192 return SERVICE_FAILED; 547 193 } 548 194 … … 551 197 OGRLayer *poDstLayer = poODS->CreateLayer( "Result", NULL,wkbLineString,NULL); 552 198 if( poDstLayer == NULL ){ 553 fprintf( stderr,"Layer creation failed.\n");554 exit( 1 );199 setMapInMaps(conf,"lenv","message","Layer creation failed.\n"); 200 return SERVICE_FAILED; 555 201 } 556 202 … … 574 220 OGR_G_DestroyGeometry(currLine); 575 221 if( OGR_L_CreateFeature( poDstLayer, hFeature ) != OGRERR_NONE ){ 576 fprintf( stderr,"Failed to create feature in file.\n");577 exit( 1 );222 setMapInMaps(conf,"lenv","message","Failed to create feature in file.\n"); 223 return SERVICE_FAILED; 578 224 } 579 225 OGR_F_Destroy( hFeature ); … … 592 238 593 239 char tmp1[1024]; 594 outputs=(maps*)malloc(sizeof(maps*));595 outputs->name="Result";596 240 597 241 FILE * fichier=fopen(pszDestDataSource,"r"); 598 242 struct stat file_status; 599 243 stat(pszDestDataSource, &file_status); 600 //fprintf(stderr,"%s (%d)",pszDestDataSource,file_status.st_size);601 244 char *res1=(char *)malloc(file_status.st_size*sizeof(char)); 602 if(fichier==NULL) 603 fprintf(stderr,"Failed to open file %s for reading purpose.\n",pszDestDataSource); 245 if(fichier==NULL){ 246 char tmp[1024]; 247 sprintf(tmp,"Failed to open file %s for reading purpose.\n", 248 pszDestDataSource); 249 setMapInMaps(conf,"lenv","message",tmp); 250 return SERVICE_FAILED; 251 } 604 252 fread(res1,1,(file_status.st_size)*sizeof(char),fichier); 605 253 res1[strlen(res1)]=0; 606 254 fclose(fichier); 607 255 unlink(pszDestDataSource); 608 //fprintf(stderr,"Read (%s).\n",res1); 609 610 outputs->content=createMap("value",res1); 256 257 setMapInMaps(outputs,"Result","value",res1); 611 258 612 259 if(strcmp(oDriver,"GML")==0) 613 addMapToMap(&outputs->content,createMap("mimeType","text/xml"));260 setMapInMaps(outputs,"Result","mimeType","text/xml"); 614 261 else 615 addMapToMap(&outputs->content,createMap("mimeType","text/plain"));616 617 addMapToMap(&outputs->content,createMap("encoding","UTF-8"));618 outputs->next=NULL; 262 setMapInMaps(outputs,"Result","mimeType","text/plain"); 263 264 setMapInMaps(outputs,"Result","encoding","UTF-8"); 265 #ifdef DEBUG 619 266 fprintf(stderr,"\nService internal print\n===\n"); 267 #endif 620 268 xmlCleanupParser(); 621 269 return SERVICE_SUCCEEDED; -
branches/branch-1.2/zoo-services/ogr/base-vect-ops/makefile.vc
r1 r217 1 GEODIR=c:/OSGeo4W/ 2 TOOLS=c:/Users/djay/GeoLabs/tools/ 3 CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG 1 ZOODIR=../../../zoo-kernel 2 THIRDSDIR=../../../thirds 3 !INCLUDE $(ZOODIR)/nmake.opt 4 CFLAGS=-I$(GEODIR)/include -I$(TPATH)/include -I$(ZOODIR) -I./ -DLINUX_FREE_ISSUE -DWIN32 #-DDEBUG 4 5 CPP=cl /TP 5 6 6 cgi-env/ service.zo: service.c7 cgi-env/ogr_service.zo: service.c 7 8 $(CPP) $(CFLAGS) /c service.c 8 link /dll /out:cgi-env/ogr_service.z so ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a9 link /dll /out:cgi-env/ogr_service.zo ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(GEODIR)/lib/geos_c_i.lib $(TPATH)/lib/libeay32.dll.a $(TPATH)/lib/libcrypto.a $(TPATH)/lib/libssl32.dll.a $(LIBINTL_CPATH)/lib/libintl.lib 9 10 10 11 clean: 11 rm -f cgi-env/ogr_service.zso12 erase cgi-env\ogr_service.* -
branches/branch-1.2/zoo-services/ogr/base-vect-ops/service.c
r55 r217 43 43 44 44 void printExceptionReportResponse(maps*,map*); 45 char *base64(const unsignedchar *input, int length);45 char *base64(const char *input, int length); 46 46 47 47 OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){ … … 56 56 xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx); 57 57 if(!xpathObj->nodesetval){ 58 map* tmp=createMap("text","Unable to parse Input Polygon"); 59 addToMap(tmp,"code","InvalidParameterValue"); 60 printExceptionReportResponse(conf,tmp); 61 exit(0); 58 setMapInMaps(conf,"lenv","message",_ss("Unable to parse Input Polygon")); 59 setMapInMaps(conf,"lenv","code","InvalidParameterValue"); 60 return NULL; 62 61 } 63 62 int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0; … … 80 79 xmlFreeDoc(doc); 81 80 xmlFreeDoc(ndoc); 81 #ifndef WIN32 82 82 xmlCleanupParser(); 83 #endif 83 84 #ifdef DEBUG 84 85 fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ..."); … … 94 95 } 95 96 97 #ifdef WIN32 98 __declspec(dllexport) 99 #endif 96 100 int Simplify(maps*& conf,maps*& inputs,maps*& outputs){ 97 101 maps* cursor=inputs; … … 104 108 else 105 109 tolerance=atof(tmp0->value); 110 #ifdef DEBUG 106 111 fprintf(stderr,"Tolerance for Simplify %f",tolerance); 112 #endif 107 113 map* tmp=getMapFromMaps(inputs,"InputPolygon","value"); 108 114 if(!tmp){ … … 126 132 return SERVICE_FAILED; 127 133 } 134 #ifdef DEBUG 128 135 fprintf(stderr,"Create GEOSGeometry object"); 136 #endif 129 137 GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS(); 130 138 GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance); 131 res= OGRGeometryFactory::createFromGEOS(gres);139 res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres); 132 140 tmp1=getMapFromMaps(outputs,"Result","mimeType"); 133 141 if(tmp1!=NULL){ … … 136 144 char *tmpS=OGR_G_ExportToJson(res); 137 145 setMapInMaps(outputs,"Result","value",tmpS); 146 #ifndef WIN32 138 147 setMapInMaps(outputs,"Result","mimeType","text/plain"); 139 148 setMapInMaps(outputs,"Result","encoding","UTF-8"); 140 149 free(tmpS); 150 #endif 141 151 } 142 152 else{ 143 153 char *tmpS=OGR_G_ExportToGML(res); 144 154 setMapInMaps(outputs,"Result","value",tmpS); 155 #ifndef WIN32 145 156 setMapInMaps(outputs,"Result","mimeType","text/xml"); 146 157 setMapInMaps(outputs,"Result","encoding","UTF-8"); 147 158 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 148 159 free(tmpS); 160 #endif 149 161 } 150 162 }else{ 151 char *tmpS=OGR_G_ExportToJson( tmp->value);163 char *tmpS=OGR_G_ExportToJson(res); 152 164 setMapInMaps(outputs,"Result","value",tmpS); 165 #ifndef WIN32 153 166 setMapInMaps(outputs,"Result","mimeType","text/plain"); 154 167 setMapInMaps(outputs,"Result","encoding","UTF-8"); 155 168 free(tmpS); 169 #endif 156 170 } 157 171 outputs->next=NULL; … … 178 192 return SERVICE_FAILED; 179 193 } 194 #ifdef DEBUG 180 195 fprintf(stderr,"Service internal print \n"); 181 196 dumpMaps(inputs); 182 197 fprintf(stderr,"/Service internal print \n"); 198 #endif 183 199 map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType"); 200 #ifdef DEBUG 184 201 fprintf(stderr,"Service internal print \n"); 185 202 dumpMap(tmp1); 186 203 fprintf(stderr,"/Service internal print \n"); 204 #endif 187 205 if(tmp1!=NULL){ 188 206 if(strncmp(tmp1->value,"text/js",7)==0 || … … 199 217 } 200 218 res=(*myFunc)(geometry); 219 #ifdef DEBUG 201 220 fprintf(stderr,"Service internal print \n"); 202 221 dumpMaps(outputs); 203 222 fprintf(stderr,"/Service internal print \n"); 223 #endif 204 224 map *tmp_2=getMapFromMaps(outputs,"Result","mimeType"); 225 #ifdef DEBUG 205 226 fprintf(stderr,"Service internal print \n"); 206 227 dumpMap(tmp_2); 207 228 fprintf(stderr,"/Service internal print \n"); 229 #endif 208 230 if(tmp_2!=NULL){ 209 231 if(strncmp(tmp_2->value,"text/js",7)==0 || … … 211 233 char *tmpS=OGR_G_ExportToJson(res); 212 234 setMapInMaps(outputs,"Result","value",tmpS); 235 #ifndef WIN32 213 236 setMapInMaps(outputs,"Result","mimeType","text/plain"); 214 237 setMapInMaps(outputs,"Result","encoding","UTF-8"); 215 238 free(tmpS); 239 #endif 216 240 } 217 241 else{ 218 242 char *tmpS=OGR_G_ExportToGML(res); 219 243 setMapInMaps(outputs,"Result","value",tmpS); 244 #ifndef WIN32 220 245 setMapInMaps(outputs,"Result","mimeType","text/xml"); 221 246 setMapInMaps(outputs,"Result","encoding","UTF-8"); 222 247 setMapInMaps(outputs,"Result","schema",schema); 223 248 free(tmpS); 249 #endif 224 250 } 225 251 }else{ 226 252 char *tmpS=OGR_G_ExportToJson(res); 227 253 setMapInMaps(outputs,"Result","value",tmpS); 254 #ifndef WIN32 228 255 setMapInMaps(outputs,"Result","mimeType","text/plain"); 229 256 setMapInMaps(outputs,"Result","encoding","UTF-8"); 230 257 free(tmpS); 231 } 232 outputs->next=NULL; 258 #endif 259 } 260 //outputs->next=NULL; 233 261 #ifdef DEBUG 234 262 dumpMaps(outputs); … … 239 267 //CPLFree(res); 240 268 //CPLFree(geometry); 269 #ifdef DEBUG 241 270 fprintf(stderr,"Service internal print \n"); 242 271 dumpMaps(outputs); 243 272 fprintf(stderr,"/Service internal print \n"); 273 #endif 244 274 return SERVICE_SUCCEEDED; 245 275 } … … 276 306 bufferDistance=atof(tmp->value); 277 307 res=OGR_G_Buffer(geometry,bufferDistance,30); 308 dumpMap(tmp); 278 309 tmp1=getMapFromMaps(outputs,"Result","mimeType"); 310 dumpMap(tmp); 279 311 if(strncmp(tmp1->value,"application/json",16)==0){ 280 312 char *tmpS=OGR_G_ExportToJson(res); 281 313 setMapInMaps(outputs,"Result","value",tmpS); 314 dumpMap(tmp); 315 #ifndef WIN32 282 316 setMapInMaps(outputs,"Result","mimeType","text/plain"); 283 317 setMapInMaps(outputs,"Result","encoding","UTF-8"); 284 318 free(tmpS); 319 #endif 285 320 } 286 321 else{ 287 322 char *tmpS=OGR_G_ExportToGML(res); 288 323 setMapInMaps(outputs,"Result","value",tmpS); 324 dumpMap(tmp); 325 #ifndef WIN32 289 326 free(tmpS); 290 327 setMapInMaps(outputs,"Result","mimeType","text/xml"); 291 328 setMapInMaps(outputs,"Result","encoding","UTF-8"); 292 329 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 330 #endif 293 331 } 294 outputs->next=NULL;332 //outputs->next=NULL; 295 333 OGR_G_DestroyGeometry(geometry); 296 334 OGR_G_DestroyGeometry(res); … … 335 373 fprintf(stderr,"\nService internal print1\n"); 336 374 fflush(stderr); 337 #endif338 375 fprintf(stderr,"\nService internal print1\n"); 339 376 dumpMaps(inputs); 340 377 fprintf(stderr,"\nService internal print1\n"); 378 #endif 341 379 342 380 maps* cursor=inputs; … … 357 395 if(geometry1==NULL){ 358 396 setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1.")); 397 #ifdef DEBUG 359 398 fprintf(stderr,"SERVICE FAILED !\n"); 360 return SERVICE_FAILED; 361 } 399 #endif 400 return SERVICE_FAILED; 401 } 402 #ifdef DEBUG 362 403 fprintf(stderr,"\nService internal print1 InputEntity1\n"); 404 #endif 363 405 { 364 406 map* tmp=getMapFromMaps(inputs,"InputEntity2","value"); 365 407 map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType"); 366 //#ifdef DEBUG408 #ifdef DEBUG 367 409 fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16)); 368 410 //dumpMap(tmp); 369 411 fprintf(stderr,"MY MAP\n"); 370 ///#endif371 412 fprintf(stderr,"\nService internal print1 InputEntity2\n"); 413 #endif 372 414 if(tmp1!=NULL){ 373 415 if(strncmp(tmp1->value,"application/json",16)==0){ 416 #ifdef DEBUG 374 417 fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n"); 418 #endif 375 419 geometry2=OGR_G_CreateGeometryFromJson(tmp->value); 376 420 } 377 421 else{ 422 #ifdef DEBUG 378 423 fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n"); 424 #endif 379 425 geometry2=createGeometryFromGML(conf,tmp->value); 380 426 } … … 382 428 else 383 429 geometry2=createGeometryFromGML(conf,tmp->value); 430 #ifdef DEBUG 384 431 fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n"); 385 } 432 #endif 433 } 434 #ifdef DEBUG 386 435 fprintf(stderr,"\nService internal print1 InputEntity2 Final\n"); 436 #endif 387 437 if(geometry2==NULL){ 388 438 setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2.")); 439 #ifdef DEBUG 389 440 fprintf(stderr,"SERVICE FAILED !\n"); 390 return SERVICE_FAILED; 391 } 441 #endif 442 return SERVICE_FAILED; 443 } 444 #ifdef DEBUG 392 445 fprintf(stderr,"\nService internal print1\n"); 446 #endif 393 447 res=(*myFunc)(geometry1,geometry2); 448 #ifdef DEBUG 394 449 fprintf(stderr,"\nService internal print1\n"); 395 450 #endif 396 451 /* nuova parte */ 397 452 map* tmp2=getMapFromMaps(outputs,"Result","mimeType"); … … 399 454 char *tmpS=OGR_G_ExportToJson(res); 400 455 setMapInMaps(outputs,"Result","value",tmpS); 456 #ifndef WIN32 401 457 setMapInMaps(outputs,"Result","mimeType","text/plain"); 402 458 setMapInMaps(outputs,"Result","encoding","UTF-8"); 403 459 free(tmpS); 460 #endif 404 461 } 405 462 else{ 406 463 char *tmpS=OGR_G_ExportToGML(res); 407 464 setMapInMaps(outputs,"Result","value",tmpS); 465 #ifndef WIN32 408 466 setMapInMaps(outputs,"Result","mimeType","text/xml"); 409 467 setMapInMaps(outputs,"Result","encoding","UTF-8"); 410 468 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 411 469 free(tmpS); 470 #endif 412 471 } 413 472 -
branches/branch-1.2/zoo-services/utils/status/service.c
r34 r217 24 24 25 25 #include "service.h" 26 #ifdef WIN32 27 #include <windows.h> 28 #endif 26 29 27 30 extern "C" { … … 135 138 setMapInMaps(conf,"lenv","status",tmp); 136 139 updateStatus(conf); 140 #ifndef WIN32 137 141 sleep(1); 142 #else 143 Sleep(1000); 144 #endif 138 145 i+=5; 139 146 }
Note: See TracChangeset
for help on using the changeset viewer.