update for HEAD-2003021201
[reactos.git] / lib / crtdll / stdio / fputws.c
1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <windows.h>
3 #include <msvcrt/stdio.h>
4 #include <msvcrt/internal/file.h>
5 #include <msvcrt/string.h>
6
7 //int fputws(const wchar_t* wsOutput, FILE* fileWrite)
8 //int fputs(const char *s, FILE *f)
9
10 int
11 fputws(const wchar_t* s, FILE* f)
12 {
13   int r = 0;
14   int c;
15   int unbuffered;
16   wchar_t localbuf[BUFSIZ];
17
18   unbuffered = f->_flag & _IONBF;
19   if (unbuffered)
20   {
21     f->_flag &= ~_IONBF;
22     f->_ptr = f->_base = localbuf;
23     f->_bufsiz = BUFSIZ;
24   }
25
26   while ((c = *s++))
27     r = putwc(c, f);
28
29   if (unbuffered)
30   {
31     fflush(f);
32     f->_flag |= _IONBF;
33     f->_base = NULL;
34     f->_bufsiz = 0;
35     f->_cnt = 0;
36   }
37   return(r);
38 }