ReactOS 0.4.16-dev-2491-g3dc6630
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 <wincon.h> // Console APIs (only if kernel32 support included)
40#include <winnls.h>
41#include <strsafe.h>
42
43/* PSEH for SEH Support */
44#include <pseh/pseh2.h>
45
46#include "conutils.h"
47#include "stream.h"
48#include "stream_private.h"
49
50
51// Also known as: RC_STRING_MAX_SIZE, MAX_BUFFER_SIZE (some programs:
52// wlanconf, shutdown, set it to 5024), OUTPUT_BUFFER_SIZE (name given
53// in cmd/console.c), MAX_STRING_SIZE (name given in diskpart) or
54// MAX_MESSAGE_SIZE (set to 512 in shutdown).
55#define CON_RC_STRING_MAX_SIZE 4096
56
57
82INT
86 IN PCTCH szStr,
87 IN DWORD len)
88{
89#ifndef USE_CRT
90 DWORD TotalLen = len, dwNumBytes = 0;
91 LPCVOID p;
92
93 /* If we do not write anything, just return */
94 if (!szStr || len == 0)
95 return 0;
96
97 /* Check whether we are writing to a console */
98 // if (IsConsoleHandle(Stream->hHandle))
99 if (Stream->IsConsole)
100 {
101 // TODO: Check if (Stream->Mode == WideText or UTF16Text) ??
102
103 /*
104 * This code is inspired from _cputws, in particular from the fact that,
105 * according to MSDN: https://learn.microsoft.com/en-us/windows/console/writeconsole
106 * the buffer size must be less than 64 KB.
107 *
108 * A similar code can be used for implementing _cputs too.
109 */
110
111 DWORD cchWrite;
112 TotalLen = len, dwNumBytes = 0;
113
114 while (len > 0)
115 {
116 cchWrite = min(len, 65535 / sizeof(WCHAR));
117
118 // FIXME: Check return value!
119 WriteConsole(Stream->hHandle, szStr, cchWrite, &dwNumBytes, NULL);
120
121 szStr += cchWrite;
122 len -= cchWrite;
123 }
124
125 return (INT)TotalLen; // FIXME: Really return the number of chars written!
126 }
127
128 /*
129 * We are redirected and writing to a file or pipe instead of the console.
130 * Convert the string from TCHARs to the desired output format, if the two differ.
131 *
132 * Implementation NOTE:
133 * MultiByteToWideChar (resp. WideCharToMultiByte) are equivalent to
134 * OemToCharBuffW (resp. CharToOemBuffW), but these latter functions
135 * uselessly depend on user32.dll, while MultiByteToWideChar and
136 * WideCharToMultiByte only need kernel32.dll.
137 */
138 if ((Stream->Mode == WideText) || (Stream->Mode == UTF16Text))
139 {
140#ifndef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
141 /* Convert from the current process/thread's code page to UTF-16 */
143 if (!buffer)
144 {
146 return 0;
147 }
148 len = (DWORD)MultiByteToWideChar(CP_THREAD_ACP, // CP_ACP, CP_OEMCP
149 0, szStr, (INT)len, buffer, (INT)len);
150 szStr = (PVOID)buffer;
151#else
152 /*
153 * Do not perform any conversion since we are already in UTF-16,
154 * that is the same encoding as the stream.
155 */
156#endif
157
158 /*
159 * Find any newline character in the buffer,
160 * write the part BEFORE the newline, then emit
161 * a carriage-return + newline sequence and finally
162 * write the remaining part of the buffer.
163 *
164 * This fixes output in files and serial console.
165 */
166 while (len > 0)
167 {
168 /* Loop until we find a newline character */
169 p = szStr;
170 while (len > 0 && *(PCWCH)p != L'\n')
171 {
172 /* Advance one character */
173 p = (LPCVOID)((PCWCH)p + 1);
174 --len;
175 }
176
177 /* Write everything up to \n */
178 dwNumBytes = (DWORD)(((PCWCH)p - (PCWCH)szStr) * sizeof(WCHAR));
179 WriteFile(Stream->hHandle, szStr, dwNumBytes, &dwNumBytes, NULL);
180
181 /*
182 * If we hit a newline and the previous character is not a carriage-return,
183 * emit a carriage-return + newline sequence, otherwise just emit the newline.
184 */
185 if (len > 0 && *(PCWCH)p == L'\n')
186 {
187 if (p == (LPCVOID)szStr || (p > (LPCVOID)szStr && *((PCWCH)p - 1) != L'\r'))
188 WriteFile(Stream->hHandle, L"\r\n", 2 * sizeof(WCHAR), &dwNumBytes, NULL);
189 else
190 WriteFile(Stream->hHandle, L"\n", sizeof(WCHAR), &dwNumBytes, NULL);
191
192 /* Skip \n */
193 p = (LPCVOID)((PCWCH)p + 1);
194 --len;
195 }
196 szStr = p;
197 }
198
199#ifndef _UNICODE
201#endif
202 }
203 else if ((Stream->Mode == UTF8Text) || (Stream->Mode == AnsiText))
204 {
205 UINT CodePage;
207
208 /*
209 * Resolve the current code page if it has not been assigned yet
210 * (we do this only if the stream is in ANSI mode; in UTF8 mode
211 * the code page is always set to CP_UTF8). Otherwise use the
212 * current stream's code page.
213 */
214 if (/*(Stream->Mode == AnsiText) &&*/ (Stream->CodePage == INVALID_CP))
215 CodePage = GetConsoleOutputCP(); // CP_ACP, CP_OEMCP
216 else
217 CodePage = Stream->CodePage;
218
219#ifdef _UNICODE // UNICODE means that TCHAR == WCHAR == UTF-16
220 /* Convert from UTF-16 to either UTF-8 or ANSI, using the stream code page */
221 // NOTE: MB_LEN_MAX defined either in limits.h or in stdlib.h .
223 if (!buffer)
224 {
226 return 0;
227 }
228 len = WideCharToMultiByte(CodePage, 0,
229 szStr, len, buffer, len * MB_LEN_MAX,
230 NULL, NULL);
231 szStr = (PVOID)buffer;
232#else
233 /*
234 * Convert from the current process/thread's code page to either
235 * UTF-8 or ANSI, using the stream code page.
236 * We need to perform a double conversion, by going through UTF-16.
237 */
238 // TODO!
239 #error "Need to implement double conversion!"
240#endif
241
242 /*
243 * Find any newline character in the buffer,
244 * write the part BEFORE the newline, then emit
245 * a carriage-return + newline sequence and finally
246 * write the remaining part of the buffer.
247 *
248 * This fixes output in files and serial console.
249 */
250 while (len > 0)
251 {
252 /* Loop until we find a newline character */
253 p = szStr;
254 while (len > 0 && *(PCCH)p != '\n')
255 {
256 /* Advance one character */
257 p = (LPCVOID)((PCCH)p + 1);
258 --len;
259 }
260
261 /* Write everything up to \n */
262 dwNumBytes = (DWORD)(((PCCH)p - (PCCH)szStr) * sizeof(CHAR));
263 WriteFile(Stream->hHandle, szStr, dwNumBytes, &dwNumBytes, NULL);
264
265 /*
266 * If we hit a newline and the previous character is not a carriage-return,
267 * emit a carriage-return + newline sequence, otherwise just emit the newline.
268 */
269 if (len > 0 && *(PCCH)p == '\n')
270 {
271 if (p == (LPCVOID)szStr || (p > (LPCVOID)szStr && *((PCCH)p - 1) != '\r'))
272 WriteFile(Stream->hHandle, "\r\n", 2, &dwNumBytes, NULL);
273 else
274 WriteFile(Stream->hHandle, "\n", 1, &dwNumBytes, NULL);
275
276 /* Skip \n */
277 p = (LPCVOID)((PCCH)p + 1);
278 --len;
279 }
280 szStr = p;
281 }
282
283#ifdef _UNICODE
285#else
286 // TODO!
287#endif
288 }
289 else // if (Stream->Mode == Binary)
290 {
291 /* Directly output the string */
292 WriteFile(Stream->hHandle, szStr, len, &dwNumBytes, NULL);
293 }
294
295 // FIXME!
296 return (INT)TotalLen;
297
298#else /* defined(USE_CRT) */
299
300 DWORD total = len;
301 DWORD written = 0;
302
303 /* If we do not write anything, just return */
304 if (!szStr || len == 0)
305 return 0;
306
307#if 1
308 /*
309 * There is no "counted" printf-to-stream or puts-like function, therefore
310 * we use this trick to output the counted string to the stream.
311 */
312 while (1)
313 {
314 written = fwprintf(Stream->fStream, L"%.*s", total, szStr);
315 if (written < total)
316 {
317 /*
318 * Some embedded NULL or special character
319 * was encountered, print it apart.
320 */
321 if (written == 0)
322 {
323 fputwc(*szStr, Stream->fStream);
324 written++;
325 }
326
327 szStr += written;
328 total -= written;
329 }
330 else
331 {
332 break;
333 }
334 }
335 return (INT)len;
336#else
337 /* ANSI text or Binary output only */
338 _setmode(_fileno(Stream->fStream), _O_TEXT); // _O_BINARY
339 return fwrite(szStr, sizeof(*szStr), len, Stream->fStream);
340#endif
341
342#endif /* defined(USE_CRT) */
343}
344
345
346#define CON_STREAM_WRITE_CALL(Stream, Str, Len) \
347 (Stream)->WriteFunc((Stream), (Str), (Len))
348
349/* Lock the stream only in non-USE_CRT mode (otherwise use the CRT stream lock) */
350#ifndef USE_CRT
351
352#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen) \
353do { \
354 EnterCriticalSection(&(Stream)->Lock); \
355 (RetLen) = CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
356 LeaveCriticalSection(&(Stream)->Lock); \
357} while(0)
358
359#define CON_STREAM_WRITE(Stream, Str, Len) \
360do { \
361 EnterCriticalSection(&(Stream)->Lock); \
362 CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
363 LeaveCriticalSection(&(Stream)->Lock); \
364} while(0)
365
366#else
367
368#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen) \
369do { \
370 (RetLen) = CON_STREAM_WRITE_CALL((Stream), (Str), (Len)); \
371} while(0)
372
373#define CON_STREAM_WRITE(Stream, Str, Len) \
374 CON_STREAM_WRITE_CALL((Stream), (Str), (Len))
375
376#endif
377
378
396INT
399 IN PCTCH szStr,
400 IN DWORD len)
401{
402 INT Len;
404 return Len;
405}
406
425INT
428 IN PCWSTR szStr)
429{
430 INT Len;
431
432 Len = (INT)wcslen(szStr);
434
435 /* Fixup returned length in case of errors */
436 if (Len < 0)
437 Len = 0;
438
439 return Len;
440}
441
464INT
467 IN PCWSTR szStr,
469{
470 INT Len;
472
473 // Len = vfwprintf(Stream->fStream, szStr, args); // vfprintf for direct ANSI
474
475 /*
476 * Re-use szStr as the pointer to end-of-string, so as
477 * to compute the string length instead of calling wcslen().
478 */
479 // StringCchVPrintfW(bufSrc, ARRAYSIZE(bufSrc), szStr, args);
480 // Len = wcslen(bufSrc);
481 StringCchVPrintfExW(bufSrc, ARRAYSIZE(bufSrc), (PWSTR*)&szStr, NULL, 0, szStr, args);
482 Len = szStr - bufSrc;
483
484 CON_STREAM_WRITE2(Stream, bufSrc, Len, Len);
485
486 /* Fixup returned length in case of errors */
487 if (Len < 0)
488 Len = 0;
489
490 return Len;
491}
492
517INT
521 IN PCWSTR szStr,
522 ...)
523{
524 INT Len;
526
527 // Len = vfwprintf(Stream->fStream, szMsgBuf, args); // vfprintf for direct ANSI
528
529 // StringCchPrintfW
530 va_start(args, szStr);
531 Len = ConPrintfV(Stream, szStr, args);
532 va_end(args);
533
534 return Len;
535}
536
567INT
571 IN UINT uID,
572 IN LANGID LanguageId)
573{
574 INT Len;
575 PWCHAR szStr = NULL;
576
577 Len = K32LoadStringExW(hInstance, uID, LanguageId, (PWSTR)&szStr, 0);
578 if (szStr && Len)
579 // Len = ConPuts(Stream, szStr);
581
582 /* Fixup returned length in case of errors */
583 if (Len < 0)
584 Len = 0;
585
586 return Len;
587}
588
608INT
611 IN UINT uID)
612{
613 return ConResPutsEx(Stream, NULL, uID,
615}
616
651INT
655 IN UINT uID,
656 IN LANGID LanguageId,
658{
659 INT Len;
661
662 // NOTE: We may use the special behaviour where nBufMaxSize == 0
663 Len = K32LoadStringExW(hInstance, uID, LanguageId, bufSrc, ARRAYSIZE(bufSrc));
664 if (Len)
665 Len = ConPrintfV(Stream, bufSrc, args);
666
667 return Len;
668}
669
693INT
696 IN UINT uID,
698{
701}
702
736INT
741 IN UINT uID,
742 IN LANGID LanguageId,
743 ...)
744{
745 INT Len;
747
748 va_start(args, LanguageId);
749 Len = ConResPrintfExV(Stream, hInstance, uID, LanguageId, args);
750 va_end(args);
751
752 return Len;
753}
754
777INT
781 IN UINT uID,
782 ...)
783{
784 INT Len;
786
787 va_start(args, uID);
789 va_end(args);
790
791 return Len;
792}
793
834INT
838 IN LPCVOID lpSource OPTIONAL,
839 IN DWORD dwMessageId,
840 IN DWORD dwLanguageId)
841{
842 INT Len;
843 DWORD dwLength = 0;
844 LPWSTR lpMsgBuf = NULL;
845
846 /*
847 * Sanitize dwFlags. This version always ignores explicitly the inserts
848 * as we emulate the behaviour of the (f)puts function.
849 */
850 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
851 dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage.
852 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
853
854 /*
855 * Retrieve the message string without appending extra newlines.
856 * Wrap in SEH to protect from invalid string parameters.
857 */
859 {
861 lpSource,
862 dwMessageId,
863 dwLanguageId,
864 (LPWSTR)&lpMsgBuf,
865 0,
866 NULL);
867 }
869 {
870 }
871 _SEH2_END;
872
873 Len = (INT)dwLength;
874
875 if (!lpMsgBuf)
876 {
877 // ASSERT(dwLength == 0);
878 }
879 else
880 {
881 // ASSERT(dwLength != 0);
882
883 /* lpMsgBuf is NULL-terminated by FormatMessage */
884 // Len = ConPuts(Stream, lpMsgBuf);
886
887 /* Fixup returned length in case of errors */
888 if (Len < 0)
889 Len = 0;
890
891 /* Free the buffer allocated by FormatMessage */
892 LocalFree(lpMsgBuf);
893 }
894
895 return Len;
896}
897
906INT
910 IN LPCVOID lpSource OPTIONAL,
911 IN DWORD dwMessageId,
912 IN DWORD dwLanguageId,
914{
915 INT Len;
916 DWORD dwLength = 0;
917 LPWSTR lpMsgBuf = NULL;
918
919 /*
920 * Sanitize dwFlags. This version always ignores explicitly the inserts.
921 * The string that we will return to the user will not be pre-formatted.
922 */
923 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
924 dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; // Ignore inserts for FormatMessage.
925 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
926
927 /*
928 * Retrieve the message string without appending extra newlines.
929 * Wrap in SEH to protect from invalid string parameters.
930 */
932 {
934 lpSource,
935 dwMessageId,
936 dwLanguageId,
937 (LPWSTR)&lpMsgBuf,
938 0,
939 NULL);
940 }
942 {
943 }
944 _SEH2_END;
945
946 Len = (INT)dwLength;
947
948 if (!lpMsgBuf)
949 {
950 // ASSERT(dwLength == 0);
951 }
952 else
953 {
954 // ASSERT(dwLength != 0);
955
956 /* lpMsgBuf is NULL-terminated by FormatMessage */
957 Len = ConPrintfV(Stream, lpMsgBuf, args);
958 // CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
959
960 /* Fixup returned length in case of errors */
961 if (Len < 0)
962 Len = 0;
963
964 /* Free the buffer allocated by FormatMessage */
965 LocalFree(lpMsgBuf);
966 }
967
968 return Len;
969}
970
1027INT
1031 IN LPCVOID lpSource OPTIONAL,
1032 IN DWORD dwMessageId,
1033 IN DWORD dwLanguageId,
1034 IN va_list *Arguments OPTIONAL)
1035{
1036 INT Len;
1037 DWORD dwLength = 0;
1038 LPWSTR lpMsgBuf = NULL;
1039
1040 /* Sanitize dwFlags */
1041 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
1042
1043 /*
1044 * Retrieve the message string without appending extra newlines.
1045 * Use the "safe" FormatMessage version (SEH-protected) to protect
1046 * from invalid string parameters.
1047 */
1049 lpSource,
1050 dwMessageId,
1051 dwLanguageId,
1052 (LPWSTR)&lpMsgBuf,
1053 0,
1054 Arguments);
1055
1056 Len = (INT)dwLength;
1057
1058 if (!lpMsgBuf)
1059 {
1060 // ASSERT(dwLength == 0);
1061 }
1062 else
1063 {
1064 // ASSERT(dwLength != 0);
1065
1066 CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
1067
1068 /* Fixup returned length in case of errors */
1069 if (Len < 0)
1070 Len = 0;
1071
1072 /* Free the buffer allocated by FormatMessage */
1073 LocalFree(lpMsgBuf);
1074 }
1075
1076 return Len;
1077}
1078
1126INT
1127__cdecl
1131 IN LPCVOID lpSource OPTIONAL,
1132 IN DWORD dwMessageId,
1133 IN DWORD dwLanguageId,
1134 ...)
1135{
1136 INT Len;
1137 va_list args;
1138
1139 /* Sanitize dwFlags */
1140 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1141
1142 va_start(args, dwLanguageId);
1144 dwFlags,
1145 lpSource,
1146 dwMessageId,
1147 dwLanguageId,
1148 &args);
1149 va_end(args);
1150
1151 return Len;
1152}
1153
1215INT
1220 IN UINT uID,
1221 IN LANGID LanguageId,
1222 IN va_list *Arguments OPTIONAL)
1223{
1224 INT Len;
1225 DWORD dwLength = 0;
1226 LPWSTR lpMsgBuf = NULL;
1228
1229 /* Retrieve the string from the resource string table */
1230 // NOTE: We may use the special behaviour where nBufMaxSize == 0
1231 Len = K32LoadStringExW(hInstance, uID, LanguageId, bufSrc, ARRAYSIZE(bufSrc));
1232 if (Len == 0)
1233 return Len;
1234
1235 /* Sanitize dwFlags */
1236 dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER; // Always allocate an internal buffer.
1237
1238 /* The string has already been manually loaded */
1241
1242 /*
1243 * Retrieve the message string without appending extra newlines.
1244 * Use the "safe" FormatMessage version (SEH-protected) to protect
1245 * from invalid string parameters.
1246 */
1248 bufSrc,
1249 0, 0,
1250 (LPWSTR)&lpMsgBuf,
1251 0,
1252 Arguments);
1253
1254 Len = (INT)dwLength;
1255
1256 if (!lpMsgBuf)
1257 {
1258 // ASSERT(dwLength == 0);
1259 }
1260 else
1261 {
1262 // ASSERT(dwLength != 0);
1263
1264 CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
1265
1266 /* Fixup returned length in case of errors */
1267 if (Len < 0)
1268 Len = 0;
1269
1270 /* Free the buffer allocated by FormatMessage */
1271 LocalFree(lpMsgBuf);
1272 }
1273
1274 return Len;
1275}
1276
1326INT
1330 IN UINT uID,
1331 IN va_list *Arguments OPTIONAL)
1332{
1335 Arguments);
1336}
1337
1389INT
1390__cdecl
1395 IN UINT uID,
1396 IN LANGID LanguageId,
1397 ...)
1398{
1399 INT Len;
1400 va_list args;
1401
1402 /* Sanitize dwFlags */
1403 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1404
1405 va_start(args, LanguageId);
1407 hInstance,
1408 dwFlags,
1409 uID,
1410 LanguageId,
1411 &args);
1412 va_end(args);
1413
1414 return Len;
1415}
1416
1456INT
1457__cdecl
1461 IN UINT uID,
1462 ...)
1463{
1464 INT Len;
1465 va_list args;
1466
1467 /* Sanitize dwFlags */
1468 dwFlags &= ~FORMAT_MESSAGE_ARGUMENT_ARRAY;
1469
1470 va_start(args, uID);
1472 va_end(args);
1473
1474 return Len;
1475}
1476
1477
1478
1479VOID
1481{
1483
1484 /*
1485 * Erase the full line where the cursor is, and move
1486 * the cursor back to the beginning of the line.
1487 */
1488
1489 if (IsConsoleHandle(hOutput))
1490 {
1492 DWORD dwWritten;
1493
1494 GetConsoleScreenBufferInfo(hOutput, &csbi);
1495
1496 csbi.dwCursorPosition.X = 0;
1497 // csbi.dwCursorPosition.Y;
1498
1499 FillConsoleOutputCharacterW(hOutput, L' ',
1500 csbi.dwSize.X,
1501 csbi.dwCursorPosition,
1502 &dwWritten);
1504 }
1505 else if (IsTTYHandle(hOutput))
1506 {
1507 ConPuts(Stream, L"\x1B[2K\x1B[1G"); // FIXME: Just use WriteFile
1508 }
1509 // else, do nothing for files
1510}
1511
1512/* EOF */
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 CHAR(Char)
#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
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
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(void)
Definition: console.c:957
wint_t CDECL fputwc(wint_t wc, FILE *file)
Definition: file.c:4203
int WINAPIV fwprintf(FILE *file, const wchar_t *format,...)
Definition: file.c:5628
int CDECL _fileno(FILE *file)
Definition: file.c:1925
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4129
#define __cdecl
Definition: corecrt.h:121
#define __stdcall
Definition: corecrt.h:120
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define MB_LEN_MAX
Definition: limits.h:7
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
#define L(x)
Definition: resources.c:13
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
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
USHORT LANGID
Definition: mui.h:9
CONST void * LPCVOID
Definition: minwindef.h:164
static IStream Stream
Definition: htmldoc.c:1115
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define DWORD
Definition: nt_native.h:44
LPCCH PCTCH
Definition: ntbasedef.h:498
CONST WCHAR * PCWCH
Definition: ntbasedef.h:423
CONST CHAR * PCCH
Definition: ntbasedef.h:404
INT __stdcall ConWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
Definition: outstream.c:84
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN PCWSTR szStr,...)
Definition: outstream.c:519
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:609
INT __cdecl ConResMsgPrintf(IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID,...)
Definition: outstream.c:1458
INT ConResPrintfV(IN PCON_STREAM Stream, IN UINT uID, IN va_list args)
Definition: outstream.c:694
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:352
INT ConPuts(IN PCON_STREAM Stream, IN PCWSTR szStr)
Definition: outstream.c:426
VOID ConClearLine(IN PCON_STREAM Stream)
Definition: outstream.c:1480
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:1216
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:835
INT ConResPutsEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId)
Definition: outstream.c:568
INT __cdecl ConResPrintfEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId,...)
Definition: outstream.c:738
INT __cdecl ConMsgPrintf(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId,...)
Definition: outstream.c:1128
INT ConResMsgPrintfV(IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1327
#define CON_RC_STRING_MAX_SIZE
Definition: outstream.c:55
INT __cdecl ConResMsgPrintfEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId,...)
Definition: outstream.c:1391
INT ConResPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
Definition: outstream.c:652
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:779
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:907
INT ConPrintfV(IN PCON_STREAM Stream, IN PCWSTR szStr, IN va_list args)
Definition: outstream.c:465
INT ConStreamWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
Definition: outstream.c:397
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:1028
#define INT
Definition: polytest.cpp:20
_In_ UINT uID
Definition: shlwapi.h:156
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#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:239
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:110
BOOL IsTTYHandle(IN HANDLE hHandle)
Definition: utils.c:403
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:264
#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 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:398
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:397
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:399
#define WriteConsole
Definition: wincon.h:1029
#define CP_THREAD_ACP
Definition: winnls.h:251
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184