#!/bin/sh
# options for dvips are passwd down

progname=`basename $0`
help()
{
  echo "Usage: $progname [-hi|-lo] file[.dvi] [options for dvips]"
  echo "  -hi: use high fax resolution (204x196) (default)"
  echo "  -lo: use low fax resolution (204x98)"
  echo
  echo "Example: $progname foo -l 2"
}

dvipsconf=dfaxhigh; res=204x196
case $1 in
  -hi) dvipsconf=dfaxhigh; res=204x196; shift;;
  -lo) dvipsconf=dfaxlo; res=204x98; shift;;
esac

case $# in
0)	help >&2
	exit 1 ;;
esac

NAME=`basename $1 .dvi`
dvips "$@" -P$dvipsconf -f |
  gs -q -dSAFER -sDEVICE=faxg3 -r$res -sOutputFile=$NAME-%03d.fax -sNOPAUSE -
