]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/lp/process/hpost
rootstub: create /sys/src/pkg and /sys/lib/pkg directories
[plan9front.git] / sys / lib / lp / process / hpost
1 #!/bin/rc
2 if (! ~ $DEBUG '') flag x +
3 REVFLAG=''
4 if (~ $LPCLASS *reverse*) {
5         switch ($REVERSE) {
6         case '';
7                 REVFLAG=1
8         case 1;
9                 REVFLAG=''
10         }
11 }
12 if (! ~ $REVFLAG '')
13         postreverse
14
15 if (~ $NOHEAD '') {
16         DATE=`{date}
17         face='FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
18 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
19 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
20 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
21 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
22 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
23 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
24 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
25 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
26 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
27 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
28 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
29 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
30 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
31 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
32 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
33 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
34 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
35         facedom=`{awk '{ if(match("'$LPMACHID'", $1)) {print $2; exit}}' /lib/face/.machinelist}
36         if (~ $#facedom 0) facedom=$LPMACHID
37
38         facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x8/.dict}
39         facedepth=8
40
41         if (~ $#facefile 0) {
42                 facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x4/.dict}
43                 facedepth=4
44         }
45         if (~ $#facefile 0) {
46                 facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x2/.dict}
47                 facedepth=2
48         }
49
50         if (~ $#facefile 0) {
51                 facefile=`{awk '/^'$facedom'\/'$LPUSERID' /{print $2}' /lib/face/48x48x1/.dict}
52                 facedepth=1
53         }
54
55         if (~ $#facefile 0) {facefile=u/unknown.1; facedepth=1}
56         facefile=/lib/face/48x48x$facedepth/$facefile
57
58         if (! ~ $#facefile 0 1)
59                 facefile=$facefile(1)
60
61         if (~ $#facefile 0 || ! test -f $facefile ) {facefile=/lib/face/48x48x2/u/unknown.1; facedepth=2}
62         if (test -r $facefile ) {
63                 switch($facedepth){
64                 case 1 2
65                         face=`{cat $facefile |
66                                 sed -e 's/0x//g' -e 's/, *//g' |
67                                 tr 0123456789abcdef fedcba9876543210 };
68                 case 4 8
69                         face=`{iconv -u -c k4 $facefile |
70                                 dd -bs 60 -skip 1 >[2]/dev/null |
71                                 xd -b | sed 's/^[^ ]+ //;s/ //g'  }
72                         facedepth=8
73                 }
74         }
75 }
76
77 # We have to make sure the face information is set before rc sees the HERE file
78 # so the cat has to be in a separate if statement.  This is an rc bug.
79 if (~ $NOHEAD '') cat <<EOF
80 %!PS-Adobe-2.0  div 112 page header - research!pg
81 /banner {
82         /saveobj save def
83         erasepage initgraphics
84         /#copies 1 def
85         /inch {72 mul} bind def
86         /pageborder {
87                 25 747 moveto
88                 590 747 lineto
89                 590 25 lineto
90                 25 25 lineto
91                 closepath
92                 2 setlinewidth
93                 0 setgray
94                 stroke
95         } def
96
97         /topborder {
98                 25 773 moveto
99                 590 773 lineto
100                 590 747 lineto
101                 25 747 lineto
102                 closepath
103                 2 setlinewidth
104                 0 setgray
105                 stroke
106         } def
107
108         /toptext {
109                 120 756 moveto
110                 /Courier-Bold findfont 14 scalefont setfont
111                 ($LPUSERID $DATE) show
112         } def
113
114         /prface {
115                 gsave
116                 translate rotate scale
117                 setgray
118                 48 48 $facedepth [48 0 0 -48 0 48] {<$face>} image
119                 grestore
120         } def
121 EOF
122 if (~ $NOHEAD '') switch ($LPCLASS) {
123 case *hp4simx*;
124         echo '
125 %% set the default papertray to be the lower tray for HP4siMX printers
126         statusdict begin defaultpapertray end 1 ne {
127                 statusdict begin
128                         1 setdefaultpapertray
129                 end
130         } if'
131 }
132 if (~ $NOHEAD '') cat <<EOF
133         statusdict /setduplexmode known {statusdict begin false setduplexmode end} if
134         statusdict begin /manualfeed false def end
135         pageborder
136         topborder
137         toptext
138         0 14 14 0 94 752 prface
139         .3 180 180 -90 3.0 inch 10.2 inch prface
140         showpage
141         saveobj
142         restore
143 } bind def
144 banner
145 EOF
146
147 if (~ $REVFLAG '') cat
148 exit ''