ReactOS  0.4.13-dev-650-g34bf247
util.c File Reference
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "winnt.h"
#include "mapiutil.h"
#include "mapitags.h"
#include "mapi32_test.h"
Include dependency graph for util.c:

Go to the source code of this file.

Functions

static SCODE (WINAPI *pScInitMapiUtil)(ULONG)
 
static void (WINAPI *pDeinitMapiUtil)(void)
 
static BOOL (WINAPI *pFBinFromHex)(LPWSTR
 
static UINT (WINAPI *pUFromSz)(LPCSTR)
 
static ULONG (WINAPI *pUlFromSzHex)(LPCSTR)
 
static void init_function_pointers (void)
 
static void test_SwapPword (void)
 
static void test_SwapPlong (void)
 
static void test_HexFromBin (void)
 
static void test_UFromSz (void)
 
static void test_UlFromSzHex (void)
 
static void test_CbOfEncoded (void)
 
static void test_IsBadBoundedStringPtr (void)
 
 START_TEST (util)
 

Variables

static HMODULE hMapi32 = 0
 
static ULONG
 
static int
 
static LPWSTR
 
static LPBYTE
 

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pFBinFromHex)
static

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 46 of file util.c.

47 {
48  hMapi32 = LoadLibraryA("mapi32.dll");
49 
50  pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
51  pDeinitMapiUtil = (void*)GetProcAddress(hMapi32, "DeinitMapiUtil@0");
52  pSwapPword = (void*)GetProcAddress(hMapi32, "SwapPword@8");
53  pSwapPlong = (void*)GetProcAddress(hMapi32, "SwapPlong@8");
54  pHexFromBin = (void*)GetProcAddress(hMapi32, "HexFromBin@12");
55  pFBinFromHex = (void*)GetProcAddress(hMapi32, "FBinFromHex@8");
56  pUFromSz = (void*)GetProcAddress(hMapi32, "UFromSz@4");
57  pUlFromSzHex = (void*)GetProcAddress(hMapi32, "UlFromSzHex@4");
58  pCbOfEncoded = (void*)GetProcAddress(hMapi32, "CbOfEncoded@4");
59  pIsBadBoundedStringPtr = (void*)GetProcAddress(hMapi32, "IsBadBoundedStringPtr@8");
60  pMAPIInitialize = (void*)GetProcAddress(hMapi32, "MAPIInitialize");
61  pMAPIUninitialize = (void*)GetProcAddress(hMapi32, "MAPIUninitialize");
62 }
static HMODULE hMapi32
Definition: util.c:31
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by START_TEST().

◆ SCODE()

static SCODE ( WINAPI pScInitMapiUtil)
static

◆ START_TEST()

START_TEST ( util  )

Definition at line 206 of file util.c.

207 {
208  SCODE ret;
209 
210  if (!HaveDefaultMailClient())
211  {
212  win_skip("No default mail client installed\n");
213  return;
214  }
215 
217 
218  if (!pScInitMapiUtil || !pDeinitMapiUtil)
219  {
220  win_skip("MAPI utility initialization functions are not available\n");
222  return;
223  }
224 
225  SetLastError(0xdeadbeef);
226  ret = pScInitMapiUtil(0);
227  if ((ret != S_OK) && (GetLastError() == ERROR_PROC_NOT_FOUND))
228  {
229  win_skip("ScInitMapiUtil is not implemented\n");
231  return;
232  }
233  else if ((ret == E_FAIL) && (GetLastError() == ERROR_INVALID_HANDLE))
234  {
235  win_skip("ScInitMapiUtil doesn't work on some Win98 and WinME systems\n");
237  return;
238  }
239 
240  test_SwapPword();
241  test_SwapPlong();
242 
243  /* We call MAPIInitialize here for the benefit of native extended MAPI
244  * providers which crash in the HexFromBin tests when MAPIInitialize has
245  * not been called. Since MAPIInitialize is irrelevant for HexFromBin on
246  * Wine, we do not care whether MAPIInitialize succeeds. */
247  if (pMAPIInitialize)
248  ret = pMAPIInitialize(NULL);
249  test_HexFromBin();
250  if (pMAPIUninitialize && ret == S_OK)
251  pMAPIUninitialize();
252 
253  test_UFromSz();
257 
258  pDeinitMapiUtil();
260 }
static HMODULE hMapi32
Definition: util.c:31
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define E_FAIL
Definition: ddrawi.h:102
static void test_SwapPlong(void)
Definition: util.c:83
static void test_HexFromBin(void)
Definition: util.c:102
static void test_UFromSz(void)
Definition: util.c:139
LONG SCODE
Definition: compat.h:1893
smooth NULL
Definition: ftsmooth.c:416
static void test_CbOfEncoded(void)
Definition: util.c:169
#define FreeLibrary(x)
Definition: compat.h:405
static void test_SwapPword(void)
Definition: util.c:64
#define SetLastError(x)
Definition: compat.h:409
int ret
static void init_function_pointers(void)
Definition: util.c:46
#define S_OK
Definition: intsafe.h:59
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
static void test_IsBadBoundedStringPtr(void)
Definition: util.c:193
static BOOL HaveDefaultMailClient(void)
Definition: mapi32_test.h:20
static void test_UlFromSzHex(void)
Definition: util.c:154
#define win_skip
Definition: test.h:141

◆ test_CbOfEncoded()

static void test_CbOfEncoded ( void  )
static

Definition at line 169 of file util.c.

170 {
171  char buff[129];
172  unsigned int i;
173 
174  if (!pCbOfEncoded)
175  {
176  win_skip("CbOfEncoded is not available\n");
177  return;
178  }
179 
180  for (i = 0; i < sizeof(buff) - 1; i++)
181  {
182  ULONG ulRet, ulExpected = (((i | 3) >> 2) + 1) * 3;
183 
184  memset(buff, '\0', sizeof(buff));
185  memset(buff, '?', i);
186  ulRet = pCbOfEncoded(buff);
187  ok(ulRet == ulExpected,
188  "CbOfEncoded(length %d): expected %d, got %d\n",
189  i, ulExpected, ulRet);
190  }
191 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by START_TEST().

◆ test_HexFromBin()

static void test_HexFromBin ( void  )
static

Definition at line 102 of file util.c.

103 {
104  static char res[] = { "000102030405060708090A0B0C0D0E0F101112131415161"
105  "718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B"
106  "3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F6"
107  "06162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8081828384"
108  "85868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A"
109  "9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCD"
110  "CECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F"
111  "2F3F4F5F6F7F8F9FAFBFCFDFE\0X" };
112  BYTE data[255];
113  WCHAR strw[256];
114  BOOL bOk;
115  int i;
116 
117  if (!pHexFromBin || !pFBinFromHex)
118  {
119  win_skip("Hexadecimal conversion functions are not available\n");
120  return;
121  }
122 
123  for (i = 0; i < 255; i++)
124  data[i] = i;
125  memset(strw, 'X', sizeof(strw));
126  pHexFromBin(data, sizeof(data), strw);
127 
128  ok(memcmp(strw, res, sizeof(res) - 1) == 0, "HexFromBin: Result differs\n");
129 
130  memset(data, 0, sizeof(data));
131  pFBinFromHex((LPWSTR)res, data);
132  bOk = TRUE;
133  for (i = 0; i < 255; i++)
134  if (data[i] != i)
135  bOk = FALSE;
136  ok(bOk == TRUE, "FBinFromHex: Result differs\n");
137 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char BYTE
Definition: mem.h:68
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
static const char * strw(LPCWSTR x)
Definition: actctx.c:49
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_IsBadBoundedStringPtr()

static void test_IsBadBoundedStringPtr ( void  )
static

Definition at line 193 of file util.c.

194 {
195  if (!pIsBadBoundedStringPtr)
196  {
197  win_skip("IsBadBoundedStringPtr is not available\n");
198  return;
199  }
200 
201  ok(pIsBadBoundedStringPtr(NULL, 0) == TRUE, "IsBadBoundedStringPtr: expected TRUE\n");
202  ok(pIsBadBoundedStringPtr("TEST", 4) == TRUE, "IsBadBoundedStringPtr: expected TRUE\n");
203  ok(pIsBadBoundedStringPtr("TEST", 5) == FALSE, "IsBadBoundedStringPtr: expected FALSE\n");
204 }
#define TRUE
Definition: types.h:120
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_SwapPlong()

static void test_SwapPlong ( void  )
static

Definition at line 83 of file util.c.

84 {
85  ULONG longs[3];
86 
87  if (!pSwapPlong)
88  {
89  win_skip("SwapPlong is not available\n");
90  return;
91  }
92 
93  longs[0] = 0xffff0001;
94  longs[1] = 0x1000ffff;
95  longs[2] = 0x20000001;
96  pSwapPlong(longs, 2);
97  ok((longs[0] == 0x0100ffff && longs[1] == 0xffff0010 && longs[2] == 0x20000001),
98  "Expected {0x0100ffff,0xffff0010,0x20000001}, got {0x%08x,0x%08x,0x%08x}\n",
99  longs[0], longs[1], longs[2]);
100 }
#define ok(value,...)
unsigned int ULONG
Definition: retypes.h:1
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_SwapPword()

static void test_SwapPword ( void  )
static

Definition at line 64 of file util.c.

65 {
66  USHORT shorts[3];
67 
68  if (!pSwapPword)
69  {
70  win_skip("SwapPword is not available\n");
71  return;
72  }
73 
74  shorts[0] = 0xff01;
75  shorts[1] = 0x10ff;
76  shorts[2] = 0x2001;
77  pSwapPword(shorts, 2);
78  ok((shorts[0] == 0x01ff && shorts[1] == 0xff10 && shorts[2] == 0x2001),
79  "Expected {0x01ff,0xff10,0x2001}, got {0x%04x,0x%04x,0x%04x}\n",
80  shorts[0], shorts[1], shorts[2]);
81 }
#define ok(value,...)
unsigned short USHORT
Definition: pedump.c:61
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_UFromSz()

static void test_UFromSz ( void  )
static

Definition at line 139 of file util.c.

140 {
141  if (!pUFromSz)
142  {
143  win_skip("UFromSz is not available\n");
144  return;
145  }
146 
147  ok(pUFromSz("105679") == 105679u,
148  "UFromSz: expected 105679, got %d\n", pUFromSz("105679"));
149 
150  ok(pUFromSz(" 4") == 0, "UFromSz: expected 0. got %d\n",
151  pUFromSz(" 4"));
152 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define ok(value,...)
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_UlFromSzHex()

static void test_UlFromSzHex ( void  )
static

Definition at line 154 of file util.c.

155 {
156  if (!pUlFromSzHex)
157  {
158  win_skip("UlFromSzHex is not available\n");
159  return;
160  }
161 
162  ok(pUlFromSzHex("fF") == 0xffu,
163  "UlFromSzHex: expected 0xff, got 0x%x\n", pUlFromSzHex("fF"));
164 
165  ok(pUlFromSzHex(" c") == 0, "UlFromSzHex: expected 0x0. got 0x%x\n",
166  pUlFromSzHex(" c"));
167 }
#define ok(value,...)
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ UINT()

static UINT ( WINAPI pUFromSz)
static

◆ ULONG()

static ULONG ( WINAPI pUlFromSzHex)
static

◆ void()

Variable Documentation

◆ hMapi32

HMODULE hMapi32 = 0
static

Definition at line 31 of file util.c.

Referenced by init_function_pointers(), and START_TEST().

◆ int

◆ LPBYTE

Definition at line 38 of file util.c.

◆ LPWSTR

Definition at line 37 of file util.c.

◆ ULONG

Definition at line 35 of file util.c.

Referenced by GetRegistryValueBuffer(), and index_to_rgba().