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