Index: trunk/zoo-project/zoo-kernel/main_conf_read.l
===================================================================
--- trunk/zoo-project/zoo-kernel/main_conf_read.l	(revision 362)
+++ trunk/zoo-project/zoo-kernel/main_conf_read.l	(revision 364)
@@ -31,5 +31,5 @@
 attname	[a-zA-Z0-9_\-:]+
 
-attvalue1	[\*,@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
+attvalue1	[\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
 
 attvalue		\"[^"]*\"|\'[^']*\'
Index: trunk/zoo-project/zoo-kernel/makefile.vc
===================================================================
--- trunk/zoo-project/zoo-kernel/makefile.vc	(revision 362)
+++ trunk/zoo-project/zoo-kernel/makefile.vc	(revision 364)
@@ -11,5 +11,5 @@
 
 main_conf_read.tab.c: main_conf_read.y service.h
-	$(TOOLS)\bison -p cr -d main_conf_read.y
+	bison -p cr -d main_conf_read.y
 
 main_conf_read.tab.obj: main_conf_read.tab.c service.h
@@ -17,5 +17,5 @@
 
 lex.cr.c: main_conf_read.y main_conf_read.l main_conf_read.tab.c service.h
-	$(TOOLS)\flex -Pcr main_conf_read.l
+	flex -Pcr main_conf_read.l
 
 lex.cr.obj: lex.cr.c service.h
@@ -23,5 +23,5 @@
 
 service_conf.tab.c: service_conf.y service.h
-	$(TOOLS)\bison -p sr -d service_conf.y
+	bison -p sr -d service_conf.y
 
 service_conf.tab.obj: service_conf.tab.c service.h
@@ -29,5 +29,5 @@
 
 lex.sr.c: service_conf.y service_conf.l service_conf.tab.c service.h
-	$(TOOLS)\flex -Psr service_conf.l
+	flex -Psr service_conf.l
 
 lex.sr.obj: lex.sr.c service.h
@@ -37,6 +37,15 @@
 	$(CPP) $(CFLAGS) /c service_internal.c
 
+service_internal_js.obj: service_internal_js.c service.h
+	$(CPP) /c $(CFLAGS) service_internal_js.c
+
+service_internal_java.obj: service_internal_java.c service.h
+	$(CPP) /c $(CFLAGS) service_internal_java.c
+
 service_internal_python.obj: service_internal_python.c service.h
 	$(CPP) /c $(CFLAGS) service_internal_python.c
+
+service_internal_ms.obj: service_internal_ms.c service.h
+	$(CPP) /c $(CFLAGS) service_internal_ms.c
 
 service_internal_java.obj: service_internal_java.c service.h
@@ -55,6 +64,6 @@
 	$(CPP) /EHsc /c $(CFLAGS) ..\..\thirds\dirent-win32\dirent.c
 
-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
-	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)
+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
+	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)
 
 clean:
Index: trunk/zoo-project/zoo-kernel/nmake.opt
===================================================================
--- trunk/zoo-project/zoo-kernel/nmake.opt	(revision 362)
+++ trunk/zoo-project/zoo-kernel/nmake.opt	(revision 364)
@@ -1,7 +1,7 @@
 LIBINTL_CPATH=..\..\..\
-PYTHON_CPATH=..\..\..\
+PYTHON_CPATH=..\..\..\Python-2.7.3
 TPATH=..\..\..\tools
-GEODIR=c:/OSGeo4W
-DESTDIR=c:/OSGeo4W
+#GEODIR=c:/OSGeo4W
+#DESTDIR=c:/OSGeo4W
 TOOLS=$(TPATH)\bin
 
@@ -9,5 +9,33 @@
 CPP=cl /TP $(CFLAGS)
 
-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
+!IFDEF JS_DIR
+JS_CFLAGS=-DXP_WIN -DUSE_JS -I$(JS_DIR)
+JS_LDFLAGS=$(JS_DIR)/mozjs185-1.0.lib
+JS_FILE=service_internal_js.obj
+!ENDIF
 
-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 
+!IFDEF MS_DIR
+MS_CFLAGS=-DUSE_MS -I$(MS_DIR)
+MS_LDFLAGS=$(MS_DIR)/mapserver_i.lib
+MS_FILE=service_internal_ms.obj
+!ENDIF
+
+!IFDEF JDK_DIR
+JAVA_CFLAGS=-DJAVA7 -DUSE_JAVA -I"$(JDK_DIR)\include" -I"$(JDK_DIR)\include\win32"
+JAVA_LDFLAGS="$(JDK_DIR)/lib/jvm.lib"
+JAVA_FILE=service_internal_java.obj
+!ENDIF
+
+!IFDEF PY_DIR
+PY_CFLAGS=-DUSE_PYTHON -I$(PY_DIR)\Include -I$(PY_DIR)\PC
+PY_LDFLAGS=$(PY_LIBRARY) 
+PY_FILE=service_internal_python.obj
+!ENDIF
+
+!IFNDEF ZOOK_DIR
+ZOOK_DIR=.
+!ENDIF
+
+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
+
+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
Index: trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service.h	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service.h	(revision 364)
@@ -43,7 +43,9 @@
 #include <string.h>
 
+#ifndef WIN32
 #define bool int
 #define true 1
 #define false -1
+#endif
 
 #define SERVICE_ACCEPTED 0
@@ -107,5 +109,5 @@
       fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
       fflush(stderr);
-    }else{
+	}else{
       fprintf(stderr,"NULL\n");
       fflush(stderr);
@@ -124,5 +126,7 @@
     map* tmp=t;
     while(tmp!=NULL){
+#ifdef DEBUG
       fprintf(stderr,"%s = %s\n",tmp->name,tmp->value);
+#endif
       fprintf(file,"%s = %s\n",tmp->name,tmp->value);
       tmp=tmp->next;
@@ -622,5 +626,7 @@
     map* tmpSize=getMapArray(m,"size",index);
     if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){
+#ifdef DEBUG
       fprintf(stderr,"%s\n",tmpSize->value);
+#endif
       map* ptr=getMapOrFill(m,tmp,"");
       free(ptr->value);
@@ -640,5 +646,7 @@
       }
     }
-    dumpMap(tmap);
+#ifdef DEBUG
+	dumpMap(tmap);
+#endif
     return tmap;
   }
@@ -676,5 +684,7 @@
       map* tmpVI=getMap(tmp->content,tmpV[i]);
       if(tmpVI!=NULL){
+#ifdef DEBUG
 	fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value);
+#endif
 	if(i<5)
 	  setMapArray(_cursor->content,tmpV[i],len,tmpVI->value);
Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 364)
@@ -24,24 +24,6 @@
 
 #include "service_internal.h"
-
-#ifdef WIN32
-char *
-strtok_r (char *s1, const char *s2, char **lasts)
-{
-  char *ret;
-  if (s1 == NULL)
-    s1 = *lasts;
-  while (*s1 && strchr(s2, *s1))
-    ++s1;
-  if (*s1 == '\0')
-    return NULL;
-  ret = s1;
-  while (*s1 && !strchr(s2, *s1))
-    ++s1;
-  if (*s1)
-    *s1++ = '\0';
-  *lasts = s1;
-  return ret;
-}
+#ifdef USE_MS
+#include "service_internal_ms.h"
 #endif
 
@@ -1215,5 +1197,5 @@
   }
 
-  
+
 
   xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp);
@@ -1232,5 +1214,5 @@
   
   printDescription(nc,ns_ows,serv->name,serv->content);
-  fflush(stderr);
+  //fflush(stderr);
 
   xmlAddChild(n,nc);
@@ -1353,4 +1335,5 @@
     xmlAddChild(n,nc);
   }
+
 #ifdef DEBUG
   fprintf(stderr,"printProcessResponse 1 202\n");
@@ -1481,5 +1464,5 @@
   xmlAddChild(nc,nc1);
   // Extract Title required to be first element in the ZCFG file !
-  bool isTitle=true;
+  bool isTitle=TRUE;
   if(e!=NULL)
     tmp=getMap(e->content,"Title");
@@ -1625,5 +1608,5 @@
 	     strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){
 	    xmlDocPtr doc =
-	      xmlParseMemory(BAD_CAST toto->value,strlen(BAD_CAST toto->value));
+	      xmlParseMemory(toto->value,strlen(toto->value));
 	    xmlNodePtr ir = xmlDocGetRootElement(doc);
 	    xmlAddChild(nc3,ir);
@@ -1634,6 +1617,7 @@
 	xmlAddChild(nc2,nc3);
       }
-      else
-	xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+      else{
+		  xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
+	  }
     }
   }
@@ -1667,5 +1651,4 @@
     }
   }
-
   xmlAddChild(nc1,nc2);
   xmlAddChild(nc,nc1);
@@ -1826,4 +1809,5 @@
     }
   }
+
   if(asRaw==0){
 #ifdef DEBUG
@@ -1834,5 +1818,5 @@
     while(tmpI!=NULL){
 #ifdef USE_MS
-      map* testMap=getMap(tmpI->content,"useMapserver");
+      map* testMap=getMap(tmpI->content,"useMapserver");	
 #endif
       toto=getMap(tmpI->content,"asReference");
@@ -2204,10 +2188,14 @@
 	      char *tcn=strdup(tmpContent->name);
 	      for(i=1;i<atoi(length->value);i++){
+#ifdef DEBUG
 		dumpMap(tmpMaps->content);
 		fprintf(stderr,"addDefaultValues %s_%d => %s\n",tcn,i,tmpContent->value);
-		int len=strlen(tcn);
-		char *tmp1=malloc((len+10)*sizeof(char));
+#endif
+		int len=strlen((char*) tcn);
+		char *tmp1=(char *)malloc((len+10)*sizeof(char));
 		sprintf(tmp1,"%s_%d",tcn,i);
+#ifdef DEBUG
 		fprintf(stderr,"addDefaultValues %s => %s\n",tmp1,tmpContent->value);
+#endif
 		addToMap(tmpMaps->content,tmp1,tmpContent->value);
 		free(tmp1);
@@ -2406,7 +2394,7 @@
 
 
-unsigned char* getMd5(char* url){
+char* getMd5(char* url){
   EVP_MD_CTX md5ctx;
-  unsigned char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
+  char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char));
   unsigned char result[EVP_MAX_MD_SIZE];
   unsigned int len;
@@ -2434,5 +2422,5 @@
   map* tmp=getMapFromMaps(conf,"main","cacheDir");
   if(tmp!=NULL){
-    unsigned char* md5str=getMd5(request);
+    char* md5str=getMd5(request);
     char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6));
     sprintf(fname,"%s/%s.zca",tmp->value,md5str);
@@ -2452,5 +2440,5 @@
   map* tmpM=getMapFromMaps(conf,"main","cacheDir");
   if(tmpM!=NULL){
-    unsigned char* md5str=getMd5(request);
+    char* md5str=getMd5(request);
 #ifdef DEBUG
     fprintf(stderr,"MD5STR : (%s)\n\n",md5str);
@@ -2474,5 +2462,5 @@
  * Try to load file from cache or download a remote file if not in cache
  */
-void loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){
+int loadRemoteFile(maps* m,map* content,HINTERNET hInternet,char *url){
   HINTERNET res;
   char* fcontent;
@@ -2516,4 +2504,5 @@
   free(fcontent);
   free(cached);
+  return 0;
 }
 
Index: trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.h	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal.h	(revision 364)
@@ -66,5 +66,9 @@
 
 #ifdef USE_JS
+#ifdef WIN32
+#define XP_WIN 1
+#else
 #define XP_UNIX 0
+#endif
 #include "service_internal_js.h"
 #endif
@@ -129,5 +133,5 @@
   void addToCache(maps*,char*,char*,int);
   char* isInCache(maps*,char*);
-  void loadRemoteFile(maps*,map*,HINTERNET,char*);
+  int loadRemoteFile(maps*,map*,HINTERNET,char*);
   
 #ifdef __cplusplus
Index: trunk/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 364)
@@ -40,5 +40,9 @@
       classpath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+4)*sizeof(char));
       oclasspath=(char*) malloc((strlen(ntmp)+strlen(tmp->value)+strlen(cclasspath)+22)*sizeof(char));
+#ifndef WIN32
       sprintf(classpath,"%s/%s/:%s",ntmp,tmp->value,cclasspath);
+#else
+      sprintf(classpath,"%s/%s/;%s",ntmp,tmp->value,cclasspath);
+#endif
     }
     else{
@@ -54,5 +58,9 @@
 #endif
 
+#ifdef WIN32
+  JavaVMOption options[2];
+#else
   JavaVMOption options[1];
+#endif
   JavaVMInitArgs vm_args;
   JavaVM *jvm;
@@ -62,14 +70,26 @@
   jfieldID fid;
   jobject jobj;
-  jclass cls,cls_gr;
+  jclass cls;
+#ifdef JAVA7
+  jobject cls_gr;
+#else
+  jclass cls_gr;
+#endif
   int i;
 
   options[0].optionString = strdup(oclasspath);
+#ifdef WIN32
+  options[1].optionString = "-Xmx512M";
+#endif
 
   JNI_GetDefaultJavaVMInitArgs(&vm_args);
   vm_args.version = JNI_VERSION_1_6;
   vm_args.options = options;
+#ifdef WIN32
+  vm_args.nOptions = 2;
+#else
   vm_args.nOptions = 1;
-  vm_args.ignoreUnrecognized = JNI_FALSE;
+#endif
+  vm_args.ignoreUnrecognized = JNI_TRUE;
 
   result = JNI_CreateJavaVM(&jvm,(void **)&env, &vm_args);
@@ -79,14 +99,21 @@
   }
 #ifdef DEBUG
-  else  
+  else
     fprintf(stderr,"JAVA VM Started\n");
 #endif
 
   tmp=getMap(s->content,"serviceProvider");
+#ifdef JAVA7
+  cls = env->FindClass(tmp->value);
+  cls_gr = env->NewGlobalRef(cls);
+#else
   cls = (*env)->FindClass(env,tmp->value);
   cls_gr = (*env)->NewGlobalRef(env, cls);
+#endif
   if( cls == NULL ) {
     char pbt[10240];
     sprintf(pbt,"can't find class %s\n",tmp->value);
+    fprintf(stderr,pbt);
+    fflush(stderr);
     map* err=createMap("text",pbt);
     addToMap(err,"code","NoApplicableCode");
@@ -94,5 +121,9 @@
     freeMap(&err);
     free(err);
+#ifdef JAVA7
+    (*jvm).DestroyJavaVM();
+#else
     (*jvm)->DestroyJavaVM(jvm);
+#endif
     return -1;
   }
@@ -104,6 +135,11 @@
 
   if (cls != NULL) {
+#ifdef JAVA7
+    (*env).ExceptionClear();
+    pmid=(*env).GetStaticMethodID(cls, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
+#else
     (*env)->ExceptionClear(env);
     pmid=(*env)->GetStaticMethodID(env,cls_gr, s->name, "(Ljava/util/HashMap;Ljava/util/HashMap;Ljava/util/HashMap;)I");
+#endif
     if (pmid!=0){
 #ifdef DEBUG
@@ -112,7 +148,13 @@
       jclass scHashMapClass,scHashMap_class;
       jmethodID scHashMap_constructor;
+#ifdef JAVA7
+      scHashMapClass = (*env).FindClass("java/util/HashMap");
+      scHashMap_class = (jclass)(*env).NewGlobalRef(scHashMapClass);
+      scHashMap_constructor = (*env).GetMethodID(scHashMap_class, "<init>", "()V");
+#else
       scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
       scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
       scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");
+#endif
       /**
        * The 3 standard parameter for each services
@@ -123,5 +165,9 @@
       jint pValue=0;
 
+#ifdef JAVA7
+      pValue=(*env).CallStaticIntMethod(cls,pmid,arg1,arg2,arg3);
+#else
       pValue=(*env)->CallStaticIntMethod(env,cls,pmid,arg1,arg2,arg3);
+#endif
       if (pValue != (jint)NULL){
 	res=pValue;
@@ -146,5 +192,9 @@
 	FILE* new_stdout=fopen(tmps,"w+");
 	dup2(fileno(new_stdout),fileno(stdout));
+#ifdef JAVA7
+	(*env).ExceptionDescribe();
+#else
 	(*env)->ExceptionDescribe(env);
+#endif
 	fflush(stdout);
 	dup2(old_stdout,fileno(stdout));
@@ -152,8 +202,8 @@
 	long flen=ftell(new_stdout);
 	rewind(new_stdout);
-	char tmps1[flen];
+	char *tmps1=(char*)malloc((flen+1)*sizeof(char));
 	fread(tmps1,flen,1,new_stdout);
 	fclose(new_stdout);
-	char pbt[100+flen];
+	char *pbt=(char*)malloc((100+flen+1)*sizeof(char));
 	sprintf(pbt,"Unable to run your java process properly. Server returns : %s",tmps1);
 	map* err=createMap("text",pbt);
@@ -162,5 +212,9 @@
 	freeMap(&err);
 	free(err);
+#ifdef JAVA7
+	(*jvm).DestroyJavaVM();
+#else
 	(*jvm)->DestroyJavaVM(jvm);
+#endif
 	return -1;
       }
@@ -173,5 +227,9 @@
       freeMap(&err);
       free(err);
+#ifdef JAVA7
+      (*jvm).DestroyJavaVM();
+#else
       (*jvm)->DestroyJavaVM(jvm);
+#endif
       return -1;
     }
@@ -183,8 +241,16 @@
     freeMap(&err);
     free(err);
+#ifdef JAVA7
+    (*jvm).DestroyJavaVM();
+#else
     (*jvm)->DestroyJavaVM(jvm);
+#endif
     return -1;
   }
+#ifdef JAVA7
+      (*jvm).DestroyJavaVM();
+#else
   (*jvm)->DestroyJavaVM(jvm);
+#endif
   return res;
 }
@@ -193,15 +259,29 @@
   jobject scObject,scObject1;
   if(scHashMap_constructor!=NULL){
+#ifdef JAVA7
+    scObject = (*env).NewObject(scHashMap_class, scHashMap_constructor);
+#else
     scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
+#endif
     jmethodID put_mid = 0;
 
+#ifdef JAVA7
+    put_mid = (*env).GetMethodID(scHashMapClass, "put",
+				  "(Ljava/lang/Object;Ljava/lang/Object;)"
+				  "Ljava/lang/Object;");
+#else
     put_mid = (*env)->GetMethodID(env,scHashMapClass, "put",
 				  "(Ljava/lang/Object;Ljava/lang/Object;)"
 				  "Ljava/lang/Object;");
+#endif
     maps* tmp=t;
     while(tmp!=NULL){
       map* tmap=getMapType(tmp->content);
       map* tmp1=tmp->content;
+#ifdef JAVA7
+      scObject1 = (*env).NewObject(scHashMap_class, scHashMap_constructor);
+#else
       scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
+#endif
       map* sizeV=getMap(tmp1,"size");
       map* isArray=getMap(tmp1,"isArray");
@@ -211,9 +291,19 @@
 	  if(isArray==NULL){
 	    if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
+#ifdef JAVA7
+	      jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
+	      (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value);
+	      (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData);
+#else
 	      jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
 	      (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
+#endif
 	    }else
+#ifdef JAVA7
+	      (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
+#else
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
+#endif
 	  }
 	  else{
@@ -224,4 +314,16 @@
 	    jmethodID scArrayList_constructor;
 	    jobject scObject2,scObject3,scObject4;
+#ifdef JAVA7
+	    scArrayListClass = (*env).FindClass("java/util/ArrayList");
+	    scArrayList_class = (jclass)(*env).NewGlobalRef(scArrayListClass);
+	    scArrayList_constructor = (*env).GetMethodID(scArrayList_class, "<init>", "()V");
+	    jmethodID add_mid = 0;
+	    scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+	    scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+	    scObject4 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
+
+	    add_mid = (*env).GetMethodID(scArrayListClass,
+					  "add","(Ljava/lang/Object;)Z");
+#else
 	    scArrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
 	    scArrayList_class = (*env)->NewGlobalRef(env, scArrayListClass);
@@ -234,5 +336,5 @@
 	    add_mid = (*env)->GetMethodID(env,scArrayListClass,
 					  "add","(Ljava/lang/Object;)Z");
-	    
+#endif	    
 	    int i;
 	    
@@ -243,23 +345,46 @@
 	      
 	      if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0){
+#ifdef JAVA7
+		jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value));
+		(*env).SetByteArrayRegion(tmpData,0,atoi(sMap->value),(const jbyte *)vMap->value);
+		(*env).CallObjectMethod(scObject2, add_mid, tmpData);
+#else
 		jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sMap->value));
 		(*env)->SetByteArrayRegion(env,tmpData,0,atoi(sMap->value),vMap->value);
 		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+#endif
 	      }else{
+#ifdef JAVA7
+		jobject tmpData=(*env).NewStringUTF(vMap->value);
+		(*env).CallObjectMethod(scObject2, add_mid, tmpData);
+#else
 		jobject tmpData=(*env)->NewStringUTF(env,vMap->value);
 		(*env)->CallObjectMethod(env,scObject2, add_mid, tmpData);
+#endif
 	      }
 	      
 	    }
-	    
+
+#ifdef JAVA7
+	    (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2);
+#else	    
 	    (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2);
-	    
+#endif
+
 	  }
 	}
 	else
+#ifdef JAVA7
+	  (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), (*env).NewStringUTF(tmp1->value));
+#else
 	  (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
+#endif
 	tmp1=tmp1->next;
       }
+#ifdef JAVA7
+      (*env).CallObjectMethod(scObject, put_mid, (*env).NewStringUTF(tmp->name), scObject1);
+#else
       (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1);
+#endif
       tmp=tmp->next;
     }
@@ -292,7 +417,13 @@
     return NULL;
   }
+#ifdef JAVA7
+  entrySet_mid = (*env).GetMethodID(scHashMapClass, "entrySet", "()Ljava/util/Set;"); 
+  containsKey_mid = (*env).GetMethodID(scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
+  get_mid = (*env).GetMethodID(scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 
+#else
   entrySet_mid = (*env)->GetMethodID(env, scHashMapClass, "entrySet", "()Ljava/util/Set;"); 
   containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z");
   get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 
+#endif
 
   if(containsKey_mid==0){
@@ -319,36 +450,74 @@
 #endif
 
+#ifdef JAVA7
+  scSetClass = (*env).FindClass("java/util/Set");
+  iterator_mid = (*env).GetMethodID(scSetClass, "iterator", "()Ljava/util/Iterator;"); 
+#else
   scSetClass = (*env)->FindClass(env, "java/util/Set");
   iterator_mid = (*env)->GetMethodID(env, scSetClass, "iterator", "()Ljava/util/Iterator;"); 
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 1 (%d) \n",iterator_mid);
 #endif
 
+#ifdef JAVA7
+  scIteratorClass = (*env).FindClass("java/util/Iterator");
+  hasNext_mid = (*env).GetMethodID(scIteratorClass, "hasNext", "()Z");
+#else
   scIteratorClass = (*env)->FindClass(env, "java/util/Iterator");
   hasNext_mid = (*env)->GetMethodID(env, scIteratorClass, "hasNext", "()Z");
+#endif
+
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 2 (%d)\n",hasNext_mid);
 #endif
+
+#ifdef JAVA7
+  next_mid = (*env).GetMethodID(scIteratorClass, "next", "()Ljava/lang/Object;");
+#else
   next_mid = (*env)->GetMethodID(env, scIteratorClass, "next", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 3 (%d)\n",next_mid);
 #endif
 
+#ifdef JAVA7
+  scMapEntryClass = (*env).FindClass("java/util/Map$Entry");
+  getKey_mid = (*env).GetMethodID(scMapEntryClass, "getKey", "()Ljava/lang/Object;");
+#else
   scMapEntryClass = (*env)->FindClass(env, "java/util/Map$Entry");
   getKey_mid = (*env)->GetMethodID(env, scMapEntryClass, "getKey", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 4 (%d)\n",getKey_mid);
 #endif
+#ifdef JAVA7
+  getValue_mid = (*env).GetMethodID(scMapEntryClass, "getValue", "()Ljava/lang/Object;");
+#else
   getValue_mid = (*env)->GetMethodID(env, scMapEntryClass, "getValue", "()Ljava/lang/Object;");
+#endif
 #ifdef DEBUG
   fprintf(stderr,"mapsFromHashMap 5 (%d)\n",getValue_mid);
 #endif
 
+#ifdef JAVA7
+  jobject final_set=(*env).CallObjectMethod(t,entrySet_mid);
+  jobject final_iterator=(*env).CallObjectMethod(final_set,iterator_mid);
+#else
   jobject final_set=(*env)->CallObjectMethod(env,t,entrySet_mid);
   jobject final_iterator=(*env)->CallObjectMethod(env,final_set,iterator_mid);
-
+#endif
 
   maps* final_res=NULL;
   map* res=NULL;
+#ifdef JAVA7
+  while((*env).CallBooleanMethod(final_iterator,hasNext_mid)){
+    jobject tmp=(*env).CallObjectMethod(final_iterator,next_mid);
+
+    jobject imap=(*env).CallObjectMethod(tmp,getValue_mid);
+    jobject set=(*env).CallObjectMethod(imap,entrySet_mid);
+    jobject iterator=(*env).CallObjectMethod(set,iterator_mid);
+
+#else
   while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){
     jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid);
@@ -358,13 +527,32 @@
     jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
 
+#endif
     int size=-1;
+#ifdef JAVA7
+    if((*env).CallBooleanMethod(imap,containsKey_mid,(*env).NewStringUTF("size"))){
+      jobject sizeV=(*env).CallObjectMethod(imap, get_mid,(*env).NewStringUTF("size"));
+      const char* sizeVS=(*env).GetStringUTFChars((jstring)sizeV, NULL);
+#else
     if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){
       jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size"));
       const char* sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL);
+#endif
       size=atoi(sizeVS);
       fprintf(stderr,"SIZE : %s\n",sizeVS);
+#ifdef JAVA7
+      (*env).ReleaseStringUTFChars((jstring)sizeV, sizeVS);
+#else
       (*env)->ReleaseStringUTFChars(env, sizeV, sizeVS);
+#endif
     }
     
+#ifdef JAVA7
+    while((*env).CallBooleanMethod(iterator,hasNext_mid)){
+      jobject tmp1=(*env).CallObjectMethod(iterator,next_mid);
+      jobject jk=(*env).CallObjectMethod(tmp1,getKey_mid);
+      jobject jv=(*env).CallObjectMethod(tmp1,getValue_mid);
+
+      const char* jkd=(*env).GetStringUTFChars((jstring)jk, NULL);
+#else
     while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
       jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
@@ -373,6 +561,11 @@
 
       const char* jkd=(*env)->GetStringUTFChars(env, jk, NULL);
+#endif
       if(size>=0 && strcmp(jkd,"value")==0){
+#ifdef JAVA7
+	jobject value=(jobject)(*env).GetByteArrayElements((jbyteArray)jv, NULL);
+#else
 	jobject value=(*env)->GetByteArrayElements(env, jv, NULL);
+#endif
 	if(res==NULL){
 	  res=createMap(jkd,"");
@@ -390,5 +583,9 @@
       }
       else{
+#ifdef JAVA7
+	const char* jvd=(*env).GetStringUTFChars((jstring)jv, NULL);
+#else
 	const char* jvd=(*env)->GetStringUTFChars(env, jv, NULL);
+#endif
 	if(res==NULL){
 	  res=createMap(jkd,jvd);
@@ -396,13 +593,29 @@
 	  addToMap(res,jkd,jvd);
 	}
+#ifdef JAVA7
+	(*env).ReleaseStringUTFChars((jstring)jv, jvd);
+#else
 	(*env)->ReleaseStringUTFChars(env, jv, jvd);
+#endif
       }
 
+#ifdef JAVA7
+      (*env).ReleaseStringUTFChars((jstring)jk, jkd);
+#else
       (*env)->ReleaseStringUTFChars(env, jk, jkd);
+#endif
 
     }
+#ifdef JAVA7
+    jobject jk=(*env).CallObjectMethod(tmp,getKey_mid);
+#else
     jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid);
+#endif
     maps* cmap=(maps*)malloc(sizeof(maps));
+#ifdef JAVA7
+    cmap->name=(char*)(*env).GetStringUTFChars((jstring)jk, NULL);
+#else
     cmap->name=(*env)->GetStringUTFChars(env, jk, NULL);
+#endif
 #ifdef DEBUG
     fprintf(stderr," / %s \n",cmap->name);
Index: trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 364)
@@ -45,6 +45,6 @@
 JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
 {
-  map* request = JS_GetContextPrivate(cx);
-  map* tmpm1=getMap(request,"metapath");
+  //map* request = JS_GetContextPrivate(cx);
+  //map* tmpm1=getMap(request,"metapath");
   JS_MaybeGC(cx);
 
@@ -58,11 +58,11 @@
     JSString* jsmsg = JS_ValueToString(cx,argv[i]);
     char *filename = JSValToChar(cx,&argv[i]);
-    char api0[strlen(tmpm1->value)+strlen(ntmp)+strlen(filename)+2];
-    sprintf(api0,"%s/%s/%s",ntmp,tmpm1->value,filename);
+    char *api0=(char*)malloc((strlen(ntmp)+strlen(filename)+2)*sizeof(char));
+    sprintf(api0,"%s/%s",ntmp,filename);
 #ifdef JS_DEBUG
     fprintf(stderr,"Trying to load %s\n",api0);
+    fflush(stderr);
 #endif
     JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0);
-    fflush(stderr);
   }
   JS_MaybeGC(cx);
@@ -83,5 +83,5 @@
   JSClass global_class = {
     "global", JSCLASS_GLOBAL_FLAGS,
-    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
     JSCLASS_NO_OPTIONAL_MEMBERS
@@ -142,5 +142,5 @@
    * Load the first part of the ZOO-API
    */
-  char api0[strlen(tmpm1->value)+strlen(ntmp)+16];
+  char *api0=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+16);
   sprintf(api0,"%s/%s/ZOO-proj4js.js",ntmp,tmpm1->value);
 #ifdef JS_DEBUG
@@ -150,5 +150,5 @@
   fflush(stderr);
 
-  char api1[strlen(tmpm1->value)+strlen(ntmp)+11];
+  char *api1=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+11);
   sprintf(api1,"%s/%s/ZOO-api.js",ntmp,tmpm1->value);
 #ifdef JS_DEBUG
@@ -165,5 +165,5 @@
   map* tmpm2=getMap(s->content,"serviceProvider");
 
-  char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3];
+  char *filename=(char*)malloc(strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+3);
   sprintf(filename,"%s/%s/%s",ntmp,tmpm1->value,tmpm2->value);
   filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2]=0;
@@ -173,5 +173,5 @@
   struct stat file_status;
   stat(filename, &file_status);
-  char source[file_status.st_size];
+  char *source=(char*)malloc(file_status.st_size);
   uint16 lineno;
   jsval rval;
@@ -244,5 +244,5 @@
     fprintf(stderr,"An array was returned !\n");
 #endif
-    jsint len;
+    jsuint	 len;
     if((JS_GetArrayLength(cx, d, &len)==JS_FALSE)){
 #ifdef JS_DEBUG
@@ -259,4 +259,6 @@
     JSBool hasElement=JS_GetElement(cx,d,1,&tmp2);
     if(hasElement==JS_TRUE){
+	  freeMaps(outputs);
+	  free(*outputs);
       *outputs=mapsFromJSObject(cx,tmp2);
     }
@@ -285,8 +287,7 @@
     *outputs=mapsFromJSObject(cx,tmp2);
 #ifdef JS_DEBUG
-    dumpMaps(outputs);
-#endif
-  }
-
+    dumpMaps(*outputs);
+#endif
+  }
   /* Cleanup. */
   JS_DestroyContext(cx);
@@ -355,9 +356,10 @@
   map* isBinary=getMap(t,"size");
   map* tmap=getMapType(t);
+#ifdef DEBUG
   if(tmap==NULL)
     fprintf(stderr,"tmap is null !\n");
   else
     fprintf(stderr,"tmap is not null ! (%s = %s)\n",tmap->name,tmap->value);
-
+#endif
   /* Avoid gesture of binary content which failed due to strlen function use */
   if(isBinary!=NULL){
@@ -441,5 +443,5 @@
 
 	jsval nvp=JSVAL_NULL;
-	if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tt), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
+	if((JS_GetProperty(cx, tt, JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
 #ifdef JS_DEBUG
 	  fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
@@ -447,5 +449,5 @@
 	}
 	
-	JSObject *nvp1=JSVAL_NULL;
+	JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL);
 	JS_ValueToObject(cx,nvp,&nvp1);
 	jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
@@ -467,5 +469,5 @@
   }
 
-  jsint len;
+  jsuint len;
   JSBool hasLen=JS_GetArrayLength(cx, tt, &len);
   if(hasLen==JS_FALSE){
@@ -522,10 +524,10 @@
 	}
 
-	JSObject *nvp1=JSVAL_NULL;
+	JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL);
 	JS_ValueToObject(cx,nvp,&nvp1);
 	jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
 	if(JSVAL_IS_OBJECT(nvp1j)){
 	  JSString *jsmsg1;
-	  JSObject *nvp2=JSVAL_NULL;
+	  JSObject *nvp2=JSVAL_TO_OBJECT(JSVAL_NULL);
 	  jsmsg1 = JS_ValueToString(cx,nvp1j);
 	  len1 = JS_GetStringLength(jsmsg1);
Index: trunk/zoo-project/zoo-kernel/service_internal_js.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_js.h	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_js.h	(revision 364)
@@ -28,6 +28,4 @@
 #pragma once 
 
-#define XP_UNIX 0
-
 #include "service.h"
 #include "service_internal.h"
@@ -35,5 +33,4 @@
 #include <sys/stat.h>
 #include <unistd.h>
-#include "jsapi.h"
 #include "ulinet.h"
 
Index: trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 364)
@@ -77,5 +77,5 @@
 
 void setReferenceUrl(maps* m,maps* tmpI){
-  dumpMaps(tmpI);
+  //dumpMaps(tmpI);
   outputMapfile(m,tmpI);
   map *msUrl=getMapFromMaps(m,"main","mapserverAddress");
@@ -299,5 +299,5 @@
       sprintf(tmpSrsStr,"%.3f,%.3f,%.3f,%.3f",min.x,min.y,max.x,max.y);
       addToMap(output->content,"wcs_extent",tmpExtent);
-      dumpMap(output->content);
+      //dumpMap(output->content);
 
     }else{
@@ -331,5 +331,5 @@
    */
 
-  OGRDataSourceH *poDS1 = NULL;
+  OGRDataSourceH poDS1 = NULL;
   OGRSFDriverH *poDriver1 = NULL;
   char *dsName=(char*)malloc((8+strlen(pszDataSource)+1)*sizeof(char));
@@ -373,5 +373,9 @@
     char** demo=VSIReadDir(dsName);
     int i=0;
-    mkdir(sdsName,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH );
+    mkdir(sdsName
+#ifndef WIN32
+		,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH 
+#endif
+		);
     while(demo[i]!=NULL){
       fprintf(stderr,"ZIP File content : %s\n",demo[i]);
@@ -414,5 +418,5 @@
   }
 
-  OGRDataSourceH *poDS = NULL;
+  OGRDataSourceH poDS = NULL;
   OGRSFDriverH *poDriver = NULL;
   poDS = OGROpen( pszDataSource, FALSE, poDriver );
@@ -432,5 +436,5 @@
   int iLayer = 0;
   for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){
-    OGRLayerH *poLayer = OGR_DS_GetLayer(poDS,iLayer);
+    OGRLayerH poLayer = OGR_DS_GetLayer(poDS,iLayer);
 
     if( poLayer == NULL ){
@@ -530,5 +534,5 @@
      * Detect the FID column or use the first attribute field as FID
      */
-    char *fid=OGR_L_GetFIDColumn(poLayer);
+    char *fid=(char*)OGR_L_GetFIDColumn(poLayer);
     if(strlen(fid)==0){
       OGRFeatureDefnH def=OGR_L_GetLayerDefn(poLayer);
@@ -536,5 +540,5 @@
       for(fIndex=0;fIndex<OGR_FD_GetFieldCount(def);fIndex++){
 	OGRFieldDefnH fdef=OGR_FD_GetFieldDefn(def,fIndex);
-	fid=OGR_Fld_GetNameRef(fdef);
+	fid=(char*)OGR_Fld_GetNameRef(fdef);
 	break;
       }
@@ -550,12 +554,12 @@
 
     if(msGrowLayerClasses(myLayer) == NULL)
-      return;
-    if(initClass((myLayer->class[myLayer->numclasses])) == -1)
-      return;
-    myLayer->class[myLayer->numclasses]->type = myLayer->type;
-    if(msGrowClassStyles(myLayer->class[myLayer->numclasses]) == NULL)
-      return ;
-    if(initStyle(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)
-      return;
+      return -1;
+    if(initClass((myLayer->_class[myLayer->numclasses])) == -1)
+      return -1;
+    myLayer->_class[myLayer->numclasses]->type = myLayer->type;
+    if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL)
+      return -1;
+    if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1)
+      return -1;
 
     /**
@@ -564,15 +568,15 @@
     tmpMap=getMap(output->content,"msStyle");
     if(tmpMap!=NULL)
-      msUpdateStyleFromString(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles],tmpMap->value,0);
+      msUpdateStyleFromString(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles],tmpMap->value,0);
     else{
       /**
        * Set style
        */
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=125;
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=125;
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=255;
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.red=80;
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.green=80;
-      myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=125;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=125;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=255;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.red=80;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.green=80;
+      myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinecolor.blue=80;
 
       /**
@@ -580,16 +584,16 @@
        */
       if(myLayer->type == MS_LAYER_POLYGON)
-	myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;
+	myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3;
       if(myLayer->type == MS_LAYER_LINE){
-	myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->width=3;
-	myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->outlinewidth=1.5;
+	myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->width=3;
+	myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->outlinewidth=1.5;
       }
       if(myLayer->type == MS_LAYER_POINT){
-	myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->symbol=1;
-	myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->size=15;
-      }
-
-    }
-    myLayer->class[myLayer->numclasses]->numstyles++;
+	myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->symbol=1;
+	myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->size=15;
+      }
+
+    }
+    myLayer->_class[myLayer->numclasses]->numstyles++;
     myLayer->numclasses++;
     m->layerorder[m->numlayers] = m->numlayers;
@@ -606,5 +610,4 @@
 
 int tryGdal(maps* conf,maps* output,mapObj* m){
-
   map* tmpMap=getMap(output->content,"storage");
   char *pszFilename=tmpMap->value;
@@ -790,12 +793,12 @@
 	     */
 	    if(msGrowLayerClasses(myLayer) == NULL)
-	      return;
-	    if(initClass((myLayer->class[myLayer->numclasses])) == -1)
-	      return;
-	    myLayer->class[myLayer->numclasses]->type = myLayer->type;
-	    if(msGrowClassStyles(myLayer->class[myLayer->numclasses]) == NULL)
-	      return ;
-	    if(initStyle(myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]) == -1)
-	      return;
+	      return -1;
+	    if(initClass((myLayer->_class[myLayer->numclasses])) == -1)
+	      return -1;
+	    myLayer->_class[myLayer->numclasses]->type = myLayer->type;
+	    if(msGrowClassStyles(myLayer->_class[myLayer->numclasses]) == NULL)
+	      return -1;
+	    if(initStyle(myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]) == -1)
+	      return -1;
 	    
 	    /**
@@ -804,5 +807,5 @@
 	    char className[7];
 	    sprintf(className,"class%d",i);
-	    myLayer->class[myLayer->numclasses]->name=strdup(className);
+	    myLayer->_class[myLayer->numclasses]->name=strdup(className);
 	    
 	    /**
@@ -814,14 +817,14 @@
 	    else
 	      sprintf(expression,"([pixel]>=%.3f AND [pixel]<=%.3f)",cstep,cstep+interval);
-	    msLoadExpressionString(&myLayer->class[myLayer->numclasses]->expression,expression);
+	    msLoadExpressionString(&myLayer->_class[myLayer->numclasses]->expression,expression);
 	    
 	    /**
 	     * Set color
 	     */
-	    myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0];
-	    myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1];
-	    myLayer->class[myLayer->numclasses]->styles[myLayer->class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2];
+	    myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.red=_tmpColors[i][0];
+	    myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.green=_tmpColors[i][1];
+	    myLayer->_class[myLayer->numclasses]->styles[myLayer->_class[myLayer->numclasses]->numstyles]->color.blue=_tmpColors[i][2];
 	    cstep+=interval;
-	    myLayer->class[myLayer->numclasses]->numstyles++;
+	    myLayer->_class[myLayer->numclasses]->numstyles++;
 	    myLayer->numclasses++;
 	    
@@ -976,4 +979,17 @@
   }
 
+  /*
+   * Set mapserver PROJ_LIB/GDAL_DATA or any other config parameter from 
+   * the main.cfg [mapserver] section if any
+   */
+  maps *tmp3=getMaps(conf,"mapserver");
+  if(tmp3!=NULL){
+    map* tmp4=tmp3->content;
+    while(tmp4!=NULL){
+      msSetConfigOption(myMap,tmp4->name,tmp4->value);
+      tmp4=tmp4->next;
+    }
+  }
+
   /**
    * Set a ows_rootlayer_title,  
@@ -1006,5 +1022,5 @@
   if(tryOgr(conf,outputs,myMap)<0)
     if(tryGdal(conf,outputs,myMap)<0)
-      return NULL;
+      return ;
 
   tmp1=getMapFromMaps(conf,"main","dataPath");
Index: trunk/zoo-project/zoo-kernel/service_internal_ms.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_ms.h	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_ms.h	(revision 364)
@@ -7,11 +7,19 @@
 #include "service.h"
 #include "cpl_conv.h"
+#include "cpl_multiproc.h"
 #include "ogr_api.h"
 #include "gdal.h"
 #include "ogr_srs_api.h"
 #include "ulinet.h"
+#ifdef WIN32
+#include <unistd.h>
+#endif
 
 #include <mapserver.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+  //#include <mapserver.h>
   /**
    * Map composed by a main.cfg maps name as key and the corresponding 
@@ -41,4 +49,7 @@
    */
   void outputMapfile(maps* conf,maps* outputs);
+#ifdef __cplusplus
+}
+#endif
 
 #endif
Index: trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 364)
@@ -70,4 +70,7 @@
 #else
   SetEnvironmentVariable("PYTHONPATH",pythonpath);
+  char* toto=(char*)malloc((strlen(pythonpath)+12)*sizeof(char));
+  sprintf(toto,"PYTHONPATH=%s",pythonpath);
+  putenv(toto);
 #endif
   free(python_path);
@@ -123,5 +126,5 @@
 	fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue));
 	dumpMaps(inputs);
-	dumpMaps(outputs);
+	dumpMaps(*real_outputs);
 #endif
       }else{	  
Index: trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/ulinet.c	(revision 364)
@@ -375,13 +375,16 @@
 
 #ifdef USE_JS
+#define XP_WIN 1
 #include "jsapi.h"
 
 char* JSValToChar(JSContext* context, jsval* arg) {
+  char *c;
+  char *tmp;
+  JSString *jsmsg;
+  size_t len;
+  int i;
   if(!JSVAL_IS_STRING(*arg)) {
     return NULL;
   }
-  char *c, *tmp;
-  JSString *jsmsg;
-  size_t len;
   jsmsg = JS_ValueToString(context,*arg);
   len = JS_GetStringLength(jsmsg);
@@ -389,5 +392,4 @@
   c = (char*)malloc((len+1)*sizeof(char));
   c[len] = '\0';
-  int i;
 #ifdef ULINET_DEBUG
   fprintf(stderr,"%d \n",len);
@@ -405,4 +407,6 @@
 HINTERNET setHeader(HINTERNET handle,JSContext *cx,JSObject *header){
   jsuint length=0;
+  jsint i=0;
+  char *tmp1;
 #ifdef ULINET_DEBUG
   fprintf(stderr,"setHeader\n");
@@ -416,10 +420,9 @@
     fprintf(stderr,"header is an array of %d elements\n",length);
 #endif
-    jsint i=0;
     handle.header=NULL;
     for(i=0;i<length;i++){
       jsval tmp;
       JS_GetElement(cx,header,i,&tmp);
-      char *tmp1=JSValToChar(cx,&tmp);
+      tmp1=JSValToChar(cx,&tmp);
 #ifdef ULINET_DEBUG
       fprintf(stderr,"Element of array n° %d, value : %s\n",i,tmp1);
@@ -440,6 +443,12 @@
   jsval *argv = JS_ARGV(cx,argv1);
   HINTERNET hInternet;
+  HINTERNET res;
+  HINTERNET res1;
+  JSObject *header;
   char *url;
   char *method;
+  char* tmpValue;
+  size_t dwRead;
+  int i=0;
   JS_MaybeGC(cx);
   hInternet=InternetOpen((LPCTSTR)"ZooWPSClient\0",
@@ -448,5 +457,4 @@
   if(!CHECK_INET_HANDLE(hInternet))
     return JS_FALSE;
-  int i=0;
   if(argc>=2){
     method=JSValToChar(cx,&argv[0]);
@@ -457,10 +465,8 @@
     url=JSValToChar(cx,argv);
   }
-  HINTERNET res;
   if(argc==4){
     char *body;
     body=JSValToChar(cx,&argv[2]);
-    JSObject *header=JSVAL_TO_OBJECT(argv[3]);
-    HINTERNET res1;
+    header=JSVAL_TO_OBJECT(argv[3]);
 #ifdef ULINET_DEBUG
     fprintf(stderr,"URL (%s) \nBODY (%s)\n",url,body);
@@ -484,6 +490,5 @@
 			INTERNET_FLAG_NO_CACHE_WRITE,0);
   }
-  char* tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char));
-  size_t dwRead;
+  tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char));
   InternetReadFile(res,(LPVOID)tmpValue,res.nDataLen,&dwRead);
   fprintf(stderr,"content downloaded (%d) (%s) \n",dwRead,tmpValue);
Index: trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.h	(revision 362)
+++ trunk/zoo-project/zoo-kernel/ulinet.h	(revision 364)
@@ -35,5 +35,9 @@
 #include "time.h"
 #ifdef USE_JS
+#ifdef WIN32
+# define XP_WIN
+#else
 #define XP_UNIX 0
+#endif
 #include "jsapi.h"
 #endif
Index: trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 364)
@@ -26,16 +26,19 @@
 #define MALLOC_CHECK 0
 
-#ifdef WIN32
-#include "windows.h"
-#endif
 /**
  * Specific includes
  */
+#ifndef WIN32
 #include "fcgio.h"
 #include "fcgi_config.h" 
 #include "fcgi_stdio.h"
+#endif
 #include <sys/types.h>
 #include <unistd.h>
 #include "service_internal.h"
+#ifdef WIN32
+#include "windows.h"
+#define strtok_r strtok_s
+#endif
 
 extern "C" {
@@ -55,6 +58,10 @@
 using namespace std;
 
+#ifndef TRUE
 #define TRUE 1
+#endif
+#ifndef FALSE
 #define FALSE -1
+#endif
 
 int cgiMain(){
@@ -68,7 +75,4 @@
   fprintf(cgiOut,"Welcome on ZOO verbose debuging mode \r\n\r\n");
   fflush(cgiOut);
-#endif
-  
-#ifdef DEBUG
   fprintf (stderr, "Addr:%s\n", cgiRemoteAddr); 
   fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0); 
@@ -143,5 +147,7 @@
   }
   else{
+#ifdef DEBUG
     dumpMap(tmpMap);
+#endif
     char **array, **arrayStep;
     if (cgiFormEntries(&array) != cgiFormSuccess) {
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 362)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 364)
@@ -78,8 +78,29 @@
 #include <windows.h>
 #include <direct.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#define pid_t int;
 #endif
 #include <fcntl.h>
 #include <time.h>
 #include <stdarg.h>
+
+#ifdef WIN32
+extern "C" {
+__declspec(dllexport) char *strcasestr(char const *a, char const *b) { 
+    char *x=_strdup(a); 
+    char *y=_strdup(b); 
+
+    x=_strlwr(x); 
+    y=_strlwr(y); 
+    char *pos = strstr(x, y); 
+    char *ret = pos == NULL ? NULL : (char *)(a + (pos-x)); 
+    free(x); 
+    free(y); 
+    return ret; 
+} 
+}
+#endif
 
 #define _(String) dgettext ("zoo-kernel",String)
@@ -218,5 +239,5 @@
   fflush(stderr);
 #endif
-  if(strncasecmp(r_inputs->value,"C",1)==0){
+  if(strlen(r_inputs->value)==1 && strncasecmp(r_inputs->value,"C",1)==0){
     r_inputs=getMap(request_inputs,"metapath");
     if(r_inputs!=NULL)
@@ -402,7 +423,5 @@
 	      }
   *myMap=m;
-#ifndef WIN32
   *ioutputs=request_output_real_format;
-#endif
 }
 
@@ -521,5 +540,15 @@
   bindtextdomain ("zoo-kernel","/usr/share/locale/");
   bindtextdomain ("zoo-services","/usr/share/locale/");
-  
+
+  /**
+   * Manage our own error log file (usefull to separate standard apache debug
+   * messages from the ZOO-Kernel ones but also for IIS users to avoid wrong 
+   * headers messages returned by the CGI due to wrong redirection of stderr)
+   */
+  FILE * fstde=NULL;
+  map* fstdem=getMapFromMaps(m,"main","logPath");
+  if(fstdem!=NULL)
+	fstde = freopen(fstdem->value, "a+", stderr) ;
+
   if((r_inputs=getMap(request_inputs,"language"))!=NULL){
     char *tmp=strdup(r_inputs->value);
@@ -1829,5 +1858,4 @@
     return 1;
   }
-
   maps* tmpReqI=request_input_real_format;
   while(tmpReqI!=NULL){
@@ -1842,5 +1870,5 @@
 	char fileNameOnServer[64];
 	char contentType[1024];
-	char buffer[BufferLen];
+	char buffer[1024];
 	char *tmpStr=NULL;
 	int size;
@@ -1866,5 +1894,5 @@
 	  fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
 	  mode=S_IRWXU|S_IRGRP|S_IROTH;
-	  targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,mode);
+	  targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH);
 	  if(targetFile<0){
 	    fprintf(stderr,"could not create the new file,%s\n",fileNameOnServer);	    
@@ -1912,12 +1940,15 @@
 #ifdef DEBUG
       fflush(stderr);
-      fprintf(stderr,"setting variable... %s\n",
+      fprintf(stderr,"setting variable... %s\n",(
 #endif
 	      SetEnvironmentVariable(mapcs->name,mapcs->value)
 #ifdef DEBUG
-	      ? "OK" : "FAILED");
+	      ==0)? "OK" : "FAILED");
 #else
       ;
 #endif
+	  char* toto=(char*)malloc((strlen(mapcs->name)+strlen(mapcs->value)+2)*sizeof(char));
+      sprintf(toto,"%s=%s",mapcs->name,mapcs->value);
+	  putenv(toto);
 #ifdef DEBUG
       fflush(stderr);
@@ -2036,15 +2067,15 @@
     addToMap(request_inputs,"status","true");
     status=getMap(request_inputs,"status");
-    fprintf(stderr,"cgiSID : %s",cgiSid);
+    //fprintf(stderr,"cgiSID : %s",cgiSid);
   }
 #endif
   if(status!=NULL)
     if(strcasecmp(status->value,"false")==0)
-      status=NULL;
+      status=NULLMAP;
   if(status==NULLMAP){
     loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
   }
   else{
-    pid_t   pid;
+    int   pid;
 #ifdef DEBUG
     fprintf(stderr,"\nPID : %d\n",cpid);
@@ -2171,2 +2202,3 @@
   return 0;
 }
+
