ReactOS 0.4.16-dev-297-gc569aee
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()

◆ _cprintf_l()

◆ _cprintf_p()

◆ _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}
#define NULL
Definition: types.h:112
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  )

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

◆ _getwch_nolock()

_Check_return_ _CRTIMP wint_t __cdecl _getwch_nolock ( void  )

◆ _getwche_nolock()

_Check_return_ _CRTIMP wint_t __cdecl _getwche_nolock ( void  )

◆ _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 KEY_EVENT
Definition: wincon.h:128
#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)

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

◆ _ungetch()

_CRTIMP int __cdecl _ungetch ( _In_ int  _Ch)

◆ _ungetch_nolock()

_CRTIMP int __cdecl _ungetch_nolock ( _In_ int  _Ch)

◆ _ungetwch()

◆ _ungetwch_nolock()

_Check_return_opt_ _CRTIMP wint_t __cdecl _ungetwch_nolock ( wint_t  _WCh)

◆ _vcprintf()

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 
)

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