Changeset 379 for trunk/zoo-project/zoo-kernel/service_internal.c
- Timestamp:
- Dec 23, 2012, 11:50:33 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r378 r379 1347 1347 maps* mcursor=outputs; 1348 1348 elements* scursor=serv->outputs; 1349 map* testResponse=getMap(request,"RawDataOutput"); 1350 if(testResponse==NULL) 1351 testResponse=getMap(request,"ResponseDocument"); 1349 1352 while(mcursor!=NULL){ 1353 map* tmp0=getMap(mcursor->content,"inRequest"); 1350 1354 scursor=getElements(serv->outputs,mcursor->name); 1351 1355 if(scursor!=NULL){ 1352 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1356 if(testResponse==NULL) 1357 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1358 else 1359 if(strncmp(tmp0->value,"true",4)==0) 1360 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1353 1361 } 1354 1362 mcursor=mcursor->next; … … 1599 1607 map* tmp1=getMap(m->content,"encoding"); 1600 1608 map* tmp2=getMap(m->content,"mimeType"); 1601 map* toto=getMap(m->content,"value"); 1609 map* tmp3=getMap(m->content,"value"); 1610 int hasValue=1; 1611 if(tmp3==NULL){ 1612 tmp3=createMap("value",""); 1613 hasValue=-1; 1614 } 1602 1615 if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0) 1603 1616 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 || … … 1610 1623 if(rs==NULL){ 1611 1624 char tmp1[1024]; 1612 sprintf(tmp1,"%d",strlen(t oto->value));1625 sprintf(tmp1,"%d",strlen(tmp3->value)); 1613 1626 rs=createMap("size",tmp1); 1614 1627 isSized=false; 1615 1628 } 1616 1629 1617 xmlAddChild(nc3,xmlNewText(BAD_CAST base64(t oto->value, atoi(rs->value))));1630 xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); 1618 1631 if(!isSized){ 1619 1632 freeMap(&rs); … … 1624 1637 if(strncmp(tmp2->value,"text/js",7)==0 || 1625 1638 strncmp(tmp2->value,"application/json",16)==0) 1626 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST t oto->value,strlen(toto->value)));1639 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 1627 1640 else{ 1628 1641 if(strncmp(tmp2->value,"text/xml",8)==0 || 1629 1642 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){ 1630 1643 xmlDocPtr doc = 1631 xmlParseMemory(t oto->value,strlen(toto->value));1644 xmlParseMemory(tmp3->value,strlen(tmp3->value)); 1632 1645 xmlNodePtr ir = xmlDocGetRootElement(doc); 1633 1646 xmlAddChild(nc3,ir); 1634 1647 } 1635 1648 else 1636 xmlAddChild(nc3,xmlNewText(BAD_CAST t oto->value));1649 xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value)); 1637 1650 } 1638 1651 xmlAddChild(nc2,nc3); 1639 1652 } 1640 1653 else{ 1641 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1642 } 1654 xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value)); 1655 } 1656 if(hasValue<0){ 1657 freeMap(&tmp3); 1658 free(tmp3); 1659 } 1643 1660 } 1644 1661 } … … 1811 1828 asRaw=1; 1812 1829 1813 map *_tmp=getMapFromMaps(m,"lenv","cookie"); 1814 map *_tmp1=getMapFromMaps(m,"lenv","sessid"); 1815 if(_tmp!=NULL){ 1816 printf("Set-Cookie: %s\r\n",_tmp->value); 1817 printf("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"\r\n"); 1818 maps *tmpSess=getMaps(m,"senv"); 1819 if(tmpSess!=NULL){ 1820 char session_file_path[1024]; 1821 map *tmpPath=getMapFromMaps(m,"main","sessPath"); 1822 if(tmpPath==NULL) 1823 tmpPath=getMapFromMaps(m,"main","tmpPath"); 1830 maps* tmpSess=getMaps(m,"senv"); 1831 if(tmpSess!=NULL){ 1832 map *_tmp=getMapFromMaps(m,"lenv","cookie"); 1833 char* sessId; 1834 if(_tmp!=NULL){ 1835 printf("Set-Cookie: %s\r\n",_tmp->value); 1836 printf("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"\r\n"); 1837 char session_file_path[100]; 1824 1838 char *tmp1=strtok(_tmp->value,";"); 1825 1839 if(tmp1!=NULL) 1826 sprintf(session_file_path,"%s /sess_%s.cfg",tmpPath->value,strstr(tmp1,"=")+1);1840 sprintf(session_file_path,"%s",strstr(tmp1,"=")+1); 1827 1841 else 1828 sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(_tmp->value,"=")+1); 1829 dumpMapsToFile(tmpSess,session_file_path); 1830 } 1831 } 1832 1842 sprintf(session_file_path,"%s",strstr(_tmp->value,"=")+1); 1843 sessId=strdup(session_file_path); 1844 }else{ 1845 maps* t=getMaps(m,"senv"); 1846 map*p=t->content; 1847 while(p!=NULL){ 1848 if(strstr(p->name,"ID")!=NULL){ 1849 sessId=strdup(p->value); 1850 break; 1851 } 1852 p=p->next; 1853 } 1854 } 1855 char session_file_path[1024]; 1856 map *tmpPath=getMapFromMaps(m,"main","sessPath"); 1857 if(tmpPath==NULL) 1858 tmpPath=getMapFromMaps(m,"main","tmpPath"); 1859 sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,sessId); 1860 dumpMapsToFile(tmpSess,session_file_path); 1861 } 1862 1833 1863 printHeaders(m); 1834 1864 … … 2472 2502 fprintf(stderr,"MD5STR : (%s)\n\n",md5str); 2473 2503 #endif 2474 char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+ 38));2504 char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+50)); 2475 2505 sprintf(fname,"%s/%s.zca",tmpM->value,md5str); 2476 2506 struct stat f_status; … … 2495 2525 char* cached=isInCache(m,url); 2496 2526 int fsize; 2527 int hasF=-1; 2497 2528 if(cached!=NULL){ 2498 2529 struct stat f_status; 2499 2530 int s=stat(cached, &f_status); 2500 2531 if(s==0){ 2501 fprintf(stderr,"FILE SIZE (%d)\n",f_status.st_size/1024);2502 2532 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 2503 2533 FILE* f=fopen(cached,"rb"); 2504 2534 fread(fcontent,sizeof(char),f_status.st_size,f); 2505 2535 fsize=f_status.st_size; 2536 hasF=1; 2506 2537 } 2507 2538 }else{ 2508 2539 res=InternetOpenUrl(hInternet,url,NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0); 2509 fcontent=(char*) calloc((res.nDataLen+1),sizeof(char));2540 fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char)); 2510 2541 if(fcontent == NULL){ 2511 2542 return errorException(m, _("Unable to allocate memory."), "InternalError"); 2512 2543 } 2544 hasF=1; 2513 2545 size_t dwRead; 2514 2546 InternetReadFile(res, (LPVOID)fcontent, res.nDataLen, &dwRead); … … 2524 2556 free(tmpMap->value); 2525 2557 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 2558 if(tmpMap->value==NULL) 2559 fprintf(stderr,"Unable to allocate memory!\n"); 2526 2560 memcpy(tmpMap->value,fcontent,(fsize)*sizeof(char)); 2527 2561 2528 2562 char ltmp1[256]; 2529 2563 sprintf(ltmp1,"%d",fsize); … … 2531 2565 if(cached==NULL) 2532 2566 addToCache(m,url,fcontent,fsize); 2533 free(fcontent); 2534 if(cached!=NULL) 2567 else{ 2568 if(hasF) 2569 free(fcontent); 2535 2570 free(cached); 2571 } 2536 2572 return 0; 2537 2573 }
Note: See TracChangeset
for help on using the changeset viewer.