diff options
author | carlosg <carlosg> | 2006-05-14 17:28:07 +0000 |
---|---|---|
committer | carlosg <carlosg> | 2006-05-14 17:28:07 +0000 |
commit | cba24c5a270acd8f3baa7100ec9dce921b24e65b (patch) | |
tree | b1958760a7395636a619ca7afe6746c709bf544e | |
parent | 73a9a73024710f0c7f39a5319dffeaaa04b8d124 (diff) |
2006-05-14 Carlos Garnacho Parro <carlosg@gnome.org>
* Utils/Replace.pm (set_join_hash): renamed to join_hash.
(set_ppp_options_re) (set_ppp_options_connect): added
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | Utils/Replace.pm | 50 |
2 files changed, 51 insertions, 1 deletions
@@ -15,6 +15,8 @@ individual services to be started/stopped from other parts of the code (say interfaces auto) * Init/ServicesList.pm: make a difference between SMB and NFS + * Utils/Replace.pm (set_join_hash): renamed to join_hash. + (set_ppp_options_re) (set_ppp_options_connect): added 2006-03-17 Carlos Garnacho Parro <carlosg@gnome.org> diff --git a/Utils/Replace.pm b/Utils/Replace.pm index 918ca7a..3726a8f 100644 --- a/Utils/Replace.pm +++ b/Utils/Replace.pm @@ -426,7 +426,7 @@ sub set_first_line # For every key in %$value, replace/append the corresponding key/value pair. # The separator for $re1 -sub set_join_hash +sub join_hash { my ($file, $re1, $re2, $value) = @_; my ($i, $res, $tmp, $val); @@ -1305,4 +1305,52 @@ sub set_pppconf_bool ($value == 1)? "enable $key" : "disable $key"); } +sub set_ppp_options_re +{ + my ($file, $re, $value) = @_; + my ($buff, $line, $replaced, $ret); + my ($pre_space, $post_comment); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_ppp_option", &Utils::Replace::regexp_to_separator ($re), $file); + + $buff = &Utils::File::load_buffer ($file); + + foreach $line (@$buff) + { + $pre_space = $post_comment = ""; + chomp $line; + $pre_space = $1 if $line =~ s/^([ \t]+)//; + $post_comment = $1 if $line =~ s/([ \t]*\#.*)//; + + if ($line =~ /$re/) + { + $line = "$value\n"; + $replaced = 1; + last; + } + + $line = $pre_space . $line . $post_comment . "\n"; + } + + push @$buff, "$value\n" if !$replaced; + + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); + return $ret; +} + +sub set_ppp_options_connect +{ + my ($file, $value) = @_; + my $ret; + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_ppp_connect", $file); + $ret = &set_ppp_options_re ($file, "^connect", "connect \"/usr/sbin/chat -v -f $value\""); + &Utils::Report::leave (); + return $ret; +} + 1; |