ReactOS 0.4.16-dev-91-g764881a
shellstring.c File Reference
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <undocshell.h>
#include <shlwapi_undoc.h>
#include <wine/unicode.h>
#include <wine/debug.h>
#include "shell32_main.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)
 

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}
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2667
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2791
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define debugstr_a
Definition: kernel32.h:31
VOID WINAPI CheckEscapesW(LPWSTR string, DWORD len)
Definition: shellstring.c:252
#define TRACE(s)
Definition: solgame.cpp:4
#define LPTR
Definition: winbase.h:381
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CheckEscapesW()

VOID WINAPI CheckEscapesW ( LPWSTR  string,
DWORD  len 
)

Definition at line 252 of file shellstring.c.

255{
256 DWORD size = lstrlenW(string);
257 LPWSTR s, d;
258
259 TRACE("(%s %d) stub\n", debugstr_w(string), len);
260
261 if (StrPBrkW(string, L" \",;^") && size + 2 <= len)
262 {
263 s = &string[size - 1];
264 d = &string[size + 2];
265 *d-- = 0;
266 *d-- = '"';
267 for (;d > string;)
268 *d-- = *s--;
269 *d = '"';
270 }
271}
#define lstrlenW
Definition: compat.h:750
LPWSTR WINAPI StrPBrkW(LPCWSTR lpszStr, LPCWSTR lpszMatch)
Definition: string.c:1284
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
GLsizeiptr size
Definition: glext.h:5919
#define d
Definition: ke_i.h:81
#define debugstr_w
Definition: kernel32.h:32
char string[160]
Definition: util.h:11
#define L(x)
Definition: ntvdm.h:50

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}
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_OFFSET
Definition: shtypes.idl:86
@ STRRET_WSTR
Definition: shtypes.idl:85

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 NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#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 __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:138
static BOOL OleStrToStrNW(LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
Definition: shellstring.c:199
static BOOL OleStrToStrNA(LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
Definition: shellstring.c:193

◆ 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 FALSE
Definition: types.h:117
#define lstrcpynW
Definition: compat.h:738

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}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define TRUE
Definition: types.h:120
#define lstrcpynA
Definition: compat.h:751
GLenum src
Definition: glext.h:6340
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
static char * dest
Definition: rtl.c:135
static const char * debugstr_strret(STRRET *s)
Definition: shellstring.c:39
SHITEMID mkid
Definition: shtypes.idl:34
const char * LPCSTR
Definition: xmlstorage.h:183

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{
128 return StrRetToStrNW(dest, len, src, pidl);
129 else
130 return StrRetToStrNA(dest, len, src, pidl);
131}
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:85
BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:54

◆ 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}
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by BrFolder_GetName(), CDefView::DoColumnContextMenu(), ILGetDisplayNameExW(), CDefView::LoadColumn(), 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 MAX_PATH
Definition: compat.h:34

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 int StrToOleStrW(LPWSTR lpWideCharStr, LPCWSTR lpWString)
Definition: shellstring.c:147
static int StrToOleStrA(LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
Definition: shellstring.c:139

◆ 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}
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55

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 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}

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}
#define strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35

Referenced by StrToOleStrAW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )