summaryrefslogtreecommitdiffstats
path: root/perl-install/detect_devices.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-09-29 16:49:51 +0000
committerFrancois Pons <fpons@mandriva.com>2000-09-29 16:49:51 +0000
commit0d05432e5549d86203a9677603824923920b10cd (patch)
tree9f1729f99647a3b8b47fad6409ce5914863e2c2f /perl-install/detect_devices.pm
parentec6fb419868416b1c90fcac09e3887d9b68eab99 (diff)
downloaddrakx-0d05432e5549d86203a9677603824923920b10cd.tar
drakx-0d05432e5549d86203a9677603824923920b10cd.tar.gz
drakx-0d05432e5549d86203a9677603824923920b10cd.tar.bz2
drakx-0d05432e5549d86203a9677603824923920b10cd.tar.xz
drakx-0d05432e5549d86203a9677603824923920b10cd.zip
*** empty log message ***
Diffstat (limited to 'perl-install/detect_devices.pm')
-rw-r--r--perl-install/detect_devices.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 4c9360d8e..b937eca48 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -254,13 +254,32 @@ sub whatParport() {
@res;
}
+sub whatUsbport() {
+ my ($i, $elem, @res) = (0, {});
+ local *F;
+ open F, "/proc/bus/usb/devices" or return;
+ foreach (<F>) {
+ $elem->{$1} = $2 if /S:\s+(.*)=(.*\S)/;
+ if (/I:.*Driver=(printer|usblp)/ && $elem->{Manufacturer} && $elem->{Product}) {
+ my $MF = ${{ 'Hewlett-Packard' => 'HP' }}{$elem->{Manufacturer}} || $elem->{Manufacturer};
+ push @res, { port => "/dev/usb/lp$i", val => { CLASS => 'PRINTER',
+ MODEL => $elem->{Product},
+ MANUFACTURER => $elem->{Manufacturer},
+ DESCRIPTION => "$MF $elem->{Product}",
+ }};
+ $i++; $elem = {}; #- try next one, but blank what has been probed.
+ }
+ }
+ @res;
+}
+
#-CLASS:PRINTER;
#-MODEL:HP LaserJet 1100;
#-MANUFACTURER:Hewlett-Packard;
#-DESCRIPTION:HP LaserJet 1100 Printer;
#-COMMAND SET:MLC,PCL,PJL;
sub whatPrinter() {
- my @res = whatParport();
+ my @res = (whatParport(), whatUsbport());
grep { $_->{val}{CLASS} eq "PRINTER"} @res;
}