Author: hbelusca
Date: Sun Oct 1 16:03:44 2017
New Revision: 76022
URL:
http://svn.reactos.org/svn/reactos?rev=76022&view=rev
Log:
[CONUTILS]: Add some string resources functions that can support a specified hModule
parameter, and add small construction helpers for CON_SCREEN and CON_PAGER.
Modified:
trunk/reactos/sdk/lib/conutils/pager.c
trunk/reactos/sdk/lib/conutils/pager.h
trunk/reactos/sdk/lib/conutils/screen.h
trunk/reactos/sdk/lib/conutils/stream.c
trunk/reactos/sdk/lib/conutils/stream.h
Modified: trunk/reactos/sdk/lib/conutils/pager.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/pager.c?r…
==============================================================================
--- trunk/reactos/sdk/lib/conutils/pager.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/conutils/pager.c [iso-8859-1] Sun Oct 1 16:03:44 2017
@@ -131,18 +131,30 @@
}
BOOL
+ConResPagingEx(
+ IN PCON_PAGER Pager,
+ IN PAGE_PROMPT PagePrompt,
+ IN BOOL StartPaging,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID)
+{
+ INT Len;
+ PWCHAR szStr = NULL;
+
+ Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
+ if (szStr && Len)
+ return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
+ else
+ return TRUE;
+}
+
+BOOL
ConResPaging(
IN PCON_PAGER Pager,
IN PAGE_PROMPT PagePrompt,
IN BOOL StartPaging,
IN UINT uID)
{
- INT Len;
- PWCHAR szStr = NULL;
-
- Len = K32LoadStringW(GetModuleHandleW(NULL), uID, (PWSTR)&szStr, 0);
- if (szStr && Len)
- return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
- else
- return TRUE;
+ return ConResPagingEx(Pager, PagePrompt, StartPaging,
+ NULL /*GetModuleHandleW(NULL)*/, uID);
}
Modified: trunk/reactos/sdk/lib/conutils/pager.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/pager.h?r…
==============================================================================
--- trunk/reactos/sdk/lib/conutils/pager.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/conutils/pager.h [iso-8859-1] Sun Oct 1 16:03:44 2017
@@ -30,6 +30,14 @@
DWORD LineCount;
} CON_PAGER, *PCON_PAGER;
+#define INIT_CON_PAGER(pScreen) {(pScreen), 0}
+
+#define InitializeConPager(pPager, pScreen) \
+do { \
+ (pPager)->Screen = (pScreen); \
+ (pPager)->LineCount = 0; \
+} while (0)
+
// Pager, Done, Total
typedef BOOL (__stdcall *PAGE_PROMPT)(IN PCON_PAGER, IN DWORD, IN DWORD);
@@ -49,6 +57,14 @@
IN LPTSTR szStr);
BOOL
+ConResPagingEx(
+ IN PCON_PAGER Pager,
+ IN PAGE_PROMPT PagePrompt,
+ IN BOOL StartPaging,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID);
+
+BOOL
ConResPaging(
IN PCON_PAGER Pager,
IN PAGE_PROMPT PagePrompt,
Modified: trunk/reactos/sdk/lib/conutils/screen.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/screen.h?…
==============================================================================
--- trunk/reactos/sdk/lib/conutils/screen.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/conutils/screen.h [iso-8859-1] Sun Oct 1 16:03:44 2017
@@ -35,6 +35,15 @@
CONSOLE_CURSOR_INFO cci;
} CON_SCREEN, *PCON_SCREEN;
+#define INIT_CON_SCREEN(pStream) {(pStream)} /* {(pStream), {{}}, {{}}} */
+
+#define InitializeConScreen(pScreen, pStream) \
+do { \
+ (pScreen)->Stream = (pStream); \
+ RtlZeroMemory(&(pScreen)->csbi, sizeof((pScreen)->csbi)); \
+ RtlZeroMemory(&(pScreen)->cci , sizeof((pScreen)->cci )); \
+} while (0)
+
BOOL
ConGetScreenInfo(
IN PCON_SCREEN Screen,
Modified: trunk/reactos/sdk/lib/conutils/stream.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/stream.c?…
==============================================================================
--- trunk/reactos/sdk/lib/conutils/stream.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/conutils/stream.c [iso-8859-1] Sun Oct 1 16:03:44 2017
@@ -483,7 +483,9 @@
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
- len = WideCharToMultiByte(Stream->CodePage, 0, szStr, len, buffer, len *
MB_LEN_MAX, NULL, NULL);
+ len = WideCharToMultiByte(Stream->CodePage, 0,
+ szStr, len, buffer, len * MB_LEN_MAX,
+ NULL, NULL);
szStr = (PVOID)buffer;
#else
/*
@@ -705,14 +707,15 @@
}
INT
-ConResPuts(
- IN PCON_STREAM Stream,
+ConResPutsEx(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
IN UINT uID)
{
INT Len;
PWCHAR szStr = NULL;
- Len = K32LoadStringW(GetModuleHandleW(NULL), uID, (PWSTR)&szStr, 0);
+ Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
if (szStr && Len)
// Len = ConPuts(Stream, szStr);
CON_STREAM_WRITE2(Stream, szStr, Len, Len);
@@ -725,8 +728,17 @@
}
INT
-ConResPrintfV(
- IN PCON_STREAM Stream,
+ConResPuts(
+ IN PCON_STREAM Stream,
+ IN UINT uID)
+{
+ return ConResPutsEx(Stream, NULL /*GetModuleHandleW(NULL)*/, uID);
+}
+
+INT
+ConResPrintfExV(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
IN UINT uID,
IN va_list args) // arg_ptr
{
@@ -734,9 +746,36 @@
WCHAR bufSrc[CON_RC_STRING_MAX_SIZE];
// NOTE: We may use the special behaviour where nBufMaxSize == 0
- Len = K32LoadStringW(GetModuleHandleW(NULL), uID, bufSrc, ARRAYSIZE(bufSrc));
+ Len = K32LoadStringW(hInstance, uID, bufSrc, ARRAYSIZE(bufSrc));
if (Len)
Len = ConPrintfV(Stream, bufSrc, args);
+
+ return Len;
+}
+
+INT
+ConResPrintfV(
+ IN PCON_STREAM Stream,
+ IN UINT uID,
+ IN va_list args) // arg_ptr
+{
+ return ConResPrintfExV(Stream, NULL /*GetModuleHandleW(NULL)*/, uID, args);
+}
+
+INT
+__cdecl
+ConResPrintfEx(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID,
+ ...)
+{
+ INT Len;
+ va_list args;
+
+ va_start(args, uID);
+ Len = ConResPrintfExV(Stream, hInstance, uID, args);
+ va_end(args);
return Len;
}
Modified: trunk/reactos/sdk/lib/conutils/stream.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/conutils/stream.h?…
==============================================================================
--- trunk/reactos/sdk/lib/conutils/stream.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/conutils/stream.h [iso-8859-1] Sun Oct 1 16:03:44 2017
@@ -184,15 +184,36 @@
...);
INT
+ConResPutsEx(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID);
+
+INT
ConResPuts(
IN PCON_STREAM Stream,
IN UINT uID);
INT
+ConResPrintfExV(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID,
+ IN va_list args); // arg_ptr
+
+INT
ConResPrintfV(
IN PCON_STREAM Stream,
IN UINT uID,
IN va_list args); // arg_ptr
+
+INT
+__cdecl
+ConResPrintfEx(
+ IN PCON_STREAM Stream,
+ IN HINSTANCE hInstance OPTIONAL,
+ IN UINT uID,
+ ...);
INT
__cdecl