| 281 cxPropertiesInit(&parser, config); |
281 cxPropertiesInit(&parser, config); |
| 282 cxPropertiesUseStack(&parser, linebuf, cx_properties_load_buf_size); |
282 cxPropertiesUseStack(&parser, linebuf, cx_properties_load_buf_size); |
| 283 |
283 |
| 284 // read/fill/parse loop |
284 // read/fill/parse loop |
| 285 status = CX_PROPERTIES_NO_DATA; |
285 status = CX_PROPERTIES_NO_DATA; |
| |
286 size_t keys_found = 0; |
| 286 while (true) { |
287 while (true) { |
| 287 size_t r = fread(fillbuf, 1, cx_properties_load_fill_size, f); |
288 size_t r = fread(fillbuf, 1, cx_properties_load_fill_size, f); |
| 288 if (ferror(f)) { |
289 if (ferror(f)) { |
| 289 status = CX_PROPERTIES_FILE_ERROR; |
290 status = CX_PROPERTIES_FILE_ERROR; |
| 290 break; |
291 break; |
| 311 if (cxMapPut(target, key, mv)) { |
312 if (cxMapPut(target, key, mv)) { |
| 312 cx_strfree(&v); |
313 cx_strfree(&v); |
| 313 status = CX_PROPERTIES_MAP_ERROR; |
314 status = CX_PROPERTIES_MAP_ERROR; |
| 314 break; |
315 break; |
| 315 } |
316 } |
| |
317 keys_found++; |
| 316 } |
318 } |
| 317 } |
319 } |
| 318 if (status > CX_PROPERTIES_OK) { |
320 if (status > CX_PROPERTIES_OK) { |
| 319 break; |
321 break; |
| 320 } else if (status == CX_PROPERTIES_NO_DATA) { |
|
| 321 // we want to report this case differently in this function |
|
| 322 status = CX_PROPERTIES_NO_ERROR; |
|
| 323 } |
322 } |
| 324 } |
323 } |
| 325 |
324 |
| 326 // cleanup and exit |
325 // cleanup and exit |
| 327 fclose(f); |
326 fclose(f); |
| 328 cxPropertiesDestroy(&parser); |
327 cxPropertiesDestroy(&parser); |
| 329 cx_strfree(&fname); |
328 cx_strfree(&fname); |
| 330 return status; |
329 if (status == CX_PROPERTIES_NO_DATA && keys_found > 0) { |
| 331 } |
330 return CX_PROPERTIES_NO_ERROR; |
| |
331 } else { |
| |
332 return status; |
| |
333 } |
| |
334 } |