#! /usr/bin/perl

BEGIN { 
    my $libdir = '/usr/local/share/foomatic';
    push (@INC, $libdir);
}

# This is just a sort of stupid example of using other stuff in the
# PHTDBPUB module.

use PHTDBPUB qw(normalizename);

my $db = new PHTDBPUB;
my $over = $db->getoverview();

my $make;
for $make (sort(keys(%{$over}))) {

    print "$make\n";

    my $model;
    for $model (sort { normalizename($a->{'model'}) cmp normalizename($b->{'model'}) }
		@{$over->{$make}}) {

	print "  ", $model->{'model'}, " (database ID ", $model->{'id'}, ")\n";

	# One could compare the pnp_ information in the $model to
	# what's plugged into this computer and know that we've got a
	# sensible match.


	# A model has various possible free software drivers:

	my $driver;
	for $driver (@{$model->{'drivers'}}) {

	    # Do something uninteresting
	    print "    $driver\n";

	    # One might instead call $db->getdat() and ->getcupsppd()
	    # to obtain a PPD for this printer/driver pair.  Or
	    # perhaps the same for PDQ or LPD.


	}
    }
}

exit 0;
