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
|
|
22 mod Size,Name,Prgrm+Objct,Reent+1,Start,Fin
|
|
23 Name fcs "Tee"
|
|
24 Ed fcb $03 Replaces Tandy's Edition #2
|
|
25
|
|
26 PathCnt rmb 1
|
|
27 BuffSize rmb 2
|
|
28 StdOut rmb 1 StdOut path...
|
|
29 PathStk rmb 40 +40 = Handles 41 paths in all!
|
|
30 Buffer rmb 250 Max. chars per line
|
|
31 Stack rmb 200
|
|
32 Parms rmb 200
|
|
33 Fin equ .
|
|
34
|
|
35 Start lda #1
|
|
36 sta PathCnt,u store a 1 in the path counter buffer
|
|
37 sta StdOut,u and the StdOut buffer
|
|
38 leay PathStk,u Position Y on the path queue
|
|
39
|
|
40 GetNext lda #write. Set mode to write only
|
|
41 ldb #read.+write.+pread. owner read/write, other read
|
|
42 os9 I$Create create the path
|
|
43 bcs Error exit if error
|
|
44
|
|
45 sta ,y+ store the path on path stack, inc Y
|
|
46 inc PathCnt,u inc path counter
|
|
47
|
|
48 CheckCR lda ,x See if last param on line
|
|
49 cmpa #$0d if cr, must be last parm
|
|
50 beq GoTee so start teeing out
|
|
51 leax 1,x inc X
|
|
52 bra CheckCR and check again
|
|
53
|
|
54 EOF cmpb #E$EOF Check for end-of-file
|
|
55 bne Error nope, other error, abort
|
|
56
|
|
57 Done clrb else clear out nicely...
|
|
58 Error os9 F$Exit and exit!
|
|
59
|
|
60 GoTee clra use StdIn
|
|
61 ldy #250 Buffer holds 250 chars. per line
|
|
62 leax Buffer,u point X to buffer
|
|
63 os9 I$ReadLn read a line from stdin
|
|
64 bcs EOF check EOF if error
|
|
65 sty BuffSize,u else save bytes read
|
|
66 ldb PathCnt,u load B with the Path counter value
|
|
67 leay StdOut,u position Y at the StdOut path (1st)
|
|
68
|
|
69 Service lda ,y+ load A with path number
|
|
70 pshs y save Y
|
|
71 ldy BuffSize,u get buffer size
|
|
72 os9 I$WritLn write out
|
|
73 bcs Error Error if exit
|
|
74 puls y get Y
|
|
75 decb decrement B
|
|
76 bne Service if not 0, service next path
|
|
77 bra GoTee else get more input from StdIn
|
|
78
|
|
79 emod
|
|
80 Size equ *
|
|
81 end
|