#!/bin/sh
# @(#)iox	2.1 10/7/93 Export Module for DDES, Chromalink, and Scitex HS to tape 
#
# Copyright (c) 1991, 92, 93 Alias Full Color. All rights reserved.
# This is unpublished proprietary source code of Alias Full Color
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
# 

#trap "rm -f /tmp/dl.$$" 0

if [ $# -lt 3 ]
then
   echo "Usage: $0 Format Extension SourceFilename" 
   exit 0
fi

DEV_STR="$1_ct"
EXT=$2

CUSTOM=`alias2Dpath PRODUCT_CUSTOM`
DEVICE=/dev/9track
if [ -r $CUSTOM/tape_device ]
then
   DEVICE=`cat $CUSTOM/tape_device`
fi
SYSBIN=`alias2Dpath PRODUCT_SYSBIN`
BIN=`alias2Dpath PRODUCT_BIN`
VERSION=`alias2Dpath PRODUCT_VERSION`

FILENAME=$3
BASENAME=`basename $3`
DIRNAME=`dirname $3`

if $SYSBIN/dialog 500 100 350 450 \
"Eclipse $1 Interface $VERSION"<<EOF > /tmp/dl.$$
Job Name:
%s
Volume Name:
%s
Device
%s $DEVICE 

Write Tape Mark %b ON
(Use if this is the last image
 going onto this tape.)

Rewind when done %b ON

EOF
then
    . /tmp/dl.$$
    [ "$STRING0" = "" ] && STRING0=JOBNAME
    [ "$STRING1" = "" ] && STRING1=VOLNAME

    echo "Processing..."

    TAPE_STR="-tape_device $STRING2"

    umask 0
    echo "$STRING2" > $CUSTOM/tape_device
    chmod 666 $CUSTOM/tape_device 2>/dev/null

    $BIN/ecio $FILENAME -silent -dev $DEV_STR -job $STRING0 -vol $STRING1 -o .$EXT $TAPE_STR  `\`alias2Dpath PRODUCT_SYSBIN\`/SepPref`

    if [ "$CHECK0" = "1" ]
    then
       echo "MARK IT"
       mt -t $STRING2 weof
    fi

    if [ "$CHECK1" = "1" ]
    then
       echo "REWIND IT"
       mt -t $STRING2 rewind
    fi
else
    exit 1

fi
