Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/bin/rc
2
# Tries to determine what type of file you are printing and do the correct
3
# thing with it.
4
# It currently knows about images, troff intermediate, and ascii files.
5
rfork e
6
temp=/tmp/lp$pid
7
fn sigexit { rm -f $temp }
8
proc=$LPLIB/process
9
 
10
if (! ~ $DEBUG '')
11
	flag x +
12
cat >$temp
13
 
14
type=`{file $temp}
15
switch ($type(2)) {
16
case troff
17
	switch ($LPCLASS) {
18
	case *Latin1* *post* *opost*
19
		switch ($type(5)) {
20
		# Latin1 is for compatibility with old research UNIX systems,
21
		# doesn't work on Plan 9
22
		case Latin1 post
23
			tcs -s -f utf -t latin1 <$temp | $proc/dpost
24
		case UTF
25
			$proc/tr2post <$temp
26
		}
27
	case *gs!* *gsijs!*
28
		switch ($type(5)) {
29
		# Latin1 is for compatibility with old research UNIX systems,
30
		# doesn't work on Plan 9
31
		case Latin1 post
32
			tcs -s -f utf -t latin1 <$temp | $proc/dpost |
33
				$proc/gspipe
34
		case UTF
35
			$proc/tr2post <$temp | $proc/gspipe
36
		}
37
	case *
38
		echo $type(2) -T$type(5) output is improper for $LPDEST >[1=2]
39
	}
40
case special
41
	switch ($type(4)) {
42
	case '#b'
43
		switch ($LPCLASS) {
44
		case *post*
45
			$proc/p9bitpost <$temp
46
		case *gs!*
47
			$proc/p9bitpost <$temp | $proc/gspipe
48
		case *gsijs!*
49
			$proc/p9bitpost <$temp | $proc/gspipeijs
50
		}
51
	case *
52
		echo $type file is improper for $LPDEST >[1=2]
53
	}
54
case Compressed plan old subfont
55
	# type is really 'Compressed image' or 'plan 9 image' or
56
	# 'old plan 9 image'
57
	# 'subfont' is to cope with a bug in png (writing wrong length),
58
	# 6 may 2008
59
	switch ($LPCLASS) {
60
	case *post*
61
		$proc/p9bitpost <$temp
62
	case *gs!*
63
		$proc/p9bitpost <$temp | $proc/gspipe
64
	case *gsijs!*
65
		$proc/p9bitpost <$temp | $proc/gspipeijs
66
	}
67
case jpeg
68
	switch ($LPCLASS) {
69
	case *post*
70
		$proc/jpgpost <$temp
71
	case *gs!*
72
		$proc/jpgpost <$temp | $proc/gspipe
73
	case *gsijs!*
74
		$proc/jpgpost <$temp | $proc/gspipeijs
75
	}
76
case GIF
77
	switch ($LPCLASS) {
78
	case *post*
79
		$proc/gifpost <$temp
80
	case *gs!*
81
		$proc/gifpost <$temp | $proc/gspipe
82
	case *gsijs!*
83
		$proc/gifpost <$temp | $proc/gspipeijs
84
	}
85
case PNG
86
	switch ($LPCLASS) {
87
	case *post*
88
		$proc/pngpost <$temp
89
	case *gs!*
90
		$proc/pngpost <$temp | $proc/gspipe
91
	case *gsijs!*
92
		$proc/pngpost <$temp | $proc/gspipeijs
93
	}
94
case ccitt-g31
95
	switch ($LPCLASS) {
96
	case *post*
97
		$proc/g3post <$temp
98
	case *gs!*
99
		$proc/g3post <$temp | $proc/gspipe
100
	case *gsijs!*
101
		$proc/g3post <$temp | $proc/gspipeijs
102
	}
103
case bitmap
104
	# bitmap for research UNIX compatibility, does not work on Plan 9.
105
	switch ($LPCLASS) {
106
	case *post*
107
		$proc/bpost <$temp
108
	case *mhcc*
109
		$proc/bpost <$temp | $proc/mhcc
110
	case *
111
		echo $type(2) file is improper for $LPDEST >[1=2]
112
	}
113
case tex
114
	mv $temp $temp.dvi
115
	temp=$temp.dvi
116
	switch ($LPCLASS) {
117
	case *post*
118
		$proc/dvipost $temp
119
	case *gs!*
120
		$proc/dvipost $temp | $proc/gspipe
121
	case *gsijs!*
122
		$proc/dvipost $temp | $proc/gspipeijs
123
	case *
124
		echo $type(2) file is improper for $LPDEST >[1=2]
125
	}
126
case postscript
127
	switch ($LPCLASS) {
128
	case *post*
129
		$proc/post <$temp
130
	case *gs!*
131
		$proc/post <$temp | $proc/gspipe
132
	case *gsijs!*
133
		$proc/post <$temp | $proc/gspipeijs
134
	case *
135
		echo $type(2) file is improper for $LPDEST >[1=2]
136
	}
137
case HPJCL HP
138
	switch ($LPCLASS) {
139
	case *HPJCL*
140
		$proc/noproc <$temp
141
	case *
142
		echo $type(2) file is improper for $LPDEST >[1=2]
143
	}
144
case daisy
145
	switch ($LPDEST) {
146
	case *
147
		echo $type(2) file is improper for $LPDEST >[1=2]
148
	}
149
case tiff
150
	switch ($LPCLASS) {
151
	case *post*
152
		$proc/tiffpost $temp
153
	case *gs!*
154
		$proc/tiffpost $temp | $proc/gspipe
155
	case *gsijs!*
156
		$proc/tiffpost $temp | $proc/gspipeijs
157
	case *
158
		echo Unrecognized class of line printer for $LPDEST >[1=2]
159
	}
160
case PDF
161
	switch ($LPCLASS) {
162
	case *pdf*
163
#		if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*)
164
#			echo -n '&l1S'		# HP JCL: duplex on
165
		if (~ $LPCLASS *duplex* && ~ $LPCLASS *HPJCL*) {
166
			echo '%-12345X@PJL DEFAULT DUPLEX=ON'	# HP PJL
167
			echo '%-12345X'
168
			echo '%-12345X@PJL DEFAULT PS:MBT=ON'	# `memory boost'
169
			echo '%-12345X'
170
		}
171
		cat $temp		# pass pdf unaltered to pdf printer
172
	case *post*
173
		$proc/pdfpost $temp
174
	case *gs!*
175
		$proc/pdfgs $temp
176
	case *gsijs!*
177
		$proc/pdfgsijs $temp
178
	case *
179
		echo Unrecognized class of line printer for $LPDEST >[1=2]
180
	}
181
case microsoft				# office document
182
	switch ($LPCLASS) {
183
	case *post*
184
		doc2ps $temp | $proc/post
185
	case *gs!*
186
		doc2ps $temp | $proc/post  | $proc/gspipe
187
	case *gsijs!*
188
		doc2ps $temp | $proc/post | $proc/gspipeijs
189
	case *
190
		echo $type(2) file is improper for $LPDEST >[1=2]
191
	}
192
case empty
193
	echo file is empty >[1=2]
194
case cannot
195
	echo cannot open file >[1=2]
196
case English Cyrillic short extended alef limbo [Aa]scii assembler c latin rc sh \
197
    as mail email message/rfc822 manual HTML
198
	switch ($LPCLASS) {
199
	case *post*
200
		$proc/ppost <$temp
201
	case *gs!*
202
		$proc/ppost <$temp | $proc/gspipe
203
	case *gsijs!*
204
		$proc/ppost <$temp | $proc/gspipeijs
205
	case *canon*
206
		$proc/can $* <$temp
207
	case *
208
		echo Unrecognized class of line printer for $LPDEST >[1=2]
209
	}
210
case *
211
	echo $type(2) file is improper for $LPDEST >[1=2]
212
}
213
 
214
wait
215
rv=$status
216
rm -f $temp
217
# exit $rv
218
exit