Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > a918147e816a04e85f8654f72077e879 > files > 58

perl-Libconf-0.42.10-6.mga4.x86_64.rpm

<?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&#39;s very simple to use, and it uses a &quot;semantic&quot; 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 =&gt; &#39;/etc/resolv.conf&#39; });
  push(@{$resolv-&gt;{nameserver}}, &#39;192.168.76.7&#39;);
  $resolv-&gt;{search}-&gt;[1] = &#39;foo&#39;;
  $resolv-&gt;write_conf(&#39;/etc/resolv_modified&#39;);</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&#39;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 &lt;stdio.h&gt;
  #include &quot;conf2xml.h&quot;
  #include &lt;string.h&gt;
  int main (int argc, char **argv, char **env)
  {
      char *xml_string;
      conf2xml_init();
      xml_string = conf2xml(&quot;/etc/rc.conf&quot;, &quot;Generic/Shell&quot;, &quot;shell_style:true_bash,shell_command:/bin/bash&quot;);
      FILE* output = fopen(&quot;/tmp/rc.xml&quot;, &quot;w&quot;);
      fwrite(xml_string, strlen(xml_string), 1, output);
      // ... alter xml_string ...
      xml2conf(xml_string, &quot;./etc/rc.conf&quot;, NULL, NULL);
      conf2xml_free();
      return (0);
  }</code></pre>

<h2 id="PYTHON">PYTHON</h2>

<pre><code>  from conf2xml import *;
  xml_string=conf2xml(&quot;/etc/passwd&quot;, &quot;System/Passwd&quot;)
  f=open(&quot;/tmp/passwd.xml&quot;, &quot;w&quot;)
  f.write(xml_string)
  f.close
  xml2conf(xml_string, &quot;/tmp/passwd&quot;, &quot;System/Passwd&quot;)</code></pre>

<h2 id="RUBY">RUBY</h2>

<pre><code>  require conf2xml
  xml=Conf2Xml.conf2xml(&quot;/etc/passwd&quot;, &quot;System/Passwd&quot;);
  Conf2Xml.xml2conf(xml, &quot;/tmp/passwd&quot;, &quot;System/Passwd&quot;);</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 &#39;list_templates&#39;</code></pre>


</body>

</html>