Commit b1e84873 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

Implement HrGetOneProp, HrSetOneProp, FPropExists, FreePadrlist,

FreeProws, ScDupPropset, HexFromBin, FBinFromHex, FEqualNames. Fix 2 cases where iterating over value arrays reused a loop variable incorrectly.
parent bd4cee32
......@@ -29,8 +29,8 @@
41 stub WrapProgress@20
42 stdcall HrThisThreadAdviseSink@8(ptr ptr) HrThisThreadAdviseSink
43 stub ScBinFromHexBounded@12
44 stub FBinFromHex@8
45 stub HexFromBin@12
44 stdcall FBinFromHex@8(ptr ptr) FBinFromHex
45 stdcall HexFromBin@12(ptr long ptr) HexFromBin
46 stub BuildDisplayTable@40
47 stdcall SwapPlong@8(ptr long) SwapPlong
48 stdcall SwapPword@8(ptr long) SwapPword
......@@ -51,7 +51,7 @@
66 stdcall MNLS_MultiByteToWideChar@24(long long str long ptr long) kernel32.MultiByteToWideChar
67 stdcall MNLS_WideCharToMultiByte@32(long long wstr long ptr long ptr ptr) kernel32.WideCharToMultiByte
68 stdcall MNLS_IsBadStringPtrW@8(ptr long) kernel32.IsBadStringPtrW
72 stub FEqualNames@8
72 stdcall FEqualNames@8(ptr ptr) FEqualNames
73 stub WrapStoreEntryID@24
74 stub IsBadBoundedStringPtr@8
75 stub HrQueryAllRows@24
......@@ -75,12 +75,12 @@
131 stdcall SzFindLastCh@8(str str long) shlwapi.StrRChrA
132 stdcall SzFindSz@8(str str) shlwapi.StrStrA
133 stub UFromSz@4
135 stub HrGetOneProp@12
136 stub HrSetOneProp@8
137 stub FPropExists@8
135 stdcall HrGetOneProp@12(ptr long ptr) HrGetOneProp
136 stdcall HrSetOneProp@8(ptr ptr) HrSetOneProp
137 stdcall FPropExists@8(ptr long) FPropExists
138 stdcall PpropFindProp@12(ptr long long) PpropFindProp
139 stub FreePadrlist@4
140 stub FreeProws@4
139 stdcall FreePadrlist@4(ptr) FreePadrlist
140 stdcall FreeProws@4(ptr) FreeProws
141 stub HrSzFromEntryID@12
142 stub HrEntryIDFromSz@12
143 stub HrComposeEID@28
......@@ -111,7 +111,7 @@
171 stdcall ScCopyProps@16(long ptr ptr ptr) ScCopyProps
172 stdcall ScRelocProps@20(long ptr ptr ptr ptr) ScRelocProps
173 stdcall LpValFindProp@12(long long ptr) LpValFindProp
174 stub ScDupPropset@16
174 stdcall ScDupPropset@16(long ptr ptr ptr) ScDupPropset
175 stdcall FBadRglpszA@8(ptr long) FBadRglpszA
176 stdcall FBadRglpszW@8(ptr long) FBadRglpszW
177 stdcall FBadRowSet@4(ptr) FBadRowSet
......
......@@ -34,6 +34,8 @@ static HMODULE hMapi32 = 0;
static SCODE (WINAPI *pScInitMapiUtil)(ULONG);
static void (WINAPI *pSwapPword)(PUSHORT,ULONG);
static void (WINAPI *pSwapPlong)(PULONG,ULONG);
static void (WINAPI *pHexFromBin)(LPBYTE,int,LPWSTR);
static void (WINAPI *pFBinFromHex)(LPWSTR,LPBYTE);
static void test_SwapPword(void)
{
......@@ -69,10 +71,47 @@ static void test_SwapPlong(void)
longs[0], longs[1], longs[2]);
}
static void test_HexFromBin(void)
{
static const char res[] = { "000102030405060708090A0B0C0D0E0F101112131415161"
"718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B"
"3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F6"
"06162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8081828384"
"85868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A"
"9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCD"
"CECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F"
"2F3F4F5F6F7F8F9FAFBFCFDFE\0X" };
BYTE data[255];
WCHAR strw[256];
BOOL bOk;
int i;
pHexFromBin = (void*)GetProcAddress(hMapi32, "HexFromBin@12");
pFBinFromHex = (void*)GetProcAddress(hMapi32, "FBinFromHex@8");
if (!pHexFromBin || !pFBinFromHex)
return;
for (i = 0; i < 255; i++)
data[i] = i;
memset(strw, 'X', sizeof(strw));
pHexFromBin(data, sizeof(data), strw);
ok(memcmp(strw, res, sizeof(res) - 1) == 0, "HexFromBin: Result differs\n");
memset(data, 0, sizeof(data));
pFBinFromHex((LPWSTR)res, data);
bOk = TRUE;
for (i = 0; i < 255; i++)
if (data[i] != i)
bOk = FALSE;
ok(bOk == TRUE, "FBinFromHex: Result differs\n");
}
START_TEST(util)
{
hMapi32 = LoadLibraryA("mapi32.dll");
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
if (!pScInitMapiUtil)
return;
......@@ -80,4 +119,5 @@ START_TEST(util)
test_SwapPword();
test_SwapPlong();
test_HexFromBin();
}
......@@ -228,6 +228,85 @@ HRESULT WINAPI HrThisThreadAdviseSink(LPMAPIADVISESINK lpSink, LPMAPIADVISESINK*
}
/*************************************************************************
* FBinFromHex (MAPI32.44)
*
* Create an array of binary data from a string.
*
* PARAMS
* lpszHex [I] String to convert to binary data
* lpOut [O] Destination for resulting binary data
*
* RETURNS
* Success: TRUE. lpOut contains the decoded binary data.
* Failure: FALSE, if lpszHex does not represent a binary string.
*
* NOTES
* - lpOut must be at least half the length of lpszHex in bytes.
* - Although the Mapi headers prototype this function as both
* Ascii and Unicode, there is only one (Ascii) implementation. This
* means that lpszHex is treated as an Ascii string (i.e. a single NUL
* character in the byte stream terminates the string).
*/
BOOL WINAPI FBinFromHex(LPWSTR lpszHex, LPBYTE lpOut)
{
static const BYTE digitsToHex[] = {
0,1,2,3,4,5,6,7,8,9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,10,11,12,13,14,15,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,10,11,12,13,
14,15 };
LPSTR lpStr = (LPSTR)lpszHex;
TRACE("(%p,%p)\n", lpszHex, lpOut);
while (*lpStr)
{
if (lpStr[0] < '0' || lpStr[0] > 'f' || digitsToHex[lpStr[0] - '0'] == 0xff ||
lpStr[1] < '0' || lpStr[1] > 'f' || digitsToHex[lpStr[1] - '0'] == 0xff)
return FALSE;
*lpOut++ = (digitsToHex[lpStr[0] - '0'] << 4) | digitsToHex[lpStr[1] - '0'];
lpStr += 2;
}
return TRUE;
}
/*************************************************************************
* HexFromBin (MAPI32.45)
*
* Create a string from an array of binary data.
*
* PARAMS
* lpHex [I] Binary data to convert to string
* iCount [I] Length of lpHex in bytes
* lpszOut [O] Destination for resulting hex string
*
* RETURNS
* Nothing.
*
* NOTES
* - lpszOut must be at least 2 * iCount + 1 bytes characters long.
* - Although the Mapi headers prototype this function as both
* Ascii and Unicode, there is only one (Ascii) implementation. This
* means that the resulting string is not properly NUL terminated
* if the caller expects it to be a Unicode string.
*/
void WINAPI HexFromBin(LPBYTE lpHex, int iCount, LPWSTR lpszOut)
{
static const char hexDigits[] = { "0123456789ABCDEF" };
LPSTR lpStr = (LPSTR)lpszOut;
TRACE("(%p,%d,%p)\n", lpHex, iCount, lpszOut);
while (iCount-- > 0)
{
*lpStr++ = hexDigits[*lpHex >> 4];
*lpStr++ = hexDigits[*lpHex & 0xf];
lpHex++;
}
*lpStr = '\0';
}
/*************************************************************************
* SwapPlong@8 (MAPI32.47)
*
* Swap the bytes in a ULONG array.
......@@ -348,6 +427,33 @@ INT WINAPI MNLS_CompareStringW(DWORD dwCp, LPCWSTR lpszLeft, LPCWSTR lpszRight)
return ret < 0 ? CSTR_LESS_THAN : ret ? CSTR_GREATER_THAN : CSTR_EQUAL;
}
/**************************************************************************
* FEqualNames@8 (MAPI32.72)
*
* Compare two Mapi names.
*
* PARAMS
* lpName1 [I] First name to compare to lpName2
* lpName2 [I] Second name to compare to lpName1
*
* RETURNS
* TRUE, if the names are the same,
* FALSE, Otherwise.
*/
BOOL WINAPI FEqualNames(LPMAPINAMEID lpName1, LPMAPINAMEID lpName2)
{
TRACE("(%p,%p)\n", lpName1, lpName2);
if (!lpName1 || !lpName2 ||
!IsEqualGUID(lpName1->lpguid, lpName2->lpguid) ||
lpName1->ulKind != lpName2->ulKind)
return FALSE;
if (lpName1->ulKind == MNID_STRING)
return !strcmpW(lpName1->Kind.lpwstrName, lpName2->Kind.lpwstrName);
return lpName1->Kind.lID == lpName2->Kind.lID ? TRUE : FALSE;
}
/**************************************************************************
* FtAddFt@16 (MAPI32.121)
......@@ -364,7 +470,7 @@ INT WINAPI MNLS_CompareStringW(DWORD dwCp, LPCWSTR lpszLeft, LPCWSTR lpszRight)
LONGLONG WINAPI MAPI32_FtAddFt(FILETIME ftLeft, FILETIME ftRight)
{
LONGLONG *pl = (LONGLONG*)&ftLeft, *pr = (LONGLONG*)&ftRight;
return *pl + *pr;
}
......@@ -374,7 +480,7 @@ LONGLONG WINAPI MAPI32_FtAddFt(FILETIME ftLeft, FILETIME ftRight)
* Subtract two FILETIME's together.
*
* PARAMS
* ftLeft [I] Initial FILETIME
* ftLeft [I] Initial FILETIME
* ftRight [I] FILETIME to subtract from ftLeft
*
* RETURNS
......@@ -383,7 +489,7 @@ LONGLONG WINAPI MAPI32_FtAddFt(FILETIME ftLeft, FILETIME ftRight)
LONGLONG WINAPI MAPI32_FtSubFt(FILETIME ftLeft, FILETIME ftRight)
{
LONGLONG *pl = (LONGLONG*)&ftLeft, *pr = (LONGLONG*)&ftRight;
return *pr - *pl;
}
......@@ -402,10 +508,10 @@ LONGLONG WINAPI MAPI32_FtSubFt(FILETIME ftLeft, FILETIME ftRight)
LONGLONG WINAPI MAPI32_FtMulDw(DWORD dwLeft, FILETIME ftRight)
{
LONGLONG *pr = (LONGLONG*)&ftRight;
return (LONGLONG)dwLeft * (*pr);
}
/**************************************************************************
* FtMulDwDw@8 (MAPI32.125)
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment