#!/bin/sh
##########################################################################
#    This program is the CONFIDENTIAL and PROPRIETARY property
#    of Mainsoft(R) Corporation. Any unauthorized use, reproduction 
#    or transfer of this computer program is strictly prohibited.
#
#    Copyright (c) 1991-1998 Mainsoft Corporation.
#    This is an unpublished work, and is subject to limited distribution
#    and restricted disclosure only. ALL RIGHTS RESERVED.
#
##########################################################################

SPR_DIR=${HOME}/.mwspr
USERINFO=${SPR_DIR}/.userinfo
SPRNUMBER=${SPR_DIR}/.count
EMAILADDRESS="support@mainsoft.com";
EURMAILADDRESS="euro-support@mainsoft.com";
PROG=`basename $0`

if [ "$MWRUNTIME" = "" ] ; then
   ISRUNTIME="FALSE"
else
   ISRUNTIME="TRUE"
fi

#---------------------------------------------------- checking for echo -n ---
if test "`echo -n foo`" = foo ; then
  ECHON1="echo -n"
  ECHON2=
elif test "`echo 'foo\c'`" = foo ; then
  ECHON1=echo
  ECHON2='\c'
else
  ECHON1=echo
  ECHON2
fi

echo ""

#-------------------------- verify if necessary environment is initialized ---

echo_debug()
{
	if [ -n "$MWDEBUG" ]
	then
		echo $*
	fi
}

init_mainwin_env()
{
	if [ "$MWRUNTIME" = "" -a -r "$MWHOME/setupmainwin" ]
	then
		echo_debug "====> Sourcing $MWHOME/setupmainwin"
	   	. $MWHOME/setupmainwin 2>/dev/null  1>&2
	elif [ -r "$MWHOME/setmwruntime" ]
	then
		echo_debug "====> Sourcing $MWHOME/setmwruntime (Assuming runtime enviroment)"
	   	. $MWHOME/setmwruntime 2>/dev/null 1>&2

		ISRUNTIME="TRUE"
	else
		echo_debug "====> Could not find MainWin init scripts"
	fi
}

deduce_mwhome()
{
	curdir=`pwd`
	dir=`dirname $0`	# should be <install_dir>/mw/bin/ (where mwspr resides)
	cd $dir/.. 			# should be <install_dir>/mw/     (our new MWHOME)
	echo `pwd`
	cd $curdir
}

if [ -z "${MWHOME}" ]
then
	echo_debug "====> MWHOME is not defined ..."
	MWHOME=`deduce_mwhome`
	export MWHOME
    echo_debug "====> Using MWHOME=$MWHOME"
	init_mainwin_env
fi
	 
if [ ! -d "${MWHOME}" ] || [ ! -r "${MWHOME}" ]
then
	echo "$PROG: Cannot access MWHOME directory - $MWHOME"
    echo "Exiting..."
	exit 1
fi

if [ -z "${MWCONFIG_NAME}" ]
then
	echo "$PROG: Looks like MainWin environment is not initialized."
	echo "Please initialize your MainWin environment."
    echo "Exiting..."
	exit 1
fi

if [ -z "${DISPLAY}" ]
then
	echo "$PROG: DISPLAY variable is not initialized.  Please initialize it to the appropriate X server.  '$PROG' needs to collect information from the X server."
	echo "Exiting..."
	exit 1
fi

ShowSeverity()
{
		echo ""
		echo "Enter this bug's priority classification:"
		echo ""
		echo "    A1 = Your customer is down in the field.  This is an urgent problem."
		echo "    A2 = You as the developer cannot move forward without this fix."
		echo "    A3 = This needs fixing prior to shipping but development can still continue."
		echo "     B = A fix would be nice but you can ship without the fix."
		echo "     C = There is an acceptable workaround or this is an FYI to development."
		echo ""
}

#---------------------------------------------------- processing arguments ---

set -- `getopt f: $*`

for i in $*
do
  case $i in
    -f)       APPENDFILE=$2; shift 2;;
    --)       shift; break;;
  esac
done

#------------------------------------------------------------------- banner ---

echo "====================================================================="
echo "             MainWin S)oftware P)roblem R)eport tool"
echo "====================================================================="
echo ""

#--------------------------------------- create the spr directory if needed ---
	
if [ ! -d ${SPR_DIR} ]; then
  mkdir ${SPR_DIR}
fi

#---------------------------------------------- acquire user info if needed ---

if [ ! -f ${USERINFO} ]; then
  echo "It seems that this is the first time that you've filed an SPR."
  echo "The answers to the questions that follow will be captured in"
  echo "${USERINFO} and reused the next time you file an SPR.  If your"
  echo "Address, phone number or email address ever change please"
  echo "update or delete this file."
  echo 
  CORRECT="n";

  while  [ ${CORRECT} = "n" ]; do
    $ECHON1 "Full name <$NAME>:  " $ECHON2
    read REP
    NAME=${REP:-$NAME}
    $ECHON1 "Company <$COMPANY>:  " $ECHON2
    read REP
    COMPANY=${REP:-$COMPANY}
    $ECHON1 "Department <$DIVISION>:  " $ECHON2
    read REP
    DIVISION=${REP:-$DIVISION}
    echo "Business address:"
    $ECHON1 "Street Address, line 1 of 2 <$ADDRESS1>:  " $ECHON2
    read REP
    ADDRESS1=${REP:-$ADDRESS1}
    $ECHON1 "Street Address, line 2 of 2 <$ADDRESS2>:  " $ECHON2
    read REP
    ADDRESS2=${REP:-$ADDRESS2}
    $ECHON1 "City, state, ZIP code <$ADDRESS3>:  " $ECHON2
    read REP
    ADDRESS3=${REP:-$ADDRESS3}
    $ECHON1 "Country <$ADDRESS4>:  " $ECHON2
    read REP
    ADDRESS4=${REP:-$ADDRESS4}
    $ECHON1 "Phone number <$PHONE>:  " $ECHON2
    read REP
    PHONE=${REP:-$PHONE}
    $ECHON1 "Fax number <$FAX>:  " $ECHON2
    read REP
    FAX=${REP:-$FAX}
    $ECHON1 "Email address <$EMAIL>:  " $ECHON2
    read REP
    EMAIL=${REP:-$EMAIL}
    echo " "
    echo "====================================================="
    echo " "
    echo " Your business address is :"
    echo " "
    echo "       $NAME"
    echo "       $COMPANY"
    echo "       $DIVISION"
    echo "       $ADDRESS1"
    echo "       $ADDRESS2"
    echo "       $ADDRESS3"
    echo "       $ADDRESS4"
    echo " "
    echo " Your Phone Number is : $PHONE"
    echo " Your Fax Number is   : $FAX"
    echo " Your Email is        : $EMAIL"
    echo " "
    echo "====================================================="
    echo " "
    $ECHON1 " Is this correct ? (<y>/n) " $ECHON2
    read CORRECT
    CORRECT=${CORRECT:-y}
  done

  echo "----------------------------------------------------------------------" > ${USERINFO}
  echo "                            IDENTIFICATION"         >> ${USERINFO}
  echo ""                           >> ${USERINFO}
  echo "        Contact: $NAME"     >> ${USERINFO}
  echo "        Company:"           >> ${USERINFO}
  echo "                 $COMPANY"  >> ${USERINFO}
  echo "                 $DIVISION" >> ${USERINFO}
  echo "                 $ADDRESS1" >> ${USERINFO}
  echo "                 $ADDRESS2" >> ${USERINFO}
  echo "                 $ADDRESS3" >> ${USERINFO}
  echo ""                           >> ${USERINFO}
  echo "          Phone: $PHONE"    >> ${USERINFO}
  echo "            Fax: $FAX"      >> ${USERINFO}
  echo "          Email: $EMAIL"    >> ${USERINFO}
fi

#------------------------------------------------------------ get SPRNUMBER ---

if [ ! -f ${SPRNUMBER} ]; then
  echo "0" > ${SPRNUMBER}
fi

NUMBER=`cat $SPRNUMBER`
NUMBER=`expr $NUMBER + 1`
SPRFORM=${SPR_DIR}/spr-$NUMBER;

#---------------------------------------------------------- fill the report ---
echo "This Software Problem Report will be written to:";
echo ""
echo "    $SPRFORM";
echo ""
echo "After answering the following questions, you will have the options";
echo "of viewing it for accuracy, saving it for later modification(s) or";
echo "you can email it directly to support@mainsoft.com";
echo ""
echo " -------------------------------------------------------------------"
echo "|   Please visit our Knowledge Base at:                             |"
echo "|                                                                   |"
echo "|        http://www.mainsoft.com/nbase/mainwin/kb/index.htm         |"
echo "|                                                                   |"
echo "|   This will help you with common questions, system/patch          |"
echo "|   requirements and other useful information.                      |" 
echo " -------------------------------------------------------------------"
echo ""

echo "=====================================================================" > ${SPRFORM}
echo "                       SOFTWARE PROBLEM REPORT" >> ${SPRFORM}
echo "=====================================================================" >> ${SRPFORM}

echo "" >> ${SPRFORM}
$ECHON1 "           Date:" >> ${SPRFORM} $ECHON2
date >> ${SPRFORM}
echo "" >> ${SPRFORM}
echo "             To: Mainsoft Corporation" >> ${SPRFORM}
echo "" >> ${SPRFORM}
echo "      Telephone: 408 774 3400" >> ${SPRFORM}
echo "   Tech Support: 408 774 3410" >> ${SPRFORM}
echo "            FAX: 408 774 3404" >> ${SPRFORM}
echo "          Email: support@mainsoft.com" >> ${SPRFORM}
echo "" >> ${SPRFORM}
echo "" >> ${SPRFORM}

cat $USERINFO >> ${SPRFORM}

echo "----------------------------------------------------------------------" >> ${SPRFORM}


# Are we on the correct platform/OS where the problem is occurring???

echo ""
$ECHON1 "Are you running 'mwspr' on the machine where the problem is occuring? <y>/n: " $ECHON2
read PLATFORM_OK
if [ ${PLATFORM_OK:-y} = "n" -o ${PLATFORM_OK:-y} = "N" ]; then
	echo "Ok, Please change to the correct machine and run 'mwspr' again."
	exit 0
fi


# Try to detect the MainWin version, if not ask for it

LIB_SUFFIX="*"

case ${MWOS} in
	ux10 | ux11)
		LIB_SUFFIX="sl"
		;;
	sunos4 | sunos5 | irix5 | irix6 | osf1v4)
		LIB_SUFFIX="so"
		;;
esac

VERSION=`strings ${MWHOME}/lib-${MWCONFIG_NAME}_optimized/libmw32.${LIB_SUFFIX} | grep RELEASE_VERSION | cut -f2 -d':'`

echo ""
if [ -z "${VERSION}" ]; then
	$ECHON1 "MainWin version (3.1, 3.2, 3.3): " $ECHON2
	read VERSION
else
	echo "Detected:$VERSION"
fi



# Dermine the bug severity
ShowSeverity

SEVERITY=h
while true; do
	
	if [ $SEVERITY = "A1" -o $SEVERITY = "A2" -o $SEVERITY = "A3" \
	 	-o $SEVERITY = "B" -o $SEVERITY = "C" ]; then
		break
 	fi
	$ECHON1 "Priority (A1, A2, A3, B, or C <h> for help) : " $ECHON2
	read SEVERITY
	SEVERITY=${SEVERITY:-h}
	if [ $SEVERITY = h ] ; then
		ShowSeverity
	fi
done


echo ""
$ECHON1 "Can the problem be reproduced <y>/n: " $ECHON2
read REPRODUCTIBLE
REPRODUCTIBLE=${REPRODUCTIBLE:=y}


echo "                        PROBLEM DESCRIPTION" >> ${SPRFORM}
echo "" >> ${SPRFORM}
echo  "   Reproducible: $REPRODUCTIBLE" >> ${SPRFORM}
#echo  "  Core dump attached: $COREATTACHED" >> ${SPRFORM}
echo  "       Severity: $SEVERITY" >> ${SPRFORM}
echo  "        Version:$VERSION" >> ${SPRFORM}

if [ "${ISRUNTIME}" = "FALSE" ]; then
	echo  "    Environment: development" >> ${SPRFORM}
else
	echo  "    Environment: runtime" >> ${SPRFORM}
fi

echo "" >> ${SPRFORM}


echo ""
echo ""
echo ""             >> ${SPRFORM}
echo "Please enter a one line summary of the problem (terminate with CTRL-D):";
echo "Summary:" >> ${SPRFORM}
cat >> $SPRFORM

echo ""
echo ""
echo ""             >> ${SPRFORM}
echo "Please describe the problem in detail.  Include the following:";
echo "1. Any error messages that you're getting";
echo "2. Debugger stack trace (if applicable)";
echo "3. Possible workaround(s)";
echo "4. Any history information that would help troubleshoot this issue";
echo ""
echo "NOTE: Please press <ENTER> between each line"
echo "      (do not use the wraparound feature of your terminal)"
echo ""
echo "Description:" >> ${SPRFORM};
cat >> $SPRFORM

#echo ""
#echo ""
#echo ""               >> ${SPRFORM}
#echo "Enter any error messages you may be getting (terminate with CTRL-D):";
#echo "Error Message:" >> ${SPRFORM}
#cat >> $SPRFORM

#echo ""
#echo ""
#echo ""           >> ${SPRFORM}
#echo "Supply any debugger stack trace if applicable (terminate with CTRL-D):";
#echo "Backtrace:" >> ${SPRFORM}
#cat >> $SPRFORM


echo ""
echo ""
echo ""         >> ${SPRFORM}
echo "Enter any sample that reproduces the problem (terminate with CTRL-D):";
echo "Example:" >> ${SPRFORM}
cat >> $SPRFORM

#echo ""
#echo ""
#echo ""            >> ${SPRFORM}
#echo "Enter any workaround or possible solution (terminate with CTRL-D):";
#echo "Workaround:" >> ${SPRFORM}
#cat >> $SPRFORM


# -------------------------------------------------------------- environment ---
echo ""
echo ""
echo "===> Capturing your environment, this will take a moment..."
echo ""
echo "=====================================================================" >> ${SPRFORM} 2>&1
echo ""														>> ${SPRFORM}
echo														>> ${SPRFORM}

# ----------------------- Get the installed platforms  ---------------------
echo "INSTALLED PLATFORMS:"                                 >> ${SPRFORM}
echo "-------------------"                                  >> ${SPRFORM}
echo "Collecting your installed platforms..."
curdir=`pwd`

cd ${MWHOME}

# Add any new platforms on this line.  Note, the output format below is:
# echo "<space>...<space>$MWCONFIGNAME<tab>[X]"
#
for i in lib-sunos5 lib-ux10 lib-ux11 lib-irix6 lib-aix4 lib-osf1v4
do
	platform=`echo ${i} | cut -f2 -d'-'`

	if [ -d "${i}" ]; then
		echo "                    ${platform}	[X]"    >> ${SPRFORM} 2>&1
	else
		echo "                    ${platform}	[ ]"    >> ${SPRFORM} 2>&1
	fi
done

cd $curdir

echo ""														>> ${SPRFORM} 2>&1

# -------------------- Get the hardware and OS version --------------------
echo "HARDWARE/OS:"											>> ${SPRFORM}
echo "-----------"											>> ${SPRFORM}
echo "Collecting your platform and OS version information..."
uname -a >> ${SPRFORM} 2>&1
case $MWOS in 
 osf1v4)
	/usr/sbin/sizer -v  >> ${SPRFORM} 2>&1
	;;
aix4)
	oslevel >> ${SPRFORM} 2>&1
	;;
esac



# -------------------- Get the C/C++ compiler versions --------------------
if [ ${ISRUNTIME} = "FALSE" ]; then
	echo														>> ${SPRFORM}
	echo "C/C++ COMPILER VERSIONS:"								>> ${SPRFORM}
	echo "-----------------------"								>> ${SPRFORM}
	echo "Collecting your C/C++ compiler versions..."

	case ${MWOS} in
	sunos4 | sunos5)
		echo "CC              = ${CC} (`type $CC | awk '{print $NF}'`)"			>> ${SPRFORM} 2>&1
		echo "CCPP            = ${CCPP} (`type $CCPP | awk '{print $NF}'`)"		>> ${SPRFORM} 2>&1
        /bin/echo "cc: \c" >> ${SPRFORM}
        /usr/ccs/bin/what `type $CC | awk '{print $NF}'` | grep RELEASE >> ${SPRFORM} 2>&1 
		$CCPP -V												>> ${SPRFORM} 2>&1
		;;
	osf1v4)
		echo "CC              = ${CC} (`type $CC | awk '{print $NF}'`)"			>> ${SPRFORM} 2>&1
		echo "CCPP            = ${CCPP} (`type $CCPP | awk '{print $NF}'`)"		>> ${SPRFORM} 2>&1
		$CC -V			| sed -n 1,2p										>> ${SPRFORM} 2>&1
		$CCPP -V												>> ${SPRFORM} 2>&1
		;;
	ux10 | ux11)
		echo "CC              = ${CC} (`type $CC | awk '{print $NF}'`)"			>> ${SPRFORM} 2>&1
		echo "CCPP            = ${CCPP} (`type $CCPP | awk '{print $NF}'`)"		>> ${SPRFORM} 2>&1
		what `type $CC | awk '{print $NF}'`										>> ${SPRFORM} 2>&1
		what `type $CCPP | awk '{print $NF}'`										>> ${SPRFORM} 2>&1
		;;
	irix5 | irix53 | irix6)
		echo "CC              = ${CC}"							>> ${SPRFORM} 2>&1
		echo "CCPP            = ${CCPP}"						>> ${SPRFORM} 2>&1
		showprods -D1 c_dev										>> ${SPRFORM} 2>&1
		showprods -D1 c++_dev									>> ${SPRFORM} 2>&1
		;;
	aix4)
		echo "CC              = ${CC} (`type $CC | awk '{print $NF}'`)"			>> ${SPRFORM} 2>&1
		echo "CCPP            = ${CCPP} (`type $CCPP | awk '{print $NF}'`)"		>> ${SPRFORM} 2>&1
		lslpp -L | egrep -i 'xlC|visual' >> ${SPRFORM} 2>&1
		;;
	esac
fi


# ------------------ Get the user's environment vars -----------------------
echo														>> ${SPRFORM}
echo "USER ENVIRONMENT:"									>> ${SPRFORM}
echo "----------------"										>> ${SPRFORM}
echo "Collecting your environment variables..."
env															>> ${SPRFORM} 2>&1


# --------------------- Get any installed patches --------------------------
echo ""														>> ${SPRFORM}
echo "INSTALLED PATCHES:"									>> ${SPRFORM}
echo "-----------------"									>> ${SPRFORM}
echo ""                                                     >> ${SPRFORM}
echo "Collecting your installed patch list..."

echo "MainWin Patches:"										>> ${SPRFORM}
echo "---------------"                                      >> ${SPRFORM}
mwversion -p												>> ${SPRFORM} 2>&1
echo ""														>> ${SPRFORM}
echo "System Patches:"										>> ${SPRFORM}
echo "--------------"     	                                >> ${SPRFORM}

case ${MWOS} in
sunos4 | sunos5) /bin/echo "\nCommand: /bin/showrev -a | sort" >> ${SPRFORM}
	/bin/showrev -a | sort									>> ${SPRFORM} 2>&1
	;;
osf1v4) /bin/echo "\nCommand: /usr/sbin/setld -i | grep -i installed | grep -i patch\n" >> ${SPRFORM}
	/usr/sbin/setld -i | grep -i installed | grep -i patch    		>> ${SPRFORM} 2>&1
	;;
ux10 | ux11)
	/usr/sbin/swlist										>> ${SPRFORM} 2>&1
	;;
irix5 | irix53 | irix6)  /bin/echo "\nCommand: /usr/sbin/showprods | grep -i patch\n" >> ${SPRFORM}
	/usr/sbin/showprods | grep -i patch						>> ${SPRFORM} 2>&1
	;;
aix4)  /bin/echo "Completely installed:\nCommand: instfix -i | grep "All filesets" | awk '{print $4}'\n" >> ${SPRFORM}
	 instfix -i | grep "All filesets" | awk '{print $4}'					>> ${SPRFORM} 2>&1
     /bin/echo "Incompletely installed:\nCommand: instfix -i | grep -v "All filesets" | awk '{print $4}'\n" >> ${SPRFORM}
	 instfix -i | grep -v "All filesets" | awk '{print $4}'					>> ${SPRFORM} 2>&1
	;;
*)
	echo "Unknown platform/OS"		                        >> ${SPRFORM} 2>&1
	;;
esac
echo ""														>> ${SPRFORM}

echo "Checking System ..." | tee -a ${SPRFORM}
echo "_________________________________________" >> ${SPRFORM}
$MWHOME/bin/mwcheck_platform -N >> ${SPRFORM}
echo "_________________________________________" >> ${SPRFORM}
echo "Collecting Additional System Info ..." | tee -a  ${SPRFORM}
case $MWOS in
	sunos5) /bin/echo "\nGraphics Device Directory: (ls /dev/fbs) \n" >> ${SPRFORM} 
			 ls /dev/fbs >> ${SPRFORM} 2>&1 
			 /bin/echo "\nKernel Version (what /kernel/genunix)\n" >> ${SPRFORM}
              if [  -f /kernel/genunix ] ; then
			     /usr/ccs/bin/what /kernel/genunix >>  ${SPRFORM} 2>&1
			  else
				echo "Couldn't find /kernel/genunix, must have another name" >> ${SPRFORM}
              fi
			  /bin/echo "System Information ..."
			 /bin/echo "\ncat /etc/system Info\n" >> ${SPRFORM}
			 cat /etc/system >> ${SPRFORM} 2>&1
			  /bin/echo "Hardware Information ..."
			 /bin/echo "\n/usr/sbin/prtconf Info\n" >> ${SPRFORM}
			 /usr/sbin/prtconf  >> ${SPRFORM} 2>&1
			  /bin/echo "Packages ..."
			 /bin/echo "\nPackages installed completely: (pkginfo -i -l)\n" >> ${SPRFORM}
			 pkginfo -i -l | egrep 'PKGINST|NAME|VERSION|INSDATE' >> ${SPRFORM} 2>&1
             ;;
	aix4)  
		     /bin/echo "Packages ..."
			/bin/echo "\nPackages installed (lslpp -L)\n:" >> ${SPRFORM}
			lslpp -L >> ${SPRFORM} 2>&1
			/bin/echo "Hardware ..."
			/bin/echo "\nSystem Devices(lsdev -C -H)\n:" >> ${SPRFORM}
			lsdev -C -H >> ${SPRFORM} 2>&1
			
			;;
   irix6)  /bin/echo "Kernel Info ..."
             /bin/echo "\nKernel Parameters (cat /var/sysgen/mtune/kernel | egrep -v '^\*')\n" >> ${SPRFORM}
			cat /var/sysgen/mtune/kernel | egrep -v '^\*' >> ${SPRFORM} 2>&1
			/bin/echo "\nMessage Queues (cat /var/sysgen/mtune/msg | egrep -v '^\*')\n" >> ${SPRFORM}
			cat /var/sysgen/mtune/msg | egrep -v '^\*' >> ${SPRFORM} 2>&1
			/bin/echo "\nSemaphores (cat /var/sysgen/mtune/sem | egrep -v '^\*')\n" >> ${SPRFORM}
			cat /var/sysgen/mtune/sem | egrep -v '^\*' >> ${SPRFORM} 2>&1

			/bin/echo "\nGraphics (cat /var/system/gfx.sm | egrep -v '^\*')\n" >> ${SPRFORM}
			cat /var/sysgen/system/gfx.sm | egrep -v '^\*' >> ${SPRFORM} 2>&1
		
			/bin/echo "Packages ..."
            /bin/echo "\nPackages Installed (versions -b)\n" >> ${SPRFORM}
		    versions -b | awk '{if ($1 != "Name" && $NF != "Removed") {if ($1 == "I") {$1 = ""; $2=""} print $0}}' >> ${SPRFORM} 2>&1
			#/bin/echo "File information ..."
			#/bin/echo "\nFile Information (showfiles)\n" >> ${SPRFORM}
			#showfiles >> ${SPRFORM} 2>&1
			;;
	osf1v4) /bin/echo "Packages ..."
            /bin/echo "\nInstalled Packages\n (/usr/sbin/setld -i ...)" >> ${SPRFORM}
			/usr/sbin/setld -i | grep installed | grep -v -i patch  >> ${SPRFORM} 2>&1
           	/bin/echo "\nBASE Package List (/usr/sbin/setld -i ...)" >> ${SPRFORM} 
			/usr/sbin/setld -i | egrep 'OSFINCLUDE|OSFSDE[0-9]|OSFPGMR' >> ${SPRFORM}
			/bin/echo "\nOpen3D Packages\n (/usr/sbin/setld -i | grep Open3D)" >> ${SPRFORM}
			/usr/sbin/setld -i | grep Open3D >> ${SPRFORM}

            if [ ${ISRUNTIME} = "FALSE" ]; then
			   /bin/echo "More compiler info ..."
			   /bin/echo "\n\nCompiler Details" >> ${SPRFORM}
			   ccpp=`type $CCPP | awk '{print $NF}' | sed 's/[()]//g'`
			   /bin/echo "\nC++ Details (what $ccpp)\n" >> ${SPRFORM}
			   what $ccpp >> ${SPRFORM} 2>&1
               /bin/echo "\nC++ Library Details (what /usr/lib/cmplrs/cxx/libcxx.so)\n" >> ${SPRFORM}
               what /usr/lib/cmplrs/cxx/libcxx.so >> ${SPRFORM} 2>&1
			   cc=`type $CC | awk '{print $NF}'` 
			   /bin/echo "\nCC Details (what $cc)\n" >> ${SPRFORM}
			   what $cc >> ${SPRFORM} 2>&1
            fi

			/bin/echo "System Information and Hardware Configuration ..."
			/bin/echo "\nMore Information\n (/usr/sbin/sizer)" >> ${SPRFORM}
			for f in c m p wt wu gt gr l atm implver ; do
                case $f in
				 c)     output="(-c) cpu type" ;;
				 #m)     output="(-m) the booted kernel's module list" ;;
				 p)     output="(-p) the number of processors available" ;;
				 wt)    output="(-wt) workstation display type" ;;
				 wu)    output="(-wu) workstation display units" ;;
				 gt)    output="(-gt) graphics controller information" ;;
				 gr)    output="(-gr) graphics controller resolution" ;;
				 l)     output="(-l) the lite system flag" ;;
				 atm)   output="(-atm) success if an ATM adaptor is present" ;;
				 implver) output=" (implver) processor family (EV4/EV5/EV6)" ;;
                esac
				/bin/echo "${output}: \c" >> ${SPRFORM}
				/usr/sbin/sizer -$f >> ${SPRFORM}
				echo >>  ${SPRFORM}
			done
		;;
	ux10|ux11)   echo "System Parameters ..."
                /bin/echo "\nSystem Parameters (cat /usr/conf/master.d/core-hpux | egrep -v '^\*')\n" >> ${SPRFORM}
				cat /usr/conf/master.d/core-hpux | egrep -v '^\*' >> ${SPRFORM} 2>&1
				echo "Kernel information ..."
				/bin/echo "\nKernel (what /stand/vmunix)\n" >> ${SPRFORM}}
				what /stand/vmunix >> ${SPRFORM} 2>&1
		     ;;	
esac

# --------------------- Get the X server settings -------------------------
echo														>> ${SPRFORM}
echo "X SERVER:"											>> ${SPRFORM}
echo "--------"												>> ${SPRFORM}
echo "Collecting your X Server configuration..."
xdpyinfo													>> ${SPRFORM} 2>&1


# -------------------- Get the MW library listings ------------------------
CurDir=`pwd`

if [ -d ${MWHOME}/lib-${MWCONFIG_NAME}_debug ]; then
	echo														>> ${SPRFORM}
	echo "Debug directory libs:"								>> ${SPRFORM}
	echo "--------------------"									>> ${SPRFORM}
	echo "Collecting your mainwin library listings..."
	echo "${MWHOME}/lib-${MWCONFIG_NAME}_debug/"				>> ${SPRFORM}
	cd ${MWHOME}/lib-${MWCONFIG_NAME}_debug
	ls -l lib*													>> ${SPRFORM} 2>&1
fi

cd ${MWHOME}/lib-${MWCONFIG_NAME}_optimized
echo														>> ${SPRFORM}
echo "Optimized directory libs:"							>> ${SPRFORM}
echo "------------------------"								>> ${SPRFORM}
echo "${MWHOME}/lib-${MWCONFIG_NAME}_optimized/"			>> ${SPRFORM}
ls -l lib*													>> ${SPRFORM} 2>&1
cd $CurDir

echo ""														>> ${SPRFORM}


# ------------- Make sure that the user included everything ---------------
echo "=====================================================================
                            END OF SPR REPORT

Thank you for taking the time to fill out this Software Problem Report.  
Our support Engineers will address this issue promptly and will provide a 
response as soon as possible.  Once recieved, this issue will be prioritized 
and engineering resources will be assigned to resolve the problem, if 
necessary.

If you have any questions or comments please send them to support@mainsoft.com 
and our Support Engineers will do their best to meet your needs.

Thank you for choosing MainWin XDE!
=====================================================================" >> ${SPRFORM}


if [ -n "$APPENDFILE" -a -f "$APPENDFILE" ]
then
  cat $APPENDFILE >> ${SPRFORM} 2>&1
  rm -f $APPENDFILE
fi


#--------------------------------------------------------- update the count ---
echo $NUMBER > ${SPRNUMBER}

#------------------------------------------ Add a Subject: line for easy ID ---
SUBJECT="SOFTWARE PROBLEM REPORT"
MAILFILE="${SPR_DIR}/.mailfile"
 
create_mail_file()
{
	rm -f ${MAILFILE}
	touch ${MAILFILE}
	echo "Subject: ${SUBJECT}" >> ${MAILFILE} 2>&1
	echo "To: ${emailaddr}" >> ${MAILFILE} 2>&1
	echo "" >> ${MAILFILE} 2>&1
	cat ${SPRFORM} >> ${MAILFILE}
}
#------------------------------------------------------------------ wrap up ---

while true; do
  echo "                                                                    "
  echo "--------------------------------------------------------------------"
  echo "What do you want to do with your Software Problem Report?";
  echo "      v    view it"
  echo "      m    email it to Mainsoft Support"
  echo "      <n>  nothing yet, keep ${SPRFORM}"
  $ECHON1 "Enter your choice: " $ECHON2
  read REP
  if [ "${REP:-n}" = "v" ]; then
     more ${SPRFORM}
  elif [ "${REP:-n}" = "m" ]; then
	 while : ; do
	       /bin/echo "Would you like to send to your email to:\n (E)urope Support or (U)S support (default (U)S support) ?\c"
		  read email
		  case $email in 
			U|u|US|us|"")
				emailaddr=$EMAILADDRESS
				break
                ;;
			E|e)
				emailaddr=$EURMAILADDRESS
				break
				;;
			*);;
		esac
	 done
	 create_mail_file
     mail ${emailaddr} < ${MAILFILE}
	 echo ""
	 echo "===> Your Software Problem Report: ${SPRFORM}"
	 echo "===> has been sent to ${emailaddr}"
	 echo ""
     break;
  elif [ "${REP:-n}" = "n" ]; then
     break;
  fi
done

# ------------------------------ "thanks" ---------------------------------
echo "=====================================================================
Thank you for taking the time to fill out this Software Problem Report.  
Our support Engineers will address this issue promptly and will provide a 
response as soon as possible.  Once received, this issue will be prioritized 
and engineering resources will be assigned to resolve the problem, if 
necessary.

If you have any questions or comments please send them to support@mainsoft.com 
and our Support Engineers will do their best to meet your needs. 

Thank you for choosing MainWin XDE!
====================================================================="
