#!perl # -*- Perl -*- # Copyright 1999 Greg Spencer (greg_spencer@acm.org) ###################################################################### # # Argument parsing # ###################################################################### use p4Config; use p4Util; use CGI; use LWP::MediaTypes; use HTTP::Date; sub GetModDate { my $file = shift; my %filehash = &p4Util::GetFileInfo($file); my $modtime = $filehash{$file}{headTime}; my $date = &time2str($modtime); return $date; } $query = new CGI; $input_file=$query->path_info(); # it's been given as a script argument via the url... if (!$input_file) { @param_keys = $query->keywords; $input_file=$param_keys[0] if !$input_file; } $input_file =~ s,^//depot,,; # make sure it isn't already there. $input_file = "//depot".$input_file; # so we don't have to give the depot... $input_file =~ s|/$||; # strip a trailing slash... ($file_name = $input_file) =~ s/\[#\@].*$//; # strip off the version number, if any $type = guess_media_type($file_name); $type = "text/plain" if ($type eq "application/octet-stream"); if (!open(INPUT,"p4 print \"$input_file\" 2>&1 |")) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n"; print "