Changeset 621 for trunk


Ignore:
Timestamp:
Apr 9, 2015, 5:23:06 AM (9 years ago)
Author:
djay
Message:

Major update. Creation of a basic parsing api. Call validateRequest after fork if any.

Location:
trunk/zoo-project
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/HISTORY.txt

    r586 r621  
    99  * Fix maxOccurs handling
    1010  * Fix gesture of downloaded inputs when multiple values are given
    11   * Add detection of generated_file key in outputs to read the file generated by a service
     11  * Add detection of generated_file key in outputs to read the file
     12  generated by a service
     13  * Add a minimal parsing API
     14  * Run validateRequest (download, default settings and decoding)
     15  after fork if any
    1216
    1317Version 1.4.0
     
    1923  * ZOO-Client Javascript API
    2024  * FastCGI fixes
    21   * JavaScript ZOO-API enhancements (COOKIE use and Output in generated XML)
     25  * JavaScript ZOO-API enhancements (COOKIE use and Output in
     26  generated XML)
    2227  * Add debian files
    2328  * Inputs passed by reference downloaded in parallel
    24   * Conform behavior for DescribeProcess when the Identifier was not found
     29  * Conform behavior for DescribeProcess when the Identifier was not
     30  found
    2531  * Add support of maximumMegabytes keywords for ComplexData Inputs
    2632  * Add the optional YAML ZCFG support #4 and the zcfg2yaml converter
    27   * Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax (ticket #90)
     33  * Return error messages that enable the service provider to quickly
     34  identify the root cause of errors due to configuration file syntax
     35  (ticket #90)
    2836  * Fix logic in addMapToMap (ticket #91)
    29   * Enable AllowedValue and multiple Range definitions using default and supported blocks
    30   * Add the lastest revision number in version.h (available in Python ZOO-API)
    31   * Add the optional Ruby Language Support to the ZOO-Kernel with an API similar to the Python ZOO-API
     37  * Enable AllowedValue and multiple Range definitions using default
     38  and supported blocks
     39  * Add the lastest revision number in version.h (available in Python
     40  ZOO-API)
     41  * Add the optional Ruby Language Support to the ZOO-Kernel with an
     42  API similar to the Python ZOO-API
    3243  * Small rewrite of Python support
    3344  * Inputs can be requested over https protocol (ticket #86)
    34   * Add capability to define both percentage of execution and a message (ticket #87).
    35   * Add usid in lenv section used to generate an unique identifier based on time and the process identifier.
     45  * Add capability to define both percentage of execution and a
     46  message (ticket #87).
     47  * Add usid in lenv section used to generate an unique identifier
     48  based on time and the process identifier.
    3649  * Add gdal_contour service
    3750  * Add dynamic definition of serverAddress from the main section
     
    4558Version 1.3.0-rc1
    4659
    47   * Updating ZOO.Class object with the OpenLayers.Class Updating ZOO.Class with the (ticket #64)
     60  * Updating ZOO.Class object with the OpenLayers.Class Updating
     61    ZOO.Class with the (ticket #64)
    4862  * Correct the content of proj4js (ticket #63)
    4963  * Enhance the COOKIE gesture (ticket #68)
    5064  * Support for dataInputs URLEncoded and xlink:href (ticket #62)
    51   * Use the same object structure for JavaScript arguments than for Python
     65  * Use the same object structure for JavaScript arguments than for
     66    Python
    5267  * Add the Normalized Difference Vegetation Index service
    5368  * Add importScripts function to JavaScript support (ticket #66)
    5469  * Add multiple inputs values for the same identifier (ticket #72)
    5570  * Add Python ZOO-API to access ZOO-Kernel internel functions
    56   * Add a [headers] section in main.cfg file to add specifics to header returned
     71  * Add a [headers] section in main.cfg file to add specifics to
     72    header returned
    5773  * Add support for multiple outputs for both GET and POST requests
    5874  * Add Content-Length to the headers if the result is sized
    59   * Add Content-Disposition to the headers if the result contains a filename
     75  * Add Content-Disposition to the headers if the result contains a
     76    filename
    6077  * Add support for sending headers through JS ZOO-api
    6178  * Add support for multi-valued inputs in JS ZOO-api
     
    6885
    6986  * add basic SOAP Envelope support (ticket #49)
    70   * support request when Content-Length header is not set by the client (ticket #57)
     87  * support request when Content-Length header is not set by the
     88  * client (ticket #57)
    7189  * fix issue when POST request is empty (ticket #45)
    7290  * add minimalist cache system (ticket #51)
  • trunk/zoo-project/zoo-kernel/Makefile.in

    r601 r621  
    3232ulinet.o: ulinet.c
    3333        gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c
     34
     35request_parser.o: request_parser.c request_parser.h
     36        gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c
    3437
    3538service_internal.o: service_internal.c service.h mimetypes.h
     
    7275        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
    7376
    74 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}
     77zoo_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}
    7578        g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
    76         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}
     79        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}
    7780
    7881zcfg2yaml: 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}
  • trunk/zoo-project/zoo-kernel/main_conf_read.l

    r378 r621  
    1 /* Line number from bison */
     1/*
     2 * Zoo main configuration file parser
     3 *
     4 * Author : Gérald FENOY
     5 *
     6 * Copyright (c) 209-2015 GeoLabs SARL
     7 *
     8 * Permission is hereby granted, free of charge, to any person obtaining a copy
     9 * of this software and associated documentation files (the "Software"), to deal
     10 * in the Software without restriction, including without limitation the rights
     11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     12 * copies of the Software, and to permit persons to whom the Software is
     13 * furnished to do so, subject to the following conditions:
     14 *
     15 * The above copyright notice and this permission notice shall be included in
     16 * all copies or substantial portions of the Software.
     17 *
     18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     24 * THE SOFTWARE.
     25 */
    226%option yylineno
    327
    428%{
    5 //======================================================
    6 /**
    7 Zoo main configuration file parser
    8 **/
    9 //======================================================
    10 
    1129
    1230#include <string.h>
    1331#include "main_conf_read.tab.h"
    1432static int affichetrace = 0 ;
    15 static int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
    16 static int attentionImpossibleDeTrouverPIapres = 0 ;
    1733
    1834%}
    19 
    20 
    21 S               [ \t\r\n]+
    22 
    23 CharRef         "&#"[0-9]+";"|"&#x"[0-9a-fA-F]+";"
    24 
    25 egalevolue              {S}?"="{S}?
    26 
    27 Name            ([_:]|[\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])(([\x41-\x5A]|[\x61-\x7A]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\xFF])|[0-9.\-_:])*
    28 
    29 chardata        [^<]*
    3035
    3136attname [a-zA-Z0-9_\-:]+
     
    3338attvalue1       [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff]+
    3439
    35 attvalue                \"[^"]*\"|\'[^']*\'
    36 
    37 virgule [,]+
    38 
    39 whitespace                      [ ]{0,}
    4040whitesp                      [ ]
    4141newline                 [\r\n]|[\n]
    42 newlines                 [\r\n]{1,}|[\n]{1,}
    43 
    44 
    4542
    4643%x DANSBALISE HORSBALISE PAIRSTART
    47 
    48 
    49 
    5044
    5145%%
     
    6559<PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*                   {if (affichetrace==1) printf ("\n\nNEWLINE 2\n") ; BEGIN(INITIAL); return NEWLINE;}
    6660
    67 <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;}
    68 
    69 <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\'  {if (affichetrace==1) printf ("\n\nVERSIONDECL:%s\n",yytext) ;return VERSIONDECL;}
    70 <INITIAL>"version"{egalevolue}\"[^"]*\"|"version"{egalevolue}\'[^']*\'  {/* erreur de version encoding */       printf("\nerror : LINE %d : XML Version not supported : %s\n",yylineno,yytext); exit (9) ; }
    71 
    72 
    73 <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;}
    74 <INITIAL>"encoding"{egalevolue}\"[^"]*\"|"encoding"{egalevolue}\'[^']*\'  {/* erreur de version encoding */     printf("\nerror : LINE %d : encoding version not supported : %s\n",yylineno,yytext); exit (8) ; }
    75 
    76 
    77 <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\'  {if (affichetrace==1) printf ("\n\nSDDECL:%s\n",yytext) ; return SDDECL;}
    78 
    79 <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) ; }
    80 
    81 
    82 <INITIAL>"?>"  {if (affichetrace==1) printf ("\n\nENDXMLDECL:%s\n",yytext) ; BEGIN(HORSBALISE);return ENDXMLDECL;}
    83 
    84 
    85 <DANSBALISE,INITIAL,HORSBALISE>{S}   {if (affichetrace==1) printf ("\n\nS:'%s'\n",yytext) ; }
    86 
    87 
    88 <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>"       {if (affichetrace==1) printf ("\n\nPIERROR:%s\n",yytext) ; return PIERROR;}
    89 <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>"          {attentionImpossibleDeTrouverPIapres=1 ;  if (affichetrace==1) printf ("\n\nPI:%s\n",yytext) ; return PI;}
    90 
    91 
    92 <INITIAL,HORSBALISE>{newline}*"<"                   {if (affichetrace==1) printf ("\n\nINFCAR:%s\n",yytext) ; BEGIN(DANSBALISE);return INFCAR;}
    93 
    94 
    95 <DANSBALISE>">"                 {if (affichetrace==1) printf ("\n\nSUPCAR:%s\n",yytext) ; BEGIN(HORSBALISE);return SUPCAR;}
    96 
    97 
    98 <DANSBALISE>"/"         {if (affichetrace==1) printf ("\n\nSLASH:%s\n",yytext) ; return SLASH;}
    99 
    100 
    101 <DANSBALISE>{egalevolue}                        {if (affichetrace==1) printf ("\n\nEq:'%s'\n",yytext) ; return Eq;}
    102 
    103 
    104 <DANSBALISE>{Name}                      {if (affichetrace==1) printf ("\n\nID:%s\n",yytext) ; crlval.s=yytext;return ID;}
    105 
    106 
    107 <DANSBALISE>{attvalue}          {if (affichetrace==1) printf ("\n\nATTVALUE:%s\n",yytext) ; return ATTVALUE;}
    108 
    109 
    110 <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->"          {attentionImpossibleDeTrouverXMLDeclapres=1; }
    111 
    112 
    113 <INITIAL,DANSBALISE,HORSBALISE>.|\n     {if (affichetrace==1)printf("error : LINE %d : character not supported '%s'\n",yylineno,yytext); }
    114 
    11561%%
    11662
  • trunk/zoo-project/zoo-kernel/main_conf_read.y

    r607 r621  
    1 %{
    21/*
    32 * Zoo main configuration file parser
     3 *
     4 * Author : Gérald FENOY
     5 *
     6 * Copyright (c) 209-2015 GeoLabs SARL
     7 *
     8 * Permission is hereby granted, free of charge, to any person obtaining a copy
     9 * of this software and associated documentation files (the "Software"), to deal
     10 * in the Software without restriction, including without limitation the rights
     11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     12 * copies of the Software, and to permit persons to whom the Software is
     13 * furnished to do so, subject to the following conditions:
     14 *
     15 * The above copyright notice and this permission notice shall be included in
     16 * all copies or substantial portions of the Software.
     17 *
     18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     24 * THE SOFTWARE.
    425 */
     26%{
    527#include <service.h>
    628
     
    2850%}
    2951
     52%union { char* s;char* chaine; char* key;char* val;}
    3053
    31 
    32 //======================================================
    33 /* le type des lval des jetons et des elements non terminaux bison */
    34 //======================================================
    35 %union { char* s;char* chaine; char* key;char* val;}
    36 //======================================================
    37 
    38 // jetons //
    39 //======================================================
    40 /* les jetons que l on retrouve dans FLEX */
    41 //======================================================
    42 /* texte on a besoin de récupérer une valeur char* pour la comparer */
    4354%token <s> ID
    4455%token <s> CHAINE
    45 /* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
    46 %token STARTXMLDECL ENDXMLDECL
    47 //======================================================
    48 /* version="xxx" et encoding="xxx" */
    49 %token VERSIONDECL ENCODINGDECL SDDECL
    50 //======================================================
    51 /* < et > */
    52 %token INFCAR SUPCAR
    53 //======================================================
    54 /* / = a1  texte "texte" */
    55 %token SLASH Eq CHARDATA ATTVALUE PAIR SPAIR EPAIR EPAIRS ANID
     56
     57%token PAIR SPAIR EPAIR EPAIRS ANID
    5658%type <chaine> PAIR
    5759%type <chaine> EPAIRS
     
    5961%type <chaine> SPAIR
    6062
    61 //======================================================
    62 /* <!-- xxx -> <? xxx yyy ?> */
    63 %token PI PIERROR /** COMMENT **/
    64 //======================================================
    65 /* <!-- xxx -> <? xxx yyy ?> */
    66 %token ERREURGENERALE CDATA WHITESPACE NEWLINE
    67 //======================================================
    68 // non terminaux typés
    69 //======================================================
    70 /* elements non terminaux de type char *     */
    71 /* uniquement ceux qui devrons etre comparés */
    72 //======================================================
    73 %type <s> STag
    74 %type <s> ETag
     63%token WHITESPACE NEWLINE
     64
    7565%type <s> ANID
    76 //======================================================
    77 // %start
    78 //======================================================
    7966
    8067%%
    81 // document <//===
    82 //======================================================
    83 // regle 1
    84 // on est a la racine du fichier xml
    85 //======================================================
     68
    8669document
    87  : miscetoile element miscetoile {}
     70 : miscetoile miscetoile {}
    8871 | contentetoile processid contentetoile document {}
    8972 ;
    9073
    9174miscetoile
    92  : miscetoile PIERROR {crerror("processing instruction begining with <?xml ?> impossible\n");}
    93  | miscetoile PI {}
    94  | {}
     75 : {}
    9576 ;
    96 // element
    97 //======================================================
    98 // regle 39
    99 // OUVRANTE CONTENU FERMANTE obligatoirement
    100 // ou neutre
    101 // on ne peut pas avoir Epsilon
    102 // un fichier xml ne peut pas etre vide ou seulement avec un prolog
    103 //======================================================
    104 element
    105  : STag contentetoile ETag     
    106 {
    107   /* les non terminaux rendent les valeurs de leur identifiants de balise */
    108   /* en char*, donc on peut comparer ces valeurs avec la fonction C++ strcmp(const char*;const char*) */
    109   /* de string */
    110   if (strcmp($1,$3) != 0)
    111     {
    112       crerror("Opening and ending tag mismatch");
    113       printf("\n  ::details : tag '%s' et '%s' \n",$1,$3);
    114       return 1;
    115       // on retourne different de 0
    116       // sinon yyparse rendra 0
    117       // et dans le main on croira a le fichier xml est valide !
    118     }
    119 }
    120 // pour neutre
    121 // on a rien a faire, meme pas renvoyer l identificateur de balise
    122 // vu qu'il n y a pas de comparaison d'identificateurs avec un balise jumelle .
    123  | EmptyElemTag          {}
    124  ;
    125 //======================================================
    126 // STag
    127 //======================================================
    128 // regle 40
    129 // BALISE OUVRANTE
    130 // on est obligé de faire appel a infcar et supcar
    131 // pour acceder aux start conditions DANSBALISE et INITIAL
    132 //======================================================
    133 STag
    134  : INFCAR ID Attributeetoile SUPCAR
    135 {       
    13677
    137 #ifdef DEBUG
    138         printf("* Identifiant : %s\n",$2);
    139 #endif
    140        
    141         $$ = $2 ;
    142 }
    143  ;
    144 //======================================================
    145 // Attributeetoile
    146 //======================================================
    147 // regle 41
    148 // une liste qui peut etre vide d'attributs
    149 // utiliser la récursivité a gauche
    150 //======================================================
    15178Attributeetoile
    152  : Attributeetoile attribute {}
     79 : Attributeetoile {}
    15380 |                                {/* Epsilon */}
    15481 ;
    155 //======================================================
    156 // attribute
    157 //======================================================
    158 // regle 41
    159 // un attribut est compose d'un identifiant
    160 // d'un "="
    161 // et d'une définition de chaine de caractere
    162 // ( "xxx" ou 'xxx' )
    163 //======================================================
    164 attribute
    165  : ID Eq ATTVALUE               
    166 {
    167         // on verifie que les attributst ne sont pas en double
    168         // sinon on ajoute au vector
    169 }
    170  ;
    171 //======================================================
    172 // EmptyElemTag
    173 //======================================================
    174 // regle 44
    175 // ICI ON DEFINIT NEUTRE
    176 // on ne renvoie pas de char*
    177 // parce qu'il n'y a pas de comparaisons a faire
    178 // avec un identifiant d'une balise jumelle
    179 //======================================================
    180 EmptyElemTag
    181  : INFCAR ID Attributeetoile SLASH SUPCAR       {}
    182  ;
    183 //======================================================
    184 // ETag
    185 //======================================================
    186 // regle 42
    187 // BALISE FERMANTE
    188 // les separateurs après ID sont filtrés
    189 //======================================================
    190 ETag
    191  : INFCAR SLASH ID SUPCAR
    192 {
    193   /* on renvoie l'identifiant de la balise pour pouvoir comparer les 2 */
    194   /* /!\ une balise fermante n'a pas d'attributs (c.f. : W3C) */
    195   $$ = $3;
    196 }
    197  ;
    198 //======================================================
    199 // contentetoile
    200 //======================================================
    201 // regle 43
    202 // ENTRE 2 BALISES
    203 // entre 2 balises, on peut avoir :
    204 // --- OUVRANTE CONTENU FERMANTE (recursivement !)
    205 // --- DU TEXTE quelconque
    206 // --- COMMENTS
    207 // --- DES PROCESSES INSTRUCTIONS
    208 // --- /!\ il peut y avoir une processing instruction invalide ! <?xml
    209 // --- EPSILON
    210 // ### et/ou tout ca a la suite en nombre indeterminé
    211 // ### donc c'est un operateur etoile (*)
    212 //======================================================
     82
    21383contentetoile
    214 : contentetoile element           {}
    215  | contentetoile PIERROR                  {crerror("processing instruction <?xml ?> impossible\n");}
    216  | contentetoile PI                       {}
    217 ///// on filtre les commentaires | contentetoile comment              {}
    218  | contentetoile NEWLINE {/*printf("NEWLINE FOUND !!");*/}
     84: contentetoile NEWLINE {}
    21985 | contentetoile pair {}
    220  | contentetoile processid {}
    221  | contentetoile texteinterbalise         {}
    222  | contentetoile CDATA {} 
    22386 | {/* Epsilon */}
    22487 ;
    225 //======================================================
    226 // texteinterbalise
    227 //======================================================
    228 // regle 14
    229 // DU TEXTE quelconque
    230 // c'est du CHARDATA
    231 // il y a eut un probleme avec ID,
    232 // on a mis des starts conditions,
    233 // maintenant on croise les ID dans les dbalises
    234 // et des CHARDATA hors des balises
    235 //======================================================
    236 texteinterbalise
    237  : CHARDATA             {}
    238  ;
    239 //======================================================
    24088
    241 pair: PAIR {curr_key=zStrdup($1);/*printf("START 0 PAIR FOUND !! \n [%s]\n",$1);*/}
     89pair: PAIR {curr_key=zStrdup($1);}
    24290| EPAIR {
    24391  if(current_content==NULL)
  • trunk/zoo-project/zoo-kernel/service.h

    r618 r621  
    12611261    }
    12621262  }
    1263 
     1263 
    12641264  /**
    12651265   * Dump a service on stderr
  • trunk/zoo-project/zoo-kernel/service_conf.l

    r618 r621  
     1/*
     2 * Author : Gérald FENOY
     3 *
     4 * Copyright (c) 209-2015 GeoLabs SARL
     5 *
     6 * Permission is hereby granted, free of charge, to any person obtaining a copy
     7 * of this software and associated documentation files (the "Software"), to deal
     8 * in the Software without restriction, including without limitation the rights
     9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     10 * copies of the Software, and to permit persons to whom the Software is
     11 * furnished to do so, subject to the following conditions:
     12 *
     13 * The above copyright notice and this permission notice shall be included in
     14 * all copies or substantial portions of the Software.
     15 *
     16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     22 * THE SOFTWARE.
     23 */
    124%option noyywrap
    225%option yylineno
     
    427
    528%{
    6 //======================================================
    7 /**
    8 
    9  authors : Jean-Marie CODOL, Naitan GROLLEMUND
    10 
    11 **/
    12 //======================================================
    13 
    1429
    1530#include <string.h>
    1631#include "service_conf.tab.h"
    1732
    18 #ifdef DEBUG_SERVICE_CONF
    19 int affichetrace = 1;
    20 #else
    21 int affichetrace = 0;
    22 #endif
    23 
    2433char *lmsg=NULL;
    25 int attentionImpossibleDeTrouverXMLDeclapres = 0 ;
    26 
    27 int attentionImpossibleDeTrouverPIapres = 0 ;
    2834
    2935%}
     
    4147
    4248attname [a-zA-Z0-9._\-]+
    43 attvalue1       [#°²θé\^\*\+,;@a-zA-Z0-9%_\-:\:.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+
     49attvalue1       [#°²θé\^\*\+,;?!~`ú@a-zA-Z0-9%_\-:\:.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+
    4450
    4551attvalue                \"[^"]*\"|\'[^']*\'\(\)
     
    5864%%
    5965
    60 "\n" {  if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE\n") ;return NEWLINE;}
     66"\n" { }
    6167
    62 {newline}+{whitesp}*                    {  if (affichetrace==1) fprintf (stderr,"\n\nNEWLINE 1\n") ; return NEWLINE;}
     68{newline}+{whitesp}*                    { return NEWLINE; }
    6369
    6470<INITIAL,HORSBALISE>"["{attname}"]"             {  srlval.chaine=yytext;return ANID; }
     
    7076<PAIRSTART,INITIAL,HORSBALISE>{whitesp}*"="{whitesp}*             {  BEGIN(PAIRSTART);}
    7177
    72 <PAIRSTART,INITIAL,HORSBALISE,DANSBALISE>{newline}+{whitesp}*             { BEGIN(INITIAL);  return NEWLINE;}
    73 
    74 <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;}
    75 
    76 <INITIAL>"version"{egalevolue}\"1.0\"|"version"{egalevolue}\'1.0\'  { return VERSIONDECL;  }
    77 <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) ; }
    78 
    79 
    80 <INITIAL>"encoding"{egalevolue}\"[Ii][Ss][Oo]"-8859-1"\"|"encoding"{egalevolue}\'[Ii][Ss][Oo]"-8859-1"\'  { return ENCODINGDECL;}
    81 <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) ; }
    82 
    83 
    84 <INITIAL>"standalone"{egalevolue}\"yes\"|"standalone"{egalevolue}\'yes\'|"standalone"{egalevolue}\"no\"|"standalone"{egalevolue}\'no\'  { return SDDECL;}
    85 
    86 <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) ; }
    87 
    88 
    89 <INITIAL>"?>"  { BEGIN(HORSBALISE); return ENDXMLDECL;}
    90 
     78<PAIRSTART,INITIAL,HORSBALISE>{newline}+{whitesp}*             { BEGIN(INITIAL);  return NEWLINE;}
    9179
    9280<DANSBALISE,INITIAL,HORSBALISE>{S}   {  }
    93 
    94 
    95 <HORSBALISE>"<?"[Xx][Mm][Ll]{S}({S}|{chardata})*"?>"|"<?"[Xx][Mm][Ll]"?>"       { return PIERROR;}
    96 <INITIAL,HORSBALISE>"<?"([^xX]|([xX][^mM])|([xX][mM][^lL]))({S}|([^?]|("?"[^>])))*"?>"          { attentionImpossibleDeTrouverPIapres=1 ; return PI;}
    97 
    9881
    9982<INITIAL,HORSBALISE>{newline}*"<"                   { BEGIN(DANSBALISE); return INFCAR;}
     
    11598
    11699
    117 <INITIAL,HORSBALISE>"<!--"([^-]|"-"[^-])*"-->"          {attentionImpossibleDeTrouverXMLDeclapres=1; }
    118 
    119 
    120100<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;}
    121101
  • trunk/zoo-project/zoo-kernel/service_conf.y

    r618 r621  
    11/*
    2  * Thx to Jean-Marie CODOL and Naitan GROLLEMUND
    3  * copyright 2009 GeoLabs SARL
    42 * Author : Gérald FENOY
    53 *
     4 * Copyright (c) 209-2015 GeoLabs SARL
     5 *
     6 * Permission is hereby granted, free of charge, to any person obtaining a copy
     7 * of this software and associated documentation files (the "Software"), to deal
     8 * in the Software without restriction, including without limitation the rights
     9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     10 * copies of the Software, and to permit persons to whom the Software is
     11 * furnished to do so, subject to the following conditions:
     12 *
     13 * The above copyright notice and this permission notice shall be included in
     14 * all copies or substantial portions of the Software.
     15 *
     16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     22 * THE SOFTWARE.
    623 */
    724%{
     
    6481%token <s> ID
    6582%token <s> CHAINE
    66 /* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
    67 %token STARTXMLDECL ENDXMLDECL
    68 
    69 /* version="xxx" et encoding="xxx" */
    70 %token VERSIONDECL ENCODINGDECL SDDECL
    71 
    72 /* < et > */
     83
    7384%token INFCAR SUPCAR
    7485
     
    130141{
    131142#ifdef DEBUG_SERVICE_CONF
    132   fprintf(stderr,"(%s %d) %s\n",__FILE__,__LINE__,$2);
     143  fprintf(stderr,"STag (%s %d) %s %d %d \n",__FILE__,__LINE__,$2,current_data,previous_data);
    133144  fflush(stderr);
    134145  dumpMap(current_content);
     
    146157  }
    147158  if(strncasecmp($2,"DataInputs",10)==0){
    148     if(wait_mainmetadata==true && current_content!=NULL){
    149       addMapToMap(&my_service->metadata,current_content);
    150       freeMap(&current_content);
    151       free(current_content);
    152       current_content=NULL;
    153       wait_mainmetadata=false;
    154     }
    155159    if(current_element==NULL){
    156160#ifdef DEBUG_SERVICE_CONF
     
    255259           || strncasecmp($2,"BoundingBoxOutput",13)==0 || strncasecmp($2,"BoundingBoxData",12)==0){
    256260          current_data=4;
    257           if(wait_metadata==true){
    258             if(current_content!=NULL){
    259 #ifdef DEBUG_SERVICE_CONF
    260               fprintf(stderr,"add current_content to current_element->content\n");
    261               fprintf(stderr,"LINE %d",__LINE__);
    262 #endif
    263               addMapToMap(&current_element->metadata,current_content);
    264               current_element->next=NULL;
    265               if($2!=NULL)
    266                 current_element->format=zStrdup($2);
    267              
    268               current_element->defaults=NULL;
    269               current_element->supported=NULL;
    270               freeMap(&current_content);
    271               free(current_content);
    272             }
    273           }else{
    274             // No MainMetaData
    275             addMapToMap(&current_element->content,current_content);
    276             freeMap(&current_content);
    277             free(current_content);
    278             current_element->metadata=NULL;
    279             current_element->next=NULL;
    280             if($2!=NULL)
    281               current_element->format=zStrdup($2);
    282             current_element->defaults=NULL;
    283             current_element->supported=NULL;
    284           }
     261          addMapToMap(&current_element->content,current_content);
     262          freeMap(&current_content);
     263          free(current_content);
     264          current_element->next=NULL;
     265          if($2!=NULL)
     266            current_element->format=zStrdup($2);
     267          current_element->defaults=NULL;
     268          current_element->supported=NULL;
    285269          current_content=NULL;
    286           wait_metadata=false;
    287270        }
    288271        else
     
    311294// utiliser la récursivité a gauche
    312295Attributeetoile
    313  : Attributeetoile attribute  {}
     296: Attributeetoile attribute  {}
    314297 |                                {/* Epsilon */}
    315298 ;
     
    367350{
    368351#ifdef DEBUG_SERVICE_CONF
    369   fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
     352  fprintf(stderr,"ETag %s (%s %d) %d %d \n",$3,__FILE__,__LINE__,current_data,previous_data);
    370353#endif
    371354  if(strcmp($3,"DataInputs")==0){
     
    399382  }
    400383  if(strcmp($3,"MetaData")==0){
     384    if(current_content!=NULL){
     385#ifdef DEBUG_SERVICE_CONF
     386      fprintf(stderr,"add current_content to current_element->content\n");
     387      fprintf(stderr,"LINE %d",__LINE__);
     388#endif
     389      if(wait_metadata){
     390        current_element->metadata=NULL;
     391        addMapToMap(&current_element->metadata,current_content);
     392        current_element->next=NULL;
     393        current_element->defaults=NULL;
     394        current_element->supported=NULL;
     395      }else{
     396        if(wait_mainmetadata){
     397          addMapToMap(&my_service->metadata,current_content);
     398        }
     399      }
     400
     401      freeMap(&current_content);
     402      free(current_content);
     403      current_content=NULL;
     404    }
    401405    current_data=previous_data;
     406    wait_mainmetadata=false;
     407    wait_metadata=false;
    402408  }
    403409  if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0
    404410     || strcmp($3,"ComplexOutput")==0 || strcmp($3,"LiteralOutput")==0){
     411    if(current_element->format==NULL)
     412      current_element->format=zStrdup($3);
    405413    current_content=NULL;
    406414  }
     
    497505| EPAIR {
    498506#ifdef DEBUG_SERVICE_CONF
    499   fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
    500   fprintf(stderr,"EPAIR FOUND !! \n");
     507  fprintf(stderr,"EPAIR (%s %d)\n",__FILE__,__LINE__);
     508  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
     509  dumpMap(current_content);
     510  fflush(stderr);
     511#endif
     512  if($1!=NULL && curr_key!=NULL){
     513    if(current_content==NULL){
     514#ifdef DEBUG_SERVICE_CONF
     515      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
     516#endif
     517      current_content=createMap(curr_key,$1);
     518#ifdef DEBUG_SERVICE_CONF
     519      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
     520#endif
     521    }
     522    else{
     523#ifdef DEBUG_SERVICE_CONF
     524      dumpMap(current_content);
     525      fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1);
     526#endif
     527      addToMap(current_content,curr_key,$1);
     528#ifdef DEBUG_SERVICE_CONF
     529      fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1);
     530#endif   
     531    }
     532  }
     533#ifdef DEBUG_SERVICE_CONF
    501534  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
    502535  fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
     
    504537  fflush(stderr);
    505538#endif
    506   if($1!=NULL && curr_key!=NULL){
    507     if(current_content==NULL){
    508 #ifdef DEBUG_SERVICE_CONF
    509       fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
    510 #endif
    511       current_content=createMap(curr_key,$1);
    512 #ifdef DEBUG_SERVICE_CONF
    513       fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
    514 #endif
    515     }
    516     else{
    517 #ifdef DEBUG_SERVICE_CONF
    518       dumpMap(current_content);
    519       fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1);
    520 #endif
    521       addToMap(current_content,curr_key,$1);
    522 #ifdef DEBUG_SERVICE_CONF
    523       fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1);
    524 #endif   
    525     }
    526   }
    527 #ifdef DEBUG_SERVICE_CONF
    528   fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
    529   fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
    530   dumpMap(current_content);
    531   fflush(stderr);
    532 #endif
    533539  if(curr_key!=NULL){
    534540    free(curr_key);
     
    543549: ANID  {
    544550#ifdef DEBUG_SERVICE_CONF
    545   fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
     551  fprintf(stderr,"processid (%s %d) %s\n",__FILE__,__LINE__,$1);
    546552#endif
    547553  if(data==-1){
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r620 r621  
    12491249    if(tmp1!=NULL)
    12501250      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);
     1251    else
     1252      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST "1");
    12511253    map* tmp3=getMapFromMaps(m,"lenv","level");
    12521254    addPrefix(m,tmp3,serv);
     
    13011303    else{
    13021304      if(j>0)
    1303         xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "false");     
     1305        xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "true");
     1306      else
     1307        xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST "1");
    13041308    }
    13051309  }
     
    14521456        datatype=1;
    14531457      }
    1454      
     1458
    14551459      if(strncmp(type,"Input",5)==0){
    14561460
     
    15211525                const char* bkt;
    15221526                if ( ( bkt = strchr(pToken, '[') ) != NULL || ( bkt = strchr(pToken, ']') ) != NULL ){
    1523                     strncpy( tmpStr, pToken, bkt - pToken );
    1524                     tmpStr[bkt - pToken] = '\0';
    1525                   }
     1527                  strncpy( tmpStr, pToken, bkt - pToken );
     1528                  tmpStr[bkt - pToken] = '\0';
     1529                }
    15261530              }
    15271531              xmlAddChild(nc7,xmlNewText(BAD_CAST tmpStr));
     
    16081612       
    16091613      }
    1610    
    16111614     
    1612     int oI=0;
    1613     for(oI=0;oI<13;oI++)
    1614       if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
     1615      int oI=0;
     1616      for(oI=0;oI<13;oI++)
     1617        if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
    16151618#ifdef DEBUG
    1616         printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
    1617 #endif
    1618         if(strcmp(tmp1->name,"asReference")!=0 &&
    1619            strncasecmp(tmp1->name,"DataType",8)!=0 &&
    1620            strcasecmp(tmp1->name,"extension")!=0 &&
    1621            strcasecmp(tmp1->name,"value")!=0 &&
    1622            strcasecmp(tmp1->name,"AllowedValues")!=0 &&
    1623            strncasecmp(tmp1->name,"range",5)!=0){
    1624           if(datatype!=1){
    1625             char *tmp2=zCapitalize1(tmp1->name);
    1626             nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
    1627             free(tmp2);
    1628           }
    1629           else{
    1630             char *tmp2=zCapitalize(tmp1->name);
    1631             nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
    1632             free(tmp2);
    1633           }
    1634           xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
    1635           xmlAddChild(nc5,nc9);
    1636           if(strcasecmp(tmp1->name,"uom")==0)
    1637             hasUOM1=true;
    1638           hasUOM=true;
    1639         }else
     1619          printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
     1620#endif
     1621          if(strcmp(tmp1->name,"asReference")!=0 &&
     1622             strncasecmp(tmp1->name,"DataType",8)!=0 &&
     1623             strcasecmp(tmp1->name,"extension")!=0 &&
     1624             strcasecmp(tmp1->name,"value")!=0 &&
     1625             strcasecmp(tmp1->name,"AllowedValues")!=0 &&
     1626             strncasecmp(tmp1->name,"range",5)!=0){
     1627            if(datatype!=1){
     1628              char *tmp2=zCapitalize1(tmp1->name);
     1629              nc9 = xmlNewNode(NULL, BAD_CAST tmp2);
     1630              free(tmp2);
     1631            }
     1632            else{
     1633              char *tmp2=zCapitalize(tmp1->name);
     1634              nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);
     1635              free(tmp2);
     1636            }
     1637            xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));
     1638            xmlAddChild(nc5,nc9);
     1639            if(strcasecmp(tmp1->name,"uom")==0)
     1640              hasUOM1=true;
     1641            hasUOM=true;
     1642          }else
    16401643         
    1641           tmp1=tmp1->next;
    1642       }
     1644            tmp1=tmp1->next;
     1645        }
    16431646   
    16441647   
     
    17921795    }
    17931796   
    1794     if((tmp1=getMap(_tmp->content,"value"))!=NULL){
     1797    if(_tmp!=NULL && (tmp1=getMap(_tmp->content,"value"))!=NULL){
    17951798      nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue");
    17961799      xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value));
     
    32003203         * cf. parseBoundingBox
    32013204         */
    3202         if(strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
     3205        if(tmpInputs->format!=NULL && strcasecmp(tmpInputs->format,"BoundingBoxData")==0){
    32033206          maps* tmpI=getMaps(*out,tmpInputs->name);
    32043207          if(tmpI!=NULL){
     
    35183521    FILE* fo=fopen(fname,"w+");
    35193522    if(fo==NULL){
    3520 #ifdef DEBUG           
     3523#ifdef DEBUG
    35213524      fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno));
    35223525#endif
     
    36003603      }
    36013604      for(int i=0;i<atoi(length->value);i++){
    3602        
    36033605        char* fcontent;
    36043606        char *mimeType=NULL;
     
    36083610        char vname1[11];
    36093611        char sname[9];
     3612        char mname[15];
    36103613        char icname[14];
    36113614        char xname[16];
     
    36203623          sprintf(vname,"value_%d",i);
    36213624          sprintf(sname,"size_%d",i);
     3625          sprintf(mname,"mimeType_%d",i);
    36223626          sprintf(icname,"isCached_%d",i);
    36233627          sprintf(xname,"Reference_%d",i);
     
    36253629          sprintf(cname,"cache_file");
    36263630          sprintf(vname,"value");
     3631          sprintf(sname,"size");
     3632          sprintf(mname,"mimeType");
    36273633          sprintf(icname,"isCached");
    3628           sprintf(sname,"size");
    36293634          sprintf(xname,"Reference");
    36303635        }
    36313636
    36323637        map* tmap=getMapFromMaps(*m,"orequests",vname1);
    3633         if((tmp1=getMap(content->content,xname))!=NULL && strcasecmp(tmap->value,tmp1->value)==0 ){
     3638        if((tmp1=getMap(content->content,xname))!=NULL /*&& ((tmap!=NULL && strcasecmp(tmap->value,tmp1->value)==0) )*/){
     3639
    36343640          if(getMap(content->content,icname)==NULL){
    36353641           
     
    36483654              mimeType=strdup("none");
    36493655            else
    3650                   mimeType=strdup(hInternet->ihandle[index].mimeType);       
     3656              mimeType=strdup(hInternet->ihandle[index].mimeType);           
    36513657           
    36523658            map* tmpMap=getMapOrFill(&content->content,vname,"");
     
    36693675            }
    36703676            addToMap(content->content,sname,ltmp1);
     3677            addToMap(content->content,mname,mimeType);
    36713678            addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0);
    36723679            free(fcontent);
    36733680            free(mimeType);
    3674             dumpMaps(content);
    36753681            index++;
    36763682
     
    36883694  }
    36893695  return 0;
     3696}
     3697
     3698/**
     3699 * Add a request in the download queue
     3700 *
     3701 * @param m the maps containing the settings of the main.cfg file
     3702 * @param url the url to add to the queue
     3703 */
     3704void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){
     3705  hInternet->waitingRequests[hInternet->nb]=strdup(url);
     3706  if(req)
     3707    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
     3708  maps *oreq=getMaps(*m,"orequests");
     3709  if(oreq==NULL){
     3710    oreq=(maps*)malloc(MAPS_SIZE);
     3711    oreq->name=zStrdup("orequests");
     3712    oreq->content=createMap("value",url);
     3713    oreq->next=NULL;
     3714    addMapsToMaps(m,oreq);
     3715    freeMaps(&oreq);
     3716    free(oreq);
     3717  }else{
     3718    setMapArray(oreq->content,"value",hInternet->nb-1,url);
     3719  }
    36903720}
    36913721
     
    37343764    }
    37353765
    3736   }else{
    3737     hInternet->waitingRequests[hInternet->nb]=strdup(url);
    3738     InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
    3739     maps *oreq=getMaps(*m,"orequests");
    3740     if(oreq==NULL){
    3741       oreq=(maps*)malloc(MAPS_SIZE);
    3742       oreq->name=zStrdup("orequests");
    3743       oreq->content=createMap("value",url);
    3744       oreq->next=NULL;
    3745       addMapsToMaps(m,oreq);
    3746       freeMaps(&oreq);
    3747       free(oreq);
    3748     }else{
    3749       setMapArray(oreq->content,"value",hInternet->nb-1,url);
    3750     }
     3766  }else{   
     3767    addRequestToQueue(m,hInternet,url,true);
    37513768    return 0;
    37523769  }
     
    37753792  else{
    37763793    addToMap(*content,"isCached","true");
    3777 
    37783794    map* tmp=getMapFromMaps(*m,"main","cacheDir");
    37793795    if(tmp!=NULL){
  • trunk/zoo-project/zoo-kernel/service_internal.h

    r587 r621  
    216216  char* isInCache(maps*,char*);
    217217  int runHttpRequests(maps**,maps**,HINTERNET*);
     218  void addRequestToQueue(maps**,HINTERNET*,const char*,bool);
    218219  int loadRemoteFile(maps**,map**,HINTERNET*,char*);
    219220
  • trunk/zoo-project/zoo-kernel/ulinet.c

    r607 r621  
    238238      handle0->ihandle[i].header=NULL;
    239239    }
     240    if(handle.post!=NULL)
     241      free(handle.post);
    240242    free(handle.mimeType);
    241243    handle.mimeType = NULL;
     
    272274  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
    273275  hInternet->ihandle[hInternet->nb].pabyData = NULL;
     276  hInternet->ihandle[hInternet->nb].post = NULL;
    274277
    275278  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
     
    321324#ifdef MSG_LAF_VERBOSE
    322325    fprintf(stderr,"FROM ULINET !!");
    323     fprintf(stderr,"HEADER : %s\n",lpszHeaders);
     326    fprintf(stderr,"HEADER : [%s] %d\n",lpszHeaders,dwHeadersLength);
    324327#endif
    325328    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POST,1);
     
    328331    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_VERBOSE,1);
    329332#endif
    330     curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,lpszHeaders);
    331     curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
     333    hInternet->ihandle[hInternet->nb].post=strdup(lpszHeaders);
     334    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,hInternet->ihandle[hInternet->nb].post);
     335    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,(long)dwHeadersLength);
    332336  }
    333337  if(hInternet->ihandle[hInternet->nb].header!=NULL)
     
    338342  curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
    339343 
     344  hInternet->ihandle[hInternet->nb].header=NULL;
    340345  ++hInternet->nb;
    341   hInternet->ihandle[hInternet->nb].header=NULL;
    342346
    343347#ifdef ULINET_DEBUG
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r607 r621  
    4848#ifndef true
    4949#define true 1
    50 #define false -1
     50#define false 0
    5151#endif
    5252
     
    8181    unsigned char *pabyData; //!< the downloaded content
    8282    char *mimeType; //!< the mimeType returned by the server
     83    char *post; //!< the potential POST XML content
    8384    int hasCacheFile; //!< 1 if we used a cache file
    8485    int nDataLen; //!< the length of the downloaded content
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r607 r621  
    5454
    5555#include "service_internal.h"
    56 
    57 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
     56#include "request_parser.h"
     57
    5858int runRequest(map**);
    5959
     
    216216   * one.
    217217   */
     218
    218219  if(strncasecmp(cgiRequestMethod,"post",4)==0 ||
    219220     (count(tmpMap)==1 && strncmp(tmpMap->value,"<",1)==0)
     
    226227     */
    227228    map* t1=getMap(tmpMap,"request");
    228     if(t1!=NULL && strncasecmp(t1->value,"<",1)==0){
     229    if(t1!=NULL && strncasecmp(t1->value,"<",1)==0) {
    229230      addToMap(tmpMap,"xrequest",t1->value);
    230231      xmlInitParser();
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r620 r621  
    5454
    5555#include "service_internal.h"
     56#include "request_parser.h"
    5657
    5758#ifdef USE_PYTHON
     
    179180}
    180181
    181 /**
    182  * Create (or append to) an array valued maps value = "["",""]"
    183  *
    184  * @param m the conf maps containing the main.cfg settings
    185  * @param mo the map to update
    186  * @param mi the map to append
    187  * @param elem the elements containing default definitions
    188  * @return 0 on success, -1 on failure
    189  */
    190 int
    191 appendMapsToMaps (maps * m, maps * mo, maps * mi, elements * elem)
    192 {
    193   maps *tmpMaps = getMaps (mo, mi->name);
    194   map *tmap = getMapType (tmpMaps->content);
    195   elements *el = getElements (elem, mi->name);
    196   int hasEl = 1;
    197   if (el == NULL)
    198     hasEl = -1;
    199   if (tmap == NULL)
    200     {
    201       if (hasEl > 0)
    202         tmap = getMapType (el->defaults->content);
    203     }
    204 
    205   map *testMap = NULL;
    206   if (hasEl > 0)
    207     {
    208       testMap = getMap (el->content, "maxOccurs");
    209     }
    210   else
    211     {
    212       testMap = createMap ("maxOccurs", "unbounded");
    213     }
    214 
    215   if (testMap != NULL)
    216     {
    217       if (strncasecmp (testMap->value, "unbounded", 9) != 0
    218           && atoi (testMap->value) > 1)
    219         {
    220           addMapsArrayToMaps (&mo, mi, tmap->name);
    221           map* nb=getMapFromMaps(mo,mi->name,"length");
    222           if (nb!=NULL && atoi(nb->value)>atoi(testMap->value))
    223             {
    224               char emsg[1024];
    225               sprintf (emsg,
    226                        _("The maximum allowed occurrences for <%s> (%i) was exceeded."),
    227                        mi->name, atoi (testMap->value));
    228               errorException (m, emsg, "InternalError", NULL);
    229               return -1;
    230             }
    231         }
    232       else
    233         {
    234           if (strncasecmp (testMap->value, "unbounded", 9) == 0)
    235             {
    236               if (hasEl < 0)
    237                 {
    238                   freeMap (&testMap);
    239                   free (testMap);
    240                 }
    241               if (addMapsArrayToMaps (&mo, mi, tmap->name) < 0)
    242                 {
    243                   char emsg[1024];
    244                   map *tmpMap = getMap (mi->content, "length");
    245                   sprintf (emsg,
    246                            _
    247                            ("ZOO-Kernel was unable to load your data for %s position %s."),
    248                            mi->name, tmpMap->value);
    249                   errorException (m, emsg, "InternalError", NULL);
    250                   return -1;
    251                 }
    252             }
    253           else
    254             {
    255               char emsg[1024];
    256               sprintf (emsg,
    257                        _
    258                        ("The maximum allowed occurrences for <%s> is one."),
    259                        mi->name);
    260               errorException (m, emsg, "InternalError", NULL);
    261               return -1;
    262             }
    263         }
    264     }
    265   return 0;
    266 }
    267182
    268183/**
     
    495410  (void) closedir (dirp);
    496411  return 1;
    497 }
    498 
    499 /**
    500  * Apply XPath Expression on XML document.
    501  *
    502  * @param doc the XML Document
    503  * @param search the XPath expression
    504  * @return xmlXPathObjectPtr containing the resulting nodes set
    505  */
    506 xmlXPathObjectPtr
    507 extractFromDoc (xmlDocPtr doc, const char *search)
    508 {
    509   xmlXPathContextPtr xpathCtx;
    510   xmlXPathObjectPtr xpathObj;
    511   xpathCtx = xmlXPathNewContext (doc);
    512   xpathObj = xmlXPathEvalExpression (BAD_CAST search, xpathCtx);
    513   xmlXPathFreeContext (xpathCtx);
    514   return xpathObj;
    515412}
    516413
     
    17221619  maps *request_input_real_format = NULL;
    17231620  maps *tmpmaps = request_input_real_format;
    1724   map *postRequest = NULL;
    1725   postRequest = getMap (request_inputs, "xrequest");
    1726   if (postRequest == NULLMAP)
    1727     {
    1728     /**
    1729      * Parsing outputs provided as KVP
    1730      */
    1731       r_inputs = NULL;
    1732 #ifdef DEBUG
    1733       fprintf (stderr, "OUTPUT Parsing ... \n");
    1734 #endif
    1735       r_inputs = getMap (request_inputs, "ResponseDocument");
    1736       if (r_inputs == NULL)
    1737         r_inputs = getMap (request_inputs, "RawDataOutput");
    1738 
    1739 #ifdef DEBUG
    1740       fprintf (stderr, "OUTPUT Parsing ... \n");
    1741 #endif
    1742       if (r_inputs != NULL)
    1743         {
    1744 #ifdef DEBUG
    1745           fprintf (stderr, "OUTPUT Parsing start now ... \n");
    1746 #endif
    1747           char cursor_output[10240];
    1748           char *cotmp = zStrdup (r_inputs->value);
    1749           snprintf (cursor_output, 10240, "%s", cotmp);
    1750           free (cotmp);
    1751           j = 0;
    1752 
    1753       /**
    1754        * Put each Output into the outputs_as_text array
    1755        */
    1756           char *pToken;
    1757           maps *tmp_output = NULL;
    1758 #ifdef DEBUG
    1759           fprintf (stderr, "OUTPUT [%s]\n", cursor_output);
    1760 #endif
    1761           pToken = strtok (cursor_output, ";");
    1762           char **outputs_as_text = (char **) malloc (128 * sizeof (char *));
    1763           if (outputs_as_text == NULL)
    1764             {
    1765               return errorException (m, _("Unable to allocate memory"),
    1766                                      "InternalError", NULL);
    1767             }
    1768           i = 0;
    1769           while (pToken != NULL)
    1770             {
    1771 #ifdef DEBUG
    1772               fprintf (stderr, "***%s***\n", pToken);
    1773               fflush (stderr);
    1774               fprintf (stderr, "***%s***\n", pToken);
    1775 #endif
    1776               outputs_as_text[i] =
    1777                 (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
    1778               if (outputs_as_text[i] == NULL)
    1779                 {
    1780                   return errorException (m, _("Unable to allocate memory"),
    1781                                          "InternalError", NULL);
    1782                 }
    1783               snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
    1784                         pToken);
    1785               pToken = strtok (NULL, ";");
    1786               i++;
    1787             }
    1788           for (j = 0; j < i; j++)
    1789             {
    1790               char *tmp = zStrdup (outputs_as_text[j]);
    1791               free (outputs_as_text[j]);
    1792               char *tmpc;
    1793               tmpc = strtok (tmp, "@");
    1794               int k = 0;
    1795               while (tmpc != NULL)
    1796                 {
    1797                   if (k == 0)
    1798                     {
    1799                       if (tmp_output == NULL)
    1800                         {
    1801                           tmp_output = (maps *) malloc (MAPS_SIZE);
    1802                           if (tmp_output == NULL)
    1803                             {
    1804                               return errorException (m,
    1805                                                      _
    1806                                                      ("Unable to allocate memory."),
    1807                                                      "InternalError", NULL);
    1808                             }
    1809                           tmp_output->name = zStrdup (tmpc);
    1810                           tmp_output->content = NULL;
    1811                           tmp_output->next = NULL;
    1812                         }
    1813                     }
    1814                   else
    1815                     {
    1816                       char *tmpv = strstr (tmpc, "=");
    1817                       char tmpn[256];
    1818                       memset (tmpn, 0, 256);
    1819                       strncpy (tmpn, tmpc,
    1820                                (strlen (tmpc) -
    1821                                 strlen (tmpv)) * sizeof (char));
    1822                       tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
    1823 #ifdef DEBUG
    1824                       fprintf (stderr, "OUTPUT DEF [%s]=[%s]\n", tmpn,
    1825                                tmpv + 1);
    1826 #endif
    1827                       if (tmp_output->content == NULL)
    1828                         {
    1829                           tmp_output->content = createMap (tmpn, tmpv + 1);
    1830                           tmp_output->content->next = NULL;
    1831                         }
    1832                       else
    1833                         addToMap (tmp_output->content, tmpn, tmpv + 1);
    1834                     }
    1835                   k++;
    1836 #ifdef DEBUG
    1837                   fprintf (stderr, "***%s***\n", tmpc);
    1838 #endif
    1839                   tmpc = strtok (NULL, "@");
    1840                 }
    1841               if (request_output_real_format == NULL)
    1842                 request_output_real_format = dupMaps (&tmp_output);
    1843               else
    1844                 addMapsToMaps (&request_output_real_format, tmp_output);
    1845               freeMaps (&tmp_output);
    1846               free (tmp_output);
    1847               tmp_output = NULL;
    1848 #ifdef DEBUG
    1849               dumpMaps (tmp_output);
    1850               fflush (stderr);
    1851 #endif
    1852               free (tmp);
    1853             }
    1854           free (outputs_as_text);
    1855         }
    1856 
    1857 
    1858     /**
    1859      * Parsing inputs provided as KVP
    1860      */
    1861       r_inputs = getMap (request_inputs, "DataInputs");
    1862 #ifdef DEBUG
    1863       fprintf (stderr, "DATA INPUTS [%s]\n", r_inputs->value);
    1864 #endif
    1865       char cursor_input[40960];
    1866       if (r_inputs != NULL){
    1867         snprintf (cursor_input, 40960, "%s", r_inputs->value);
    1868         j = 0;
    1869 
    1870         /**
    1871          * Put each DataInputs into the inputs_as_text array
    1872          */
    1873         char *tmp1 = zStrdup (cursor_input);
    1874         char *pToken;
    1875         pToken = strtok (cursor_input, ";");
    1876         if (pToken != NULL && strncasecmp (pToken, tmp1, strlen (tmp1)) == 0)
    1877           {
    1878             char *tmp2 = url_decode (tmp1);
    1879             snprintf (cursor_input, (strlen (tmp2) + 1) * sizeof (char), "%s",
    1880                       tmp2);
    1881             free (tmp2);
    1882             pToken = strtok (cursor_input, ";");
    1883           }
    1884         free (tmp1);
    1885        
    1886         char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
    1887         if (inputs_as_text == NULL)
    1888           {
    1889             return errorException (m, _("Unable to allocate memory."),
    1890                                    "InternalError", NULL);
    1891           }
    1892         i = 0;
    1893         while (pToken != NULL)
    1894           {
    1895 #ifdef DEBUG
    1896             fprintf (stderr, "***%s***\n", pToken);
    1897             fflush (stderr);
    1898             fprintf (stderr, "***%s***\n", pToken);
    1899 #endif
    1900             inputs_as_text[i] =
    1901               (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
    1902             if (inputs_as_text[i] == NULL)
    1903               {
    1904                 return errorException (m, _("Unable to allocate memory."),
    1905                                        "InternalError", NULL);
    1906               }
    1907             snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
    1908             pToken = strtok (NULL, ";");
    1909             i++;
    1910           }
    1911        
    1912         for (j = 0; j < i; j++)
    1913           {
    1914             char *tmp = zStrdup (inputs_as_text[j]);
    1915             free (inputs_as_text[j]);
    1916             char *tmpc;
    1917             tmpc = strtok (tmp, "@");
    1918             while (tmpc != NULL)
    1919               {
    1920 #ifdef DEBUG
    1921                 fprintf (stderr, "***\n***%s***\n", tmpc);
    1922 #endif
    1923                 char *tmpv = strstr (tmpc, "=");
    1924                 char tmpn[256];
    1925                 memset (tmpn, 0, 256);
    1926                 if (tmpv != NULL)
    1927                   {
    1928                     strncpy (tmpn, tmpc,
    1929                              (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
    1930                     tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
    1931                   }
    1932                 else
    1933                   {
    1934                     strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
    1935                     tmpn[strlen (tmpc)] = 0;
    1936                   }
    1937 #ifdef DEBUG
    1938                 fprintf (stderr, "***\n*** %s = %s ***\n", tmpn, tmpv + 1);
    1939 #endif
    1940                 if (tmpmaps == NULL)
    1941                   {
    1942                     tmpmaps = (maps *) malloc (MAPS_SIZE);
    1943                     if (tmpmaps == NULL)
    1944                       {
    1945                         return errorException (m,
    1946                                                _("Unable to allocate memory."),
    1947                                                "InternalError", NULL);
    1948                       }
    1949                     tmpmaps->name = zStrdup (tmpn);
    1950                     if (tmpv != NULL)
    1951                       {
    1952                         char *tmpvf = url_decode (tmpv + 1);
    1953                         tmpmaps->content = createMap ("value", tmpvf);
    1954                         free (tmpvf);
    1955                       }
    1956                     else
    1957                       tmpmaps->content = createMap ("value", "Reference");
    1958                     tmpmaps->next = NULL;
    1959                   }
    1960                 tmpc = strtok (NULL, "@");
    1961                 while (tmpc != NULL)
    1962                   {
    1963 #ifdef DEBUG
    1964                     fprintf (stderr, "*** KVP NON URL-ENCODED \n***%s***\n",
    1965                              tmpc);
    1966 #endif
    1967                     char *tmpv1 = strstr (tmpc, "=");
    1968 #ifdef DEBUG
    1969                     fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
    1970                              tmpv1 + 1);
    1971 #endif
    1972                     char tmpn1[1024];
    1973                     memset (tmpn1, 0, 1024);
    1974                     if (tmpv1 != NULL)
    1975                       {
    1976                         strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
    1977                         tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
    1978                         addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
    1979                       }
    1980                     else
    1981                       {
    1982                         strncpy (tmpn1, tmpc, strlen (tmpc));
    1983                         tmpn1[strlen (tmpc)] = 0;
    1984                         map *lmap = getLastMap (tmpmaps->content);
    1985                         char *tmpValue =
    1986                           (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
    1987                                            sizeof (char));
    1988                         sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
    1989                         free (lmap->value);
    1990                         lmap->value = zStrdup (tmpValue);
    1991                         free (tmpValue);
    1992                         tmpc = strtok (NULL, "@");
    1993                         continue;
    1994                       }
    1995 #ifdef DEBUG
    1996                     fprintf (stderr, "*** NAME NON URL-ENCODED \n***%s***\n",
    1997                              tmpn1);
    1998                     fprintf (stderr, "*** VALUE NON URL-ENCODED \n***%s***\n",
    1999                              tmpv1 + 1);
    2000 #endif
    2001                     if (strcmp (tmpn1, "xlink:href") != 0)
    2002                       addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
    2003                     else if (tmpv1 != NULL)
    2004                       {
    2005                         char *tmpx2 = url_decode (tmpv1 + 1);
    2006                         if (strncasecmp (tmpx2, "http://", 7) != 0 &&
    2007                             strncasecmp (tmpx2, "ftp://", 6) != 0 &&
    2008                             strncasecmp (tmpx2, "https://", 8) != 0)
    2009                           {
    2010                             char emsg[1024];
    2011                             sprintf (emsg,
    2012                                      _
    2013                                      ("Unable to find a valid protocol to download the remote file %s"),
    2014                                      tmpv1 + 1);
    2015                             errorException (m, emsg, "InternalError", NULL);
    2016                             freeMaps (&m);
    2017                             free (m);
    2018                             free (REQUEST);
    2019                             free (SERVICE_URL);
    2020                             InternetCloseHandle (&hInternet);
    2021                             freeService (&s1);
    2022                             free (s1);
    2023                             return 0;
    2024                           }
    2025 #ifdef DEBUG
    2026                         fprintf (stderr,
    2027                                  "REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",
    2028                                  tmpv1 + 1);
    2029 #endif
    2030                         addToMap (tmpmaps->content, tmpn1, tmpx2);
    2031 #ifndef WIN32
    2032                         if (CHECK_INET_HANDLE (hInternet))
    2033 #endif
    2034                           {
    2035                             if (loadRemoteFile
    2036                                 (&m, &tmpmaps->content, &hInternet, tmpx2) < 0)
    2037                               {
    2038                                 freeMaps (&m);
    2039                                 free (m);
    2040                                 free (REQUEST);
    2041                                 free (SERVICE_URL);
    2042                                 InternetCloseHandle (&hInternet);
    2043                                 freeService (&s1);
    2044                                 free (s1);
    2045                                 return 0;
    2046                               }
    2047                           }
    2048                         free (tmpx2);
    2049                         addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
    2050                       }
    2051                     tmpc = strtok (NULL, "@");
    2052                   }
    2053 #ifdef DEBUG
    2054                 dumpMaps (tmpmaps);
    2055                 fflush (stderr);
    2056 #endif
    2057                 if (request_input_real_format == NULL)
    2058                   request_input_real_format = dupMaps (&tmpmaps);
    2059                 else
    2060                   {
    2061                     maps *testPresence =
    2062                       getMaps (request_input_real_format, tmpmaps->name);
    2063                     if (testPresence != NULL)
    2064                       {
    2065                         elements *elem =
    2066                           getElements (s1->inputs, tmpmaps->name);
    2067                         if (elem != NULL)
    2068                           {
    2069                             if (appendMapsToMaps
    2070                                 (m, request_input_real_format, tmpmaps,
    2071                                  elem) < 0)
    2072                               {
    2073                                 freeMaps (&m);
    2074                                 free (m);
    2075                                 free (REQUEST);
    2076                                 free (SERVICE_URL);
    2077                                 InternetCloseHandle (&hInternet);
    2078                                 freeService (&s1);
    2079                                 free (s1);
    2080                                 return 0;
    2081                               }
    2082                           }
    2083                       }
    2084                     else
    2085                       addMapsToMaps (&request_input_real_format, tmpmaps);
    2086                   }
    2087                 freeMaps (&tmpmaps);
    2088                 free (tmpmaps);
    2089                 tmpmaps = NULL;
    2090                 free (tmp);
    2091               }
    2092           }
    2093         free (inputs_as_text);
    2094       }
    2095     }
    2096   else
    2097     {
    2098     /**
    2099      * Parse XML request
    2100      */
    2101       xmlInitParser ();
    2102 #ifdef DEBUG
    2103       fflush (stderr);
    2104       fprintf (stderr, "BEFORE %s\n", postRequest->value);
    2105       fflush (stderr);
    2106 #endif
    2107       xmlDocPtr doc = xmlParseMemory (postRequest->value, cgiContentLength);
    2108 #ifdef DEBUG
    2109       fprintf (stderr, "AFTER\n");
    2110       fflush (stderr);
    2111 #endif
    2112 
    2113     /**
    2114      * Parse every Input in DataInputs node.
    2115      */
    2116       xmlXPathObjectPtr tmpsptr =
    2117         extractFromDoc (doc, "/*/*/*[local-name()='Input']");
    2118       xmlNodeSet *tmps = tmpsptr->nodesetval;
    2119 #ifdef DEBUG
    2120       fprintf (stderr, "*****%d*****\n", tmps->nodeNr);
    2121 #endif
    2122       for (int k = 0; k < tmps->nodeNr; k++)
    2123         {
    2124           maps *tmpmaps = NULL;
    2125           xmlNodePtr cur = tmps->nodeTab[k];
    2126           if (tmps->nodeTab[k]->type == XML_ELEMENT_NODE)
    2127             {
    2128         /**
    2129          * A specific Input node.
    2130          */
    2131 #ifdef DEBUG
    2132               fprintf (stderr, "= element 0 node \"%s\"\n", cur->name);
    2133 #endif
    2134               xmlNodePtr cur2 = cur->children;
    2135               while (cur2 != NULL)
    2136                 {
    2137                   while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
    2138                     cur2 = cur2->next;
    2139                   if (cur2 == NULL)
    2140                     break;
    2141           /**
    2142            * Indentifier
    2143            */
    2144                   if (xmlStrncasecmp
    2145                       (cur2->name, BAD_CAST "Identifier",
    2146                        xmlStrlen (cur2->name)) == 0)
    2147                     {
    2148                       xmlChar *val =
    2149                         xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
    2150                       if (tmpmaps == NULL)
    2151                         {
    2152                           tmpmaps = (maps *) malloc (MAPS_SIZE);
    2153                           if (tmpmaps == NULL)
    2154                             {
    2155                               return errorException (m,
    2156                                                      _
    2157                                                      ("Unable to allocate memory."),
    2158                                                      "InternalError", NULL);
    2159                             }
    2160                           tmpmaps->name = zStrdup ((char *) val);
    2161                           tmpmaps->content = NULL;
    2162                           tmpmaps->next = NULL;
    2163                         }
    2164                       xmlFree (val);
    2165                     }
    2166           /**
    2167            * Title, Asbtract
    2168            */
    2169                   if (xmlStrncasecmp
    2170                       (cur2->name, BAD_CAST "Title",
    2171                        xmlStrlen (cur2->name)) == 0
    2172                       || xmlStrncasecmp (cur2->name, BAD_CAST "Abstract",
    2173                                          xmlStrlen (cur2->name)) == 0)
    2174                     {
    2175                       xmlChar *val =
    2176                         xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
    2177                       if (tmpmaps == NULL)
    2178                         {
    2179                           tmpmaps = (maps *) malloc (MAPS_SIZE);
    2180                           if (tmpmaps == NULL)
    2181                             {
    2182                               return errorException (m,
    2183                                                      _
    2184                                                      ("Unable to allocate memory."),
    2185                                                      "InternalError", NULL);
    2186                             }
    2187                           tmpmaps->name = zStrdup ("missingIndetifier");
    2188                           tmpmaps->content =
    2189                             createMap ((char *) cur2->name, (char *) val);
    2190                           tmpmaps->next = NULL;
    2191                         }
    2192                       else
    2193                         {
    2194                           if (tmpmaps->content != NULL)
    2195                             addToMap (tmpmaps->content,
    2196                                       (char *) cur2->name, (char *) val);
    2197                           else
    2198                             tmpmaps->content =
    2199                               createMap ((char *) cur2->name, (char *) val);
    2200                         }
    2201 #ifdef DEBUG
    2202                       dumpMaps (tmpmaps);
    2203 #endif
    2204                       xmlFree (val);
    2205                     }
    2206           /**
    2207            * InputDataFormChoice (Reference or Data ?)
    2208            */
    2209                   if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
    2210                     {
    2211             /**
    2212              * Get every attribute from a Reference node
    2213              * mimeType, encoding, schema, href, method
    2214              * Header and Body gesture should be added here
    2215              */
    2216 #ifdef DEBUG
    2217                       fprintf (stderr, "REFERENCE\n");
    2218 #endif
    2219                       const char *refs[5] =
    2220                         { "mimeType", "encoding", "schema", "method",
    2221                         "href"
    2222                       };
    2223                       for (int l = 0; l < 5; l++)
    2224                         {
    2225 #ifdef DEBUG
    2226                           fprintf (stderr, "*** %s ***", refs[l]);
    2227 #endif
    2228                           xmlChar *val = xmlGetProp (cur2, BAD_CAST refs[l]);
    2229                           if (val != NULL && xmlStrlen (val) > 0)
    2230                             {
    2231                               if (tmpmaps->content != NULL)
    2232                                 addToMap (tmpmaps->content, refs[l],
    2233                                           (char *) val);
    2234                               else
    2235                                 tmpmaps->content =
    2236                                   createMap (refs[l], (char *) val);
    2237                               map *ltmp = getMap (tmpmaps->content, "method");
    2238                               if (l == 4)
    2239                                 {
    2240                                   if (!
    2241                                       (ltmp != NULL
    2242                                        && strncmp (ltmp->value, "POST",
    2243                                                    4) == 0)
    2244                                       && CHECK_INET_HANDLE (hInternet))
    2245                                     {
    2246                                       if (loadRemoteFile
    2247                                           (&m, &tmpmaps->content, &hInternet,
    2248                                            (char *) val) != 0)
    2249                                         {
    2250                                           freeMaps (&m);
    2251                                           free (m);
    2252                                           free (REQUEST);
    2253                                           free (SERVICE_URL);
    2254                                           InternetCloseHandle (&hInternet);
    2255                                           freeService (&s1);
    2256                                           free (s1);
    2257                                           return 0;
    2258                                         }
    2259                                     }
    2260                                 }
    2261                             }
    2262 #ifdef DEBUG
    2263                           fprintf (stderr, "%s\n", val);
    2264 #endif
    2265                           xmlFree (val);
    2266                         }
    2267 #ifdef POST_DEBUG
    2268                       fprintf (stderr,
    2269                                "Parse Header and Body from Reference \n");
    2270 #endif
    2271                       xmlNodePtr cur3 = cur2->children;
    2272                       /*      HINTERNET hInternetP;
    2273                          hInternetP=InternetOpen(
    2274                          #ifndef WIN32
    2275                          (LPCTSTR)
    2276                          #endif
    2277                          "ZooWPSClient\0",
    2278                          INTERNET_OPEN_TYPE_PRECONFIG,
    2279                          NULL,NULL, 0); */
    2280                       //hInternet.ihandle[hInternet.nb].header=NULL;
    2281                       while (cur3 != NULL)
    2282                         {
    2283                           while (cur3 != NULL
    2284                                  && cur3->type != XML_ELEMENT_NODE)
    2285                             cur3 = cur3->next;
    2286                           if (cur3 == NULL)
    2287                             break;
    2288                           if (xmlStrcasecmp (cur3->name, BAD_CAST "Header") ==
    2289                               0)
    2290                             {
    2291                               const char *ha[2];
    2292                               ha[0] = "key";
    2293                               ha[1] = "value";
    2294                               int hai;
    2295                               char *has;
    2296                               char *key;
    2297                               for (hai = 0; hai < 2; hai++)
    2298                                 {
    2299                                   xmlChar *val =
    2300                                     xmlGetProp (cur3, BAD_CAST ha[hai]);
    2301 #ifdef POST_DEBUG
    2302                                   fprintf (stderr, "%s = %s\n", ha[hai],
    2303                                            (char *) val);
    2304 #endif
    2305                                   if (hai == 0)
    2306                                     {
    2307                                       key = zStrdup ((char *) val);
    2308                                     }
    2309                                   else
    2310                                     {
    2311                                       has =
    2312                                         (char *)
    2313                                         malloc ((4 + xmlStrlen (val) +
    2314                                                  strlen (key)) *
    2315                                                 sizeof (char));
    2316                                       if (has == NULL)
    2317                                         {
    2318                                           return errorException (m,
    2319                                                                  _
    2320                                                                  ("Unable to allocate memory."),
    2321                                                                  "InternalError",
    2322                                                                  NULL);
    2323                                         }
    2324                                       snprintf (has,
    2325                                                 (3 + xmlStrlen (val) +
    2326                                                  strlen (key)), "%s: %s", key,
    2327                                                 (char *) val);
    2328                                       free (key);
    2329 #ifdef POST_DEBUG
    2330                                       fprintf (stderr, "%s\n", has);
    2331 #endif
    2332                                     }
    2333                                   xmlFree (val);
    2334                                 }
    2335                               hInternet.ihandle[hInternet.nb].header =
    2336                                 curl_slist_append (hInternet.ihandle
    2337                                                    [hInternet.nb].header,
    2338                                                    has);
    2339                               if (has != NULL)
    2340                                 free (has);
    2341                             }
    2342                           else
    2343                             {
    2344 #ifdef POST_DEBUG
    2345                               fprintf (stderr,
    2346                                        "Try to fetch the body part of the request ...\n");
    2347 #endif
    2348                               if (xmlStrcasecmp (cur3->name, BAD_CAST "Body")
    2349                                   == 0)
    2350                                 {
    2351 #ifdef POST_DEBUG
    2352                                   fprintf (stderr, "Body part found !!!\n",
    2353                                            (char *) cur3->content);
    2354 #endif
    2355                                   char *tmp =
    2356                                     (char *) malloc (cgiContentLength +
    2357                                                      1 * sizeof (char));
    2358                                   memset (tmp, 0, cgiContentLength);
    2359                                   xmlNodePtr cur4 = cur3->children;
    2360                                   while (cur4 != NULL)
    2361                                     {
    2362                                       while (cur4->type != XML_ELEMENT_NODE)
    2363                                         cur4 = cur4->next;
    2364                                       xmlDocPtr bdoc =
    2365                                         xmlNewDoc (BAD_CAST "1.0");
    2366                                       bdoc->encoding =
    2367                                         xmlCharStrdup ("UTF-8");
    2368                                       xmlDocSetRootElement (bdoc, cur4);
    2369                                       xmlChar *btmps;
    2370                                       int bsize;
    2371                                       xmlDocDumpMemory (bdoc, &btmps, &bsize);
    2372 #ifdef POST_DEBUG
    2373                                       fprintf (stderr,
    2374                                                "Body part found !!! %s %s\n",
    2375                                                tmp, (char *) btmps);
    2376 #endif
    2377                                       if (btmps != NULL)
    2378                                         sprintf (tmp, "%s", (char *) btmps);
    2379                                       xmlFree (btmps);
    2380                                       cur4 = cur4->next;
    2381                                       xmlFreeDoc (bdoc);
    2382                                     }
    2383                                   map *btmp =
    2384                                     getMap (tmpmaps->content, "href");
    2385                                   if (btmp != NULL)
    2386                                     {
    2387 #ifdef POST_DEBUG
    2388                                       fprintf (stderr, "%s %s\n", btmp->value,
    2389                                                tmp);
    2390                                       curl_easy_setopt (hInternet.handle,
    2391                                                         CURLOPT_VERBOSE, 1);
    2392 #endif
    2393                                       hInternet.
    2394                                         waitingRequests[hInternet.nb] =
    2395                                         strdup (tmp);
    2396                                       InternetOpenUrl (&hInternet,
    2397                                                        btmp->value,
    2398                                                        hInternet.waitingRequests
    2399                                                        [hInternet.nb],
    2400                                                        strlen
    2401                                                        (hInternet.waitingRequests
    2402                                                         [hInternet.nb]),
    2403                                                        INTERNET_FLAG_NO_CACHE_WRITE,
    2404                                                        0);
    2405                                     }
    2406                                   free (tmp);
    2407                                 }
    2408                               else
    2409                                 if (xmlStrcasecmp
    2410                                     (cur3->name,
    2411                                      BAD_CAST "BodyReference") == 0)
    2412                                 {
    2413                                   xmlChar *val =
    2414                                     xmlGetProp (cur3, BAD_CAST "href");
    2415                                   HINTERNET bInternet, res1;
    2416                                   bInternet = InternetOpen (
    2417 #ifndef WIN32
    2418                                                              (LPCTSTR)
    2419 #endif
    2420                                                              "ZooWPSClient\0",
    2421                                                              INTERNET_OPEN_TYPE_PRECONFIG,
    2422                                                              NULL, NULL, 0);
    2423                                   if (!CHECK_INET_HANDLE (hInternet))
    2424                                     fprintf (stderr,
    2425                                              "WARNING : hInternet handle failed to initialize");
    2426 #ifdef POST_DEBUG
    2427                                   curl_easy_setopt (bInternet.handle,
    2428                                                     CURLOPT_VERBOSE, 1);
    2429 #endif
    2430                                   bInternet.waitingRequests[0] =
    2431                                     strdup ((char *) val);
    2432                                   res1 =
    2433                                     InternetOpenUrl (&bInternet,
    2434                                                      bInternet.waitingRequests
    2435                                                      [0], NULL, 0,
    2436                                                      INTERNET_FLAG_NO_CACHE_WRITE,
    2437                                                      0);
    2438                                   processDownloads (&bInternet);
    2439                                   char *tmp =
    2440                                     (char *)
    2441                                     malloc ((bInternet.ihandle[0].nDataLen +
    2442                                              1) * sizeof (char));
    2443                                   if (tmp == NULL)
    2444                                     {
    2445                                       return errorException (m,
    2446                                                              _
    2447                                                              ("Unable to allocate memory."),
    2448                                                              "InternalError",
    2449                                                              NULL);
    2450                                     }
    2451                                   size_t bRead;
    2452                                   InternetReadFile (bInternet.ihandle[0],
    2453                                                     (LPVOID) tmp,
    2454                                                     bInternet.
    2455                                                     ihandle[0].nDataLen,
    2456                                                     &bRead);
    2457                                   tmp[bInternet.ihandle[0].nDataLen] = 0;
    2458                                   InternetCloseHandle (&bInternet);
    2459                                   map *btmp =
    2460                                     getMap (tmpmaps->content, "href");
    2461                                   if (btmp != NULL)
    2462                                     {
    2463 #ifdef POST_DEBUG
    2464                                       fprintf (stderr, "%s %s\n", btmp->value,
    2465                                                tmp);
    2466 #endif
    2467                                       hInternet.
    2468                                         waitingRequests[hInternet.nb] =
    2469                                         strdup (tmp);
    2470                                       res =
    2471                                         InternetOpenUrl (&hInternet,
    2472                                                          btmp->value,
    2473                                                          hInternet.waitingRequests
    2474                                                          [hInternet.nb],
    2475                                                          strlen
    2476                                                          (hInternet.waitingRequests
    2477                                                           [hInternet.nb]),
    2478                                                          INTERNET_FLAG_NO_CACHE_WRITE,
    2479                                                          0);
    2480                                     }
    2481                                   free (tmp);
    2482                                 }
    2483                             }
    2484                           cur3 = cur3->next;
    2485                         }
    2486 #ifdef POST_DEBUG
    2487                       fprintf (stderr,
    2488                                "Header and Body was parsed from Reference \n");
    2489 #endif
    2490 #ifdef DEBUG
    2491                       dumpMap (tmpmaps->content);
    2492                       fprintf (stderr, "= element 2 node \"%s\" = (%s)\n",
    2493                                cur2->name, cur2->content);
    2494 #endif
    2495                     }
    2496                   else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0)
    2497                     {
    2498 #ifdef DEBUG
    2499                       fprintf (stderr, "DATA\n");
    2500 #endif
    2501                       xmlNodePtr cur4 = cur2->children;
    2502                       while (cur4 != NULL)
    2503                         {
    2504                           while (cur4 != NULL
    2505                                  && cur4->type != XML_ELEMENT_NODE)
    2506                             cur4 = cur4->next;
    2507                           if (cur4 == NULL)
    2508                             break;
    2509                           if (xmlStrcasecmp
    2510                               (cur4->name, BAD_CAST "LiteralData") == 0)
    2511                             {
    2512                 /**
    2513                  * Get every attribute from a LiteralData node
    2514                  * dataType , uom
    2515                  */
    2516                               char *list[2];
    2517                               list[0] = zStrdup ("dataType");
    2518                               list[1] = zStrdup ("uom");
    2519                               for (int l = 0; l < 2; l++)
    2520                                 {
    2521 #ifdef DEBUG
    2522                                   fprintf (stderr, "*** LiteralData %s ***",
    2523                                            list[l]);
    2524 #endif
    2525                                   xmlChar *val =
    2526                                     xmlGetProp (cur4, BAD_CAST list[l]);
    2527                                   if (val != NULL
    2528                                       && strlen ((char *) val) > 0)
    2529                                     {
    2530                                       if (tmpmaps->content != NULL)
    2531                                         addToMap (tmpmaps->content, list[l],
    2532                                                   (char *) val);
    2533                                       else
    2534                                         tmpmaps->content =
    2535                                           createMap (list[l], (char *) val);
    2536 #ifdef DEBUG
    2537                                       fprintf (stderr, "%s\n", val);
    2538 #endif
    2539                                     }
    2540                                   xmlFree (val);
    2541                                   free (list[l]);
    2542                                 }
    2543                             }
    2544                           else
    2545                             if (xmlStrcasecmp
    2546                                 (cur4->name, BAD_CAST "ComplexData") == 0)
    2547                             {
    2548                 /**
    2549                  * Get every attribute from a Reference node
    2550                  * mimeType, encoding, schema
    2551                  */
    2552                               const char *coms[3] =
    2553                                 { "mimeType", "encoding", "schema" };
    2554                               for (int l = 0; l < 3; l++)
    2555                                 {
    2556 #ifdef DEBUG
    2557                                   fprintf (stderr, "*** ComplexData %s ***\n",
    2558                                            coms[l]);
    2559 #endif
    2560                                   xmlChar *val =
    2561                                     xmlGetProp (cur4, BAD_CAST coms[l]);
    2562                                   if (val != NULL
    2563                                       && strlen ((char *) val) > 0)
    2564                                     {
    2565                                       if (tmpmaps->content != NULL)
    2566                                         addToMap (tmpmaps->content, coms[l],
    2567                                                   (char *) val);
    2568                                       else
    2569                                         tmpmaps->content =
    2570                                           createMap (coms[l], (char *) val);
    2571 #ifdef DEBUG
    2572                                       fprintf (stderr, "%s\n", val);
    2573 #endif
    2574                                     }
    2575                                   xmlFree (val);
    2576                                 }
    2577                             }
    2578 
    2579                           map *test = getMap (tmpmaps->content, "encoding");
    2580 
    2581                           if (test == NULL)
    2582                             {
    2583                               if (tmpmaps->content != NULL)
    2584                                 addToMap (tmpmaps->content, "encoding",
    2585                                           "utf-8");
    2586                               else
    2587                                 tmpmaps->content =
    2588                                   createMap ("encoding", "utf-8");
    2589                               test = getMap (tmpmaps->content, "encoding");
    2590                             }
    2591 
    2592                           if (strcasecmp (test->value, "base64") != 0)
    2593                             {
    2594                               xmlChar *mv = xmlNodeListGetString (doc,
    2595                                                                   cur4->
    2596                                                                   xmlChildrenNode,
    2597                                                                   1);
    2598                               map *ltmp =
    2599                                 getMap (tmpmaps->content, "mimeType");
    2600                               if (mv == NULL
    2601                                   ||
    2602                                   (xmlStrcasecmp
    2603                                    (cur4->name, BAD_CAST "ComplexData") == 0
    2604                                    && (ltmp == NULL
    2605                                        || strncasecmp (ltmp->value,
    2606                                                        "text/xml", 8) == 0)))
    2607                                 {
    2608                                   xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
    2609                                   int buffersize;
    2610                                   xmlNodePtr cur5 = cur4->children;
    2611                                   while (cur5 != NULL
    2612                                          && cur5->type != XML_ELEMENT_NODE
    2613                                          && cur5->type !=
    2614                                          XML_CDATA_SECTION_NODE)
    2615                                     cur5 = cur5->next;
    2616                                   if (cur5 != NULL
    2617                                       && cur5->type != XML_CDATA_SECTION_NODE)
    2618                                     {
    2619                                       xmlDocSetRootElement (doc1, cur5);
    2620                                       xmlDocDumpFormatMemoryEnc (doc1, &mv,
    2621                                                                  &buffersize,
    2622                                                                  "utf-8", 1);
    2623                                       char size[1024];
    2624                                       sprintf (size, "%d", buffersize);
    2625                                       addToMap (tmpmaps->content, "size",
    2626                                                 size);
    2627                                       xmlFreeDoc (doc1);
    2628                                     }
    2629                                   else
    2630                                     {
    2631                                       if (cur5 != NULL
    2632                                           && cur5->type == XML_CDATA_SECTION_NODE){
    2633                                         xmlDocPtr doc2 = xmlParseMemory((const char*)cur5->content,xmlStrlen(cur5->content));
    2634                                         xmlDocSetRootElement (doc1,xmlDocGetRootElement(doc2));
    2635                                         xmlDocDumpFormatMemoryEnc (doc1, &mv,
    2636                                                                    &buffersize,
    2637                                                                    "utf-8", 1);
    2638                                         char size[1024];
    2639                                         sprintf (size, "%d", buffersize);
    2640                                         addToMap (tmpmaps->content, "size",
    2641                                                   size);
    2642                                         xmlFreeDoc (doc2);
    2643                                         xmlFreeDoc (doc1);
    2644                                       }
    2645                                     }
    2646                                 }else{
    2647                                 xmlNodePtr cur5 = cur4->children;
    2648                                 while (cur5 != NULL
    2649                                        && cur5->type != XML_CDATA_SECTION_NODE)
    2650                                   cur5 = cur5->next;
    2651                                 if (cur5 != NULL
    2652                                     && cur5->type == XML_CDATA_SECTION_NODE){
    2653                                   xmlFree(mv);
    2654                                   mv=xmlStrdup(cur5->content);
    2655                                 }
    2656                               }
    2657                               if (mv != NULL)
    2658                                 {
    2659                                   addToMap (tmpmaps->content, "value",
    2660                                             (char *) mv);
    2661                                   xmlFree (mv);
    2662                                 }
    2663                             }
    2664                           else
    2665                             {
    2666                               xmlChar *tmp = xmlNodeListGetRawString (doc,
    2667                                                                       cur4->xmlChildrenNode,
    2668                                                                       0);
    2669                               addToMap (tmpmaps->content, "value",
    2670                                         (char *) tmp);
    2671                               map *tmpv = getMap (tmpmaps->content, "value");
    2672                               char *res = NULL;
    2673                               char *curs = tmpv->value;
    2674                               for (int i = 0; i <= strlen (tmpv->value) / 64;
    2675                                    i++)
    2676                                 {
    2677                                   if (res == NULL)
    2678                                     res =
    2679                                       (char *) malloc (67 * sizeof (char));
    2680                                   else
    2681                                     res =
    2682                                       (char *) realloc (res,
    2683                                                         (((i + 1) * 65) +
    2684                                                          i) * sizeof (char));
    2685                                   int csize = i * 65;
    2686                                   strncpy (res + csize, curs, 64);
    2687                                   if (i == xmlStrlen (tmp) / 64)
    2688                                     strcat (res, "\n\0");
    2689                                   else
    2690                                     {
    2691                                       strncpy (res + (((i + 1) * 64) + i),
    2692                                                "\n\0", 2);
    2693                                       curs += 64;
    2694                                     }
    2695                                 }
    2696                               free (tmpv->value);
    2697                               tmpv->value = zStrdup (res);
    2698                               free (res);
    2699                               xmlFree (tmp);
    2700                             }
    2701                           cur4 = cur4->next;
    2702                         }
    2703                     }
    2704 #ifdef DEBUG
    2705                   fprintf (stderr, "cur2 next \n");
    2706                   fflush (stderr);
    2707 #endif
    2708                   cur2 = cur2->next;
    2709                 }
    2710 #ifdef DEBUG
    2711               fprintf (stderr, "ADD MAPS TO REQUEST MAPS !\n");
    2712               fflush (stderr);
    2713 #endif
    2714 
    2715               {
    2716                 maps *testPresence =
    2717                   getMaps (request_input_real_format, tmpmaps->name);
    2718                 if (testPresence != NULL)
    2719                   {
    2720                     elements *elem = getElements (s1->inputs, tmpmaps->name);
    2721                     if (elem != NULL)
    2722                       {
    2723                         if (appendMapsToMaps
    2724                             (m, request_input_real_format, tmpmaps, elem) < 0)
    2725                           {
    2726                             freeMaps (&m);
    2727                             free (m);
    2728                             free (REQUEST);
    2729                             free (SERVICE_URL);
    2730                             InternetCloseHandle (&hInternet);
    2731                             freeService (&s1);
    2732                             free (s1);
    2733                             return 0;
    2734                           }
    2735                       }
    2736                   }
    2737                 else
    2738                   addMapsToMaps (&request_input_real_format, tmpmaps);
    2739               }
    2740 
    2741 #ifdef DEBUG
    2742               fprintf (stderr, "******TMPMAPS*****\n");
    2743               dumpMaps (tmpmaps);
    2744               fprintf (stderr, "******REQUESTMAPS*****\n");
    2745               dumpMaps (request_input_real_format);
    2746 #endif
    2747               freeMaps (&tmpmaps);
    2748               free (tmpmaps);
    2749               tmpmaps = NULL;
    2750             }
    2751 #ifdef DEBUG
    2752           dumpMaps (tmpmaps);
    2753 #endif
    2754         }
    2755 #ifdef DEBUG
    2756       fprintf (stderr, "Search for response document node\n");
    2757 #endif
    2758       xmlXPathFreeObject (tmpsptr);
    2759 
    2760       tmpsptr =
    2761         extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']");
    2762       bool asRaw = false;
    2763       tmps = tmpsptr->nodesetval;
    2764       if (tmps->nodeNr == 0)
    2765         {
    2766           xmlXPathFreeObject (tmpsptr);
    2767           tmpsptr =
    2768             extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']");
    2769           tmps = tmpsptr->nodesetval;
    2770           asRaw = true;
    2771         }
    2772 #ifdef DEBUG
    2773       fprintf (stderr, "*****%d*****\n", tmps->nodeNr);
    2774 #endif
    2775       if (asRaw == true)
    2776         {
    2777           addToMap (request_inputs, "RawDataOutput", "");
    2778           xmlNodePtr cur0 = tmps->nodeTab[0];
    2779           if (cur0->type == XML_ELEMENT_NODE)
    2780             {
    2781 
    2782               maps *tmpmaps = (maps *) malloc (MAPS_SIZE);
    2783               if (tmpmaps == NULL)
    2784                 {
    2785                   return errorException (m, _("Unable to allocate memory."),
    2786                                          "InternalError", NULL);
    2787                 }
    2788               tmpmaps->name = zStrdup ("unknownIdentifier");
    2789               tmpmaps->content = NULL;
    2790               tmpmaps->next = NULL;
    2791 
    2792         /**
    2793          * Get every attribute from a RawDataOutput node
    2794          * mimeType, encoding, schema, uom
    2795          */
    2796               const char *outs[4] =
    2797                 { "mimeType", "encoding", "schema", "uom" };
    2798               for (int l = 0; l < 4; l++)
    2799                 {
    2800 #ifdef DEBUG
    2801                   fprintf (stderr, "*** %s ***\t", outs[l]);
    2802 #endif
    2803                   xmlChar *val = xmlGetProp (cur0, BAD_CAST outs[l]);
    2804                   if (val != NULL)
    2805                     {
    2806                       if (strlen ((char *) val) > 0)
    2807                         {
    2808                           if (tmpmaps->content != NULL)
    2809                             addToMap (tmpmaps->content, outs[l],
    2810                                       (char *) val);
    2811                           else
    2812                             tmpmaps->content =
    2813                               createMap (outs[l], (char *) val);
    2814                         }
    2815                       xmlFree (val);
    2816                     }
    2817                 }
    2818               xmlNodePtr cur2 = cur0->children;
    2819               while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
    2820                 cur2 = cur2->next;
    2821               while (cur2 != NULL)
    2822                 {
    2823                   if (xmlStrncasecmp
    2824                       (cur2->name, BAD_CAST "Identifier",
    2825                        xmlStrlen (cur2->name)) == 0)
    2826                     {
    2827                       xmlChar *val =
    2828                         xmlNodeListGetString (NULL, cur2->xmlChildrenNode, 1);
    2829                       free (tmpmaps->name);
    2830                       tmpmaps->name = zStrdup ((char *) val);
    2831                       xmlFree (val);
    2832                     }
    2833                   cur2 = cur2->next;
    2834                   while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
    2835                     cur2 = cur2->next;
    2836                 }
    2837               if (request_output_real_format == NULL)
    2838                 request_output_real_format = dupMaps (&tmpmaps);
    2839               else
    2840                 addMapsToMaps (&request_output_real_format, tmpmaps);
    2841               if (tmpmaps != NULL)
    2842                 {
    2843                   freeMaps (&tmpmaps);
    2844                   free (tmpmaps);
    2845                   tmpmaps = NULL;
    2846                 }
    2847             }
    2848         }
    2849       else
    2850           {
    2851                 addToMap (request_inputs, "ResponseDocument", "");
    2852                        
    2853                 xmlNodePtr cur = tmps->nodeTab[0]; // only one ResponseDocument node
    2854                 if (cur->type == XML_ELEMENT_NODE) {
    2855                 /**
    2856                  * Get every attribute: storeExecuteResponse, lineage, status
    2857                  */
    2858                         //map* attributes = NULL;
    2859                         const char *ress[3] =
    2860                           { "storeExecuteResponse", "lineage", "status" };
    2861                         xmlChar *val;
    2862                         for (int l = 0; l < 3; l++)
    2863                         {
    2864         #ifdef DEBUG
    2865                                 fprintf (stderr, "*** %s ***\t", ress[l]);
    2866         #endif
    2867                                 val = xmlGetProp (cur, BAD_CAST ress[l]);
    2868                                 if (val != NULL && strlen ((char *) val) > 0)
    2869                                 {
    2870                                 /*
    2871                                         if (attributes == NULL) {
    2872                                                 attributes = createMap (ress[l], (char *) val);
    2873                                         }
    2874                                         else {
    2875                                                 addToMap (attributes, ress[l], (char *) val);
    2876                                         }
    2877                                 */             
    2878                                         addToMap (request_inputs, ress[l], (char *) val);
    2879                                   }
    2880         #ifdef DEBUG
    2881                                 fprintf (stderr, "%s\n", val);
    2882         #endif
    2883                                 xmlFree (val);
    2884                         }
    2885                        
    2886                         xmlNodePtr cur1 = cur->children;               
    2887                         while (cur1 != NULL) // iterate over Output nodes
    2888                         {
    2889                                 if (cur1->type != XML_ELEMENT_NODE ||
    2890                                         xmlStrncasecmp(cur1->name, BAD_CAST "Output",
    2891                                                                    xmlStrlen (cur1->name)) != 0) {
    2892                                         cur1 = cur1->next;
    2893                                         continue;
    2894                                 }
    2895                                
    2896                                 maps *tmpmaps = (maps *) malloc (MAPS_SIZE); // one per Output node
    2897                                 if (tmpmaps == NULL) {
    2898                                         return errorException (m,
    2899                                                                                    _
    2900                                                                                    ("Unable to allocate memory."),
    2901                                                                                    "InternalError", NULL);
    2902                                 }
    2903                                 tmpmaps->name = zStrdup ("unknownIdentifier");
    2904                                 tmpmaps->content = NULL;
    2905                                 tmpmaps->next = NULL;
    2906                                
    2907                                 xmlNodePtr elems = cur1->children;
    2908                                
    2909                                 while (elems != NULL) {
    2910                                
    2911                                         /**
    2912                                          * Identifier
    2913                                          */             
    2914                                         if (xmlStrncasecmp
    2915                                                 (elems->name, BAD_CAST "Identifier",
    2916                                                  xmlStrlen (elems->name)) == 0)
    2917                                         {                       
    2918                                                 xmlChar *val =
    2919                                                   xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
    2920                                                
    2921                                                 free(tmpmaps->name);
    2922                                                 tmpmaps->name = zStrdup ((char *) val); 
    2923                                                 if (tmpmaps->content == NULL) {
    2924                                                         tmpmaps->content = createMap("Identifier", zStrdup ((char *) val));
    2925                                                 }
    2926                                                 else {
    2927                                                         addToMap(tmpmaps->content, "Identifier", zStrdup ((char *) val));
    2928                                                 }
    2929                                          
    2930                                                 map* tt = getMap (request_inputs, "ResponseDocument");                           
    2931                                                 if (strlen(tt->value) == 0) {
    2932                                                   addToMap (request_inputs, "ResponseDocument",
    2933                                                                         (char *) val);                                                 
    2934                                                 }       
    2935                                                 else {
    2936                                                         char* tmp = (char*) malloc((strlen(tt->value) + 1
    2937                                                                                                 + strlen((char*) val) + 1) * sizeof(char));
    2938                                                         sprintf (tmp, "%s;%s", tt->value, (char *) val);
    2939                                                         free(tt->value);
    2940                                                         tt->value = tmp;       
    2941                                                 }       
    2942                                                 xmlFree (val);
    2943                                         }                               
    2944                                         /**
    2945                                          * Title, Abstract
    2946                                          */
    2947                                         else if (xmlStrncasecmp(elems->name, BAD_CAST "Title",
    2948                                                                                         xmlStrlen (elems->name)) == 0
    2949                                                   || xmlStrncasecmp(elems->name, BAD_CAST "Abstract",
    2950                                                                                  xmlStrlen (elems->name)) == 0)
    2951                                         {
    2952                                                 xmlChar *val =
    2953                                                         xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
    2954                                                        
    2955                                                 if (tmpmaps->content == NULL) {
    2956                                                         tmpmaps->content = createMap((char*) elems->name, zStrdup ((char *) val));
    2957                                                 }
    2958                                                 else {
    2959                                                         addToMap(tmpmaps->content, (char*) elems->name, zStrdup ((char *) val));
    2960                                                 }
    2961                                                 xmlFree (val);
    2962                                         }
    2963                                         elems = elems->next;
    2964                                 }
    2965                                
    2966                                 /**
    2967                                  * Get every attribute from an Output node:
    2968                                  * mimeType, encoding, schema, uom, asReference
    2969                                  */
    2970                                 const char *outs[5] =
    2971                                           { "mimeType", "encoding", "schema", "uom", "asReference" };
    2972                                          
    2973                                 for (int l = 0; l < 5; l++) {
    2974         #ifdef DEBUG
    2975                                         fprintf (stderr, "*** %s ***\t", outs[l]);
    2976         #endif
    2977                                         xmlChar *val = xmlGetProp (cur1, BAD_CAST outs[l]);                             
    2978                                         if (val != NULL && xmlStrlen(val) > 0) {
    2979                                                 if (tmpmaps->content != NULL) {
    2980                                                         addToMap (tmpmaps->content, outs[l], (char *) val);
    2981                                                 }                         
    2982                                                 else {
    2983                                                         tmpmaps->content = createMap (outs[l], (char *) val);
    2984                                                 }       
    2985                                         }
    2986         #ifdef DEBUG
    2987                                         fprintf (stderr, "%s\n", val);
    2988         #endif
    2989                                         xmlFree (val);
    2990                                 }
    2991                                
    2992                                 if (request_output_real_format == NULL) {
    2993                                         request_output_real_format = tmpmaps;
    2994                                 }       
    2995                                 else if (getMaps(request_output_real_format, tmpmaps->name) != NULL) {
    2996                                         return errorException (m,
    2997                                                                                    _
    2998                                                                                    ("Duplicate <Output> elements in WPS Execute request"),
    2999                                                                                    "InternalError", NULL);
    3000                                 }
    3001                                 else {
    3002                                         maps* mptr = request_output_real_format;
    3003                                         while (mptr->next != NULL) {
    3004                                                 mptr = mptr->next;
    3005                                         }
    3006                                         mptr->next = tmpmaps;   
    3007                                 }                                       
    3008                                 cur1 = cur1->next;
    3009                         }                       
    3010                 }
    3011           }
    3012       xmlXPathFreeObject (tmpsptr);
    3013       xmlFreeDoc (doc);
    3014       xmlCleanupParser ();
    3015     }
    3016 
    3017   runHttpRequests (&m, &request_input_real_format, &hInternet);
    3018 
    3019   //  if(CHECK_INET_HANDLE(hInternet))
    3020   InternetCloseHandle (&hInternet);
    3021 
    3022 #ifdef DEBUG
    3023   fprintf (stderr, "\n%d\n", __LINE__);
    3024   fflush (stderr);
    3025   dumpMaps (request_input_real_format);
    3026   dumpMaps (request_output_real_format);
    3027   dumpMap (request_inputs);
    3028   fprintf (stderr, "\n%d\n", __LINE__);
    3029   fflush (stderr);
    3030 #endif
    3031 
    3032   /**
    3033    * Ensure that each requested arguments are present in the request
    3034    * DataInputs and ResponseDocument / RawDataOutput
    3035    */
    3036   map* errI=NULL;
    3037 #ifdef DEBUG 
    3038   dumpMaps(request_input_real_format);
    3039 #endif 
    3040   char *dfv = addDefaultValues (&request_input_real_format, s1->inputs, m, 0,&errI);
    3041 #ifdef DEBUG 
    3042   dumpMaps(request_input_real_format);
    3043 #endif 
    3044   maps *ptr = request_input_real_format;
    3045   while (ptr != NULL)
    3046     {
    3047       map *tmp0 = getMap (ptr->content, "size");
    3048       map *tmp1 = getMap (ptr->content, "maximumMegabytes");
    3049       if (tmp1 != NULL && tmp0 != NULL)
    3050         {
    3051           float i = atof (tmp0->value) / 1048576.0;
    3052           if (i >= atoi (tmp1->value))
    3053             {
    3054               char tmps[1024];
    3055               map *tmpe = createMap ("code", "FileSizeExceeded");
    3056               snprintf (tmps, 1024,
    3057                         _
    3058                         ("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)."),
    3059                         ptr->name, tmp1->value, i);
    3060               addToMap (tmpe, "locator", ptr->name);
    3061               addToMap (tmpe, "text", tmps);
    3062               printExceptionReportResponse (m, tmpe);
    3063               freeService (&s1);
    3064               free (s1);
    3065               freeMap (&tmpe);
    3066               free (tmpe);
    3067               freeMaps (&m);
    3068               free (m);
    3069               free (REQUEST);
    3070               free (SERVICE_URL);
    3071               freeMaps (&request_input_real_format);
    3072               free (request_input_real_format);
    3073               freeMaps (&request_output_real_format);
    3074               free (request_output_real_format);
    3075               freeMaps (&tmpmaps);
    3076               free (tmpmaps);
    3077               return 1;
    3078             }
    3079         }
    3080       ptr = ptr->next;
    3081     }
    3082 
    3083   map* errO=NULL;
    3084   char *dfv1 =
    3085     addDefaultValues (&request_output_real_format, s1->outputs, m, 1,&errO);
    3086   if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
    3087     {
    3088       char tmps[1024];
    3089       map *tmpe = NULL;
    3090       if (strcmp (dfv, "") != 0)
    3091         {
    3092           tmpe = createMap ("code", "MissingParameterValue");
    3093           int nb=0;
    3094           int length=1;
    3095           map* len=getMap(errI,"length");
    3096           if(len!=NULL)
    3097             length=atoi(len->value);
    3098           for(nb=0;nb<length;nb++){
    3099             map* errp=getMapArray(errI,"value",nb);
    3100             snprintf (tmps, 1024,
    3101                       _
    3102                       ("The <%s> argument was not specified in DataInputs but is required according to the ZOO ServicesProvider configuration file."),
    3103                       errp->value);
    3104             setMapArray (tmpe, "locator", nb , errp->value);
    3105             setMapArray (tmpe, "text", nb , tmps);
    3106             setMapArray (tmpe, "code", nb , "MissingParameterValue");
    3107           }
    3108         }
    3109       if (strcmp (dfv1, "") != 0)
    3110         {
    3111           int ilength=0;
    3112           if(tmpe==NULL)
    3113             tmpe = createMap ("code", "InvalidParameterValue");
    3114           else{
    3115             map* len=getMap(tmpe,"length");
    3116             if(len!=NULL)
    3117               ilength=atoi(len->value);
    3118           }
    3119           int nb=0;
    3120           int length=1;
    3121           map* len=getMap(errO,"length");
    3122           if(len!=NULL)
    3123             length=atoi(len->value);
    3124           for(nb=0;nb<length;nb++){
    3125             map* errp=getMapArray(errO,"value",nb);
    3126             snprintf (tmps, 1024,
    3127                       _
    3128                       ("The <%s> argument specified as %s identifier was not recognized (not defined in the ZOO Configuration File)."),
    3129                       errp->value,
    3130                       ((getMap(request_inputs,"RawDataOutput")!=NULL)?"RawDataOutput":"ResponseDocument"));
    3131             setMapArray (tmpe, "locator", nb+ilength , errp->value);
    3132             setMapArray (tmpe, "text", nb+ilength , tmps);
    3133             setMapArray (tmpe, "code", nb+ilength , "InvalidParameterValue");
    3134           }
    3135         }
    3136       printExceptionReportResponse (m, tmpe);
    3137       freeService (&s1);
    3138       free (s1);
    3139       freeMap (&tmpe);
    3140       free (tmpe);
    3141       freeMaps (&m);
    3142       free (m);
    3143       free (REQUEST);
    3144       free (SERVICE_URL);
    3145       freeMaps (&request_input_real_format);
    3146       free (request_input_real_format);
    3147       freeMaps (&request_output_real_format);
    3148       free (request_output_real_format);
    3149       freeMaps (&tmpmaps);
    3150       free (tmpmaps);
    3151       if(errI!=NULL){
    3152         freeMap(&errI);
    3153         free(errI);
    3154       }
    3155       if(errO!=NULL){
    3156         freeMap(&errO);
    3157         free(errO);
    3158       }
    3159       return 1;
    3160     }
    3161   maps *tmpReqI = request_input_real_format;
    3162   while (tmpReqI != NULL)
    3163     {
    3164       char name[1024];
    3165       if (getMap (tmpReqI->content, "isFile") != NULL)
    3166         {
    3167           if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
    3168               cgiFormSuccess)
    3169             {
    3170               int BufferLen = 1024;
    3171               cgiFilePtr file;
    3172               int targetFile;
    3173               char storageNameOnServer[2048];
    3174               char fileNameOnServer[64];
    3175               char contentType[1024];
    3176               char buffer[1024];
    3177               char *tmpStr = NULL;
    3178               int size;
    3179               int got, t;
    3180               map *path = getMapFromMaps (m, "main", "tmpPath");
    3181               cgiFormFileSize (tmpReqI->name, &size);
    3182               cgiFormFileContentType (tmpReqI->name, contentType,
    3183                                       sizeof (contentType));
    3184               if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
    3185                 {
    3186                   t = -1;
    3187                   while (1)
    3188                     {
    3189                       tmpStr = strstr (name + t + 1, "\\");
    3190                       if (NULL == tmpStr)
    3191                         tmpStr = strstr (name + t + 1, "/");
    3192                       if (NULL != tmpStr)
    3193                         t = (int) (tmpStr - name);
    3194                       else
    3195                         break;
    3196                     }
    3197                   strcpy (fileNameOnServer, name + t + 1);
    3198 
    3199                   sprintf (storageNameOnServer, "%s/%s", path->value,
    3200                            fileNameOnServer);
    3201 #ifdef DEBUG
    3202                   fprintf (stderr, "Name on server %s\n",
    3203                            storageNameOnServer);
    3204                   fprintf (stderr, "fileNameOnServer: %s\n",
    3205                            fileNameOnServer);
    3206 #endif
    3207                   targetFile =
    3208                     open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
    3209                           S_IRWXU | S_IRGRP | S_IROTH);
    3210                   if (targetFile < 0)
    3211                     {
    3212 #ifdef DEBUG
    3213                       fprintf (stderr, "could not create the new file,%s\n",
    3214                                fileNameOnServer);
    3215 #endif
    3216                     }
    3217                   else
    3218                     {
    3219                       while (cgiFormFileRead (file, buffer, BufferLen, &got)
    3220                              == cgiFormSuccess)
    3221                         {
    3222                           if (got > 0)
    3223                             write (targetFile, buffer, got);
    3224                         }
    3225                     }
    3226                   addToMap (tmpReqI->content, "lref", storageNameOnServer);
    3227                   cgiFormFileClose (file);
    3228                   close (targetFile);
    3229 #ifdef DEBUG
    3230                   fprintf (stderr, "File \"%s\" has been uploaded",
    3231                            fileNameOnServer);
    3232 #endif
    3233                 }
    3234             }
    3235         }
    3236       tmpReqI = tmpReqI->next;
    3237     }
    3238 
    3239   ensureDecodedBase64 (&request_input_real_format);
    3240 
    3241 #ifdef DEBUG
    3242   fprintf (stderr, "REQUEST_INPUTS\n");
    3243   dumpMaps (request_input_real_format);
    3244   fprintf (stderr, "REQUEST_OUTPUTS\n");
    3245   dumpMaps (request_output_real_format);
    3246 #endif
     1621
     1622
     1623  if(parseRequest(&m,&request_inputs,s1,&request_input_real_format,&request_output_real_format,&hInternet)<0){
     1624    freeMaps (&m);
     1625    free (m);
     1626    free (REQUEST);
     1627    free (SERVICE_URL);
     1628    InternetCloseHandle (&hInternet);
     1629    freeService (&s1);
     1630    free (s1);
     1631    return 0;
     1632  }
    32471633
    32481634  maps *curs = getMaps (m, "env");
     
    34901876  if (status == NULLMAP)
    34911877    {
     1878      if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
     1879        freeService (&s1);
     1880        free (s1);
     1881        freeMaps (&m);
     1882        free (m);
     1883        free (REQUEST);
     1884        free (SERVICE_URL);
     1885        freeMaps (&request_input_real_format);
     1886        free (request_input_real_format);
     1887        freeMaps (&request_output_real_format);
     1888        free (request_output_real_format);
     1889        freeMaps (&tmpmaps);
     1890        free (tmpmaps);
     1891        return -1;
     1892      }
     1893
    34921894      loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
    34931895                         &request_output_real_format, &eres);
     
    35301932      else if (pid == 0)
    35311933        {
    3532       /**
    3533        * son : have to close the stdout, stdin and stderr to let the parent
    3534        * process answer to http client.
    3535        */
     1934          /**
     1935           * son : have to close the stdout, stdin and stderr to let the parent
     1936           * process answer to http client.
     1937           */
    35361938#ifndef WIN32
    35371939          zSleep (1);
     
    35861988#endif
    35871989          free (flog);
     1990          if(validateRequest(&m,s1,request_inputs, &request_input_real_format,&request_output_real_format,&hInternet)<0){
     1991            freeService (&s1);
     1992            free (s1);
     1993            freeMaps (&m);
     1994            free (m);
     1995            free (REQUEST);
     1996            free (SERVICE_URL);
     1997            freeMaps (&request_input_real_format);
     1998            free (request_input_real_format);
     1999            freeMaps (&request_output_real_format);
     2000            free (request_output_real_format);
     2001            freeMaps (&tmpmaps);
     2002            free (tmpmaps);
     2003            fflush (stdout);
     2004            unlockShm (lid);
     2005            fflush (stderr);
     2006            return -1;
     2007          }
    35882008      /**
    35892009       * set status to SERVICE_STARTED and flush stdout to ensure full
  • trunk/zoo-project/zoo-services/utils/status/Makefile

    r522 r621  
    1616
    1717cgi-env/wps_status.zo: service.c
    18         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
     18        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
    1919
    2020install:
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png