#-h- teesym 189 asc 08-may-80 11:14:56 # symbols definitions for tee # put on a file called 'teesym' # used only by the tee tool define(MAXTEEFILES,3) #Number of output files allowed #(should be max nbr open files - 3) #-h- tee.r 1023 asc 08-may-80 11:14:56 #-h- main 306 asc 08-may-80 11:14:49 #--------------------------------------------------------------------- # include symbol definitions # include symbols include teesym #--------------------------------------------------------------------- ## main - calling routine for tee # call initr4 # call tee # call endr4 # end #-h- tees 619 asc 08-may-80 11:14:49 ## tee - copy input to standard output and named files # subroutine tee subroutine main integer files (MAXTEEFILES) integer nf, int, i integer getarg, create character buf(MAXLINE) character getc character c nf = 0 for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == QMARK & buf(2) == EOS) call error ('usage: tee [file ...].') nf = nf + 1 if (nf > MAXTEEFILES) call error ('too many files.') files(nf) = create(buf,WRITE) if (files(nf) == ERR) call cant(buf) } while(getc(c) != EOF) { call putch(c,STDOUT) for (i=1; i<=nf; i=i+1) call putch(c, files(i)) } return end