#!/bin/sh
# a2pswrap
#
# Copyright (c) 2000 SuSE GmbH Nuernberg, Germany.  All rights reserved.
#
# Author: Carsten Hoeger <choeger@suse.de>
#

test -f /var/spool/fax/etc/setup.cache || {
    cat<<EOF

FATAL ERROR: /var/spool/fax/etc/setup.cache is missing!

The file /var/spool/fax/etc/setup.cache is not present.  This
probably means the machine has not been setup using the faxsetup(1M)
command.  Read the documentation on setting up HylaFAX before you
startup a server system.

EOF
    exit 1
}

. /var/spool/fax/etc/setup.cache

MED=$1

#
# Resolve the default media
#
if [ "$MED" == "default" ]; then
   MED=`$GREP "^default" $LIBDATA/pagesizes |$AWK '{print $2}'`
fi

MED=`$ECHO $MED | (LC_ALL=C; export LC_ALL; tr A-Z a-z)`

case "$MED" in
na-let)
   MEDIA=letter;;
us-leg)
   MEDIA=legal;;
us-exe)
   MEDIA=Executive;;
us-led)
   MEDIA=ledger;;
a3|a4|a5|a6|a4)
   MEDIA=$MED;;
*) echo 1>&2 "$0: Unsupported page media: $MED";
   exit 254;;
esac

a2ps -o $2 -1 -R -f 11 -B -M $MEDIA --borders=no -s 1 \
     --prologue=bold < $3 2> /dev/null $4
