212 cx_properties_sink_func sink_func; |
212 cx_properties_sink_func sink_func; |
213 } CxPropertiesSink; |
213 } CxPropertiesSink; |
214 ``` |
214 ``` |
215 |
215 |
216 You can create your own sources and sinks by initializing the respective structures. |
216 You can create your own sources and sinks by initializing the respective structures. |
|
217 |
217 For a source, only the `read_func` is mandatory, the other two functions are optional and used for initialization and cleanup, if required. |
218 For a source, only the `read_func` is mandatory, the other two functions are optional and used for initialization and cleanup, if required. |
218 The file source created by `cxPropertiesFileSource()`, for example, |
219 The file source created by `cxPropertiesFileSource()`, for example, |
219 uses the `read_init_func` to allocate, and the `read_clean_func` to free the read buffer, respectively. |
220 uses the `read_init_func` to allocate, and the `read_clean_func` to free the read buffer, respectively. |
220 |
221 |
221 Since the default map sink created by `cxPropertiesMapSink()` stores `char*` pointers into a map, |
222 Since the default map sink created by `cxPropertiesMapSink()` stores `char*` pointers into a map, |
222 the following example uses a different sink, which stores them as `cxmutstr` values, automatically freeing them |
223 the following example uses a different sink, which stores them as `cxmutstr` values, automatically freeing them |
223 when the map gets destroyed. |
224 when the map gets destroyed. |
|
225 And instead of reading the data from a file with `fread()`, it uses `mmap()` to map the file into memory for reading. |
224 |
226 |
225 ```C |
227 ```C |
226 #include <stdio.h> |
228 #include <stdio.h> |
227 #include <unistd.h> |
229 #include <unistd.h> |
228 #include <fcntl.h> |
230 #include <fcntl.h> |