:
#  httpd_index - evaluate query and create result file  // Nov 23th 93
#  arguments:
#  $1 = name of file from index request
#  $2, $3, ... = keywords
#
#  (C) Christian Neuss, Fraunhofer IGD (neuss@igd.fhg.de) 

#--- start of configuration --- put your changes here ---
#  where to find executables
#  Example:
#    BINDIR="/usr/local/httpd/bin" 
BINDIR="/LocalLibrary/SERVER/IndexBin"
HELPFILE="/icib/query-syntax.html"
SERVER="icib.igd.fhg.de"
#--- end of configuration --- don't change anything below ---


SEARCHCMD="/bin/sh $BINDIR/httpd_getindex"
PROCESSCMD="$BINDIR/process-query"
EXTRTITLE="$BINDIR/extract-title"

file=$1
shift
keywords="$@"
dir=`expr $file : '\(.*\)/.*'`  # get dir from requesting file

eval `$PROCESSCMD $file "$keywords" `
###$PROCESSCMD "$file" "$keywords" > /dev/console
 
cat << EOF
<HEADER>
<ISINDEX>
<TITLE>(Query)</TITLE>
</HEADER>
<BODY>
<H1>Query result</H1>
<P>
EOF
echo "This is the server <B>$SERVER</B>. "
echo "It supports free text queries (look at the"
echo "<A HREF=\"$HELPFILE\">syntax description</A>).<P>"
echo "From document <B>$file</B> you entered the query: "
echo "\"<B>$keywords</B>\"<P>"

if test -n "$theDir"
then
  dir=$theDir
  echo "The context argument has evaluated to \"$dir\" <P>"
fi

if test -n "$theFields"
then
  # field extraction is currently not supported - cn 11/93
  ##query="@theFields $theWords"
  query="$theWords"
else  
  query="$theWords"
fi

echo requesting file is $dir, query is $query > /dev/console

if test -n "$err"
then
  echo "<PRE>" 
  echo $err  
  echo "</PRE>"
else

  $SEARCHCMD "$query" "$dir" "@$theFields" "$theBool" | 
  ( 
    first="1"
    while read a
    do 
      if test "$first" = "1"
        then
        echo "These are the results: <UL>"
        first="0"
      fi
      file=`expr $a : '\(.*\):.*'`
      title=`$EXTRTITLE "" $file`
      hitnum=`expr $a : '.*:\(.*\)'`
      if test $hitnum -gt 0
        then
        if test $hitnum -gt 1
         then
           echo -n "<LI> $hitnum hits:  " 
         else
           echo -n "<LI> $hitnum hit:  " 
         fi
        echo -n "<A HREF=\"http://$SERVER$file\"> $title </A>\n" 
      fi
    done
  ) | (read a; echo $a; sort +1nr -2) | grep L # trick to get return value 


  if test $? = 1
  then
    echo "No matching files have been found."
  else
    echo "</UL>"
    echo "<P>(End of list)"
  fi
fi

echo "</BODY>"