src/properties.c

changeset 1503
48993e0e0dba
parent 1426
3a89b31f0724
equal deleted inserted replaced
1502:0130ee1ae112 1503:48993e0e0dba
118 current_buffer = &prop->buffer; 118 current_buffer = &prop->buffer;
119 } else { 119 } else {
120 // still not enough data, copy input buffer to internal buffer 120 // still not enough data, copy input buffer to internal buffer
121 if (cxBufferAppend(input.ptr, 1, 121 if (cxBufferAppend(input.ptr, 1,
122 input.length, &prop->buffer) < input.length) { 122 input.length, &prop->buffer) < input.length) {
123 return CX_PROPERTIES_BUFFER_ALLOC_FAILED; 123 return CX_PROPERTIES_BUFFER_ALLOC_FAILED; // LCOV_EXCL_LINE
124 } 124 }
125 // reset the input buffer (make way for a re-fill) 125 // reset the input buffer (make way for a re-fill)
126 cxBufferReset(&prop->input); 126 cxBufferReset(&prop->input);
127 return CX_PROPERTIES_INCOMPLETE_DATA; 127 return CX_PROPERTIES_INCOMPLETE_DATA;
128 } 128 }
358 assert(sink.sink_func != NULL); 358 assert(sink.sink_func != NULL);
359 359
360 // initialize reader 360 // initialize reader
361 if (source.read_init_func != NULL) { 361 if (source.read_init_func != NULL) {
362 if (source.read_init_func(prop, &source)) { 362 if (source.read_init_func(prop, &source)) {
363 return CX_PROPERTIES_READ_INIT_FAILED; 363 return CX_PROPERTIES_READ_INIT_FAILED; // LCOV_EXCL_LINE
364 } 364 }
365 } 365 }
366 366
367 // transfer the data from the source to the sink 367 // transfer the data from the source to the sink
368 CxPropertiesStatus status; 368 CxPropertiesStatus status;
369 CxPropertiesStatus kv_status = CX_PROPERTIES_NO_DATA; 369 CxPropertiesStatus kv_status = CX_PROPERTIES_NO_DATA;
370 bool found = false; 370 bool found = false;
371 while (true) { 371 while (true) {
372 // read input 372 // read input
373 cxstring input; 373 cxstring input;
374 if (source.read_func(prop, &source, &input)) { 374 if (source.read_func(prop, &source, &input)) { // LCOV_EXCL_START
375 status = CX_PROPERTIES_READ_FAILED; 375 status = CX_PROPERTIES_READ_FAILED;
376 break; 376 break;
377 } 377 } // LCOV_EXCL_STOP
378 378
379 // no more data - break 379 // no more data - break
380 if (input.length == 0) { 380 if (input.length == 0) {
381 if (found) { 381 if (found) {
382 // something was found, check the last kv_status 382 // something was found, check the last kv_status
399 cxstring key, value; 399 cxstring key, value;
400 kv_status = cxPropertiesNext(prop, &key, &value); 400 kv_status = cxPropertiesNext(prop, &key, &value);
401 if (kv_status == CX_PROPERTIES_NO_ERROR) { 401 if (kv_status == CX_PROPERTIES_NO_ERROR) {
402 found = true; 402 found = true;
403 if (sink.sink_func(prop, &sink, key, value)) { 403 if (sink.sink_func(prop, &sink, key, value)) {
404 kv_status = CX_PROPERTIES_SINK_FAILED; 404 kv_status = CX_PROPERTIES_SINK_FAILED; // LCOV_EXCL_LINE
405 } 405 }
406 } 406 }
407 } while (kv_status == CX_PROPERTIES_NO_ERROR); 407 } while (kv_status == CX_PROPERTIES_NO_ERROR);
408 408
409 if (kv_status > CX_PROPERTIES_OK) { 409 if (kv_status > CX_PROPERTIES_OK) {

mercurial