NAME

esmith::db - Routines for handling the e-smith configuration database


VERSION

This file documents esmith::db version 1.4.0


SYNOPSIS

    use esmith::db;


DESCRIPTION

The e-smith server and gateway keeps most of its configuration in a flat text file /home/e-smith/configuration. This module provides utility routines for manipulating that configuration data.

db_set($hash, $key, $new_value, $hashref)

Takes a reference to a hash, a scalar key and a scalar value and an optional hash reference. If the hash reference is provided, a new value is constructed from the scalar value and the referred to hash. It then sets the key/value pair.

It returns one on success and undef on failure.

db_get($hashref, $key)

Takes a reference to a hash and an optional scalar key. If the scalar key is not provided, it returns a list of keys. If the scalar key is provided, it returns the value of that key (in array context, as a list suitable for assigning to a type and properties hash list) or undef if the key does not exist.

db_delete($hashref, $key)

Takes a reference to a hash and a scalar key and deletes the key. It returns one on success and undef if the key does not exist.

db_set_type($hashref, $key, $type)

Takes a reference to a hash, a scalar key and a scalar value and sets the type for the key. It returns one on success and undef on failure.

db_get_type($hashref, $key);

Takes a reference to a hash and a scalar key and returns the type associated with the key. It returns undef if the key does not exist.

db_set_prop($hashref, $key, $prop, $new_value)

Takes a reference to a hash, a scalar key, a scalar property and a scalar value and sets the property from the value. It returns with the return status of db_set or undef if the key does not exist.

db_get_prop($hashref, $key, $prop)

Takes a reference to a hash, a scalar key and an optional scalar property. If the property is supplied, it returns the value associated with that property. If the property is not supplied, it returns a hash of all properties for the key. It returns undef if the key or the property does not exist.

db_delete_prop($hashref, $key, $prop)

Takes a reference to a hash, a scalar key and a scalar property and deletes the property from the value. It returns with the return status of db_set or undef if the key or the property do not exist.

db_print($hash, $key)

Takes a reference to a hash and an optional scalar key. If the scalar key is not provided, it prints key=value for each key in the hash. If the scalar key is provided, it prints key=value for that key. It returns one on success or undef if the key does not exist.

db_show($hashref, $key)

Takes a reference to a hash and an optional scalar key. If the scalar key is not provided, it prints key/value pairs for each key in the hash. If the scalar key is provided, it prints the key/value for that key. The value is expanded to show properties. It returns one on success or undef if the key does not exist.

db_print_type($hashref, $key)

Takes a reference to a hash and an optional scalar key. If the scalar key is not provided, it prints key=type for each key in the hash. If the scalar key is provided, it prints key=type for that key. It returns one on success or undef if the key does not exist.

db_print_prop($hashref, $key, $prop)

Takes a reference to a hash, a scalar key and an optional scalar property. If the scalar property is not provided, it prints prop=value for each property associated with the key. If the scalar property is provided, it prints prop=value for that key. It returns one on success or undef if the key or property does not exist.

private_db_hash_to_string($hashref)

Takes a reference to a hash and returns a string of pipe ``|'' delimited pairs.

private_db_string_to_type_and_hash($arg)

Takes a string and expands it on the assumption that the string is a type string, followed by a list of pipe ``|'' delimited pairs. It returns the expanded string as an array, which can be assigned to a type and property hash.


AUTHOR

e-smith, inc.

For more information, see http://www.e-smith.org/