1 /* 2 * Copyright (c) 1984 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7 #if defined(LIBC_SCCS) && !defined(lint) 8 static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) 03/09/86"; 9 #endif LIBC_SCCS and not lint 10 11 #include <stdio.h> 12 13 fputs(s, iop) 14 register char *s; 15 register FILE *iop; 16 { 17 register r = 0; 18 register c; 19 int unbuffered; 20 char localbuf[BUFSIZ]; 21 22 unbuffered = iop->_flag & _IONBF; 23 if (unbuffered) { 24 iop->_flag &= ~_IONBF; 25 iop->_ptr = iop->_base = localbuf; 26 iop->_bufsiz = BUFSIZ; 27 } 28 29 while (c = *s++) 30 r = putc(c, iop); 31 32 if (unbuffered) { 33 fflush(iop); 34 iop->_flag |= _IONBF; 35 iop->_base = NULL; 36 iop->_bufsiz = NULL; 37 iop->_cnt = 0; 38 } 39 40 return(r); 41 } 42