source: branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c @ 867

Last change on this file since 867 was 867, checked in by djay, 6 years ago

Fix issue #163 and add support for extra cookie through definition of ecookie array map and the corresponding ecookie_lenght. This give the capability to return more than only a single Cookie.

  • Property svn:keywords set to Id
File size: 55.6 KB
Line 
1/*
2 * Author : Gérald FENOY
3 *
4 * Copyright (c) 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 */
24
25#include "request_parser.h"
26#include "service_internal.h"
27#include "server_internal.h"
28#include "response_print.h"
29#include "caching.h"
30
31/**
32 * Apply XPath Expression on XML document.
33 *
34 * @param doc the XML Document
35 * @param search the XPath expression
36 * @return xmlXPathObjectPtr containing the resulting nodes set
37 */
38xmlXPathObjectPtr
39extractFromDoc (xmlDocPtr doc, const char *search)
40{
41  xmlXPathContextPtr xpathCtx;
42  xmlXPathObjectPtr xpathObj;
43  xpathCtx = xmlXPathNewContext (doc);
44  xpathObj = xmlXPathEvalExpression (BAD_CAST search, xpathCtx);
45  xmlXPathFreeContext (xpathCtx);
46  return xpathObj;
47}
48
49/**
50 * Create (or append to) an array valued maps value = "["",""]"
51 *
52 * @param m the conf maps containing the main.cfg settings
53 * @param mo the map to update
54 * @param mi the map to append
55 * @param elem the elements containing default definitions
56 * @return 0 on success, -1 on failure
57 */
58int appendMapsToMaps (maps * m, maps * mo, maps * mi, elements * elem){
59  maps *tmpMaps = getMaps (mo, mi->name);
60  map *tmap = getMapType (tmpMaps->content);
61  elements *el = getElements (elem, mi->name);
62  elements *cursor = elem;
63  while(cursor!=NULL && el==NULL){
64    if(cursor->child!=NULL)
65      el = getElements (cursor->child, mi->name);
66    cursor=cursor->next;
67  }
68  int hasEl = 1;
69  if (el == NULL)
70    hasEl = -1;
71
72  if (tmap == NULL)
73    {
74      if (hasEl > 0)
75        tmap = getMapType (el->defaults->content);
76    }
77 
78  map *testMap = NULL;
79  if (hasEl > 0)
80    {
81      testMap = getMap (el->content, "maxOccurs");
82    }
83  else
84    {
85      testMap = createMap ("maxOccurs", "unbounded");
86    }
87   
88  if (testMap != NULL)
89    {
90      if (strncasecmp (testMap->value, "unbounded", 9) != 0
91          && atoi (testMap->value) > 1)
92        {
93          addMapsArrayToMaps (&mo, mi, tmap->name);
94          map* nb=getMapFromMaps(mo,mi->name,"length");
95          if (nb!=NULL && atoi(nb->value)>atoi(testMap->value))
96            {
97              char emsg[1024];
98              sprintf (emsg,
99                       _("The maximum allowed occurrences for <%s> (%i) was exceeded."),
100                       mi->name, atoi (testMap->value));
101              errorException (m, emsg, "InternalError", NULL);
102              return -1;
103            }
104        }
105      else
106        {
107          if (strncasecmp (testMap->value, "unbounded", 9) == 0)
108            {
109              if (hasEl < 0)
110                {
111                  freeMap (&testMap);
112                  free (testMap);
113                }
114              if (addMapsArrayToMaps (&mo, mi, tmap->name) < 0)
115                {
116                  char emsg[1024];
117                  map *tmpMap = getMap (mi->content, "length");
118                  sprintf (emsg,
119                           _
120                           ("ZOO-Kernel was unable to load your data for %s position %s."),
121                           mi->name, tmpMap->value);
122                  errorException (m, emsg, "InternalError", NULL);
123                  return -1;
124                }
125            }
126          else
127            {
128              char emsg[1024];
129              sprintf (emsg,
130                       _
131                       ("The maximum allowed occurrences for <%s> is one."),
132                       mi->name);
133              errorException (m, emsg, "InternalError", NULL);
134              return -1;
135            }
136        }
137    }
138  return 0;
139}
140
141/**
142 * Make sure that each value encoded in base64 in a maps is decoded.
143 *
144 * @param in the maps containing the values
145 * @see readBase64
146 */
147void ensureDecodedBase64(maps **in){
148  maps* cursor=*in;
149  while(cursor!=NULL){
150    map *tmp=getMap(cursor->content,"encoding");
151    if(tmp!=NULL && strncasecmp(tmp->value,"base64",6)==0){
152      tmp=getMap(cursor->content,"value");
153      readBase64(&tmp);
154      addToMap(cursor->content,"base64_value",tmp->value);
155      int size=0;
156      char *s=strdup(tmp->value);
157      free(tmp->value);
158      tmp->value=base64d(s,strlen(s),&size);
159      free(s);
160      char sizes[1024];
161      sprintf(sizes,"%d",size);
162      addToMap(cursor->content,"size",sizes);
163    }
164    map* length=getMap(cursor->content,"length");
165    if(length!=NULL){
166      int len=atoi(length->value);
167      for(int i=1;i<len;i++){
168        tmp=getMapArray(cursor->content,"encoding",i);
169        if(tmp!=NULL && strncasecmp(tmp->value,"base64",6)==0){
170          char key[17];
171          sprintf(key,"base64_value_%d",i);
172          tmp=getMapArray(cursor->content,"value",i);
173          readBase64(&tmp);
174          addToMap(cursor->content,key,tmp->value);
175          int size=0;
176          char *s=strdup(tmp->value);
177          free(tmp->value);
178          tmp->value=base64d(s,strlen(s),&size);
179          free(s);
180          char sizes[1024];
181          sprintf(sizes,"%d",size);
182          sprintf(key,"size_%d",i);
183          addToMap(cursor->content,key,sizes);
184        }
185      }
186    }
187    if(cursor->child!=NULL)
188      ensureDecodedBase64(&cursor->child);
189    cursor=cursor->next;
190  }
191}
192
193/**
194 * Parse inputs provided as KVP and store them in a maps.
195 *
196 * @param main_conf the conf maps containing the main.cfg settings
197 * @param s the service
198 * @param request_inputs the map storing KVP raw value
199 * @param request_output the maps to store the KVP pairs
200 * @param hInternet the HINTERNET queue to add potential requests
201 * @return 0 on success, -1 on failure
202 */
203int kvpParseInputs(maps** main_conf,service* s,map *request_inputs,maps** request_output,HINTERNET* hInternet){
204  // Parsing inputs provided as KVP
205  maps *tmpmaps = *request_output;
206  map* r_inputs = getMap (request_inputs, "DataInputs");
207  char* cursor_input;
208  if (r_inputs != NULL){
209    //snprintf (cursor_input, 40960, "%s", r_inputs->value);
210    if(strstr(r_inputs->value,"=")==NULL)
211      cursor_input = url_decode (r_inputs->value);
212    else
213      cursor_input = zStrdup (r_inputs->value);
214    int j = 0;
215
216    // Put each DataInputs into the inputs_as_text array
217    char *pToken;
218    pToken = strtok (cursor_input, ";");
219    char **inputs_as_text = (char **) malloc (100 * sizeof (char *));
220    if (inputs_as_text == NULL)
221      {
222        free(cursor_input);
223        return errorException (*main_conf, _("Unable to allocate memory"),
224                               "InternalError", NULL);
225      }
226    int i = 0;
227    while (pToken != NULL)
228      {
229        inputs_as_text[i] =
230          (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
231        if (inputs_as_text[i] == NULL)
232          {
233            free(cursor_input);
234            return errorException (*main_conf, _("Unable to allocate memory"),
235                                   "InternalError", NULL);
236          }
237        snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
238        pToken = strtok (NULL, ";");
239        i++;
240      }
241       
242    for (j = 0; j < i; j++)
243      {
244        char *tmp = zStrdup (inputs_as_text[j]);
245        free (inputs_as_text[j]);
246        char *tmpc;
247        tmpc = strtok (tmp, "@");
248        while (tmpc != NULL)
249          {
250            char *tmpv = strstr (tmpc, "=");
251            char tmpn[256];
252            memset (tmpn, 0, 256);
253            if (tmpv != NULL)
254              {
255                strncpy (tmpn, tmpc,
256                         (strlen (tmpc) - strlen (tmpv)) * sizeof (char));
257                tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
258              }
259            else
260              {
261                strncpy (tmpn, tmpc, strlen (tmpc) * sizeof (char));
262                tmpn[strlen (tmpc)] = 0;
263              }
264            if (tmpmaps == NULL)
265              {
266                tmpmaps = createMaps(tmpn);
267                if (tmpmaps == NULL)
268                  {
269                    free(cursor_input);
270                    return errorException (*main_conf,
271                                           _("Unable to allocate memory"),
272                                           "InternalError", NULL);
273                  }
274                if (tmpv != NULL)
275                  {
276                    char *tmpvf = url_decode (tmpv + 1);
277                    tmpmaps->content = createMap ("value", tmpvf);
278                    free (tmpvf);
279                  }
280                else
281                  tmpmaps->content = createMap ("value", "Reference");
282                tmpmaps->next = NULL;
283              }
284            tmpc = strtok (NULL, "@");
285            while (tmpc != NULL)
286              {
287                char *tmpv1 = strstr (tmpc, "=");
288                char tmpn1[1024];
289                memset (tmpn1, 0, 1024);
290                if (tmpv1 != NULL)
291                  {
292                    strncpy (tmpn1, tmpc, strlen (tmpc) - strlen (tmpv1));
293                    tmpn1[strlen (tmpc) - strlen (tmpv1)] = 0;
294                    addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
295                  }
296                else
297                  {
298                    strncpy (tmpn1, tmpc, strlen (tmpc));
299                    tmpn1[strlen (tmpc)] = 0;
300                    map *lmap = getLastMap (tmpmaps->content);
301                    char *tmpValue =
302                      (char *) malloc ((strlen (tmpv) + strlen (tmpc) + 1) *
303                                       sizeof (char));
304                    sprintf (tmpValue, "%s@%s", tmpv + 1, tmpc);
305                    free (lmap->value);
306                    lmap->value = zStrdup (tmpValue);
307                    free (tmpValue);
308                    tmpc = strtok (NULL, "@");
309                    continue;
310                  }
311                if (strcmp (tmpn1, "xlink:href") != 0)
312                  addToMap (tmpmaps->content, tmpn1, tmpv1 + 1);
313                else if (tmpv1 != NULL)
314                  {
315                    char *tmpx2 = url_decode (tmpv1 + 1);
316                    if (strncasecmp (tmpx2, "http://", 7) != 0 &&
317                        strncasecmp (tmpx2, "ftp://", 6) != 0 &&
318                        strncasecmp (tmpx2, "https://", 8) != 0)
319                      {
320                        char emsg[1024];
321                        sprintf (emsg,
322                                 _
323                                 ("Unable to find a valid protocol to download the remote file %s"),
324                                 tmpv1 + 1);
325                        free(cursor_input);
326                        return errorException (*main_conf, emsg, "InternalError", NULL);
327                      }
328                    addToMap (tmpmaps->content, tmpn1, tmpx2);
329                    {
330                      if (loadRemoteFile
331                          (&*main_conf, &tmpmaps->content, hInternet, tmpx2) < 0)
332                        {
333                          free(cursor_input);
334                          return errorException (*main_conf, "Unable to fetch any resource", "InternalError", NULL);
335                        }
336                      }
337                    free (tmpx2);
338                    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
339                    addToMap (tmpmaps->content, "Reference", tmpv1 + 1);
340                  }
341                tmpc = strtok (NULL, "@");
342              }
343            if (*request_output == NULL)
344              *request_output = dupMaps (&tmpmaps);
345            else
346              {
347                maps *testPresence =
348                  getMaps (*request_output, tmpmaps->name);
349                if (testPresence != NULL)
350                  {
351                    elements *elem =
352                      getElements (s->inputs, tmpmaps->name);
353                    if (elem != NULL)
354                      {
355                        if (appendMapsToMaps
356                            (*main_conf, *request_output, tmpmaps,
357                             elem) < 0)
358                          {
359                            free(cursor_input);
360                            return errorException (*main_conf, "Unable to append maps", "InternalError", NULL);
361                          }
362                      }
363                  }
364                else
365                  addMapsToMaps (request_output, tmpmaps);
366              }
367            freeMaps (&tmpmaps);
368            free (tmpmaps);
369            tmpmaps = NULL;
370            free (tmp);
371          }
372      }
373    free (inputs_as_text);
374    free(cursor_input);
375  }
376  return 1;
377}
378
379/**
380 * Parse outputs provided as KVP and store them in a maps.
381 *
382 * @param main_conf the conf maps containing the main.cfg settings
383 * @param request_inputs the map storing KVP raw value
384 * @param request_output the maps to store the KVP pairs
385 * @return 0 on success, -1 on failure
386 */
387int kvpParseOutputs(maps** main_conf,map *request_inputs,maps** request_output){
388  /**
389   * Parsing outputs provided as KVP
390   */
391  map *r_inputs = NULL;
392  r_inputs = getMap (request_inputs, "ResponseDocument");
393  if (r_inputs == NULL)
394    r_inputs = getMap (request_inputs, "RawDataOutput");
395
396  if (r_inputs != NULL)
397    {
398      char *cursor_output = zStrdup (r_inputs->value);
399      int j = 0;
400
401      /**
402       * Put each Output into the outputs_as_text array
403       */
404      char *pToken;
405      maps *tmp_output = NULL;
406      pToken = strtok (cursor_output, ";");
407      char **outputs_as_text = (char **) malloc (128 * sizeof (char *));
408      if (outputs_as_text == NULL)
409        {
410          free(cursor_output);
411          return errorException (*main_conf, _("Unable to allocate memory"),
412                                 "InternalError", NULL);
413        }
414      int i = 0;
415      while (pToken != NULL)
416        {
417          outputs_as_text[i] =
418            (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
419          if (outputs_as_text[i] == NULL)
420            {
421              free(cursor_output);
422              return errorException (*main_conf, _("Unable to allocate memory"),
423                                     "InternalError", NULL);
424            }
425          snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
426                    pToken);
427          pToken = strtok (NULL, ";");
428          i++;
429        }
430      for (j = 0; j < i; j++)
431        {
432          char *tmp = zStrdup (outputs_as_text[j]);
433          free (outputs_as_text[j]);
434          char *tmpc;
435          tmpc = strtok (tmp, "@");
436          int k = 0;
437          while (tmpc != NULL)
438            {
439              if (k == 0)
440                {
441                  if (tmp_output == NULL)
442                    {
443                      tmp_output = createMaps(tmpc);
444                      if (tmp_output == NULL)
445                        {
446                          free(cursor_output);
447                          return errorException (*main_conf,
448                                                 _
449                                                 ("Unable to allocate memory"),
450                                                 "InternalError", NULL);
451                        }
452                    }
453                }
454              else
455                {
456                  char *tmpv = strstr (tmpc, "=");
457                  char tmpn[256];
458                  memset (tmpn, 0, 256);
459                  strncpy (tmpn, tmpc,
460                           (strlen (tmpc) -
461                            strlen (tmpv)) * sizeof (char));
462                  tmpn[strlen (tmpc) - strlen (tmpv)] = 0;
463                  if (tmp_output->content == NULL)
464                    {
465                      tmp_output->content = createMap (tmpn, tmpv + 1);
466                      tmp_output->content->next = NULL;
467                    }
468                  else
469                    addToMap (tmp_output->content, tmpn, tmpv + 1);
470                }
471              k++;
472              tmpc = strtok (NULL, "@");
473            }
474          if (*request_output == NULL)
475            *request_output = dupMaps (&tmp_output);
476          else
477            addMapsToMaps (request_output, tmp_output);
478          freeMaps (&tmp_output);
479          free (tmp_output);
480          tmp_output = NULL;
481          free (tmp);
482        }
483      free (outputs_as_text);
484      free(cursor_output);
485    }
486  return 1;
487}
488
489/**
490 * Create a "missingIdentifier" maps in case it is NULL.
491 *
492 * @param main_conf the conf maps containing the main.cfg settings
493 * @param mymaps the maps to update
494 * @return 0 on success, 4 on failure
495 */
496int defineMissingIdentifier(maps** main_conf,maps** mymaps){
497  if (*mymaps == NULL){
498    *mymaps = createMaps("missingIndetifier");
499    if (*mymaps == NULL){
500      return errorException (*main_conf,
501                             _("Unable to allocate memory"),
502                             "InternalError", NULL);
503    }
504  }
505  return 0;
506}
507
508/**
509 * Parse inputs from XML nodes and store them in a maps.
510 *
511 * @param main_conf the conf maps containing the main.cfg settings
512 * @param s the service
513 * @param request_output the maps to store the KVP pairs
514 * @param doc the xmlDocPtr containing the original request
515 * @param nodes the input nodes array
516 * @param hInternet the HINTERNET queue to add potential requests
517 * @return 0 on success, -1 on failure
518 */
519int xmlParseInputs(maps** main_conf,service* s,maps** request_output,xmlDocPtr doc,xmlNodeSet* nodes,HINTERNET* hInternet){
520  int k = 0;
521  int l = 0;
522  map* version=getMapFromMaps(*main_conf,"main","rversion");
523  int vid=getVersionId(version->value);
524  for (k=0; k < nodes->nodeNr; k++)
525    {
526      maps *tmpmaps = NULL;
527      xmlNodePtr cur = nodes->nodeTab[k];
528
529      if (nodes->nodeTab[k]->type == XML_ELEMENT_NODE)
530        {
531          // A specific Input node.
532          if(vid==1){
533            xmlChar *val = xmlGetProp (cur, BAD_CAST "id");
534            tmpmaps = createMaps((char *) val);
535            xmlFree(val);
536          }
537
538          xmlNodePtr cur2 = cur->children;
539          while (cur2 != NULL)
540            {
541              while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
542                cur2 = cur2->next;
543              if (cur2 == NULL)
544                break;
545              // Indentifier
546              if (xmlStrncasecmp
547                  (cur2->name, BAD_CAST "Identifier",
548                   xmlStrlen (cur2->name)) == 0)
549                {
550                  xmlChar *val =
551                    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
552                  if (tmpmaps == NULL && val!=NULL)
553                    {
554                      tmpmaps = createMaps((char*)val);
555                      if (tmpmaps == NULL)
556                        {
557                          return errorException (*main_conf,
558                                                 _
559                                                 ("Unable to allocate memory"),
560                                                 "InternalError", NULL);
561                        }
562                      xmlFree (val);
563                    }
564                }
565              // Title, Asbtract
566              if (xmlStrncasecmp
567                  (cur2->name, BAD_CAST "Title",
568                   xmlStrlen (cur2->name)) == 0
569                  || xmlStrncasecmp (cur2->name, BAD_CAST "Abstract",
570                                     xmlStrlen (cur2->name)) == 0)
571                {
572                  xmlChar *val =
573                    xmlNodeListGetString (doc, cur2->xmlChildrenNode, 1);
574                  defineMissingIdentifier(main_conf,&tmpmaps);
575                  if(val!=NULL){
576                    if (tmpmaps->content != NULL)
577                      addToMap (tmpmaps->content,
578                                (char *) cur2->name, (char *) val);
579                    else
580                      tmpmaps->content =
581                        createMap ((char *) cur2->name, (char *) val);
582                    xmlFree (val);
583                  }
584                }
585              // InputDataFormChoice (Reference or Data ?) / 2.0.0 DataInputType / Input
586              if (xmlStrcasecmp (cur2->name, BAD_CAST "Input") == 0)
587                {
588                  char *xpathExpr=(char*)malloc(61+strlen(tmpmaps->name));
589                  sprintf(xpathExpr,"/*/*[local-name()='Input' and @id='%s']/*[local-name()='Input']",tmpmaps->name);
590                  xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr);
591                  xmlNodeSet *tmps = tmpsptr->nodesetval;
592                  if(tmps!=NULL){
593                    maps* request_output1=NULL;
594                    if(xmlParseInputs(main_conf,s,&request_output1,doc,tmps,hInternet)<0)
595                      return -1;
596                    if(tmpmaps->child==NULL)
597                      tmpmaps->child=dupMaps(&request_output1);
598                    else
599                      addMapsToMaps(&tmpmaps->child,request_output1);
600                    freeMaps(&request_output1);
601                    free(request_output1);
602                  }
603                  while(cur2->next!=NULL)
604                    cur2=cur2->next;
605                }
606              else if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
607                {
608                  defineMissingIdentifier(main_conf,&tmpmaps);
609                  // Get every attribute from a Reference node
610                  // mimeType, encoding, schema, href, method
611                  // Header and Body gesture should be added here
612                  const char *refs[5] =
613                    { "mimeType", "encoding", "schema", "method",
614                      "href"
615                    };
616                  for (l = 0; l < 5; l++)
617                    {
618                      xmlChar *val = xmlGetProp (cur2, BAD_CAST refs[l]);
619                      if (val != NULL && xmlStrlen (val) > 0)
620                        {
621                          if (tmpmaps->content != NULL)
622                            addToMap (tmpmaps->content, refs[l],
623                                      (char *) val);
624                          else
625                            tmpmaps->content =
626                              createMap (refs[l], (char *) val);
627                          map *ltmp = getMap (tmpmaps->content, "method");
628                          if (l == 4 )
629                            {
630                              if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0))
631                                {
632                                  if (loadRemoteFile
633                                      (main_conf, &tmpmaps->content, hInternet,
634                                       (char *) val) != 0)
635                                    {
636                                      return errorException (*main_conf,
637                                                             _("Unable to add a request in the queue."),
638                                                             "InternalError",
639                                                             NULL);
640                                    }
641                                  addIntToMap (tmpmaps->content, "Order", hInternet->nb);
642                                }
643                              addToMap (tmpmaps->content, "Reference", (char*) val);
644                            }
645                        }
646                      xmlFree (val);
647                    }
648                  // Parse Header and Body from Reference
649                  xmlNodePtr cur3 = cur2->children;
650                  while (cur3 != NULL)
651                    {
652                      while (cur3 != NULL
653                             && cur3->type != XML_ELEMENT_NODE)
654                        cur3 = cur3->next;
655                      if (cur3 == NULL)
656                        break;
657                      if (xmlStrcasecmp (cur3->name, BAD_CAST "Header") ==
658                          0)
659                        {
660                          const char *ha[2];
661                          ha[0] = "key";
662                          ha[1] = "value";
663                          int hai;
664                          char *has=NULL;
665                          char *key;
666                          for (hai = 0; hai < 2; hai++)
667                            {
668                              xmlChar *val =
669                                xmlGetProp (cur3, BAD_CAST ha[hai]);
670#ifdef POST_DEBUG
671                              fprintf (stderr, "%s = %s\n", ha[hai],
672                                       (char *) val);
673#endif
674                              if (hai == 0)
675                                {
676                                  key = zStrdup ((char *) val);
677                                }
678                              else
679                                {
680                                  has =
681                                    (char *)
682                                    malloc ((4 + xmlStrlen (val) +
683                                             strlen (key)) *
684                                            sizeof (char));
685                                  if (has == NULL)
686                                    {
687                                      return errorException (*main_conf,
688                                                             _
689                                                             ("Unable to allocate memory"),
690                                                             "InternalError",
691                                                             NULL);
692                                    }
693                                  snprintf (has,
694                                            (3 + xmlStrlen (val) +
695                                             strlen (key)), "%s: %s", key,
696                                            (char *) val);
697                                  free (key);
698                                }
699                              xmlFree (val);
700                            }
701                          if (has != NULL){
702                            hInternet->ihandle[hInternet->nb].header = NULL;
703                            hInternet->ihandle[hInternet->nb].header =
704                              curl_slist_append (hInternet->ihandle
705                                                 [hInternet->nb].header,
706                                                 has);
707                            free (has);
708                          }
709                        }
710                      else
711                        {
712#ifdef POST_DEBUG
713                          fprintf (stderr,
714                                   "Try to fetch the body part of the request ...\n");
715#endif
716                          if (xmlStrcasecmp (cur3->name, BAD_CAST "Body")
717                              == 0)
718                            {
719#ifdef POST_DEBUG
720                              fprintf (stderr, "Body part found (%s) !!!\n",
721                                       (char *) cur3->content);
722#endif
723                              char *tmp = NULL;
724                              xmlNodePtr cur4 = cur3->children;
725                              while (cur4 != NULL)
726                                {
727                                  while (cur4 && cur4 != NULL && cur4->type && cur4->type != XML_ELEMENT_NODE){
728                                    if(cur4->next)
729                                      cur4 = cur4->next;
730                                    else
731                                      cur4 = NULL;
732                                  }
733                                  if(cur4 != NULL) {
734                                    xmlDocPtr bdoc =
735                                      xmlNewDoc (BAD_CAST "1.0");
736                                    bdoc->encoding =
737                                      xmlCharStrdup ("UTF-8");
738                                    xmlDocSetRootElement (bdoc, cur4);
739                                    xmlChar *btmps;
740                                    int bsize;
741                                    // TODO : check for encoding defined in the input
742                                    xmlDocDumpFormatMemoryEnc(bdoc, &btmps, &bsize, "UTF-8", 0);
743                                    if (btmps != NULL){
744                                      tmp = (char *) malloc ((bsize + 1) * sizeof (char));
745
746                                      sprintf (tmp, "%s", (char*) btmps);
747
748                                      //xmlFreeDoc (bdoc);
749                                         
750                                      map *btmp =
751                                        getMap (tmpmaps->content, "Reference");
752                                      addToMap (tmpmaps->content, "Body", tmp);
753                                      if (btmp != NULL)
754                                        {
755                                          addRequestToQueue(main_conf,hInternet,(char *) btmp->value,false);
756                                          InternetOpenUrl (hInternet,
757                                                           btmp->value,
758                                                           tmp,
759                                                           xmlStrlen(btmps),
760                                                           INTERNET_FLAG_NO_CACHE_WRITE,
761                                                           0,
762                                                           *main_conf);
763                                          addIntToMap (tmpmaps->content, "Order", hInternet->nb);
764                                        }
765                                      xmlFree (btmps);
766                                      free (tmp);
767                                      break;
768                                    }
769                                  }
770                                  cur4 = cur4->next;
771                                }
772                            }
773                          else
774                            if (xmlStrcasecmp
775                                (cur3->name,
776                                 BAD_CAST "BodyReference") == 0)
777                              {
778                                xmlChar *val =
779                                  xmlGetProp (cur3, BAD_CAST "href");
780                                HINTERNET bInternet, res1, res;
781                                maps *tmpConf=createMaps("main");
782                                tmpConf->content=createMap("memory","load");
783                                bInternet = InternetOpen (
784#ifndef WIN32
785                                                          (LPCTSTR)
786#endif
787                                                          "ZooWPSClient\0",
788                                                          INTERNET_OPEN_TYPE_PRECONFIG,
789                                                          NULL, NULL, 0);
790                                if (!CHECK_INET_HANDLE (bInternet))
791                                  fprintf (stderr,
792                                           "WARNING : bInternet handle failed to initialize");
793                                bInternet.waitingRequests[0] =
794                                  strdup ((char *) val);
795                                res1 =
796                                  InternetOpenUrl (&bInternet,
797                                                   bInternet.waitingRequests
798                                                   [0], NULL, 0,
799                                                   INTERNET_FLAG_NO_CACHE_WRITE,
800                                                   0,
801                                                   tmpConf);
802                                processDownloads (&bInternet);
803                                freeMaps(&tmpConf);
804                                free(tmpConf);
805                                char *tmp =
806                                  (char *)
807                                  malloc ((bInternet.ihandle[0].nDataLen +
808                                           1) * sizeof (char));
809                                if (tmp == NULL)
810                                  {
811                                    return errorException (*main_conf,
812                                                           _
813                                                           ("Unable to allocate memory"),
814                                                           "InternalError",
815                                                           NULL);
816                                  }
817                                size_t bRead;
818                                InternetReadFile (bInternet.ihandle[0],
819                                                  (LPVOID) tmp,
820                                                  bInternet.
821                                                  ihandle[0].nDataLen,
822                                                  &bRead);
823                                tmp[bInternet.ihandle[0].nDataLen] = 0;
824                                InternetCloseHandle(&bInternet);
825                                addToMap (tmpmaps->content, "Body", tmp);
826                                map *btmp =
827                                  getMap (tmpmaps->content, "href");
828                                if (btmp != NULL)
829                                  {
830                                    addRequestToQueue(main_conf,hInternet,(char *) btmp->value,false);
831
832                                    res =
833                                      InternetOpenUrl (hInternet,
834                                                       btmp->value,
835                                                       tmp,
836                                                       strlen(tmp),
837                                                       INTERNET_FLAG_NO_CACHE_WRITE,
838                                                       0,
839                                                       *main_conf);
840                                    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
841                                  }
842                                free (tmp);
843                                xmlFree (val);
844                              }
845                        }
846                      cur3 = cur3->next;
847                    }
848                }
849              else if (xmlStrcasecmp (cur2->name, BAD_CAST "Data") == 0)
850                {
851                  defineMissingIdentifier(main_conf,&tmpmaps);
852                  xmlNodePtr cur4 = cur2->children;
853                  if(vid==1){
854                    // Get every dataEncodingAttributes from a Data node:
855                    // mimeType, encoding, schema
856                    const char *coms[3] =
857                      { "mimeType", "encoding", "schema" };
858                    for (l = 0; l < 3; l++){
859                      xmlChar *val =
860                          xmlGetProp (cur4, BAD_CAST coms[l]);
861                        if (val != NULL && strlen ((char *) val) > 0){
862                          if (tmpmaps->content != NULL)
863                            addToMap (tmpmaps->content,coms[l],(char *) val);
864                          else
865                            tmpmaps->content =
866                              createMap (coms[l],(char *) val);
867                        }
868                        xmlFree (val);
869                    }
870                    while (cur4 != NULL){
871                      while(cur4 != NULL && 
872                            cur4->type != XML_CDATA_SECTION_NODE &&
873                            cur4->type != XML_TEXT_NODE &&
874                            cur4->type != XML_ELEMENT_NODE)
875                        cur4=cur4->next;
876                      if(cur4!=NULL){
877                        if (cur4->type == XML_ELEMENT_NODE)
878                          {
879                            xmlChar *mv;
880                            int buffersize;
881                            xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
882                            xmlDocSetRootElement (doc1, cur4);
883                            xmlDocDumpFormatMemoryEnc (doc1, &mv,
884                                                       &buffersize,
885                                                       "utf-8", 0);
886                            if (tmpmaps->content != NULL)
887                              addToMap (tmpmaps->content, "value",
888                                        (char *) mv);
889                            else
890                              tmpmaps->content =
891                                createMap ("value", (char *) mv);
892                            free(mv);
893                          }
894                        else{
895                          if (tmpmaps->content != NULL)
896                            addToMap (tmpmaps->content, "value",
897                                      (char *) cur4->content);
898                          else
899                            tmpmaps->content =
900                              createMap ("value", (char *) cur4->content);
901                        }
902                        cur4=cur4->next;
903                      }
904                    }
905                  }
906
907                  while (cur4 != NULL)
908                    {
909                      while (cur4 != NULL
910                             && cur4->type != XML_ELEMENT_NODE)
911                        cur4 = cur4->next;
912                      if (cur4 == NULL)
913                        break;
914                      if (xmlStrcasecmp
915                          (cur4->name, BAD_CAST "LiteralData") == 0)
916                        {
917                          // Get every attribute from a LiteralData node
918                          // dataType , uom
919                          char *list[2];
920                          list[0] = zStrdup ("dataType");
921                          list[1] = zStrdup ("uom");
922                          for (l = 0; l < 2; l++)
923                            {
924                              xmlChar *val =
925                                xmlGetProp (cur4, BAD_CAST list[l]);
926                              if (val != NULL
927                                  && strlen ((char *) val) > 0)
928                                {
929                                  if (tmpmaps->content != NULL)
930                                    addToMap (tmpmaps->content, list[l],
931                                              (char *) val);
932                                  else
933                                    tmpmaps->content =
934                                      createMap (list[l], (char *) val);
935                                }
936                              xmlFree (val);
937                              free (list[l]);
938                            }
939                        }
940                      else
941                        if (xmlStrcasecmp
942                            (cur4->name, BAD_CAST "ComplexData") == 0)
943                          {
944                            // Get every attribute from a Reference node
945                            // mimeType, encoding, schema
946                            const char *coms[3] =
947                              { "mimeType", "encoding", "schema" };
948                            for (l = 0; l < 3; l++)
949                              {
950                                xmlChar *val =
951                                  xmlGetProp (cur4, BAD_CAST coms[l]);
952                                if (val != NULL
953                                    && strlen ((char *) val) > 0)
954                                  {
955                                    if (tmpmaps->content != NULL)
956                                      addToMap (tmpmaps->content, coms[l],
957                                                (char *) val);
958                                    else
959                                      tmpmaps->content =
960                                        createMap (coms[l], (char *) val);
961                                  }
962                                xmlFree (val);
963                              }
964                          }
965
966                      map *test = getMap (tmpmaps->content, "encoding");
967
968                      if (test == NULL)
969                        { 
970                          if (tmpmaps->content != NULL)
971                            addToMap (tmpmaps->content, "encoding",
972                                      "utf-8");
973                          else
974                            tmpmaps->content =
975                              createMap ("encoding", "utf-8");
976                          test = getMap (tmpmaps->content, "encoding");
977                        }
978
979                      if (strcasecmp (test->value, "base64") != 0)
980                        {
981                          xmlChar *mv = xmlNodeListGetString (doc,
982                                                              cur4->xmlChildrenNode,
983                                                              1);
984                          map *ltmp =
985                            getMap (tmpmaps->content, "mimeType");
986                          if (mv == NULL
987                              ||
988                              (xmlStrcasecmp
989                               (cur4->name, BAD_CAST "ComplexData") == 0
990                               && (ltmp == NULL
991                                   || strncasecmp (ltmp->value,
992                                                   "text/xml", 8) == 0)))
993                            {
994                              xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
995                              int buffersize;
996                              xmlNodePtr cur5 = cur4->children;
997                              while (cur5 != NULL
998                                     && cur5->type != XML_ELEMENT_NODE
999                                     && cur5->type != XML_CDATA_SECTION_NODE)
1000                                cur5 = cur5->next;
1001                              if (cur5 != NULL
1002                                  && cur5->type != XML_CDATA_SECTION_NODE)
1003                                {
1004                                  xmlDocSetRootElement (doc1, cur5);
1005                                  xmlDocDumpFormatMemoryEnc (doc1, &mv,
1006                                                             &buffersize,
1007                                                             "utf-8", 0);
1008                                  xmlFreeDoc (doc1);
1009                                }
1010                              else
1011                                {
1012                                  if (cur5 != NULL
1013                                      && cur5->type == XML_CDATA_SECTION_NODE){
1014                                    xmlDocPtr doc2 = xmlReadMemory((const char*)cur5->content,xmlStrlen(cur5->content),
1015                                                                   "input_content.xml", NULL, XML_PARSE_RECOVER);
1016                                    xmlDocDumpFormatMemoryEnc (doc2, &mv,
1017                                                               &buffersize,
1018                                                               "utf-8", 0);
1019                                    xmlFreeDoc (doc2);
1020                                  }
1021                                }
1022                              addIntToMap (tmpmaps->content, "size",
1023                                           buffersize);
1024                            }else{
1025                            if(xmlStrcasecmp
1026                               (cur4->name, BAD_CAST "BoundingBoxData") == 0){
1027                              xmlDocPtr doc1 = xmlNewDoc(BAD_CAST "1.0");
1028                              int buffersize;
1029                              xmlDocSetRootElement(doc1,cur4);
1030                              xmlDocDumpFormatMemoryEnc(doc1,&mv,
1031                                                        &buffersize,
1032                                                        "utf-8",0);
1033                              addIntToMap (tmpmaps->content, "size",
1034                                           buffersize);
1035                              xmlParseBoundingBox(main_conf,&tmpmaps->content,doc1);
1036                            }else{
1037                              xmlNodePtr cur5 = cur4->children;
1038                              while (cur5 != NULL
1039                                     && cur5->type != XML_ELEMENT_NODE
1040                                     && cur5->type != XML_CDATA_SECTION_NODE)
1041                                cur5 = cur5->next;
1042                              if (cur5 != NULL
1043                                  && cur5->type != XML_CDATA_SECTION_NODE)
1044                                {
1045                                  xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0");
1046                                  int buffersize;
1047                                  xmlDocSetRootElement (doc1, cur5);
1048                                  xmlDocDumpFormatMemoryEnc (doc1, &mv,
1049                                                             &buffersize,
1050                                                             "utf-8", 0);
1051                                  addIntToMap (tmpmaps->content, "size",
1052                                               buffersize);
1053                                }
1054                              else /*if (cur5 != NULL
1055                                     && cur5->type == XML_CDATA_SECTION_NODE)*/{
1056                                xmlFree(mv);
1057                                mv=xmlStrdup(cur5->content);
1058                              }
1059                            }
1060                          }
1061                          if (mv != NULL)
1062                            {
1063                              addToMap (tmpmaps->content, "value",
1064                                        (char*) mv);
1065                              xmlFree (mv);
1066                            }
1067                        }
1068                      else
1069                        {
1070                          xmlChar *tmp = xmlNodeListGetRawString (doc,
1071                                                                  cur4->xmlChildrenNode,
1072                                                                  0);
1073                          addToMap (tmpmaps->content, "value",
1074                                    (char *) tmp);
1075                          xmlFree (tmp);
1076                        }
1077
1078                      cur4 = cur4->next;
1079                    }
1080                }
1081              cur2 = cur2->next;
1082              while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE){
1083                cur2 = cur2->next;
1084              }
1085            }
1086          {
1087            map* test=getMap(tmpmaps->content,"value");
1088            if(test==NULL && tmpmaps->child==NULL)
1089              addToMap(tmpmaps->content,"value","");
1090            maps *testPresence = getMaps (*request_output, tmpmaps->name);
1091            maps *cursor=*request_output;
1092            while(testPresence == NULL && cursor!=NULL){
1093              if(cursor->child!=NULL){
1094                testPresence = getMaps (cursor->child, tmpmaps->name);
1095              }
1096              cursor=cursor->next;
1097            }
1098            if (testPresence != NULL)
1099              {
1100                elements *elem = getElements (s->inputs, tmpmaps->name);
1101                elements *cursor=s->inputs;
1102                while(elem == NULL && cursor!=NULL){
1103                  if(cursor->child!=NULL){
1104                    elem = getElements (cursor->child, tmpmaps->name);
1105                  }
1106                  cursor=cursor->next;
1107                }
1108                if (elem != NULL)
1109                  {
1110                    if (appendMapsToMaps
1111                        (*main_conf, testPresence, tmpmaps, elem) < 0)
1112                      {
1113                        return errorException (*main_conf,
1114                                               _("Unable to append maps to maps."),
1115                                               "InternalError",
1116                                               NULL);
1117                      }
1118                  }
1119              }
1120            else
1121              addMapsToMaps (request_output, tmpmaps);
1122          }
1123          freeMaps (&tmpmaps);
1124          free (tmpmaps);
1125          tmpmaps = NULL;
1126        }
1127    }
1128  return 1;
1129}
1130
1131/**
1132 * Parse a BoundingBoxData node
1133 *
1134 * http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd: BoundingBoxType
1135 *
1136 * A map to store boundingbox information will contain:
1137 *  - LowerCorner : double double (minimum within this bounding box)
1138 *  - UpperCorner : double double (maximum within this bounding box)
1139 *  - crs : URI (Reference to definition of the CRS)
1140 *  - dimensions : int
1141 *
1142 * @param main_conf the conf maps containing the main.cfg settings
1143 * @param request_inputs the map storing KVP raw value
1144 * @param doc the xmlDocPtr containing the BoudingoxData node
1145 * @return a map containing all the bounding box keys
1146 */
1147int xmlParseBoundingBox(maps** main_conf,map** current_input,xmlDocPtr doc){
1148  xmlNode *root_element = xmlDocGetRootElement(doc);
1149  for(xmlAttrPtr attr = root_element->properties; NULL != attr; attr = attr->next){
1150    xmlChar *val = xmlGetProp (root_element, BAD_CAST attr->name);
1151    addToMap(*current_input,(char*)attr->name,(char*)val);
1152    xmlFree(val);
1153    xmlNodePtr cur = root_element->children;
1154    while(cur!=NULL && cur->type != XML_ELEMENT_NODE)
1155      cur=cur->next;
1156    while(cur!=NULL && cur->type==XML_ELEMENT_NODE){
1157      xmlChar *val =
1158        xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
1159      addToMap(*current_input,(char*)cur->name,(char*)val);
1160      cur=cur->next;
1161      xmlFree(val);
1162      while(cur!=NULL && cur->type != XML_ELEMENT_NODE)
1163        cur=cur->next;
1164    }
1165  }
1166}
1167
1168/**
1169 * Parse outputs from XML nodes and store them in a maps (WPS version 2.0.0).
1170 *
1171 * @param main_conf the conf maps containing the main.cfg settings
1172 * @param request_inputs the map storing KVP raw value
1173 * @param request_output the maps to store the KVP pairs
1174 * @param doc the xmlDocPtr containing the original request
1175 * @param cur the xmlNodePtr corresponding to the ResponseDocument or RawDataOutput XML node
1176 * @param raw true if the node is RawDataOutput, false in case of ResponseDocument
1177 * @return 0 on success, -1 on failure
1178 */
1179int xmlParseOutputs2(maps** main_conf,map** request_inputs,maps** request_output,xmlDocPtr doc,xmlNodeSet* nodes){
1180  int k = 0;
1181  int l = 0;
1182  for (k=0; k < nodes->nodeNr; k++){
1183    maps *tmpmaps = NULL;
1184    xmlNodePtr cur = nodes->nodeTab[k];
1185    if (cur->type == XML_ELEMENT_NODE){
1186      maps *tmpmaps = NULL;
1187      xmlChar *val = xmlGetProp (cur, BAD_CAST "id");
1188      if(val!=NULL)
1189        tmpmaps = createMaps((char *)val);
1190      else
1191        tmpmaps = createMaps("unknownIdentifier");
1192      const char ress[4][13] =
1193        { "mimeType", "encoding", "schema", "transmission" };
1194      xmlFree (val);
1195      for (l = 0; l < 4; l++){
1196        val = xmlGetProp (cur, BAD_CAST ress[l]);
1197        if (val != NULL && strlen ((char *) val) > 0)
1198          {
1199            if (tmpmaps->content != NULL)
1200              addToMap (tmpmaps->content, ress[l],
1201                        (char *) val);
1202            else
1203              tmpmaps->content =
1204                createMap (ress[l], (char *) val);
1205            if(l==3 && strncasecmp((char*)val,"reference",xmlStrlen(val))==0)
1206              addToMap (tmpmaps->content,"asReference","true");
1207          }
1208        xmlFree (val);
1209      }
1210      if(cur->children!=NULL){
1211        xmlNodePtr ccur = cur->children;
1212        while (ccur != NULL){
1213          if(ccur->type == XML_ELEMENT_NODE){
1214            char *xpathExpr=(char*)malloc(66+strlen(tmpmaps->name));
1215            sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name);           
1216            xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr);
1217            xmlNodeSet* cnodes = tmpsptr->nodesetval;
1218            xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes);
1219            xmlXPathFreeObject (tmpsptr);
1220            free(xpathExpr);
1221            break;
1222          }
1223          ccur = ccur->next;
1224        }
1225      }
1226      if (*request_output == NULL){
1227        *request_output = dupMaps(&tmpmaps);
1228      }
1229      else{
1230        addMapsToMaps(request_output,tmpmaps);
1231      }
1232      freeMaps(&tmpmaps);
1233      free(tmpmaps);
1234    }
1235  }
1236  return 0;
1237}
1238
1239/**
1240 * Parse outputs from XML nodes and store them in a maps.
1241 *
1242 * @param main_conf the conf maps containing the main.cfg settings
1243 * @param request_inputs the map storing KVP raw value
1244 * @param request_output the maps to store the KVP pairs
1245 * @param doc the xmlDocPtr containing the original request
1246 * @param cur the xmlNodePtr corresponding to the ResponseDocument or RawDataOutput XML node
1247 * @param raw true if the node is RawDataOutput, false in case of ResponseDocument
1248 * @return 0 on success, -1 on failure
1249 */
1250int xmlParseOutputs(maps** main_conf,map** request_inputs,maps** request_output,xmlDocPtr doc,xmlNodePtr cur,bool raw){
1251  int l=0;
1252  if( raw == true)
1253    {
1254      addToMap (*request_inputs, "RawDataOutput", "");
1255      if (cur->type == XML_ELEMENT_NODE)
1256        {
1257
1258          maps *tmpmaps = createMaps("unknownIdentifier");
1259          if (tmpmaps == NULL)
1260            {
1261              return errorException (*main_conf, _("Unable to allocate memory"),
1262                                     "InternalError", NULL);
1263            }
1264
1265          // Get every attribute from a RawDataOutput node
1266          // mimeType, encoding, schema, uom
1267          const char *outs[4] =
1268            { "mimeType", "encoding", "schema", "uom" };
1269          for (l = 0; l < 4; l++)
1270            {
1271              xmlChar *val = xmlGetProp (cur, BAD_CAST outs[l]);
1272              if (val != NULL)
1273                {
1274                  if (strlen ((char *) val) > 0)
1275                    {
1276                      if (tmpmaps->content != NULL)
1277                        addToMap (tmpmaps->content, outs[l],
1278                                  (char *) val);
1279                      else
1280                        tmpmaps->content =
1281                          createMap (outs[l], (char *) val);
1282                    }
1283                  xmlFree (val);
1284                }
1285            }
1286          xmlNodePtr cur2 = cur->children;
1287          while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
1288            cur2 = cur2->next;
1289          while (cur2 != NULL)
1290            {
1291              if (xmlStrncasecmp
1292                  (cur2->name, BAD_CAST "Identifier",
1293                   xmlStrlen (cur2->name)) == 0)
1294                {
1295                  xmlChar *val =
1296                    xmlNodeListGetString (NULL, cur2->xmlChildrenNode, 1);
1297                  free (tmpmaps->name);
1298                  tmpmaps->name = zStrdup ((char *) val);
1299                  xmlFree (val);
1300                }
1301              cur2 = cur2->next;
1302              while (cur2 != NULL && cur2->type != XML_ELEMENT_NODE)
1303                cur2 = cur2->next;
1304            }
1305          if (*request_output == NULL)
1306            *request_output = dupMaps (&tmpmaps);
1307          else
1308            addMapsToMaps (request_output, tmpmaps);
1309          if (tmpmaps != NULL)
1310            {
1311              freeMaps (&tmpmaps);
1312              free (tmpmaps);
1313              tmpmaps = NULL;
1314            }
1315        }
1316    }
1317  else
1318    {
1319      addToMap (*request_inputs, "ResponseDocument", "");
1320
1321      if (cur->type == XML_ELEMENT_NODE) {
1322        // Get every attribute: storeExecuteResponse, lineage, status
1323        const char *ress[3] =
1324          { "storeExecuteResponse", "lineage", "status" };
1325        xmlChar *val;
1326        for (l = 0; l < 3; l++)
1327          {
1328            val = xmlGetProp (cur, BAD_CAST ress[l]);
1329            if (val != NULL && strlen ((char *) val) > 0)
1330              {
1331                addToMap (*request_inputs, ress[l], (char *) val);
1332              }
1333            xmlFree (val);
1334          }
1335                       
1336        xmlNodePtr cur1 = cur->children;               
1337        while (cur1 != NULL) // iterate over Output nodes
1338          {
1339            if (cur1->type != XML_ELEMENT_NODE || 
1340                xmlStrncasecmp(cur1->name, BAD_CAST "Output", 
1341                               xmlStrlen (cur1->name)) != 0) {
1342              cur1 = cur1->next;
1343              continue;
1344            }
1345                               
1346            maps *tmpmaps = createMaps("unknownIdentifier"); // one per Output node
1347            if (tmpmaps == NULL) {
1348              return errorException (*main_conf,
1349                                     _
1350                                     ("Unable to allocate memory"),
1351                                     "InternalError", NULL);
1352            }
1353                               
1354            xmlNodePtr elems = cur1->children;
1355                               
1356            while (elems != NULL) {
1357
1358              // Identifier
1359              if (xmlStrncasecmp
1360                  (elems->name, BAD_CAST "Identifier",
1361                   xmlStrlen (elems->name)) == 0)
1362                {
1363                  xmlChar *val =
1364                    xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
1365               
1366                  free(tmpmaps->name);
1367                  tmpmaps->name = zStrdup ((char *) val);
1368                  if (tmpmaps->content == NULL) {
1369                    tmpmaps->content = createMap("Identifier", zStrdup ((char *) val));
1370                  }
1371                  else {
1372                    addToMap(tmpmaps->content, "Identifier", zStrdup ((char *) val));
1373                  }
1374
1375                  map* tt = getMap (*request_inputs, "ResponseDocument");
1376                  if (strlen(tt->value) == 0) {
1377                    addToMap (*request_inputs, "ResponseDocument",
1378                              (char *) val);
1379                  }
1380                  else {
1381                    char* tmp = (char*) malloc((strlen(tt->value) + 1 
1382                                                + strlen((char*) val) + 1) * sizeof(char));
1383                    sprintf (tmp, "%s;%s", tt->value, (char *) val);
1384                    free(tt->value);
1385                    tt->value = tmp;
1386                  }
1387                  xmlFree (val);
1388                }
1389             
1390              // Title, Abstract
1391              else if (xmlStrncasecmp(elems->name, BAD_CAST "Title",
1392                                      xmlStrlen (elems->name)) == 0
1393                       || xmlStrncasecmp(elems->name, BAD_CAST "Abstract",
1394                                         xmlStrlen (elems->name)) == 0)
1395                {
1396                  xmlChar *val =
1397                    xmlNodeListGetString (doc, elems->xmlChildrenNode, 1);
1398                                                       
1399                  if (tmpmaps->content == NULL) {
1400                    tmpmaps->content = createMap((char*) elems->name, zStrdup ((char *) val));
1401                  }
1402                  else {
1403                    addToMap(tmpmaps->content, (char*) elems->name, zStrdup ((char *) val));
1404                  }
1405                  xmlFree (val);
1406                }
1407              elems = elems->next;
1408            }
1409                               
1410            // Get every attribute from an Output node:
1411            // mimeType, encoding, schema, uom, asReference
1412            const char *outs[5] =
1413              { "mimeType", "encoding", "schema", "uom", "asReference" };
1414                                         
1415            for (l = 0; l < 5; l++) {
1416              xmlChar *val = xmlGetProp (cur1, BAD_CAST outs[l]);                               
1417              if (val != NULL && xmlStrlen(val) > 0) {
1418                if (tmpmaps->content != NULL) {
1419                  addToMap (tmpmaps->content, outs[l], (char *) val);
1420                }                         
1421                else {
1422                  tmpmaps->content = createMap (outs[l], (char *) val);
1423                }       
1424              }
1425              xmlFree (val);
1426            }
1427                               
1428            if (*request_output == NULL) {
1429              *request_output = tmpmaps;
1430            }   
1431            else if (getMaps(*request_output, tmpmaps->name) != NULL) {
1432              return errorException (*main_conf,
1433                                     _
1434                                     ("Duplicate <Output> elements in WPS Execute request"),
1435                                     "InternalError", NULL);
1436            }
1437            else {
1438              maps* mptr = *request_output;
1439              while (mptr->next != NULL) {
1440                mptr = mptr->next;
1441              }
1442              mptr->next = tmpmaps;     
1443            }                                   
1444            cur1 = cur1->next;
1445          }                     
1446      }
1447    }
1448  return 1;
1449}
1450
1451/**
1452 * Parse XML request and store information in maps.
1453 *
1454 * @param main_conf the conf maps containing the main.cfg settings
1455 * @param post the string containing the XML request
1456 * @param request_inputs the map storing KVP raw value
1457 * @param s the service
1458 * @param inputs the maps to store the KVP pairs
1459 * @param outputs the maps to store the KVP pairs
1460 * @param hInternet the HINTERNET queue to add potential requests
1461 * @return 0 on success, -1 on failure
1462 */
1463int xmlParseRequest(maps** main_conf,const char* post,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
1464
1465  map* version=getMapFromMaps(*main_conf,"main","rversion");
1466  int vid=getVersionId(version->value);
1467
1468  xmlInitParser ();
1469  xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER);
1470
1471  /**
1472   * Extract Input nodes from the XML Request.
1473   */
1474  xmlXPathObjectPtr tmpsptr =
1475    extractFromDoc (doc, (vid==0?"/*/*/*[local-name()='Input']":"/*/*[local-name()='Input']"));
1476  xmlNodeSet *tmps = tmpsptr->nodesetval;
1477  if(tmps==NULL || xmlParseInputs(main_conf,s,inputs,doc,tmps,hInternet)<0){
1478    xmlXPathFreeObject (tmpsptr);
1479    xmlFreeDoc (doc);
1480    xmlCleanupParser ();
1481    return -1;
1482  }
1483  xmlXPathFreeObject (tmpsptr);
1484
1485  if(vid==1){
1486    tmpsptr =
1487      extractFromDoc (doc, "/*[local-name()='Execute']");
1488    bool asRaw = false;
1489    tmps = tmpsptr->nodesetval;
1490    if(tmps->nodeNr > 0){
1491      int k = 0;
1492      for (k=0; k < tmps->nodeNr; k++){
1493        maps *tmpmaps = NULL;
1494        xmlNodePtr cur = tmps->nodeTab[k];
1495        if (cur->type == XML_ELEMENT_NODE){
1496          xmlChar *val = xmlGetProp (cur, BAD_CAST "mode");
1497          if(val!=NULL)
1498            addToMap(*request_inputs,"mode",(char*)val);
1499          else
1500            addToMap(*request_inputs,"mode","auto");
1501          xmlFree(val);
1502          val = xmlGetProp (cur, BAD_CAST "response");
1503          if(val!=NULL){
1504            addToMap(*request_inputs,"response",(char*)val);
1505            if(strncasecmp((char*)val,"raw",xmlStrlen(val))==0)
1506              addToMap(*request_inputs,"RawDataOutput","");
1507            else
1508              addToMap(*request_inputs,"ResponseDocument","");
1509          }
1510          else{
1511            addToMap(*request_inputs,"response","document");
1512            addToMap(*request_inputs,"ResponseDocument","");
1513          }
1514          xmlFree(val);
1515        }
1516      }
1517    }
1518    xmlXPathFreeObject (tmpsptr);
1519    tmpsptr =
1520      extractFromDoc (doc, "/*/*[local-name()='Output']");
1521    tmps = tmpsptr->nodesetval;
1522    if(tmps->nodeNr > 0){
1523      if(xmlParseOutputs2(main_conf,request_inputs,outputs,doc,tmps)<0){
1524        xmlXPathFreeObject (tmpsptr);
1525        xmlFreeDoc (doc);
1526        xmlCleanupParser ();
1527        return -1;
1528      }
1529    }
1530  }
1531  else{
1532    // Extract ResponseDocument / RawDataOutput from the XML Request
1533    tmpsptr =
1534      extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']");
1535    bool asRaw = false;
1536    tmps = tmpsptr->nodesetval;
1537    if (tmps->nodeNr == 0)
1538      {
1539        xmlXPathFreeObject (tmpsptr);
1540        tmpsptr =
1541          extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']");
1542        tmps = tmpsptr->nodesetval;
1543        asRaw = true;
1544      }
1545    if(tmps->nodeNr != 0){
1546      if(xmlParseOutputs(main_conf,request_inputs,outputs,doc,tmps->nodeTab[0],asRaw)<0){
1547        xmlXPathFreeObject (tmpsptr);
1548        xmlFreeDoc (doc);
1549        xmlCleanupParser ();
1550        return -1;
1551      }
1552    }
1553  }
1554  xmlXPathFreeObject (tmpsptr);
1555  xmlFreeDoc (doc);
1556  xmlCleanupParser ();
1557  return 1;
1558}
1559
1560/**
1561 * Parse request and store information in maps.
1562 *
1563 * @param main_conf the conf maps containing the main.cfg settings
1564 * @param post the string containing the XML request
1565 * @param request_inputs the map storing KVP raw value
1566 * @param s the service
1567 * @param inputs the maps to store the KVP pairs
1568 * @param outputs the maps to store the KVP pairs
1569 * @param hInternet the HINTERNET queue to add potential requests
1570 * @return 0 on success, -1 on failure
1571 * @see kvpParseOutputs,kvpParseInputs,xmlParseRequest
1572 */
1573int parseRequest(maps** main_conf,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
1574  map *postRequest = NULL;
1575  postRequest = getMap (*request_inputs, "xrequest");
1576  if (postRequest == NULLMAP)
1577    {
1578      if(kvpParseOutputs(main_conf,*request_inputs,outputs)<0){
1579        return -1;
1580      }
1581      if(kvpParseInputs(main_conf,s,*request_inputs,inputs,hInternet)<0){
1582        return -1;
1583      }
1584    }
1585  else
1586    {
1587      //Parse XML request
1588      if(xmlParseRequest(main_conf,postRequest->value,request_inputs,s,inputs,outputs,hInternet)<0){
1589        return -1;
1590      }
1591    }
1592  return 1;
1593}
1594
1595/**
1596 * Ensure that each requested arguments are present in the request
1597 * DataInputs and ResponseDocument / RawDataOutput. Potentially run
1598 * http requests from the queue in parallel.
1599 * For optional inputs add default values defined in the ZCFG file.
1600 *
1601 * @param main_conf
1602 * @param s
1603 * @param original_request
1604 * @param request_inputs
1605 * @param request_outputs
1606 * @param hInternet
1607 *
1608 * @see runHttpRequests
1609 */
1610int validateRequest(maps** main_conf,service* s,map* original_request, maps** request_inputs,maps** request_outputs,HINTERNET* hInternet){
1611
1612  map* errI0=NULL;
1613  runHttpRequests (main_conf, request_inputs, hInternet,&errI0);
1614  if(errI0!=NULL){
1615    printExceptionReportResponse (*main_conf, errI0);
1616    InternetCloseHandle (hInternet);
1617    return -1;
1618  }
1619  InternetCloseHandle (hInternet);
1620
1621
1622  map* errI=NULL;
1623  char *dfv = addDefaultValues (request_inputs, s->inputs, *main_conf, 0,&errI);
1624
1625  maps *ptr = *request_inputs;
1626  while (ptr != NULL)
1627    {
1628      map *tmp0 = getMap (ptr->content, "size");
1629      map *tmp1 = getMap (ptr->content, "maximumMegabytes");
1630      if (tmp1 != NULL && tmp0 != NULL)
1631        {
1632          float i = atof (tmp0->value) / 1048576.0;
1633          if (i >= atoi (tmp1->value))
1634            {
1635              char tmps[1024];
1636              map *tmpe = createMap ("code", "FileSizeExceeded");
1637              snprintf (tmps, 1024,
1638                        _
1639                        ("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)."),
1640                        ptr->name, tmp1->value, i);
1641              addToMap (tmpe, "locator", ptr->name);
1642              addToMap (tmpe, "text", tmps);
1643              printExceptionReportResponse (*main_conf, tmpe);
1644              freeMap (&tmpe);
1645              free (tmpe);
1646              return -1;
1647            }
1648        }
1649      ptr = ptr->next;
1650    }
1651
1652  map* errO=NULL;
1653  char *dfv1 =
1654    addDefaultValues (request_outputs, s->outputs, *main_conf, 1,&errO);
1655
1656  if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
1657    {
1658      char tmps[1024];
1659      map *tmpe = NULL;
1660      if (strcmp (dfv, "") != 0)
1661        {
1662          tmpe = createMap ("code", "MissingParameterValue");
1663          int nb=0;
1664          int length=1;
1665          map* len=getMap(errI,"length");
1666          if(len!=NULL)
1667            length=atoi(len->value);
1668          for(nb=0;nb<length;nb++){
1669            map* errp=getMapArray(errI,"value",nb);
1670            snprintf (tmps, 1024,
1671                      _
1672                      ("The <%s> argument was not specified in DataInputs but is required according to the ZOO ServicesProvider configuration file."),
1673                      errp->value);
1674            setMapArray (tmpe, "locator", nb , errp->value);
1675            setMapArray (tmpe, "text", nb , tmps);
1676            setMapArray (tmpe, "code", nb , "MissingParameterValue");
1677          }
1678        }
1679      if (strcmp (dfv1, "") != 0)
1680        {
1681          int ilength=0;
1682          if(tmpe==NULL)
1683            tmpe = createMap ("code", "InvalidParameterValue");
1684          else{
1685            map* len=getMap(tmpe,"length");
1686            if(len!=NULL)
1687              ilength=atoi(len->value);
1688          }
1689          int nb=0;
1690          int length=1;
1691          map* len=getMap(errO,"length");
1692          if(len!=NULL)
1693            length=atoi(len->value);
1694          for(nb=0;nb<length;nb++){
1695            map* errp=getMapArray(errO,"value",nb);
1696            snprintf (tmps, 1024,
1697                      _
1698                      ("The <%s> argument specified as %s identifier was not recognized (not defined in the ZOO Configuration File)."),
1699                      errp->value,
1700                      ((getMap(original_request,"RawDataOutput")!=NULL)?"RawDataOutput":"ResponseDocument"));
1701            setMapArray (tmpe, "locator", nb+ilength , errp->value);
1702            setMapArray (tmpe, "text", nb+ilength , tmps);
1703            setMapArray (tmpe, "code", nb+ilength , "InvalidParameterValue");
1704          }
1705        }
1706      printExceptionReportResponse (*main_conf, tmpe);
1707      if(errI!=NULL){
1708        freeMap(&errI);
1709        free(errI);
1710      }
1711      if(errO!=NULL){
1712        freeMap(&errO);
1713        free(errO);
1714      }
1715      freeMap (&tmpe);
1716      free (tmpe);
1717      return -1;
1718    }
1719  maps *tmpReqI = *request_inputs;
1720  while (tmpReqI != NULL)
1721    {
1722      char name[1024];
1723      if (getMap (tmpReqI->content, "isFile") != NULL)
1724        {
1725          if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
1726              cgiFormSuccess)
1727            {
1728              int BufferLen = 1024;
1729              cgiFilePtr file;
1730              int targetFile;
1731              char *storageNameOnServer;
1732              char *fileNameOnServer;
1733              char contentType[1024];
1734              char buffer[1024];
1735              char *tmpStr = NULL;
1736              int size;
1737              int got, t;
1738              map *path = getMapFromMaps (*main_conf, "main", "tmpPath");
1739              cgiFormFileSize (tmpReqI->name, &size);
1740              cgiFormFileContentType (tmpReqI->name, contentType,
1741                                      sizeof (contentType));
1742              if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
1743                {
1744                  t = -1;
1745                  while (1)
1746                    {
1747                      tmpStr = strstr (name + t + 1, "\\");
1748                      if (NULL == tmpStr)
1749                        tmpStr = strstr (name + t + 1, "/");
1750                      if (NULL != tmpStr)
1751                        t = (int) (tmpStr - name);
1752                      else
1753                        break;
1754                    }
1755                  fileNameOnServer=(char*)malloc((strlen(name) - t - 1 )*sizeof(char));
1756                  strcpy (fileNameOnServer, name + t + 1);
1757
1758                  storageNameOnServer=(char*)malloc((strlen(path->value) + strlen(fileNameOnServer) + 2)*sizeof(char));
1759                  sprintf (storageNameOnServer, "%s/%s", path->value,
1760                           fileNameOnServer);
1761#ifdef DEBUG
1762                  fprintf (stderr, "Name on server %s\n",
1763                           storageNameOnServer);
1764                  fprintf (stderr, "fileNameOnServer: %s\n",
1765                           fileNameOnServer);
1766#endif
1767                  targetFile =
1768                    open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,
1769                          S_IRWXU | S_IRGRP | S_IROTH);
1770                  if (targetFile < 0)
1771                    {
1772#ifdef DEBUG
1773                      fprintf (stderr, "could not create the new file,%s\n",
1774                               fileNameOnServer);
1775#endif
1776                    }
1777                  else
1778                    {
1779                      while (cgiFormFileRead (file, buffer, BufferLen, &got)
1780                             == cgiFormSuccess)
1781                        {
1782                          if (got > 0)
1783                            write (targetFile, buffer, got);
1784                        }
1785                    }
1786                  addToMap (tmpReqI->content, "lref", storageNameOnServer);
1787                  cgiFormFileClose (file);
1788                  close (targetFile);
1789                  free(fileNameOnServer);
1790                  free(storageNameOnServer);
1791#ifdef DEBUG
1792                  fprintf (stderr, "File \"%s\" has been uploaded",
1793                           fileNameOnServer);
1794#endif
1795                }
1796            }
1797        }
1798      tmpReqI = tmpReqI->next;
1799    }
1800
1801  ensureDecodedBase64 (request_inputs);
1802  return 1;
1803}
1804
1805
1806/**
1807 * Verify if a parameter value is valid.
1808 *
1809 * @param request the request map
1810 * @param res the error map potentially generated
1811 * @param toCheck the parameter to use
1812 * @param avalues the acceptable values (or null if testing only for presence)
1813 * @param mandatory verify the presence of the parameter if mandatory > 0
1814 */
1815void checkValidValue(map* request,map** res,const char* toCheck,const char** avalues,int mandatory){
1816  map* lres=*res;
1817  map* r_inputs = getMap (request,toCheck);
1818  if (r_inputs == NULL){
1819    if(mandatory>0){
1820      char *replace=_("Mandatory parameter <%s> was not specified");
1821      char *message=(char*)malloc((strlen(replace)+strlen(toCheck)+1)*sizeof(char));
1822      sprintf(message,replace,toCheck);
1823      if(lres==NULL){
1824        lres=createMap("code","MissingParameterValue");
1825        addToMap(lres,"text",message);
1826        addToMap(lres,"locator",toCheck);       
1827      }else{
1828        int length=1;
1829        map* len=getMap(lres,"length");
1830        if(len!=NULL){
1831          length=atoi(len->value);
1832        }
1833        setMapArray(lres,"text",length,message);
1834        setMapArray(lres,"locator",length,toCheck);
1835        setMapArray(lres,"code",length,"MissingParameterValue");
1836      }
1837      free(message);
1838    }
1839  }else{
1840    if(avalues==NULL)
1841      return;
1842    int nb=0;
1843    int hasValidValue=-1;
1844    if(strncasecmp(toCheck,"Accept",6)==0){
1845      char *tmp=zStrdup(r_inputs->value);
1846      char *pToken,*saveptr;
1847      pToken=strtok_r(tmp,",",&saveptr);
1848      while(pToken!=NULL){
1849        while(avalues[nb]!=NULL){
1850          if(strcasecmp(avalues[nb],pToken)==0){
1851            hasValidValue=1;
1852            break;
1853          }
1854          nb++;
1855        }
1856        pToken=strtok_r(NULL,",",&saveptr);
1857      }
1858      free(tmp);
1859    }else{
1860      while(avalues[nb]!=NULL){
1861        if(strcasecmp(avalues[nb],r_inputs->value)==0){
1862          hasValidValue=1;
1863          break;
1864        }
1865        nb++;
1866      }
1867    }
1868    if(hasValidValue<0){
1869      char *replace=_("The value <%s> was not recognized, %s %s the only acceptable value.");
1870      nb=0;
1871      char *vvalues=NULL;
1872      char* num=_("is");
1873      while(avalues[nb]!=NULL){
1874        char *tvalues;
1875        if(vvalues==NULL){
1876          vvalues=(char*)malloc((strlen(avalues[nb])+3)*sizeof(char));
1877          sprintf(vvalues,"%s",avalues[nb]);
1878        }
1879        else{
1880          tvalues=zStrdup(vvalues);
1881          vvalues=(char*)realloc(vvalues,(strlen(tvalues)+strlen(avalues[nb])+3)*sizeof(char));
1882          sprintf(vvalues,"%s, %s",tvalues,avalues[nb]);
1883          free(tvalues);
1884          num=_("are");
1885        }
1886        nb++;
1887      }
1888      char *message=(char*)malloc((strlen(replace)+strlen(num)+strlen(vvalues)+strlen(toCheck)+1)*sizeof(char));
1889      sprintf(message,replace,toCheck,vvalues,num);
1890      const char *code="VersionNegotiationFailed";
1891      code="InvalidParameterValue";
1892      const char *locator=toCheck;
1893      if( strncasecmp(toCheck,"version",7)==0 ||
1894          strncasecmp(toCheck,"AcceptVersions",14)==0 )
1895        code="VersionNegotiationFailed";
1896      if( strncasecmp(toCheck,"request",7)==0){
1897        code="OperationNotSupported";
1898        locator=r_inputs->value;
1899      }
1900      if(lres==NULL){
1901        lres=createMap("code",code);
1902        addToMap(lres,"text",message);
1903        addToMap(lres,"locator",locator);       
1904      }else{
1905        int length=1;
1906        map* len=getMap(lres,"length");
1907        if(len!=NULL){
1908          length=atoi(len->value);
1909        }
1910        setMapArray(lres,"text",length,message);
1911        setMapArray(lres,"locator",length,locator);
1912        setMapArray(lres,"code",length,code);
1913      }
1914    }
1915  }
1916  if(lres!=NULL){
1917    *res=lres;
1918  }
1919}
1920
1921/**
1922 * Parse cookie contained in request headers.
1923 *
1924 * @param conf the conf maps containinfg the main.cfg
1925 * @param cookie the
1926 */
1927void parseCookie(maps** conf,const char* cookie){
1928  char* tcook=zStrdup(cookie);
1929  char *token, *saveptr;
1930  token = strtok_r (tcook, "; ", &saveptr);
1931  maps* res=createMaps("cookies");
1932  while (token != NULL){
1933    char *token1, *saveptr1, *name;
1934    int i=0;
1935    token1 = strtok_r (token, "=", &saveptr1);
1936    while (token1 != NULL){
1937      if(i==0){
1938        name=zStrdup(token1);
1939        i++;
1940      }
1941      else{
1942        if(res->content==NULL)
1943          res->content=createMap(name,token1);
1944        else
1945          addToMap(res->content,name,token1);
1946        free(name);
1947        i=0;
1948      }
1949      token1 = strtok_r (NULL, "=", &saveptr1);
1950    }
1951    token = strtok_r (NULL, "; ", &saveptr);
1952  }
1953  addMapsToMaps(conf,res);
1954  freeMaps(&res);
1955  free(res);
1956  free(tcook);
1957}
Note: See TracBrowser for help on using the repository browser.

Search

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