#!/usr/local/bin/perl5
# -*- perl -*-
use P4CGI ;
use strict ;
#
#####################################################################
##
## CONFIGURATION INFORMATION
## All config info should be in $configFile (see init() in P4CGI.pm)
##
#####################################################################
##
## Search For File
##
#####################################################################
# Set back references
my $homepage="index.cgi";
my $backtohome="Back to Home" ;
# Get file spec argument
my $filespec = P4CGI::cgi()->param("FSPC") ;
$filespec = "" unless defined $filespec ;
my $label = P4CGI::cgi()->param("LABEL") ;
if(!defined $label) {
$label = "" ;
}
my $filedesc ;
my $showDiffSelection="Y" ;
if($filespec eq "") {
$filedesc = " label$label
" ;
$showDiffSelection= undef ;
}
else {
$filedesc = "$filespec
" ;
if($label ne "") {
$filedesc .= "
in label$label
" ;
}
}
if($label ne "") {
$label = "\@$label" ;
}
# Add //... if not there
if($filespec !~ /^\/\//) {
$filespec = "//...$filespec" ;
}
while($filespec =~ s/\.\.\.\.\.\./\.\.\./) { ; } ;
while($filespec =~ s/\*\*/\*/) { ; } ;
#Check if file exists
my @matches ;
&P4CGI::p4call(\@matches, "files \"${filespec}${label}\"" );
# Set what we searched on
my $search ;
if ( $label )
{
$label =~ /\@(.*)/ ;
$search = "$1" ; }
else {
$search = $filespec ;
}
# Print title and legend
print
"",
&P4CGI::start_page("Search Results",
&P4CGI::ul_list(
"Change: to see the complete change description,
including other files",
"Action: to see the deltas (diffs)",
"Rev: to see the file text",
"Filename: to see the complete file history"),
$homepage,$backtohome);
# Print the files
if( $label eq "" ) {
print
"",
"Search on: $search" ;
}
else {
print
"",
"Search on label: $search" ;
}
if(scalar(@matches) == 0) {
print
"",
"
",
"0 files found";
}
else {
print
"",
"
",
"", scalar(@matches),
" file",
scalar(@matches)==1 ? "" : "s",
" found",
"