From 9862f54d6821034041f629f907fdad90b1d95845 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 13 Nov 2002 15:55:23 +0000 Subject: - set_usermode() : don't reinvent the wheel, use substInFile - get_usermode() : ditto, use getVarsFromSh --- perl-install/printer/main.pm | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'perl-install') diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 06329bdfc..7d25021e3 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -734,38 +734,14 @@ sub get_cups_autoconf { sub set_usermode { my $usermode = $_[0]; $::expert = $usermode; - - # Read config file - my $file = "$prefix/etc/sysconfig/printing"; - @file_content = cat_($file); - - # Remove all valid "USER_MODE" lines - (/^\s*USER_MODE/ and $_ = "") foreach @file_content; - - # Insert the new "USER_MODE" line - if ($usermode) { - push @file_content, "USER_MODE=expert\n"; - } else { - push @file_content, "USER_MODE=recommended\n"; - } - - output($file, @file_content); - - return 1; + $str = $usermode ? "expert" : "recommended"; + substInFile { s/^(USER_MODE=).*/$1=$str/ } "$prefix/etc/sysconfig/printing"; } sub get_usermode { - local *F; - open F, "< $prefix/etc/sysconfig/printing" or return 0; - my $line; - while ($line = ) { - if ($line =~ m!^[^\#]*USER_MODE=expert!) { - $::expert = 1; - return 1; - } - } - $::expert = 0; - return 0; + my %cfg = getVarsFromSh("$prefix/etc/sysconfig/printing"); + $::expert = $cfg{CLASS} eq 'expert' ? 1 : 0; + return $::expert; } sub read_cupsd_conf { -- cgit v1.2.1