summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/cups.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer/cups.pm')
-rw-r--r--perl-install/printer/cups.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm
new file mode 100644
index 000000000..1de54edf2
--- /dev/null
+++ b/perl-install/printer/cups.pm
@@ -0,0 +1,30 @@
+package printer::cups;
+
+use strict;
+use printer::data;
+
+sub get_remote_queues {
+ my ($printer) = $_[0];
+ # The following code 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;
+ if (($2 =~ m!^ipp://([^/:]+)[:/]!) &&
+ (!$printer->{configured}{$queuename})) {
+ my $server = $1;
+ push (@printerlist, "$queuename|$server");
+ }
+ }
+ }
+ close F;
+ return @printerlist;
+}
+
+1;