ntdll:
-critical.c: catch (more) invalid use
-impl. sscanf (stolen from wine)
crt:
-use native mingw headers and not private copies of them
-converted some routines to using tchar == impl. many missing unicode routines
-impl. sscanf and friends correctly (stolen from wine)
tchar.h:
-added lotsa missin stuff
Modified: trunk/reactos/lib/crt/conio/cgets.c
Modified: trunk/reactos/lib/crt/conio/cprintf.c
Modified: trunk/reactos/lib/crt/conio/cputs.c
Deleted: trunk/reactos/lib/crt/conio/cscanf.c
Modified: trunk/reactos/lib/crt/conio/getch.c
Modified: trunk/reactos/lib/crt/conio/getche.c
Modified: trunk/reactos/lib/crt/conio/kbhit.c
Modified: trunk/reactos/lib/crt/conio/putch.c
Modified: trunk/reactos/lib/crt/conio/ungetch.c
Modified: trunk/reactos/lib/crt/ctype/ctype.c
Modified: trunk/reactos/lib/crt/ctype/isalnum.c
Modified: trunk/reactos/lib/crt/ctype/isalpha.c
Modified: trunk/reactos/lib/crt/ctype/isascii.c
Modified: trunk/reactos/lib/crt/ctype/iscntrl.c
Modified: trunk/reactos/lib/crt/ctype/iscsym.c
Modified: trunk/reactos/lib/crt/ctype/isctype.c
Modified: trunk/reactos/lib/crt/ctype/isdigit.c
Modified: trunk/reactos/lib/crt/ctype/isgraph.c
Modified: trunk/reactos/lib/crt/ctype/islower.c
Modified: trunk/reactos/lib/crt/ctype/isprint.c
Modified: trunk/reactos/lib/crt/ctype/ispunct.c
Modified: trunk/reactos/lib/crt/ctype/isspace.c
Modified: trunk/reactos/lib/crt/ctype/isupper.c
Modified: trunk/reactos/lib/crt/ctype/isxdigit.c
Modified: trunk/reactos/lib/crt/ctype/toascii.c
Modified: trunk/reactos/lib/crt/ctype/tolower.c
Modified: trunk/reactos/lib/crt/ctype/toupper.c
Modified: trunk/reactos/lib/crt/direct/chdir.c
Modified: trunk/reactos/lib/crt/direct/chdrive.c
Modified: trunk/reactos/lib/crt/direct/getcwd.c
Modified: trunk/reactos/lib/crt/direct/getdcwd.c
Modified: trunk/reactos/lib/crt/direct/getdfree.c
Modified: trunk/reactos/lib/crt/direct/getdrive.c
Modified: trunk/reactos/lib/crt/direct/mkdir.c
Modified: trunk/reactos/lib/crt/direct/rmdir.c
Modified: trunk/reactos/lib/crt/direct/wchdir.c
Modified: trunk/reactos/lib/crt/direct/wgetcwd.c
Modified: trunk/reactos/lib/crt/direct/wgetdcwd.c
Modified: trunk/reactos/lib/crt/direct/wmkdir.c
Modified: trunk/reactos/lib/crt/direct/wrmdir.c
Modified: trunk/reactos/lib/crt/float/chgsign.c
Modified: trunk/reactos/lib/crt/float/clearfp.c
Modified: trunk/reactos/lib/crt/float/cntrlfp.c
Modified: trunk/reactos/lib/crt/float/copysign.c
Modified: trunk/reactos/lib/crt/float/fpclass.c
Modified: trunk/reactos/lib/crt/float/fpecode.c
Modified: trunk/reactos/lib/crt/float/fpreset.c
Modified: trunk/reactos/lib/crt/float/isnan.c
Modified: trunk/reactos/lib/crt/float/logb.c
Modified: trunk/reactos/lib/crt/float/nafter.c
Modified: trunk/reactos/lib/crt/float/scalb.c
Modified: trunk/reactos/lib/crt/float/statfp.c
Modified: trunk/reactos/lib/crt/io/access.c
Modified: trunk/reactos/lib/crt/io/chmod.c
Modified: trunk/reactos/lib/crt/io/chsize.c
Modified: trunk/reactos/lib/crt/io/close.c
Modified: trunk/reactos/lib/crt/io/commit.c
Modified: trunk/reactos/lib/crt/io/create.c
Modified: trunk/reactos/lib/crt/io/dup.c
Modified: trunk/reactos/lib/crt/io/dup2.c
Modified: trunk/reactos/lib/crt/io/eof.c
Modified: trunk/reactos/lib/crt/io/filelen.c
Modified: trunk/reactos/lib/crt/io/fileleni.c
Modified: trunk/reactos/lib/crt/io/find.c
Modified: trunk/reactos/lib/crt/io/fmode.c
Modified: trunk/reactos/lib/crt/io/isatty.c
Modified: trunk/reactos/lib/crt/io/locking.c
Modified: trunk/reactos/lib/crt/io/lseek.c
Modified: trunk/reactos/lib/crt/io/lseeki64.c
Modified: trunk/reactos/lib/crt/io/mktemp.c
Modified: trunk/reactos/lib/crt/io/open.c
Modified: trunk/reactos/lib/crt/io/pipe.c
Modified: trunk/reactos/lib/crt/io/read.c
Modified: trunk/reactos/lib/crt/io/setmode.c
Modified: trunk/reactos/lib/crt/io/sopen.c
Modified: trunk/reactos/lib/crt/io/tell.c
Modified: trunk/reactos/lib/crt/io/telli64.c
Modified: trunk/reactos/lib/crt/io/umask.c
Modified: trunk/reactos/lib/crt/io/unlink.c
Modified: trunk/reactos/lib/crt/io/utime.c
Modified: trunk/reactos/lib/crt/io/waccess.c
Modified: trunk/reactos/lib/crt/io/wchmod.c
Modified: trunk/reactos/lib/crt/io/wcreate.c
Modified: trunk/reactos/lib/crt/io/wfind.c
Modified: trunk/reactos/lib/crt/io/wmktemp.c
Modified: trunk/reactos/lib/crt/io/wopen.c
Modified: trunk/reactos/lib/crt/io/write.c
Modified: trunk/reactos/lib/crt/io/wunlink.c
Modified: trunk/reactos/lib/crt/io/wutime.c
Modified: trunk/reactos/lib/crt/locale/locale.c
Modified: trunk/reactos/lib/crt/makefile
Modified: trunk/reactos/lib/crt/math/acos.c
Modified: trunk/reactos/lib/crt/math/asin.c
Modified: trunk/reactos/lib/crt/math/atan.c
Modified: trunk/reactos/lib/crt/math/atan2.c
Modified: trunk/reactos/lib/crt/math/cabs.c
Modified: trunk/reactos/lib/crt/math/ceil.c
Modified: trunk/reactos/lib/crt/math/cos.c
Modified: trunk/reactos/lib/crt/math/cosh.c
Modified: trunk/reactos/lib/crt/math/exp.c
[truncated at 100 lines; 288 more skipped]
Modified: trunk/reactos/lib/crt/conio/cgets.c
--- trunk/reactos/lib/crt/conio/cgets.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/cgets.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,8 +6,8 @@
  * PROGRAMMER:       Eric Kohl (Imported from DJGPP)
  */
 
-#include <msvcrt/conio.h>
-#include <msvcrt/stdlib.h>
+#include <conio.h>
+#include <stdlib.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/conio/cprintf.c
--- trunk/reactos/lib/crt/conio/cprintf.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/cprintf.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,8 +6,9 @@
  * PROGRAMMER:       Eric Kohl (Imported from DJGPP)
  */
 
-#include <msvcrt/stdio.h>
-#include <msvcrt/conio.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <conio.h>
 
 /*
  * @unimplemented

Modified: trunk/reactos/lib/crt/conio/cputs.c
--- trunk/reactos/lib/crt/conio/cputs.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/cputs.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -9,10 +9,10 @@
  */
 
 #include "precomp.h"
-#include <msvcrt/conio.h>
-#include <msvcrt/string.h>
-#include <msvcrt/stdio.h>
-#include <msvcrt/internal/file.h>
+#include <conio.h>
+#include <string.h>
+#include <stdio.h>
+#include <internal/file.h>
 
 
 /*
@@ -22,7 +22,7 @@
 {
   int len = strlen(_str);
   DWORD written = 0;
-  if (!WriteFile(filehnd(stdout->_file),_str,len,&written,NULL))
+  if (!WriteFile( fdinfo(stdout->_file)->hFile ,_str,len,&written,NULL))
     return -1;
   return 0;
 }

Deleted: trunk/reactos/lib/crt/conio/cscanf.c
--- trunk/reactos/lib/crt/conio/cscanf.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/cscanf.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,29 +0,0 @@
-/*
- * COPYRIGHT:        See COPYING in the top level directory
- * PROJECT:          ReactOS kernel
- * FILE:             msvcrt/conio/cscanf.c
- * PURPOSE:          C Runtime
- * PROGRAMMER:       Eric Kohl (Imported from DJGPP)
- */
-
-#include <msvcrt/conio.h>
-#include <msvcrt/stdarg.h>
-#include <msvcrt/stdio.h>
-#include <msvcrt/internal/stdio.h>
-
-/*
- * @unimplemented
- */
-int _cscanf(char *fmt, ...)
-{
-    int cnt;
-
-    va_list ap;
-
-    //fixme cscanf should scan the console's keyboard
-    va_start(ap, fmt);
-    cnt = __vscanf(fmt, ap);
-    va_end(ap);
-
-    return cnt;
-}

Modified: trunk/reactos/lib/crt/conio/getch.c
--- trunk/reactos/lib/crt/conio/getch.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/getch.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -9,10 +9,10 @@
  */
 
 #include "precomp.h"
-#include <msvcrt/conio.h>
-#include <msvcrt/stdio.h>
-#include <msvcrt/io.h>
-#include <msvcrt/internal/console.h>
+#include <conio.h>
+#include <stdio.h>
+#include <io.h>
+#include <internal/console.h>
 
 
 /*
@@ -26,7 +26,7 @@
         c = ungot_char;
         char_avail = 0;
     } else {
-        ReadConsoleA(_get_osfhandle(stdin->_file),
+        ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
 		             &c,
 		             1,
 		             &NumberOfCharsRead,

Modified: trunk/reactos/lib/crt/conio/getche.c
--- trunk/reactos/lib/crt/conio/getche.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/getche.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -10,11 +10,11 @@
  *              28/12/98: Created
  */
 
-#include <msvcrt/conio.h>
-#include <msvcrt/internal/console.h>
+#include <conio.h>
+#include <internal/console.h>
 
 
-int getche(void)
+int _getche(void)
 {
   if (char_avail)
     /*
@@ -26,6 +26,6 @@
      * hasn't been got by a conio function.
      * We don't echo again.
      */ 
-    return(getch());
-  return (_putch(getch()));
+    return(_getch());
+  return (_putch(_getch()));
 }

Modified: trunk/reactos/lib/crt/conio/kbhit.c
--- trunk/reactos/lib/crt/conio/kbhit.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/kbhit.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -9,8 +9,8 @@
  */
 
 #include "precomp.h"
-#include <msvcrt/conio.h>
-#include <msvcrt/internal/console.h>
+#include <conio.h>
+#include <internal/console.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/conio/putch.c
--- trunk/reactos/lib/crt/conio/putch.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/putch.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -9,7 +9,7 @@
  */
 
 #include "precomp.h"
-#include <msvcrt/conio.h>
+#include <conio.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/conio/ungetch.c
--- trunk/reactos/lib/crt/conio/ungetch.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/conio/ungetch.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -10,8 +10,8 @@
  *              28/12/98: Created
  */
 
-#include <msvcrt/conio.h>
-#include <msvcrt/internal/console.h>
+#include <conio.h>
+#include <internal/console.h>
 
 #define EOF -1
 

Modified: trunk/reactos/lib/crt/ctype/ctype.c
--- trunk/reactos/lib/crt/ctype/ctype.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/ctype.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 unsigned short _ctype[] = {
 	0,			/* <EOF>, 0xFFFF */

Modified: trunk/reactos/lib/crt/ctype/isalnum.c
--- trunk/reactos/lib/crt/ctype/isalnum.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isalnum.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -7,7 +7,7 @@
  * UPDATE HISTORY:
  *              28/12/98: Created
  */
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 #undef isalnum

Modified: trunk/reactos/lib/crt/ctype/isalpha.c
--- trunk/reactos/lib/crt/ctype/isalpha.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isalpha.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -8,7 +8,7 @@
  *              28/12/98: Created
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 #undef isalpha

Modified: trunk/reactos/lib/crt/ctype/isascii.c
--- trunk/reactos/lib/crt/ctype/isascii.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isascii.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -8,7 +8,7 @@
  *              28/12/98: Created
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/ctype/iscntrl.c
--- trunk/reactos/lib/crt/ctype/iscntrl.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/iscntrl.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef iscntrl
 /*

Modified: trunk/reactos/lib/crt/ctype/iscsym.c
--- trunk/reactos/lib/crt/ctype/iscsym.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/iscsym.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -7,7 +7,7 @@
  * UPDATE HISTORY:
  *              28/12/98: Created
  */
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/ctype/isctype.c
--- trunk/reactos/lib/crt/ctype/isctype.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isctype.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
  
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 extern unsigned short _ctype[];
@@ -34,7 +34,7 @@
 /*
  * @implemented
  */
-int _isctype(unsigned int c, int ctypeFlags)
+int _isctype(int c, int ctypeFlags)
 {
    return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
 }

Modified: trunk/reactos/lib/crt/ctype/isdigit.c
--- trunk/reactos/lib/crt/ctype/isdigit.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isdigit.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 #undef isdigit

Modified: trunk/reactos/lib/crt/ctype/isgraph.c
--- trunk/reactos/lib/crt/ctype/isgraph.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isgraph.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef isgraph
 /*

Modified: trunk/reactos/lib/crt/ctype/islower.c
--- trunk/reactos/lib/crt/ctype/islower.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/islower.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 #undef islower

Modified: trunk/reactos/lib/crt/ctype/isprint.c
--- trunk/reactos/lib/crt/ctype/isprint.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isprint.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef isprint
 /*

Modified: trunk/reactos/lib/crt/ctype/ispunct.c
--- trunk/reactos/lib/crt/ctype/ispunct.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/ispunct.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef ispunct
 /*

Modified: trunk/reactos/lib/crt/ctype/isspace.c
--- trunk/reactos/lib/crt/ctype/isspace.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isspace.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -8,7 +8,7 @@
  *              28/12/98: Created
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 
 #undef isspace

Modified: trunk/reactos/lib/crt/ctype/isupper.c
--- trunk/reactos/lib/crt/ctype/isupper.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isupper.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef isupper
 /*

Modified: trunk/reactos/lib/crt/ctype/isxdigit.c
--- trunk/reactos/lib/crt/ctype/isxdigit.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/isxdigit.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef isxdigit
 /*

Modified: trunk/reactos/lib/crt/ctype/toascii.c
--- trunk/reactos/lib/crt/ctype/toascii.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/toascii.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/ctype/tolower.c
--- trunk/reactos/lib/crt/ctype/tolower.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/tolower.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef tolower
 /*

Modified: trunk/reactos/lib/crt/ctype/toupper.c
--- trunk/reactos/lib/crt/ctype/toupper.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/ctype/toupper.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -6,7 +6,7 @@
  * PROGRAMMER:       Copyright (C) 1995 DJ Delorie
  */
 
-#include <msvcrt/ctype.h>
+#include <ctype.h>
 
 #undef toupper
 /*

Modified: trunk/reactos/lib/crt/direct/chdir.c
--- trunk/reactos/lib/crt/direct/chdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/chdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,7 +1,7 @@
 #include "precomp.h"
-#include <msvcrt/ctype.h>
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <ctype.h>
+#include <direct.h>
+#include <internal/file.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/direct/chdrive.c
--- trunk/reactos/lib/crt/direct/chdrive.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/chdrive.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,9 +1,9 @@
 #include "precomp.h"
-#include <msvcrt/ctype.h>
-#include <msvcrt/direct.h>
-#include <msvcrt/stdlib.h>
-#include <msvcrt/errno.h>
-#include <msvcrt/internal/file.h>
+#include <ctype.h>
+#include <direct.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <internal/file.h>
 
 
 int cur_drive = 0;

Modified: trunk/reactos/lib/crt/direct/getcwd.c
--- trunk/reactos/lib/crt/direct/getcwd.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/getcwd.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,8 +1,8 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/stdlib.h>
-#include <msvcrt/errno.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/getdcwd.c
--- trunk/reactos/lib/crt/direct/getdcwd.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/getdcwd.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/direct/getdfree.c
--- trunk/reactos/lib/crt/direct/getdfree.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/getdfree.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/ctype.h>
-#include <msvcrt/direct.h>
+#include <ctype.h>
+#include <direct.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/getdrive.c
--- trunk/reactos/lib/crt/direct/getdrive.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/getdrive.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/ctype.h>
-#include <msvcrt/direct.h>
+#include <ctype.h>
+#include <direct.h>
 
 
 extern int cur_drive;

Modified: trunk/reactos/lib/crt/direct/mkdir.c
--- trunk/reactos/lib/crt/direct/mkdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/mkdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/rmdir.c
--- trunk/reactos/lib/crt/direct/rmdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/rmdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/wchdir.c
--- trunk/reactos/lib/crt/direct/wchdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/wchdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,8 +1,7 @@
 #include "precomp.h"
-#include <msvcrt/ctype.h>
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
-#include <msvcrt/internal/file.h>
+#include <ctype.h>
+#include <direct.h>
+#include <internal/file.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/direct/wgetcwd.c
--- trunk/reactos/lib/crt/direct/wgetcwd.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/wgetcwd.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,8 +1,8 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/stdlib.h>
-#include <msvcrt/errno.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/wgetdcwd.c
--- trunk/reactos/lib/crt/direct/wgetdcwd.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/wgetdcwd.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/wmkdir.c
--- trunk/reactos/lib/crt/direct/wmkdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/wmkdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/direct/wrmdir.c
--- trunk/reactos/lib/crt/direct/wrmdir.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/direct/wrmdir.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 #include "precomp.h"
-#include <msvcrt/direct.h>
-#include <msvcrt/internal/file.h>
+#include <direct.h>
+#include <internal/file.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/float/chgsign.c
--- trunk/reactos/lib/crt/float/chgsign.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/chgsign.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,5 +1,5 @@
-#include <msvcrt/float.h>
-#include <msvcrt/internal/ieee.h>
+#include <float.h>
+#include <internal/ieee.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/float/clearfp.c
--- trunk/reactos/lib/crt/float/clearfp.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/clearfp.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,4 +1,4 @@
-#include <msvcrt/float.h>
+#include <float.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/float/cntrlfp.c
--- trunk/reactos/lib/crt/float/cntrlfp.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/cntrlfp.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 
-#include <msvcrt/float.h>
+#include <float.h>
 
 #define X87_CW_IM   (1<<0)      /* Invalid operation mask */
 #define X87_CW_DM   (1<<1)      /* Denormal operand mask */

Modified: trunk/reactos/lib/crt/float/copysign.c
--- trunk/reactos/lib/crt/float/copysign.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/copysign.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,5 +1,5 @@
-#include <msvcrt/float.h>
-#include <msvcrt/internal/ieee.h>
+#include <float.h>
+#include <internal/ieee.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/float/fpclass.c
--- trunk/reactos/lib/crt/float/fpclass.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/fpclass.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,6 +1,6 @@
-#include <msvcrt/float.h>
-#include <msvcrt/math.h>
-#include <msvcrt/internal/ieee.h>
+#include <float.h>
+#include <math.h>
+#include <internal/ieee.h>
 
 
 #define _FPCLASS_SNAN	0x0001	/* signaling NaN */

Modified: trunk/reactos/lib/crt/float/fpecode.c
--- trunk/reactos/lib/crt/float/fpecode.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/fpecode.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -2,8 +2,8 @@
 #undef __USE_W32API
 #endif
 
-#include <msvcrt/float.h>
-#include <msvcrt/internal/tls.h>
+#include <float.h>
+#include <internal/tls.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/float/fpreset.c
--- trunk/reactos/lib/crt/float/fpreset.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/fpreset.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,4 +1,4 @@
-#include <msvcrt/float.h>
+#include <float.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/float/isnan.c
--- trunk/reactos/lib/crt/float/isnan.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/isnan.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -16,9 +16,9 @@
 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
-#include <msvcrt/math.h>
-#include <msvcrt/float.h>
-#include <msvcrt/internal/ieee.h>
+#include <math.h>
+#include <float.h>
+#include <internal/ieee.h>
 
 
 /*

Modified: trunk/reactos/lib/crt/float/logb.c
--- trunk/reactos/lib/crt/float/logb.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/logb.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -18,7 +18,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <msvcrt/float.h>
+#include <float.h>
 
 double _logb (double __x)
 {

Modified: trunk/reactos/lib/crt/float/nafter.c
--- trunk/reactos/lib/crt/float/nafter.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/nafter.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,4 +1,4 @@
-#include <msvcrt/float.h>
+#include <float.h>
 
 
 /*
@@ -9,7 +9,7 @@
 	if ( x == y)
 		return x;
 
-	if ( isnan(x) || isnan(y) )
+	if ( _isnan(x) || _isnan(y) )
 		return x;
 
 	return x;

Modified: trunk/reactos/lib/crt/float/scalb.c
--- trunk/reactos/lib/crt/float/scalb.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/scalb.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,5 +1,5 @@
-#include <msvcrt/float.h>
-#include <msvcrt/internal/ieee.h>
+#include <float.h>
+#include <internal/ieee.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/float/statfp.c
--- trunk/reactos/lib/crt/float/statfp.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/float/statfp.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,4 +1,4 @@
-#include <msvcrt/float.h>
+#include <float.h>
 
 /*
  * @implemented

Modified: trunk/reactos/lib/crt/io/access.c
--- trunk/reactos/lib/crt/io/access.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/access.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,17 +1,26 @@
 #include "precomp.h"
-#include <msvcrt/io.h>
-#include <msvcrt/errno.h>
+#include <io.h>
+#include <errno.h>
+#include <tchar.h>
+#include <internal/file.h>
+
 #define NDEBUG
-#include <msvcrt/msvcrtdbg.h>
+#include <internal/msvcrtdbg.h>
 
+#ifdef _UNICODE
+ #define _TS S
+#else
+ #define _TS s
+#endif
 
+
 /*
  * @implemented
  */
-int _access( const char *_path, int _amode )
+int _taccess( const _TCHAR *_path, int _amode )
 {
-    DWORD Attributes = GetFileAttributesA(_path);
-    DPRINT("_access('%s', %x)\n", _path, _amode);
+    DWORD Attributes = GetFileAttributes(_path);
+    DPRINT(MK_STR(_taccess)"('%"_TS"', %x)\n", _path, _amode);
 
     if (Attributes == -1) {
     	_dosmaperr(GetLastError());
@@ -23,11 +32,31 @@
             return -1;
         }
     }
-    if ((_amode & D_OK) == D_OK) {
-        if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) {
-            __set_errno(EACCES);
-            return -1;
-        }
-    }
+    
     return 0;
 }
+
+
+
+/*
+ * INTERNAL
+ */
+int access_dirT(const _TCHAR *_path)
+{
+    DWORD Attributes = GetFileAttributes(_path);
+    DPRINT(MK_STR(is_dirT)"('%"_TS"')\n", _path);
+
+    if (Attributes == -1) {
+         _dosmaperr(GetLastError());
+        return -1;
+    }
+       
+    if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) 
+    {
+      __set_errno(EACCES);
+      return -1;
+    }
+
+   return 0;
+}
+

Modified: trunk/reactos/lib/crt/io/chmod.c
--- trunk/reactos/lib/crt/io/chmod.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/chmod.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,24 +1,28 @@
+
 #include "precomp.h"
-#include <msvcrt/io.h>
-#include <msvcrt/internal/file.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <tchar.h>
+#include <internal/file.h>
 
 #define NDEBUG
-#include <msvcrt/msvcrtdbg.h>
+#include <internal/msvcrtdbg.h>
 
+
 #define mode_t int
 
 
 /*
  * @implemented
  */
-int _chmod(const char* filename, mode_t mode)
+int _tchmod(const _TCHAR* filename, mode_t mode)
 {
     DWORD FileAttributes = 0;
     BOOLEAN Set = FALSE;
 
-    DPRINT("_chmod('%s', %x)\n", filename, mode);
+    DPRINT(#_tchmod"('%"sT"', %x)\n", filename, mode);
 
-    FileAttributes = GetFileAttributesA(filename);
+    FileAttributes = GetFileAttributes(filename);
     if ( FileAttributes == -1 ) {
     	_dosmaperr(GetLastError());
         return -1;
@@ -38,7 +42,7 @@
 	    Set = TRUE;
 	}
     }
-    if (Set && SetFileAttributesA(filename, FileAttributes) == FALSE) {
+    if (Set && SetFileAttributes(filename, FileAttributes) == FALSE) {
         _dosmaperr(GetLastError());
 	return -1;
     }

Modified: trunk/reactos/lib/crt/io/chsize.c
--- trunk/reactos/lib/crt/io/chsize.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/chsize.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,8 +1,8 @@
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
-#include <msvcrt/io.h>
+#include <io.h>
 
 #define NDEBUG
-#include <msvcrt/msvcrtdbg.h>
+#include <internal/msvcrtdbg.h>
 
 /*
  * @implemented
@@ -10,7 +10,7 @@
 int _chsize(int _fd, long size)
 {
   DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
-  if (lseek(_fd, size, 0) == -1)
+  if (_lseek(_fd, size, 0) == -1)
     return -1;
   if (_write(_fd, 0, 0) < 0)
     return -1;

Modified: trunk/reactos/lib/crt/io/close.c
--- trunk/reactos/lib/crt/io/close.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/close.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,19 +1,22 @@
 #include "precomp.h"
-#include <msvcrt/io.h>
-#include <msvcrt/internal/file.h>
+#include <io.h>
+#include <internal/file.h>
 
 #define NDEBUG
-#include <msvcrt/msvcrtdbg.h>
+#include <internal/msvcrtdbg.h>
 
 /*
  * @implemented
  */
 int _close(int _fd)
 {
-  DPRINT("_close(fd %d)\n", _fd);
-  if (_fd == -1)
-    return -1;
-  if (CloseHandle(_get_osfhandle(_fd)) == FALSE)
-    return -1;
-  return __fileno_close(_fd);
+   TRACE("_close(%i)", _fd);
+   
+   if (_fd == -1)
+      return(-1);
+   if (CloseHandle((HANDLE)_get_osfhandle(_fd)) == FALSE)
+      return(-1);
+  //return
+   free_fd(_fd);
+   return(0);
 }

Modified: trunk/reactos/lib/crt/io/commit.c
--- trunk/reactos/lib/crt/io/commit.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/commit.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,7 +1,7 @@
 #include "precomp.h"
-#include <msvcrt/io.h>
-#include <msvcrt/errno.h>
-#include <msvcrt/internal/file.h>
+#include <io.h>
+#include <errno.h>
+#include <internal/file.h>
 
 
 /*
@@ -9,7 +9,7 @@
  */
 int _commit(int _fd)
 {
-   if (! FlushFileBuffers(_get_osfhandle(_fd)) ) {
+   if (! FlushFileBuffers((HANDLE)_get_osfhandle(_fd)) ) {
 	__set_errno(EBADF);
 	return -1;
      }

Modified: trunk/reactos/lib/crt/io/create.c
--- trunk/reactos/lib/crt/io/create.c	2005-02-16 22:29:16 UTC (rev 13607)
+++ trunk/reactos/lib/crt/io/create.c	2005-02-16 22:29:48 UTC (rev 13608)
@@ -1,8 +1,8 @@
-#include <msvcrt/io.h>
-#include <msvcrt/fcntl.h>
+#include <io.h>
+#include <fcntl.h>
 
 #define NDEBUG
-#include <msvcrt/msvcrtdbg.h>
+#include <internal/msvcrtdbg.h>
 
[truncated at 1000 lines; 12226 more skipped]