<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:root@localhost" /> </head> <body style="background-color: white"> <ul id="index"> <li><a href="#NAME">NAME</a></li> <li><a href="#DESCRIPTION">DESCRIPTION</a> <ul> <li><a href="#PERL">PERL</a></li> <li><a href="#C">C</a></li> <li><a href="#PYTHON">PYTHON</a></li> <li><a href="#RUBY">RUBY</a></li> <li><a href="#TEMPLATES">TEMPLATES</a></li> </ul> </li> </ul> <h1 id="NAME">NAME</h1> <pre><code> Libconf - Set of abstraction layers to the linux/unix configuration</code></pre> <h1 id="DESCRIPTION">DESCRIPTION</h1> <h2 id="PERL">PERL</h2> <dl> <dt id="High-level"><b>High level</b></dt> <dd> <p>This high level layer provides a hierarchical structure representing the configuration file informations. It's very simple to use, and it uses a "semantic" approach to structure the informations. You should use this layer.</p> <pre><code> use Libconf::Glueconf::Networking::Resolv; my $resolv = new Libconf::Glueconf::Networking::Resolv({filename => '/etc/resolv.conf' }); push(@{$resolv->{nameserver}}, '192.168.76.7'); $resolv->{search}->[1] = 'foo'; $resolv->write_conf('/etc/resolv_modified');</code></pre> <p>See <a>Libconf::Glueconf</a></p> </dd> <dt id="Low-level"><b>Low level</b></dt> <dd> <p>This is the core layer and templates of Libconf, don't use it unless you know what you do, or if there is no high level templates for your needs. But you better contact us so that we add a tempalte. See <a>Libconf::Templates</a>.</p> </dd> </dl> <h2 id="C">C</h2> <pre><code> #include <stdio.h> #include "conf2xml.h" #include <string.h> int main (int argc, char **argv, char **env) { char *xml_string; conf2xml_init(); xml_string = conf2xml("/etc/rc.conf", "Generic/Shell", "shell_style:true_bash,shell_command:/bin/bash"); FILE* output = fopen("/tmp/rc.xml", "w"); fwrite(xml_string, strlen(xml_string), 1, output); // ... alter xml_string ... xml2conf(xml_string, "./etc/rc.conf", NULL, NULL); conf2xml_free(); return (0); }</code></pre> <h2 id="PYTHON">PYTHON</h2> <pre><code> from conf2xml import *; xml_string=conf2xml("/etc/passwd", "System/Passwd") f=open("/tmp/passwd.xml", "w") f.write(xml_string) f.close xml2conf(xml_string, "/tmp/passwd", "System/Passwd")</code></pre> <h2 id="RUBY">RUBY</h2> <pre><code> require conf2xml xml=Conf2Xml.conf2xml("/etc/passwd", "System/Passwd"); Conf2Xml.xml2conf(xml, "/tmp/passwd", "System/Passwd");</code></pre> <h2 id="TEMPLATES">TEMPLATES</h2> <p>The template list can be found in <a>Libconf::Glueconf</a>, or you can have a list by issuing on the command line :</p> <pre><code> libconf --command 'list_templates'</code></pre> </body> </html>