#!/bin/sh # Last edited on 2008-02-04 20:47:03 by stolfi # # A cgi-bin script for VMS page-coloring service. # This cgi-bin script is designed to be used as the POST method of an # HTML form. VMSDIR=${STOLFIHOME}/projects/voynich/work/Notes/050 debug=0 if [ $debug = 1 ]; then tr '&' '\012' \ | iso-to-html -title "DEBUG - stdin dump" exit 0 fi read QUERY_STRING if [ -x $VMSDIR ]; then # Output HTML headers: # # echo "Content-type: text/html" echo "" # To support an ISINDEX type search, set query string if given # an argument on the command line: # if [ "$QUERY_STRING" = "" ]; then PREFIX="ctable=" 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 # parms=`echo $PREFIX$QUERY_STRING | \ /bin/sed \ -e 's/%0D//g' \ -e 's/'"'"'/%27/g' | \ gawk \ 'BEGIN{RS="&";FS="="} \ ($1~/^[a-zA-Z][a-zA-Z0-9_]*$/) { printf "QS_%s=%c%s%c\n",$1,39,$2,39}' \ ` # Display the parameters: if [ $debug = 1 ]; then echo '' echo '
'
echo $parms |
sed 's/%0A/ /g' |
tr -s " " "\012"
echo ''
fi
# Assign them to shell variables:
#
eval $parms
# Obtain the parameters:
fnum="$QS_fnum";
version="$QS_version";
comments="$QS_comments";
similar="$QS_similar";
# Display the color table:
if [ $debug = 1 ]; then
echo ''
echo $QS_ctable |
sed 's/%0A/@/g' |
tr -s "@+" "\012 "
echo ''
fi
# Write the color table to disk:
ctable=$VMSDIR/color-tables/$$.cdic
echo $QS_ctable |
sed -e 's/%0A/@/g' -e 's/%23/#/g' |
tr -s "@+" "\012 " \
> $ctable
# Call the colorizing script, expect results in HTML:
if [ $debug = 1 ]; then
echo ''
echo ''
else
$VMSDIR/custom-colorize-page \
"${fnum}" \
"${version}" \
"${similar}" "${comments}" \
"$ctable"
# /bin/rm $ctable
fi
fi
fi