#!/bin/sh
# Copyright (c) 1991-1997 Adobe Systems, Incorporated. All rights reserved.
# Shell file to execute external filters.
#
# Edit as needed to execute other filters; 
# The cases below should match the external export filters in the file
# fminit/filterlist
#
# Inputs are:
# $1 = input file to be filtered (full path, example: /usr/drf/foo.bar )
# $2 = output file from filter   (full path, example: /usr/drf/foo.tmp )
# $3 = output file's path         (           example: /usr/drf         )
# $4 = fminit directory
# $5 = bin directory
# $6 = user interface language
# $7 = filter id, must match the filter id defined in fminit/filterlist
# $8 = informat, as registered in the filterlist/API clients file
# $9 = outformat, as registered in the filterlist/API clients file
# See what the filter id is, and run the appropriate program

: ${FMARCH:?}

case " $FMDEBUG " in
*' export '*)
	echo "-> $0 $*" >&2
	set -x
	;;
esac

T=${TMPDIR:-/tmp}
sdir=$5/scripts

#
# NB if your filterid is shorter than 8 characters, FrameMaker will
# pad it on the right with white space (e.g., vendor ACME, format FOO
# becomes "ACMEFOO ").  Use 'ACMEFOO ', and not ACMEFOO, to match
# $7 in the following case statement.
#
case $7 in
'FFLTMWPB') $5/miftowp <"$1" >$T/$$.wp
	mv $T/$$.wp "$2"  ;;
'FFLTMIAF') $5/miftoiaf <"$1" >$T/$$.iaf
	mv $T/$$.iaf "$2" ;;
'FFLTMRTF') $5/miftortf -w <"$1" >$T/$$.rtf
	mv $T/$$.rtf "$2" ;;
# imagemark export filters
IMAG*)
	$sdir/fminso "$8" "$9" "$1" $T/$$.img || exit 1
	mv $T/$$.img "$2"
	;;
# Ivy systems
IVY*)
        echo "dir is $5"
        $5/$FMARCH/mif2rtfj  "$1" $T/$$.rtf && mv $T/$$.rtf "$2"
        ;;

# Itedo
'ISO '????)
	$5/$FMARCH/isoconverter "$1" $T/$$.itdo -`echo $7 | sed 's/ISO //'`
	mv $T/$$.itdo "$2"
	;;
# Word-for-Word
AW4W*)
	$5/miftow4w `echo $7 | sed s/AW4W//` "$1" $T/$$.w4w && mv $T/$$.w4w "$2"
	;;
*)
	echo "No filters matched!">&2
	exit 1
esac
