Index: dll/win32/msvcrt/msvcrt.spec =================================================================== --- dll/win32/msvcrt/msvcrt.spec (revision 62562) +++ dll/win32/msvcrt/msvcrt.spec (working copy) @@ -494,8 +494,8 @@ @ cdecl _getpid() kernel32.GetCurrentProcessId @ cdecl _getsystime(ptr) @ cdecl _getw(ptr) -# stub _getwch -# stub _getwche +@ cdecl _getwch() +@ cdecl _getwche() @ cdecl _getws(ptr) @ cdecl -i386 _global_unwind2(ptr) @ cdecl _gmtime32(ptr) Index: lib/sdk/crt/conio/getwch.c =================================================================== --- lib/sdk/crt/conio/getwch.c (revision 0) +++ lib/sdk/crt/conio/getwch.c (working copy) @@ -0,0 +1,52 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/conio/getch.c + * PURPOSE: Writes a character to stdout + * PROGRAMER: Ariadne + * Lee Schroeder + * UPDATE HISTORY: + * 28/12/98: Created + */ + +#include + +wint_t _getwch(void) +{ + DWORD NumberOfCharsRead = 0; + wchar_t c; + HANDLE ConsoleHandle; + BOOL RestoreMode; + DWORD ConsoleMode; + + if (char_avail) { + c = ungot_char; + char_avail = 0; + } else { + /* + * _getch() is documented to NOT echo characters. Testing shows it + * doesn't wait for a CR either. So we need to switch off + * ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently + * switched on. + */ + ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file); + RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) && + (0 != (ConsoleMode & + (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT))); + if (RestoreMode) { + SetConsoleMode(ConsoleHandle, + ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT))); + } + ReadConsoleW((HANDLE)_get_osfhandle(stdin->_file), + &c, + 1, + &NumberOfCharsRead, + NULL); + if (RestoreMode) { + SetConsoleMode(ConsoleHandle, ConsoleMode); + } + } + if (c == 10) + c = 13; + return c; +} \ No newline at end of file Index: lib/sdk/crt/conio/getwche.c =================================================================== --- lib/sdk/crt/conio/getwche.c (revision 0) +++ lib/sdk/crt/conio/getwche.c (working copy) @@ -0,0 +1,30 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/conio/getwche.c + * PURPOSE: Reads a character from stdin + * PROGRAMER: DJ Delorie + Ariadne + Lee Schroeder + * UPDATE HISTORY: + * 28/12/98: Created + */ + +#include + +wint_t _getwche(void) +{ + if (char_avail) + /* + * We don't know, wether the ungot char was already echoed + * we assume yes (for example in cscanf, probably the only + * place where ungetch is ever called. + * There is no way to check for this really, because + * ungetch could have been called with a character that + * hasn't been got by a conio function. + * We don't echo again. + */ + return(_getwch()); + return (_putwch(_getwch())); + } \ No newline at end of file Index: lib/sdk/crt/crt.cmake =================================================================== --- lib/sdk/crt/crt.cmake (revision 62562) +++ lib/sdk/crt/crt.cmake (working copy) @@ -3,7 +3,9 @@ conio/cgets.c conio/cputs.c conio/getch.c + conio/getwch.c conio/getche.c + conio/getwche.c conio/kbhit.c conio/putch.c conio/ungetch.c