summaryrefslogtreecommitdiff
path: root/sys/lib/lp/process/generic
blob: 0188bc0f48c178da9c296aa5a189d0769ea40ffc (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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/rc
# Tries to determine what type of file you are printing and do the correct
# thing with it.
# It currently knows about images, troff intermediate, and ascii files.
rfork e
temp=/tmp/lp$pid
fn sigexit { rm -f $temp }
proc=$LPLIB/process

if (! ~ $DEBUG '')
	flag x +
cat >$temp

type=`{file $temp}
switch ($type(2)) {
case troff
	switch ($LPCLASS) {
	case *Latin1* *post* *opost*
		switch ($type(5)) {
		# Latin1 is for compatibility with old research UNIX systems,
		# doesn't work on Plan 9
		case Latin1 post
			tcs -s -f utf -t latin1 <$temp | $proc/dpost
		case UTF
			$proc/tr2post <$temp
		}
	case *gs!* *gsijs!*
		switch ($type(5)) {
		# Latin1 is for compatibility with old research UNIX systems,
		# doesn't work on Plan 9
		case Latin1 post
			tcs -s -f utf -t latin1 <$temp | $proc/dpost |
				$proc/gspipe
		case UTF
			$proc/tr2post <$temp | $proc/gspipe
		}
	case *
		echo $type(2) -T$type(5) output is improper for $LPDEST >[1=2]
	}
case special
	switch ($type(4)) {
	case '#b'
		switch ($LPCLASS) {
		case *post*
			$proc/p9bitpost <$temp
		case *gs!*
			$proc/p9bitpost <$temp | $proc/gspipe
		case *gsijs!*
			$proc/p9bitpost <$temp | $proc/gspipeijs
		}
	case *
		echo $type file is improper for $LPDEST >[1=2]
	}
case Compressed plan old subfont
	# type is really 'Compressed image' or 'plan 9 image' or
	# 'old plan 9 image'
	# 'subfont' is to cope with a bug in png (writing wrong length),
	# 6 may 2008
	switch ($LPCLASS) {
	case *post*
		$proc/p9bitpost <$temp
	case *gs!*
		$proc/p9bitpost <$temp | $proc/gspipe
	case *gsijs!*
		$proc/p9bitpost <$temp | $proc/gspipeijs
	}
case jpeg
	switch ($LPCLASS) {
	case *post*
		$proc/jpgpost <$temp
	case *gs!*
		$proc/jpgpost <$temp | $proc/gspipe
	case *gsijs!*
		$proc/jpgpost <$temp | $proc/gspipeijs
	}
case GIF
	switch ($LPCLASS) {
	case *post*
		$proc/gifpost <$temp
	case *gs!*
		$proc/gifpost <$temp | $proc/gspipe
	case *gsijs!*
		$proc/gifpost <$temp | $proc/gspipeijs
	}
case PNG
	switch ($LPCLASS) {
	case *post*
		$proc/pngpost <$temp
	case *gs!*
		$proc/pngpost <$temp | $proc/gspipe
	case *gsijs!*
		$proc/pngpost <$temp | $proc/gspipeijs
	}
case ccitt-g31
	switch ($LPCLASS) {
	case *post*
		$proc/g3post <$temp
	case *gs!*
		$proc/g3post <$temp | $proc/gspipe
	case *gsijs!*
		$proc/g3post <$temp | $proc/gspipeijs
	}
case bitmap
	# bitmap for research UNIX compatibility, does not work on Plan 9.
	switch ($LPCLASS) {
	case *post*
		$proc/bpost <$temp
	case *mhcc*
		$proc/bpost <$temp | $proc/mhcc
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case tex
	mv $temp $temp.dvi
	temp=$temp.dvi
	switch ($LPCLASS) {
	case *post*
		$proc/dvipost $temp
	case *gs!*
		$proc/dvipost $temp | $proc/gspipe
	case *gsijs!*
		$proc/dvipost $temp | $proc/gspipeijs
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case postscript
	switch ($LPCLASS) {
	case *post*
		$proc/post <$temp
	case *gs!*
		$proc/post <$temp | $proc/gspipe
	case *gsijs!*
		$proc/post <$temp | $proc/gspipeijs
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case HPJCL HP
	switch ($LPCLASS) {
	case *HPJCL*
		$proc/noproc <$temp
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case daisy
	switch ($LPDEST) {
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case tiff
	switch ($LPCLASS) {
	case *post*
		$proc/tiffpost $temp
	case *gs!*
		$proc/tiffpost $temp | $proc/gspipe
	case *gsijs!*
		$proc/tiffpost $temp | $proc/gspipeijs
	case *
		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case PDF
	switch ($LPCLASS) {
	case *pdf*
#		if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*)
#			echo -n '&l1S'		# HP JCL: duplex on
		if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*) {
			echo '%-12345X@PJL DEFAULT DUPLEX=ON'	# HP PJL
			echo '%-12345X'
			echo '%-12345X@PJL DEFAULT PS:MBT=ON'	# `memory boost'
			echo '%-12345X'
		}
		cat $temp		# pass pdf unaltered to pdf printer
	case *post*
		$proc/pdfpost $temp
	case *gs!*
		$proc/pdfgs $temp
	case *gsijs!*
		$proc/pdfgsijs $temp
	case *
		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case microsoft				# office document
	switch ($LPCLASS) {
	case *post*
		doc2ps $temp | $proc/post
	case *gs!*
		doc2ps $temp | $proc/post  | $proc/gspipe
	case *gsijs!*
		doc2ps $temp | $proc/post | $proc/gspipeijs
	case *
		echo $type(2) file is improper for $LPDEST >[1=2]
	}
case empty
	echo file is empty >[1=2]
case cannot
	echo cannot open file >[1=2]
case English short extended alef limbo [Aa]scii assembler c latin rc sh \
    as mail email message/rfc822 manual HTML
	switch ($LPCLASS) {
	case *post*
		$proc/ppost <$temp
	case *gs!*
		$proc/ppost <$temp | $proc/gspipe
	case *gsijs!*
		$proc/ppost <$temp | $proc/gspipeijs
	case *canon*
		$proc/can $* <$temp
	case *
		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case *
	echo $type(2) file is improper for $LPDEST >[1=2]
}

wait
rv=$status
rm -f $temp
# exit $rv
exit