Index: /trunk/zoo-api/js/ZOO-api.js
===================================================================
--- /trunk/zoo-api/js/ZOO-api.js	(revision 25)
+++ /trunk/zoo-api/js/ZOO-api.js	(revision 26)
@@ -74,5 +74,10 @@
 
     return Class;
+  },
+  UpdateStatus: function(env,value) {
+    return ZOOUpdateStatus(env,value);
   }
+};
+
 };
 
Index: /trunk/zoo-kernel/Makefile.in
===================================================================
--- /trunk/zoo-kernel/Makefile.in	(revision 25)
+++ /trunk/zoo-kernel/Makefile.in	(revision 26)
@@ -55,5 +55,5 @@
 
 service_internal.o: service_internal.c service.h
-	g++ ${XML2CFLAGS} ${CFLAGS} -c service_internal.c
+	gcc ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c service_internal.c
 
 service_internal_python.o: service_internal_python.c service.h
@@ -78,5 +78,5 @@
 
 zoo_service_loader.o: zoo_service_loader.c service.h
-	g++ -g -O2 -Wall ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PHPCFLAGS} ${JS_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
+	g++ -g -O2 -Wall ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PHPCFLAGS} ${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 service_internal_python.o  ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE}
Index: unk/zoo-kernel/service.c
===================================================================
--- /trunk/zoo-kernel/service.c	(revision 25)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#include "service.h"
-
-map* createMap(char* name,char* value){
-  map* tmp=(map *)malloc(sizeof(map*));
-  tmp->name=strdup(name);
-  tmp->value=strdup(value);
-  tmp->next=NULL;
-  return tmp;
-}
-
-bool hasKey(map* m,char *key){
-  map* tmp=m;
-  while(tmp!=NULL){
-    if(strcmp(tmp->name,key)==0)
-      return true;
-    tmp=tmp->next;
-  }
-#ifdef DEBUG_MAP
-  printf("NOT FOUND \n");
-#endif
-  return false;
-}
-
-map* getMap(map* m,char *key){
-  map* tmp=m;
-  while(tmp!=NULL){
-    if(strcmp(tmp->name,key)==0)
-      return tmp;
-    tmp=tmp->next;
-  }
-  return NULL;
-}
-
-void* addToMap(map* m,char* n,char* v){
-  if(hasKey(m,n)==false){
-    map* _cursor=m;
-    while(_cursor->next)
-      _cursor=_cursor->next;
-    _cursor->next=createMap(n,v);
-  }
-  else{
-    map *tmp=getMap(m,n);
-    tmp->value=strdup(v);
-  }
-}
-
-void* _dumpMap(map* t){
-  fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
-  fflush(stderr);
-}
-
-void* dumpMap(map* t){
-  map* tmp=t;
-  while(tmp!=NULL){
-    _dumpMap(tmp);
-    tmp=tmp->next;
-  }
-}
Index: /trunk/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-kernel/service.h	(revision 25)
+++ /trunk/zoo-kernel/service.h	(revision 26)
@@ -53,19 +53,5 @@
 #define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
 
-
-  /*  static char* mtoupper(char* str){
-    char* tmp=strdup(str);
-    if(tmp){
-      int cnt=strlen(tmp);
-      int i;
-      for(i=0;i<cnt;i++){
-	tmp[i]=toupper(str[i]);
-	tmp[i+1]=0;
-      }
-    }
-    else
-      tmp[0]=0;
-    return tmp;
-    }*/
+#define SHMSZ     27
 
   /**
@@ -437,4 +423,19 @@
       }
       tmp=tmp->next;
+    }
+  }
+
+
+  static void* setMapInMaps(maps* m,char* key,char* subkey,char *value){
+    maps* _tmpm=getMaps(m,key);
+    if(_tmpm!=NULL){
+      map* _ztmpm=getMap(_tmpm->content,subkey);
+      if(_ztmpm!=NULL){
+	free(_ztmpm->value);
+	_ztmpm->value=strdup(value);
+	dumpMap(_ztmpm);
+      }else{
+	addToMap(_tmpm->content,subkey,value);
+      }
     }
   }
Index: /trunk/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-kernel/service_internal.c	(revision 25)
+++ /trunk/zoo-kernel/service_internal.c	(revision 26)
@@ -35,4 +35,122 @@
   return hex[code & 15];
 }
+
+void* unhandleStatus(maps *conf){
+  int shmid,i;
+  key_t key;
+  void *shm;
+  struct shmid_ds shmids;
+  char *s,*s1;
+  map *tmpMap=getMapFromMaps(conf,"lenv","sid");
+  if(tmpMap!=NULL){
+    key=atoi(tmpMap->value);
+    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
+#ifdef DEBUG
+      fprintf(stderr,"shmget failed to update value\n");
+#endif
+    }else{
+      if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
+#ifdef DEBUG
+	fprintf(stderr,"shmat failed to update value\n");
+#endif
+      }else{
+	shmdt(shm);
+	shmctl(shmid,IPC_RMID,&shmids);
+      }
+    }
+  }
+}
+
+#ifdef USE_JS
+
+JSBool
+JSUpdateStatus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+  JS_MaybeGC(cx);
+  char *sid;
+  int istatus=0;
+  char *status=NULL;
+  maps *conf;
+  int i=0;
+  if(argc>2){
+#ifdef JS_DEBUG
+    fprintf(stderr,"Number of arguments used to call the function : %i",argc);
+#endif
+    return JS_FALSE;
+  }
+  conf=mapsFromJSObject(cx,argv[0]);
+  dumpMaps(conf);
+  if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
+    char tmpStatus[4];
+    sprintf(tmpStatus,"%i",istatus);
+    tmpStatus[3]=0;
+    status=strdup(tmpStatus);
+  }
+  if(getMapFromMaps(conf,"lenv","status")!=NULL){
+    if(status!=NULL)
+      setMapInMaps(conf,"lenv","status",status);
+    else
+      setMapInMaps(conf,"lenv","status","15");
+    updateStatus(conf);
+  }
+  freeMaps(&conf);
+  free(conf);
+  JS_MaybeGC(cx);
+  return JS_TRUE;
+}
+
+#endif
+
+void* updateStatus(maps *conf){
+  int shmid,i;
+  key_t key;
+  char *shm,*s,*s1;
+  map *tmpMap=NULL;
+  tmpMap=getMapFromMaps(conf,"lenv","sid");
+  if(tmpMap!=NULL){
+    key=atoi(tmpMap->value);
+    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
+#ifdef DEBUG
+      fprintf(stderr,"shmget failed to update value\n");
+#endif
+    }else{
+      if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
+#ifdef DEBUG
+	fprintf(stderr,"shmat failed to update value\n");
+#endif
+      }
+      else{
+	tmpMap=getMapFromMaps(conf,"lenv","status");
+	s1=shm;
+	for(s=tmpMap->value;*s!=NULL;s++)
+	  *s1++=*s;
+	shmdt((void *)shm);
+      }
+    }
+  }
+}
+
+char* getStatus(int pid){
+  int shmid,i;
+  key_t key;
+  void *shm;
+  char *s;
+  key=pid;
+  if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
+#ifdef DEBUG
+    fprintf(stderr,"shmget failed in getStatus\n");
+#endif
+  }else{
+    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
+#ifdef DEBUG
+      fprintf(stderr,"shmat failed in getStatus\n");
+#endif
+    }else{
+      return (char*)shm;
+    }
+  }
+  return "-1";
+}
+
 
 /* Returns a url-encoded version of str */
@@ -729,5 +847,5 @@
 	  char tmp[1024];
 	  sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value);
-	  xmlNewNsProp(nc6,ns_xlink,BAD_CAST "reference",BAD_CAST tmp);
+	  xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp);
 	  xmlAddChild(nc3,nc6);
 	  tmp1=tmp1->next;
@@ -841,20 +959,61 @@
   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
   char tmp[256];
-  char url[256];
+  char url[1024];
   memset(tmp,0,256);
   memset(url,0,256);
   maps* tmp_maps=getMaps(m,"main");
   if(tmp_maps!=NULL){
-    map* tmpm=getMap(tmp_maps->content,"serverAddress");
-    map* tmpm1=getMap(tmp_maps->content,"tmpUrl");
-    if(tmpm!=NULL && tmpm1!=NULL){
-      sprintf(url,"%s/%s/%s_%i.xml",tmpm->value,tmpm1->value,service,pid);
-    }
-    if(tmpm!=NULL)
-      sprintf(tmp,"%s/",tmpm->value);
+    dumpMaps(getMaps(m,"lenv"));
+    map* tmpm1=getMap(tmp_maps->content,"serverAddress");
+    /**
+     * Check if the ZOO Service GetStatus is available in the local directory.
+     * If yes, then it uses a reference to an URL which the client can access
+     * to get information on the status of a running Service (using the 
+     * percentCompleted attribute). 
+     * Else fallback to the initial method using the xml file to write in ...
+     */
+    char ntmp[1024];
+#ifndef WIN32
+    getcwd(ntmp,1024);
+#else
+    _getcwd(ntmp,1024);
+#endif
+    struct stat myFileInfo;
+    int statRes;
+    char file_path[1024];
+    sprintf(file_path,"%s/GetStatus.zcfg",ntmp);
+    statRes=stat(file_path,&myFileInfo);
+    if(statRes==0){
+      char currentSid[128];
+      map* tmpm=getMap(tmp_maps->content,"rewriteUrl");
+      map *tmp_lenv=NULL;
+      tmp_lenv=getMapFromMaps(m,"lenv","sid");
+      if(tmp_lenv==NULL)
+	sprintf(currentSid,"%i",pid);
+      else
+	sprintf(currentSid,"%s",tmp_lenv->value);
+      if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){
+	sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
+      }else{
+	if(strlen(tmpm->value)>0)
+	  if(strcasecmp(tmpm->value,"true")!=0)
+	    sprintf(url,"%s/%s/GetStatus/%s",tmpm1->value,tmpm->value,currentSid);
+	  else
+	    sprintf(url,"%s/GetStatus/%s",tmpm1->value,currentSid);
+	else
+	  sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
+      }
+    }else{
+      map* tmpm2=getMap(tmp_maps->content,"tmpUrl");
+      if(tmpm1!=NULL && tmpm2!=NULL){
+	sprintf(url,"%s/%s/%s_%i.xml",tmpm1->value,tmpm2->value,service,pid);
+      }
+    }
+    if(tmpm1!=NULL)
+      sprintf(tmp,"%s/",tmpm1->value);
   }
 
   xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp);
-  if(status!=SERVICE_SUCCEEDED){
+  if(status!=SERVICE_SUCCEEDED && status!=SERVICE_FAILED){
     xmlNewProp(n,BAD_CAST "statusLocation",BAD_CAST url);
   }
@@ -876,4 +1035,5 @@
   time_t now;
   char *tmp1;
+  map *tmpStatus;
   
   now = time ( NULL );
@@ -884,24 +1044,48 @@
   len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm );
 
+  xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
+
+  char sMsg[2048];
   switch(status){
   case SERVICE_SUCCEEDED:
-    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
     nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");
+    sprintf(sMsg,"Service \"%s\" run successfully.",serv->name);
+    nc3=xmlNewText(BAD_CAST sMsg);
+    xmlAddChild(nc1,nc3);
     break;
   case SERVICE_STARTED:
-    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
     nc1 = xmlNewNode(ns, BAD_CAST "ProcessStarted");
-    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST "NEED_SERVICE_ACCESS"); 
+    tmpStatus=getMapFromMaps(m,"lenv","status");
+    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);
+    sprintf(sMsg,"ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service.",serv->name);
+    nc3=xmlNewText(BAD_CAST sMsg);
+    xmlAddChild(nc1,nc3);
     break;
   case SERVICE_ACCEPTED:
-    xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
     nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");
+    sprintf(sMsg,"Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document.",serv->name);
+    nc3=xmlNewText(BAD_CAST sMsg);
+    xmlAddChild(nc1,nc3);
     break;
   case SERVICE_FAILED:
     nc1 = xmlNewNode(ns, BAD_CAST "ProcessFailed");
+    map *errorMap;
+    map *te;
+    te=getMapFromMaps(m,"lenv","code");
+    if(te!=NULL)
+      errorMap=createMap("code",te->value);
+    else
+      errorMap=createMap("code","NoApplicableCode");
+    te=getMapFromMaps(m,"lenv","message");
+    if(te!=NULL)
+      addToMap(errorMap,"text",te->value);
+    else
+      addToMap(errorMap,"text","No more information available");
+    nc3=createExceptionReportNode(m,errorMap,0);
+    xmlAddChild(nc1,nc3);
     break;
   default :
     printf("error code not know : %i\n",status);
-    exit(1);
+    //exit(1);
     break;
   }
@@ -1059,8 +1243,8 @@
   nc1=xmlNewNode(ns_wps, BAD_CAST type);
   map *tmp=e->content;
-  //#ifdef DEBUG
+#ifdef DEBUG
   dumpMap(tmp);
   dumpElements(e);
-  //#endif
+#endif
   nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier");
   nc3=xmlNewText(BAD_CAST e->name);
@@ -1085,7 +1269,7 @@
    * IO type Reference or full Data ?
    */
-  //#ifdef DEBUG
+#ifdef DEBUG
   fprintf(stderr,"FORMAT %s %s\n",e->format,e->format);
-  //#endif
+#endif
   map *tmpMap=getMap(m->content,"Reference");
   if(tmpMap==NULL){
@@ -1210,5 +1394,7 @@
   maps* tmpMap=getMaps(m,"main");
   char *encoding=getEncoding(tmpMap);
-  printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
+  map *tmpSid=getMapFromMaps(m,"lenv","sid");
+  if(tmpSid==NULL)
+    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
 
   ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
@@ -1217,9 +1403,7 @@
   ns_xlink=xmlNewNs(n,BAD_CAST "http://www.w3.org/1999/xlink",BAD_CAST "xlink");
   ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
-  xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1/owsExceptionReport.xsd");
+  xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
-  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
-
-  xmlNewProp(n,BAD_CAST "version",BAD_CAST getVersion(tmpMap));
+  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
 
   nc = xmlNewNode(ns, BAD_CAST "Exception");  
@@ -1251,4 +1435,49 @@
   xmlFreeNs(ns);
   xmlCleanupParser();
+}
+
+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");
+
+  ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
+  n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
+
+  if(use_ns==1){
+    ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
+    int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
+    ns_xsi=usedNs[xsiId];
+    int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
+    ns_xlink=usedNs[xlinkId];
+    xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
+  }
+  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
+  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
+  
+  nc = xmlNewNode(ns, BAD_CAST "Exception");
+
+  map* tmp=getMap(s,"code");
+  if(tmp!=NULL)
+    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
+  else
+    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
+
+  tmp=getMap(s,"text");
+  nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
+  nc2=NULL;
+  if(tmp!=NULL){
+    xmlNodeSetContent(nc1, BAD_CAST tmp->value);
+  }
+  else{
+    xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
+  }
+  xmlAddChild(nc,nc1);
+  xmlAddChild(n,nc);
+  return n;
 }
 
@@ -1296,43 +1525,59 @@
 #endif
     printProcessResponse(m,request_inputs1,cpid,
-			  s,r_inputs->value,res,
-			  request_inputs,
-			  request_outputs);
-  }
-  else{
-    /**
-     * We get the first output only !!
-     */
-    char mime[1024];
-    map* mi=getMap(request_outputs->content,"mimeType");
-#ifdef DEBUG
-    fprintf(stderr,"SERVICE OUTPUTS\n");
-    dumpMaps(request_outputs);
-    fprintf(stderr,"SERVICE OUTPUTS\n");
-#endif
-    map* en=getMap(request_outputs->content,"encoding");
-    if(mi!=NULL && en!=NULL)
-      sprintf(mime,
-	      "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n",
-	      mi->value,en->value);
-    else
-      if(mi!=NULL)
+			 s,r_inputs->value,res,
+			 request_inputs,
+			 request_outputs);
+  }
+  else
+    if(res!=SERVICE_FAILED){
+      /**
+       * We get the first output only !!
+       */
+      char mime[1024];
+      map* mi=getMap(request_outputs->content,"mimeType");
+#ifdef DEBUG
+      fprintf(stderr,"SERVICE OUTPUTS\n");
+      dumpMaps(request_outputs);
+      fprintf(stderr,"SERVICE OUTPUTS\n");
+#endif
+      map* en=getMap(request_outputs->content,"encoding");
+      if(mi!=NULL && en!=NULL)
 	sprintf(mime,
-		"Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n",
-		mi->value);
+		"Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n",
+		mi->value,en->value);
       else
-	sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
-    printf("%s",mime);
-    toto=getMap(request_outputs->content,"value");
-    if(mi!=NULL && strncmp(mi->value,"image",5)==0){
-      map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
-      fwrite(toto->value,atoi(rs->value),1,stdout);
-    }
-    else
-      printf("%s",toto->value);
-#ifdef DEBUG
-    dumpMap(toto);
-#endif
-  }
+	if(mi!=NULL)
+	  sprintf(mime,
+		  "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n",
+		  mi->value);
+	else
+	  sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
+      printf("%s",mime);
+      toto=getMap(request_outputs->content,"value");
+      if(mi!=NULL && strncmp(mi->value,"image",5)==0){
+	map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
+	fwrite(toto->value,atoi(rs->value),1,stdout);
+      }
+      else
+	printf("%s",toto->value);
+#ifdef DEBUG
+      dumpMap(toto);
+#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");
+      printf("Content-Type: text/xml; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
+      printExceptionReportResponse(m,errormap);
+      freeMap(&errormap);
+      free(errormap);
+    }
 }
 
Index: /trunk/zoo-kernel/service_internal.h
===================================================================
--- /trunk/zoo-kernel/service_internal.h	(revision 25)
+++ /trunk/zoo-kernel/service_internal.h	(revision 26)
@@ -31,5 +31,9 @@
 #define TIME_SIZE 40
 
+#include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <time.h>
@@ -48,4 +52,9 @@
 extern   int conf_read(char*,maps*);
 
+#ifdef USE_JS
+#define XP_UNIX 0
+#include "service_internal_js.h"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
@@ -57,5 +66,13 @@
   static int nbNs=0;
 
+  void* unhandleStatus(maps*);
+  void* updateStatus(maps*);
+  char* getStatus(int);
 
+#ifdef USE_JS
+  char* JSValToChar(JSContext*,jsval*);
+  JSBool JSUpdateStatus(JSContext*,JSObject*,uintN,jsval *,jsval *);
+#endif
+  
   void URLDecode(char *);
   char *url_encode(char *);
@@ -67,4 +84,5 @@
   
   void printExceptionReportResponse(maps*,map*);
+  xmlNodePtr createExceptionReportNode(maps*,map*,int);
   void printProcessResponse(maps*,map*,int,service*,char*,int,maps*,maps*);
   xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,char*,maps*);
Index: /trunk/zoo-kernel/service_internal_js.c
===================================================================
--- /trunk/zoo-kernel/service_internal_js.c	(revision 25)
+++ /trunk/zoo-kernel/service_internal_js.c	(revision 26)
@@ -23,5 +23,5 @@
  */
 
-#include "service_internal_js.h"
+#include "service_internal.h"
 
 static char dbg[1024];
@@ -74,4 +74,6 @@
   if (!JS_DefineFunction(cx, global, "ZOORequest", JSRequest, 4, 0))
     return 1;
+  if (!JS_DefineFunction(cx, global, "ZOOUpdateStatus", JSUpdateStatus, 2, 0))
+    return 1;
 
   /* Your application code here. This may include JSAPI calls
@@ -82,8 +84,10 @@
   map* tmpm1=getMap(request,"metapath");
   map* tmpm2=getMap(s->content,"serviceProvider");
-  char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+6];
   char ntmp[1024];
   getcwd(ntmp,1024);
+  char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2];
   sprintf(filename,"%s/%s%s",ntmp,tmpm1->value,tmpm2->value);
+  filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+1]=0;
+  fprintf(stderr,"FILENAME %s\n",filename);
   struct stat file_status;
   stat(filename, &file_status);
@@ -203,7 +207,6 @@
 
   /* Cleanup. */
-  // The JS_MaybeGC call imply segmentation fault
-  //JS_MaybeGC(cx);
   JS_DestroyScript(cx, script);
+  JS_MaybeGC(cx);
   // If we use the DestroyContext as requested to release memory then we get 
   // issue getting back the main configuration maps after coming back to the 
@@ -387,5 +390,7 @@
 #endif
       if(res!=NULL){
+#ifdef JS_DEBUG
 	fprintf(stderr,"%s - %s\n",JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
+#endif
 	addToMap(res,JS_GetStringBytes(jsmsg),JS_GetStringBytes(jsmsg1));
       }
@@ -394,5 +399,7 @@
 	res->next=NULL;
       }
+#ifdef JS_DEBUG
       dumpMap(res);
+#endif
     }
   }
Index: /trunk/zoo-services/ogr/base-vect-ops/Makefile
===================================================================
--- /trunk/zoo-services/ogr/base-vect-ops/Makefile	(revision 25)
+++ /trunk/zoo-services/ogr/base-vect-ops/Makefile	(revision 26)
@@ -1,7 +1,9 @@
-CFLAGS=-I../../../zoo-kernel/ -I./ `xml2-config --cflags` `python-config --cflags`  `gdal-config --cflags`   -DLINUX_FREE_ISSUE #-DDEBUG
-CC=gcc
+CFLAGS=-I../../../zoo-kernel/ -I./ `xsl-config --cflags`  `gdal-config --cflags`  -DLINUX_FREE_ISSUE #-DDEBUG
+# if JS_ENABLED flag is set to true in your ZOO-Kernel Makefile then you'll have
+# uncomment the following line
+# JS_LDFLAGS=../../../zoo-kernel/ulinet.o ../../../zoo-kernel/service_internal_js.o
 
-cgi-env/service.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o `gdal-config --libs`
+cgi-env/ogr_service.zo: service.c
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/ogr_service.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} `xsl-config --libs` `gdal-config --libs` `geos-config --libs`
 
 clean:
Index: /trunk/zoo-services/ogr/base-vect-ops/service.c
===================================================================
--- /trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 25)
+++ /trunk/zoo-services/ogr/base-vect-ops/service.c	(revision 26)
@@ -74,5 +74,4 @@
     char *tmp=(char*)calloc((xmlStrlen(xmlStrstr(xmlbuff,BAD_CAST "?>"))-1),sizeof(char));
     sprintf(tmp,"%s",xmlStrstr(xmlbuff,BAD_CAST "?>")+2);
-    //strdup(strstr((char*)xmlbuff,"?>")+2);
     xmlXPathFreeObject(xpathObj);
     xmlXPathFreeContext(xpathCtx);
@@ -87,11 +86,9 @@
     free(tmp);
     if(res==NULL){
-      map* tmp=createMap("text","Unable to call OGR_G_CreatFromGML");
-      addToMap(tmp,"code","NoApplicableCode");
-      printExceptionReportResponse(conf,tmp);
-      exit(0);
+      setMapInMaps(conf,"lenv","message","Unable to call OGR_G_CreatFromGML");
+      return NULL;
     }
     else
-      return res;//OGR_G_CreateFromGML(tmp);
+      return res;
   }
 
@@ -108,36 +105,52 @@
     fprintf(stderr,"Tolerance for Simplify %f",tolerance);
     map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
-    if(!tmp)
-      return SERVICE_FAILED;
-    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeTime");
+    if(!tmp){
+      setMapInMaps(conf,"lenv","message","Unagle to parse the input geometry from InputPolygon");
+      return SERVICE_FAILED;
+    }
+    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
     if(tmp1!=NULL){
       if(strncmp(tmp1->value,"text/js",7)==0 ||
-	 strncmp(tmp1->value,"application/json",7)==0)
+	 strncmp(tmp1->value,"application/json",16)==0)
         geometry=OGR_G_CreateGeometryFromJson(tmp->value);
       else
         geometry=createGeometryFromGML(conf,tmp->value);
     }
-    else
-      geometry=createGeometryFromGML(conf,tmp->value);
+    else{
+      setMapInMaps(conf,"lenv","message","Unable to find any geometry for InputPolygon");
+      return SERVICE_FAILED;
+    }
+    if(geometry==NULL){
+      setMapInMaps(conf,"lenv","message","Unagle to parse the input geometry from InputPolygon");
+      return SERVICE_FAILED;
+    }
+    fprintf(stderr,"Create GEOSGeometry object");
     GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
     GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
     res=OGRGeometryFactory::createFromGEOS(gres);
+    tmp1=getMapFromMaps(outputs,"Result","mimeType");
     if(tmp1!=NULL){
       if(strncmp(tmp1->value,"text/js",7)==0 ||
 	 strncmp(tmp1->value,"application/json",16)==0){
-        outputs->content=createMap("value",OGR_G_ExportToJson(tmp->value));
-	addMapToMap(&outputs->content,createMap("mimeType","text/plain"));
-	addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
+	char *tmpS=OGR_G_ExportToJson(res);
+	setMapInMaps(outputs,"Result","value",tmpS);
+	setMapInMaps(outputs,"Result","mimeType","text/plain");
+	setMapInMaps(outputs,"Result","encoding","UTF-8");
+	free(tmpS);
       }
       else{
-        outputs->content=createMap("value",OGR_G_ExportToGML(res));
-	addMapToMap(&outputs->content,createMap("mimeType","text/xml"));
-	addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
-	addMapToMap(&outputs->content,createMap("schema","http://fooa/gml/3.1.0/polygon.xsd"));
+	char *tmpS=OGR_G_ExportToGML(res);
+	setMapInMaps(outputs,"Result","value",tmpS);
+	setMapInMaps(outputs,"Result","mimeType","text/xml");
+	setMapInMaps(outputs,"Result","encoding","UTF-8");
+	setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
+	free(tmpS);
       }
     }else{
-      outputs->content=createMap("value",OGR_G_ExportToJson(res));
-      addMapToMap(&outputs->content,createMap("mimeType","text/plain"));
-      addMapToMap(&outputs->content,createMap("encoding","UTF-8"));
+      char *tmpS=OGR_G_ExportToJson(tmp->value);
+      setMapInMaps(outputs,"Result","value",tmpS);
+      setMapInMaps(outputs,"Result","mimeType","text/plain");
+      setMapInMaps(outputs,"Result","encoding","UTF-8");
+      free(tmpS);
     }
     outputs->next=NULL;
@@ -178,4 +191,6 @@
     else
       geometry=createGeometryFromGML(conf,tmp->value);
+    if(geometry==NULL)
+      return SERVICE_FAILED;
     res=(*myFunc)(geometry);
     fprintf(stderr,"Service internal print \n");
@@ -189,21 +204,24 @@
       if(strncmp(tmp_2->value,"text/js",7)==0 ||
 	 strncmp(tmp_2->value,"application/json",16)==0){
-	char *tres=OGR_G_ExportToJson(res);
-        addToMap(outputs->content,"value",tres);
-	free(tres);
-	addToMap(outputs->content,"mimeType","text/plain");
-	addToMap(outputs->content,"encoding","UTF-8");
+	char *tmpS=OGR_G_ExportToJson(res);
+	setMapInMaps(outputs,"Result","value",tmpS);
+	setMapInMaps(outputs,"Result","mimeType","text/plain");
+	setMapInMaps(outputs,"Result","encoding","UTF-8");
+	free(tmpS);
       }
       else{
-	char *tres=OGR_G_ExportToGML(res);
-        addToMap(outputs->content,"value",tres);
-	free(tres);
+	char *tmpS=OGR_G_ExportToGML(res);
+	setMapInMaps(outputs,"Result","value",tmpS);
+	setMapInMaps(outputs,"Result","mimeType","text/plain");
+	setMapInMaps(outputs,"Result","encoding","UTF-8");
+	free(tmpS);
+
       }
     }else{
-      char *tres=OGR_G_ExportToJson(res);
-      addToMap(outputs->content,"value",tres);
-      free(tres);
-      addToMap(outputs->content,"mimeType","text/plain");
-      addToMap(outputs->content,"encoding","UTF-8");
+      char *tmpS=OGR_G_ExportToJson(res);
+      setMapInMaps(outputs,"Result","value",tmpS);
+      setMapInMaps(outputs,"Result","mimeType","text/plain");
+      setMapInMaps(outputs,"Result","encoding","UTF-8");
+      free(tmpS);
     }
     outputs->next=NULL;
@@ -235,16 +253,30 @@
    else
      geometry=createGeometryFromGML(conf,tmp->value);
-   int bufferDistance=1;
+   if(geometry==NULL){
+     setMapInMaps(conf,"lenv","message","Unable to parse input geometry");
+     return SERVICE_FAILED;
+   }
+   double bufferDistance;
    tmp=getMapFromMaps(inputs,"BufferDistance","value");
-   if(tmp!=NULL)
-		bufferDistance=atoi(tmp->value);
+   if(tmp==NULL){
+     bufferDistance=atof("10.0");
+   }
+   else
+     bufferDistance=atof(tmp->value);
    res=OGR_G_Buffer(geometry,bufferDistance,30);
    tmp1=getMapFromMaps(outputs,"Result","mimeType");
    if(strncmp(tmp1->value,"application/json",16)==0){
-		addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
-		addToMap(outputs->content,"mimeType","text/plain");
+     char *tmpS=OGR_G_ExportToJson(res);
+     setMapInMaps(outputs,"Result","value",tmpS);
+     setMapInMaps(outputs,"Result","mimeType","text/plain");
+     setMapInMaps(outputs,"Result","encoding","UTF-8");
+     free(tmpS);
    }
    else{
-		addToMap(outputs->content,"value",OGR_G_ExportToGML(res));
+     char *tmpS=OGR_G_ExportToGML(res);
+     setMapInMaps(outputs,"Result","value",tmpS);
+     setMapInMaps(outputs,"Result","mimeType","text/xml");
+     setMapInMaps(outputs,"Result","encoding","UTF-8");
+     setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    }
    outputs->next=NULL;
@@ -254,101 +286,4 @@
 }
 
-/*  int Buffer(maps*& conf,maps*& inputs,maps*& outputs){
-#ifdef DEBUG
-    fprintf(stderr,"\nService internal print\n");
-#endif
-    maps* cursor=inputs;
-    OGRGeometryH geometry,res;
-    int bufferDistance;    
-    if(cursor!=NULL){
-#ifdef DEBUG
-      fprintf(stderr,"\nService internal print\n");
-      dumpMaps(cursor);
-      fprintf(stderr,"\nService internal print\n");
-      dumpMaps(inputs);
-      fprintf(stderr,"\nService internal print\n");
-#endif
-      map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
-      map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
-      if(tmp1!=NULL){
-        if(strncmp(tmp1->value,"application/json",16)==0 ||
-	   strncmp(tmp1->value,"text/js",7)==0)
-      	  geometry=OGR_G_CreateGeometryFromJson(tmp->value);
-	else
-	  geometry=createGeometryFromGML(conf,tmp->value);
-      }
-      else
-      	geometry=createGeometryFromGML(conf,tmp->value);
-    }
-    if(cursor!=NULL){
-      map* tmp=getMapFromMaps(cursor,"BufferDistance","value");
-      if(tmp==NULL){
-	bufferDistance=10;
-      }
-      else
-	bufferDistance=atoi(tmp->value);
-#ifdef DEBUG
-      fprintf(stderr,"\nService internal print (BufferDistance value: %i)\n",bufferDistance);
-#endif
-    }
-#ifdef DEBUG
-    dumpMaps(outputs);
-#endif
-    map* tmp=getMapFromMaps(outputs,"Result","mimeType");
-    res=OGR_G_Buffer(geometry,bufferDistance,30);
-#ifdef DEBUG
-    dumpMap(tmp);
-#endif
-    if(tmp!=NULL){
-#ifdef DEBUG
-      dumpMap(tmp);
-#endif
-      if(strncmp(tmp->value,"application/json",16)==0){
-	addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
-	addToMap(outputs->content,"mimeType","text/plain");
-	addToMap(outputs->content,"encoding","UTF-8");
-      }
-      else if(strcmp(tmp->value,"text/xml")==0){
-	xmlInitParser();
-	xmlDocPtr doc = xmlParseMemory(tmp->value,strlen(tmp->value));
-	xmlChar *xmlbuff;
-	int buffersize;
-	char *buff=OGR_G_ExportToGML(res);
-	addToMap(outputs->content,"value",buff);
-	map* tmp1=getMapFromMaps(outputs,"Result","encoding");
-	if(tmp1!=NULL)
-	  addToMap(outputs->content,"encoding",tmp1->value);
-	else
-	  addToMap(outputs->content,"encoding","UTF-8");
-	xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
-	xmlFree(xmlbuff);
-	xmlFreeDoc(doc);
-	xmlCleanupParser();
-      }
-      else{
-	addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
-	addToMap(outputs->content,"mimeType","text/plain");
-	addToMap(outputs->content,"encoding","UTF-8");
-	outputs->next=NULL;
-      }
-      outputs->next=NULL;
-    }
-    else{
-      addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
-      addToMap(outputs->content,"mimeType","text/plain");
-      addToMap(outputs->content,"encoding","UTF-8");
-      outputs->next=NULL;
-    }
-    outputs->next=NULL;
-#ifdef DEBUG
-    dumpMaps(outputs);
-    fprintf(stderr,"\nService internal print\n===\n");
-#endif
-    OGR_G_DestroyGeometry(geometry);
-    OGR_G_DestroyGeometry(res);
-    return SERVICE_SUCCEEDED;
-  }
-*/
-
 #ifdef WIN32
   __declspec(dllexport)
@@ -387,6 +322,9 @@
 #ifdef DEBUG
     fprintf(stderr,"\nService internal print1\n");
-#endif
     fflush(stderr);
+#endif
+    fprintf(stderr,"\nService internal print1\n");
+    dumpMaps(inputs);
+    fprintf(stderr,"\nService internal print1\n");
 
     maps* cursor=inputs;
@@ -405,26 +343,47 @@
       	geometry1=createGeometryFromGML(conf,tmp->value);
     }
+    if(geometry1==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity1.");
+      fprintf(stderr,"SERVICE FAILED !\n");
+      return SERVICE_FAILED;
+    }
+    fprintf(stderr,"\nService internal print1 InputEntity1\n");
     {
       map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
       map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
-#ifdef DEBUG
+      //#ifdef DEBUG
+      fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
+      //dumpMap(tmp);
       fprintf(stderr,"MY MAP\n");
-      dumpMap(tmp1);
-      fprintf(stderr,"MY MAP\n");
-#endif
+      ///#endif
+      fprintf(stderr,"\nService internal print1 InputEntity2\n");
       if(tmp1!=NULL){
-        if(strncmp(tmp1->value,"application/json",16)==0)
+        if(strncmp(tmp1->value,"application/json",16)==0){
+	  fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
       	  geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
-	else
+	}
+	else{
+	  fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
 	  geometry2=createGeometryFromGML(conf,tmp->value);
+	}
       }
       else
       	geometry2=createGeometryFromGML(conf,tmp->value);
-    }
+      fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
+    }
+    fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
+    if(geometry2==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity2.");
+      fprintf(stderr,"SERVICE FAILED !\n");
+      return SERVICE_FAILED;
+    }
+    fprintf(stderr,"\nService internal print1\n");
     res=(*myFunc)(geometry1,geometry2);
-    addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
-    addToMap(outputs->content,"mimeType","text/plain");
-    addToMap(outputs->content,"encoding","UTF-8");
-    outputs->next=NULL;
+    fprintf(stderr,"\nService internal print1\n");
+    char *tmpS=OGR_G_ExportToJson(res);
+    setMapInMaps(outputs,"Result","value",tmpS);
+    setMapInMaps(outputs,"Result","mimeType","text/plain");
+    setMapInMaps(outputs,"Result","encoding","UTF-8");
+    free(tmpS);
     OGR_G_DestroyGeometry(geometry1);
     OGR_G_DestroyGeometry(geometry2);
@@ -469,5 +428,4 @@
 #endif
     fflush(stderr);
-
     maps* cursor=inputs;
     OGRGeometryH geometry1,geometry2;
@@ -491,4 +449,9 @@
       	geometry1=createGeometryFromGML(conf,tmp->value);
     }
+    if(geometry1==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity1.");
+      fprintf(stderr,"SERVICE FAILED !\n");
+      return SERVICE_FAILED;
+    }
     {
       map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
@@ -509,12 +472,14 @@
       	geometry2=createGeometryFromGML(conf,tmp->value);
     }
-    res=OGR_G_Distance(geometry1,geometry2);
-    outputs=(maps*)malloc(sizeof(maps*));
-    outputs->name="Distance";
+    if(geometry2==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry for InputEntity2.");
+      fprintf(stderr,"SERVICE FAILED !\n");
+      return SERVICE_FAILED;
+    }
+    res=OGR_G_Distance(geometry1,geometry2);    
     char tmpres[100];
     sprintf(tmpres,"%d",res);
-    outputs->content=createMap("value",tmpres);
-    addMapToMap(&outputs->content,createMap("datatype","float"));
-    outputs->next=NULL;
+    setMapInMaps(outputs,"Distance","value",tmpres);
+    setMapInMaps(outputs,"Distance","dataType","float");
 #ifdef DEBUG
     dumpMaps(outputs);
@@ -531,23 +496,28 @@
     double res;
     /**
-     * Extract Geometry from the InputEntity1 value
+     * Extract Geometry from the InputPolygon value
      */
-    OGRGeometryH geometry1;
-    map* tmp=getMapFromMaps(inputs,"InputEntity1","value");
+    OGRGeometryH geometry;
+    map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
+    if(tmp==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry from InputPolygon");
+      return SERVICE_FAILED;
+    }
     fprintf(stderr,"geometry creation %s \n",tmp->value);
-    geometry1=createGeometryFromGML(conf,tmp->value);
+    geometry=createGeometryFromGML(conf,tmp->value);
+    if(geometry==NULL){
+      setMapInMaps(conf,"lenv","message","Unable to parse input geometry from InputPolygon");
+      return SERVICE_FAILED;
+    }
     fprintf(stderr,"geometry created %s \n",tmp->value);
-    res=OGR_G_GetArea(geometry1);
+    res=OGR_G_GetArea(geometry);
     fprintf(stderr,"area %d \n",res);
     /**
-     * Creating the outputs
+     * Filling the outputs
      */
-    outputs=(maps*)malloc(sizeof(maps*));
-    outputs->name="Area";
     char tmp1[100];
     sprintf(tmp1,"%d",res);
-    outputs->content=createMap("value",tmp1);
-    addMapToMap(&outputs->content,createMap("datatype","float"));
-    outputs->next=NULL;
+    setMapInMaps(outputs,"Area","value",tmp1);
+    setMapInMaps(outputs,"Area","dataType","float");
 #ifdef DEBUG
     dumpMaps(outputs);
Index: /trunk/zoo-services/utils/status/Makefile
===================================================================
--- /trunk/zoo-services/utils/status/Makefile	(revision 26)
+++ /trunk/zoo-services/utils/status/Makefile	(revision 26)
@@ -0,0 +1,10 @@
+CFLAGS=-I../../../zoo-kernel/ -I./ `xslt-config --cflags` `xml2-config --cflags` -DLINUX_FREE_ISSUE #-DDEBUG
+# if JS_ENABLED flag is set to true in your ZOO-Kernel Makefile then you'll have
+# uncomment the following line
+# JS_LDFLAGS=../../../zoo-kernel/ulinet.o ../../../zoo-kernel/service_internal_js.o
+
+cgi-env/wps_status.zo: service.c
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ../../../zoo-kernel/service_internal.o ${JS_LDFLAGS} `xml2-config --libs` `xslt-config --libs`
+
+clean:
+	rm -f cgi-env/wps_status.zo
Index: /trunk/zoo-services/utils/status/cgi-env/GetStatus.zcfg
===================================================================
--- /trunk/zoo-services/utils/status/cgi-env/GetStatus.zcfg	(revision 26)
+++ /trunk/zoo-services/utils/status/cgi-env/GetStatus.zcfg	(revision 26)
@@ -0,0 +1,44 @@
+[GetStatus]
+ Title = Produce an updated ExecuteResponse document. 
+ Abstract = Create an ExecuteResponse document from a sid (Service ID), it will use the niternal ZOO Kernel mechanisms to access the current status from a running Service and update the percentCompleted from the original backup file used by the ZOO Kernel when running a Service in background. 
+ processVersion = 1
+ storeSupported = true
+ statusSupported = true
+ serviceProvider = wps_status.zo
+ serviceType = C
+ <MetaData lang="en">
+   title = Demo GetStatus request
+ </MetaData>
+ <DataInputs>
+  [sid]
+   Title = Service ID
+   Abstract = The ZOO Service ID of the ZOO Service we want to get the current status.
+   minOccurs = 1
+   maxOccurs = 1
+   <LiteralData>
+    DataType = integer
+    <Default>
+     uom = meters
+    </Default>
+    <Supported>
+     uom = feet
+    </Supported>
+   </LiteralData>
+ </DataInputs>
+ <DataOutputs>
+  [Result]
+   Title = ExecuteResponse document
+   Abstract = The resulting ExecuteResponse document.
+   <MetaData lang="en">
+    title = Demo XSL use case
+   </MetaData>   
+   <LiteralData>
+    DataType = string
+    <Default>
+     uom = meters
+    </Default>
+    <Supported>
+     uom = feet
+    </Supported>
+   </LiteralData>
+ </DataOutputs>  
Index: /trunk/zoo-services/utils/status/cgi-env/longProcess.zcfg
===================================================================
--- /trunk/zoo-services/utils/status/cgi-env/longProcess.zcfg	(revision 26)
+++ /trunk/zoo-services/utils/status/cgi-env/longProcess.zcfg	(revision 26)
@@ -0,0 +1,44 @@
+[longProcess]
+ Title = Demo long process. 
+ Abstract = This service doesn't do anything except taking its time, it demonstrates how to use the updateStatus function from your ZOO Service. 
+ processVersion = 1
+ storeSupported = true
+ statusSupported = true
+ serviceProvider = wps_status.zo
+ serviceType = C
+ <MetaData lang="en">
+   title = Demo GetStatus request
+ </MetaData>
+ <DataInputs>
+  [sid]
+   Title = Service ID
+   Abstract = A ZOO Service ID (unused).
+   minOccurs = 0
+   maxOccurs = 1
+   <LiteralData>
+    dataType = integer
+    <Default>
+     uom = meters
+    </Default>
+    <Supported>
+     uom = feet
+    </Supported>
+   </LiteralData>
+ </DataInputs>
+ <DataOutputs>
+  [Result]
+   Title = ExecuteResponse document
+   Abstract = The resulting ExecuteResponse document.
+   <MetaData lang="en">
+    title = Demo XSL use case
+   </MetaData>   
+   <LiteralData>
+    dataType = string
+    <Default>
+     uom = meters
+    </Default>
+    <Supported>
+     uom = feet
+    </Supported>
+   </LiteralData>
+ </DataOutputs>  
Index: /trunk/zoo-services/utils/status/service.c
===================================================================
--- /trunk/zoo-services/utils/status/service.c	(revision 26)
+++ /trunk/zoo-services/utils/status/service.c	(revision 26)
@@ -0,0 +1,132 @@
+/**
+ * Author : Gérald FENOY
+ *
+ * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * 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.h"
+
+extern "C" {
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <libxslt/xslt.h>
+#include <libxslt/xsltInternals.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
+
+#include <dirent.h>
+#include "service_internal.h"
+
+  /**
+   * GetStatus ZOO Service :
+   * This service is used in the ZOO-Project to get information about Services
+   * running as background tasks. The service will first get the XML document 
+   * cached by the ZOO-Kernel before calling effectively the Service, then 
+   * will access the shared memory space created by the Kernel to extract the 
+   * current status of the running Service. Using a simple XSL file it will 
+   * finally produce the final ExecuteResponse including the updated 
+   * percentCompleted attribute of the ProcessStarted node of the cached
+   * document if any (so if the Service is currently running) else it will 
+   * return the final ExecuteResponse stored on the Server file system.
+   */
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
+  int GetStatus(maps*& conf,maps*& inputs,maps*& outputs){
+    const char *params[2 + 1];
+    int xmlLoadExtDtdDefaultValue;
+    map* tmpMap=NULL,*tmpMmap=NULL, *tmpTmap=NULL;
+    tmpMap=getMapFromMaps(inputs,"sid","value");
+    tmpTmap=getMapFromMaps(conf,"main","tmpPath");
+    tmpMmap=getMapFromMaps(conf,"main","dataPath");
+    xmlInitParser();
+    struct dirent *dp;
+    DIR *dirp = opendir(tmpTmap->value);
+    char fileName[1024],xslFileName[1024];
+    if(dirp!=NULL){
+      char tmp[128];
+      sprintf(tmp,"_%s.xml",tmpMap->value);
+      while ((dp = readdir(dirp)) != NULL)
+	if(strstr(dp->d_name,tmp)!=0)
+	  sprintf(fileName,"%s/%s",tmpTmap->value,dp->d_name);
+    }else{  
+      setMapInMaps(conf,"lenv","message","GetStatus was unable to use the tmpPath value set in main.cfg file.");
+      return SERVICE_FAILED;
+    }
+    sprintf(xslFileName,"%s/updateStatus.xsl",tmpMmap->value);
+    xmlSubstituteEntitiesDefault(1);
+    xmlLoadExtDtdDefaultValue = 0;
+    xsltStylesheetPtr cur = NULL;
+    xmlDocPtr doc, res;
+    cur = xsltParseStylesheetFile(BAD_CAST xslFileName);
+    doc = xmlParseFile(fileName);
+    if(cur!=NULL && doc!=NULL){
+      params[0]="value";
+      params[1]=getStatus(atoi(tmpMap->value));
+      params[2]=NULL;
+      res = xsltApplyStylesheet(cur, doc, params);
+      xmlChar *xmlbuff;
+      int buffersize;
+      xmlDocDumpFormatMemory(res, &xmlbuff, &buffersize, 1);
+      setMapInMaps(outputs,"Result","value",(char*)xmlbuff);
+      setMapInMaps(outputs,"Result","mimeType","text/xml");
+      setMapInMaps(outputs,"Result","encoding","UTF-8");
+      xmlFree(xmlbuff);
+    }
+    else{   
+      char tmp[1024];
+      sprintf(tmp,"ZOO GetStatus Service was unable to find or parse the cache xml file available for the Service ID %s.",tmpMap->value);
+      setMapInMaps(conf,"lenv","message",tmp);
+      return SERVICE_FAILED;
+    }
+    return SERVICE_SUCCEEDED;
+  }
+
+
+  /**
+   * longProcess ZOO Service :
+   * Simple Service which just loop over 100 times then return a welcome message
+   * string, at each step the service will sleep for one second.
+   */
+#ifdef WIN32
+  __declspec(dllexport)
+#endif
+  int longProcess(maps*& conf,maps*& inputs,maps*& outputs){
+    int i=0;
+    while(i<100){
+      char tmp[4];
+      sprintf(tmp,"%i",i);
+      map* tmpMap=NULL;
+      tmpMap=getMapFromMaps(conf,"lenv","sid");
+      if(tmpMap!=NULL)
+	fprintf(stderr,"Status %s %s\n",tmpMap->value,tmp);
+      setMapInMaps(conf,"lenv","status",tmp);
+      updateStatus(conf);
+      sleep(1);
+      i+=5;
+    }
+    setMapInMaps(outputs,"Result","value","\"Running long process successfully\"");
+    return SERVICE_SUCCEEDED;
+  }
+
+}
