source: trunk/zoo-kernel/zoo_service_loader.c @ 20

Last change on this file since 20 was 20, checked in by djay, 14 years ago

Small cleanup.

File size: 50.1 KB
RevLine 
[1]1/**
2 * Author : Gérald FENOY
3 *
4 *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
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#define length(x) (sizeof(x) / sizeof(x[0]))
26
27extern "C" int yylex();
28extern "C" int crlex();
[9]29
30
[1]31extern "C" {
32#include <libxml/tree.h>
33#include <libxml/xmlmemory.h>
34#include <libxml/parser.h>
35#include <libxml/xpath.h>
36#include <libxml/xpathInternals.h>
37}
38
39#include "cgic.h"
40#include "ulinet.h"
41
42#include <string.h>
43
44#include "service.h"
45#include "service_internal.h"
46#include "service_internal_python.h"
47
48#ifdef USE_JAVA
49#include "service_internal_java.h"
50#endif
51
52#ifdef USE_PHP
53#include "service_internal_php.h"
54#endif
55
56#ifdef USE_JS
57#include "service_internal_js.h"
58#endif
59
60
61#include <dirent.h>
62#include <signal.h>
63#include <unistd.h>
64#ifndef WIN32
65#include <dlfcn.h>
66#include <libgen.h>
67#else
68#include <windows.h>
69#include <direct.h>
70#endif
71#include <fcntl.h>
72#include <time.h>
73#include <stdarg.h>
74
[9]75xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,char* search){
[1]76  xmlXPathContextPtr xpathCtx;
77  xmlXPathObjectPtr xpathObj;
78  xpathCtx = xmlXPathNewContext(doc);
79  xpathObj = xmlXPathEvalExpression(BAD_CAST search,xpathCtx);
[9]80  xmlXPathFreeContext(xpathCtx);
81  return xpathObj;
[1]82}
83
[9]84void sig_handler(int sig){
85  char tmp[100];
86  char *ssig;
87  switch(sig){
88  case SIGSEGV:
89    ssig="SIGSEGV";
90    break;
91  case SIGTERM:
92    ssig="SIGTERM";
93    break;
94  case SIGINT:
95    ssig="SIGINT";
96    break;
97  case SIGILL:
98    ssig="SIGILL";
99    break;
100  case SIGFPE:
101    ssig="SIGFPE";
102    break;
103  case SIGABRT:
104    ssig="SIGABRT";
105    break;
106  default:
107    ssig="UNKNOWN";
108    break;
109  }
110  sprintf(tmp,"ZOO Kernel failed to process your request receiving signal %d = %s",sig,ssig);
111  errorException(NULL, tmp, "InternalError");
[10]112#ifdef DEBUG
[1]113  fprintf(stderr,"Not this time!\n");
[10]114#endif
[9]115  exit(0);
[1]116}
117
118int runRequest(map* request_inputs)
119{
120
[9]121  (void) signal(SIGSEGV,sig_handler);
122  (void) signal(SIGTERM,sig_handler);
123  (void) signal(SIGINT,sig_handler);
124  (void) signal(SIGILL,sig_handler);
125  (void) signal(SIGFPE,sig_handler);
126  (void) signal(SIGABRT,sig_handler);
127
[1]128  map* r_inputs=NULL,*tmps=NULL;
129  maps* m=NULL;
130  int argc=count(request_inputs);
131
132  char* REQUEST=NULL;
133  /**
134   * Parsing service specfic configuration file
135   */
[9]136  m=(maps*)calloc(1,MAPS_SIZE);
137  if(m == NULL){
138    return errorException(m, "Unable to allocate memory.", "InternalError");
139  }
[1]140  char ntmp[1024];
141#ifndef WIN32
142  getcwd(ntmp,1024);
143#else
144  _getcwd(ntmp,1024);
145#endif
[9]146  r_inputs=getMap(request_inputs,"metapath");
147  if(r_inputs==NULL){
148    if(request_inputs==NULL)
149      request_inputs=createMap("metapath","");
150    else
151      addToMap(request_inputs,"metapath","");
152#ifdef DEBUG
153    fprintf(stderr,"ADD METAPATH\n");
154    dumpMap(request_inputs);
155#endif
156    r_inputs=getMap(request_inputs,"metapath");
157  }
158  char conf_file[10240];
159  snprintf(conf_file,10240,"%s/%s/main.cfg",ntmp,r_inputs->value);
[1]160  conf_read(conf_file,m);
[9]161#ifdef DEBUG
162  fprintf(stderr, "***** BEGIN MAPS\n"); 
163  dumpMaps(m);
164  fprintf(stderr, "***** END MAPS\n");
165#endif
166
[1]167  /**
168   * Check for minimum inputs
169   */
170  r_inputs=getMap(request_inputs,"Request");
[9]171  if(request_inputs==NULL || r_inputs==NULL){ 
172    errorException(m, "Parameter <request> was not specified","MissingParameterValue");
173    freeMaps(&m);
174    free(m);
[1]175    return 1;
176  }
[9]177  else{
[1]178    REQUEST=strdup(r_inputs->value);
[9]179    if(strncasecmp(r_inputs->value,"GetCapabilities",15)!=0
180       && strncasecmp(r_inputs->value,"DescribeProcess",15)!=0
181       && strncasecmp(r_inputs->value,"Execute",7)!=0){ 
182      errorException(m, "Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute.", "InvalidParameterValue");
183      freeMaps(&m);
184      free(m);
185      free(REQUEST);
186      return 1;
187    }
188  }
[1]189  r_inputs=NULL;
190  r_inputs=getMap(request_inputs,"Service");
[9]191  if(r_inputs==NULLMAP){
192    errorException(m, "Parameter <service> was not specified","MissingParameterValue");
193    freeMaps(&m);
194    free(m);
195    free(REQUEST);
[1]196    return 1;
197  }
[9]198  if(strncasecmp(REQUEST,"GetCapabilities",15)!=0){
[1]199    r_inputs=getMap(request_inputs,"Version");
200    if(r_inputs==NULL){ 
[9]201      errorException(m, "Parameter <version> was not specified","MissingParameterValue");
202      freeMaps(&m);
203      free(m);
204      free(REQUEST);
[1]205      return 1;
206    }
207  }
208
[9]209  r_inputs=getMap(request_inputs,"serviceprovider");
210  if(r_inputs==NULL){
211    addToMap(request_inputs,"serviceprovider","");
[1]212  }
213
214  map* outputs=NULL;
215  maps* request_output_real_format=NULL;
216  map* tmpm=getMapFromMaps(m,"main","serverAddress");
217  if(tmpm!=NULL)
218    SERVICE_URL=strdup(tmpm->value);
219  else
220    SERVICE_URL=DEFAULT_SERVICE_URL;
221
222  service* s[100];
223  service* s1;
224  int scount=0;
225
226#ifdef DEBUG
227  dumpMap(r_inputs);
228#endif
229  char conf_dir[1024];
230  int t;
231  char tmps1[1024];
232
[9]233  r_inputs=NULL;
234  r_inputs=getMap(request_inputs,"metapath");
235  if(r_inputs!=NULL)
236    snprintf(conf_dir,1024,"%s/%s",ntmp,r_inputs->value);
237  else
238    snprintf(conf_dir,1024,"%s",ntmp);
239
240  if(strncasecmp(REQUEST,"GetCapabilities",15)==0){
[1]241    int i=0;
242    struct dirent *dp;
243#ifdef DEBUG
244    dumpMap(r_inputs);
245#endif
[9]246    DIR *dirp = opendir(conf_dir);
[1]247    if(dirp==NULL){
[9]248      return errorException(m, "The specified path doesn't exist.","InvalidParameterValue");
[1]249    }
250    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
251    r_inputs=NULL;
252    r_inputs=getMap(request_inputs,"ServiceProvider");
[9]253    xmlNodePtr n;
254    //dumpMap(request_inputs);
255    if(r_inputs!=NULL)
256      n = printGetCapabilitiesHeader(doc,r_inputs->value,m);
257    else
258      n = printGetCapabilitiesHeader(doc,"",m);
[1]259    /**
260     * Strange, here we need to close stdout to ensure that no uneeded
261     * char will be printed (parser issue ?)
262     */
263    int saved_stdout = dup(fileno(stdout));
264    dup2(fileno(stderr),fileno(stdout));
265    while ((dp = readdir(dirp)) != NULL)
266      if(strstr(dp->d_name,".zcfg")!=0){
[9]267        memset(tmps1,0,1024);
268        snprintf(tmps1,1024,"%s/%s",conf_dir,dp->d_name);
269        s1=(service*)calloc(1,SERVICE_SIZE);
270        if(s1 == NULL){ 
271          return errorException(m, "Unable to allocate memory.","InternalError");
272        }
[1]273#ifdef DEBUG
274        fprintf(stderr,"#################\n%s\n#################\n",tmps1);
275#endif
276        t=getServiceFromFile(tmps1,&s1);
277#ifdef DEBUG
278        dumpService(s1);
279        fflush(stdout);
280        fflush(stderr);
281#endif
282        printGetCapabilitiesForProcess(m,n,s1);
[9]283        freeService(&s1);
284        free(s1);
[1]285        scount++;
286      }
287    (void)closedir(dirp);
288    fflush(stdout);
289    dup2(saved_stdout,fileno(stdout));
[9]290    printDocument(m,doc,getpid());
291    freeMaps(&m);
292    free(m);
293    free(REQUEST);
294    free(SERVICE_URL);
[1]295    fflush(stdout);
296    return 0;
297  }
298  else{
299    r_inputs=getMap(request_inputs,"Identifier");
300    if(r_inputs==NULL 
301       || strlen(r_inputs->name)==0 || strlen(r_inputs->value)==0){ 
[9]302      errorException(m, "Mandatory <identifier> was not specified","MissingParameterValue");
303      freeMaps(&m);
304      free(m);
305      free(REQUEST);
306      free(SERVICE_URL);
307      return 0;
[1]308    }
309
310    struct dirent *dp;
311    DIR *dirp = opendir(conf_dir);
312    if(dirp==NULL){
[9]313      errorException(m, "The specified path path doesn't exist.","InvalidParameterValue");
314      freeMaps(&m);
315      free(m);
316      free(REQUEST);
317      free(SERVICE_URL);
318      return 0;
[1]319    }
[9]320    if(strncasecmp(REQUEST,"DescribeProcess",15)==0){
[1]321      /**
322       * Loop over Identifier list
323       */
324      xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
325      r_inputs=NULL;
326      r_inputs=getMap(request_inputs,"ServiceProvider");
[9]327
[1]328      xmlNodePtr n;
329      if(r_inputs!=NULL)
330        n = printDescribeProcessHeader(doc,r_inputs->value,m);
[9]331      else
332        n = printDescribeProcessHeader(doc,"",m);
[1]333
334      r_inputs=getMap(request_inputs,"Identifier");
335      char *tmps=strtok(r_inputs->value,",");
336     
337      char buff[256];
338      char buff1[1024];
339      int i=0;
340      int j=0;
341      int end=-1;
342      int saved_stdout = dup(fileno(stdout));
343      dup2(fileno(stderr),fileno(stdout));
344      while(tmps){
345        memset(buff,0,256);
[9]346        snprintf(buff,256,"%s.zcfg",tmps);
[1]347        memset(buff1,0,1024);
348#ifdef DEBUG
349        fprintf(stderr,"\n#######%s\n########\n",buff1);
350#endif
351        while ((dp = readdir(dirp)) != NULL)
352          if(strcmp(dp->d_name,buff)==0){
353            memset(buff1,0,1024);
[9]354            snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name);
355            //s1=(service*)malloc(sizeof(service*));
356            s1=(service*)calloc(1,SERVICE_SIZE);
357            if(s1 == NULL){
358              return errorException(m, "Unable to allocate memory.","InternalError");
359            }
[1]360#ifdef DEBUG
[9]361            fprintf(stderr,"#################\n%s\n#################\n",buff1);
[1]362#endif
363            t=getServiceFromFile(buff1,&s1);
[9]364#ifdef DEBUG
365            dumpService(s1);
366#endif
367            printDescribeProcessForProcess(m,n,s1,1);
368            freeService(&s1);
369            free(s1);
[1]370            scount++;
371          }
372        rewinddir(dirp);
373        tmps=strtok(NULL,",");
374      }
[9]375      closedir(dirp);
[1]376      fflush(stdout);
377      dup2(saved_stdout,fileno(stdout));
[9]378      printDocument(m,doc,getpid());
379      freeMaps(&m);
380      free(m);
381      free(REQUEST);
382      free(SERVICE_URL);
[1]383      fflush(stdout);
384      //xmlFree(n);
385#ifndef LINUX_FREE_ISSUE
[9]386      if(s1)
387        free(s1);
[1]388#endif
389      return 0;
390    }
391    else
[9]392      if(strncasecmp(REQUEST,"Execute",strlen(REQUEST))!=0){
393        errorException(m, "Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute.", "InvalidParameterValue");
[1]394#ifdef DEBUG
395        fprintf(stderr,"No request found %s",REQUEST);
396#endif 
[9]397        closedir(dirp);
[1]398        free(s);
399        return 0;
400      }
[9]401    closedir(dirp);
[1]402  }
403 
404  s1=NULL;
[9]405  s1=(service*)calloc(1,SERVICE_SIZE);
406  if(s1 == NULL){
407    return errorException(m, "Unable to allocate memory.","InternalError");
408  }
[1]409  r_inputs=getMap(request_inputs,"MetaPath");
[9]410  if(r_inputs!=NULL)
411    snprintf(tmps1,1024,"%s/%s",ntmp,r_inputs->value);
412  else
413    snprintf(tmps1,1024,"%s/",ntmp);
[1]414  r_inputs=getMap(request_inputs,"Identifier");
[9]415  char *ttmp=strdup(tmps1);
416  snprintf(tmps1,1024,"%s/%s.zcfg",ttmp,r_inputs->value);
417  free(ttmp);
[1]418#ifdef DEBUG
419  fprintf(stderr,"Trying to load %s\n", tmps1);
420#endif
421  int saved_stdout = dup(fileno(stdout));
422  dup2(fileno(stderr),fileno(stdout));
423  t=getServiceFromFile(tmps1,&s1);
424  fflush(stdout);
425  dup2(saved_stdout,fileno(stdout));
426  if(t==22){
[9]427    errorException(m, "The value for <indetifier> seems to be wrong. Please, ensure that the process exsits using the GetCapabilities request.", "InvalidParameterValue");
[1]428    exit(0);
429  }
[9]430  //s[0]=s1;
[1]431
432#ifdef DEBUG
433  dumpService(s1);
434#endif
435  map* inputs=NULL;
436  elements* c_inputs=s1->inputs;
437  int j;
438 
439  /**
440   * Create the input maps data structure
441   */
442  int i=0;
443  HINTERNET hInternet;
444  HINTERNET res;
445  hInternet=InternetOpen(
446#ifndef WIN32
447                         (LPCTSTR)
448#endif
449                         "ZooWPSClient\0",
450                         INTERNET_OPEN_TYPE_PRECONFIG,
451                         NULL,NULL, 0);
452
453#ifndef WIN32
454  if(!CHECK_INET_HANDLE(hInternet))
455    fprintf(stderr,"WARNING : hInternet handle failed to initialize");
456#endif
457  maps* request_input_real_format=NULL;
458  maps* tmpmaps = request_input_real_format;
459  map* postRequest=NULL;
460  postRequest=getMap(request_inputs,"xrequest");
461  if(postRequest==NULLMAP){
462    /**
463     * Parsing outputs provided as KVP
464     */
465    r_inputs=NULL;
466#ifdef DEBUG
467    fprintf(stderr,"OUTPUT Parsing ... \n");
468#endif
469    r_inputs=getMap(request_inputs,"ResponseDocument"); 
[9]470    if(r_inputs==NULL) r_inputs=getMap(request_inputs,"RawDataOutput");
471   
472    //#ifdef DEBUG
[1]473    fprintf(stderr,"OUTPUT Parsing ... \n");
[9]474    //#endif
475    if(r_inputs!=NULL){
476      //#ifdef DEBUG
[1]477      fprintf(stderr,"OUTPUT Parsing start now ... \n");
[9]478      //#endif
[1]479      char current_output_as_string[10240];
480      char cursor_output[10240];
[9]481      char *cotmp=strdup(r_inputs->value);
482      snprintf(cursor_output,10240,"%s",cotmp);
483      free(cotmp);
[1]484      j=0;
485      map* request_kvp_outputs=NULL;
486       
487      /**
488       * Put each Output into the outputs_as_text array
489       */
490      char * pToken;
491      maps* tmp_output=NULL;
492#ifdef DEBUG
493      fprintf(stderr,"OUTPUT [%s]\n",cursor_output);
494#endif
495      pToken=strtok(cursor_output,";");
[9]496      char** outputs_as_text=(char**)calloc(128,sizeof(char*));
497      if(outputs_as_text == NULL) {
498        return errorException(m, "Unable to allocate memory", "InternalError");
499      }
[1]500      i=0;
501      while(pToken!=NULL){
502#ifdef DEBUG
503        fprintf(stderr,"***%s***\n",pToken);
504        fflush(stderr);
505        fprintf(stderr,"***%s***\n",pToken);
506#endif
[9]507        outputs_as_text[i]=(char*)calloc(strlen(pToken)+1,sizeof(char));
508        if(outputs_as_text[i] == NULL) {
509          return errorException(m, "Unable to allocate memory", "InternalError");
510        }
511        snprintf(outputs_as_text[i],strlen(pToken)+1,"%s",pToken);
[1]512        pToken = strtok(NULL,";");
513        i++;
514      }
515      for(j=0;j<i;j++){
516        char *tmp=strdup(outputs_as_text[j]);
[9]517        free(outputs_as_text[j]);
[1]518        char *tmpc;
519        tmpc=strtok(tmp,"@");
520        int k=0;
521        while(tmpc!=NULL){
522          if(k==0){
523            if(tmp_output==NULL){
[9]524              tmp_output=(maps*)calloc(1,MAPS_SIZE);
525              if(tmp_output == NULL){
526                return errorException(m, "Unable to allocate memory.", "InternalError");
527              }
[1]528              tmp_output->name=strdup(tmpc);
529              tmp_output->content=NULL;
530              tmp_output->next=NULL;
531            }
532          }
533          else{
534            char *tmpv=strstr(tmpc,"=");
535            char tmpn[256];
536            memset(tmpn,0,256);
537            strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
538            tmpn[strlen(tmpc)-strlen(tmpv)]=0;
539#ifdef DEBUG
540            fprintf(stderr,"OUTPUT DEF [%s]=[%s]\n",tmpn,tmpv+1);
541#endif
542            if(tmp_output->content==NULL){
543              tmp_output->content=createMap(tmpn,tmpv+1);
544              tmp_output->content->next=NULL;
545            }
546            else
547              addToMap(tmp_output->content,tmpn,tmpv+1);
548          }
549          k++;
550#ifdef DEBUG
551          fprintf(stderr,"***%s***\n",tmpc);
552#endif
553          tmpc=strtok(NULL,"@");
554        }
555        if(request_output_real_format==NULL)
[9]556          request_output_real_format=dupMaps(&tmp_output);
[1]557        else
558          addMapsToMaps(&request_output_real_format,tmp_output);
[9]559        freeMaps(&tmp_output);
560        free(tmp_output);
561        tmp_output=NULL;
[1]562#ifdef DEBUG
563        dumpMaps(tmp_output);
564        fflush(stderr);
565#endif
[9]566        //tmp_output=tmp_output->next;
567        free(tmp);
[1]568      }
[9]569      free(outputs_as_text);
[1]570    }
571
572
573    /**
574     * Parsing inputs provided as KVP
575     */
576    r_inputs=getMap(request_inputs,"DataInputs");
577#ifdef DEBUG
578    fprintf(stderr,"DATA INPUTS [%s]\n",r_inputs->value);
579#endif
580    char current_input_as_string[40960];
581    char cursor_input[40960];
[9]582    if(r_inputs!=NULL)
583      snprintf(cursor_input,40960,"%s",r_inputs->value);
584    else{
585      errorException(m, "Parameter <DataInputs> was not specified","MissingParameterValue");
586      freeMaps(&m);
587      free(m);
588      free(REQUEST);
589      free(SERVICE_URL);
590      return 0;
591    }
[1]592    j=0;
593    map* request_kvp_inputs=NULL;
594 
595    /**
596     * Put each DataInputs into the inputs_as_text array
597     */
598    char * pToken;
599    pToken=strtok(cursor_input,";");
[9]600    char** inputs_as_text=(char**)calloc(100,sizeof(char*));
601    if(inputs_as_text == NULL){
602      return errorException(m, "Unable to allocate memory.", "InternalError");
603    }
[1]604    i=0;
605    while(pToken!=NULL){
606#ifdef DEBUG
607      fprintf(stderr,"***%s***\n",pToken);
608#endif
609      fflush(stderr);
610#ifdef DEBUG
611      fprintf(stderr,"***%s***\n",pToken);
612#endif
[9]613      inputs_as_text[i]=(char*)calloc(strlen(pToken)+1,sizeof(char));
614      snprintf(inputs_as_text[i],strlen(pToken)+1,"%s",pToken);
615      if(inputs_as_text[i] == NULL){
616        return errorException(m, "Unable to allocate memory.", "InternalError");
617      }
[1]618      pToken = strtok(NULL,";");
619      i++;
620    }
621
622    for(j=0;j<i;j++){
623      char *tmp=strdup(inputs_as_text[j]);
[9]624      free(inputs_as_text[j]);
[1]625      char *tmpc;
626      tmpc=strtok(tmp,"@");
627      while(tmpc!=NULL){
628#ifdef DEBUG
629        fprintf(stderr,"***\n***%s***\n",tmpc);
630#endif
631        char *tmpv=strstr(tmpc,"=");
632        char tmpn[256];
633        memset(tmpn,0,256);
634        strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
635        tmpn[strlen(tmpc)-strlen(tmpv)]=0;
636        int cnt=0;
637#ifdef DEBUG
638        fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1);
639#endif
640        if(tmpmaps==NULL){
[9]641          tmpmaps=(maps*)calloc(1,MAPS_SIZE);
642          if(tmpmaps == NULL){
643            return errorException(m, "Unable to allocate memory.", "InternalError");
644          }
[1]645          tmpmaps->name=strdup(tmpn);
646          tmpmaps->content=createMap("value",tmpv+1);
647          tmpmaps->next=NULL;
648        }
649        tmpc=strtok(NULL,"@");
650        while(tmpc!=NULL){
651#ifdef DEBUG
652          fprintf(stderr,"*** KVP NON URL-ENCODED \n***%s***\n",tmpc);
653#endif
654          char *tmpv1=strstr(tmpc,"=");
655#ifdef DEBUG
656          fprintf(stderr,"*** VALUE NON URL-ENCODED \n***%s***\n",tmpv1+1);
657#endif
658          char tmpn1[1024];
659          memset(tmpn1,0,1024);
660          strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
661          tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
662#ifdef DEBUG
663          fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1);
664          fprintf(stderr,"*** VALUE NON URL-ENCODED \n***%s***\n",tmpv1+1);
665#endif
666          if(strcmp(tmpn1,"xlink:href")!=0)
667            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
668          else{
669#ifdef DEBUG
670            fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
671#endif
672#ifndef WIN32
[9]673            if(CHECK_INET_HANDLE(hInternet))
[1]674#endif
[9]675              {
676                res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0,
677                                    INTERNET_FLAG_NO_CACHE_WRITE,0);
[1]678#ifdef DEBUG
[9]679                fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n",
680                        tmpv1+1,res.nDataAlloc,res.nDataLen);
[1]681#endif
[9]682                char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char));
683                if(tmpContent == NULL){
684                  return errorException(m, "Unable to allocate memory.", "InternalError");
685                }
686                size_t dwRead;
687                InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);
688                map* tmpMap=getMap(tmpmaps->content,"value");
689                if(tmpMap!=NULL)
690                  tmpMap->value=strdup(tmpContent);
691                free(tmpContent);
692              }
[1]693            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
694          }
695          tmpc=strtok(NULL,"@");
696        }
697#ifdef DEBUG
698        dumpMaps(tmpmaps);
699        fflush(stderr);
700#endif
[9]701        if(request_input_real_format==NULL)
702          request_input_real_format=dupMaps(&tmpmaps);
703        else
704          addMapsToMaps(&request_input_real_format,tmpmaps);
705        /*freeMap(&tmpmaps->content);
706        free(tmpmaps->content);
707        tmpmaps->content=NULL;*/
708        freeMaps(&tmpmaps);
709        free(tmpmaps);
710          //}
711        tmpmaps=NULL;
712        free(tmp);
[1]713      }
714    }
[9]715    free(inputs_as_text);
716  }
[1]717  else {
[9]718    /**
719     * Parse XML request
720     */ 
[1]721    xmlInitParser();
722#ifdef DEBUG
723    fflush(stderr);
724    fprintf(stderr,"BEFORE %s\n",postRequest->value);
725    fflush(stderr);
726#endif
727    xmlDocPtr doc =
[5]728      xmlParseMemory(postRequest->value,cgiContentLength);
[1]729#ifdef DEBUG
730    fprintf(stderr,"AFTER\n");
731    fflush(stderr);
732#endif
733    xmlNodePtr cur = xmlDocGetRootElement(doc);
734    /**
735     * Parse every Input in DataInputs node.
736     */
737    maps* tempMaps=NULL;
[9]738    xmlXPathObjectPtr tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='Input']");
739    xmlNodeSet* tmps=tmpsptr->nodesetval;
[1]740#ifdef DEBUG
741    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
742#endif
743    for(int k=0;k<tmps->nodeNr;k++){
744      maps *tmpmaps=NULL;
745      xmlNodePtr cur=tmps->nodeTab[k];
746      if(tmps->nodeTab[k]->type == XML_ELEMENT_NODE) {
747        /**
748         * A specific Input node.
749         */
750#ifdef DEBUG
751        fprintf(stderr, "= element 0 node \"%s\"\n", cur->name);
752#endif
[9]753        xmlNodePtr cur2=cur->children;
754        while(cur2){
755          while(cur2->type!=XML_ELEMENT_NODE)
756            cur2=cur2->next;
757          /**
758           * Indentifier
759           */
760          if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
761            xmlChar *val= xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
762            if(tmpmaps==NULL){
763              tmpmaps=(maps*)calloc(1,MAPS_SIZE);
764              if(tmpmaps == NULL){
765                return errorException(m, "Unable to allocate memory.", "InternalError");
[1]766              }
[9]767              tmpmaps->name=strdup((char*)val);
768              tmpmaps->content=NULL;
769              tmpmaps->next=NULL;
[1]770            }
[9]771            xmlFree(val);
772          }
773          /**
774           * Title, Asbtract
775           */
776          if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
777             xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
778            xmlChar *val=
779              xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
780            if(tmpmaps==NULL){
781              tmpmaps=(maps*)calloc(1,MAPS_SIZE);
782              if(tmpmaps == NULL){
783                return errorException(m, "Unable to allocate memory.", "InternalError");
[1]784              }
[9]785              tmpmaps->name="missingIndetifier";
786              tmpmaps->content=createMap((char*)cur2->name,(char*)val);
787              tmpmaps->next=NULL;
788            }
789            else{
790              if(tmpmaps->content!=NULL)
791                addToMap(tmpmaps->content,
792                         (char*)cur2->name,(char*)val);
793              else
794                tmpmaps->content=
795                  createMap((char*)cur2->name,(char*)val);
796            }
[1]797#ifdef DEBUG
[9]798            dumpMaps(tmpmaps);
[1]799#endif
[9]800            xmlFree(val);
801          }
802          /**
803           * InputDataFormChoice (Reference or Data ?)
804           */
805          if(xmlStrcasecmp(cur2->name,BAD_CAST "Reference")==0){
[1]806            /**
[9]807             * Get every attribute from a Reference node
808             * mimeType, encoding, schema, href, method
809             * Header and Body gesture should be added here
[1]810             */
811#ifdef DEBUG
[9]812            fprintf(stderr,"REFERENCE\n");
[1]813#endif
[9]814            map* referenceMap=NULL;
815            char *refs[5];
816            refs[0]="mimeType";
817            refs[1]="encoding";
818            refs[2]="schema";
819            refs[3]="method";
820            refs[4]="href";
821            char*url;
822            for(int l=0;l<5;l++){
[1]823#ifdef DEBUG
[9]824              fprintf(stderr,"*** %s ***",refs[l]);
[1]825#endif
[9]826              xmlChar *val=xmlGetProp(cur2,BAD_CAST refs[l]);
827              if(val!=NULL && xmlStrlen(val)>0){
828                if(tmpmaps->content!=NULL)
829                  addToMap(tmpmaps->content,refs[l],(char*)val);
830                else
831                  tmpmaps->content=createMap(refs[l],(char*)val);
832                map* ltmp=getMap(tmpmaps->content,"method");
833                if(l==4){
834                  if(!(ltmp!=NULL && strcmp(ltmp->value,"POST")==0)
835                     && CHECK_INET_HANDLE(hInternet)){
836                    res=InternetOpenUrl(hInternet,(char*)val,NULL,0,
837                                        INTERNET_FLAG_NO_CACHE_WRITE,0);
838                    char* tmpContent=
839                      (char*)calloc((res.nDataLen+1),sizeof(char));
840                    if(tmpContent == NULL){
841                      return errorException(m, "Unable to allocate memory.", "InternalError");
[1]842                    }
[9]843                    size_t dwRead;
844                    InternetReadFile(res, (LPVOID)tmpContent,
845                                     res.nDataLen, &dwRead);
846                    tmpContent[res.nDataLen]=0;
847                    addToMap(tmpmaps->content,"value",tmpContent);
[1]848                  }
849                }
[9]850              }
[1]851#ifdef DEBUG
[9]852              fprintf(stderr,"%s\n",val);
[1]853#endif
[9]854              xmlFree(val);
855            }
[1]856#ifdef POST_DEBUG
[9]857            fprintf(stderr,"Parse Header and Body from Reference \n");
[1]858#endif
[9]859            xmlNodePtr cur3=cur2->children;
860            hInternet.header=NULL;
861            while(cur3){
862              if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){
863                xmlNodePtr cur4=cur3;
864                char *tmp=new char[cgiContentLength];
865                char *ha[2];
866                ha[0]="key";
867                ha[1]="value";
868                int hai;
869                char *has;
870                char *key;
871                for(hai=0;hai<2;hai++){
872                  xmlChar *val=xmlGetProp(cur3,BAD_CAST ha[hai]);
[1]873#ifdef POST_DEBUG
[9]874                  fprintf(stderr,"%s = %s\n",ha[hai],(char*)val);
[1]875#endif
[9]876                  if(hai==0){
877                    key=(char*)calloc((1+strlen((char*)val)),sizeof(char));
878                    snprintf(key,1+strlen((char*)val),"%s",(char*)val);
879                  }else{
880                    has=(char*)calloc((3+strlen((char*)val)+strlen(key)),sizeof(char));
881                    if(has == NULL){
882                      return errorException(m, "Unable to allocate memory.", "InternalError");
883                    }
884                    snprintf(has,(3+strlen((char*)val)+strlen(key)),"%s: %s",key,(char*)val);
[1]885#ifdef POST_DEBUG
[9]886                    fprintf(stderr,"%s\n",has);
[1]887#endif
888                  }
889                }
[9]890                hInternet.header=curl_slist_append(hInternet.header, has);
891                //free(has);
892              }
893              else{
[1]894#ifdef POST_DEBUG
[9]895                fprintf(stderr,"Try to fetch the body part of the request ...\n");
[1]896#endif
[9]897                if(xmlStrcasecmp(cur3->name,BAD_CAST "Body")==0 ){
[1]898#ifdef POST_DEBUG
[9]899                  fprintf(stderr,"Body part found !!!\n",(char*)cur3->content);
[1]900#endif
[9]901                  char *tmp=new char[cgiContentLength];
902                  memset(tmp,0,cgiContentLength);
903                  xmlNodePtr cur4=cur3->children;
904                  while(cur4!=NULL){
905                    xmlDocPtr bdoc = xmlNewDoc(BAD_CAST "1.0");
906                    bdoc->encoding = xmlCharStrdup ("UTF-8");
907                    xmlDocSetRootElement(bdoc,cur4);
908                    xmlChar* btmps;
909                    int bsize;
910                    xmlDocDumpMemory(bdoc,&btmps,&bsize);
[1]911#ifdef POST_DEBUG
[9]912                    fprintf(stderr,"Body part found !!! %s %s\n",tmp,(char*)btmps);
[1]913#endif
[9]914                    if(btmps!=NULL)
915                      sprintf(tmp,"%s",(char*)btmps);
916                    xmlFreeDoc(bdoc);
917                    cur4=cur4->next;
918                  }
919                  map *btmp=getMap(tmpmaps->content,"href");
920                  if(btmp!=NULL){
921#ifdef POST_DEBUG
922                    fprintf(stderr,"%s %s\n",btmp->value,tmp);
923                    curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1);
924#endif
925                    res=InternetOpenUrl(hInternet,btmp->value,tmp,strlen(tmp),
926                                        INTERNET_FLAG_NO_CACHE_WRITE,0);
927                    char* tmpContent = (char*)calloc((res.nDataLen+1),sizeof(char));
928                    if(tmpContent == NULL){
929                      return errorException(m, "Unable to allocate memory.", "InternalError");
[1]930                    }
[9]931                    size_t dwRead;
932                    InternetReadFile(res, (LPVOID)tmpContent,
933                                     res.nDataLen, &dwRead);
934                    tmpContent[res.nDataLen]=0;
935                    if(hInternet.header!=NULL)
936                      curl_slist_free_all(hInternet.header);
937                    addToMap(tmpmaps->content,"value",tmpContent);
938#ifdef POST_DEBUG
939                    fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
940#endif
941                  }
942                }
943                else
944                  if(xmlStrcasecmp(cur3->name,BAD_CAST "BodyReference")==0 ){
945                    xmlChar *val=xmlGetProp(cur3,BAD_CAST "href");
946                    HINTERNET bInternet,res1;
947                    bInternet=InternetOpen(
948#ifndef WIN32
949                                           (LPCTSTR)
950#endif
951                                           "ZooWPSClient\0",
952                                           INTERNET_OPEN_TYPE_PRECONFIG,
953                                           NULL,NULL, 0);
954                    if(!CHECK_INET_HANDLE(bInternet))
955                      fprintf(stderr,"WARNING : hInternet handle failed to initialize");
956#ifdef POST_DEBUG
957                    curl_easy_setopt(bInternet.handle, CURLOPT_VERBOSE, 1);
958#endif
959                    res1=InternetOpenUrl(bInternet,(char*)val,NULL,0,
960                                         INTERNET_FLAG_NO_CACHE_WRITE,0);
961                    char* tmp=
962                      (char*)calloc((res1.nDataLen+1),sizeof(char));
963                    if(tmp == NULL){
964                      return errorException(m, "Unable to allocate memory.", "InternalError");
965                    }
966                    size_t bRead;
967                    InternetReadFile(res1, (LPVOID)tmp,
968                                     res1.nDataLen, &bRead);
969                    tmp[res1.nDataLen]=0;
970                    InternetCloseHandle(bInternet);
[1]971                    map *btmp=getMap(tmpmaps->content,"href");
972                    if(btmp!=NULL){
973#ifdef POST_DEBUG
974                      fprintf(stderr,"%s %s\n",btmp->value,tmp);
975                      curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1);
976#endif
[9]977                      res=InternetOpenUrl(hInternet,btmp->value,tmp,
978                                          strlen(tmp),
[1]979                                          INTERNET_FLAG_NO_CACHE_WRITE,0);
[9]980                      char* tmpContent = (char*)calloc((res.nDataLen+1),sizeof(char));
981                      if(tmpContent == NULL){
982                        return errorException(m, "Unable to allocate memory.", "InternalError");
983                      }
[1]984                      size_t dwRead;
985                      InternetReadFile(res, (LPVOID)tmpContent,
986                                       res.nDataLen, &dwRead);
987                      tmpContent[res.nDataLen]=0;
988                      if(hInternet.header!=NULL)
989                        curl_slist_free_all(hInternet.header);
990                      addToMap(tmpmaps->content,"value",tmpContent);
991#ifdef POST_DEBUG
992                      fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
993#endif
994                    }
995                  }
996              }
[9]997              cur3=cur3->next;
998            }
[1]999#ifdef POST_DEBUG
[9]1000            fprintf(stderr,"Header and Body was parsed from Reference \n");
[1]1001#endif
1002#ifdef DEBUG
[9]1003            dumpMap(tmpmaps->content);
1004            fprintf(stderr, "= element 2 node \"%s\" = (%s)\n", 
1005                    cur2->name,cur2->content);
[1]1006#endif
[9]1007          }
1008          else if(xmlStrcasecmp(cur2->name,BAD_CAST "Data")==0){
[1]1009#ifdef DEBUG
[9]1010            fprintf(stderr,"DATA\n");
[1]1011#endif
[9]1012            xmlNodePtr cur4=cur2->children;
1013            while(cur4){
1014              while(cur4->type!=XML_ELEMENT_NODE)
1015                cur4=cur4->next;
1016
1017              if(xmlStrcasecmp(cur4->name, BAD_CAST "LiteralData")==0){
1018                /**
1019                 * Get every attribute from a LiteralData node
1020                 * dataType , uom
1021                 */
1022                char *lits[2];
1023                lits[0]="dataType";
1024                lits[1]="uom";
1025                for(int l=0;l<2;l++){
[1]1026#ifdef DEBUG
[9]1027                  fprintf(stderr,"*** LiteralData %s ***",lits[l]);
[1]1028#endif
[9]1029                  xmlChar *val=xmlGetProp(cur4,BAD_CAST lits[l]);
1030                  if(val!=NULL && strlen((char*)val)>0){
1031                    if(tmpmaps->content!=NULL)
1032                      addToMap(tmpmaps->content,lits[l],(char*)val);
1033                    else
1034                      tmpmaps->content=createMap(lits[l],(char*)val);
1035                  }
[1]1036#ifdef DEBUG
[9]1037                  fprintf(stderr,"%s\n",val);
[1]1038#endif
[9]1039                  xmlFree(val);
[1]1040                }
[9]1041              }
1042              else if(xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0){
1043                /**
1044                 * Get every attribute from a Reference node
1045                 * mimeType, encoding, schema
1046                 */
1047                char *coms[3];
1048                coms[0]="mimeType";
1049                coms[1]="encoding";
1050                coms[2]="schema";
1051                for(int l=0;l<3;l++){
[1]1052#ifdef DEBUG
[9]1053                  fprintf(stderr,"*** ComplexData %s ***",coms[l]);
[1]1054#endif
[9]1055                  xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]);
1056                  if(val!=NULL && strlen((char*)val)>0){
1057                    if(tmpmaps->content!=NULL)
1058                      addToMap(tmpmaps->content,coms[l],(char*)val);
1059                    else
1060                      tmpmaps->content=createMap(coms[l],(char*)val);
1061                  }
[1]1062#ifdef DEBUG
[9]1063                  fprintf(stderr,"%s\n",val);
[1]1064#endif
[9]1065                  xmlFree(val);
[1]1066                }
1067              }
[9]1068              xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
1069              addToMap(tmpmaps->content,"value",(char*)mv);
1070              xmlFree(mv);
1071              cur4=cur4->next;
[1]1072            }
[9]1073          }
[1]1074#ifdef DEBUG
[9]1075          fprintf(stderr,"cur2 next \n");
1076          fflush(stderr);
[1]1077#endif
[9]1078          cur2=cur2->next;
1079        }
[1]1080#ifdef DEBUG
[9]1081        fprintf(stderr,"ADD MAPS TO REQUEST MAPS !\n");
1082        fflush(stderr);
[1]1083#endif
[9]1084        addMapsToMaps(&request_input_real_format,tmpmaps);
1085       
[1]1086#ifdef DEBUG
[9]1087        fprintf(stderr,"******TMPMAPS*****\n");
[1]1088        dumpMaps(tmpmaps);
[9]1089        fprintf(stderr,"******REQUESTMAPS*****\n");
1090        dumpMaps(request_input_real_format);
[1]1091#endif
1092        tmpmaps=tmpmaps->next;
1093             
1094      }
1095#ifdef DEBUG
1096      dumpMaps(tmpmaps); 
1097#endif
1098    }
1099#ifdef DEBUG
[9]1100    fprintf(stderr,"Search for response document node\n");
1101#endif
1102    xmlXPathFreeObject(tmpsptr);
1103    //xmlFree(tmps);
1104    tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='ResponseDocument']");
1105    tmps=tmpsptr->nodesetval;
1106#ifdef DEBUG
[1]1107    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
1108#endif
1109    for(int k=0;k<tmps->nodeNr;k++){
1110      addToMap(request_inputs,"ResponseDocument","");
1111      request_output_real_format;
1112      maps *tmpmaps=NULL;
1113      xmlNodePtr cur=tmps->nodeTab[k];
1114      if(cur->type == XML_ELEMENT_NODE) {
1115        /**
1116         * A specific responseDocument node.
1117         */
1118        if(tmpmaps==NULL){
[9]1119          tmpmaps=(maps*)calloc(1,MAPS_SIZE);
1120          if(tmpmaps == NULL){
1121            return errorException(m, "Unable to allocate memory.", "InternalError");
1122          }
[1]1123          tmpmaps->name="unknownIdentifier";
1124          tmpmaps->next=NULL;
1125        }
1126        /**
1127         * Get every attribute from a LiteralData node
1128         * storeExecuteResponse, lineage, status
1129         */
1130        char *ress[3];
1131        ress[0]="storeExecuteResponse";
1132        ress[1]="lineage";
1133        ress[2]="status";
1134        xmlChar *val;
1135        for(int l=0;l<3;l++){
1136#ifdef DEBUG
1137          fprintf(stderr,"*** %s ***\t",ress[l]);
1138#endif
1139          val=xmlGetProp(cur,BAD_CAST ress[l]);
1140          if(val!=NULL && strlen((char*)val)>0){
1141            if(tmpmaps->content!=NULL)
1142              addToMap(tmpmaps->content,ress[l],(char*)val);
1143            else
1144              tmpmaps->content=createMap(ress[l],(char*)val);
1145            addToMap(request_inputs,ress[l],(char*)val);
1146          }
1147#ifdef DEBUG
1148          fprintf(stderr,"%s\n",val);
1149#endif
1150          xmlFree(val);
1151        }
1152        xmlNodePtr cur1=cur->children;
1153        while(cur1){
[9]1154          if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
[1]1155            /**
1156             * Get every attribute from a Output node
1157             * mimeType, encoding, schema, uom, asReference
1158             */
1159            char *outs[5];
1160            outs[0]="mimeType";
1161            outs[1]="encoding";
1162            outs[2]="schema";
1163            outs[3]="uom";
1164            outs[4]="asReference";
1165            for(int l=0;l<5;l++){
1166#ifdef DEBUG
1167              fprintf(stderr,"*** %s ***\t",outs[l]);
1168#endif
1169              val=xmlGetProp(cur1,BAD_CAST outs[l]);
1170              if(val!=NULL && strlen((char*)val)>0){
1171                if(tmpmaps->content!=NULL)
1172                  addToMap(tmpmaps->content,outs[l],(char*)val);
1173                else
1174                  tmpmaps->content=createMap(outs[l],(char*)val);
1175              }
1176#ifdef DEBUG
1177              fprintf(stderr,"%s\n",val);
1178#endif
1179              xmlFree(val);
1180            }
1181           
1182            xmlNodePtr cur2=cur1->children;
1183            while(cur2){
1184              /**
1185               * Indentifier
1186               */
[9]1187              if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
[1]1188                xmlChar *val=
1189                  xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1190                if(tmpmaps==NULL){
[9]1191                  tmpmaps=(maps*)calloc(1,MAPS_SIZE);
1192                  if(tmpmaps == NULL){
1193                    return errorException(m, "Unable to allocate memory.", "InternalError");
1194                  }
[1]1195                  tmpmaps->name=strdup((char*)val);
1196                  tmpmaps->content=NULL;
1197                  tmpmaps->next=NULL;
1198                }
1199                else
1200                  tmpmaps->name=strdup((char*)val);;
1201                xmlFree(val);
1202              }
1203              /**
1204               * Title, Asbtract
1205               */
[9]1206              if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
1207                 xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
[1]1208                xmlChar *val=
1209                  xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1210                if(tmpmaps==NULL){
[9]1211                  tmpmaps=(maps*)calloc(1,MAPS_SIZE);
1212                  if(tmpmaps == NULL){
1213                    return errorException(m, "Unable to allocate memory.", "InternalError");
1214                  }
[1]1215                  tmpmaps->name="missingIndetifier";
1216                  tmpmaps->content=createMap((char*)cur2->name,(char*)val);
1217                  tmpmaps->next=NULL;
1218                }
1219                else{
1220                  if(tmpmaps->content!=NULL)
1221                    addToMap(tmpmaps->content,
1222                             (char*)cur2->name,(char*)val);
1223                  else
1224                    tmpmaps->content=
1225                      createMap((char*)cur2->name,(char*)val);
1226                }
1227                xmlFree(val);
1228              }
1229              cur2=cur2->next;
1230            }
1231          }
1232          cur1=cur1->next;
1233        }
1234      }
1235      //xmlFree(cur);
1236      if(request_output_real_format==NULL)
1237        request_output_real_format=tmpmaps;
1238      else
1239        addMapsToMaps(&request_output_real_format,tmpmaps);
1240#ifdef DEBUG
1241      dumpMaps(tmpmaps);
1242#endif
1243    }
[9]1244    xmlXPathFreeObject(tmpsptr);
1245    //xmlFree(tmps);
1246    tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='RawDataOutput']");
1247    tmps=tmpsptr->nodesetval;
[1]1248#ifdef DEBUG
1249    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
1250#endif
1251    for(int k=0;k<tmps->nodeNr;k++){
1252      addToMap(request_inputs,"RawDataOutput","");
1253      xmlNodePtr cur1=tmps->nodeTab[k];
1254      xmlChar *val;
1255      /**
1256       * Get every attribute from a Output node
1257       * mimeType, encoding, schema, uom, asReference
1258       */
1259      char *outs[4];
1260      outs[0]="mimeType";
1261      outs[1]="encoding";
1262      outs[2]="schema";
1263      outs[3]="uom";
1264      for(int l=0;l<4;l++){
1265#ifdef DEBUG
1266        fprintf(stderr,"*** %s ***\t",outs[l]);
1267#endif
1268        val=xmlGetProp(cur1,BAD_CAST outs[l]);
1269        if(val!=NULL && strlen((char*)val)>0){
1270          if(tmpmaps==NULL){
[9]1271            tmpmaps=(maps*)calloc(1,MAPS_SIZE);
1272            if(tmpmaps == NULL){
1273              return errorException(m, "Unable to allocate memory.", "InternalError");
1274            }
[1]1275            tmpmaps->name="unknownIdentifier";
1276            tmpmaps->content=createMap(outs[l],(char*)val);
1277            tmpmaps->next=NULL;
1278          }
1279          else
1280            addToMap(tmpmaps->content,outs[l],(char*)val);
1281        }
1282#ifdef DEBUG
1283        fprintf(stderr,"%s\n",val);
1284#endif
1285        xmlFree(val);
1286      }
1287           
1288      xmlNodePtr cur2=cur1->children;
1289      while(cur2){
1290        /**
1291         * Indentifier
1292         */
[9]1293        if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
[1]1294          val=
1295            xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1296          if(tmpmaps==NULL){
[9]1297            tmpmaps=(maps*)calloc(1,MAPS_SIZE);
1298            if(tmpmaps == NULL){
1299              return errorException(m, "Unable to allocate memory.", "InternalError");
1300            }
[1]1301            tmpmaps->name=strdup((char*)val);
1302            tmpmaps->content=NULL;
1303            tmpmaps->next=NULL;
1304          }
1305          else
1306            tmpmaps->name=strdup((char*)val);;
1307          xmlFree(val);
1308        }
1309        cur2=cur2->next;
1310      }
1311      if(request_output_real_format==NULL)
1312        request_output_real_format=tmpmaps;
1313      else
1314        addMapsToMaps(&request_output_real_format,tmpmaps);
1315#ifdef DEBUG
1316      dumpMaps(tmpmaps);
1317#endif
1318    }
[9]1319    xmlXPathFreeObject(tmpsptr);
1320    //xmlFree(tmps);
[1]1321    xmlCleanupParser();
1322  }
1323
[9]1324  //if(CHECK_INET_HANDLE(hInternet))
1325  InternetCloseHandle(hInternet);
[1]1326
1327#ifdef DEBUG
1328  fprintf(stderr,"\n%i\n",i);
1329  dumpMaps(request_input_real_format);
1330  dumpMaps(request_output_real_format);
[9]1331  dumpMap(request_inputs);
[1]1332#endif
1333
1334  /**
1335   * Ensure that each requested arguments are present in the request
1336   * DataInputs and ResponseDocument / RawDataOutput
[9]1337   */ 
1338  char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,"inputs");
1339  if(strcmp(dfv,"")!=0){
1340    char tmps[1024];
1341    snprintf(tmps,1024,"The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file.",dfv);
1342    map* tmpe=createMap("text",tmps);
1343    addToMap(tmpe,"code","MissingParameterValue");
1344    printExceptionReportResponse(m,tmpe);
1345    freeMap(&tmpe);
1346    free(tmpe);
1347    freeMaps(&m);
1348    free(m);
1349    free(REQUEST);
1350    freeMaps(&request_input_real_format);
1351    free(request_input_real_format);
1352    freeMaps(&request_output_real_format);
1353    free(request_output_real_format);
1354    freeMaps(&tmpmaps);
1355    free(tmpmaps);
1356    return 1;
1357  }
[1]1358  addDefaultValues(&request_output_real_format,s1->outputs,m,"outputs");
1359
[9]1360#ifdef DEBUG
1361  fprintf(stderr,"REQUEST_INPUTS\n");
1362  dumpMaps(request_input_real_format);
1363  fprintf(stderr,"REQUEST_OUTPUTS\n");
1364  dumpMaps(request_output_real_format);
1365#endif
[1]1366
1367  maps* curs=getMaps(m,"env");
1368  if(curs!=NULL){
1369    map* mapcs=curs->content;
1370    while(mapcs!=NULLMAP){
1371#ifndef WIN32
1372      setenv(mapcs->name,mapcs->value,1);
1373#else
1374#ifdef DEBUG
1375      fprintf(stderr,"[ZOO: setenv (%s=%s)]\n",mapcs->name,mapcs->value);
1376#endif
1377      if(mapcs->value[strlen(mapcs->value)-2]=='\r'){
1378#ifdef DEBUG
1379        fprintf(stderr,"[ZOO: Env var finish with \r]\n");
1380#endif
1381        mapcs->value[strlen(mapcs->value)-1]=0;
1382      }
1383#ifdef DEBUG
1384      fflush(stderr);
1385      fprintf(stderr,"setting variable... %s\n",
1386#endif
1387              SetEnvironmentVariable(mapcs->name,mapcs->value)
1388#ifdef DEBUG
1389              ? "OK" : "FAILED");
1390#else
1391      ;
1392#endif
1393#ifdef DEBUG
1394      fflush(stderr);
1395#endif
1396#endif
1397#ifdef DEBUG
1398      fprintf(stderr,"[ZOO: setenv (%s=%s)]\n",mapcs->name,mapcs->value);
1399      fflush(stderr);
1400#endif
1401      mapcs=mapcs->next;
1402    }
1403  }
1404 
1405#ifdef DEBUG
1406  dumpMap(request_inputs);
1407#endif
1408
1409  /**
1410   * Need to check if we need to fork to load a status enabled
1411   */
1412  r_inputs=NULL;
1413  r_inputs=getMap(request_inputs,"storeExecuteResponse");
1414  int eres=SERVICE_STARTED;
1415  int cpid=getpid();
1416#ifdef DEBUG
1417  dumpMap(request_inputs);
1418#endif
1419
[9]1420  if(r_inputs!=NULL)
1421    if(strcasecmp(r_inputs->value,"false")==0)
1422      r_inputs=NULL;
[1]1423  if(r_inputs==NULLMAP){
1424    /**
1425     * Extract serviceType to know what kind of service shoudl be loaded
1426     */
1427    r_inputs=NULL;
1428    r_inputs=getMap(s1->content,"serviceType");
1429#ifdef DEBUG
1430    fprintf(stderr,"LOAD A %s SERVICE PROVIDER IN NORMAL MODE \n",r_inputs->value);
1431    fflush(stderr);
1432#endif
[9]1433    if(strncasecmp(r_inputs->value,"C",1)==0){
[1]1434      r_inputs=getMap(request_inputs,"metapath");
[9]1435      if(r_inputs!=NULL)
1436        sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
1437      else
1438        sprintf(tmps1,"%s/",ntmp);
1439      char *altPath=strdup(tmps1);
[1]1440      r_inputs=getMap(s1->content,"ServiceProvider");
1441      sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
[9]1442      free(altPath);
[1]1443#ifdef DEBUG
1444      fprintf(stderr,"Trying to load %s\n",tmps1);
1445#endif
1446#ifdef WIN32
[9]1447      HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
[1]1448#else
1449      void* so = dlopen(tmps1, RTLD_LAZY);
1450#endif
[9]1451#ifdef DEBUG
[1]1452#ifdef WIN32
1453      DWORD errstr;
[9]1454      errstr = GetLastError();
1455      fprintf(stderr,"%s loaded (%d) \n",tmps1,errstr);
[1]1456#else
1457      char *errstr;
[9]1458      errstr = dlerror();
[1]1459#endif
[9]1460#endif
[1]1461
1462      if( so != NULL ) {
1463#ifdef DEBUG
1464        fprintf(stderr,"Library loaded %s \n",errstr);
1465        fprintf(stderr,"Service Shared Object = %s\n",r_inputs->value);
1466#endif
1467        r_inputs=getMap(s1->content,"serviceType");
1468#ifdef DEBUG
1469        dumpMap(r_inputs);
[9]1470        fprintf(stderr,"%s\n",r_inputs->value);
[1]1471        fflush(stderr);
1472#endif
[9]1473        if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
[1]1474#ifdef WIN32
1475          //Strange return value needed here !
1476          return 1;
1477#endif
1478          r_inputs=getMap(request_inputs,"Identifier");
1479          char fname[1024];
[9]1480          sprintf(fname,"%s_",r_inputs->value);
[1]1481#ifdef DEBUG
1482          fprintf(stderr,"Try to load function %s\n",fname);
1483#endif
1484#ifdef WIN32
1485          typedef int (CALLBACK* execute_t)(char***,char***,char***);
1486          execute_t execute=(execute_t)GetProcAddress(so,fname);
1487#else
1488          typedef int (*execute_t)(char***,char***,char***);
1489          execute_t execute=(execute_t)dlsym(so,fname);
1490#endif
1491#ifdef DEBUG
1492#ifdef WIN32
1493          errstr = GetLastError();
1494#else
1495          errstr = dlerror();
1496#endif
1497          fprintf(stderr,"Function loaded %s\n",errstr);
1498#endif 
[9]1499
[1]1500          char main_conf[10][30][1024];
1501          char inputs[10][30][1024];
1502          char outputs[10][30][1024];
1503          for(int i=0;i<10;i++){
1504            for(int j=0;j<30;j++){
1505              memset(main_conf[i][j],0,1024);
1506              memset(inputs[i][j],0,1024);
1507              memset(outputs[i][j],0,1024);
1508            }
1509          }
1510          mapsToCharXXX(m,(char***)main_conf);
1511          mapsToCharXXX(request_input_real_format,(char***)inputs);
1512          mapsToCharXXX(request_output_real_format,(char***)outputs);
1513          eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
1514#ifdef DEBUG
1515          fprintf(stderr,"Function run successfully \n");
1516#endif
1517          charxxxToMaps((char***)&outputs[0],&request_output_real_format);
1518        }else{
[9]1519#ifdef DEBUG
[2]1520#ifdef WIN32
[1]1521          errstr = GetLastError();
1522          fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
1523#endif
[2]1524#endif
[1]1525          r_inputs=getMap(request_inputs,"Identifier");
1526#ifdef DEBUG
1527          fprintf(stderr,"Try to load function %s\n",r_inputs->value);
1528#endif
1529          typedef int (*execute_t)(maps**,maps**,maps**);
1530#ifdef WIN32
1531          execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value); 
1532#ifdef DEBUG
1533          errstr = GetLastError();
1534          fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
1535#endif
1536#else
1537          execute_t execute=(execute_t)dlsym(so,r_inputs->value);
1538#endif
1539
1540#ifdef DEBUG
1541#ifdef WIN32
1542          errstr = GetLastError();
1543#else
1544          errstr = dlerror();
1545#endif
1546          fprintf(stderr,"Function loaded %s\n",errstr);
1547#endif 
1548
1549#ifdef DEBUG
1550          fprintf(stderr,"Now run the function \n");
1551          fflush(stderr);
1552#endif
1553          eres=execute(&m,&request_input_real_format,&request_output_real_format);
1554#ifdef DEBUG
1555          fprintf(stderr,"Function loaded and returned %d\n",eres);
1556          fflush(stderr);
1557#endif
1558        }
[5]1559        dlclose(so);
[1]1560      } else {
1561        /**
1562         * Unable to load the specified shared library
1563         */
1564        char tmps[1024];
[9]1565#ifdef WIN32
1566        DWORD errstr = GetLastError();
1567#else
1568        char* errstr = dlerror();
1569#endif
[1]1570        sprintf(tmps,"C Library can't be loaded %s \n",errstr);
1571        map* tmps1=createMap("text",tmps);
1572        printExceptionReportResponse(m,tmps1);
1573        exit(1);
1574      }
1575    }
1576    else{
[9]1577      if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
1578        eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1579      }
1580      else
1581       
1582#ifdef USE_JAVA
1583        if(strncasecmp(r_inputs->value,"JAVA",4)==0){
[1]1584          eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1585        }
1586        else
[9]1587#endif
[1]1588
[9]1589#ifdef USE_PHP
1590          if(strncasecmp(r_inputs->value,"PHP",3)==0){
[1]1591            eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1592          }
[9]1593          else
1594#endif
1595         
1596#ifdef USE_JS
1597            if(strncasecmp(r_inputs->value,"JS",2)==0){
[1]1598              eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1599            }
1600            else
[9]1601#endif
1602              {
1603                char tmpv[1024];
1604                sprintf(tmpv,"Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n",r_inputs->value);
1605                map* tmps=createMap("text",tmpv);
1606                printExceptionReportResponse(m,tmps);
1607                return(-1);
1608              }
[1]1609    }
1610  }
1611  else{
1612
1613    pid_t   pid;
1614#ifdef DEBUG
1615    fprintf(stderr,"\nPID : %d\n",cpid);
1616#endif
[9]1617
[1]1618#ifndef WIN32
[9]1619    pid = fork ();
[1]1620#else
[9]1621    pid = 0;
[1]1622#endif
1623    if (pid > 0) {
1624      /**
1625       * dady :
1626       * set status to SERVICE_ACCEPTED
1627       */
1628#ifdef DEBUG
1629      fprintf(stderr,"father pid continue (origin %d) %d ...\n",cpid,getpid());
1630#endif
1631      eres=SERVICE_ACCEPTED;
1632    }else if (pid == 0) {
1633      /**
1634       * son : have to close the stdout, stdin and stderr to let the parent
1635       * process answer to http client.
1636       */
1637      r_inputs=getMapFromMaps(m,"main","tmpPath");
[9]1638      map* r_inputs1=getMap(s1->content,"ServiceProvider");
1639      char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+16)*sizeof(char));
1640      sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid);
1641      char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+22)*sizeof(char));
1642      sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid);
1643      fprintf(stderr,"File to use as backup %s\n",fbkp);
[1]1644#ifdef DEBUG
1645      fprintf(stderr,"RUN IN BACKGROUND MODE \n");
1646      fprintf(stderr,"son pid continue (origin %d) %d ...\n",cpid,getpid());
[9]1647      fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value);
[1]1648#endif
[9]1649      freopen(fbkp , "w+", stdout);
[1]1650      fclose(stdin);
[9]1651      freopen(flog,"w+",stderr);
1652      free(fbkp);
1653      free(flog);
[1]1654      /**
1655       * set status to SERVICE_STARTED and flush stdout to ensure full
1656       * content was outputed (the file used to store the ResponseDocument).
1657       * The rewind stdout to restart writing from the bgining of the file,
1658       * this way the data will be updated at the end of the process run.
1659       */
[9]1660      printProcessResponse(m,request_inputs,cpid,
1661                            s1,r_inputs->value,SERVICE_STARTED,
[1]1662                            request_input_real_format,
1663                            request_output_real_format);
1664      fflush(stdout);
1665      rewind(stdout);
1666      /**
1667       * Extract serviceType to know what kind of service shoudl be loaded
1668       */
1669      r_inputs=NULL;
1670      r_inputs=getMap(s1->content,"serviceType");
1671#ifdef DEBUG
1672      fprintf(stderr,"LOAD A %s SERVICE PROVIDER IN BACKGROUND MODE \n",r_inputs->value);
1673#endif
1674
[9]1675      if(strncasecmp(r_inputs->value,"C",1)==0){
1676
[1]1677        r_inputs=getMap(request_inputs,"metapath");
[9]1678        if(r_inputs!=NULL){
1679          sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
1680          r_inputs=getMap(s1->content,"ServiceProvider");
1681          if(r_inputs!=NULL)
1682            sprintf(tmps1,"%s/%s",strdup(tmps1),r_inputs->value);
1683        }else{
1684          sprintf(tmps1,"%s/",ntmp);
1685        }
1686         
[1]1687 
1688#ifdef DEBUG
1689        fprintf(stderr,"Trying to load %s\n",tmps1);
1690#endif
1691#ifdef WIN32
[9]1692        HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
[1]1693#else
[9]1694        void* so = dlopen(tmps1, RTLD_LAZY);
[1]1695#endif
1696#ifdef WIN32
[9]1697        DWORD errstr;
1698        errstr = GetLastError();
[1]1699#else
[9]1700        char *errstr;
1701        errstr = dlerror();
[1]1702#endif
1703        if( so != NULL ) {
1704          r_inputs=getMap(s1->content,"serviceType");
1705#ifdef DEBUG
1706          fprintf(stderr,"r_inputs->value = %s\n",r_inputs->value);
1707#endif
[9]1708          if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
[1]1709            r_inputs=getMap(request_inputs,"Identifier");
1710#ifdef DEBUG
1711            fprintf(stderr,"Try to load function %s\n",r_inputs->value);
1712#endif
1713            typedef int (*execute_t)(char***,char***,char***);
1714            char fname[1024];
1715            sprintf(fname,"%s_",r_inputs->value);
1716#ifdef DEBUG
1717            fprintf(stderr,"Try to load function %s\n",fname);
1718#endif
1719#ifdef WIN32
[9]1720            execute_t execute=(execute_t)GetProcAddress(so,fname); 
[1]1721#else
[9]1722            execute_t execute=(execute_t)dlsym(so,fname);
[1]1723#endif
1724#ifdef DEBUG
1725#ifdef WIN32
[9]1726            errstr = GetLastError();
[1]1727#else
[9]1728            errstr = dlerror();
[1]1729#endif
1730#endif 
1731            char main_conf[10][10][1024];
1732            char inputs[10][10][1024];
1733            char outputs[10][10][1024];
1734            for(int i=0;i<10;i++){
1735              for(int j=0;j<10;j++){
1736                memset(main_conf[i][j],0,1024);
1737                memset(inputs[i][j],0,1024);
1738                memset(outputs[i][j],0,1024);
1739              }
1740            }
1741            mapsToCharXXX(m,(char***)main_conf);
1742            mapsToCharXXX(request_input_real_format,(char***)inputs);
1743            //mapsToCharXXX(request_output_real_format,(char***)outputs);
1744            eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
1745            charxxxToMaps((char***)&outputs[0],&request_output_real_format);
1746
1747          }else{
1748
1749            typedef int (*execute_t)(maps**,maps**,maps**);
1750#ifdef DEBUG
1751            fprintf(stderr,"Library loaded %s \n",errstr);
1752#endif
1753            r_inputs=getMap(request_inputs,"Identifier");
1754#ifdef DEBUG
1755            fprintf(stderr,"Try to load function %s\n",r_inputs->value);
1756#endif
1757#ifdef WIN32
[9]1758            execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value); 
[1]1759#else
[9]1760            execute_t execute=(execute_t)dlsym(so,r_inputs->value);
[1]1761#endif
1762#ifdef DEBUG
1763#ifdef WIN32
[9]1764            errstr = GetLastError();
[1]1765#else
[9]1766            errstr = dlerror();
[1]1767#endif
1768            fprintf(stderr,"Function loaded %s\n",errstr);
1769#endif 
1770            /**
1771             * set the status code value returned by the service function itself
1772             */
1773            eres=execute(&m,&request_input_real_format,&request_output_real_format);
1774          }
[9]1775          dlclose(so);
[1]1776        } else {
1777          /**
[5]1778           * Unable to load the requested C Library
[1]1779           */
1780          char tmps2[1024];
1781          sprintf(tmps1,"C Library can't be loaded %s \n",errstr);
1782          map* tmps=createMap("text",tmps1);
1783          printExceptionReportResponse(m,tmps);
[9]1784          freeMap(&tmps);
1785          free(tmps);
[1]1786          exit(1);
1787        }
1788      } else{
[9]1789        if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
[1]1790          eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1791        }
1792        else
1793
[9]1794#ifdef USE_JAVA
1795          if(strncasecmp(r_inputs->value,"JAVA",4)==0){
[1]1796            eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1797          }
1798          else
[9]1799#endif
1800           
1801#ifdef USE_PHP
1802            if(strncasecmp(r_inputs->value,"PHP",3)==0){
[1]1803              eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1804            }
1805            else
[9]1806#endif
1807             
1808#ifdef USE_JS
1809              if(strncasecmp(r_inputs->value,"JS",2)==0){
[1]1810                eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
1811              }
[9]1812              else
1813#endif
1814                {
1815                  char tmpv[1024];
1816                  sprintf(tmpv,"Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n",r_inputs->value);
1817                  map* tmps=createMap("text",tmpv);
1818                  printExceptionReportResponse(m,tmps);
1819                  return -1;
1820                }
[1]1821      }
1822 
1823      //res=execute(&m,&request_input_real_format,&request_output_real_format);
1824    } else {
1825      /**
1826       * error server don't accept the process need to output a valid
1827       * error response here !!!
1828       */
1829    }
1830       
1831  }
1832
1833#ifdef DEBUG
1834  dumpMaps(request_output_real_format);
[9]1835  fprintf(stderr,"Function loaded and returned %d\n",eres);
1836  fflush(stderr);
[1]1837#endif
[9]1838  if(eres!=-1)
1839    outputResponse(s1,request_input_real_format,
1840                   request_output_real_format,request_inputs,
1841                   cpid,m,eres);
[1]1842
[9]1843  freeService(&s1);
1844  free(s1);
1845  freeMaps(&m);
1846  free(m);
1847 
1848  freeMaps(&request_input_real_format);
1849  free(request_input_real_format);
[20]1850
[9]1851  /* The following is requested but get issue using with Python support :/ */
[20]1852  /*freeMaps(&request_output_real_format);
1853  free(request_output_real_format);*/
[9]1854 
1855  free(REQUEST);
1856  free(SERVICE_URL);
[1]1857#ifdef DEBUG
1858  fprintf(stderr,"Processed response \n");
1859  fflush(stdout);
1860  fflush(stderr);
1861#endif
1862
1863  return 0;
1864}
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