From b9b53f7ae5005eab2ebe4826e355569f217f766a Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sep 13 2005 13:00:48 +0000 Subject: First skeleton code for fixing up foomatic PPD options XML --- diff --git a/foomatic-ppdopts b/foomatic-ppdopts new file mode 100755 index 0000000..e9cb92e --- /dev/null +++ b/foomatic-ppdopts @@ -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 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); +}