Index: /trunk/zoo-project/zoo-kernel/Makefile.in
===================================================================
--- /trunk/zoo-project/zoo-kernel/Makefile.in	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/Makefile.in	(revision 490)
@@ -92,5 +92,5 @@
 	g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
 
-zoo_loader.cgi: zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}
+zoo_loader.cgi: version.h zoo_loader.c zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}
 	g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
 	g++  ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
Index: /trunk/zoo-project/zoo-kernel/main_conf_read.y
===================================================================
--- /trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 490)
@@ -13,5 +13,4 @@
 static char* curr_key;
 static int debug=0;
-using namespace std;
 
 extern void crerror(const char *s);
Index: /trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.h	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service.h	(revision 490)
@@ -61,7 +61,11 @@
 #include <string.h>
 #ifndef WIN32
+#ifndef bool
 #define bool int
+#endif
+#ifndef true
 #define true 1
 #define false -1
+#endif
 #else
   //#include <stdbool.h>
@@ -422,8 +426,8 @@
     if(hasKey(m,n)==false){
       map* _cursor=m;
-      if(_cursor->next!=NULL){
-	addToMap(_cursor->next,n,v);
-      }else
-	_cursor->next=createMap(n,v);
+      while(_cursor->next!=NULL){
+	_cursor=_cursor->next;
+      }
+      _cursor->next=createMap(n,v);
     }
     else{
@@ -478,10 +482,11 @@
   }
 
-  static map* getMapOrFill(map** m,const char *key,char* value){
+  static map* getMapOrFill(map** m,const char *key,const char* value){
     map* tmp=*m;
     map* tmpMap=getMap(tmp,key);
     if(tmpMap==NULL){
-      if(tmp!=NULL)
-	addToMap(*m,key,value);
+      if(tmp!=NULL){
+	addToMap((*m),key,value);
+      }
       else
 	(*m)=createMap(key,value);
@@ -580,5 +585,5 @@
   }
 
-  static map* getMapArray(map* m,char* key,int index){
+  static map* getMapArray(map* m,const char* key,int index){
     char tmp[1024];
     if(index>0)
@@ -659,5 +664,4 @@
     addToMap(_cursor->content,"length",tmpLen);
     int i=0;
-    map* tmpSizeI=getMap(tmp->content,tmpV[i]);
     for(i=0;i<8;i++){
       map* tmpVI=getMap(tmp->content,tmpV[i]);
@@ -887,5 +891,4 @@
 
   static void dumpServiceAsYAML(service* s){
-    int level=0;
     int i;
     fprintf(stderr,"# %s\n\n",s->name);
@@ -905,9 +908,9 @@
     }
     if(s->inputs!=NULL){
-      fprintf(stderr,"\ninputs:\n",s->name);
+      fprintf(stderr,"\ninputs:\n");
       dumpElementsAsYAML(s->inputs);
     }
     if(s->outputs!=NULL){
-      fprintf(stderr,"\noutputs:\n",s->name);
+      fprintf(stderr,"\noutputs:\n");
       dumpElementsAsYAML(s->outputs);
     }
Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 490)
@@ -181,9 +181,8 @@
 
 void unhandleStatus(maps *conf){
-  int shmid,i;
+  int shmid;
   key_t key;
   void *shm;
   struct shmid_ds shmids;
-  char *s,*s1;
   map *tmpMap=getMapFromMaps(conf,"lenv","sid");
   if(tmpMap!=NULL){
@@ -207,5 +206,5 @@
 
 int _updateStatus(maps *conf){
-  int shmid,i;
+  int shmid;
   key_t key;
   char *shm,*s,*s1;
@@ -247,8 +246,7 @@
 
 char* getStatus(int pid){
-  int shmid,i;
+  int shmid;
   key_t key;
   void *shm;
-  char *s;
   key=pid;
   if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
@@ -265,5 +263,5 @@
     }
   }
-  return "-1";
+  return (char*)"-1";
 }
 
@@ -277,9 +275,7 @@
   jsval *argv = JS_ARGV(cx,argv1);
   JS_MaybeGC(cx);
-  char *sid;
   int istatus=0;
   char *status=NULL;
   maps *conf;
-  int i=0;
   if(argc>2){
 #ifdef JS_DEBUG
@@ -385,5 +381,4 @@
 #endif
   int currId=-1;
-  int currNode=-1;
   if(nbNs==0){
     nbNs++;
@@ -419,4 +414,22 @@
   nbNs=0;
 }
+
+
+int zooXmlAddDoc(const char* value){
+  int currId=0;
+  nbDocs++;
+  currId=nbDocs-1;
+  iDocs[currId]=xmlParseMemory(value,strlen(value));
+  return currId;
+}
+
+void zooXmlCleanupDocs(){
+  int j;
+  for(j=nbDocs-1;j>=0;j--){
+    xmlFreeDoc(iDocs[j]);
+  }
+  nbDocs=0;
+}
+
 
 xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){
@@ -447,7 +460,5 @@
 
   xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
-  xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
-  xmlChar *xmlbuff;
-  int buffersize;
+  xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6;
   /**
    * Create the document and its temporary root.
@@ -486,5 +497,5 @@
   if(tmp4!=NULL){
     map* tmp2=tmp4->content;
-    char *orderedFields[5];
+    const char *orderedFields[5];
     orderedFields[0]="Title";
     orderedFields[1]="Abstract";
@@ -555,5 +566,5 @@
   if(tmp4!=NULL){
     map* tmp2=tmp4->content;
-    char *tmpAddress[6];
+    const char *tmpAddress[6];
     tmpAddress[0]="addressDeliveryPoint";
     tmpAddress[1]="addressCity";
@@ -562,8 +573,8 @@
     tmpAddress[4]="addressCountry";
     tmpAddress[5]="addressElectronicMailAddress";
-    char *tmpPhone[2];
+    const char *tmpPhone[2];
     tmpPhone[0]="phoneVoice";
     tmpPhone[1]="phoneFacsimile";
-    char *orderedFields[12];
+    const char *orderedFields[12];
     orderedFields[0]="providerName";
     orderedFields[1]="providerSite";
@@ -608,8 +619,6 @@
 		  for(j=0;j<2;j++)
 		    if(strcasecmp(tmp2->name,tmpPhone[j])==0){
-		      char *toto=NULL;
-		      char *toto1=tmp2->name;
-		      toto=strstr(toto1,"Phone");
-		      nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
+		      char *tmp4=tmp2->name;
+		      nc1 = xmlNewNode(ns_ows, BAD_CAST tmp4+5);
 		      xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
 		      xmlAddChild(nc5,nc1);
@@ -621,8 +630,6 @@
 		    for(j=0;j<6;j++)
 		      if(strcasecmp(tmp2->name,tmpAddress[j])==0){
-			char *toto=NULL;
-			char *toto1=tmp2->name;
-			toto=strstr(toto1,"Address");
-			nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
+			char *tmp4=tmp2->name;
+			nc1 = xmlNewNode(ns_ows, BAD_CAST tmp4+7);
 			xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
 			xmlAddChild(nc6,nc1);
@@ -799,5 +806,5 @@
 void printGetCapabilitiesForProcess(maps* m,xmlNodePtr nc,service* serv){
   xmlNsPtr ns,ns_ows,ns_xlink;
-  xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
+  xmlNodePtr n=NULL,nc1,nc2;
   /**
    * Initialize or get existing namspaces
@@ -810,5 +817,4 @@
   ns_xlink=usedNs[xlinkId];
 
-  int cursor=0;
   map* tmp1;
   if(serv->content!=NULL){
@@ -833,14 +839,11 @@
 xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,const char* service,maps* m){
 
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
-  xmlNodePtr n,nr;
-  xmlChar *xmlbuff;
-  int buffersize;
+  xmlNsPtr ns,ns_xsi;
+  xmlNodePtr n;
 
   int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps");
   ns=usedNs[wpsId];
   n = xmlNewNode(ns, BAD_CAST "ProcessDescriptions");
-  int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
-  ns_ows=usedNs[owsId];
+  zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
   xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
   zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
@@ -860,8 +863,7 @@
 
 void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv){
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
-  xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
-
-  char tmp[256];
+  xmlNsPtr ns,ns_ows,ns_xlink;
+  xmlNodePtr n,nc1;
+
   n=nc;
   
@@ -874,5 +876,5 @@
 
   nc = xmlNewNode(NULL, BAD_CAST "ProcessDescription");
-  char *tmp4[3];
+  const char *tmp4[3];
   tmp4[0]="processVersion";
   tmp4[1]="storeSupported";
@@ -916,5 +918,5 @@
     nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs");
     elements* e=serv->inputs;
-    printFullDescription(e,"Input",ns_ows,nc1);
+    printFullDescription(1,e,"Input",ns_ows,nc1);
     xmlAddChild(nc,nc1);
   }
@@ -922,5 +924,5 @@
   nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs");
   elements* e=serv->outputs;
-  printFullDescription(e,"Output",ns_ows,nc1);
+  printFullDescription(0,e,"Output",ns_ows,nc1);
   xmlAddChild(nc,nc1);
 
@@ -929,6 +931,6 @@
 }
 
-void printFullDescription(elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){
-  char *orderedFields[13];
+void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){
+  const char *orderedFields[13];
   orderedFields[0]="mimeType";
   orderedFields[1]="encoding";
@@ -1001,5 +1003,4 @@
     iotype* _tmp=e->defaults;
     int datatype=0;
-    bool hasDefault=false;
     bool hasUOM=false;
     bool hasUOM1=false;
@@ -1079,5 +1080,5 @@
 	     * RangeClosure: Table 47 OGC Web Services Common Standard
 	     */
-	    char *tmp="closed";
+	    const char *tmp="closed";
 	    if(orig[0]=='[' && orig[strlen(orig)-1]=='[')
 	      tmp="closed-open";
@@ -1146,5 +1147,5 @@
 	    tmp0=getMap(tmp1,"rangeClosure");
 	    if(tmp0!=NULL){
-	      char *tmp="closed";
+	      const char *tmp="closed";
 	      if(strcasecmp(tmp0->value,"co")==0)
 		tmp="closed-open";
@@ -1190,6 +1191,4 @@
     
       
-    int avcnt=0;
-    int dcnt=0;
     int oI=0;
     for(oI=0;oI<13;oI++)
@@ -1247,5 +1246,5 @@
 
       map* metadata=e->metadata;
-      xmlNodePtr n;
+      xmlNodePtr n=NULL;
       int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
       xmlNsPtr ns_xlink=usedNs[xlinkId];
@@ -1353,5 +1352,5 @@
     }
 
-    if(datatype==1 &&
+    if(in>0 && datatype==1 &&
        getMap(_tmp->content,"AllowedValues")==NULL &&
        getMap(_tmp->content,"range")==NULL &&
@@ -1389,9 +1388,7 @@
 
 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){
-  xmlNsPtr ns,ns1,ns_ows,ns_xlink,ns_xsi;
-  xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor;
+  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
+  xmlNodePtr nr,n,nc,nc1=NULL,nc3;
   xmlDocPtr doc;
-  xmlChar *xmlbuff;
-  int buffersize;
   time_t time1;  
   time(&time1);
@@ -1574,5 +1571,4 @@
   if(lineage!=NULL && strcasecmp(lineage->value,"true")==0){
     nc = xmlNewNode(ns, BAD_CAST "DataInputs");
-    int i;
     maps* mcursor=inputs;
     elements* scursor=NULL;
@@ -1727,5 +1723,5 @@
 
 void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,const char* type){
-  xmlNodePtr nc1,nc2,nc3;
+  xmlNodePtr nc1;
   nc1=xmlNewNode(ns_wps, BAD_CAST type);
   map *tmp=NULL;  
@@ -1774,6 +1770,4 @@
   xmlAddChild(nc1,nc2);
   xmlAddChild(nc,nc1);
-  // Extract Title required to be first element in the ZCFG file !
-  bool isTitle=TRUE;
   if(e!=NULL)
     tmp=getMap(e->content,"Title");
@@ -1836,18 +1830,20 @@
 	 strcasecmp(tmp->name,"schema")==0 ||
 	 strcasecmp(tmp->name,"datatype")==0 ||
-	 strcasecmp(tmp->name,"uom")==0)
+	 strcasecmp(tmp->name,"uom")==0){
 #ifdef USE_MS
 	if(testMap==NULL || (testMap!=NULL && strncasecmp(testMap->value,"text/xml",8)==0)){
 #endif
-	xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	  xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
 #ifdef USE_MS
 	}
-      else
-	if(strcasecmp(tmp->name,"mimeType")==0)
-	  if(testMap!=NULL)
-	    xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST testMap->value);
-	  else 
-	    xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
-#endif
+	else
+	  if(strcasecmp(tmp->name,"mimeType")==0){
+	    if(testMap!=NULL)
+	      xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST testMap->value);
+	    else 
+	      xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	  }
+#endif
+      }
       tmp=tmp->next;
       xmlAddChild(nc2,nc3);
@@ -1897,8 +1893,8 @@
       if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0)
 	 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 ||
-			    (strncmp(tmp2->value,"application/",12)==0) &&
-			    strncmp(tmp2->value,"application/json",16)!=0&&
-			    strncmp(tmp2->value,"application/x-javascript",24)!=0&&
-			    strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0)
+			    (strncmp(tmp2->value,"application/",12)==0 &&
+			     strncmp(tmp2->value,"application/json",16)!=0&&
+			     strncmp(tmp2->value,"application/x-javascript",24)!=0&&
+			     strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0))
 	     )) {
 	map* rs=getMap(m->content,"size");
@@ -1906,5 +1902,5 @@
 	if(rs==NULL){
 	  char tmp1[1024];
-	  sprintf(tmp1,"%d",strlen(tmp3->value));
+	  sprintf(tmp1,"%u",strlen(tmp3->value));
 	  rs=createMap("size",tmp1);
 	  isSized=false;
@@ -1924,6 +1920,6 @@
 	  if(strncmp(tmp2->value,"text/xml",8)==0 ||
 	     strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){
-	    xmlDocPtr doc =
-	      xmlParseMemory(tmp3->value,strlen(tmp3->value));
+	    int li=zooXmlAddDoc(tmp3->value);
+	    xmlDocPtr doc = iDocs[li];
 	    xmlNodePtr ir = xmlDocGetRootElement(doc);
 	    xmlAddChild(nc3,ir);
@@ -1959,5 +1955,5 @@
 	 strcasecmp(tmp->name,"schema")==0 ||
 	 strcasecmp(tmp->name,"datatype")==0 ||
-	 strcasecmp(tmp->name,"uom")==0)
+	 strcasecmp(tmp->name,"uom")==0){
 #ifdef USE_MS
 	if(testMap!=NULL  && strncasecmp(testMap->value,"text/xml",8)!=0){
@@ -1967,5 +1963,6 @@
 	else
 #endif
-	xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	  xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+      }
       tmp=tmp->next;
       xmlAddChild(nc2,nc3);
@@ -1983,5 +1980,5 @@
   xmlAddChild(root,nc2);
   map* tmp=amap;
-  char *tmp2[2];
+  const char *tmp2[2];
   tmp2[0]="Title";
   tmp2[1]="Abstract";
@@ -2004,8 +2001,8 @@
     }
     else
-      return "UTF-8";
+      return (char*)"UTF-8";
   }
   else
-    return "UTF-8";  
+    return (char*)"UTF-8";  
 }
 
@@ -2017,8 +2014,8 @@
     }
     else
-      return "1.0.0";
+      return (char*)"1.0.0";
   }
   else
-    return "1.0.0";
+    return (char*)"1.0.0";
 }
 
@@ -2035,5 +2032,5 @@
   maps* tmpMap=getMaps(m,"main");
   char *encoding=getEncoding(tmpMap);
-  char *exceptionCode;
+  const char *exceptionCode;
   
   map* tmp=getMap(s,"code");
@@ -2087,10 +2084,6 @@
 xmlNodePtr createExceptionReportNode(maps* m,map* s,int use_ns){
   
-  int buffersize;
-  xmlChar *xmlbuff;
-  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
-  xmlNodePtr n,nc,nc1,nc2;
-
-  maps* tmpMap=getMaps(m,"main");
+  xmlNsPtr ns,ns_xsi;
+  xmlNodePtr n,nc,nc1;
 
   int nsid=zooXmlAddNs(NULL,"http://www.opengis.net/ows","ows");
@@ -2101,5 +2094,5 @@
   n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
   if(use_ns==1){
-    ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",NULL);
+    xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",NULL);
     int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
     ns_xsi=usedNs[xsiId];
@@ -2126,5 +2119,4 @@
   tmp=getMap(s,"text");
   nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
-  nc2=NULL;
   if(tmp!=NULL){
     xmlNodeSetContent(nc1, BAD_CAST tmp->value);
@@ -2154,5 +2146,5 @@
   if(tmpSess!=NULL){
     map *_tmp=getMapFromMaps(m,"lenv","cookie");
-    char* sessId;
+    char* sessId=NULL;
     if(_tmp!=NULL){
       printf("Set-Cookie: %s; HttpOnly\r\n",_tmp->value);
@@ -2493,5 +2485,5 @@
       if(type==0){
 	map* tmpMapMinO=getMap(tmpInputs->content,"minOccurs");
-	if(tmpMapMinO!=NULL)
+	if(tmpMapMinO!=NULL){
 	  if(atoi(tmpMapMinO->value)>=1){
 	    freeMaps(&tmpMaps2);
@@ -2505,16 +2497,19 @@
 	      addToMap(tmpMaps2->content,"minOccurs",tmpMapMinO->value);
 	  }
+	}
 	map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs");
-	if(tmpMaxO!=NULL)
+	if(tmpMaxO!=NULL){
 	  if(tmpMaps2->content==NULL)
 	    tmpMaps2->content=createMap("maxOccurs",tmpMaxO->value);
 	  else
 	    addToMap(tmpMaps2->content,"maxOccurs",tmpMaxO->value);
+	}
 	map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes");
-	if(tmpMaxMB!=NULL)
+	if(tmpMaxMB!=NULL){
 	  if(tmpMaps2->content==NULL)
 	    tmpMaps2->content=createMap("maximumMegabytes",tmpMaxMB->value);
 	  else
 	    addToMap(tmpMaps2->content,"maximumMegabytes",tmpMaxMB->value);
+	}
       }
 
@@ -2572,9 +2567,10 @@
 	}
 	map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes");
-	if(tmpMaxMB!=NULL)
+	if(tmpMaxMB!=NULL){
 	  if(tmpMaps->content==NULL)
 	    tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value);
 	  else
 	    addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value);
+	}
 	/**
 	 * Parsing BoundingBoxData, fill the following map and then add it to
@@ -2746,5 +2742,5 @@
 void printBoundingBox(xmlNsPtr ns_ows,xmlNodePtr n,map* boundingbox){
 
-  xmlNodePtr bb,lw,uc;
+  xmlNodePtr lw=NULL,uc=NULL;
 
   map* tmp=getMap(boundingbox,"value");
@@ -2876,5 +2872,5 @@
     fprintf(stderr,"MIMETYPE: %s\n",mimeType);
 #endif
-    fwrite(mimeType,sizeof(char),strlen(mimeType),fo);
+    fwrite(mimeType,1,strlen(mimeType),fo);
     fclose(fo);
 
@@ -2914,6 +2910,5 @@
   char* cached=isInCache(*m,url);
   char *mimeType=NULL;
-  int fsize;
-  int hasF=-1;
+  int fsize=0;
   if(cached!=NULL){
     struct stat f_status;
@@ -2922,5 +2917,5 @@
       fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
       FILE* f=fopen(cached,"rb");
-      int len=fread(fcontent,f_status.st_size,1,f);
+      fread(fcontent,f_status.st_size,1,f);
       fsize=f_status.st_size;
       fcontent[fsize]=0;
@@ -2932,5 +2927,5 @@
       mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1));
       FILE* f=fopen(cached,"rb");
-      int len=fread(mimeType,f_status.st_size,1,f);
+      fread(mimeType,f_status.st_size,1,f);
       mimeType[f_status.st_size]=0;
       fclose(f);
@@ -2970,9 +2965,7 @@
   if(cached==NULL)
     addToCache(*m,url,fcontent,mimeType,fsize);
-  else{
-    free(fcontent);
-    free(mimeType);
-    free(cached);
-  }
+  free(fcontent);
+  free(mimeType);
+  free(cached);
   return 0;
 }
@@ -2992,4 +2985,5 @@
 }
 
+
 char *readVSIFile(maps* conf,const char* dataSource){
     VSILFILE * fichier=VSIFOpenL(dataSource,"rb");
@@ -3004,5 +2998,6 @@
     }
     char *res1=(char *)malloc(file_status.st_size*sizeof(char));
-    VSIFReadL(res1,1,(file_status.st_size)*sizeof(char),fichier);
+    VSIFReadL(res1,1,file_status.st_size*sizeof(char),fichier);
+    res1[file_status.st_size-1]=0;
     VSIFCloseL(fichier);
     VSIUnlink(dataSource);
@@ -3065,5 +3060,4 @@
 }
 
-
 int updateStatus( maps* conf, const int percentCompleted, const char* message ){
   char tmp[4];
@@ -3098,5 +3092,5 @@
     tmp->value=(char*) malloc((numberOfBytes+1)*sizeof(char));
     memcpy(tmp->value,data,numberOfBytes);
-    sprintf(size,"%d",numberOfBytes);
+    sprintf(size,"%lu",numberOfBytes);
     setMapInMaps(outputs,parameterName,"size",size);
   }
Index: /trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service_internal.h	(revision 490)
@@ -57,4 +57,6 @@
 #endif
 #include <dirent.h>
+#include "ulinet.h"
+
 #include "service.h"
 #include <openssl/sha.h>
@@ -64,6 +66,4 @@
 #include <openssl/bio.h>
 #include <openssl/buffer.h>
-
-#include "ulinet.h"
 
 extern   int conf_read(const char*,maps*);
@@ -88,5 +88,7 @@
   static xmlNsPtr usedNs[10];
   static char* nsName[10];
+  static xmlDocPtr iDocs[10];
   static int nbNs=0;
+  static int nbDocs=0;
 
   int getServiceFromYAML(maps*,char*,service**,char *name);
@@ -112,4 +114,7 @@
   int zooXmlAddNs(xmlNodePtr,const char*,const char*);
   void zooXmlCleanupNs();
+
+  int zooXmlAddDoc(xmlNodePtr,const char*,const char*);
+  void zooXmlCleanupDocs();
   
   void printExceptionReportResponse(maps*,map*);
@@ -120,5 +125,5 @@
   xmlNodePtr printDescribeProcessHeader(xmlDocPtr,const char*,maps*);
   void printDescribeProcessForProcess(maps*,xmlNodePtr,service*);
-  void printFullDescription(elements*,const char*,xmlNsPtr,xmlNodePtr);
+  void printFullDescription(int,elements*,const char*,xmlNsPtr,xmlNodePtr);
   void printDocument(maps*,xmlDocPtr,int);
   void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*);
Index: /trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 490)
@@ -129,12 +129,14 @@
   if(strncasecmp(rformat->value,"image/tiff",10)==0)
     proto=2;
-  if(protoMap!=NULL)
+  if(protoMap!=NULL){
     if(strncasecmp(protoMap->value,"WMS",3)==0)
       proto=0;
-    else if(strncasecmp(protoMap->value,"WFS",3)==0)
-      proto=1;
-    else 
-      proto=2;
-  
+    else{
+      if(strncasecmp(protoMap->value,"WFS",3)==0)
+	proto=1;
+      else 
+	proto=2;
+    }
+  }
   char *protoVersion=options[proto][1];
   if(proto==1){
@@ -278,5 +280,5 @@
       msLoadProjectionStringEPSG(&myLayer->projection,msSrs->value);
       char tmpSrs[128];
-      sprintf(tmpSrs,"%s EPSG:4326 EPSG:900913",msSrs);
+      sprintf(tmpSrs,"%s EPSG:4326 EPSG:900913",msSrs->value);
       msInsertHashTable(&(m->web.metadata),"ows_srs",tmpSrs);
       msInsertHashTable(&(myLayer->metadata),"ows_srs",tmpSrs);
@@ -574,7 +576,4 @@
       msInsertHashTable(&(myLayer->metadata), "ows_srs", "EPSG:4326 EPSG:900913");
     }
-
-    map* crs=getMap(output->content,"crs");
-    map* isGeo=getMap(output->content,"crs_isGeographic");
 
     OGREnvelope oExt;
Index: /trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 490)
@@ -107,5 +107,5 @@
   Py_DECREF(tmp);
 
-  ZooError = PyErr_NewException("zoo.error", NULL, NULL);
+  ZooError = PyErr_NewException((char*)"zoo.error", NULL, NULL);
   Py_INCREF(ZooError);
   PyModule_AddObject(module, "error", ZooError);
@@ -138,5 +138,5 @@
   }
   else{
-    python_path=".";
+    python_path=(char*)".";
   }
   tmp=NULL;
@@ -243,5 +243,5 @@
 	if(PyString_Check(trace)){
 	  char *tpbt=zStrdup(pbt);
-	  sprintf(pbt,"%s\n%s\0",tpbt,PyString_AsString(trace));
+	  sprintf(pbt,"%s\n%s",tpbt,PyString_AsString(trace));
 	  free(tpbt);
 	}
@@ -261,5 +261,5 @@
 	  sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s",tpbt,PyString_AsString(trace));
 	else
-	  sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations. %s",tpbt);
+	  sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations.",tpbt);
 	free(tpbt);
 	map* err=createMap("text",pbt);
@@ -492,5 +492,5 @@
       tmpR->value[size]=0;
       char sin[1024];
-      sprintf(sin,"%d",size);
+      sprintf(sin,"%ld",size);
       addToMap(res,"size",sin);
     }else{
@@ -546,8 +546,8 @@
   /* now update the map */
   {
-    PyObject* lenv = PyMapping_GetItemString(confdict, "lenv");
+    PyObject* lenv = PyMapping_GetItemString(confdict, (char *)"lenv");
     if (lenv && PyMapping_Check(lenv)){
       PyObject* valobj = PyString_FromString(status);
-      PyMapping_SetItemString(lenv, "status", valobj);
+      PyMapping_SetItemString(lenv, (char *)"status", valobj);
       Py_DECREF(valobj);
     }
Index: /trunk/zoo-project/zoo-kernel/service_yaml.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_yaml.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/service_yaml.c	(revision 490)
@@ -144,11 +144,11 @@
     case YAML_SCALAR_TOKEN:  
       if(ttype==0){
-	cur_key=zStrdup(token.data.scalar.value);
+	cur_key=zStrdup((char *)token.data.scalar.value);
       }
       if(ttype==1){
 	if(current_content==NULL){
-	  current_content=createMap(cur_key,token.data.scalar.value);
+	  current_content=createMap(cur_key,(char *)token.data.scalar.value);
 	}else{
-	  addToMap(current_content,cur_key,token.data.scalar.value);
+	  addToMap(current_content,cur_key,(char *)token.data.scalar.value);
 	}
 	free(cur_key);
@@ -156,5 +156,5 @@
       }
 
-      if(ttype==0 && blevel==0 && level==0 && strcasecmp(token.data.scalar.value,"MetaData")==0 && blevel==0){
+      if(ttype==0 && blevel==0 && level==0 && strcasecmp((char *)token.data.scalar.value,"MetaData")==0 && blevel==0){
 	addMapToMap(&my_service->content,current_content);
 #ifdef DEBUG_YAML
@@ -166,5 +166,5 @@
 	wait_metadata=1;
       }
-      if(ttype==0 && blevel>0 && level>0 && strcasecmp(token.data.scalar.value,"MetaData")==0){
+      if(ttype==0 && blevel>0 && level>0 && strcasecmp((char *)token.data.scalar.value,"MetaData")==0){
 	if(current_element->content==NULL && current_content!=NULL)
 	  addMapToMap(&current_element->content,current_content);
@@ -178,5 +178,5 @@
 	wait_metadata=1;
       }
-      if(ttype==0 && strcasecmp(token.data.scalar.value,"inputs")==0 && blevel==0){
+      if(ttype==0 && strcasecmp((char *)token.data.scalar.value,"inputs")==0 && blevel==0){
 	if(wait_metadata>0){
 	  addMapToMap(&my_service->metadata,current_content);
@@ -196,5 +196,5 @@
 	level++;
       }
-      if(ttype==0 && strcasecmp(token.data.scalar.value,"outputs")==0 && blevel==1){
+      if(ttype==0 && strcasecmp((char *)token.data.scalar.value,"outputs")==0 && blevel==1){
 	level++;
 #ifdef DEBUG_YAML
@@ -229,8 +229,8 @@
 	}
       }
-      if(level==1 && strcasecmp(token.data.scalar.value,"default")==0){
+      if(level==1 && strcasecmp((char *)token.data.scalar.value,"default")==0){
 	ilevel=0;
       }
-      if(level==1 && strcasecmp(token.data.scalar.value,"supported")==0){
+      if(level==1 && strcasecmp((char *)token.data.scalar.value,"supported")==0){
 #ifdef DEBUG_YAML
 	dumpMap(current_content);
@@ -271,8 +271,11 @@
 
 
-      if(strncasecmp(token.data.scalar.value,"ComplexData",11)==0 || strncasecmp(token.data.scalar.value,"LiteralData",10)==0
-	 || strncasecmp(token.data.scalar.value,"ComplexOutput",13)==0 || strncasecmp(token.data.scalar.value,"LiteralOutput",12)==0
-	 || strncasecmp(token.data.scalar.value,"BoundingBoxOutput",13)==0 || strncasecmp(token.data.scalar.value,"BoundingBoxData",12)==0){
-	current_element->format=zStrdup(token.data.scalar.value);
+      if(strncasecmp((char *)token.data.scalar.value,"ComplexData",11)==0 || 
+	 strncasecmp((char *)token.data.scalar.value,"LiteralData",10)==0 || 
+	 strncasecmp((char *)token.data.scalar.value,"ComplexOutput",13)==0 || 
+	 strncasecmp((char *)token.data.scalar.value,"LiteralOutput",12)==0 || 
+	 strncasecmp((char *)token.data.scalar.value,"BoundingBoxOutput",13)==0 || 
+	 strncasecmp((char *)token.data.scalar.value,"BoundingBoxData",12)==0){
+	current_element->format=zStrdup((char *)token.data.scalar.value);
 	free(cur_key);
 	cur_key=NULL;
@@ -324,5 +327,5 @@
 	plevel=level;
 	current_element=(elements*)malloc(ELEMENTS_SIZE);
-	current_element->name=strdup(token.data.scalar.value);
+	current_element->name=zStrdup((char *)token.data.scalar.value);
 	current_element->content=NULL;
 	current_element->metadata=NULL;
@@ -367,5 +370,5 @@
 	plevel=level;
 	current_element=(elements*)malloc(ELEMENTS_SIZE);
-	current_element->name=strdup(token.data.scalar.value);
+	current_element->name=zStrdup((char *)token.data.scalar.value);
 	current_element->content=NULL;
 	current_element->metadata=NULL;
Index: /trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/ulinet.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/ulinet.c	(revision 490)
@@ -27,4 +27,5 @@
 
 #define _ULINET
+#define MAX_WAIT_MSECS 180*1000 /* Wait max. 180 seconds */
 #include "ulinet.h"
 #include <assert.h>
@@ -162,34 +163,12 @@
 #endif
 
-HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){
-  
+HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){  
   HINTERNET ret;
-  struct MemoryStruct header;
+  ret.handle=curl_multi_init();
+  ret.ihandle=NULL;
   ret.hasCacheFile=0;
   ret.nDataAlloc = 0;
   ret.mimeType = NULL;
-
-  curl_global_init(CURL_GLOBAL_ALL|CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32);
-  ret.handle=curl_easy_init();
-
-  curl_easy_setopt(ret.handle, CURLOPT_COOKIEFILE, "ALL");
-#ifndef TIGER
-  curl_easy_setopt(ret.handle, CURLOPT_COOKIELIST, "ALL");
-#endif
-  curl_easy_setopt(ret.handle, CURLOPT_USERAGENT, lpszAgent);
-  
-  curl_easy_setopt(ret.handle,CURLOPT_FOLLOWLOCATION,1);
-  curl_easy_setopt(ret.handle,CURLOPT_MAXREDIRS,3);
-  
-  header.memory=NULL;
-  header.size = 0;
-
-  curl_easy_setopt(ret.handle, CURLOPT_HEADERFUNCTION, header_write_data);
-  curl_easy_setopt(ret.handle, CURLOPT_WRITEHEADER, (void *)&header);
-
-#ifdef MSG_LAF_VERBOSE
-  curl_easy_setopt(ret.handle, CURLOPT_VERBOSE, 1);
-#endif
-
+  ret.agent=strdup(lpszAgent);
   return ret;
 }
@@ -206,7 +185,9 @@
     handle.nDataAlloc = handle.nDataLen = 0;
   }
+  if(handle.ihandle!=NULL)
+    curl_easy_cleanup(handle.ihandle);
   if(handle.handle)
-    curl_easy_cleanup(handle.handle);
-  curl_global_cleanup();
+    curl_multi_cleanup(handle.handle);
+  free(handle.agent);
 }
 
@@ -214,8 +195,33 @@
 
   char filename[255];
+  struct MemoryStruct header;
+
   hInternet.nDataLen = 0;
 
   hInternet.nDataAlloc = 0;
   hInternet.pabyData= NULL;
+
+  if(hInternet.ihandle!=NULL)
+    curl_easy_cleanup(hInternet.ihandle);
+  hInternet.ihandle=curl_easy_init( );
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIEFILE, "ALL");
+#ifndef TIGER
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIELIST, "ALL");
+#endif
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_USERAGENT, hInternet.agent);
+  
+  curl_easy_setopt(hInternet.ihandle,CURLOPT_FOLLOWLOCATION,1);
+  curl_easy_setopt(hInternet.ihandle,CURLOPT_MAXREDIRS,3);
+  
+  header.memory=NULL;
+  header.size = 0;
+
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_HEADERFUNCTION, header_write_data);
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEHEADER, (void *)&header);
+
+#ifdef MSG_LAF_VERBOSE
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_VERBOSE, 1);
+#endif
+
       
   switch(dwFlags)
@@ -223,6 +229,6 @@
     case INTERNET_FLAG_NO_CACHE_WRITE:    
       hInternet.hasCacheFile=-1;
-      curl_easy_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, write_data_into);
-      curl_easy_setopt(hInternet.handle, CURLOPT_WRITEDATA, &hInternet);
+      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEFUNCTION, write_data_into);
+      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEDATA, &hInternet);
       break;
     default:
@@ -236,6 +242,6 @@
     
       hInternet.hasCacheFile=1;
-      curl_easy_setopt(hInternet.handle, CURLOPT_WRITEFUNCTION, NULL);
-      curl_easy_setopt(hInternet.handle, CURLOPT_WRITEDATA, hInternet.file);
+      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEFUNCTION, NULL);
+      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEDATA, hInternet.file);
       hInternet.nDataLen=0;
       break;
@@ -250,18 +256,38 @@
 #endif
     //curl_easy_setopt(hInternet.handle,CURLOPT_COOKIE,lpszHeaders);
-    curl_easy_setopt(hInternet.handle,CURLOPT_POST,1);
+    curl_easy_setopt(hInternet.ihandle,CURLOPT_POST,1);
 #ifdef ULINET_DEBUG
     fprintf(stderr,"** (%s) %d **\n",lpszHeaders,dwHeadersLength);
-    curl_easy_setopt(hInternet.handle,CURLOPT_VERBOSE,1);
-#endif
-    curl_easy_setopt(hInternet.handle,CURLOPT_POSTFIELDS,lpszHeaders);
+    curl_easy_setopt(hInternet.ihandle,CURLOPT_VERBOSE,1);
+#endif
+    curl_easy_setopt(hInternet.ihandle,CURLOPT_POSTFIELDS,lpszHeaders);
     //curl_easy_setopt(hInternet.handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
     if(hInternet.header!=NULL)
-      curl_easy_setopt(hInternet.handle,CURLOPT_HTTPHEADER,hInternet.header);
-  }
-
-  curl_easy_setopt(hInternet.handle,CURLOPT_URL,lpszUrl);
-  curl_easy_perform(hInternet.handle);
-  curl_easy_getinfo(hInternet.handle,CURLINFO_CONTENT_TYPE,&hInternet.mimeType);
+      curl_easy_setopt(hInternet.ihandle,CURLOPT_HTTPHEADER,hInternet.header);
+  }
+
+  curl_easy_setopt(hInternet.ihandle,CURLOPT_URL,lpszUrl);
+
+  curl_multi_add_handle(hInternet.handle,hInternet.ihandle);
+  
+  int still_running=0;
+  int msgs_left=0;
+  do{
+    curl_multi_perform(hInternet.handle, &still_running);
+  }while(still_running);
+
+  CURLMsg *msg=NULL;
+  while ((msg = curl_multi_info_read(hInternet.handle, &msgs_left))) {
+    if (msg->msg == CURLMSG_DONE) {
+      CURL *eh=NULL;
+      eh = msg->easy_handle;
+      curl_easy_getinfo(eh,CURLINFO_CONTENT_TYPE,&hInternet.mimeType);
+    }
+    else {
+      fprintf(stderr, "error: after curl_multi_info_read(), CURLMsg=%d\n", msg->msg);
+    }
+  }
+  curl_multi_remove_handle(hInternet.handle, hInternet.ihandle);
+
 #ifdef ULINET_DEBUG
   fprintf(stderr,"DEBUG MIMETYPE: %s\n",hInternet.mimeType);
@@ -274,5 +300,5 @@
   memset(&CCookie[0],0,1024);
 #ifndef TIGER
-  curl_easy_setopt(hInternet.handle, CURLOPT_COOKIELIST, "ALL");
+  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIELIST, "ALL");
 #endif
   return 1;
Index: /trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/ulinet.h	(revision 490)
@@ -64,7 +64,9 @@
 
 typedef struct {
-  CURLSH *handle;
+  CURLM *handle;
+  CURL *ihandle;
   struct curl_slist *header;
   char* filename;
+  char *agent;
   FILE* file;
   size_t size;
Index: /trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 490)
@@ -54,5 +54,5 @@
 
 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
-int runRequest(map*);
+int runRequest(map**);
 
 using namespace std;
@@ -91,22 +91,23 @@
   if(strncmp(cgiContentType,"text/xml",8)==0 || 
      strncasecmp(cgiRequestMethod,"post",4)==0){
-    if(cgiContentLength==NULL){
-       cgiContentLength=0;
+    if(cgiContentLength==0){
        char *buffer=new char[2];
        char *res=NULL;
        int r=0;
        while((r=fread(buffer,sizeof(char),1,cgiIn))){
+	 buffer[1]=0;
 	 cgiContentLength+=r;
 	 if(res==NULL){
-	   res=(char*)malloc(1*sizeof(char));
+	   res=(char*)malloc(2*sizeof(char));
 	   sprintf(res,"%s",buffer);
 	 }
 	 else{
-	   res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
 	   char *tmp=zStrdup(res);
+	   res=(char*)realloc(res,(strlen(tmp)+2)*sizeof(char));
 	   sprintf(res,"%s%s",tmp,buffer);
 	   free(tmp);
 	 }
        }
+       delete[] buffer;
        if(res==NULL && (strQuery==NULL || strlen(strQuery)==0)){
 	 return errorException(NULL,"ZOO-Kernel failed to process your request cause the request was emtpty.","InternalError",NULL);
@@ -114,8 +115,10 @@
 	 if(strQuery==NULL || strlen(strQuery)==0)
 	   tmpMap=createMap("request",res);
-            }
+       }
+       if(res!=NULL)
+	 free(res);
     }else{
       char *buffer=new char[cgiContentLength+1];
-      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)>=0){
+      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)>0){
 	buffer[cgiContentLength]=0;
 	tmpMap=createMap("request",buffer);
@@ -146,5 +149,8 @@
 	  arrayStep++;
 	}
-	tmpMap=createMap("request",buffer);
+	if(tmpMap!=NULL)
+	  addToMap(tmpMap,"request",buffer);
+	else
+	  tmpMap=createMap("request",buffer);
       }
       delete[]buffer;
@@ -202,10 +208,4 @@
 #endif
      ){
-    /**
-     * First include the MetaPath and the ServiceProvider default parameters
-     * (which should be always available in GET params so in cgiQueryString)
-     */
-    char *str1;
-    str1=cgiQueryString;
     /**
      * Store the original XML request in xrequest map
@@ -232,4 +232,5 @@
 	    }
 	  }
+	  xmlXPathFreeObject(reqptr);
 	}
       }
@@ -239,10 +240,14 @@
       tval=NULL;
       tval = (char*) xmlGetProp(cur,BAD_CAST "service");
-      if(tval!=NULL)
+      if(tval!=NULL){
 	addToMap(tmpMap,"service",tval);
+	xmlFree(tval);
+      }
       tval=NULL;
       tval = (char*) xmlGetProp(cur,BAD_CAST "language");
-      if(tval!=NULL)
+      if(tval!=NULL){
 	addToMap(tmpMap,"language",tval);
+	xmlFree(tval);
+      }
       const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"};
       for(int j=0;j<3;j++){
@@ -256,4 +261,6 @@
 #endif
 	  if(req!=NULL && req->nodeNr==1){
+	    if(t1->value!=NULL)
+	      free(t1->value);
 	    t1->value=zStrdup(requests[j]);
 	    j=2;
@@ -272,9 +279,13 @@
 	tval=NULL;
 	tval = (char*) xmlGetProp(cur,BAD_CAST "version");
-	if(tval!=NULL)
+	if(tval!=NULL){
 	  addToMap(tmpMap,"version",tval);
+	  xmlFree(tval);
+	}
 	tval = (char*) xmlGetProp(cur,BAD_CAST "language");
-	if(tval!=NULL)
+	if(tval!=NULL){
 	  addToMap(tmpMap,"language",tval);
+	  xmlFree(tval);
+	}
 	xmlXPathObjectPtr idptr=extractFromDoc(doc,"/*/*[local-name()='Identifier']");
 	if(idptr!=NULL){
@@ -343,10 +354,11 @@
   if(strQuery!=NULL)
     free(strQuery);
-  runRequest(tmpMap);
+
+  runRequest(&tmpMap);
 
   /** 
    * Required but can't be made after executing a process using POST requests.
    */
-  if(strncasecmp(cgiRequestMethod,"post",4)!=0 && count(tmpMap)!=1 && tmpMap!=NULL){
+  if(/*strncasecmp(cgiRequestMethod,"post",4)!=0 && count(tmpMap)!=1 && */tmpMap!=NULL){
     freeMap(&tmpMap);
     free(tmpMap);
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 489)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 490)
@@ -221,5 +221,5 @@
       sprintf(prefix,"%s.",dp->d_name);
       
-      map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
+      //map* tmpMap=getMapFromMaps(m,"lenv",tmp1);
       
       int res;
@@ -467,4 +467,5 @@
 	  fprintf(stderr,"Function %s error %s\n",r_inputs->value,errstr);
 #endif
+	  *eres=-1;
 	  return;
 	}
@@ -661,7 +662,7 @@
 #endif
 
-int runRequest(map* request_inputs)
+int runRequest(map** inputs)
 {
-
+  
 #ifndef USE_GDB
   (void) signal(SIGSEGV,sig_handler);
@@ -674,6 +675,6 @@
 
   map* r_inputs=NULL;
+  map* request_inputs=*inputs;
   maps* m=NULL;
-
   char* REQUEST=NULL;
   /**
@@ -788,6 +789,8 @@
   if(request_inputs==NULL || r_inputs==NULL){ 
     errorException(m, _("Parameter <request> was not specified"),"MissingParameterValue","request");
-    freeMap(&request_inputs);
-    free(request_inputs);
+    if(count(request_inputs)==1){
+      freeMap(&request_inputs);
+      free(request_inputs);
+    }
     freeMaps(&m);
     free(m);
@@ -871,5 +874,4 @@
 
   if(strncasecmp(REQUEST,"GetCapabilities",15)==0){
-    struct dirent *dp;
 #ifdef DEBUG
     dumpMap(r_inputs);
@@ -1622,16 +1624,17 @@
 #endif
 		  if(hai==0){
-		    key=(char*)malloc((1+strlen((char*)val))*sizeof(char));
-		    snprintf(key,1+strlen((char*)val),"%s",(char*)val);
+		    key=zStrdup((char*)val);
 		  }else{
-		    has=(char*)malloc((3+strlen((char*)val)+strlen(key))*sizeof(char));
+		    has=(char*)malloc((4+xmlStrlen(val)+strlen(key))*sizeof(char));
 		    if(has == NULL){
 		      return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
 		    }
-		    snprintf(has,(3+strlen((char*)val)+strlen(key)),"%s: %s",key,(char*)val);
+		    snprintf(has,(3+xmlStrlen(val)+strlen(key)),"%s: %s",key,(char*)val);
+		    free(key);
 #ifdef POST_DEBUG
 		    fprintf(stderr,"%s\n",has);
 #endif
 		  }
+		  xmlFree(val);
 		}
 		hInternetP.header=curl_slist_append(hInternetP.header, has);
@@ -1647,5 +1650,5 @@
 		  fprintf(stderr,"Body part found !!!\n",(char*)cur3->content);
 #endif
-		  char *tmp=new char[cgiContentLength];
+		  char *tmp=(char*)malloc(cgiContentLength+1*sizeof(char));
 		  memset(tmp,0,cgiContentLength);
 		  xmlNodePtr cur4=cur3->children;
@@ -1664,6 +1667,7 @@
 		    if(btmps!=NULL)
 		      sprintf(tmp,"%s",(char*)btmps);
+		    xmlFree(btmps);
+		    cur4=cur4->next;
 		    xmlFreeDoc(bdoc);
-		    cur4=cur4->next;
 		  }
 		  map *btmp=getMap(tmpmaps->content,"href");
@@ -1686,8 +1690,10 @@
 		      curl_slist_free_all(hInternetP.header);
 		    addToMap(tmpmaps->content,"value",tmpContent);
+		    free(tmpContent);
 #ifdef POST_DEBUG
 		    fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
-#endif
+#endif		    
 		  }
+		  free(tmp);
 		}
 		else
@@ -1842,4 +1848,5 @@
 		  sprintf(size,"%d",buffersize);
 		  addToMap(tmpmaps->content,"size",size);
+		  xmlFreeDoc(doc1);
 		}
 		addToMap(tmpmaps->content,"value",(char*)mv);
@@ -2137,4 +2144,5 @@
     }
     xmlXPathFreeObject(tmpsptr);
+    xmlFreeDoc(doc);
     xmlCleanupParser();
   }
@@ -2168,5 +2176,5 @@
 	char tmps[1024];
 	map* tmpe=createMap("code","FileSizeExceeded");
-	snprintf(tmps,1024,_("The <%s> parameter has a limited size (%sMB) defined in ZOO ServicesProvider configuration file but the reference you provided exceed this limitation (%dMB), please correct your query or the ZOO Configuration file."),ptr->name,tmp1->value,i);
+	snprintf(tmps,1024,_("The <%s> parameter has a limited size (%sMB) defined in ZOO ServicesProvider configuration file but the reference you provided exceed this limitation (%fMB), please correct your query or the ZOO Configuration file."),ptr->name,tmp1->value,i);
 	addToMap(tmpe,"locator",ptr->name);
 	addToMap(tmpe,"text",tmps);
@@ -2230,5 +2238,4 @@
 	cgiFilePtr file;
 	int targetFile;
-	mode_t mode;
 	char storageNameOnServer[2048];
 	char fileNameOnServer[64];
@@ -2259,5 +2266,4 @@
 	  fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
 #endif
-	  mode=S_IRWXU|S_IRGRP|S_IROTH;
 	  targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH);
 	  if(targetFile<0){
@@ -2408,5 +2414,4 @@
     char *tcook=zStrdup(cgiCookie);
     char *tmp=NULL;
-    int hasVal=-1;
     map* testing=getMapFromMaps(m,"main","cookiePrefix");
     if(testing==NULL){
@@ -2415,5 +2420,4 @@
       tmp=(char*)malloc((strlen(testing->value)+2)*sizeof(char));
       sprintf(tmp,"%s=",testing->value);
-      hasVal=1;
     }
     if(strstr(cgiCookie,";")!=NULL){
@@ -2585,5 +2589,4 @@
   (void) signal(SIGABRT,donothing);
 #endif
-
   if(((int)getpid())!=cpid || cgiSid!=NULL){
     fclose(stdout);
@@ -2608,4 +2611,5 @@
     unlink(fbkp1);
     free(fbkp1);
+    free(tmps1);
   }
 
