Dicop::Config -- manage config files



NAME

Dicop::Config -- manage config files


SYNOPSIS

        use Dicop::Config;
        my $config = new Dicop::Config ('data/server.cfg');
        print $config->{logging_dir},"\n";


REQUIRES

perl5.004, Exporter


EXPORTS

Exports nothing.


DESCRIPTION

This module reads config files and stores their contents in memory.


METHODS

new()

Create a new config object from a file. The only parameter is the file name to read in.

_read()

Read in the config. Called automatically by new().

_write()

Write the config back to disk. Not implemented yet. Use flush().

flush()

If config was modified, write it back to disk. Does call _write() and thus not work yet.

set()

set() one or more config value(s):

        $config->set( logging_dir => 'logs', blah => 9, );
        $config->set( { foo => 9 });
        $config->flush();                       # write back

This automatically tags the config data as modified, so that the next flush() writes it out.

get()

        $config->get('field');

Return the value of the config entry named field.

check()

        my $msg = $config->check();
        $msg = $config->check( { name => $line_nr1, foo => undef, } );

Check the config for being ok. Returns undef for ok, otherwise the error message.

The optional parameter is a hash, listing the allowed/obsolete keys. Allowed ones map the key name to the key type. If the type is undef, the key is obsolete and should not be in the config file.

_check_entry()

        my $msg = $config->_check_entry( $key );

Internally used by check().

Check one config entry consisting of the key and its value. Returns undef for ok, otherwise the error message.

$config_file is an optional config file name for the potentially returned error message. $line_numbers is a hash containing as keys the read in keys of the config, and as values the line from which this key was read. This is also used for the potential error message.

type()

        $type = $config->type($key);

Return the type of a config key. Returns undef for invalid keys.


BUGS


AUTHOR

(c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2006

DiCoP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

See http://www.bsi.de/ for more information.