:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / crtdll / conio / getch.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/crtdll/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 <crtdll/conio.h>
12 #include <crtdll/stdio.h>
13 #include <crtdll/io.h>
14
15 extern int char_avail;
16 extern int ungot_char;
17
18
19 int
20 _getch(void)
21 {
22   
23   DWORD  NumberOfCharsRead = 0;
24   char c;
25   if (char_avail)
26   {
27     c = ungot_char;
28     char_avail = 0;
29   }
30   else
31   {     
32         ReadConsoleA(_get_osfhandle(stdin->_file), &c,1,&NumberOfCharsRead ,NULL);
33         
34   }
35   if ( c == 10 )
36         c = 13;
37   putchar(c);
38   return c;
39 }