source: trunk/zoo-kernel/service_internal.c @ 26

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

ZOO-Kernel updates and bug fixes :

  • Fixing gestion of RawDataOutput? when the Service return SERVICE_FAILED an ExceptionReport? was returned to the client.
  • Use gcc when compiling service_internal.c to avoid strange error messages about switch ....
  • Function setMapInMaps was added in service.h to let users set the value of a specific map in a maps.
  • Fixing JavaScript? issue during the context destruction process.
  • Use the GetStatus? ZOO Service when it is available on the local installation for statusLocation.
  • Add some comments for ServiceStarted?, ServiceSucceeded?, ServiceFailed? and ServiceAccepted?.
  • Dynamic creation of a lenv maps in the main configuration file maps, containing the current status and a sid (Service ID). Those informations can be used later by the GetStatus? Service to let user check the on-going status during the Service runs.
  • Function updateStatus was added to service_internal.h which let the Services developers set the current percentCompleted value.

ZOO-Service updates and bug fixes :

  • Add GetStatus? Service and its demo longProcess Service. All are in the wps_status.zo Services Provider.
  • Use the setMapInMaps in the base-vect-ops code to enhance readibility.

ZOO-API updates :

  • Add the function ZOO.UpdateStatus? to the ZOO JavaScript? API which simply point on ZOOUpdateStatus which can be called as-is from JavaScript?. Use : ZOOUpdateStatus(conf,value) where conf is the main configuration file maps and value the the value of the current status.
File size: 46.6 KB
Line 
1/**
2 * Author : Gérald FENOY
3 *
4 * Copyright (c) 2009-2010 GeoLabs SARL
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#include "service_internal.h"
26
27/* Converts a hex character to its integer value */
28char from_hex(char ch) {
29  return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
30}
31
32/* Converts an integer value to its hex character*/
33char to_hex(char code) {
34  static char hex[] = "0123456789abcdef";
35  return hex[code & 15];
36}
37
38void* unhandleStatus(maps *conf){
39  int shmid,i;
40  key_t key;
41  void *shm;
42  struct shmid_ds shmids;
43  char *s,*s1;
44  map *tmpMap=getMapFromMaps(conf,"lenv","sid");
45  if(tmpMap!=NULL){
46    key=atoi(tmpMap->value);
47    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
48#ifdef DEBUG
49      fprintf(stderr,"shmget failed to update value\n");
50#endif
51    }else{
52      if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
53#ifdef DEBUG
54        fprintf(stderr,"shmat failed to update value\n");
55#endif
56      }else{
57        shmdt(shm);
58        shmctl(shmid,IPC_RMID,&shmids);
59      }
60    }
61  }
62}
63
64#ifdef USE_JS
65
66JSBool
67JSUpdateStatus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
68{
69  JS_MaybeGC(cx);
70  char *sid;
71  int istatus=0;
72  char *status=NULL;
73  maps *conf;
74  int i=0;
75  if(argc>2){
76#ifdef JS_DEBUG
77    fprintf(stderr,"Number of arguments used to call the function : %i",argc);
78#endif
79    return JS_FALSE;
80  }
81  conf=mapsFromJSObject(cx,argv[0]);
82  dumpMaps(conf);
83  if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
84    char tmpStatus[4];
85    sprintf(tmpStatus,"%i",istatus);
86    tmpStatus[3]=0;
87    status=strdup(tmpStatus);
88  }
89  if(getMapFromMaps(conf,"lenv","status")!=NULL){
90    if(status!=NULL)
91      setMapInMaps(conf,"lenv","status",status);
92    else
93      setMapInMaps(conf,"lenv","status","15");
94    updateStatus(conf);
95  }
96  freeMaps(&conf);
97  free(conf);
98  JS_MaybeGC(cx);
99  return JS_TRUE;
100}
101
102#endif
103
104void* updateStatus(maps *conf){
105  int shmid,i;
106  key_t key;
107  char *shm,*s,*s1;
108  map *tmpMap=NULL;
109  tmpMap=getMapFromMaps(conf,"lenv","sid");
110  if(tmpMap!=NULL){
111    key=atoi(tmpMap->value);
112    if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
113#ifdef DEBUG
114      fprintf(stderr,"shmget failed to update value\n");
115#endif
116    }else{
117      if ((shm = (char*) shmat(shmid, NULL, 0)) == (char *) -1) {
118#ifdef DEBUG
119        fprintf(stderr,"shmat failed to update value\n");
120#endif
121      }
122      else{
123        tmpMap=getMapFromMaps(conf,"lenv","status");
124        s1=shm;
125        for(s=tmpMap->value;*s!=NULL;s++)
126          *s1++=*s;
127        shmdt((void *)shm);
128      }
129    }
130  }
131}
132
133char* getStatus(int pid){
134  int shmid,i;
135  key_t key;
136  void *shm;
137  char *s;
138  key=pid;
139  if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
140#ifdef DEBUG
141    fprintf(stderr,"shmget failed in getStatus\n");
142#endif
143  }else{
144    if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
145#ifdef DEBUG
146      fprintf(stderr,"shmat failed in getStatus\n");
147#endif
148    }else{
149      return (char*)shm;
150    }
151  }
152  return "-1";
153}
154
155
156/* Returns a url-encoded version of str */
157/* IMPORTANT: be sure to free() the returned string after use */
158char *url_encode(char *str) {
159  char *pstr = str, *buf = (char*) malloc(strlen(str) * 3 + 1), *pbuf = buf;
160  while (*pstr) {
161    if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') 
162      *pbuf++ = *pstr;
163    else if (*pstr == ' ') 
164      *pbuf++ = '+';
165    else 
166      *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
167    pstr++;
168  }
169  *pbuf = '\0';
170  return buf;
171}
172
173/* Returns a url-decoded version of str */
174/* IMPORTANT: be sure to free() the returned string after use */
175char *url_decode(char *str) {
176  char *pstr = str, *buf = (char*) malloc(strlen(str) + 1), *pbuf = buf;
177  while (*pstr) {
178    if (*pstr == '%') {
179      if (pstr[1] && pstr[2]) {
180        *pbuf++ = from_hex(pstr[1]) << 4 | from_hex(pstr[2]);
181        pstr += 2;
182      }
183    } else if (*pstr == '+') { 
184      *pbuf++ = ' ';
185    } else {
186      *pbuf++ = *pstr;
187    }
188    pstr++;
189  }
190  *pbuf = '\0';
191  return buf;
192}
193
194char *zCapitalize1(char *tmp){
195        char *res=strdup(tmp);
196        if(res[0]>=97 && res[0]<=122)
197                res[0]-=32;
198        return res;
199}
200
201char *zCapitalize(char *tmp){
202  int i=0;
203  char *res=strdup(tmp);
204  for(i=0;i<strlen(res);i++)
205    if(res[i]>=97 && res[i]<=122)
206      res[i]-=32;
207  return res;
208}
209
210
211int zooXmlSearchForNs(char* name){
212  int i;
213  int res=-1;
214  for(i=0;i<nbNs;i++)
215    if(strncasecmp(name,nsName[i],strlen(nsName[i]))==0){
216      res=i;
217      break;
218    }
219  return res;
220}
221
222int zooXmlAddNs(xmlNodePtr nr,char* url,char* name){
223#ifdef DEBUG
224  fprintf(stderr,"zooXmlAddNs %d \n",nbNs);
225#endif
226  int currId=-1;
227  if(nbNs==0){
228    nbNs++;
229    currId=0;
230    nsName[currId]=strdup(name);
231    usedNs[currId]=xmlNewNs(nr,BAD_CAST url,BAD_CAST name);
232  }else{
233    currId=zooXmlSearchForNs(name);
234    if(currId<0){
235      nbNs++;
236      currId=nbNs-1;
237      nsName[currId]=strdup(name);
238      usedNs[currId]=xmlNewNs(nr,BAD_CAST url,BAD_CAST name);
239    }
240  }
241  return currId;
242}
243
244void zooXmlCleanupNs(){
245  int j;
246#ifdef DEBUG
247  fprintf(stderr,"zooXmlCleanup %d\n",nbNs);
248#endif
249  for(j=nbNs-1;j>=0;j--){
250#ifdef DEBUG
251    fprintf(stderr,"zooXmlCleanup %d\n",j);
252#endif
253    if(j==0)
254      xmlFreeNs(usedNs[j]);
255    free(nsName[j]);
256    nbNs--;
257  }
258  nbNs=0;
259}
260
261xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr doc,char* service,maps* m){
262
263  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
264  xmlNodePtr n,nc,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
265  xmlChar *xmlbuff;
266  int buffersize;
267  /**
268   * Create the document and its temporary root.
269   */
270  int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
271  ns=usedNs[wpsId];
272  maps* toto1=getMaps(m,"main");
273
274  n = xmlNewNode(ns, BAD_CAST "Capabilities");
275  int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
276  ns_ows=usedNs[owsId];
277  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
278  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
279  ns_xsi=usedNs[xsiId];
280  int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
281  ns_xlink=usedNs[xlinkId];
282  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd"); 
283  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
284 
285  if(toto1!=NULL){
286    map* tmp=getMap(toto1->content,"version");
287    if(tmp!=NULL){
288      xmlNewProp(n,BAD_CAST "version",BAD_CAST tmp->value);
289    }
290    else
291      xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
292  }
293  else
294    xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
295
296  char tmp[256];
297 
298  nc = xmlNewNode(ns_ows, BAD_CAST "ServiceIdentification");
299  maps* tmp4=getMaps(m,"identification");
300  if(tmp4!=NULL){
301    map* tmp2=tmp4->content;
302    while(tmp2!=NULL){
303      if(strncasecmp(tmp2->name,"keywords",8)!=0 &&
304         strncasecmp(tmp2->name,"serverAddress",13)!=0 &&
305         strncasecmp(tmp2->name,"lang",4)!=0 &&
306         strncasecmp(tmp2->name,"encoding",8)!=0 &&
307         strncasecmp(tmp2->name,"version",7)!=0){
308        tmp2->name[0]=toupper(tmp2->name[0]);
309        nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
310        xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
311        xmlAddChild(nc,nc1);
312      }
313      else
314        if(strcmp(tmp2->name,"keywords")==0){
315          nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords");
316          char *toto=tmp2->value;
317          char buff[256];
318          int i=0;
319          int j=0;
320          while(toto[i]){
321            if(toto[i]!=',' && toto[i]!=0){
322              buff[j]=toto[i];
323              buff[j+1]=0;
324              j++;
325            }
326            else{
327              nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword");
328              xmlAddChild(nc2,xmlNewText(BAD_CAST buff));             
329              xmlAddChild(nc1,nc2);
330              j=0;
331            }
332            i++;
333          }
334          if(strlen(buff)>0){
335            nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword");
336            xmlAddChild(nc2,xmlNewText(BAD_CAST buff));       
337            xmlAddChild(nc1,nc2);
338          }
339          xmlAddChild(nc,nc1);
340          nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceType");
341          xmlAddChild(nc2,xmlNewText(BAD_CAST "WPS"));
342          xmlAddChild(nc,nc2);
343          nc2 = xmlNewNode(ns_ows, BAD_CAST "ServiceTypeVersion");
344          xmlAddChild(nc2,xmlNewText(BAD_CAST "1.0.0"));
345          xmlAddChild(nc,nc2);   
346        }
347      tmp2=tmp2->next;
348    }
349  }
350  else{
351    fprintf(stderr,"TMP4 NOT FOUND !!");
352    //dumpMaps(tmp4);
353    return NULL;
354  }
355  xmlAddChild(n,nc);
356
357  nc = xmlNewNode(ns_ows, BAD_CAST "ServiceProvider");
358  nc3 = xmlNewNode(ns_ows, BAD_CAST "ServiceContact");
359  nc4 = xmlNewNode(ns_ows, BAD_CAST "ContactInfo");
360  nc5 = xmlNewNode(ns_ows, BAD_CAST "Phone");
361  nc6 = xmlNewNode(ns_ows, BAD_CAST "Address");
362  tmp4=getMaps(m,"provider");
363  if(tmp4!=NULL){
364    map* tmp2=tmp4->content;
365    while(tmp2!=NULL){
366      if(strcmp(tmp2->name,"keywords")!=0 &&
367         strcmp(tmp2->name,"serverAddress")!=0 &&
368         strcmp(tmp2->name,"lang")!=0){
369        tmp2->name[0]=toupper(tmp2->name[0]);
370        if(strcmp(tmp2->name,"ProviderName")==0){
371          nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
372          xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
373          xmlAddChild(nc,nc1);
374        }
375        else{
376          if(strcmp(tmp2->name,"ProviderSite")==0){
377            nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
378            xmlNewNsProp(nc1,ns_xlink,BAD_CAST "href",BAD_CAST tmp2->value);
379            xmlAddChild(nc,nc1);
380          } 
381          else 
382            if(strcmp(tmp2->name,"IndividualName")==0 || 
383               strcmp(tmp2->name,"PositionName")==0){
384              nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
385              xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
386              xmlAddChild(nc3,nc1);
387            } 
388            else 
389              if(strncmp(tmp2->name,"Phone",5)==0){
390                char *toto=NULL;
391                char *toto1=tmp2->name;
392                toto=strstr(toto1,"Phone");
393                nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
394                xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
395                xmlAddChild(nc5,nc1);
396              }
397              else 
398                if(strncmp(tmp2->name,"Address",7)==0){
399                  char *toto=NULL;
400                  char *toto1=tmp2->name;
401                  toto=strstr(toto1,"Address");
402                  nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
403                  xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
404                  xmlAddChild(nc6,nc1);
405                }
406        }
407      }
408      else
409        if(strcmp(tmp2->name,"keywords")==0){
410          nc1 = xmlNewNode(ns_ows, BAD_CAST "Keywords");
411          char *toto=tmp2->value;
412          char buff[256];
413          int i=0;
414          int j=0;
415          while(toto[i]){
416            if(toto[i]!=',' && toto[i]!=0){
417              buff[j]=toto[i];
418              buff[j+1]=0;
419              j++;
420            }
421            else{
422              nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword");
423              xmlAddChild(nc2,xmlNewText(BAD_CAST buff));             
424              xmlAddChild(nc1,nc2);
425              j=0;
426            }
427            i++;
428          }
429          if(strlen(buff)>0){
430            nc2 = xmlNewNode(ns_ows, BAD_CAST "Keyword");
431            xmlAddChild(nc2,xmlNewText(BAD_CAST buff));       
432            xmlAddChild(nc1,nc2);
433          }
434          xmlAddChild(nc,nc1);
435        }
436      tmp2=tmp2->next;
437    }
438  }
439  else{
440    fprintf(stderr,"TMP4 NOT FOUND !!");
441    //dumpMaps(tmp4);
442  }
443  xmlAddChild(nc4,nc5);
444  xmlAddChild(nc4,nc6);
445  xmlAddChild(nc3,nc4);
446  xmlAddChild(nc,nc3);
447  xmlAddChild(n,nc);
448
449
450  nc = xmlNewNode(ns_ows, BAD_CAST "OperationsMetadata");
451  char *tmp2[3];
452  tmp2[0]=strdup("GetCapabilities");
453  tmp2[1]=strdup("DescribeProcess");
454  tmp2[2]=strdup("Execute");
455  int j=0;
456
457  if(toto1!=NULL){
458    map* tmp=getMap(toto1->content,"serverAddress");
459    if(tmp!=NULL){
460      SERVICE_URL = strdup(tmp->value);
461    }
462    else
463      SERVICE_URL = strdup("not_found");
464  }
465  else
466    SERVICE_URL = strdup("not_found");
467
468  for(j=0;j<3;j++){
469    nc1 = xmlNewNode(ns_ows, BAD_CAST "Operation");
470    xmlNewProp(nc1,BAD_CAST "name",BAD_CAST tmp2[j]);
471    nc2 = xmlNewNode(ns_ows, BAD_CAST "DCP");
472    nc3 = xmlNewNode(ns_ows, BAD_CAST "HTTP");
473    nc4 = xmlNewNode(ns_ows, BAD_CAST "Get");
474    sprintf(tmp,"%s/%s",SERVICE_URL,service);
475    xmlNewNsProp(nc4,ns_xlink,BAD_CAST "href",BAD_CAST tmp);
476    xmlAddChild(nc3,nc4);
477    if(j>0){
478      nc4 = xmlNewNode(ns_ows, BAD_CAST "Post");
479      xmlNewNsProp(nc4,ns_xlink,BAD_CAST "href",BAD_CAST tmp);
480      xmlAddChild(nc3,nc4);
481    }
482    xmlAddChild(nc2,nc3);
483    xmlAddChild(nc1,nc2);   
484    xmlAddChild(nc,nc1);   
485  }
486  for(j=2;j>=0;j--)
487    free(tmp2[j]);
488  xmlAddChild(n,nc);
489
490  nc = xmlNewNode(ns, BAD_CAST "ProcessOfferings");
491  xmlAddChild(n,nc);
492
493  nc1 = xmlNewNode(ns, BAD_CAST "Languages");
494  nc2 = xmlNewNode(ns, BAD_CAST "Default");
495  nc3 = xmlNewNode(ns, BAD_CAST "Supported");
496 
497  toto1=getMaps(m,"main");
498  if(toto1!=NULL){
499    map* tmp1=getMap(toto1->content,"lang");
500    char *toto=tmp1->value;
501    char buff[256];
502    int i=0;
503    int j=0;
504    int dcount=0;
505    while(toto[i]){
506      if(toto[i]!=',' && toto[i]!=0){
507        buff[j]=toto[i];
508        buff[j+1]=0;
509        j++;
510      }
511      else{
512        nc4 = xmlNewNode(ns_ows, BAD_CAST "Language");
513        xmlAddChild(nc4,xmlNewText(BAD_CAST buff));
514        if(dcount==0){
515          xmlAddChild(nc2,nc4);
516          xmlAddChild(nc1,nc2);
517          xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST buff);
518          dcount++;
519        }
520        nc4 = xmlNewNode(ns_ows, BAD_CAST "Language");
521        xmlAddChild(nc4,xmlNewText(BAD_CAST buff));
522        xmlAddChild(nc3,nc4);
523        j=0;
524        buff[j]=0;
525      }
526      i++;
527    }
528    if(strlen(buff)>0){
529      nc4 = xmlNewNode(ns_ows, BAD_CAST "Language");
530      xmlAddChild(nc4,xmlNewText(BAD_CAST buff));             
531      xmlAddChild(nc3,nc4);
532    }
533  }
534  xmlAddChild(nc1,nc3);
535  xmlAddChild(n,nc1);
536 
537  xmlDocSetRootElement(doc, n);
538  //xmlFreeNs(ns);
539  free(SERVICE_URL);
540  return nc;
541}
542
543void printGetCapabilitiesForProcess(maps* m,xmlNodePtr nc,service* serv){
544  xmlNsPtr ns,ns_ows,ns_xlink;
545  xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
546  /**
547   * Initialize or get existing namspaces
548   */
549  int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
550  ns=usedNs[wpsId];
551  int owsId=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
552  ns_ows=usedNs[owsId];
553  int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
554  ns_xlink=usedNs[xlinkId];
555
556  int cursor=0;
557  map* tmp1;
558  if(serv->content!=NULL){
559    nc1 = xmlNewNode(ns, BAD_CAST "Process");
560    tmp1=getMap(serv->content,"processVersion");
561    if(tmp1!=NULL)
562      xmlNewNsProp(nc1,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);
563    printDescription(nc1,ns_ows,serv->name,serv->content);
564    tmp1=serv->metadata;
565    while(tmp1!=NULL){
566      nc2 = xmlNewNode(ns_ows, BAD_CAST "Metadata");
567      xmlNewNsProp(nc2,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
568      xmlAddChild(nc1,nc2);
569      tmp1=tmp1->next;
570    }
571    xmlAddChild(nc,nc1);
572  }
573}
574
575xmlNodePtr printDescribeProcessHeader(xmlDocPtr doc,char* service,maps* m){
576
577  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
578  xmlNodePtr n,nr;
579  xmlChar *xmlbuff;
580  int buffersize;
581
582  int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps");
583  ns=usedNs[wpsId];
584  n = xmlNewNode(ns, BAD_CAST "ProcessDescriptions");
585  int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
586  ns_ows=usedNs[owsId];
587  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
588  zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
589  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
590  ns_xsi=usedNs[xsiId];
591 
592  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd");
593  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
594  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
595  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
596
597  xmlDocSetRootElement(doc, n);
598
599  return n;
600}
601
602void printDescribeProcessForProcess(maps* m,xmlNodePtr nc,service* serv,int sc){
603  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
604  xmlNodePtr nr,n,nc1,nc2,nc3,nc4,nc5,nc6,pseudor;
605
606  char tmp[256];
607  n=nc;
608 
609  int wpsId=zooXmlAddNs(NULL,"http://schemas.opengis.net/wps/1.0.0","wps");
610  ns=usedNs[wpsId];
611  int owsId=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows");
612  ns_ows=usedNs[owsId];
613  int xlinkId=zooXmlAddNs(NULL,"http://www.w3.org/1999/xlink","xlink");
614  ns_xlink=usedNs[xlinkId];
615
616  nc = xmlNewNode(NULL, BAD_CAST "ProcessDescription");
617  char *tmp4[3];
618  tmp4[0]="processVersion";
619  tmp4[1]="storeSupported";
620  tmp4[2]="statusSupported";
621  int j=0;
622  map* tmp1=NULL;
623  for(j=0;j<3;j++){
624    tmp1=getMap(serv->content,tmp4[j]);
625    if(tmp1!=NULL){
626      if(j==0)
627        xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST tmp1->value);     
628      else
629        xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST tmp1->value);     
630    }
631    else{
632      if(j>0)
633        xmlNewProp(nc,BAD_CAST tmp4[j],BAD_CAST "false");     
634    }
635  }
636 
637  printDescription(nc,ns_ows,serv->name,serv->content);
638
639  tmp1=serv->metadata;
640  while(tmp1!=NULL){
641    nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata");
642    xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
643    xmlAddChild(nc,nc1);
644    tmp1=tmp1->next;
645  }
646
647  tmp1=getMap(serv->content,"Profile");
648  if(tmp1!=NULL){
649    nc1 = xmlNewNode(ns, BAD_CAST "Profile");
650    xmlAddChild(nc1,xmlNewText(BAD_CAST tmp1->value));
651    xmlAddChild(nc,nc1);
652  }
653
654  nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs");
655 
656  elements* e=serv->inputs;
657  while(e!=NULL){
658    nc2 = xmlNewNode(NULL, BAD_CAST "Input");
659    tmp1=getMap(e->content,"minOccurs");
660    if(tmp1){
661      xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
662    }
663    tmp1=getMap(e->content,"maxOccurs");
664    if(tmp1){
665      xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
666    }
667
668    printDescription(nc2,ns_ows,e->name,e->content);
669
670
671    nc3 = xmlNewNode(NULL, BAD_CAST e->format);
672    iotype* _tmp=e->defaults;
673    int datatype=0;
674    if(_tmp!=NULL){
675      int isAnyValue=1;
676      if(strcmp(e->format,"LiteralData")!=0){
677        nc4 = xmlNewNode(NULL, BAD_CAST "Default");
678        nc5 = xmlNewNode(NULL, BAD_CAST "Format");
679      }
680      else{
681        nc4 = xmlNewNode(NULL, BAD_CAST "UOMs");
682        nc5 = xmlNewNode(NULL, BAD_CAST "Default");
683        datatype=1;
684      }
685      tmp1=_tmp->content;
686      int default1=0;
687      xmlNodePtr nc7;
688      while(tmp1!=NULL){
689#ifdef DEBUG
690        printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
691#endif
692        if(strncasecmp(tmp1->name,"DataType",8)==0){
693          nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType");
694          xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
695          char tmp[1024];
696          sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value);
697          xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp);
698          xmlAddChild(nc3,nc6);
699          tmp1=tmp1->next;
700          continue;
701        }
702        if(strcasecmp(tmp1->name,"asReference")!=0 && 
703           strcasecmp(tmp1->name,"DataType")!=0 && 
704           strncasecmp(tmp1->name,"AllowedValues",13)!=0 &&
705           strcasecmp(tmp1->name,"value")!=0 &&
706           strcasecmp(tmp1->name,"extension")!=0){
707          if(datatype==0){
708            char *tmp2=zCapitalize1(tmp1->name);
709            nc6 = xmlNewNode(NULL, BAD_CAST tmp2);
710            free(tmp2);
711          }
712          else{
713            char *tmp2=zCapitalize(tmp1->name);
714            nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2);
715            free(tmp2);
716          }
717          xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
718          xmlAddChild(nc5,nc6);
719        }
720        else{
721          if(strcmp(tmp1->name,"value")==0){
722            nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue");
723            xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value));
724            default1=1;
725          }
726          if(strncasecmp(tmp1->name,"AllowedValues",13)==0){
727            nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues");
728            char *token,*saveptr1;
729            token=strtok_r(tmp1->value,",",&saveptr1);
730            while(token!=NULL){
731                nc7 = xmlNewNode(ns_ows, BAD_CAST "Value");
732                char *tmps=strdup(token);
733                tmps[strlen(tmps)]=0;
734                xmlAddChild(nc7,xmlNewText(BAD_CAST tmps));
735                fprintf(stderr,"strgin : %s\n",tmps);
736                xmlAddChild(nc6,nc7);
737                token=strtok_r(NULL,",",&saveptr1);
738            }
739            xmlAddChild(nc3,nc6);
740            isAnyValue=-1;
741          }
742        }
743        tmp1=tmp1->next;
744      }
745      xmlAddChild(nc4,nc5);
746      xmlAddChild(nc3,nc4);
747      if(datatype==1 && isAnyValue==1){
748        xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));
749        if(default1>0)
750          xmlAddChild(nc3,nc7);
751      }
752      if(datatype==1 && default1>0)
753        xmlAddChild(nc3,nc7);
754    }
755    xmlAddChild(nc2,nc3);
756   
757    _tmp=e->supported;
758    while(_tmp!=NULL){
759      if(datatype==0){
760        nc4 = xmlNewNode(NULL, BAD_CAST "Supported");
761        nc5 = xmlNewNode(NULL, BAD_CAST "Format");
762      }
763      else{
764        nc5 = xmlNewNode(NULL, BAD_CAST "Supported");
765      }
766      tmp1=_tmp->content;
767      while(tmp1!=NULL){
768        /*if(strcmp(e->format,"LiteralData")==0)
769          xmlAddChild(nc5,nc6);*/
770        if(datatype==0){
771          char *tmp2=zCapitalize1(tmp1->name);
772          nc6 = xmlNewNode(NULL, BAD_CAST tmp2);
773          free(tmp2);
774        }
775        else{
776          char *tmp2=zCapitalize(tmp1->name);     
777          nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2);
778          free(tmp2);
779        }
780        xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
781        xmlAddChild(nc5,nc6);
782        tmp1=tmp1->next;
783      }
784      if(datatype==0){
785        xmlAddChild(nc4,nc5);
786        xmlAddChild(nc3,nc4);
787      }else{
788        xmlAddChild(nc4,nc5);
789        //xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));
790      }
791      _tmp=_tmp->next;
792      if(strcmp(e->format,"LiteralData")!=0){
793        xmlAddChild(nc2,nc3);
794      }
795      xmlAddChild(nc1,nc2);
796    }
797   
798   
799    e=e->next;
800  }
801  xmlAddChild(nc,nc1);
802
803  nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs");
804 
805  e=serv->outputs;
806  while(e!=NULL){
807    nc2 = xmlNewNode(NULL, BAD_CAST "Output");
808    tmp1=getMap(e->content,"minOccurs");
809    if(tmp1){
810      xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
811    }
812    tmp1=getMap(e->content,"maxOccurs");
813    if(tmp1){
814      xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value);
815    }
816
817    printDescription(nc2,ns_ows,e->name,e->content);
818
819    if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0)
820      nc3 = xmlNewNode(NULL, BAD_CAST "LiteralOutput");
821    else
822      if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0)
823        nc3 = xmlNewNode(NULL, BAD_CAST "ComplexOutput");
824      else
825        nc3 = xmlNewNode(NULL, BAD_CAST e->format);
826    iotype* _tmp=e->defaults;
827    int datatype=0;
828    if(_tmp!=NULL){
829     if(strcmp(e->format,"LiteralOutput")==0 ||
830        strcmp(e->format,"LiteralData")==0){
831        datatype=1;
832        nc4 = xmlNewNode(NULL, BAD_CAST "UOMs");
833        nc5 = xmlNewNode(NULL, BAD_CAST "Default");
834     }
835      else{
836        nc4 = xmlNewNode(NULL, BAD_CAST "Default");
837        nc5 = xmlNewNode(NULL, BAD_CAST "Format");
838      }
839      tmp1=_tmp->content;
840      while(tmp1!=NULL){
841#ifdef DEBUG
842        printf("DATATYPE DEFAULT ? %s\n",tmp1->name);
843#endif
844        if(strncasecmp(tmp1->name,"DataType",8)==0){
845          nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType");
846          xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
847          char tmp[1024];
848          sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value);
849          xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp);
850          xmlAddChild(nc3,nc6);
851          tmp1=tmp1->next;
852          datatype=1;
853          continue;
854        }
855        if(strcmp(tmp1->name,"asReference")!=0 &&
856           strncasecmp(tmp1->name,"DataType",8)!=0 &&
857           strcasecmp(tmp1->name,"extension")!=0){
858          if(datatype==0){
859            char *tmp2=zCapitalize1(tmp1->name);
860            nc6 = xmlNewNode(NULL, BAD_CAST tmp2);
861            free(tmp2);
862          }
863          else{
864            char *tmp2=zCapitalize(tmp1->name);
865            nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2);
866            free(tmp2);
867          }
868          xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
869          xmlAddChild(nc5,nc6);
870        }
871        tmp1=tmp1->next;
872      }
873      xmlAddChild(nc4,nc5);
874      xmlAddChild(nc3,nc4);         
875    }
876    _tmp=e->supported;
877    while(_tmp!=NULL){
878    if(datatype==0){
879      nc4 = xmlNewNode(NULL, BAD_CAST "Supported");
880      nc5 = xmlNewNode(NULL, BAD_CAST "Format");
881      }
882      else
883      nc5 = xmlNewNode(NULL, BAD_CAST "Supported");
884      tmp1=_tmp->content;
885      while(tmp1!=NULL){
886#ifdef DEBUG
887        printf("DATATYPE SUPPORTED ? %s\n",tmp1->name);
888#endif
889        if(strcmp(tmp1->name,"asReference")!=0 && 
890           strcmp(tmp1->name,"DataType")!=0 &&
891           strcasecmp(tmp1->name,"extension")!=0){
892          if(datatype==0){
893            char *tmp2=zCapitalize1(tmp1->name);
894            nc6 = xmlNewNode(NULL, BAD_CAST tmp2);
895            free(tmp2);
896          }
897          else{
898            char *tmp2=zCapitalize(tmp1->name);
899            nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2);
900            free(tmp2);
901          }
902          xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));
903          xmlAddChild(nc5,nc6);
904        }
905        tmp1=tmp1->next;
906      }
907      _tmp=_tmp->next;
908      if(datatype==0){
909         xmlAddChild(nc4,nc5);
910         xmlAddChild(nc3,nc4);
911      }else
912      xmlAddChild(nc4,nc5);
913    }
914    xmlAddChild(nc2,nc3);
915
916    xmlAddChild(nc3,nc4);
917     
918   
919    xmlAddChild(nc2,nc3);
920   
921    xmlAddChild(nc1,nc2);
922   
923    e=e->next;
924  }
925  xmlAddChild(nc,nc1);
926
927  xmlAddChild(n,nc);
928
929}
930
931void printProcessResponse(maps* m,map* request, int pid,service* serv,char* service,int status,maps* inputs,maps* outputs){
932  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
933  xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor;
934  xmlDocPtr doc;
935  xmlChar *xmlbuff;
936  int buffersize;
937  time_t time1; 
938  time(&time1);
939  /**
940   * Create the document and its temporary root.
941   */
942  doc = xmlNewDoc(BAD_CAST "1.0");
943  int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps");
944  ns=usedNs[wpsId];
945 
946  n = xmlNewNode(ns, BAD_CAST "ExecuteResponse");
947  int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows");
948  ns_ows=usedNs[owsId];
949  int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
950  ns_xlink=usedNs[xlinkId];
951  int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
952  ns_xsi=usedNs[xsiId];
953  xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps");
954
955  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd");
956 
957  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
958  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
959  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
960  char tmp[256];
961  char url[1024];
962  memset(tmp,0,256);
963  memset(url,0,256);
964  maps* tmp_maps=getMaps(m,"main");
965  if(tmp_maps!=NULL){
966    dumpMaps(getMaps(m,"lenv"));
967    map* tmpm1=getMap(tmp_maps->content,"serverAddress");
968    /**
969     * Check if the ZOO Service GetStatus is available in the local directory.
970     * If yes, then it uses a reference to an URL which the client can access
971     * to get information on the status of a running Service (using the
972     * percentCompleted attribute).
973     * Else fallback to the initial method using the xml file to write in ...
974     */
975    char ntmp[1024];
976#ifndef WIN32
977    getcwd(ntmp,1024);
978#else
979    _getcwd(ntmp,1024);
980#endif
981    struct stat myFileInfo;
982    int statRes;
983    char file_path[1024];
984    sprintf(file_path,"%s/GetStatus.zcfg",ntmp);
985    statRes=stat(file_path,&myFileInfo);
986    if(statRes==0){
987      char currentSid[128];
988      map* tmpm=getMap(tmp_maps->content,"rewriteUrl");
989      map *tmp_lenv=NULL;
990      tmp_lenv=getMapFromMaps(m,"lenv","sid");
991      if(tmp_lenv==NULL)
992        sprintf(currentSid,"%i",pid);
993      else
994        sprintf(currentSid,"%s",tmp_lenv->value);
995      if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){
996        sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
997      }else{
998        if(strlen(tmpm->value)>0)
999          if(strcasecmp(tmpm->value,"true")!=0)
1000            sprintf(url,"%s/%s/GetStatus/%s",tmpm1->value,tmpm->value,currentSid);
1001          else
1002            sprintf(url,"%s/GetStatus/%s",tmpm1->value,currentSid);
1003        else
1004          sprintf(url,"%s/?request=Execute&amp;service=WPS&amp;version=1.0.0&amp;Identifier=GetStatus&amp;DataInputs=sid=%s&amp;RawDataOutput=Result",tmpm1->value,currentSid);
1005      }
1006    }else{
1007      map* tmpm2=getMap(tmp_maps->content,"tmpUrl");
1008      if(tmpm1!=NULL && tmpm2!=NULL){
1009        sprintf(url,"%s/%s/%s_%i.xml",tmpm1->value,tmpm2->value,service,pid);
1010      }
1011    }
1012    if(tmpm1!=NULL)
1013      sprintf(tmp,"%s/",tmpm1->value);
1014  }
1015
1016  xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp);
1017  if(status!=SERVICE_SUCCEEDED && status!=SERVICE_FAILED){
1018    xmlNewProp(n,BAD_CAST "statusLocation",BAD_CAST url);
1019  }
1020
1021  nc = xmlNewNode(ns, BAD_CAST "Process");
1022  map* tmp2=getMap(serv->content,"processVersion");
1023
1024  if(tmp2!=NULL)
1025    xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST tmp2->value);
1026 
1027  printDescription(nc,ns_ows,serv->name,serv->content);
1028  fflush(stderr);
1029
1030  xmlAddChild(n,nc);
1031
1032  nc = xmlNewNode(ns, BAD_CAST "Status");
1033  const struct tm *tm;
1034  size_t len;
1035  time_t now;
1036  char *tmp1;
1037  map *tmpStatus;
1038 
1039  now = time ( NULL );
1040  tm = localtime ( &now );
1041
1042  tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char));
1043
1044  len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm );
1045
1046  xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);
1047
1048  char sMsg[2048];
1049  switch(status){
1050  case SERVICE_SUCCEEDED:
1051    nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");
1052    sprintf(sMsg,"Service \"%s\" run successfully.",serv->name);
1053    nc3=xmlNewText(BAD_CAST sMsg);
1054    xmlAddChild(nc1,nc3);
1055    break;
1056  case SERVICE_STARTED:
1057    nc1 = xmlNewNode(ns, BAD_CAST "ProcessStarted");
1058    tmpStatus=getMapFromMaps(m,"lenv","status");
1059    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);
1060    sprintf(sMsg,"ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service.",serv->name);
1061    nc3=xmlNewText(BAD_CAST sMsg);
1062    xmlAddChild(nc1,nc3);
1063    break;
1064  case SERVICE_ACCEPTED:
1065    nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");
1066    sprintf(sMsg,"Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document.",serv->name);
1067    nc3=xmlNewText(BAD_CAST sMsg);
1068    xmlAddChild(nc1,nc3);
1069    break;
1070  case SERVICE_FAILED:
1071    nc1 = xmlNewNode(ns, BAD_CAST "ProcessFailed");
1072    map *errorMap;
1073    map *te;
1074    te=getMapFromMaps(m,"lenv","code");
1075    if(te!=NULL)
1076      errorMap=createMap("code",te->value);
1077    else
1078      errorMap=createMap("code","NoApplicableCode");
1079    te=getMapFromMaps(m,"lenv","message");
1080    if(te!=NULL)
1081      addToMap(errorMap,"text",te->value);
1082    else
1083      addToMap(errorMap,"text","No more information available");
1084    nc3=createExceptionReportNode(m,errorMap,0);
1085    xmlAddChild(nc1,nc3);
1086    break;
1087  default :
1088    printf("error code not know : %i\n",status);
1089    //exit(1);
1090    break;
1091  }
1092  xmlAddChild(nc,nc1);
1093  xmlAddChild(n,nc);
1094  free(tmp1);
1095
1096#ifdef DEBUG
1097  fprintf(stderr,"printProcessResponse 1 161\n");
1098#endif
1099
1100  map* lineage=getMap(request,"lineage");
1101  if(lineage!=NULL){
1102    nc = xmlNewNode(ns, BAD_CAST "DataInputs");
1103    int i;
1104    maps* mcursor=inputs;
1105    elements* scursor=serv->inputs;
1106    while(mcursor!=NULL /*&& scursor!=NULL*/){
1107      printIOType(doc,nc,ns,ns_ows,scursor,mcursor,"Input");
1108      mcursor=mcursor->next;
1109      //scursor=scursor->next;
1110    }
1111    xmlAddChild(n,nc);
1112   
1113#ifdef DEBUG
1114    fprintf(stderr,"printProcessResponse 1 177\n");
1115#endif
1116
1117    nc = xmlNewNode(ns, BAD_CAST "OutputDefinitions");
1118    mcursor=outputs;
1119    scursor=serv->outputs;
1120    while(mcursor!=NULL /*&& scursor!=NULL*/){
1121      printOutputDefinitions1(doc,nc,ns,ns_ows,scursor,mcursor,"Output");
1122      mcursor=mcursor->next;
1123      //scursor=scursor->next;
1124    }
1125    xmlAddChild(n,nc);
1126  }
1127#ifdef DEBUG
1128  fprintf(stderr,"printProcessResponse 1 190\n");
1129#endif
1130
1131  /**
1132   * Display the process output only when requested !
1133   */
1134  if(status==SERVICE_SUCCEEDED){
1135    nc = xmlNewNode(ns, BAD_CAST "ProcessOutputs");
1136    maps* mcursor=outputs;
1137    elements* scursor=serv->outputs;
1138    while(mcursor!=NULL && scursor!=NULL){
1139      printIOType(doc,nc,ns,ns_ows,scursor,mcursor,"Output");
1140      mcursor=mcursor->next;
1141      scursor=scursor->next;
1142    }
1143    xmlAddChild(n,nc);
1144  }
1145#ifdef DEBUG
1146  fprintf(stderr,"printProcessResponse 1 202\n");
1147#endif
1148  xmlDocSetRootElement(doc, n);
1149  printDocument(m,doc,pid);
1150
1151  xmlCleanupParser();
1152  zooXmlCleanupNs();
1153}
1154
1155
1156void printDocument(maps* m, xmlDocPtr doc,int pid){
1157  rewind(stdout);
1158  char *encoding=getEncoding(m);
1159  if(pid==getpid()){
1160    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
1161  }
1162  fflush(stdout);
1163  xmlChar *xmlbuff;
1164  int buffersize;
1165  /*
1166   * Dump the document to a buffer and print it on stdout
1167   * for demonstration purposes.
1168   */
1169  xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
1170  printf((char *) xmlbuff);
1171  //fflush(stdout);
1172  /*
1173   * Free associated memory.
1174   */
1175  xmlFree(xmlbuff);
1176  xmlFreeDoc(doc);
1177  xmlCleanupParser();
1178  zooXmlCleanupNs();
1179}
1180
1181void printOutputDefinitions1(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,char* type){
1182  xmlNodePtr nc1;
1183  nc1=xmlNewNode(ns_wps, BAD_CAST type);
1184  map *tmp=NULL; 
1185  if(e!=NULL && e->defaults!=NULL)
1186    tmp=e->defaults->content;
1187  else{
1188    /*
1189    dumpElements(e);
1190    */
1191    return;
1192  }
1193  while(tmp!=NULL){
1194    if(strncasecmp(tmp->name,"MIMETYPE",strlen(tmp->name))==0
1195       || strncasecmp(tmp->name,"ENCODING",strlen(tmp->name))==0
1196       || strncasecmp(tmp->name,"SCHEMA",strlen(tmp->name))==0
1197       || strncasecmp(tmp->name,"UOM",strlen(tmp->name))==0)
1198    xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
1199    tmp=tmp->next;
1200  }
1201  tmp=getMap(e->defaults->content,"asReference");
1202  if(tmp==NULL)
1203    xmlNewProp(nc1,BAD_CAST "asReference",BAD_CAST "false");
1204
1205  tmp=e->content;
1206
1207  printDescription(nc1,ns_ows,m->name,e->content);
1208
1209  xmlAddChild(nc,nc1);
1210
1211}
1212
1213void printOutputDefinitions(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,map* m,char* type){
1214  xmlNodePtr nc1,nc2,nc3;
1215  nc1=xmlNewNode(ns_wps, BAD_CAST type);
1216  map *tmp=NULL; 
1217  if(e!=NULL && e->defaults!=NULL)
1218    tmp=e->defaults->content;
1219  else{
1220    /*
1221    dumpElements(e);
1222    */
1223    return;
1224  }
1225  while(tmp!=NULL){
1226    xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
1227    tmp=tmp->next;
1228  }
1229  tmp=getMap(e->defaults->content,"asReference");
1230  if(tmp==NULL)
1231    xmlNewProp(nc1,BAD_CAST "asReference",BAD_CAST "false");
1232
1233  tmp=e->content;
1234
1235  printDescription(nc1,ns_ows,m->name,e->content);
1236
1237  xmlAddChild(nc,nc1);
1238
1239}
1240
1241void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,elements* e,maps* m,char* type){
1242  xmlNodePtr nc1,nc2,nc3;
1243  nc1=xmlNewNode(ns_wps, BAD_CAST type);
1244  map *tmp=e->content;
1245#ifdef DEBUG
1246  dumpMap(tmp);
1247  dumpElements(e);
1248#endif
1249  nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier");
1250  nc3=xmlNewText(BAD_CAST e->name);
1251  xmlAddChild(nc2,nc3);
1252  xmlAddChild(nc1,nc2);
1253  xmlAddChild(nc,nc1);
1254  // Extract Title required to be first element in the ZCFG file !
1255  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
1256  nc3=xmlNewText(BAD_CAST tmp->value);
1257  xmlAddChild(nc2,nc3); 
1258  xmlAddChild(nc1,nc2);
1259  // Extract Abstract required to be second element in the ZCFG file !
1260  tmp=tmp->next;
1261  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
1262  nc3=xmlNewText(BAD_CAST tmp->value);
1263  xmlAddChild(nc2,nc3); 
1264  xmlAddChild(nc1,nc2);
1265  xmlAddChild(nc,nc1);
1266  tmp=tmp->next;
1267
1268  /**
1269   * IO type Reference or full Data ?
1270   */
1271#ifdef DEBUG
1272  fprintf(stderr,"FORMAT %s %s\n",e->format,e->format);
1273#endif
1274  map *tmpMap=getMap(m->content,"Reference");
1275  if(tmpMap==NULL){
1276    nc2=xmlNewNode(ns_wps, BAD_CAST "Data");
1277    if(strncasecmp(e->format,"LITERALOUTPUT",strlen(e->format))==0)
1278      nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData");
1279    else
1280      if(strncasecmp(e->format,"COMPLEXOUTPUT",strlen(e->format))==0)
1281        nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData");
1282      else
1283        nc3=xmlNewNode(ns_wps, BAD_CAST e->format);
1284    tmp=m->content;
1285    while(tmp!=NULL){
1286      if(strncasecmp(tmp->name,"value",strlen(tmp->name))!=0 &&
1287         strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0)
1288        xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
1289      tmp=tmp->next;
1290      xmlAddChild(nc2,nc3);
1291    }
1292    tmp=getMap(e->defaults->content,"mimeType");
1293    map* tmp1=getMap(m->content,"encoding");
1294    map* tmp2=getMap(m->content,"mimeType");
1295    map* toto=getMap(m->content,"value");
1296    if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0)
1297       || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0
1298                          || strncmp(tmp2->value,"application/",6)==0)) ){
1299      map* rs=getMap(m->content,"size");
1300      if(rs==NULL){
1301        char tmp1[1024];
1302        sprintf(tmp1,"%d",strlen(toto->value));
1303        rs=createMap("z",tmp1);
1304      }
1305      xmlAddChild(nc3,xmlNewText(BAD_CAST base64((const unsigned char*)toto->value,atoi(rs->value))));
1306    }
1307    else if(tmp!=NULL){
1308      if(strcmp(tmp->value,"text/js")==0)
1309        xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value)));
1310      else
1311        xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
1312      xmlAddChild(nc2,nc3);
1313    }
1314    else
1315      xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
1316  }
1317  else{
1318    nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference");
1319    xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value);
1320    tmp=m->content;
1321    while(tmp!=NULL){
1322      if(strncasecmp(tmp->name,"value",strlen(tmp->name))!=0 &&
1323         strncasecmp(tmp->name,"reference",strlen(tmp->name))!=0 &&
1324         strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
1325         strncasecmp(tmp->name,"abstract",strlen(tmp->name))!=0 &&
1326         strncasecmp(tmp->name,"status",strlen(tmp->name))!=0 &&
1327         strncasecmp(tmp->name,"storeExecuteResponse",strlen(tmp->name))!=0 &&
1328         strncasecmp(tmp->name,"asReference",strlen(tmp->name))!=0)
1329        xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
1330      tmp=tmp->next;
1331      xmlAddChild(nc2,nc3);
1332    }
1333  }
1334
1335  xmlAddChild(nc1,nc2);
1336  xmlAddChild(nc,nc1);
1337
1338}
1339
1340void printDescription(xmlNodePtr root,xmlNsPtr ns_ows,char* identifier,map* amap){
1341  xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "Identifier");
1342  xmlAddChild(nc2,xmlNewText(BAD_CAST identifier));
1343  xmlAddChild(root,nc2);
1344  map* tmp=amap;
1345  char *tmp2[2];
1346  tmp2[0]="Title";
1347  tmp2[1]="Abstract";
1348  int j=0;
1349  for(j=0;j<2;j++){
1350    map* tmp1=getMap(tmp,tmp2[j]);
1351    if(tmp1!=NULL){
1352      nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]);
1353      xmlAddChild(nc2,xmlNewText(BAD_CAST tmp1->value));
1354      xmlAddChild(root,nc2);
1355    }
1356  }
1357}
1358
1359char* getEncoding(maps* m){
1360  if(m!=NULL){
1361    map* tmp=getMap(m->content,"encoding");
1362    if(tmp!=NULL){
1363      return tmp->value;
1364    }
1365    else
1366      return "UTF-8";
1367  }
1368  else
1369    return "UTF-8"; 
1370}
1371
1372char* getVersion(maps* m){
1373  if(m!=NULL){
1374    map* tmp=getMap(m->content,"version");
1375    if(tmp!=NULL){
1376      return tmp->value;
1377    }
1378    else
1379      return "1.0.0";
1380  }
1381  else
1382    return "1.0.0";
1383}
1384
1385void printExceptionReportResponse(maps* m,map* s){
1386 
1387  int buffersize;
1388  xmlDocPtr doc;
1389  xmlChar *xmlbuff;
1390  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
1391  xmlNodePtr n,nc,nc1,nc2;
1392
1393  doc = xmlNewDoc(BAD_CAST "1.0");
1394  maps* tmpMap=getMaps(m,"main");
1395  char *encoding=getEncoding(tmpMap);
1396  map *tmpSid=getMapFromMaps(m,"lenv","sid");
1397  if(tmpSid==NULL)
1398    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
1399
1400  ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
1401  n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 
1402  ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
1403  ns_xlink=xmlNewNs(n,BAD_CAST "http://www.w3.org/1999/xlink",BAD_CAST "xlink");
1404  ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
1405  xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
1406  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
1407  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
1408
1409  nc = xmlNewNode(ns, BAD_CAST "Exception"); 
1410
1411  map* tmp=getMap(s,"code");
1412  if(tmp!=NULL)
1413    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
1414  else
1415    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
1416
1417  tmp=getMap(s,"text");
1418  nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
1419  nc2=NULL;
1420  if(tmp!=NULL){
1421    xmlNodeSetContent(nc1, BAD_CAST tmp->value);
1422  }
1423  else{
1424    xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
1425  }
1426  xmlAddChild(nc,nc1);
1427  xmlAddChild(n,nc);
1428  xmlDocSetRootElement(doc, n);
1429
1430  xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
1431  printf("%s",xmlbuff);
1432  fflush(stdout);
1433  xmlFreeDoc(doc);
1434  xmlFree(xmlbuff);
1435  xmlFreeNs(ns);
1436  xmlCleanupParser();
1437}
1438
1439xmlNodePtr createExceptionReportNode(maps* m,map* s,int use_ns){
1440 
1441  int buffersize;
1442  xmlChar *xmlbuff;
1443  xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
1444  xmlNodePtr n,nc,nc1,nc2;
1445
1446  maps* tmpMap=getMaps(m,"main");
1447
1448  ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
1449  n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
1450
1451  if(use_ns==1){
1452    ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
1453    int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi");
1454    ns_xsi=usedNs[xsiId];
1455    int xlinkId=zooXmlAddNs(n,"http://www.w3.org/1999/xlink","xlink");
1456    ns_xlink=usedNs[xlinkId];
1457    xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
1458  }
1459  xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
1460  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
1461 
1462  nc = xmlNewNode(ns, BAD_CAST "Exception");
1463
1464  map* tmp=getMap(s,"code");
1465  if(tmp!=NULL)
1466    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
1467  else
1468    xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
1469
1470  tmp=getMap(s,"text");
1471  nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
1472  nc2=NULL;
1473  if(tmp!=NULL){
1474    xmlNodeSetContent(nc1, BAD_CAST tmp->value);
1475  }
1476  else{
1477    xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
1478  }
1479  xmlAddChild(nc,nc1);
1480  xmlAddChild(n,nc);
1481  return n;
1482}
1483
1484
1485void outputResponse(service* s,maps* request_inputs,maps* request_outputs,
1486                    map* request_inputs1,int cpid,maps* m,int res){
1487#ifdef DEBUG
1488  dumpMaps(request_inputs);
1489  dumpMaps(request_outputs);
1490  fprintf(stderr,"printProcessResponse\n");
1491#endif
1492  map* toto=getMap(request_inputs1,"RawDataOutput");
1493  int asRaw=0;
1494  if(toto!=NULL)
1495    asRaw=1;
1496 
1497  if(asRaw==0){
1498#ifdef DEBUG
1499    fprintf(stderr,"REQUEST_OUTPUTS FINAL\n");
1500    dumpMaps(request_outputs);
1501#endif
1502    toto=getMap(request_outputs->content,"asReference");
1503    if(toto!=NULL && strcasecmp(toto->value,"true")==0){
1504      toto=getMap(request_outputs->content,"extension");
1505      map *tmp1=getMapFromMaps(m,"main","tmpPath");
1506      char *file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
1507      sprintf(file_name,"%s/%s_%i.%s",tmp1->value,s->name,cpid+100000,toto->value);
1508      FILE *ofile=fopen(file_name,"w");
1509      map *tmp2=getMapFromMaps(m,"main","tmpUrl");
1510      map *tmp3=getMapFromMaps(m,"main","serverAddress");
1511      char *file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
1512      sprintf(file_url,"%s/%s/%s_%i.%s",tmp3->value,tmp2->value,s->name,cpid+100000,toto->value);
1513      addToMap(request_outputs->content,"Reference",file_url);
1514      toto=getMap(request_outputs->content,"value");
1515      if(toto!=NULL)
1516        fwrite(toto->value,sizeof(char),strlen(toto->value),ofile);
1517      fclose(ofile);
1518      free(file_name);
1519      free(file_url);
1520    }
1521    map *r_inputs=getMap(s->content,"serviceProvider");
1522#ifdef DEBUG
1523    fprintf(stderr,"SERVICE : %s\n",r_inputs->value);
1524    dumpMaps(m);
1525#endif
1526    printProcessResponse(m,request_inputs1,cpid,
1527                         s,r_inputs->value,res,
1528                         request_inputs,
1529                         request_outputs);
1530  }
1531  else
1532    if(res!=SERVICE_FAILED){
1533      /**
1534       * We get the first output only !!
1535       */
1536      char mime[1024];
1537      map* mi=getMap(request_outputs->content,"mimeType");
1538#ifdef DEBUG
1539      fprintf(stderr,"SERVICE OUTPUTS\n");
1540      dumpMaps(request_outputs);
1541      fprintf(stderr,"SERVICE OUTPUTS\n");
1542#endif
1543      map* en=getMap(request_outputs->content,"encoding");
1544      if(mi!=NULL && en!=NULL)
1545        sprintf(mime,
1546                "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n",
1547                mi->value,en->value);
1548      else
1549        if(mi!=NULL)
1550          sprintf(mime,
1551                  "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n",
1552                  mi->value);
1553        else
1554          sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
1555      printf("%s",mime);
1556      toto=getMap(request_outputs->content,"value");
1557      if(mi!=NULL && strncmp(mi->value,"image",5)==0){
1558        map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
1559        fwrite(toto->value,atoi(rs->value),1,stdout);
1560      }
1561      else
1562        printf("%s",toto->value);
1563#ifdef DEBUG
1564      dumpMap(toto);
1565#endif
1566    }else{
1567      char tmp[1024];
1568      map * errormap;
1569      map *lenv;
1570      lenv=getMapFromMaps(m,"lenv","message");
1571      if(lenv!=NULL)
1572        sprintf(tmp,"Unable to run the Service. The message returned back by the Service was the following : %s",lenv->value);
1573      else
1574        sprintf(tmp,"Unable to run the Service. No more information was returned back by the Service.");
1575      errormap = createMap("text",tmp);     
1576      addToMap(errormap,"code", "InternalError");
1577      printf("Content-Type: text/xml; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
1578      printExceptionReportResponse(m,errormap);
1579      freeMap(&errormap);
1580      free(errormap);
1581    }
1582}
1583
1584char *base64(const unsigned char *input, int length)
1585{
1586  BIO *bmem, *b64;
1587  BUF_MEM *bptr;
1588
1589  b64 = BIO_new(BIO_f_base64());
1590  bmem = BIO_new(BIO_s_mem());
1591  b64 = BIO_push(b64, bmem);
1592  BIO_write(b64, input, length);
1593  BIO_flush(b64);
1594  BIO_get_mem_ptr(b64, &bptr);
1595
1596  char *buff = (char *)malloc(bptr->length);
1597  memcpy(buff, bptr->data, bptr->length-1);
1598  buff[bptr->length-1] = 0;
1599
1600  BIO_free_all(b64);
1601
1602  fprintf(stderr,"BASE64 [%s] \n",buff);
1603  return buff;
1604}
1605
1606char* addDefaultValues(maps** out,elements* in,maps* m,char* type){
1607  elements* tmpInputs=in;
1608  maps* out1=*out;
1609  while(tmpInputs!=NULL){
1610    maps *tmpMaps=getMaps(out1,tmpInputs->name);
1611    if(tmpMaps==NULL){
1612      map* tmpMap1=getMap(tmpInputs->content,"minOccurs");
1613      if(strncmp(type,"inputs",6)==0)
1614        if(tmpMap1!=NULL && atoi(tmpMap1->value)>=1){
1615          return tmpInputs->name;
1616        }
1617      maps* tmpMaps2=(maps*)malloc(MAPS_SIZE);
1618      tmpMaps2->name=strdup((char*)tmpInputs->name);
1619      tmpMaps2->content=NULL;
1620      tmpMaps2->next=NULL;
1621      iotype* tmpIoType=tmpInputs->defaults;
1622      while(tmpIoType!=NULL){
1623        addMapToMap(&tmpMaps2->content,tmpIoType->content);
1624        tmpIoType=tmpIoType->next;
1625      }
1626      map *tmpMap=getMap(tmpMaps2->content,"value");
1627      if(tmpMap==NULL)
1628        addToMap(tmpMaps2->content,"value","NULL");
1629      if(out1==NULL){
1630        *out=dupMaps(&tmpMaps2);
1631      }
1632      else
1633        addMapsToMaps(&out1,tmpMaps2);
1634      freeMaps(&tmpMaps2);
1635      free(tmpMaps2);
1636      tmpMaps2=NULL;
1637    }
1638    else{
1639      map* tmpContent=tmpInputs->defaults->content;
1640     
1641      map* cval=NULL;
1642     
1643      while(tmpContent!=NULL){
1644        if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
1645#ifdef DEBUG
1646          fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
1647#endif
1648          if(tmpMaps->content==NULL)
1649            tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
1650          else
1651            addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
1652        }
1653        tmpContent=tmpContent->next;
1654      }
1655    }
1656    tmpInputs=tmpInputs->next;
1657  }
1658  return "";
1659}
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