Index: trunk/zoo-project/HISTORY.txt
===================================================================
--- trunk/zoo-project/HISTORY.txt	(revision 620)
+++ trunk/zoo-project/HISTORY.txt	(revision 621)
@@ -9,5 +9,9 @@
   * Fix maxOccurs handling
   * Fix gesture of downloaded inputs when multiple values are given
-  * Add detection of generated_file key in outputs to read the file generated by a service
+  * Add detection of generated_file key in outputs to read the file
+  generated by a service
+  * Add a minimal parsing API 
+  * Run validateRequest (download, default settings and decoding)
+  after fork if any
 
 Version 1.4.0
@@ -19,19 +23,28 @@
   * ZOO-Client Javascript API
   * FastCGI fixes
-  * JavaScript ZOO-API enhancements (COOKIE use and Output in generated XML)
+  * JavaScript ZOO-API enhancements (COOKIE use and Output in
+  generated XML)
   * Add debian files
   * Inputs passed by reference downloaded in parallel
-  * Conform behavior for DescribeProcess when the Identifier was not found
+  * Conform behavior for DescribeProcess when the Identifier was not
+  found
   * Add support of maximumMegabytes keywords for ComplexData Inputs
   * Add the optional YAML ZCFG support #4 and the zcfg2yaml converter
-  * Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax (ticket #90)
+  * Return error messages that enable the service provider to quickly
+  identify the root cause of errors due to configuration file syntax
+  (ticket #90)
   * Fix logic in addMapToMap (ticket #91)
-  * Enable AllowedValue and multiple Range definitions using default and supported blocks
-  * Add the lastest revision number in version.h (available in Python ZOO-API)
-  * Add the optional Ruby Language Support to the ZOO-Kernel with an API similar to the Python ZOO-API
+  * Enable AllowedValue and multiple Range definitions using default
+  and supported blocks
+  * Add the lastest revision number in version.h (available in Python
+  ZOO-API)
+  * Add the optional Ruby Language Support to the ZOO-Kernel with an
+  API similar to the Python ZOO-API
   * Small rewrite of Python support
   * Inputs can be requested over https protocol (ticket #86)
-  * Add capability to define both percentage of execution and a message (ticket #87). 
-  * Add usid in lenv section used to generate an unique identifier based on time and the process identifier.
+  * Add capability to define both percentage of execution and a
+  message (ticket #87). 
+  * Add usid in lenv section used to generate an unique identifier
+  based on time and the process identifier.
   * Add gdal_contour service
   * Add dynamic definition of serverAddress from the main section
@@ -45,17 +58,21 @@
 Version 1.3.0-rc1
 
-  * Updating ZOO.Class object with the OpenLayers.Class Updating ZOO.Class with the (ticket #64)
+  * Updating ZOO.Class object with the OpenLayers.Class Updating
+    ZOO.Class with the (ticket #64)
   * Correct the content of proj4js (ticket #63)
   * Enhance the COOKIE gesture (ticket #68)
   * Support for dataInputs URLEncoded and xlink:href (ticket #62)
-  * Use the same object structure for JavaScript arguments than for Python
+  * Use the same object structure for JavaScript arguments than for
+    Python
   * Add the Normalized Difference Vegetation Index service
   * Add importScripts function to JavaScript support (ticket #66)
   * Add multiple inputs values for the same identifier (ticket #72)
   * Add Python ZOO-API to access ZOO-Kernel internel functions
-  * Add a [headers] section in main.cfg file to add specifics to header returned
+  * Add a [headers] section in main.cfg file to add specifics to
+    header returned
   * Add support for multiple outputs for both GET and POST requests
   * Add Content-Length to the headers if the result is sized
-  * Add Content-Disposition to the headers if the result contains a filename
+  * Add Content-Disposition to the headers if the result contains a
+    filename
   * Add support for sending headers through JS ZOO-api
   * Add support for multi-valued inputs in JS ZOO-api
@@ -68,5 +85,6 @@
 
   * add basic SOAP Envelope support (ticket #49)
-  * support request when Content-Length header is not set by the client (ticket #57)
+  * support request when Content-Length header is not set by the
+  * client (ticket #57)
   * fix issue when POST request is empty (ticket #45)
   * add minimalist cache system (ticket #51)
Index: trunk/zoo-project/zoo-kernel/Makefile.in
===================================================================
--- trunk/zoo-project/zoo-kernel/Makefile.in	(revision 620)
+++ trunk/zoo-project/zoo-kernel/Makefile.in	(revision 621)
@@ -32,4 +32,7 @@
 ulinet.o: ulinet.c
 	gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c
+
+request_parser.o: request_parser.c request_parser.h
+	gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c
 
 service_internal.o: service_internal.c service.h mimetypes.h
@@ -72,7 +75,7 @@
 	g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${OTB_ENABLED} ${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: 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} ${OTB_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 request_parser.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_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} ${OTBCFLAGS} ${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} ${OTB_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
+	g++  ${JSCFLAGS} ${OTBCFLAGS} ${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} ${OTB_FILE} request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
 
 zcfg2yaml: zcfg2yaml.c  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} ${JS_FILE} ${RUBY_FILE}  ${YAML_FILE}
Index: trunk/zoo-project/zoo-kernel/main_conf_read.l
===================================================================
--- trunk/zoo-project/zoo-kernel/main_conf_read.l	(revision 620)
+++ trunk/zoo-project/zoo-kernel/main_conf_read.l	(revision 621)
@@ -1,31 +1,36 @@
-/* Line number from bison */
+/*
+ * Zoo main configuration file parser
+ *
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 209-2015 GeoLabs SARL
+ *
+ * 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.
+ */
 %option yylineno
 
 %{
-//======================================================
-/**
-Zoo main configuration file parser
-**/
-//======================================================
-
 
 #include <string.h>
 #include "main_conf_read.tab.h"
 static int affichetrace = 0 ;
-static int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
-static int attentionImpossibleDeTrouverPIapres = 0 ;
 
 %}
-
-
-S		[ \t\r\n]+
-
-CharRef		"&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";"
-
-egalevolue		{S}?"="{S}?
-
-Name		([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])*
-
-chardata	[^<]*
 
 attname	[a-zA-Z0-9_\-:]+
@@ -33,19 +38,8 @@
 attvalue1	[%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
 
-attvalue		\"[^"]*\"|\'[^']*\'
-
-virgule	[,]+
-
-whitespace                      [ ]{0,}
 whitesp                      [ ]
 newline                 [\r\n]|[\n]
-newlines                 [\r\n]{1,}|[\n]{1,}
-
-
 
 %x DANSBALISE HORSBALISE PAIRSTART
-
-
-
 
 %%
@@ -65,52 +59,4 @@
 <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*			{if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;}
 
-<INITIAL>"<?"[Xx][Mm][Ll]  { if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) { printf("\nerror : LINE %d : comment ot PI before xml declaration\n",yylineno); exit (10) ; } ; if (affichetrace==1) printf ("\n\nSTARTXMLDECL:%s\n",yytext) ;return STARTXMLDECL;}
-
-<INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\'  {if (affichetrace==1) printf ("\n\nVERSIONDECL:%s\n",yytext) ;return VERSIONDECL;}
-<INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\'  {/* erreur de version encoding */ 	printf("\nerror : LINE %d : XML Version not supported : %s\n",yylineno,yytext); exit (9) ; }
-
-
-<INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\'  {if (affichetrace==1) printf ("\n\nENCODINGDECL:%s\n",yytext) ; return ENCODINGDECL;}
-<INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\'  {/* erreur de version encoding */ 	printf("\nerror : LINE %d : encoding version not supported : %s\n",yylineno,yytext); exit (8) ; }
-
-
-<INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\'  {if (affichetrace==1) printf ("\n\nSDDECL:%s\n",yytext) ; return SDDECL;}
-
-<INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'  {/* erreur de version encoding */ 	printf("\nerror : LINE %d : standalone version not supported : %s\n",yylineno,yytext); exit (7) ; }
-
-
-<INITIAL>"?>"  {if (affichetrace==1) printf ("\n\nENDXMLDECL:%s\n",yytext) ; BEGIN(HORSBALISE);return ENDXMLDECL;}
-
-
-<DANSBALISE,INITIAL,HORSBALISE>{S}   {if (affichetrace==1) printf ("\n\nS:'%s'\n",yytext) ; }
-
-
-<HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>"	{if (affichetrace==1) printf ("\n\nPIERROR:%s\n",yytext) ; return PIERROR;}
-<INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>"		{attentionImpossibleDeTrouverPIapres=1 ;  if (affichetrace==1) printf ("\n\nPI:%s\n",yytext) ; return PI;}
-
-
-<INITIAL,HORSBALISE>{newline}*"<"		    {if (affichetrace==1) printf ("\n\nINFCAR:%s\n",yytext) ; BEGIN(DANSBALISE);return INFCAR;}
-
-
-<DANSBALISE>">"			{if (affichetrace==1) printf ("\n\nSUPCAR:%s\n",yytext) ; BEGIN(HORSBALISE);return SUPCAR;}
-
-
-<DANSBALISE>"/"		{if (affichetrace==1) printf ("\n\nSLASH:%s\n",yytext) ; return SLASH;}
-
-
-<DANSBALISE>{egalevolue}			{if (affichetrace==1) printf ("\n\nEq:'%s'\n",yytext) ; return Eq;}
-
-
-<DANSBALISE>{Name}			{if (affichetrace==1) printf ("\n\nID:%s\n",yytext) ; crlval.s=yytext;return ID;}
-
-
-<DANSBALISE>{attvalue}		{if (affichetrace==1) printf ("\n\nATTVALUE:%s\n",yytext) ; return ATTVALUE;}
-
-
-<INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->"		{attentionImpossibleDeTrouverXMLDeclapres=1; }
-
-
-<INITIAL,DANSBALISE,HORSBALISE>.|\n	{if (affichetrace==1)printf("error : LINE %d : character not supported '%s'\n",yylineno,yytext); }
-
 %%
 
Index: trunk/zoo-project/zoo-kernel/main_conf_read.y
===================================================================
--- trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 620)
+++ trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 621)
@@ -1,6 +1,28 @@
-%{
 /*
  * Zoo main configuration file parser
+ *
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 209-2015 GeoLabs SARL
+ *
+ * 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>
 
@@ -28,30 +50,10 @@
 %}
 
+%union { char* s;char* chaine; char* key;char* val;}
 
-
-//======================================================
-/* le type des lval des jetons et des elements non terminaux bison */
-//======================================================
-%union { char* s;char* chaine; char* key;char* val;}
-//======================================================
-
-// jetons //
-//======================================================
-/* les jetons que l on retrouve dans FLEX */
-//======================================================
-/* texte on a besoin de récupérer une valeur char* pour la comparer */
 %token <s> ID
 %token <s> CHAINE
-/* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
-%token STARTXMLDECL ENDXMLDECL
-//======================================================
-/* version="xxx" et encoding="xxx" */
-%token VERSIONDECL ENCODINGDECL SDDECL
-//======================================================
-/* < et > */
-%token INFCAR SUPCAR 
-//======================================================
-/* / = a1  texte "texte" */
-%token SLASH Eq CHARDATA ATTVALUE PAIR SPAIR EPAIR EPAIRS ANID
+
+%token PAIR SPAIR EPAIR EPAIRS ANID
 %type <chaine> PAIR
 %type <chaine> EPAIRS
@@ -59,185 +61,31 @@
 %type <chaine> SPAIR
 
-//======================================================
-/* <!-- xxx -> <? xxx yyy ?> */
-%token PI PIERROR /** COMMENT **/
-//======================================================
-/* <!-- xxx -> <? xxx yyy ?> */
-%token ERREURGENERALE CDATA WHITESPACE NEWLINE
-//======================================================
-// non terminaux typés
-//======================================================
-/* elements non terminaux de type char *     */
-/* uniquement ceux qui devrons etre comparés */
-//======================================================
-%type <s> STag
-%type <s> ETag
+%token WHITESPACE NEWLINE
+
 %type <s> ANID
-//======================================================
-// %start
-//======================================================
 
 %%
-// document <//===
-//======================================================
-// regle 1
-// on est a la racine du fichier xml
-//======================================================
+
 document
- : miscetoile element miscetoile {}
+ : miscetoile miscetoile {}
  | contentetoile processid contentetoile document {}
  ;
 
 miscetoile
- : miscetoile PIERROR {crerror("processing instruction begining with <?xml ?> impossible\n");}
- | miscetoile PI {}
- | {}
+ : {}
  ;
-// element
-//======================================================
-// regle 39
-// OUVRANTE CONTENU FERMANTE obligatoirement
-// ou neutre
-// on ne peut pas avoir Epsilon
-// un fichier xml ne peut pas etre vide ou seulement avec un prolog
-//======================================================
-element
- : STag contentetoile ETag	
-{
-  /* les non terminaux rendent les valeurs de leur identifiants de balise */
-  /* en char*, donc on peut comparer ces valeurs avec la fonction C++ strcmp(const char*;const char*) */
-  /* de string */
-  if (strcmp($1,$3) != 0)
-    {
-      crerror("Opening and ending tag mismatch");
-      printf("\n  ::details : tag '%s' et '%s' \n",$1,$3);
-      return 1;
-      // on retourne different de 0
-      // sinon yyparse rendra 0
-      // et dans le main on croira a le fichier xml est valide !
-    }
-}
-// pour neutre
-// on a rien a faire, meme pas renvoyer l identificateur de balise
-// vu qu'il n y a pas de comparaison d'identificateurs avec un balise jumelle .
- | EmptyElemTag          {}
- ;
-//======================================================
-// STag
-//======================================================
-// regle 40
-// BALISE OUVRANTE
-// on est obligé de faire appel a infcar et supcar
-// pour acceder aux start conditions DANSBALISE et INITIAL
-//======================================================
-STag
- : INFCAR ID Attributeetoile SUPCAR
-{	
 
-#ifdef DEBUG
-	printf("* Identifiant : %s\n",$2);
-#endif
-	
-	$$ = $2 ;
-}
- ;
-//======================================================
-// Attributeetoile
-//======================================================
-// regle 41
-// une liste qui peut etre vide d'attributs
-// utiliser la récursivité a gauche
-//======================================================
 Attributeetoile
- : Attributeetoile attribute  {}
+ : Attributeetoile  {}
  | 	                          {/* Epsilon */}
  ;
-//======================================================
-// attribute
-//======================================================
-// regle 41
-// un attribut est compose d'un identifiant
-// d'un "="
-// et d'une définition de chaine de caractere
-// ( "xxx" ou 'xxx' )
-//======================================================
-attribute
- : ID Eq ATTVALUE		
-{
-	// on verifie que les attributst ne sont pas en double
-	// sinon on ajoute au vector
-}
- ;
-//======================================================
-// EmptyElemTag
-//======================================================
-// regle 44
-// ICI ON DEFINIT NEUTRE
-// on ne renvoie pas de char*
-// parce qu'il n'y a pas de comparaisons a faire
-// avec un identifiant d'une balise jumelle
-//======================================================
-EmptyElemTag
- : INFCAR ID Attributeetoile SLASH SUPCAR	{}
- ;
-//======================================================
-// ETag
-//======================================================
-// regle 42
-// BALISE FERMANTE
-// les separateurs après ID sont filtrés
-//======================================================
-ETag
- : INFCAR SLASH ID SUPCAR
-{
-  /* on renvoie l'identifiant de la balise pour pouvoir comparer les 2 */
-  /* /!\ une balise fermante n'a pas d'attributs (c.f. : W3C) */
-  $$ = $3;
-}
- ;
-//======================================================
-// contentetoile
-//======================================================
-// regle 43
-// ENTRE 2 BALISES
-// entre 2 balises, on peut avoir :
-// --- OUVRANTE CONTENU FERMANTE (recursivement !)
-// --- DU TEXTE quelconque
-// --- COMMENTS 
-// --- DES PROCESSES INSTRUCTIONS
-// --- /!\ il peut y avoir une processing instruction invalide ! <?xml
-// --- EPSILON
-// ### et/ou tout ca a la suite en nombre indeterminé
-// ### donc c'est un operateur etoile (*)
-//======================================================
+
 contentetoile
-: contentetoile element	          {}
- | contentetoile PIERROR	          {crerror("processing instruction <?xml ?> impossible\n");}
- | contentetoile PI	                  {}
-///// on filtre les commentaires | contentetoile comment              {} 
- | contentetoile NEWLINE {/*printf("NEWLINE FOUND !!");*/}
+: contentetoile NEWLINE {}
  | contentetoile pair {}
- | contentetoile processid {}
- | contentetoile texteinterbalise	  {}
- | contentetoile CDATA {}  
  | {/* Epsilon */}
  ;
-//======================================================
-// texteinterbalise
-//======================================================
-// regle 14
-// DU TEXTE quelconque
-// c'est du CHARDATA
-// il y a eut un probleme avec ID,
-// on a mis des starts conditions,
-// maintenant on croise les ID dans les dbalises
-// et des CHARDATA hors des balises
-//======================================================
-texteinterbalise
- : CHARDATA		{}
- ;
-//======================================================
 
-pair: PAIR {curr_key=zStrdup($1);/*printf("START 0 PAIR FOUND !! \n [%s]\n",$1);*/}
+pair: PAIR {curr_key=zStrdup($1);}
 | EPAIR {
   if(current_content==NULL) 
Index: trunk/zoo-project/zoo-kernel/request_parser.c
===================================================================
--- trunk/zoo-project/zoo-kernel/request_parser.c	(revision 621)
+++ trunk/zoo-project/zoo-kernel/request_parser.c	(revision 621)
@@ -0,0 +1,1460 @@
+/*
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 2015 GeoLabs SARL
+ *
+ * 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 "request_parser.h"
+#include "service_internal.h"
+
+/**
+ * Apply XPath Expression on XML document.
+ *
+ * @param doc the XML Document
+ * @param search the XPath expression
+ * @return xmlXPathObjectPtr containing the resulting nodes set
+ */
+xmlXPathObjectPtr
+extractFromDoc (xmlDocPtr doc, const char *search)
+{
+  xmlXPathContextPtr xpathCtx;
+  xmlXPathObjectPtr xpathObj;
+  xpathCtx = xmlXPathNewContext (doc);
+  xpathObj = xmlXPathEvalExpression (BAD_CAST search, xpathCtx);
+  xmlXPathFreeContext (xpathCtx);
+  return xpathObj;
+}
+
+/**
+ * Create (or append to) an array valued maps value = "["",""]"
+ *
+ * @param m the conf maps containing the main.cfg settings
+ * @param mo the map to update
+ * @param mi the map to append
+ * @param elem the elements containing default definitions
+ * @return 0 on success, -1 on failure
+ */
+int appendMapsToMaps (maps * m, maps * mo, maps * mi, elements * elem){
+  maps *tmpMaps = getMaps (mo, mi->name);
+  map *tmap = getMapType (tmpMaps->content);
+  elements *el = getElements (elem, mi->name);
+  int hasEl = 1;
+  if (el == NULL)
+    hasEl = -1;
+  if (tmap == NULL)
+    {
+      if (hasEl > 0)
+	tmap = getMapType (el->defaults->content);
+    }
+  
+  map *testMap = NULL;
+  if (hasEl > 0)
+    {
+      testMap = getMap (el->content, "maxOccurs");
+    }
+  else
+    {
+      testMap = createMap ("maxOccurs", "unbounded");
+    }
+    
+  if (testMap != NULL)
+    {
+      if (strncasecmp (testMap->value, "unbounded", 9) != 0
+	  && atoi (testMap->value) > 1)
+	{
+	  addMapsArrayToMaps (&mo, mi, tmap->name);
+	  map* nb=getMapFromMaps(mo,mi->name,"length");
+	  if (nb!=NULL && atoi(nb->value)>atoi(testMap->value))
+	    {
+	      char emsg[1024];
+	      sprintf (emsg,
+		       _("The maximum allowed occurrences for <%s> (%i) was exceeded."),
+		       mi->name, atoi (testMap->value));
+	      errorException (m, emsg, "InternalError", NULL);
+	      return -1;
+	    }
+	}
+      else
+	{
+	  if (strncasecmp (testMap->value, "unbounded", 9) == 0)
+	    {
+	      if (hasEl < 0)
+		{
+		  freeMap (&testMap);
+		  free (testMap);
+		}
+	      if (addMapsArrayToMaps (&mo, mi, tmap->name) < 0)
+		{
+		  char emsg[1024];
+		  map *tmpMap = getMap (mi->content, "length");
+		  sprintf (emsg,
+			   _
+			   ("ZOO-Kernel was unable to load your data for %s position %s."),
+			   mi->name, tmpMap->value);
+		  errorException (m, emsg, "InternalError", NULL);
+		  return -1;
+		}
+	    }
+	  else
+	    {
+	      char emsg[1024];
+	      sprintf (emsg,
+		       _
+		       ("The maximum allowed occurrences for <%s> is one."),
+		       mi->name);
+	      errorException (m, emsg, "InternalError", NULL);
+	      return -1;
+	    }
+	}
+    }
+  return 0;
+}
+
+/**
+ * Parse inputs provided as KVP and store them in a maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param s the service
+ * @param request_inputs the map storing KVP raw value 
+ * @param request_output the maps to store the KVP pairs 
+ * @param hInternet the HINTERNET queue to add potential requests
+ * @return 0 on success, -1 on failure
+ */
+int kvpParseInputs(maps** main_conf,service* s,map *request_inputs,maps** request_output,HINTERNET* hInternet){
+  // Parsing inputs provided as KVP
+  maps *tmpmaps = *request_output;
+  map* r_inputs = getMap (request_inputs, "DataInputs");
+  char* cursor_input;
+  if (r_inputs != NULL){
+    //snprintf (cursor_input, 40960, "%s", r_inputs->value);
+    cursor_input = zStrdup (r_inputs->value);
+    int j = 0;
+
+    // Put each DataInputs into the inputs_as_text array
+    char *pToken;
+    pToken = strtok (cursor_input, ";");
+    char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
+    if (inputs_as_text == NULL)
+      {
+	return errorException (*main_conf, _("Unable to allocate memory."),
+			       "InternalError", NULL);
+      }
+    int i = 0;
+    while (pToken != NULL)
+      {
+	inputs_as_text[i] =
+	  (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
+	if (inputs_as_text[i] == NULL)
+	  {
+	    return errorException (*main_conf, _("Unable to allocate memory."),
+				   "InternalError", NULL);
+	  }
+	snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
+	pToken = strtok (NULL, ";");
+	i++;
+      }
+	
+    for (j = 0; j < i; j++)
+      {
+	char *tmp = zStrdup (inputs_as_text[j]);
+	free (inputs_as_text[j]);
+	char *tmpc;
+	tmpc = strtok (tmp, "@");
+	while (tmpc != NULL)
+	  {
+	    char *tmpv = strstr (tmpc, "=");
+	    char tmpn[256];
+	    memset (tmpn, 0, 256);
+	    if (tmpv != NULL)
+	      {
+		strncpy (tmpn, tmpc,
+			 (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
+		tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
+	      }
+	    else
+	      {
+		strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
+		tmpn[strlen (tmpc)] = 0;
+	      }
+	    if (tmpmaps == NULL)
+	      {
+		tmpmaps = (maps *) malloc (MAPS_SIZE);
+		if (tmpmaps == NULL)
+		  {
+		    return errorException (*main_conf,
+					   _("Unable to allocate memory."),
+					   "InternalError", NULL);
+		  }
+		tmpmaps->name = zStrdup (tmpn);
+		if (tmpv != NULL)
+		  {
+		    char *tmpvf = url_decode (tmpv + 1);
+		    tmpmaps->content = createMap ("value", tmpvf);
+		    free (tmpvf);
+		  }
+		else
+		  tmpmaps->content = createMap ("value", "Reference");
+		tmpmaps->next = NULL;
+	      }
+	    tmpc = strtok (NULL, "@");
+	    while (tmpc != NULL)
+	      {
+		char *tmpv1 = strstr (tmpc, "=");
+		char tmpn1[1024];
+		memset (tmpn1, 0, 1024);
+		if (tmpv1 != NULL)
+		  {
+		    strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
+		    tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
+		    addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
+		  }
+		else
+		  {
+		    strncpy (tmpn1, tmpc, strlen (tmpc));
+		    tmpn1[strlen (tmpc)] = 0;
+		    map *lmap = getLastMap (tmpmaps->content);
+		    char *tmpValue =
+		      (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
+				       sizeof (char));
+		    sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
+		    free (lmap->value);
+		    lmap->value = zStrdup (tmpValue);
+		    free (tmpValue);
+		    tmpc = strtok (NULL, "@");
+		    continue;
+		  }
+		if (strcmp (tmpn1, "xlink:href") != 0)
+		  addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
+		else if (tmpv1 != NULL)
+		  {
+		    char *tmpx2 = url_decode (tmpv1 + 1);
+		    if (strncasecmp (tmpx2, "http://", 7) != 0 &&
+			strncasecmp (tmpx2, "ftp://", 6) != 0 &&
+			strncasecmp (tmpx2, "https://", 8) != 0)
+		      {
+			char emsg[1024];
+			sprintf (emsg,
+				 _
+				 ("Unable to find a valid protocol to download the remote file %s"),
+				 tmpv1 + 1);
+			return errorException (*main_conf, emsg, "InternalError", NULL);
+		      }
+		    addToMap (tmpmaps->content, tmpn1, tmpx2);
+		    {
+		      if (loadRemoteFile
+			  (&*main_conf, &tmpmaps->content, hInternet, tmpx2) < 0)
+			{
+			  return errorException (*main_conf, "Unable to fetch any ressource", "InternalError", NULL);
+			  }
+		      }
+		    free (tmpx2);
+		    addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
+		  }
+		tmpc = strtok (NULL, "@");
+	      }
+	    if (*request_output == NULL)
+	      *request_output = dupMaps (&tmpmaps);
+	    else
+	      {
+		maps *testPresence =
+		  getMaps (*request_output, tmpmaps->name);
+		if (testPresence != NULL)
+		  {
+		    elements *elem =
+		      getElements (s->inputs, tmpmaps->name);
+		    if (elem != NULL)
+		      {
+			if (appendMapsToMaps
+			    (*main_conf, *request_output, tmpmaps,
+			     elem) < 0)
+			  {
+			    return errorException (*main_conf, "Unable to append maps", "InternalError", NULL);
+			  }
+		      }
+		  }
+		else
+		  addMapsToMaps (&(*request_output), tmpmaps);
+	      }
+	    freeMaps (&tmpmaps);
+	    free (tmpmaps);
+	    tmpmaps = NULL;
+	    free (tmp);
+	  }
+      }
+    free (inputs_as_text);
+  }
+  return 1;
+}
+
+/**
+ * Parse outputs provided as KVP and store them in a maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param request_inputs the map storing KVP raw value 
+ * @param request_output the maps to store the KVP pairs 
+ * @return 0 on success, -1 on failure
+ */
+int kvpParseOutputs(maps** main_conf,map *request_inputs,maps** request_output){
+  /**
+   * Parsing outputs provided as KVP
+   */
+  map *r_inputs = NULL;
+  r_inputs = getMap (request_inputs, "ResponseDocument");
+  if (r_inputs == NULL)
+    r_inputs = getMap (request_inputs, "RawDataOutput");
+
+  if (r_inputs != NULL)
+    {
+      char *cursor_output = zStrdup (r_inputs->value);
+      int j = 0;
+
+      /**
+       * Put each Output into the outputs_as_text array
+       */
+      char *pToken;
+      maps *tmp_output = NULL;
+      pToken = strtok (cursor_output, ";");
+      char **outputs_as_text = (char **) malloc (128 * sizeof (char *));
+      if (outputs_as_text == NULL)
+	{
+	  return errorException (*main_conf, _("Unable to allocate memory"),
+				 "InternalError", NULL);
+	}
+      int i = 0;
+      while (pToken != NULL)
+	{
+	  outputs_as_text[i] =
+	    (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
+	  if (outputs_as_text[i] == NULL)
+	    {
+	      return errorException (*main_conf, _("Unable to allocate memory"),
+				     "InternalError", NULL);
+	    }
+	  snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
+		    pToken);
+	  pToken = strtok (NULL, ";");
+	  i++;
+	}
+      for (j = 0; j < i; j++)
+	{
+	  char *tmp = zStrdup (outputs_as_text[j]);
+	  free (outputs_as_text[j]);
+	  char *tmpc;
+	  tmpc = strtok (tmp, "@");
+	  int k = 0;
+	  while (tmpc != NULL)
+	    {
+	      if (k == 0)
+		{
+		  if (tmp_output == NULL)
+		    {
+		      tmp_output = (maps *) malloc (MAPS_SIZE);
+		      if (tmp_output == NULL)
+			{
+			  return errorException (*main_conf,
+						 _
+						 ("Unable to allocate memory."),
+						 "InternalError", NULL);
+			}
+		      tmp_output->name = zStrdup (tmpc);
+		      tmp_output->content = NULL;
+		      tmp_output->next = NULL;
+		    }
+		}
+	      else
+		{
+		  char *tmpv = strstr (tmpc, "=");
+		  char tmpn[256];
+		  memset (tmpn, 0, 256);
+		  strncpy (tmpn, tmpc,
+			   (strlen (tmpc) -
+			    strlen (tmpv)) * sizeof (char));
+		  tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
+		  if (tmp_output->content == NULL)
+		    {
+		      tmp_output->content = createMap (tmpn, tmpv + 1);
+		      tmp_output->content->next = NULL;
+		    }
+		  else
+		    addToMap (tmp_output->content, tmpn, tmpv + 1);
+		}
+	      k++;
+	      tmpc = strtok (NULL, "@");
+	    }
+	  if (*request_output == NULL)
+	    *request_output = dupMaps (&tmp_output);
+	  else
+	    addMapsToMaps (&(*request_output), tmp_output);
+	  freeMaps (&tmp_output);
+	  free (tmp_output);
+	  tmp_output = NULL;
+	  free (tmp);
+	}
+      free (outputs_as_text);
+    }
+  return 1;
+}
+
+/**
+ * Parse inputs from XML nodes and store them in a maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param s the service
+ * @param request_output the maps to store the KVP pairs 
+ * @param doc the xmlDocPtr containing the original request
+ * @param nodes the input nodes array
+ * @param hInternet the HINTERNET queue to add potential requests
+ * @return 0 on success, -1 on failure
+ */
+int xmlParseInputs(maps** main_conf,service* s,maps** request_output,xmlDocPtr doc,xmlNodeSet* nodes,HINTERNET* hInternet){
+  for (int k = 0; k < nodes->nodeNr; k++)
+    {
+      maps *tmpmaps = NULL;
+      xmlNodePtr cur = nodes->nodeTab[k];
+
+      if (nodes->nodeTab[k]->type == XML_ELEMENT_NODE)
+	{
+	  // A specific Input node.
+	  xmlNodePtr cur2 = cur->children;
+	  while (cur2 != NULL)
+	    {
+	      while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
+		cur2 = cur2->next;
+	      if (cur2 == NULL)
+		break;
+	      // Indentifier
+	      if (xmlStrncasecmp
+		  (cur2->name, BAD_CAST "Identifier",
+		   xmlStrlen (cur2->name)) == 0)
+		{
+		  xmlChar *val =
+		    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
+		  if (tmpmaps == NULL)
+		    {
+		      tmpmaps = (maps *) malloc (MAPS_SIZE);
+		      if (tmpmaps == NULL)
+			{
+			  return errorException (*main_conf,
+						 _
+						 ("Unable to allocate memory."),
+						 "InternalError", NULL);
+			}
+		      tmpmaps->name = zStrdup ((char *) val);
+		      tmpmaps->content = NULL;
+		      tmpmaps->next = NULL;
+		    }
+		  xmlFree (val);
+		}
+	      // Title, Asbtract
+	      if (xmlStrncasecmp
+		  (cur2->name, BAD_CAST "Title",
+		   xmlStrlen (cur2->name)) == 0
+		  || xmlStrncasecmp (cur2->name, BAD_CAST "Abstract",
+				     xmlStrlen (cur2->name)) == 0)
+		{
+		  xmlChar *val =
+		    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
+		  if (tmpmaps == NULL)
+		    {
+		      tmpmaps = (maps *) malloc (MAPS_SIZE);
+		      if (tmpmaps == NULL)
+			{
+			  return errorException (*main_conf,
+						 _
+						 ("Unable to allocate memory."),
+						 "InternalError", NULL);
+			}
+		      tmpmaps->name = zStrdup ("missingIndetifier");
+		      tmpmaps->content =
+			createMap ((char *) cur2->name, (char *) val);
+		      tmpmaps->next = NULL;
+		    }
+		  else
+		    {
+		      if (tmpmaps->content != NULL)
+			addToMap (tmpmaps->content,
+				  (char *) cur2->name, (char *) val);
+		      else
+			tmpmaps->content =
+			  createMap ((char *) cur2->name, (char *) val);
+		    }
+		  xmlFree (val);
+		}
+	      // InputDataFormChoice (Reference or Data ?) 
+	      if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
+		{
+		  // Get every attribute from a Reference node
+		  // mimeType, encoding, schema, href, method
+		  // Header and Body gesture should be added here
+		  const char *refs[5] =
+		    { "mimeType", "encoding", "schema", "method",
+		      "href"
+		    };
+		  for (int l = 0; l < 5; l++)
+		    {
+		      xmlChar *val = xmlGetProp (cur2, BAD_CAST refs[l]);
+		      if (val != NULL && xmlStrlen (val) > 0)
+			{
+			  if (tmpmaps->content != NULL)
+			    addToMap (tmpmaps->content, refs[l],
+				      (char *) val);
+			  else
+			    tmpmaps->content =
+			      createMap (refs[l], (char *) val);
+
+			  map *ltmp = getMap (tmpmaps->content, "method");
+			  if (l == 4 )
+			    {
+			      addToMap (tmpmaps->content, "Reference", (char*) val);
+			      if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0))
+				{
+				  if (loadRemoteFile
+				      (&(*main_conf), &tmpmaps->content, hInternet,
+				       (char *) val) != 0)
+				    {
+				      return errorException (*main_conf,
+							     _("Unable to add a request in the queue."),
+							     "InternalError",
+							     NULL);
+				    }
+				}
+			    }
+			}
+		      xmlFree (val);
+		    }
+		  // Parse Header and Body from Reference
+		  xmlNodePtr cur3 = cur2->children;
+		  while (cur3 != NULL)
+		    {
+		      while (cur3 != NULL
+			     && cur3->type != XML_ELEMENT_NODE)
+			cur3 = cur3->next;
+		      if (cur3 == NULL)
+			break;
+		      if (xmlStrcasecmp (cur3->name, BAD_CAST "Header") ==
+			  0)
+			{
+			  const char *ha[2];
+			  ha[0] = "key";
+			  ha[1] = "value";
+			  int hai;
+			  char *has;
+			  char *key;
+			  for (hai = 0; hai < 2; hai++)
+			    {
+			      xmlChar *val =
+				xmlGetProp (cur3, BAD_CAST ha[hai]);
+#ifdef POST_DEBUG
+			      fprintf (stderr, "%s = %s\n", ha[hai],
+				       (char *) val);
+#endif
+			      if (hai == 0)
+				{
+				  key = zStrdup ((char *) val);
+				}
+			      else
+				{
+				  has =
+				    (char *)
+				    malloc ((4 + xmlStrlen (val) +
+					     strlen (key)) *
+					    sizeof (char));
+				  if (has == NULL)
+				    {
+				      return errorException (*main_conf,
+							     _
+							     ("Unable to allocate memory."),
+							     "InternalError",
+							     NULL);
+				    }
+				  snprintf (has,
+					    (3 + xmlStrlen (val) +
+					     strlen (key)), "%s: %s", key,
+					    (char *) val);
+				  free (key);
+				}
+			      xmlFree (val);
+			    }
+			  hInternet->ihandle[hInternet->nb].header =
+			    curl_slist_append (hInternet->ihandle
+					       [hInternet->nb].header,
+					       has);
+			  if (has != NULL)
+			    free (has);
+			}
+		      else
+			{
+#ifdef POST_DEBUG
+			  fprintf (stderr,
+				   "Try to fetch the body part of the request ...\n");
+#endif
+			  if (xmlStrcasecmp (cur3->name, BAD_CAST "Body")
+			      == 0)
+			    {
+#ifdef POST_DEBUG
+			      fprintf (stderr, "Body part found (%s) !!!\n",
+				       (char *) cur3->content);
+#endif
+			      char *tmp = NULL;
+			      xmlNodePtr cur4 = cur3->children;
+			      while (cur4 != NULL)
+				{
+				  while (cur4 && cur4 != NULL && cur4->type && cur4->type != XML_ELEMENT_NODE){
+				    if(cur4->next)
+				      cur4 = cur4->next;
+				    else
+				      cur4 = NULL;
+				  }
+				  if(cur4 != NULL) {
+				    xmlDocPtr bdoc =
+				      xmlNewDoc (BAD_CAST "1.0");
+				    bdoc->encoding =
+				      xmlCharStrdup ("UTF-8");
+				    xmlDocSetRootElement (bdoc, cur4);
+				    xmlChar *btmps;
+				    int bsize;
+				    // TODO : check for encoding defined in the input
+				    xmlDocDumpFormatMemoryEnc(bdoc, &btmps, &bsize, "UTF-8", 0);
+				    if (btmps != NULL){
+				      tmp = (char *) malloc ((bsize + 1) * sizeof (char));
+
+				      sprintf (tmp, "%s", (char*) btmps);
+					  
+				      xmlFreeDoc (bdoc);
+					  
+				      map *btmp =
+					getMap (tmpmaps->content, "Reference");
+				      if (btmp != NULL)
+					{
+					  addRequestToQueue(&(*main_conf),hInternet,(char *) btmp->value,false);
+					  InternetOpenUrl (hInternet,
+							   btmp->value,
+							   tmp,
+							   xmlStrlen(btmps),
+							   INTERNET_FLAG_NO_CACHE_WRITE,
+							   0);
+					}
+				      xmlFree (btmps);
+				      free (tmp);
+				      break;
+				    }
+				  }
+				  cur4 = cur4->next;
+				}
+			    }
+			  else
+			    if (xmlStrcasecmp
+				(cur3->name,
+				 BAD_CAST "BodyReference") == 0)
+			      {
+				xmlChar *val =
+				  xmlGetProp (cur3, BAD_CAST "href");
+				HINTERNET bInternet, res1, res;
+				bInternet = InternetOpen (
+#ifndef WIN32
+							  (LPCTSTR)
+#endif
+							  "ZooWPSClient\0",
+							  INTERNET_OPEN_TYPE_PRECONFIG,
+							  NULL, NULL, 0);
+				if (!CHECK_INET_HANDLE (bInternet))
+				  fprintf (stderr,
+					   "WARNING : bInternet handle failed to initialize");
+				bInternet.waitingRequests[0] =
+				  strdup ((char *) val);
+				res1 =
+				  InternetOpenUrl (&bInternet,
+						   bInternet.waitingRequests
+						   [0], NULL, 0,
+						   INTERNET_FLAG_NO_CACHE_WRITE,
+						   0);
+				processDownloads (&bInternet);
+				char *tmp =
+				  (char *)
+				  malloc ((bInternet.ihandle[0].nDataLen +
+					   1) * sizeof (char));
+				if (tmp == NULL)
+				  {
+				    return errorException (*main_conf,
+							   _
+							   ("Unable to allocate memory."),
+							   "InternalError",
+							   NULL);
+				  }
+				size_t bRead;
+				InternetReadFile (bInternet.ihandle[0],
+						  (LPVOID) tmp,
+						  bInternet.
+						  ihandle[0].nDataLen,
+						  &bRead);
+				tmp[bInternet.ihandle[0].nDataLen] = 0;
+				InternetCloseHandle (&bInternet);
+				map *btmp =
+				  getMap (tmpmaps->content, "href");
+				if (btmp != NULL)
+				  {
+				    addRequestToQueue(&(*main_conf),hInternet,(char *) btmp->value,false);
+
+				    res =
+				      InternetOpenUrl (hInternet,
+						       btmp->value,
+						       tmp,
+						       strlen(tmp),
+						       INTERNET_FLAG_NO_CACHE_WRITE,
+						       0);
+				  }
+				free (tmp);
+			      }
+			}
+		      cur3 = cur3->next;
+		    }
+		}
+	      else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0)
+		{
+		  xmlNodePtr cur4 = cur2->children;
+		  while (cur4 != NULL)
+		    {
+		      while (cur4 != NULL
+			     && cur4->type != XML_ELEMENT_NODE)
+			cur4 = cur4->next;
+		      if (cur4 == NULL)
+			break;
+		      if (xmlStrcasecmp
+			  (cur4->name, BAD_CAST "LiteralData") == 0)
+			{
+			  // Get every attribute from a LiteralData node
+			  // dataType , uom
+			  char *list[2];
+			  list[0] = zStrdup ("dataType");
+			  list[1] = zStrdup ("uom");
+			  for (int l = 0; l < 2; l++)
+			    {
+			      xmlChar *val =
+				xmlGetProp (cur4, BAD_CAST list[l]);
+			      if (val != NULL
+				  && strlen ((char *) val) > 0)
+				{
+				  if (tmpmaps->content != NULL)
+				    addToMap (tmpmaps->content, list[l],
+					      (char *) val);
+				  else
+				    tmpmaps->content =
+				      createMap (list[l], (char *) val);
+				}
+			      xmlFree (val);
+			      free (list[l]);
+			    }
+			}
+		      else
+			if (xmlStrcasecmp
+			    (cur4->name, BAD_CAST "ComplexData") == 0)
+			  {
+			    // Get every attribute from a Reference node
+			    // mimeType, encoding, schema
+			    const char *coms[3] =
+			      { "mimeType", "encoding", "schema" };
+			    for (int l = 0; l < 3; l++)
+			      {
+				xmlChar *val =
+				  xmlGetProp (cur4, BAD_CAST coms[l]);
+				if (val != NULL
+				    && strlen ((char *) val) > 0)
+				  {
+				    if (tmpmaps->content != NULL)
+				      addToMap (tmpmaps->content, coms[l],
+						(char *) val);
+				    else
+				      tmpmaps->content =
+					createMap (coms[l], (char *) val);
+				  }
+				xmlFree (val);
+			      }
+			  }
+
+		      map *test = getMap (tmpmaps->content, "encoding");
+
+		      if (test == NULL)
+			{ 
+			  if (tmpmaps->content != NULL)
+			    addToMap (tmpmaps->content, "encoding",
+				      "utf-8");
+			  else
+			    tmpmaps->content =
+			      createMap ("encoding", "utf-8");
+			  test = getMap (tmpmaps->content, "encoding");
+			}
+
+		      if (strcasecmp (test->value, "base64") != 0)
+			{ 
+			  xmlChar *mv = xmlNodeListGetString (doc,
+							      cur4->xmlChildrenNode,
+							      1);
+			  map *ltmp =
+			    getMap (tmpmaps->content, "mimeType");
+			  if (mv == NULL
+			      ||
+			      (xmlStrcasecmp
+			       (cur4->name, BAD_CAST "ComplexData") == 0
+			       && (ltmp == NULL
+				   || strncasecmp (ltmp->value,
+						   "text/xml", 8) == 0)))
+			    {
+			      xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
+			      int buffersize;
+			      xmlNodePtr cur5 = cur4->children;
+			      while (cur5 != NULL
+				     && cur5->type != XML_ELEMENT_NODE
+				     && cur5->type !=
+				     XML_CDATA_SECTION_NODE)
+				cur5 = cur5->next;
+			      if (cur5 != NULL
+				  && cur5->type != XML_CDATA_SECTION_NODE)
+				{
+				  xmlDocSetRootElement (doc1, cur5);
+				  xmlDocDumpFormatMemoryEnc (doc1, &mv,
+							     &buffersize,
+							     "utf-8", 1);
+				  char size[1024];
+				  sprintf (size, "%d", buffersize);
+				  addToMap (tmpmaps->content, "size",
+					    size);
+				  xmlFreeDoc (doc1);
+				}
+			      else
+				{
+				  if (cur5 != NULL
+				      && cur5->type == XML_CDATA_SECTION_NODE){
+				    xmlDocPtr doc2 = xmlParseMemory((const char*)cur5->content,xmlStrlen(cur5->content));
+				    xmlDocSetRootElement (doc1,xmlDocGetRootElement(doc2));
+				    xmlDocDumpFormatMemoryEnc (doc1, &mv,
+							       &buffersize,
+							       "utf-8", 1);
+				    char size[1024];
+				    sprintf (size, "%d", buffersize);
+				    addToMap (tmpmaps->content, "size",
+					      size);
+				    xmlFreeDoc (doc2);
+				    xmlFreeDoc (doc1);
+				  }
+				}
+			    }else{
+			    xmlNodePtr cur5 = cur4->children;
+			    while (cur5 != NULL
+				   && cur5->type != XML_CDATA_SECTION_NODE)
+			      cur5 = cur5->next;
+			    if (cur5 != NULL
+				&& cur5->type == XML_CDATA_SECTION_NODE){
+			      xmlFree(mv);
+			      mv=xmlStrdup(cur5->content);
+			    }
+			  }
+			  if (mv != NULL)
+			    {
+			      addToMap (tmpmaps->content, "value",
+					(char *) mv);
+			      xmlFree (mv);
+			    }
+			}
+		      else
+			{
+			  xmlChar *tmp = xmlNodeListGetRawString (doc,
+								  cur4->xmlChildrenNode,
+								  0);
+			  addToMap (tmpmaps->content, "value",
+				    (char *) tmp);
+			  map *tmpv = getMap (tmpmaps->content, "value");
+			  char *res = NULL;
+			  char *curs = tmpv->value;
+			  for (int i = 0; i <= strlen (tmpv->value) / 64;
+			       i++)
+			    {
+			      if (res == NULL)
+				res =
+				  (char *) malloc (67 * sizeof (char));
+			      else
+				res =
+				  (char *) realloc (res,
+						    (((i + 1) * 65) +
+						     i) * sizeof (char));
+			      int csize = i * 65;
+			      strncpy (res + csize, curs, 64);
+			      if (i == xmlStrlen (tmp) / 64)
+				strcat (res, "\n\0");
+			      else
+				{
+				  strncpy (res + (((i + 1) * 64) + i),
+					   "\n\0", 2);
+				  curs += 64;
+				}
+			    }
+			  free (tmpv->value);
+			  tmpv->value = zStrdup (res);
+			  free (res);
+			  xmlFree (tmp);
+			}
+		      cur4 = cur4->next;
+		    }
+		}
+	      cur2 = cur2->next;
+	    }
+
+	  {
+	    maps *testPresence =
+	      getMaps (*request_output, tmpmaps->name);
+	    if (testPresence != NULL)
+	      {
+		elements *elem = getElements (s->inputs, tmpmaps->name);
+		if (elem != NULL)
+		  {
+		    if (appendMapsToMaps
+			(*main_conf, *request_output, tmpmaps, elem) < 0)
+		      {
+			return errorException (*main_conf,
+					       _("Unable to append maps to maps."),
+					       "InternalError",
+					       NULL);
+		      }
+		  }
+	      }
+	    else
+	      addMapsToMaps (&(*request_output), tmpmaps);
+	  }
+	  freeMaps (&tmpmaps);
+	  free (tmpmaps);
+	  tmpmaps = NULL;
+	}
+    }
+  return 1;
+}
+
+/**
+ * Parse outputs from XML nodes and store them in a maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param request_inputs the map storing KVP raw value 
+ * @param request_output the maps to store the KVP pairs 
+ * @param doc the xmlDocPtr containing the original request
+ * @param cur the xmlNodePtr corresponding to the ResponseDocument or RawDataOutput XML node
+ * @param raw true if the node is RawDataOutput, false in case of ResponseDocument
+ * @return 0 on success, -1 on failure
+ */
+int xmlParseOutputs(maps** main_conf,map** request_inputs,maps** request_output,xmlDocPtr doc,xmlNodePtr cur,bool raw){
+  if( raw == true)
+    {
+      addToMap (*request_inputs, "RawDataOutput", "");
+      if (cur->type == XML_ELEMENT_NODE)
+	{
+
+	  maps *tmpmaps = (maps *) malloc (MAPS_SIZE);
+	  if (tmpmaps == NULL)
+	    {
+	      return errorException (*main_conf, _("Unable to allocate memory."),
+				     "InternalError", NULL);
+	    }
+	  tmpmaps->name = zStrdup ("unknownIdentifier");
+	  tmpmaps->content = NULL;
+	  tmpmaps->next = NULL;
+
+	  // Get every attribute from a RawDataOutput node
+	  // mimeType, encoding, schema, uom
+	  const char *outs[4] =
+	    { "mimeType", "encoding", "schema", "uom" };
+	  for (int l = 0; l < 4; l++)
+	    {
+	      xmlChar *val = xmlGetProp (cur, BAD_CAST outs[l]);
+	      if (val != NULL)
+		{
+		  if (strlen ((char *) val) > 0)
+		    {
+		      if (tmpmaps->content != NULL)
+			addToMap (tmpmaps->content, outs[l],
+				  (char *) val);
+		      else
+			tmpmaps->content =
+			  createMap (outs[l], (char *) val);
+		    }
+		  xmlFree (val);
+		}
+	    }
+	  xmlNodePtr cur2 = cur->children;
+	  while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
+	    cur2 = cur2->next;
+	  while (cur2 != NULL)
+	    {
+	      if (xmlStrncasecmp
+		  (cur2->name, BAD_CAST "Identifier",
+		   xmlStrlen (cur2->name)) == 0)
+		{
+		  xmlChar *val =
+		    xmlNodeListGetString (NULL, cur2->xmlChildrenNode, 1);
+		  free (tmpmaps->name);
+		  tmpmaps->name = zStrdup ((char *) val);
+		  xmlFree (val);
+		}
+	      cur2 = cur2->next;
+	      while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
+		cur2 = cur2->next;
+	    }
+	  if (*request_output == NULL)
+	    *request_output = dupMaps (&tmpmaps);
+	  else
+	    addMapsToMaps (&(*request_output), tmpmaps);
+	  if (tmpmaps != NULL)
+	    {
+	      freeMaps (&tmpmaps);
+	      free (tmpmaps);
+	      tmpmaps = NULL;
+	    }
+	}
+    }
+  else
+    {
+      addToMap (*request_inputs, "ResponseDocument", "");
+
+      if (cur->type == XML_ELEMENT_NODE) {
+	// Get every attribute: storeExecuteResponse, lineage, status
+	const char *ress[3] =
+	  { "storeExecuteResponse", "lineage", "status" };
+	xmlChar *val;
+	for (int l = 0; l < 3; l++)
+	  {
+	    val = xmlGetProp (cur, BAD_CAST ress[l]);
+	    if (val != NULL && strlen ((char *) val) > 0)
+	      {
+		addToMap (*request_inputs, ress[l], (char *) val);
+	      }
+	    xmlFree (val);
+	  }
+			
+	xmlNodePtr cur1 = cur->children;		
+	while (cur1 != NULL) // iterate over Output nodes
+	  {
+	    if (cur1->type != XML_ELEMENT_NODE || 
+		xmlStrncasecmp(cur1->name, BAD_CAST "Output", 
+			       xmlStrlen (cur1->name)) != 0) {
+	      cur1 = cur1->next;
+	      continue;
+	    }
+				
+	    maps *tmpmaps = (maps *) malloc (MAPS_SIZE); // one per Output node
+	    if (tmpmaps == NULL) {
+	      return errorException (*main_conf,
+				     _
+				     ("Unable to allocate memory."),
+				     "InternalError", NULL);
+	    }
+	    tmpmaps->name = zStrdup ("unknownIdentifier");
+	    tmpmaps->content = NULL;
+	    tmpmaps->next = NULL;
+				
+	    xmlNodePtr elems = cur1->children;
+				
+	    while (elems != NULL) {
+
+	      // Identifier
+	      if (xmlStrncasecmp
+		  (elems->name, BAD_CAST "Identifier",
+		   xmlStrlen (elems->name)) == 0)
+		{
+		  xmlChar *val =
+		    xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
+		
+		  free(tmpmaps->name);
+		  tmpmaps->name = zStrdup ((char *) val);
+		  if (tmpmaps->content == NULL) {
+		    tmpmaps->content = createMap("Identifier", zStrdup ((char *) val));
+		  }
+		  else {
+		    addToMap(tmpmaps->content, "Identifier", zStrdup ((char *) val));
+		  }
+
+		  map* tt = getMap (*request_inputs, "ResponseDocument");
+		  if (strlen(tt->value) == 0) {
+		    addToMap (*request_inputs, "ResponseDocument",
+			      (char *) val);
+		  }
+		  else {
+		    char* tmp = (char*) malloc((strlen(tt->value) + 1 
+						+ strlen((char*) val) + 1) * sizeof(char));
+		    sprintf (tmp, "%s;%s", tt->value, (char *) val);
+		    free(tt->value);
+		    tt->value = tmp;
+		  }
+		  xmlFree (val);
+		}
+	      
+	      // Title, Abstract
+	      else if (xmlStrncasecmp(elems->name, BAD_CAST "Title",
+				      xmlStrlen (elems->name)) == 0
+		       || xmlStrncasecmp(elems->name, BAD_CAST "Abstract",
+					 xmlStrlen (elems->name)) == 0)
+		{
+		  xmlChar *val =
+		    xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
+							
+		  if (tmpmaps->content == NULL) {
+		    tmpmaps->content = createMap((char*) elems->name, zStrdup ((char *) val));
+		  }
+		  else {
+		    addToMap(tmpmaps->content, (char*) elems->name, zStrdup ((char *) val));
+		  }
+		  xmlFree (val);
+		}
+	      elems = elems->next;
+	    }
+				
+	    // Get every attribute from an Output node:
+	    // mimeType, encoding, schema, uom, asReference
+	    const char *outs[5] =
+	      { "mimeType", "encoding", "schema", "uom", "asReference" };
+					  
+	    for (int l = 0; l < 5; l++) {
+	      xmlChar *val = xmlGetProp (cur1, BAD_CAST outs[l]);				
+	      if (val != NULL && xmlStrlen(val) > 0) {
+		if (tmpmaps->content != NULL) {
+		  addToMap (tmpmaps->content, outs[l], (char *) val);
+		}			  
+		else {
+		  tmpmaps->content = createMap (outs[l], (char *) val);
+		}	
+	      }
+	      xmlFree (val);
+	    }
+				
+	    if (*request_output == NULL) {
+	      *request_output = tmpmaps;
+	    }	
+	    else if (getMaps(*request_output, tmpmaps->name) != NULL) {
+	      return errorException (*main_conf,
+				     _
+				     ("Duplicate <Output> elements in WPS Execute request"),
+				     "InternalError", NULL);
+	    }
+	    else {
+	      maps* mptr = *request_output;
+	      while (mptr->next != NULL) {
+		mptr = mptr->next;
+	      }
+	      mptr->next = tmpmaps;	
+	    }					
+	    cur1 = cur1->next;
+	  }			 
+      }
+    }
+  return 1;
+}
+
+/**
+ * Parse XML request and store informations in maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param post the string containing the XML request
+ * @param request_inputs the map storing KVP raw value 
+ * @param s the service
+ * @param inputs the maps to store the KVP pairs 
+ * @param outputs the maps to store the KVP pairs 
+ * @param hInternet the HINTERNET queue to add potential requests
+ * @return 0 on success, -1 on failure
+ */
+int xmlParseRequest(maps** main_conf,const char* post,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
+  xmlInitParser ();
+  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+  xmlDocPtr doc = xmlParseMemory (post, cgiContentLength);
+  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+
+  /**
+   * Extract Input nodes from the XML Request.
+   */
+  xmlXPathObjectPtr tmpsptr =
+    extractFromDoc (doc, "/*/*/*[local-name()='Input']");
+  xmlNodeSet *tmps = tmpsptr->nodesetval;
+  if(xmlParseInputs(main_conf,s,inputs,doc,tmps,hInternet)<0){
+    xmlXPathFreeObject (tmpsptr);
+    xmlFreeDoc (doc);
+    xmlCleanupParser ();
+    return -1;
+  }
+  xmlXPathFreeObject (tmpsptr);
+  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+
+  // Extract ResponseDocument / RawDataOutput from the XML Request 
+  tmpsptr =
+    extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']");
+  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+  bool asRaw = false;
+  tmps = tmpsptr->nodesetval;
+  if (tmps->nodeNr == 0)
+    {
+      fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+      xmlXPathFreeObject (tmpsptr);
+      tmpsptr =
+	extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']");
+      tmps = tmpsptr->nodesetval;
+      asRaw = true;
+    }
+  if(tmps->nodeNr != 0){
+    fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+    if(xmlParseOutputs(main_conf,request_inputs,outputs,doc,tmps->nodeTab[0],asRaw)<0){
+      xmlXPathFreeObject (tmpsptr);
+      xmlFreeDoc (doc);
+      xmlCleanupParser ();
+      return -1;
+    }
+  }
+  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
+  xmlXPathFreeObject (tmpsptr);
+  xmlFreeDoc (doc);
+  xmlCleanupParser ();
+  return 1;
+}
+
+/**
+ * Parse request and store informations in maps.
+ *
+ * @param main_conf the conf maps containing the main.cfg settings
+ * @param post the string containing the XML request
+ * @param request_inputs the map storing KVP raw value 
+ * @param s the service
+ * @param inputs the maps to store the KVP pairs 
+ * @param outputs the maps to store the KVP pairs 
+ * @param hInternet the HINTERNET queue to add potential requests
+ * @return 0 on success, -1 on failure
+ * @see kvpParseOutputs,kvpParseInputs,xmlParseRequest
+ */
+int parseRequest(maps** main_conf,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
+  map *postRequest = NULL;
+  postRequest = getMap (*request_inputs, "xrequest");
+  if (postRequest == NULLMAP)
+    {
+      if(kvpParseOutputs(main_conf,*request_inputs,outputs)<0){
+	return -1;
+      }
+      if(kvpParseInputs(main_conf,s,*request_inputs,inputs,hInternet)<0){
+	return -1;
+      }
+    }
+  else
+    {
+      //Parse XML request
+      if(xmlParseRequest(main_conf,postRequest->value,request_inputs,s,inputs,outputs,hInternet)<0){
+	return -1;
+      }
+    }
+  return 1;
+}
+
+/**
+ * Ensure that each requested arguments are present in the request
+ * DataInputs and ResponseDocument / RawDataOutput. Potentially run
+ * http requests from the queue in parallel.
+ * For optional inputs add default values defined in the ZCFG file.
+ * 
+ * @param main_conf
+ * @param s 
+ * @param original_request
+ * @param request_inputs
+ * @param request_outputs
+ * @param hInternet 
+ * 
+ * @see runHttpRequests
+ */
+int validateRequest(maps** main_conf,service* s,map* original_request, maps** request_inputs,maps** request_outputs,HINTERNET* hInternet){
+
+  runHttpRequests (main_conf, request_inputs, hInternet);
+  InternetCloseHandle (hInternet);
+
+  map* errI=NULL;
+  char *dfv = addDefaultValues (request_inputs, s->inputs, *main_conf, 0,&errI);
+
+  maps *ptr = *request_inputs;
+  while (ptr != NULL)
+    {
+      map *tmp0 = getMap (ptr->content, "size");
+      map *tmp1 = getMap (ptr->content, "maximumMegabytes");
+      if (tmp1 != NULL && tmp0 != NULL)
+        {
+          float i = atof (tmp0->value) / 1048576.0;
+          if (i >= atoi (tmp1->value))
+            {
+              char tmps[1024];
+              map *tmpe = createMap ("code", "FileSizeExceeded");
+              snprintf (tmps, 1024,
+                        _
+                        ("The <%s> parameter has a size limit (%s MB) defined in the ZOO ServicesProvider configuration file, but the reference you provided exceeds this limit (%f MB)."),
+                        ptr->name, tmp1->value, i);
+              addToMap (tmpe, "locator", ptr->name);
+              addToMap (tmpe, "text", tmps);
+              printExceptionReportResponse (*main_conf, tmpe);
+              freeMap (&tmpe);
+              free (tmpe);
+	      return -1;
+            }
+        }
+      ptr = ptr->next;
+    }
+
+  map* errO=NULL;
+  char *dfv1 =
+    addDefaultValues (request_outputs, s->outputs, *main_conf, 1,&errO);
+  if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
+    {
+      char tmps[1024];
+      map *tmpe = NULL;
+      if (strcmp (dfv, "") != 0)
+        {
+	  tmpe = createMap ("code", "MissingParameterValue");
+	  int nb=0;
+	  int length=1;
+	  map* len=getMap(errI,"length");
+	  if(len!=NULL)
+	    length=atoi(len->value);
+	  for(nb=0;nb<length;nb++){
+	    map* errp=getMapArray(errI,"value",nb);
+	    snprintf (tmps, 1024,
+		      _
+		      ("The <%s> argument was not specified in DataInputs but is required according to the ZOO ServicesProvider configuration file."),
+		      errp->value);
+	    setMapArray (tmpe, "locator", nb , errp->value);
+	    setMapArray (tmpe, "text", nb , tmps);
+	    setMapArray (tmpe, "code", nb , "MissingParameterValue");
+	  }
+	}
+      if (strcmp (dfv1, "") != 0)
+        {
+	  int ilength=0;
+	  if(tmpe==NULL)
+	    tmpe = createMap ("code", "InvalidParameterValue");
+	  else{
+	    map* len=getMap(tmpe,"length");
+	    if(len!=NULL)
+	      ilength=atoi(len->value);
+	  }
+	  int nb=0;
+	  int length=1;
+	  map* len=getMap(errO,"length");
+	  if(len!=NULL)
+	    length=atoi(len->value);
+	  for(nb=0;nb<length;nb++){
+	    map* errp=getMapArray(errO,"value",nb);
+	    snprintf (tmps, 1024,
+		      _
+		      ("The <%s> argument specified as %s identifier was not recognized (not defined in the ZOO Configuration File)."),
+		      errp->value,
+		      ((getMap(original_request,"RawDataOutput")!=NULL)?"RawDataOutput":"ResponseDocument"));
+	    setMapArray (tmpe, "locator", nb+ilength , errp->value);
+	    setMapArray (tmpe, "text", nb+ilength , tmps);
+	    setMapArray (tmpe, "code", nb+ilength , "InvalidParameterValue");
+	  }
+	}
+      printExceptionReportResponse (*main_conf, tmpe);
+      if(errI!=NULL){
+	freeMap(&errI);
+	free(errI);
+      }
+      if(errO!=NULL){
+	freeMap(&errO);
+	free(errO);
+      }
+      freeMap (&tmpe);
+      free (tmpe);
+      return -1;
+    }
+  maps *tmpReqI = *request_inputs;
+  while (tmpReqI != NULL)
+    {
+      char name[1024];
+      if (getMap (tmpReqI->content, "isFile") != NULL)
+        {
+          if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
+              cgiFormSuccess)
+            {
+              int BufferLen = 1024;
+              cgiFilePtr file;
+              int targetFile;
+              char storageNameOnServer[2048];
+              char fileNameOnServer[64];
+              char contentType[1024];
+              char buffer[1024];
+              char *tmpStr = NULL;
+              int size;
+              int got, t;
+              map *path = getMapFromMaps (*main_conf, "main", "tmpPath");
+              cgiFormFileSize (tmpReqI->name, &size);
+              cgiFormFileContentType (tmpReqI->name, contentType,
+                                      sizeof (contentType));
+              if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
+                {
+                  t = -1;
+                  while (1)
+                    {
+                      tmpStr = strstr (name + t + 1, "\\");
+                      if (NULL == tmpStr)
+                        tmpStr = strstr (name + t + 1, "/");
+                      if (NULL != tmpStr)
+                        t = (int) (tmpStr - name);
+                      else
+                        break;
+                    }
+                  strcpy (fileNameOnServer, name + t + 1);
+
+                  sprintf (storageNameOnServer, "%s/%s", path->value,
+                           fileNameOnServer);
+#ifdef DEBUG
+                  fprintf (stderr, "Name on server %s\n",
+                           storageNameOnServer);
+                  fprintf (stderr, "fileNameOnServer: %s\n",
+                           fileNameOnServer);
+#endif
+                  targetFile =
+                    open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
+                          S_IRWXU | S_IRGRP | S_IROTH);
+                  if (targetFile < 0)
+                    {
+#ifdef DEBUG
+                      fprintf (stderr, "could not create the new file,%s\n",
+                               fileNameOnServer);
+#endif
+                    }
+                  else
+                    {
+                      while (cgiFormFileRead (file, buffer, BufferLen, &got)
+                             == cgiFormSuccess)
+                        {
+                          if (got > 0)
+                            write (targetFile, buffer, got);
+                        }
+                    }
+                  addToMap (tmpReqI->content, "lref", storageNameOnServer);
+                  cgiFormFileClose (file);
+                  close (targetFile);
+#ifdef DEBUG
+                  fprintf (stderr, "File \"%s\" has been uploaded",
+                           fileNameOnServer);
+#endif
+                }
+            }
+        }
+      tmpReqI = tmpReqI->next;
+    }
+
+  ensureDecodedBase64 (request_inputs);
+  return 1;
+}
Index: trunk/zoo-project/zoo-kernel/request_parser.h
===================================================================
--- trunk/zoo-project/zoo-kernel/request_parser.h	(revision 621)
+++ trunk/zoo-project/zoo-kernel/request_parser.h	(revision 621)
@@ -0,0 +1,53 @@
+/*
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 2015 GeoLabs SARL
+ *
+ * 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.
+ */
+
+#ifndef SERVICE_PARSER_H
+#define SERVICE_PARSER_H 1
+
+#pragma once 
+
+#include "service.h"
+#include "ulinet.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+
+  xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *);
+  int appendMapsToMaps (maps*, maps*, maps*, elements*);
+  int kvpParseInputs(maps**,service*,map*,maps**,HINTERNET*);
+  int kvpParseOutputs(maps**,map *,maps**);
+  int xmlParseInputs(maps**,service*,maps**,xmlDocPtr,xmlNodeSet*,HINTERNET*);
+  int xmlParseOutputs(maps**,map**,maps**,xmlDocPtr,xmlNodePtr,bool);
+  int xmlParseRequest(maps**,const char*,map**,service*,maps**,maps**,HINTERNET*);
+  int parseRequest(maps**,map**,service*,maps**,maps**,HINTERNET*);
+  int validateRequest(maps**,service*,map*,maps**,maps**,HINTERNET*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service.h	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service.h	(revision 621)
@@ -1261,5 +1261,5 @@
     }
   }
-
+  
   /**
    * Dump a service on stderr
Index: trunk/zoo-project/zoo-kernel/service_conf.l
===================================================================
--- trunk/zoo-project/zoo-kernel/service_conf.l	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service_conf.l	(revision 621)
@@ -1,2 +1,25 @@
+/*
+ * Author : Gérald FENOY
+ *
+ * Copyright (c) 209-2015 GeoLabs SARL
+ *
+ * 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.
+ */
 %option noyywrap
 %option yylineno
@@ -4,26 +27,9 @@
 
 %{
-//======================================================
-/**
-
- authors : Jean-Marie CODOL, Naitan GROLLEMUND
-
-**/
-//======================================================
-
 
 #include <string.h>
 #include "service_conf.tab.h"
 
-#ifdef DEBUG_SERVICE_CONF
-int affichetrace = 1;
-#else
-int affichetrace = 0;
-#endif
-
 char *lmsg=NULL;
-int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
-
-int attentionImpossibleDeTrouverPIapres = 0 ;
 
 %}
@@ -41,5 +47,5 @@
 
 attname	[a-zA-Z0-9._\-]+
-attvalue1	[#°²θé\^\*\+,;@a-zA-Z0-9%_\-:\:.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+
+attvalue1	[#°²θé\^\*\+,;?!~`Ãº@a-zA-Z0-9%_\-:\:.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+
 
 attvalue		\"[^"]*\"|\'[^']*\'\(\)
@@ -58,7 +64,7 @@
 %%
 
-"\n" {  if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE\n") ;return NEWLINE;}
+"\n" { }
 
-{newline}+{whitesp}*			{  if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE 1\n") ; return NEWLINE;}
+{newline}+{whitesp}*			{ return NEWLINE; }
 
 <INITIAL,HORSBALISE>"["{attname}"]"             {  srlval.chaine=yytext;return ANID; }
@@ -70,30 +76,7 @@
 <PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}*             {  BEGIN(PAIRSTART);}
 
-<PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*             { BEGIN(INITIAL);  return NEWLINE;}
-
-<INITIAL>"<?"[Xx][Mm][Ll]  {   if (attentionImpossibleDeTrouverXMLDeclapres == 1 || attentionImpossibleDeTrouverPIapres == 1) {/* il y a eut un commentaire ou une balise applicative avant la declaration xml */ fprintf(stderr,"\nerror : a la ligne %d : il y a eut un commentaire ou un PI avant la declaration xml\n",srlineno); exit (10) ; } ; return STARTXMLDECL;}
-
-<INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\'  { return VERSIONDECL;  }
-<INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\'  {/* erreur de version encoding */ fprintf(stderr,"\nerror : a la ligne %d : la version xml n est pas reconnue : %s\n",srlineno,yytext); exit (9) ; }
-
-
-<INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\'  { return ENCODINGDECL;}
-<INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\'  {/* erreur de version encoding */ 	fprintf(stderr,"\nerror : a la ligne %d : la version d encodage n est pas reconnue : %s\n",srlineno,yytext); exit (8) ; }
-
-
-<INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\'  { return SDDECL;}
-
-<INITIAL>"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'|"standalone"{egalevolue}\"[^"]*\"|"standalone"{egalevolue}\'[^']*\'  { /* erreur de version encoding */ 	fprintf(stderr,"\nerror : a la ligne %d : la version standalone n est pas reconnue : %s\n",srlineno,yytext); exit (7) ; }
-
-
-<INITIAL>"?>"  { BEGIN(HORSBALISE); return ENDXMLDECL;}
-
+<PAIRSTART,INITIAL,HORSBALISE>{newline}+{whitesp}*             { BEGIN(INITIAL);  return NEWLINE;}
 
 <DANSBALISE,INITIAL,HORSBALISE>{S}   {  }
-
-
-<HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>"	{ return PIERROR;}
-<INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>"		{ attentionImpossibleDeTrouverPIapres=1 ; return PI;}
-
 
 <INITIAL,HORSBALISE>{newline}*"<"		    { BEGIN(DANSBALISE); return INFCAR;}
@@ -115,7 +98,4 @@
 
 
-<INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->"		{attentionImpossibleDeTrouverXMLDeclapres=1; }
-
-
 <INITIAL,DANSBALISE,HORSBALISE>.|\n	{lmsg=(char*)malloc(1024*sizeof(char));sprintf(lmsg,"error: line %d: character not allowed '%s'",srlineno,yytext);fprintf(stderr,"%s \n",lmsg);srlval.chaine=lmsg;fprintf(stderr,"%s \n",lmsg);return -1;}
 
Index: trunk/zoo-project/zoo-kernel/service_conf.y
===================================================================
--- trunk/zoo-project/zoo-kernel/service_conf.y	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service_conf.y	(revision 621)
@@ -1,7 +1,24 @@
 /*
- * Thx to Jean-Marie CODOL and Naitan GROLLEMUND
- * copyright 2009 GeoLabs SARL 
  * Author : Gérald FENOY
  *
+ * Copyright (c) 209-2015 GeoLabs SARL
+ *
+ * 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.
  */
 %{
@@ -64,11 +81,5 @@
 %token <s> ID
 %token <s> CHAINE
-/* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
-%token STARTXMLDECL ENDXMLDECL
-
-/* version="xxx" et encoding="xxx" */
-%token VERSIONDECL ENCODINGDECL SDDECL
-
-/* < et > */
+
 %token INFCAR SUPCAR 
 
@@ -130,5 +141,5 @@
 {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d) %s\n",__FILE__,__LINE__,$2);
+  fprintf(stderr,"STag (%s %d) %s %d %d \n",__FILE__,__LINE__,$2,current_data,previous_data);
   fflush(stderr);
   dumpMap(current_content);
@@ -146,11 +157,4 @@
   }
   if(strncasecmp($2,"DataInputs",10)==0){
-    if(wait_mainmetadata==true && current_content!=NULL){
-      addMapToMap(&my_service->metadata,current_content);
-      freeMap(&current_content);
-      free(current_content);
-      current_content=NULL;
-      wait_mainmetadata=false;
-    }
     if(current_element==NULL){
 #ifdef DEBUG_SERVICE_CONF
@@ -255,34 +259,13 @@
 	   || strncasecmp($2,"BoundingBoxOutput",13)==0 || strncasecmp($2,"BoundingBoxData",12)==0){
 	  current_data=4;
-	  if(wait_metadata==true){
-	    if(current_content!=NULL){
-#ifdef DEBUG_SERVICE_CONF
-	      fprintf(stderr,"add current_content to current_element->content\n");
-	      fprintf(stderr,"LINE %d",__LINE__);
-#endif
-	      addMapToMap(&current_element->metadata,current_content);
-	      current_element->next=NULL;
-	      if($2!=NULL)
-		current_element->format=zStrdup($2);
-	      
-	      current_element->defaults=NULL;
-	      current_element->supported=NULL;
-	      freeMap(&current_content);
-	      free(current_content);
-	    }
-	  }else{ 
-	    // No MainMetaData
-	    addMapToMap(&current_element->content,current_content);
-	    freeMap(&current_content);
-	    free(current_content);
-	    current_element->metadata=NULL;
-	    current_element->next=NULL;
-	    if($2!=NULL)
-	      current_element->format=zStrdup($2);
-	    current_element->defaults=NULL;
-	    current_element->supported=NULL;
-	  }
+	  addMapToMap(&current_element->content,current_content);
+	  freeMap(&current_content);
+	  free(current_content);
+	  current_element->next=NULL;
+	  if($2!=NULL)
+	    current_element->format=zStrdup($2);
+	  current_element->defaults=NULL;
+	  current_element->supported=NULL;
 	  current_content=NULL;
-	  wait_metadata=false;
 	}
 	else
@@ -311,5 +294,5 @@
 // utiliser la récursivité a gauche
 Attributeetoile
- : Attributeetoile attribute  {}
+: Attributeetoile attribute  {}
  | 	                          {/* Epsilon */}
  ;
@@ -367,5 +350,5 @@
 {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"ETag %s (%s %d) %d %d \n",$3,__FILE__,__LINE__,current_data,previous_data);
 #endif
   if(strcmp($3,"DataInputs")==0){
@@ -399,8 +382,33 @@
   }
   if(strcmp($3,"MetaData")==0){
+    if(current_content!=NULL){
+#ifdef DEBUG_SERVICE_CONF
+      fprintf(stderr,"add current_content to current_element->content\n");
+      fprintf(stderr,"LINE %d",__LINE__);
+#endif
+      if(wait_metadata){
+	current_element->metadata=NULL;
+	addMapToMap(&current_element->metadata,current_content);
+	current_element->next=NULL;
+	current_element->defaults=NULL;
+	current_element->supported=NULL;
+      }else{
+	if(wait_mainmetadata){
+	  addMapToMap(&my_service->metadata,current_content);
+	}
+      }
+
+      freeMap(&current_content);
+      free(current_content);
+      current_content=NULL;
+    }
     current_data=previous_data;
+    wait_mainmetadata=false;
+    wait_metadata=false;
   }
   if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0 
      || strcmp($3,"ComplexOutput")==0 || strcmp($3,"LiteralOutput")==0){
+    if(current_element->format==NULL)
+      current_element->format=zStrdup($3);
     current_content=NULL;
   }
@@ -497,6 +505,31 @@
 | EPAIR {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
-  fprintf(stderr,"EPAIR FOUND !! \n"); 
+  fprintf(stderr,"EPAIR (%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
+  dumpMap(current_content);
+  fflush(stderr);
+#endif
+  if($1!=NULL && curr_key!=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
+    }
+    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
   fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
   fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
@@ -504,31 +537,4 @@
   fflush(stderr);
 #endif
-  if($1!=NULL && curr_key!=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
-    }
-    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
-  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(curr_key!=NULL){
     free(curr_key);
@@ -543,5 +549,5 @@
 : ANID  {
 #ifdef DEBUG_SERVICE_CONF
-  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
+  fprintf(stderr,"processid (%s %d) %s\n",__FILE__,__LINE__,$1);
 #endif
   if(data==-1){
Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 621)
@@ -1249,4 +1249,6 @@
     if(tmp1!=NULL)
       xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);
+    else
+      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST "1");
     map* tmp3=getMapFromMaps(m,"lenv","level");
     addPrefix(m,tmp3,serv);
@@ -1301,5 +1303,7 @@
     else{
       if(j>0)
-	xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "false");      
+	xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "true");
+      else
+	xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST "1");
     }
   }
@@ -1452,5 +1456,5 @@
 	datatype=1;
       }
-      
+
       if(strncmp(type,"Input",5)==0){
 
@@ -1521,7 +1525,7 @@
 		const char* bkt;
 		if ( ( bkt = strchr(pToken, '[') ) != NULL || ( bkt = strchr(pToken, ']') ) != NULL ){
-		    strncpy( tmpStr, pToken, bkt - pToken );
-		    tmpStr[bkt - pToken] = '\0';
-		  }
+		  strncpy( tmpStr, pToken, bkt - pToken );
+		  tmpStr[bkt - pToken] = '\0';
+		}
 	      }
 	      xmlAddChild(nc7,xmlNewText(BAD_CAST tmpStr));
@@ -1608,37 +1612,36 @@
 	
       }
-    
       
-    int oI=0;
-    for(oI=0;oI<13;oI++)
-      if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
+      int oI=0;
+      for(oI=0;oI<13;oI++)
+	if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
 #ifdef DEBUG
-	printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
-#endif
-	if(strcmp(tmp1->name,"asReference")!=0 &&
-	   strncasecmp(tmp1->name,"DataType",8)!=0 &&
-	   strcasecmp(tmp1->name,"extension")!=0 &&
-	   strcasecmp(tmp1->name,"value")!=0 &&
-	   strcasecmp(tmp1->name,"AllowedValues")!=0 &&
-	   strncasecmp(tmp1->name,"range",5)!=0){
-	  if(datatype!=1){
-	    char *tmp2=zCapitalize1(tmp1->name);
-	    nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
-	    free(tmp2);
-	  }
-	  else{
-	    char *tmp2=zCapitalize(tmp1->name);
-	    nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
-	    free(tmp2);
-	  }
-	  xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
-	  xmlAddChild(nc5,nc9);
-	  if(strcasecmp(tmp1->name,"uom")==0)
-	    hasUOM1=true;
-	  hasUOM=true;
-	}else 
+	  printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
+#endif
+	  if(strcmp(tmp1->name,"asReference")!=0 &&
+	     strncasecmp(tmp1->name,"DataType",8)!=0 &&
+	     strcasecmp(tmp1->name,"extension")!=0 &&
+	     strcasecmp(tmp1->name,"value")!=0 &&
+	     strcasecmp(tmp1->name,"AllowedValues")!=0 &&
+	     strncasecmp(tmp1->name,"range",5)!=0){
+	    if(datatype!=1){
+	      char *tmp2=zCapitalize1(tmp1->name);
+	      nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
+	      free(tmp2);
+	    }
+	    else{
+	      char *tmp2=zCapitalize(tmp1->name);
+	      nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
+	      free(tmp2);
+	    }
+	    xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
+	    xmlAddChild(nc5,nc9);
+	    if(strcasecmp(tmp1->name,"uom")==0)
+	      hasUOM1=true;
+	    hasUOM=true;
+	  }else 
 	  
-	  tmp1=tmp1->next;
-      }
+	    tmp1=tmp1->next;
+	}
     
     
@@ -1792,5 +1795,5 @@
     }
     
-    if((tmp1=getMap(_tmp->content,"value"))!=NULL){
+    if(_tmp!=NULL && (tmp1=getMap(_tmp->content,"value"))!=NULL){
       nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue");
       xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value));
@@ -3200,5 +3203,5 @@
 	 * cf. parseBoundingBox
 	 */
-	if(strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
+	if(tmpInputs->format!=NULL && strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
 	  maps* tmpI=getMaps(*out,tmpInputs->name);
 	  if(tmpI!=NULL){
@@ -3518,5 +3521,5 @@
     FILE* fo=fopen(fname,"w+");
     if(fo==NULL){
-#ifdef DEBUG		
+#ifdef DEBUG
       fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno));
 #endif
@@ -3600,5 +3603,4 @@
       }
       for(int i=0;i<atoi(length->value);i++){
-	
 	char* fcontent;
 	char *mimeType=NULL;
@@ -3608,4 +3610,5 @@
 	char vname1[11];
 	char sname[9];
+	char mname[15];
 	char icname[14];
 	char xname[16];
@@ -3620,4 +3623,5 @@
 	  sprintf(vname,"value_%d",i);
 	  sprintf(sname,"size_%d",i);
+	  sprintf(mname,"mimeType_%d",i);
 	  sprintf(icname,"isCached_%d",i);
 	  sprintf(xname,"Reference_%d",i);
@@ -3625,11 +3629,13 @@
 	  sprintf(cname,"cache_file");
 	  sprintf(vname,"value");
+	  sprintf(sname,"size");
+	  sprintf(mname,"mimeType");
 	  sprintf(icname,"isCached");
-	  sprintf(sname,"size");
 	  sprintf(xname,"Reference");
 	}
 
 	map* tmap=getMapFromMaps(*m,"orequests",vname1);
-	if((tmp1=getMap(content->content,xname))!=NULL && strcasecmp(tmap->value,tmp1->value)==0 ){
+	if((tmp1=getMap(content->content,xname))!=NULL /*&& ((tmap!=NULL && strcasecmp(tmap->value,tmp1->value)==0) )*/){
+
 	  if(getMap(content->content,icname)==NULL){
 	    
@@ -3648,5 +3654,5 @@
 	      mimeType=strdup("none");
 	    else
-		  mimeType=strdup(hInternet->ihandle[index].mimeType);	      
+	      mimeType=strdup(hInternet->ihandle[index].mimeType);	      
 	    
 	    map* tmpMap=getMapOrFill(&content->content,vname,"");
@@ -3669,8 +3675,8 @@
 	    }
 	    addToMap(content->content,sname,ltmp1);
+	    addToMap(content->content,mname,mimeType);
 	    addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0);
 	    free(fcontent);
 	    free(mimeType);
-	    dumpMaps(content);
 	    index++;
 
@@ -3688,4 +3694,28 @@
   }
   return 0;
+}
+
+/**
+ * Add a request in the download queue
+ *
+ * @param m the maps containing the settings of the main.cfg file
+ * @param url the url to add to the queue
+ */
+void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){
+  hInternet->waitingRequests[hInternet->nb]=strdup(url);
+  if(req)
+    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
+  maps *oreq=getMaps(*m,"orequests");
+  if(oreq==NULL){
+    oreq=(maps*)malloc(MAPS_SIZE);
+    oreq->name=zStrdup("orequests");
+    oreq->content=createMap("value",url);
+    oreq->next=NULL;
+    addMapsToMaps(m,oreq);
+    freeMaps(&oreq);
+    free(oreq);
+  }else{
+    setMapArray(oreq->content,"value",hInternet->nb-1,url);
+  }
 }
 
@@ -3734,19 +3764,6 @@
     }
 
-  }else{
-    hInternet->waitingRequests[hInternet->nb]=strdup(url);
-    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
-    maps *oreq=getMaps(*m,"orequests");
-    if(oreq==NULL){
-      oreq=(maps*)malloc(MAPS_SIZE);
-      oreq->name=zStrdup("orequests");
-      oreq->content=createMap("value",url);
-      oreq->next=NULL;
-      addMapsToMaps(m,oreq);
-      freeMaps(&oreq);
-      free(oreq);
-    }else{
-      setMapArray(oreq->content,"value",hInternet->nb-1,url);
-    }
+  }else{    
+    addRequestToQueue(m,hInternet,url,true);
     return 0;
   }
@@ -3775,5 +3792,4 @@
   else{
     addToMap(*content,"isCached","true");
-
     map* tmp=getMapFromMaps(*m,"main","cacheDir");
     if(tmp!=NULL){
Index: trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.h	(revision 620)
+++ trunk/zoo-project/zoo-kernel/service_internal.h	(revision 621)
@@ -216,4 +216,5 @@
   char* isInCache(maps*,char*);
   int runHttpRequests(maps**,maps**,HINTERNET*);
+  void addRequestToQueue(maps**,HINTERNET*,const char*,bool);
   int loadRemoteFile(maps**,map**,HINTERNET*,char*);
 
Index: trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.c	(revision 620)
+++ trunk/zoo-project/zoo-kernel/ulinet.c	(revision 621)
@@ -238,4 +238,6 @@
       handle0->ihandle[i].header=NULL;
     }
+    if(handle.post!=NULL)
+      free(handle.post);
     free(handle.mimeType);
     handle.mimeType = NULL;
@@ -272,4 +274,5 @@
   hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
   hInternet->ihandle[hInternet->nb].pabyData = NULL;
+  hInternet->ihandle[hInternet->nb].post = NULL;
 
   curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
@@ -321,5 +324,5 @@
 #ifdef MSG_LAF_VERBOSE
     fprintf(stderr,"FROM ULINET !!");
-    fprintf(stderr,"HEADER : %s\n",lpszHeaders);
+    fprintf(stderr,"HEADER : [%s] %d\n",lpszHeaders,dwHeadersLength);
 #endif
     curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POST,1);
@@ -328,6 +331,7 @@
     curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_VERBOSE,1);
 #endif
-    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,lpszHeaders);
-    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
+    hInternet->ihandle[hInternet->nb].post=strdup(lpszHeaders);
+    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,hInternet->ihandle[hInternet->nb].post);
+    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,(long)dwHeadersLength);
   }
   if(hInternet->ihandle[hInternet->nb].header!=NULL)
@@ -338,6 +342,6 @@
   curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
   
+  hInternet->ihandle[hInternet->nb].header=NULL;
   ++hInternet->nb;
-  hInternet->ihandle[hInternet->nb].header=NULL;
 
 #ifdef ULINET_DEBUG
Index: trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.h	(revision 620)
+++ trunk/zoo-project/zoo-kernel/ulinet.h	(revision 621)
@@ -48,5 +48,5 @@
 #ifndef true
 #define true 1
-#define false -1
+#define false 0
 #endif
 
@@ -81,4 +81,5 @@
     unsigned char *pabyData; //!< the downloaded content
     char *mimeType; //!< the mimeType returned by the server
+    char *post; //!< the potential POST XML content
     int hasCacheFile; //!< 1 if we used a cache file
     int nDataLen; //!< the length of the downloaded content
Index: trunk/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 620)
+++ trunk/zoo-project/zoo-kernel/zoo_loader.c	(revision 621)
@@ -54,6 +54,6 @@
 
 #include "service_internal.h"
-
-xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
+#include "request_parser.h"
+
 int runRequest(map**);
 
@@ -216,4 +216,5 @@
    * one.
    */
+
   if(strncasecmp(cgiRequestMethod,"post",4)==0 || 
      (count(tmpMap)==1 && strncmp(tmpMap->value,"<",1)==0) 
@@ -226,5 +227,5 @@
      */
     map* t1=getMap(tmpMap,"request");
-    if(t1!=NULL && strncasecmp(t1->value,"<",1)==0){
+    if(t1!=NULL && strncasecmp(t1->value,"<",1)==0) {
       addToMap(tmpMap,"xrequest",t1->value);
       xmlInitParser();
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 620)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 621)
@@ -54,4 +54,5 @@
 
 #include "service_internal.h"
+#include "request_parser.h"
 
 #ifdef USE_PYTHON
@@ -179,90 +180,4 @@
 }
 
-/**
- * Create (or append to) an array valued maps value = "["",""]"
- *
- * @param m the conf maps containing the main.cfg settings
- * @param mo the map to update
- * @param mi the map to append
- * @param elem the elements containing default definitions
- * @return 0 on success, -1 on failure
- */
-int
-appendMapsToMaps (maps * m, maps * mo, maps * mi, elements * elem)
-{
-  maps *tmpMaps = getMaps (mo, mi->name);
-  map *tmap = getMapType (tmpMaps->content);
-  elements *el = getElements (elem, mi->name);
-  int hasEl = 1;
-  if (el == NULL)
-    hasEl = -1;
-  if (tmap == NULL)
-    {
-      if (hasEl > 0)
-        tmap = getMapType (el->defaults->content);
-    }
-
-  map *testMap = NULL;
-  if (hasEl > 0)
-    {
-      testMap = getMap (el->content, "maxOccurs");
-    }
-  else
-    {
-      testMap = createMap ("maxOccurs", "unbounded");
-    }
-
-  if (testMap != NULL)
-    {
-      if (strncasecmp (testMap->value, "unbounded", 9) != 0
-          && atoi (testMap->value) > 1)
-        {
-	  addMapsArrayToMaps (&mo, mi, tmap->name);
-	  map* nb=getMapFromMaps(mo,mi->name,"length");
-          if (nb!=NULL && atoi(nb->value)>atoi(testMap->value))
-            {
-              char emsg[1024];
-              sprintf (emsg,
-                       _("The maximum allowed occurrences for <%s> (%i) was exceeded."),
-                       mi->name, atoi (testMap->value));
-              errorException (m, emsg, "InternalError", NULL);
-              return -1;
-            }
-        }
-      else
-        {
-          if (strncasecmp (testMap->value, "unbounded", 9) == 0)
-            {
-              if (hasEl < 0)
-                {
-                  freeMap (&testMap);
-                  free (testMap);
-                }
-              if (addMapsArrayToMaps (&mo, mi, tmap->name) < 0)
-                {
-                  char emsg[1024];
-                  map *tmpMap = getMap (mi->content, "length");
-                  sprintf (emsg,
-                           _
-                           ("ZOO-Kernel was unable to load your data for %s position %s."),
-                           mi->name, tmpMap->value);
-                  errorException (m, emsg, "InternalError", NULL);
-                  return -1;
-                }
-            }
-          else
-            {
-              char emsg[1024];
-              sprintf (emsg,
-                       _
-                       ("The maximum allowed occurrences for <%s> is one."),
-                       mi->name);
-              errorException (m, emsg, "InternalError", NULL);
-              return -1;
-            }
-        }
-    }
-  return 0;
-}
 
 /**
@@ -495,22 +410,4 @@
   (void) closedir (dirp);
   return 1;
-}
-
-/**
- * Apply XPath Expression on XML document.
- *
- * @param doc the XML Document
- * @param search the XPath expression
- * @return xmlXPathObjectPtr containing the resulting nodes set
- */
-xmlXPathObjectPtr
-extractFromDoc (xmlDocPtr doc, const char *search)
-{
-  xmlXPathContextPtr xpathCtx;
-  xmlXPathObjectPtr xpathObj;
-  xpathCtx = xmlXPathNewContext (doc);
-  xpathObj = xmlXPathEvalExpression (BAD_CAST search, xpathCtx);
-  xmlXPathFreeContext (xpathCtx);
-  return xpathObj;
 }
 
@@ -1722,1527 +1619,16 @@
   maps *request_input_real_format = NULL;
   maps *tmpmaps = request_input_real_format;
-  map *postRequest = NULL;
-  postRequest = getMap (request_inputs, "xrequest");
-  if (postRequest == NULLMAP)
-    {
-    /**
-     * Parsing outputs provided as KVP
-     */
-      r_inputs = NULL;
-#ifdef DEBUG
-      fprintf (stderr, "OUTPUT Parsing ... \n");
-#endif
-      r_inputs = getMap (request_inputs, "ResponseDocument");
-      if (r_inputs == NULL)
-        r_inputs = getMap (request_inputs, "RawDataOutput");
-
-#ifdef DEBUG
-      fprintf (stderr, "OUTPUT Parsing ... \n");
-#endif
-      if (r_inputs != NULL)
-        {
-#ifdef DEBUG
-          fprintf (stderr, "OUTPUT Parsing start now ... \n");
-#endif
-          char cursor_output[10240];
-          char *cotmp = zStrdup (r_inputs->value);
-          snprintf (cursor_output, 10240, "%s", cotmp);
-          free (cotmp);
-          j = 0;
-
-      /**
-       * Put each Output into the outputs_as_text array
-       */
-          char *pToken;
-          maps *tmp_output = NULL;
-#ifdef DEBUG
-          fprintf (stderr, "OUTPUT [%s]\n", cursor_output);
-#endif
-          pToken = strtok (cursor_output, ";");
-          char **outputs_as_text = (char **) malloc (128 * sizeof (char *));
-          if (outputs_as_text == NULL)
-            {
-              return errorException (m, _("Unable to allocate memory"),
-                                     "InternalError", NULL);
-            }
-          i = 0;
-          while (pToken != NULL)
-            {
-#ifdef DEBUG
-              fprintf (stderr, "***%s***\n", pToken);
-              fflush (stderr);
-              fprintf (stderr, "***%s***\n", pToken);
-#endif
-              outputs_as_text[i] =
-                (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
-              if (outputs_as_text[i] == NULL)
-                {
-                  return errorException (m, _("Unable to allocate memory"),
-                                         "InternalError", NULL);
-                }
-              snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
-                        pToken);
-              pToken = strtok (NULL, ";");
-              i++;
-            }
-          for (j = 0; j < i; j++)
-            {
-              char *tmp = zStrdup (outputs_as_text[j]);
-              free (outputs_as_text[j]);
-              char *tmpc;
-              tmpc = strtok (tmp, "@");
-              int k = 0;
-              while (tmpc != NULL)
-                {
-                  if (k == 0)
-                    {
-                      if (tmp_output == NULL)
-                        {
-                          tmp_output = (maps *) malloc (MAPS_SIZE);
-                          if (tmp_output == NULL)
-                            {
-                              return errorException (m,
-                                                     _
-                                                     ("Unable to allocate memory."),
-                                                     "InternalError", NULL);
-                            }
-                          tmp_output->name = zStrdup (tmpc);
-                          tmp_output->content = NULL;
-                          tmp_output->next = NULL;
-                        }
-                    }
-                  else
-                    {
-                      char *tmpv = strstr (tmpc, "=");
-                      char tmpn[256];
-                      memset (tmpn, 0, 256);
-                      strncpy (tmpn, tmpc,
-                               (strlen (tmpc) -
-                                strlen (tmpv)) * sizeof (char));
-                      tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
-#ifdef DEBUG
-                      fprintf (stderr, "OUTPUT DEF [%s]=[%s]\n", tmpn,
-                               tmpv + 1);
-#endif
-                      if (tmp_output->content == NULL)
-                        {
-                          tmp_output->content = createMap (tmpn, tmpv + 1);
-                          tmp_output->content->next = NULL;
-                        }
-                      else
-                        addToMap (tmp_output->content, tmpn, tmpv + 1);
-                    }
-                  k++;
-#ifdef DEBUG
-                  fprintf (stderr, "***%s***\n", tmpc);
-#endif
-                  tmpc = strtok (NULL, "@");
-                }
-              if (request_output_real_format == NULL)
-                request_output_real_format = dupMaps (&tmp_output);
-              else
-                addMapsToMaps (&request_output_real_format, tmp_output);
-              freeMaps (&tmp_output);
-              free (tmp_output);
-              tmp_output = NULL;
-#ifdef DEBUG
-              dumpMaps (tmp_output);
-              fflush (stderr);
-#endif
-              free (tmp);
-            }
-          free (outputs_as_text);
-        }
-
-
-    /**
-     * Parsing inputs provided as KVP
-     */
-      r_inputs = getMap (request_inputs, "DataInputs");
-#ifdef DEBUG
-      fprintf (stderr, "DATA INPUTS [%s]\n", r_inputs->value);
-#endif
-      char cursor_input[40960];
-      if (r_inputs != NULL){
-        snprintf (cursor_input, 40960, "%s", r_inputs->value);
-	j = 0;
-
-	/**
-	 * Put each DataInputs into the inputs_as_text array
-	 */
-	char *tmp1 = zStrdup (cursor_input);
-	char *pToken;
-	pToken = strtok (cursor_input, ";");
-	if (pToken != NULL && strncasecmp (pToken, tmp1, strlen (tmp1)) == 0)
-	  {
-	    char *tmp2 = url_decode (tmp1);
-	    snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char), "%s",
-		      tmp2);
-	    free (tmp2);
-	    pToken = strtok (cursor_input, ";");
-	  }
-	free (tmp1);
-	
-	char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
-	if (inputs_as_text == NULL)
-	  {
-	    return errorException (m, _("Unable to allocate memory."),
-				   "InternalError", NULL);
-	  }
-	i = 0;
-	while (pToken != NULL)
-	  {
-#ifdef DEBUG
-	    fprintf (stderr, "***%s***\n", pToken);
-	    fflush (stderr);
-	    fprintf (stderr, "***%s***\n", pToken);
-#endif
-	    inputs_as_text[i] =
-	      (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
-	    if (inputs_as_text[i] == NULL)
-	      {
-		return errorException (m, _("Unable to allocate memory."),
-				       "InternalError", NULL);
-	      }
-	    snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
-	    pToken = strtok (NULL, ";");
-	    i++;
-	  }
-	
-	for (j = 0; j < i; j++)
-	  {
-	    char *tmp = zStrdup (inputs_as_text[j]);
-	    free (inputs_as_text[j]);
-	    char *tmpc;
-	    tmpc = strtok (tmp, "@");
-	    while (tmpc != NULL)
-	      {
-#ifdef DEBUG
-		fprintf (stderr, "***\n***%s***\n", tmpc);
-#endif
-		char *tmpv = strstr (tmpc, "=");
-		char tmpn[256];
-		memset (tmpn, 0, 256);
-		if (tmpv != NULL)
-		  {
-		    strncpy (tmpn, tmpc,
-			     (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
-		    tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
-		  }
-		else
-		  {
-		    strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
-		    tmpn[strlen (tmpc)] = 0;
-		  }
-#ifdef DEBUG
-		fprintf (stderr, "***\n*** %s = %s ***\n", tmpn, tmpv + 1);
-#endif
-		if (tmpmaps == NULL)
-		  {
-		    tmpmaps = (maps *) malloc (MAPS_SIZE);
-		    if (tmpmaps == NULL)
-		      {
-			return errorException (m,
-					       _("Unable to allocate memory."),
-					       "InternalError", NULL);
-		      }
-		    tmpmaps->name = zStrdup (tmpn);
-		    if (tmpv != NULL)
-		      {
-			char *tmpvf = url_decode (tmpv + 1);
-			tmpmaps->content = createMap ("value", tmpvf);
-			free (tmpvf);
-		      }
-		    else
-		      tmpmaps->content = createMap ("value", "Reference");
-		    tmpmaps->next = NULL;
-		  }
-		tmpc = strtok (NULL, "@");
-		while (tmpc != NULL)
-		  {
-#ifdef DEBUG
-		    fprintf (stderr, "*** KVP NON URL-ENCODED \n***%s***\n",
-			     tmpc);
-#endif
-		    char *tmpv1 = strstr (tmpc, "=");
-#ifdef DEBUG
-		    fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
-			     tmpv1 + 1);
-#endif
-		    char tmpn1[1024];
-		    memset (tmpn1, 0, 1024);
-		    if (tmpv1 != NULL)
-		      {
-			strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
-			tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
-			addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
-		      }
-		    else
-		      {
-			strncpy (tmpn1, tmpc, strlen (tmpc));
-			tmpn1[strlen (tmpc)] = 0;
-			map *lmap = getLastMap (tmpmaps->content);
-			char *tmpValue =
-			  (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
-					   sizeof (char));
-			sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
-			free (lmap->value);
-			lmap->value = zStrdup (tmpValue);
-			free (tmpValue);
-			tmpc = strtok (NULL, "@");
-			continue;
-		      }
-#ifdef DEBUG
-		    fprintf (stderr, "*** NAME NON URL-ENCODED \n***%s***\n",
-			     tmpn1);
-		    fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
-			     tmpv1 + 1);
-#endif
-		    if (strcmp (tmpn1, "xlink:href") != 0)
-		      addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
-		    else if (tmpv1 != NULL)
-		      {
-			char *tmpx2 = url_decode (tmpv1 + 1);
-			if (strncasecmp (tmpx2, "http://", 7) != 0 &&
-			    strncasecmp (tmpx2, "ftp://", 6) != 0 &&
-			    strncasecmp (tmpx2, "https://", 8) != 0)
-			  {
-			    char emsg[1024];
-			    sprintf (emsg,
-				     _
-				     ("Unable to find a valid protocol to download the remote file %s"),
-				     tmpv1 + 1);
-			    errorException (m, emsg, "InternalError", NULL);
-			    freeMaps (&m);
-			    free (m);
-			    free (REQUEST);
-			    free (SERVICE_URL);
-			    InternetCloseHandle (&hInternet);
-			    freeService (&s1);
-			    free (s1);
-			    return 0;
-			  }
-#ifdef DEBUG
-			fprintf (stderr,
-				 "REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",
-				 tmpv1 + 1);
-#endif
-			addToMap (tmpmaps->content, tmpn1, tmpx2);
-#ifndef WIN32
-			if (CHECK_INET_HANDLE (hInternet))
-#endif
-			  {
-			    if (loadRemoteFile
-				(&m, &tmpmaps->content, &hInternet, tmpx2) < 0)
-			      {
-				freeMaps (&m);
-				free (m);
-				free (REQUEST);
-				free (SERVICE_URL);
-				InternetCloseHandle (&hInternet);
-				freeService (&s1);
-				free (s1);
-				return 0;
-			      }
-			  }
-			free (tmpx2);
-			addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
-		      }
-		    tmpc = strtok (NULL, "@");
-		  }
-#ifdef DEBUG
-		dumpMaps (tmpmaps);
-		fflush (stderr);
-#endif
-		if (request_input_real_format == NULL)
-		  request_input_real_format = dupMaps (&tmpmaps);
-		else
-		  {
-		    maps *testPresence =
-		      getMaps (request_input_real_format, tmpmaps->name);
-		    if (testPresence != NULL)
-		      {
-			elements *elem =
-			  getElements (s1->inputs, tmpmaps->name);
-			if (elem != NULL)
-			  {
-			    if (appendMapsToMaps
-				(m, request_input_real_format, tmpmaps,
-				 elem) < 0)
-			      {
-				freeMaps (&m);
-				free (m);
-				free (REQUEST);
-				free (SERVICE_URL);
-				InternetCloseHandle (&hInternet);
-				freeService (&s1);
-				free (s1);
-				return 0;
-			      }
-			  }
-		      }
-		    else
-		      addMapsToMaps (&request_input_real_format, tmpmaps);
-		  }
-		freeMaps (&tmpmaps);
-		free (tmpmaps);
-		tmpmaps = NULL;
-		free (tmp);
-	      }
-	  }
-	free (inputs_as_text);
-      }
-    }
-  else
-    {
-    /**
-     * Parse XML request
-     */
-      xmlInitParser ();
-#ifdef DEBUG
-      fflush (stderr);
-      fprintf (stderr, "BEFORE %s\n", postRequest->value);
-      fflush (stderr);
-#endif
-      xmlDocPtr doc = xmlParseMemory (postRequest->value, cgiContentLength);
-#ifdef DEBUG
-      fprintf (stderr, "AFTER\n");
-      fflush (stderr);
-#endif
-
-    /**
-     * Parse every Input in DataInputs node.
-     */
-      xmlXPathObjectPtr tmpsptr =
-        extractFromDoc (doc, "/*/*/*[local-name()='Input']");
-      xmlNodeSet *tmps = tmpsptr->nodesetval;
-#ifdef DEBUG
-      fprintf (stderr, "*****%d*****\n", tmps->nodeNr);
-#endif
-      for (int k = 0; k < tmps->nodeNr; k++)
-        {
-          maps *tmpmaps = NULL;
-          xmlNodePtr cur = tmps->nodeTab[k];
-          if (tmps->nodeTab[k]->type == XML_ELEMENT_NODE)
-            {
-        /**
-	 * A specific Input node.
-	 */
-#ifdef DEBUG
-              fprintf (stderr, "= element 0 node \"%s\"\n", cur->name);
-#endif
-              xmlNodePtr cur2 = cur->children;
-              while (cur2 != NULL)
-                {
-                  while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
-                    cur2 = cur2->next;
-                  if (cur2 == NULL)
-                    break;
-          /**
-	   * Indentifier
-	   */
-                  if (xmlStrncasecmp
-                      (cur2->name, BAD_CAST "Identifier",
-                       xmlStrlen (cur2->name)) == 0)
-                    {
-                      xmlChar *val =
-                        xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
-                      if (tmpmaps == NULL)
-                        {
-                          tmpmaps = (maps *) malloc (MAPS_SIZE);
-                          if (tmpmaps == NULL)
-                            {
-                              return errorException (m,
-                                                     _
-                                                     ("Unable to allocate memory."),
-                                                     "InternalError", NULL);
-                            }
-                          tmpmaps->name = zStrdup ((char *) val);
-                          tmpmaps->content = NULL;
-                          tmpmaps->next = NULL;
-                        }
-                      xmlFree (val);
-                    }
-          /**
-	   * Title, Asbtract
-	   */
-                  if (xmlStrncasecmp
-                      (cur2->name, BAD_CAST "Title",
-                       xmlStrlen (cur2->name)) == 0
-                      || xmlStrncasecmp (cur2->name, BAD_CAST "Abstract",
-                                         xmlStrlen (cur2->name)) == 0)
-                    {
-                      xmlChar *val =
-                        xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
-                      if (tmpmaps == NULL)
-                        {
-                          tmpmaps = (maps *) malloc (MAPS_SIZE);
-                          if (tmpmaps == NULL)
-                            {
-                              return errorException (m,
-                                                     _
-                                                     ("Unable to allocate memory."),
-                                                     "InternalError", NULL);
-                            }
-                          tmpmaps->name = zStrdup ("missingIndetifier");
-                          tmpmaps->content =
-                            createMap ((char *) cur2->name, (char *) val);
-                          tmpmaps->next = NULL;
-                        }
-                      else
-                        {
-                          if (tmpmaps->content != NULL)
-                            addToMap (tmpmaps->content,
-                                      (char *) cur2->name, (char *) val);
-                          else
-                            tmpmaps->content =
-                              createMap ((char *) cur2->name, (char *) val);
-                        }
-#ifdef DEBUG
-                      dumpMaps (tmpmaps);
-#endif
-                      xmlFree (val);
-                    }
-          /**
-	   * InputDataFormChoice (Reference or Data ?) 
-	   */
-                  if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
-                    {
-            /**
-	     * Get every attribute from a Reference node
-	     * mimeType, encoding, schema, href, method
-	     * Header and Body gesture should be added here
-	     */
-#ifdef DEBUG
-                      fprintf (stderr, "REFERENCE\n");
-#endif
-                      const char *refs[5] =
-                        { "mimeType", "encoding", "schema", "method",
-                        "href"
-                      };
-                      for (int l = 0; l < 5; l++)
-                        {
-#ifdef DEBUG
-                          fprintf (stderr, "*** %s ***", refs[l]);
-#endif
-                          xmlChar *val = xmlGetProp (cur2, BAD_CAST refs[l]);
-                          if (val != NULL && xmlStrlen (val) > 0)
-                            {
-                              if (tmpmaps->content != NULL)
-                                addToMap (tmpmaps->content, refs[l],
-                                          (char *) val);
-                              else
-                                tmpmaps->content =
-                                  createMap (refs[l], (char *) val);
-                              map *ltmp = getMap (tmpmaps->content, "method");
-                              if (l == 4)
-                                {
-                                  if (!
-                                      (ltmp != NULL
-                                       && strncmp (ltmp->value, "POST",
-                                                   4) == 0)
-                                      && CHECK_INET_HANDLE (hInternet))
-                                    {
-                                      if (loadRemoteFile
-                                          (&m, &tmpmaps->content, &hInternet,
-                                           (char *) val) != 0)
-                                        {
-                                          freeMaps (&m);
-                                          free (m);
-                                          free (REQUEST);
-                                          free (SERVICE_URL);
-                                          InternetCloseHandle (&hInternet);
-                                          freeService (&s1);
-                                          free (s1);
-                                          return 0;
-                                        }
-                                    }
-                                }
-                            }
-#ifdef DEBUG
-                          fprintf (stderr, "%s\n", val);
-#endif
-                          xmlFree (val);
-                        }
-#ifdef POST_DEBUG
-                      fprintf (stderr,
-                               "Parse Header and Body from Reference \n");
-#endif
-                      xmlNodePtr cur3 = cur2->children;
-                      /*      HINTERNET hInternetP;
-                         hInternetP=InternetOpen(
-                         #ifndef WIN32
-                         (LPCTSTR)
-                         #endif
-                         "ZooWPSClient\0",
-                         INTERNET_OPEN_TYPE_PRECONFIG,
-                         NULL,NULL, 0); */
-                      //hInternet.ihandle[hInternet.nb].header=NULL;
-                      while (cur3 != NULL)
-                        {
-                          while (cur3 != NULL
-                                 && cur3->type != XML_ELEMENT_NODE)
-                            cur3 = cur3->next;
-                          if (cur3 == NULL)
-                            break;
-                          if (xmlStrcasecmp (cur3->name, BAD_CAST "Header") ==
-                              0)
-                            {
-                              const char *ha[2];
-                              ha[0] = "key";
-                              ha[1] = "value";
-                              int hai;
-                              char *has;
-                              char *key;
-                              for (hai = 0; hai < 2; hai++)
-                                {
-                                  xmlChar *val =
-                                    xmlGetProp (cur3, BAD_CAST ha[hai]);
-#ifdef POST_DEBUG
-                                  fprintf (stderr, "%s = %s\n", ha[hai],
-                                           (char *) val);
-#endif
-                                  if (hai == 0)
-                                    {
-                                      key = zStrdup ((char *) val);
-                                    }
-                                  else
-                                    {
-                                      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 + xmlStrlen (val) +
-                                                 strlen (key)), "%s: %s", key,
-                                                (char *) val);
-                                      free (key);
-#ifdef POST_DEBUG
-                                      fprintf (stderr, "%s\n", has);
-#endif
-                                    }
-                                  xmlFree (val);
-                                }
-                              hInternet.ihandle[hInternet.nb].header =
-                                curl_slist_append (hInternet.ihandle
-                                                   [hInternet.nb].header,
-                                                   has);
-                              if (has != NULL)
-                                free (has);
-                            }
-                          else
-                            {
-#ifdef POST_DEBUG
-                              fprintf (stderr,
-                                       "Try to fetch the body part of the request ...\n");
-#endif
-                              if (xmlStrcasecmp (cur3->name, BAD_CAST "Body")
-                                  == 0)
-                                {
-#ifdef POST_DEBUG
-                                  fprintf (stderr, "Body part found !!!\n",
-                                           (char *) cur3->content);
-#endif
-                                  char *tmp =
-                                    (char *) malloc (cgiContentLength +
-                                                     1 * sizeof (char));
-                                  memset (tmp, 0, cgiContentLength);
-                                  xmlNodePtr cur4 = cur3->children;
-                                  while (cur4 != NULL)
-                                    {
-                                      while (cur4->type != XML_ELEMENT_NODE)
-                                        cur4 = cur4->next;
-                                      xmlDocPtr bdoc =
-                                        xmlNewDoc (BAD_CAST "1.0");
-                                      bdoc->encoding =
-                                        xmlCharStrdup ("UTF-8");
-                                      xmlDocSetRootElement (bdoc, cur4);
-                                      xmlChar *btmps;
-                                      int bsize;
-                                      xmlDocDumpMemory (bdoc, &btmps, &bsize);
-#ifdef POST_DEBUG
-                                      fprintf (stderr,
-                                               "Body part found !!! %s %s\n",
-                                               tmp, (char *) btmps);
-#endif
-                                      if (btmps != NULL)
-                                        sprintf (tmp, "%s", (char *) btmps);
-                                      xmlFree (btmps);
-                                      cur4 = cur4->next;
-                                      xmlFreeDoc (bdoc);
-                                    }
-                                  map *btmp =
-                                    getMap (tmpmaps->content, "href");
-                                  if (btmp != NULL)
-                                    {
-#ifdef POST_DEBUG
-                                      fprintf (stderr, "%s %s\n", btmp->value,
-                                               tmp);
-                                      curl_easy_setopt (hInternet.handle,
-                                                        CURLOPT_VERBOSE, 1);
-#endif
-                                      hInternet.
-                                        waitingRequests[hInternet.nb] =
-                                        strdup (tmp);
-                                      InternetOpenUrl (&hInternet,
-                                                       btmp->value,
-                                                       hInternet.waitingRequests
-                                                       [hInternet.nb],
-                                                       strlen
-                                                       (hInternet.waitingRequests
-                                                        [hInternet.nb]),
-                                                       INTERNET_FLAG_NO_CACHE_WRITE,
-                                                       0);
-                                    }
-                                  free (tmp);
-                                }
-                              else
-                                if (xmlStrcasecmp
-                                    (cur3->name,
-                                     BAD_CAST "BodyReference") == 0)
-                                {
-                                  xmlChar *val =
-                                    xmlGetProp (cur3, BAD_CAST "href");
-                                  HINTERNET bInternet, res1;
-                                  bInternet = InternetOpen (
-#ifndef WIN32
-                                                             (LPCTSTR)
-#endif
-                                                             "ZooWPSClient\0",
-                                                             INTERNET_OPEN_TYPE_PRECONFIG,
-                                                             NULL, NULL, 0);
-                                  if (!CHECK_INET_HANDLE (hInternet))
-                                    fprintf (stderr,
-                                             "WARNING : hInternet handle failed to initialize");
-#ifdef POST_DEBUG
-                                  curl_easy_setopt (bInternet.handle,
-                                                    CURLOPT_VERBOSE, 1);
-#endif
-                                  bInternet.waitingRequests[0] =
-                                    strdup ((char *) val);
-                                  res1 =
-                                    InternetOpenUrl (&bInternet,
-                                                     bInternet.waitingRequests
-                                                     [0], NULL, 0,
-                                                     INTERNET_FLAG_NO_CACHE_WRITE,
-                                                     0);
-                                  processDownloads (&bInternet);
-                                  char *tmp =
-                                    (char *)
-                                    malloc ((bInternet.ihandle[0].nDataLen +
-                                             1) * sizeof (char));
-                                  if (tmp == NULL)
-                                    {
-                                      return errorException (m,
-                                                             _
-                                                             ("Unable to allocate memory."),
-                                                             "InternalError",
-                                                             NULL);
-                                    }
-                                  size_t bRead;
-                                  InternetReadFile (bInternet.ihandle[0],
-                                                    (LPVOID) tmp,
-                                                    bInternet.
-                                                    ihandle[0].nDataLen,
-                                                    &bRead);
-                                  tmp[bInternet.ihandle[0].nDataLen] = 0;
-                                  InternetCloseHandle (&bInternet);
-                                  map *btmp =
-                                    getMap (tmpmaps->content, "href");
-                                  if (btmp != NULL)
-                                    {
-#ifdef POST_DEBUG
-                                      fprintf (stderr, "%s %s\n", btmp->value,
-                                               tmp);
-#endif
-                                      hInternet.
-                                        waitingRequests[hInternet.nb] =
-                                        strdup (tmp);
-                                      res =
-                                        InternetOpenUrl (&hInternet,
-                                                         btmp->value,
-                                                         hInternet.waitingRequests
-                                                         [hInternet.nb],
-                                                         strlen
-                                                         (hInternet.waitingRequests
-                                                          [hInternet.nb]),
-                                                         INTERNET_FLAG_NO_CACHE_WRITE,
-                                                         0);
-                                    }
-                                  free (tmp);
-                                }
-                            }
-                          cur3 = cur3->next;
-                        }
-#ifdef POST_DEBUG
-                      fprintf (stderr,
-                               "Header and Body was parsed from Reference \n");
-#endif
-#ifdef DEBUG
-                      dumpMap (tmpmaps->content);
-                      fprintf (stderr, "= element 2 node \"%s\" = (%s)\n",
-                               cur2->name, cur2->content);
-#endif
-                    }
-                  else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0)
-                    {
-#ifdef DEBUG
-                      fprintf (stderr, "DATA\n");
-#endif
-                      xmlNodePtr cur4 = cur2->children;
-                      while (cur4 != NULL)
-                        {
-                          while (cur4 != NULL
-                                 && cur4->type != XML_ELEMENT_NODE)
-                            cur4 = cur4->next;
-                          if (cur4 == NULL)
-                            break;
-                          if (xmlStrcasecmp
-                              (cur4->name, BAD_CAST "LiteralData") == 0)
-                            {
-                /**
-		 * Get every attribute from a LiteralData node
-		 * dataType , uom
-		 */
-                              char *list[2];
-                              list[0] = zStrdup ("dataType");
-                              list[1] = zStrdup ("uom");
-                              for (int l = 0; l < 2; l++)
-                                {
-#ifdef DEBUG
-                                  fprintf (stderr, "*** LiteralData %s ***",
-                                           list[l]);
-#endif
-                                  xmlChar *val =
-                                    xmlGetProp (cur4, BAD_CAST list[l]);
-                                  if (val != NULL
-                                      && strlen ((char *) val) > 0)
-                                    {
-                                      if (tmpmaps->content != NULL)
-                                        addToMap (tmpmaps->content, list[l],
-                                                  (char *) val);
-                                      else
-                                        tmpmaps->content =
-                                          createMap (list[l], (char *) val);
-#ifdef DEBUG
-                                      fprintf (stderr, "%s\n", val);
-#endif
-                                    }
-                                  xmlFree (val);
-                                  free (list[l]);
-                                }
-                            }
-                          else
-                            if (xmlStrcasecmp
-                                (cur4->name, BAD_CAST "ComplexData") == 0)
-                            {
-                /**
-		 * Get every attribute from a Reference node
-		 * mimeType, encoding, schema
-		 */
-                              const char *coms[3] =
-                                { "mimeType", "encoding", "schema" };
-                              for (int l = 0; l < 3; l++)
-                                {
-#ifdef DEBUG
-                                  fprintf (stderr, "*** ComplexData %s ***\n",
-                                           coms[l]);
-#endif
-                                  xmlChar *val =
-                                    xmlGetProp (cur4, BAD_CAST coms[l]);
-                                  if (val != NULL
-                                      && strlen ((char *) val) > 0)
-                                    {
-                                      if (tmpmaps->content != NULL)
-                                        addToMap (tmpmaps->content, coms[l],
-                                                  (char *) val);
-                                      else
-                                        tmpmaps->content =
-                                          createMap (coms[l], (char *) val);
-#ifdef DEBUG
-                                      fprintf (stderr, "%s\n", val);
-#endif
-                                    }
-                                  xmlFree (val);
-                                }
-                            }
-
-                          map *test = getMap (tmpmaps->content, "encoding");
-
-                          if (test == NULL)
-                            { 
-                              if (tmpmaps->content != NULL)
-                                addToMap (tmpmaps->content, "encoding",
-                                          "utf-8");
-                              else
-                                tmpmaps->content =
-                                  createMap ("encoding", "utf-8");
-                              test = getMap (tmpmaps->content, "encoding");
-                            }
-
-                          if (strcasecmp (test->value, "base64") != 0)
-                            { 
-                              xmlChar *mv = xmlNodeListGetString (doc,
-                                                                  cur4->
-                                                                  xmlChildrenNode,
-                                                                  1);
-                              map *ltmp =
-                                getMap (tmpmaps->content, "mimeType");
-                              if (mv == NULL
-                                  ||
-                                  (xmlStrcasecmp
-                                   (cur4->name, BAD_CAST "ComplexData") == 0
-                                   && (ltmp == NULL
-                                       || strncasecmp (ltmp->value,
-                                                       "text/xml", 8) == 0)))
-                                {
-                                  xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
-                                  int buffersize;
-                                  xmlNodePtr cur5 = cur4->children;
-                                  while (cur5 != NULL
-                                         && cur5->type != XML_ELEMENT_NODE
-                                         && cur5->type !=
-                                         XML_CDATA_SECTION_NODE)
-                                    cur5 = cur5->next;
-                                  if (cur5 != NULL
-                                      && cur5->type != XML_CDATA_SECTION_NODE)
-                                    {
-                                      xmlDocSetRootElement (doc1, cur5);
-                                      xmlDocDumpFormatMemoryEnc (doc1, &mv,
-                                                                 &buffersize,
-                                                                 "utf-8", 1);
-                                      char size[1024];
-                                      sprintf (size, "%d", buffersize);
-                                      addToMap (tmpmaps->content, "size",
-                                                size);
-                                      xmlFreeDoc (doc1);
-                                    }
-				  else
-				    {
-				      if (cur5 != NULL
-					  && cur5->type == XML_CDATA_SECTION_NODE){
-					xmlDocPtr doc2 = xmlParseMemory((const char*)cur5->content,xmlStrlen(cur5->content));
-					xmlDocSetRootElement (doc1,xmlDocGetRootElement(doc2));
-					xmlDocDumpFormatMemoryEnc (doc1, &mv,
-								   &buffersize,
-								   "utf-8", 1);
-					char size[1024];
-					sprintf (size, "%d", buffersize);
-					addToMap (tmpmaps->content, "size",
-						  size);
-					xmlFreeDoc (doc2);
-					xmlFreeDoc (doc1);
-				      }
-				    }
-                                }else{
-				xmlNodePtr cur5 = cur4->children;
-				while (cur5 != NULL
-				       && cur5->type != XML_CDATA_SECTION_NODE)
-				  cur5 = cur5->next;
-				if (cur5 != NULL
-				    && cur5->type == XML_CDATA_SECTION_NODE){
-				  xmlFree(mv);
-				  mv=xmlStrdup(cur5->content);
-				}
-			      }
-                              if (mv != NULL)
-                                {
-                                  addToMap (tmpmaps->content, "value",
-                                            (char *) mv);
-                                  xmlFree (mv);
-                                }
-                            }
-                          else
-                            {
-                              xmlChar *tmp = xmlNodeListGetRawString (doc,
-                                                                      cur4->xmlChildrenNode,
-                                                                      0);
-                              addToMap (tmpmaps->content, "value",
-                                        (char *) tmp);
-                              map *tmpv = getMap (tmpmaps->content, "value");
-                              char *res = NULL;
-                              char *curs = tmpv->value;
-                              for (int i = 0; i <= strlen (tmpv->value) / 64;
-                                   i++)
-                                {
-                                  if (res == NULL)
-                                    res =
-                                      (char *) malloc (67 * sizeof (char));
-                                  else
-                                    res =
-                                      (char *) realloc (res,
-                                                        (((i + 1) * 65) +
-                                                         i) * sizeof (char));
-                                  int csize = i * 65;
-                                  strncpy (res + csize, curs, 64);
-                                  if (i == xmlStrlen (tmp) / 64)
-                                    strcat (res, "\n\0");
-                                  else
-                                    {
-                                      strncpy (res + (((i + 1) * 64) + i),
-                                               "\n\0", 2);
-                                      curs += 64;
-                                    }
-                                }
-                              free (tmpv->value);
-                              tmpv->value = zStrdup (res);
-                              free (res);
-                              xmlFree (tmp);
-                            }
-                          cur4 = cur4->next;
-                        }
-                    }
-#ifdef DEBUG
-                  fprintf (stderr, "cur2 next \n");
-                  fflush (stderr);
-#endif
-                  cur2 = cur2->next;
-                }
-#ifdef DEBUG
-              fprintf (stderr, "ADD MAPS TO REQUEST MAPS !\n");
-              fflush (stderr);
-#endif
-
-              {
-                maps *testPresence =
-                  getMaps (request_input_real_format, tmpmaps->name);
-                if (testPresence != NULL)
-                  {
-                    elements *elem = getElements (s1->inputs, tmpmaps->name);
-                    if (elem != NULL)
-                      {
-                        if (appendMapsToMaps
-                            (m, request_input_real_format, tmpmaps, elem) < 0)
-                          {
-                            freeMaps (&m);
-                            free (m);
-                            free (REQUEST);
-                            free (SERVICE_URL);
-                            InternetCloseHandle (&hInternet);
-                            freeService (&s1);
-                            free (s1);
-                            return 0;
-                          }
-                      }
-                  }
-                else
-                  addMapsToMaps (&request_input_real_format, tmpmaps);
-              }
-
-#ifdef DEBUG
-              fprintf (stderr, "******TMPMAPS*****\n");
-              dumpMaps (tmpmaps);
-              fprintf (stderr, "******REQUESTMAPS*****\n");
-              dumpMaps (request_input_real_format);
-#endif
-              freeMaps (&tmpmaps);
-              free (tmpmaps);
-              tmpmaps = NULL;
-            }
-#ifdef DEBUG
-          dumpMaps (tmpmaps);
-#endif
-        }
-#ifdef DEBUG
-      fprintf (stderr, "Search for response document node\n");
-#endif
-      xmlXPathFreeObject (tmpsptr);
-
-      tmpsptr =
-        extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']");
-      bool asRaw = false;
-      tmps = tmpsptr->nodesetval;
-      if (tmps->nodeNr == 0)
-        {
-          xmlXPathFreeObject (tmpsptr);
-          tmpsptr =
-            extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']");
-          tmps = tmpsptr->nodesetval;
-          asRaw = true;
-        }
-#ifdef DEBUG
-      fprintf (stderr, "*****%d*****\n", tmps->nodeNr);
-#endif
-      if (asRaw == true)
-        {
-          addToMap (request_inputs, "RawDataOutput", "");
-          xmlNodePtr cur0 = tmps->nodeTab[0];
-          if (cur0->type == XML_ELEMENT_NODE)
-            {
-
-              maps *tmpmaps = (maps *) malloc (MAPS_SIZE);
-              if (tmpmaps == NULL)
-                {
-                  return errorException (m, _("Unable to allocate memory."),
-                                         "InternalError", NULL);
-                }
-              tmpmaps->name = zStrdup ("unknownIdentifier");
-              tmpmaps->content = NULL;
-              tmpmaps->next = NULL;
-
-        /**
-	 * Get every attribute from a RawDataOutput node
-	 * mimeType, encoding, schema, uom
-	 */
-              const char *outs[4] =
-                { "mimeType", "encoding", "schema", "uom" };
-              for (int l = 0; l < 4; l++)
-                {
-#ifdef DEBUG
-                  fprintf (stderr, "*** %s ***\t", outs[l]);
-#endif
-                  xmlChar *val = xmlGetProp (cur0, BAD_CAST outs[l]);
-                  if (val != NULL)
-                    {
-                      if (strlen ((char *) val) > 0)
-                        {
-                          if (tmpmaps->content != NULL)
-                            addToMap (tmpmaps->content, outs[l],
-                                      (char *) val);
-                          else
-                            tmpmaps->content =
-                              createMap (outs[l], (char *) val);
-                        }
-                      xmlFree (val);
-                    }
-                }
-              xmlNodePtr cur2 = cur0->children;
-              while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
-                cur2 = cur2->next;
-              while (cur2 != NULL)
-                {
-                  if (xmlStrncasecmp
-                      (cur2->name, BAD_CAST "Identifier",
-                       xmlStrlen (cur2->name)) == 0)
-                    {
-                      xmlChar *val =
-                        xmlNodeListGetString (NULL, cur2->xmlChildrenNode, 1);
-                      free (tmpmaps->name);
-                      tmpmaps->name = zStrdup ((char *) val);
-                      xmlFree (val);
-                    }
-                  cur2 = cur2->next;
-                  while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
-                    cur2 = cur2->next;
-                }
-              if (request_output_real_format == NULL)
-                request_output_real_format = dupMaps (&tmpmaps);
-              else
-                addMapsToMaps (&request_output_real_format, tmpmaps);
-              if (tmpmaps != NULL)
-                {
-                  freeMaps (&tmpmaps);
-                  free (tmpmaps);
-                  tmpmaps = NULL;
-                }
-            }
-        }
-      else
-	  {
-		addToMap (request_inputs, "ResponseDocument", "");
-			
-		xmlNodePtr cur = tmps->nodeTab[0]; // only one ResponseDocument node
-		if (cur->type == XML_ELEMENT_NODE) {
-		/**
-		 * Get every attribute: storeExecuteResponse, lineage, status
-		 */
-			//map* attributes = NULL;
-			const char *ress[3] =
-			  { "storeExecuteResponse", "lineage", "status" };
-			xmlChar *val;
-			for (int l = 0; l < 3; l++)
-			{
-	#ifdef DEBUG
-				fprintf (stderr, "*** %s ***\t", ress[l]);
-	#endif
-				val = xmlGetProp (cur, BAD_CAST ress[l]);
-				if (val != NULL && strlen ((char *) val) > 0)
-				{
-				/*
-					if (attributes == NULL) {
-						attributes = createMap (ress[l], (char *) val);
-					}
-					else {
-						addToMap (attributes, ress[l], (char *) val);
-					}
-				*/		
-					addToMap (request_inputs, ress[l], (char *) val);
-				  }
-	#ifdef DEBUG
-				fprintf (stderr, "%s\n", val);
-	#endif
-				xmlFree (val);
-			}
-			
-			xmlNodePtr cur1 = cur->children;		
-			while (cur1 != NULL) // iterate over Output nodes
-			{
-				if (cur1->type != XML_ELEMENT_NODE || 
-					xmlStrncasecmp(cur1->name, BAD_CAST "Output", 
-								   xmlStrlen (cur1->name)) != 0) {
-					cur1 = cur1->next;
-					continue;
-				}
-				
-				maps *tmpmaps = (maps *) malloc (MAPS_SIZE); // one per Output node
-				if (tmpmaps == NULL) {
-					return errorException (m,
-										   _
-										   ("Unable to allocate memory."),
-										   "InternalError", NULL);
-				}
-				tmpmaps->name = zStrdup ("unknownIdentifier");
-				tmpmaps->content = NULL;
-				tmpmaps->next = NULL;
-				
-				xmlNodePtr elems = cur1->children;
-				
-				while (elems != NULL) {
-				
-					/**
-					 * Identifier
-					 */		
-					if (xmlStrncasecmp
-						(elems->name, BAD_CAST "Identifier",
-						 xmlStrlen (elems->name)) == 0)
-					{			
-						xmlChar *val =
-						  xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
-						
-						free(tmpmaps->name);
-						tmpmaps->name = zStrdup ((char *) val);  
-						if (tmpmaps->content == NULL) {
-							tmpmaps->content = createMap("Identifier", zStrdup ((char *) val));
-						}
-						else {
-							addToMap(tmpmaps->content, "Identifier", zStrdup ((char *) val));
-						}
-					  
-						map* tt = getMap (request_inputs, "ResponseDocument");				  
-						if (strlen(tt->value) == 0) {
-						  addToMap (request_inputs, "ResponseDocument",
-									(char *) val);							
-						}	
-						else {
-							char* tmp = (char*) malloc((strlen(tt->value) + 1 
-												+ strlen((char*) val) + 1) * sizeof(char));
-							sprintf (tmp, "%s;%s", tt->value, (char *) val);
-							free(tt->value);
-							tt->value = tmp;	
-						}	
-						xmlFree (val);
-					}				
-					/**
-					 * Title, Abstract
-					 */
-					else if (xmlStrncasecmp(elems->name, BAD_CAST "Title",
-											xmlStrlen (elems->name)) == 0
-						  || xmlStrncasecmp(elems->name, BAD_CAST "Abstract",
-										 xmlStrlen (elems->name)) == 0)
-					{
-						xmlChar *val =
-							xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
-							
-						if (tmpmaps->content == NULL) {
-							tmpmaps->content = createMap((char*) elems->name, zStrdup ((char *) val));
-						}
-						else {
-							addToMap(tmpmaps->content, (char*) elems->name, zStrdup ((char *) val));
-						}
-						xmlFree (val);
-					}
-					elems = elems->next;
-				}
-				
-				/**
-				 * Get every attribute from an Output node:
-				 * mimeType, encoding, schema, uom, asReference
-				 */
-				const char *outs[5] =
-					  { "mimeType", "encoding", "schema", "uom", "asReference" };
-					  
-				for (int l = 0; l < 5; l++) {
-	#ifdef DEBUG
-					fprintf (stderr, "*** %s ***\t", outs[l]);
-	#endif
-					xmlChar *val = xmlGetProp (cur1, BAD_CAST outs[l]);				
-					if (val != NULL && xmlStrlen(val) > 0) {
-						if (tmpmaps->content != NULL) {
-							addToMap (tmpmaps->content, outs[l], (char *) val);
-						}			  
-						else {
-							tmpmaps->content = createMap (outs[l], (char *) val);
-						}	
-					}
-	#ifdef DEBUG
-					fprintf (stderr, "%s\n", val);
-	#endif
-					xmlFree (val);
-				}
-				
-				if (request_output_real_format == NULL) {
-					request_output_real_format = tmpmaps;
-				}	
-				else if (getMaps(request_output_real_format, tmpmaps->name) != NULL) {
-					return errorException (m,
-										   _
-										   ("Duplicate <Output> elements in WPS Execute request"),
-										   "InternalError", NULL);
-				}
-				else {
-					maps* mptr = request_output_real_format;
-					while (mptr->next != NULL) {
-						mptr = mptr->next;
-					}
-					mptr->next = tmpmaps;	
-				}					
-				cur1 = cur1->next;
-			}			 
-		}
-	  } 
-      xmlXPathFreeObject (tmpsptr);
-      xmlFreeDoc (doc);
-      xmlCleanupParser ();
-    }
-
-  runHttpRequests (&m, &request_input_real_format, &hInternet);
-
-  //  if(CHECK_INET_HANDLE(hInternet))
-  InternetCloseHandle (&hInternet);
-
-#ifdef DEBUG
-  fprintf (stderr, "\n%d\n", __LINE__);
-  fflush (stderr);
-  dumpMaps (request_input_real_format);
-  dumpMaps (request_output_real_format);
-  dumpMap (request_inputs);
-  fprintf (stderr, "\n%d\n", __LINE__);
-  fflush (stderr);
-#endif
-
-  /**
-   * Ensure that each requested arguments are present in the request
-   * DataInputs and ResponseDocument / RawDataOutput
-   */
-  map* errI=NULL;
-#ifdef DEBUG  
-  dumpMaps(request_input_real_format);
-#endif  
-  char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0,&errI);
-#ifdef DEBUG  
-  dumpMaps(request_input_real_format);
-#endif  
-  maps *ptr = request_input_real_format;
-  while (ptr != NULL)
-    {
-      map *tmp0 = getMap (ptr->content, "size");
-      map *tmp1 = getMap (ptr->content, "maximumMegabytes");
-      if (tmp1 != NULL && tmp0 != NULL)
-        {
-          float i = atof (tmp0->value) / 1048576.0;
-          if (i >= atoi (tmp1->value))
-            {
-              char tmps[1024];
-              map *tmpe = createMap ("code", "FileSizeExceeded");
-              snprintf (tmps, 1024,
-                        _
-                        ("The <%s> parameter has a size limit (%s MB) defined in the ZOO ServicesProvider configuration file, but the reference you provided exceeds this limit (%f MB)."),
-                        ptr->name, tmp1->value, i);
-              addToMap (tmpe, "locator", ptr->name);
-              addToMap (tmpe, "text", tmps);
-              printExceptionReportResponse (m, tmpe);
-              freeService (&s1);
-              free (s1);
-              freeMap (&tmpe);
-              free (tmpe);
-              freeMaps (&m);
-              free (m);
-              free (REQUEST);
-              free (SERVICE_URL);
-              freeMaps (&request_input_real_format);
-              free (request_input_real_format);
-              freeMaps (&request_output_real_format);
-              free (request_output_real_format);
-              freeMaps (&tmpmaps);
-              free (tmpmaps);
-              return 1;
-            }
-        }
-      ptr = ptr->next;
-    }
-
-  map* errO=NULL;
-  char *dfv1 =
-    addDefaultValues (&request_output_real_format, s1->outputs, m, 1,&errO);
-  if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
-    {
-      char tmps[1024];
-      map *tmpe = NULL;
-      if (strcmp (dfv, "") != 0)
-        {
-	  tmpe = createMap ("code", "MissingParameterValue");
-	  int nb=0;
-	  int length=1;
-	  map* len=getMap(errI,"length");
-	  if(len!=NULL)
-	    length=atoi(len->value);
-	  for(nb=0;nb<length;nb++){
-	    map* errp=getMapArray(errI,"value",nb);
-	    snprintf (tmps, 1024,
-		      _
-		      ("The <%s> argument was not specified in DataInputs but is required according to the ZOO ServicesProvider configuration file."),
-		      errp->value);
-	    setMapArray (tmpe, "locator", nb , errp->value);
-	    setMapArray (tmpe, "text", nb , tmps);
-	    setMapArray (tmpe, "code", nb , "MissingParameterValue");
-	  }
-	}
-      if (strcmp (dfv1, "") != 0)
-        {
-	  int ilength=0;
-	  if(tmpe==NULL)
-	    tmpe = createMap ("code", "InvalidParameterValue");
-	  else{
-	    map* len=getMap(tmpe,"length");
-	    if(len!=NULL)
-	      ilength=atoi(len->value);
-	  }
-	  int nb=0;
-	  int length=1;
-	  map* len=getMap(errO,"length");
-	  if(len!=NULL)
-	    length=atoi(len->value);
-	  for(nb=0;nb<length;nb++){
-	    map* errp=getMapArray(errO,"value",nb);
-	    snprintf (tmps, 1024,
-		      _
-		      ("The <%s> argument specified as %s identifier was not recognized (not defined in the ZOO Configuration File)."),
-		      errp->value,
-		      ((getMap(request_inputs,"RawDataOutput")!=NULL)?"RawDataOutput":"ResponseDocument"));
-	    setMapArray (tmpe, "locator", nb+ilength , errp->value);
-	    setMapArray (tmpe, "text", nb+ilength , tmps);
-	    setMapArray (tmpe, "code", nb+ilength , "InvalidParameterValue");
-	  }
-	}
-      printExceptionReportResponse (m, tmpe);
-      freeService (&s1);
-      free (s1);
-      freeMap (&tmpe);
-      free (tmpe);
-      freeMaps (&m);
-      free (m);
-      free (REQUEST);
-      free (SERVICE_URL);
-      freeMaps (&request_input_real_format);
-      free (request_input_real_format);
-      freeMaps (&request_output_real_format);
-      free (request_output_real_format);
-      freeMaps (&tmpmaps);
-      free (tmpmaps);
-      if(errI!=NULL){
-	freeMap(&errI);
-	free(errI);
-      }
-      if(errO!=NULL){
-	freeMap(&errO);
-	free(errO);
-      }
-      return 1;
-    }
-  maps *tmpReqI = request_input_real_format;
-  while (tmpReqI != NULL)
-    {
-      char name[1024];
-      if (getMap (tmpReqI->content, "isFile") != NULL)
-        {
-          if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
-              cgiFormSuccess)
-            {
-              int BufferLen = 1024;
-              cgiFilePtr file;
-              int targetFile;
-              char storageNameOnServer[2048];
-              char fileNameOnServer[64];
-              char contentType[1024];
-              char buffer[1024];
-              char *tmpStr = NULL;
-              int size;
-              int got, t;
-              map *path = getMapFromMaps (m, "main", "tmpPath");
-              cgiFormFileSize (tmpReqI->name, &size);
-              cgiFormFileContentType (tmpReqI->name, contentType,
-                                      sizeof (contentType));
-              if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
-                {
-                  t = -1;
-                  while (1)
-                    {
-                      tmpStr = strstr (name + t + 1, "\\");
-                      if (NULL == tmpStr)
-                        tmpStr = strstr (name + t + 1, "/");
-                      if (NULL != tmpStr)
-                        t = (int) (tmpStr - name);
-                      else
-                        break;
-                    }
-                  strcpy (fileNameOnServer, name + t + 1);
-
-                  sprintf (storageNameOnServer, "%s/%s", path->value,
-                           fileNameOnServer);
-#ifdef DEBUG
-                  fprintf (stderr, "Name on server %s\n",
-                           storageNameOnServer);
-                  fprintf (stderr, "fileNameOnServer: %s\n",
-                           fileNameOnServer);
-#endif
-                  targetFile =
-                    open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
-                          S_IRWXU | S_IRGRP | S_IROTH);
-                  if (targetFile < 0)
-                    {
-#ifdef DEBUG
-                      fprintf (stderr, "could not create the new file,%s\n",
-                               fileNameOnServer);
-#endif
-                    }
-                  else
-                    {
-                      while (cgiFormFileRead (file, buffer, BufferLen, &got)
-                             == cgiFormSuccess)
-                        {
-                          if (got > 0)
-                            write (targetFile, buffer, got);
-                        }
-                    }
-                  addToMap (tmpReqI->content, "lref", storageNameOnServer);
-                  cgiFormFileClose (file);
-                  close (targetFile);
-#ifdef DEBUG
-                  fprintf (stderr, "File \"%s\" has been uploaded",
-                           fileNameOnServer);
-#endif
-                }
-            }
-        }
-      tmpReqI = tmpReqI->next;
-    }
-
-  ensureDecodedBase64 (&request_input_real_format);
-
-#ifdef DEBUG
-  fprintf (stderr, "REQUEST_INPUTS\n");
-  dumpMaps (request_input_real_format);
-  fprintf (stderr, "REQUEST_OUTPUTS\n");
-  dumpMaps (request_output_real_format);
-#endif
+
+
+  if(parseRequest(&m,&request_inputs,s1,&request_input_real_format,&request_output_real_format,&hInternet)<0){
+    freeMaps (&m);
+    free (m);
+    free (REQUEST);
+    free (SERVICE_URL);
+    InternetCloseHandle (&hInternet);
+    freeService (&s1);
+    free (s1);
+    return 0;
+  }
 
   maps *curs = getMaps (m, "env");
@@ -3490,4 +1876,20 @@
   if (status == NULLMAP)
     {
+      if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
+	freeService (&s1);
+	free (s1);
+	freeMaps (&m);
+	free (m);
+	free (REQUEST);
+	free (SERVICE_URL);
+	freeMaps (&request_input_real_format);
+	free (request_input_real_format);
+	freeMaps (&request_output_real_format);
+	free (request_output_real_format);
+	freeMaps (&tmpmaps);
+	free (tmpmaps);
+	return -1;
+      }
+
       loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
                          &request_output_real_format, &eres);
@@ -3530,8 +1932,8 @@
       else if (pid == 0)
         {
-      /**
-       * son : have to close the stdout, stdin and stderr to let the parent
-       * process answer to http client.
-       */
+	  /**
+	   * son : have to close the stdout, stdin and stderr to let the parent
+	   * process answer to http client.
+	   */
 #ifndef WIN32
           zSleep (1);
@@ -3586,4 +1988,22 @@
 #endif
           free (flog);
+	  if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
+	    freeService (&s1);
+	    free (s1);
+	    freeMaps (&m);
+	    free (m);
+	    free (REQUEST);
+	    free (SERVICE_URL);
+	    freeMaps (&request_input_real_format);
+	    free (request_input_real_format);
+	    freeMaps (&request_output_real_format);
+	    free (request_output_real_format);
+	    freeMaps (&tmpmaps);
+	    free (tmpmaps);
+	    fflush (stdout);
+	    unlockShm (lid);
+	    fflush (stderr);
+	    return -1;
+	  }
       /**
        * set status to SERVICE_STARTED and flush stdout to ensure full 
Index: trunk/zoo-project/zoo-services/utils/status/Makefile
===================================================================
--- trunk/zoo-project/zoo-services/utils/status/Makefile	(revision 620)
+++ trunk/zoo-project/zoo-services/utils/status/Makefile	(revision 621)
@@ -16,5 +16,5 @@
 
 cgi-env/wps_status.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ../../../zoo-kernel/service_internal.o ${MS_FILE} ${MS_LDFLAGS} ${JS_LDFLAGS} ${JSLDFLAGS} ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} -lfcgi
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ../../../zoo-kernel/service_internal.o ${MS_FILES} ${MS_LDFLAGS} ${JS_LDFLAGS} ${JSLDFLAGS} ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} -lfcgi
 
 install:
