:
#	streaming tape i/o utility
#	copyright (c) 1987 by Bell Technologies
#

#ident	"@(#)cptape.sh	2.0"

DEV=${DEV:-/dev/tape}
IN=${IN:-"-icduvm"}
OUT=${OUT:-"-ocv"}
TABLE=${TABLE:-"-ictv"}
SIZE=${SIZE:-600}
OPT=NONE

while true		# process options
do
  case $1 in
	-i) OPT=$IN; shift;
		;;
	-o) OPT=$OUT; shift;
		;;
	-t) OPT=$TABLE; shift;
		;;
	-f) if [ $# -gt 1 ]
	    then
		DEV=$2; shift; shift;
	    else
		OPT=NONE
		echo $0: missing devname on -f option
		break
	    fi
		;;
	-*) OPT=NONE
	    echo $0: unknown option: $1
	    break
		;;
	*) break
		;;
  esac
done

case $OPT in
	$OUT)
		find $* -print | cpio $OPT -C `expr $SIZE '*' 1024` -O $DEV
		;;
	$IN | $TABLE)
		cpio $OPT -C `expr $SIZE '*' 1024` -I $DEV $*
		;;
	*)
		echo usage: $0 "-{i|o|t}" "[-f devname]" files . . .
		exit 1
esac
