ReactOS 0.4.16-dev-737-g3368adc
conio.h File Reference
#include <corecrt.h>
#include <corecrt_wconio.h>
Include dependency graph for conio.h:

Go to the source code of this file.

Macros

#define _INC_CONIO
 

Functions

_UCRT_DISABLE_CLANG_WARNINGS _CRT_BEGIN_C_HEADER _Check_return_wat_ _Success_ (_BufferCount > 0) _DCRTIMP errno_t __cdecl _cgets_s(_Out_writes_z_(_BufferCount) char *_Buffer
 
 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1 (_Success_(return==0) errno_t, _cgets_s, _Out_writes_z_(*_Buffer) char, _Buffer, _Out_ size_t *, _SizeRead) _Check_return_opt_ _DCRTIMP int __cdecl _cputs(_In_z_ char const *_Buffer)
 
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf (_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_s (_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_p (_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_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)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf (_In_z_ _Printf_format_string_ char const *const _Format, va_list _ArgList)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_s_l (_In_z_ _Printf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_s (_In_z_ _Printf_format_string_ char const *const _Format, va_list _ArgList)
 
_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)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_p (_In_z_ char const *const _Format, va_list _ArgList)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf_l (_In_z_ _Printf_format_string_params_(0) char const *const _Format, _In_opt_ _locale_t const _Locale,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf (_In_z_ _Printf_format_string_ char const *const _Format,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf_s_l (_In_z_ _Printf_format_string_params_(0) char const *const _Format, _In_opt_ _locale_t const _Locale,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf_s (_In_z_ _Printf_format_string_ char const *const _Format,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf_p_l (_In_z_ _Printf_format_string_params_(0) char const *const _Format, _In_opt_ _locale_t const _Locale,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cprintf_p (_In_z_ _Printf_format_string_ char const *const _Format,...)
 
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcscanf (_In_ unsigned __int64 _Options, _In_z_ _Scanf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)
 
_Check_return_opt_ _CRT_INSECURE_DEPRECATE (_vcscanf_s_l) _CRT_STDIO_INLINE int __CRTDECL _vcscanf_l(_In_z_ _Scanf_format_string_params_(2) char const *const _Format
 
_Check_return_opt_ _CRT_INSECURE_DEPRECATE (_vcscanf_s) _CRT_STDIO_INLINE int __CRTDECL _vcscanf(_In_z_ _Scanf_format_string_params_(1) char const *const _Format
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcscanf_s_l (_In_z_ _Scanf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcscanf_s (_In_z_ _Scanf_format_string_params_(1) char const *const _Format, va_list _ArgList)
 
_Check_return_opt_ _CRT_INSECURE_DEPRECATE (_cscanf_s_l) _CRT_STDIO_INLINE int __CRTDECL _cscanf_l(_In_z_ _Scanf_format_string_params_(0) char const *const _Format
 
 __crt_va_start (_ArgList, _Locale)
 
 __crt_va_end (_ArgList)
 
_Check_return_opt_ _CRT_INSECURE_DEPRECATE (_cscanf_s) _CRT_STDIO_INLINE int __CRTDECL _cscanf(_In_z_ _Scanf_format_string_ char const *const _Format
 
 __crt_va_start (_ArgList, _Format)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cscanf_s_l (_In_z_ _Scanf_format_string_params_(0) char const *const _Format, _In_opt_ _locale_t const _Locale,...)
 
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _cscanf_s (_In_z_ _Scanf_format_string_ char const *const _Format,...)
 
_DCRTIMP int __cdecl _kbhit (void)
 
_Check_return_ _DCRTIMP int __cdecl _getch (void)
 
_Check_return_ _DCRTIMP int __cdecl _getche (void)
 
_Check_return_opt_ _DCRTIMP int __cdecl _putch (_In_ int _Ch)
 
_Check_return_opt_ _DCRTIMP int __cdecl _ungetch (_In_ int _Ch)
 
_Check_return_ _DCRTIMP int __cdecl _getch_nolock (void)
 
_Check_return_ _DCRTIMP int __cdecl _getche_nolock (void)
 
_Check_return_opt_ _DCRTIMP int __cdecl _putch_nolock (_In_ int _Ch)
 
_Check_return_opt_ _DCRTIMP int __cdecl _ungetch_nolock (_In_ int _Ch)
 

Variables

_UCRT_DISABLE_CLANG_WARNINGS _CRT_BEGIN_C_HEADER _Check_return_wat_ _In_ size_t _BufferCount
 
_UCRT_DISABLE_CLANG_WARNINGS _CRT_BEGIN_C_HEADER _Check_return_wat_ _In_ size_t _Out_ size_t_SizeRead
 
_Check_return_opt_ _In_opt_ _locale_t const _Locale
 
_Check_return_opt_ _In_opt_ _locale_t const va_list _ArgList
 
 _Result = _vcscanf_l(_Format, _Locale, _ArgList)
 

Macro Definition Documentation

◆ _INC_CONIO

#define _INC_CONIO

Definition at line 10 of file conio.h.

Function Documentation

◆ __conio_common_vcprintf()

_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf ( _In_ unsigned __int64  _Options,
_In_z_ _Printf_format_string_params_(2) char const _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

Referenced by _vcprintf_l().

◆ __conio_common_vcprintf_p()

_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_p ( _In_ unsigned __int64  _Options,
_In_z_ _Printf_format_string_params_(2) char const _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

Referenced by _vcprintf_p_l().

◆ __conio_common_vcprintf_s()

_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_s ( _In_ unsigned __int64  _Options,
_In_z_ _Printf_format_string_params_(2) char const _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

Referenced by _vcprintf_s_l().

◆ __conio_common_vcscanf()

_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcscanf ( _In_ unsigned __int64  _Options,
_In_z_ _Scanf_format_string_params_(2) char const _Format,
_In_opt_ _locale_t  _Locale,
va_list  _ArgList 
)

Referenced by _vcscanf_s_l().

◆ __crt_va_end()

◆ __crt_va_start() [1/2]

__crt_va_start ( _ArgList  ,
_Format   
)

◆ __crt_va_start() [2/2]

◆ __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1()

__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1 ( _Success_(return==0)  errno_t,
_cgets_s  ,
_Out_writes_z_ *_Buffer char  ,
_Buffer  ,
_Out_ size_t ,
_SizeRead   
) const

◆ _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()

Definition at line 158 of file conio.h.

165 {
166 int _Result;
171 return _Result;
172 }
_Check_return_opt_ _In_opt_ _locale_t const _Locale
Definition: conio.h:279

◆ _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()

Definition at line 228 of file conio.h.

◆ _cprintf_s()

Definition at line 211 of file conio.h.

217 {
218 int _Result;
223 return _Result;
224 }
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_s_l(_In_z_ _Printf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
Definition: conio.h:100

◆ _cprintf_s_l()

Definition at line 193 of file conio.h.

◆ _CRT_INSECURE_DEPRECATE() [1/4]

_Check_return_opt_ _CRT_INSECURE_DEPRECATE ( _cscanf_s  ) const

◆ _CRT_INSECURE_DEPRECATE() [2/4]

_Check_return_opt_ _CRT_INSECURE_DEPRECATE ( _cscanf_s_l  ) const

◆ _CRT_INSECURE_DEPRECATE() [3/4]

_Check_return_opt_ _CRT_INSECURE_DEPRECATE ( _vcscanf_s  ) const

◆ _CRT_INSECURE_DEPRECATE() [4/4]

_Check_return_opt_ _CRT_INSECURE_DEPRECATE ( _vcscanf_s_l  ) const

◆ _cscanf_s()

Definition at line 392 of file conio.h.

398 {
399 int _Result;
404 return _Result;
405 }
_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcscanf_s_l(_In_z_ _Scanf_format_string_params_(2) char const *const _Format, _In_opt_ _locale_t const _Locale, va_list _ArgList)
Definition: conio.h:306

◆ _cscanf_s_l()

Definition at line 374 of file conio.h.

◆ _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_ _DCRTIMP 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
WORD EventType
Definition: wincon.h:273
union _INPUT_RECORD::@3298 Event
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:275
union _KEY_EVENT_RECORD::@3297 uChar
WCHAR UnicodeChar
Definition: wincon.h:245
#define KEY_EVENT
Definition: wincon.h:128

Referenced by _getch(), and _getche_nolock().

◆ _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_ _DCRTIMP 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)

Referenced by _getche().

◆ _kbhit()

_DCRTIMP 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

◆ _putch()

◆ _putch_nolock()

_Check_return_opt_ _DCRTIMP int __cdecl _putch_nolock ( _In_ int  _Ch)

◆ _Success_()

◆ _ungetch()

◆ _ungetch_nolock()

_Check_return_opt_ _DCRTIMP int __cdecl _ungetch_nolock ( _In_ int  _Ch)

◆ _vcprintf()

Definition at line 87 of file conio.h.

94 {
96 }

Referenced by _cprintf().

◆ _vcprintf_l()

Definition at line 71 of file conio.h.

79 {
83 }
#define _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf(_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)

◆ _vcprintf_p()

_Check_return_opt_ _CRT_STDIO_INLINE int __CRTDECL _vcprintf_p ( _In_z_ char const *const  _Format,
va_list  _ArgList 
)

Definition at line 145 of file conio.h.

152 {
154 }

◆ _vcprintf_p_l()

Definition at line 129 of file conio.h.

137 {
141 }
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_p(_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)

◆ _vcprintf_s()

Definition at line 116 of file conio.h.

123 {
125 }

◆ _vcprintf_s_l()

Definition at line 100 of file conio.h.

108 {
112 }
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcprintf_s(_In_ unsigned __int64 _Options, _In_z_ _Printf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)

Referenced by _cprintf_s(), _cprintf_s_l(), and _vcprintf_s().

◆ _vcscanf_s()

Definition at line 322 of file conio.h.

329 {
331 }

◆ _vcscanf_s_l()

Definition at line 306 of file conio.h.

314 {
318 }
#define _CRT_INTERNAL_SCANF_SECURECRT
#define _CRT_INTERNAL_LOCAL_SCANF_OPTIONS
_Check_return_opt_ _DCRTIMP int __cdecl __conio_common_vcscanf(_In_ unsigned __int64 _Options, _In_z_ _Scanf_format_string_params_(2) char const *_Format, _In_opt_ _locale_t _Locale, va_list _ArgList)

Referenced by _cscanf_s(), _cscanf_s_l(), and _vcscanf_s().

Variable Documentation

◆ _ArgList

◆ _BufferCount

_In_z_ char const _In_ size_t _BufferCount

Definition at line 25 of file conio.h.

◆ _Locale

Definition at line 279 of file conio.h.

◆ _Result

◆ _SizeRead