Add copyright
[unix-history] / usr / src / lib / libc / stdio / fputs.c
CommitLineData
b8f253e8
KM
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#ifndef lint
8static char sccsid[] = "@(#)fputs.c 5.1 (Berkeley) %G%";
9#endif not lint
10
00c89ac3
BJ
11#include <stdio.h>
12
13fputs(s, iop)
14register char *s;
15register FILE *iop;
16{
7b9f9d12 17 register r = 0;
00c89ac3 18 register c;
41e01b3e
S
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 }
00c89ac3
BJ
28
29 while (c = *s++)
30 r = putc(c, iop);
41e01b3e
S
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
00c89ac3
BJ
40 return(r);
41}