#!//usr/local/bin/perl -w
# dspEXCOminutes.pl
# Read the directory containing the EXCO minutes for several years
# and provide links to each of them.
# October 9, 1997 R. C. Groman
# Passed parameters
# $ARGV[0] - file spec of parameter file
# Information in the parameter file takes the form:
# source = directory spec containing the file names to display
# (must be accessible to httpd)
# filetype = file type of valid files to display, e.g. txt
# title = text used in
tag
# header = text used in header tag. May contain imbedded tags
@monthname = ("dummy", "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December");
print ("Content-type: text/html\n\n");
$paramfile = $ARGV[0];
if (! defined $paramfile) {
print ("No parameter file specified for $0 routine.\n",
"Cannot continue.\n
");
exit 1;
}
#print "**debug, paramfile=$paramfile\n";
&getparams ($paramfile);
$http_path = $params{source};
$http_path =~ s!^.*htdocs(.*)!$1!;
print ("", $params{title}, "\n",
" \n\n", $params{header}, "
",
"\n\n\n");
$dir=$params{'source'};
chdir $dir or
die "Could not change directory to $dir, $!";
opendir SOURCEDIR, $params{source} or
die "Could not open source directory $params{source}, $!";
@files = grep !/^\./, readdir SOURCEDIR;
$i=0;
foreach $file (@files) {
# print "**debug, file=$file\n";
unless ( -f $file) {next;}
($year[$i], $month[$i], $day[$i], $type[$i]) = split /\./, $file;
# print "**debug, split=$year[$i], $month[$i], $day[$i], $type[$i]\n";
$type[$i] =~ s/ //g;
$params{filetype} =~ s/ //g;
# print "**debug, params{filetype}=$params{filetype}\n";
unless (lc $type[$i] eq lc $params{filetype}) {next;}
$key=$year[$i]*10000 + $month[$i]*100 + $day[$i];
# print "**debug, key=$key\n";
$dates{$key}=$i;
$filename[$i]=$file;
$i++;
}
foreach $key (reverse sort keys %dates) {
# print "**debug, key=$key\n";
print (" ",
$monthname[$month[$dates{$key}]], " ",
$day[$dates{$key}], ", ",
$year[$dates{$key}], "\n");
}
exit 0;
#----------------------------------------------------------------------
sub getparams {
# open and read the parameter file specified in $_[0]. Return 0
# if okay.
# Parameters to look for include
# $params{source}
# $params{filetype}
# $params{title}
# $params{header}
# Other parameters will be defined but may not be used.
# Restrictions:
# Equal signs ("=") cannot appear within the text to the right
# of the key words. In place of an equal sign, use two consecutive colons.
#print "**debug, getparams, _[0]=$_[0]\n";
open PARAMETERFILE, $_[0] or
die "Could not read parameter file $paramfile, $!";
while () {
chomp;
if ( m/^#.*/ ) { next;}
($keyword, $content)= split "=", $_;
$keyword =~ s/ //g;
$content =~ s/^\ +(.*)/$1/;
$content =~ s/::/=/g;
# print "**degub, keywork=$keyword, content=$content\n";
$params{lc "$keyword"} = $content;
}
close PARAMETERFILE;
return 0;
}