#!/afs/athena/contrib/perl5/p -w

# Copyright 1988,1996 by the Massachusetts Institute of Technology.
# See the file <mit-copyright.h> for copying and distribution information.

use lib ('/mit/bert/project/perl5/arch/share/lib',
	 '/mit/bert/project/perl5/arch/@sys/lib');

use Hesiod 0.80;
use Getopt::Std;

local($opt_b, $opt_l);  # *not* my()

getopts('lb') || (scalar(@ARGV) == 2) || do {
    print STDERR <<End_of_Usage;
Usage: $0 [-bl] identifier type
	-l selects long format
	-b also does hes_to_bind conversion
End_of_Usage
    exit 2;
};


my($identifier, $type) = @ARGV;
		
if ($opt_b) {
    print "hes_to_bind($identifier, $type) expands to\n" if $opt_l;
    my($cp) = hes_to_bind($identifier, $type)
	|| die " error $Hesiod::ERROR\n quitting";
    print $cp, "\n";
    print "which " if $opt_l;
}
print "resolves to\n" if $opt_l;

@cpp = hes_resolve($identifier, $type);
if (! @cpp) { 
    print "nothing\n" if $opt_l;
    print STDERR $Hesiod::ERROR, "\n";
} else {
    print join("\n", @cpp), "\n";
}

if (! @cpp) {
    exit(1);
} else {
    exit(0);
}
