summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-12-13 11:13:06 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-12-13 11:13:06 +0000
commit25430f59a831afcbef81d03d388332708492bf06 (patch)
tree8db5484b9f91fb0b68f995d5bb33159c256a3843 /perl-install
parent6b3b8e7f7c83278c823dde17d96a251b53df8c72 (diff)
downloaddrakx-backup-do-not-use-25430f59a831afcbef81d03d388332708492bf06.tar
drakx-backup-do-not-use-25430f59a831afcbef81d03d388332708492bf06.tar.gz
drakx-backup-do-not-use-25430f59a831afcbef81d03d388332708492bf06.tar.bz2
drakx-backup-do-not-use-25430f59a831afcbef81d03d388332708492bf06.tar.xz
drakx-backup-do-not-use-25430f59a831afcbef81d03d388332708492bf06.zip
(read_cups_printer_list, get_cups_remote_queues): much cleanup
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer/main.pm75
1 files changed, 27 insertions, 48 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index a9a45e2c4..f136e057c 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -628,61 +628,40 @@ sub set_cups_special_options {
}
#------------------------------------------------------------------------------
+sub lpstat_v {
+ map {
+ if (my ($queuename, $uri) = m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) {
+ +{ queuename => $queuename, uri => $uri, if_($uri =~ m!^ipp://([^/:]+)[:/]!, ipp => $1) };
+ } else {
+ ();
+ }
+# } run_program::rooted_get_stdout($::prefix, 'lpstat', '-v');
+ } run_program::rooted_get_stdout($::prefix, 'cat', '/tmp/t');
+}
sub read_cups_printer_list {
- my ($printer) = $_[0];
+ my ($printer) = @_;
# This function reads in a list of all printers which the local CUPS
# daemon currently knows, including remote ones.
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "lpstat -v |" or return ();
- my @printerlist;
- my $line;
- while ($line = <F>) {
- if ($line =~ m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) {
- my $queuename = $1;
- my $comment = "";
- if ($2 =~ m!^ipp://([^/:]+)[:/]! &&
- !$printer->{configured}{$queuename}) {
- $comment = N("(on %s)", $1);
- } else {
- $comment = N("(on this machine)");
- }
- push @printerlist, "$queuename $comment";
- }
- }
- close F;
- return @printerlist;
+ map {
+ my $comment =
+ $_->{ipp} && !$printer->{configured}{$_->{queuename}} ?
+ N("(on %s)", $_->{ipp}) : N("(on this machine)");
+ "$_->{queuename} $comment";
+ } lpstat_v();
}
sub get_cups_remote_queues {
- my ($printer) = $_[0];
- # This function reads in a list of all remote printers which the local
- # CUPS daemon knows due to broadcasting of remote servers or
- # "BrowsePoll" entries in the local /etc/cups/cupsd.conf/
- local *F;
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "lpstat -v |" or return ();
- my @printerlist;
- my $line;
- while ($line = <F>) {
- if ($line =~ m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) {
- my $queuename = $1;
- my $comment = "";
- if ($2 =~ m!^ipp://([^/:]+)[:/]! &&
- !$printer->{configured}{$queuename}) {
- $comment = N("On CUPS server \"%s\"", $1);
- my $sep = "!";
- push @printerlist,
- ($::expert ? N("CUPS") . $sep : "") .
- N("Remote Printers") . "$sep$queuename: $comment"
- . ($queuename eq $printer->{DEFAULT} ?
- N(" (Default)") : "");
- }
- }
- }
- close F;
- return @printerlist;
+ my ($printer) = @_;
+
+ map {
+ join('!', if_($::expert, N("CUPS")), N("Remote Printers"), $_);
+ } map {
+ my $comment = N("On CUPS server \"%s\"", $_->{ipp}) . ($_->{queuename} eq $printer->{DEFAULT} ? N(" (Default)") : "");
+ "$_->{queuename}: $comment";
+ } grep {
+ $_->{ipp} && !$printer->{configured}{$_->{queuename}};
+ } lpstat_v();
}
sub set_cups_autoconf {