Changeset 364
- Timestamp:
- Sep 29, 2012, 3:59:06 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/thirds/cgic206/cgic.c
r348 r364 145 145 cgiGetenv(&cgiQueryString, "QUERY_STRING"); 146 146 cgiSid=NULL; 147 if( strcmp(cgiQueryString,"")==0&& argc>=2){147 if(cgiQueryString!=NULL && argc>=2){ 148 148 cgiQueryString=argv[1]; 149 149 if(argc>2){ -
trunk/thirds/cgic206/makefile.vc
r216 r364 1 GEODIR= C:/OSGeo4W2 DESTDIR= C:\OSGeo4W1 GEODIR=\MMBK\SRCS\fcgi-2.4.1-SNAP-0311112127\ 2 DESTDIR=.. 3 3 CFLAGS=-g -Wall 4 4 CC=cl /TP 5 LIBS=$(GEODIR)/lib /libfcgi.lib /nologo5 LIBS=$(GEODIR)/libfcgi/Release/libfcgi.lib /nologo 6 6 LIBS1=./libcgic.lib 7 7 8 CFLAGS=/EHa /nologo /DCRT_SECURE_NO_WARNING /M T/W2 /O2 /D "WIN32" \9 -I $(GEODIR) /include8 CFLAGS=/EHa /nologo /DCRT_SECURE_NO_WARNING /MD /W2 /O2 /D "WIN32" \ 9 -I $(GEODIR)\include 10 10 11 11 all: libcgic.lib #cgictest.exe capture.exe -
trunk/thirds/include/unistd.h
r348 r364 3 3 #include <io.h> 4 4 #include <process.h> 5 #define mode_t int 6 #define strtok_r strtok_s 7 #define S_IRWXU _S_IREAD|_S_IWRITE 8 #define S_IRGRP _S_IREAD|_S_IWRITE 9 #define S_IROTH _S_IREAD|_S_IWRITE 10 #define S_IXGRP _S_IREAD|_S_IWRITE 11 #define S_IXOTH _S_IREAD|_S_IWRITE 12 #define S_IWOTH _S_IREAD|_S_IWRITE 13 #define S_IRUSR _S_IREAD 14 #define S_IXGRP _S_IREAD|_S_IWRITE 15 #define S_IWGRP _S_IREAD|_S_IWRITE 16 #define S_IWUSR _S_IREAD|_S_IWRITE 5 17 6 18 #endif -
trunk/zoo-project/zoo-kernel/main_conf_read.l
r354 r364 31 31 attname [a-zA-Z0-9_\-:]+ 32 32 33 attvalue1 [\*, @a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+33 attvalue1 [\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+ 34 34 35 35 attvalue \"[^"]*\"|\'[^']*\' -
trunk/zoo-project/zoo-kernel/makefile.vc
r304 r364 11 11 12 12 main_conf_read.tab.c: main_conf_read.y service.h 13 $(TOOLS)\bison -p cr -d main_conf_read.y13 bison -p cr -d main_conf_read.y 14 14 15 15 main_conf_read.tab.obj: main_conf_read.tab.c service.h … … 17 17 18 18 lex.cr.c: main_conf_read.y main_conf_read.l main_conf_read.tab.c service.h 19 $(TOOLS)\flex -Pcr main_conf_read.l19 flex -Pcr main_conf_read.l 20 20 21 21 lex.cr.obj: lex.cr.c service.h … … 23 23 24 24 service_conf.tab.c: service_conf.y service.h 25 $(TOOLS)\bison -p sr -d service_conf.y25 bison -p sr -d service_conf.y 26 26 27 27 service_conf.tab.obj: service_conf.tab.c service.h … … 29 29 30 30 lex.sr.c: service_conf.y service_conf.l service_conf.tab.c service.h 31 $(TOOLS)\flex -Psr service_conf.l31 flex -Psr service_conf.l 32 32 33 33 lex.sr.obj: lex.sr.c service.h … … 37 37 $(CPP) $(CFLAGS) /c service_internal.c 38 38 39 service_internal_js.obj: service_internal_js.c service.h 40 $(CPP) /c $(CFLAGS) service_internal_js.c 41 42 service_internal_java.obj: service_internal_java.c service.h 43 $(CPP) /c $(CFLAGS) service_internal_java.c 44 39 45 service_internal_python.obj: service_internal_python.c service.h 40 46 $(CPP) /c $(CFLAGS) service_internal_python.c 47 48 service_internal_ms.obj: service_internal_ms.c service.h 49 $(CPP) /c $(CFLAGS) service_internal_ms.c 41 50 42 51 service_internal_java.obj: service_internal_java.c service.h … … 55 64 $(CPP) /EHsc /c $(CFLAGS) ..\..\thirds\dirent-win32\dirent.c 56 65 57 zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj service_internal_python.objulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj dirent.obj58 link zoo_loader.obj dirent.obj service_internal.obj service_internal_python.objulinet.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)66 zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj dirent.obj 67 link zoo_loader.obj dirent.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) 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) 59 68 60 69 clean: -
trunk/zoo-project/zoo-kernel/nmake.opt
r304 r364 1 1 LIBINTL_CPATH=..\..\..\ 2 PYTHON_CPATH=..\..\..\ 2 PYTHON_CPATH=..\..\..\Python-2.7.3 3 3 TPATH=..\..\..\tools 4 GEODIR=c:/OSGeo4W5 DESTDIR=c:/OSGeo4W4 #GEODIR=c:/OSGeo4W 5 #DESTDIR=c:/OSGeo4W 6 6 TOOLS=$(TPATH)\bin 7 7 … … 9 9 CPP=cl /TP $(CFLAGS) 10 10 11 CFLAGS=-DUSE_PYTHON /EHa /nologo /MT /W3 /EHsc /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I./ -I..\..\thirds\dirent-win32 -I..\..\thirds\include -I$(PYTHON_CPATH)\include -I$(GEODIR)/include -ILIBINTL_CPATH\include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 11 !IFDEF JS_DIR 12 JS_CFLAGS=-DXP_WIN -DUSE_JS -I$(JS_DIR) 13 JS_LDFLAGS=$(JS_DIR)/mozjs185-1.0.lib 14 JS_FILE=service_internal_js.obj 15 !ENDIF 12 16 13 LDFLAGS=$(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_imp.lib $(GEODIR)/apps/Python25/libs/python25.lib $(GEODIR)/lib/libxml2.lib ../../thirds/cgic206/libcgic.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)\..\lib\libeay32.dll.a $(TOOLS)\..\lib\libcrypto.a $(TOOLS)\..\lib\libssl32.dll.a $(TOOLS)\..\lib\libintl.lib /machine:i386 17 !IFDEF MS_DIR 18 MS_CFLAGS=-DUSE_MS -I$(MS_DIR) 19 MS_LDFLAGS=$(MS_DIR)/mapserver_i.lib 20 MS_FILE=service_internal_ms.obj 21 !ENDIF 22 23 !IFDEF JDK_DIR 24 JAVA_CFLAGS=-DJAVA7 -DUSE_JAVA -I"$(JDK_DIR)\include" -I"$(JDK_DIR)\include\win32" 25 JAVA_LDFLAGS="$(JDK_DIR)/lib/jvm.lib" 26 JAVA_FILE=service_internal_java.obj 27 !ENDIF 28 29 !IFDEF PY_DIR 30 PY_CFLAGS=-DUSE_PYTHON -I$(PY_DIR)\Include -I$(PY_DIR)\PC 31 PY_LDFLAGS=$(PY_LIBRARY) 32 PY_FILE=service_internal_python.obj 33 !ENDIF 34 35 !IFNDEF ZOOK_DIR 36 ZOOK_DIR=. 37 !ENDIF 38 39 CFLAGS=-SPOST_DEBUG $(CFLAGS1) /nologo /MD /W3 /EHsc /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I$(ZOOK_DIR) -I./ $(JAVA_CFLAGS) -I$(TROOT)..\..\thirds\dirent-win32 -I$(INTL_DIR) -I$(CURL_DIR)\include -I$(XML2_DIR)\include -I$(GDAL_DIR)\port $(JS_CFLAGS) -I$(GDAL_DIR)\ogr -I$(GDAL_DIR)\gcore -I$(GD_DIR) -I$(ICONV_DIR) -I$(TROOT)..\..\thirds\include -I$(TROOT)..\..\thirds\cgic206 -I$(PYTHON_CPATH)\include -I$(SSL_DIR)/inc32 -I$(FCGI_DIR)\include $(PY_CFLAGS) -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 40 41 LDFLAGS=$(FCGI_LIBRARY) $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(TROOT)../../thirds/cgic206/libcgic.lib $(SSL_DIR)/out32dll/libeay32.lib $(JAVA_LDFLAGS) $(SSL_DIR)/out32dll/ssleay32.lib $(MS_LDFLAGS) $(INTL_DIR)/intl.lib $(XML2_DIR)/win32/bin.msvc/libxml2.lib $(GDAL_DIR)/gdal_i.lib $(CURL_DIR)/lib/libcurl.lib $(JS_LDFLAGS) /machine:i386 -
trunk/zoo-project/zoo-kernel/service.h
r362 r364 43 43 #include <string.h> 44 44 45 #ifndef WIN32 45 46 #define bool int 46 47 #define true 1 47 48 #define false -1 49 #endif 48 50 49 51 #define SERVICE_ACCEPTED 0 … … 107 109 fprintf(stderr,"[%s] => [%s] \n",t->name,t->value); 108 110 fflush(stderr); 109 111 }else{ 110 112 fprintf(stderr,"NULL\n"); 111 113 fflush(stderr); … … 124 126 map* tmp=t; 125 127 while(tmp!=NULL){ 128 #ifdef DEBUG 126 129 fprintf(stderr,"%s = %s\n",tmp->name,tmp->value); 130 #endif 127 131 fprintf(file,"%s = %s\n",tmp->name,tmp->value); 128 132 tmp=tmp->next; … … 622 626 map* tmpSize=getMapArray(m,"size",index); 623 627 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 628 #ifdef DEBUG 624 629 fprintf(stderr,"%s\n",tmpSize->value); 630 #endif 625 631 map* ptr=getMapOrFill(m,tmp,""); 626 632 free(ptr->value); … … 640 646 } 641 647 } 642 dumpMap(tmap); 648 #ifdef DEBUG 649 dumpMap(tmap); 650 #endif 643 651 return tmap; 644 652 } … … 676 684 map* tmpVI=getMap(tmp->content,tmpV[i]); 677 685 if(tmpVI!=NULL){ 686 #ifdef DEBUG 678 687 fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value); 688 #endif 679 689 if(i<5) 680 690 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); -
trunk/zoo-project/zoo-kernel/service_internal.c
r360 r364 24 24 25 25 #include "service_internal.h" 26 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 } 26 #ifdef USE_MS 27 #include "service_internal_ms.h" 46 28 #endif 47 29 … … 1215 1197 } 1216 1198 1217 1199 1218 1200 1219 1201 xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp); … … 1232 1214 1233 1215 printDescription(nc,ns_ows,serv->name,serv->content); 1234 fflush(stderr);1216 //fflush(stderr); 1235 1217 1236 1218 xmlAddChild(n,nc); … … 1353 1335 xmlAddChild(n,nc); 1354 1336 } 1337 1355 1338 #ifdef DEBUG 1356 1339 fprintf(stderr,"printProcessResponse 1 202\n"); … … 1481 1464 xmlAddChild(nc,nc1); 1482 1465 // Extract Title required to be first element in the ZCFG file ! 1483 bool isTitle= true;1466 bool isTitle=TRUE; 1484 1467 if(e!=NULL) 1485 1468 tmp=getMap(e->content,"Title"); … … 1625 1608 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){ 1626 1609 xmlDocPtr doc = 1627 xmlParseMemory( BAD_CAST toto->value,strlen(BAD_CASTtoto->value));1610 xmlParseMemory(toto->value,strlen(toto->value)); 1628 1611 xmlNodePtr ir = xmlDocGetRootElement(doc); 1629 1612 xmlAddChild(nc3,ir); … … 1634 1617 xmlAddChild(nc2,nc3); 1635 1618 } 1636 else 1637 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1619 else{ 1620 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1621 } 1638 1622 } 1639 1623 } … … 1667 1651 } 1668 1652 } 1669 1670 1653 xmlAddChild(nc1,nc2); 1671 1654 xmlAddChild(nc,nc1); … … 1826 1809 } 1827 1810 } 1811 1828 1812 if(asRaw==0){ 1829 1813 #ifdef DEBUG … … 1834 1818 while(tmpI!=NULL){ 1835 1819 #ifdef USE_MS 1836 map* testMap=getMap(tmpI->content,"useMapserver"); 1820 map* testMap=getMap(tmpI->content,"useMapserver"); 1837 1821 #endif 1838 1822 toto=getMap(tmpI->content,"asReference"); … … 2204 2188 char *tcn=strdup(tmpContent->name); 2205 2189 for(i=1;i<atoi(length->value);i++){ 2190 #ifdef DEBUG 2206 2191 dumpMap(tmpMaps->content); 2207 2192 fprintf(stderr,"addDefaultValues %s_%d => %s\n",tcn,i,tmpContent->value); 2208 int len=strlen(tcn); 2209 char *tmp1=malloc((len+10)*sizeof(char)); 2193 #endif 2194 int len=strlen((char*) tcn); 2195 char *tmp1=(char *)malloc((len+10)*sizeof(char)); 2210 2196 sprintf(tmp1,"%s_%d",tcn,i); 2197 #ifdef DEBUG 2211 2198 fprintf(stderr,"addDefaultValues %s => %s\n",tmp1,tmpContent->value); 2199 #endif 2212 2200 addToMap(tmpMaps->content,tmp1,tmpContent->value); 2213 2201 free(tmp1); … … 2406 2394 2407 2395 2408 unsignedchar* getMd5(char* url){2396 char* getMd5(char* url){ 2409 2397 EVP_MD_CTX md5ctx; 2410 unsignedchar* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));2398 char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char)); 2411 2399 unsigned char result[EVP_MAX_MD_SIZE]; 2412 2400 unsigned int len; … … 2434 2422 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 2435 2423 if(tmp!=NULL){ 2436 unsignedchar* md5str=getMd5(request);2424 char* md5str=getMd5(request); 2437 2425 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 2438 2426 sprintf(fname,"%s/%s.zca",tmp->value,md5str); … … 2452 2440 map* tmpM=getMapFromMaps(conf,"main","cacheDir"); 2453 2441 if(tmpM!=NULL){ 2454 unsignedchar* md5str=getMd5(request);2442 char* md5str=getMd5(request); 2455 2443 #ifdef DEBUG 2456 2444 fprintf(stderr,"MD5STR : (%s)\n\n",md5str); … … 2474 2462 * Try to load file from cache or download a remote file if not in cache 2475 2463 */ 2476 voidloadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){2464 int loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){ 2477 2465 HINTERNET res; 2478 2466 char* fcontent; … … 2516 2504 free(fcontent); 2517 2505 free(cached); 2506 return 0; 2518 2507 } 2519 2508 -
trunk/zoo-project/zoo-kernel/service_internal.h
r348 r364 66 66 67 67 #ifdef USE_JS 68 #ifdef WIN32 69 #define XP_WIN 1 70 #else 68 71 #define XP_UNIX 0 72 #endif 69 73 #include "service_internal_js.h" 70 74 #endif … … 129 133 void addToCache(maps*,char*,char*,int); 130 134 char* isInCache(maps*,char*); 131 voidloadRemoteFile(maps*,map*,HINTERNET,char*);135 int loadRemoteFile(maps*,map*,HINTERNET,char*); 132 136 133 137 #ifdef __cplusplus -
trunk/zoo-project/zoo-kernel/service_internal_java.c
r360 r364 40 40 classpath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+4)*sizeof(char)); 41 41 oclasspath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+22)*sizeof(char)); 42 #ifndef WIN32 42 43 sprintf(classpath,"%s/%s/:%s",ntmp,tmp->value,cclasspath); 44 #else 45 sprintf(classpath,"%s/%s/;%s",ntmp,tmp->value,cclasspath); 46 #endif 43 47 } 44 48 else{ … … 54 58 #endif 55 59 60 #ifdef WIN32 61 JavaVMOption options[2]; 62 #else 56 63 JavaVMOption options[1]; 64 #endif 57 65 JavaVMInitArgs vm_args; 58 66 JavaVM *jvm; … … 62 70 jfieldID fid; 63 71 jobject jobj; 64 jclass cls,cls_gr; 72 jclass cls; 73 #ifdef JAVA7 74 jobject cls_gr; 75 #else 76 jclass cls_gr; 77 #endif 65 78 int i; 66 79 67 80 options[0].optionString = strdup(oclasspath); 81 #ifdef WIN32 82 options[1].optionString = "-Xmx512M"; 83 #endif 68 84 69 85 JNI_GetDefaultJavaVMInitArgs(&vm_args); 70 86 vm_args.version = JNI_VERSION_1_6; 71 87 vm_args.options = options; 88 #ifdef WIN32 89 vm_args.nOptions = 2; 90 #else 72 91 vm_args.nOptions = 1; 73 vm_args.ignoreUnrecognized = JNI_FALSE; 92 #endif 93 vm_args.ignoreUnrecognized = JNI_TRUE; 74 94 75 95 result = JNI_CreateJavaVM(&jvm,(void **)&env, &vm_args); … … 79 99 } 80 100 #ifdef DEBUG 81 else 101 else 82 102 fprintf(stderr,"JAVA VM Started\n"); 83 103 #endif 84 104 85 105 tmp=getMap(s->content,"serviceProvider"); 106 #ifdef JAVA7 107 cls = env->FindClass(tmp->value); 108 cls_gr = env->NewGlobalRef(cls); 109 #else 86 110 cls = (*env)->FindClass(env,tmp->value); 87 111 cls_gr = (*env)->NewGlobalRef(env, cls); 112 #endif 88 113 if( cls == NULL ) { 89 114 char pbt[10240]; 90 115 sprintf(pbt,"can't find class %s\n",tmp->value); 116 fprintf(stderr,pbt); 117 fflush(stderr); 91 118 map* err=createMap("text",pbt); 92 119 addToMap(err,"code","NoApplicableCode"); … … 94 121 freeMap(&err); 95 122 free(err); 123 #ifdef JAVA7 124 (*jvm).DestroyJavaVM(); 125 #else 96 126 (*jvm)->DestroyJavaVM(jvm); 127 #endif 97 128 return -1; 98 129 } … … 104 135 105 136 if (cls != NULL) { 137 #ifdef JAVA7 138 (*env).ExceptionClear(); 139 pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I"); 140 #else 106 141 (*env)->ExceptionClear(env); 107 142 pmid=(*env)->GetStaticMethodID(env,cls_gr, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I"); 143 #endif 108 144 if (pmid!=0){ 109 145 #ifdef DEBUG … … 112 148 jclass scHashMapClass,scHashMap_class; 113 149 jmethodID scHashMap_constructor; 150 #ifdef JAVA7 151 scHashMapClass = (*env).FindClass("java/util/HashMap"); 152 scHashMap_class = (jclass)(*env).NewGlobalRef(scHashMapClass); 153 scHashMap_constructor = (*env).GetMethodID(scHashMap_class, "<init>", "()V"); 154 #else 114 155 scHashMapClass = (*env)->FindClass(env, "java/util/HashMap"); 115 156 scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass); 116 157 scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V"); 158 #endif 117 159 /** 118 160 * The 3 standard parameter for each services … … 123 165 jint pValue=0; 124 166 167 #ifdef JAVA7 168 pValue=(*env).CallStaticIntMethod(cls,pmid,arg1,arg2,arg3); 169 #else 125 170 pValue=(*env)->CallStaticIntMethod(env,cls,pmid,arg1,arg2,arg3); 171 #endif 126 172 if (pValue != (jint)NULL){ 127 173 res=pValue; … … 146 192 FILE* new_stdout=fopen(tmps,"w+"); 147 193 dup2(fileno(new_stdout),fileno(stdout)); 194 #ifdef JAVA7 195 (*env).ExceptionDescribe(); 196 #else 148 197 (*env)->ExceptionDescribe(env); 198 #endif 149 199 fflush(stdout); 150 200 dup2(old_stdout,fileno(stdout)); … … 152 202 long flen=ftell(new_stdout); 153 203 rewind(new_stdout); 154 char tmps1[flen];204 char *tmps1=(char*)malloc((flen+1)*sizeof(char)); 155 205 fread(tmps1,flen,1,new_stdout); 156 206 fclose(new_stdout); 157 char pbt[100+flen];207 char *pbt=(char*)malloc((100+flen+1)*sizeof(char)); 158 208 sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1); 159 209 map* err=createMap("text",pbt); … … 162 212 freeMap(&err); 163 213 free(err); 214 #ifdef JAVA7 215 (*jvm).DestroyJavaVM(); 216 #else 164 217 (*jvm)->DestroyJavaVM(jvm); 218 #endif 165 219 return -1; 166 220 } … … 173 227 freeMap(&err); 174 228 free(err); 229 #ifdef JAVA7 230 (*jvm).DestroyJavaVM(); 231 #else 175 232 (*jvm)->DestroyJavaVM(jvm); 233 #endif 176 234 return -1; 177 235 } … … 183 241 freeMap(&err); 184 242 free(err); 243 #ifdef JAVA7 244 (*jvm).DestroyJavaVM(); 245 #else 185 246 (*jvm)->DestroyJavaVM(jvm); 247 #endif 186 248 return -1; 187 249 } 250 #ifdef JAVA7 251 (*jvm).DestroyJavaVM(); 252 #else 188 253 (*jvm)->DestroyJavaVM(jvm); 254 #endif 189 255 return res; 190 256 } … … 193 259 jobject scObject,scObject1; 194 260 if(scHashMap_constructor!=NULL){ 261 #ifdef JAVA7 262 scObject = (*env).NewObject(scHashMap_class, scHashMap_constructor); 263 #else 195 264 scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor); 265 #endif 196 266 jmethodID put_mid = 0; 197 267 268 #ifdef JAVA7 269 put_mid = (*env).GetMethodID(scHashMapClass, "put", 270 "(Ljava/lang/Object;Ljava/lang/Object;)" 271 "Ljava/lang/Object;"); 272 #else 198 273 put_mid = (*env)->GetMethodID(env,scHashMapClass, "put", 199 274 "(Ljava/lang/Object;Ljava/lang/Object;)" 200 275 "Ljava/lang/Object;"); 276 #endif 201 277 maps* tmp=t; 202 278 while(tmp!=NULL){ 203 279 map* tmap=getMapType(tmp->content); 204 280 map* tmp1=tmp->content; 281 #ifdef JAVA7 282 scObject1 = (*env).NewObject(scHashMap_class, scHashMap_constructor); 283 #else 205 284 scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor); 285 #endif 206 286 map* sizeV=getMap(tmp1,"size"); 207 287 map* isArray=getMap(tmp1,"isArray"); … … 211 291 if(isArray==NULL){ 212 292 if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){ 293 #ifdef JAVA7 294 jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value)); 295 (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value); 296 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData); 297 #else 213 298 jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value)); 214 299 (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value); 215 300 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData); 301 #endif 216 302 }else 303 #ifdef JAVA7 304 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value)); 305 #else 217 306 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value)); 307 #endif 218 308 } 219 309 else{ … … 224 314 jmethodID scArrayList_constructor; 225 315 jobject scObject2,scObject3,scObject4; 316 #ifdef JAVA7 317 scArrayListClass = (*env).FindClass("java/util/ArrayList"); 318 scArrayList_class = (jclass)(*env).NewGlobalRef(scArrayListClass); 319 scArrayList_constructor = (*env).GetMethodID(scArrayList_class, "<init>", "()V"); 320 jmethodID add_mid = 0; 321 scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 322 scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 323 scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 324 325 add_mid = (*env).GetMethodID(scArrayListClass, 326 "add","(Ljava/lang/Object;)Z"); 327 #else 226 328 scArrayListClass = (*env)->FindClass(env, "java/util/ArrayList"); 227 329 scArrayList_class = (*env)->NewGlobalRef(env, scArrayListClass); … … 234 336 add_mid = (*env)->GetMethodID(env,scArrayListClass, 235 337 "add","(Ljava/lang/Object;)Z"); 236 338 #endif 237 339 int i; 238 340 … … 243 345 244 346 if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){ 347 #ifdef JAVA7 348 jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value)); 349 (*env).SetByteArrayRegion(tmpData,0,atoi(sMap->value),(const jbyte *)vMap->value); 350 (*env).CallObjectMethod(scObject2, add_mid, tmpData); 351 #else 245 352 jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sMap->value)); 246 353 (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sMap->value),vMap->value); 247 354 (*env)->CallObjectMethod(env,scObject2, add_mid, tmpData); 355 #endif 248 356 }else{ 357 #ifdef JAVA7 358 jobject tmpData=(*env).NewStringUTF(vMap->value); 359 (*env).CallObjectMethod(scObject2, add_mid, tmpData); 360 #else 249 361 jobject tmpData=(*env)->NewStringUTF(env,vMap->value); 250 362 (*env)->CallObjectMethod(env,scObject2, add_mid, tmpData); 363 #endif 251 364 } 252 365 253 366 } 254 367 368 #ifdef JAVA7 369 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2); 370 #else 255 371 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2); 256 372 #endif 373 257 374 } 258 375 } 259 376 else 377 #ifdef JAVA7 378 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value)); 379 #else 260 380 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value)); 381 #endif 261 382 tmp1=tmp1->next; 262 383 } 384 #ifdef JAVA7 385 (*env).CallObjectMethod(scObject, put_mid, (*env).NewStringUTF(tmp->name), scObject1); 386 #else 263 387 (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1); 388 #endif 264 389 tmp=tmp->next; 265 390 } … … 292 417 return NULL; 293 418 } 419 #ifdef JAVA7 420 entrySet_mid = (*env).GetMethodID(scHashMapClass, "entrySet", "()Ljava/util/Set;"); 421 containsKey_mid = (*env).GetMethodID(scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z"); 422 get_mid = (*env).GetMethodID(scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 423 #else 294 424 entrySet_mid = (*env)->GetMethodID(env, scHashMapClass, "entrySet", "()Ljava/util/Set;"); 295 425 containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z"); 296 426 get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 427 #endif 297 428 298 429 if(containsKey_mid==0){ … … 319 450 #endif 320 451 452 #ifdef JAVA7 453 scSetClass = (*env).FindClass("java/util/Set"); 454 iterator_mid = (*env).GetMethodID(scSetClass, "iterator", "()Ljava/util/Iterator;"); 455 #else 321 456 scSetClass = (*env)->FindClass(env, "java/util/Set"); 322 457 iterator_mid = (*env)->GetMethodID(env, scSetClass, "iterator", "()Ljava/util/Iterator;"); 458 #endif 323 459 #ifdef DEBUG 324 460 fprintf(stderr,"mapsFromHashMap 1 (%d) \n",iterator_mid); 325 461 #endif 326 462 463 #ifdef JAVA7 464 scIteratorClass = (*env).FindClass("java/util/Iterator"); 465 hasNext_mid = (*env).GetMethodID(scIteratorClass, "hasNext", "()Z"); 466 #else 327 467 scIteratorClass = (*env)->FindClass(env, "java/util/Iterator"); 328 468 hasNext_mid = (*env)->GetMethodID(env, scIteratorClass, "hasNext", "()Z"); 469 #endif 470 329 471 #ifdef DEBUG 330 472 fprintf(stderr,"mapsFromHashMap 2 (%d)\n",hasNext_mid); 331 473 #endif 474 475 #ifdef JAVA7 476 next_mid = (*env).GetMethodID(scIteratorClass, "next", "()Ljava/lang/Object;"); 477 #else 332 478 next_mid = (*env)->GetMethodID(env, scIteratorClass, "next", "()Ljava/lang/Object;"); 479 #endif 333 480 #ifdef DEBUG 334 481 fprintf(stderr,"mapsFromHashMap 3 (%d)\n",next_mid); 335 482 #endif 336 483 484 #ifdef JAVA7 485 scMapEntryClass = (*env).FindClass("java/util/Map$Entry"); 486 getKey_mid = (*env).GetMethodID(scMapEntryClass, "getKey", "()Ljava/lang/Object;"); 487 #else 337 488 scMapEntryClass = (*env)->FindClass(env, "java/util/Map$Entry"); 338 489 getKey_mid = (*env)->GetMethodID(env, scMapEntryClass, "getKey", "()Ljava/lang/Object;"); 490 #endif 339 491 #ifdef DEBUG 340 492 fprintf(stderr,"mapsFromHashMap 4 (%d)\n",getKey_mid); 341 493 #endif 494 #ifdef JAVA7 495 getValue_mid = (*env).GetMethodID(scMapEntryClass, "getValue", "()Ljava/lang/Object;"); 496 #else 342 497 getValue_mid = (*env)->GetMethodID(env, scMapEntryClass, "getValue", "()Ljava/lang/Object;"); 498 #endif 343 499 #ifdef DEBUG 344 500 fprintf(stderr,"mapsFromHashMap 5 (%d)\n",getValue_mid); 345 501 #endif 346 502 503 #ifdef JAVA7 504 jobject final_set=(*env).CallObjectMethod(t,entrySet_mid); 505 jobject final_iterator=(*env).CallObjectMethod(final_set,iterator_mid); 506 #else 347 507 jobject final_set=(*env)->CallObjectMethod(env,t,entrySet_mid); 348 508 jobject final_iterator=(*env)->CallObjectMethod(env,final_set,iterator_mid); 349 509 #endif 350 510 351 511 maps* final_res=NULL; 352 512 map* res=NULL; 513 #ifdef JAVA7 514 while((*env).CallBooleanMethod(final_iterator,hasNext_mid)){ 515 jobject tmp=(*env).CallObjectMethod(final_iterator,next_mid); 516 517 jobject imap=(*env).CallObjectMethod(tmp,getValue_mid); 518 jobject set=(*env).CallObjectMethod(imap,entrySet_mid); 519 jobject iterator=(*env).CallObjectMethod(set,iterator_mid); 520 521 #else 353 522 while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){ 354 523 jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid); … … 358 527 jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid); 359 528 529 #endif 360 530 int size=-1; 531 #ifdef JAVA7 532 if((*env).CallBooleanMethod(imap,containsKey_mid,(*env).NewStringUTF("size"))){ 533 jobject sizeV=(*env).CallObjectMethod(imap, get_mid,(*env).NewStringUTF("size")); 534 const char* sizeVS=(*env).GetStringUTFChars((jstring)sizeV, NULL); 535 #else 361 536 if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){ 362 537 jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size")); 363 538 const char* sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL); 539 #endif 364 540 size=atoi(sizeVS); 365 541 fprintf(stderr,"SIZE : %s\n",sizeVS); 542 #ifdef JAVA7 543 (*env).ReleaseStringUTFChars((jstring)sizeV, sizeVS); 544 #else 366 545 (*env)->ReleaseStringUTFChars(env, sizeV, sizeVS); 546 #endif 367 547 } 368 548 549 #ifdef JAVA7 550 while((*env).CallBooleanMethod(iterator,hasNext_mid)){ 551 jobject tmp1=(*env).CallObjectMethod(iterator,next_mid); 552 jobject jk=(*env).CallObjectMethod(tmp1,getKey_mid); 553 jobject jv=(*env).CallObjectMethod(tmp1,getValue_mid); 554 555 const char* jkd=(*env).GetStringUTFChars((jstring)jk, NULL); 556 #else 369 557 while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){ 370 558 jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid); … … 373 561 374 562 const char* jkd=(*env)->GetStringUTFChars(env, jk, NULL); 563 #endif 375 564 if(size>=0 && strcmp(jkd,"value")==0){ 565 #ifdef JAVA7 566 jobject value=(jobject)(*env).GetByteArrayElements((jbyteArray)jv, NULL); 567 #else 376 568 jobject value=(*env)->GetByteArrayElements(env, jv, NULL); 569 #endif 377 570 if(res==NULL){ 378 571 res=createMap(jkd,""); … … 390 583 } 391 584 else{ 585 #ifdef JAVA7 586 const char* jvd=(*env).GetStringUTFChars((jstring)jv, NULL); 587 #else 392 588 const char* jvd=(*env)->GetStringUTFChars(env, jv, NULL); 589 #endif 393 590 if(res==NULL){ 394 591 res=createMap(jkd,jvd); … … 396 593 addToMap(res,jkd,jvd); 397 594 } 595 #ifdef JAVA7 596 (*env).ReleaseStringUTFChars((jstring)jv, jvd); 597 #else 398 598 (*env)->ReleaseStringUTFChars(env, jv, jvd); 599 #endif 399 600 } 400 601 602 #ifdef JAVA7 603 (*env).ReleaseStringUTFChars((jstring)jk, jkd); 604 #else 401 605 (*env)->ReleaseStringUTFChars(env, jk, jkd); 606 #endif 402 607 403 608 } 609 #ifdef JAVA7 610 jobject jk=(*env).CallObjectMethod(tmp,getKey_mid); 611 #else 404 612 jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid); 613 #endif 405 614 maps* cmap=(maps*)malloc(sizeof(maps)); 615 #ifdef JAVA7 616 cmap->name=(char*)(*env).GetStringUTFChars((jstring)jk, NULL); 617 #else 406 618 cmap->name=(*env)->GetStringUTFChars(env, jk, NULL); 619 #endif 407 620 #ifdef DEBUG 408 621 fprintf(stderr," / %s \n",cmap->name); -
trunk/zoo-project/zoo-kernel/service_internal_js.c
r360 r364 45 45 JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1) 46 46 { 47 map* request = JS_GetContextPrivate(cx);48 map* tmpm1=getMap(request,"metapath");47 //map* request = JS_GetContextPrivate(cx); 48 //map* tmpm1=getMap(request,"metapath"); 49 49 JS_MaybeGC(cx); 50 50 … … 58 58 JSString* jsmsg = JS_ValueToString(cx,argv[i]); 59 59 char *filename = JSValToChar(cx,&argv[i]); 60 char api0[strlen(tmpm1->value)+strlen(ntmp)+strlen(filename)+2];61 sprintf(api0,"%s/%s /%s",ntmp,tmpm1->value,filename);60 char *api0=(char*)malloc((strlen(ntmp)+strlen(filename)+2)*sizeof(char)); 61 sprintf(api0,"%s/%s",ntmp,filename); 62 62 #ifdef JS_DEBUG 63 63 fprintf(stderr,"Trying to load %s\n",api0); 64 fflush(stderr); 64 65 #endif 65 66 JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0); 66 fflush(stderr);67 67 } 68 68 JS_MaybeGC(cx); … … 83 83 JSClass global_class = { 84 84 "global", JSCLASS_GLOBAL_FLAGS, 85 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_ PropertyStub,85 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, 86 86 JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, 87 87 JSCLASS_NO_OPTIONAL_MEMBERS … … 142 142 * Load the first part of the ZOO-API 143 143 */ 144 char api0[strlen(tmpm1->value)+strlen(ntmp)+16];144 char *api0=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+16); 145 145 sprintf(api0,"%s/%s/ZOO-proj4js.js",ntmp,tmpm1->value); 146 146 #ifdef JS_DEBUG … … 150 150 fflush(stderr); 151 151 152 char api1[strlen(tmpm1->value)+strlen(ntmp)+11];152 char *api1=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+11); 153 153 sprintf(api1,"%s/%s/ZOO-api.js",ntmp,tmpm1->value); 154 154 #ifdef JS_DEBUG … … 165 165 map* tmpm2=getMap(s->content,"serviceProvider"); 166 166 167 char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3];167 char *filename=(char*)malloc(strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3); 168 168 sprintf(filename,"%s/%s/%s",ntmp,tmpm1->value,tmpm2->value); 169 169 filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2]=0; … … 173 173 struct stat file_status; 174 174 stat(filename, &file_status); 175 char source[file_status.st_size];175 char *source=(char*)malloc(file_status.st_size); 176 176 uint16 lineno; 177 177 jsval rval; … … 244 244 fprintf(stderr,"An array was returned !\n"); 245 245 #endif 246 js intlen;246 jsuint len; 247 247 if((JS_GetArrayLength(cx, d, &len)==JS_FALSE)){ 248 248 #ifdef JS_DEBUG … … 259 259 JSBool hasElement=JS_GetElement(cx,d,1,&tmp2); 260 260 if(hasElement==JS_TRUE){ 261 freeMaps(outputs); 262 free(*outputs); 261 263 *outputs=mapsFromJSObject(cx,tmp2); 262 264 } … … 285 287 *outputs=mapsFromJSObject(cx,tmp2); 286 288 #ifdef JS_DEBUG 287 dumpMaps(outputs); 288 #endif 289 } 290 289 dumpMaps(*outputs); 290 #endif 291 } 291 292 /* Cleanup. */ 292 293 JS_DestroyContext(cx); … … 355 356 map* isBinary=getMap(t,"size"); 356 357 map* tmap=getMapType(t); 358 #ifdef DEBUG 357 359 if(tmap==NULL) 358 360 fprintf(stderr,"tmap is null !\n"); 359 361 else 360 362 fprintf(stderr,"tmap is not null ! (%s = %s)\n",tmap->name,tmap->value); 361 363 #endif 362 364 /* Avoid gesture of binary content which failed due to strlen function use */ 363 365 if(isBinary!=NULL){ … … 441 443 442 444 jsval nvp=JSVAL_NULL; 443 if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tt), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){445 if((JS_GetProperty(cx, tt, JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){ 444 446 #ifdef JS_DEBUG 445 447 fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg)); … … 447 449 } 448 450 449 JSObject *nvp1=JSVAL_ NULL;451 JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL); 450 452 JS_ValueToObject(cx,nvp,&nvp1); 451 453 jsval nvp1j=OBJECT_TO_JSVAL(nvp1); … … 467 469 } 468 470 469 js int len;471 jsuint len; 470 472 JSBool hasLen=JS_GetArrayLength(cx, tt, &len); 471 473 if(hasLen==JS_FALSE){ … … 522 524 } 523 525 524 JSObject *nvp1=JSVAL_ NULL;526 JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL); 525 527 JS_ValueToObject(cx,nvp,&nvp1); 526 528 jsval nvp1j=OBJECT_TO_JSVAL(nvp1); 527 529 if(JSVAL_IS_OBJECT(nvp1j)){ 528 530 JSString *jsmsg1; 529 JSObject *nvp2=JSVAL_ NULL;531 JSObject *nvp2=JSVAL_TO_OBJECT(JSVAL_NULL); 530 532 jsmsg1 = JS_ValueToString(cx,nvp1j); 531 533 len1 = JS_GetStringLength(jsmsg1); -
trunk/zoo-project/zoo-kernel/service_internal_js.h
r348 r364 28 28 #pragma once 29 29 30 #define XP_UNIX 031 32 30 #include "service.h" 33 31 #include "service_internal.h" … … 35 33 #include <sys/stat.h> 36 34 #include <unistd.h> 37 #include "jsapi.h"38 35 #include "ulinet.h" 39 36 -
trunk/zoo-project/zoo-kernel/service_internal_ms.c
r362 r364 77 77 78 78 void setReferenceUrl(maps* m,maps* tmpI){ 79 dumpMaps(tmpI);79 //dumpMaps(tmpI); 80 80 outputMapfile(m,tmpI); 81 81 map *msUrl=getMapFromMaps(m,"main","mapserverAddress"); … … 299 299 sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y); 300 300 addToMap(output->content,"wcs_extent",tmpExtent); 301 dumpMap(output->content);301 //dumpMap(output->content); 302 302 303 303 }else{ … … 331 331 */ 332 332 333 OGRDataSourceH *poDS1 = NULL;333 OGRDataSourceH poDS1 = NULL; 334 334 OGRSFDriverH *poDriver1 = NULL; 335 335 char *dsName=(char*)malloc((8+strlen(pszDataSource)+1)*sizeof(char)); … … 373 373 char** demo=VSIReadDir(dsName); 374 374 int i=0; 375 mkdir(sdsName,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ); 375 mkdir(sdsName 376 #ifndef WIN32 377 ,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH 378 #endif 379 ); 376 380 while(demo[i]!=NULL){ 377 381 fprintf(stderr,"ZIP File content : %s\n",demo[i]); … … 414 418 } 415 419 416 OGRDataSourceH *poDS = NULL;420 OGRDataSourceH poDS = NULL; 417 421 OGRSFDriverH *poDriver = NULL; 418 422 poDS = OGROpen( pszDataSource, FALSE, poDriver ); … … 432 436 int iLayer = 0; 433 437 for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){ 434 OGRLayerH *poLayer = OGR_DS_GetLayer(poDS,iLayer);438 OGRLayerH poLayer = OGR_DS_GetLayer(poDS,iLayer); 435 439 436 440 if( poLayer == NULL ){ … … 530 534 * Detect the FID column or use the first attribute field as FID 531 535 */ 532 char *fid= OGR_L_GetFIDColumn(poLayer);536 char *fid=(char*)OGR_L_GetFIDColumn(poLayer); 533 537 if(strlen(fid)==0){ 534 538 OGRFeatureDefnH def=OGR_L_GetLayerDefn(poLayer); … … 536 540 for(fIndex=0;fIndex<OGR_FD_GetFieldCount(def);fIndex++){ 537 541 OGRFieldDefnH fdef=OGR_FD_GetFieldDefn(def,fIndex); 538 fid= OGR_Fld_GetNameRef(fdef);542 fid=(char*)OGR_Fld_GetNameRef(fdef); 539 543 break; 540 544 } … … 550 554 551 555 if(msGrowLayerClasses(myLayer) == NULL) 552 return ;553 if(initClass((myLayer-> class[myLayer->numclasses])) == -1)554 return ;555 myLayer-> class[myLayer->numclasses]->type = myLayer->type;556 if(msGrowClassStyles(myLayer-> class[myLayer->numclasses]) == NULL)557 return ;558 if(initStyle(myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)559 return ;556 return -1; 557 if(initClass((myLayer->_class[myLayer->numclasses])) == -1) 558 return -1; 559 myLayer->_class[myLayer->numclasses]->type = myLayer->type; 560 if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL) 561 return -1; 562 if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1) 563 return -1; 560 564 561 565 /** … … 564 568 tmpMap=getMap(output->content,"msStyle"); 565 569 if(tmpMap!=NULL) 566 msUpdateStyleFromString(myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles],tmpMap->value,0);570 msUpdateStyleFromString(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles],tmpMap->value,0); 567 571 else{ 568 572 /** 569 573 * Set style 570 574 */ 571 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=125;572 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=125;573 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=255;574 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.red=80;575 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.green=80;576 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80;575 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=125; 576 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=125; 577 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=255; 578 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.red=80; 579 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.green=80; 580 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80; 577 581 578 582 /** … … 580 584 */ 581 585 if(myLayer->type == MS_LAYER_POLYGON) 582 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;586 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3; 583 587 if(myLayer->type == MS_LAYER_LINE){ 584 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;585 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinewidth=1.5;588 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3; 589 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinewidth=1.5; 586 590 } 587 591 if(myLayer->type == MS_LAYER_POINT){ 588 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->symbol=1;589 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->size=15;590 } 591 592 } 593 myLayer-> class[myLayer->numclasses]->numstyles++;592 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->symbol=1; 593 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->size=15; 594 } 595 596 } 597 myLayer->_class[myLayer->numclasses]->numstyles++; 594 598 myLayer->numclasses++; 595 599 m->layerorder[m->numlayers] = m->numlayers; … … 606 610 607 611 int tryGdal(maps* conf,maps* output,mapObj* m){ 608 609 612 map* tmpMap=getMap(output->content,"storage"); 610 613 char *pszFilename=tmpMap->value; … … 790 793 */ 791 794 if(msGrowLayerClasses(myLayer) == NULL) 792 return ;793 if(initClass((myLayer-> class[myLayer->numclasses])) == -1)794 return ;795 myLayer-> class[myLayer->numclasses]->type = myLayer->type;796 if(msGrowClassStyles(myLayer-> class[myLayer->numclasses]) == NULL)797 return ;798 if(initStyle(myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)799 return ;795 return -1; 796 if(initClass((myLayer->_class[myLayer->numclasses])) == -1) 797 return -1; 798 myLayer->_class[myLayer->numclasses]->type = myLayer->type; 799 if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL) 800 return -1; 801 if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1) 802 return -1; 800 803 801 804 /** … … 804 807 char className[7]; 805 808 sprintf(className,"class%d",i); 806 myLayer-> class[myLayer->numclasses]->name=strdup(className);809 myLayer->_class[myLayer->numclasses]->name=strdup(className); 807 810 808 811 /** … … 814 817 else 815 818 sprintf(expression,"([pixel]>=%.3f AND [pixel]<=%.3f)",cstep,cstep+interval); 816 msLoadExpressionString(&myLayer-> class[myLayer->numclasses]->expression,expression);819 msLoadExpressionString(&myLayer->_class[myLayer->numclasses]->expression,expression); 817 820 818 821 /** 819 822 * Set color 820 823 */ 821 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0];822 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1];823 myLayer-> class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2];824 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0]; 825 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1]; 826 myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2]; 824 827 cstep+=interval; 825 myLayer-> class[myLayer->numclasses]->numstyles++;828 myLayer->_class[myLayer->numclasses]->numstyles++; 826 829 myLayer->numclasses++; 827 830 … … 976 979 } 977 980 981 /* 982 * Set mapserver PROJ_LIB/GDAL_DATA or any other config parameter from 983 * the main.cfg [mapserver] section if any 984 */ 985 maps *tmp3=getMaps(conf,"mapserver"); 986 if(tmp3!=NULL){ 987 map* tmp4=tmp3->content; 988 while(tmp4!=NULL){ 989 msSetConfigOption(myMap,tmp4->name,tmp4->value); 990 tmp4=tmp4->next; 991 } 992 } 993 978 994 /** 979 995 * Set a ows_rootlayer_title, … … 1006 1022 if(tryOgr(conf,outputs,myMap)<0) 1007 1023 if(tryGdal(conf,outputs,myMap)<0) 1008 return NULL;1024 return ; 1009 1025 1010 1026 tmp1=getMapFromMaps(conf,"main","dataPath"); -
trunk/zoo-project/zoo-kernel/service_internal_ms.h
r348 r364 7 7 #include "service.h" 8 8 #include "cpl_conv.h" 9 #include "cpl_multiproc.h" 9 10 #include "ogr_api.h" 10 11 #include "gdal.h" 11 12 #include "ogr_srs_api.h" 12 13 #include "ulinet.h" 14 #ifdef WIN32 15 #include <unistd.h> 16 #endif 13 17 14 18 #include <mapserver.h> 15 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 //#include <mapserver.h> 16 24 /** 17 25 * Map composed by a main.cfg maps name as key and the corresponding … … 41 49 */ 42 50 void outputMapfile(maps* conf,maps* outputs); 51 #ifdef __cplusplus 52 } 53 #endif 43 54 44 55 #endif -
trunk/zoo-project/zoo-kernel/service_internal_python.c
r360 r364 70 70 #else 71 71 SetEnvironmentVariable("PYTHONPATH",pythonpath); 72 char* toto=(char*)malloc((strlen(pythonpath)+12)*sizeof(char)); 73 sprintf(toto,"PYTHONPATH=%s",pythonpath); 74 putenv(toto); 72 75 #endif 73 76 free(python_path); … … 123 126 fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue)); 124 127 dumpMaps(inputs); 125 dumpMaps( outputs);128 dumpMaps(*real_outputs); 126 129 #endif 127 130 }else{ -
trunk/zoo-project/zoo-kernel/ulinet.c
r361 r364 375 375 376 376 #ifdef USE_JS 377 #define XP_WIN 1 377 378 #include "jsapi.h" 378 379 379 380 char* JSValToChar(JSContext* context, jsval* arg) { 381 char *c; 382 char *tmp; 383 JSString *jsmsg; 384 size_t len; 385 int i; 380 386 if(!JSVAL_IS_STRING(*arg)) { 381 387 return NULL; 382 388 } 383 char *c, *tmp;384 JSString *jsmsg;385 size_t len;386 389 jsmsg = JS_ValueToString(context,*arg); 387 390 len = JS_GetStringLength(jsmsg); … … 389 392 c = (char*)malloc((len+1)*sizeof(char)); 390 393 c[len] = '\0'; 391 int i;392 394 #ifdef ULINET_DEBUG 393 395 fprintf(stderr,"%d \n",len); … … 405 407 HINTERNET setHeader(HINTERNET handle,JSContext *cx,JSObject *header){ 406 408 jsuint length=0; 409 jsint i=0; 410 char *tmp1; 407 411 #ifdef ULINET_DEBUG 408 412 fprintf(stderr,"setHeader\n"); … … 416 420 fprintf(stderr,"header is an array of %d elements\n",length); 417 421 #endif 418 jsint i=0;419 422 handle.header=NULL; 420 423 for(i=0;i<length;i++){ 421 424 jsval tmp; 422 425 JS_GetElement(cx,header,i,&tmp); 423 char *tmp1=JSValToChar(cx,&tmp);426 tmp1=JSValToChar(cx,&tmp); 424 427 #ifdef ULINET_DEBUG 425 428 fprintf(stderr,"Element of array n° %d, value : %s\n",i,tmp1); … … 440 443 jsval *argv = JS_ARGV(cx,argv1); 441 444 HINTERNET hInternet; 445 HINTERNET res; 446 HINTERNET res1; 447 JSObject *header; 442 448 char *url; 443 449 char *method; 450 char* tmpValue; 451 size_t dwRead; 452 int i=0; 444 453 JS_MaybeGC(cx); 445 454 hInternet=InternetOpen((LPCTSTR)"ZooWPSClient\0", … … 448 457 if(!CHECK_INET_HANDLE(hInternet)) 449 458 return JS_FALSE; 450 int i=0;451 459 if(argc>=2){ 452 460 method=JSValToChar(cx,&argv[0]); … … 457 465 url=JSValToChar(cx,argv); 458 466 } 459 HINTERNET res;460 467 if(argc==4){ 461 468 char *body; 462 469 body=JSValToChar(cx,&argv[2]); 463 JSObject *header=JSVAL_TO_OBJECT(argv[3]); 464 HINTERNET res1; 470 header=JSVAL_TO_OBJECT(argv[3]); 465 471 #ifdef ULINET_DEBUG 466 472 fprintf(stderr,"URL (%s) \nBODY (%s)\n",url,body); … … 484 490 INTERNET_FLAG_NO_CACHE_WRITE,0); 485 491 } 486 char* tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char)); 487 size_t dwRead; 492 tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char)); 488 493 InternetReadFile(res,(LPVOID)tmpValue,res.nDataLen,&dwRead); 489 494 fprintf(stderr,"content downloaded (%d) (%s) \n",dwRead,tmpValue); -
trunk/zoo-project/zoo-kernel/ulinet.h
r348 r364 35 35 #include "time.h" 36 36 #ifdef USE_JS 37 #ifdef WIN32 38 # define XP_WIN 39 #else 37 40 #define XP_UNIX 0 41 #endif 38 42 #include "jsapi.h" 39 43 #endif -
trunk/zoo-project/zoo-kernel/zoo_loader.c
r348 r364 26 26 #define MALLOC_CHECK 0 27 27 28 #ifdef WIN3229 #include "windows.h"30 #endif31 28 /** 32 29 * Specific includes 33 30 */ 31 #ifndef WIN32 34 32 #include "fcgio.h" 35 33 #include "fcgi_config.h" 36 34 #include "fcgi_stdio.h" 35 #endif 37 36 #include <sys/types.h> 38 37 #include <unistd.h> 39 38 #include "service_internal.h" 39 #ifdef WIN32 40 #include "windows.h" 41 #define strtok_r strtok_s 42 #endif 40 43 41 44 extern "C" { … … 55 58 using namespace std; 56 59 60 #ifndef TRUE 57 61 #define TRUE 1 62 #endif 63 #ifndef FALSE 58 64 #define FALSE -1 65 #endif 59 66 60 67 int cgiMain(){ … … 68 75 fprintf(cgiOut,"Welcome on ZOO verbose debuging mode \r\n\r\n"); 69 76 fflush(cgiOut); 70 #endif71 72 #ifdef DEBUG73 77 fprintf (stderr, "Addr:%s\n", cgiRemoteAddr); 74 78 fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0); … … 143 147 } 144 148 else{ 149 #ifdef DEBUG 145 150 dumpMap(tmpMap); 151 #endif 146 152 char **array, **arrayStep; 147 153 if (cgiFormEntries(&array) != cgiFormSuccess) { -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r362 r364 78 78 #include <windows.h> 79 79 #include <direct.h> 80 #include <sys/types.h> 81 #include <sys/stat.h> 82 #include <unistd.h> 83 #define pid_t int; 80 84 #endif 81 85 #include <fcntl.h> 82 86 #include <time.h> 83 87 #include <stdarg.h> 88 89 #ifdef WIN32 90 extern "C" { 91 __declspec(dllexport) char *strcasestr(char const *a, char const *b) { 92 char *x=_strdup(a); 93 char *y=_strdup(b); 94 95 x=_strlwr(x); 96 y=_strlwr(y); 97 char *pos = strstr(x, y); 98 char *ret = pos == NULL ? NULL : (char *)(a + (pos-x)); 99 free(x); 100 free(y); 101 return ret; 102 } 103 } 104 #endif 84 105 85 106 #define _(String) dgettext ("zoo-kernel",String) … … 218 239 fflush(stderr); 219 240 #endif 220 if(str ncasecmp(r_inputs->value,"C",1)==0){241 if(strlen(r_inputs->value)==1 && strncasecmp(r_inputs->value,"C",1)==0){ 221 242 r_inputs=getMap(request_inputs,"metapath"); 222 243 if(r_inputs!=NULL) … … 402 423 } 403 424 *myMap=m; 404 #ifndef WIN32405 425 *ioutputs=request_output_real_format; 406 #endif407 426 } 408 427 … … 521 540 bindtextdomain ("zoo-kernel","/usr/share/locale/"); 522 541 bindtextdomain ("zoo-services","/usr/share/locale/"); 523 542 543 /** 544 * Manage our own error log file (usefull to separate standard apache debug 545 * messages from the ZOO-Kernel ones but also for IIS users to avoid wrong 546 * headers messages returned by the CGI due to wrong redirection of stderr) 547 */ 548 FILE * fstde=NULL; 549 map* fstdem=getMapFromMaps(m,"main","logPath"); 550 if(fstdem!=NULL) 551 fstde = freopen(fstdem->value, "a+", stderr) ; 552 524 553 if((r_inputs=getMap(request_inputs,"language"))!=NULL){ 525 554 char *tmp=strdup(r_inputs->value); … … 1829 1858 return 1; 1830 1859 } 1831 1832 1860 maps* tmpReqI=request_input_real_format; 1833 1861 while(tmpReqI!=NULL){ … … 1842 1870 char fileNameOnServer[64]; 1843 1871 char contentType[1024]; 1844 char buffer[ BufferLen];1872 char buffer[1024]; 1845 1873 char *tmpStr=NULL; 1846 1874 int size; … … 1866 1894 fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer); 1867 1895 mode=S_IRWXU|S_IRGRP|S_IROTH; 1868 targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC, mode);1896 targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH); 1869 1897 if(targetFile<0){ 1870 1898 fprintf(stderr,"could not create the new file,%s\n",fileNameOnServer); … … 1912 1940 #ifdef DEBUG 1913 1941 fflush(stderr); 1914 fprintf(stderr,"setting variable... %s\n", 1942 fprintf(stderr,"setting variable... %s\n",( 1915 1943 #endif 1916 1944 SetEnvironmentVariable(mapcs->name,mapcs->value) 1917 1945 #ifdef DEBUG 1918 ? "OK" : "FAILED");1946 ==0)? "OK" : "FAILED"); 1919 1947 #else 1920 1948 ; 1921 1949 #endif 1950 char* toto=(char*)malloc((strlen(mapcs->name)+strlen(mapcs->value)+2)*sizeof(char)); 1951 sprintf(toto,"%s=%s",mapcs->name,mapcs->value); 1952 putenv(toto); 1922 1953 #ifdef DEBUG 1923 1954 fflush(stderr); … … 2036 2067 addToMap(request_inputs,"status","true"); 2037 2068 status=getMap(request_inputs,"status"); 2038 fprintf(stderr,"cgiSID : %s",cgiSid);2069 //fprintf(stderr,"cgiSID : %s",cgiSid); 2039 2070 } 2040 2071 #endif 2041 2072 if(status!=NULL) 2042 2073 if(strcasecmp(status->value,"false")==0) 2043 status=NULL ;2074 status=NULLMAP; 2044 2075 if(status==NULLMAP){ 2045 2076 loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres); 2046 2077 } 2047 2078 else{ 2048 pid_t pid;2079 int pid; 2049 2080 #ifdef DEBUG 2050 2081 fprintf(stderr,"\nPID : %d\n",cpid); … … 2171 2202 return 0; 2172 2203 } 2204
Note: See TracChangeset
for help on using the changeset viewer.