xref: /plan9/sys/src/cmd/postscript/hardcopy/hardcopy.rc (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1#!/bin/rc
2# Generate paper output from the data that a PostScript program normally
3# sends back to a host computer using file output operators.
4#
5
6POSTLIB=/sys/lib/postscript/prologues
7PROLOGUE=$POSTLIB/hardcopy.ps
8
9OPTIONS=
10MODE=portrait
11
12NONCONFORMING='%!PS'
13ENDPROLOG='%%EndProlog'
14BEGINSETUP='%%BeginSetup'
15ENDSETUP='%%EndSetup'
16TRAILER='%%Trailer'
17
18SETUP=HardcopySetup
19DONE='(%stdout)(w) file -1 write'
20
21while (! ~ $#* 0 && ~ $1 -*) {
22	switch ($1) {
23	case -c;  shift; OPTIONS=$OPTIONS' /#copies '$1' store'
24	case -c*; OPTIONS=$OPTIONS' /#copies `{echo $1 | sed s/-c//}' store'
25
26	case -f;  shift; OPTIONS=$OPTIONS' /font '/$1' def'
27	case -f*; OPTIONS=$OPTIONS' /font '/`{echo $1 | sed s/-f//}' def'
28
29	case -p;  shift; MODE=$1
30	case -p*; MODE=`{echo $1 | sed s/-p//}
31
32	case -m;  shift; OPTIONS=$OPTIONS' /magnification '$1' def'
33	case -m*; OPTIONS=$OPTIONS' /magnification '`{echo $1 | sed s/-m//}' def'
34
35	case -s;  shift; OPTIONS=$OPTIONS' /pointsize '$1' def'
36	case -s*; OPTIONS=$OPTIONS' /pointsize '`{echo $1 | sed s/-s//}' def'
37
38	case -x;  shift; OPTIONS=$OPTIONS' /xoffset '$1' def'
39	case -x*; OPTIONS=$OPTIONS' /xoffset '`{echo $1 | sed s/-x//}' def'
40
41	case -y;  shift; OPTIONS=$OPTIONS' /yoffset '$1' def'
42	case -y*; OPTIONS=$OPTIONS' /yoffset '`{echo $1 | sed s/-y//}' def'
43
44	case -L;  shift; PROLOGUE=$1
45	case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
46
47	case --;
48
49	case -*;  echo '$0: illegal option $1' >&2; exit 1
50	}
51	shift
52}
53
54switch ($MODE) {
55	case l*; OPTIONS=$OPTIONS' /landscape true def'
56	case *;  OPTIONS=$OPTIONS' /landscape false def'
57}
58
59echo $NONCONFORMING
60cat $PROLOGUE
61echo $ENDPROLOG
62echo $BEGINSETUP
63echo $OPTIONS
64echo $SETUP
65echo $ENDSETUP
66
67cat $*
68
69echo $TRAILER
70echo $DONE
71