0
|
1 ************************************************************
|
|
2 * TEE - Tees input to multiple outputs
|
|
3 *
|
|
4 * By: Boisy G. Pitre
|
|
5 * Southern Station, Box 8455
|
|
6 * Hattiesburg, MS 39406-8455
|
|
7 * Internet: bgpitre@seabass.st.usm.edu
|
|
8 *
|
|
9 * Usage: Tee <dev> [...] [...]
|
|
10 *
|
|
11 * Tee accepts input from StdIn. You may use a pipe to send it information,
|
|
12 * or use the '<' operator of the shell to redirect StdIn.
|
|
13 *
|
|
14
|
|
15 nam Tee
|
|
16 ttl Tees input to multiple outputs
|
|
17
|
|
18 ifp1
|
|
19 use defsfile
|
|
20 endc
|
|
21
|
1260
|
22 mod Size,Name,Prgrm+Objct,ReEnt+1,Start,Fin
|
|
23
|
0
|
24 Name fcs "Tee"
|
1260
|
25 fcb $03 Replaces Tandy's Edition #2
|
0
|
26
|
|
27 PathCnt rmb 1
|
|
28 BuffSize rmb 2
|
|
29 StdOut rmb 1 StdOut path...
|
|
30 PathStk rmb 40 +40 = Handles 41 paths in all!
|
|
31 Buffer rmb 250 Max. chars per line
|
|
32 Stack rmb 200
|
|
33 Parms rmb 200
|
|
34 Fin equ .
|
|
35
|
|
36 Start lda #1
|
|
37 sta PathCnt,u store a 1 in the path counter buffer
|
|
38 sta StdOut,u and the StdOut buffer
|
|
39 leay PathStk,u Position Y on the path queue
|
|
40
|
1260
|
41 GetNext lda #WRITE. Set mode to write only
|
|
42 ldb #UPDAT.+PREAD. owner read/write, other read
|
0
|
43 os9 I$Create create the path
|
|
44 bcs Error exit if error
|
|
45
|
|
46 sta ,y+ store the path on path stack, inc Y
|
|
47 inc PathCnt,u inc path counter
|
|
48
|
|
49 CheckCR lda ,x See if last param on line
|
1260
|
50 cmpa #C$CR if cr, must be last parm
|
0
|
51 beq GoTee so start teeing out
|
|
52 leax 1,x inc X
|
|
53 bra CheckCR and check again
|
|
54
|
|
55 EOF cmpb #E$EOF Check for end-of-file
|
|
56 bne Error nope, other error, abort
|
|
57
|
|
58 Done clrb else clear out nicely...
|
|
59 Error os9 F$Exit and exit!
|
|
60
|
|
61 GoTee clra use StdIn
|
|
62 ldy #250 Buffer holds 250 chars. per line
|
|
63 leax Buffer,u point X to buffer
|
|
64 os9 I$ReadLn read a line from stdin
|
|
65 bcs EOF check EOF if error
|
|
66 sty BuffSize,u else save bytes read
|
|
67 ldb PathCnt,u load B with the Path counter value
|
|
68 leay StdOut,u position Y at the StdOut path (1st)
|
|
69
|
|
70 Service lda ,y+ load A with path number
|
|
71 pshs y save Y
|
|
72 ldy BuffSize,u get buffer size
|
|
73 os9 I$WritLn write out
|
|
74 bcs Error Error if exit
|
|
75 puls y get Y
|
|
76 decb decrement B
|
|
77 bne Service if not 0, service next path
|
|
78 bra GoTee else get more input from StdIn
|
|
79
|
|
80 emod
|
|
81 Size equ *
|
|
82 end
|
1260
|
83
|