[4121] | 1 | #include <string.h>
|
---|
| 2 | #include <stdio.h>
|
---|
| 3 | #include <ctype.h>
|
---|
[6709] | 4 | #include <stdlib.h>
|
---|
[4121] | 5 |
|
---|
| 6 | #include "winnls.h"
|
---|
| 7 | #include "winerror.h"
|
---|
[8048] | 8 | #include "winreg.h"
|
---|
[4121] | 9 |
|
---|
[5618] | 10 | #include "shlobj.h"
|
---|
[4121] | 11 | #include "shellapi.h"
|
---|
| 12 | #include "shell32_main.h"
|
---|
[8614] | 13 | #include "undocshell.h"
|
---|
[4121] | 14 | #include "wine/unicode.h"
|
---|
[8048] | 15 | #include "debugtools.h"
|
---|
[4121] | 16 |
|
---|
| 17 | DEFAULT_DEBUG_CHANNEL(shell);
|
---|
| 18 |
|
---|
| 19 | /************************* STRRET functions ****************************/
|
---|
| 20 |
|
---|
[8048] | 21 | /*
|
---|
| 22 | * ***** NOTE *****
|
---|
| 23 | * These routines are identical to StrRetToBuf[AW] in dlls/shlwapi/string.c.
|
---|
| 24 | * They were duplicated here because not every version of Shlwapi.dll exports
|
---|
| 25 | * StrRetToBuf[AW]. If you change one routine, change them both. YOU HAVE BEEN
|
---|
| 26 | * WARNED.
|
---|
| 27 | * ***** NOTE *****
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
---|
| 31 | {
|
---|
| 32 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
---|
| 33 |
|
---|
| 34 | switch (src->uType)
|
---|
| 35 | {
|
---|
| 36 | case STRRET_WSTR:
|
---|
[21916] | 37 | WideCharToMultiByte(CP_ACP, 0, src->DUMMYUNIONNAME_DOT pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
---|
| 38 | /* SHFree(src->DUMMYUNIONNAME_DOT pOleStr); FIXME: is this right? */
|
---|
[8048] | 39 | break;
|
---|
| 40 |
|
---|
[21512] | 41 | case STRRET_CSTR:
|
---|
[21916] | 42 | lstrcpynA((LPSTR)dest, src->DUMMYUNIONNAME_DOT cStr, len);
|
---|
[8048] | 43 | break;
|
---|
| 44 |
|
---|
[21512] | 45 | case STRRET_OFFSET:
|
---|
[21916] | 46 | lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->DUMMYUNIONNAME_DOT uOffset, len);
|
---|
[8048] | 47 | break;
|
---|
| 48 |
|
---|
| 49 | default:
|
---|
| 50 | FIXME("unknown type!\n");
|
---|
| 51 | if (len)
|
---|
| 52 | {
|
---|
| 53 | *(LPSTR)dest = '\0';
|
---|
| 54 | }
|
---|
| 55 | return(FALSE);
|
---|
| 56 | }
|
---|
| 57 | return S_OK;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | /************************************************************************/
|
---|
| 61 |
|
---|
| 62 | HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
---|
| 63 | {
|
---|
| 64 | LPWSTR dest = (LPWSTR) dest1;
|
---|
| 65 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
---|
| 66 |
|
---|
| 67 | switch (src->uType)
|
---|
| 68 | {
|
---|
| 69 | case STRRET_WSTR:
|
---|
[21916] | 70 | lstrcpynW((LPWSTR)dest, src->DUMMYUNIONNAME_DOT pOleStr, len);
|
---|
| 71 | /* SHFree(src->DUMMYUNIONNAME_DOT pOleStr); FIXME: is this right? */
|
---|
[8048] | 72 | break;
|
---|
| 73 |
|
---|
[21512] | 74 | case STRRET_CSTR:
|
---|
[21916] | 75 | if (!MultiByteToWideChar( CP_ACP, 0, src->DUMMYUNIONNAME_DOT cStr, -1, dest, len ) && len)
|
---|
[8048] | 76 | dest[len-1] = 0;
|
---|
| 77 | break;
|
---|
| 78 |
|
---|
[21512] | 79 | case STRRET_OFFSET:
|
---|
[8048] | 80 | if (pidl)
|
---|
| 81 | {
|
---|
[21916] | 82 | if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->DUMMYUNIONNAME_DOT uOffset, -1,
|
---|
[8048] | 83 | dest, len ) && len)
|
---|
| 84 | dest[len-1] = 0;
|
---|
| 85 | }
|
---|
| 86 | break;
|
---|
| 87 |
|
---|
| 88 | default:
|
---|
| 89 | FIXME("unknown type!\n");
|
---|
| 90 | if (len)
|
---|
| 91 | { *(LPSTR)dest = '\0';
|
---|
| 92 | }
|
---|
| 93 | return(FALSE);
|
---|
| 94 | }
|
---|
| 95 | return S_OK;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 |
|
---|
[4121] | 99 | /*************************************************************************
|
---|
[6709] | 100 | * StrRetToStrN [SHELL32.96]
|
---|
| 101 | *
|
---|
[4121] | 102 | * converts a STRRET to a normal string
|
---|
| 103 | *
|
---|
| 104 | * NOTES
|
---|
| 105 | * the pidl is for STRRET OFFSET
|
---|
| 106 | */
|
---|
[5618] | 107 | HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
---|
[4121] | 108 | {
|
---|
[6709] | 109 | if(SHELL_OsIsUnicode())
|
---|
| 110 | return StrRetToStrNW (dest, len, src, pidl);
|
---|
| 111 | return StrRetToStrNA (dest, len, src, pidl);
|
---|
[4121] | 112 | }
|
---|
| 113 |
|
---|
| 114 | /************************* OLESTR functions ****************************/
|
---|
| 115 |
|
---|
| 116 | /************************************************************************
|
---|
[6709] | 117 | * StrToOleStr [SHELL32.163]
|
---|
[4121] | 118 | *
|
---|
| 119 | */
|
---|
| 120 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
---|
| 121 | {
|
---|
[6709] | 122 | TRACE("(%p, %p %s)\n",
|
---|
| 123 | lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
---|
[4121] | 124 |
|
---|
[6709] | 125 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
---|
[4121] | 126 |
|
---|
| 127 | }
|
---|
| 128 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
---|
| 129 | {
|
---|
[6709] | 130 | TRACE("(%p, %p %s)\n",
|
---|
| 131 | lpWideCharStr, lpWString, debugstr_w(lpWString));
|
---|
[4121] | 132 |
|
---|
[6709] | 133 | strcpyW (lpWideCharStr, lpWString );
|
---|
| 134 | return strlenW(lpWideCharStr);
|
---|
[4121] | 135 | }
|
---|
| 136 |
|
---|
| 137 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
---|
| 138 | {
|
---|
[6709] | 139 | if (SHELL_OsIsUnicode())
|
---|
| 140 | return StrToOleStrW (lpWideCharStr, lpString);
|
---|
| 141 | return StrToOleStrA (lpWideCharStr, lpString);
|
---|
[4121] | 142 | }
|
---|
| 143 |
|
---|
| 144 | /*************************************************************************
|
---|
[6709] | 145 | * StrToOleStrN [SHELL32.79]
|
---|
[4121] | 146 | * lpMulti, nMulti, nWide [IN]
|
---|
| 147 | * lpWide [OUT]
|
---|
| 148 | */
|
---|
[6709] | 149 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
---|
[4121] | 150 | {
|
---|
[6709] | 151 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
---|
| 152 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
---|
[4121] | 153 | }
|
---|
[6709] | 154 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
---|
[4121] | 155 | {
|
---|
[6709] | 156 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
---|
[4121] | 157 |
|
---|
[6709] | 158 | if (lstrcpynW (lpWide, lpStrW, nWide))
|
---|
| 159 | { return lstrlenW (lpWide);
|
---|
| 160 | }
|
---|
| 161 | return 0;
|
---|
[4121] | 162 | }
|
---|
| 163 |
|
---|
[6709] | 164 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
---|
[4121] | 165 | {
|
---|
[6709] | 166 | if (SHELL_OsIsUnicode())
|
---|
| 167 | return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
|
---|
| 168 | return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
|
---|
[4121] | 169 | }
|
---|
| 170 |
|
---|
| 171 | /*************************************************************************
|
---|
[6709] | 172 | * OleStrToStrN [SHELL32.78]
|
---|
[4121] | 173 | */
|
---|
[6709] | 174 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
---|
[4121] | 175 | {
|
---|
[6709] | 176 | TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
---|
| 177 | return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
---|
[4121] | 178 | }
|
---|
| 179 |
|
---|
[6709] | 180 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
---|
[4121] | 181 | {
|
---|
[6709] | 182 | TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
---|
[4121] | 183 |
|
---|
[6709] | 184 | if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
---|
| 185 | { return lstrlenW (lpwStr);
|
---|
| 186 | }
|
---|
| 187 | return 0;
|
---|
[4121] | 188 | }
|
---|
| 189 |
|
---|
[6709] | 190 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
---|
[4121] | 191 | {
|
---|
[6709] | 192 | if (SHELL_OsIsUnicode())
|
---|
| 193 | return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
|
---|
| 194 | return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
|
---|
[4121] | 195 | }
|
---|
[8048] | 196 |
|
---|
| 197 |
|
---|
| 198 | /*************************************************************************
|
---|
| 199 | * CheckEscapes [SHELL32]
|
---|
| 200 | */
|
---|
| 201 | DWORD WINAPI CheckEscapesA(
|
---|
| 202 | LPSTR string, /* [in] string to check ??*/
|
---|
| 203 | DWORD b, /* [???] is 0 */
|
---|
| 204 | DWORD c, /* [???] is 0 */
|
---|
| 205 | LPDWORD d, /* [???] is address */
|
---|
| 206 | LPDWORD e, /* [???] is address */
|
---|
| 207 | DWORD handle ) /* [in] looks like handle but not */
|
---|
| 208 | {
|
---|
| 209 | FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
|
---|
| 210 | string, debugstr_a(string),
|
---|
| 211 | b,
|
---|
| 212 | c,
|
---|
| 213 | d, (d) ? *d : 0xabbacddc,
|
---|
| 214 | e, (e) ? *e : 0xabbacddd,
|
---|
| 215 | handle);
|
---|
| 216 | return 0;
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | DWORD WINAPI CheckEscapesW(
|
---|
| 220 | LPWSTR string, /* [in] string to check ??*/
|
---|
| 221 | DWORD b, /* [???] is 0 */
|
---|
| 222 | DWORD c, /* [???] is 0 */
|
---|
| 223 | LPDWORD d, /* [???] is address */
|
---|
| 224 | LPDWORD e, /* [???] is address */
|
---|
| 225 | DWORD handle ) /* [in] looks like handle but not */
|
---|
| 226 | {
|
---|
| 227 | FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
|
---|
| 228 | string, debugstr_w(string),
|
---|
| 229 | b,
|
---|
| 230 | c,
|
---|
| 231 | d, (d) ? *d : 0xabbacddc,
|
---|
| 232 | e, (e) ? *e : 0xabbacddd,
|
---|
| 233 | handle);
|
---|
| 234 | return 0;
|
---|
| 235 | }
|
---|