From 58551a88694dde4a93d04e7b45781b554a17b4c2 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Wed, 9 Feb 2005 02:22:20 +0000 Subject: Added subroutine to parse HPLIP device database XML file. --- perl-install/printer/main.pm | 115 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) (limited to 'perl-install') diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 3d78ebfbd..796a72e88 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -2238,6 +2238,121 @@ sub autodetectionentry_for_uri { # # ------------------------------------------------------------------ +sub read_hplip_db { + + # Read the device database XML file which comes with the HPLIP + # package + open(my $F, "< $::prefix/usr/share/hplip/data/xml/models.xml") or + die "Could not read /usr/share/hplip/data/xml/models.xml\n"; + + my $entry = {}; + my $inentry = 0; + my $inrX = 0; + my $incomment = 0; + my %hplipdevices; + local $_; + while (<$F>) { + chomp; + if ($incomment) { + # In a comment block, skip all except the end of the comment + if (m!^(.*?)-->(.*)$!) { + # End of comment, keep rest of line + $_ = $2; + $incomment = 0; + } else { + # Skip line + $_ = ''; + } + } else { + while (m/^(.*?)(.*)$/) { + # Remove one-line comments + $_ = $1 . $3; + } + if (m/^(.*?)