Added binary and unicode file i/o support to msvcrt.
[reactos.git] / reactos / lib / crtdll / conio / getch.c
index 6830ac5..070a867 100644 (file)
@@ -8,32 +8,40 @@
  *              28/12/98: Created
  */
 #include <windows.h>
-#include <crtdll/conio.h>
-#include <crtdll/stdio.h>
-#include <crtdll/io.h>
+#include <msvcrt/conio.h>
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/console.h>
 
-extern int char_avail;
-extern int ungot_char;
 
+int _getch(void)
+{
+    DWORD  NumberOfCharsRead = 0;
+    char c;
+    if (char_avail) {
+        c = ungot_char;
+        char_avail = 0;
+    } else {
+        ReadConsoleA(_get_osfhandle(stdin->_file),
+                            &c,
+                            1,
+                            &NumberOfCharsRead,
+                            NULL);
+    }
+    if (c == 10)
+        c = 13;
+    putchar(c);
+    return c;
+}
 
-int
-_getch(void)
+#if 0
+int _getche(void)
 {
-  
-  DWORD  NumberOfCharsRead = 0;
-  char c;
-  if (char_avail)
-  {
-    c = ungot_char;
-    char_avail = 0;
-  }
-  else
-  {    
-       ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
-       
-  }
-  if ( c == 10 )
-       c = 13;
-  putchar(c);
-  return c;
+    int c;
+
+    c = _getch();
+    _putch(c);
+
+    return c;
 }
+#endif