universe@390: universe@390: universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:universe@390: |
universe@390: ucx
universe@390:
universe@390: UAP Common Extensions
universe@390: |
universe@390:
Load / store utilities for properties files. universe@390: More...
universe@390: universe@390:Go to the source code of this file.
universe@390:universe@390: Data Structures | |
struct | UcxProperties |
UcxProperties object for parsing properties data. More... | |
universe@390: 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.
universe@390: universe@390:int ucx_properties2map | universe@390:( | universe@390:UcxProperties * | universe@390:prop, | universe@390:
universe@390: | universe@390: | UcxMap * | universe@390:map | universe@390:
universe@390: | ) | universe@390:universe@390: |
Retrieves all available key/value-pairs and puts them into a UcxMap.
universe@390:This is done by successive calls to ucx_properties_next() until no more key/value-pairs can be retrieved.
universe@390:The memory for the map values is allocated by the map's own allocator.
universe@390:prop | the UcxProperties object |
map | the target map |
void ucx_properties_fill | universe@390:( | universe@390:UcxProperties * | universe@390:prop, | universe@390:
universe@390: | universe@390: | char * | universe@390:buf, | universe@390:
universe@390: | universe@390: | size_t | universe@390:len | universe@390:
universe@390: | ) | universe@390:universe@390: |
Sets the input buffer for the properties parser.
universe@390: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.
universe@390:prop | the UcxProperties object |
buf | a pointer to the new buffer |
len | the payload length of the buffer |
void ucx_properties_free | universe@390:( | universe@390:UcxProperties * | universe@390:prop | ) | universe@390:universe@390: |
Destroys a UcxProperties object.
universe@390:prop | the UcxProperties object to destroy |
int ucx_properties_load | universe@390:( | universe@390:UcxMap * | universe@390:map, | universe@390:
universe@390: | universe@390: | FILE * | universe@390:file | universe@390:
universe@390: | ) | universe@390:universe@390: |
Loads a properties file to a UcxMap.
universe@390:This is a convenience function that reads data from an input stream until the end of the stream is reached.
universe@390:map | the map object to write the key/value-pairs to |
file | the FILE* stream to read from |
UcxProperties* ucx_properties_new | universe@390:( | universe@390:) | universe@390:universe@390: |
Constructs a new UcxProperties object.
universe@390:int ucx_properties_next | universe@390:( | universe@390:UcxProperties * | universe@390:prop, | universe@390:
universe@390: | universe@390: | sstr_t * | universe@390:name, | universe@390:
universe@390: | universe@390: | sstr_t * | universe@390:value | universe@390:
universe@390: | ) | universe@390:universe@390: |
Retrieves the next key/value-pair.
universe@390: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().
universe@390: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.
universe@390: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 |
int ucx_properties_store | universe@390:( | universe@390:UcxMap * | universe@390:map, | universe@390:
universe@390: | universe@390: | FILE * | universe@390:file | universe@390:
universe@390: | ) | universe@390:universe@390: |
Stores a UcxMap to a file.
universe@390:The key/value-pairs are written by using the following format:
universe@390:[key] = [value]\n
map | the map to store |
file | the FILE* stream to write to |