Index: trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 377)
+++ trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 383)
@@ -25,4 +25,8 @@
 #include "service_internal.h"
 
+#ifndef JSCLASS_GLOBAL_FLAGS
+#define JSCLSAS_GLOBAL_FLAGS 0
+#endif
+
 static char dbg[1024];
 
@@ -81,5 +85,5 @@
 
   /* The class of the global object. */
-  JSClass global_class = {
+  JSClass global_class= {
     "global", JSCLASS_GLOBAL_FLAGS,
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
@@ -99,9 +103,9 @@
   
   /* Create a context. */
-  cx = JS_NewContext(rt,8192);
+  cx = JS_NewContext(rt,81920);
   if (cx == NULL){
     return 1;
   }
-  JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT );//| JSOPTION_METHODJIT);
+  JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT | JSOPTION_METHODJIT);
   JS_SetVersion(cx, JSVERSION_LATEST);
   JS_SetErrorReporter(cx, reportError);
@@ -111,5 +115,5 @@
   global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
   //#else
-  //global = JS_NewObject(cx, &global_class, NULL,NULL);
+  //global = JS_NewObject(cx, &global_class, 0,0);
   //#endif
 
@@ -150,5 +154,5 @@
    * Load the first part of the ZOO-API
    */
-  char *api0=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+16);
+  char *api0=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+17);
   sprintf(api0,"%s/%s/ZOO-proj4js.js",ntmp,tmpm1->value);
 #ifdef JS_DEBUG
@@ -158,5 +162,5 @@
   fflush(stderr);
 
-  char *api1=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+11);
+  char *api1=(char*)malloc(strlen(tmpm1->value)+strlen(ntmp)+13);
   sprintf(api1,"%s/%s/ZOO-api.js",ntmp,tmpm1->value);
 #ifdef JS_DEBUG
@@ -200,4 +204,5 @@
     exit(-1);
   }
+
   /* Call a function in obj's scope. */
   jsval argv[3];
@@ -264,16 +269,30 @@
     fprintf(stderr," * %d * \n",res);
 #endif
-    jsval tmp2;
-    JSBool hasElement=JS_GetElement(cx,d,1,&tmp2);
-    if(hasElement==JS_TRUE){
-	  freeMaps(outputs);
-	  free(*outputs);
-      *outputs=mapsFromJSObject(cx,tmp2);
-    }
+    if(res==SERVICE_SUCCEEDED){
+      jsval tmp2;
+      JSBool hasElement=JS_GetElement(cx,d,1,&tmp2);
+      if(hasElement==JS_TRUE){
+	freeMaps(outputs);
+	free(*outputs);
+	*outputs=mapsFromJSObject(cx,tmp2);
+      }
+    }else{
+      jsval tmp3;
+      JSBool hasConf=JS_GetElement(cx,d,1,&tmp3);
+      if(hasConf==JS_TRUE){
+	freeMaps(main_conf);
+	free(*main_conf);
+	*main_conf=mapsFromJSObject(cx,tmp3);
+      }
+    }
+
   }
   else{
 #ifdef JS_DEBUG
-    fprintf(stderr,"The serice didn't return an array !\n");
-#endif
+    fprintf(stderr,"The service didn't return an array !\n");
+#endif
+    /**
+     * Extract result
+     */
     jsval tmp1;
     JSBool hasResult=JS_GetProperty(cx,d,"result",&tmp1);
@@ -283,15 +302,39 @@
     fprintf(stderr," * %d * \n",res);
 #endif
+    /**
+     * Extract outputs when available.
+     */
     jsval tmp2;
     JSBool hasElement=JS_GetProperty(cx,d,"outputs",&tmp2);
-#ifdef JS_DEBUG
-    if(!hasElement)
+    if(!JSVAL_IS_VOID(tmp2) && hasElement==JS_TRUE){
+      freeMaps(outputs);
+      free(*outputs);    
+      *outputs=mapsFromJSObject(cx,tmp2);
+    }
+    JS_MaybeGC(cx);
+#ifdef JS_DEBUG
+    if(JSVAL_IS_VOID(tmp2))
       fprintf(stderr,"No outputs property returned\n");
-    if(JS_IsArrayObject(cx,JSVAL_TO_OBJECT(tmp2)))
-      fprintf(stderr,"outputs is array an as expected\n");
-    else
-      fprintf(stderr,"outputs is not an array as expected\n");
-#endif
-    *outputs=mapsFromJSObject(cx,tmp2);
+    else{
+      if(JS_IsArrayObject(cx,JSVAL_TO_OBJECT(tmp2)))
+	fprintf(stderr,"outputs is an array as expected\n");
+      else
+	fprintf(stderr,"outputs is not an array as expected\n");
+    }
+    JS_MaybeGC(cx);
+#endif
+
+    /**
+     * Extract conf when available.
+     */
+    jsval tmp3;
+    JSBool hasConf=JS_GetProperty(cx,d,"conf",&tmp3);
+    if(!JSVAL_IS_VOID(tmp3) && hasConf==JS_TRUE){
+      freeMaps(main_conf);
+      free(*main_conf);
+      *main_conf=mapsFromJSObject(cx,tmp3);
+    }
+    JS_MaybeGC(cx);
+
 #ifdef JS_DEBUG
     dumpMaps(*outputs);
@@ -299,4 +342,5 @@
   }
   /* Cleanup. */
+  JS_MaybeGC(cx);
   JS_DestroyContext(cx);
   JS_DestroyRuntime(rt);
@@ -479,10 +523,8 @@
   jsuint len;
   JSBool hasLen=JS_GetArrayLength(cx, tt, &len);
+#ifdef JS_DEBUG
   if(hasLen==JS_FALSE){
-#ifdef JS_DEBUG
     fprintf(stderr,"outputs array is empty\n");
-#endif
-  }
-#ifdef JS_DEBUG
+  }
   fprintf(stderr,"outputs array length : %d\n",len);
 #endif
@@ -694,4 +736,5 @@
       tmp1=JSValToChar(cx,&tmp);
 #ifdef ULINET_DEBUG
+      curl_easy_setopt(handle.handle,CURLOPT_VERBOSE,1);
       fprintf(stderr,"Element of array n° %d, value : %s\n",i,tmp1);
 #endif
