Index: trunk/thirds/cgic206/cgic.c
===================================================================
--- trunk/thirds/cgic206/cgic.c	(revision 215)
+++ trunk/thirds/cgic206/cgic.c	(revision 216)
@@ -68,4 +68,5 @@
 char *cgiUserAgent;
 char *cgiReferrer;
+char *cgiSid;
 
 FILE *cgiIn;
@@ -143,6 +144,10 @@
 	cgiGetenv(&cgiScriptName, "SCRIPT_NAME");
 	cgiGetenv(&cgiQueryString, "QUERY_STRING");
+	cgiSid=NULL;
 	if(strcmp(cgiQueryString,"")==0 && argc>=2){
 		cgiQueryString=argv[1];
+		if(argc>2){
+		  cgiSid=argv[2];
+		}
 	}
 	cgiGetenv(&cgiRemoteHost, "REMOTE_HOST");
Index: trunk/thirds/cgic206/cgic.h
===================================================================
--- trunk/thirds/cgic206/cgic.h	(revision 215)
+++ trunk/thirds/cgic206/cgic.h	(revision 216)
@@ -124,4 +124,10 @@
 #endif
 char *cgiCookie;
+
+extern 
+#ifdef __cplusplus
+"C" 
+#endif
+char *cgiSid;
 
 /* A macro providing the same incorrect spelling that is
Index: trunk/thirds/cgic206/makefile.vc
===================================================================
--- trunk/thirds/cgic206/makefile.vc	(revision 215)
+++ trunk/thirds/cgic206/makefile.vc	(revision 216)
@@ -9,5 +9,5 @@
 	-I $(GEODIR)/include 
 
-all: libcgic.lib cgictest.exe capture.exe
+all: libcgic.lib #cgictest.exe capture.exe 
 
 install: libcgic.lib
@@ -24,5 +24,5 @@
 
 cgictest.exe: cgictest.obj 
-	link cgictest.obj $(LIBS1) /out:cgictest.exe
+	link cgictest.obj $(LIBS) /out:cgictest.exe
 
 cgic.obj: 
@@ -30,5 +30,5 @@
 
 capture.exe: capture.obj libcgic.lib
-	$(CC) $(CFLAGS) capture.c $(LIBS1)
+	$(CC) $(CFLAGS) capture.c $(LIBS)
 
 clean:
Index: trunk/zoo-kernel/main_conf_read.y
===================================================================
--- trunk/zoo-kernel/main_conf_read.y	(revision 215)
+++ trunk/zoo-kernel/main_conf_read.y	(revision 216)
@@ -335,5 +335,7 @@
 
   fclose(crin);
+#ifndef WIN32
   crlex_destroy();
+#endif
 
   return resultatYYParse;
Index: trunk/zoo-kernel/makefile.vc
===================================================================
--- trunk/zoo-kernel/makefile.vc	(revision 215)
+++ trunk/zoo-kernel/makefile.vc	(revision 216)
@@ -1,14 +1,12 @@
-GEODIR=c:/OSGeo4W
-DESTDIR=c:/OSGeo4W
-TPATH=..\..\..\tools
-TOOLS=$(TPATH)\bin
-CFLAGS=/EHa /nologo /MT /W3 /GX /O2 /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I./ -I..\thirds\dirent-win32 -IC:\OSGeo4W\apps\Python25\include -I$(GEODIR)/include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG
-CC=cl $(CFLAGS)
-CPP=cl /TP $(CFLAGS)
+# WIN32 Makefile tested using VC-9.0
+# Don't forget to set your PATH using the following command :
+# c:\Progam Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat
+# set PATH=%PATH%;$(TOOLS)
+# using value for TOOLS relative to your local installation
+#
 
-all:  service_loader
+!INCLUDE nmake.opt
 
-service_loader: service.h lex.sr.obj service_conf.tab.obj service_conf.y service_internal_python.obj service_loader.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj
-	cl $(CFLAGS) lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj lex.cr.obj service_internal.obj service_internal_python.obj service_loader.obj -o service_loader -ldl `python-config --libs` `xml2-config --libs` -lfl -lcurl
+all:  zoo_loader.cgi
 
 main_conf_read.tab.c: main_conf_read.y service.h
@@ -54,7 +52,10 @@
 	$(CPP) /EHsc /c $(CFLAGS) zoo_loader.c
 
+dirent.obj:
+	$(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  $(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_imp.lib  $(GEODIR)/apps/Python25/libs/python25.lib $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/libcgic.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)\..\lib\libeay32.dll.a $(TOOLS)\..\lib\libcrypto.a $(TOOLS)\..\lib\libssl32.dll.a /machine:i386 
+	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)
 
 clean:
-	erase -f *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling
+	erase -f *.cgi *.obj *.tab.c* *.tab.h *.sr.c* lex.* *.lreg *.sibling
Index: trunk/zoo-kernel/nmake.opt
===================================================================
--- trunk/zoo-kernel/nmake.opt	(revision 216)
+++ trunk/zoo-kernel/nmake.opt	(revision 216)
@@ -0,0 +1,14 @@
+LIBINTL_CPATH=..\..\..\
+PYTHON_CPATH=..\..\..\
+TPATH=..\..\..\tools
+GEODIR=c:/OSGeo4W
+DESTDIR=c:/OSGeo4W
+TOOLS=$(TPATH)\bin
+
+CC=cl $(CFLAGS)
+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$(PYTHON_CPATH)\include -I$(GEODIR)/include -ILIBINTL_CPATH\include -I$(TPATH)\include -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
+
+LDFLAGS=$(GEODIR)/lib/libfcgi.lib $(GEODIR)/lib/libcurl_im
+p.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 
Index: trunk/zoo-kernel/service.h
===================================================================
--- trunk/zoo-kernel/service.h	(revision 215)
+++ trunk/zoo-kernel/service.h	(revision 216)
@@ -28,4 +28,10 @@
 #pragma once
 
+#ifdef WIN32
+#define strncasecmp strnicmp
+#define strcasecmp stricmp
+#define snprintf sprintf_s
+#endif 
+
 #ifdef __cplusplus
 extern "C" {
@@ -193,4 +199,15 @@
   }
 
+  static map* getLastMap(map* m){
+    map* tmp=m;
+    while(tmp!=NULL){
+      if(tmp->next==NULL){
+	return tmp;
+      }
+      tmp=tmp->next;
+    }
+    return NULL;
+  }
+
   static map* getMapFromMaps(maps* m,const char* key,const char* subkey){
     maps* _tmpm=getMaps(m,key);
@@ -201,4 +218,52 @@
     else return NULL;
   }
+
+  static char* getMapsAsKVP(maps* m,int length,int type){
+    char *dataInputsKVP=(char*) malloc(length*sizeof(char));
+    maps* curs=m;
+    int i=0;
+    while(curs!=NULL){
+      if(i==0)
+	if(type==0)
+	  sprintf(dataInputsKVP,"%s=",curs->name);
+	else
+	  sprintf(dataInputsKVP,"%s",curs->name);
+      else{
+	char *temp=strdup(dataInputsKVP);
+	if(type==0)
+	  sprintf(dataInputsKVP,"%s;%s=",temp,curs->name);
+	else
+	  sprintf(dataInputsKVP,"%s;%s",temp,curs->name);
+	free(temp);
+      }
+      map* icurs=curs->content;
+      if(type==0){
+	map* tmp=getMap(curs->content,"value");
+	char *temp=strdup(dataInputsKVP);
+	if(getMap(m->content,"xlink:href")!=NULL)
+	  sprintf(dataInputsKVP,"%sReference",temp);
+	else
+	  sprintf(dataInputsKVP,"%s%s",temp,icurs->value);
+	free(temp);
+      }
+      int j=0;
+      while(icurs!=NULL){
+	if(strcasecmp(icurs->name,"value")!=0 &&
+	   strcasecmp(icurs->name,"Reference")!=0 &&
+	   strcasecmp(icurs->name,"minOccurs")!=0 &&
+	   strcasecmp(icurs->name,"maxOccurs")!=0 &&
+	   strcasecmp(icurs->name,"inRequest")!=0){
+	  char *itemp=strdup(dataInputsKVP);
+	  sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value);
+	  free(itemp);
+	}
+	icurs=icurs->next;
+      }
+      curs=curs->next;
+      i++;
+    }
+    return dataInputsKVP;
+  }
+
 
   static void freeMap(map** mo){
@@ -516,5 +581,6 @@
       map* _ztmpm=getMap(_tmpm->content,subkey);
       if(_ztmpm!=NULL){
-	free(_ztmpm->value);
+	if(_ztmpm->value!=NULL)
+	  free(_ztmpm->value);
 	_ztmpm->value=strdup(value);
       }else{
Index: trunk/zoo-kernel/service_conf.y
===================================================================
--- trunk/zoo-kernel/service_conf.y	(revision 215)
+++ trunk/zoo-kernel/service_conf.y	(revision 216)
@@ -801,5 +801,7 @@
   *service=my_service;
 
+#ifndef WIN32
   srlex_destroy();
+#endif
   return resultatYYParse;
 }
Index: trunk/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-kernel/service_internal.c	(revision 215)
+++ trunk/zoo-kernel/service_internal.c	(revision 216)
@@ -25,5 +25,26 @@
 #include "service_internal.h"
 
-void *addLangAttr(xmlNodePtr n,maps *m){
+#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;
+}
+#endif
+
+void addLangAttr(xmlNodePtr n,maps *m){
   map *tmpLmap=getMapFromMaps(m,"main","language");
   if(tmpLmap!=NULL)
@@ -44,5 +65,113 @@
 }
 
-void* unhandleStatus(maps *conf){
+#ifdef WIN32
+
+#include <windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <tchar.h>
+
+#define SHMEMSIZE 4096
+
+static LPVOID lpvMemG = NULL;      // pointer to shared memory
+static HANDLE hMapObjectG = NULL;  // handle to file mapping
+
+void updateStatus(maps *conf){
+	fprintf(stderr,"OK Final 1 \n");
+	fflush(stderr);
+	LPWSTR lpszTmp;
+	BOOL fInit;
+	char *s=NULL;
+	map *tmpMap=getMapFromMaps(conf,"lenv","sid");
+	fprintf(stderr,"OK Final 11 \n");
+	fflush(stderr);
+	if(hMapObjectG==NULL)
+	hMapObjectG = CreateFileMapping( 
+		INVALID_HANDLE_VALUE,   // use paging file
+		NULL,                   // default security attributes
+		PAGE_READWRITE,         // read/write access
+		0,                      // size: high 32-bits
+		SHMEMSIZE,              // size: low 32-bits
+		TEXT(tmpMap->value));   // name of map object
+	if (hMapObjectG == NULL){
+		fprintf(stderr,"Unable to create share memory segment %s !! \n",tmpMap->value);
+		return ;
+	}
+	fprintf(stderr,"OK Final 2 \n");
+	fflush(stderr);
+	fInit = (GetLastError() != ERROR_ALREADY_EXISTS); 
+	if(lpvMemG==NULL)
+	lpvMemG = MapViewOfFile( 
+		hMapObjectG,     // object to map view of
+		FILE_MAP_WRITE, // read/write access
+		0,              // high offset:  map from
+		0,              // low offset:   beginning
+		0);             // default: map entire file
+	if (lpvMemG == NULL){
+		fprintf(stderr,"Unable to create or access the shared memory segment %s !! \n",tmpMap->value);
+		return ;
+	} 
+	fprintf(stderr,"OK Final 3 \n");
+	fflush(stderr);
+	if (fInit)
+		memset(lpvMemG, '\0', SHMEMSIZE);
+	fprintf(stderr,"OK Final 4 \n");
+	fflush(stderr);
+	tmpMap=getMapFromMaps(conf,"lenv","status");
+	lpszTmp = (LPWSTR) lpvMemG;
+	for(s=tmpMap->value;*s!=NULL;s++)
+		*lpszTmp++ = *s;
+	*lpszTmp = '\0'; 
+}
+
+char* getStatus(int pid){
+  LPWSTR lpszBuf=NULL;
+  LPWSTR lpszTmp=NULL;
+  LPVOID lpvMem = NULL;
+  HANDLE hMapObject = NULL;
+  BOOL fIgnore,fInit;
+  char tmp[100];
+  sprintf(tmp,"%i",pid);
+  if(hMapObject==NULL)
+    hMapObject = CreateFileMapping( 
+				   INVALID_HANDLE_VALUE,   // use paging file
+				   NULL,                   // default security attributes
+				   PAGE_READWRITE,         // read/write access
+				   0,                      // size: high 32-bits
+				   4096,                   // size: low 32-bits
+				   TEXT(tmp));   // name of map object
+  if (hMapObject == NULL) 
+    return FALSE;
+  if((GetLastError() != ERROR_ALREADY_EXISTS)){
+    fIgnore = UnmapViewOfFile(lpvMem); 
+    fIgnore = CloseHandle(hMapObject);
+    return "-1";
+  }
+  fInit=TRUE;
+  if(lpvMem==NULL)
+    lpvMem = MapViewOfFile( 
+			   hMapObject,     // object to map view of
+			   FILE_MAP_READ,  // read/write access
+			   0,              // high offset:  map from
+			   0,              // low offset:   beginning
+			   0);             // default: map entire file
+  if (lpvMem == NULL) 
+    return "-1"; 
+  lpszTmp = (LPWSTR) lpvMem;
+  while (*lpszTmp!=NULL)
+    *lpszBuf++ = *lpszTmp++;
+  *lpszBuf = '\0';
+  fIgnore = UnmapViewOfFile(lpvMem); 
+  fIgnore = CloseHandle(hMapObject);
+  return (char*)lpszBuf;
+}
+
+void unhandleStatus(maps *conf){
+  BOOL fIgnore;
+  fIgnore = UnmapViewOfFile(lpvMemG); 
+  fIgnore = CloseHandle(hMapObjectG);
+}
+#else
+void unhandleStatus(maps *conf){
   int shmid,i;
   key_t key;
@@ -69,4 +198,57 @@
   }
 }
+
+void updateStatus(maps *conf){
+  int shmid,i;
+  key_t key;
+  char *shm,*s,*s1;
+  map *tmpMap=NULL;
+  tmpMap=getMapFromMaps(conf,"lenv","sid");
+  if(tmpMap!=NULL){
+    key=atoi(tmpMap->value);
+    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
+#ifdef DEBUG
+      fprintf(stderr,"shmget failed to update value\n");
+#endif
+    }else{
+      if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
+#ifdef DEBUG
+	fprintf(stderr,"shmat failed to update value\n");
+#endif
+      }
+      else{
+	tmpMap=getMapFromMaps(conf,"lenv","status");
+	s1=shm;
+	for(s=tmpMap->value;s!=NULL;s++)
+	  *s1++=*s;
+	shmdt((void *)shm);
+      }
+    }
+  }
+}
+
+char* getStatus(int pid){
+  int shmid,i;
+  key_t key;
+  void *shm;
+  char *s;
+  key=pid;
+  if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
+#ifdef DEBUG
+    fprintf(stderr,"shmget failed in getStatus\n");
+#endif
+  }else{
+    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
+#ifdef DEBUG
+      fprintf(stderr,"shmat failed in getStatus\n");
+#endif
+    }else{
+      return (char*)shm;
+    }
+  }
+  return "-1";
+}
+
+#endif
 
 #ifdef USE_JS
@@ -109,54 +291,4 @@
 #endif
 
-void* updateStatus(maps *conf){
-  int shmid,i;
-  key_t key;
-  char *shm,*s,*s1;
-  map *tmpMap=NULL;
-  tmpMap=getMapFromMaps(conf,"lenv","sid");
-  if(tmpMap!=NULL){
-    key=atoi(tmpMap->value);
-    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
-#ifdef DEBUG
-      fprintf(stderr,"shmget failed to update value\n");
-#endif
-    }else{
-      if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
-#ifdef DEBUG
-	fprintf(stderr,"shmat failed to update value\n");
-#endif
-      }
-      else{
-	tmpMap=getMapFromMaps(conf,"lenv","status");
-	s1=shm;
-	for(s=tmpMap->value;s!=NULL;s++)
-	  *s1++=*s;
-	shmdt((void *)shm);
-      }
-    }
-  }
-}
-
-char* getStatus(int pid){
-  int shmid,i;
-  key_t key;
-  void *shm;
-  char *s;
-  key=pid;
-  if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
-#ifdef DEBUG
-    fprintf(stderr,"shmget failed in getStatus\n");
-#endif
-  }else{
-    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
-#ifdef DEBUG
-      fprintf(stderr,"shmat failed in getStatus\n");
-#endif
-    }else{
-      return (char*)shm;
-    }
-  }
-  return "-1";
-}
 
 
@@ -1192,5 +1324,5 @@
     int buffersize;
     xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "UTF-8", 1);
-    fwrite(xmlbuff,1,strlen(xmlbuff)*sizeof(char),output);
+    fwrite(xmlbuff,1,xmlStrlen(xmlbuff)*sizeof(char),output);
     xmlFree(xmlbuff);
     fclose(output);
@@ -1204,5 +1336,4 @@
 
 void printDocument(maps* m, xmlDocPtr doc,int pid){
-  rewind(stdout);
   char *encoding=getEncoding(m);
   if(pid==getpid()){
@@ -1218,5 +1349,5 @@
   xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
   printf("%s",xmlbuff);
-  //fflush(stdout);
+  fflush(stdout);
   /*
    * Free associated memory.
@@ -1527,5 +1658,5 @@
   maps* tmpMap=getMaps(m,"main");
 
-  int nsid=zooXmlAddNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
+  int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
   ns=usedNs[nsid];
   n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
@@ -1757,5 +1888,5 @@
 }
 
-char *base64(const unsigned char *input, int length)
+char *base64(const char *input, int length)
 {
   BIO *bmem, *b64;
@@ -1779,5 +1910,5 @@
 }
 
-char *base64d(unsigned char *input, int length,int* red)
+char *base64d(const char *input, int length,int* red)
 {
   BIO *b64, *bmem;
@@ -1788,5 +1919,5 @@
     b64 = BIO_new(BIO_f_base64());
     if(b64){
-      bmem = BIO_new_mem_buf(input,length);
+      bmem = BIO_new_mem_buf((unsigned char*)input,length);
       bmem = BIO_push(b64, bmem);
       *red=BIO_read(bmem, buffer, length);
@@ -2078,5 +2209,5 @@
   ns_ows=usedNs[owsId];
   n = xmlNewNode(ns_ows, BAD_CAST "BoundingBox");
-  xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1","ows");
+  xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
   int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
   ns_xsi=usedNs[xsiId];
Index: trunk/zoo-kernel/service_internal.h
===================================================================
--- trunk/zoo-kernel/service_internal.h	(revision 215)
+++ trunk/zoo-kernel/service_internal.h	(revision 216)
@@ -38,6 +38,10 @@
 #include <sys/stat.h>
 #include <sys/types.h>
+#ifndef WIN32
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#else
+#include <direct.h>
+#endif
 #include <stdio.h>
 #include <unistd.h>
@@ -71,6 +75,6 @@
   static int nbNs=0;
 
-  void* unhandleStatus(maps*);
-  void* updateStatus(maps*);
+  void unhandleStatus(maps*);
+  void updateStatus(maps*);
   char* getStatus(int);
 
@@ -106,6 +110,6 @@
   void outputResponse(service*,maps*,maps*,map*,int,maps*,int);
 
-  char *base64(const unsigned char*,int);
-  char *base64d(unsigned char*,int,int*);
+  char *base64(const char*,int);
+  char *base64d(const char*,int,int*);
   void ensureDecodedBase64(maps**);
 
Index: trunk/zoo-kernel/zoo_loader.c
===================================================================
--- trunk/zoo-kernel/zoo_loader.c	(revision 215)
+++ trunk/zoo-kernel/zoo_loader.c	(revision 216)
@@ -26,4 +26,7 @@
 #define MALLOC_CHECK 0
 
+#ifdef WIN32
+#include "windows.h"
+#endif
 /**
  * Specific includes
@@ -64,26 +67,4 @@
 /* ************************************************************************* */
 
-#ifndef STRTOK_R
-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;
-}
-
-#endif
 
 #define TRUE 1
Index: trunk/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-kernel/zoo_service_loader.c	(revision 215)
+++ trunk/zoo-kernel/zoo_service_loader.c	(revision 216)
@@ -203,8 +203,4 @@
 #endif
       if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
-#ifdef WIN32
-	//Strange return value needed here !
-	return 1;
-#endif
 	r_inputs=getMap(request_inputs,"Identifier");
 	char fname[1024];
@@ -284,5 +280,10 @@
 #endif
       }
+#ifdef WIN32
+      *ioutputs=dupMaps(&request_output_real_format);
+      FreeLibrary(so);
+#else
       dlclose(so);
+#endif
     } else {
       /**
@@ -345,6 +346,80 @@
 	      }
   *myMap=m;
+#ifndef WIN32
   *ioutputs=request_output_real_format;
+#endif
 }
+
+#ifdef WIN32
+/**
+ * createProcess function: create a new process after setting some env variables
+ */
+void createProcess(maps* m,map* request_inputs,service* s1,char* opts,int cpid, maps* inputs,maps* outputs){
+  STARTUPINFO si;
+  PROCESS_INFORMATION pi;
+  ZeroMemory( &si, sizeof(si) );
+  si.cb = sizeof(si);
+  ZeroMemory( &pi, sizeof(pi) );
+  char *tmp=(char *)malloc((1024+cgiContentLength)*sizeof(char));
+  char *tmpq=(char *)malloc((1024+cgiContentLength)*sizeof(char));
+  map *req=getMap(request_inputs,"request");
+  map *id=getMap(request_inputs,"identifier");
+  map *di=getMap(request_inputs,"DataInputs");
+
+  char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0);
+  char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1);
+  fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP);
+  fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP);
+  map *sid=getMapFromMaps(m,"lenv","sid");
+  map* r_inputs=getMapFromMaps(m,"main","tmpPath");
+  map* r_inputs1=getMap(s1->content,"ServiceProvider");
+  map* r_inputs2=getMap(s1->content,"ResponseDocument");
+  if(r_inputs2==NULL)
+    r_inputs2=getMap(s1->content,"RawDataOutput");
+  map *tmpPath=getMapFromMaps(m,"lenv","cwd");
+
+  if(r_inputs2!=NULL){
+    sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);
+	sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);
+  }
+  else{
+    sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value);
+    sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value);
+  }
+
+  char *tmp1=strdup(tmp);
+  sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
+
+  free(dataInputsKVP);
+  free(dataOutputsKVP);
+  fprintf(stderr,"REQUEST IS : %s \n",tmp);
+  SetEnvironmentVariable("CGISID",TEXT(sid->value));
+  SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq));
+  char clen[1000];
+  sprintf(clen,"%d",strlen(tmpq));
+  SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen));
+
+  if( !CreateProcess( NULL,             // No module name (use command line)
+		      TEXT(tmp),        // Command line
+		      NULL,             // Process handle not inheritable
+		      NULL,             // Thread handle not inheritable
+		      FALSE,            // Set handle inheritance to FALSE
+		      CREATE_NO_WINDOW, // Apache won't wait until the end
+		      NULL,             // Use parent's environment block
+		      NULL,             // Use parent's starting directory 
+		      &si,              // Pointer to STARTUPINFO struct
+		      &pi )             // Pointer to PROCESS_INFORMATION struct
+      ) 
+    { 
+      fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() );
+      return ;
+    }else{
+    fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() );
+  }
+  CloseHandle( pi.hProcess );
+  CloseHandle( pi.hThread );
+  fprintf(stderr,"CreateProcess finished !\n");
+}
+#endif
 
 int runRequest(map* request_inputs)
@@ -671,12 +746,14 @@
 #endif
   int saved_stdout = dup(fileno(stdout));
-  dup2(fileno(stderr),fileno(stdout));
+    dup2(fileno(stderr),fileno(stdout));
   t=getServiceFromFile(tmps1,&s1);
   fflush(stdout);
   dup2(saved_stdout,fileno(stdout));
   if(t<0){
-    char tmpMsg[2048+strlen(r_inputs->value)];
+    char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value));
+    
     sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value);
     errorException(m, tmpMsg, "InvalidParameterValue");
+    free(tmpMsg);
     freeService(&s1);
     free(s1);
@@ -687,5 +764,5 @@
     return 0;
   }
-  close(saved_stdout);
+  //close(saved_stdout);
 
 #ifdef DEBUG
@@ -887,6 +964,12 @@
 	char tmpn[256];
 	memset(tmpn,0,256);
-	strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
-	tmpn[strlen(tmpc)-strlen(tmpv)]=0;
+	if(tmpv!=NULL){
+	  strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
+	  tmpn[strlen(tmpc)-strlen(tmpv)]=0;
+	}
+	else{
+	  strncpy(tmpn,tmpc,strlen(tmpc)*sizeof(char));
+	  tmpn[strlen(tmpc)]=0;
+	}
 #ifdef DEBUG
 	fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1);
@@ -898,5 +981,8 @@
 	  }
 	  tmpmaps->name=strdup(tmpn);
-	  tmpmaps->content=createMap("value",tmpv+1);
+	  if(tmpv!=NULL)
+	    tmpmaps->content=createMap("value",tmpv+1);
+	  else
+	    tmpmaps->content=createMap("value","Reference");
 	  tmpmaps->next=NULL;
 	}
@@ -912,6 +998,22 @@
 	  char tmpn1[1024];
 	  memset(tmpn1,0,1024);
-	  strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
-	  tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
+	  if(tmpv1!=NULL){
+	    strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
+	    tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
+	    addToMap(tmpmaps->content,tmpn1,tmpv1+1);
+	  }
+	  else{
+	    strncpy(tmpn1,tmpc,strlen(tmpc));
+	    tmpn1[strlen(tmpc)]=0;
+	    map* lmap=getLastMap(tmpmaps->content);
+	    char *tmpValue=(char*)calloc((strlen(lmap->value)+strlen(tmpc)+1),sizeof(char));
+	    sprintf(tmpValue,"%s@%s",lmap->value,tmpc);
+	    free(lmap->value);
+	    lmap->value=strdup(tmpValue);
+	    free(tmpValue);
+	    dumpMap(tmpmaps->content);
+	    tmpc=strtok(NULL,"@");
+	    continue;
+	  }
 #ifdef DEBUG
 	  fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1);
@@ -920,55 +1022,59 @@
 	  if(strcmp(tmpn1,"xlink:href")!=0)
 	    addToMap(tmpmaps->content,tmpn1,tmpv1+1);
-	  else{
-	    if(strncasecmp(tmpv1+1,"http://",7)!=0 &&
-	       strncasecmp(tmpv1+1,"ftp://",6)!=0){
-	      char emsg[1024];
-	      sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
-	      errorException(m,emsg,"InternalError");
-	      freeMaps(&m);
-	      free(m);
-	      free(REQUEST);
-	      free(SERVICE_URL);
-	      InternetCloseHandle(hInternet);
-	      freeService(&s1);
-	      free(s1);
-	      return 0;
+	  else
+	    if(tmpv1!=NULL){
+	      if(strncasecmp(tmpv1+1,"http://",7)!=0 &&
+		 strncasecmp(tmpv1+1,"ftp://",6)!=0){
+		char emsg[1024];
+		sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
+		errorException(m,emsg,"InternalError");
+		freeMaps(&m);
+		free(m);
+		free(REQUEST);
+		free(SERVICE_URL);
+		InternetCloseHandle(hInternet);
+		freeService(&s1);
+		free(s1);
+		return 0;
+	      }
+#ifdef DEBUG
+	      fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
+#endif
+#ifndef WIN32
+	      if(CHECK_INET_HANDLE(hInternet))
+#endif
+		{
+		  res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
+				      INTERNET_FLAG_NO_CACHE_WRITE,0);
+#ifdef DEBUG
+		  fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
+			  tmpv1+1,res.nDataAlloc,res.nDataLen);
+#endif
+		  char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
+		  if(tmpContent == NULL){
+		    return errorException(m, _("Unable to allocate memory."), "InternalError");
+		  }
+		  size_t dwRead;
+		  InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
+		  map* tmpMap=getMap(tmpmaps->content,"value");
+		  if(tmpMap!=NULL){
+		    free(tmpMap->value);
+		    tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
+		    memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
+		    tmpMap->value[res.nDataLen]=0;
+		    if(strlen(tmpContent)!=res.nDataLen){
+		      char tmp[256];
+		      sprintf(tmp,"%d",res.nDataLen*sizeof(char));
+		      addToMap(tmpmaps->content,"size",tmp);
+		    }
+		  }
+		  free(tmpContent);
+		}
+	      char *tmpx=url_encode(tmpv1+1);
+	      addToMap(tmpmaps->content,tmpn1,tmpx);
+	      free(tmpx);
+	      addToMap(tmpmaps->content,"Reference",tmpv1+1);
+	      dumpMap(tmpmaps->content);
 	    }
-#ifdef DEBUG
-	    fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
-#endif
-#ifndef WIN32
-	    if(CHECK_INET_HANDLE(hInternet))
-#endif
-	      {
-		res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
-				    INTERNET_FLAG_NO_CACHE_WRITE,0);
-#ifdef DEBUG
-		fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
-			tmpv1+1,res.nDataAlloc,res.nDataLen);
-#endif
-		char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
-		if(tmpContent == NULL){
-		  return errorException(m, _("Unable to allocate memory."), "InternalError");
-		}
-		size_t dwRead;
-		InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
-		map* tmpMap=getMap(tmpmaps->content,"value");
-		if(tmpMap!=NULL){
-		  free(tmpMap->value);
-		  tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));
-		  memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));
-		  tmpMap->value[res.nDataLen]=0;
-		  if(strlen(tmpContent)!=res.nDataLen){
-		    char tmp[256];
-		    sprintf(tmp,"%d",res.nDataLen*sizeof(char));
-		    addToMap(tmpmaps->content,"size",tmp);
-		  }
-		}
-		free(tmpContent);
-	      }
-	    addToMap(tmpmaps->content,tmpn1,tmpv1+1);
-	    addToMap(tmpmaps->content,"Reference",tmpv1+1);
-	  }
 	  tmpc=strtok(NULL,"@");
 	}
@@ -1132,4 +1238,6 @@
 	    hInternet.header=NULL;
 	    while(cur3){
+	      while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE)
+		cur2=cur3->next;
 	      if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){
 		const char *ha[2];
@@ -1697,4 +1805,5 @@
   _tmpMaps->next=NULL;
   addToMap(_tmpMaps->content,"status","0");
+  addToMap(_tmpMaps->content,"cwd",ntmp);
   if(cgiCookie!=NULL && strlen(cgiCookie)>0){
     addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
@@ -1722,5 +1831,20 @@
   dumpMap(request_inputs);
 #endif
-
+#ifdef WIN32
+  char *cgiSidL=NULL;
+  if(getenv("CGISID")!=NULL)
+	addToMap(request_inputs,"cgiSid",getenv("CGISID"));
+  map* test1=getMap(request_inputs,"cgiSid");
+  if(test1!=NULL){
+    cgiSid=test1->value;
+  }
+  if(cgiSid!=NULL){
+    addToMap(request_inputs,"storeExecuteResponse","true");
+    addToMap(request_inputs,"status","true");
+    status=getMap(request_inputs,"status");
+    dumpMap(request_inputs);
+    fprintf(stderr,"cgiSID : %s",cgiSid);
+  }
+#endif
   if(status!=NULL)
     if(strcasecmp(status->value,"false")==0)
@@ -1738,5 +1862,13 @@
     pid = fork ();
 #else
-    pid = 0;
+    if(cgiSid==NULL){
+      addToMap(request_inputs,"cgSid",cgiSid);
+      createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format);
+      pid = cpid;
+    }else{
+      pid=0;
+      cpid=atoi(cgiSid);
+    }
+    fflush(stderr);
 #endif
     if (pid > 0) {
@@ -1765,7 +1897,7 @@
       fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value);
 #endif
+      freopen(flog,"w+",stderr);
       freopen(fbkp , "w+", stdout);
       fclose(stdin);
-      freopen(flog,"w+",stderr);
       free(fbkp);
       free(flog);
@@ -1778,9 +1910,11 @@
       updateStatus(m);
       printProcessResponse(m,request_inputs,cpid,
-			    s1,r_inputs1->value,SERVICE_STARTED,
-			    request_input_real_format,
-			    request_output_real_format);
+			   s1,r_inputs1->value,SERVICE_STARTED,
+			   request_input_real_format,
+			   request_output_real_format);
+#ifndef WIN32
       fflush(stdout);
       rewind(stdout);
+#endif
 
       loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
@@ -1798,5 +1932,5 @@
 #ifdef DEBUG
   dumpMaps(request_output_real_format);
-  fprintf(stderr,"Function loaded and returned %d\n",eres);
+  fprintf(stderr,"Function loaded and returned %d\n",*eres);
   fflush(stderr);
 #endif
@@ -1805,4 +1939,5 @@
 		   request_output_real_format,request_inputs,
 		   cpid,m,eres);
+  fflush(stdout);
   /**
    * Ensure that if error occurs when freeing memory, no signal will return
Index: trunk/zoo-services/arithmetics/cgi-env/Multiply.zcfg
===================================================================
--- trunk/zoo-services/arithmetics/cgi-env/Multiply.zcfg	(revision 215)
+++ trunk/zoo-services/arithmetics/cgi-env/Multiply.zcfg	(revision 216)
@@ -5,5 +5,5 @@
  storeSupported = true
  statusSupported = true
- serviceProvider = demo_service.zo
+ serviceProvider = test_service.zo
  serviceType = C
  <MetaData>
Index: trunk/zoo-services/arithmetics/makefile.vc
===================================================================
--- trunk/zoo-services/arithmetics/makefile.vc	(revision 215)
+++ trunk/zoo-services/arithmetics/makefile.vc	(revision 216)
@@ -1,11 +1,11 @@
 GEODIR=c:/OSGeo4W/
 TOOLS=c:/Users/djay/GeoLabs/tools/
-CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG
+CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG -DWIN32
 CPP=cl /TP 
 
-cgi-env/service.zo: service.c
-	$(CPP) $(CFLAGS) /c service.c
-	link /dll /out:cgi-env/ogr_service.zso ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a 
+cgi-env/test_service.zo: test_service.c
+	$(CPP) $(CFLAGS) /c test_service.c
+	link /dll /out:cgi-env/test_service.zo ../../zoo-kernel/service_internal.obj ./test_service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a $(TOOLS)/lib/libintl.lib
 
 clean:
-	rm -f cgi-env/ogr_service.zso
+	erase cgi-env\demo_service.*
Index: trunk/zoo-services/arithmetics/test_service.c
===================================================================
--- trunk/zoo-services/arithmetics/test_service.c	(revision 215)
+++ trunk/zoo-services/arithmetics/test_service.c	(revision 216)
@@ -3,4 +3,7 @@
 extern "C" {
 
+#ifdef WIN32
+__declspec(dllexport)
+#endif
   int Multiply(maps*& conf,maps*& inputs,maps*& outputs){
   	fprintf(stderr,"\nService internal print\n");
Index: trunk/zoo-services/ogr/base-vect-ops/makefile.vc
===================================================================
--- trunk/zoo-services/ogr/base-vect-ops/makefile.vc	(revision 215)
+++ trunk/zoo-services/ogr/base-vect-ops/makefile.vc	(revision 216)
@@ -1,11 +1,12 @@
-GEODIR=c:/OSGeo4W/
-TOOLS=c:/Users/djay/GeoLabs/tools/
-CFLAGS=-I$(GEODIR)/include -I$(TOOLS)/include -I../../../zoo-kernel/ -I./ -DLINUX_FREE_ISSUE -DDEBUG
+ZOODIR=../../../zoo-kernel
+THIRDSDIR=../../../thirds
+!INCLUDE $(ZOODIR)/nmake.opt
+CFLAGS=-I$(GEODIR)/include -I$(TPATH)/include -I$(ZOODIR) -I./ -DLINUX_FREE_ISSUE -DWIN32 #-DDEBUG
 CPP=cl /TP 
 
-cgi-env/service.zo: service.c
+cgi-env/ogr_service.zo: service.c
 	$(CPP) $(CFLAGS) /c service.c
-	link /dll /out:cgi-env/ogr_service.zso ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(TOOLS)/lib/libeay32.dll.a $(TOOLS)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a 
+	link /dll /out:cgi-env/ogr_service.zo ../../../zoo-kernel/service_internal.obj ./service.obj -L$(TOOLS)/lib/libssl32.dll.a $(GEODIR)/lib/libxml2.lib $(GEODIR)/lib/gdal_i.lib $(GEODIR)/lib/geos_c_i.lib $(TPATH)/lib/libeay32.dll.a $(TPATH)/lib/libcrypto.a $(TPATH)/lib/libssl32.dll.a $(LIBINTL_CPATH)/lib/libintl.lib 
 
 clean:
-	rm -f cgi-env/ogr_service.zso
+	erase cgi-env\ogr_service.*
Index: trunk/zoo-services/ogr/base-vect-ops/service.c
===================================================================
--- trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 215)
+++ trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 216)
@@ -43,5 +43,5 @@
 
   void printExceptionReportResponse(maps*,map*);
-  char *base64(const unsigned char *input, int length);
+  char *base64(const char *input, int length);
 
   OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){
@@ -56,8 +56,7 @@
     xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx);
     if(!xpathObj->nodesetval){
-      map* tmp=createMap("text","Unable to parse Input Polygon");
-      addToMap(tmp,"code","InvalidParameterValue");
-      printExceptionReportResponse(conf,tmp);
-      exit(0);
+      setMapInMaps(conf,"lenv","message",_ss("Unable to parse Input Polygon"));
+      setMapInMaps(conf,"lenv","code","InvalidParameterValue");
+      return NULL;
     }
     int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0;
@@ -80,5 +79,7 @@
     xmlFreeDoc(doc);
     xmlFreeDoc(ndoc);
+#ifndef WIN32
     xmlCleanupParser();
+#endif
 #ifdef DEBUG
     fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ...");
@@ -94,4 +95,7 @@
   }
 
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
   int Simplify(maps*& conf,maps*& inputs,maps*& outputs){
     maps* cursor=inputs;
@@ -104,5 +108,7 @@
     else
       tolerance=atof(tmp0->value);
+#ifdef DEBUG
     fprintf(stderr,"Tolerance for Simplify %f",tolerance);
+#endif
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
     if(!tmp){
@@ -126,8 +132,10 @@
       return SERVICE_FAILED;
     }
+#ifdef DEBUG
     fprintf(stderr,"Create GEOSGeometry object");
+#endif
     GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
     GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
-    res=OGRGeometryFactory::createFromGEOS(gres);
+    res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres);
     tmp1=getMapFromMaps(outputs,"Result","mimeType");
     if(tmp1!=NULL){
@@ -136,22 +144,28 @@
 	char *tmpS=OGR_G_ExportToJson(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/plain");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	free(tmpS);
+#endif
       }
       else{
 	char *tmpS=OGR_G_ExportToGML(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/xml");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
 	free(tmpS);
+#endif
       }
     }else{
-      char *tmpS=OGR_G_ExportToJson(tmp->value);
+      char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
+#endif
     }
     outputs->next=NULL;
@@ -178,11 +192,15 @@
       return SERVICE_FAILED;
     }
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(inputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMap(tmp1);
     fprintf(stderr,"/Service internal print \n");
+#endif
     if(tmp1!=NULL){
       if(strncmp(tmp1->value,"text/js",7)==0 ||
@@ -199,11 +217,15 @@
     }
     res=(*myFunc)(geometry);
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(outputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     map *tmp_2=getMapFromMaps(outputs,"Result","mimeType");
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMap(tmp_2);
     fprintf(stderr,"/Service internal print \n");
+#endif
     if(tmp_2!=NULL){
       if(strncmp(tmp_2->value,"text/js",7)==0 ||
@@ -211,24 +233,30 @@
 	char *tmpS=OGR_G_ExportToJson(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/plain");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	free(tmpS);
+#endif
       }
       else{
 	char *tmpS=OGR_G_ExportToGML(res);
 	setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
 	setMapInMaps(outputs,"Result","mimeType","text/xml");
 	setMapInMaps(outputs,"Result","encoding","UTF-8");
 	setMapInMaps(outputs,"Result","schema",schema);
 	free(tmpS);
+#endif
       }
     }else{
       char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
-    }
-    outputs->next=NULL;
+#endif
+    }
+    //outputs->next=NULL;
 #ifdef DEBUG
     dumpMaps(outputs);
@@ -239,7 +267,9 @@
     //CPLFree(res);
     //CPLFree(geometry);
+#ifdef DEBUG
     fprintf(stderr,"Service internal print \n");
     dumpMaps(outputs);
     fprintf(stderr,"/Service internal print \n");
+#endif
     return SERVICE_SUCCEEDED;
   }
@@ -276,21 +306,29 @@
      bufferDistance=atof(tmp->value);
    res=OGR_G_Buffer(geometry,bufferDistance,30);
+   dumpMap(tmp);
    tmp1=getMapFromMaps(outputs,"Result","mimeType");
+   dumpMap(tmp);
    if(strncmp(tmp1->value,"application/json",16)==0){
      char *tmpS=OGR_G_ExportToJson(res);
      setMapInMaps(outputs,"Result","value",tmpS);
+     dumpMap(tmp);
+#ifndef WIN32
      setMapInMaps(outputs,"Result","mimeType","text/plain");
      setMapInMaps(outputs,"Result","encoding","UTF-8");
      free(tmpS);
+#endif
    }
    else{
      char *tmpS=OGR_G_ExportToGML(res);
      setMapInMaps(outputs,"Result","value",tmpS);
+     dumpMap(tmp);
+#ifndef WIN32
      free(tmpS);
      setMapInMaps(outputs,"Result","mimeType","text/xml");
      setMapInMaps(outputs,"Result","encoding","UTF-8");
      setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
+#endif
    }
-   outputs->next=NULL;
+   //outputs->next=NULL;
    OGR_G_DestroyGeometry(geometry);
    OGR_G_DestroyGeometry(res);
@@ -335,8 +373,8 @@
     fprintf(stderr,"\nService internal print1\n");
     fflush(stderr);
-#endif
     fprintf(stderr,"\nService internal print1\n");
     dumpMaps(inputs);
     fprintf(stderr,"\nService internal print1\n");
+#endif
 
     maps* cursor=inputs;
@@ -357,24 +395,32 @@
     if(geometry1==NULL){
       setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1."));
+#ifdef DEBUG
       fprintf(stderr,"SERVICE FAILED !\n");
-      return SERVICE_FAILED;
-    }
+#endif
+      return SERVICE_FAILED;
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1 InputEntity1\n");
+#endif
     {
       map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
       map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
-      //#ifdef DEBUG
+#ifdef DEBUG
       fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
       //dumpMap(tmp);
       fprintf(stderr,"MY MAP\n");
-      ///#endif
       fprintf(stderr,"\nService internal print1 InputEntity2\n");
+#endif
       if(tmp1!=NULL){
         if(strncmp(tmp1->value,"application/json",16)==0){
+#ifdef DEBUG
 	  fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
+#endif
       	  geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
 	}
 	else{
+#ifdef DEBUG
 	  fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
+#endif
 	  geometry2=createGeometryFromGML(conf,tmp->value);
 	}
@@ -382,16 +428,25 @@
       else
       	geometry2=createGeometryFromGML(conf,tmp->value);
+#ifdef DEBUG
       fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
-    }
+#endif
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
+#endif
     if(geometry2==NULL){
       setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2."));
+#ifdef DEBUG
       fprintf(stderr,"SERVICE FAILED !\n");
-      return SERVICE_FAILED;
-    }
+#endif
+      return SERVICE_FAILED;
+    }
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1\n");
+#endif
     res=(*myFunc)(geometry1,geometry2);
+#ifdef DEBUG
     fprintf(stderr,"\nService internal print1\n");
-    
+#endif    
     /* nuova parte */
     map* tmp2=getMapFromMaps(outputs,"Result","mimeType");
@@ -399,15 +454,19 @@
       char *tmpS=OGR_G_ExportToJson(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/plain");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       free(tmpS);
+#endif
     }
     else{
       char *tmpS=OGR_G_ExportToGML(res);
       setMapInMaps(outputs,"Result","value",tmpS);
+#ifndef WIN32
       setMapInMaps(outputs,"Result","mimeType","text/xml");
       setMapInMaps(outputs,"Result","encoding","UTF-8");
       setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
       free(tmpS);
+#endif
     }
     
Index: trunk/zoo-services/utils/status/makefile.vc
===================================================================
--- trunk/zoo-services/utils/status/makefile.vc	(revision 216)
+++ trunk/zoo-services/utils/status/makefile.vc	(revision 216)
@@ -0,0 +1,12 @@
+ZOODIR=../../../zoo-kernel
+THIRDSDIR=../../../thirds
+!INCLUDE $(ZOODIR)/nmake.opt
+CFLAGS=-DWIN32 -I$(THIRDSDIR)/dirent-win32 -I$(GEODIR)/include -I$(TPATH)/include -I$(ZOODIR)/ -I./ -DLINUX_FREE_ISSUE -DDEBUG
+CPP=cl /TP 
+
+cgi-env/wps_status.zo: service.c
+	$(CPP) $(CFLAGS) /c service.c
+	link /dll /out:cgi-env/wps_status.zo $(ZOODIR)/service_internal.obj $(ZOODIR)/dirent.obj ./service.obj -L$(TPATH)/lib/libssl32.dll.a $(TPATH)/lib/libxslt.lib $(TPATH)/lib/libxml2.lib $(TPATH)/lib/libeay32.dll.a $(TPATH)/lib/libcrypto.a $(TOOLS)/lib/libssl32.dll.a $(LIBINTL_CPATH)/lib/libintl.lib
+
+clean:
+	del /f cgi-env\wps*
Index: trunk/zoo-services/utils/status/service.c
===================================================================
--- trunk/zoo-services/utils/status/service.c	(revision 215)
+++ trunk/zoo-services/utils/status/service.c	(revision 216)
@@ -24,4 +24,7 @@
 
 #include "service.h"
+#ifdef WIN32
+#include <windows.h>
+#endif
 
 extern "C" {
@@ -135,5 +138,9 @@
       setMapInMaps(conf,"lenv","status",tmp);
       updateStatus(conf);
+#ifndef WIN32
       sleep(1);
+#else
+      Sleep(1000);
+#endif
       i+=5;
     }
