Index: /trunk/zoo-kernel/service_conf.y
===================================================================
--- /trunk/zoo-kernel/service_conf.y	(revision 103)
+++ /trunk/zoo-kernel/service_conf.y	(revision 104)
@@ -169,13 +169,14 @@
       free(current_content);
       current_content=NULL;
+      wait_mainmetadata=false;
     }
     if(current_element==NULL){
 #ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"(DATAINPUTS - 184) FREE current_element\n");
+      fprintf(stderr,"(DATAINPUTS - %d) FREE current_element\n",__LINE__);
 #endif
       freeElements(&current_element);
       free(current_element);
 #ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"(DATAINPUTS - 186) ALLOCATE current_element\n");
+      fprintf(stderr,"(DATAINPUTS - %d) ALLOCATE current_element\n",__LINE__);
 #endif
       current_element=NULL;
@@ -197,5 +198,5 @@
       if(wait_inputs==true){
 #ifdef DEBUG_SERVICE_CONF
-	fprintf(stderr,"(DATAOUTPUTS) DUP INPUTS current_element\n");
+	fprintf(stderr,"(DATAOUTPUTS %d) DUP INPUTS current_element\n",__LINE__);
 	fprintf(stderr,"CURRENT_ELEMENT\n");
 	dumpElements(current_element);
@@ -225,5 +226,5 @@
       if(current_element==NULL){
 #ifdef DEBUG_SERVICE_CONF
-	fprintf(stderr,"(DATAOUTPUTS - 206) ALLOCATE current_element (%s)\n",$2);
+	fprintf(stderr,"(DATAOUTPUTS - %d) ALLOCATE current_element (%s)\n",__LINE__,$2);
 #endif
 	current_element=(elements*)malloc(ELEMENTS_SIZE);
@@ -247,13 +248,19 @@
 #ifdef DEBUG_SERVICE_CONF
 	  fprintf(stderr,"add current_content to current_element->content\n");
-	  fprintf(stderr,"LINE 247");
+	  fprintf(stderr,"LINE %d",__LINE__);
 #endif
 	  addMapToMap(&current_element->content,current_content);
 	  freeMap(&current_content);
 	  free(current_content);
-	  wait_metadata=true;
+	  if(previous_data==1 || previous_data==2)
+	    wait_metadata=true;
+	  else
+	    wait_mainmetadata=true;
 	}
 	else{
-	  wait_mainmetadata=true;
+	  if(previous_data==1 || previous_data==2)
+	    wait_metadata=true;
+	  else
+	    wait_mainmetadata=true;
 	}
 	current_content=NULL;
@@ -268,5 +275,7 @@
 	      addMapToMap(&current_element->metadata,current_content);
 	      current_element->next=NULL;
-	      current_element->format=strdup($2);
+	      if($2!=NULL)
+		current_element->format=strdup($2);
+	      
 	      current_element->defaults=NULL;
 	      current_element->supported=NULL;
@@ -281,4 +290,5 @@
 	    current_element->metadata=NULL;
 	    current_element->next=NULL;
+	    if($2!=NULL)
 	    current_element->format=strdup($2);
 	    current_element->defaults=NULL;
@@ -347,5 +357,5 @@
 //======================================================
 EmptyElemTag
- : INFCAR ID Attributeetoile SLASH SUPCAR	{/*lattribute.clear();/* voir Stag */}
+ : INFCAR ID Attributeetoile SLASH SUPCAR	{}
  ;
 
@@ -368,5 +378,4 @@
   if(strcmp($3,"MetaData")==0){
     current_data=previous_data;
-    wait_metadata=true;
   }
   if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0 
@@ -467,32 +476,34 @@
 //======================================================
 
-pair: PAIR {  if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} }
+pair: PAIR { if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} }
 | EPAIR {
 #ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"EPAIR FOUND !! \n"); 
-    fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
-    fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-    dumpMap(current_content);
-    fflush(stderr);
-#endif
-  if(current_content==NULL){
-#ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-#endif
-    current_content=createMap(curr_key,$1);
-#ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
-#endif
-    //current_content->next=NULL;
-  }
-  else{ 
-#ifdef DEBUG_SERVICE_CONF
-    dumpMap(current_content);
-    fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1); 
-#endif
-    addToMap(current_content,curr_key,$1);
-#ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1); 
+  fprintf(stderr,"EPAIR FOUND !! \n"); 
+  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
+  fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
+  dumpMap(current_content);
+  fflush(stderr);
+#endif
+  if($1!=NULL){
+    if(current_content==NULL){
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
+#endif
+      current_content=createMap(curr_key,$1);
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
+#endif
+      //current_content->next=NULL;
+    }
+    else{ 
+#ifdef DEBUG_SERVICE_CONF
+      dumpMap(current_content);
+      fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1); 
+#endif
+      addToMap(current_content,curr_key,$1);
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1); 
 #endif    
+    }
   }
 #ifdef DEBUG_SERVICE_CONF
@@ -507,5 +518,5 @@
   }
   }
-| SPAIR  { curr_key=strdup($1);if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); }
+| SPAIR  { if(curr_key!=NULL) {free(curr_key);curr_key=NULL;} if($1!=NULL) curr_key=strdup($1);if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); }
  ;
 
@@ -515,15 +526,17 @@
   if(data==-1){
     data=1;
-    char *cen=strdup($1);
-    my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
-    cen[strlen(cen)-1]=0;
-    cen+=1;
-    sprintf(my_service->name,"%s",cen);
-    cen-=1;
-    free(cen);
-    my_service->content=NULL;
-    my_service->metadata=NULL;
-    my_service->inputs=NULL;
-    my_service->outputs=NULL;
+    if($1!=NULL){
+      char *cen=strdup($1);
+      my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
+      cen[strlen(cen)-1]=0;
+      cen+=1;
+      sprintf(my_service->name,"%s",cen);
+      cen-=1;
+      free(cen);
+      my_service->content=NULL;
+      my_service->metadata=NULL;
+      my_service->inputs=NULL;
+      my_service->outputs=NULL;
+    }
   } else {
     if(current_data==1){
@@ -567,23 +580,25 @@
 	fprintf(stderr,"(DATAINPUTS - 501) SET NAME OF current_element\n");
 #endif
-	char *cen=strdup($1);
-	current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
-	cen[strlen(cen)-1]=0;
-	cen+=1;
-	sprintf(current_element->name,"%s",cen);
-	cen-=1;
-	free(cen);
-#ifdef DEBUG_SERVICE_CONF
-	fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
-#endif
-	current_element->content=NULL;
-	current_element->metadata=NULL;
-	current_element->format=NULL;
-	current_element->defaults=NULL;
-	current_element->supported=NULL;
-	current_element->next=NULL;
-#ifdef DEBUG_SERVICE_CONF
-	fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
-#endif
+	if($1!=NULL){ 
+	  char *cen=strdup($1);
+	  current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
+	  cen[strlen(cen)-1]=0;
+	  cen+=1;
+	  sprintf(current_element->name,"%s",cen);
+	  cen-=1;
+	  free(cen);
+#ifdef DEBUG_SERVICE_CONF
+	  fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
+#endif
+	  current_element->content=NULL;
+	  current_element->metadata=NULL;
+	  current_element->format=NULL;
+	  current_element->defaults=NULL;
+	  current_element->supported=NULL;
+	  current_element->next=NULL;
+#ifdef DEBUG_SERVICE_CONF
+	  fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
+#endif
+	}
       }
     }
@@ -611,5 +626,5 @@
 	    current_element=NULL;
 #ifdef DEBUG_SERVICE_CONF
-	    fprintf(stderr,"(DATAOUTPUTS) ALLOCATE current_element %s %i\n",__FILE__,__LINE__);
+	    fprintf(stderr,"(DATAOUTPUTS -%d) ALLOCATE current_element %s \n",__LINE__,__FILE__);
 #endif
 	    current_element=(elements*)malloc(ELEMENTS_SIZE);
@@ -625,19 +640,21 @@
 #ifdef DEBUG_SERVICE_CONF
 	    fprintf(stderr,"NAME OUT %s\n",$1);
-	    fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n");
-#endif
-	    char *cen=strdup($1);
-	    current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
-	    cen[strlen(cen)-1]=0;
-	    cen+=1;
-	    sprintf(current_element->name,"%s",cen);
-	    cen-=1;
-	    free(cen);
-	    current_element->content=NULL;
-	    current_element->metadata=NULL;
-	    current_element->format=NULL;
-	    current_element->defaults=NULL;
-	    current_element->supported=NULL;
-	    current_element->next=NULL;
+	    fprintf(stderr,"(DATAOUTPUTS - %d) SET NAME OF current_element\n",__LINE__);
+#endif
+	    if($1!=NULL){ 
+	      char *cen=strdup($1);
+	      current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
+	      cen[strlen(cen)-1]=0;
+	      cen+=1;
+	      sprintf(current_element->name,"%s",cen);
+	      cen-=1;
+	      free(cen);
+	      current_element->content=NULL;
+	      current_element->metadata=NULL;
+	      current_element->format=NULL;
+	      current_element->defaults=NULL;
+	      current_element->supported=NULL;
+	      current_element->next=NULL;
+	    }
 	  }
 
@@ -663,20 +680,22 @@
 	    fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n");
 #endif
-	    char *cen=strdup($1);
-	    current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
-	    cen[strlen(cen)-1]=0;
+	    if($1!=NULL){ 
+	      char *cen=strdup($1);
+	      current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
+	      cen[strlen(cen)-1]=0;
 #ifdef DEBUG
-	    fprintf(stderr,"tmp %s\n",cen);
-#endif
-	    cen+=1;
-	    sprintf(current_element->name,"%s",cen);
-	    cen-=1;
-	    free(cen);
-	    current_element->content=NULL;
-	    current_element->metadata=NULL;
-	    current_element->format=NULL;
-	    current_element->defaults=NULL;
-	    current_element->supported=NULL;
-	    current_element->next=NULL;
+	      fprintf(stderr,"tmp %s\n",cen);
+#endif
+	      cen+=1;
+	      sprintf(current_element->name,"%s",cen);
+	      cen-=1;
+	      free(cen);
+	      current_element->content=NULL;
+	      current_element->metadata=NULL;
+	      current_element->format=NULL;
+	      current_element->defaults=NULL;
+	      current_element->supported=NULL;
+	      current_element->next=NULL;
+	    }
 	  }
 	wait_inputs=false;
@@ -746,5 +765,5 @@
     if(my_service->outputs==NULL){      
 #ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"(DATAOUTPUTS - 623) DUP current_element\n");
+      fprintf(stderr,"(DATAOUTPUTS - %d) DUP current_element\n",__LINE__);
 #endif
       my_service->outputs=dupElements(current_element);
@@ -753,10 +772,10 @@
     else{
 #ifdef DEBUG_SERVICE_CONF
-      fprintf(stderr,"(DATAOUTPUTS - 628) COPY current_element\n");
+      fprintf(stderr,"(DATAOUTPUTS - %d) COPY current_element\n",__LINE__);
 #endif
       addToElements(&my_service->outputs,current_element);
     }
 #ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"(DATAOUTPUTS - 631) FREE current_element\n");
+    fprintf(stderr,"(DATAOUTPUTS - %d) FREE current_element\n",__LINE__);
 #endif
     freeElements(&current_element);
@@ -764,5 +783,5 @@
     current_element=NULL;
 #ifdef DEBUG_SERVICE_CONF
-    fprintf(stderr,"(DATAOUTPUTS - 631) FREE current_element\n");
+    fprintf(stderr,"(DATAOUTPUTS - %d) FREE current_element\n",__LINE__);
 #endif
   }
