ReactOS 0.4.16-dev-303-g11d5cb8
outstream.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Console Utilities Library
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Provides basic abstraction wrappers around CRT streams or
5 * Win32 console API I/O functions, to deal with i18n + Unicode
6 * related problems.
7 * COPYRIGHT: Copyright 2017-2018 ReactOS Team
8 * Copyright 2017-2018 Hermes Belusca-Maito
9 */
10
18/*
19 * Enable this define if you want to only use CRT functions to output
20 * UNICODE stream to the console, as in the way explained by
21 * http://archives.miloush.net/michkap/archive/2008/03/18/8306597.html
22 */
24// #define USE_CRT
25
26/* FIXME: Temporary HACK before we cleanly support UNICODE functions */
27#define UNICODE
28#define _UNICODE
29
30#ifdef USE_CRT
31#include <fcntl.h>
32#include <io.h>
33#endif /* USE_CRT */
34
35#include <stdlib.h> // limits.h // For MB_LEN_MAX
36
37#include <windef.h>
38#include <winbase.h>
39#include <winnls.h>
40#include <winuser.h> // MAKEINTRESOURCEW, RT_STRING
41#include <wincon.h> // Console APIs (only if kernel32 support included)
42#include <strsafe.h>
43
44/* PSEH for SEH Support */
45#include <pseh/pseh2.h>
46
47#include "conutils.h"
48#include "stream.h"
49#include "stream_private.h"
50
51
52// Also known as: RC_STRING_MAX_SIZE, MAX_BUFFER_SIZE (some programs:
53// wlanconf, shutdown, set it to 5024), OUTPUT_BUFFER_SIZE (name given
54// in cmd/console.c), MAX_STRING_SIZE (name given in diskpart) or
55// MAX_MESSAGE_SIZE (set to 512 in shutdown).
56#define CON_RC_STRING_MAX_SIZE 4096
57
58
83INT
87 IN PCTCH szStr,
88 IN DWORD len)
89{
90#ifndef USE_CRT
91 DWORD TotalLen = len, dwNumBytes = 0;
92 LPCVOID p;
93
94 /* If we do not write anything, just return */
95 if (!szStr || len == 0)
96 return 0;
97
98 /* Check whether we are writing to a console */
99 // if (IsConsoleHandle(Stream->hHandle))
100 if (Stream->IsConsole)
101 {
102 // TODO: Check if (Stream->Mode == WideText or UTF16Text) ??
103
104 /*
105 * This code is inspired from _cputws, in particular from the fact that,
106 * according to MSDN: https://msdn.microsoft.com/en-us/library/ms687401(v=vs.85).aspx
107 * the buffer size must be less than 64 KB.
108 *
109 * A similar code can be used for implementing _cputs too.
110 */
111
112 DWORD cchWrite;
113 TotalLen = len, dwNumBytes = 0;
114
115 while (len > 0)
116 {
117 cchWrite = min(len, 65535 / sizeof(WCHAR));
118
119 // FIXME: Check return value!
120 WriteConsole(Stream->hHandle, szStr, cchWrite, &dwNumBytes, NULL);
121
122 szStr += cchWrite;
123 len -= cchWrite;
124 }
125
126 return (INT)TotalLen; // FIXME: Really return the number of chars written!
127 }
128
129 /*
130 * We are redirected and writing to a file or pipe instead of the console.
131 * Convert the string from TCHARs to the desired output format, if the two differ.
132 *
133 * Implementation NOTE:
134 * MultiByteToWideChar (resp. WideCharToMultiByte) are equivalent to
135 * OemToCharBuffW (resp. CharToOemBuffW), but these latter functions
136 * uselessly depend on user32.dll, while MultiByteToWideChar and
137 * WideCharToMultiByte only need kernel32.dll.
138 */
139 if ((Stream->Mode == WideText) || (Stream->Mode == UTF16Text))
140 {
141#ifndef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
142 /* Convert from the current process/thread's code page to UTF-16 */
144 if (!buffer)
145 {
147 return 0;
148 }
149 len = (DWORD)MultiByteToWideChar(CP_THREAD_ACP, // CP_ACP, CP_OEMCP
150 0, szStr, (INT)len, buffer, (INT)len);
151 szStr = (PVOID)buffer;
152#else
153 /*
154 * Do not perform any conversion since we are already in UTF-16,
155 * that is the same encoding as the stream.
156 */
157#endif
158
159 /*
160 * Find any newline character in the buffer,
161 * write the part BEFORE the newline, then emit
162 * a carriage-return + newline sequence and finally
163 * write the remaining part of the buffer.
164 *
165 * This fixes output in files and serial console.
166 */
167 while (len > 0)
168 {
169 /* Loop until we find a newline character */
170 p = szStr;
171 while (len > 0 && *(PCWCH)p != L'\n')
172 {
173 /* Advance one character */
174 p = (LPCVOID)((PCWCH)p + 1);
175 --len;
176 }
177
178 /* Write everything up to \n */
179 dwNumBytes = ((PCWCH)p - (PCWCH)szStr) * sizeof(WCHAR);
180 WriteFile(Stream->hHandle, szStr, dwNumBytes, &dwNumBytes, NULL);
181
182 /*
183 * If we hit a newline and the previous character is not a carriage-return,
184 * emit a carriage-return + newline sequence, otherwise just emit the newline.
185 */
186 if (len > 0 && *(PCWCH)p == L'\n')
187 {
188 if (p == (LPCVOID)szStr || (p > (LPCVOID)szStr && *((PCWCH)p - 1) != L'\r'))
189 WriteFile(Stream->hHandle, L"\r\n", 2 * sizeof(WCHAR), &dwNumBytes, NULL);
190 else
191 WriteFile(Stream->hHandle, L"\n", sizeof(WCHAR), &dwNumBytes, NULL);
192
193 /* Skip \n */
194 p = (LPCVOID)((PCWCH)p + 1);
195 --len;
196 }
197 szStr = p;
198 }
199
200#ifndef _UNICODE
202#endif
203 }
204 else if ((Stream->Mode == UTF8Text) || (Stream->Mode == AnsiText))
205 {
206 UINT CodePage;
208
209 /*
210 * Resolve the current code page if it has not been assigned yet
211 * (we do this only if the stream is in ANSI mode; in UTF8 mode
212 * the code page is always set to CP_UTF8). Otherwise use the
213 * current stream's code page.
214 */
215 if (/*(Stream->Mode == AnsiText) &&*/ (Stream->CodePage == INVALID_CP))
216 CodePage = GetConsoleOutputCP(); // CP_ACP, CP_OEMCP
217 else
218 CodePage = Stream->CodePage;
219
220#ifdef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
221 /* Convert from UTF-16 to either UTF-8 or ANSI, using the stream code page */
222 // NOTE: MB_LEN_MAX defined either in limits.h or in stdlib.h .
224 if (!buffer)
225 {
227 return 0;
228 }
229 len = WideCharToMultiByte(CodePage, 0,
230 szStr, len, buffer, len * MB_LEN_MAX,
231 NULL, NULL);
232 szStr = (PVOID)buffer;
233#else
234 /*
235 * Convert from the current process/thread's code page to either
236 * UTF-8 or ANSI, using the stream code page.
237 * We need to perform a double conversion, by going through UTF-16.
238 */
239 // TODO!
240 #error "Need to implement double conversion!"
241#endif
242
243 /*
244 * Find any newline character in the buffer,
245 * write the part BEFORE the newline, then emit
246 * a carriage-return + newline sequence and finally
247 * write the remaining part of the buffer.
248 *
249 * This fixes output in files and serial console.
250 */
251 while (len > 0)
252 {
253 /* Loop until we find a newline character */
254 p = szStr;
255 while (len > 0 && *(PCCH)p != '\n')
256 {
257 /* Advance one character */
258 p = (LPCVOID)((PCCH)p + 1);
259 --len;
260 }
261
262 /* Write everything up to \n */
263 dwNumBytes = ((PCCH)p - (PCCH)szStr) * sizeof(CHAR);
264 WriteFile(Stream->hHandle, szStr, dwNumBytes, &dwNumBytes, NULL);
265
266 /*
267 * If we hit a newline and the previous character is not a carriage-return,
268 * emit a carriage-return + newline sequence, otherwise just emit the newline.
269 */
270 if (len > 0 && *(PCCH)p == '\n')
271 {
272 if (p == (LPCVOID)szStr || (p > (LPCVOID)szStr && *((PCCH)p - 1) != '\r'))
273 WriteFile(Stream->hHandle, "\r\n", 2, &dwNumBytes, NULL);
274 else
275 WriteFile(Stream->hHandle, "\n", 1, &dwNumBytes, NULL);
276
277 /* Skip \n */
278 p = (LPCVOID)((PCCH)p + 1);
279 --len;
280 }
281 szStr = p;
282 }
283
284#ifdef _UNICODE
286#else
287 // TODO!
288#endif
289 }
290 else // if (Stream->Mode == Binary)
291 {
292 /* Directly output the string */
293 WriteFile(Stream->hHandle, szStr, len, &dwNumBytes, NULL);
294 }
295
296 // FIXME!
297 return (INT)TotalLen;
298
299#else /* defined(USE_CRT) */
300
301 DWORD total = len;
302 DWORD written = 0;
303
304 /* If we do not write anything, just return */
305 if (!szStr || len == 0)
306 return 0;
307
308#if 1
309 /*
310 * There is no "counted" printf-to-stream or puts-like function, therefore
311 * we use this trick to output the counted string to the stream.
312 */
313 while (1)
314 {
315 written = fwprintf(Stream->fStream, L"%.*s", total, szStr);
316 if (written < total)
317 {
318 /*
319 * Some embedded NULL or special character
320 * was encountered, print it apart.
321 */
322 if (written == 0)
323 {
324 fputwc(*szStr, Stream->fStream);
325 written++;
326 }
327
328 szStr += written;
329 total -= written;
330 }
331 else
332 {
333 break;
334 }
335 }
336 return (INT)len;
337#else
338 /* ANSI text or Binary output only */
339 _setmode(_fileno(Stream->fStream), _O_TEXT); // _O_BINARY
340 return fwrite(szStr, sizeof(*szStr), len, Stream->fStream);
341#endif
342
343#endif /* defined(USE_CRT) */
344}
345
346
347#define CON_STREAM_WRITE_CALL(Stream, Str, Len) \
348 (Stream)->WriteFunc((Stream), (Str), (Len))
349
350/* Lock the stream only in non-USE_CRT mode (otherwise use the CRT stream lock) */
351#ifndef USE_CRT
352
353#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen) \
354do { \
355 EnterCriticalSection(&(Stream)->Lock); \
356 (RetLen) = CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
357 LeaveCriticalSection(&(Stream)->Lock); \
358} while(0)
359
360#define CON_STREAM_WRITE(Stream, Str, Len) \
361do { \
362 EnterCriticalSection(&(Stream)->Lock); \
363 CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
364 LeaveCriticalSection(&(Stream)->Lock); \
365} while(0)
366
367#else
368
369#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen) \
370do { \
371 (RetLen) = CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
372} while(0)
373
374#define CON_STREAM_WRITE(Stream, Str, Len) \
375 CON_STREAM_WRITE_CALL((Stream), (Str), (Len))
376
377#endif
378
379
397INT
400 IN PCTCH szStr,
401 IN DWORD len)
402{
403 INT Len;
405 return Len;
406}
407
426INT
429 IN PCWSTR szStr)
430{
431 INT Len;
432
433 Len = wcslen(szStr);
435
436 /* Fixup returned length in case of errors */
437 if (Len < 0)
438 Len = 0;
439
440 return Len;
441}
442
465INT
468 IN PCWSTR szStr,
470{
471 INT Len;
473
474 // Len = vfwprintf(Stream->fStream, szStr, args); // vfprintf for direct ANSI
475
476 /*
477 * Re-use szStr as the pointer to end-of-string, so as
478 * to compute the string length instead of calling wcslen().
479 */
480 // StringCchVPrintfW(bufSrc, ARRAYSIZE(bufSrc), szStr, args);
481 // Len = wcslen(bufSrc);
482 StringCchVPrintfExW(bufSrc, ARRAYSIZE(bufSrc), (PWSTR*)&szStr, NULL, 0, szStr, args);
483 Len = szStr - bufSrc;
484
485 CON_STREAM_WRITE2(Stream, bufSrc, Len, Len);
486
487 /* Fixup returned length in case of errors */
488 if (Len < 0)
489 Len = 0;
490
491 return Len;
492}
493
518INT
522 IN PCWSTR szStr,
523 ...)
524{
525 INT Len;
527
528 // Len = vfwprintf(Stream->fStream, szMsgBuf, args); // vfprintf for direct ANSI
529
530 // StringCchPrintfW
531 va_start(args, szStr);
532 Len = ConPrintfV(Stream, szStr, args);
533 va_end(args);
534
535 return Len;
536}
537
568INT
572 IN UINT uID,
573 IN LANGID LanguageId)
574{
575 INT Len;
576 PWCHAR szStr = NULL;
577
578 Len = K32LoadStringExW(hInstance, uID, LanguageId, (PWSTR)&szStr, 0);
579 if (szStr && Len)
580 // Len = ConPuts(Stream, szStr);
582
583 /* Fixup returned length in case of errors */
584 if (Len < 0)
585 Len = 0;
586
587 return Len;
588}
589
609INT
612 IN UINT uID)
613{
614 return ConResPutsEx(Stream, NULL /*GetModuleHandleW(NULL)*/,
616}
617
652INT
656 IN UINT uID,
657 IN LANGID LanguageId,
659{
660 INT Len;
662
663 // NOTE: We may use the special behaviour where nBufMaxSize == 0
664 Len = K32LoadStringExW(hInstance, uID, LanguageId, bufSrc, ARRAYSIZE(bufSrc));
665 if (Len)
666 Len = ConPrintfV(Stream, bufSrc, args);
667
668 return Len;
669}
670
694INT
697 IN UINT uID,
699{
700 return ConResPrintfExV(Stream, NULL /*GetModuleHandleW(NULL)*/,
702 args);
703}
704
738INT
743 IN UINT uID,
744 IN LANGID LanguageId,
745 ...)
746{
747 INT Len;
749
750 va_start(args, LanguageId);
751 Len = ConResPrintfExV(Stream, hInstance, uID, LanguageId, args);
752 va_end(args);
753
754 return Len;
755}
756
779INT
783 IN UINT uID,
784 ...)
785{
786 INT Len;
788
789 va_start(args, uID);
790 Len = ConResPrintfV(Stream, uID, args);
791 va_end(args);
792
793 return Len;
794}
795
836INT
840 IN LPCVOID lpSource OPTIONAL,
841 IN DWORD dwMessageId,
842 IN DWORD dwLanguageId)
843{
844 INT Len;
845 DWORD dwLength = 0;
846 LPWSTR lpMsgBuf = NULL;
847
848 /*
849 * Sanitize dwFlags. This version always ignores explicitly the inserts
850 * as we emulate the behaviour of the (f)puts function.
851 */
852 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
853 dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage.
854 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
855
856 /*
857 * Retrieve the message string without appending extra newlines.
858 * Wrap in SEH to protect from invalid string parameters.
859 */
861 {
863 lpSource,
864 dwMessageId,
865 dwLanguageId,
866 (LPWSTR)&lpMsgBuf,
867 0,
868 NULL);
869 }
871 {
872 }
873 _SEH2_END;
874
875 Len = (INT)dwLength;
876
877 if (!lpMsgBuf)
878 {
879 // ASSERT(dwLength == 0);
880 }
881 else
882 {
883 // ASSERT(dwLength != 0);
884
885 /* lpMsgBuf is NULL-terminated by FormatMessage */
886 // Len = ConPuts(Stream, lpMsgBuf);
888
889 /* Fixup returned length in case of errors */
890 if (Len < 0)
891 Len = 0;
892
893 /* Free the buffer allocated by FormatMessage */
894 LocalFree(lpMsgBuf);
895 }
896
897 return Len;
898}
899
908INT
912 IN LPCVOID lpSource OPTIONAL,
913 IN DWORD dwMessageId,
914 IN DWORD dwLanguageId,
916{
917 INT Len;
918 DWORD dwLength = 0;
919 LPWSTR lpMsgBuf = NULL;
920
921 /*
922 * Sanitize dwFlags. This version always ignores explicitly the inserts.
923 * The string that we will return to the user will not be pre-formatted.
924 */
925 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
926 dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage.
927 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
928
929 /*
930 * Retrieve the message string without appending extra newlines.
931 * Wrap in SEH to protect from invalid string parameters.
932 */
934 {
936 lpSource,
937 dwMessageId,
938 dwLanguageId,
939 (LPWSTR)&lpMsgBuf,
940 0,
941 NULL);
942 }
944 {
945 }
946 _SEH2_END;
947
948 Len = (INT)dwLength;
949
950 if (!lpMsgBuf)
951 {
952 // ASSERT(dwLength == 0);
953 }
954 else
955 {
956 // ASSERT(dwLength != 0);
957
958 /* lpMsgBuf is NULL-terminated by FormatMessage */
959 Len = ConPrintfV(Stream, lpMsgBuf, args);
960 // CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
961
962 /* Fixup returned length in case of errors */
963 if (Len < 0)
964 Len = 0;
965
966 /* Free the buffer allocated by FormatMessage */
967 LocalFree(lpMsgBuf);
968 }
969
970 return Len;
971}
972
1029INT
1033 IN LPCVOID lpSource OPTIONAL,
1034 IN DWORD dwMessageId,
1035 IN DWORD dwLanguageId,
1036 IN va_list *Arguments OPTIONAL)
1037{
1038 INT Len;
1039 DWORD dwLength = 0;
1040 LPWSTR lpMsgBuf = NULL;
1041
1042 /* Sanitize dwFlags */
1043 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
1044
1045 /*
1046 * Retrieve the message string without appending extra newlines.
1047 * Use the "safe" FormatMessage version (SEH-protected) to protect
1048 * from invalid string parameters.
1049 */
1051 lpSource,
1052 dwMessageId,
1053 dwLanguageId,
1054 (LPWSTR)&lpMsgBuf,
1055 0,
1056 Arguments);
1057
1058 Len = (INT)dwLength;
1059
1060 if (!lpMsgBuf)
1061 {
1062 // ASSERT(dwLength == 0);
1063 }
1064 else
1065 {
1066 // ASSERT(dwLength != 0);
1067
1068 CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
1069
1070 /* Fixup returned length in case of errors */
1071 if (Len < 0)
1072 Len = 0;
1073
1074 /* Free the buffer allocated by FormatMessage */
1075 LocalFree(lpMsgBuf);
1076 }
1077
1078 return Len;
1079}
1080
1128INT
1129__cdecl
1133 IN LPCVOID lpSource OPTIONAL,
1134 IN DWORD dwMessageId,
1135 IN DWORD dwLanguageId,
1136 ...)
1137{
1138 INT Len;
1139 va_list args;
1140
1141 /* Sanitize dwFlags */
1142 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1143
1144 va_start(args, dwLanguageId);
1146 dwFlags,
1147 lpSource,
1148 dwMessageId,
1149 dwLanguageId,
1150 &args);
1151 va_end(args);
1152
1153 return Len;
1154}
1155
1217INT
1222 IN UINT uID,
1223 IN LANGID LanguageId,
1224 IN va_list *Arguments OPTIONAL)
1225{
1226 INT Len;
1227 DWORD dwLength = 0;
1228 LPWSTR lpMsgBuf = NULL;
1230
1231 /* Retrieve the string from the resource string table */
1232 // NOTE: We may use the special behaviour where nBufMaxSize == 0
1233 Len = K32LoadStringExW(hInstance, uID, LanguageId, bufSrc, ARRAYSIZE(bufSrc));
1234 if (Len == 0)
1235 return Len;
1236
1237 /* Sanitize dwFlags */
1238 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
1239
1240 /* The string has already been manually loaded */
1243
1244 /*
1245 * Retrieve the message string without appending extra newlines.
1246 * Use the "safe" FormatMessage version (SEH-protected) to protect
1247 * from invalid string parameters.
1248 */
1250 bufSrc,
1251 0, 0,
1252 (LPWSTR)&lpMsgBuf,
1253 0,
1254 Arguments);
1255
1256 Len = (INT)dwLength;
1257
1258 if (!lpMsgBuf)
1259 {
1260 // ASSERT(dwLength == 0);
1261 }
1262 else
1263 {
1264 // ASSERT(dwLength != 0);
1265
1266 CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
1267
1268 /* Fixup returned length in case of errors */
1269 if (Len < 0)
1270 Len = 0;
1271
1272 /* Free the buffer allocated by FormatMessage */
1273 LocalFree(lpMsgBuf);
1274 }
1275
1276 return Len;
1277}
1278
1328INT
1332 IN UINT uID,
1333 IN va_list *Arguments OPTIONAL)
1334{
1335 return ConResMsgPrintfExV(Stream, NULL /*GetModuleHandleW(NULL)*/,
1336 dwFlags, uID,
1338 Arguments);
1339}
1340
1392INT
1393__cdecl
1398 IN UINT uID,
1399 IN LANGID LanguageId,
1400 ...)
1401{
1402 INT Len;
1403 va_list args;
1404
1405 /* Sanitize dwFlags */
1406 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1407
1408 va_start(args, LanguageId);
1410 hInstance,
1411 dwFlags,
1412 uID,
1413 LanguageId,
1414 &args);
1415 va_end(args);
1416
1417 return Len;
1418}
1419
1459INT
1460__cdecl
1464 IN UINT uID,
1465 ...)
1466{
1467 INT Len;
1468 va_list args;
1469
1470 /* Sanitize dwFlags */
1471 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1472
1473 va_start(args, uID);
1475 va_end(args);
1476
1477 return Len;
1478}
1479
1480
1481
1482VOID
1484{
1486
1487 /*
1488 * Erase the full line where the cursor is, and move
1489 * the cursor back to the beginning of the line.
1490 */
1491
1492 if (IsConsoleHandle(hOutput))
1493 {
1495 DWORD dwWritten;
1496
1497 GetConsoleScreenBufferInfo(hOutput, &csbi);
1498
1499 csbi.dwCursorPosition.X = 0;
1500 // csbi.dwCursorPosition.Y;
1501
1502 FillConsoleOutputCharacterW(hOutput, L' ',
1503 csbi.dwSize.X,
1504 csbi.dwCursorPosition,
1505 &dwWritten);
1507 }
1508 else if (IsTTYHandle(hOutput))
1509 {
1510 ConPuts(Stream, L"\x1B[2K\x1B[1G"); // FIXME: Just use WriteFile
1511 }
1512 // else, do nothing for files
1513}
1514
1515/* EOF */
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:641
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
#define _setmode(fd, mode)
Definition: cat.c:21
HINSTANCE hInstance
Definition: charmap.c:19
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define Len
Definition: deflate.h:82
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define _O_TEXT
Definition: cabinet.h:50
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2451
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: readwrite.c:1674
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
unsigned long DWORD
Definition: ntddk_ex.h:95
size_t total
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fwprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const wchar_t *_Format,...)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
#define MB_LEN_MAX
Definition: stdlib.h:19
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
USHORT LANGID
Definition: mui.h:9
static IStream Stream
Definition: htmldoc.c:1115
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
LPCCH PCTCH
Definition: ntbasedef.h:494
CONST WCHAR * PCWCH
Definition: ntbasedef.h:419
CONST CHAR * PCCH
Definition: ntbasedef.h:400
#define L(x)
Definition: ntvdm.h:50
INT __stdcall ConWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
Definition: outstream.c:85
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN PCWSTR szStr,...)
Definition: outstream.c:520
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
INT __cdecl ConResMsgPrintf(IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID,...)
Definition: outstream.c:1461
INT ConResPrintfV(IN PCON_STREAM Stream, IN UINT uID, IN va_list args)
Definition: outstream.c:695
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
INT ConPuts(IN PCON_STREAM Stream, IN PCWSTR szStr)
Definition: outstream.c:427
VOID ConClearLine(IN PCON_STREAM Stream)
Definition: outstream.c:1483
INT ConResMsgPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1218
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
INT ConResPutsEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId)
Definition: outstream.c:569
INT __cdecl ConResPrintfEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId,...)
Definition: outstream.c:740
INT __cdecl ConMsgPrintf(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId,...)
Definition: outstream.c:1130
INT ConResMsgPrintfV(IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1329
#define CON_RC_STRING_MAX_SIZE
Definition: outstream.c:56
INT __cdecl ConResMsgPrintfEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId,...)
Definition: outstream.c:1394
INT ConResPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
Definition: outstream.c:653
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
INT ConMsgPrintf2V(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, IN va_list args)
Definition: outstream.c:909
INT ConPrintfV(IN PCON_STREAM Stream, IN PCWSTR szStr, IN va_list args)
Definition: outstream.c:466
INT ConStreamWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
Definition: outstream.c:398
INT ConMsgPrintfV(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1030
#define INT
Definition: polytest.cpp:20
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define IsConsoleHandle(h)
Definition: console.h:14
HANDLE ConStreamGetOSHandle(IN PCON_STREAM Stream)
Definition: stream.c:240
Console I/O streams.
@ AnsiText
Definition: stream.h:47
@ UTF16Text
Definition: stream.h:49
@ WideText
Definition: stream.h:48
@ UTF8Text
Definition: stream.h:50
#define INVALID_CP
Definition: stream.h:53
INT WINAPI K32LoadStringExW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:99
BOOL IsTTYHandle(IN HANDLE hHandle)
Definition: utils.c:393
DWORD WINAPI FormatMessageSafeW(IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, OUT LPWSTR lpBuffer, IN DWORD nSize, IN va_list *Arguments OPTIONAL)
Definition: utils.c:254
#define args
Definition: format.c:66
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
STRSAFEAPI StringCchVPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat, va_list argList)
Definition: strsafe.h:661
Definition: match.c:390
SHORT X
Definition: blue.h:26
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
void * PVOID
Definition: typedefs.h:50
int32_t INT
Definition: typedefs.h:58
#define __stdcall
Definition: typedefs.h:25
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
char * PCHAR
Definition: typedefs.h:51
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:447
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448
#define WriteConsole
Definition: wincon.h:784
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
CONST void * LPCVOID
Definition: windef.h:191
#define CP_THREAD_ACP
Definition: winnls.h:235
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175