Commit | Line | Data |
---|---|---|
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 | ||
2ce81398 DS |
7 | #if defined(LIBC_SCCS) && !defined(lint) |
8 | static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) %G%"; | |
9 | #endif LIBC_SCCS and not lint | |
b8f253e8 | 10 | |
00c89ac3 BJ |
11 | #include <stdio.h> |
12 | ||
13 | fputs(s, iop) | |
14 | register char *s; | |
15 | register 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 | } |