source: trunk/zoo-project/zoo-kernel/zoo_service_loader.c @ 390

Last change on this file since 390 was 390, checked in by djay, 11 years ago

Fix issue about reading session file when client send cookie not relative to the ZOO-Kernel.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 64.5 KB
RevLine 
[1]1/**
2 * Author : Gérald FENOY
3 *
[360]4 *  Copyright 2008-2012 GeoLabs SARL. All rights reserved.
[1]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
[376]30#include "cgic.h"
31
[1]32extern "C" {
33#include <libxml/tree.h>
34#include <libxml/xmlmemory.h>
35#include <libxml/parser.h>
36#include <libxml/xpath.h>
37#include <libxml/xpathInternals.h>
38}
39
40#include "ulinet.h"
41
[34]42#include <libintl.h>
43#include <locale.h>
[1]44#include <string.h>
45
46#include "service.h"
[34]47
[1]48#include "service_internal.h"
[33]49
50#ifdef USE_PYTHON
[1]51#include "service_internal_python.h"
[33]52#endif
[1]53
54#ifdef USE_JAVA
55#include "service_internal_java.h"
56#endif
57
58#ifdef USE_PHP
59#include "service_internal_php.h"
60#endif
61
62#ifdef USE_JS
63#include "service_internal_js.h"
64#endif
65
[25]66#ifdef USE_PERL
67#include "service_internal_perl.h"
68#endif
[1]69
70#include <dirent.h>
71#include <signal.h>
72#include <unistd.h>
73#ifndef WIN32
74#include <dlfcn.h>
75#include <libgen.h>
76#else
77#include <windows.h>
78#include <direct.h>
[364]79#include <sys/types.h>
80#include <sys/stat.h>
81#include <unistd.h>
82#define pid_t int;
[1]83#endif
84#include <fcntl.h>
85#include <time.h>
86#include <stdarg.h>
87
[364]88#ifdef WIN32
89extern "C" {
[370]90  __declspec(dllexport) char *strcasestr(char const *a, char const *b)
91#ifndef USE_MS
92 { 
93  char *x=_strdup(a); 
94  char *y=_strdup(b); 
95 
96  x=_strlwr(x); 
97  y=_strlwr(y); 
98  char *pos = strstr(x, y); 
99  char *ret = pos == NULL ? NULL : (char *)(a + (pos-x)); 
100  free(x); 
101  free(y); 
102  return ret; 
103 };
104#else
105  ;
106#endif
[364]107}
108#endif
109
[34]110#define _(String) dgettext ("zoo-kernel",String)
[376]111#define __(String) dgettext ("zoo-service",String)
[34]112
113
[109]114void translateChar(char* str,char toReplace,char toReplaceBy){
[34]115  int i=0,len=strlen(str);
116  for(i=0;i<len;i++){
117    if(str[i]==toReplace)
118      str[i]=toReplaceBy;
119  }
120}
121
[360]122/**
123 * Create (or append to) an array valued maps
124 * value = "["",""]"
125 */
126int appendMapsToMaps(maps* m,maps* mo,maps* mi,elements* elem){
[362]127  maps* tmpMaps=getMaps(mo,mi->name);
128  map* tmap=getMapType(tmpMaps->content);
129  elements* el=getElements(elem,mi->name);
130  int hasEl=1;
131  if(el==NULL)
132    hasEl=-1;
[360]133  if(tmap==NULL){
[362]134    if(hasEl>0)
135      tmap=getMapType(el->defaults->content);     
[360]136  }
137
[362]138  map* testMap=NULL;
139  if(hasEl>0){
140    testMap=getMap(el->content,"maxOccurs");
141  }else{
142    testMap=createMap("maxOccurs","unbounded");
143  }
144
[360]145  if(testMap!=NULL){
146    if(strncasecmp(testMap->value,"unbounded",9)!=0 && atoi(testMap->value)>1){
147      if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
148        char emsg[1024];
149        sprintf(emsg,_("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."),mi->name,atoi(testMap->value));
150        errorException(m,emsg,"InternalError");
151        return -1;
152      }
153    }else{
154      if(strncasecmp(testMap->value,"unbounded",9)==0){
[362]155        if(hasEl<0){
156          freeMap(&testMap);
157          free(testMap);
158        }
[360]159        if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
160          char emsg[1024];
161          map* tmpMap=getMap(mi->content,"length");
162          sprintf(emsg,_("ZOO-Kernel was unable to load your data for %s position %s."),mi->name,tmpMap->value);
163          errorException(m,emsg,"InternalError");
164          return -1;
165        }
166      }
167      else{
168        char emsg[1024];
169        sprintf(emsg,_("You set maximum occurences for <%s> to one but you tried to use it more than once. Please correct your ZCFG file or your request."),mi->name);
170        errorException(m,emsg,"InternalError");
171        return -1;
172      }
173    }
174  }
175  return 0;
176}
177
[114]178xmlXPathObjectPtr extractFromDoc(xmlDocPtr doc,const char* search){
[1]179  xmlXPathContextPtr xpathCtx;
180  xmlXPathObjectPtr xpathObj;
181  xpathCtx = xmlXPathNewContext(doc);
182  xpathObj = xmlXPathEvalExpression(BAD_CAST search,xpathCtx);
[9]183  xmlXPathFreeContext(xpathCtx);
184  return xpathObj;
[1]185}
186
[105]187void donothing(int sig){
188  fprintf(stderr,"Signal %d after the ZOO-Kernel returned result !\n",sig);
189  exit(0);
190}
191
[9]192void sig_handler(int sig){
193  char tmp[100];
[114]194  const char *ssig;
[9]195  switch(sig){
196  case SIGSEGV:
197    ssig="SIGSEGV";
198    break;
199  case SIGTERM:
200    ssig="SIGTERM";
201    break;
202  case SIGINT:
203    ssig="SIGINT";
204    break;
205  case SIGILL:
206    ssig="SIGILL";
207    break;
208  case SIGFPE:
209    ssig="SIGFPE";
210    break;
211  case SIGABRT:
212    ssig="SIGABRT";
213    break;
214  default:
215    ssig="UNKNOWN";
216    break;
217  }
[34]218  sprintf(tmp,_("ZOO Kernel failed to process your request receiving signal %d = %s"),sig,ssig);
[9]219  errorException(NULL, tmp, "InternalError");
[10]220#ifdef DEBUG
[1]221  fprintf(stderr,"Not this time!\n");
[10]222#endif
[9]223  exit(0);
[1]224}
225
[109]226void loadServiceAndRun(maps **myMap,service* s1,map* request_inputs,maps **inputs,maps** ioutputs,int* eres){
[34]227  char tmps1[1024];
228  char ntmp[1024];
229  maps *m=*myMap;
230  maps *request_output_real_format=*ioutputs;
231  maps *request_input_real_format=*inputs;
232  /**
233   * Extract serviceType to know what kind of service should be loaded
234   */
235  map* r_inputs=NULL;
236#ifndef WIN32
[114]237  char* pntmp=getcwd(ntmp,1024);
[34]238#else
239  _getcwd(ntmp,1024);
240#endif
241  r_inputs=getMap(s1->content,"serviceType");
242#ifdef DEBUG
243  fprintf(stderr,"LOAD A %s SERVICE PROVIDER \n",r_inputs->value);
244  fflush(stderr);
245#endif
[364]246  if(strlen(r_inputs->value)==1 && strncasecmp(r_inputs->value,"C",1)==0){
[34]247    r_inputs=getMap(request_inputs,"metapath");
248    if(r_inputs!=NULL)
249      sprintf(tmps1,"%s/%s",ntmp,r_inputs->value);
250    else
251      sprintf(tmps1,"%s/",ntmp);
252    char *altPath=strdup(tmps1);
253    r_inputs=getMap(s1->content,"ServiceProvider");
254    sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
255    free(altPath);
256#ifdef DEBUG
257    fprintf(stderr,"Trying to load %s\n",tmps1);
258#endif
259#ifdef WIN32
260    HINSTANCE so = LoadLibraryEx(tmps1,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
261#else
262    void* so = dlopen(tmps1, RTLD_LAZY);
263#endif
264#ifdef DEBUG
[57]265#ifdef WIN32
[34]266    DWORD errstr;
267    errstr = GetLastError();
268    fprintf(stderr,"%s loaded (%d) \n",tmps1,errstr);
269#else
270    char *errstr;
271    errstr = dlerror();
272#endif
273#endif
274
275    if( so != NULL ) {
276#ifdef DEBUG
277      fprintf(stderr,"Library loaded %s \n",errstr);
278      fprintf(stderr,"Service Shared Object = %s\n",r_inputs->value);
279#endif
280      r_inputs=getMap(s1->content,"serviceType");
281#ifdef DEBUG
282      dumpMap(r_inputs);
283      fprintf(stderr,"%s\n",r_inputs->value);
284      fflush(stderr);
285#endif
286      if(strncasecmp(r_inputs->value,"C-FORTRAN",9)==0){
287        r_inputs=getMap(request_inputs,"Identifier");
288        char fname[1024];
289        sprintf(fname,"%s_",r_inputs->value);
290#ifdef DEBUG
291        fprintf(stderr,"Try to load function %s\n",fname);
292#endif
293#ifdef WIN32
294        typedef int (CALLBACK* execute_t)(char***,char***,char***);
295        execute_t execute=(execute_t)GetProcAddress(so,fname);
296#else
297        typedef int (*execute_t)(char***,char***,char***);
298        execute_t execute=(execute_t)dlsym(so,fname);
299#endif
300#ifdef DEBUG
301#ifdef WIN32
302        errstr = GetLastError();
303#else
304        errstr = dlerror();
305#endif
306        fprintf(stderr,"Function loaded %s\n",errstr);
307#endif 
308
309        char main_conf[10][30][1024];
310        char inputs[10][30][1024];
311        char outputs[10][30][1024];
312        for(int i=0;i<10;i++){
313          for(int j=0;j<30;j++){
314            memset(main_conf[i][j],0,1024);
315            memset(inputs[i][j],0,1024);
316            memset(outputs[i][j],0,1024);
317          }
318        }
319        mapsToCharXXX(m,(char***)main_conf);
320        mapsToCharXXX(request_input_real_format,(char***)inputs);
321        mapsToCharXXX(request_output_real_format,(char***)outputs);
322        *eres=execute((char***)&main_conf[0],(char***)&inputs[0],(char***)&outputs[0]);
323#ifdef DEBUG
324        fprintf(stderr,"Function run successfully \n");
325#endif
326        charxxxToMaps((char***)&outputs[0],&request_output_real_format);
327      }else{
328#ifdef DEBUG
329#ifdef WIN32
330        errstr = GetLastError();
331        fprintf(stderr,"Function %s failed to load because of %d\n",r_inputs->value,errstr);
332#endif
333#endif
334        r_inputs=getMap(request_inputs,"Identifier");
335#ifdef DEBUG
336        fprintf(stderr,"Try to load function %s\n",r_inputs->value);
337#endif
338        typedef int (*execute_t)(maps**,maps**,maps**);
339#ifdef WIN32
340        execute_t execute=(execute_t)GetProcAddress(so,r_inputs->value); 
341#else
342        execute_t execute=(execute_t)dlsym(so,r_inputs->value);
343#endif
344
345#ifdef DEBUG
346#ifdef WIN32
347        errstr = GetLastError();
348#else
349        errstr = dlerror();
350#endif
351        fprintf(stderr,"Function loaded %s\n",errstr);
352#endif 
353
354#ifdef DEBUG
355        fprintf(stderr,"Now run the function \n");
356        fflush(stderr);
357#endif
358        *eres=execute(&m,&request_input_real_format,&request_output_real_format);
359#ifdef DEBUG
360        fprintf(stderr,"Function loaded and returned %d\n",eres);
361        fflush(stderr);
362#endif
363      }
[216]364#ifdef WIN32
365      *ioutputs=dupMaps(&request_output_real_format);
366      FreeLibrary(so);
367#else
[34]368      dlclose(so);
[216]369#endif
[34]370    } else {
371      /**
372       * Unable to load the specified shared library
373       */
374      char tmps[1024];
375#ifdef WIN32
376      DWORD errstr = GetLastError();
377#else
378      char* errstr = dlerror();
379#endif
380      sprintf(tmps,_("C Library can't be loaded %s \n"),errstr);
381      map* tmps1=createMap("text",tmps);
382      printExceptionReportResponse(m,tmps1);
383      *eres=-1;
384    }
385  }
386  else
387#ifdef USE_PYTHON
388    if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
389      *eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
390    }
391    else
392#endif
393       
394#ifdef USE_JAVA
395      if(strncasecmp(r_inputs->value,"JAVA",4)==0){
396        *eres=zoo_java_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
397      }
398      else
399#endif
400
401#ifdef USE_PHP
402        if(strncasecmp(r_inputs->value,"PHP",3)==0){
403          *eres=zoo_php_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
404        }
405        else
406#endif
407           
408           
409#ifdef USE_PERL
410          if(strncasecmp(r_inputs->value,"PERL",4)==0){
411            *eres=zoo_perl_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
412          }
413          else
414#endif
415
416#ifdef USE_JS
417            if(strncasecmp(r_inputs->value,"JS",2)==0){
418              *eres=zoo_js_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
419            }
420            else
421#endif
422              {
423                char tmpv[1024];
424                sprintf(tmpv,_("Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n"),r_inputs->value);
425                map* tmps=createMap("text",tmpv);
426                printExceptionReportResponse(m,tmps);
427                *eres=-1;
428              }
[57]429  *myMap=m;
[34]430  *ioutputs=request_output_real_format;
431}
432
[384]433
[216]434#ifdef WIN32
435/**
436 * createProcess function: create a new process after setting some env variables
437 */
438void createProcess(maps* m,map* request_inputs,service* s1,char* opts,int cpid, maps* inputs,maps* outputs){
439  STARTUPINFO si;
440  PROCESS_INFORMATION pi;
441  ZeroMemory( &si, sizeof(si) );
442  si.cb = sizeof(si);
443  ZeroMemory( &pi, sizeof(pi) );
444  char *tmp=(char *)malloc((1024+cgiContentLength)*sizeof(char));
445  char *tmpq=(char *)malloc((1024+cgiContentLength)*sizeof(char));
446  map *req=getMap(request_inputs,"request");
447  map *id=getMap(request_inputs,"identifier");
448  map *di=getMap(request_inputs,"DataInputs");
449
450  char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0);
451  char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1);
[384]452#ifdef DEBUG
[216]453  fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP);
454  fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP);
[384]455#endif
[216]456  map *sid=getMapFromMaps(m,"lenv","sid");
457  map* r_inputs=getMapFromMaps(m,"main","tmpPath");
[384]458  map* r_inputs1=getMap(request_inputs,"metapath");
459  int hasIn=-1;
460  if(r_inputs1==NULL){
461    r_inputs1=createMap("metapath","");
462    hasIn=1;
463  }
[216]464  map* r_inputs2=getMap(s1->content,"ResponseDocument");
465  if(r_inputs2==NULL)
466    r_inputs2=getMap(s1->content,"RawDataOutput");
467  map *tmpPath=getMapFromMaps(m,"lenv","cwd");
468
469  if(r_inputs2!=NULL){
[384]470    sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);
471    sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);
[216]472  }
473  else{
[384]474    sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value);
475    sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value);
[216]476  }
[384]477 
478  if(hasIn>0){
479    freeMap(&r_inputs1);
480    free(r_inputs1);
481  }
[216]482  char *tmp1=strdup(tmp);
483  sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
[384]484 
[216]485  free(dataInputsKVP);
486  free(dataOutputsKVP);
[384]487  //printf("REQUEST IS : %s \n",tmp);
488#ifdef DEBUG
[216]489  fprintf(stderr,"REQUEST IS : %s \n",tmp);
[384]490#endif
[216]491  SetEnvironmentVariable("CGISID",TEXT(sid->value));
492  SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq));
493  char clen[1000];
494  sprintf(clen,"%d",strlen(tmpq));
495  SetEnvironmentVariable("CONTENT_LENGTH",TEXT(clen));
496
497  if( !CreateProcess( NULL,             // No module name (use command line)
498                      TEXT(tmp),        // Command line
499                      NULL,             // Process handle not inheritable
500                      NULL,             // Thread handle not inheritable
501                      FALSE,            // Set handle inheritance to FALSE
502                      CREATE_NO_WINDOW, // Apache won't wait until the end
503                      NULL,             // Use parent's environment block
504                      NULL,             // Use parent's starting directory
505                      &si,              // Pointer to STARTUPINFO struct
506                      &pi )             // Pointer to PROCESS_INFORMATION struct
507      ) 
508    { 
[384]509      //printf("CreateProcess failed (%d).\n",GetLastError() );
510#ifdef DEBUG
[216]511      fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() );
[384]512#endif
[216]513      return ;
514    }else{
[384]515    //printf("CreateProcess successfull (%d).\n",GetLastError() );
516#ifdef DEBUG
[216]517    fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() );
[384]518#endif
[216]519  }
520  CloseHandle( pi.hProcess );
521  CloseHandle( pi.hThread );
[384]522  //printf("CreateProcess finished !\n");
523#ifdef DEBUG
[216]524  fprintf(stderr,"CreateProcess finished !\n");
[384]525#endif
[216]526}
527#endif
528
[1]529int runRequest(map* request_inputs)
530{
531
[53]532#ifndef USE_GDB
[9]533  (void) signal(SIGSEGV,sig_handler);
534  (void) signal(SIGTERM,sig_handler);
535  (void) signal(SIGINT,sig_handler);
536  (void) signal(SIGILL,sig_handler);
537  (void) signal(SIGFPE,sig_handler);
538  (void) signal(SIGABRT,sig_handler);
[53]539#endif
[9]540
[114]541  map* r_inputs=NULL;
[1]542  maps* m=NULL;
543
544  char* REQUEST=NULL;
545  /**
546   * Parsing service specfic configuration file
547   */
[381]548  m=(maps*)malloc(MAPS_SIZE);
[9]549  if(m == NULL){
[34]550    return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]551  }
[1]552  char ntmp[1024];
553#ifndef WIN32
[114]554  char *pntmp=getcwd(ntmp,1024);
[1]555#else
556  _getcwd(ntmp,1024);
557#endif
[282]558  r_inputs=getMapOrFill(request_inputs,"metapath","");
559
[381]560
[9]561  char conf_file[10240];
562  snprintf(conf_file,10240,"%s/%s/main.cfg",ntmp,r_inputs->value);
[385]563  if(conf_read(conf_file,m)==2){
564    errorException(NULL, _("Unable to load the main.cfg file."),"InternalError");
565    free(m);
566    return 1;
567  }
[9]568#ifdef DEBUG
569  fprintf(stderr, "***** BEGIN MAPS\n"); 
570  dumpMaps(m);
571  fprintf(stderr, "***** END MAPS\n");
572#endif
573
[376]574  map *getPath=getMapFromMaps(m,"main","gettextPath");
575  if(getPath!=NULL){
576    bindtextdomain ("zoo-kernel",getPath->value);
577    bindtextdomain ("zoo-services",getPath->value);   
578  }else{
579    bindtextdomain ("zoo-kernel","/usr/share/locale/");
580    bindtextdomain ("zoo-services","/usr/share/locale/");
581  }
[364]582
[381]583
[364]584  /**
585   * Manage our own error log file (usefull to separate standard apache debug
586   * messages from the ZOO-Kernel ones but also for IIS users to avoid wrong
587   * headers messages returned by the CGI due to wrong redirection of stderr)
588   */
589  FILE * fstde=NULL;
590  map* fstdem=getMapFromMaps(m,"main","logPath");
591  if(fstdem!=NULL)
592        fstde = freopen(fstdem->value, "a+", stderr) ;
593
[376]594  r_inputs=getMap(request_inputs,"language");
595  if(r_inputs==NULL)
596    r_inputs=getMapFromMaps(m,"main","language");
597  if(r_inputs!=NULL){
[34]598    char *tmp=strdup(r_inputs->value);
[376]599    setMapInMaps(m,"main","language",tmp);
[34]600    translateChar(tmp,'-','_');
601    setlocale (LC_ALL, tmp);
[376]602#ifdef WIN32
603    char tmp1[12];
604    sprintf(tmp1,"LC_ALL=%s",tmp);
605    putenv(tmp1);
606#endif
[34]607    free(tmp);
608  }
609  else{
610    setlocale (LC_ALL, "en_US");
[376]611#ifdef WIN32
612    char tmp1[12];
613    sprintf(tmp1,"LC_ALL=en_US");
614    putenv(tmp1);
615#endif
[34]616    setMapInMaps(m,"main","language","en-US");
617  }
618  setlocale (LC_NUMERIC, "en_US");
619  bind_textdomain_codeset("zoo-kernel","UTF-8");
620  textdomain("zoo-kernel");
621  bind_textdomain_codeset("zoo-services","UTF-8");
622  textdomain("zoo-services");
623
[280]624  map* lsoap=getMap(request_inputs,"soap");
625  if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0)
626    setMapInMaps(m,"main","isSoap","true");
627  else
628    setMapInMaps(m,"main","isSoap","false");
[34]629
[381]630
[1]631  /**
632   * Check for minimum inputs
633   */
634  r_inputs=getMap(request_inputs,"Request");
[9]635  if(request_inputs==NULL || r_inputs==NULL){ 
[34]636    errorException(m, _("Parameter <request> was not specified"),"MissingParameterValue");
[9]637    freeMaps(&m);
638    free(m);
[60]639    freeMap(&request_inputs);
640    free(request_inputs);
[1]641    return 1;
642  }
[9]643  else{
[1]644    REQUEST=strdup(r_inputs->value);
[9]645    if(strncasecmp(r_inputs->value,"GetCapabilities",15)!=0
646       && strncasecmp(r_inputs->value,"DescribeProcess",15)!=0
647       && strncasecmp(r_inputs->value,"Execute",7)!=0){ 
[34]648      errorException(m, _("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."), "InvalidParameterValue");
[9]649      freeMaps(&m);
650      free(m);
651      free(REQUEST);
652      return 1;
653    }
654  }
[1]655  r_inputs=NULL;
656  r_inputs=getMap(request_inputs,"Service");
[9]657  if(r_inputs==NULLMAP){
[34]658    errorException(m, _("Parameter <service> was not specified"),"MissingParameterValue");
[9]659    freeMaps(&m);
660    free(m);
661    free(REQUEST);
[1]662    return 1;
663  }
[9]664  if(strncasecmp(REQUEST,"GetCapabilities",15)!=0){
[1]665    r_inputs=getMap(request_inputs,"Version");
666    if(r_inputs==NULL){ 
[34]667      errorException(m, _("Parameter <version> was not specified"),"MissingParameterValue");
[9]668      freeMaps(&m);
669      free(m);
670      free(REQUEST);
[1]671      return 1;
672    }
673  }
674
[9]675  r_inputs=getMap(request_inputs,"serviceprovider");
676  if(r_inputs==NULL){
677    addToMap(request_inputs,"serviceprovider","");
[1]678  }
679
680  maps* request_output_real_format=NULL;
681  map* tmpm=getMapFromMaps(m,"main","serverAddress");
682  if(tmpm!=NULL)
683    SERVICE_URL=strdup(tmpm->value);
684  else
[63]685    SERVICE_URL=strdup(DEFAULT_SERVICE_URL);
[1]686
687  service* s1;
688  int scount=0;
689#ifdef DEBUG
690  dumpMap(r_inputs);
691#endif
692  char conf_dir[1024];
693  int t;
694  char tmps1[1024];
695
[9]696  r_inputs=NULL;
697  r_inputs=getMap(request_inputs,"metapath");
698  if(r_inputs!=NULL)
699    snprintf(conf_dir,1024,"%s/%s",ntmp,r_inputs->value);
700  else
701    snprintf(conf_dir,1024,"%s",ntmp);
702
703  if(strncasecmp(REQUEST,"GetCapabilities",15)==0){
[1]704    struct dirent *dp;
705#ifdef DEBUG
706    dumpMap(r_inputs);
707#endif
[9]708    DIR *dirp = opendir(conf_dir);
[1]709    if(dirp==NULL){
[34]710      return errorException(m, _("The specified path doesn't exist."),"InvalidParameterValue");
[1]711    }
712    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
713    r_inputs=NULL;
714    r_inputs=getMap(request_inputs,"ServiceProvider");
[9]715    xmlNodePtr n;
716    if(r_inputs!=NULL)
717      n = printGetCapabilitiesHeader(doc,r_inputs->value,m);
718    else
719      n = printGetCapabilitiesHeader(doc,"",m);
[1]720    /**
[214]721     * Here we need to close stdout to ensure that not supported chars
722     * has been found in the zcfg and then printed on stdout
[1]723     */
724    int saved_stdout = dup(fileno(stdout));
725    dup2(fileno(stderr),fileno(stdout));
726    while ((dp = readdir(dirp)) != NULL)
727      if(strstr(dp->d_name,".zcfg")!=0){
[9]728        memset(tmps1,0,1024);
729        snprintf(tmps1,1024,"%s/%s",conf_dir,dp->d_name);
[381]730        s1=(service*)malloc(SERVICE_SIZE);
[9]731        if(s1 == NULL){ 
[34]732          return errorException(m, _("Unable to allocate memory."),"InternalError");
[9]733        }
[1]734#ifdef DEBUG
735        fprintf(stderr,"#################\n%s\n#################\n",tmps1);
736#endif
737        t=getServiceFromFile(tmps1,&s1);
738#ifdef DEBUG
739        dumpService(s1);
740        fflush(stdout);
741        fflush(stderr);
742#endif
743        printGetCapabilitiesForProcess(m,n,s1);
[9]744        freeService(&s1);
745        free(s1);
[1]746        scount++;
747      }
748    (void)closedir(dirp);
749    fflush(stdout);
750    dup2(saved_stdout,fileno(stdout));
[9]751    printDocument(m,doc,getpid());
752    freeMaps(&m);
753    free(m);
754    free(REQUEST);
755    free(SERVICE_URL);
[1]756    fflush(stdout);
757    return 0;
758  }
759  else{
760    r_inputs=getMap(request_inputs,"Identifier");
761    if(r_inputs==NULL 
762       || strlen(r_inputs->name)==0 || strlen(r_inputs->value)==0){ 
[34]763      errorException(m, _("Mandatory <identifier> was not specified"),"MissingParameterValue");
[9]764      freeMaps(&m);
765      free(m);
766      free(REQUEST);
767      free(SERVICE_URL);
768      return 0;
[1]769    }
770
771    struct dirent *dp;
772    DIR *dirp = opendir(conf_dir);
773    if(dirp==NULL){
[34]774      errorException(m, _("The specified path path doesn't exist."),"InvalidParameterValue");
[9]775      freeMaps(&m);
776      free(m);
777      free(REQUEST);
778      free(SERVICE_URL);
779      return 0;
[1]780    }
[9]781    if(strncasecmp(REQUEST,"DescribeProcess",15)==0){
[1]782      /**
783       * Loop over Identifier list
784       */
785      xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
786      r_inputs=NULL;
787      r_inputs=getMap(request_inputs,"ServiceProvider");
[9]788
[1]789      xmlNodePtr n;
790      if(r_inputs!=NULL)
791        n = printDescribeProcessHeader(doc,r_inputs->value,m);
[9]792      else
793        n = printDescribeProcessHeader(doc,"",m);
[1]794
795      r_inputs=getMap(request_inputs,"Identifier");
796      char *tmps=strtok(r_inputs->value,",");
797     
798      char buff[256];
799      char buff1[1024];
800      int saved_stdout = dup(fileno(stdout));
801      dup2(fileno(stderr),fileno(stdout));
802      while(tmps){
803        memset(buff,0,256);
[9]804        snprintf(buff,256,"%s.zcfg",tmps);
[1]805        memset(buff1,0,1024);
806#ifdef DEBUG
[379]807        printf("\n#######%s\n########\n",buff1);
[1]808#endif
809        while ((dp = readdir(dirp)) != NULL)
[260]810          if((strcasecmp("all.zcfg",buff)==0 && strstr(dp->d_name,".zcfg")>0)
811             || strcasecmp(dp->d_name,buff)==0){
[1]812            memset(buff1,0,1024);
[9]813            snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name);
[381]814            s1=(service*)malloc(SERVICE_SIZE);
[9]815            if(s1 == NULL){
[379]816              dup2(saved_stdout,fileno(stdout));
[34]817              return errorException(m, _("Unable to allocate memory."),"InternalError");
[9]818            }
[1]819#ifdef DEBUG
[379]820            printf("#################\n%s\n#################\n",buff1);
[1]821#endif
822            t=getServiceFromFile(buff1,&s1);
[9]823#ifdef DEBUG
824            dumpService(s1);
825#endif
826            printDescribeProcessForProcess(m,n,s1,1);
827            freeService(&s1);
828            free(s1);
[1]829            scount++;
830          }
831        rewinddir(dirp);
832        tmps=strtok(NULL,",");
833      }
[9]834      closedir(dirp);
[1]835      fflush(stdout);
836      dup2(saved_stdout,fileno(stdout));
[9]837      printDocument(m,doc,getpid());
838      freeMaps(&m);
839      free(m);
840      free(REQUEST);
841      free(SERVICE_URL);
[1]842      fflush(stdout);
843      return 0;
844    }
845    else
[9]846      if(strncasecmp(REQUEST,"Execute",strlen(REQUEST))!=0){
[34]847        errorException(m, _("Unenderstood <request> value. Please check that it was set to GetCapabilities, DescribeProcess or Execute."), "InvalidParameterValue");
[1]848#ifdef DEBUG
849        fprintf(stderr,"No request found %s",REQUEST);
850#endif 
[9]851        closedir(dirp);
[385]852        freeMaps(&m);
853        free(m);
854        free(REQUEST);
855        free(SERVICE_URL);
856        fflush(stdout);
[1]857        return 0;
858      }
[9]859    closedir(dirp);
[1]860  }
861 
862  s1=NULL;
[381]863  s1=(service*)malloc(SERVICE_SIZE);
[9]864  if(s1 == NULL){
[32]865    freeMaps(&m);
866    free(m);
867    free(REQUEST);
868    free(SERVICE_URL);
[34]869    return errorException(m, _("Unable to allocate memory."),"InternalError");
[9]870  }
[1]871  r_inputs=getMap(request_inputs,"MetaPath");
[9]872  if(r_inputs!=NULL)
873    snprintf(tmps1,1024,"%s/%s",ntmp,r_inputs->value);
874  else
875    snprintf(tmps1,1024,"%s/",ntmp);
[1]876  r_inputs=getMap(request_inputs,"Identifier");
[9]877  char *ttmp=strdup(tmps1);
878  snprintf(tmps1,1024,"%s/%s.zcfg",ttmp,r_inputs->value);
879  free(ttmp);
[1]880#ifdef DEBUG
881  fprintf(stderr,"Trying to load %s\n", tmps1);
882#endif
883  int saved_stdout = dup(fileno(stdout));
[331]884  dup2(fileno(stderr),fileno(stdout));
[1]885  t=getServiceFromFile(tmps1,&s1);
886  fflush(stdout);
887  dup2(saved_stdout,fileno(stdout));
[32]888  if(t<0){
[216]889    char *tmpMsg=(char*)malloc(2048+strlen(r_inputs->value));
890   
[34]891    sprintf(tmpMsg,_("The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request."),r_inputs->value);
[32]892    errorException(m, tmpMsg, "InvalidParameterValue");
[216]893    free(tmpMsg);
[32]894    free(s1);
895    freeMaps(&m);
896    free(m);
897    free(REQUEST);
898    free(SERVICE_URL);
899    return 0;
[1]900  }
[258]901  close(saved_stdout);
[1]902
903#ifdef DEBUG
904  dumpService(s1);
905#endif
906  int j;
907 
[381]908
[1]909  /**
[344]910   * Create the input and output maps data structure
[1]911   */
912  int i=0;
913  HINTERNET hInternet;
914  HINTERNET res;
915  hInternet=InternetOpen(
916#ifndef WIN32
917                         (LPCTSTR)
918#endif
919                         "ZooWPSClient\0",
920                         INTERNET_OPEN_TYPE_PRECONFIG,
921                         NULL,NULL, 0);
922
923#ifndef WIN32
924  if(!CHECK_INET_HANDLE(hInternet))
925    fprintf(stderr,"WARNING : hInternet handle failed to initialize");
926#endif
927  maps* request_input_real_format=NULL;
928  maps* tmpmaps = request_input_real_format;
929  map* postRequest=NULL;
930  postRequest=getMap(request_inputs,"xrequest");
931  if(postRequest==NULLMAP){
932    /**
933     * Parsing outputs provided as KVP
934     */
935    r_inputs=NULL;
936#ifdef DEBUG
937    fprintf(stderr,"OUTPUT Parsing ... \n");
938#endif
939    r_inputs=getMap(request_inputs,"ResponseDocument"); 
[9]940    if(r_inputs==NULL) r_inputs=getMap(request_inputs,"RawDataOutput");
941   
[32]942#ifdef DEBUG
[1]943    fprintf(stderr,"OUTPUT Parsing ... \n");
[32]944#endif
[9]945    if(r_inputs!=NULL){
[32]946#ifdef DEBUG
[1]947      fprintf(stderr,"OUTPUT Parsing start now ... \n");
[32]948#endif
[1]949      char cursor_output[10240];
[9]950      char *cotmp=strdup(r_inputs->value);
951      snprintf(cursor_output,10240,"%s",cotmp);
952      free(cotmp);
[1]953      j=0;
954       
955      /**
956       * Put each Output into the outputs_as_text array
957       */
958      char * pToken;
959      maps* tmp_output=NULL;
960#ifdef DEBUG
961      fprintf(stderr,"OUTPUT [%s]\n",cursor_output);
962#endif
963      pToken=strtok(cursor_output,";");
[381]964      char** outputs_as_text=(char**)malloc(128*sizeof(char*));
[9]965      if(outputs_as_text == NULL) {
[34]966        return errorException(m, _("Unable to allocate memory"), "InternalError");
[9]967      }
[1]968      i=0;
969      while(pToken!=NULL){
970#ifdef DEBUG
971        fprintf(stderr,"***%s***\n",pToken);
972        fflush(stderr);
973        fprintf(stderr,"***%s***\n",pToken);
974#endif
[381]975        outputs_as_text[i]=(char*)malloc((strlen(pToken)+1)*sizeof(char));
[9]976        if(outputs_as_text[i] == NULL) {
[34]977          return errorException(m, _("Unable to allocate memory"), "InternalError");
[9]978        }
979        snprintf(outputs_as_text[i],strlen(pToken)+1,"%s",pToken);
[1]980        pToken = strtok(NULL,";");
981        i++;
982      }
983      for(j=0;j<i;j++){
984        char *tmp=strdup(outputs_as_text[j]);
[9]985        free(outputs_as_text[j]);
[1]986        char *tmpc;
987        tmpc=strtok(tmp,"@");
988        int k=0;
989        while(tmpc!=NULL){
990          if(k==0){
991            if(tmp_output==NULL){
[381]992              tmp_output=(maps*)malloc(MAPS_SIZE);
[9]993              if(tmp_output == NULL){
[34]994                return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]995              }
[1]996              tmp_output->name=strdup(tmpc);
997              tmp_output->content=NULL;
998              tmp_output->next=NULL;
999            }
1000          }
1001          else{
1002            char *tmpv=strstr(tmpc,"=");
1003            char tmpn[256];
1004            memset(tmpn,0,256);
1005            strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
1006            tmpn[strlen(tmpc)-strlen(tmpv)]=0;
1007#ifdef DEBUG
1008            fprintf(stderr,"OUTPUT DEF [%s]=[%s]\n",tmpn,tmpv+1);
1009#endif
1010            if(tmp_output->content==NULL){
1011              tmp_output->content=createMap(tmpn,tmpv+1);
1012              tmp_output->content->next=NULL;
1013            }
1014            else
1015              addToMap(tmp_output->content,tmpn,tmpv+1);
1016          }
1017          k++;
1018#ifdef DEBUG
1019          fprintf(stderr,"***%s***\n",tmpc);
1020#endif
1021          tmpc=strtok(NULL,"@");
1022        }
1023        if(request_output_real_format==NULL)
[9]1024          request_output_real_format=dupMaps(&tmp_output);
[1]1025        else
1026          addMapsToMaps(&request_output_real_format,tmp_output);
[9]1027        freeMaps(&tmp_output);
1028        free(tmp_output);
1029        tmp_output=NULL;
[1]1030#ifdef DEBUG
1031        dumpMaps(tmp_output);
1032        fflush(stderr);
1033#endif
[9]1034        free(tmp);
[1]1035      }
[9]1036      free(outputs_as_text);
[1]1037    }
1038
1039
1040    /**
1041     * Parsing inputs provided as KVP
1042     */
1043    r_inputs=getMap(request_inputs,"DataInputs");
1044#ifdef DEBUG
1045    fprintf(stderr,"DATA INPUTS [%s]\n",r_inputs->value);
1046#endif
1047    char cursor_input[40960];
[9]1048    if(r_inputs!=NULL)
1049      snprintf(cursor_input,40960,"%s",r_inputs->value);
1050    else{
[34]1051      errorException(m, _("Parameter <DataInputs> was not specified"),"MissingParameterValue");
[9]1052      freeMaps(&m);
1053      free(m);
1054      free(REQUEST);
1055      free(SERVICE_URL);
[57]1056      InternetCloseHandle(hInternet);
1057      freeService(&s1);
1058      free(s1);
[9]1059      return 0;
1060    }
[1]1061    j=0;
1062 
1063    /**
1064     * Put each DataInputs into the inputs_as_text array
1065     */
[328]1066    char *tmp1=strdup(cursor_input);
[1]1067    char * pToken;
1068    pToken=strtok(cursor_input,";");
[328]1069    if(pToken!=NULL && strncasecmp(pToken,tmp1,strlen(tmp1))==0){
1070      char* tmp2=url_decode(tmp1);
1071      snprintf(cursor_input,(strlen(tmp2)+1)*sizeof(char),"%s",tmp2);
1072      free(tmp2);
1073      pToken=strtok(cursor_input,";");
1074    }
1075    free(tmp1);
1076
[381]1077    char** inputs_as_text=(char**)malloc(100*sizeof(char*));
[9]1078    if(inputs_as_text == NULL){
[34]1079      return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1080    }
[1]1081    i=0;
1082    while(pToken!=NULL){
1083#ifdef DEBUG
1084      fprintf(stderr,"***%s***\n",pToken);
1085#endif
1086      fflush(stderr);
1087#ifdef DEBUG
1088      fprintf(stderr,"***%s***\n",pToken);
1089#endif
[381]1090      inputs_as_text[i]=(char*)malloc((strlen(pToken)+1)*sizeof(char));
[9]1091      snprintf(inputs_as_text[i],strlen(pToken)+1,"%s",pToken);
1092      if(inputs_as_text[i] == NULL){
[34]1093        return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1094      }
[1]1095      pToken = strtok(NULL,";");
1096      i++;
1097    }
1098
1099    for(j=0;j<i;j++){
1100      char *tmp=strdup(inputs_as_text[j]);
[9]1101      free(inputs_as_text[j]);
[1]1102      char *tmpc;
1103      tmpc=strtok(tmp,"@");
1104      while(tmpc!=NULL){
1105#ifdef DEBUG
1106        fprintf(stderr,"***\n***%s***\n",tmpc);
1107#endif
1108        char *tmpv=strstr(tmpc,"=");
1109        char tmpn[256];
1110        memset(tmpn,0,256);
[216]1111        if(tmpv!=NULL){
1112          strncpy(tmpn,tmpc,(strlen(tmpc)-strlen(tmpv))*sizeof(char));
1113          tmpn[strlen(tmpc)-strlen(tmpv)]=0;
1114        }
1115        else{
1116          strncpy(tmpn,tmpc,strlen(tmpc)*sizeof(char));
1117          tmpn[strlen(tmpc)]=0;
1118        }
[1]1119#ifdef DEBUG
1120        fprintf(stderr,"***\n*** %s = %s ***\n",tmpn,tmpv+1);
1121#endif
1122        if(tmpmaps==NULL){
[381]1123          tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1124          if(tmpmaps == NULL){
[34]1125            return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1126          }
[1]1127          tmpmaps->name=strdup(tmpn);
[344]1128          if(tmpv!=NULL){
1129            char *tmpvf=url_decode(tmpv+1);
1130            tmpmaps->content=createMap("value",tmpvf);
1131            free(tmpvf);
1132          }
[216]1133          else
1134            tmpmaps->content=createMap("value","Reference");
[1]1135          tmpmaps->next=NULL;
1136        }
1137        tmpc=strtok(NULL,"@");
1138        while(tmpc!=NULL){
1139#ifdef DEBUG
1140          fprintf(stderr,"*** KVP NON URL-ENCODED \n***%s***\n",tmpc);
1141#endif
1142          char *tmpv1=strstr(tmpc,"=");
1143#ifdef DEBUG
1144          fprintf(stderr,"*** VALUE NON URL-ENCODED \n***%s***\n",tmpv1+1);
1145#endif
1146          char tmpn1[1024];
1147          memset(tmpn1,0,1024);
[216]1148          if(tmpv1!=NULL){
1149            strncpy(tmpn1,tmpc,strlen(tmpc)-strlen(tmpv1));
1150            tmpn1[strlen(tmpc)-strlen(tmpv1)]=0;
1151            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
1152          }
1153          else{
1154            strncpy(tmpn1,tmpc,strlen(tmpc));
1155            tmpn1[strlen(tmpc)]=0;
1156            map* lmap=getLastMap(tmpmaps->content);
[381]1157            char *tmpValue=(char*)malloc((strlen(tmpv)+strlen(tmpc)+1)*sizeof(char));
[365]1158            sprintf(tmpValue,"%s@%s",tmpv+1,tmpc);
[216]1159            free(lmap->value);
1160            lmap->value=strdup(tmpValue);
1161            free(tmpValue);
1162            tmpc=strtok(NULL,"@");
1163            continue;
1164          }
[1]1165#ifdef DEBUG
1166          fprintf(stderr,"*** NAME NON URL-ENCODED \n***%s***\n",tmpn1);
1167          fprintf(stderr,"*** VALUE NON URL-ENCODED \n***%s***\n",tmpv1+1);
1168#endif
1169          if(strcmp(tmpn1,"xlink:href")!=0)
1170            addToMap(tmpmaps->content,tmpn1,tmpv1+1);
[216]1171          else
1172            if(tmpv1!=NULL){
[328]1173              char *tmpx2=url_decode(tmpv1+1);
1174              if(strncasecmp(tmpx2,"http://",7)!=0 &&
1175                 strncasecmp(tmpx2,"ftp://",6)!=0){
[216]1176                char emsg[1024];
1177                sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
1178                errorException(m,emsg,"InternalError");
1179                freeMaps(&m);
1180                free(m);
1181                free(REQUEST);
1182                free(SERVICE_URL);
1183                InternetCloseHandle(hInternet);
1184                freeService(&s1);
1185                free(s1);
1186                return 0;
1187              }
[1]1188#ifdef DEBUG
[216]1189              fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
[1]1190#endif
[328]1191              addToMap(tmpmaps->content,tmpn1,tmpx2);
[280]1192             
[1]1193#ifndef WIN32
[216]1194              if(CHECK_INET_HANDLE(hInternet))
[1]1195#endif
[216]1196                {
[368]1197                  if(loadRemoteFile(m,tmpmaps->content,hInternet,tmpx2)<0){
1198                    freeMaps(&m);
1199                    free(m);
1200                    free(REQUEST);
1201                    free(SERVICE_URL);
1202                    InternetCloseHandle(hInternet);
1203                    freeService(&s1);
1204                    free(s1);
1205                    return 0;
1206                  }
[58]1207                }
[328]1208              free(tmpx2);
[216]1209              addToMap(tmpmaps->content,"Reference",tmpv1+1);
1210            }
[1]1211          tmpc=strtok(NULL,"@");
1212        }
1213#ifdef DEBUG
1214        dumpMaps(tmpmaps);
1215        fflush(stderr);
1216#endif
[9]1217        if(request_input_real_format==NULL)
1218          request_input_real_format=dupMaps(&tmpmaps);
[360]1219        else{
1220          maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
1221          if(testPresence!=NULL){
1222            elements* elem=getElements(s1->inputs,tmpmaps->name);
1223            if(elem!=NULL){
1224              if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
1225                freeMaps(&m);
1226                free(m);
1227                free(REQUEST);
1228                free(SERVICE_URL);
1229                InternetCloseHandle(hInternet);
1230                freeService(&s1);
1231                free(s1);
1232                return 0;
1233              }
1234            }
1235          }
1236          else
1237            addMapsToMaps(&request_input_real_format,tmpmaps);
1238        }
[9]1239        freeMaps(&tmpmaps);
1240        free(tmpmaps);
1241        tmpmaps=NULL;
1242        free(tmp);
[1]1243      }
1244    }
[9]1245    free(inputs_as_text);
1246  }
[1]1247  else {
[9]1248    /**
1249     * Parse XML request
1250     */ 
[1]1251    xmlInitParser();
1252#ifdef DEBUG
1253    fflush(stderr);
1254    fprintf(stderr,"BEFORE %s\n",postRequest->value);
1255    fflush(stderr);
1256#endif
1257    xmlDocPtr doc =
[5]1258      xmlParseMemory(postRequest->value,cgiContentLength);
[1]1259#ifdef DEBUG
1260    fprintf(stderr,"AFTER\n");
1261    fflush(stderr);
1262#endif
1263    /**
1264     * Parse every Input in DataInputs node.
1265     */
[9]1266    xmlXPathObjectPtr tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='Input']");
1267    xmlNodeSet* tmps=tmpsptr->nodesetval;
[1]1268#ifdef DEBUG
1269    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
1270#endif
1271    for(int k=0;k<tmps->nodeNr;k++){
1272      maps *tmpmaps=NULL;
1273      xmlNodePtr cur=tmps->nodeTab[k];
1274      if(tmps->nodeTab[k]->type == XML_ELEMENT_NODE) {
1275        /**
1276         * A specific Input node.
1277         */
1278#ifdef DEBUG
1279        fprintf(stderr, "= element 0 node \"%s\"\n", cur->name);
1280#endif
[9]1281        xmlNodePtr cur2=cur->children;
[32]1282        while(cur2!=NULL){
1283          while(cur2!=NULL && cur2->type!=XML_ELEMENT_NODE)
[9]1284            cur2=cur2->next;
[32]1285          if(cur2==NULL)
1286            break;
[9]1287          /**
1288           * Indentifier
1289           */
1290          if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
1291            xmlChar *val= xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1292            if(tmpmaps==NULL){
[381]1293              tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1294              if(tmpmaps == NULL){
[34]1295                return errorException(m, _("Unable to allocate memory."), "InternalError");
[1]1296              }
[9]1297              tmpmaps->name=strdup((char*)val);
1298              tmpmaps->content=NULL;
1299              tmpmaps->next=NULL;
[1]1300            }
[9]1301            xmlFree(val);
1302          }
1303          /**
1304           * Title, Asbtract
1305           */
1306          if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
1307             xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
1308            xmlChar *val=
1309              xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1310            if(tmpmaps==NULL){
[381]1311              tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1312              if(tmpmaps == NULL){
[34]1313                return errorException(m, _("Unable to allocate memory."), "InternalError");
[1]1314              }
[114]1315              tmpmaps->name=strdup("missingIndetifier");
[9]1316              tmpmaps->content=createMap((char*)cur2->name,(char*)val);
1317              tmpmaps->next=NULL;
1318            }
1319            else{
1320              if(tmpmaps->content!=NULL)
1321                addToMap(tmpmaps->content,
1322                         (char*)cur2->name,(char*)val);
1323              else
1324                tmpmaps->content=
1325                  createMap((char*)cur2->name,(char*)val);
1326            }
[1]1327#ifdef DEBUG
[9]1328            dumpMaps(tmpmaps);
[1]1329#endif
[9]1330            xmlFree(val);
1331          }
1332          /**
1333           * InputDataFormChoice (Reference or Data ?)
1334           */
1335          if(xmlStrcasecmp(cur2->name,BAD_CAST "Reference")==0){
[1]1336            /**
[9]1337             * Get every attribute from a Reference node
1338             * mimeType, encoding, schema, href, method
1339             * Header and Body gesture should be added here
[1]1340             */
1341#ifdef DEBUG
[9]1342            fprintf(stderr,"REFERENCE\n");
[1]1343#endif
[283]1344            const char *refs[5]={"mimeType","encoding","schema","method","href"};
[9]1345            for(int l=0;l<5;l++){
[1]1346#ifdef DEBUG
[9]1347              fprintf(stderr,"*** %s ***",refs[l]);
[1]1348#endif
[9]1349              xmlChar *val=xmlGetProp(cur2,BAD_CAST refs[l]);
1350              if(val!=NULL && xmlStrlen(val)>0){
1351                if(tmpmaps->content!=NULL)
1352                  addToMap(tmpmaps->content,refs[l],(char*)val);
1353                else
1354                  tmpmaps->content=createMap(refs[l],(char*)val);
1355                map* ltmp=getMap(tmpmaps->content,"method");
1356                if(l==4){
1357                  if(!(ltmp!=NULL && strcmp(ltmp->value,"POST")==0)
1358                     && CHECK_INET_HANDLE(hInternet)){
[379]1359                    if(loadRemoteFile(m,tmpmaps->content,hInternet,(char*)val)!=0){
[368]1360                      freeMaps(&m);
1361                      free(m);
1362                      free(REQUEST);
1363                      free(SERVICE_URL);
1364                      InternetCloseHandle(hInternet);
1365                      freeService(&s1);
1366                      free(s1);
1367                      return 0;
1368                    }
[1]1369                  }
1370                }
[9]1371              }
[1]1372#ifdef DEBUG
[9]1373              fprintf(stderr,"%s\n",val);
[1]1374#endif
[9]1375              xmlFree(val);
1376            }
[1]1377#ifdef POST_DEBUG
[9]1378            fprintf(stderr,"Parse Header and Body from Reference \n");
[1]1379#endif
[9]1380            xmlNodePtr cur3=cur2->children;
1381            hInternet.header=NULL;
1382            while(cur3){
[216]1383              while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE)
1384                cur2=cur3->next;
[9]1385              if(xmlStrcasecmp(cur3->name,BAD_CAST "Header")==0 ){
[114]1386                const char *ha[2];
[9]1387                ha[0]="key";
1388                ha[1]="value";
1389                int hai;
1390                char *has;
1391                char *key;
1392                for(hai=0;hai<2;hai++){
1393                  xmlChar *val=xmlGetProp(cur3,BAD_CAST ha[hai]);
[1]1394#ifdef POST_DEBUG
[9]1395                  fprintf(stderr,"%s = %s\n",ha[hai],(char*)val);
[1]1396#endif
[9]1397                  if(hai==0){
[381]1398                    key=(char*)malloc((1+strlen((char*)val))*sizeof(char));
[9]1399                    snprintf(key,1+strlen((char*)val),"%s",(char*)val);
1400                  }else{
[381]1401                    has=(char*)malloc((3+strlen((char*)val)+strlen(key))*sizeof(char));
[9]1402                    if(has == NULL){
[34]1403                      return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1404                    }
1405                    snprintf(has,(3+strlen((char*)val)+strlen(key)),"%s: %s",key,(char*)val);
[1]1406#ifdef POST_DEBUG
[9]1407                    fprintf(stderr,"%s\n",has);
[1]1408#endif
1409                  }
1410                }
[9]1411                hInternet.header=curl_slist_append(hInternet.header, has);
[114]1412                free(has);
[9]1413              }
1414              else{
[1]1415#ifdef POST_DEBUG
[9]1416                fprintf(stderr,"Try to fetch the body part of the request ...\n");
[1]1417#endif
[9]1418                if(xmlStrcasecmp(cur3->name,BAD_CAST "Body")==0 ){
[1]1419#ifdef POST_DEBUG
[9]1420                  fprintf(stderr,"Body part found !!!\n",(char*)cur3->content);
[1]1421#endif
[9]1422                  char *tmp=new char[cgiContentLength];
1423                  memset(tmp,0,cgiContentLength);
1424                  xmlNodePtr cur4=cur3->children;
1425                  while(cur4!=NULL){
[127]1426                    while(cur4->type!=XML_ELEMENT_NODE)
1427                      cur4=cur4->next;
[9]1428                    xmlDocPtr bdoc = xmlNewDoc(BAD_CAST "1.0");
1429                    bdoc->encoding = xmlCharStrdup ("UTF-8");
1430                    xmlDocSetRootElement(bdoc,cur4);
1431                    xmlChar* btmps;
1432                    int bsize;
1433                    xmlDocDumpMemory(bdoc,&btmps,&bsize);
[1]1434#ifdef POST_DEBUG
[9]1435                    fprintf(stderr,"Body part found !!! %s %s\n",tmp,(char*)btmps);
[1]1436#endif
[9]1437                    if(btmps!=NULL)
1438                      sprintf(tmp,"%s",(char*)btmps);
1439                    xmlFreeDoc(bdoc);
1440                    cur4=cur4->next;
1441                  }
1442                  map *btmp=getMap(tmpmaps->content,"href");
1443                  if(btmp!=NULL){
1444#ifdef POST_DEBUG
1445                    fprintf(stderr,"%s %s\n",btmp->value,tmp);
1446                    curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1);
1447#endif
1448                    res=InternetOpenUrl(hInternet,btmp->value,tmp,strlen(tmp),
1449                                        INTERNET_FLAG_NO_CACHE_WRITE,0);
[381]1450                    char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));
[9]1451                    if(tmpContent == NULL){
[34]1452                      return errorException(m, _("Unable to allocate memory."), "InternalError");
[1]1453                    }
[9]1454                    size_t dwRead;
1455                    InternetReadFile(res, (LPVOID)tmpContent,
1456                                     res.nDataLen, &dwRead);
1457                    tmpContent[res.nDataLen]=0;
1458                    if(hInternet.header!=NULL)
1459                      curl_slist_free_all(hInternet.header);
1460                    addToMap(tmpmaps->content,"value",tmpContent);
1461#ifdef POST_DEBUG
1462                    fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
1463#endif
1464                  }
1465                }
1466                else
1467                  if(xmlStrcasecmp(cur3->name,BAD_CAST "BodyReference")==0 ){
1468                    xmlChar *val=xmlGetProp(cur3,BAD_CAST "href");
1469                    HINTERNET bInternet,res1;
1470                    bInternet=InternetOpen(
1471#ifndef WIN32
1472                                           (LPCTSTR)
1473#endif
1474                                           "ZooWPSClient\0",
1475                                           INTERNET_OPEN_TYPE_PRECONFIG,
1476                                           NULL,NULL, 0);
1477                    if(!CHECK_INET_HANDLE(bInternet))
1478                      fprintf(stderr,"WARNING : hInternet handle failed to initialize");
1479#ifdef POST_DEBUG
1480                    curl_easy_setopt(bInternet.handle, CURLOPT_VERBOSE, 1);
1481#endif
1482                    res1=InternetOpenUrl(bInternet,(char*)val,NULL,0,
1483                                         INTERNET_FLAG_NO_CACHE_WRITE,0);
1484                    char* tmp=
[381]1485                      (char*)malloc((res1.nDataLen+1)*sizeof(char));
[9]1486                    if(tmp == NULL){
[34]1487                      return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1488                    }
1489                    size_t bRead;
1490                    InternetReadFile(res1, (LPVOID)tmp,
1491                                     res1.nDataLen, &bRead);
1492                    tmp[res1.nDataLen]=0;
1493                    InternetCloseHandle(bInternet);
[1]1494                    map *btmp=getMap(tmpmaps->content,"href");
1495                    if(btmp!=NULL){
1496#ifdef POST_DEBUG
1497                      fprintf(stderr,"%s %s\n",btmp->value,tmp);
1498                      curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1);
1499#endif
[9]1500                      res=InternetOpenUrl(hInternet,btmp->value,tmp,
1501                                          strlen(tmp),
[1]1502                                          INTERNET_FLAG_NO_CACHE_WRITE,0);
[381]1503                      char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));
[9]1504                      if(tmpContent == NULL){
[34]1505                        return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1506                      }
[1]1507                      size_t dwRead;
1508                      InternetReadFile(res, (LPVOID)tmpContent,
1509                                       res.nDataLen, &dwRead);
1510                      tmpContent[res.nDataLen]=0;
1511                      if(hInternet.header!=NULL)
1512                        curl_slist_free_all(hInternet.header);
1513                      addToMap(tmpmaps->content,"value",tmpContent);
1514#ifdef POST_DEBUG
1515                      fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
1516#endif
1517                    }
1518                  }
1519              }
[9]1520              cur3=cur3->next;
1521            }
[1]1522#ifdef POST_DEBUG
[9]1523            fprintf(stderr,"Header and Body was parsed from Reference \n");
[1]1524#endif
1525#ifdef DEBUG
[9]1526            dumpMap(tmpmaps->content);
1527            fprintf(stderr, "= element 2 node \"%s\" = (%s)\n", 
1528                    cur2->name,cur2->content);
[1]1529#endif
[9]1530          }
1531          else if(xmlStrcasecmp(cur2->name,BAD_CAST "Data")==0){
[1]1532#ifdef DEBUG
[9]1533            fprintf(stderr,"DATA\n");
[1]1534#endif
[9]1535            xmlNodePtr cur4=cur2->children;
[32]1536            while(cur4!=NULL){
1537              while(cur4!=NULL &&cur4->type!=XML_ELEMENT_NODE)
[9]1538                cur4=cur4->next;
[32]1539              if(cur4==NULL)
1540                break;
[9]1541              if(xmlStrcasecmp(cur4->name, BAD_CAST "LiteralData")==0){
1542                /**
1543                 * Get every attribute from a LiteralData node
1544                 * dataType , uom
1545                 */
[114]1546                char *list[2];
1547                list[0]=strdup("dataType");
1548                list[1]=strdup("uom");
[9]1549                for(int l=0;l<2;l++){
[1]1550#ifdef DEBUG
[114]1551                  fprintf(stderr,"*** LiteralData %s ***",list[l]);
[1]1552#endif
[114]1553                  xmlChar *val=xmlGetProp(cur4,BAD_CAST list[l]);
[9]1554                  if(val!=NULL && strlen((char*)val)>0){
1555                    if(tmpmaps->content!=NULL)
[114]1556                      addToMap(tmpmaps->content,list[l],(char*)val);
[9]1557                    else
[114]1558                      tmpmaps->content=createMap(list[l],(char*)val);
[1]1559#ifdef DEBUG
[280]1560                    fprintf(stderr,"%s\n",val);
[1]1561#endif
[280]1562                  }
[9]1563                  xmlFree(val);
[280]1564                  free(list[l]);                 
[1]1565                }
[9]1566              }
1567              else if(xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0){
1568                /**
1569                 * Get every attribute from a Reference node
1570                 * mimeType, encoding, schema
1571                 */
[282]1572                const char *coms[3]={"mimeType","encoding","schema"};
[9]1573                for(int l=0;l<3;l++){
[1]1574#ifdef DEBUG
[280]1575                  fprintf(stderr,"*** ComplexData %s ***\n",coms[l]);
[1]1576#endif
[9]1577                  xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]);
1578                  if(val!=NULL && strlen((char*)val)>0){
1579                    if(tmpmaps->content!=NULL)
1580                      addToMap(tmpmaps->content,coms[l],(char*)val);
1581                    else
1582                      tmpmaps->content=createMap(coms[l],(char*)val);
[1]1583#ifdef DEBUG
[280]1584                    fprintf(stderr,"%s\n",val);
[1]1585#endif
[280]1586                  }
[9]1587                  xmlFree(val);
[1]1588                }
1589              }
[280]1590
[94]1591              map* test=getMap(tmpmaps->content,"encoding");
[280]1592              if(test==NULL){
1593                if(tmpmaps->content!=NULL)
1594                  addToMap(tmpmaps->content,"encoding","utf-8");
1595                else
1596                  tmpmaps->content=createMap("encoding","utf-8");
1597                test=getMap(tmpmaps->content,"encoding");
1598              }
1599
1600              if(strcasecmp(test->value,"base64")!=0){
[94]1601                xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1);
[280]1602                map* ltmp=getMap(tmpmaps->content,"mimeType");
1603                if(mv==NULL || 
1604                   (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 &&
1605                    (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){
[94]1606                  xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0");
1607                  int buffersize;
[280]1608                  xmlNodePtr cur5=cur4->children;
1609                  while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE)
1610                    cur5=cur5->next;
1611                  xmlDocSetRootElement(doc1,cur5);
[94]1612                  xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1);
1613                  char size[1024];
1614                  sprintf(size,"%d",buffersize);
1615                  addToMap(tmpmaps->content,"size",size);
1616                }
1617                addToMap(tmpmaps->content,"value",(char*)mv);
1618                xmlFree(mv);
1619              }else{
[95]1620                xmlChar* tmp=xmlNodeListGetRawString(doc,cur4->xmlChildrenNode,0);
[94]1621                addToMap(tmpmaps->content,"value",(char*)tmp);
1622                map* tmpv=getMap(tmpmaps->content,"value");
1623                char *res=NULL;
1624                char *curs=tmpv->value;
1625                for(int i=0;i<=strlen(tmpv->value)/64;i++) {
1626                  if(res==NULL)
1627                    res=(char*)malloc(67*sizeof(char));
1628                  else
1629                    res=(char*)realloc(res,(((i+1)*65)+i)*sizeof(char));
1630                  int csize=i*65;
1631                  strncpy(res + csize,curs,64);
1632                  if(i==xmlStrlen(tmp)/64)
1633                    strcat(res,"\n\0");
1634                  else{
1635                    strncpy(res + (((i+1)*64)+i),"\n\0",2);
1636                    curs+=64;
1637                  }
1638                }
1639                free(tmpv->value);
1640                tmpv->value=strdup(res);
1641                free(res);
1642                xmlFree(tmp);
[69]1643              }
[9]1644              cur4=cur4->next;
[1]1645            }
[9]1646          }
[1]1647#ifdef DEBUG
[9]1648          fprintf(stderr,"cur2 next \n");
1649          fflush(stderr);
[1]1650#endif
[9]1651          cur2=cur2->next;
1652        }
[1]1653#ifdef DEBUG
[9]1654        fprintf(stderr,"ADD MAPS TO REQUEST MAPS !\n");
1655        fflush(stderr);
[1]1656#endif
[360]1657
1658        {
1659          maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
1660          if(testPresence!=NULL){
1661            elements* elem=getElements(s1->inputs,tmpmaps->name);
1662            if(elem!=NULL){
1663              if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
1664                freeMaps(&m);
1665                free(m);
1666                free(REQUEST);
1667                free(SERVICE_URL);
1668                InternetCloseHandle(hInternet);
1669                freeService(&s1);
1670                free(s1);
1671                return 0;
1672              }
1673            }
1674          }
1675          else
1676            addMapsToMaps(&request_input_real_format,tmpmaps);
1677        }
[9]1678       
[1]1679#ifdef DEBUG
[9]1680        fprintf(stderr,"******TMPMAPS*****\n");
[1]1681        dumpMaps(tmpmaps);
[9]1682        fprintf(stderr,"******REQUESTMAPS*****\n");
1683        dumpMaps(request_input_real_format);
[1]1684#endif
[32]1685        freeMaps(&tmpmaps);
1686        free(tmpmaps);
1687        tmpmaps=NULL;         
[1]1688      }
[25]1689#ifdef DEBUG
1690      dumpMaps(tmpmaps); 
1691#endif
[1]1692    }
1693#ifdef DEBUG
[9]1694    fprintf(stderr,"Search for response document node\n");
1695#endif
1696    xmlXPathFreeObject(tmpsptr);
[105]1697   
[9]1698    tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='ResponseDocument']");
[105]1699    bool asRaw=false;
[9]1700    tmps=tmpsptr->nodesetval;
[105]1701    if(tmps->nodeNr==0){
1702      tmpsptr=extractFromDoc(doc,"/*/*/*[local-name()='RawDataOutput']");
1703      tmps=tmpsptr->nodesetval;
1704      asRaw=true;
1705    }
[9]1706#ifdef DEBUG
[1]1707    fprintf(stderr,"*****%d*****\n",tmps->nodeNr);
1708#endif
1709    for(int k=0;k<tmps->nodeNr;k++){
[105]1710      if(asRaw==true)
1711        addToMap(request_inputs,"RawDataOutput","");
1712      else
1713        addToMap(request_inputs,"ResponseDocument","");
[1]1714      maps *tmpmaps=NULL;
1715      xmlNodePtr cur=tmps->nodeTab[k];
1716      if(cur->type == XML_ELEMENT_NODE) {
1717        /**
1718         * A specific responseDocument node.
1719         */
1720        if(tmpmaps==NULL){
[381]1721          tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1722          if(tmpmaps == NULL){
[34]1723            return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1724          }
[114]1725          tmpmaps->name=strdup("unknownIdentifier");
[381]1726          tmpmaps->content=NULL;
[1]1727          tmpmaps->next=NULL;
1728        }
1729        /**
[384]1730         * Get every attribute: storeExecuteResponse, lineage, status
[1]1731         */
[283]1732        const char *ress[3]={"storeExecuteResponse","lineage","status"};
[1]1733        xmlChar *val;
1734        for(int l=0;l<3;l++){
1735#ifdef DEBUG
1736          fprintf(stderr,"*** %s ***\t",ress[l]);
1737#endif
1738          val=xmlGetProp(cur,BAD_CAST ress[l]);
1739          if(val!=NULL && strlen((char*)val)>0){
1740            if(tmpmaps->content!=NULL)
1741              addToMap(tmpmaps->content,ress[l],(char*)val);
1742            else
1743              tmpmaps->content=createMap(ress[l],(char*)val);
1744            addToMap(request_inputs,ress[l],(char*)val);
1745          }
1746#ifdef DEBUG
1747          fprintf(stderr,"%s\n",val);
1748#endif
1749          xmlFree(val);
1750        }
1751        xmlNodePtr cur1=cur->children;
[381]1752        while(cur1!=NULL && cur1->type != XML_ELEMENT_NODE)
1753          cur1=cur1->next;
[1]1754        while(cur1){
[280]1755          /**
1756           * Indentifier
1757           */
1758          if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){
1759            xmlChar *val=
1760              xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
1761            if(tmpmaps==NULL){
[381]1762              tmpmaps=(maps*)malloc(MAPS_SIZE);
[280]1763              if(tmpmaps == NULL){
1764                return errorException(m, _("Unable to allocate memory."), "InternalError");
1765              }
1766              tmpmaps->name=strdup((char*)val);
1767              tmpmaps->content=NULL;
1768              tmpmaps->next=NULL;
1769            }
[384]1770            else{
1771              //free(tmpmaps->name);
1772              tmpmaps->name=strdup((char*)val);
1773            }
[280]1774            xmlFree(val);
1775          }
1776          /**
1777           * Title, Asbtract
1778           */
1779          else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 ||
1780                  xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){
1781            xmlChar *val=
1782              xmlNodeListGetString(doc,cur1->xmlChildrenNode,1);
1783            if(tmpmaps==NULL){
[381]1784              tmpmaps=(maps*)malloc(MAPS_SIZE);
[280]1785              if(tmpmaps == NULL){
1786                return errorException(m, _("Unable to allocate memory."), "InternalError");
1787              }
1788              tmpmaps->name=strdup("missingIndetifier");
1789              tmpmaps->content=createMap((char*)cur1->name,(char*)val);
1790              tmpmaps->next=NULL;
1791            }
1792            else{
1793              if(tmpmaps->content!=NULL)
[384]1794                addToMap(tmpmaps->content,(char*)cur1->name,(char*)val);
[280]1795              else
[384]1796                tmpmaps->content=createMap((char*)cur1->name,(char*)val);
[280]1797            }
1798            xmlFree(val);
1799          }
1800          else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){
[1]1801            /**
1802             * Get every attribute from a Output node
1803             * mimeType, encoding, schema, uom, asReference
1804             */
[283]1805            const char *outs[5]={"mimeType","encoding","schema","uom","asReference"};
[1]1806            for(int l=0;l<5;l++){
1807#ifdef DEBUG
1808              fprintf(stderr,"*** %s ***\t",outs[l]);
1809#endif
1810              val=xmlGetProp(cur1,BAD_CAST outs[l]);
1811              if(val!=NULL && strlen((char*)val)>0){
1812                if(tmpmaps->content!=NULL)
1813                  addToMap(tmpmaps->content,outs[l],(char*)val);
1814                else
1815                  tmpmaps->content=createMap(outs[l],(char*)val);
1816              }
1817#ifdef DEBUG
1818              fprintf(stderr,"%s\n",val);
1819#endif
1820              xmlFree(val);
1821            }
1822            xmlNodePtr cur2=cur1->children;
[384]1823            while(cur2!=NULL && cur2->type != XML_ELEMENT_NODE)
1824              cur2=cur2->next;
[1]1825            while(cur2){
1826              /**
1827               * Indentifier
1828               */
[9]1829              if(xmlStrncasecmp(cur2->name,BAD_CAST "Identifier",xmlStrlen(cur2->name))==0){
[1]1830                xmlChar *val=
1831                  xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1832                if(tmpmaps==NULL){
[381]1833                  tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1834                  if(tmpmaps == NULL){
[34]1835                    return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1836                  }
[1]1837                  tmpmaps->name=strdup((char*)val);
1838                  tmpmaps->content=NULL;
1839                  tmpmaps->next=NULL;
1840                }
[380]1841                else{
1842                  if(tmpmaps->name!=NULL)
1843                    free(tmpmaps->name);
[1]1844                  tmpmaps->name=strdup((char*)val);;
[380]1845                }
[1]1846                xmlFree(val);
1847              }
1848              /**
1849               * Title, Asbtract
1850               */
[274]1851              else if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||
[331]1852                      xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){
[1]1853                xmlChar *val=
1854                  xmlNodeListGetString(doc,cur2->xmlChildrenNode,1);
1855                if(tmpmaps==NULL){
[381]1856                  tmpmaps=(maps*)malloc(MAPS_SIZE);
[9]1857                  if(tmpmaps == NULL){
[34]1858                    return errorException(m, _("Unable to allocate memory."), "InternalError");
[9]1859                  }
[114]1860                  tmpmaps->name=strdup("missingIndetifier");
[1]1861                  tmpmaps->content=createMap((char*)cur2->name,(char*)val);
1862                  tmpmaps->next=NULL;
1863                }
1864                else{
1865                  if(tmpmaps->content!=NULL)
1866                    addToMap(tmpmaps->content,
1867                             (char*)cur2->name,(char*)val);
1868                  else
1869                    tmpmaps->content=
1870                      createMap((char*)cur2->name,(char*)val);
1871                }
1872                xmlFree(val);
1873              }
[380]1874              if(request_output_real_format==NULL)
1875                request_output_real_format=dupMaps(&tmpmaps);
1876              else
1877                addMapsToMaps(&request_output_real_format,tmpmaps);
[1]1878              cur2=cur2->next;
[380]1879              while(cur2!=NULL && cur2->type != XML_ELEMENT_NODE)
1880                cur2=cur2->next;
[1]1881            }
1882          }
1883          cur1=cur1->next;
[380]1884          while(cur1!=NULL && cur1->type != XML_ELEMENT_NODE)
1885            cur1=cur1->next;
[1]1886        }
1887      }
[380]1888      if(tmpmaps!=NULL){
1889        freeMaps(&tmpmaps);
1890        free(tmpmaps);
1891        tmpmaps=NULL;
1892      }
[1]1893    }
[9]1894    xmlXPathFreeObject(tmpsptr);
[1]1895    xmlCleanupParser();
1896  }
[105]1897 
[9]1898  //if(CHECK_INET_HANDLE(hInternet))
1899  InternetCloseHandle(hInternet);
[1]1900
1901#ifdef DEBUG
[375]1902  fprintf(stderr,"\n%d\n",__LINE__);
1903  fflush(stderr);
[1]1904  dumpMaps(request_input_real_format);
1905  dumpMaps(request_output_real_format);
[9]1906  dumpMap(request_inputs);
[375]1907  fprintf(stderr,"\n%d\n",__LINE__);
1908  fflush(stderr);
[1]1909#endif
1910
1911  /**
1912   * Ensure that each requested arguments are present in the request
1913   * DataInputs and ResponseDocument / RawDataOutput
[92]1914   */
[63]1915  char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0);
[280]1916  char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1);
1917  if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){
[9]1918    char tmps[1024];
[280]1919    if(strcmp(dfv,"")!=0){
1920      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);
1921    }
1922    else if(strcmp(dfv1,"")!=0){
1923      snprintf(tmps,1024,_("The <%s> argument was specified as Output identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),dfv1);
1924    }
[9]1925    map* tmpe=createMap("text",tmps);
1926    addToMap(tmpe,"code","MissingParameterValue");
1927    printExceptionReportResponse(m,tmpe);
[63]1928    freeService(&s1);
1929    free(s1);
[9]1930    freeMap(&tmpe);
1931    free(tmpe);
1932    freeMaps(&m);
1933    free(m);
1934    free(REQUEST);
[63]1935    free(SERVICE_URL);
[9]1936    freeMaps(&request_input_real_format);
1937    free(request_input_real_format);
1938    freeMaps(&request_output_real_format);
1939    free(request_output_real_format);
1940    freeMaps(&tmpmaps);
1941    free(tmpmaps);
1942    return 1;
1943  }
[331]1944  maps* tmpReqI=request_input_real_format;
1945  while(tmpReqI!=NULL){
1946    char name[1024];
1947    if(getMap(tmpReqI->content,"isFile")!=NULL){
1948      if (cgiFormFileName(tmpReqI->name, name, sizeof(name)) == cgiFormSuccess) {
1949        int BufferLen=1024;
1950        cgiFilePtr file;
1951        int targetFile;
1952        mode_t mode;
1953        char storageNameOnServer[2048];
1954        char fileNameOnServer[64];
1955        char contentType[1024];
[364]1956        char buffer[1024];
[331]1957        char *tmpStr=NULL;
1958        int size;
1959        int got,t;
1960        map *path=getMapFromMaps(m,"main","tmpPath");
1961        cgiFormFileSize(tmpReqI->name, &size);
1962        cgiFormFileContentType(tmpReqI->name, contentType, sizeof(contentType));
1963        if (cgiFormFileOpen(tmpReqI->name, &file) == cgiFormSuccess) {
1964          t=-1;
1965          while(1){
1966            tmpStr=strstr(name+t+1,"\\");
1967            if(NULL==tmpStr)
1968              tmpStr=strstr(name+t+1,"/");
1969            if(NULL!=tmpStr)
1970              t=(int)(tmpStr-name);
1971            else
1972              break;
1973          }
1974          strcpy(fileNameOnServer,name+t+1);
1975         
1976          sprintf(storageNameOnServer,"%s/%s",path->value,fileNameOnServer);
[375]1977          printf("\n\nName on server %s\n",storageNameOnServer);
1978#ifdef DEBUG
[331]1979          fprintf(stderr,"Name on server %s\n",storageNameOnServer);
1980          fprintf(stderr,"fileNameOnServer: %s\n",fileNameOnServer);
[375]1981#endif
[331]1982          mode=S_IRWXU|S_IRGRP|S_IROTH;
[364]1983          targetFile = open (storageNameOnServer,O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH);
[331]1984          if(targetFile<0){
[375]1985#ifdef DEBUG
[331]1986            fprintf(stderr,"could not create the new file,%s\n",fileNameOnServer);         
[375]1987#endif
[331]1988          }else{
1989            while (cgiFormFileRead(file, buffer, BufferLen, &got) ==cgiFormSuccess){
1990              if(got>0)
1991                write(targetFile,buffer,got);
1992            }
1993          }
1994          addToMap(tmpReqI->content,"lref",storageNameOnServer);
1995          cgiFormFileClose(file);
1996          close(targetFile);
[375]1997#ifdef DEBUG
[331]1998          fprintf(stderr,"File \"%s\" has been uploaded",fileNameOnServer);
[375]1999#endif
[331]2000        }
2001      }
2002    }
2003    tmpReqI=tmpReqI->next;
2004  }
2005
[88]2006  ensureDecodedBase64(&request_input_real_format);
2007
[9]2008#ifdef DEBUG
2009  fprintf(stderr,"REQUEST_INPUTS\n");
2010  dumpMaps(request_input_real_format);
2011  fprintf(stderr,"REQUEST_OUTPUTS\n");
2012  dumpMaps(request_output_real_format);
2013#endif
[1]2014
2015  maps* curs=getMaps(m,"env");
2016  if(curs!=NULL){
2017    map* mapcs=curs->content;
2018    while(mapcs!=NULLMAP){
2019#ifndef WIN32
2020      setenv(mapcs->name,mapcs->value,1);
2021#else
2022#ifdef DEBUG
2023      fprintf(stderr,"[ZOO: setenv (%s=%s)]\n",mapcs->name,mapcs->value);
2024#endif
2025      if(mapcs->value[strlen(mapcs->value)-2]=='\r'){
2026#ifdef DEBUG
2027        fprintf(stderr,"[ZOO: Env var finish with \r]\n");
2028#endif
2029        mapcs->value[strlen(mapcs->value)-1]=0;
2030      }
2031#ifdef DEBUG
2032      fflush(stderr);
[364]2033      fprintf(stderr,"setting variable... %s\n",(
[1]2034#endif
2035              SetEnvironmentVariable(mapcs->name,mapcs->value)
2036#ifdef DEBUG
[364]2037              ==0)? "OK" : "FAILED");
[1]2038#else
2039      ;
2040#endif
[364]2041          char* toto=(char*)malloc((strlen(mapcs->name)+strlen(mapcs->value)+2)*sizeof(char));
2042      sprintf(toto,"%s=%s",mapcs->name,mapcs->value);
2043          putenv(toto);
[1]2044#ifdef DEBUG
2045      fflush(stderr);
2046#endif
2047#endif
2048#ifdef DEBUG
2049      fprintf(stderr,"[ZOO: setenv (%s=%s)]\n",mapcs->name,mapcs->value);
2050      fflush(stderr);
2051#endif
2052      mapcs=mapcs->next;
2053    }
2054  }
2055 
2056#ifdef DEBUG
2057  dumpMap(request_inputs);
2058#endif
2059
2060  /**
2061   * Need to check if we need to fork to load a status enabled
2062   */
2063  r_inputs=NULL;
[72]2064  map* store=getMap(request_inputs,"storeExecuteResponse");
2065  map* status=getMap(request_inputs,"status");
2066  /**
2067   * 05-007r7 WPS 1.0.0 page 57 :
2068   * 'If status="true" and storeExecuteResponse is "false" then the service
2069   * shall raise an exception.'
2070   */
2071  if(status!=NULL && strcmp(status->value,"true")==0 && 
2072     store!=NULL && strcmp(store->value,"false")==0){
2073    errorException(m, _("Status cannot be set to true with storeExecuteResponse to false. Please, modify your request parameters."), "InvalidParameterValue");
2074    freeService(&s1);
2075    free(s1);
2076    freeMaps(&m);
2077    free(m);
2078   
2079    freeMaps(&request_input_real_format);
2080    free(request_input_real_format);
2081   
2082    freeMaps(&request_output_real_format);
2083    free(request_output_real_format);
2084   
2085    free(REQUEST);
2086    free(SERVICE_URL);
2087    return 1;
2088  }
[1]2089  r_inputs=getMap(request_inputs,"storeExecuteResponse");
2090  int eres=SERVICE_STARTED;
2091  int cpid=getpid();
[94]2092
[32]2093  maps *_tmpMaps=(maps*)malloc(MAPS_SIZE);
2094  _tmpMaps->name=strdup("lenv");
2095  char tmpBuff[100];
2096  sprintf(tmpBuff,"%i",cpid);
2097  _tmpMaps->content=createMap("sid",tmpBuff);
2098  _tmpMaps->next=NULL;
2099  addToMap(_tmpMaps->content,"status","0");
[216]2100  addToMap(_tmpMaps->content,"cwd",ntmp);
[280]2101  map* ltmp=getMap(request_inputs,"soap");
2102  if(ltmp!=NULL)
2103    addToMap(_tmpMaps->content,"soap",ltmp->value);
2104  else
2105    addToMap(_tmpMaps->content,"soap","false");
[92]2106  if(cgiCookie!=NULL && strlen(cgiCookie)>0){
[390]2107    int hasValidCookie=-1;
[342]2108    char *tcook=strdup(cgiCookie);
2109    if(strstr(cgiCookie,";")>0){
2110      char *token,*saveptr;
2111      token=strtok_r(cgiCookie,";",&saveptr);
2112      while(token!=NULL){
2113        if(strcasestr(token,"ID")!=NULL){
2114          if(tcook!=NULL)
2115            free(tcook);
2116          tcook=strdup(token);
[390]2117          hasValidCookie=1;
[342]2118        }
2119        token=strtok_r(NULL,";",&saveptr);
2120      }
2121    }
[390]2122    if(hasValidCookie>0){
2123      addToMap(_tmpMaps->content,"sessid",strstr(tcook,"=")+1);
2124      char session_file_path[1024];
2125      map *tmpPath=getMapFromMaps(m,"main","sessPath");
2126      if(tmpPath==NULL)
2127        tmpPath=getMapFromMaps(m,"main","tmpPath");
2128      char *tmp1=strtok(tcook,";");
2129      if(tmp1!=NULL)
2130        sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(tmp1,"=")+1);
2131      else
2132        sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(cgiCookie,"=")+1);
2133      free(tcook);
2134      maps *tmpSess=(maps*)malloc(MAPS_SIZE);
2135      struct stat file_status;
2136      int istat = stat(session_file_path, &file_status);
2137      if(istat==0 && file_status.st_size>0){
2138        conf_read(session_file_path,tmpSess);
2139        addMapsToMaps(&m,tmpSess);
2140        freeMaps(&tmpSess);
2141      }else{
2142        errorException(m, _("Unable to read your session file."), "InternalError");
2143        free(tmpSess);
2144        freeService(&s1);
2145        free(s1);
2146        freeMaps(&m);
2147        free(m);
2148        freeMaps(&request_input_real_format);
2149        free(request_input_real_format);
2150        freeMaps(&request_output_real_format);
2151        free(request_output_real_format);
2152        free(REQUEST);
2153        free(SERVICE_URL);
2154        return 1;
2155      }
2156      free(tmpSess);
[92]2157    }
2158  }
[32]2159  addMapsToMaps(&m,_tmpMaps);
2160  freeMaps(&_tmpMaps);
2161  free(_tmpMaps);
2162
[1]2163#ifdef DEBUG
2164  dumpMap(request_inputs);
2165#endif
[216]2166#ifdef WIN32
2167  char *cgiSidL=NULL;
2168  if(getenv("CGISID")!=NULL)
[331]2169    addToMap(request_inputs,"cgiSid",getenv("CGISID"));
[216]2170  map* test1=getMap(request_inputs,"cgiSid");
2171  if(test1!=NULL){
2172    cgiSid=test1->value;
2173    addToMap(request_inputs,"storeExecuteResponse","true");
2174    addToMap(request_inputs,"status","true");
[384]2175    setMapInMaps(m,"lenv","sid",test1->value);
[216]2176    status=getMap(request_inputs,"status");
[384]2177    printf("cgiSid %s\n",cgiSid);
[216]2178  }
2179#endif
[384]2180  int hrstd=-1;
2181  char *fbkp,*fbkp1;
2182  FILE *f0,*f1;
[72]2183  if(status!=NULL)
2184    if(strcasecmp(status->value,"false")==0)
[364]2185      status=NULLMAP;
[72]2186  if(status==NULLMAP){
[34]2187    loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
2188  }
[1]2189  else{
[364]2190    int   pid;
[1]2191#ifdef DEBUG
2192    fprintf(stderr,"\nPID : %d\n",cpid);
2193#endif
[9]2194
[1]2195#ifndef WIN32
[9]2196    pid = fork ();
[1]2197#else
[216]2198    if(cgiSid==NULL){
2199      createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format);
2200      pid = cpid;
2201    }else{
2202      pid=0;
2203      cpid=atoi(cgiSid);
[384]2204      printf("cgiSid %s\n",cgiSid);
[216]2205    }
[384]2206    //printf("pid cpid %d %d\n",pid,cpid);
2207    //fflush(stderr);
[1]2208#endif
2209    if (pid > 0) {
2210      /**
2211       * dady :
2212       * set status to SERVICE_ACCEPTED
2213       */
2214#ifdef DEBUG
2215      fprintf(stderr,"father pid continue (origin %d) %d ...\n",cpid,getpid());
2216#endif
2217      eres=SERVICE_ACCEPTED;
2218    }else if (pid == 0) {
2219      /**
2220       * son : have to close the stdout, stdin and stderr to let the parent
2221       * process answer to http client.
2222       */
2223      r_inputs=getMapFromMaps(m,"main","tmpPath");
[9]2224      map* r_inputs1=getMap(s1->content,"ServiceProvider");
[384]2225      fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
[9]2226      sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid);
[384]2227      char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
[9]2228      sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid);
[1]2229#ifdef DEBUG
2230      fprintf(stderr,"RUN IN BACKGROUND MODE \n");
2231      fprintf(stderr,"son pid continue (origin %d) %d ...\n",cpid,getpid());
[9]2232      fprintf(stderr,"\nFILE TO STORE DATA %s\n",r_inputs->value);
[1]2233#endif
[216]2234      freopen(flog,"w+",stderr);
[384]2235      f0=freopen(fbkp , "w+", stdout);
[1]2236      fclose(stdin);
[9]2237      free(flog);
[1]2238      /**
2239       * set status to SERVICE_STARTED and flush stdout to ensure full
2240       * content was outputed (the file used to store the ResponseDocument).
2241       * The rewind stdout to restart writing from the bgining of the file,
2242       * this way the data will be updated at the end of the process run.
2243       */
[9]2244      printProcessResponse(m,request_inputs,cpid,
[216]2245                           s1,r_inputs1->value,SERVICE_STARTED,
2246                           request_input_real_format,
2247                           request_output_real_format);
2248#ifndef WIN32
[1]2249      fflush(stdout);
2250      rewind(stdout);
[384]2251#else
[216]2252#endif
[384]2253      fbkp1=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
2254      sprintf(fbkp1,"%s/%s_final_%d.xml",r_inputs->value,r_inputs1->value,cpid);
2255      f1=freopen(fbkp1 , "w+", stdout);
[34]2256      loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
[1]2257    } else {
2258      /**
2259       * error server don't accept the process need to output a valid
2260       * error response here !!!
2261       */
[34]2262      eres=-1;
2263      errorException(m, _("Unable to run the child process properly"), "InternalError");
[1]2264    }
2265  }
2266
2267#ifdef DEBUG
2268  dumpMaps(request_output_real_format);
2269#endif
[9]2270  if(eres!=-1)
2271    outputResponse(s1,request_input_real_format,
2272                   request_output_real_format,request_inputs,
2273                   cpid,m,eres);
[216]2274  fflush(stdout);
[105]2275  /**
2276   * Ensure that if error occurs when freeing memory, no signal will return
2277   * an ExceptionReport document as the result was already returned to the
2278   * client.
2279   */
2280#ifndef USE_GDB
2281  (void) signal(SIGSEGV,donothing);
2282  (void) signal(SIGTERM,donothing);
2283  (void) signal(SIGINT,donothing);
2284  (void) signal(SIGILL,donothing);
2285  (void) signal(SIGFPE,donothing);
2286  (void) signal(SIGABRT,donothing);
2287#endif
[1]2288
[32]2289  if(((int)getpid())!=cpid){
2290    fclose(stdout);
2291    fclose(stderr);
2292    unhandleStatus(m);
[384]2293    /**
2294     * Dump back the final file fbkp1 to fbkp
2295     */
2296    fclose(f0);
2297    fclose(f1);
2298    FILE* f2=fopen(fbkp1,"rb");
2299    FILE* f3=fopen(fbkp,"wb+");
2300    free(fbkp);
2301    free(fbkp1);
2302    fseek(f2,0,SEEK_END);
2303    long flen=ftell(f2);
2304    fseek(f2,0,SEEK_SET);
2305    char *tmps1=(char*)malloc((flen+1)*sizeof(char));
2306    fread(tmps1,flen,1,f2);
2307    fwrite(tmps1,1,flen,f3);
2308    fclose(f2);
2309    fclose(f3);
[32]2310  }
2311
[9]2312  freeService(&s1);
2313  free(s1);
[59]2314  freeMaps(&m);
[9]2315  free(m);
2316 
2317  freeMaps(&request_input_real_format);
2318  free(request_input_real_format);
[25]2319 
[59]2320  freeMaps(&request_output_real_format);
2321  free(request_output_real_format);
[9]2322 
2323  free(REQUEST);
2324  free(SERVICE_URL);
[1]2325#ifdef DEBUG
2326  fprintf(stderr,"Processed response \n");
2327  fflush(stdout);
2328  fflush(stderr);
2329#endif
2330
2331  return 0;
2332}
[364]2333
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