3b8dbcc
#!/bin/bash
3b8dbcc
## Copyright (C) 2003-2006 Red Hat, Inc.
3b8dbcc
## Copyright (C) 2003-2006 Tim Waugh <twaugh@redhat.com>
3b8dbcc
3b8dbcc
## This program is free software; you can redistribute it and/or modify
3b8dbcc
## it under the terms of the GNU General Public License as published by
3b8dbcc
## the Free Software Foundation; either version 2 of the License, or
3b8dbcc
## (at your option) any later version.
3b8dbcc
3b8dbcc
## This program is distributed in the hope that it will be useful,
3b8dbcc
## but WITHOUT ANY WARRANTY; without even the implied warranty of
3b8dbcc
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3b8dbcc
## GNU General Public License for more details.
3b8dbcc
3b8dbcc
## You should have received a copy of the GNU General Public License
3b8dbcc
## along with this program; if not, write to the Free Software
3b8dbcc
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3b8dbcc
3b8dbcc
if [ $# == 0 ]; then
3b8dbcc
  echo >&2 "ERROR: $0 job-id user title copies options [file]"
3b8dbcc
  exit 1
3b8dbcc
fi
3b8dbcc
3b8dbcc
# Extract the papersize
3b8dbcc
SENDFF=`grep '^\*DefaultSendFF' "$PPD" | cut -d\  -f2`
3b8dbcc
COPIES=1
3b8dbcc
if [ $# -ge 4 ]; then
3b8dbcc
  COPIES="$4"
3b8dbcc
fi
3b8dbcc
3b8dbcc
if [ "$COPIES" -gt 1 ] && [ $# -lt 6 ]; then
3b8dbcc
  unset TMPFILE
3b8dbcc
  trap -- 'rm -f "$TMPFILE"' EXIT
3b8dbcc
  TMPFILE=$(mktemp ${TMPDIR:-/tmp}/textonly.XXXXXX)
3b8dbcc
  cat > "$TMPFILE"
3b8dbcc
else
3b8dbcc
  TMPFILE="$6"
3b8dbcc
fi
3b8dbcc
3b8dbcc
while [ "$COPIES" -gt 0 ]; do
3b8dbcc
  # Just translate LF->CRLF at the moment, until the PPD has options added.
3b8dbcc
  sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE"
3b8dbcc
3b8dbcc
  if [ "$SENDFF" == "True" ]
3b8dbcc
    then
3b8dbcc
    echo -ne \\14
3b8dbcc
  fi
3b8dbcc
3b8dbcc
  COPIES=$(($COPIES - 1))
3b8dbcc
done