aboutsummaryrefslogtreecommitdiff
path: root/lp/process/hpost
blob: 169cb2acd9d9421f4f341dde153355a64a592100 (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
#!/usr/local/plan9/bin/rc
if (! ~ $DEBUG '') flag x +
REVFLAG=''
if (~ $LPCLASS *reverse*) {
	switch ($REVERSE) {
	case '';
		REVFLAG=1
	case 1;
		REVFLAG=''
	}
}
if (! ~ $REVFLAG '')
	postreverse

if (~ $NOHEAD '') {
	DATE=`{date}
	face='FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
	facedom=`{awk '{ if(match("'$LPMACHID'", $1)) {print $2; exit}}' $PLAN9/face/.machinelist}
	if (~ $#facedom 0) facedom=$LPMACHID

	facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' $PLAN9/face/48x48x4/.dict}
	facedepth=4

	if (~ $#facefile 0) {
		facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' $PLAN9/face/48x48x2/.dict}
		facedepth=2
	}

	if (~ $#facefile 0) {
		facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' $PLAN9/face/48x48x1/.dict}
		facedepth=1
	}

	if (~ $#facefile 0) {facefile=u/unknown.1; facedepth=1}
	facefile=$PLAN9/face/48x48x$facedepth/$facefile

	if (! ~ $#facefile 0 1)
		facefile=$facefile(1)

	if (~ $#facefile 0 || ! test -f $facefile ) {facefile=$PLAN9/face/48x48x2/u/unknown.1; facedepth=2}
	if (test -r $facefile ) {
		switch($facedepth){
		case 1 2
			face=`{cat $facefile |
				sed -e 's/0x//g' -e 's/, *//g' |
				tr 0123456789abcdef fedcba9876543210 };
		case 4
			face=`{iconv -u -c k4 $facefile |
				dd -bs 60 -skip 1 >[2]/dev/null |
				xd -b | sed 's/^[^ ]+ //;s/ //g'  }
		}
	}
}

# We have to make sure the face information is set before rc sees the HERE file
# so the cat has to be in a separate if statement.  This is an rc bug.
if (~ $NOHEAD '') cat <<EOF
%!PS-Adobe-2.0	div 112 page header - research!pg
/banner {
	/saveobj save def
	erasepage initgraphics
	/#copies 1 def
	/inch {72 mul} bind def
	/pageborder {
		25 747 moveto
		590 747 lineto
		590 25 lineto
		25 25 lineto
		closepath
		2 setlinewidth
		0 setgray
		stroke
	} def

	/topborder {
		25 773 moveto
		590 773 lineto
		590 747 lineto
		25 747 lineto
		closepath
		2 setlinewidth
		0 setgray
		stroke
	} def

	/toptext {
		120 756 moveto
		/Courier-Bold findfont 14 scalefont setfont
		($LPUSERID $DATE) show
	} def

	/prface {
		gsave
		translate rotate scale
		setgray
		48 48 $facedepth [48 0 0 -48 0 48] {<$face>} image
		grestore
	} def
EOF
if (~ $NOHEAD '') switch ($LPCLASS) {
case *hp4simx*;
	echo '
%% set the default papertray to be the lower tray for HP4siMX printers
	statusdict begin defaultpapertray end 1 ne {
		statusdict begin
			1 setdefaultpapertray
		end
	} if'
}
if (~ $NOHEAD '') cat <<EOF
	statusdict /setduplexmode known {statusdict begin false setduplexmode end} if
	statusdict begin /manualfeed false def end
	pageborder
	topborder
	toptext
	0 14 14 0 94 752 prface
	.3 180 180 -90 3.0 inch 10.2 inch prface
	showpage
	saveobj
	restore
} bind def
banner
EOF

if (~ $REVFLAG '') cat
exit ''