aboutsummaryrefslogtreecommitdiffstats
path: root/print/epsonepl/files/patch-ps2epl
blob: 6f13ed23e32ef2a6ec53ea4f0d5b1c375ea2b60f (plain) (blame)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
--- ps2epl.orig Wed Jan 29 11:19:06 2003
+++ ps2epl  Fri Feb 14 23:33:46 2003
@@ -1,11 +1,105 @@
 #!/bin/sh
 
+parse() {
+if [ ! -r "$1" ]; then
+   echo "${BASENAME}: Can't read config file '$1'!" >&2
+   exit 1
+fi
+sed -e 's/#.*//;
+   /^[[:space:]]*$/d;
+   s/^[[:space:]]*//;
+   s/[[:space:]]*$//;
+   s/^\([^[:space:]=]*\)[[:space:]=]*\(.*\)/\1 \2/' "$1" |
+while read var value
+do
+   case `echo ${var} | tr '[[:upper:]]' '[[:lower:]]'` in
+   model)
+       case "${value}" in
+       EPL5[789]00L)
+           echo "MODEL='${value}'"
+           ;;
+       *)
+           echo "${BASENAME}: Unknown model '${value}'!" >&2
+           exit 1
+           ;;
+       esac
+       ;;
+   papersize)
+       echo "PAPERSIZE='${value}'"
+       ;;
+   dpi)
+       case "${value}" in
+       300|Class600|600|Class1200)
+           echo "DPI='${value}'"
+           ;;
+       *)
+           echo "${BASENAME}: Unknown resolution '${value}'!" >&2
+           exit 1
+           ;;
+       esac
+       ;;
+   ritech)
+       case "${value}" in
+       on|off)
+           echo "RITECH='${value}'"
+           ;;
+       *)
+           echo "${BASENAME}: Unknown ritech setting '${value}'!" >&2
+           exit 1
+           ;;
+       esac
+       ;;
+   density)
+       case "${value}" in
+       [12345])
+           echo "DENSITY='${value}'"
+           ;;
+       *)
+           echo "${BASENAME}: Unknown density setting '${value}'!" >&2
+           exit 1
+           ;;
+       esac
+       ;;
+   tonersave)
+       case "${value}" in
+       on|off)
+           echo "TONERSAVE='${value}'"
+           ;;
+       *)
+           echo "${BASENAME}: Unknown tonersave setting '${value}'!" >&2
+           exit 1
+           ;;
+       esac
+       ;;
+   *)
+       echo "${BASENAME}: Unknown setting '${var}=${value}'!" >&2
+       exit 1
+       ;;
+   esac
+done
+}
+
+BASENAME=`basename $0`
+PREFIX=`dirname $0`
+PREFIX=${PREFIX%/bin}
+CONFIGFILE=${PREFIX}/etc/epsonepl.conf
+
+case "$1" in
+-f?*)
+   CONFIGFILE=${1#-f}
+   ;;
+esac
+
+settings=`parse "${CONFIGFILE}"` || exit 1
+eval "${settings}"
 
 IJSPARMS=""
 
-# Start of printer selection part #########################################
+if [ -z "${MODEL}" ]; then
+   echo "${BASENAME}: You must specify a model!" >&2
+   exit 1
+fi
 
-MODEL=EPL5700L
   # possible values: EPL5700L, EPL5800L, EPL5900L
   # default: none, you have to specify a printer!
 
@@ -14,7 +108,10 @@
 
 # Start of paper size selection part ######################################
 
-PAPERSIZE=a4
+if [ -z "${PAPERSIZE}" ]; then
+   echo "${BASENAME}: You must specify a papersize!" >&2
+   exit 1
+fi
   # possible values: a4, letter, legal ...
   #                  The full list is available in the Use.htm file of
   #                  the ghostscript documentation (see appendix).
@@ -25,25 +122,29 @@
 
 # Start of options part ###################################################
 
-DPI=600
+if [ -n "${DPI}" ]; then
   # possible values: 300, Class600, 600, Class1200
   # default: 600
   IJSPARMS="EplDpi=$DPI"
+fi
 
-RITECH=on
+if [ -n "${RITECH}" ]; then
   # possible values: on, off
   # default: on
-  IJSPARMS="$IJSPARMS,EplRitech=$RITECH"
+  IJSPARMS="$IJSPARMS${IJSPARMS:+,}EplRitech=$RITECH"
+fi
 
-DENSITY=3
+if [ -n "${DENSITY}" ]; then
   # possible values: 1, 2, 3, 4, 5
   # default: 3
-  IJSPARMS="$IJSPARMS,EplDensity=$DENSITY"
+  IJSPARMS="$IJSPARMS${IJSPARMS:+,}EplDensity=$DENSITY"
+fi
 
-TONERSAVE=off
+if [ -n "${TONERSAVE}" ]; then
   # possible values: on, off
   # default: off
-  IJSPARMS="$IJSPARMS,EplTonerSave=$TONERSAVE"
+  IJSPARMS="$IJSPARMS${IJSPARMS:+,}EplTonerSave=$TONERSAVE"
+fi
 
 ##################################################### End of options part #
 
@@ -63,7 +164,7 @@
 done
 
 if [ $# -lt 1 -o $# -gt 2 ]; then
-   echo "Usage: `basename $0` [options...] (input.[e]ps|-) [output.epl|-]" 1>&2
+   echo "Usage: ${BASENAME} [-f<config>] [options...] (input.[e]ps|-) [output.epl|-]" 1>&2
    exit 1
 fi
 
@@ -81,19 +182,11 @@
    outfile="$2"
 fi
 
-echo
-echo -e "***** Printer: \"$MODEL\" *****"
-echo
-echo -e "***** Paper Size: \"$PAPERSIZE\" *****"
-echo
-echo -e "***** using parameters: \"$IJSPARMS\" *****"
-echo
-
 exec gs -sPAPERSIZE=$PAPERSIZE -dFIXEDMEDIA \
 -sProcessColorModel=DeviceGray -dBitsPerSample=1 \
 -sDEVICE=ijs -sIjsServer=ijs_server_epsonepl \
 -sDeviceManufacturer=Epson -sDeviceModel=$MODEL \
 -sIjsParams="$IJSPARMS" \
 -dIjsUseOutputFD \
--dNOPAUSE -dSAFER -dBATCH \
--sOutputFile=$outfile $infile
+-dQUIET -dNOPAUSE -dSAFER -dBATCH \
+-sOutputFile="$outfile" "$infile"