NAME

Libconf::Glueconf - Libconf high level common module


DESCRIPTION

Libconf::Glueconf is a class that represents a config file at a high level. It provides an easy to use and powerful structure to edit the config file.


GLOBAL OPTIONS

$Libconf::Templates::OldLibconfTemplates
This BOOLEAN tells wether to use the old libconf template system (if set to true), or the new one (if set to false, default). This is kept for compatibility only, it will be removed at some point


SYNOPSYS

This is the high level layer of libconf. You should use it to read/write the informations to the config files. Here are some examples, but you should look in the specific modules below for more examples.

  use Libconf::Glueconf::Samba::Smb_conf;
  my $samba = new Libconf::Glueconf::Samba::Smb_conf('/etc/samba/smb.conf');
  $samba->{homes}->{writable} = 'TEST';
  $samba->{global}->{workgroup} eq 'WORKGROUP' or die "workgroup is not correct\n";
  $samba->write_conf();
  use Libconf::Glueconf::X::XF86Config;
  use Data::Dumper;
  $Data::Dumper::Deepcopy = 1;
  $Data::Dumper::Quotekeys = 0;
  my $xorg = new Libconf::Glueconf::X::XF86Config('/etc/X11/xorg.conf');
  print Dumper($xorg) . "\n";


MODULE LIST

See their documentation for specific methods

Generic - Shell
the Libconf::Glueconf::Generic::Shell manpage : glueconf representation of shell-like files.

Samba - Smb_conf
the Libconf::Glueconf::Samba::Smb_conf manpage : glueconf representation of smb.conf from samba.

X - XF86Config
the Libconf::Glueconf::X::XF86Config manpage : glueconf representation of XF86Config or xorg.conf from X.


GLUECONF GENERAL METHODS

read_conf()
  use Data::Dumper;
  my $structure = new Libconf::Glueconf::Some::Module;
  $structure->read_conf();
  print Dumper($structure) . "\n";

description

This method reads the config file, and maps it to the structure. It doesn't use any argument for its own use, but you can give it arguments, they will be passed to the underlying Libconf::Templates::read_conf().

write_conf()
  my $structure = new Libconf::Glueconf::Some::Module;
  $structure->read_conf();
  ... edit $structure ...
  $structure->write_conf();

description

This method writes the structure back to the config file. It doesn't use any argument for its own use, but you can give it arguments, they will be passed to the underlying Libconf::Templates::write_conf().

toXMLString($format)
    $template->toXMLString();

description

toXMLString exports the template informations into an XML string.

The optional $format parameter sets the indenting of the output.

toXMLFile($filename, $format)
    $template->toXMLFile('xml_filename');

description

toXMLFile exports the template informations into an XML file.

The optional $format parameter sets the indenting of the output.

fromXMLFile($filename)
    $template->fromXMLFile('file.xml');

description

fromXMLFile imports the data from an XML file previously generated by toXMLFile

get_comments('path description')
description

get the comments of an atom, described by the structure.

example

$comments = $samba->get_comments('{global}{workgroup}')

set_comments('path description', $comments)
description

set the comments of an atom, described by the structure.

example

$samba->set_comments('{global}{workgroup}', $comments)

set_commented('path description', $value)
description

change the status of the atom to be commented or uncommented. A commented line will output commented with the first comment of $self->{comment_struct}

example

$samba->set_commented('{global}{workgroup}', 1)

when outputed, the line will be something like : # workgroup=foo;

commented('path description')
description

returns the comment status of the atom.

example

if ($samba->commented('{global}{workgroup}')) { ... }