# 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; print "\n\n$spec: Pattern: $nicepat\n
\n";
    local( $n, $i );

    if( -f "$file" ) {
        open(IN,"<$file");

        while() {
            $foundpat=1 if /$pat/i;
            next unless $foundpat;

            s/\&/\>/g;
            s/\/\>/g;
            print;
        }
    }
    else {
      print "No such freeport file $file exists\n";
      $cwd=`pwd`;
      print "Current dir is: $cwd\n";
    }
    print "
\n"; } 1;