4 #pragma GCC system_header
11 #define FOREGROUND_BLUE 1
12 #define FOREGROUND_GREEN 2
13 #define FOREGROUND_RED 4
14 #define FOREGROUND_INTENSITY 8
15 #define BACKGROUND_BLUE 16
16 #define BACKGROUND_GREEN 32
17 #define BACKGROUND_RED 64
18 #define BACKGROUND_INTENSITY 128
19 #if (_WIN32_WINNT >= 0x0501)
20 #define CONSOLE_FULLSCREEN_MODE 1
21 #define CONSOLE_WINDOWED_MODE 2
23 #define CTRL_C_EVENT 0
24 #define CTRL_BREAK_EVENT 1
25 #define CTRL_CLOSE_EVENT 2
26 #define CTRL_LOGOFF_EVENT 5
27 #define CTRL_SHUTDOWN_EVENT 6
28 #define ENABLE_LINE_INPUT 2
29 #define ENABLE_ECHO_INPUT 4
30 #define ENABLE_PROCESSED_INPUT 1
31 #define ENABLE_WINDOW_INPUT 8
32 #define ENABLE_MOUSE_INPUT 16
33 #define ENABLE_INSERT_MODE 32
34 #define ENABLE_QUICK_EDIT_MODE 64
35 #define ENABLE_EXTENDED_FLAGS 128
36 #define ENABLE_AUTO_POSITION 256
37 #define ENABLE_PROCESSED_OUTPUT 1
38 #define ENABLE_WRAP_AT_EOL_OUTPUT 2
41 #define WINDOW_BUFFER_SIZE_EVENT 4
43 #define FOCUS_EVENT 16
44 #define CAPSLOCK_ON 128
45 #define ENHANCED_KEY 256
46 #define RIGHT_ALT_PRESSED 1
47 #define LEFT_ALT_PRESSED 2
48 #define RIGHT_CTRL_PRESSED 4
49 #define LEFT_CTRL_PRESSED 8
50 #define SHIFT_PRESSED 16
52 #define SCROLLLOCK_ON 64
53 #define FROM_LEFT_1ST_BUTTON_PRESSED 1
54 #define RIGHTMOST_BUTTON_PRESSED 2
55 #define FROM_LEFT_2ND_BUTTON_PRESSED 4
56 #define FROM_LEFT_3RD_BUTTON_PRESSED 8
57 #define FROM_LEFT_4TH_BUTTON_PRESSED 16
59 #define DOUBLE_CLICK 2
60 #define MOUSE_WHEELED 4
62 typedef struct _CHAR_INFO
{
68 } CHAR_INFO
, *PCHAR_INFO
;
69 typedef struct _SMALL_RECT
{
74 } SMALL_RECT
, *PSMALL_RECT
;
75 typedef struct _CONSOLE_CURSOR_INFO
{
78 } CONSOLE_CURSOR_INFO
,*PCONSOLE_CURSOR_INFO
;
79 typedef struct _COORD
{
83 typedef struct _CONSOLE_FONT_INFO
{
86 } CONSOLE_FONT_INFO
, *PCONSOLE_FONT_INFO
;
87 typedef struct _CONSOLE_SCREEN_BUFFER_INFO
{
89 COORD dwCursorPosition
;
92 COORD dwMaximumWindowSize
;
93 } CONSOLE_SCREEN_BUFFER_INFO
,*PCONSOLE_SCREEN_BUFFER_INFO
;
94 typedef BOOL(CALLBACK
*PHANDLER_ROUTINE
)(DWORD
);
95 typedef struct _KEY_EVENT_RECORD
{
99 WORD wVirtualScanCode
;
104 DWORD dwControlKeyState
;
107 /* gcc's alignment is not what win32 expects */
112 typedef struct _MOUSE_EVENT_RECORD
{
113 COORD dwMousePosition
;
115 DWORD dwControlKeyState
;
117 } MOUSE_EVENT_RECORD
;
118 typedef struct _WINDOW_BUFFER_SIZE_RECORD
{ COORD dwSize
; } WINDOW_BUFFER_SIZE_RECORD
;
119 typedef struct _MENU_EVENT_RECORD
{ UINT dwCommandId
; } MENU_EVENT_RECORD
,*PMENU_EVENT_RECORD
;
120 typedef struct _FOCUS_EVENT_RECORD
{ BOOL bSetFocus
; } FOCUS_EVENT_RECORD
;
121 typedef struct _INPUT_RECORD
{
124 KEY_EVENT_RECORD KeyEvent
;
125 MOUSE_EVENT_RECORD MouseEvent
;
126 WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent
;
127 MENU_EVENT_RECORD MenuEvent
;
128 FOCUS_EVENT_RECORD FocusEvent
;
130 } INPUT_RECORD
,*PINPUT_RECORD
;
132 BOOL WINAPI
AllocConsole(void);
133 #if (_WIN32_WINNT >= 0x0500)
134 #define ATTACH_PARENT_PROCESS ((DWORD)-1)
135 BOOL WINAPI
AttachConsole(DWORD
);
137 HANDLE WINAPI
CreateConsoleScreenBuffer(DWORD
,DWORD
,CONST SECURITY_ATTRIBUTES
*,DWORD
,LPVOID
);
138 BOOL WINAPI
FillConsoleOutputAttribute(HANDLE
,WORD
,DWORD
,COORD
,PDWORD
);
139 BOOL WINAPI
FillConsoleOutputCharacterA(HANDLE
,CHAR
,DWORD
,COORD
,PDWORD
);
140 BOOL WINAPI
FillConsoleOutputCharacterW(HANDLE
,WCHAR
,DWORD
,COORD
,PDWORD
);
141 BOOL WINAPI
FlushConsoleInputBuffer(HANDLE
);
142 BOOL WINAPI
FreeConsole(void);
143 BOOL WINAPI
GenerateConsoleCtrlEvent(DWORD
,DWORD
);
144 UINT WINAPI
GetConsoleCP(void);
145 BOOL WINAPI
GetConsoleCursorInfo(HANDLE
,PCONSOLE_CURSOR_INFO
);
146 BOOL WINAPI
GetConsoleMode(HANDLE
,PDWORD
);
147 UINT WINAPI
GetConsoleOutputCP(void);
148 BOOL WINAPI
GetConsoleScreenBufferInfo(HANDLE
,PCONSOLE_SCREEN_BUFFER_INFO
);
149 DWORD WINAPI
GetConsoleTitleA(LPSTR
,DWORD
);
150 DWORD WINAPI
GetConsoleTitleW(LPWSTR
,DWORD
);
151 #if (_WIN32_WINNT >= 0x0500)
152 BOOL WINAPI
GetConsoleDisplayMode(LPDWORD
);
153 HWND WINAPI
GetConsoleWindow(void);
155 #if (_WIN32_WINNT >= 0x0501)
156 DWORD WINAPI
GetConsoleProcessList(LPDWORD
, DWORD
);
158 COORD WINAPI
GetLargestConsoleWindowSize(HANDLE
);
159 BOOL WINAPI
GetNumberOfConsoleInputEvents(HANDLE
,PDWORD
);
160 BOOL WINAPI
GetNumberOfConsoleMouseButtons(PDWORD
);
161 BOOL WINAPI
PeekConsoleInputA(HANDLE
,PINPUT_RECORD
,DWORD
,PDWORD
);
162 BOOL WINAPI
PeekConsoleInputW(HANDLE
,PINPUT_RECORD
,DWORD
,PDWORD
);
163 BOOL WINAPI
ReadConsoleA(HANDLE
,PVOID
,DWORD
,PDWORD
,PVOID
);
164 BOOL WINAPI
ReadConsoleW(HANDLE
,PVOID
,DWORD
,PDWORD
,PVOID
);
165 BOOL WINAPI
ReadConsoleInputA(HANDLE
,PINPUT_RECORD
,DWORD
,PDWORD
);
166 BOOL WINAPI
ReadConsoleInputW(HANDLE
,PINPUT_RECORD
,DWORD
,PDWORD
);
167 BOOL WINAPI
ReadConsoleOutputAttribute(HANDLE
,LPWORD
,DWORD
,COORD
,LPDWORD
);
168 BOOL WINAPI
ReadConsoleOutputCharacterA(HANDLE
,LPSTR
,DWORD
,COORD
,PDWORD
);
169 BOOL WINAPI
ReadConsoleOutputCharacterW(HANDLE
,LPWSTR
,DWORD
,COORD
,PDWORD
);
170 BOOL WINAPI
ReadConsoleOutputA(HANDLE
,PCHAR_INFO
,COORD
,COORD
,PSMALL_RECT
);
171 BOOL WINAPI
ReadConsoleOutputW(HANDLE
,PCHAR_INFO
,COORD
,COORD
,PSMALL_RECT
);
172 BOOL WINAPI
ScrollConsoleScreenBufferA(HANDLE
,const SMALL_RECT
*,const SMALL_RECT
*,COORD
,const CHAR_INFO
*);
173 BOOL WINAPI
ScrollConsoleScreenBufferW(HANDLE
,const SMALL_RECT
*,const SMALL_RECT
*,COORD
,const CHAR_INFO
*);
174 BOOL WINAPI
SetConsoleActiveScreenBuffer(HANDLE
);
175 BOOL WINAPI
SetConsoleCP(UINT
);
176 BOOL WINAPI
SetConsoleCtrlHandler(PHANDLER_ROUTINE
,BOOL
);
177 BOOL WINAPI
SetConsoleCursorInfo(HANDLE
,const CONSOLE_CURSOR_INFO
*);
178 BOOL WINAPI
SetConsoleCursorPosition(HANDLE
,COORD
);
179 #if (_WIN32_WINNT >= 0x0501)
180 BOOL WINAPI
SetConsoleDisplayMode(HANDLE
,DWORD
,PCOORD
);
182 BOOL WINAPI
SetConsoleMode(HANDLE
,DWORD
);
183 BOOL WINAPI
SetConsoleOutputCP(UINT
);
184 BOOL WINAPI
SetConsoleScreenBufferSize(HANDLE
,COORD
);
185 BOOL WINAPI
SetConsoleTextAttribute(HANDLE
,WORD
);
186 BOOL WINAPI
SetConsoleTitleA(LPCSTR
);
187 BOOL WINAPI
SetConsoleTitleW(LPCWSTR
);
188 BOOL WINAPI
SetConsoleWindowInfo(HANDLE
,BOOL
,const SMALL_RECT
*);
189 BOOL WINAPI
WriteConsoleA(HANDLE
,PCVOID
,DWORD
,PDWORD
,PVOID
);
190 BOOL WINAPI
WriteConsoleW(HANDLE
,PCVOID
,DWORD
,PDWORD
,PVOID
);
191 BOOL WINAPI
WriteConsoleInputA(HANDLE
,const INPUT_RECORD
*,DWORD
,PDWORD
);
192 BOOL WINAPI
WriteConsoleInputW(HANDLE
,const INPUT_RECORD
*,DWORD
,PDWORD
);
193 BOOL WINAPI
WriteConsoleOutputA(HANDLE
,const CHAR_INFO
*,COORD
,COORD
,PSMALL_RECT
);
194 BOOL WINAPI
WriteConsoleOutputW(HANDLE
,const CHAR_INFO
*,COORD
,COORD
,PSMALL_RECT
);
195 BOOL WINAPI
WriteConsoleOutputAttribute(HANDLE
,const WORD
*,DWORD
,COORD
,PDWORD
);
196 BOOL WINAPI
WriteConsoleOutputCharacterA(HANDLE
,LPCSTR
,DWORD
,COORD
,PDWORD
);
197 BOOL WINAPI
WriteConsoleOutputCharacterW(HANDLE
,LPCWSTR
,DWORD
,COORD
,PDWORD
);
200 #define FillConsoleOutputCharacter FillConsoleOutputCharacterW
201 #define GetConsoleTitle GetConsoleTitleW
202 #define PeekConsoleInput PeekConsoleInputW
203 #define ReadConsole ReadConsoleW
204 #define ReadConsoleInput ReadConsoleInputW
205 #define ReadConsoleOutput ReadConsoleOutputW
206 #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterW
207 #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferW
208 #define SetConsoleTitle SetConsoleTitleW
209 #define WriteConsole WriteConsoleW
210 #define WriteConsoleInput WriteConsoleInputW
211 #define WriteConsoleOutput WriteConsoleOutputW
212 #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterW
214 #define FillConsoleOutputCharacter FillConsoleOutputCharacterA
215 #define GetConsoleTitle GetConsoleTitleA
216 #define PeekConsoleInput PeekConsoleInputA
217 #define ReadConsole ReadConsoleA
218 #define ReadConsoleInput ReadConsoleInputA
219 #define ReadConsoleOutput ReadConsoleOutputA
220 #define ReadConsoleOutputCharacter ReadConsoleOutputCharacterA
221 #define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferA
222 #define SetConsoleTitle SetConsoleTitleA
223 #define WriteConsole WriteConsoleA
224 #define WriteConsoleInput WriteConsoleInputA
225 #define WriteConsoleOutput WriteConsoleOutputA
226 #define WriteConsoleOutputCharacter WriteConsoleOutputCharacterA