Changeset 281 for trunk/zoo-kernel/zoo_service_loader.c
- Timestamp:
- Jul 27, 2011, 2:28:25 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/zoo_service_loader.c
r280 r281 1053 1053 #endif 1054 1054 { 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); 1097 } 1055 loadRemoteFile(m,tmpmaps->content,hInternet,tmpv1+1); 1098 1056 } 1099 1057 char *tmpx1=url_encode(tmpv1+1); … … 1237 1195 if(!(ltmp!=NULL && strcmp(ltmp->value,"POST")==0) 1238 1196 && CHECK_INET_HANDLE(hInternet)){ 1239 res=InternetOpenUrl(hInternet,(char*)val,NULL,0, 1240 INTERNET_FLAG_NO_CACHE_WRITE,0); 1241 char* tmpContent= 1242 (char*)calloc((res.nDataLen+1),sizeof(char)); 1243 if(tmpContent == NULL){ 1244 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1245 } 1246 size_t dwRead; 1247 InternetReadFile(res, (LPVOID)tmpContent, 1248 res.nDataLen, &dwRead); 1249 tmpContent[res.nDataLen]=0; 1250 addToMap(tmpmaps->content,"value",tmpContent); 1197 loadRemoteFile(m,tmpmaps->content,hInternet,(char*)val); 1251 1198 } 1252 1199 }
Note: See TracChangeset
for help on using the changeset viewer.