Changeset 216
- Timestamp:
- May 31, 2011, 3:13:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/thirds/cgic206/cgic.c
r98 r216 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"); -
trunk/thirds/cgic206/cgic.h
r98 r216 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 -
trunk/thirds/cgic206/makefile.vc
r1 r216 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: -
trunk/zoo-kernel/main_conf_read.y
r114 r216 335 335 336 336 fclose(crin); 337 #ifndef WIN32 337 338 crlex_destroy(); 339 #endif 338 340 339 341 return resultatYYParse; -
trunk/zoo-kernel/makefile.vc
r1 r216 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 -
trunk/zoo-kernel/service.h
r114 r216 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" { … … 193 199 } 194 200 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 195 212 static map* getMapFromMaps(maps* m,const char* key,const char* subkey){ 196 213 maps* _tmpm=getMaps(m,key); … … 201 218 else return NULL; 202 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 203 268 204 269 static void freeMap(map** mo){ … … 516 581 map* _ztmpm=getMap(_tmpm->content,subkey); 517 582 if(_ztmpm!=NULL){ 518 free(_ztmpm->value); 583 if(_ztmpm->value!=NULL) 584 free(_ztmpm->value); 519 585 _ztmpm->value=strdup(value); 520 586 }else{ -
trunk/zoo-kernel/service_conf.y
r114 r216 801 801 *service=my_service; 802 802 803 #ifndef WIN32 803 804 srlex_destroy(); 805 #endif 804 806 return resultatYYParse; 805 807 } -
trunk/zoo-kernel/service_internal.c
r114 r216 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 … … 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()){ … … 1218 1349 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1); 1219 1350 printf("%s",xmlbuff); 1220 //fflush(stdout);1351 fflush(stdout); 1221 1352 /* 1222 1353 * Free associated memory. … … 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"); … … 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); … … 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]; -
trunk/zoo-kernel/service_internal.h
r114 r216 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> … … 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 … … 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 -
trunk/zoo-kernel/zoo_loader.c
r114 r216 26 26 #define MALLOC_CHECK 0 27 27 28 #ifdef WIN32 29 #include "windows.h" 30 #endif 28 31 /** 29 32 * Specific includes … … 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 -
trunk/zoo-kernel/zoo_service_loader.c
r214 r216 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) … … 671 746 #endif 672 747 int saved_stdout = dup(fileno(stdout)); 673 dup2(fileno(stderr),fileno(stdout));748 dup2(fileno(stderr),fileno(stdout)); 674 749 t=getServiceFromFile(tmps1,&s1); 675 750 fflush(stdout); 676 751 dup2(saved_stdout,fileno(stdout)); 677 752 if(t<0){ 678 char tmpMsg[2048+strlen(r_inputs->value)]; 753 char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value)); 754 679 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); 680 756 errorException(m, tmpMsg, "InvalidParameterValue"); 757 free(tmpMsg); 681 758 freeService(&s1); 682 759 free(s1); … … 687 764 return 0; 688 765 } 689 close(saved_stdout);766 //close(saved_stdout); 690 767 691 768 #ifdef DEBUG … … 887 964 char tmpn[256]; 888 965 memset(tmpn,0,256); 889 strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char)); 890 tmpn[strlen(tmpc)-strlen(tmpv)]=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 } 891 974 #ifdef DEBUG 892 975 fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1); … … 898 981 } 899 982 tmpmaps->name=strdup(tmpn); 900 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"); 901 987 tmpmaps->next=NULL; 902 988 } … … 912 998 char tmpn1[1024]; 913 999 memset(tmpn1,0,1024); 914 strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1)); 915 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 } 916 1018 #ifdef DEBUG 917 1019 fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1); … … 920 1022 if(strcmp(tmpn1,"xlink:href")!=0) 921 1023 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 922 else{ 923 if(strncasecmp(tmpv1+1,"http://",7)!=0 && 924 strncasecmp(tmpv1+1,"ftp://",6)!=0){ 925 char emsg[1024]; 926 sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1); 927 errorException(m,emsg,"InternalError"); 928 freeMaps(&m); 929 free(m); 930 free(REQUEST); 931 free(SERVICE_URL); 932 InternetCloseHandle(hInternet); 933 freeService(&s1); 934 free(s1); 935 return 0; 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); 1042 #endif 1043 #ifndef WIN32 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); 1072 } 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); 936 1078 } 937 #ifdef DEBUG938 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);939 #endif940 #ifndef WIN32941 if(CHECK_INET_HANDLE(hInternet))942 #endif943 {944 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,945 INTERNET_FLAG_NO_CACHE_WRITE,0);946 #ifdef DEBUG947 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",948 tmpv1+1,res.nDataAlloc,res.nDataLen);949 #endif950 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));951 if(tmpContent == NULL){952 return errorException(m, _("Unable to allocate memory."), "InternalError");953 }954 size_t dwRead;955 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);956 map* tmpMap=getMap(tmpmaps->content,"value");957 if(tmpMap!=NULL){958 free(tmpMap->value);959 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));960 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));961 tmpMap->value[res.nDataLen]=0;962 if(strlen(tmpContent)!=res.nDataLen){963 char tmp[256];964 sprintf(tmp,"%d",res.nDataLen*sizeof(char));965 addToMap(tmpmaps->content,"size",tmp);966 }967 }968 free(tmpContent);969 }970 addToMap(tmpmaps->content,tmpn1,tmpv1+1);971 addToMap(tmpmaps->content,"Reference",tmpv1+1);972 }973 1079 tmpc=strtok(NULL,"@"); 974 1080 } … … 1132 1238 hInternet.header=NULL; 1133 1239 while(cur3){ 1240 while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE) 1241 cur2=cur3->next; 1134 1242 if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){ 1135 1243 const char *ha[2]; … … 1697 1805 _tmpMaps->next=NULL; 1698 1806 addToMap(_tmpMaps->content,"status","0"); 1807 addToMap(_tmpMaps->content,"cwd",ntmp); 1699 1808 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1700 1809 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1); … … 1722 1831 dumpMap(request_inputs); 1723 1832 #endif 1724 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 1725 1849 if(status!=NULL) 1726 1850 if(strcasecmp(status->value,"false")==0) … … 1738 1862 pid = fork (); 1739 1863 #else 1740 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); 1741 1873 #endif 1742 1874 if (pid > 0) { … … 1765 1897 fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value); 1766 1898 #endif 1899 freopen(flog,"w+",stderr); 1767 1900 freopen(fbkp , "w+", stdout); 1768 1901 fclose(stdin); 1769 freopen(flog,"w+",stderr);1770 1902 free(fbkp); 1771 1903 free(flog); … … 1778 1910 updateStatus(m); 1779 1911 printProcessResponse(m,request_inputs,cpid, 1780 s1,r_inputs1->value,SERVICE_STARTED, 1781 request_input_real_format, 1782 request_output_real_format); 1912 s1,r_inputs1->value,SERVICE_STARTED, 1913 request_input_real_format, 1914 request_output_real_format); 1915 #ifndef WIN32 1783 1916 fflush(stdout); 1784 1917 rewind(stdout); 1918 #endif 1785 1919 1786 1920 loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres); … … 1798 1932 #ifdef DEBUG 1799 1933 dumpMaps(request_output_real_format); 1800 fprintf(stderr,"Function loaded and returned %d\n", eres);1934 fprintf(stderr,"Function loaded and returned %d\n",*eres); 1801 1935 fflush(stderr); 1802 1936 #endif … … 1805 1939 request_output_real_format,request_inputs, 1806 1940 cpid,m,eres); 1941 fflush(stdout); 1807 1942 /** 1808 1943 * Ensure that if error occurs when freeing memory, no signal will return -
trunk/zoo-services/arithmetics/cgi-env/Multiply.zcfg
r106 r216 5 5 storeSupported = true 6 6 statusSupported = true 7 serviceProvider = demo_service.zo7 serviceProvider = test_service.zo 8 8 serviceType = C 9 9 <MetaData> -
trunk/zoo-services/arithmetics/makefile.vc
r1 r216 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.* -
trunk/zoo-services/arithmetics/test_service.c
r1 r216 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"); -
trunk/zoo-services/ogr/base-vect-ops/makefile.vc
r1 r216 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.* -
trunk/zoo-services/ogr/base-vect-ops/service.c
r55 r216 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 -
trunk/zoo-services/utils/status/service.c
r34 r216 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.