xref: /csrg-svn/lib/libc/stdio/fputs.c (revision 17951)
1 /* @(#)fputs.c	4.3 (Berkeley) 02/13/85 */
2 #include	<stdio.h>
3 
4 fputs(s, iop)
5 register char *s;
6 register FILE *iop;
7 {
8 	register r = 0;
9 	register c;
10 	int unbuffered;
11 	char localbuf[BUFSIZ];
12 
13 	unbuffered = iop->_flag & _IONBF;
14 	if (unbuffered) {
15 		iop->_flag &= ~_IONBF;
16 		iop->_ptr = iop->_base = localbuf;
17 		iop->_bufsiz = BUFSIZ;
18 	}
19 
20 	while (c = *s++)
21 		r = putc(c, iop);
22 
23 	if (unbuffered) {
24 		fflush(iop);
25 		iop->_flag |= _IONBF;
26 		iop->_base = NULL;
27 		iop->_bufsiz = NULL;
28 		iop->_cnt = 0;
29 	}
30 
31 	return(r);
32 }
33