1 /*- 2 * Copyright (c) 1983 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)tee.c 4.3 (Berkeley) 04/17/91"; 10 #endif /* not lint */ 11 12 #include <stdio.h> 13 main() 14 { 15 int f, c; 16 17 f = creat(".ocopy", 0666); 18 while (read(0, &c, 1) == 1) { 19 write (1, &c, 1); 20 put(c, f); 21 } 22 fl(f); 23 close(f); 24 } 25 26 static char ln[BUFSIZ]; 27 char *p = ln; 28 put(c, f) 29 { 30 *p++ = c; 31 if (c == '\n') { 32 fl(f); 33 p=ln; 34 } 35 } 36 fl(f) 37 { 38 register char *s; 39 40 s = ln; 41 while (*s == '$' && *(s+1) == ' ') 42 s += 2; 43 write(f, s, p-s); 44 } 45