ucx
UAP Common Extensions
|
Load / store utilities for properties files. More...
Go to the source code of this file.
Data Structures | |
struct | UcxProperties |
UcxProperties object for parsing properties data. More... | |
Functions | |
UcxProperties * | ucx_properties_new () |
Constructs a new UcxProperties object. More... | |
void | ucx_properties_free (UcxProperties *prop) |
Destroys a UcxProperties object. More... | |
void | ucx_properties_fill (UcxProperties *prop, char *buf, size_t len) |
Sets the input buffer for the properties parser. More... | |
int | ucx_properties_next (UcxProperties *prop, sstr_t *name, sstr_t *value) |
Retrieves the next key/value-pair. More... | |
int | ucx_properties2map (UcxProperties *prop, UcxMap *map) |
Retrieves all available key/value-pairs and puts them into a UcxMap. More... | |
int | ucx_properties_load (UcxMap *map, FILE *file) |
Loads a properties file to a UcxMap. More... | |
int | ucx_properties_store (UcxMap *map, FILE *file) |
Stores a UcxMap to a file. More... | |
Load / store utilities for properties files.
int ucx_properties2map | ( | UcxProperties * | prop, |
UcxMap * | map | ||
) |
Retrieves all available key/value-pairs and puts them into a UcxMap.
This is done by successive calls to ucx_properties_next() until no more key/value-pairs can be retrieved.
The memory for the map values is allocated by the map's own allocator.
prop | the UcxProperties object |
map | the target map |
void ucx_properties_fill | ( | UcxProperties * | prop, |
char * | buf, | ||
size_t | len | ||
) |
Sets the input buffer for the properties parser.
After calling this function, you may parse the data by calling ucx_properties_next() until it returns 0. The function ucx_properties2map() is a convenience function that reads as much data as possible by using this function.
prop | the UcxProperties object |
buf | a pointer to the new buffer |
len | the payload length of the buffer |
void ucx_properties_free | ( | UcxProperties * | prop | ) |
Destroys a UcxProperties object.
prop | the UcxProperties object to destroy |
int ucx_properties_load | ( | UcxMap * | map, |
FILE * | file | ||
) |
Loads a properties file to a UcxMap.
This is a convenience function that reads data from an input stream until the end of the stream is reached.
map | the map object to write the key/value-pairs to |
file | the FILE* stream to read from |
UcxProperties* ucx_properties_new | ( | ) |
Constructs a new UcxProperties object.
int ucx_properties_next | ( | UcxProperties * | prop, |
sstr_t * | name, | ||
sstr_t * | value | ||
) |
Retrieves the next key/value-pair.
This function returns a nonzero value as long as there are key/value-pairs found. If no more key/value-pairs are found, you may refill the input buffer with ucx_properties_fill().
Attention: the sstr_t.ptr pointers of the output parameters point to memory within the input buffer of the parser and will get invalid some time. If you want long term copies of the key/value-pairs, use sstrdup() after calling this function.
prop | the UcxProperties object |
name | a pointer to the sstr_t that shall contain the property name |
value | a pointer to the sstr_t that shall contain the property value |