Augeas
Description:
A configuration file editing tool
Augeas parses a configuration file in its native format using a "lens" and transforms it into a tree. Configuration changes are made by manipulating this tree and saving it back into the native configuration file.
- Home: http://augeas.net/
- C-Documentation: http://augeas.net/docs/references/c_api/files/augeas-h.html
Loading a Configuration File into the Tree
The following example uses a hosts file. A hosts file maps network host names to Internet Protocol (IP) addresses. For Unix systems this is usually located at /etc/hosts
void main () {
var tree = new Augeas.Tree ();
tree.transform ("hosts", "/etc/hosts");
tree.load ();
tree.print ();
}
The example creates an instance of Augeas.Tree and then adds a transform to the tree using the "hosts" lens for the file "/etc/hosts". A tree
can have many transforms. There are also many lenses available for parsing different types of configuration files. The Augeas website has a list
of stock lenses.
The configuration file is then loaded in to the tree using the specified lens. The print () call shows how the tree is structured with the transformed configuration file.