# freeport.pl -- freeport server gateway # # by mcr@ccs.carleton.ca $map{'pattern'} = '&do_filepattern($rest, $query)'; package freeport; $pattern_name="/pattern"; sub main'do_filepattern { local($spec, $query) = @_; $spec = $default_spec if $spec eq ''; &main'MIME_header('ok', 'text/html'); $file = "$root_dir/$spec"; $pat = $query; $pat =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # convert %## escapes $nicepat=$pat; $nicepat =~ s/\</g; $nicepat =~ s/>/\>/g; print "\n
\n\n";
local( $n, $i );
if( -f "$file" ) {
open(IN,"<$file");
while() {
$foundpat=1 if /$pat/i;
next unless $foundpat;
s/\&/\>/g;
s/\\</g;
s/\>/\>/g;
print;
}
}
else {
print "No such freeport file $file exists\n";
$cwd=`pwd`;
print "Current dir is: $cwd\n";
}
print "