122133Smckusick /* 222133Smckusick * Copyright (c) 1984 Regents of the University of California. 322133Smckusick * All rights reserved. The Berkeley software License Agreement 422133Smckusick * specifies the terms and conditions for redistribution. 522133Smckusick */ 622133Smckusick 7*26650Sdonn #if defined(LIBC_SCCS) && !defined(lint) 8*26650Sdonn static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) 03/09/86"; 9*26650Sdonn #endif LIBC_SCCS and not lint 1022133Smckusick 112007Swnj #include <stdio.h> 122007Swnj 132007Swnj fputs(s, iop) 142007Swnj register char *s; 152007Swnj register FILE *iop; 162007Swnj { 1717201Slepreau register r = 0; 182007Swnj register c; 1917951Sserge int unbuffered; 2017951Sserge char localbuf[BUFSIZ]; 212007Swnj 2217951Sserge unbuffered = iop->_flag & _IONBF; 2317951Sserge if (unbuffered) { 2417951Sserge iop->_flag &= ~_IONBF; 2517951Sserge iop->_ptr = iop->_base = localbuf; 2617951Sserge iop->_bufsiz = BUFSIZ; 2717951Sserge } 2817951Sserge 292007Swnj while (c = *s++) 302007Swnj r = putc(c, iop); 3117951Sserge 3217951Sserge if (unbuffered) { 3317951Sserge fflush(iop); 3417951Sserge iop->_flag |= _IONBF; 3517951Sserge iop->_base = NULL; 3617951Sserge iop->_bufsiz = NULL; 3717951Sserge iop->_cnt = 0; 3817951Sserge } 3917951Sserge 402007Swnj return(r); 412007Swnj } 42