#!/bin/sh tclsh << 'EOF' puts "Content-type: text/html\n" source tcl-helpers/searchterms.tcl; source tcl-helpers/common.tcl; source tcl-helpers/http-query-setup.tcl; http_proc_cgi_args set DocumentRoot ../../../DocumentRoot; set URLbase [findDocumentBase $env(REMOTE_HOST) $env(SERVER_NAME) \ $env(SERVER_PORT)]; puts "" puts "Document Search Results" puts "
" if {[lsearch [array names ar] MAXHITS] >= 0} { set MAXHITS $ar(MAXHITS); } else { set MAXHITS 50; } set matchList {}; set searchTerms [join [constructSearchTerms] " AND "]; set verboseTerms [constructVerboseSearchTerms]; set searchCommandBase [list | htmlsearch alldocs.db]; set searchCommand [concat $searchCommandBase $searchTerms]; set searchOutput [open $searchCommand]; set numberOfHits [lindex [gets $searchOutput] 1]; puts "

$numberOfHits matches found:

    "; for {set hits 0} {[gets $searchOutput inline] >= 0} {incr hits} { if [string match ".*" [lindex $inline 0]] { set document [string range [lindex $inline 0] 1 end]; } else { set document "/[lindex $inline 0]"; } set score [lindex $inline 1]; set first_line [lindex $inline 2]; set icon "../Home/Icons/default_search_icon.gif"; set icondir $document; catch { set lastDir ""; set icondir [file dirname $icondir]; while {[string length $icondir] > 1} { set root $DocumentRoot$icondir; if [file exists $root/search_icon.gif] { set icon "../..$icondir/search_icon.gif"; break; } elseif [file exists $root/$lastDir.search_icon.gif] { set icon "../../$icondir/$lastDir.search_icon.gif"; break; } set lastDir [file tail $icondir]; set icondir [file dirname $icondir]; } } error; if {![regexp {title="(.*)"} $inline match title]} { set title [file tail $document]; } puts "
  1. $title (score: $score)
  2. "; if {$hits == $MAXHITS} { puts "

    Listing limited to $MAXHITS hits.

    " break; } } puts "

Copyright(c)1995 Taligent,Inc. All rights reserved.
" close $searchOutput; EOF