update for HEAD-2003021201
[reactos.git] / lib / crtdll / stdio / fputws.c
diff --git a/lib/crtdll/stdio/fputws.c b/lib/crtdll/stdio/fputws.c
new file mode 100644 (file)
index 0000000..399ac41
--- /dev/null
@@ -0,0 +1,38 @@
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <windows.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/internal/file.h>
+#include <msvcrt/string.h>
+
+//int fputws(const wchar_t* wsOutput, FILE* fileWrite)
+//int fputs(const char *s, FILE *f)
+
+int
+fputws(const wchar_t* s, FILE* f)
+{
+  int r = 0;
+  int c;
+  int unbuffered;
+  wchar_t localbuf[BUFSIZ];
+
+  unbuffered = f->_flag & _IONBF;
+  if (unbuffered)
+  {
+    f->_flag &= ~_IONBF;
+    f->_ptr = f->_base = localbuf;
+    f->_bufsiz = BUFSIZ;
+  }
+
+  while ((c = *s++))
+    r = putwc(c, f);
+
+  if (unbuffered)
+  {
+    fflush(f);
+    f->_flag |= _IONBF;
+    f->_base = NULL;
+    f->_bufsiz = 0;
+    f->_cnt = 0;
+  }
+  return(r);
+}