Changeset 634 for trunk/zoo-project/zoo-kernel/service_internal.c
- Timestamp:
- Apr 24, 2015, 4:57:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r633 r634 2249 2249 if(e!=NULL){ 2250 2250 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 2251 2251 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2252 2252 else 2253 2253 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 2254 2255 2256 2257 2258 2254 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 2255 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 2256 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 2257 else 2258 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 2259 2259 } 2260 2260 else { 2261 2261 map* tmpV=getMapFromMaps(m,"format","value"); 2262 2262 if(tmpV!=NULL) 2263 2263 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); 2264 2264 else 2265 2265 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2266 2266 } 2267 2267 tmp=m->content; … … 2269 2269 while(tmp!=NULL){ 2270 2270 if(strcasecmp(tmp->name,"mimeType")==0 || 2271 2272 2273 2274 2275 2276 2271 strcasecmp(tmp->name,"encoding")==0 || 2272 strcasecmp(tmp->name,"schema")==0 || 2273 strcasecmp(tmp->name,"datatype")==0 || 2274 strcasecmp(tmp->name,"uom")==0) { 2275 2276 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2277 2277 } 2278 2278 tmp=tmp->next; … … 2282 2282 map* bb=getMap(m->content,"value"); 2283 2283 if(bb!=NULL) { 2284 2285 2286 2287 2288 } 2289 } 2290 2284 map* tmpRes=parseBoundingBox(bb->value); 2285 printBoundingBox(ns_ows,nc3,tmpRes); 2286 freeMap(&tmpRes); 2287 free(tmpRes); 2288 } 2289 } 2290 else { 2291 2291 if(e!=NULL) 2292 2292 tmp=getMap(e->defaults->content,"mimeType"); 2293 2293 else 2294 2294 tmp=NULL; 2295 2295 2296 map* tmp1=getMap(m->content,"encoding"); 2297 map* tmp2=getMap(m->content,"mimeType"); 2298 map* tmp3=getMap(m->content,"value"); 2299 int hasValue=1; 2300 if(tmp3==NULL){ 2301 tmp3=createMap("value",""); 2302 hasValue=-1; 2303 } 2304 2305 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2306 || // or if 2307 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2308 && // nor 2309 strstr(tmp2->value,"xml") == NULL // xml 2310 && // nor 2311 strstr(tmp2->value,"javascript") == NULL // javascript 2312 && 2313 strstr(tmp2->value,"json") == NULL 2314 && 2315 strstr(tmp2->value,"ecmascript") == NULL 2316 && 2317 // include for backwards compatibility, 2318 // although correct mime type is ...kml+xml: 2319 strstr(tmp2->value,"google-earth.kml") == NULL 2320 ) 2321 ) 2322 ) { // then 2323 map* rs=getMap(m->content,"size"); // obtain size 2324 bool isSized=true; 2325 if(rs==NULL){ 2326 char tmp1[1024]; 2327 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2328 rs=createMap("size",tmp1); 2329 isSized=false; 2330 } 2331 2332 xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2296 map* tmp1=getMap(m->content,"encoding"); 2297 map* tmp2=getMap(m->content,"mimeType"); 2298 map* tmp3=getMap(m->content,"value"); 2299 int hasValue=1; 2300 if(tmp3==NULL){ 2301 tmp3=createMap("value",""); 2302 hasValue=-1; 2303 } 2304 2305 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2306 || // or if 2307 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2308 && // nor 2309 strstr(tmp2->value,"xml") == NULL // xml 2310 && // nor 2311 strstr(tmp2->value,"javascript") == NULL // javascript 2312 && 2313 strstr(tmp2->value,"json") == NULL 2314 && 2315 strstr(tmp2->value,"ecmascript") == NULL 2316 && 2317 // include for backwards compatibility, 2318 // although correct mime type is ...kml+xml: 2319 strstr(tmp2->value,"google-earth.kml") == NULL ) 2320 ) 2321 ) { // then 2322 map* rs=getMap(m->content,"size"); // obtain size 2323 bool isSized=true; 2324 if(rs==NULL){ 2325 char tmp1[1024]; 2326 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2327 rs=createMap("size",tmp1); 2328 isSized=false; 2329 } 2330 2331 xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2333 2332 2334 2335 2336 2337 2338 2339 2340 2333 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 2334 xmlAttrPtr ap = xmlHasProp(nc3, BAD_CAST "encoding"); 2335 if (ap != NULL) { 2336 xmlRemoveProp(ap); 2337 } 2338 xmlNewProp(nc3,BAD_CAST "encoding",BAD_CAST "base64"); 2339 } 2341 2340 2342 2343 2344 2345 2341 if(!isSized){ 2342 freeMap(&rs); 2343 free(rs); 2344 } 2346 2345 } 2347 2346 else if (tmp2!=NULL) { // else (text-based format) 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2347 if(strstr(tmp2->value, "javascript") != NULL || // if javascript put code in CDATA block 2348 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2349 strstr(tmp2->value, "ecmascript") != NULL 2350 ) { 2351 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2352 } 2353 else { // else 2354 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2355 // include for backwards compatibility, 2356 // although correct mime type is ...kml+xml: 2357 strstr(tmp2->value, "google-earth.kml") != NULL 2358 ) { 2360 2359 2361 2362 2363 2364 2365 2366 2367 2368 2369 2360 int li=zooXmlAddDoc(tmp3->value); 2361 xmlDocPtr doc = iDocs[li]; 2362 xmlNodePtr ir = xmlDocGetRootElement(doc); 2363 xmlAddChild(nc3,ir); 2364 } 2365 else // else 2366 xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value)); // add text node 2367 } 2368 xmlAddChild(nc2,nc3); 2370 2369 } 2371 2370 else { 2372 2371 xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value)); 2373 2372 } 2374 2373 2375 2374 if(hasValue<0) { 2376 2377 2375 freeMap(&tmp3); 2376 free(tmp3); 2378 2377 } 2379 2378 } … … 2387 2386 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 2388 2387 2389 2388 tmp=m->content; 2390 2389 while(tmp!=NULL) { 2391 2390 if(strcasecmp(tmp->name,"mimeType")==0 || 2392 2393 2394 2395 2396 2397 2398 2399 2400 2391 strcasecmp(tmp->name,"encoding")==0 || 2392 strcasecmp(tmp->name,"schema")==0 || 2393 strcasecmp(tmp->name,"datatype")==0 || 2394 strcasecmp(tmp->name,"uom")==0){ 2395 2396 if(strcasecmp(tmp->name,"datatype")==0) 2397 xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain"); 2398 else 2399 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2401 2400 } 2402 2401 tmp=tmp->next; … … 2660 2659 free(tmpMap1->value); 2661 2660 tmpMap1->value=(char*) malloc((count+1)*sizeof(char)); 2662 fread(tmpMap1->value,count,sizeof(char),file); 2661 fread(tmpMap1->value,1,count,file); 2662 tmpMap1->value[count]=0; 2663 2663 fclose(file); 2664 char rsize[100 ];2664 char rsize[1000]; 2665 2665 sprintf(rsize,"%ld",count); 2666 2666 addToMap(content,"size",rsize); … … 2833 2833 map* size=getMap(tmpI->content,"size"); 2834 2834 if(size!=NULL && toto!=NULL) 2835 fwrite(toto->value,1, atoi(size->value)*sizeof(char),ofile);2835 fwrite(toto->value,1,(atoi(size->value))*sizeof(char),ofile); 2836 2836 else 2837 2837 if(toto!=NULL && toto->value!=NULL) … … 3044 3044 bmem = BIO_new(BIO_s_mem()); 3045 3045 b64 = BIO_push(b64, bmem); 3046 BIO_write(b64, input, length +1);3046 BIO_write(b64, input, length); 3047 3047 BIO_flush(b64); 3048 3048 BIO_get_mem_ptr(b64, &bptr); … … 3050 3050 char *buff = (char *)malloc((bptr->length+1)*sizeof(char)); 3051 3051 memcpy(buff, bptr->data, bptr->length); 3052 buff[bptr->length -1] = 0;3052 buff[bptr->length] = 0; 3053 3053 3054 3054 BIO_free_all(b64);
Note: See TracChangeset
for help on using the changeset viewer.