#!/bin/sh

#
# mkfilter - make feature-filters for you printer
#

FILTER_DIR=$APS_BASEDIR/filter

PRINTER=$1
PAPER=$2
COLOR=$3

if [ ! -d $FILTER_DIR ]; then
	echo "cannot find the directory for printerfilter (symlinks)"
	echo "creating $FILTER_DIR..."
	mkdir -p $FILTER_DIR
fi

cd $FILTER_DIR

set -x 

case $COLOR in
	c|C)		color="color mono"	;;
	*)		color="mono"		;;
esac

for COLOR in $color
do
    for method in auto ascii
    do
        if [ -f aps-${PRINTER}-${PAPER}-${method}-${COLOR} ]; then
		rm -f aps-${PRINTER}-${PAPER}-${method}-${COLOR}
	fi
        ln -s ../bin/apsfilter aps-${PRINTER}-${PAPER}-${method}-${COLOR}
    done
done

# and now a raw filter to print data unprocessed ...

if [ -f aps-${PRINTER}-${PAPER}-raw ]; then
	rm -f aps-${PRINTER}-${PAPER}-raw
fi
ln -s ../bin/apsfilter ./aps-${PRINTER}-${PAPER}-raw
