Changeset 217 for branches/branch-1.2/zoo-kernel
- Timestamp:
- May 31, 2011, 3:30:49 AM (14 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
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
Note: See TracChangeset
for help on using the changeset viewer.