ReactOS  0.4.12-dev-918-g6c6e7b8
outstream.h File Reference

Console I/O utility API – Output. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _CON_STREAM CON_STREAM
 
typedef struct _CON_STREAMPCON_STREAM
 
typedef INT(__stdcallCON_WRITE_FUNC) (IN PCON_STREAM, IN PTCHAR, IN DWORD)
 

Functions

INT __stdcall ConWrite (IN PCON_STREAM Stream, IN PTCHAR szStr, IN DWORD len)
 
INT ConStreamWrite (IN PCON_STREAM Stream, IN PTCHAR szStr, IN DWORD len)
 
INT ConPuts (IN PCON_STREAM Stream, IN LPWSTR szStr)
 
INT ConPrintfV (IN PCON_STREAM Stream, IN LPWSTR szStr, IN va_list args)
 
INT __cdecl ConPrintf (IN PCON_STREAM Stream, IN LPWSTR szStr,...)
 
INT ConResPutsEx (IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId)
 
INT ConResPuts (IN PCON_STREAM Stream, IN UINT uID)
 
INT ConResPrintfExV (IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
 
INT ConResPrintfV (IN PCON_STREAM Stream, IN UINT uID, IN va_list args)
 
INT __cdecl ConResPrintfEx (IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId,...)
 
INT __cdecl ConResPrintf (IN PCON_STREAM Stream, IN UINT uID,...)
 
INT ConMsgPuts (IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
 
INT ConMsgPrintf2V (IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, IN va_list args)
 
INT ConMsgPrintfV (IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, IN va_list *Arguments OPTIONAL)
 
INT __cdecl ConMsgPrintf (IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId,...)
 
INT ConResMsgPrintfExV (IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId, IN va_list *Arguments OPTIONAL)
 
INT ConResMsgPrintfV (IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID, IN va_list *Arguments OPTIONAL)
 
INT __cdecl ConResMsgPrintfEx (IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN DWORD dwFlags, IN UINT uID, IN LANGID LanguageId,...)
 
INT __cdecl ConResMsgPrintf (IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID,...)
 
VOID ConClearLine (IN PCON_STREAM Stream)
 

Detailed Description

Console I/O utility API – Output.

Definition in file outstream.h.

Typedef Documentation

◆ CON_STREAM

NOTE: Experimental! Don't use USE_CRT yet because output to console is a bit broken

Definition at line 40 of file outstream.h.

◆ CON_WRITE_FUNC

typedef INT(__stdcall * CON_WRITE_FUNC) (IN PCON_STREAM, IN PTCHAR, IN DWORD)

Definition at line 44 of file outstream.h.

◆ PCON_STREAM

Definition at line 40 of file outstream.h.

Function Documentation

◆ ConClearLine()

VOID ConClearLine ( IN PCON_STREAM  Stream)

Definition at line 1483 of file outstream.c.

1484 {
1485  HANDLE hOutput = ConStreamGetOSHandle(Stream);
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 }
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:590
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
ULONG X
Definition: bl.h:1340
BOOL IsTTYHandle(IN HANDLE hHandle)
Definition: utils.c:342
HANDLE ConStreamGetOSHandle(IN PCON_STREAM Stream)
Definition: stream.c:240
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IsConsoleHandle(h)
Definition: console.h:14
static const WCHAR L[]
Definition: oid.c:1250
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
BOOL WINAPI DECLSPEC_HOTPATCH FillConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: readwrite.c:1676

Referenced by PagePrompt().

◆ ConMsgPrintf()

INT __cdecl ConMsgPrintf ( IN PCON_STREAM  Stream,
IN DWORD  dwFlags,
IN LPCVOID lpSource  OPTIONAL,
IN DWORD  dwMessageId,
IN DWORD  dwLanguageId,
  ... 
)

Definition at line 1130 of file outstream.c.

1137 {
1138  INT Len;
1139  va_list args;
1140 
1141  /* Sanitize dwFlags */
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 }
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
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 va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

◆ ConMsgPrintf2V()

INT ConMsgPrintf2V ( IN PCON_STREAM  Stream,
IN DWORD  dwFlags,
IN LPCVOID lpSource  OPTIONAL,
IN DWORD  dwMessageId,
IN DWORD  dwLanguageId,
IN va_list  args 
)

Definition at line 909 of file outstream.c.

916 {
917  INT Len;
918  DWORD dwLength = 0;
919  LPWSTR lpMsgBuf = NULL;
920 
921  /*
922  * Sanitize dwFlags. This version always ignore explicitely 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.
928 
929  /*
930  * Retrieve the message string without appending extra newlines.
931  * Wrap in SEH to protect from invalid string parameters.
932  */
933  _SEH2_TRY
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 }
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define INT
Definition: polytest.cpp:20
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4250
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
_SEH2_END
Definition: create.c:4424
INT ConPrintfV(IN PCON_STREAM Stream, IN LPWSTR szStr, IN va_list args)
Definition: outstream.c:466
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

◆ ConMsgPrintfV()

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 at line 1030 of file outstream.c.

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 }
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:56
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184
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
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConFormatMessage(), and ConMsgPrintf().

◆ ConMsgPuts()

INT ConMsgPuts ( IN PCON_STREAM  Stream,
IN DWORD  dwFlags,
IN LPCVOID lpSource  OPTIONAL,
IN DWORD  dwMessageId,
IN DWORD  dwLanguageId 
)

Definition at line 837 of file outstream.c.

843 {
844  INT Len;
845  DWORD dwLength = 0;
846  LPWSTR lpMsgBuf = NULL;
847 
848  /*
849  * Sanitize dwFlags. This version always ignore explicitely 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.
855 
856  /*
857  * Retrieve the message string without appending extra newlines.
858  * Wrap in SEH to protect from invalid string parameters.
859  */
860  _SEH2_TRY
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);
887  CON_STREAM_WRITE2(Stream, lpMsgBuf, dwLength, Len);
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 }
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define INT
Definition: polytest.cpp:20
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
int32_t INT
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4250
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
_SEH2_END
Definition: create.c:4424
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by DisplayError(), DoFormatMessage(), PrintError(), and PrintWin32Error().

◆ ConPrintf()

INT __cdecl ConPrintf ( IN PCON_STREAM  Stream,
IN LPWSTR  szStr,
  ... 
)

Definition at line 520 of file outstream.c.

524 {
525  INT Len;
526  va_list args;
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 }
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define Len
Definition: deflate.h:82
INT ConPrintfV(IN PCON_STREAM Stream, IN LPWSTR szStr, IN va_list args)
Definition: outstream.c:466
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by CheckLogOrSourceExistence(), ChkdskCallback(), cmdAccounts(), cmdContinue(), cmdGroup(), cmdHelpMsg(), cmdLocalGroup(), cmdPause(), cmdStop(), cmdUser(), DisplayError(), DisplayGroup(), DisplayLocalGroup(), DisplayServerConfig(), DisplayServerStatistics(), DisplayUser(), DisplayWorkstationConfig(), DisplayWorkstationStatistics(), download_file(), DrawTree(), DumpSubstedDrives(), EnumerateConnections(), EnumerateDevices(), EnumerateGroups(), EnumerateLocalGroups(), EnumerateRunningServices(), EnumerateUsers(), FormatExCallback(), PrintAllJobs(), PrintDateTime(), PrintError(), PrintErrorMessage(), PrintFileDacl(), PrintHorizontalLine(), PrintParserError(), PrintWin32Error(), SetParallelState(), ShowParallelStatus(), StartOneService(), Usage(), wmain(), and write_status().

◆ ConPrintfV()

INT ConPrintfV ( IN PCON_STREAM  Stream,
IN LPWSTR  szStr,
IN va_list  args 
)

Definition at line 466 of file outstream.c.

470 {
471  INT Len;
473 
474  // Len = vfwprintf(Stream->fStream, szStr, args); // vfprintf for direct ANSI
475 
476  /*
477  * Reuse szStr as the pointer to end-of-string, to compute
478  * the string length instead of calling wcslen().
479  */
480  // StringCchVPrintfW(bufSrc, ARRAYSIZE(bufSrc), szStr, args);
481  // Len = wcslen(bufSrc);
482  StringCchVPrintfExW(bufSrc, ARRAYSIZE(bufSrc), &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 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
#define CON_RC_STRING_MAX_SIZE
Definition: outstream.c:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define Len
Definition: deflate.h:82
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
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConMsgPrintf2V(), ConPrintf(), ConResPrintfExV(), and DirPrintf().

◆ ConPuts()

INT ConPuts ( IN PCON_STREAM  Stream,
IN LPWSTR  szStr 
)

◆ ConResMsgPrintf()

INT __cdecl ConResMsgPrintf ( IN PCON_STREAM  Stream,
IN DWORD  dwFlags,
IN UINT  uID,
  ... 
)

Definition at line 1461 of file outstream.c.

1466 {
1467  INT Len;
1468  va_list args;
1469 
1470  /* Sanitize dwFlags */
1472 
1473  va_start(args, uID);
1474  Len = ConResMsgPrintfV(Stream, dwFlags, uID, &args);
1475  va_end(args);
1476 
1477  return Len;
1478 }
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
INT ConResMsgPrintfV(IN PCON_STREAM Stream, IN DWORD dwFlags, IN UINT uID, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1329
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

◆ ConResMsgPrintfEx()

INT __cdecl ConResMsgPrintfEx ( IN PCON_STREAM  Stream,
IN HINSTANCE hInstance  OPTIONAL,
IN DWORD  dwFlags,
IN UINT  uID,
IN LANGID  LanguageId,
  ... 
)

Definition at line 1394 of file outstream.c.

1401 {
1402  INT Len;
1403  va_list args;
1404 
1405  /* Sanitize dwFlags */
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 }
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
#define va_end(ap)
Definition: acmsvcex.h:90
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
char * va_list
Definition: acmsvcex.h:78
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

◆ ConResMsgPrintfExV()

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 at line 1218 of file outstream.c.

1225 {
1226  INT Len;
1227  DWORD dwLength = 0;
1228  LPWSTR lpMsgBuf = NULL;
1229  WCHAR bufSrc[CON_RC_STRING_MAX_SIZE];
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 }
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
#define INT
Definition: polytest.cpp:20
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
#define CON_RC_STRING_MAX_SIZE
Definition: outstream.c:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define Len
Definition: deflate.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184
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
INT WINAPI K32LoadStringExW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:99
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConResMsgPrintfEx(), and ConResMsgPrintfV().

◆ ConResMsgPrintfV()

INT ConResMsgPrintfV ( IN PCON_STREAM  Stream,
IN DWORD  dwFlags,
IN UINT  uID,
IN va_list *Arguments  OPTIONAL 
)

Definition at line 1329 of file outstream.c.

1334 {
1335  return ConResMsgPrintfExV(Stream, NULL /*GetModuleHandleW(NULL)*/,
1336  dwFlags, uID,
1338  Arguments);
1339 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_NEUTRAL
Definition: nls.h:167
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
smooth NULL
Definition: ftsmooth.c:416
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MAKELANGID(p, s)
Definition: nls.h:15
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConResMsgPrintf().

◆ ConResPrintf()

INT __cdecl ConResPrintf ( IN PCON_STREAM  Stream,
IN UINT  uID,
  ... 
)

Definition at line 781 of file outstream.c.

785 {
786  INT Len;
787  va_list args;
788 
789  va_start(args, uID);
790  Len = ConResPrintfV(Stream, uID, args);
791  va_end(args);
792 
793  return Len;
794 }
INT ConResPrintfV(IN PCON_STREAM Stream, IN UINT uID, IN va_list args)
Definition: outstream.c:695
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define Len
Definition: deflate.h:82
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by AddJob(), AddSubst(), CBindStatusCallback_OnProgress(), CheckLogOrSourceExistence(), ChkdskCallback(), cmdAccounts(), cmdConfig(), cmdGroup(), cmdLocalGroup(), cmdUse(), cmdUser(), Confirm(), ConFormatMessage(), ConsoleCtrlHandler(), DeleteJob(), DeleteSubst(), DisplayServerStatistics(), DisplayWorkstationStatistics(), EnumerateDevices(), EnumerateGroups(), EnumerateLocalGroups(), EnumerateUsers(), FormatExCallback(), InputWait(), ListDisk(), ListPartition(), PagePrompt(), ParseCmdLine(), Ping(), print_err(), PrintAllJobs(), PrintError(), PrintJobDetails(), PrintStats(), ResolveTarget(), RunScript(), SelectDisk(), SelectPartition(), SerialPortQuery(), SetConsoleCPState(), SetConsoleState(), SetConsoleStateOld(), SetSerialState(), ShowConsoleCPStatus(), ShowConsoleStatus(), ShowHeader(), ShowParallelStatus(), ShowSerialStatus(), Usage(), WlanPrintCurrentStatus(), WlanScan(), and wmain().

◆ ConResPrintfEx()

INT __cdecl ConResPrintfEx ( IN PCON_STREAM  Stream,
IN HINSTANCE hInstance  OPTIONAL,
IN UINT  uID,
IN LANGID  LanguageId,
  ... 
)

Definition at line 740 of file outstream.c.

746 {
747  INT Len;
748  va_list args;
749 
750  va_start(args, LanguageId);
751  Len = ConResPrintfExV(Stream, hInstance, uID, LanguageId, args);
752  va_end(args);
753 
754  return Len;
755 }
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
INT ConResPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
Definition: outstream.c:653
#define Len
Definition: deflate.h:82
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

◆ ConResPrintfExV()

INT ConResPrintfExV ( IN PCON_STREAM  Stream,
IN HINSTANCE hInstance  OPTIONAL,
IN UINT  uID,
IN LANGID  LanguageId,
IN va_list  args 
)

Definition at line 653 of file outstream.c.

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 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
Definition: match.c:390
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
#define CON_RC_STRING_MAX_SIZE
Definition: outstream.c:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define Len
Definition: deflate.h:82
INT ConPrintfV(IN PCON_STREAM Stream, IN LPWSTR szStr, IN va_list args)
Definition: outstream.c:466
INT WINAPI K32LoadStringExW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:99
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConResPrintfEx(), and ConResPrintfV().

◆ ConResPrintfV()

INT ConResPrintfV ( IN PCON_STREAM  Stream,
IN UINT  uID,
IN va_list  args 
)

Definition at line 695 of file outstream.c.

699 {
700  return ConResPrintfExV(Stream, NULL /*GetModuleHandleW(NULL)*/,
702  args);
703 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_NEUTRAL
Definition: nls.h:167
Definition: match.c:390
smooth NULL
Definition: ftsmooth.c:416
INT ConResPrintfExV(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, IN va_list args)
Definition: outstream.c:653
#define MAKELANGID(p, s)
Definition: nls.h:15
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConResPrintf(), PrintParserError(), and UnderlinedResPrintf().

◆ ConResPuts()

INT ConResPuts ( IN PCON_STREAM  Stream,
IN UINT  uID 
)

Definition at line 610 of file outstream.c.

613 {
614  return ConResPutsEx(Stream, NULL /*GetModuleHandleW(NULL)*/,
616 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_NEUTRAL
Definition: nls.h:167
smooth NULL
Definition: ftsmooth.c:416
INT ConResPutsEx(IN PCON_STREAM Stream, IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId)
Definition: outstream.c:569
#define MAKELANGID(p, s)
Definition: nls.h:15
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by _tmain(), AddSubst(), CheckLogOrSourceExistence(), ChkdskCallback(), cmdAccounts(), cmdComputer(), cmdConfig(), cmdContinue(), cmdGroup(), cmdHelp(), cmdHelpMsg(), cmdLocalGroup(), cmdPause(), cmdStart(), cmdStatistics(), cmdStop(), cmdSyntax(), cmdUser(), DisplayGroup(), DisplayLocalGroup(), DisplayServerConfig(), DisplayServerStatistics(), DisplayUser(), DisplayWorkstationConfig(), FormatExCallback(), help_cmdlist(), help_main(), InputWait(), InterpretMain(), list_main(), ListDisk(), ListPartition(), ListVolume(), online_main(), PagePrompt(), ParseArguments(), ParseCmdline(), ParseCommandLine(), PrintFileDacl(), PrintPaddedResourceString(), PrintParserError(), PrintWin32Error(), ReadPassword(), rescan_main(), select_main(), SelectDisk(), SelectPartition(), SetConsoleState(), SetConsoleStateOld(), ShowHeader(), ShowParallelStatus(), WlanConnect(), WlanDisconnect(), WlanPrintCurrentStatus(), WlanScan(), and wmain().

◆ ConResPutsEx()

INT ConResPutsEx ( IN PCON_STREAM  Stream,
IN HINSTANCE hInstance  OPTIONAL,
IN UINT  uID,
IN LANGID  LanguageId 
)

Definition at line 569 of file outstream.c.

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);
581  CON_STREAM_WRITE2(Stream, szStr, Len, Len);
582 
583  /* Fixup returned length in case of errors */
584  if (Len < 0)
585  Len = 0;
586 
587  return Len;
588 }
uint16_t * PWSTR
Definition: typedefs.h:54
uint16_t * PWCHAR
Definition: typedefs.h:54
int32_t INT
Definition: typedefs.h:56
HINSTANCE hInstance
Definition: charmap.c:20
smooth NULL
Definition: ftsmooth.c:416
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
#define Len
Definition: deflate.h:82
INT WINAPI K32LoadStringExW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, IN LANGID LanguageId, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:99
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by ConResPuts().

◆ ConStreamWrite()

INT ConStreamWrite ( IN PCON_STREAM  Stream,
IN PTCHAR  szStr,
IN DWORD  len 
)

Definition at line 398 of file outstream.c.

402 {
403  INT Len;
404  CON_STREAM_WRITE2(Stream, szStr, len, Len);
405  return Len;
406 }
int32_t INT
Definition: typedefs.h:56
#define CON_STREAM_WRITE2(Stream, Str, Len, RetLen)
Definition: outstream.c:353
#define Len
Definition: deflate.h:82
GLenum GLsizei len
Definition: glext.h:6722
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by PagePrompt(), and UnderlinedResPrintf().

◆ ConWrite()

INT __stdcall ConWrite ( IN PCON_STREAM  Stream,
IN PTCHAR  szStr,
IN DWORD  len 
)

Definition at line 85 of file outstream.c.

89 {
90 #ifndef USE_CRT
91  DWORD TotalLen = len, dwNumBytes = 0;
92  PVOID 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 && *(PWCHAR)p != L'\n')
172  {
173  /* Advance one character */
174  p = (PVOID)((PWCHAR)p + 1);
175  --len;
176  }
177 
178  /* Write everything up to \n */
179  dwNumBytes = ((PWCHAR)p - (PWCHAR)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 && *(PWCHAR)p == L'\n')
187  {
188  if (p == (PVOID)szStr || (p > (PVOID)szStr && *((PWCHAR)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 = (PVOID)((PWCHAR)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;
207  PCHAR buffer;
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 && *(PCHAR)p != '\n')
256  {
257  /* Advance one character */
258  p = (PVOID)((PCHAR)p + 1);
259  --len;
260  }
261 
262  /* Write everything up to \n */
263  dwNumBytes = ((PCHAR)p - (PCHAR)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 && *(PCHAR)p == '\n')
271  {
272  if (p == (PVOID)szStr || (p > (PVOID)szStr && *((PCHAR)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 = (PVOID)((PCHAR)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 }
signed char * PCHAR
Definition: retypes.h:7
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define _setmode(fd, mode)
Definition: cat.c:21
#define WideCharToMultiByte
Definition: compat.h:101
unsigned long total
Definition: inflate.h:92
char CHAR
Definition: xmlstorage.h:175
#define INT
Definition: polytest.cpp:20
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLuint buffer
Definition: glext.h:5915
uint16_t * PWCHAR
Definition: typedefs.h:54
_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 DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
_Check_return_opt_ _CRTIMP int __cdecl fwprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const wchar_t *_Format,...)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2453
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define PCHAR
Definition: match.c:90
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_CP
Definition: stream.h:53
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#define _O_TEXT
Definition: cabinet.h:50
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define WriteConsole
Definition: wincon.h:772
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE *_File)
GLfloat GLfloat p
Definition: glext.h:8902
#define CP_THREAD_ACP
Definition: winnls.h:230
_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE *_File)
#define HeapFree(x, y, z)
Definition: compat.h:394
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
#define MB_LEN_MAX
Definition: limits.h:35

Referenced by ConErrChar(), ConOutChar(), ConStreamInit(), and ConStreamInitEx().