1 #ifndef lint 2 static char sccsid[] = "@(#)ttoutput.c 3.3 04/24/85"; 3 #endif 4 5 /* 6 * Copyright (c) 1983 Regents of the University of California, 7 * All rights reserved. Redistribution permitted subject to 8 * the terms of the Berkeley Software License Agreement. 9 */ 10 11 #include "ww.h" 12 #include "tt.h" 13 #include <sys/errno.h> 14 15 /* 16 * Buffered output package. 17 * We need this because stdio fails on non-blocking writes. 18 */ 19 20 ttflush() 21 { 22 register char *p; 23 register n; 24 extern errno; 25 26 wwnflush++; 27 for (p = tt_ob; p < tt_obp;) { 28 wwnwr++; 29 n = write(1, p, tt_obp - p); 30 if (n < 0) { 31 wwnwre++; 32 if (errno != EWOULDBLOCK) { 33 /* can't deal with this */ 34 p = tt_obp; 35 } 36 } else if (n == 0) { 37 /* what to do? */ 38 wwnwrz++; 39 } else { 40 wwnwrc += n; 41 p += n; 42 } 43 } 44 tt_obp = tt_ob; 45 } 46 47 ttputs(s) 48 register char *s; 49 { 50 while (*s) 51 ttputc(*s++); 52 } 53