Changeset 280 for trunk/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Jul 26, 2011, 5:37:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/zoo_service_loader.c
r277 r280 493 493 textdomain("zoo-services"); 494 494 495 map* lsoap=getMap(request_inputs,"soap"); 496 if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0) 497 setMapInMaps(m,"main","isSoap","true"); 498 else 499 setMapInMaps(m,"main","isSoap","false"); 495 500 496 501 /** … … 1041 1046 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1042 1047 #endif 1048 char *tmpx=url_encode(tmpv1+1); 1049 addToMap(tmpmaps->content,tmpn1,tmpx); 1050 1043 1051 #ifndef WIN32 1044 1052 if(CHECK_INET_HANDLE(hInternet)) 1045 1053 #endif 1046 1054 { 1047 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1048 INTERNET_FLAG_NO_CACHE_WRITE,0); 1049 #ifdef DEBUG 1050 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1051 tmpv1+1,res.nDataAlloc,res.nDataLen); 1052 #endif 1053 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1054 if(tmpContent == NULL){ 1055 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1055 char* cached=isInCache(m,tmpv1+1); 1056 if(cached!=NULL){ 1057 fprintf(stderr,"Use cached file: %s\n",cached); 1058 struct stat f_status; 1059 int s=stat(cached, &f_status); 1060 if(s==0){ 1061 map* tmpMap=getMap(tmpmaps->content,"value"); 1062 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 1063 FILE* f=fopen(cached,"r"); 1064 fread(fcontent,sizeof(char),f_status.st_size,f); 1065 free(tmpMap->value); 1066 tmpMap->value=(char*)malloc((f_status.st_size+1)*sizeof(char)); 1067 memmove(tmpMap->value,fcontent,(f_status.st_size)*sizeof(char)); 1068 free(fcontent); 1069 } 1070 }else{ 1071 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1072 INTERNET_FLAG_NO_CACHE_WRITE,0); 1073 #ifdef DEBUG 1074 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1075 tmpv1+1,res.nDataAlloc,res.nDataLen); 1076 #endif 1077 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1078 if(tmpContent == NULL){ 1079 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1080 } 1081 size_t dwRead; 1082 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 1083 map* tmpMap=getMap(tmpmaps->content,"value"); 1084 if(tmpMap!=NULL){ 1085 free(tmpMap->value); 1086 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 1087 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 1088 tmpMap->value[res.nDataLen]=0; 1089 if(strlen(tmpContent)!=res.nDataLen){ 1090 char tmp[256]; 1091 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 1092 addToMap(tmpmaps->content,"size",tmp); 1093 } 1094 addToCache(m,tmpv1+1,tmpContent,res.nDataLen); 1095 } 1096 free(tmpContent); 1056 1097 } 1057 size_t dwRead;1058 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);1059 map* tmpMap=getMap(tmpmaps->content,"value");1060 if(tmpMap!=NULL){1061 free(tmpMap->value);1062 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));1063 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));1064 tmpMap->value[res.nDataLen]=0;1065 if(strlen(tmpContent)!=res.nDataLen){1066 char tmp[256];1067 sprintf(tmp,"%d",res.nDataLen*sizeof(char));1068 addToMap(tmpmaps->content,"size",tmp);1069 }1070 }1071 free(tmpContent);1072 1098 } 1073 char *tmpx =url_encode(tmpv1+1);1074 addToMap(tmpmaps->content,tmpn1,tmpx );1075 free(tmpx );1099 char *tmpx1=url_encode(tmpv1+1); 1100 addToMap(tmpmaps->content,tmpn1,tmpx1); 1101 free(tmpx1); 1076 1102 addToMap(tmpmaps->content,"Reference",tmpv1+1); 1077 1103 } … … 1413 1439 else 1414 1440 tmpmaps->content=createMap(list[l],(char*)val); 1441 #ifdef DEBUG 1442 fprintf(stderr,"%s\n",val); 1443 #endif 1415 1444 } 1416 #ifdef DEBUG1417 fprintf(stderr,"%s\n",val);1418 #endif1419 1445 xmlFree(val); 1420 free(list[l]); 1446 free(list[l]); 1421 1447 } 1422 1448 } … … 1432 1458 for(int l=0;l<3;l++){ 1433 1459 #ifdef DEBUG 1434 fprintf(stderr,"*** ComplexData %s *** ",coms[l]);1460 fprintf(stderr,"*** ComplexData %s ***\n",coms[l]); 1435 1461 #endif 1436 1462 xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]); … … 1440 1466 else 1441 1467 tmpmaps->content=createMap(coms[l],(char*)val); 1468 #ifdef DEBUG 1469 fprintf(stderr,"%s\n",val); 1470 #endif 1442 1471 } 1443 #ifdef DEBUG1444 fprintf(stderr,"%s\n",val);1445 #endif1446 1472 xmlFree(val); 1447 1473 } 1448 1474 } 1475 1449 1476 map* test=getMap(tmpmaps->content,"encoding"); 1450 if(test==NULL || strcasecmp(test->value,"base64")!=0){ 1477 if(test==NULL){ 1478 if(tmpmaps->content!=NULL) 1479 addToMap(tmpmaps->content,"encoding","utf-8"); 1480 else 1481 tmpmaps->content=createMap("encoding","utf-8"); 1482 test=getMap(tmpmaps->content,"encoding"); 1483 } 1484 1485 if(strcasecmp(test->value,"base64")!=0){ 1451 1486 xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1); 1452 if(mv==NULL){ 1487 map* ltmp=getMap(tmpmaps->content,"mimeType"); 1488 if(mv==NULL || 1489 (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 && 1490 (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){ 1453 1491 xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0"); 1454 1492 int buffersize; 1455 xmlDocSetRootElement(doc1,cur4->xmlChildrenNode); 1493 xmlNodePtr cur5=cur4->children; 1494 while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE) 1495 cur5=cur5->next; 1496 xmlDocSetRootElement(doc1,cur5); 1456 1497 xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1); 1457 1498 char size[1024]; … … 1578 1619 xmlNodePtr cur1=cur->children; 1579 1620 while(cur1){ 1580 if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1621 /** 1622 * Indentifier 1623 */ 1624 if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){ 1625 xmlChar *val= 1626 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1627 if(tmpmaps==NULL){ 1628 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1629 if(tmpmaps == NULL){ 1630 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1631 } 1632 tmpmaps->name=strdup((char*)val); 1633 tmpmaps->content=NULL; 1634 tmpmaps->next=NULL; 1635 } 1636 else 1637 tmpmaps->name=strdup((char*)val);; 1638 xmlFree(val); 1639 } 1640 /** 1641 * Title, Asbtract 1642 */ 1643 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 || 1644 xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){ 1645 xmlChar *val= 1646 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1647 if(tmpmaps==NULL){ 1648 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1649 if(tmpmaps == NULL){ 1650 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1651 } 1652 tmpmaps->name=strdup("missingIndetifier"); 1653 tmpmaps->content=createMap((char*)cur1->name,(char*)val); 1654 tmpmaps->next=NULL; 1655 } 1656 else{ 1657 if(tmpmaps->content!=NULL) 1658 addToMap(tmpmaps->content, 1659 (char*)cur1->name,(char*)val); 1660 else 1661 tmpmaps->content= 1662 createMap((char*)cur1->name,(char*)val); 1663 } 1664 xmlFree(val); 1665 } 1666 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1581 1667 /** 1582 1668 * Get every attribute from a Output node … … 1682 1768 dumpMaps(request_output_real_format); 1683 1769 dumpMap(request_inputs); 1770 fprintf(stderr,"\n%i\n",i); 1684 1771 #endif 1685 1772 … … 1689 1776 */ 1690 1777 char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0); 1691 if(strcmp(dfv,"")!=0){ 1778 char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1); 1779 if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){ 1692 1780 char tmps[1024]; 1693 snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv); 1781 if(strcmp(dfv,"")!=0){ 1782 snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv); 1783 } 1784 else if(strcmp(dfv1,"")!=0){ 1785 snprintf(tmps,1024,_("The <%s> argument was specified as Output identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),dfv1); 1786 } 1694 1787 map* tmpe=createMap("text",tmps); 1695 1788 addToMap(tmpe,"code","MissingParameterValue"); … … 1711 1804 return 1; 1712 1805 } 1713 addDefaultValues(&request_output_real_format,s1->outputs,m,1);1714 1806 1715 1807 ensureDecodedBase64(&request_input_real_format); … … 1805 1897 addToMap(_tmpMaps->content,"status","0"); 1806 1898 addToMap(_tmpMaps->content,"cwd",ntmp); 1899 map* ltmp=getMap(request_inputs,"soap"); 1900 if(ltmp!=NULL) 1901 addToMap(_tmpMaps->content,"soap",ltmp->value); 1902 else 1903 addToMap(_tmpMaps->content,"soap","false"); 1807 1904 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1808 1905 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
Note: See TracChangeset
for help on using the changeset viewer.