Index: /trunk/zoo-project/zoo-kernel/main_conf_read.y
===================================================================
--- /trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 453)
@@ -249,5 +249,5 @@
 //======================================================
 
-pair: PAIR {curr_key=strdup($1);/*printf("START 0 PAIR FOUND !! \n [%s]\n",$1);*/}
+pair: PAIR {curr_key=zStrdup($1);/*printf("START 0 PAIR FOUND !! \n [%s]\n",$1);*/}
 | EPAIR {
   if(current_content==NULL) 
@@ -262,5 +262,5 @@
   free(curr_key);
   }
-| SPAIR  {curr_key=strdup($1);if(debug) printf("SPAIR FOUND !!\n"); }
+| SPAIR  {curr_key=zStrdup($1);if(debug) printf("SPAIR FOUND !!\n"); }
  ;
 
@@ -274,5 +274,5 @@
      current_maps->next=NULL;
      current_maps->next=(maps*)malloc(MAPS_SIZE);
-     current_maps->next->name=strdup($1);
+     current_maps->next->name=zStrdup($1);
      current_maps->next->content=NULL;
      current_maps->next->next=NULL;
Index: /trunk/zoo-project/zoo-kernel/makefile.vc
===================================================================
--- /trunk/zoo-project/zoo-kernel/makefile.vc	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/makefile.vc	(revision 453)
@@ -43,4 +43,7 @@
 	$(CPP) /c $(CFLAGS) service_internal_java.c
 
+service_internal_ruby.obj: service_internal_ruby.c service_internal_ruby.h service.h
+	$(CPP) /c $(CFLAGS) service_internal_ruby.c
+
 service_internal_python.obj: service_internal_python.c service.h
 	$(CPP) /c $(CFLAGS) service_internal_python.c
@@ -61,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 $(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) $(LDFLAGSCGI)
+zoo_loader.cgi: zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_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) $(RUBY_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) $(LDFLAGSCGI)
 
 clean:
Index: /trunk/zoo-project/zoo-kernel/nmake.opt
===================================================================
--- /trunk/zoo-project/zoo-kernel/nmake.opt	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/nmake.opt	(revision 453)
@@ -32,4 +32,26 @@
 !ENDIF
 
+!IFDEF RUBY_DIR
+#################################################################
+#RUBY 1.8.7
+ZRUBY_VERSION=1
+RUBY_CFLAGS=-DZRUBY_VERSION=1 -DUSE_RUBY -I$(RUBY_DIR) 
+RUBY_LDFLAGS="$(RUBY_DIR)/msvcr100-ruby18.lib"
+#################################################################
+#RUBY 1.9.3
+#ZRUBY_VERSION=2
+#RUBY_CFLAGS=-DZRUBY_VERSION=2 -DUSE_RUBY -I$(RUBY_DIR)/include/ruby-1.9.1/ -I$(RUBY_DIR)/include/ruby-1.9.1/i386-mswin32_100
+#RUBY_LDFLAGS="$(RUBY_DIR)/lib/msvcr100-ruby191.lib"
+#RUBY 2.1.0
+#ZRUBY_VERSION=2
+#RUBY_CFLAGS=-DZRUBY_VERSION=2 -DUSE_RUBY -I$(RUBY_DIR)/include/ruby-2.1.0/ -I$(RUBY_DIR)/include/ruby-2.1.0/i386-mswin32_100
+#RUBY_LDFLAGS="$(RUBY_DIR)/lib/msvcr100-ruby210.lib"
+#################################################################
+RUBY_FILE=service_internal_ruby.obj
+!IFDEF MS_DIR
+RUBY_CFLAGS=$(RUBY_CFLAGS) -DHAVE_ROUND
+!ENDIF
+!ENDIF
+
 !IFNDEF ZOOK_DIR
 ZOOK_DIR=.
@@ -41,6 +63,6 @@
 PYTHON_CPATH=$(PY_DIR)
 
-CFLAGS=/traceback  $(MS_DEFS) $(INCLUDES) $(CFLAGS1) /nologo /MD /W3 /EHsc /Ox /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I$(ZOOK_DIR) -I./ $(JAVA_CFLAGS) $(MS_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
+CFLAGS= $(MS_DEFS) $(INCLUDES) $(CFLAGS1) /nologo /MD /W3 /EHsc /Ox /D_CRT_SECURE_NO_WARNINGS /DWIN32 $(CJFLAGS) -I$(ZOOK_DIR) $(RUBY_CFLAGS) -I./ $(JAVA_CFLAGS) $(MS_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
 
 LDFLAGSCGI=$(TROOT)/../../thirds/cgic206/libcgic.lib 
-LDFLAGS=$(FCGI_DIR)/libfcgi/Release/libfcgi.lib $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(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
+LDFLAGS=$(FCGI_DIR)/libfcgi/Release/libfcgi.lib $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(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) $(RUBY_LDFLAGS) /machine:i386
Index: /trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.h	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service.h	(revision 453)
@@ -35,7 +35,12 @@
 #ifndef snprintf
 #define snprintf sprintf_s
+#endif
+#define zStrdup _strdup
+#define zMkdir _mkdir
+#define zOpen _open
+#define zWrite _write
 #else
-
-#endif
+#define zStrdup strdup
+#define zMkdir mkdir
 #endif 
 
@@ -53,5 +58,4 @@
 #include <stdio.h>
 #include <string.h>
-
 #ifndef WIN32
 #define bool int
@@ -176,6 +180,6 @@
   static map* createMap(const char* name,const char* value){
     map* tmp=(map *)malloc(MAP_SIZE);
-    tmp->name=strdup(name);
-    tmp->value=strdup(value);
+    tmp->name=zStrdup(name);
+    tmp->value=zStrdup(value);
     tmp->next=NULL;
     return tmp;
@@ -253,37 +257,40 @@
     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){
-	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);
-      }
-      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);
+      map *inRequest=getMap(curs->content,"inRequest");
+      if(strncasecmp(inRequest->value,"true",4)==0){
+	if(i==0)
+	  if(type==0)
+	    sprintf(dataInputsKVP,"%s=",curs->name);
+	  else
+	    sprintf(dataInputsKVP,"%s",curs->name);
+	else{
+	  char *temp=zStrdup(dataInputsKVP);
+	  if(type==0)
+	    sprintf(dataInputsKVP,"%s;%s=",temp,curs->name);
+	  else
+	    sprintf(dataInputsKVP,"%s;%s",temp,curs->name);
+	  free(temp);
 	}
-	icurs=icurs->next;
+	map* icurs=curs->content;
+	if(type==0){
+	  char *temp=zStrdup(dataInputsKVP);
+	  if(getMap(m->content,"xlink:href")!=NULL)
+	    sprintf(dataInputsKVP,"%sReference",temp);
+	  else
+	    sprintf(dataInputsKVP,"%s%s",temp,icurs->value);
+	  free(temp);
+	}
+	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=zStrdup(dataInputsKVP);
+	    sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value);
+	    free(itemp);
+	  }
+	  icurs=icurs->next;
+	}
       }
       curs=curs->next;
@@ -469,5 +476,5 @@
       if(tmp->value!=NULL)
       	free(tmp->value);
-      tmp->value=strdup(v);
+      tmp->value=zStrdup(v);
     }
   }
@@ -574,5 +581,5 @@
     if(_cursor!=NULL){
       res=(maps*)malloc(MAPS_SIZE);
-      res->name=strdup(_cursor->name);
+      res->name=zStrdup(_cursor->name);
       res->content=NULL;
       res->next=NULL;
@@ -723,5 +730,5 @@
 	if(_ztmpm->value!=NULL)
 	  free(_ztmpm->value);
-	_ztmpm->value=strdup(value);
+	_ztmpm->value=zStrdup(value);
       }else{
 	addToMap(_tmpm->content,subkey,value);
@@ -729,5 +736,5 @@
     }else{
       maps *tmp=(maps*)malloc(MAPS_SIZE);
-      tmp->name=strdup(key);
+      tmp->name=zStrdup(key);
       tmp->content=createMap(subkey,value);
       tmp->next=NULL;
@@ -779,10 +786,10 @@
 #endif
       tmp=(elements*)malloc(ELEMENTS_SIZE);
-      tmp->name=strdup(e->name);
+      tmp->name=zStrdup(e->name);
       tmp->content=NULL;
       addMapToMap(&tmp->content,e->content);
       tmp->metadata=NULL;
       addMapToMap(&tmp->metadata,e->metadata);
-      tmp->format=strdup(e->format);
+      tmp->format=zStrdup(e->format);
       if(e->defaults!=NULL){
 	tmp->defaults=(iotype*)malloc(IOTYPE_SIZE);
Index: /trunk/zoo-project/zoo-kernel/service_conf.y
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_conf.y	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_conf.y	(revision 453)
@@ -283,5 +283,5 @@
 	      current_element->next=NULL;
 	      if($2!=NULL)
-		current_element->format=strdup($2);
+		current_element->format=zStrdup($2);
 	      
 	      current_element->defaults=NULL;
@@ -298,5 +298,5 @@
 	    current_element->next=NULL;
 	    if($2!=NULL)
-	      current_element->format=strdup($2);
+	      current_element->format=zStrdup($2);
 	    current_element->defaults=NULL;
 	    current_element->supported=NULL;
@@ -549,5 +549,5 @@
   }
   }
-| SPAIR  { if(curr_key!=NULL) {free(curr_key);curr_key=NULL;} if($1!=NULL) curr_key=strdup($1);if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); }
+| SPAIR  { if(curr_key!=NULL) {free(curr_key);curr_key=NULL;} if($1!=NULL) curr_key=zStrdup($1);if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); }
  ;
 
@@ -561,5 +561,5 @@
     data=1;
     if($1!=NULL){
-      char *cen=strdup($1);
+      char *cen=zStrdup($1);
       my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
       cen[strlen(cen)-1]=0;
@@ -615,5 +615,5 @@
 #endif
 	if($1!=NULL){ 
-	  char *cen=strdup($1);
+	  char *cen=zStrdup($1);
 	  current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
 	  cen[strlen(cen)-1]=0;
@@ -677,5 +677,5 @@
 #endif
 	    if($1!=NULL){ 
-	      char *cen=strdup($1);
+	      char *cen=zStrdup($1);
 	      current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
 	      cen[strlen(cen)-1]=0;
@@ -709,5 +709,5 @@
 	    current_element=NULL;
 	    current_element=(elements*)malloc(ELEMENTS_SIZE);
-	    char *cen=strdup($1);
+	    char *cen=zStrdup($1);
 	    current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
 	    cen[strlen(cen)-1]=0;
@@ -729,5 +729,5 @@
 #endif
 	    if($1!=NULL){ 
-	      char *cen=strdup($1);
+	      char *cen=zStrdup($1);
 	      current_element->name=(char*)malloc((strlen(cen))*sizeof(char*));
 	      cen[strlen(cen)-1]=0;
Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 453)
@@ -1212,5 +1212,6 @@
       map* tmpm2=getMap(tmp_maps->content,"tmpUrl");
       if(tmpm1!=NULL && tmpm2!=NULL){
-	if(strncasecmp(tmpm2->value,"http://",7)==0){
+	if( strncasecmp( tmpm2->value, "http://", 7) == 0 ||
+	    strncasecmp( tmpm2->value, "https://", 8 ) == 0 ){
 	  sprintf(url,"%s/%s_%i.xml",tmpm2->value,service,pid);
 	}else
@@ -1892,4 +1893,5 @@
       map * errormap = createMap("text",tmpMsg);
       addToMap(errormap,"code", "InternalError");
+      
       printExceptionReportResponse(m,errormap);
       freeMap(&errormap);
@@ -1903,4 +1905,26 @@
   }
   
+  if(res==SERVICE_FAILED){
+    map * errormap;
+    map *lenv;
+    lenv=getMapFromMaps(m,"lenv","message");
+    char *tmp0;
+    if(lenv!=NULL){
+      tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "+1)))*sizeof(char));
+      sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value);
+    }
+    else{
+      tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char));
+      sprintf(tmp0,_("Unable to run the Service. No more information was returned back by the Service."));
+    }
+    errormap = createMap("text",tmp0);
+    free(tmp0);
+    addToMap(errormap,"code", "InternalError");
+    printExceptionReportResponse(m,errormap);
+    freeMap(&errormap);
+    free(errormap);
+    return;
+  }
+
   if(asRaw==0){
 #ifdef DEBUG
@@ -1915,8 +1939,9 @@
       toto=getMap(tmpI->content,"asReference");
 #ifdef USE_MS
-      if(toto!=NULL && strcasecmp(toto->value,"true")==0 && testMap==NULL){
+      if(toto!=NULL && strcasecmp(toto->value,"true")==0 && testMap==NULL)
 #else
-      if(toto!=NULL && strcasecmp(toto->value,"true")==0){
-#endif
+      if(toto!=NULL && strcasecmp(toto->value,"true")==0)
+#endif
+	{
 	elements* in=getElements(s->outputs,tmpI->name);
 	char *format=NULL;
@@ -1933,5 +1958,5 @@
 	map *ext=getMap(tmpI->content,"extension");
 	map *tmp1=getMapFromMaps(m,"main","tmpPath");
-	char *file_name;
+	char *file_name,*file_path;
 	bool hasExt=true;
 	if(ext==NULL){
@@ -1957,7 +1982,10 @@
 	  hasExt=false;
 	}
-	file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+13)*sizeof(char));
-	sprintf(file_name,"%s/%s_%s_%i.%s",tmp1->value,s->name,tmpI->name,cpid+100000,ext->value);
-	FILE *ofile=fopen(file_name,"wb");
+	file_name=(char*)malloc((strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+1024)*sizeof(char));
+	int cpid0=cpid+time(NULL);
+	sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,ext->value);
+	file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char));
+	sprintf(file_path,"%s/%s",tmp1->value,file_name);
+	FILE *ofile=fopen(file_path,"wb");
 	if(ofile==NULL){
 	  char tmpMsg[1024];
@@ -1968,15 +1996,18 @@
 	  freeMap(&errormap);
 	  free(errormap);
+	  free(file_name);
+	  free(file_path);
 	  return;
 	}
+	free(file_path);
 	map *tmp2=getMapFromMaps(m,"main","tmpUrl");
 	map *tmp3=getMapFromMaps(m,"main","serverAddress");
 	char *file_url;
 	if(strncasecmp(tmp2->value,"http://",7)==0){
-	  file_url=(char*)malloc((strlen(tmp2->value)+strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+13)*sizeof(char));
-	  sprintf(file_url,"%s/%s_%s_%i.%s",tmp2->value,s->name,tmpI->name,cpid+100000,ext->value);
+	  file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name))*sizeof(char));
+	  sprintf(file_url,"%s/%s",tmp2->value,file_name);
 	}else{
-	  file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+13)*sizeof(char));
-	  sprintf(file_url,"%s/%s/%s_%s_%i.%s",tmp3->value,tmp2->value,s->name,tmpI->name,cpid+100000,ext->value);
+	  file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name))*sizeof(char));
+	  sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name);
 	}
 	addToMap(tmpI->content,"Reference",file_url);
@@ -2019,7 +2050,6 @@
 			 request_inputs,
 			 request_outputs);
-  }
-  else
-    if(res!=SERVICE_FAILED){
+    }
+    else{
       /**
        * We get the requested output or fallback to the first one if the 
@@ -2083,18 +2113,4 @@
 #endif
       }
-    }else{
-      char tmp[1024];
-      map * errormap;
-      map *lenv;
-      lenv=getMapFromMaps(m,"lenv","message");
-      if(lenv!=NULL)
-	sprintf(tmp,_("Unable to run the Service. The message returned back by the Service was the following : %s"),lenv->value);
-      else
-	sprintf(tmp,_("Unable to run the Service. No more information was returned back by the Service."));
-      errormap = createMap("text",tmp);      
-      addToMap(errormap,"code", "InternalError");
-      printExceptionReportResponse(m,errormap);
-      freeMap(&errormap);
-      free(errormap);
     }
 }
Index: /trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 453)
@@ -45,7 +45,11 @@
 #endif
 #include <stdio.h>
-#include <unistd.h>
 #include <time.h>
 #include <ctype.h>
+#ifdef WIN32
+#ifndef USE_RUBY
+#include <unistd.h>
+#endif
+#endif
 #ifndef WIN32
 #include <xlocale.h>
@@ -72,4 +76,5 @@
 #include "service_internal_js.h"
 #endif
+
 
 #ifdef __cplusplus
Index: /trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 453)
@@ -483,5 +483,5 @@
 
 	tres=(maps*)malloc(MAPS_SIZE);
-	tres->name=strdup(JS_EncodeString(cx,jsmsg));
+	tres->name=zStrdup(JS_EncodeString(cx,jsmsg));
 	tres->content=NULL;
 	tres->next=NULL;
@@ -578,10 +578,10 @@
 #endif
 	  if(strcasecmp(JS_EncodeString(cx,jsmsg1),"[object Object]")==0){
-	    tres->name=strdup(JS_EncodeString(cx,jsmsg));
+	    tres->name=zStrdup(JS_EncodeString(cx,jsmsg));
 	    tres->content=mapFromJSObject(cx,nvp1j);
 	  }
 	  else
 	    if(strcasecmp(JS_EncodeString(cx,jsmsg),"name")==0){
-	      tres->name=strdup(JS_EncodeString(cx,jsmsg1));
+	      tres->name=zStrdup(JS_EncodeString(cx,jsmsg1));
 	    }
 	    else{
@@ -775,5 +775,5 @@
   }
   else{
-    method=strdup("GET");
+    method=zStrdup("GET");
     url=JSValToChar(cx,argv);
   }
Index: /trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 453)
@@ -109,5 +109,5 @@
   map *msOgcVersion=getMapFromMaps(m,"main","msOgcVersion");
   map *dataPath=getMapFromMaps(m,"main","dataPath");
-  map *sid=getMapFromMaps(m,"lenv","sid");
+  map *sid=getMapFromMaps(m,"lenv","usid");
   map* format=getMap(tmpI->content,"mimeType");
   map* rformat=getMap(tmpI->content,"requestedMimeType");
@@ -371,6 +371,6 @@
   OGRSFDriverH *poDriver1 = NULL;
   char *dsName=(char*)malloc((8+strlen(pszDataSource)+1)*sizeof(char));
-  char *odsName=strdup(pszDataSource);
-  char *sdsName=strdup(pszDataSource);
+  char *odsName=zStrdup(pszDataSource);
+  char *sdsName=zStrdup(pszDataSource);
   char *demo=strstr(odsName,".");
   sdsName[strlen(sdsName)-(strlen(demo)-1)]='d';
@@ -414,5 +414,5 @@
     char** demo=VSIReadDir(dsName);
     int i=0;
-    mkdir(sdsName
+    zMkdir(sdsName
 #ifndef WIN32
 		,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH 
@@ -432,15 +432,15 @@
 #endif
       VSIFSeekL(vsif,0,SEEK_END);
-      int size=VSIFTellL(vsif);
+      vsi_l_offset size=VSIFTellL(vsif);
 #ifdef DEBUGMS
       fprintf(stderr,"size : %d\n",size);
 #endif
       VSIFSeekL(vsif,0,SEEK_SET);
-      char *vsifcontent=(char*) malloc((size+1)*sizeof(char));
-      VSIFReadL(vsifcontent,1,size,vsif);
+      char *vsifcontent=(char*) malloc(((int)size+1)*sizeof(char));
+      VSIFReadL(vsifcontent,1,(size_t)size,vsif);
       char *fpath=(char*) malloc((strlen(sdsName)+strlen(demo[1])+2)*sizeof(char));
       sprintf(fpath,"%s/%s",sdsName,demo[i]);
-      int f=open(fpath,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
-      write(f,vsifcontent,size);
+      int f=zOpen(fpath,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+      zWrite(f,vsifcontent,(int)size);
       close(f);
       chmod(fpath,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH);
@@ -511,8 +511,8 @@
     dumpMaps(output);
 #endif
-    myLayer->name = strdup(output->name);
+    myLayer->name = zStrdup(output->name);
     myLayer->tileitem=NULL;
-    myLayer->data = strdup(OGR_L_GetName(poLayer));
-    myLayer->connection = strdup(pszDataSource);
+    myLayer->data = zStrdup(OGR_L_GetName(poLayer));
+    myLayer->connection = zStrdup(pszDataSource);
     myLayer->index = m->numlayers;
     myLayer->dump = MS_TRUE;
@@ -699,7 +699,7 @@
 
   layerObj* myLayer=m->layers[m->numlayers];
-  myLayer->name = strdup(output->name);
+  myLayer->name = zStrdup(output->name);
   myLayer->tileitem=NULL;
-  myLayer->data = strdup(pszFilename);
+  myLayer->data = zStrdup(pszFilename);
   myLayer->index = m->numlayers;
   myLayer->dump = MS_TRUE;
@@ -734,12 +734,13 @@
   const char *tRef=GDALGetProjectionRef( hDataset );
   if( tRef != NULL && strlen(tRef)>0 ){
-    OGRSpatialReferenceH  hSRS;
     char *pszProjection;
     pszProjection = (char *) GDALGetProjectionRef( hDataset );
-#ifdef DEBUGMS
+    //#ifdef DEBUGMS
     fprintf(stderr,"Accessing the DataSource %s\n",GDALGetProjectionRef( hDataset ));
-#endif
+    //#endif
     setSrsInformations(output,m,myLayer,pszProjection);
-    }
+  }else{
+    fprintf(stderr,"NO SRS FOUND ! %s\n",GDALGetProjectionRef( hDataset ));    
+  }
 
 
@@ -792,5 +793,5 @@
     }else{
       if(iBand<4){
-	char *tmpS=strdup(nameBands);
+	char *tmpS=zStrdup(nameBands);
 	nameBands=(char*)realloc(nameBands,(strlen(nameBands)+strlen(lBands)+1)*sizeof(char));
 	sprintf(nameBands,"%s %s",tmpS,lBands);
@@ -805,8 +806,8 @@
    */
   for( iBand = 0; iBand < nBandsI; iBand++ ){
-    int         bGotNodata, bSuccess;
-    double      adfCMinMax[2], dfNoData;
-    int         nBlockXSize, nBlockYSize, nMaskFlags;
-    double      dfMean, dfStdDev;
+    //int         bGotNodata;//, bSuccess;
+    double      adfCMinMax[2]/*, dfNoData*/;
+    //int         nBlockXSize, nBlockYSize, nMaskFlags;
+    //double      /*dfMean, dfStdDev*/;
     hBand = GDALGetRasterBand( hDataset, iBand+1 );
 
@@ -863,5 +864,5 @@
 	    char className[7];
 	    sprintf(className,"class%d",i);
-	    myLayer->CLASS[myLayer->numclasses]->name=strdup(className);
+	    myLayer->CLASS[myLayer->numclasses]->name=zStrdup(className);
 	    
 	    /**
@@ -924,5 +925,5 @@
   
   map* tmpMap=getMapFromMaps(conf,"main","dataPath");
-  map* sidMap=getMapFromMaps(conf,"lenv","sid");
+  map* sidMap=getMapFromMaps(conf,"lenv","usid");
   char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char));
   sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext);
@@ -945,5 +946,5 @@
   mapObj *myMap=msNewMapObj();
   free(myMap->name);
-  myMap->name=strdup("ZOO-Project_WXS_Server");
+  myMap->name=zStrdup("ZOO-Project_WXS_Server");
   msMapSetSize(myMap,2048,2048);
   msMapSetExtent(myMap,-1,-1,1,1);
@@ -953,7 +954,7 @@
    */
   map *tmp1=getMapFromMaps(conf,"main","tmpPath");
-  myMap->web.imagepath=strdup(tmp1->value);
+  myMap->web.imagepath=zStrdup(tmp1->value);
   tmp1=getMapFromMaps(conf,"main","tmpUrl");
-  myMap->web.imageurl=strdup(tmp1->value);
+  myMap->web.imageurl=zStrdup(tmp1->value);
   
   /*
@@ -1084,8 +1085,8 @@
   sprintf(tmpPath,"%s/symbols.sym",tmp1->value);
   msInitSymbolSet(&myMap->symbolset);
-  myMap->symbolset.filename=strdup(tmpPath);
+  myMap->symbolset.filename=zStrdup(tmpPath);
   free(tmpPath);
 
-  map* sid=getMapFromMaps(conf,"lenv","sid");
+  map* sid=getMapFromMaps(conf,"lenv","usid");
   char *mapPath=
     (char*)malloc((16+strlen(outputs->name)+strlen(tmp1->value))*sizeof(char));
Index: /trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 453)
@@ -2,5 +2,5 @@
  * Author : Gérald FENOY
  *
- * Copyright (c) 2009-2013 GeoLabs SARL
+ * Copyright (c) 2009-2014 GeoLabs SARL
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -31,4 +31,11 @@
 #if PY_MAJOR_VERSION >= 3
 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_AsLong PyLong_AsLong
+#define PyString_FromString PyUnicode_FromString
+#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
+#define PyString_Check PyUnicode_Check
+#define	PyString_AsString _PyUnicode_AsString
+#define	PyString_Size PyUnicode_GetSize
 #else
 #define GETSTATE(m) (&_state)
@@ -88,17 +95,9 @@
 
   d = PyModule_GetDict(module);
-#if PY_MAJOR_VERSION >= 3
-  tmp = PyLong_FromLong(3);
-#else
   tmp = PyInt_FromLong(3);
-#endif
   PyDict_SetItemString(d, "SERVICE_SUCCEEDED", tmp);
   Py_DECREF(tmp);
 
-#if PY_MAJOR_VERSION >= 3
-  tmp = PyLong_FromLong(4);
-#else
   tmp = PyInt_FromLong(4);
-#endif
   PyDict_SetItemString(d, "SERVICE_FAILED", tmp);
   Py_DECREF(tmp);
@@ -191,10 +190,5 @@
   tmp=getMap(s->content,"serviceProvider");
   if(tmp!=NULL)
-    pName = 
-#if PY_MAJOR_VERSION >= 3
-      PyUnicode_FromString(tmp->value);
-#else
-      PyString_FromString(tmp->value);
-#endif
+    pName = PyString_FromString(tmp->value);
   else{
     map* err=createMap("text","Unable to parse serviceProvider please check your zcfg file.");
@@ -218,16 +212,7 @@
       PyTuple_SetItem(pArgs, 1, (PyObject *)arg2);
       PyTuple_SetItem(pArgs, 2, (PyObject *)arg3);
-      tmp=getMap(request,"storeExecuteResponse");
-#ifdef DEBUG
-      fprintf(stderr,"RUN IN NORMAL MODE \n");
-      fflush(stderr);
-#endif
       pValue = PyObject_CallObject(pFunc, pArgs);
       if (pValue != NULL) {
-#if PY_MAJOR_VERSION >= 3
-	res=PyLong_AsLong(pValue);
-#else
 	res=PyInt_AsLong(pValue);
-#endif
 	freeMaps(real_outputs);
 	free(*real_outputs);
@@ -237,9 +222,5 @@
 	*real_outputs=mapsFromPyDict(arg3);
 #ifdef DEBUG
-#if PY_MAJOR_VERSION >= 3
-	fprintf(stderr,"Result of call: %i\n", PyLong_AsLong(pValue));
-#else
 	fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue));
-#endif
 	dumpMaps(inputs);
 	dumpMaps(*real_outputs);
@@ -250,26 +231,13 @@
 	PyObject *trace=PyObject_Str(pvalue);
 	char pbt[10240];
-#if PY_MAJOR_VERSION >= 3
-	if(PyUnicode_Check(trace))
-	  sprintf(pbt,"TRACE : %s",_PyUnicode_AsString(trace));
-#else
 	if(PyString_Check(trace))
 	  sprintf(pbt,"TRACE : %s",PyString_AsString(trace));
-#endif
 	else
 	  fprintf(stderr,"EMPTY TRACE ?");
 	trace=NULL;
 	trace=PyObject_Str(ptype);
-#if PY_MAJOR_VERSION >= 3
-	if(PyUnicode_Check(trace)){
-#else
 	if(PyString_Check(trace)){
-#endif
-	  char *tpbt=strdup(pbt);
-#if PY_MAJOR_VERSION >= 3
-	  sprintf(pbt,"%s\n%s\0",tpbt,_PyUnicode_AsString(trace));
-#else
+	  char *tpbt=zStrdup(pbt);
 	  sprintf(pbt,"%s\n%s\0",tpbt,PyString_AsString(trace));
-#endif
 	  free(tpbt);
 	}
@@ -277,10 +245,6 @@
 	  fprintf(stderr,"EMPTY TRACE ?");
 	
-	char *tpbt=strdup(pbt);
-#if PY_MAJOR_VERSION >= 3
-	pName = PyUnicode_FromString("traceback");
-#else
+	char *tpbt=zStrdup(pbt);
 	pName = PyString_FromString("traceback");
-#endif
 	pModule = PyImport_Import(pName);
 	pArgs = PyTuple_New(1);
@@ -290,11 +254,6 @@
 	trace=NULL;
 	trace=PyObject_Str(pValue);
-#if PY_MAJOR_VERSION >= 3
-	if(PyUnicode_Check(trace))
-	  sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s",tpbt,_PyUnicode_AsString(trace));
-#else
 	if(PyString_Check(trace))
 	  sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s",tpbt,PyString_AsString(trace));
-#endif
 	else
 	  sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations. %s",tpbt);
@@ -338,10 +297,5 @@
   while(tmp!=NULL){
     PyObject* value=(PyObject*)PyDict_FromMap(tmp->content);
-    PyObject* name=
-#if PY_MAJOR_VERSION >= 3
-      PyUnicode_FromString(tmp->name);
-#else
-      PyString_FromString(tmp->name);
-#endif
+    PyObject* name=PyString_FromString(tmp->name);
     if(PyDict_SetItem(res,name,value)<0){
       fprintf(stderr,"Unable to set map value ...");
@@ -362,10 +316,5 @@
   map* tmap=getMapType(tmp);
   while(tmp!=NULL){
-    PyObject* name=
-#if PY_MAJOR_VERSION >= 3
-      PyUnicode_FromString(tmp->name);
-#else
-      PyString_FromString(tmp->name);
-#endif
+    PyObject* name=PyString_FromString(tmp->name);
     if(strcasecmp(tmp->name,"value")==0) {
       if(isArray!=NULL){
@@ -386,19 +335,10 @@
 	    PyObject* lsvalue;
 	    if(sMap==NULL){
-#if PY_MAJOR_VERSION >= 3
-	      lvalue=PyUnicode_FromString(vMap->value);
-#else
 	      lvalue=PyString_FromString(vMap->value);
-#endif
 	      lsvalue=Py_None;
 	    }
-	    else{
-#if PY_MAJOR_VERSION >= 3
-	      lvalue=PyUnicode_FromStringAndSize(vMap->value,atoi(sMap->value));
-	      lsvalue=PyUnicode_FromString(sMap->value);
-#else
+	    else{    
 	      lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value));
 	      lsvalue=PyString_FromString(sMap->value);
-#endif
 	      hasSize=1;
 	    }
@@ -417,9 +357,5 @@
 	  PyObject* lmvalue;
 	  if(mMap!=NULL){
-#if PY_MAJOR_VERSION >= 3
-	    lmvalue=PyUnicode_FromString(mMap->value);
-#else
 	    lmvalue=PyString_FromString(mMap->value);
-#endif
 	  }else
 	    lmvalue=Py_None;
@@ -436,18 +372,10 @@
 	  return NULL;
 	}
-#if PY_MAJOR_VERSION >= 3
-	if(PyDict_SetItem(res,PyUnicode_FromString(tmap->name),mvalue)<0){
-#else
 	if(PyDict_SetItem(res,PyString_FromString(tmap->name),mvalue)<0){
-#endif
 	  fprintf(stderr,"Unable to set key value pair...");
 	  return NULL;
 	}
 	if(hasSize>0)
-#if PY_MAJOR_VERSION >= 3
-	  if(PyDict_SetItem(res,PyUnicode_FromString("size"),svalue)<0){
-#else
 	  if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){
-#endif
 	    fprintf(stderr,"Unable to set key value pair...");
 	    return NULL;
@@ -455,10 +383,5 @@
       }
       else if(size!=NULL){
-	PyObject* value=
-#if PY_MAJOR_VERSION >= 3
-	  PyUnicode_FromStringAndSize(tmp->value,atoi(size->value));
-#else
-	  PyString_FromStringAndSize(tmp->value,atoi(size->value));
-#endif
+	PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value));
 	if(PyDict_SetItem(res,name,value)<0){
 	  fprintf(stderr,"Unable to set key value pair...");
@@ -467,10 +390,5 @@
       }
       else{
-	PyObject* value=
-#if PY_MAJOR_VERSION >= 3
-	  PyUnicode_FromString(tmp->value);
-#else
-	  PyString_FromString(tmp->value);
-#endif
+	PyObject* value=PyString_FromString(tmp->value);
 	if(PyDict_SetItem(res,name,value)<0){
 	  fprintf(stderr,"Unable to set key value pair...");
@@ -481,10 +399,5 @@
     else{
       if(PyDict_GetItem(res,name)==NULL){
-	PyObject* value=
-#if PY_MAJOR_VERSION >= 3
-	  PyUnicode_FromString(tmp->value);
-#else
-	  PyString_FromString(tmp->value);
-#endif
+	PyObject* value=PyString_FromString(tmp->value);
 	if(PyDict_SetItem(res,name,value)<0){
 	  fprintf(stderr,"Unable to set key value pair...");
@@ -516,9 +429,5 @@
 #endif
     cursor=(maps*)malloc(MAPS_SIZE);
-#if PY_MAJOR_VERSION >= 3
-    cursor->name=_PyUnicode_AsString(key);
-#else
     cursor->name=PyString_AsString(key);
-#endif
     cursor->content=mapFromPyDict((PyDictObject*)value);
 #ifdef DEBUG
@@ -553,9 +462,6 @@
 	    PyString_AsString(key),PyString_AsString(value));
 #endif
-#if PY_MAJOR_VERSION >= 3
-    if(strcmp(_PyUnicode_AsString(key),"value")==0){
-#else
+    
     if(strcmp(PyString_AsString(key),"value")==0){
-#endif
       char *buffer=NULL;
       Py_ssize_t size;
@@ -566,15 +472,7 @@
 #endif
       if(res!=NULL){
-#if PY_MAJOR_VERSION >= 3
-	addToMap(res,_PyUnicode_AsString(key),"");
-#else
 	addToMap(res,PyString_AsString(key),"");
-#endif
       }else{
-#if PY_MAJOR_VERSION >= 3
-	res=createMap(_PyUnicode_AsString(key),"");
-#else
 	res=createMap(PyString_AsString(key),"");
-#endif
       }
       map* tmpR=getMap(res,"value");
@@ -589,18 +487,9 @@
       if(res!=NULL){
 	if(PyString_Size(value)>0)
-#if PY_MAJOR_VERSION >= 3
-	  addToMap(res,_PyUnicode_AsString(key),_PyUnicode_AsString(value));
-#else
 	  addToMap(res,PyString_AsString(key),PyString_AsString(value));
-#endif
       }
       else{
 	if(PyString_Size(value)>0)
-	  res=
-#if PY_MAJOR_VERSION >= 3
-	    createMap(_PyUnicode_AsString(key),_PyUnicode_AsString(value));
-#else
-	    createMap(PyString_AsString(key),PyString_AsString(value));
-#endif
+	  res=createMap(PyString_AsString(key),PyString_AsString(value));
       }
     }
@@ -619,9 +508,5 @@
     return NULL;
   }
-#if PY_MAJOR_VERSION >= 3
-  return PyUnicode_FromString(_ss(str));
-#else
   return PyString_FromString(_ss(str));
-#endif
 }
 
@@ -645,5 +530,5 @@
      char tmpStatus[4];
      snprintf(tmpStatus, 4, "%i", istatus);
-     status = strdup(tmpStatus);
+     status = zStrdup(tmpStatus);
   }
   /* now update the map */
@@ -651,10 +536,5 @@
     PyObject* lenv = PyMapping_GetItemString(confdict, "lenv");
     if (lenv && PyMapping_Check(lenv)){
-      PyObject* valobj = 
-#if PY_MAJOR_VERSION >= 3
-	PyUnicode_FromString(status);
-#else
-	PyString_FromString(status);
-#endif
+      PyObject* valobj = PyString_FromString(status);
       PyMapping_SetItemString(lenv, "status", valobj);
       Py_DECREF(valobj);
Index: /trunk/zoo-project/zoo-kernel/service_internal_ruby.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_ruby.c	(revision 453)
+++ /trunk/zoo-project/zoo-kernel/service_internal_ruby.c	(revision 453)
@@ -0,0 +1,400 @@
+/**
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 2014 GeoLabs SARL
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "service_internal_ruby.h"
+
+#if RUBY_API_VERSION_MAJOR >= 2 || RUBY_API_VERSION_MINOR == 9 
+int argc=0;
+char **argv=NULL;
+#endif
+
+int zoo_ruby_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
+#if RUBY_API_VERSION_MAJOR >= 2 || RUBY_API_VERSION_MINOR == 9
+  ruby_sysinit(&argc,&argv);
+  RUBY_INIT_STACK;
+#endif
+  ruby_init();
+  maps* m=*main_conf;
+  maps* inputs=*real_inputs;
+  maps* outputs=*real_outputs;
+  map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd");
+  char *ntmp=tmp0->value;
+  map* tmp=NULL;
+  ruby_init_loadpath();
+  ruby_script("ZOO_EMBEDDED_ENV");
+  
+  VALUE klass=rb_define_module("Zoo");
+  rb_define_const(klass,"SERVICE_SUCCEEDED",INT2FIX(3));
+  rb_define_const(klass,"SERVICE_FAILED",INT2FIX(4));
+  typedef VALUE (*HOOK)(...);
+  rb_define_module_function(klass,"Translate",reinterpret_cast<HOOK>(RubyTranslate),-1);
+  rb_define_module_function(klass,"UpdateStatus",reinterpret_cast<HOOK>(RubyUpdateStatus),-1);
+
+  int error = 0;
+		
+  ID rFunc=Qnil;
+  tmp=getMap(s->content,"serviceProvider");
+  if(tmp!=NULL){
+#if RUBY_VERSION_MINOR == 8
+    const char* script = ruby_sourcefile = rb_source_filename(tmp->value);
+    rb_protect(LoadWrap, reinterpret_cast<VALUE>(script), &error);
+#else
+    rb_load_protect(rb_str_new2(tmp->value), 0, &error);
+#endif
+    if(error) {
+      ruby_trace_error(m);
+      return -1;
+    }
+#if RUBY_VERSION_MINOR == 8
+    ruby_exec();
+#else
+    ruby_exec_node(NULL);
+#endif
+  }
+  else{
+    map* err=createMap("text","Unable to parse serviceProvider please check your zcfg file.");
+    addToMap(err,"code","NoApplicableCode");
+    printExceptionReportResponse(m,err);
+    return -1;
+  }
+  int res=SERVICE_FAILED;
+  rFunc=rb_intern(s->name);
+  if(rFunc!=Qnil){
+    VALUE arg1=RubyHash_FromMaps(m);
+    VALUE arg2=RubyHash_FromMaps(inputs);
+    VALUE arg3=RubyHash_FromMaps(outputs);
+    VALUE rArgs[3]={arg1,arg2,arg3};
+    if (!rArgs)
+      return -1;
+    struct my_callback data;
+    data.obj=Qnil;
+    data.method_id=rFunc;
+    data.nargs=3;
+    data.args[0]=rArgs[0];
+    data.args[1]=rArgs[1];
+    data.args[2]=rArgs[2];
+    typedef VALUE (*HOOK)(VALUE);
+    VALUE tres=rb_protect(reinterpret_cast<HOOK>(FunCallWrap),(VALUE)(&data),&error);
+    if (TYPE(tres) == T_FIXNUM) {
+      res=FIX2INT(tres);
+      freeMaps(real_outputs);
+      free(*real_outputs);
+      freeMaps(main_conf);
+      free(*main_conf);
+      *main_conf=mapsFromRubyHash(arg1);
+      *real_outputs=mapsFromRubyHash(arg3);
+#ifdef DEBUG
+      dumpMaps(*main_conf);
+      dumpMaps(*real_outputs);
+#endif
+    }else{
+      ruby_trace_error(m);
+      res=-1;
+    }
+  }
+  else{
+    char tmpS[1024];
+    sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value);
+    map* tmps=createMap("text",tmpS);
+    printExceptionReportResponse(m,tmps);
+    res=-1;
+  }
+  ruby_finalize();
+  return res;
+}
+
+VALUE LoadWrap(VALUE arg) {
+  const char *filename = reinterpret_cast<const char*>(arg);
+  rb_load_file(filename);
+  return Qnil;
+}
+
+VALUE FunCallWrap(VALUE rdata) {
+  struct my_callback* data = (struct my_callback*) rdata;
+  return rb_funcall2(data->obj,data->method_id,data->nargs,data->args);
+}
+
+void ruby_trace_error(maps* m){
+#if RUBY_VERSION_MINOR == 8
+  VALUE lasterr = rb_gv_get("$!");
+#else
+  VALUE lasterr = rb_errinfo();
+  VALUE ruby_errinfo = lasterr;
+#endif
+  VALUE message = rb_obj_as_string(lasterr);
+  VALUE lklass = rb_class_path(CLASS_OF(lasterr));
+#if RUBY_VERSION_MINOR == 8
+  char *trace=(char*)malloc((strlen(RSTRING(lklass)->ptr)+strlen(RSTRING(message)->ptr)+3)*sizeof(char));
+  sprintf(trace,"%s: %s",RSTRING_PTR(lklass),RSTRING_PTR(message));
+#else
+  char *trace=(char*)malloc((strlen(RSTRING_PTR(lklass))+strlen(RSTRING_PTR(message))+3)*sizeof(char));
+  sprintf(trace,"%s: %s",RSTRING_PTR(lklass),RSTRING_PTR(message));
+#endif
+  if(!NIL_P(ruby_errinfo))
+    {
+      VALUE ary = rb_funcall(ruby_errinfo, rb_intern("backtrace"), 0);
+      int c;
+      for (c=0; c<RARRAY_LEN(ary); c++) {
+	int len=strlen(trace);
+	char *tmp0=zStrdup(trace);
+#if RUBY_VERSION_MINOR == 8
+	trace=(char *) realloc(trace,(len+strlen(RSTRING(RARRAY(ary)->ptr[c])->ptr)+2)*sizeof(char));
+	sprintf(trace,"%s\n%s",tmp0,RSTRING(RARRAY(ary)->ptr[c])->ptr);
+#else
+	trace=(char *) realloc(trace,(len+strlen(RSTRING_PTR(RARRAY_PTR(ary)[c]))+2)*sizeof(char));
+	sprintf(trace,"%s\n%s",tmp0,RSTRING_PTR(RARRAY_PTR(ary)[c]));
+#endif
+	free(tmp0);
+      }
+    }
+  map* err=createMap("text",trace);
+  addToMap(err,"code","NoApplicableCode");
+  printExceptionReportResponse(m,err);
+}
+
+VALUE RubyHash_FromMaps(maps* t){
+  VALUE res=rb_hash_new();
+  maps* tmp=t;
+  while(tmp!=NULL){
+    VALUE value=RubyHash_FromMap(tmp->content);
+    VALUE name=rb_str_new2(tmp->name);
+    rb_hash_aset(res,name,value);
+    tmp=tmp->next;
+  }  
+  return res;
+}
+
+int
+keys_i(VALUE key,VALUE value,VALUE ary)
+{
+  if (key == Qundef) return ST_CONTINUE;
+  rb_ary_push(ary, key);
+  return ST_CONTINUE;
+}
+
+VALUE
+rb_hash_size(VALUE hash)
+{
+    return INT2FIX(RHASH_TBL(hash)->num_entries);
+}
+
+VALUE RubyHash_FromMap(map* t){
+  VALUE res=rb_hash_new( );
+  map* tmp=t;
+  int hasSize=0;
+  map* isArray=getMap(tmp,"isArray");
+  map* size=getMap(tmp,"size");
+  map* tmap=getMapType(tmp);
+  while(tmp!=NULL){
+    VALUE name= rb_str_new2(tmp->name);
+    if(strcasecmp(tmp->name,"value")==0) {
+      if(isArray!=NULL){
+	map* len=getMap(tmp,"length");
+	int cnt=atoi(len->value);
+	VALUE value=rb_ary_new2(cnt);
+	VALUE mvalue=rb_ary_new2(cnt);
+	VALUE svalue=rb_ary_new2(cnt);
+
+	for(int i=0;i<cnt;i++){
+	  
+	  map* vMap=getMapArray(tmp,"value",i);	    
+	  map* sMap=getMapArray(tmp,"size",i);
+
+	  if(vMap!=NULL){
+	    
+	    VALUE lvalue;
+	    VALUE lsvalue;
+	    if(sMap==NULL){
+	      lvalue=rb_str_new2(vMap->value);
+	      lsvalue=Qnil;
+	    }
+	    else{
+	      lvalue=rb_str_new(vMap->value,atoi(sMap->value));
+	      lsvalue=rb_str_new2(sMap->value);
+	      hasSize=1;
+	    }
+
+	    rb_ary_push(value,lvalue);
+	    rb_ary_push(svalue,lsvalue);
+	  }
+	  
+	  map* mMap=getMapArray(tmp,tmap->name,i);
+
+	  VALUE lmvalue;
+	  if(mMap!=NULL){
+	    lmvalue=rb_str_new2(mMap->value);
+	  }else
+	    lmvalue=Qnil;
+	  rb_ary_push(mvalue,lmvalue);
+	  
+	}
+
+	rb_hash_aset(res, name, mvalue);
+	rb_hash_aset(res, rb_str_new2(tmap->name), mvalue);
+      
+	if(hasSize>0){
+	  VALUE lname=rb_str_new2("size");
+	  rb_hash_aset(res, lname, value);
+	}
+      }
+      else if(size!=NULL){
+	VALUE value=rb_str_new(tmp->value,atoi(size->value));
+	rb_hash_aset(res, name, value);
+      }
+      else{
+	VALUE value=rb_str_new2(tmp->value);
+	rb_hash_aset(res, name, value);
+      }
+    }
+    else{
+      VALUE value=rb_str_new2(tmp->value);
+      rb_hash_aset(res, name, value);
+    }
+    tmp=tmp->next;
+  }
+  return res;
+}
+
+
+maps* mapsFromRubyHash(VALUE t){
+  maps* res=NULL;
+  maps* cursor=res;
+  VALUE list;
+  list = rb_ary_new();
+  typedef int (*HOOK)(...);
+  rb_hash_foreach(t, reinterpret_cast<HOOK>(keys_i), list);
+  int nb=rb_hash_size(t);
+  int i;
+  for(i=0;i<FIX2INT(nb);i++){
+    VALUE key=rb_ary_pop(list);
+    VALUE value=rb_hash_aref(t,key);
+#ifdef DEBUG
+    fprintf(stderr,">> DEBUG VALUES : %s => %s\n",
+	    StringValueCStr(key),StringValueCStr(value));
+#endif
+    cursor=(maps*)malloc(MAPS_SIZE);
+    cursor->name=StringValueCStr(key);
+    cursor->content=mapFromRubyHash(value);
+    cursor->next=NULL;
+    if(res==NULL)
+      res=dupMaps(&cursor);
+    else
+      addMapsToMaps(&res,cursor);
+    freeMap(&cursor->content);
+    free(cursor->content);
+    free(cursor);
+  }
+  return res;
+}
+
+map* mapFromRubyHash(VALUE t){
+  map* res=NULL;
+  VALUE list;
+  list = rb_ary_new();
+  typedef int (*HOOK)(...);
+  rb_hash_foreach(t,reinterpret_cast<HOOK>(keys_i), list);
+  int nb=RHASH_TBL(t)->num_entries;
+  int i;
+  for(i=0;i<nb;i++){
+    VALUE key=rb_ary_pop(list);
+    VALUE value=rb_hash_aref(t,key);
+#ifdef DEBUG
+    fprintf(stderr,">> DEBUG VALUES : %s => %s\n",
+	    StringValueCStr(key),StringValueCStr(value));
+#endif
+    if(strcmp(StringValueCStr(key),"value")==0){
+      char *buffer=NULL;
+      int size=RSTRING_LEN(value);
+      buffer=StringValueCStr(value);
+      if(res!=NULL){
+	addToMap(res,StringValueCStr(key),"");
+      }else{
+	res=createMap(StringValueCStr(key),"");
+      }
+      map* tmpR=getMap(res,"value");
+      free(tmpR->value);
+      tmpR->value=(char*)malloc((size+1)*sizeof(char));
+      memmove(tmpR->value,buffer,size*sizeof(char));
+      tmpR->value[size]=0;
+      char sin[1024];
+      sprintf(sin,"%d",size);
+      addToMap(res,"size",sin);
+    }else{
+      if(res!=NULL){
+	addToMap(res,StringValueCStr(key),StringValueCStr(value));
+      }
+      else{
+	res=
+	  createMap(StringValueCStr(key),StringValueCStr(value));
+      }
+    }
+  }
+  return res;
+}
+
+VALUE
+RubyTranslate(int argc, VALUE *argv, VALUE obj)
+{
+  return rb_str_new2(_ss(StringValueCStr(argv[0])));
+}
+
+VALUE
+RubyUpdateStatus(int argc, VALUE *argv, VALUE obj)
+{
+  maps* conf;
+  VALUE confdict=argv[0];
+  int istatus=argv[1];
+  char* status;
+  if (istatus < 0 || istatus > 100){
+    fprintf(stderr,"Status must be a percentage.");
+    return NULL;
+  }else{
+     char tmpStatus[4];
+     snprintf(tmpStatus, 4, "%i", istatus);
+     status = zStrdup(tmpStatus);
+  }
+  /* now update the map */
+  {
+    VALUE lenv = rb_hash_aref(confdict,rb_str_new2("lenv"));
+    if(TYPE(lenv)!=T_NIL){
+      VALUE valobj=rb_str_new2(status);
+      rb_hash_aset(lenv,rb_str_new2("status"),valobj);
+    }
+  }
+  conf = mapsFromRubyHash(confdict);
+  if (getMapFromMaps(conf,"lenv","status") != NULL){
+    fprintf(stderr,"STATUS RETURNED : %s\n",status);
+    if(status!=NULL){
+      setMapInMaps(conf,"lenv","status",status);
+      free(status);
+    }
+    else
+      setMapInMaps(conf,"lenv","status","15");
+    updateStatus(conf);
+  }
+  freeMaps(&conf);
+  free(conf);
+  return Qnil;
+}
+
Index: /trunk/zoo-project/zoo-kernel/service_internal_ruby.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_ruby.h	(revision 453)
+++ /trunk/zoo-project/zoo-kernel/service_internal_ruby.h	(revision 453)
@@ -0,0 +1,75 @@
+/**
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 2014 GeoLabs SARL
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef ZOO_SERVICE_INTERNAL_RUBY_H
+#define ZOO_SERVICE_INTERNAL_RUBY_H 1
+
+#pragma once 
+
+#define RUBY_GLOBAL_SETUP
+#undef NEED_STRLCAT
+#undef NEED_STRLCPY
+#include "service.h"
+#include "service_internal.h"
+#undef RUBY_EXPORT
+#undef STRCASECMP
+#undef STRNCASECMP
+#undef _
+#include <ruby.h>
+#if ZRUBY_VERSION < 2
+#include <version.h>
+#else
+#include <ruby/version.h>
+#endif
+#if RUBY_VERSION_MINOR==8
+#include <st.h>
+#else
+#include <ruby/st.h>
+#endif
+
+#define MAX_ARGS 3
+struct my_callback {
+  VALUE obj;
+  ID method_id;
+  int nargs;
+  VALUE args[MAX_ARGS];
+};
+
+void ruby_trace_error(maps*);
+VALUE FunCallWrap(VALUE);
+VALUE LoadWrap(VALUE);
+
+VALUE RubyHash_FromMaps(maps*);
+VALUE RubyHash_FromMap(map*);
+
+maps* mapsFromRubyHash(VALUE);
+void createMapsFromRubyHash(maps**,VALUE);
+map* mapFromRubyHash(VALUE);
+
+int zoo_ruby_support(maps**,map*,service*,maps**,maps**);
+
+VALUE RubyTranslate(int,VALUE*,VALUE);
+VALUE RubyUpdateStatus(int,VALUE*,VALUE);
+
+#endif
Index: /trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 453)
@@ -26,5 +26,5 @@
 #define _ULINET_H
 
-#include "fcgi_stdio.h"
+#include "stdio.h"
 #include <stdlib.h>
 #include <fcntl.h>
@@ -37,5 +37,5 @@
 #ifdef USE_JS
 #ifdef WIN32
-# define XP_WIN
+#define XP_WIN 1
 #else
 #define XP_UNIX 0
Index: /trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 453)
@@ -86,5 +86,5 @@
   char *strQuery=NULL;
   if(cgiQueryString!=NULL)
-    strQuery=strdup(cgiQueryString);
+    strQuery=zStrdup(cgiQueryString);
   map* tmpMap=NULL;
 
@@ -104,5 +104,5 @@
 	 else{
 	   res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
-	   char *tmp=strdup(res);
+	   char *tmp=zStrdup(res);
 	   sprintf(res,"%s%s",tmp,buffer);
 	   free(tmp);
@@ -136,5 +136,5 @@
 	    sprintf(buffer,"%s",tmpValueFinal);
 	  }else{
-	    char *tmp=strdup(buffer);
+	    char *tmp=zStrdup(buffer);
 	    sprintf(buffer,"%s&%s",tmp,tmpValueFinal);
 	    free(tmp);
@@ -240,5 +240,5 @@
 #endif
 	  if(req!=NULL && req->nodeNr==1){
-	    t1->value=strdup(requests[j]);
+	    t1->value=zStrdup(requests[j]);
 	    j=2;
 	  }
@@ -271,5 +271,5 @@
 	      xmlChar* content=xmlNodeListGetString(doc, id->nodeTab[k]->xmlChildrenNode,1);
 	      if(strlen(identifiers)>0){
-		char *tmp=strdup(identifiers);
+		char *tmp=zStrdup(identifiers);
 		snprintf(identifiers,strlen(tmp)+xmlStrlen(content)+2,"%s,%s",tmp,content);
 		free(tmp);
@@ -303,7 +303,7 @@
       while(token1!=NULL){
 	if(name==NULL)
-	  name=strdup(token1);
+	  name=zStrdup(token1);
 	else
-	  value=strdup(token1);
+	  value=zStrdup(token1);
 	token1=strtok_r(NULL,"=",&saveptr1);
       }
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 452)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 453)
@@ -64,4 +64,8 @@
 #endif
 
+#ifdef USE_RUBY
+#include "service_internal_ruby.h"
+#endif
+
 #ifdef USE_PERL
 #include "service_internal_perl.h"
@@ -91,6 +95,6 @@
 #ifndef USE_MS
  { 
-  char *x=_strdup(a); 
-  char *y=_strdup(b); 
+  char *x=_zStrdup(a); 
+  char *y=_zStrdup(b); 
   
   x=_strlwr(x); 
@@ -250,5 +254,5 @@
     else
       sprintf(tmps1,"%s/",ntmp);
-    char *altPath=strdup(tmps1);
+    char *altPath=zStrdup(tmps1);
     r_inputs=getMap(s1->content,"ServiceProvider");
     sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
@@ -419,4 +423,12 @@
 	    else
 #endif
+
+#ifdef USE_RUBY
+          if(strncasecmp(r_inputs->value,"Ruby",4)==0){
+            *eres=zoo_ruby_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
+          }
+          else
+#endif
+
 	      {
 		char tmpv[1024];
@@ -479,5 +491,5 @@
     free(r_inputs1);
   }
-  char *tmp1=strdup(tmp);
+  char *tmp1=zStrdup(tmp);
   sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
   
@@ -594,5 +606,5 @@
     r_inputs=getMapFromMaps(m,"main","language");
   if(r_inputs!=NULL){
-    char *tmp=strdup(r_inputs->value);
+    char *tmp=zStrdup(r_inputs->value);
     setMapInMaps(m,"main","language",tmp);
     translateChar(tmp,'-','_');
@@ -650,5 +662,5 @@
   }
   else{
-    REQUEST=strdup(r_inputs->value);
+    REQUEST=zStrdup(r_inputs->value);
     if(strncasecmp(r_inputs->value,"GetCapabilities",15)!=0
        && strncasecmp(r_inputs->value,"DescribeProcess",15)!=0
@@ -689,7 +701,7 @@
   map* tmpm=getMapFromMaps(m,"main","serverAddress");
   if(tmpm!=NULL)
-    SERVICE_URL=strdup(tmpm->value);
+    SERVICE_URL=zStrdup(tmpm->value);
   else
-    SERVICE_URL=strdup(DEFAULT_SERVICE_URL);
+    SERVICE_URL=zStrdup(DEFAULT_SERVICE_URL);
 
   service* s1;
@@ -883,5 +895,5 @@
     snprintf(tmps1,1024,"%s/",ntmp);
   r_inputs=getMap(request_inputs,"Identifier");
-  char *ttmp=strdup(tmps1);
+  char *ttmp=zStrdup(tmps1);
   snprintf(tmps1,1024,"%s/%s.zcfg",ttmp,r_inputs->value);
   free(ttmp);
@@ -956,5 +968,5 @@
 #endif
       char cursor_output[10240];
-      char *cotmp=strdup(r_inputs->value);
+      char *cotmp=zStrdup(r_inputs->value);
       snprintf(cursor_output,10240,"%s",cotmp);
       free(cotmp);
@@ -990,5 +1002,5 @@
       }
       for(j=0;j<i;j++){
-	char *tmp=strdup(outputs_as_text[j]);
+	char *tmp=zStrdup(outputs_as_text[j]);
 	free(outputs_as_text[j]);
 	char *tmpc;
@@ -1002,5 +1014,5 @@
 		return errorException(m, _("Unable to allocate memory."), "InternalError");
 	      }
-	      tmp_output->name=strdup(tmpc);
+	      tmp_output->name=zStrdup(tmpc);
 	      tmp_output->content=NULL;
 	      tmp_output->next=NULL;
@@ -1072,5 +1084,5 @@
      * Put each DataInputs into the inputs_as_text array
      */
-    char *tmp1=strdup(cursor_input);
+    char *tmp1=zStrdup(cursor_input);
     char * pToken;
     pToken=strtok(cursor_input,";");
@@ -1106,5 +1118,5 @@
 
     for(j=0;j<i;j++){
-      char *tmp=strdup(inputs_as_text[j]);
+      char *tmp=zStrdup(inputs_as_text[j]);
       free(inputs_as_text[j]);
       char *tmpc;
@@ -1133,5 +1145,5 @@
 	    return errorException(m, _("Unable to allocate memory."), "InternalError");
 	  }
-	  tmpmaps->name=strdup(tmpn);
+	  tmpmaps->name=zStrdup(tmpn);
 	  if(tmpv!=NULL){
 	    char *tmpvf=url_decode(tmpv+1);
@@ -1166,5 +1178,5 @@
 	    sprintf(tmpValue,"%s@%s",tmpv+1,tmpc);
 	    free(lmap->value);
-	    lmap->value=strdup(tmpValue);
+	    lmap->value=zStrdup(tmpValue);
 	    free(tmpValue);
 	    tmpc=strtok(NULL,"@");
@@ -1181,5 +1193,6 @@
 	      char *tmpx2=url_decode(tmpv1+1);
 	      if(strncasecmp(tmpx2,"http://",7)!=0 &&
-		 strncasecmp(tmpx2,"ftp://",6)!=0){
+		 strncasecmp(tmpx2,"ftp://",6)!=0 &&
+		 strncasecmp(tmpx2,"https://",8)!=0){
 		char emsg[1024];
 		sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
@@ -1303,5 +1316,5 @@
 		return errorException(m, _("Unable to allocate memory."), "InternalError");
 	      }
-	      tmpmaps->name=strdup((char*)val);
+	      tmpmaps->name=zStrdup((char*)val);
 	      tmpmaps->content=NULL;
 	      tmpmaps->next=NULL;
@@ -1321,5 +1334,5 @@
 		return errorException(m, _("Unable to allocate memory."), "InternalError");
 	      }
-	      tmpmaps->name=strdup("missingIndetifier");
+	      tmpmaps->name=zStrdup("missingIndetifier");
 	      tmpmaps->content=createMap((char*)cur2->name,(char*)val);
 	      tmpmaps->next=NULL;
@@ -1563,6 +1576,6 @@
 		 */
 		char *list[2];
-		list[0]=strdup("dataType");
-		list[1]=strdup("uom");
+		list[0]=zStrdup("dataType");
+		list[1]=zStrdup("uom");
 		for(int l=0;l<2;l++){
 #ifdef DEBUG
@@ -1656,5 +1669,5 @@
 		}
 		free(tmpv->value);
-		tmpv->value=strdup(res);
+		tmpv->value=zStrdup(res);
 		free(res);
 		xmlFree(tmp);
@@ -1741,5 +1754,5 @@
 	    return errorException(m, _("Unable to allocate memory."), "InternalError");
 	  }
-	  tmpmaps->name=strdup("unknownIdentifier");
+	  tmpmaps->name=zStrdup("unknownIdentifier");
 	  tmpmaps->content=NULL;
 	  tmpmaps->next=NULL;
@@ -1783,5 +1796,5 @@
 		return errorException(m, _("Unable to allocate memory."), "InternalError");
 	      }
-	      tmpmaps->name=strdup((char*)val);
+	      tmpmaps->name=zStrdup((char*)val);
 	      tmpmaps->content=NULL;
 	      tmpmaps->next=NULL;
@@ -1789,5 +1802,5 @@
 	    else{
 	      //free(tmpmaps->name);
-	      tmpmaps->name=strdup((char*)val);
+	      tmpmaps->name=zStrdup((char*)val);
 	    }
 	    if(asRaw==true)
@@ -1798,5 +1811,5 @@
 	      else{
 		map* tt=getMap(request_inputs,"ResponseDocument");
-		char* tmp=strdup(tt->value);
+		char* tmp=zStrdup(tt->value);
 		free(tt->value);
 		tt->value=(char*)malloc((strlen(tmp)+strlen((char*)val)+1)*sizeof(char));
@@ -1820,5 +1833,5 @@
 		return errorException(m, _("Unable to allocate memory."), "InternalError");
 	      }
-	      tmpmaps->name=strdup("missingIndetifier");
+	      tmpmaps->name=zStrdup("missingIndetifier");
 	      tmpmaps->content=createMap((char*)cur1->name,(char*)val);
 	      tmpmaps->next=NULL;
@@ -1869,5 +1882,5 @@
 		    return errorException(m, _("Unable to allocate memory."), "InternalError");
 		  }
-		  tmpmaps->name=strdup((char*)val);
+		  tmpmaps->name=zStrdup((char*)val);
 		  tmpmaps->content=NULL;
 		  tmpmaps->next=NULL;
@@ -1876,5 +1889,5 @@
 		  if(tmpmaps->name!=NULL)
 		    free(tmpmaps->name);
-		  tmpmaps->name=strdup((char*)val);;
+		  tmpmaps->name=zStrdup((char*)val);;
 		}
 		xmlFree(val);
@@ -1892,5 +1905,5 @@
 		    return errorException(m, _("Unable to allocate memory."), "InternalError");
 		  }
-		  tmpmaps->name=strdup("missingIndetifier");
+		  tmpmaps->name=zStrdup("missingIndetifier");
 		  tmpmaps->content=createMap((char*)cur2->name,(char*)val);
 		  tmpmaps->next=NULL;
@@ -2125,11 +2138,32 @@
   int cpid=getpid();
 
+  /**
+   * Initialize the specific [lenv] section which contains runtime variables:
+   * 
+   *  - usid : it is an unique identification number 
+   *  - sid : it is the process idenfitication number (OS)
+   *  - status : value between 0 and 100 to express the  completude of 
+   * the operations of the running service 
+   *  - message : is a string where you can store error messages, in case 
+   * service is failing, or o provide details on the ongoing operation.
+   *  - cwd : is the current working directory
+   *  - soap : is a boolean value, true if the request was contained in a SOAP 
+   * Envelop 
+   *  - sessid : string storing the session identifier (only when cookie is 
+   * used)
+   *  - cgiSid : only defined on Window platforms (for being able to identify 
+   * the created process)
+   *
+   */
   maps *_tmpMaps=(maps*)malloc(MAPS_SIZE);
-  _tmpMaps->name=strdup("lenv");
+  _tmpMaps->name=zStrdup("lenv");
   char tmpBuff[100];
+  sprintf(tmpBuff,"%i",(cpid+(int)time(NULL)));
+  _tmpMaps->content=createMap("usid",tmpBuff);
+  _tmpMaps->next=NULL;
   sprintf(tmpBuff,"%i",cpid);
-  _tmpMaps->content=createMap("sid",tmpBuff);
-  _tmpMaps->next=NULL;
+  addToMap(_tmpMaps->content,"sid",tmpBuff);
   addToMap(_tmpMaps->content,"status","0");
+  addToMap(_tmpMaps->content,"message",_("No message provided"));
   addToMap(_tmpMaps->content,"cwd",ntmp);
   map* ltmp=getMap(request_inputs,"soap");
@@ -2140,10 +2174,10 @@
   if(cgiCookie!=NULL && strlen(cgiCookie)>0){
     int hasValidCookie=-1;
-    char *tcook=strdup(cgiCookie);
+    char *tcook=zStrdup(cgiCookie);
     char *tmp=NULL;
     int hasVal=-1;
     map* testing=getMapFromMaps(m,"main","cookiePrefix");
     if(testing==NULL){
-      tmp=strdup("ID=");
+      tmp=zStrdup("ID=");
     }else{
       tmp=(char*)malloc((strlen(testing->value)+2)*sizeof(char));
@@ -2158,5 +2192,5 @@
 	  if(tcook!=NULL)
 	    free(tcook);
-	  tcook=strdup(token);
+	  tcook=zStrdup(token);
 	  hasValidCookie=1;
 	}
@@ -2165,5 +2199,5 @@
     }else{
       if(strstr(cgiCookie,"=")!=NULL && strcasestr(cgiCookie,tmp)!=NULL){
-	tcook=strdup(cgiCookie);
+	tcook=zStrdup(cgiCookie);
 	hasValidCookie=1;
       }
