- Cleanup the /lib directory, by putting more 3rd-party libs in /3rdparty, and by...
[reactos.git] / reactos / lib / sdk / crt / stdio / fputs.c
1 /* $Id$
2 *
3 * ReactOS msvcrt library
4 *
5 * fputs.c
6 *
7 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 *
9 * Based on original work Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
10 * 28/12/1998: Appropriated for Reactos
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
27
28 #include <precomp.h>
29 #include <tchar.h>
30
31 int
32 _fputts(const _TCHAR *s, FILE *f)
33 {
34 int r = 0;
35 int c;
36 int unbuffered;
37 _TCHAR localbuf[BUFSIZ];
38
39 unbuffered = f->_flag & _IONBF;
40 if (unbuffered)
41 {
42 f->_flag &= ~_IONBF;
43 f->_ptr = f->_base = (char*)localbuf;
44 f->_bufsiz = BUFSIZ;
45 }
46
47 while ((c = *s++))
48 r = _puttc(c, f);
49
50 if (unbuffered)
51 {
52 fflush(f);
53 f->_flag |= _IONBF;
54 f->_base = NULL;
55 f->_bufsiz = 0;
56 f->_cnt = 0;
57 }
58
59 return(r);
60 }
61