diff options
author | pad <pad@mandriva.com> | 1999-09-14 14:50:50 +0000 |
---|---|---|
committer | pad <pad@mandriva.com> | 1999-09-14 14:50:50 +0000 |
commit | 0aa7a9e98c3b51085c87aa13d61eef8e3f694626 (patch) | |
tree | 06c3462cb7af3adb37d3a4606dd43d2604b88eec /perl-install/detect_devices.pm | |
parent | 951e65ef820631665dbeddf6cfb43afce034efb9 (diff) | |
download | drakx-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar drakx-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.gz drakx-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.bz2 drakx-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.tar.xz drakx-0aa7a9e98c3b51085c87aa13d61eef8e3f694626.zip |
*** empty log message ***
Diffstat (limited to 'perl-install/detect_devices.pm')
-rw-r--r-- | perl-install/detect_devices.pm | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 034fa48b9..9cc57b2fb 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -3,17 +3,24 @@ package detect_devices; use diagnostics; use strict; +#-###################################################################################### +#- misc imports +#-###################################################################################### use log; use common qw(:common :file); use devices; use c; +#-##################################################################################### +#- Globals +#-##################################################################################### my @netdevices = map { my $l = $_; map { "$l$_" } (0..3) } qw(eth tr plip fddi); my $scsiDeviceAvailable; my $CSADeviceAvailable; -1; - +#-###################################################################################### +#- Functions +#-###################################################################################### sub get { #- Detect the default BIOS boot harddrive is kind of tricky. We may have IDE, #- SCSI and RAID devices on the same machine. From what I see so far, the default @@ -162,6 +169,12 @@ sub tryOpen($) { local *F; sysopen F, devices::make($_[0]), c::O_NONBLOCK() and \*F; } + +sub tryWrite($) { + local *F; + sysopen F, devices::make($_[0]), 1 | c::O_NONBLOCK() and \*F; +} + sub syslog { -r "/tmp/syslog" and return map { /<\d+>(.*)/ } cat_("/tmp/syslog"); `dmesg` @@ -171,3 +184,35 @@ sub hasSMP { my $nb = grep { /^processor/ } cat_("/proc/cpuinfo"); $nb > 1; } + +sub whatParport() { + my @res =(); + foreach (0..3) { + local *F; + my $elem = {}; + open F, "/proc/parport/$_/autoprobe" or next; + foreach (<F>) { $elem->{$1} = $2 if /(.*):(.*);/ } + push @res, { port => "/dev/lp$_", val => $elem}; + } + @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(); + grep { $_->{val}{CLASS} eq "PRINTER"} @res; +} + +sub whatPrinterPort() { + grep { tryWrite($_)} qw(/dev/lp0 /dev/lp1 /dev/lp2); +} + +#-###################################################################################### +#- Wonderful perl :( +#-###################################################################################### +1; # + |