update for HEAD-2003021201
[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 int _getch(void)
18 {
19     DWORD  NumberOfCharsRead = 0;
20     char c;
21     if (char_avail) {
22         c = ungot_char;
23         char_avail = 0;
24     } else {
25         ReadConsoleA(_get_osfhandle(stdin->_file),
26                              &c,
27                              1,
28                              &NumberOfCharsRead,
29                              NULL);
30     }
31     if (c == 10)
32         c = 13;
33     putchar(c);
34     return c;
35 }
36
37 #if 0
38 int _getche(void)
39 {
40     int c;
41
42     c = _getch();
43     _putch(c);
44
45     return c;
46 }
47 #endif