Changeset 797 for trunk/zoo-project/zoo-kernel/caching.c
- Timestamp:
- Jan 10, 2017, 5:21:45 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/caching.c
r790 r797 154 154 * @param index the input index 155 155 * @param hInternet the internet connection 156 * @return 0 in case of success, 4 in case of failure 157 */ 158 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet){ 156 * @param error the error map pointer 157 * @return 0 in case of success, -1 in case of failure 158 */ 159 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){ 159 160 map* tmp1; 160 161 char sindex[5]; … … 207 208 208 209 if(getMap(content->content,icname)==NULL){ 209 210 210 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 211 211 if(fcontent == NULL){ 212 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 212 errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 213 return -1; 213 214 } 214 215 size_t dwRead; … … 231 232 } 232 233 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 234 if(hInternet->ihandle[*index].code!=200){ 235 char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d."); 236 char *error_msg=(char*)malloc((strlen(error_rep_str)+strlen(content->name)+4)*sizeof(char)); 237 sprintf(error_msg,error_rep_str,content->name,hInternet->ihandle[*index].code); 238 if(*error==NULL){ 239 *error=createMap("text",error_msg); 240 addToMap(*error,"locator",content->name); 241 addToMap(*error,"code","InvalidParameterValue"); 242 }else{ 243 int nb=1; 244 map* tmpMap=getMap(*error,"length"); 245 if(tmpMap!=NULL) 246 nb=atoi(tmpMap->value); 247 setMapArray(*error,"text",nb,error_msg); 248 setMapArray(*error,"locator",nb,content->name); 249 setMapArray(*error,"code",nb,"InvalidParameterValue"); 250 } 251 return -1; 252 } 233 253 234 254 char ltmp1[256]; … … 266 286 * per default based on the zcfg file) 267 287 * @param hInternet the HINTERNET pointer 268 * @return 0 on success 269 */ 270 int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){ 288 * @param error the error map pointer 289 * @return 0 on success, -1 on failure 290 */ 291 int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet,map** error){ 292 int hasAFailure=0; 271 293 if(hInternet!=NULL && hInternet->nb>0){ 272 294 processDownloads(hInternet); … … 277 299 maps* cursor=content->child; 278 300 while(cursor!=NULL){ 279 readCurrentInput(m,&cursor,&index,hInternet); 301 int red=readCurrentInput(m,&cursor,&index,hInternet,error); 302 if(red<0) 303 hasAFailure=red; 280 304 cursor=cursor->next; 281 305 } 282 306 } 283 else 284 readCurrentInput(m,&content,&index,hInternet); 307 else{ 308 int red=readCurrentInput(m,&content,&index,hInternet,error); 309 if(red<0) 310 hasAFailure=red; 311 } 285 312 content=content->next; 286 } 287 } 288 return 0;313 } 314 } 315 return hasAFailure; 289 316 } 290 317
Note: See TracChangeset
for help on using the changeset viewer.