#!/bin/sh # # A Hypertext Ortho Gateway for the CGI interface of an httpd deamon # # Version 0.0 19 Apr 94 # # This script relies on the Ortho from Tomasz Kowaltowski, # Claudio Luchesi and Jorge Stolfi # # QUERIES # # An accompanying HTML Form sets up the query and allows all the functionality # of ortho to be set explicitly. # # PORTING NOTES # # This script should work on almost all systems with a bourne shell, awk. # **** **** **** **** CONFIGURABLE VARIABLES **** **** **** **** MaqSunOS=atibaia read QUERY_STRING ORTHODIR=${STOLFIHOME}/PUB # **** **** **** **** NO CONFIGURATION NEEDED BELOW **** **** **** **** # if [ -x $ORTHODIR ]; then # #.. To support an ISINDEX type search, set query string if given # an argument on the command line # if [ "$QUERY_STRING" = "" ]; then PREFIX="file=" fi # #.. Check that a query has been made # if [ "$QUERY_STRING" ]; then # #.. Strip the variables out from the query string, # and assign them into the environment, prefixed by 'QS_' # # o sed removes any ' that would upset quoted assignment # # o awk ensures that # - all variables passed have legal names # - special characters are not interpreted by sh # eval `echo $PREFIX$QUERY_STRING | sed -e 's/'"'"'/%27/g' | \ awk 'BEGIN{RS="&";FS="="} $1~/^[a-zA-Z][a-zA-Z0-9_]*$/ { printf "QS_%s=%c%s%c\n",$1,39,$2,39}' ` # #.. Set the search type # case $QS_code in tt*) OPT_code='tt-' ;; tex*) OPT_code='tex-' ;; iso*) OPT_code='' ;; esac # #.. Set the output contents # case $QS_out in Erradas+com+alternativas) OPT_out='-alt' ;; Todas+com+alternativas) OPT_out='-allwrong' ;; Apenas+erradas) OPT_out='' ;; esac # #.. Output header # # cat << EOM Content-type: text/html Resultados do Ortho

Resultados do Ortho

    EOM #.. Call ortho, and filter the results into HTML # echo $QS_file | sed 's/%0A/ /g' | tr -s " " "\012" | nawk 'BEGIN { letra["A"]= 10 letra["B"]= 11 letra["C"]= 12 letra["D"]= 13 letra["E"]= 14 letra["F"]= 15 } function hexaint(ch) { if (ch >= "0" && ch <= "9" ) return ( ch - "0") else if (ch >= "A" && ch <= "F" ) return (letra[ch] ) } { out="" len= length($0) for (i= 1; i <= len; i++) { ch1= substr($0,i,1) if (ch1 == "\\") chout= substr($0,++i,1) else if (ch1 == "%") { hi = hexaint(substr($0,++i,1)) * 16 + \ hexaint(substr($0,++i,1)) chout=sprintf("%c",hi) } else if (ch1 == "+" ) chout= " " else chout= ch1 out= out chout } print out }' | rsh $MaqSunOS "$ORTHODIR/${OPT_code}ortho $OPT_out 2>/dev/null" | sed 's/ /:/' | awk -F: '{ print "
  1. " $1 " " print " " $2 }' echo '
' echo '' fi fi