Module config

Reading Simple Configuration Files.

config_read will read a configuration file in so-called property format; Blank lines and comments beginning with ‘#’ are ignored; otherwise lines are in the form “key=value”. It returns the result as a simple map.

The various config_gets* functions will look up and convert values, returning a default if the key is not found. The _arr variants will return an array, where values are delimited by commas; the default is the empty array.

test-config.c shows the usage; config.c shows an alternative way using the arg module where variables are bound directly to properties.

Functions

config_gets (m, key, def) get a string value, with default.
config_geti (m, key, def) get an int value, with default.
config_getf (m, key, def) get a double value, with default.
config_gets_arr (m, key) get an array of strings.
config_geti_arr (m, key) get an array of ints.
config_getf_arr (m, key) get an array of double.
config_read_stream (in, flags) read a configuration stream.
config_read_opt (file, flags) read a configuration file, with options.
config_read (file) read a configuration file, skipping # comments and blank lines.


Functions

config_gets (m, key, def)
get a string value, with default.

Parameters:

  • m SMap
  • key str_t
  • def str_t

Returns:

    str_t
config_geti (m, key, def)
get an int value, with default.

Parameters:

  • m SMap
  • key str_t
  • def int

Returns:

    int
config_getf (m, key, def)
get a double value, with default.

Parameters:

  • m SMap
  • key str_t
  • def double

Returns:

    double
config_gets_arr (m, key)
get an array of strings.

Parameters:

  • m SMap
  • key str_t

Returns:

    char * *
config_geti_arr (m, key)
get an array of ints.

Parameters:

  • m SMap
  • key str_t

Returns:

    int *
config_getf_arr (m, key)
get an array of double.

Parameters:

  • m SMap
  • key str_t

Returns:

    double *
config_read_stream (in, flags)
read a configuration stream.

Parameters:

  • in FILE *
  • flags int

Returns:

    char * *
config_read_opt (file, flags)
read a configuration file, with options. Currently either CONFIG_DELIM_EQUALS or CONFIG_DELIM_SPACE. Will return NULL if the file cannot be opened.

Parameters:

  • file str_t
  • flags int

Returns:

    char * *
config_read (file)
read a configuration file, skipping # comments and blank lines.

Parameters:

  • file str_t

Returns:

    char * *
generated by LDoc 1.4.3 Last updated 2015-04-27 12:35:55