Changeset 57 for trunk/zoo-kernel/service_internal.c
- Timestamp:
- Jan 5, 2011, 3:20:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal.c
r52 r57 309 309 map* tmp2=tmp4->content; 310 310 while(tmp2!=NULL){ 311 if(strncasecmp(tmp2->name,"keywords",8)!=0 && 312 strncasecmp(tmp2->name,"serverAddress",13)!=0 && 313 strncasecmp(tmp2->name,"lang",4)!=0 && 314 strncasecmp(tmp2->name,"encoding",8)!=0 && 315 strncasecmp(tmp2->name,"version",7)!=0){ 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){ 316 315 tmp2->name[0]=toupper(tmp2->name[0]); 317 316 nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name); … … 370 369 if(tmp4!=NULL){ 371 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"; 372 381 while(tmp2!=NULL){ 373 382 if(strcmp(tmp2->name,"keywords")!=0 && … … 395 404 else 396 405 if(strncmp(tmp2->name,"Phone",5)==0){ 397 char *toto=NULL; 398 char *toto1=tmp2->name; 399 toto=strstr(toto1,"Phone"); 400 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5); 401 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 402 xmlAddChild(nc5,nc1); 406 int j; 407 for(j=0;j<2;j++) 408 if(strlen(tmp2->name)==strlen(tmpPhone[j]) && strncasecmp(tmp2->name,tmpPhone[j],strlen(tmp2->name))==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 } 403 416 } 404 417 else 405 418 if(strncmp(tmp2->name,"Address",7)==0){ 406 char *toto=NULL; 407 char *toto1=tmp2->name; 408 toto=strstr(toto1,"Address"); 409 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7); 410 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value)); 411 xmlAddChild(nc6,nc1); 419 int j; 420 for(j=0;j<6;j++) 421 if(strlen(tmp2->name)==strlen(tmpAddress[j]) && strncasecmp(tmp2->name,tmpAddress[j],strlen(tmp2->name))==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 } 412 429 } 413 430 } … … 1084 1101 te=getMapFromMaps(m,"lenv","message"); 1085 1102 if(te!=NULL) 1086 addToMap(errorMap,"text", te->value);1103 addToMap(errorMap,"text",_ss(te->value)); 1087 1104 else 1088 1105 addToMap(errorMap,"text",_("No more information available")); … … 1364 1381 if(tmp1!=NULL){ 1365 1382 nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]); 1366 fprintf(stderr,"[%s] \n[%s]\n",tmp1->value,_ss(tmp1->value));1367 1383 xmlAddChild(nc2,xmlNewText(BAD_CAST _ss(tmp1->value))); 1368 1384 xmlAddChild(root,nc2); … … 1398 1414 1399 1415 void printExceptionReportResponse(maps* m,map* s){ 1400 1401 1416 int buffersize; 1402 1417 xmlDocPtr doc; … … 1425 1440 xmlFree(xmlbuff); 1426 1441 xmlCleanupParser(); 1442 zooXmlCleanupNs(); 1427 1443 } 1428 1444 … … 1436 1452 maps* tmpMap=getMaps(m,"main"); 1437 1453 1438 ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows"); 1454 int nsid=zooXmlAddNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows"); 1455 ns=usedNs[nsid]; 1439 1456 n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 1440 1457 … … 1493 1510 if(toto!=NULL && strcasecmp(toto->value,"true")==0){ 1494 1511 toto=getMap(request_outputs->content,"extension"); 1495 /* put gml extension if the extension is defined as .js and the result will be a gml file */1496 map* mtype=getMap(request_outputs->content,"mimeType");1497 if (strcasecmp(toto->value,"js")==0 && strcasecmp(mtype->value,"text/xml")==0) {1498 toto->value="gml";1499 }1500 1512 map *tmp1=getMapFromMaps(m,"main","tmpPath"); 1501 char *file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char)); 1513 char *file_name; 1514 bool hasExt=true; 1515 if(toto==NULL){ 1516 // We can fallback to a default list of supported formats using 1517 // mimeType information if present here. Maybe we can add more formats 1518 // here. 1519 // If mimeType was not found, we then set txt as the default extension. 1520 map* mtype=getMap(request_outputs->content,"mimeType"); 1521 if(mtype!=NULL){ 1522 if(strcasecmp(mtype->value,"text/xml")==0) 1523 toto=createMap("extension","xml"); 1524 else 1525 toto=createMap("extension","txt"); 1526 } 1527 if(toto==NULL) 1528 toto=createMap("extension","txt"); 1529 hasExt=false; 1530 } 1531 file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char)); 1502 1532 sprintf(file_name,"%s/%s_%i.%s",tmp1->value,s->name,cpid+100000,toto->value); 1503 1533 FILE *ofile=fopen(file_name,"w"); 1534 if(ofile==NULL) 1535 fprintf(stderr,"Unable to create file on disk implying segfault ! \n"); 1504 1536 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 1505 1537 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 1506 char *file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char)); 1538 char *file_url; 1539 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char)); 1507 1540 sprintf(file_url,"%s/%s/%s_%i.%s",tmp3->value,tmp2->value,s->name,cpid+100000,toto->value); 1508 1541 addToMap(request_outputs->content,"Reference",file_url); 1542 if(hasExt!=true){ 1543 freeMap(&toto); 1544 free(toto); 1545 } 1509 1546 toto=getMap(request_outputs->content,"value"); 1510 if(toto!=NULL )1511 fwrite(toto->value, sizeof(char),strlen(toto->value),ofile);1547 if(toto!=NULL && toto->value!=NULL) 1548 fwrite(toto->value,1,(strlen(toto->value)+1)*sizeof(char),ofile); 1512 1549 fclose(ofile); 1513 1550 free(file_name); … … 1601 1638 BIO_free_all(b64); 1602 1639 1603 fprintf(stderr,"BASE64 [%s] \n",buff);1604 1640 return buff; 1605 1641 } … … 1610 1646 while(tmpInputs!=NULL){ 1611 1647 maps *tmpMaps=getMaps(out1,tmpInputs->name); 1648 /*fprintf(stderr,"IN LOOP\n"); 1649 dumpElements(tmpInputs); 1650 dumpMaps(tmpMaps); 1651 fprintf(stderr,"/ IN LOOP\n");*/ 1612 1652 if(tmpMaps==NULL){ 1613 1653 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); … … 1617 1657 } 1618 1658 maps* tmpMaps2=(maps*)malloc(MAPS_SIZE); 1619 tmpMaps2->name=strdup( (char*)tmpInputs->name);1659 tmpMaps2->name=strdup(tmpInputs->name); 1620 1660 tmpMaps2->content=NULL; 1621 1661 tmpMaps2->next=NULL; … … 1625 1665 tmpIoType=tmpIoType->next; 1626 1666 } 1627 map *tmpMap=getMap(tmpMaps2->content,"value"); 1628 if(tmpMap==NULL) 1629 addToMap(tmpMaps2->content,"value","NULL"); 1667 if(strncmp(type,"outputs",7)==0){ 1668 map *tmpMap=getMap(tmpMaps2->content,"value"); 1669 if(tmpMap==NULL) 1670 addToMap(tmpMaps2->content,"value","NULL"); 1671 } 1630 1672 if(out1==NULL){ 1631 1673 *out=dupMaps(&tmpMaps2); … … 1638 1680 } 1639 1681 else{ 1640 map* tmpContent=tmpInputs->defaults->content; 1641 1642 map* cval=NULL; 1643 1644 while(tmpContent!=NULL){ 1645 if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){ 1646 #ifdef DEBUG 1647 fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value); 1648 #endif 1649 if(tmpMaps->content==NULL) 1650 tmpMaps->content=createMap(tmpContent->name,tmpContent->value); 1651 else 1652 addToMap(tmpMaps->content,tmpContent->name,tmpContent->value); 1682 iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name, 1683 tmpMaps->content); 1684 if(tmpIoType!=NULL){ 1685 map* tmpContent=tmpIoType->content; 1686 map* cval=NULL; 1687 1688 while(tmpContent!=NULL){ 1689 if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){ 1690 #ifdef DEBUG 1691 fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value); 1692 #endif 1693 if(tmpMaps->content==NULL) 1694 tmpMaps->content=createMap(tmpContent->name,tmpContent->value); 1695 else 1696 addToMap(tmpMaps->content,tmpContent->name,tmpContent->value); 1697 } 1698 tmpContent=tmpContent->next; 1653 1699 } 1654 tmpContent=tmpContent->next;1655 1700 } 1656 1701 }
Note: See TracChangeset
for help on using the changeset viewer.