wintab32[3/5]: implement WTInfoW (resend)
Mikolaj Zalewski
mikolajz at google.com
Wed Sep 12 12:15:57 CDT 2007
-------------- next part --------------
From ed9380a729f109a3d2c66da2021134eadbf5bb82 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Wed, 5 Sep 2007 16:50:09 -0700
Subject: [PATCH] wintab32: implement WTInfoW
---
dlls/wintab32/context.c | 55 ++++++++++++++++++++++++++++------------------
1 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c
index c34c17e..4ebc827 100644
--- a/dlls/wintab32/context.c
+++ b/dlls/wintab32/context.c
@@ -352,7 +352,7 @@ static BOOL is_logcontext_category(UINT wCategory)
return wCategory == WTI_DEFSYSCTX || wCategory == WTI_DEFCONTEXT || wCategory == WTI_DDCTXS;
}
-static UINT get_wtinfo_field(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+static UINT get_wtinfo_field(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
{
DWORD cchString = 0;
UINT ret;
@@ -374,27 +374,34 @@ static UINT get_wtinfo_field(UINT wCategory, UINT nIndex, LPVOID lpOutput)
}
}
- ret = pWTInfoW(wCategory, nIndex, lpOutput, &cchString);
- if (cchString > 0)
+ if (!bUnicode)
{
- WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*cchString);
- pWTInfoW(wCategory, nIndex, buf, NULL);
- ret = WideCharToMultiByte(CP_ACP, 0, buf, cchString, lpOutput, lpOutput ? 2*cchString: 0, NULL, NULL);
- HeapFree(GetProcessHeap(), 0, buf);
- }
+ ret = pWTInfoW(wCategory, nIndex, lpOutput, &cchString);
+ if (cchString > 0)
+ {
+ WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*cchString);
+ pWTInfoW(wCategory, nIndex, buf, NULL);
+ ret = WideCharToMultiByte(CP_ACP, 0, buf, cchString, lpOutput, lpOutput ? 2*cchString: 0, NULL, NULL);
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
+ }
+ else
+ ret = pWTInfoW(wCategory, nIndex, lpOutput, NULL);
return ret;
}
/***********************************************************************
- * WTInfoA (WINTAB32.20)
+ * WTInfoT [INTERNAL]
+ *
+ * Implements WTInfoA and WTInfoW
*/
-UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+UINT WINAPI WTInfoT(UINT wCategory, UINT nIndex, LPVOID lpOutput, BOOL bUnicode)
{
if (gLoaded == FALSE)
LoadTablet();
- if (wCategory == 0) /* TODO */
- return get_wtinfo_field(0, 0, NULL);
+ if (wCategory == 0) /* TODO - should be implemented here */
+ return get_wtinfo_field(0, 0, NULL, bUnicode);
if (nIndex == 0)
{
@@ -402,7 +409,7 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
int size = 0;
int i;
- if (get_wtinfo_field(wCategory, 0, &numIndex) != sizeof(DWORD))
+ if (get_wtinfo_field(wCategory, 0, &numIndex, bUnicode) != sizeof(DWORD))
return 0; /* an unknown category */
if (!is_logcontext_category(wCategory))
@@ -411,13 +418,13 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
for (i = 1; i <= numIndex; i++)
{
char *buf = lpOutput ? (char *)lpOutput + size : 0;
- int field_size = get_wtinfo_field(wCategory, i, buf);
+ int field_size = get_wtinfo_field(wCategory, i, buf, bUnicode);
- /* it seems that only the LOGCONTEXT categories the string is
+ /* it seems that for only the LOGCONTEXT categories the string is
* padded so that the result fits in the C structure
*/
if (is_logcontext_category(wCategory) && i == CTX_NAME)
- size += LCNAMELEN;
+ size += LCNAMELEN * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
else
size += field_size;
}
@@ -425,7 +432,15 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
return size;
}
else
- return get_wtinfo_field(wCategory, nIndex, lpOutput);
+ return get_wtinfo_field(wCategory, nIndex, lpOutput, bUnicode);
+}
+
+/***********************************************************************
+ * WTInfoA (WINTAB32.20)
+ */
+UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
+{
+ return WTInfoT(wCategory, nIndex, lpOutput, FALSE);
}
/***********************************************************************
@@ -433,11 +448,7 @@ UINT WINAPI WTInfoA(UINT wCategory, UINT nIndex, LPVOID lpOutput)
*/
UINT WINAPI WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
{
- FIXME("(%u, %u, %p): stub\n", wCategory, nIndex, lpOutput);
-
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-
- return 0;
+ return WTInfoT(wCategory, nIndex, lpOutput, TRUE);
}
/***********************************************************************
--
1.4.4.2
More information about the wine-patches
mailing list