Author: | Adrian Perez <aperez@igalia.com> |
---|---|
Copyright: | 2008-2009 Igalia S.L. |
License: | GPL3 |
Abstract
Parse configuration files in key-value pairs and INI-style.
Contents
config_filter_uneeded [ commentchar ]
This function acts as a filter, stripping lines which start with a given commentchar, and blank lines as well. By default the command character is # (hash), but can be changed to any other string.
config_keyval destination [ separator [ commentchar ] ]
Parses text in a key-value fashion, and stores key-value pairs in a hash table. Text input must be given as standard input. Arguments:
The default settings will be able of parsing input like the following:
# This is a comment
key1 = value1
key2 = value2
# ...
keyN = valueN
Note that spaces around both keys and values will be strippped.
config_ini destination [ separator [ commentchar ] ]
Parses text from standard in a INI-like fashion. Read values are stored into a hash table which has a nested hash table for each section found. Helper functions for getting values and full sections (config_ini_get). Arguments:
The default settings will be able of parsing input like the following:
# Comments are started like this line, with hash symbols
# Sections are enclosed in brackets
[section1]
key1 = one
# This is another section
[section2]
key1 = uno
anotherkey = another value
Note that spaces around both keys and values will be strippped.
config_ini_get hash section [ key ]
Obtains a full section if key is not specified, or the value of a given key of the section otherwise. The given hash table must have the nested structure as the ones created by config_ini.
config_ini_get_chained hash section fallback key default
Obtains a value associated with the given key of a section. If the key does not exist in the section, it will be looked up in the alternative fallback section, and if not given then the default value is printed out.
config_ini_clear hash
Disposes keys and values in a hash table hierarchy as created by config_ini.