#! /bin/sh
# $Id: gen-scale.sh,v 1.1 2013/12/24 18:05:46 vegogine Exp $
#
# This script generates source variations from scale.c for different datatypes.

UPPER="$1"
MIXED="$2"
DTYPE="$3"
CTYPE="$4"

# The widget provides for setting the digits.  Turn on/off the corresponding
# ifdef.
case $CTYPE in
float|*double)
	float=1
	print=f
	;;
long*long)
	float=0
	print=ll
	;;
unsigned*long)
	float=0
	print=lu
	;;
unsigned)
	float=0
	print=u
	;;
long)
	float=0
	print=l
	;;
*)
	float=0
	print=d
	;;
esac

if test "$print" = "d" ; then
	MODEL=
elif test $CTYPE = double; then
	MODEL="d"
else
	MODEL=$print
fi

if test $float = 0 ; then
sed	-e '/^#if <FLOAT>/,/^#endif <FLOAT>/d' \
	-e '/^#if <INT>/d' \
	-e '/^#endif <INT>/d' \
	-e 's/<UPPER>/'"$UPPER"'/g' \
	-e 's/<MIXED>/'"$MIXED"'/g' \
	-e 's/<DTYPE>/'"$DTYPE"'/g' \
	-e 's/<CTYPE>/'"$CTYPE"'/g' \
	-e 's/<MODEL>/'"$MODEL"'/g' \
	-e 's/<PRINT>/'"$print"'/g' \
	$5
else
sed	-e '/^#if <INT>/,/^#endif <INT>/d' \
	-e '/^#if <FLOAT>/d' \
	-e '/^#endif <FLOAT>/d' \
	-e 's/<UPPER>/'"$UPPER"'/g' \
	-e 's/<MIXED>/'"$MIXED"'/g' \
	-e 's/<DTYPE>/'"$DTYPE"'/g' \
	-e 's/<CTYPE>/'"$CTYPE"'/g' \
	-e 's/<MODEL>/'"$MODEL"'/g' \
	-e 's/<PRINT>/'"$print"'/g' \
	$5
fi


#! /bin/sh
# $Id: headers.sh,v 1.1 2013/12/24 18:05:49 vegogine Exp $
# vi:ts=4 sw=4
#
# Adjust includes for header files that reside in a subdirectory of
# /usr/include, etc.
#
# Options:
#	-c CFG	specify an alternate name for config.h
#	-d DIR	target directory
#	-e FILE	extra editing commands, e.g., for manpage references
#	-h FILE install the given file in subdirectory DIR rather than parent
#	-i    	create/update the headers.sed script
#	-p PKG	specify the package name
#	-s DIR	source directory
#	-t TYPE renaming for manpage-sections
#	-x PRG	install-program (plus options, the whole value in quotes)
#
# Other parameters are assumed to be provided only for the install scenario.

SCRIPT=headers.sed
MYFILE=headers.tmp

OPT_C=config.h
OPT_D=
OPT_E=
OPT_H=
OPT_I=n
OPT_P=
OPT_S=
OPT_T=
OPT_X=install

while test $# != 0
do
	case $1 in
	-c)	# CFG	specify an alternate name for config.h
		shift
		OPT_C="$1"
		;;
	-d)	# DIR	target directory
		shift
		OPT_D="$1"
		;;
	-e)	# FILE	extra sed-commands
		shift
		OPT_E="$OPT_E -f $1"
		;;
	-h)	# FILE	special-case of header in subdirectory
		shift
		OPT_H="$1"
		;;
	-i)	# create the headers.sed script
		if test "$OPT_I" = n
		then
			rm -f $SCRIPT
		fi
		OPT_I=y

		if ( test -n "$OPT_D" )
		then
			if ( test -n "$OPT_S" && test -d "$OPT_S" )
			then
				LEAF=`basename $OPT_D`
				case $OPT_D in
				/*/include/$LEAF)
					END=`basename $OPT_D`
					for i in $OPT_S/*.h
					do
						NAME=`basename $i`
						if test -z "$OPT_H" || test "$OPT_H" != "$NAME"
						then
							echo "s%<$NAME>%<$END/$NAME>%g" >> $SCRIPT
						fi
					done
					;;
				*)
					echo "" >> $SCRIPT
					;;
				esac
				OPT_S=
				if test -f $SCRIPT ; then
					sort -u $SCRIPT >$MYFILE
					rm -f $SCRIPT
					mv $MYFILE $SCRIPT
				fi
			fi
		fi

		if test -n "$OPT_P"
		then
			for name in `
			egrep "#define[ 	][ 	]*[A-Z]" $OPT_C \
				| sed	-e 's/^#define[ 	][ 	]*//' \
					-e 's/[ 	].*//' \
				| fgrep -v GCC_ \
				| sort -u \
				| egrep -v "^${OPT_P}_"`
			do
				echo "s%\\<$name\\>%${OPT_P}_$name%g" >>$SCRIPT
			done
			if test -f $SCRIPT ; then
				sort -u $SCRIPT >$MYFILE
				rm -f $SCRIPT
				mv $MYFILE $SCRIPT
			fi
			OPT_P=
		fi
		;;
	-p)	# PKG	specify the package name
		shift
		OPT_P="$1"
		;;
	-s)	# DIR	source directory
		shift
		OPT_S="$1"
		;;
	-t)	# rename suffix of target
		shift
		OPT_T="$1"
		;;
	-x)	# PRG	install-program (plus options, the whole value in quotes)
		shift
		OPT_X="$1"
		;;
	*)
		FILE=$1

		SHOW=`basename $FILE`
		TMPSRC=${TMPDIR-/tmp}/${SHOW}$$

		echo "	... $SHOW"
		test -f $OPT_S/$FILE && FILE="$OPT_S/$FILE"

		if test -f "$FILE"
		then
			rm -f $TMPSRC
			sed -f $SCRIPT $OPT_E $FILE > $TMPSRC
			NAME=`basename $FILE`
			if test -n "$OPT_T" ; then
				NAME=`echo "$NAME" | sed -e 's/\.[^.]*$//'`.$OPT_T
			fi

			# Just in case someone gzip'd manpages,
			# remove the conflicting copy.
			test -f $OPT_D/$NAME.gz && rm -f $OPT_D/$NAME.gz

			eval $OPT_X $TMPSRC $OPT_D/$NAME
			rm -f $TMPSRC
		fi
		;;
	esac
	shift
done


#! /bin/sh
# $Id: manlinks.sh,v 1.1 2013/12/24 18:05:53 vegogine Exp $
# install/uninstall aliases for one or more manpages,
#
#  Copyright 2002,2005 Thomas Dickey
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#  3. All advertising materials mentioning features or use of this software
#     must display the following acknowledgment:
#       This product includes software developed by Thomas Dickey
#       and contributors.
#  4. Neither the name of Thomas Dickey, nor the names of contributors
#     may be used to endorse or promote products derived from this software
#     without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THOMAS DICKEY AND CONTRIBUTORS ``AS IS'' AND
#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED.  IN NO EVENT SHALL THOMAS DICKEY OR CONTRIBUTORS BE LIABLE
#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#  SUCH DAMAGE.

CDPATH=

verb=$1
shift

srcdir=$1
shift

mandir=$1
shift

mansect=$1
shift

parent=`pwd`
script=$srcdir/manlinks.sed

for source in $* ; do
case $source in #(vi
*.orig|*.rej) ;; #(vi
*.[0-9]*)
	cd $parent
	section=`expr "$source" : '.*\.\([0-9]\)[xm]*'`;
	aliases=
	inalias=$source
	test ! -f $inalias && inalias="$srcdir/$inalias"
	if test ! -f $inalias ; then
		echo "	.. skipped $source"
		continue
	fi
	aliases=`sed -f $script $inalias | sort -u`

	suffix=`basename $source | sed -e 's/^[^.]*//'`
	cd $mandir || exit 1
	if test $verb = installing ; then
		test -n "$aliases" && (
			if test "$suffix" = ".$mansect" ; then
				target=`basename $source`
			else
				target=`basename $source $suffix`.$mansect
				suffix=".$mansect"
			fi
			for cf_alias in $aliases
			do
				cf_doit=no
				if test -f $cf_alias${suffix} ; then
					if ( cmp -s $target $cf_alias${suffix} )
					then
						:
					else
						cf_doit=yes
					fi
				else
					cf_doit=yes
				fi
				if test $cf_doit = yes ; then
					echo "	... alias $cf_alias${suffix}"
					rm -f $cf_alias${suffix}
					if (ln -s $target $cf_alias${suffix}) ; then
						:
					else
						echo ".so $target" > $cf_alias${suffix}
					fi
				fi
			done
		)
	elif test $verb = removing ; then
		suffix=".$mansect"
		test -n "$aliases" && (
			for cf_alias in $aliases
			do
				echo "	... alias $cf_alias${suffix}"
				rm -f $cf_alias${suffix}
			done
		)
	fi
	;;
esac
done
exit 0


#!/bin/sh
# $Id: alphalist.sh,v 1.1 2013/12/24 18:06:16 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the alphalist widget.
#

#
# This gets the password file.
#
getPasswordFile()
{
   system=$1
   file=$2

   #
   # Depeding on the system, get the password file
   # using nicat, ypcat, or just plain old /etc/passwd
   #
   if [ "$system" = "NIS" ]; then
      niscat passwd.org_dir > $file
   elif [ "$system" = "YP" ]; then
      ypcat passwd > $file
   else
      cp /etc/passwd $file
   fi
}

#
# This displays account information.
#
displayAccountInformation()
{
   userAccount=$1
   passwordFile=$2

   #
   # Get the user account information.
   #
   line=`grep "^${userAccount}" $passwordFile`
   uid=`echo $line | cut -d: -f3`
   gid=`echo $line | cut -d: -f4`
   info=`echo $line | cut -d: -f5`
   home=`echo $line | cut -d: -f6`
   shell=`echo $line | cut -d: -f7`

   #
   # Create the label message information.
   #
   accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID    : </U>${uid}
GID    : </U>${gid}
Info   : </U>${info}
Home   : </U>${home}
Shell  : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"

   #
   # Create the popup label.
   #
   ${CDK_LABEL} -m "${accountMessage}" -p " "
}

#
# Create some global variables.
#
CDK_ALPHALIST="${CDK_BINDIR=..}/cdkalphalist"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/alphalist.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"

#
# Create the message for the scrolling list.
#
title="<C>Pick an account
<C>you want to view."

#
# Get the password file and stick it into the temp file.
#
#getPasswordFile "YP" "$tmpPass"
#getPasswordFile "NIS" "$tmpPass"
getPasswordFile "Other" "$tmpPass"

#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}

#
# Create the scrolling list.
#
${CDK_ALPHALIST} -T "${title}" -f ${userAccounts} -H -10 -W -20 2> ${output}
selected=$?
test $selected = 255 && exit 1

answer=`sed -e 's/^[ ]*//' -e 's/[ ]*$//' ${output}`

#
# Display the account information.
#
if [ -n "$answer" ]; then
    displayAccountInformation $answer $tmpPass
fi

#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}


#!/bin/sh
# $Id: calendar.sh,v 1.1 2013/12/24 18:06:17 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the celendar widget.
#

#
# Create some global variables.
#
CDK_CALENDAR="${CDK_BINDIR=..}/cdkcalendar"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

date="${TMPDIR=/tmp}/cal.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

xpos=CENTER
ypos=CENTER

#
# Get today's date.
#
day=`date +%d`
month=`date +%m`
year=`date +%Y`

#
# Chop up the command line.
#
set -- `getopt d:m:y:X:Y: $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -d) day=$2; shift 2;;
         -m) month=$2; shift 2;;
         -y) year=$2; shift 2;;
         -X) xpos=$2; shift 2;;
         -Y) ypos=$2; shift 2;;
         --) shift; break;;
    esac
done

#
# Create the title and buttons.
#
title="<C><#HL(22)>
<C>Select a date
<C><#HL(22)>"
buttons=" OK
Cancel "

#
# Create the calendar widget.
#
${CDK_CALENDAR} -B "${buttons}" -d ${day} -m ${month} -y ${year} -T "${title}" -X ${xpos} -Y ${ypos} -O ${date} -S
selected=$?
test $selected = 255 && exit 1

answer=`cat ${date}`

#
# Create the message for the label widget.
#
echo "<C>You chose the following date" > ${tmp}
echo " " >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo "<C>${answer}" >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${date}


#!/bin/sh
# $Id: dialog.sh,v 1.1 2013/12/24 18:06:18 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the dialog widget.
#

#
# Create some global variables.
#
CDK_DIALOG="${CDK_BINDIR=..}/cdkdialog"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/dialog_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the message for the scrolling list.
#
message="<C>Pick which command
<C>you wish to run."

#
# Create the button labels.
#
commands="who
w
uptime
date
pwd
whoami
df
fortune"

#
# Create the dialog box.
#
${CDK_DIALOG} -m "${message}" -B "${commands}" 2> ${output}
selection=$?
if [ "$selection" -eq 255 ]; then
   exit;
fi

#
# Create the message for the label widget.
#
echo "<C>Here is the result of the command" > ${tmp}
echo " " >> ${tmp}

#
# Determine which command to run.
#
if [ "${selection}" -eq 0 ]; then
   who | awk '{printf "%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 1 ]; then
   w | awk '{printf "%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 2 ]; then
   uptime | awk '{printf "<C>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 3 ]; then
   date | awk '{printf "<C>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 4 ]; then
   pwd | awk '{printf "<C>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 5 ]; then
   whoami | awk '{printf "<C>%s\n", $0}' >> ${tmp}
elif [ "${selection}" -eq 6 ]; then
   #
   # We will use the label demo to do this.
   #
   ./label.sh
   rm -f ${tmp} ${output} ${fileSystemList}
   exit 0;
elif [ "${selection}" -eq 7 ]; then
   fortune | awk '{printf "%s\n", $0}' >> ${tmp}
fi
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output} ${fileSystemList}


#!/bin/sh
# $Id: entry.sh,v 1.1 2013/12/24 18:06:19 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the entry widget.
#

#
# Create some global variables.
#
CDK_ENTRY="${CDK_BINDIR=..}/cdkentry"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/entry_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the title.
#
title="<C>  Type a simple string.  "
buttons=" OK
 Cancel "

#
# Create the entry box.
#
${CDK_ENTRY} -f 20 -T "${title}" -B "${buttons}" -F "</5>_ " -O ${output} -S
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Create the message for the label widget.
#
echo "<C>Here is the string you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output}


#!/bin/sh
# $Id: fselect.sh,v 1.1 2013/12/24 18:06:20 vegogine Exp $

#
# Description:
#	This demonstrates the CDK command line
#	interface to the file selection widget.
#

#
# Create some global variables.
#
CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

directory="."
label="File: "
title="<C>Select a file"

buttons=" OK
 Cancel "

xpos="CENTER"
ypos="CENTER"

width=0
height=-5

tmp="${TMPDIR=/tmp}/tmp.$$"
file="${TMPDIR=/tmp}/fs.$$"

#
# Chop up the command line.
#
set -- `getopt d:L:T:X:Y:W:H: $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -d) directory=$2; shift 2;;
         -T) title=$2; shift 2;;
         -L) label=$2; shift 2;;
         -X) xpos=$2; shift 2;;
         -Y) ypos=$2; shift 2;;
         -W) width=$2; shift 2;;
         -H) height=$2; shift 2;;
         --) shift; break;;
    esac
done

#
# Create the CDK file selector.
#
${CDK_FSELECT} -d "${directory}" -T "${title}" -L "${label}" -X ${xpos} -Y ${ypos} -W ${width} -H ${height} -B "${buttons}" 2> ${file}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${file}`

#
# Diplay the file the user selected.
#
echo "<C>You selected the following file" > ${tmp}
echo " " >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo "<C></B>${answer}" >> ${tmp}
echo "<C><#HL(10)>" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Press </R>space<!R> to continue." >> ${tmp}

${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${file}


#!/bin/sh
# $Id: itemlist.sh,v 1.1 2013/12/24 18:06:21 vegogine Exp $

#
# Description:
# 		This demonstrates the CDK command line
# interface to the itemlist list widget.
#

#
# This gets the password file.
#
getPasswordFile()
{
   system=$1
   file=$2

   #
   # Depeding on the system, get the password file
   # using nicat, ypcat, or just plain old /etc/passwd
   #
   if [ "$system" = "NIS" ]; then
      niscat passwd.org_dir | sort > $file
   elif [ "$system" = "YP" ]; then
      ypcat passwd | sort > $file
   else
      sort /etc/passwd > $file
   fi
}

#
# This displays account information.
#
displayAccountInformation()
{
   userAccount=$1
   passwordFile=$2

   #
   # Get the user account information.
   #
   line=`grep "^${userAccount}" $passwordFile`
   uid=`echo $line | cut -d: -f3`
   gid=`echo $line | cut -d: -f4`
   info=`echo $line | cut -d: -f5`
   home=`echo $line | cut -d: -f6`
   shell=`echo $line | cut -d: -f7`

   #
   # Create the label message information.
   #
   accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID    : </U>${uid}
GID    : </U>${gid}
Info   : </U>${info}
Home   : </U>${home}
Shell  : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"

   #
   # Create the popup label.
   #
   ${CDK_LABEL} -m "${accountMessage}" -p " "
}

#
# Create some global variables.
#
CDK_ITEMLIST="${CDK_BINDIR=..}/cdkitemlist"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/output.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"

TYPE="Other";

#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -n) TYPE="YP"; shift;;
         -N) TYPE="NIS"; shift;;
         -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
         --) shift; break;;
    esac
done

#
# Create the message for the item list.
#
title="<C>Pick an account you want to view."
label="Account Name "
buttons=" OK
 Cancel "

#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"

#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "</R>%s\n", $1}' $tmpPass | sort > ${userAccounts}

#
# Create the item list.
#
${CDK_ITEMLIST} -d 3 -L "${label}" -T "${title}" -B "${buttons}" -f "${userAccounts}" 2> ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Display the account information.
#
displayAccountInformation $answer $tmpPass

#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}


#!/bin/sh
# $Id: label.sh,v 1.1 2013/12/24 18:06:22 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the label widget.
#

#
# Create some global variables.
#
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

dfTmp="${TMPDIR=/tmp}/label.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"
top="${TMPDIR=/tmp}/dfTop.$$"
bottom="${TMPDIR=/tmp}/dfBottom.$$"

#
# Get the filesystem information.
#
getDiskInfo()
{
   fileName=$1;
   command="df"

   #
   # Determine the type of operating system.
   #
   machine=`uname -s`
   if [ "$machine" = "SunOS" ]; then
      level=`uname -r`

      if [ "$level" -gt 4 ]; then
         command="df -kl"
      fi
   else
      if [ "$machine" = "AIX" ]; then
         command="df -i"
      fi
   fi

   #
   # Run the command.
   #
   ${command} > ${fileName}
}

#
# Get the disk information.
#
getDiskInfo ${dfTmp}

#
# Bold the first line of the df command.
#
head -1 ${dfTmp} | awk '{printf "</B>%s\n", $0}' > ${top}
tail +2 ${dfTmp} > ${bottom}

#
# Create the message for the label widget.
#
echo "<C>This is the current" > ${tmp}
echo "<C>status of your local filesystems." >> ${tmp}
echo "<C><#HL(2)>" >> ${tmp}
cat ${top} >> ${tmp}
cat ${bottom} >> ${tmp}
echo "<C><#HL(2)>" >> ${tmp}
echo "" >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f "${tmp}" -p " " -c "ls" -S

#
# Clean up.
#
rm -f ${tmp} ${output} ${dfTmp} ${top} ${bottom}


#!/bin/sh
# $Id: matrix.sh,v 1.4 2005/12/27 17:07:00 tom Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the matrix widget.
#

#
# Create some global variables.
#
CDK_MATRIX="${CDK_BINDIR=..}/cdkmatrix"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

fileSystemList="${TMPDIR=/tmp}/fsList.$$"
info="${TMPDIR=/tmp}/fsInfo.$$"
diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Get the filesystem information.
#
getDiskInfo()
{
   fileName=$1;
   command="df"

   #
   # Determine the type of operating system.
   #
   machine=`uname -s`
   if [ "$machine" = "SunOS" ]; then
      level=`uname -r`

      if [ "$level" -gt 4 ]; then
         command="df -kl"
      fi
   else
      if [ "$machine" = "AIX" ]; then
         command="df -i"
      fi
   fi

   #
   # Run the command.
   #
   ${command} > ${fileName}
}

#
# Get the disk information.
#
getDiskInfo ${diskInfo}

#
# Create the row titles.
#
rowTitles=`tail +2 ${diskInfo} | awk '{printf "%s\n", $1}'`

#
# Create the column titles.
#
colTitles="KBytes
Used
Avail
Capacity
Mounted on"

#
# Define the matrix title.
#
title="<C></U>Current Filesystem Information"

#
# Create the data file to fill in the matrix.
#
tail +2 ${diskInfo} | awk '{printf "%s%s%s%s%s\n", $2, $3, $4, $5, $6}' > ${info}

#
# Set the widths of the columns.
#
colWidths="5
5
5
5
5"

#
# Set the cells as uneditable.
#
types="VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY
VIEWONLY"

buttons=" OK
 Cancel "

#
# Start the matrix.
#
${CDK_MATRIX} -r "${rowTitles}" -c "${colTitles}" -v 3 -w "${colWidths}" -d "${info}" -t "${types}" -T "${title}" -B "${buttons}" -O"$tmp"
selected=$?
test $selected = 255 && exit 1

#
# Create the message for the label widget.
#
echo "<C>You chose button #${selected}" > ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f "${tmp}" -p " "

#
# Clean up.
#
rm -f ${info} ${fileSystemList} ${tmp} ${diskInfo}


#!/bin/sh
# $Id: mentry.sh,v 1.1 2013/12/24 18:06:23 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the multiple line entry widget.
#

#
# Create some global variables.
#
CDK_MENTRY="${CDK_BINDIR=..}/cdkmentry"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/mentry_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the title.
#
title="<C>Type in a short message."
buttons=" OK
 Cancel "

#
# Create the mentry box.
#
${CDK_MENTRY} -s 5 -v 10 -f 20 -T "${title}" -B "${buttons}" -F '_' -O ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Create the message for the label widget.
#
echo "<C>Here is the message you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output}


#!/bin/sh
# $Id: radio.sh,v 1.1 2013/12/24 18:06:24 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the radio widget.
#

#
# Create some global variables.
#
CDK_RADIO="${CDK_BINDIR=..}/cdkradio"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

fileSystemList="${TMPDIR=/tmp}/fsList.$$"
diskInfo="${TMPDIR=/tmp}/diskInfo.$$"
output="${TMPDIR=/tmp}/radio_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Get the filesystem information.
#
getDiskInfo()
{
   fileName=$1;
   command="df"

   #
   # Determine the type of operating system.
   #
   machine=`uname -s`
   if [ "$machine" = "SunOS" ]; then
      level=`uname -r`

      if [ "$level" -gt 4 ]; then
         command="df -kl"
      fi
   else
      if [ "$machine" = "AIX" ]; then
         command="df -i"
      fi
   fi

   #
   # Run the command.
   #
   ${command} > ${fileName}
}

#
# Create the title for the scrolling list.
#
title="<C>Pick a filesystem to view."
buttons=" OK
 Cancel "

#
# Get a list of the local filesystems.
#
getDiskInfo ${diskInfo}

#
# Create the file system list.
#
grep "^/" ${diskInfo} | awk '{printf "%s\n", $1}' > ${fileSystemList}

#
# Create the radio list.
#
${CDK_RADIO} -T "${title}" -f "${fileSystemList}" -c "*" -B "${buttons}" 2> $output
selected=$?
test $selected = 255 && exit 1

#
# The selection is now in the file $output.
#
fs=`cat ${output}`
echo "<C></R>File Statistics on the filesystem ${fs}" > ${tmp}
echo " " >> ${tmp}
grep "${fs}" ${diskInfo} | awk '{printf "%s\n", $0}' >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output} ${fileSystemList} ${diskInfo}


#!/bin/sh
# $Id: scale.sh,v 1.1 2013/12/24 18:06:24 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the scale widget.
#

#
# Create some global variables.
#
CDK_SCALE="${CDK_BINDIR=..}/cdkscale"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/scale_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the title.
#
title="<C>Enter a value using the cursor keys."
label="</R>Value"
buttons=" OK
 Cancel "

#
# Create the scale box.
#
${CDK_SCALE} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -B "${buttons}" -O ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Create the message for the label widget.
#
echo "<C>Here is the value you selected" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output}


#!/bin/sh
# $Id: scroll.sh,v 1.1 2013/12/24 18:06:25 vegogine Exp $

#
# Description:
# 		This demonstrates the CDK command line
# interface to the scrolling list widget.
#

#
# This gets the password file.
#
getPasswordFile()
{
   system=$1
   file=$2

   #
   # Depeding on the system, get the password file
   # using nicat, ypcat, or just plain old /etc/passwd
   #
   if [ "$system" = "NIS" ]; then
      niscat passwd.org_dir > $file
   elif [ "$system" = "YP" ]; then
      ypcat passwd > $file
   else
      cp /etc/passwd $file
   fi
}

#
# This displays account information.
#
displayAccountInformation()
{
   userAccount=$1
   passwordFile=$2

   #
   # Get the user account information.
   #
   line=`grep "^${userAccount}" $passwordFile`
   uid=`echo $line | cut -d: -f3`
   gid=`echo $line | cut -d: -f4`
   info=`echo $line | cut -d: -f5`
   home=`echo $line | cut -d: -f6`
   shell=`echo $line | cut -d: -f7`

   #
   # Create the label message information.
   #
   accountMessage="<C></U>Account
<C><#HL(30)>
Account: </U>${userAccount}
UID    : </U>${uid}
GID    : </U>${gid}
Info   : </U>${info}
Home   : </U>${home}
Shell  : </U>${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"

   #
   # Create the popup label.
   #
   ${CDK_LABEL} -m "${accountMessage}" -p " "
}

#
# Create some global variables.
#
CDK_SCROLL="${CDK_BINDIR=..}/cdkscroll"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

tmpPass="${TMPDIR=/tmp}/sl.$$"
output="${TMPDIR=/tmp}/output.$$"
userAccounts="${TMPDIR=/tmp}/ua.$$"

TYPE="Other"

#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -n) TYPE="YP"; shift;;
         -N) TYPE="NIS"; shift;;
         -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
         --) shift; break;;
    esac
done

#
# Create the message for the scrolling list.
#
title="<C><#HL(30)>
<C>Pick an account you want to view.
<C><#HL(30)>"
buttons=" OK
 Cancel "

#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"

#
# Get the user account from the password file.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}

#
# Create the scrolling list.
#
${CDK_SCROLL} -T "${title}" -f ${userAccounts} -n -B "${buttons}" 2> ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Display the account information.
#
displayAccountInformation $answer $tmpPass

#
# Clean up.
#
rm -f ${output} ${tmpPass} ${userAccounts}


#!/bin/sh
# $Id: selection.sh,v 1.1 2013/12/24 18:06:25 vegogine Exp $

#
# Description:
#	This demonstrates the CDK command line
#	interface to the selection widget.
#

#
# This gets the password file.
#
getPasswordFile()
{
   system=$1
   file=$2

   #
   # Depending on the system, get the password file
   # using nicat, ypcat, or just plain old /etc/passwd
   #
   if [ "$system" = "NIS" ]; then
      niscat passwd.org_dir > $file
   elif [ "$system" = "YP" ]; then
      ypcat passwd > $file
   else
      cp /etc/passwd $file
   fi
}

#
# This displays account information.
#
displayAccountInformation()
{
   totalSelections=$1
   currentSelection=$2
   userAccount=$3
   passwordFile=$4

   #
   # Get the user account information.
   #
   line=`grep "^${userAccount}" $passwordFile`
   uid=`echo $line | cut -d: -f3`
   gid=`echo $line | cut -d: -f4`
   info=`echo $line | cut -d: -f5`
   home=`echo $line | cut -d: -f6`
   shell=`echo $line | cut -d: -f7`

   #
   # Create the label message information.
   #
   accountMessage="<C>Account ${currentSelection}/${totalSelections}
<C><#HL(30)>
Account: ${userAccount}
UID    : ${uid}
GID    : ${gid}
Info   : ${info}
Home   : ${home}
Shell  : ${shell}
<C><#HL(30)>
<C>Hit </R>space<!R> to continue"

   #
   # Create the popup label.
   #
   ${CDK_LABEL} -m "${accountMessage}" -p " "
}

#
# Define where the CDK widgets are.
#
CDK_SELECTION="${CDK_BINDIR=..}/cdkselection"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

TYPE="Other"

#
# Define the output files.
#
accountList="${TMPDIR=/tmp}/accList.$$"
userAccounts="${TMPDIR=/tmp}/userAccList.$$"
output="${TMPDIR=/tmp}/selection_output.$$"
tmpPass="${TMPDIR=/tmp}/ps.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Chop up the command line.
#
set -- `getopt nNh $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -n) TYPE="YP"; shift;;
         -N) TYPE="NIS"; shift;;
         -h) echo "$0 [-n YP] [-N NIS+] [-h]"; exit 0;;
         --) shift; break;;
    esac
done

#
# Create the message for the selection list.
#
title="<C>Pick a user account to view."

#
# Get the password file and stick it into the temp file.
#
getPasswordFile "${TYPE}" "$tmpPass"

#
# Create the user account list.
#
awk 'BEGIN {FS=":"} {printf "%s\n", $1}' $tmpPass | sort > ${userAccounts}
awk '{printf "<C>%s\n", $1}' ${userAccounts} > ${accountList}
accounts=`cat ${userAccounts}`

#
# Create the choices list.
#
choices="<C>No
<C> Yes "
buttons=" OK
 Cancel "

#
# Create the selection list.
#
${CDK_SELECTION} -T "${title}" -f "${accountList}" -c "${choices}" -B "${buttons}"  2> $output
selected=$?
test $selected = 255 && exit 1

#
# Initialize the variables.
#
selection=""
value=""

#
# Count how many were selected.
#
count=`grep -c "^1" ${output}`
current=0

#
# Create the label.
#
for i in `cat ${output}`
do
   #
   # Since every other variable is value/selection, we
   # store every other value in the correct variable.
   #
   if [ "$value" = "" ]; then
      value="$i"
   else
      selection="$i"

      #
      # Only display the selected accounts.
      #
      if [ "$value" -eq 1 ]; then
         #
         # Increment our counter.
         #
         current=`expr $current + 1`

         #
         # Display the account information.
         #
         displayAccountInformation $count $current $selection $tmpPass
      fi

      #
      # Reset the variables.
      #
      value=""
      selection=""
   fi
done

#
# Clean up.
#
rm -f ${accountList} ${userAccounts} ${output} ${tmpPass} ${tmp}


#!/bin/sh
# $Id: slider.sh,v 1.1 2013/12/24 18:06:25 vegogine Exp $

#
# Description:
#	This demonstrates the CDK command line
#	interface to the slider widget.
#

#
# Create some global variables.
#
CDK_SLIDER="${CDK_BINDIR=..}/cdkslider"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/slider_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the title.
#
title="<C>Enter a value using the cursor keys"
label="Value: "
buttons=" OK
 Cancel "

#
# Create the slider box.
#
${CDK_SLIDER} -f 20 -l 0 -h 100 -i 5 -L "${label}" -T "${title}" -F "</R>*" -B "${buttons}" -O ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Create the message for the label widget.
#
echo "<C>Here is the value you selected" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output}


#!/bin/sh
# $Id: template.sh,v 1.1 2013/12/24 18:06:26 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the template widget.
#

#
# Create some global variables.
#
CDK_TEMPLATE="${CDK_BINDIR=..}/cdktemplate"
CDK_LABEL="${CDK_BINDIR=..}/cdklabel"

output="${TMPDIR=/tmp}/template_output.$$"
tmp="${TMPDIR=/tmp}/tmp.$$"

#
# Create the title.
#
title="<C>               Type in the
<C>IP Address for this machine."
buttons=" OK
 Cancel "

#
# Create the template box.
#
${CDK_TEMPLATE} -p "###.###.###.###" -o "___.___.___.___" -T "${title}" -P -B "${buttons}" 2> ${output}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${output}`

#
# Create the message for the label widget.
#
echo "<C>Here is the IP you typed in" > ${tmp}
echo " " >> ${tmp}
echo "<C></R>${answer}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>You chose button #${selected}" >> ${tmp}
echo " " >> ${tmp}
echo "<C>Hit </R>space<!R> to continue." >> ${tmp}

#
# Create the label widget to display the information.
#
${CDK_LABEL} -f ${tmp} -p " "

#
# Clean up.
#
rm -f ${tmp} ${output}


#!/bin/sh
# $Id: viewer.sh,v 1.1 2013/12/24 18:06:26 vegogine Exp $

#
# Description:
#		This demonstrates the CDK command line
# interface to the viewer widget.
#

#
# Create some global variables.
#
CDK_FSELECT="${CDK_BINDIR=..}/cdkfselect"
CDK_VIEWER="${CDK_BINDIR=..}/cdkviewer"

tmp="${TMPDIR=/tmp}/tmp.$$"
file="${TMPDIR=/tmp}/fs.$$"

directory="."
xpos=CENTER
ypos=CENTER
width="-2"
height="0"
interpret=0

#
# Chop up the command line.
#
set -- `getopt d:x:y:w:h:i $*`
if [ $? != 0 ]
then
   echo $USAGE
   exit 2
fi
for c in $*
do
    case $c in
         -d) directory=$2; shift 2;;
         -x) xpos=$2; shift 2;;
         -y) ypos=$2; shift 2;;
         -w) width=$2; shift 2;;
         -h) height=$2; shift 2;;
         -i) interpret=1; shift 1;;
         --) shift; break;;
    esac
done

#
# Create the CDK file selector.
#
${CDK_FSELECT} -T "<C>Select a file" -d "${directory}" 2> ${file}
selected=$?
test $selected = 255 && exit 1

answer=`cat ${file}`

#
# Create the title and buttons for the viewer.
#
title="<C>CDK File Viewer Widget
<C></U>${answer}"
buttons="OK"

#
# Create the file viewer.
#
if [ "$interpret" -eq 1 ]; then
   ${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -i -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}"
else
   ${CDK_VIEWER} -f "${answer}" -T "${title}" -B "${buttons}" -X ${xpos} -Y ${ypos} -H "${height}" -W "${width}" -B "${buttons}"
fi

#
# Clean up.
#
rm -f ${tmp} ${file}