47 lines
1.0 KiB
Plaintext
47 lines
1.0 KiB
Plaintext
|
#!/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);
|
||
|
}
|