Changeset 301 for branches/branch-1.2/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Aug 5, 2011, 3:02:43 PM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/zoo-kernel/zoo_service_loader.c
r268 r301 452 452 _getcwd(ntmp,1024); 453 453 #endif 454 r_inputs=getMap(request_inputs,"metapath"); 455 if(r_inputs==NULL){ 456 if(request_inputs==NULL) 457 request_inputs=createMap("metapath",""); 458 else 459 addToMap(request_inputs,"metapath",""); 460 #ifdef DEBUG 461 fprintf(stderr,"ADD METAPATH\n"); 462 dumpMap(request_inputs); 463 #endif 464 r_inputs=getMap(request_inputs,"metapath"); 465 } 454 r_inputs=getMapOrFill(request_inputs,"metapath",""); 455 466 456 char conf_file[10240]; 467 457 snprintf(conf_file,10240,"%s/%s/main.cfg",ntmp,r_inputs->value); … … 493 483 textdomain("zoo-services"); 494 484 485 map* lsoap=getMap(request_inputs,"soap"); 486 if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0) 487 setMapInMaps(m,"main","isSoap","true"); 488 else 489 setMapInMaps(m,"main","isSoap","false"); 495 490 496 491 /** … … 1013 1008 lmap->value=strdup(tmpValue); 1014 1009 free(tmpValue); 1015 dumpMap(tmpmaps->content);1016 1010 tmpc=strtok(NULL,"@"); 1017 1011 continue; … … 1042 1036 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1043 1037 #endif 1038 char *tmpx=url_encode(tmpv1+1); 1039 addToMap(tmpmaps->content,tmpn1,tmpx); 1040 1044 1041 #ifndef WIN32 1045 1042 if(CHECK_INET_HANDLE(hInternet)) 1046 1043 #endif 1047 1044 { 1048 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1049 INTERNET_FLAG_NO_CACHE_WRITE,0); 1050 #ifdef DEBUG 1051 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1052 tmpv1+1,res.nDataAlloc,res.nDataLen); 1053 #endif 1054 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1055 if(tmpContent == NULL){ 1056 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1057 } 1058 size_t dwRead; 1059 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 1060 map* tmpMap=getMap(tmpmaps->content,"value"); 1061 if(tmpMap!=NULL){ 1062 free(tmpMap->value); 1063 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 1064 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 1065 tmpMap->value[res.nDataLen]=0; 1066 if(strlen(tmpContent)!=res.nDataLen){ 1067 char tmp[256]; 1068 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 1069 addToMap(tmpmaps->content,"size",tmp); 1070 } 1071 } 1072 free(tmpContent); 1045 loadRemoteFile(m,tmpmaps->content,hInternet,tmpv1+1); 1073 1046 } 1074 char *tmpx =url_encode(tmpv1+1);1075 addToMap(tmpmaps->content,tmpn1,tmpx );1076 free(tmpx );1047 char *tmpx1=url_encode(tmpv1+1); 1048 addToMap(tmpmaps->content,tmpn1,tmpx1); 1049 free(tmpx1); 1077 1050 addToMap(tmpmaps->content,"Reference",tmpv1+1); 1078 dumpMap(tmpmaps->content);1079 1051 } 1080 1052 tmpc=strtok(NULL,"@"); … … 1193 1165 fprintf(stderr,"REFERENCE\n"); 1194 1166 #endif 1195 const char *refs[5]; 1196 refs[0]="mimeType"; 1197 refs[1]="encoding"; 1198 refs[2]="schema"; 1199 refs[3]="method"; 1200 refs[4]="href"; 1167 const char *refs[5]={"mimeType","encoding","schema","method","href"}; 1201 1168 for(int l=0;l<5;l++){ 1202 1169 #ifdef DEBUG … … 1213 1180 if(!(ltmp!=NULL && strcmp(ltmp->value,"POST")==0) 1214 1181 && CHECK_INET_HANDLE(hInternet)){ 1215 res=InternetOpenUrl(hInternet,(char*)val,NULL,0, 1216 INTERNET_FLAG_NO_CACHE_WRITE,0); 1217 char* tmpContent= 1218 (char*)calloc((res.nDataLen+1),sizeof(char)); 1219 if(tmpContent == NULL){ 1220 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1221 } 1222 size_t dwRead; 1223 InternetReadFile(res, (LPVOID)tmpContent, 1224 res.nDataLen, &dwRead); 1225 tmpContent[res.nDataLen]=0; 1226 addToMap(tmpmaps->content,"value",tmpContent); 1182 loadRemoteFile(m,tmpmaps->content,hInternet,(char*)val); 1227 1183 } 1228 1184 } … … 1415 1371 else 1416 1372 tmpmaps->content=createMap(list[l],(char*)val); 1373 #ifdef DEBUG 1374 fprintf(stderr,"%s\n",val); 1375 #endif 1417 1376 } 1418 #ifdef DEBUG1419 fprintf(stderr,"%s\n",val);1420 #endif1421 1377 xmlFree(val); 1422 free(list[l]); 1378 free(list[l]); 1423 1379 } 1424 1380 } … … 1428 1384 * mimeType, encoding, schema 1429 1385 */ 1430 const char *coms[3]; 1431 coms[0]="mimeType"; 1432 coms[1]="encoding"; 1433 coms[2]="schema"; 1386 const char *coms[3]={"mimeType","encoding","schema"}; 1434 1387 for(int l=0;l<3;l++){ 1435 1388 #ifdef DEBUG 1436 fprintf(stderr,"*** ComplexData %s *** ",coms[l]);1389 fprintf(stderr,"*** ComplexData %s ***\n",coms[l]); 1437 1390 #endif 1438 1391 xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]); … … 1442 1395 else 1443 1396 tmpmaps->content=createMap(coms[l],(char*)val); 1397 #ifdef DEBUG 1398 fprintf(stderr,"%s\n",val); 1399 #endif 1444 1400 } 1445 #ifdef DEBUG1446 fprintf(stderr,"%s\n",val);1447 #endif1448 1401 xmlFree(val); 1449 1402 } 1450 1403 } 1404 1451 1405 map* test=getMap(tmpmaps->content,"encoding"); 1452 if(test==NULL || strcasecmp(test->value,"base64")!=0){ 1406 if(test==NULL){ 1407 if(tmpmaps->content!=NULL) 1408 addToMap(tmpmaps->content,"encoding","utf-8"); 1409 else 1410 tmpmaps->content=createMap("encoding","utf-8"); 1411 test=getMap(tmpmaps->content,"encoding"); 1412 } 1413 1414 if(strcasecmp(test->value,"base64")!=0){ 1453 1415 xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1); 1454 if(mv==NULL){ 1416 map* ltmp=getMap(tmpmaps->content,"mimeType"); 1417 if(mv==NULL || 1418 (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 && 1419 (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){ 1455 1420 xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0"); 1456 1421 int buffersize; 1457 xmlDocSetRootElement(doc1,cur4->xmlChildrenNode); 1422 xmlNodePtr cur5=cur4->children; 1423 while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE) 1424 cur5=cur5->next; 1425 xmlDocSetRootElement(doc1,cur5); 1458 1426 xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1); 1459 1427 char size[1024]; … … 1556 1524 * storeExecuteResponse, lineage, status 1557 1525 */ 1558 const char *ress[3]; 1559 ress[0]="storeExecuteResponse"; 1560 ress[1]="lineage"; 1561 ress[2]="status"; 1526 const char *ress[3]={"storeExecuteResponse","lineage","status"}; 1562 1527 xmlChar *val; 1563 1528 for(int l=0;l<3;l++){ … … 1580 1545 xmlNodePtr cur1=cur->children; 1581 1546 while(cur1){ 1582 if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1547 /** 1548 * Indentifier 1549 */ 1550 if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){ 1551 xmlChar *val= 1552 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1553 if(tmpmaps==NULL){ 1554 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1555 if(tmpmaps == NULL){ 1556 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1557 } 1558 tmpmaps->name=strdup((char*)val); 1559 tmpmaps->content=NULL; 1560 tmpmaps->next=NULL; 1561 } 1562 else 1563 tmpmaps->name=strdup((char*)val);; 1564 xmlFree(val); 1565 } 1566 /** 1567 * Title, Asbtract 1568 */ 1569 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 || 1570 xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){ 1571 xmlChar *val= 1572 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1573 if(tmpmaps==NULL){ 1574 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1575 if(tmpmaps == NULL){ 1576 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1577 } 1578 tmpmaps->name=strdup("missingIndetifier"); 1579 tmpmaps->content=createMap((char*)cur1->name,(char*)val); 1580 tmpmaps->next=NULL; 1581 } 1582 else{ 1583 if(tmpmaps->content!=NULL) 1584 addToMap(tmpmaps->content, 1585 (char*)cur1->name,(char*)val); 1586 else 1587 tmpmaps->content= 1588 createMap((char*)cur1->name,(char*)val); 1589 } 1590 xmlFree(val); 1591 } 1592 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1583 1593 /** 1584 1594 * Get every attribute from a Output node 1585 1595 * mimeType, encoding, schema, uom, asReference 1586 1596 */ 1587 const char *outs[5]; 1588 outs[0]="mimeType"; 1589 outs[1]="encoding"; 1590 outs[2]="schema"; 1591 outs[3]="uom"; 1592 outs[4]="asReference"; 1597 const char *outs[5]={"mimeType","encoding","schema","uom","asReference"}; 1593 1598 for(int l=0;l<5;l++){ 1594 1599 #ifdef DEBUG … … 1632 1637 * Title, Asbtract 1633 1638 */ 1634 if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 ||1639 else if(xmlStrncasecmp(cur2->name,BAD_CAST "Title",xmlStrlen(cur2->name))==0 || 1635 1640 xmlStrncasecmp(cur2->name,BAD_CAST "Abstract",xmlStrlen(cur2->name))==0){ 1636 1641 xmlChar *val= … … 1684 1689 dumpMaps(request_output_real_format); 1685 1690 dumpMap(request_inputs); 1691 fprintf(stderr,"\n%i\n",i); 1686 1692 #endif 1687 1693 … … 1691 1697 */ 1692 1698 char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0); 1693 if(strcmp(dfv,"")!=0){ 1699 char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1); 1700 if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){ 1694 1701 char tmps[1024]; 1695 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); 1702 if(strcmp(dfv,"")!=0){ 1703 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); 1704 } 1705 else if(strcmp(dfv1,"")!=0){ 1706 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); 1707 } 1696 1708 map* tmpe=createMap("text",tmps); 1697 1709 addToMap(tmpe,"code","MissingParameterValue"); … … 1713 1725 return 1; 1714 1726 } 1715 addDefaultValues(&request_output_real_format,s1->outputs,m,1);1716 1727 1717 1728 ensureDecodedBase64(&request_input_real_format); … … 1807 1818 addToMap(_tmpMaps->content,"status","0"); 1808 1819 addToMap(_tmpMaps->content,"cwd",ntmp); 1820 map* ltmp=getMap(request_inputs,"soap"); 1821 if(ltmp!=NULL) 1822 addToMap(_tmpMaps->content,"soap",ltmp->value); 1823 else 1824 addToMap(_tmpMaps->content,"soap","false"); 1809 1825 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1810 1826 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1); … … 1824 1840 if(istat==0 && file_status.st_size>0){ 1825 1841 conf_read(session_file_path,tmpSess); 1826 dumpMaps(tmpSess);1827 1842 addMapsToMaps(&m,tmpSess); 1828 1843 freeMaps(&tmpSess); … … 1849 1864 addToMap(request_inputs,"status","true"); 1850 1865 status=getMap(request_inputs,"status"); 1851 dumpMap(request_inputs);1852 1866 fprintf(stderr,"cgiSID : %s",cgiSid); 1853 1867 }
Note: See TracChangeset
for help on using the changeset viewer.