First skeleton code for fixing up foomatic PPD options XML

This commit is contained in:
Tim Waugh 2005-09-13 13:00:48 +00:00
parent 59f78d51c0
commit b9b53f7ae5
1 changed files with 46 additions and 0 deletions

46
foomatic-ppdopts Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/perl
use Getopt::Std;
getopts("hr:");
help() if $opt_h;
$libdir=$opt_r if $opt_r;
use Foomatic::PPD;
use Foomatic::Defaults;
my $file = $ARGV[0];
my $printer = $ARGV[1];
my $driver = $ARGV[2];
if (! -f "$libdir/db/source/printer/$printer.xml") {
die "Printer $printer does not seem to exist in the database!\n";
}
if (! -f $file) {
die "The PPD file you specified, $file, does not seem to exist!\n";
}
# Load the PPD
my $p = new Foomatic::PPD $file, $printer;
# Normal behavior, save as various option files by ID
my @opts = $p->foo_options();
for (@opts) {
my ($id, $xml) = ($_->{'id'}, $_->{'xml'});
my $ofile = "$libdir/db/source/opt/$id.xml";
if (-f "$ofile") { die "Output file $ofile already exists\n"; }
open TMP, ">$ofile" or die "Cannot write $ofile!\n";
print STDERR "Writing $ofile\n";
# Fix <driver> section>
print TMP join('',@{$xml});
close TMP;
}
exit(0);
sub help {
select STDERR;
print "\n";
print "Usage: foomatic-ppdopts filename.ppd printer-id\n";
print "\n";
exit(1);
}