xref: /csrg-svn/usr.bin/window/ttoutput.c (revision 16537)
1 #ifndef lint
2 static char sccsid[] = "@(#)ttoutput.c	3.2 05/23/84";
3 #endif
4 
5 #include "ww.h"
6 #include "tt.h"
7 #include <sys/errno.h>
8 
9 /*
10  * Buffered output package.
11  * We need this because stdio fails on non-blocking writes.
12  */
13 
14 ttflush()
15 {
16 	register char *p;
17 	register n;
18 	extern errno;
19 
20 	wwnflush++;
21 	for (p = tt_ob; p < tt_obp;) {
22 		wwnwr++;
23 		n = write(1, p, tt_obp - p);
24 		if (n < 0) {
25 			wwnwre++;
26 			if (errno != EWOULDBLOCK) {
27 				/* can't deal with this */
28 				p = tt_obp;
29 			}
30 		} else if (n == 0) {
31 			/* what to do? */
32 			wwnwrz++;
33 		} else {
34 			wwnwrc += n;
35 			p += n;
36 		}
37 	}
38 	tt_obp = tt_ob;
39 }
40 
41 ttputs(s)
42 register char *s;
43 {
44 	while (*s)
45 		ttputc(*s++);
46 }
47