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