Author: hbelusca
Date: Thu Nov 3 16:30:48 2016
New Revision: 73111
URL:
http://svn.reactos.org/svn/reactos?rev=73111&view=rev
Log:
[WHOAMI]: Use the conutils (stream) library for console output (see also r65894).
CORE-8965 CORE-10504
Modified:
trunk/reactos/base/applications/cmdutils/whoami/CMakeLists.txt
trunk/reactos/base/applications/cmdutils/whoami/whoami.c
Modified: trunk/reactos/base/applications/cmdutils/whoami/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/whoami/CMakeLists.txt [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/cmdutils/whoami/CMakeLists.txt [iso-8859-1] Thu Nov 3
16:30:48 2016
@@ -1,5 +1,8 @@
+
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils)
add_executable(whoami whoami.c whoami.rc)
set_module_type(whoami win32cui UNICODE)
+target_link_libraries(whoami conutils ${PSEH_LIB})
add_importlibs(whoami user32 secur32 advapi32 msvcrt kernel32)
add_cd_file(TARGET whoami DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/base/applications/cmdutils/whoami/whoami.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
==============================================================================
--- trunk/reactos/base/applications/cmdutils/whoami/whoami.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/cmdutils/whoami/whoami.c [iso-8859-1] Thu Nov 3
16:30:48 2016
@@ -6,69 +6,16 @@
* PROGRAMMERS: Ismael Ferreras Morezuelas (swyterzone+ros(a)gmail.com)
*/
-
#define SECURITY_WIN32
#include <security.h>
#include <sddl.h>
-
#include <strsafe.h>
+#include <conutils.h>
+
#include "resource.h"
-
-/* Unicode (W) to ANSI OEM wrapper function, as console and Unicode don't mix well,
sigh */
-static void WhoamiOemConversion_printf(const WCHAR *lpSourceFormatW, ...)
-{
- CHAR *lpBufferA = NULL;
- WCHAR *lpBufferW = NULL;
-
- UINT Size;
- va_list Args;
-
- /* first let's find out the final output'ed length of the wprintf routine */
- va_start(Args, lpSourceFormatW);
-
- Size = _vscwprintf(lpSourceFormatW, Args);
-
- va_end(Args);
-
- /* allocate a proportional memory chunk taking into account the char width */
- lpBufferW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (Size + 1) *
sizeof(WCHAR));
-
- if (!lpBufferW)
- return;
-
- /* do wprintf to this newly allocated buffer of ours */
- va_start(Args, lpSourceFormatW);
-
- _vsnwprintf(lpBufferW, Size, lpSourceFormatW, Args);
-
- va_end(Args);
-
- /* allocate a similarly sized buffer for the ANSI/OEM version of our string */
- lpBufferA = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (Size + 1) *
sizeof(CHAR));
-
- if (!lpBufferA)
- {
- HeapFree(GetProcessHeap(), 0, lpBufferW);
- return;
- }
-
- /* convert our Unicode/Wide char string into a proper ANSI/OEM
- string that our console may understand, at least in theory */
- CharToOemBuffW(lpBufferW,
- lpBufferA,
- Size);
-
- /* print the converted OEM string into the console's output and call it a day */
- printf("%s", lpBufferA);
-
- /* clean everything up */
- HeapFree(GetProcessHeap(), 0, lpBufferW);
- HeapFree(GetProcessHeap(), 0, lpBufferA);
-}
-
-#define wprintf WhoamiOemConversion_printf
+#define wprintf(...) ConPrintf(StdOut, ##__VA_ARGS__)
BOOL NoHeader = FALSE;
UINT NoHeaderArgCount = 0;
@@ -194,7 +141,6 @@
while (Length--)
wprintf(L"-");
- /* _putws seems to be broken in ReactOS' CRT ??? */
wprintf(L"\n\n");
}
@@ -718,12 +664,15 @@
int wmain(int argc, WCHAR* argv[])
{
- INT i;
- BYTE WamBit = 0;
-
#define WAM_USER 1<<0
#define WAM_GROUPS 1<<1
#define WAM_PRIV 1<<2
+
+ INT i;
+ BYTE WamBit = 0;
+
+ /* Initialize the Console Standard Streams */
+ ConInitStdStreams();
/* * * * * * * * * * * * * * * *