:
#	@(#) scanoff 23.3 91/10/30 
#
#	Copyright (C) 1991 The Santa Cruz Operation, Inc.
#		All Rights Reserved.
#	The information in this file is provided for the exclusive use of
#	the licensees of The Santa Cruz Operation, Inc.  Such users have the
#	right to use, modify, and incorporate this code into other products
#	for purposes authorized by the license agreement provided they include
#	this notice and the associated copyright notice with any such product.
#	The information in this file is provided "AS IS" without warranty.
#

TTYFILE="/etc/ttytype"

scanloop()
{
while [ $# -gt 0 ]
do
	# Look up the tty type for the required device in /etc/ttytype
	ttname=`echo $1 | sed 's:/dev/::p'`
	ttype=`awk '$2 == tname {print $1; exit}' tname=$ttname $TTYFILE`

	[ "$ttype" = "" -o "$ttype" = "unknown" ] && {
		echo "$0: cannot find $1 terminal type in $TTYFILE" >&2
		errcnt=`expr $errcnt + 1`
		shift; continue
	}

	[ -c "$1" ] && tput -T"$ttype" rmsc > "$1" && \
	stty -isscancode -xscancode < "$1" || {
		echo "$0: cannot set $1 scancode off" >&2
		errcnt=`expr $errcnt + 1`
	}
	shift
done
}

scan_off()
{
	tput rmsc && stty -isscancode -xscancode || {
		echo "$0: cannot set scancode off" >&2
		errcnt=1
	}
}

errcnt=0
case $# in
0) scan_off	;;
*) scanloop "$@";;
esac
exit $errcnt
