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;
       }
