ReactOS  0.4.14-dev-552-g2fad488
string.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "shellapi.h"
#include "shtypes.h"
#include "objbase.h"
#include "wine/test.h"
Include dependency graph for string.c:

Go to the source code of this file.

Macros

#define WINE_NOWINSOCK
 

Functions

static BOOL (WINAPI *pStrRetToStrNAW)(LPVOID
 
static const ITEMIDLIST *static WCHARCoDupStrW (const char *src)
 
static int strcmpW (const WCHAR *str1, const WCHAR *str2)
 
static void test_StrRetToStringNA (void)
 
static void test_StrRetToStringNW (void)
 
 START_TEST (string)
 

Variables

static HMODULE hShell32
 
static DWORD
 
static LPSTRRET
 

Macro Definition Documentation

◆ WINE_NOWINSOCK

#define WINE_NOWINSOCK

Definition at line 24 of file string.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pStrRetToStrNAW)
static

◆ CoDupStrW()

static const ITEMIDLIST* static WCHAR* CoDupStrW ( const char src)
static

Definition at line 37 of file string.c.

38 {
39  INT len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
40  WCHAR* szTemp = CoTaskMemAlloc(len * sizeof(WCHAR));
41  MultiByteToWideChar(CP_ACP, 0, src, -1, szTemp, len);
42  return szTemp;
43 }
#define CP_ACP
Definition: compat.h:99
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:100
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

Referenced by test_StrRetToStringNW().

◆ START_TEST()

START_TEST ( string  )

Definition at line 100 of file string.c.

101 {
102  CoInitialize(0);
103 
104  hShell32 = GetModuleHandleA("shell32.dll");
105 
106  pStrRetToStrNAW = (void*)GetProcAddress(hShell32, (LPSTR)96);
107  if (pStrRetToStrNAW)
108  {
109  if (!(GetVersion() & 0x80000000))
111  else
113  }
114 
115  CoUninitialize();
116 }
char * LPSTR
Definition: xmlstorage.h:182
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
static void test_StrRetToStringNW(void)
Definition: string.c:57
static void test_StrRetToStringNA(void)
Definition: string.c:51
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define GetProcAddress(x, y)
Definition: compat.h:418
static HMODULE hShell32
Definition: string.c:34

◆ strcmpW()

static int strcmpW ( const WCHAR str1,
const WCHAR str2 
)
inlinestatic

Definition at line 45 of file string.c.

46 {
47  while (*str1 && (*str1 == *str2)) { str1++; str2++; }
48  return *str1 - *str2;
49 }

Referenced by test_StrRetToStringNW().

◆ test_StrRetToStringNA()

static void test_StrRetToStringNA ( void  )
static

Definition at line 51 of file string.c.

52 {
53  trace("StrRetToStringNAW is Ascii\n");
54  /* FIXME */
55 }
#define trace
Definition: atltest.h:70

Referenced by START_TEST().

◆ test_StrRetToStringNW()

static void test_StrRetToStringNW ( void  )
static

Definition at line 57 of file string.c.

58 {
59  static const WCHAR szTestW[] = { 'T','e','s','t','\0' };
60  ITEMIDLIST iidl[10];
61  WCHAR buff[128];
62  STRRET strret;
63  BOOL ret;
64 
65  trace("StrRetToStringNAW is Unicode\n");
66 
67  strret.uType = STRRET_WSTR;
68  U(strret).pOleStr = CoDupStrW("Test");
69  memset(buff, 0xff, sizeof(buff));
70  ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
71  ok(ret == TRUE && !strcmpW(buff, szTestW),
72  "STRRET_WSTR: dup failed, ret=%d\n", ret);
73 
74  strret.uType = STRRET_CSTR;
75  lstrcpyA(U(strret).cStr, "Test");
76  memset(buff, 0xff, sizeof(buff));
77  ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
78  ok(ret == TRUE && !strcmpW(buff, szTestW),
79  "STRRET_CSTR: dup failed, ret=%d\n", ret);
80 
81  strret.uType = STRRET_OFFSET;
82  U(strret).uOffset = 1;
83  strcpy((char*)&iidl, " Test");
84  memset(buff, 0xff, sizeof(buff));
85  ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, iidl);
86  ok(ret == TRUE && !strcmpW(buff, szTestW),
87  "STRRET_OFFSET: dup failed, ret=%d\n", ret);
88 
89  /* The next test crashes on W2K, WinXP and W2K3, so we don't test. */
90 if (0)
91 {
92  /* Invalid dest - should return FALSE, except NT4 does not, so we don't check. */
93  strret.uType = STRRET_WSTR;
94  U(strret).pOleStr = CoDupStrW("Test");
95  pStrRetToStrNAW(NULL, ARRAY_SIZE(buff), &strret, NULL);
96  trace("NULL dest: ret=%d\n", ret);
97 }
98 }
#define TRUE
Definition: types.h:120
static int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: string.c:45
#define U(x)
Definition: wordpad.c:44
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
UINT uType
Definition: shtypes.idl:93
#define memset(x, y, z)
Definition: compat.h:39
static const ITEMIDLIST *static WCHAR * CoDupStrW(const char *src)
Definition: string.c:37
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 35 of file string.c.

◆ hShell32

◆ LPSTRRET

Definition at line 35 of file string.c.