|
C |
CfgTie::Cfgfile -- An object to help interface to configuration files
Helps interface to the text based configuration files commonly used in Unix
This is a fairly generic interface to allow many configuration files to be used as hash ties. Note: This is not intended to be called by user programs, but by modules wishing to reuse a template structure!
package mytie; require CfgTie::Cfgfile;
@ISA = qw(CfgTie::Cfgfile);
The major methods:
new($filepath, @Extra stuff)
or
new($RCS-Object, @Extra stuff)
END routine is
called. If a filepath is specified, it will override the one previously
set with the RCS object. If no filepath is specified, but the RCS has one
specified, it will be used instead.
Your derived object may need to provide the following methods:
scan{Contents} key.
format(key,contents)cfg_begincfg_endmakerewrites
Comment_Add This appends the string to the list of comments that will be
logged for this revision (assuming that a Revision Control object was used).
Queue_Store($key,$val) This queues (for later) the transaction that
key should be associated with val. The queue is employed to synchronize
all of the settings with the stored settings on disk.
Queue_Delete($key) This queues (for later) the transaction that any value
associated with key should be removed.
RENAME(\%rules) This method will move through the whole table and make a
series of changes. It may:
\%rules is the set of rules that governs will be changed in name and what
will be removed. It is an associative array (hash) of a form like:
{
PATTERN1 => "",
PATTERN2 => REWRITE,
}
PATTERN1 =
Two things will happen with a rule like this:
PATTERN2 = REWRITE
In this case the rewrite indicates what should replace the pattern:
the CfgTie::TieAliases manpage, the CfgTie::TieGeneric manpage, the CfgTie::TieGroup manpage the CfgTie::TieHost manpage, the CfgTie::TieMTab manpage, the CfgTie::TieNamed manpage, the CfgTie::TieNet manpage, the CfgTie::TiePh manpage, the CfgTie::TieProto manpage, the CfgTie::TieRCService manpage, the CfgTie::TieRsrc manpage, the CfgTie::TieServ manpage, the CfgTie::TieShadow manpage, the CfgTie::TieUser manpage
Additions that do not change any previously established values are reflected
immediately (and newaliases is run as appropriate). Anything which changes
a previously established value, regardless of whether or not it has been
committed, are queue'd for later. This queue is used to rewrite the file when
END is executed.
Randall Maas (mailto:randym@acm.org, http://www.hamline.edu/~rcmaas/)
|
C |