tcharize a couple of routines
Modified: trunk/reactos/lib/crt/makefile
Modified: trunk/reactos/lib/crt/stdio/fopen.c
Modified: trunk/reactos/lib/crt/stdio/fprintf.c
Added: trunk/reactos/lib/crt/stdio/fwprintf.c
Added: trunk/reactos/lib/crt/stdio/wfopen.c

Modified: trunk/reactos/lib/crt/makefile
--- trunk/reactos/lib/crt/makefile	2005-03-01 22:13:40 UTC (rev 13790)
+++ trunk/reactos/lib/crt/makefile	2005-03-01 22:22:56 UTC (rev 13791)
@@ -274,7 +274,9 @@
 	stdio/fileno.o \
 	stdio/flsbuf.o \
 	stdio/fopen.o \
+	stdio/wfopen.o \
 	stdio/fprintf.o \
+	stdio/fwprintf.o \
 	stdio/fputc.o \
 	stdio/fputchar.o \
 	stdio/fputs.o \

Modified: trunk/reactos/lib/crt/stdio/fopen.c
--- trunk/reactos/lib/crt/stdio/fopen.c	2005-03-01 22:13:40 UTC (rev 13790)
+++ trunk/reactos/lib/crt/stdio/fopen.c	2005-03-01 22:22:56 UTC (rev 13791)
@@ -30,13 +30,14 @@
 #include <string.h>
 #include <io.h>
 #include <fcntl.h>
+#include <tchar.h>
 #include <internal/file.h>
 
 //might change fopen(file,mode) -> fsopen(file,mode,_SH_DENYNO);
 
 
 
-FILE* fopen(const char *file, const char *mode)
+FILE* _tfopen(const _TCHAR *file, const _TCHAR *mode)
 {
   FILE *f;
   int fd, rw, oflags = 0;
@@ -50,28 +51,28 @@
   if (f == NULL)
     return NULL;
 
-  rw = (strchr(mode, '+') == NULL) ? 0 : 1;
-  if (strchr(mode, 'a'))
+  rw = (_tcschr(mode, '+') == NULL) ? 0 : 1;
+  if (_tcschr(mode, 'a'))
     oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
-  if (strchr(mode, 'r'))
+  if (_tcschr(mode, 'r'))
     oflags = rw ? O_RDWR : O_RDONLY;
-  if (strchr(mode, 'w'))
+  if (_tcschr(mode, 'w'))
     oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
-  if (strchr(mode, 't'))
+  if (_tcschr(mode, 't'))
     oflags |= O_TEXT;
-  else if (strchr(mode, 'b'))
+  else if (_tcschr(mode, 'b'))
     oflags |= O_BINARY;
   else
     oflags |= (_fmode& (O_TEXT|O_BINARY));
 
-  fd = _open(file, oflags, 0);
+  fd = _topen(file, oflags, 0);
   if (fd < 0)
     return NULL;
 
 // msvcrt ensures that writes will end up at the end of file in append mode
 // we just move the file pointer to the end of file initially
 
-  if (strchr(mode, 'a'))
+  if (_tcschr(mode, 'a'))
     _lseek(fd, 0, SEEK_END);
 
   f->_cnt = 0;
@@ -79,14 +80,14 @@
   f->_bufsiz = 0;
   if (rw)
     f->_flag = _IOREAD | _IOWRT;
-  else if (strchr(mode, 'r'))
+  else if (_tcschr(mode, 'r'))
     f->_flag = _IOREAD;
   else
     f->_flag = _IOWRT;
 
-  if (strchr(mode, 't'))
+  if (_tcschr(mode, 't'))
     f->_flag |= _IOTEXT;
-  else if (strchr(mode, 'b'))
+  else if (_tcschr(mode, 'b'))
     f->_flag |= _IOBINARY;
   else if (_fmode& O_BINARY)
     f->_flag |= _IOBINARY;
@@ -94,64 +95,3 @@
   f->_base = f->_ptr = NULL;
   return f;
 }
-
-/*
- * @implemented
- */
-FILE* _wfopen(const wchar_t *file, const wchar_t *mode)
-{
-  FILE *f;
-  int fd, rw, oflags = 0;
-   
-  if (file == 0)
-    return 0;
-  if (mode == 0)
-    return 0;
-
-  f = __alloc_file();
-  if (f == NULL)
-    return NULL;
-
-  rw = (wcschr(mode, L'+') == NULL) ? 0 : 1;
-  if (wcschr(mode, L'a'))
-    oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
-  if (wcschr(mode, L'r'))
-    oflags = rw ? O_RDWR : O_RDONLY;
-  if (wcschr(mode, L'w'))
-    oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
-  if (wcschr(mode, L't'))
-    oflags |= O_TEXT;
-  else if (wcschr(mode, L'b'))
-    oflags |= O_BINARY;
-  else
-    oflags |= (_fmode& (O_TEXT|O_BINARY));
-
-  fd = _wopen(file, oflags, 0);
-  if (fd < 0)
-    return NULL;
-
-// msvcrt ensures that writes will end up at the end of file in append mode
-// we just move the file pointer to the end of file initially
-  if (wcschr(mode, 'a'))
-    _lseek(fd, 0, SEEK_END);
-
-  f->_cnt = 0;
-  f->_file = fd;
-  f->_bufsiz = 0;
-  if (rw)
-    f->_flag = _IOREAD | _IOWRT;
-  else if (wcschr(mode, L'r'))
-    f->_flag = _IOREAD;
-  else
-    f->_flag = _IOWRT;
-
-  if (wcschr(mode, L't'))
-    f->_flag |= _IOTEXT;
-  else if (wcschr(mode, L'b'))
-    f->_flag |= _IOBINARY;
-  else if (_fmode& O_BINARY)
-    f->_flag |= _IOBINARY;
-
-  f->_base = f->_ptr = NULL;
-  return f;
-}

Modified: trunk/reactos/lib/crt/stdio/fprintf.c
--- trunk/reactos/lib/crt/stdio/fprintf.c	2005-03-01 22:13:40 UTC (rev 13790)
+++ trunk/reactos/lib/crt/stdio/fprintf.c	2005-03-01 22:22:56 UTC (rev 13791)
@@ -1,16 +1,17 @@
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
 #include <wchar.h>
+#include <tchar.h>
 #include <internal/file.h>
 
 /*
  * @implemented
  */
 int
-fprintf(register FILE *iop, const char *fmt, ...)
+_ftprintf(register FILE *iop, const _TCHAR *fmt, ...)
 {
   int len;
-  char localbuf[BUFSIZ];
+  _TCHAR localbuf[BUFSIZ];
   va_list a=0;
   
 
@@ -18,38 +19,9 @@
   if (iop->_flag & _IONBF)
   {
     iop->_flag &= ~_IONBF;
-    iop->_ptr = iop->_base = localbuf;
-    iop->_bufsiz = BUFSIZ;
-    len = vfprintf(iop,fmt,a);
-    fflush(iop);
-    iop->_flag |= _IONBF;
-    iop->_base = NULL;
-    iop->_bufsiz = 0;
-    iop->_cnt = 0;
-  }
-  else
-    len = vfprintf(iop, fmt, a);
-  return ferror(iop) ? EOF : len;
-}
-
-/*
- * @implemented
- */
-int
-fwprintf(register FILE *iop, const wchar_t *fmt, ...)
-{
-  int len;
-  wchar_t localbuf[BUFSIZ];
-  va_list a=0;
-  
-
-  va_start( a, fmt ); 
-  if (iop->_flag & _IONBF)
-  {
-    iop->_flag &= ~_IONBF;
     iop->_ptr = iop->_base = (char *)localbuf;
     iop->_bufsiz = BUFSIZ;
-    len = vfwprintf(iop,fmt,a);
+    len = _vftprintf(iop,fmt,a);
     fflush(iop);
     iop->_flag |= _IONBF;
     iop->_base = NULL;
@@ -57,6 +29,6 @@
     iop->_cnt = 0;
   }
   else
-    len = vfwprintf(iop, fmt, a);
-  return ferror(iop) ? EOF : len;
+    len = _vftprintf(iop, fmt, a);
+  return ferror(iop) ? -1 : len;
 }

Added: trunk/reactos/lib/crt/stdio/fwprintf.c
--- trunk/reactos/lib/crt/stdio/fwprintf.c	2005-03-01 22:13:40 UTC (rev 13790)
+++ trunk/reactos/lib/crt/stdio/fwprintf.c	2005-03-01 22:22:56 UTC (rev 13791)
@@ -0,0 +1,4 @@
+#define UNICODE
+#define _UNICODE
+
+#include "fprintf.c"

Added: trunk/reactos/lib/crt/stdio/wfopen.c
--- trunk/reactos/lib/crt/stdio/wfopen.c	2005-03-01 22:13:40 UTC (rev 13790)
+++ trunk/reactos/lib/crt/stdio/wfopen.c	2005-03-01 22:22:56 UTC (rev 13791)
@@ -0,0 +1,4 @@
+#define UNICODE
+#define _UNICODE
+
+#include "fopen.c"