#!/usr/bin/perl

# $Id: //depot/cad/tools/1.0/icp4-1.1/bin/p4rm#4 $
#
# CSWITCH CORPORATION CONFIDENTIAL PROPRIETARY
# 
# This file contains information which is the
# proprietary property of Cswitch Corporation.
# This file is confidential and its contents may
# not be disclosed without the expressed written
# consent of Cswitch Corporation.


use strict;
use warnings;

use FindBin qw($Bin);
use lib "$Bin/../lib";

use Icp4;
use Getopt::Std;
use File::Basename;

our (%opt, $Program);

MAIN: {

    my ($nflag, $cell, $cells);

    $Program = $FindBin::Script;

    getopts('hDn', \%opt);

    if ($opt{h} || $#ARGV < 0) {
	print "Usage: $Program [-h] [-n] [-i] cell+\n";
        print "       Returns file status\n";
	print "   -h: help usage\n";
	print " cell: cell name(s)\n";
	exit;
    }

    $Icp4::debug = ($opt{D}) ? 1 : 0 ;

    $cell = $ARGV[0];
	
    if (-d $cell) {
	print "0";
    }
    my %fstat = &Icp4::fstat("$cell");
    
    foreach my $file (keys %fstat) {
	my $filestatus = $fstat{$file};
	#print "$fstat{$file}\n";
	if ($filestatus =~ /\#(\d+)\/\#(\d+)/) {
	    my $cur = $1;
	    my $ci  = $2;
	    if ($cur == $ci) {
		print "latest\n";
	    } else {
		print "old\n";
	    }
	}
	elsif ($filestatus =~ /\?/) {
	    print "new\n";
	}
	else {
	    print "$filestatus\n";
	}
    }
    if (! -f $cell) {
	print "notfound\n";
    }

    exit 0;
}