#!/bin/csh
# putjoinenv 
#   takes 3 arguments, from joinu.shtml (in DOCUMENT_ROOT)
#      PATH_INFO
#      REFERER
#      QUERY_STRING
# the third arg may be NULL, if no sub-selections are active 
#   see build-opt-env for the definitions for environment vars
# 1. creates a file in $USETEMPDIR (see build-opt-env) called join-object-1
#    which contains the name of the current object
# 2. creates a file 'parameters' containing the current selections/projections
# 3. creates a file 'from_loc' containing the referring program
# 
# modified 12-11-98 clh - see comment with date below
# modified 11-02-99 clh - revamp to fully utilize the environment set in 
#    build-opt-env 
#
# only argument 3 - active subselections - might be NULL
#
if ($#argv == 3) then
  setenv QUERY_STRING $3
endif
setenv PATH_INFO $1
source build-opt-env
#
if ("x${SUBSELS}" == "x") then
   set params="none"
else
   set params=${SUBSELS}
endif
#
#echo "params are $params" >>/usr/local/httpdOO/logs/error_log

set refering=$2
if ("x$refering" == "x") then
   set refering="${MYADDR}/jg/otheropt"
#
# don't need the port 80 designation if there
#
else
   set refering="`echo $refering | sed 's%:80/%/%'`" 
endif
#
# note re: REMOTE_HOST
#    server value below is to determine which optionserver to 
#    return to should that become necessary - or to place in
#    a constructed URL for that server to perform the work,
#    therefore, we can guarantee that REMOTE_HOST will be 
#    present in environment - optionservers DO HAVE DNS names
#
# now, begin the saving work...
#   build-opt-env guarantees that USETEMPDIR is present
#
rm -f ${USETEMPDIR}/join-object-1
echo "${OBJECT}" >${USETEMPDIR}/join-object-1
#
# referring host is recorded in from_loc (arg 2)
# subselections are saved in parameters (arg 3)
#
echo "$refering" >${USETEMPDIR}/from_loc
# problem is to protect the >,<,;,| chars from shell 
#   solution is to quote them - this is very important
#
echo "$params" >${USETEMPDIR}/parameters
# off to join-form
