Main Page | Modules | Data Structures | File List | Data Fields

Configuration


Functions

void u_config_print (u_config_t *c, int lev)
 Print configuration to stdout.
int u_config_load (u_config_t *c, int fd, int overwrite)
 Load a configuration file.
int u_config_load_from_file (const char *file, u_config_t **pc)
 Create a configuration object reading from a config file.
int u_config_create (u_config_t **pc)
 Create a config object.
int u_config_free (u_config_t *c)
 Free a config object and all its children.
const char * u_config_get_key (u_config_t *c)
 Return the key of a config object.
const char * u_config_get_value (u_config_t *c)
 Return the value of a config object.
const char * u_config_get_subkey_value (u_config_t *c, const char *subkey)
 Return the value of a subkey.
int u_config_get_subkey_value_i (u_config_t *c, const char *subkey, int def, int *out)
 Return the value of an integer subkey.
int u_config_get_subkey_value_b (u_config_t *c, const char *subkey, int def, int *out)
 Return the value of an bool subkey.

Detailed Description

Intro
The u_config_t object is used to store, load and parse text configuration files.
A configuration file is a plain text file that stores a list of key=values pair in a tree-ordered structure. TODO

Function Documentation

int u_config_create u_config_t **  pc  ) 
 

Create a config object. Use u_config_set_key(...) to set its key/value pairs.

Parameters:
pc value-result that will get the new configuration object
Returns:
0 on success, not-zero on error.

Definition at line 477 of file config.c.

References u_config_free(), and u_zalloc().

Referenced by u_config_load_from_file().

int u_config_free u_config_t *  c  ) 
 

Free a config object and all its children.

Parameters:
c configuration object
Returns:
0 on success, not zero on failure

Definition at line 518 of file config.c.

Referenced by u_config_create(), and u_config_load_from_file().

const char* u_config_get_key u_config_t *  c  ) 
 

Return the key string of a config object.

Parameters:
c configuration object
Returns:
The key string pointer on success, NULL on failure

Definition at line 550 of file config.c.

const char* u_config_get_subkey_value u_config_t *  c,
const char *  subkey
 

Return the value of the child config object whose key is subkey.

Parameters:
c configuration object
subkey the key value of the child config object
Returns:
The value string pointer on success, NULL on failure

Definition at line 587 of file config.c.

References u_config_get_value().

Referenced by u_config_get_subkey_value_b(), and u_config_get_subkey_value_i().

int u_config_get_subkey_value_b u_config_t *  c,
const char *  subkey,
int  def,
int *  out
 

Return the bool value of the child config object whose key is subkey.

Recognized bool values are (case insensitive) yes/no, 1/0, enable/disable.

Parameters:
c configuration object
subkey the key value of the child config object
def the value to return if the key is missing
out on exit will get the bool value of the key
Returns:
0 on success, not zero if the key value is not a bool keyword

Definition at line 649 of file config.c.

References u_config_get_subkey_value().

int u_config_get_subkey_value_i u_config_t *  c,
const char *  subkey,
int  def,
int *  out
 

Return the integer value (atoi is used for conversion) of the child config object whose key is subkey.

Parameters:
c configuration object
subkey the key value of the child config object
def the value to return if the key is missing
out on exit will get the integer value of the key
Returns:
0 on success, not zero if the key value is not an int

Definition at line 611 of file config.c.

References u_config_get_subkey_value().

const char* u_config_get_value u_config_t *  c  ) 
 

Return the value string of a config object.

Parameters:
c configuration object
Returns:
The value string pointer on success, NULL on failure

Definition at line 568 of file config.c.

Referenced by u_config_get_subkey_value().

int u_config_load u_config_t *  c,
int  fd,
int  overwrite
 

Fill a config object with key/value pairs loaded from the configuration file linked to the descriptor fd. If overwrite is not zero values of keys with the same name will overwrite previous values otherwise new keys with the same name will be added.

Parameters:
c configuration object
fd file descriptor
overwrite if 1 overwrite keys with the same name otherwise new key with the same name will be added
Returns:
0 on success, not-zero on error.

Definition at line 416 of file config.c.

Referenced by u_config_load_from_file().

int u_config_load_from_file const char *  file,
u_config_t **  pc
 

Create a configuration object reading from a config file

Parameters:
file file descriptor
pc value-result that will get the new configuration object
Returns:
0 on success, not-zero on error.

Definition at line 444 of file config.c.

References u_config_create(), u_config_free(), and u_config_load().

void u_config_print u_config_t *  c,
int  lev
 

Print a configuration object and its children to stdout. For each config object all keys/values pair will be printed.

Parameters:
c configuration object
lev nesting level; must be zero
Returns:
0 on success, not zero on failure

Definition at line 57 of file config.c.


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved