1*48269Sbostic /*- 2*48269Sbostic * Copyright (c) 1983 The Regents of the University of California. 3*48269Sbostic * All rights reserved. 4*48269Sbostic * 5*48269Sbostic * %sccs.include.proprietary.c% 6*48269Sbostic */ 7*48269Sbostic 811266Smckusick #ifndef lint 9*48269Sbostic static char sccsid[] = "@(#)tee.c 4.3 (Berkeley) 04/17/91"; 10*48269Sbostic #endif /* not lint */ 1111266Smckusick 1211266Smckusick #include <stdio.h> 1311266Smckusick main() 1411266Smckusick { 1511266Smckusick int f, c; 1611266Smckusick 1711266Smckusick f = creat(".ocopy", 0666); 1811266Smckusick while (read(0, &c, 1) == 1) { 1911266Smckusick write (1, &c, 1); 2011266Smckusick put(c, f); 2111266Smckusick } 2211266Smckusick fl(f); 2311266Smckusick close(f); 2411266Smckusick } 2511266Smckusick 2611266Smckusick static char ln[BUFSIZ]; 2711266Smckusick char *p = ln; 2811266Smckusick put(c, f) 2911266Smckusick { 3011266Smckusick *p++ = c; 3111266Smckusick if (c == '\n') { 3211266Smckusick fl(f); 3311266Smckusick p=ln; 3411266Smckusick } 3511266Smckusick } 3611266Smckusick fl(f) 3711266Smckusick { 3811266Smckusick register char *s; 3911266Smckusick 4011266Smckusick s = ln; 4111266Smckusick while (*s == '$' && *(s+1) == ' ') 4211266Smckusick s += 2; 4311266Smckusick write(f, s, p-s); 4411266Smckusick } 45