#!/usr/bin/perl
#
# co file...
#
# For all the files that we find in clearcase,  check  them  out.   At
# present  we  don't check to see whether they are checked out, so you
# will receive spurious error messages for those that you already have
# checked  out  (and valid error messages for any that are checked out
# by someone else).
#
# The exit status is the count of files that aren't found in Clearcase; 
# zero means that all went ok.

$C = "-nc";
$V = ($ENV{"V"} || $ENV{"VOB"}) || "/vobs/nm/cmagent";
$D = ($ENV{"D"} || $ENV{"DOC"}) || ($V . "/doc");
$S = ($ENV{"S"} || $ENV{"SRC"}) || ($V . "/src");
$stat = 0;

for $f (@ARGV) {
	if ( -f ($F = "$S/$f")) {
		system "cleartool co $C $F";
	} elsif ( -f ($F = "$D/$f")) {
		system "cleartool co $C $F";
	} else {
		print STDERR "Can't find $f in ClearCase.\n";
		++$stat;
	}
}
exit $stat;
