summaryrefslogtreecommitdiffstats
path: root/brother-dcp9010cn/brlpdwrapperdcp9010cn
blob: 960fb896dcb447b81ed98bec90482646425a60e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/sh
#
# Copyright (C) 2005 Brother. Industries, Ltd.
#                                    Ver1.10

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA
#

LOGFILE="/dev/null"
LOGLEVEL="1"
LOGCLEVEL="7"
DEBUG=0
NUPENABLE=1
LOG_LATESTONLY=1
errorcode=0

if [ $DEBUG != 0 ]; then
    LOGFILE=/tmp/br_cupsfilter_debug_log
fi

PPDC=`printenv | grep "PPD="`
PPDC=`echo $PPDC | sed -e 's/PPD=//'`

if [ "$PPDC" = "" ]; then
    PPDC="/usr/share/cups/model/brdcp9010cn.ppd"
fi


if [ $LOGFILE != "/dev/null" ]; then
  if [ $LOG_LATESTONLY == "1" ]; then
    rm -f $LOGFILE
    date                                                           >$LOGFILE
  else
    if [ -e $LOGFILE ]; then
	    date                                                        >>$LOGFILE
    else
	    date                                                        >$LOGFILE
    fi
  fi
    echo "arg0 = $0"                                           >>$LOGFILE
    echo "arg1 = $1"                                           >>$LOGFILE
    echo "arg2 = $2"                                           >>$LOGFILE
    echo "arg3 = $3"                                           >>$LOGFILE
    echo "arg4 = $4"                                           >>$LOGFILE
    echo "arg5 = $5"                                           >>$LOGFILE
    echo "arg6 = $6"                                           >>$LOGFILE
    echo "PPD  = $PPD"                                         >>$LOGFILE
fi

INPUT_TEMP_PS=`mktemp /tmp/br_input_ps.XXXXXX`

nup="cat"
if [ "" != '' ] && [ $NUPENABLE != 0 ]; then

	if   [ "" != '' ]; then
		nup="psnup -64"
	elif [ "" != '' ]; then
		nup="psnup -32"
	elif [ "" != '' ]; then
		nup="psnup -25"
	elif [ "" != '' ]; then
		nup="psnup -16"
	elif [ "" != '' ]; then
		nup="psnup -8"
	elif [ "" != '' ]; then
		nup="psnup -6"
	elif [ "" != '' ]; then
		nup="psnup -4"
	elif [ "" != '' ]; then
		nup="psnup -2"
	elif [ "" != '' ]; then
		nup="cat"
	fi
	echo   "NUP=$nup"                                      >>$LOGFILE
   if [ -e /usr/bin/psnup ]; then
       if [ $# -ge 7 ]; then
	       cat $6  | $nup > $INPUT_TEMP_PS
       else
	       cat       | $nup > $INPUT_TEMP_PS
       fi
   else
       if [ $# -ge 7 ]; then
	       cp $6  $INPUT_TEMP_PS
       else
	       cat    > $INPUT_TEMP_PS
       fi
   fi
else
   if [ $# -ge 7 ]; then
      cp $6  $INPUT_TEMP_PS
   else
      cat    > $INPUT_TEMP_PS
   fi
fi
if [ -e "/usr/local/Brother/Printer/dcp9010cn/lpd/filterdcp9010cn" ]; then
       :
else
    echo "ERROR: /usr/local/Brother/Printer/dcp9010cn/lpd/filterdcp9010cn does not exist"   >>$LOGFILE
    errorcode=30
    exit
fi

CUPSOPTION=`echo "$5 Copies=1" | sed -e 's/BrMirror=OFF/MirrorPrint=OFF/' -e 's/BrMirror=ON/MirrorPrint=ON/' -e 's/BrChain/Chain/' -e 's/BrBrightness/Brightness/' -e 's/BrContrast/Contrast/' -e 's/BrHalfCut/HalfCut/' -e 's/BrAutoTapeCut/AutoCut/' -e 's/BrHalftonePattern/Halftone/' -e 's/Binary/Binary/' -e 's/Dither/Dither/' -e 's/ErrorDiffusion/ErrorDiffusion/' -e 's/BrSheets/Sheets/' -e 's/multiple-document-handling/Collate/' -e 's/separate-documents-collated-copies/ON/' -e 's/separate-documents-uncollated-copies/OFF/'`
if [ -e "/usr/local/Brother/Printer/dcp9010cn/cupswrapper/brcupsconfpt1" ]; then
  if [ $DEBUG = 0 ]; then
     /usr/local/Brother/Printer/dcp9010cn/cupswrapper/brcupsconfpt1  DCP9010CN  $PPDC 0 "$CUPSOPTION" "dcp9010cn">> /dev/null
  else
     /usr/local/Brother/Printer/dcp9010cn/cupswrapper/brcupsconfpt1  DCP9010CN  $PPDC $LOGCLEVEL "$CUPSOPTION" "dcp9010cn">>$LOGFILE
  fi
fi

if [ $DEBUG -lt 10 ]; then
    cat    $INPUT_TEMP_PS | /usr/local/Brother/Printer/dcp9010cn/lpd/filterdcp9010cn "$$" "CUPS" "USB"

    if [ $LOGLEVEL -gt 2 ];  then
	   if [ $LOGFILE != "/dev/null" ]; then
	     echo ""                                                >>$LOGFILE
	     echo "    ------PostScript Data-------"                >>$LOGFILE
	     cat    $INPUT_TEMP_PS                                  >>$LOGFILE
	   fi
    fi
fi
rm -f  $INPUT_TEMP_PS

exit