:
#!/bin/sh
#
# $Header: casedes.pp 1012100.5 92/07/20 11:32:50 sreddy Osd<unix> $ casedes.pp Copyr (c) 1989 Oracle
#
# ******************************************************************
# *                                                                *
# *           CASE*DESIGNER by Oracle UK                           * 
# *                                                                *
# *  Copyright C 1988 Oracle Corporation UK Ltd.,                  *
# *                   Richmond, England.                           *
# *  All rights reserved                                           *  
# *                                                                *
# *  This  material has  been provided  pursuant to  an agreement  *
# *  containing  restrictions  on its use.  The  material is also  *
# *  protected  by  copyright law.  No part  of this material may  *
# *  be copied   or distributed,  transmitted  or transcribed, in  *
# *  any form or  by any means, electronic, mechanical, magnetic,  *
# *  manual, or  otherwise, or disclosed to third parties without  *
# *  the express written permission of Oracle Corporation UK Ltd,  *
# *  Thames Link House , 1 Church Road, Richmond, Surrey, England  *
# *                                                                *
# ******************************************************************
#
# Application : CASE*Designer
# Author : SJStow
# Date   : 27-Jun-88
#
# Changed:
#  27June89   Stephen Beer
#             Now tests for the existence of bitmaps and menus files 
#             below $CASE_HOME rather than explicitly below "/usr/lib/CASE"
#
#  11Oct89    John S Cooper
#             Appends relevant font directory to font path.
#
#  02Nov89    John S Cooper
#             Merged changes from Sun version:-
#               tests for -c options on the command line, and that
#               specified crt file exists.
#               Added crt usage instructions.
#               Changed version number to V1.1 in usage section.
#
#  28Aug91    Bob Stockwell
#             Made changes for 1.1.21 Designer.
#               Changed references to CASE_CRT TO CASE_RESOURCE.
#               Put check in for CASE_RESOURCE file. 
# 
# ******************************************************************

STRCMD=strings

# ******************************************************************
#
# Flag handling 
#
FLAGS=" "

if test "$1" = '-?'
then
    $STRCMD $ORACLE_HOME/bin/casefront | fgrep 'CASE*Designer' | fgrep 'Oracle Version' | awk 'NR == 1'
    exit 0
fi

if test -z "$DISPLAY"
then
   DISPLAY=unix:0
fi

if test -z "$CASE_RESOURCE"
then

   CASE_RESOURCE=xterm

fi

if test "$#" -ge 1
then
  for i in "$@"
  do
    if test "$dflag" = "y"
    then 
       DISPLAY=$i
       dflag=n
    else if test "$cflag" = "y"
         then
            CASE_RESOURCE=$i
            cflag=n
         else
            case "$i" in
              -d) dflag=y;;
              -c) cflag=y;;
              * ) TEMP=$FLAGS
                  FLAGS="$TEMP $i";;
            esac
         fi
    fi
  done
fi

export DISPLAY
export CASE_RESOURCE

# ******************************************************************
#
# Usage statements
#
if test "$1" = "-h"
then
   echo 

   echo "CASE*Designer : Version 1.1"

   echo
   echo "Copyright (c) 1989, Oracle Corporation, UK.  All rights reserved."
   echo 
   echo
   echo "Format is : "
   echo ""
   echo "casedes [userid/password] [-d <display>] [-c <resource_file>]"
   echo ""
   echo "   -d display     Use this display"
   echo "   -c resource    Use this resource definition"
   echo ""
   exit 0
fi

# ******************************************************************
#
# Check environment variables
#
# Must have SDD_HOME, SDD_BIN, ORACLE_HOME and CASE_HOME
#
#  - if SDD_HOME is not set then ORACLE_HOME/dict50/admin is taken as default
#
if test -z "$SDD_HOME"
then
   if test -z "$ORACLE_HOME"
   then
       echo
       echo ERROR : Environment variable ORACLE_HOME is not defined
       echo
       exit 0
   else
       SDD_HOME=$ORACLE_HOME/dict50/admin
       export SDD_HOME
   fi
fi

#
# ******************************************************************
#
# Check that environment variable SDD_BIN exists
#
# - if SDD_BIN is not set then ORACLE_HOME/bin is taken as default
# SDD_HOME will have been set already
#
#
if test -z "$SDD_BIN"
then
    SDD_BIN=$ORACLE_HOME/bin
    export SDD_BIN
fi

#
# ******************************************************************
#
# Check that directory $SDD_HOME exists
#
if test ! -d "$SDD_HOME"
then
   echo ""
   echo "ERROR : Cannot find directory $SDD_HOME"
   echo "ERROR : Environment variable SDD_HOME not set correctly"
   echo "        Check location of dict directory and correct SDD_HOME"
   echo ""
   exit 0
fi

# ******************************************************************
#
# Check that directory $SDD_BIN exists
#
if test ! -d "$SDD_BIN"
then
   echo ""
   echo "ERROR : Cannot find directory $SDD_BIN"
   echo "ERROR : Environment variable SDD_BIN not set correctly"
   echo "        Check location of bin directory and correct SDD_BIN"
   echo ""
   exit 0
fi

#
# ******************************************************************
#
# Check that directory $CASE_HOME is set & exists
#
if test -z "$CASE_HOME"
then
   CASE_HOME=$ORACLE_HOME/cdes
   export CASE_HOME
fi

if test ! -d "$CASE_HOME"
then
      echo ""
      echo "ERROR : Cannot find directory $CASE_HOME"
      echo "ERROR : Envirnment variable CASE_HOME not set correctly"
      echo "        Check location of cdes directory and correct CASE_HOME"
      echo ""
      exit 0
fi

# ******************************************************************
#
# Check that directories $CASE_HOME/admin/bitmaps and
# $CASE_HOME/admin/menus exist
#

if test ! -d $CASE_HOME"/admin/bitmaps"
then
    echo ""
    echo "ERROR : Cannot find directory " $CASE_HOME"/admin/bitmaps"
    echo ""
    exit 0
fi

if test ! -d $CASE_HOME"/admin/menus"
then
    echo ""
    echo "ERROR : Cannot find directory " $CASE_HOME"/admin/menus"
    echo ""
    exit 0
fi

# ******************************************************************
# Test that specified resource file exists
CASE_RESFILE=`echo $CASE_RESOURCE|sed -e 's/:.*$/.r/'`
OLD_IFS="$IFS"
IFS=" :"
for i in $FORMS30PATH $ORAKITPATH
do
  if test -f $i/$CASE_RESFILE
  then
    RESFILE_FOUND=TRUE
    break
  fi
done
if test -z "$RESFILE_FOUND"
then
  echo ""
  echo "ERROR : Cannot find resource file $CASE_RESOURCE"
  echo "ERROR : Environment variable CASE_RESOURCE not set correctly"
  echo "        Check valid resource files in FORMS30PATH environment"
  echo "        variable paths and correct CASE_RESOURCE"
  echo ""
  exit 0
fi
IFS="$OLD_IFS"

# ******************************************************************
#
# Default CASE_SDPRINT to lw if is not already defined
#
if test -z "$CASE_SDPRINT"
then
    CASE_SDPRINT=lw
    export CASE_SDPRINT
fi

case $FONT_DIR_REMOTE in 
T) ;;
*)
    # Set the font path so as to pick up the Oracle supplied fonts
    xset q | fgrep "case_1.1" > /dev/null
    if [ $? -ne 0 ]
    then
        xset +fp $ORACLE_HOME/cdes/admin/fonts/case_1.1
        xset fp rehash
        xset q | fgrep "case_1.1" > /dev/null
        if [ $? -ne 0 ]
        then
            echo "Display $DISPLAY does not have CASE*Designer specific fonts installed."
            echo "Please refer to CASE*Designer Installation Guide to install fonts onto X server display."
            exit 1
        fi
    fi
;;
esac

# ******************************************************************
#
# Ok - now we can run casefront
#

exec $ORACLE_HOME/bin/casefront $FLAGS -name "CASE*Designer" -d $DISPLAY -c $CASE_RESOURCE

# ******************************************************************
#
# End of casedes
#
# ******************************************************************
