src/properties.c

changeset 972
a9a1d07a6840
parent 929
192a440b99df
equal deleted inserted replaced
971:cc204fc56c9c 972:a9a1d07a6840
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "cx/properties.h" 29 #include "cx/properties.h"
30 30
31 #include <string.h>
32 #include <assert.h> 31 #include <assert.h>
33 32
34 static const int CX_PROPERTIES_FLAG_USE_STACK = 0x01; 33 static const int CX_PROPERTIES_FLAG_USE_STACK = 0x01;
35 34
36 const CxPropertiesConfig cx_properties_config_default = { 35 const CxPropertiesConfig cx_properties_config_default = {
104 size_t len = prop->text_size - prop->text_pos; 103 size_t len = prop->text_size - prop->text_pos;
105 104
106 return cx_properties_rescuen_input(prop, len); 105 return cx_properties_rescuen_input(prop, len);
107 } 106 }
108 107
109 void cxPropertiesInput( 108 int cxPropertiesFilln(
110 CxProperties *prop, 109 CxProperties *prop,
111 const char *buf, 110 const char *buf,
112 size_t len 111 size_t len
113 ) { 112 ) {
113 if (cx_properties_rescue_input(prop)) return 1;
114 prop->text = buf; 114 prop->text = buf;
115 prop->text_size = len; 115 prop->text_size = len;
116 prop->text_pos = 0; 116 prop->text_pos = 0;
117 }
118
119 int cxPropertiesFill(
120 CxProperties *prop,
121 const char *buf,
122 size_t len
123 ) {
124 if (cx_properties_rescue_input(prop)) return 1;
125 cxPropertiesInput(prop, buf, len);
126 return 0; 117 return 0;
127 } 118 }
128 119
129 void cxPropertiesUseStack( 120 void cxPropertiesUseStack(
130 CxProperties *prop, 121 CxProperties *prop,
427 status = found ? CX_PROPERTIES_NO_ERROR : CX_PROPERTIES_NO_DATA; 418 status = found ? CX_PROPERTIES_NO_ERROR : CX_PROPERTIES_NO_DATA;
428 break; 419 break;
429 } 420 }
430 421
431 // set the input buffer and read the k/v-pairs 422 // set the input buffer and read the k/v-pairs
432 cxPropertiesInput(prop, input.ptr, input.length); 423 prop->text = input.ptr;
424 prop->text_size = input.length;
425 prop->text_pos = 0;
433 426
434 CxPropertiesStatus kv_status; 427 CxPropertiesStatus kv_status;
435 do { 428 do {
436 cxstring key, value; 429 cxstring key, value;
437 kv_status = cxPropertiesNext(prop, &key, &value); 430 kv_status = cxPropertiesNext(prop, &key, &value);

mercurial