#!/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 import 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 = input 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

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

: ${FMARCH:?}
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
# graphics import filters
IMAG*)
	# In fmexport we carefully filter into a tmp file and copy that to $2
	# only if the filter succeeded.  Don't bother here because $2 *is*
	# a tmp file.
	$sdir/fminso "$8" "$9" "$1" "$2"
	;;
'FFLTPICT') $5/pict2mif  <"$1" > "$2" ;;
# Word-4-Word
AW4W????) exec $5/w4wtomif `echo $7 | sed s/AW4W//` "$1" "$2" ;;
# Ivy filters
IVY?J?W?) exec $5/$FMARCH/jbw2mif "$1" "$2";;
IVY?RTF?) exec $5/$FMARCH/rtfj2mif "$1" "$2";;
# Itedo
'ISO '????) exec $5/$FMARCH/isoconverter "$1" "$2" -FrameVector ;;
# document import filters
'FFLTWDBN') $5/word2mif -d <"$1" > "$2" ;;
'FFLTWPBN') $5/wptomif  <"$1" > "$2" ;;
'FFLTIAF ') $5/iaftomif  <"$1" > "$2" ;;
'FFLTDCA ') $5/dcatomif  <"$1" > "$2" ;;
'FFLTTRFF') $5/trofftomif <"$1" > "$2" ;;
'FFLTTRFA') $5/trofftomif -man <"$1" > "$2" ;;
'FFLTTRFE') $5/trofftomif -me <"$1" > "$2" ;;
'FFLTTRFS') $5/trofftomif -ms <"$1" > "$2" ;;
'FRAMMML ') $5/mmltomif -L$6 -I$3 -I~ -I$4 <"$1" >"$2";;
'FFLTTXIS') $5/is1tomif  <"$1" > "$2" ;;
'FFLTTXRM') $5/rm8tomif < "$1" > "$2" ;;
*)
	echo "No filters matched!">&2
	exit 1
	;;
esac
