summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/main.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-11-13 15:55:23 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-11-13 15:55:23 +0000
commit9862f54d6821034041f629f907fdad90b1d95845 (patch)
tree2c8c972018e9f7f04c33978b1f3466499b40a264 /perl-install/printer/main.pm
parent20546649db339d6d4d8fea471ebccb158e10c5de (diff)
downloaddrakx-9862f54d6821034041f629f907fdad90b1d95845.tar
drakx-9862f54d6821034041f629f907fdad90b1d95845.tar.gz
drakx-9862f54d6821034041f629f907fdad90b1d95845.tar.bz2
drakx-9862f54d6821034041f629f907fdad90b1d95845.tar.xz
drakx-9862f54d6821034041f629f907fdad90b1d95845.zip
- set_usermode() : don't reinvent the wheel, use substInFile
- get_usermode() : ditto, use getVarsFromSh
Diffstat (limited to 'perl-install/printer/main.pm')
-rw-r--r--perl-install/printer/main.pm34
1 files changed, 5 insertions, 29 deletions
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 = <F>) {
- 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 {