summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-08-05 22:36:42 +0000
committerfukachan <fukachan>2001-08-05 22:36:42 +0000
commit13e5488261d1b881f36fc8ee18cf62401946ea1d (patch)
treece061468c7c792c9d493c19bde684810a10eb0c2 /fml
parent818f68a3ddadc3aaffc3c430812be8058027cfbc (diff)
downloadfml8-13e5488261d1b881f36fc8ee18cf62401946ea1d.tar.gz
fml8-13e5488261d1b881f36fc8ee18cf62401946ea1d.tar.bz2
fml8-13e5488261d1b881f36fc8ee18cf62401946ea1d.zip
template of config.cf modification
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Command/edit.pm16
-rw-r--r--fml/lib/FML/Config.pm20
2 files changed, 30 insertions, 6 deletions
diff --git a/fml/lib/FML/Command/edit.pm b/fml/lib/FML/Command/edit.pm
index 62179cd2..3dac3b28 100644
--- a/fml/lib/FML/Command/edit.pm
+++ b/fml/lib/FML/Command/edit.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: edit.pm,v 1.4 2001/07/15 12:03:37 fukachan Exp $
+# $FML: edit.pm,v 1.5 2001/07/15 23:20:29 fukachan Exp $
#
package FML::Command::edit;
@@ -26,9 +26,17 @@ See C<FML::Command> for more details.
=head2 C<edit( $address )>
+ TODO
+
+now we can read and write config.cf, not change it.
+
=cut
+# Descriptions: edit config.cf
+# Arguments: $self $curproc $optargs
+# Side Effects: update config.cf
+# Return Value: none
sub edit
{
my ($self, $curproc, $optargs) = @_;
@@ -47,6 +55,12 @@ sub edit
# read configuration. configuration is holded in FML:Config space.
$c->read( $config_cf );
+ # modify $c (config) object
+ # XXX TODO
+ # XXX ... snip ...
+ # $c->set('key', 'value'); # set up
+ # $c->regist('key'); # add list to write into config.cf
+
# ovewrite $config_cf
# after old $config_cf is backup'ed to $config_cf.bak
$c->write( $config_cf );
diff --git a/fml/lib/FML/Config.pm b/fml/lib/FML/Config.pm
index 9ac8e4c8..5cc6eb12 100644
--- a/fml/lib/FML/Config.pm
+++ b/fml/lib/FML/Config.pm
@@ -1,7 +1,7 @@
#-*- perl -*-
# Copyright (C) 2000-2001 Ken'ichi Fukamachi
#
-# $FML: Config.pm,v 1.35 2001/07/15 08:38:22 fukachan Exp $
+# $FML: Config.pm,v 1.36 2001/07/15 23:35:37 fukachan Exp $
#
package FML::Config;
@@ -148,6 +148,12 @@ sub set
}
+sub regist
+{
+ my ($self, $key) = @_;
+ push(@{ $self->{ _newly_added_keys } }, $key);
+}
+
=head2 C<overload( filename )>
@@ -335,14 +341,18 @@ sub write
my $fh = IO::File::Atomic->open($file);
# back up config.cf firstly
- my $st = IO::File::Atomic->copy($file, $file.".bak");
- unless ($st) {
- Log("cannot backup $file");
+ my $status = IO::File::Atomic->copy($file, $file.".bak");
+ unless ($status) {
+ croak "cannot backup $file";
}
if (defined $fh) {
$fh->autoflush(1);
- for my $k (@$order) {
+
+ # XXX it works not well ??? ( regist() not works ??)
+ # XXX get variable list modified in this process
+ my $newkeys = $self->{ _newly_added_keys };
+ for my $k (@$order, @$newkeys) {
print $fh $comment->{$k} if defined $comment->{$k};
print $fh "$k = ";
print $fh join("\n\t", split(/\s+/, $config->{$k}));