ReactOS  0.4.15-dev-1070-ge1a01de
shellstring.c File Reference
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <wine/unicode.h>
#include <wine/debug.h>
#include "shell32_main.h"
#include "undocshell.h"
#include "shlwapi_undoc.h"
Include dependency graph for shellstring.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static const chardebugstr_strret (STRRET *s)
 
BOOL WINAPI StrRetToStrNA (LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 
BOOL WINAPI StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 
BOOL WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 
static int StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
 
static int StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
 
BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
 
static BOOL StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
 
static BOOL StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
 
BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
 
static BOOL OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
 
static BOOL OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
 
BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
 
VOID WINAPI CheckEscapesA (LPSTR string, DWORD len)
 
VOID WINAPI CheckEscapesW (LPWSTR string, DWORD len)
 

Variables

static const WCHAR strEscapedChars [] = {' ','"',',',';','^',0}
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 20 of file shellstring.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 22 of file shellstring.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 21 of file shellstring.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 19 of file shellstring.c.

Function Documentation

◆ CheckEscapesA()

VOID WINAPI CheckEscapesA ( LPSTR  string,
DWORD  len 
)

Definition at line 227 of file shellstring.c.

230 {
231  LPWSTR wString;
232  TRACE("(%s %d)\n", debugstr_a(string), len);
233 
234  if (!string || !string[0])
235  return;
236 
237  wString = LocalAlloc(LPTR, len * sizeof(WCHAR));
238  if (!wString)
239  return;
240 
241  SHAnsiToUnicode(string, wString, len);
242  CheckEscapesW(wString, len);
243  SHUnicodeToAnsi(wString, string, len);
244  LocalFree(wString);
245 }
VOID WINAPI CheckEscapesW(LPWSTR string, DWORD len)
Definition: shellstring.c:254
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
GLenum GLsizei len
Definition: glext.h:6722
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CheckEscapesW()

VOID WINAPI CheckEscapesW ( LPWSTR  string,
DWORD  len 
)

Definition at line 254 of file shellstring.c.

257 {
258  DWORD size = lstrlenW(string);
259  LPWSTR s, d;
260 
261  TRACE("(%s %d) stub\n", debugstr_w(string), len);
262 
263  if (StrPBrkW(string, strEscapedChars) && size + 2 <= len)
264  {
265  s = &string[size - 1];
266  d = &string[size + 2];
267  *d-- = 0;
268  *d-- = '"';
269  for (;d > string;)
270  *d-- = *s--;
271  *d = '"';
272  }
273 }
LPWSTR WINAPI StrPBrkW(LPCWSTR lpszStr, LPCWSTR lpszMatch)
Definition: string.c:1276
#define lstrlenW
Definition: compat.h:498
static const WCHAR strEscapedChars[]
Definition: shellstring.c:247
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define d
Definition: ke_i.h:81
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
char string[160]
Definition: util.h:11
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CheckEscapesA().

◆ debugstr_strret()

static const char* debugstr_strret ( STRRET s)
static

Definition at line 39 of file shellstring.c.

40 {
41  switch (s->uType)
42  {
43  case STRRET_WSTR:
44  return "STRRET_WSTR";
45  case STRRET_CSTR:
46  return "STRRET_CSTR";
47  case STRRET_OFFSET:
48  return "STRRET_OFFSET";
49  default:
50  return "STRRET_???";
51  }
52 }
GLdouble s
Definition: gl.h:2039

Referenced by StrRetToStrNA(), and StrRetToStrNW().

◆ OleStrToStrNA()

static BOOL OleStrToStrNA ( LPSTR  lpStr,
INT  nStr,
LPCWSTR  lpOle,
INT  nOle 
)
static

Definition at line 193 of file shellstring.c.

194 {
195  TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
196  return WideCharToMultiByte (CP_ACP, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
197 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_wn
Definition: kernel32.h:33

Referenced by OleStrToStrNAW().

◆ OleStrToStrNAW()

BOOL WINAPI OleStrToStrNAW ( LPVOID  lpOut,
INT  nOut,
LPCVOID  lpIn,
INT  nIn 
)

Definition at line 209 of file shellstring.c.

210 {
211  if (SHELL_OsIsUnicode())
212  return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
213  return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
214 }
static BOOL OleStrToStrNA(LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
Definition: shellstring.c:193
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static BOOL OleStrToStrNW(LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
Definition: shellstring.c:199

◆ OleStrToStrNW()

static BOOL OleStrToStrNW ( LPWSTR  lpwStr,
INT  nwStr,
LPCWSTR  lpOle,
INT  nOle 
)
static

Definition at line 199 of file shellstring.c.

200 {
201  TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
202 
203  if (lstrcpynW ( lpwStr, lpOle, nwStr))
204  { return lstrlenW (lpwStr);
205  }
206  return FALSE;
207 }
#define lstrlenW
Definition: compat.h:498
#define lstrcpynW
Definition: compat.h:486
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_wn
Definition: kernel32.h:33

Referenced by OleStrToStrNAW().

◆ StrRetToStrNA()

BOOL WINAPI StrRetToStrNA ( LPSTR  dest,
DWORD  len,
LPSTRRET  src,
const ITEMIDLIST pidl 
)

Definition at line 54 of file shellstring.c.

55 {
56  TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n", dest, len, src, debugstr_strret(src), pidl);
57 
58  if (!dest)
59  return FALSE;
60 
61  switch (src->uType)
62  {
63  case STRRET_WSTR:
64  WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, dest, len, NULL, NULL);
65  CoTaskMemFree(src->u.pOleStr);
66  break;
67  case STRRET_CSTR:
68  lstrcpynA(dest, src->u.cStr, len);
69  break;
70  case STRRET_OFFSET:
71  lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
72  break;
73  default:
74  FIXME("unknown type %u!\n", src->uType);
75  if (len)
76  *dest = '\0';
77  return FALSE;
78  }
79  TRACE("-- %s\n", debugstr_a(dest) );
80  return TRUE;
81 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
static const char * debugstr_strret(STRRET *s)
Definition: shellstring.c:39
#define lstrcpynA
Definition: compat.h:499
static char * dest
Definition: rtl.c:135
SHITEMID mkid
Definition: shtypes.idl:34

Referenced by CDefView::OnNotify(), and StrRetToStrNAW().

◆ StrRetToStrNAW()

BOOL WINAPI StrRetToStrNAW ( LPVOID  dest,
DWORD  len,
LPSTRRET  src,
const ITEMIDLIST pidl 
)

Definition at line 125 of file shellstring.c.

126 {
127  if(SHELL_OsIsUnicode())
128  return StrRetToStrNW(dest, len, src, pidl);
129  else
130  return StrRetToStrNA(dest, len, src, pidl);
131 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:54
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:85

◆ StrRetToStrNW()

BOOL WINAPI StrRetToStrNW ( LPWSTR  dest,
DWORD  len,
LPSTRRET  src,
const ITEMIDLIST pidl 
)

Definition at line 85 of file shellstring.c.

86 {
87  TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n", dest, len, src, debugstr_strret(src), pidl);
88 
89  if (!dest)
90  return FALSE;
91 
92  switch (src->uType)
93  {
94  case STRRET_WSTR:
95  lstrcpynW(dest, src->u.pOleStr, len);
96  CoTaskMemFree(src->u.pOleStr);
97  break;
98  case STRRET_CSTR:
99  if (!MultiByteToWideChar(CP_ACP, 0, src->u.cStr, -1, dest, len) && len)
100  dest[len-1] = 0;
101  break;
102  case STRRET_OFFSET:
103  if (!MultiByteToWideChar(CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len)
104  && len)
105  dest[len-1] = 0;
106  break;
107  default:
108  FIXME("unknown type %u!\n", src->uType);
109  if (len)
110  *dest = '\0';
111  return FALSE;
112  }
113  return TRUE;
114 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define lstrcpynW
Definition: compat.h:486
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
const char * LPCSTR
Definition: xmlstorage.h:183
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
static const char * debugstr_strret(STRRET *s)
Definition: shellstring.c:39
#define MultiByteToWideChar
Definition: compat.h:110
static char * dest
Definition: rtl.c:135
SHITEMID mkid
Definition: shtypes.idl:34

Referenced by GetName(), ILGetDisplayNameExW(), CDefView::InitList(), CDefView::OnNotify(), SHELL_GetPathFromIDListForExecuteW(), SHGetFileInfoW(), and StrRetToStrNAW().

◆ StrToOleStrA()

static int StrToOleStrA ( LPWSTR  lpWideCharStr,
LPCSTR  lpMultiByteString 
)
static

Definition at line 139 of file shellstring.c.

140 {
141  TRACE("(%p, %p %s)\n",
142  lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
143 
144  return MultiByteToWideChar(CP_ACP, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
145 
146 }
#define CP_ACP
Definition: compat.h:109
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by StrToOleStrAW().

◆ StrToOleStrAW()

BOOL WINAPI StrToOleStrAW ( LPWSTR  lpWideCharStr,
LPCVOID  lpString 
)

Definition at line 156 of file shellstring.c.

157 {
158  if (SHELL_OsIsUnicode())
159  return StrToOleStrW (lpWideCharStr, lpString);
160  return StrToOleStrA (lpWideCharStr, lpString);
161 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static int StrToOleStrA(LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
Definition: shellstring.c:139
static int StrToOleStrW(LPWSTR lpWideCharStr, LPCWSTR lpWString)
Definition: shellstring.c:147

◆ StrToOleStrNA()

static BOOL StrToOleStrNA ( LPWSTR  lpWide,
INT  nWide,
LPCSTR  lpStrA,
INT  nStr 
)
static

Definition at line 168 of file shellstring.c.

169 {
170  TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
171  return MultiByteToWideChar (CP_ACP, 0, lpStrA, nStr, lpWide, nWide);
172 }
#define CP_ACP
Definition: compat.h:109
#define TRACE(s)
Definition: solgame.cpp:4
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by StrToOleStrNAW().

◆ StrToOleStrNAW()

BOOL WINAPI StrToOleStrNAW ( LPWSTR  lpWide,
INT  nWide,
LPCVOID  lpStr,
INT  nStr 
)

Definition at line 183 of file shellstring.c.

184 {
185  if (SHELL_OsIsUnicode())
186  return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
187  return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
188 }
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
static BOOL StrToOleStrNW(LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
Definition: shellstring.c:173
static BOOL StrToOleStrNA(LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
Definition: shellstring.c:168

◆ StrToOleStrNW()

static BOOL StrToOleStrNW ( LPWSTR  lpWide,
INT  nWide,
LPCWSTR  lpStrW,
INT  nStr 
)
static

Definition at line 173 of file shellstring.c.

174 {
175  TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
176 
177  if (lstrcpynW (lpWide, lpStrW, nWide))
178  { return lstrlenW (lpWide);
179  }
180  return FALSE;
181 }
#define lstrlenW
Definition: compat.h:498
#define lstrcpynW
Definition: compat.h:486
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_wn
Definition: kernel32.h:33

Referenced by StrToOleStrNAW().

◆ StrToOleStrW()

static int StrToOleStrW ( LPWSTR  lpWideCharStr,
LPCWSTR  lpWString 
)
static

Definition at line 147 of file shellstring.c.

148 {
149  TRACE("(%p, %p %s)\n",
150  lpWideCharStr, lpWString, debugstr_w(lpWString));
151 
152  strcpyW (lpWideCharStr, lpWString );
153  return strlenW(lpWideCharStr);
154 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219

Referenced by StrToOleStrAW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ strEscapedChars

const WCHAR strEscapedChars[] = {' ','"',',',';','^',0}
static

Definition at line 247 of file shellstring.c.

Referenced by CheckEscapesW().