mirror of
https://github.com/reactos/reactos.git
synced 2025-05-28 21:48:19 +00:00
[CONUTILS]: Add some string resources functions that can support a specified hModule parameter, and add small construction helpers for CON_SCREEN and CON_PAGER.
svn path=/trunk/; revision=76022
This commit is contained in:
parent
d47bb60c1c
commit
0599206b8b
5 changed files with 110 additions and 13 deletions
|
@ -130,6 +130,24 @@ ConPutsPaging(
|
||||||
return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, len);
|
return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
BOOL
|
||||||
ConResPaging(
|
ConResPaging(
|
||||||
IN PCON_PAGER Pager,
|
IN PCON_PAGER Pager,
|
||||||
|
@ -137,12 +155,6 @@ ConResPaging(
|
||||||
IN BOOL StartPaging,
|
IN BOOL StartPaging,
|
||||||
IN UINT uID)
|
IN UINT uID)
|
||||||
{
|
{
|
||||||
INT Len;
|
return ConResPagingEx(Pager, PagePrompt, StartPaging,
|
||||||
PWCHAR szStr = NULL;
|
NULL /*GetModuleHandleW(NULL)*/, uID);
|
||||||
|
|
||||||
Len = K32LoadStringW(GetModuleHandleW(NULL), uID, (PWSTR)&szStr, 0);
|
|
||||||
if (szStr && Len)
|
|
||||||
return ConWritePaging(Pager, PagePrompt, StartPaging, szStr, Len);
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,14 @@ typedef struct _CON_PAGER
|
||||||
DWORD LineCount;
|
DWORD LineCount;
|
||||||
} CON_PAGER, *PCON_PAGER;
|
} 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
|
// Pager, Done, Total
|
||||||
typedef BOOL (__stdcall *PAGE_PROMPT)(IN PCON_PAGER, IN DWORD, IN DWORD);
|
typedef BOOL (__stdcall *PAGE_PROMPT)(IN PCON_PAGER, IN DWORD, IN DWORD);
|
||||||
|
|
||||||
|
@ -48,6 +56,14 @@ ConPutsPaging(
|
||||||
IN BOOL StartPaging,
|
IN BOOL StartPaging,
|
||||||
IN LPTSTR szStr);
|
IN LPTSTR szStr);
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
ConResPagingEx(
|
||||||
|
IN PCON_PAGER Pager,
|
||||||
|
IN PAGE_PROMPT PagePrompt,
|
||||||
|
IN BOOL StartPaging,
|
||||||
|
IN HINSTANCE hInstance OPTIONAL,
|
||||||
|
IN UINT uID);
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ConResPaging(
|
ConResPaging(
|
||||||
IN PCON_PAGER Pager,
|
IN PCON_PAGER Pager,
|
||||||
|
|
|
@ -35,6 +35,15 @@ typedef struct _CON_SCREEN
|
||||||
CONSOLE_CURSOR_INFO cci;
|
CONSOLE_CURSOR_INFO cci;
|
||||||
} CON_SCREEN, *PCON_SCREEN;
|
} 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
|
BOOL
|
||||||
ConGetScreenInfo(
|
ConGetScreenInfo(
|
||||||
IN PCON_SCREEN Screen,
|
IN PCON_SCREEN Screen,
|
||||||
|
|
|
@ -483,7 +483,9 @@ ConWrite(
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return 0;
|
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;
|
szStr = (PVOID)buffer;
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
|
@ -705,14 +707,15 @@ ConPrintf(
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
ConResPuts(
|
ConResPutsEx(
|
||||||
IN PCON_STREAM Stream,
|
IN PCON_STREAM Stream,
|
||||||
|
IN HINSTANCE hInstance OPTIONAL,
|
||||||
IN UINT uID)
|
IN UINT uID)
|
||||||
{
|
{
|
||||||
INT Len;
|
INT Len;
|
||||||
PWCHAR szStr = NULL;
|
PWCHAR szStr = NULL;
|
||||||
|
|
||||||
Len = K32LoadStringW(GetModuleHandleW(NULL), uID, (PWSTR)&szStr, 0);
|
Len = K32LoadStringW(hInstance, uID, (PWSTR)&szStr, 0);
|
||||||
if (szStr && Len)
|
if (szStr && Len)
|
||||||
// Len = ConPuts(Stream, szStr);
|
// Len = ConPuts(Stream, szStr);
|
||||||
CON_STREAM_WRITE2(Stream, szStr, Len, Len);
|
CON_STREAM_WRITE2(Stream, szStr, Len, Len);
|
||||||
|
@ -725,8 +728,17 @@ ConResPuts(
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
ConResPrintfV(
|
ConResPuts(
|
||||||
IN PCON_STREAM Stream,
|
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 UINT uID,
|
||||||
IN va_list args) // arg_ptr
|
IN va_list args) // arg_ptr
|
||||||
{
|
{
|
||||||
|
@ -734,13 +746,40 @@ ConResPrintfV(
|
||||||
WCHAR bufSrc[CON_RC_STRING_MAX_SIZE];
|
WCHAR bufSrc[CON_RC_STRING_MAX_SIZE];
|
||||||
|
|
||||||
// NOTE: We may use the special behaviour where nBufMaxSize == 0
|
// 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)
|
if (Len)
|
||||||
Len = ConPrintfV(Stream, bufSrc, args);
|
Len = ConPrintfV(Stream, bufSrc, args);
|
||||||
|
|
||||||
return Len;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
__cdecl
|
__cdecl
|
||||||
ConResPrintf(
|
ConResPrintf(
|
||||||
|
|
|
@ -183,17 +183,38 @@ ConPrintf(
|
||||||
IN LPWSTR szStr,
|
IN LPWSTR szStr,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
INT
|
||||||
|
ConResPutsEx(
|
||||||
|
IN PCON_STREAM Stream,
|
||||||
|
IN HINSTANCE hInstance OPTIONAL,
|
||||||
|
IN UINT uID);
|
||||||
|
|
||||||
INT
|
INT
|
||||||
ConResPuts(
|
ConResPuts(
|
||||||
IN PCON_STREAM Stream,
|
IN PCON_STREAM Stream,
|
||||||
IN UINT uID);
|
IN UINT uID);
|
||||||
|
|
||||||
|
INT
|
||||||
|
ConResPrintfExV(
|
||||||
|
IN PCON_STREAM Stream,
|
||||||
|
IN HINSTANCE hInstance OPTIONAL,
|
||||||
|
IN UINT uID,
|
||||||
|
IN va_list args); // arg_ptr
|
||||||
|
|
||||||
INT
|
INT
|
||||||
ConResPrintfV(
|
ConResPrintfV(
|
||||||
IN PCON_STREAM Stream,
|
IN PCON_STREAM Stream,
|
||||||
IN UINT uID,
|
IN UINT uID,
|
||||||
IN va_list args); // arg_ptr
|
IN va_list args); // arg_ptr
|
||||||
|
|
||||||
|
INT
|
||||||
|
__cdecl
|
||||||
|
ConResPrintfEx(
|
||||||
|
IN PCON_STREAM Stream,
|
||||||
|
IN HINSTANCE hInstance OPTIONAL,
|
||||||
|
IN UINT uID,
|
||||||
|
...);
|
||||||
|
|
||||||
INT
|
INT
|
||||||
__cdecl
|
__cdecl
|
||||||
ConResPrintf(
|
ConResPrintf(
|
||||||
|
|
Loading…
Reference in a new issue