File: psbanner.sh_init

package info (click to toggle)
cti-ifhp 2.1.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 932 kB
  • ctags: 845
  • sloc: ansic: 6,036; sh: 1,524; makefile: 318
file content (514 lines) | stat: -rwxr-xr-x 13,881 bytes parent folder | download
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
#!_SHELL_
#  This code was derived from the lprps version 2.6 software,
#  distributed with the PLP4.0 release
#  The original distribution is available at ftp://iona.ie/pub/plp/contrib
# 
# Patrick Powell
# Sat Aug 19 20:40:33 PDT 1995
#
#  ** This is lprps version 2.6plp.
#  ** 
#  ** lprps is a collection of programs for using lpr with a PostScript
#  ** printer connected by a bidirectional serial channel.  It has been
#  ** tested mainly with Suns running various versions of SunOS (4.0.3, 4.1
#  ** and 4.1.1).  It should be easy to port to other 4.3 BSD based systems.
#  ** It is also intended for use with System V. See Makefile.
#  ** 
#  ** * Supports banner printing:
#  **   - for PLP use banner.ps including a nice
#  **     PLP-logo (and define LPRPS_BANNER in PLP Makefile);
#  **   - banner.ps is the banner page without the logo (define LPRPS_BANNER in
#  **     PLP-Makefile);
#  **   - for the lpd use banner.ps.old.
#  ** 
#  ** There is no copyright on lprps.
#  ** 
#  ** James Clark
#  ** jjc@jclark.com
#  ** 
#  ** $Id: psbanner.sh_init,v 2.1 1997/01/05 18:41:48 papowell Exp $
#  **  Note: Mr. Clark has explicitly granted permission to use this
#  **  code.  See the lprps distribution.
#  **
#  
# Concept - the program is invoked by the LPRng lpd as the banner printer
# It is passed a set of arguments as follows,  or can read an input line
# with a set of options
#
#  PostScript Banner Printer
#  
#  Called with:
#  psbanner banner [-FLAGvalue]* [accountingfile]
#  
#   Important flags:                 Postscript Variable
#    -jnumber   - job number          /Seq
#    -Jbanner   - banner              /Job
#    -hhost     - host                /Host
#    -Cclass    - job class           /Class
#    -nuser     - user                /User
#    -tdate      - date               /Date
#    -Lname     - name                /Name
#  
#  Example:
#  
#  banner -Pt1 -w80 -l66 -x0 -y0 -Ff
#      -kcfA684taco.sdsu.edu -Lpapowell -J../VERSION -CA
#      -npapowell -htaco.sdsu.edu -Htaco.sdsu.edu
#      -d/tmp/LPD/t1/dfA684 taco.sdsu.edu accnt
#  
# Input Line: consists of the Seq:, Job:, ... words followed by values on
# one of more line.
#  You should define
#      :bl= Seq\: $j Job\: $-J Host\: $-H Seq\: $-j Class\: $-C User\: $-n \
#            Date\: $-t
#
#  Output needed:
#  
#  %!PS-Adobe-2.0
#  /Seq (number) def
#  /Job (banner) def  (with '()\' escaped )
#  /Host (HOST) def  
#  /Class (CLASS) def
#  /User (USER) def
#  /Date (DATE) def
#  /Name (NAME) def
#   < followed by the contents of the banner file >
# These variables are used by the banner printing script to
# produce output.
##
# ----------- start version 1 ------------
## echo debugging -- "$0" "$@" 1>&2
#
number=
banner=
host=
class=
user=
date=`date`
name=
args="$*"
while test $# != 0
do  case "$1" in
    -j*) number=$1 ;;
	-J*) banner=$1 ;;
	-h*) host=$1; if [ "$1" = "-h" ]; then shift; host=$1; fi ;;
	-C*) class=$1 ;;
	-n*) user=$1; if [ "$1" = "-n" ]; then shift; user=$1; fi ;;
	-t*) date=$1 ;;
	-L*) name=$1 ;;
    esac
    shift
done
# now strip off the leading -? tags
strip () {
	v=`echo "X$2" \
		| sed -e 's/^X//' -e 's/^-.//' -e 's/[()\\]/\\\\&/g' -e 's/.*/(&)/'`;
	echo "$1" "$v" def;
}
echo '%!PS-Adobe-2.0'
echo "%% $0 $args"
strip "/Seq" "$number" ;
strip "/Job" "$banner" ;
strip "/Host" "$host" ;
strip "/Class" "$class" ;
strip "/User" "$user" ;
strip "/Date" "$date" ;
strip "/Name" "$name" ;
#
## ----------- end version 1 ------------
## #
## # VERSION 2: read the input line
while read a; do
## echo debugging input --  "$a" 1>&2
	echo "%% input $a"
	echo "$a" | awk '
	{
		found = 0;
		for( i = 1; i <= NF; ++i ){
			l = length( $i );
			if( $i ~ /:$/ ){
				if( found ){
					printf "%s) def\n", value;
				}
				v = substr( $i,1, l-1 );
				printf "/%s (", v;
				found = 1;
				value = "";
			} else {
				if( length(value) > 0  ){
					value = value  " ";
				}
				for( j = 1; j <= l; ++j ){
					s = substr( $i, j, 1 );
					if( s == "(" ||  s == ")" || s == "\\" ){
						 s = "\\" s ;
					}
					value = value s;
				}
			}
		}
		if( found ){
			printf "%s) def\n", value;
		}
	}'
done
## ----------- end version 2 ------------
#
# VERSION 2: use the command line flags
#
#
# The following is the postscript file that uses the variables
#
# Note that dimensions are given in points (72/inch)
# 8.5 x 11.0 => 612 x 792
# a4 = 8.5 x 11.75 => 612 x 846
cat <<'EOF'
/entries [(User:) (Name:) (Host:) (Date:) (Job:) (Class:)] def
/low-point-size 10 def
/high-point-size 120 def
/line-spacing low-point-size 1.2 mul def
/left-margin 22 def
% a4     /first-baseline 840 def
% 8.5x11 /first-baseline 786 def
/first-baseline 786 def
/last-baseline 30 def
/user-baseline 150 def
/user-margin left-margin low-point-size 4.2 mul add def
/banner-baseline 630 def
/banner-line-spacing high-point-size 1.1 mul def

/Courier findfont low-point-size scalefont setfont

0 1 5 {
 dup line-spacing mul exch 2 gt
  { first-baseline exch sub }
  { last-baseline add } ifelse
 left-margin exch moveto
 (****************************************) show
 (**************************************** SEQ NR. ) show
 Seq show
} for

0 1 5 {
 dup line-spacing mul user-baseline exch sub
 left-margin exch moveto
 entries exch get show
} for

/i 0 def

[User Name Host Date Job Class] {
 user-margin user-baseline i line-spacing mul sub moveto
 i 0 eq
  { show (@) show Host } if
 show
 /i i 1 add def
} forall

/i 0 def
%%%%%%%% FANCY HEADER %%%%%%%%%%%%%%%%%
%%%% if you don't mind waiting, remove the comments
%%%%
%% [Seq User Host Job] {
%%  gsave
%%  left-margin banner-baseline banner-line-spacing i mul sub translate
%%  0 0 moveto
%%  i 0 eq i 3 eq or
%%  { i 0 eq 
%%  	{ /Helvetica }
%% 	 { /Courier /high-point-size 76 def } ifelse
%%  }
%%   { /ZapfChancery-MediumItalic } ifelse
%%  findfont high-point-size scalefont setfont
%%  {
%%   /charcode exch def
%%   /thechar (-) dup 0 charcode put def
%%   thechar true charpath stroke
%%   thechar stringwidth pop 0 translate 0 0 moveto
%%  } forall
%%  /i i 1 add def
%%  grestore
%% } forall
%% 

%%%% Neat little Printer ICON
%%%% if you don't mind waiting, remove the comments
%%%%
%% gsave
%% /$F2psDict 200 dict def 
%% $F2psDict begin
%% $F2psDict /mtrx matrix put
%% /l {lineto} bind def
%% /m {moveto} bind def
%% /s {stroke} bind def
%% /n {newpath} bind def
%% /gs {gsave} bind def
%% /gr {grestore} bind def
%% /clp {closepath} bind def
%% /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
%% 4 -2 roll mul setrgbcolor} bind def
%% /col-1 {} def
%% /col0 {0 0 0 setrgbcolor} bind def
%% /col1 {0 0 1 setrgbcolor} bind def
%% /col2 {0 1 0 setrgbcolor} bind def
%% /col3 {0 1 1 setrgbcolor} bind def
%% /col4 {1 0 0 setrgbcolor} bind def
%% /col5 {1 0 1 setrgbcolor} bind def
%% /col6 {1 1 0 setrgbcolor} bind def
%% /col7 {1 1 1 setrgbcolor} bind def
%% /col8 {.68 .85 .9 setrgbcolor} bind def
%% /col9 {0 .39 0 setrgbcolor} bind def
%% /col10 {.65 .17 .17 setrgbcolor} bind def
%% /col11 {1 .51 0 setrgbcolor} bind def
%% /col12 {.63 .13 .94 setrgbcolor} bind def
%% /col13 {1 .75 .8 setrgbcolor} bind def
%% /col14 {.7 .13 .13 setrgbcolor} bind def
%% /col15 {1 .84 0 setrgbcolor} bind def
%% 	end
%% /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
%% /$F2psEnd {$F2psEnteredState restore end} def
%% %%EndProlog
%% 
%% $F2psBegin
%% 0 setlinecap 0 setlinejoin
%% 412.0 205.0 translate 0.900 -0.900 scale
%% 1.000 setlinewidth
%% % Polyline
%% n 64 107 m 64 101 l  124 101 l  124 107 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 64 106 m 64 110 l gs col0 s gr
%% % Polyline
%% n 124 106 m 124 110 l gs col0 s gr
%% % Polyline
%% n 128 128 m 128 119 l  59 119 l  59 128 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 59 119 m 59 104 l  44 104 l  44 119 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 143 119 m 143 104 l  128 104 l  128 119 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 146 92 m 146 116 l  143 116 l  143 92 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 44 92 m 44 116 l  41 116 l  41 92 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 50 95 m 50 92 l  44 92 l  44 95 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% % Polyline
%% n 137 95 m 137 92 l  143 92 l  143 95 l  clp gs 0.00 setgray fill gr
%% gs col-1 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 146 77 m 146 89 l  41 89 l  41 77 l  clp gs col-1 s gr
%% % Polyline
%% n 43 90 m 43 78 l gs col-1 s gr
%% % Polyline
%% n 144 89 m 144 77 l gs col-1 s gr
%% % Polyline
%% n 41 77 m 41 71 l gs col-1 s gr
%% % Polyline
%% n 146 77 m 146 71 l gs col-1 s gr
%% % Polyline
%% n 50 65 m 59 65 l gs col-1 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 59 70 m 128 70 l gs col-1 s gr
%% % Polyline
%% n 59 41 m 59 71 l gs col-1 s gr
%% % Polyline
%% n 59 71 m 128 71 l gs col-1 s gr
%% % Polyline
%% n 59 41 m 122 41 l gs col-1 s gr
%% % Polyline
%% n 128 48 m 128 71 l gs col-1 s gr
%% % Polyline
%% n 122 41 m 128 48 l gs col-1 s gr
%% % Polyline
%% n 116 41 m 116 53 l  128 53 l gs col-1 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 128 65 m 131 65 l gs col-1 s gr
%% % Polyline
%% n 129 65 m 140 65 l  146 72 l gs col-1 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 128 66 m 131 66 l gs col-1 s gr
%% % Polyline
%% n 128 67 m 131 67 l gs col-1 s gr
%% % Polyline
%% n 133 66 m 140 66 l gs col-1 s gr
%% % Polyline
%% n 133 67 m 141 67 l gs col-1 s gr
%% % Polyline
%% n 131 68 m 133 68 l gs col-1 s gr
%% % Polyline
%% n 131 69 m 133 69 l gs col-1 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 51 65 m 41 72 l gs 0.85 setgray fill gr
%% gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 143 88 m 143 78 l  44 78 l  44 88 l  clp gs 0.60 setgray fill gr
%% gs col0 s gr
%% % Polyline
%% n 132 77 m 41 77 l  41 72 l  51 65 l  59 65 l  59 71 l 
%%  128 71 l  128 67 l  131 67 l gs 0.75 setgray fill gr
%% gs col0 s gr
%% % Polyline
%% n 132 77 m 145 77 l  146 77 l  146 71 l  146 72 l  141 66 l 
%%  133 66 l  133 68 l  133 68 l  133 69 l  131 69 l gs 0.75 setgray fill gr
%% gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 141 89 m 141 92 l gs col0 s gr
%% % Polyline
%% n 46 89 m 46 93 l gs col0 s gr
%% % Polyline
%% n 138 80 m 140 80 l gs col0 s gr
%% % Polyline
%% n 138 85 m 140 85 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 128 104 m 143 104 l  143 95 l  137 95 l  137 92 l  141 92 l 
%%  141 92 l  140 92 l  141 92 l  141 89 l  46 89 l 
%%  46 92 l  50 92 l  50 95 l  44 95 l  44 104 l 
%%  59 104 l gs 0.50 setgray fill gr
%% gs col0 s gr
%% % Polyline
%% n 59 104 m 59 119 l  128 119 l  128 104 l gs 0.35 setgray fill gr
%% gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 65 102 m 69 102 l gs col0 s gr
%% % Polyline
%% n 124 102 m 120 102 l gs col0 s gr
%% % Polyline
%% n 121 102 m 119 102 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 64 104 m 64 108 l gs col0 s gr
%% % Polyline
%% n 124 104 m 124 108 l gs col0 s gr
%% % Polyline
%% n 125 108 m 131 108 l gs col0 s gr
%% % Polyline
%% n 57 108 m 63 108 l gs col0 s gr
%% % Polyline
%% n 120 108 m 124 108 l gs col0 s gr
%% % Polyline
%% n 64 108 m 68 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 67 110 m 71 110 l gs col0 s gr
%% % Polyline
%% n 67 106 m 71 106 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 71 108 m 73 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 73 110 m 76 110 l gs col0 s gr
%% % Polyline
%% n 73 106 m 76 106 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 76 108 m 78 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 78 110 m 82 110 l gs col0 s gr
%% % Polyline
%% n 78 106 m 82 106 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 82 108 m 86 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 64 106 m 64 100 l  124 100 l  124 106 l gs col0 s gr
%% % Polyline
%% n 86 106 m 89 106 l gs col0 s gr
%% % Polyline
%% n 86 110 m 89 110 l gs col0 s gr
%% % Polyline
%% n 117 106 m 121 106 l gs col0 s gr
%% % Polyline
%% n 117 110 m 121 110 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 115 108 m 117 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 112 110 m 115 110 l gs col0 s gr
%% % Polyline
%% n 112 106 m 115 106 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 110 108 m 112 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 106 110 m 110 110 l gs col0 s gr
%% % Polyline
%% n 106 106 m 110 106 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 102 108 m 106 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 99 106 m 102 106 l gs col0 s gr
%% % Polyline
%% n 99 110 m 102 110 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 89 108 m 93 108 l gs col0 s gr
%% % Polyline
%% n 95 108 m 99 108 l gs col0 s gr
%% 1.000 setlinewidth
%% % Polyline
%% n 77 101 m 77 105 l gs col0 s gr
%% % Polyline
%% n 72 101 m 72 105 l gs col0 s gr
%% % Polyline
%% n 83 101 m 83 105 l gs col0 s gr
%% % Polyline
%% n 85 101 m 85 105 l gs col0 s gr
%% % Polyline
%% n 103 101 m 103 105 l gs col0 s gr
%% % Polyline
%% n 105 101 m 105 105 l gs col0 s gr
%% % Polyline
%% n 111 101 m 111 105 l gs col0 s gr
%% % Polyline
%% n 116 101 m 116 105 l gs col0 s gr
%% % Polyline
%% n 90 101 m 90 105 l gs col0 s gr
%% % Polyline
%% n 92 101 m 92 105 l gs col0 s gr
%% % Polyline
%% n 96 101 m 96 105 l gs col0 s gr
%% % Polyline
%% n 98 101 m 98 105 l gs col0 s gr
%% % Polyline
%% n 94 104 m 94 107 l gs col0 s gr
%% % Polyline
%% n 94 108 m 94 111 l gs col0 s gr
%% 0.500 setlinewidth
%% % Polyline
%% n 64 109 m 64 113 l gs col0 s gr
%% % Polyline
%% n 124 109 m 124 113 l gs col0 s gr
%% % Polyline
%% n 64 116 m 64 120 l gs col0 s gr
%% %/Times-Roman findfont 24.00 scalefont setfont
%% %69 64 m 
%% /Times-Roman findfont 20.00 scalefont setfont
%% 63 64 m 
%% gs 1 -1 scale (LPRng) col0 show gr
%% $F2psEnd
%% grestore
showpage

EOF