Changeset 492 for trunk/zoo-project/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Jul 11, 2014, 10:14:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r490 r492 257 257 #endif 258 258 t=readServiceFile(m,tmps1,&s1,dp->d_name); 259 259 260 if(t<0){ 260 261 dumpMaps(m); … … 961 962 char buff1[1024]; 962 963 while(tmps!=NULL){ 964 int hasVal=-1; 963 965 char *corig=strdup(tmps); 964 966 if(strstr(corig,".")!=NULL){ … … 966 968 s1=(service*)malloc(SERVICE_SIZE); 967 969 t=readServiceFile(m,buff1,&s1,corig); 970 968 971 if(t<0){ 969 972 map* tmp00=getMapFromMaps(m,"lenv","message"); … … 977 980 freeMaps(&m); 978 981 free(m); 982 free(REQUEST); 979 983 return 1; 980 984 } … … 989 993 setMapInMaps(m,"lenv","level","0"); 990 994 } 991 free(corig);992 995 993 996 memset(buff,0,256); 994 snprintf(buff,256,"%s.zcfg",tmps); 997 snprintf(buff,256,"%s.zcfg",corig); 998 free(corig); 995 999 memset(buff1,0,1024); 996 1000 #ifdef DEBUG 997 1001 printf("\n#######%s\n########\n",buff); 998 1002 #endif 999 while ((dp = readdir(dirp)) != NULL) 1000 if( (strcasecmp("all.zcfg",buff)==0 && strstr(dp->d_name,".zcfg")>0) 1001 || strcasecmp(dp->d_name,buff)==0 ){ 1003 while ((dp = readdir(dirp)) != NULL){ 1004 if( strcasecmp(dp->d_name,buff)==0 ){ 1002 1005 memset(buff1,0,1024); 1003 1006 snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name); … … 1025 1028 freeMaps(&m); 1026 1029 free(m); 1030 free(orig); 1031 free(REQUEST); 1032 closedir(dirp); 1033 xmlFreeDoc(doc); 1027 1034 return 1; 1028 1035 } … … 1035 1042 s1=NULL; 1036 1043 scount++; 1044 hasVal=1; 1037 1045 } 1046 } 1047 if(hasVal<0){ 1048 map* tmp00=getMapFromMaps(m,"lenv","message"); 1049 char tmp01[1024]; 1050 if(tmp00!=NULL) 1051 sprintf(tmp01,_("Unable to parse the ZCFG file: %s (%s)"),buff,tmp00->value); 1052 else 1053 sprintf(tmp01,_("Unable to parse the ZCFG file: %s."),buff); 1054 dup2(saved_stdout,fileno(stdout)); 1055 errorException(m, tmp01,"InvalidParameterValue","Identifier"); 1056 freeMaps(&m); 1057 free(m); 1058 free(orig); 1059 free(REQUEST); 1060 closedir(dirp); 1061 xmlFreeDoc(doc); 1062 return 1; 1063 } 1038 1064 rewinddir(dirp); 1039 1065 tmps=strtok_r(NULL,",",&saveptr); … … 1271 1297 free(REQUEST); 1272 1298 free(SERVICE_URL); 1273 InternetCloseHandle( hInternet);1299 InternetCloseHandle(&hInternet); 1274 1300 freeService(&s1); 1275 1301 free(s1); … … 1399 1425 free(REQUEST); 1400 1426 free(SERVICE_URL); 1401 InternetCloseHandle( hInternet);1427 InternetCloseHandle(&hInternet); 1402 1428 freeService(&s1); 1403 1429 free(s1); … … 1407 1433 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1408 1434 #endif 1409 addToMap(tmpmaps->content,tmpn1,tmpx2); 1410 1435 addToMap(tmpmaps->content,tmpn1,tmpx2); 1411 1436 #ifndef WIN32 1412 1437 if(CHECK_INET_HANDLE(hInternet)) 1413 1438 #endif 1414 1439 { 1415 if(loadRemoteFile(&m,&tmpmaps->content, hInternet,tmpx2)<0){1440 if(loadRemoteFile(&m,&tmpmaps->content,&hInternet,tmpx2)<0){ 1416 1441 freeMaps(&m); 1417 1442 free(m); 1418 1443 free(REQUEST); 1419 1444 free(SERVICE_URL); 1420 InternetCloseHandle( hInternet);1445 InternetCloseHandle(&hInternet); 1421 1446 freeService(&s1); 1422 1447 free(s1); … … 1445 1470 free(REQUEST); 1446 1471 free(SERVICE_URL); 1447 InternetCloseHandle( hInternet);1472 InternetCloseHandle(&hInternet); 1448 1473 freeService(&s1); 1449 1474 free(s1); … … 1575 1600 if(!(ltmp!=NULL && strncmp(ltmp->value,"POST",4)==0) 1576 1601 && CHECK_INET_HANDLE(hInternet)){ 1577 if(loadRemoteFile(&m,&tmpmaps->content, hInternet,(char*)val)!=0){1602 if(loadRemoteFile(&m,&tmpmaps->content,&hInternet,(char*)val)!=0){ 1578 1603 freeMaps(&m); 1579 1604 free(m); 1580 1605 free(REQUEST); 1581 1606 free(SERVICE_URL); 1582 InternetCloseHandle( hInternet);1607 InternetCloseHandle(&hInternet); 1583 1608 freeService(&s1); 1584 1609 free(s1); … … 1597 1622 #endif 1598 1623 xmlNodePtr cur3=cur2->children; 1599 HINTERNET hInternetP;1624 /* HINTERNET hInternetP; 1600 1625 hInternetP=InternetOpen( 1601 1626 #ifndef WIN32 … … 1604 1629 "ZooWPSClient\0", 1605 1630 INTERNET_OPEN_TYPE_PRECONFIG, 1606 NULL,NULL, 0); 1607 hInternetP.header=NULL;1631 NULL,NULL, 0);*/ 1632 //hInternet.ihandle[hInternet.nb].header=NULL; 1608 1633 while(cur3!=NULL){ 1609 1634 while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE) … … 1638 1663 xmlFree(val); 1639 1664 } 1640 hInternet P.header=curl_slist_append(hInternetP.header, has);1665 hInternet.ihandle[hInternet.nb].header=curl_slist_append(hInternet.ihandle[hInternet.nb].header, has); 1641 1666 if(has!=NULL) 1642 1667 free(has); … … 1675 1700 #ifdef POST_DEBUG 1676 1701 fprintf(stderr,"%s %s\n",btmp->value,tmp); 1677 curl_easy_setopt(hInternetP.handle, CURLOPT_VERBOSE, 1); 1678 #endif 1679 res=InternetOpenUrl(hInternetP,btmp->value,tmp,strlen(tmp), 1702 curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1); 1703 #endif 1704 hInternet.waitingRequests[hInternet.nb]=strdup(tmp); 1705 InternetOpenUrl(&hInternet,btmp->value,hInternet.waitingRequests[hInternet.nb],strlen(hInternet.waitingRequests[hInternet.nb]), 1680 1706 INTERNET_FLAG_NO_CACHE_WRITE,0); 1681 char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));1682 if(tmpContent == NULL){1683 return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);1684 }1685 size_t dwRead;1686 InternetReadFile(res, (LPVOID)tmpContent,1687 res.nDataLen, &dwRead);1688 tmpContent[res.nDataLen]=0;1689 if(hInternetP.header!=NULL)1690 curl_slist_free_all(hInternetP.header);1691 addToMap(tmpmaps->content,"value",tmpContent);1692 free(tmpContent);1693 #ifdef POST_DEBUG1694 fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);1695 #endif1696 1707 } 1697 1708 free(tmp); … … 1708 1719 INTERNET_OPEN_TYPE_PRECONFIG, 1709 1720 NULL,NULL, 0); 1710 if(!CHECK_INET_HANDLE( bInternet))1721 if(!CHECK_INET_HANDLE(hInternet)) 1711 1722 fprintf(stderr,"WARNING : hInternet handle failed to initialize"); 1712 1723 #ifdef POST_DEBUG 1713 1724 curl_easy_setopt(bInternet.handle, CURLOPT_VERBOSE, 1); 1714 1725 #endif 1715 res1=InternetOpenUrl(bInternet,(char*)val,NULL,0, 1726 bInternet.waitingRequests[0]=strdup((char*)val); 1727 res1=InternetOpenUrl(&bInternet,bInternet.waitingRequests[0],NULL,0, 1716 1728 INTERNET_FLAG_NO_CACHE_WRITE,0); 1729 processDownloads(&bInternet); 1717 1730 char* tmp= 1718 (char*)malloc(( res1.nDataLen+1)*sizeof(char));1731 (char*)malloc((bInternet.ihandle[0].nDataLen+1)*sizeof(char)); 1719 1732 if(tmp == NULL){ 1720 1733 return errorException(m, _("Unable to allocate memory."), "InternalError",NULL); 1721 1734 } 1722 1735 size_t bRead; 1723 InternetReadFile( res1, (LPVOID)tmp,1724 res1.nDataLen, &bRead);1725 tmp[ res1.nDataLen]=0;1726 InternetCloseHandle( bInternet);1736 InternetReadFile(bInternet.ihandle[0], (LPVOID)tmp, 1737 bInternet.ihandle[0].nDataLen, &bRead); 1738 tmp[bInternet.ihandle[0].nDataLen]=0; 1739 InternetCloseHandle(&bInternet); 1727 1740 map *btmp=getMap(tmpmaps->content,"href"); 1728 1741 if(btmp!=NULL){ 1729 1742 #ifdef POST_DEBUG 1730 1743 fprintf(stderr,"%s %s\n",btmp->value,tmp); 1731 curl_easy_setopt(hInternetP.handle, CURLOPT_VERBOSE, 1); 1732 #endif 1733 res=InternetOpenUrl( hInternetP,btmp->value,tmp,1734 strlen( tmp),1744 #endif 1745 hInternet.waitingRequests[hInternet.nb]=strdup(tmp); 1746 res=InternetOpenUrl(&hInternet,btmp->value,hInternet.waitingRequests[hInternet.nb], 1747 strlen(hInternet.waitingRequests[hInternet.nb]), 1735 1748 INTERNET_FLAG_NO_CACHE_WRITE,0); 1736 char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));1737 if(tmpContent == NULL){1738 return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);1739 }1740 size_t dwRead;1741 InternetReadFile(res, (LPVOID)tmpContent,1742 res.nDataLen, &dwRead);1743 tmpContent[res.nDataLen]=0;1744 if(hInternetP.header!=NULL)1745 curl_slist_free_all(hInternetP.header);1746 addToMap(tmpmaps->content,"value",tmpContent);1747 #ifdef POST_DEBUG1748 fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);1749 #endif1750 1749 } 1750 free(tmp); 1751 1751 } 1752 1752 } 1753 1753 cur3=cur3->next; 1754 1754 } 1755 InternetCloseHandle(hInternetP);1756 1755 #ifdef POST_DEBUG 1757 1756 fprintf(stderr,"Header and Body was parsed from Reference \n"); … … 1901 1900 free(REQUEST); 1902 1901 free(SERVICE_URL); 1903 InternetCloseHandle( hInternet);1902 InternetCloseHandle(&hInternet); 1904 1903 freeService(&s1); 1905 1904 free(s1); … … 2148 2147 } 2149 2148 2149 runHttpRequests(&m,&request_input_real_format,&hInternet); 2150 2150 2151 2151 // if(CHECK_INET_HANDLE(hInternet)) 2152 InternetCloseHandle( hInternet);2152 InternetCloseHandle(&hInternet); 2153 2153 2154 2154 #ifdef DEBUG
Note: See TracChangeset
for help on using the changeset viewer.