#!/usr/local/bin/perl

if ($#ARGV != -1) {
   exit print "Usage: ctihave\n" ;
}

$tool = $ENV{"DTOOL"} ;
if ( $tool eq "" ) {
   die "not configured for using CTtools\n" ;
}

require "$tool/include/ctutils.pl" ;
require "$tool/include/ctvspec.pl" ;
require "$tool/include/ctquery.pl" ;
require "$tool/include/ctproj.pl" ;
require "$tool/include/ctcm.pl" ;

$projs = $ENV{"CTPROJS"} ;
@projsplit = split( / +/, $projs ) ;

foreach $item ( @projsplit ) {
    @items = split( /:/, $item ) ;
    $thisproj = $items[0] ;
    $thisflav = $items[1] ;
    $thisspec = &CTResolveSpec( $thisproj, $thisflav ) ;
    $result = $result . &CTCMIHave( $thisproj, $thisflav, $thisspec ) ;
}
if ( $result ne "" ) {
    @splitlist = split( /\n/, $result ) ;
    foreach $item ( @splitlist ) {
	print $item . "\n" ;
    }
}
