#!/usr/bin/perl

use Foomatic::Defaults;
use Foomatic::DB;
use Getopt::Std;

getopts("d:p:ht:fw");
help() if $opt_h;
my $driver = $opt_d;
my $poid   = $opt_p;

if (defined($driver) and defined($poid)) {

    # If the user supplies an old numerical printer ID, translate it to
    # a new clear-text ID
    $poid = Foomatic::DB::translate_printer_id($poid);

    my $db = Foomatic::DB->new();
    # Get all the data about this driver/printer pair
    $db->getdat($driver, $poid);

    my @data;

    @data = $db->getppd($opt_w);
    
    print @data;
}

exit 0;

sub help {
    print <<HELP;
foomatic-ppdfile -d <driver> -p <printerid>
 -d: Driver name
 -p: Printer ID
 -w: Generate PPD which is compatible to the CUPS PostScript
     driver for Windows (GUI strings are limited to 39 characters).

HELP

}
