update for HEAD-2003091401
[reactos.git] / lib / msvcrt / conio / getch.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/msvcrt/conio/getch.c
5  * PURPOSE:     Writes a character to stdout
6  * PROGRAMER:   Boudewijn Dekker
7  * UPDATE HISTORY:
8  *              28/12/98: Created
9  */
10 #include <windows.h>
11 #include <msvcrt/conio.h>
12 #include <msvcrt/stdio.h>
13 #include <msvcrt/io.h>
14 #include <msvcrt/internal/console.h>
15
16
17 /*
18  * @implemented
19  */
20 int _getch(void)
21 {
22     DWORD  NumberOfCharsRead = 0;
23     char c;
24     if (char_avail) {
25         c = ungot_char;
26         char_avail = 0;
27     } else {
28         ReadConsoleA(_get_osfhandle(stdin->_file),
29                              &c,
30                              1,
31                              &NumberOfCharsRead,
32                              NULL);
33     }
34     if (c == 10)
35         c = 13;
36     putchar(c);
37     return c;
38 }
39
40 #if 0
41 /*
42  * @unimplemented
43  */
44 int _getche(void)
45 {
46     int c;
47
48     c = _getch();
49     _putch(c);
50
51     return c;
52 }
53 #endif