#!/bin/sh

# **** **** **** **** NO CONFIGURATION NEEDED BELOW **** **** **** ****

#
#
#..	To support an ISINDEX type search, set query string if given
#	an argument on the command line
#
    if [ $# -gt 0 ]; then 
	PREFIX="query="
    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}' `
    fi
#
#..	do the job...	
#

CAL=/usr/bin/cal

echo Content-type: text/html
echo

if [ -x $CAL ]; then
CALX=`$CAL $QS_Month $QS_Year`
else
CALX="Cannot find cal on this system."
fi
cat << EOM
<TITLE>Calendar</TITLE>
<H1>Calendar</H1>
To look up a calendar month, type the month followed by a space then the year.<P>
Example: <code>3 1993</code> would give the calendar for March 1993.
<P>
$QS_Month $QS_Year
<P>
<PRE>
		$CALX
EOM

