ReactOS 0.4.16-dev-822-gbcedb53
conio.h File Reference
#include <corecrt.h>
#include <stdarg.h>
#include <sec_api/conio_s.h>
Include dependency graph for conio.h:

Go to the source code of this file.

Macros

#define __need___va_list
 
#define _WCONIO_DEFINED
 
#define WEOF   (wint_t)(0xFFFF)
 
#define _putwch()   _putwch_nolock()
 
#define _getwch()   _getwch_nolock()
 
#define _getwche()   _getwche_nolock()
 
#define _ungetwch()   _ungetwch_nolock()
 

Functions

_CRTIMP char *__cdecl _cgets (_Pre_notnull_ _Post_z_ char *_Buffer)
 
_Check_return_opt_ _CRTIMP int __cdecl _cprintf (_In_z_ _Printf_format_string_ const char *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _cputs (_In_z_ const char *_Str)
 
_Check_return_opt_ _CRTIMP int __cdecl _cscanf (_In_z_ _Scanf_format_string_ const char *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _cscanf_l (_In_z_ _Scanf_format_string_ const char *_Format, _In_opt_ _locale_t _Locale,...)
 
_Check_return_ _CRTIMP int __cdecl _getch (void)
 
_Check_return_ _CRTIMP int __cdecl _getche (void)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcprintf (_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
 
_Check_return_opt_ _CRTIMP int __cdecl _cprintf_p (_In_z_ _Printf_format_string_ const char *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcprintf_p (_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
 
_Check_return_opt_ _CRTIMP int __cdecl _cprintf_l (_In_z_ _Printf_format_string_ const char *_Format, _In_opt_ _locale_t _Locale,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcprintf_l (_In_z_ _Printf_format_string_ const char *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_Check_return_opt_ _CRTIMP int __cdecl _cprintf_p_l (_In_z_ _Printf_format_string_ const char *_Format, _In_opt_ _locale_t _Locale,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcprintf_p_l (_In_z_ _Printf_format_string_ const char *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_CRTIMP int __cdecl _kbhit (void)
 
_CRTIMP int __cdecl _putch (_In_ int _Ch)
 
_CRTIMP int __cdecl _ungetch (_In_ int _Ch)
 
_Check_return_ _CRTIMP int __cdecl _getch_nolock (void)
 
_Check_return_ _CRTIMP int __cdecl _getche_nolock (void)
 
_CRTIMP int __cdecl _putch_nolock (_In_ int _Ch)
 
_CRTIMP int __cdecl _ungetch_nolock (_In_ int _Ch)
 
_CRTIMP wchar_t_cgetws (_Pre_notnull_ _Post_z_ wchar_t *_Buffer)
 
_Check_return_ _CRTIMP wint_t __cdecl _putwch (wchar_t _WCh)
 
_Check_return_ _CRTIMP wint_t __cdecl _ungetwch (wint_t _WCh)
 
_Check_return_opt_ _CRTIMP int __cdecl _cputws (_In_z_ const wchar_t *_String)
 
_Check_return_opt_ _CRTIMP int __cdecl _cwprintf (_In_z_ _Printf_format_string_ const wchar_t *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _cwscanf (_In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _cwscanf_l (_In_z_ _Scanf_format_string_ const wchar_t *_Format, _In_opt_ _locale_t _Locale,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcwprintf (_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
 
_Check_return_opt_ _CRTIMP int __cdecl _cwprintf_p (_In_z_ _Printf_format_string_ const wchar_t *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl _vcwprintf_p (_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
 
_CRTIMP int __cdecl _cwprintf_l (_In_z_ _Printf_format_string_ const wchar_t *_Format, _In_opt_ _locale_t _Locale,...)
 
_CRTIMP int __cdecl _vcwprintf_l (_In_z_ _Printf_format_string_ const wchar_t *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_CRTIMP int __cdecl _cwprintf_p_l (_In_z_ _Printf_format_string_ const wchar_t *_Format, _In_opt_ _locale_t _Locale,...)
 
_CRTIMP int __cdecl _vcwprintf_p_l (_In_z_ _Printf_format_string_ const wchar_t *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_Check_return_opt_ _CRTIMP wint_t __cdecl _putwch_nolock (wchar_t _WCh)
 
_Check_return_ _CRTIMP wint_t __cdecl _getwch_nolock (void)
 
_Check_return_ _CRTIMP wint_t __cdecl _getwche_nolock (void)
 
_Check_return_opt_ _CRTIMP wint_t __cdecl _ungetwch_nolock (wint_t _WCh)
 
_Check_return_opt_ _CRTIMP char *__cdecl cgets (_Out_writes_z_(_Inexpressible_(*_Buffer+2)) char *_Buffer)
 
_Check_return_opt_ _CRTIMP int __cdecl cprintf (_In_z_ _Printf_format_string_ const char *_Format,...)
 
_Check_return_opt_ _CRTIMP int __cdecl cputs (_In_z_ const char *_Str)
 
_Check_return_opt_ _CRTIMP int __cdecl cscanf (_In_z_ _Scanf_format_string_ const char *_Format,...)
 
_Check_return_ _CRTIMP int __cdecl getch (void)
 
_Check_return_ _CRTIMP int __cdecl getche (void)
 
_Check_return_ _CRTIMP int __cdecl kbhit (void)
 
_Check_return_opt_ _CRTIMP int __cdecl putch (int _Ch)
 
_Check_return_opt_ _CRTIMP int __cdecl ungetch (int _Ch)
 

Macro Definition Documentation

◆ __need___va_list

#define __need___va_list

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER within this package.

Definition at line 11 of file conio.h.

◆ _getwch

Definition at line 339 of file conio.h.

◆ _getwche

Definition at line 340 of file conio.h.

◆ _putwch

#define _putwch ( )    _putwch_nolock()

Definition at line 338 of file conio.h.

◆ _ungetwch

#define _ungetwch ( )    _ungetwch_nolock()

Definition at line 341 of file conio.h.

◆ _WCONIO_DEFINED

#define _WCONIO_DEFINED

Definition at line 182 of file conio.h.

◆ WEOF

#define WEOF   (wint_t)(0xFFFF)

Definition at line 185 of file conio.h.

Function Documentation

◆ _cgets()

_CRTIMP char *__cdecl _cgets ( _Pre_notnull_ _Post_z_ char _Buffer)

◆ _cgetws()

_CRTIMP wchar_t * _cgetws ( _Pre_notnull_ _Post_z_ wchar_t _Buffer)

◆ _cprintf()

Definition at line 176 of file conio.h.

182 {
183 int _Result;
188 return _Result;
189 }
char * va_list
Definition: acmsvcex.h:78
#define NULL
Definition: types.h:112
_In_ size_t _In_z_ _Printf_format_string_ const char * _Format
Definition: time.h:147
_Result
Definition: conio.h:347
__crt_va_end(_ArgList)
_Check_return_opt_ _In_opt_ _locale_t const va_list _ArgList
Definition: conio.h:285
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_l(_In_z_ _Printf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
Definition: conio.h:71
__crt_va_start(_ArgList, _Locale)

◆ _cprintf_l()

◆ _cprintf_p()

Definition at line 246 of file conio.h.

252 {
253 int _Result;
258 return _Result;
259 }
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_p_l(_In_z_ _Printf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
Definition: conio.h:129

◆ _cprintf_p_l()

_Check_return_opt_ _CRTIMP int __cdecl _cprintf_p_l ( _In_z_ _Printf_format_string_ const char _Format,
_In_opt_ _locale_t  _Locale,
  ... 
)

◆ _cputs()

◆ _cputws()

◆ _cscanf()

◆ _cscanf_l()

◆ _cwprintf()

◆ _cwprintf_l()

_CRTIMP int __cdecl _cwprintf_l ( _In_z_ _Printf_format_string_ const wchar_t _Format,
_In_opt_ _locale_t  _Locale,
  ... 
)

◆ _cwprintf_p()

◆ _cwprintf_p_l()

_CRTIMP int __cdecl _cwprintf_p_l ( _In_z_ _Printf_format_string_ const wchar_t _Format,
_In_opt_ _locale_t  _Locale,
  ... 
)

◆ _cwscanf()

◆ _cwscanf_l()

◆ _getch()

Definition at line 16 of file getch.c.

17{
18 DWORD NumberOfCharsRead = 0;
19 char c;
20 HANDLE ConsoleHandle;
21 BOOL RestoreMode;
22 DWORD ConsoleMode;
23
24 if (char_avail) {
25 c = ungot_char;
26 char_avail = 0;
27 } else {
28 /*
29 * _getch() is documented to NOT echo characters. Testing shows it
30 * doesn't wait for a CR either. So we need to switch off
31 * ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
32 * switched on.
33 */
34 ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
35 RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
36 (0 != (ConsoleMode &
38 if (RestoreMode) {
39 SetConsoleMode(ConsoleHandle,
40 ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
41 }
43 &c,
44 1,
45 &NumberOfCharsRead,
46 NULL);
47 if (RestoreMode) {
48 SetConsoleMode(ConsoleHandle, ConsoleMode);
49 }
50 }
51 if (c == 10)
52 c = 13;
53 return c;
54}
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1195
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLubyte * c
Definition: glext.h:8905
#define stdin
Definition: stdio.h:98
#define c
Definition: ke_i.h:80
_CRTIMP intptr_t __cdecl _get_osfhandle(_In_ int _FileHandle)
PVOID HANDLE
Definition: typedefs.h:73
int char_avail
Definition: ungetch.c:15
int ungot_char
Definition: ungetch.c:16
#define ENABLE_ECHO_INPUT
Definition: wincon.h:80
#define ENABLE_LINE_INPUT
Definition: wincon.h:79

◆ _getch_nolock()

_Check_return_ _CRTIMP int __cdecl _getch_nolock ( void  )

Definition at line 277 of file getch.cpp.

278{
279 // Check the pushback buffer for a character. If one is present, return it:
280 int const pushback = get_next_getch_pushback_buffer();
281 if (pushback != EOF)
282 {
283 return pushback;
284 }
285
287 return EOF;
288 }
289
290 // Switch console to raw mode:
291 DWORD old_console_mode;
292 __dcrt_get_input_console_mode(&old_console_mode);
294
295 int result = 0;
296
297 __try
298 {
299 for ( ; ; )
300 {
301 // Get a console input event:
302 INPUT_RECORD input_record;
303 DWORD num_read;
304
305 if (__dcrt_read_console_input(&input_record, 1, &num_read) == FALSE || num_read == 0)
306 {
307 result = EOF;
308 __leave;
309 }
310
311 // Look for, and decipher, key events.
312 if (input_record.EventType == KEY_EVENT && input_record.Event.KeyEvent.bKeyDown)
313 {
314 // Simple case: if UnicodeChar is non-zero, we can convert it to char and return it.
315 wchar_t const c = input_record.Event.KeyEvent.uChar.UnicodeChar;
316 if (c != 0)
317 {
318 wchar_t const c_buffer[2] = {c, L'\0'};
319 char mb_chars[4];
320
321 size_t const amount_written = __acrt_wcs_to_mbs_cp_array(
322 c_buffer,
323 mb_chars,
325 );
326
327 // Mask with 0xFF to just get lowest byte
328 if (amount_written >= 1) {
329 result = mb_chars[0] & 0xFF;
330 }
331
332 if (amount_written >= 2) {
333 for (size_t i = 1; i < amount_written; ++i) {
334 add_to_getch_pushback_buffer(mb_chars[i] & 0xFF);
335 }
336 }
337 __leave;
338 }
339
340 // Hard case: either it is an extended code or an event which
341 // should not be recognized. Let _getextendedkeycode do the work:
342 CharPair const* const cp = _getextendedkeycode(&input_record.Event.KeyEvent);
343 if (cp != nullptr)
344 {
345 // Mask with 0xFF to just get lowest byte
346 add_to_getch_pushback_buffer(cp->SecondChar & 0xFF);
347 result = cp->LeadChar & 0xFF;
348 __leave;
349 }
350 }
351 }
352 }
354 {
355 // Restore the previous console mode:
356 __dcrt_set_input_console_mode(old_console_mode);
357 }
359 return result;
360}
size_t __acrt_wcs_to_mbs_cp_array(wchar_t const *const null_terminated_input_string, char(&buffer)[N], unsigned int const code_page)
#define FALSE
Definition: types.h:117
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(VOID)
Definition: console.c:2391
static int get_next_getch_pushback_buffer()
Definition: getch.cpp:216
CharPair const *__cdecl _getextendedkeycode(KEY_EVENT_RECORD *)
Definition: getch.cpp:506
static void add_to_getch_pushback_buffer(int const c)
Definition: getch.cpp:201
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EOF
Definition: stdio.h:24
BOOL __cdecl __dcrt_read_console_input(_Out_ PINPUT_RECORD lpBuffer, _In_ DWORD nLength, _Out_ LPDWORD lpNumberOfEventsRead)
Definition: initconin.cpp:67
BOOL __cdecl __dcrt_get_input_console_mode(_Out_ LPDWORD lpMode)
Definition: initconin.cpp:136
BOOL __cdecl __dcrt_lowio_ensure_console_input_initialized()
Definition: initconin.cpp:31
BOOL __cdecl __dcrt_set_input_console_mode(_In_ DWORD dwMode)
Definition: initconin.cpp:150
POINT cp
Definition: magnifier.c:59
#define L(x)
Definition: ntvdm.h:50
#define __try
Definition: pseh2_64.h:172
#define __leave
Definition: pseh2_64.h:176
#define __endtry
Definition: pseh2_64.h:175
#define __finally
Definition: pseh2_64.h:174
union _INPUT_RECORD::@3303 Event
WORD EventType
Definition: wincon.h:273
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:275
WCHAR UnicodeChar
Definition: wincon.h:245
union _KEY_EVENT_RECORD::@3302 uChar
#define KEY_EVENT
Definition: wincon.h:128

◆ _getche()

Definition at line 15 of file getche.c.

16{
17 if (char_avail)
18 /*
19 * We don't know, wether the ungot char was already echoed
20 * we assume yes (for example in cscanf, probably the only
21 * place where ungetch is ever called.
22 * There is no way to check for this really, because
23 * ungetch could have been called with a character that
24 * hasn't been got by a conio function.
25 * We don't echo again.
26 */
27 return(_getch());
28 return (_putch(_getch()));
29}
_CRTIMP int __cdecl _putch(_In_ int _Ch)
int _getch()
Definition: getch.c:16

◆ _getche_nolock()

_Check_return_ _CRTIMP int __cdecl _getche_nolock ( void  )

Definition at line 364 of file getch.cpp.

365{
366 // Check the pushback buffer for a character. If one is present, return
367 // it without echoing:
368 int const pushback = get_next_getch_pushback_buffer();
369 if (pushback != EOF)
370 {
371 return pushback;
372 }
373
374 // Otherwise, read the next character from the console and echo it:
375 int const c = _getch_nolock();
376 if (c == EOF)
377 return EOF;
378
379 if (_putch_nolock(c) == EOF)
380 return EOF;
381
382 return c;
383}
int __cdecl _getch_nolock()
Definition: getch.cpp:277
_CRTIMP int __cdecl _putch_nolock(_In_ int _Ch)

◆ _getwch_nolock()

_Check_return_ _CRTIMP wint_t __cdecl _getwch_nolock ( void  )

Definition at line 77 of file getwch.cpp.

78{
79 // First check the pushback buffer for a character. If it has one, return
80 // it without echoing and reset the buffer:
81 if (wchbuf != WEOF)
82 {
83 wchar_t const buffered_wchar = static_cast<wchar_t>(wchbuf & 0xFFFF);
84 wchbuf = WEOF;
85 return buffered_wchar;
86 }
87
88 // The console input handle is created the first time that _getwch(),
89 // _cgetws(), or _kbhit() is called:
91 return WEOF;
92
93 // Switch to raw mode (no line input, no echo input):
94 DWORD old_console_mode;
95 __dcrt_get_input_console_mode(&old_console_mode);
97 wint_t result = 0;
98 __try
99 {
100 for ( ; ; )
101 {
102 // Get a console input event:
103 INPUT_RECORD input_record;
104 DWORD num_read;
105 if (__dcrt_read_console_input(&input_record, 1, &num_read) == FALSE)
106 {
107 result = WEOF;
108 __leave;
109 }
110
111 if (num_read == 0)
112 {
113 result = WEOF;
114 __leave;
115 }
116
117 // Look for, and decipher, key events.
118 if (input_record.EventType == KEY_EVENT && input_record.Event.KeyEvent.bKeyDown)
119 {
120 // Easy case: if UnicodeChar is non-zero, we can just return it:
121 wchar_t const c = static_cast<wchar_t>(input_record.Event.KeyEvent.uChar.UnicodeChar);
122 if (c != 0)
123 {
124 result = c;
125 __leave;
126 }
127
128 // Hard case: either it is an extended code or an event which
129 // should not be recognized. Let _getextendedkeycode do the work:
130 CharPair const* const cp = _getextendedkeycode(&input_record.Event.KeyEvent);
131 if (cp != nullptr)
132 {
133 wchbuf = cp->SecondChar;
134 result = cp->LeadChar;
135 __leave;
136 }
137 }
138 }
139 }
141 {
142 // Restore the previous console mode:
143 __dcrt_set_input_console_mode(old_console_mode);
144 }
146 return result;
147}
int wint_t
Definition: _apple.h:38
static wint_t wchbuf
Definition: getwch.cpp:28
CharPair const *__cdecl _getextendedkeycode(KEY_EVENT_RECORD *)
Definition: getch.cpp:506
#define WEOF
Definition: conio.h:185

◆ _getwche_nolock()

_Check_return_ _CRTIMP wint_t __cdecl _getwche_nolock ( void  )

Definition at line 151 of file getwch.cpp.

152{
153 // First check the pushback buffer for a character. If it has one, return
154 // it without echoing and reset the buffer:
155 if (wchbuf != WEOF)
156 {
157 wchar_t const buffered_wchar = static_cast<wchar_t>(wchbuf & 0xFFFF);
158 wchbuf = WEOF;
159 return buffered_wchar;
160 }
161
162 // Othwrwise, read the character, echo it, and return it. If anything fails,
163 // we immediately return WEOF.
164 wchar_t const gotten_wchar = _getwch_nolock();
165 if (gotten_wchar == WEOF)
166 return WEOF;
167
168 if (_putwch_nolock(gotten_wchar) == WEOF)
169 return WEOF;
170
171 return gotten_wchar;
172}
wint_t __cdecl _getwch_nolock()
Definition: getwch.cpp:77
_Check_return_opt_ _CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh)
Definition: putwch.cpp:22

◆ _kbhit()

_CRTIMP int __cdecl _kbhit ( void  )

Definition at line 21 of file kbhit.c.

22{
23 PINPUT_RECORD InputRecord = NULL;
24 DWORD NumberRead = 0;
25 DWORD EventsRead = 0;
26 DWORD RecordIndex = 0;
27 DWORD BufferIndex = 0;
28 HANDLE StdInputHandle = 0;
29 DWORD ConsoleInputMode = 0;
30
31 /* Attempt some thread safety */
33 {
36 }
37
39
40 if (char_avail)
41 {
43 return 1;
44 }
45
46 StdInputHandle = GetStdHandle(STD_INPUT_HANDLE);
47
48 /* Turn off processed input so we get key modifiers as well */
49 GetConsoleMode(StdInputHandle, &ConsoleInputMode);
50
51 SetConsoleMode(StdInputHandle, ConsoleInputMode & ~ENABLE_PROCESSED_INPUT);
52
53 /* Start the process */
54 if (!GetNumberOfConsoleInputEvents(StdInputHandle, &EventsRead))
55 {
57 return 0;
58 }
59
60 if (!EventsRead)
61 {
63 return 0;
64 }
65
66 if (!(InputRecord = (PINPUT_RECORD)malloc(EventsRead * sizeof(INPUT_RECORD))))
67 {
69 return 0;
70 }
71
72 if (!PeekConsoleInput(StdInputHandle, InputRecord, EventsRead, &NumberRead))
73 {
74 free(InputRecord);
76 return 0;
77 }
78
79 for (RecordIndex = 0; RecordIndex < NumberRead; RecordIndex++)
80 {
81 if (InputRecord[RecordIndex].EventType == KEY_EVENT &&
82 InputRecord[RecordIndex].Event.KeyEvent.bKeyDown)
83 {
84 BufferIndex = 1;
85 break;
86 }
87 }
88
89 free(InputRecord);
90
91 /* Restore console input mode */
92 SetConsoleMode(StdInputHandle, ConsoleInputMode);
93
95
96 return BufferIndex;
97}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define TRUE
Definition: types.h:120
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1635
volatile BOOL CriticalSectionInitialized
Definition: kbhit.c:15
static CRITICAL_SECTION CriticalSection
Definition: kbhit.c:14
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE EventType
Definition: exfuncs.h:167
BOOL WINAPI InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount)
Definition: synch.c:765
#define STD_INPUT_HANDLE
Definition: winbase.h:293
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define PeekConsoleInput
Definition: wincon.h:776
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:78

Referenced by gl_getcx(), and main().

◆ _putch()

◆ _putch_nolock()

_CRTIMP int __cdecl _putch_nolock ( _In_ int  _Ch)

Referenced by _cputs(), and _getche_nolock().

◆ _putwch()

Definition at line 3703 of file file.c.

3704{
3705 return fputwc(c, stdout);
3706}
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE *_File)

◆ _putwch_nolock()

_Check_return_opt_ _CRTIMP wint_t __cdecl _putwch_nolock ( wchar_t  _WCh)

Definition at line 22 of file putwch.cpp.

23{
25 return WEOF;
26
27 // Write character to console:
28 DWORD charsWritten;
29 if (__dcrt_write_console(&c, 1, &charsWritten) == FALSE)
30 return WEOF;
31
32 return c;
33}
BOOL __cdecl __dcrt_lowio_ensure_console_output_initialized()
Definition: initcon.cpp:31
BOOL __cdecl __dcrt_write_console(_In_ void const *lpBuffer, _In_ DWORD nNumberOfCharsToWrite, _Out_ LPDWORD lpNumberOfCharsWritten)
Definition: initcon.cpp:67

Referenced by _getwche_nolock(), _putch_nolock_internal(), and write_double_translated_unicode_nolock().

◆ _ungetch()

_CRTIMP int __cdecl _ungetch ( _In_ int  _Ch)

◆ _ungetch_nolock()

_CRTIMP int __cdecl _ungetch_nolock ( _In_ int  _Ch)

◆ _ungetwch()

Definition at line 179 of file getwch.cpp.

180{
182 wint_t result = 0;
183 __try
184 {
186 }
188 {
190 }
192 return result;
193}
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
Definition: locks.cpp:57
@ __acrt_conio_lock
__acrt_lock(__acrt_heap_lock)
wint_t __cdecl _ungetwch_nolock(wint_t const c)
Definition: getwch.cpp:197

◆ _ungetwch_nolock()

_Check_return_opt_ _CRTIMP wint_t __cdecl _ungetwch_nolock ( wint_t  _WCh)

Definition at line 197 of file getwch.cpp.

198{
199 // Fail if the char is EOF or the pushback buffer is non-empty:
200 if (c == WEOF || wchbuf != WEOF)
201 return static_cast<wint_t>(EOF);
202
203 wchbuf = (c & 0xFF);
204 return wchbuf;
205}

◆ _vcprintf()

Definition at line 87 of file conio.h.

94 {
96 }

Referenced by _cprintf().

◆ _vcprintf_l()

_Check_return_opt_ _CRTIMP int __cdecl _vcprintf_l ( _In_z_ _Printf_format_string_ const char _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

Referenced by _cprintf(), _cprintf_l(), and _vcprintf().

◆ _vcprintf_p()

◆ _vcprintf_p_l()

_Check_return_opt_ _CRTIMP int __cdecl _vcprintf_p_l ( _In_z_ _Printf_format_string_ const char _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

◆ _vcwprintf()

Referenced by _cwprintf().

◆ _vcwprintf_l()

_CRTIMP int __cdecl _vcwprintf_l ( _In_z_ _Printf_format_string_ const wchar_t _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

◆ _vcwprintf_p()

◆ _vcwprintf_p_l()

_CRTIMP int __cdecl _vcwprintf_p_l ( _In_z_ _Printf_format_string_ const wchar_t _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

◆ cgets()

_Check_return_opt_ _CRTIMP char *__cdecl cgets ( _Out_writes_z_(_Inexpressible_(*_Buffer+2)) char _Buffer)

◆ cprintf()

◆ cputs()

◆ cscanf()

◆ getch()

Definition at line 180 of file mwerks_console_OS_X.c.

181{
182 return 0;
183}

Referenced by interact(), main(), and tokenize().

◆ getche()

◆ kbhit()

Definition at line 175 of file mwerks_console_OS_X.c.

176{
177 return 0;
178}

◆ putch()

◆ ungetch()