| 1 | #include <string.h> | 
|---|
| 2 | #include <stdio.h> | 
|---|
| 3 | #include <ctype.h> | 
|---|
| 4 | #include <stdlib.h> | 
|---|
| 5 |  | 
|---|
| 6 | #include "winnls.h" | 
|---|
| 7 | #include "winerror.h" | 
|---|
| 8 | #include "winreg.h" | 
|---|
| 9 |  | 
|---|
| 10 | #include "shlobj.h" | 
|---|
| 11 | #include "shellapi.h" | 
|---|
| 12 | #include "shell32_main.h" | 
|---|
| 13 | #include "undocshell.h" | 
|---|
| 14 | #include "wine/unicode.h" | 
|---|
| 15 | #include "debugtools.h" | 
|---|
| 16 |  | 
|---|
| 17 | DEFAULT_DEBUG_CHANNEL(shell); | 
|---|
| 18 |  | 
|---|
| 19 | /************************* STRRET functions ****************************/ | 
|---|
| 20 |  | 
|---|
| 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: | 
|---|
| 37 | WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL); | 
|---|
| 38 | /*          SHFree(src->u.pOleStr);  FIXME: is this right? */ | 
|---|
| 39 | break; | 
|---|
| 40 |  | 
|---|
| 41 | case STRRET_CSTRA: | 
|---|
| 42 | lstrcpynA((LPSTR)dest, src->u.cStr, len); | 
|---|
| 43 | break; | 
|---|
| 44 |  | 
|---|
| 45 | case STRRET_OFFSETA: | 
|---|
| 46 | lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len); | 
|---|
| 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: | 
|---|
| 70 | lstrcpynW((LPWSTR)dest, src->u.pOleStr, len); | 
|---|
| 71 | /*          SHFree(src->u.pOleStr);  FIXME: is this right? */ | 
|---|
| 72 | break; | 
|---|
| 73 |  | 
|---|
| 74 | case STRRET_CSTRA: | 
|---|
| 75 | if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len) | 
|---|
| 76 | dest[len-1] = 0; | 
|---|
| 77 | break; | 
|---|
| 78 |  | 
|---|
| 79 | case STRRET_OFFSETA: | 
|---|
| 80 | if (pidl) | 
|---|
| 81 | { | 
|---|
| 82 | if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, | 
|---|
| 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 |  | 
|---|
| 99 | /************************************************************************* | 
|---|
| 100 | * StrRetToStrN                                 [SHELL32.96] | 
|---|
| 101 | * | 
|---|
| 102 | * converts a STRRET to a normal string | 
|---|
| 103 | * | 
|---|
| 104 | * NOTES | 
|---|
| 105 | *  the pidl is for STRRET OFFSET | 
|---|
| 106 | */ | 
|---|
| 107 | HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl) | 
|---|
| 108 | { | 
|---|
| 109 | if(SHELL_OsIsUnicode()) | 
|---|
| 110 | return StrRetToStrNW (dest, len, src, pidl); | 
|---|
| 111 | return StrRetToStrNA (dest, len, src, pidl); | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | /************************* OLESTR functions ****************************/ | 
|---|
| 115 |  | 
|---|
| 116 | /************************************************************************ | 
|---|
| 117 | *      StrToOleStr                     [SHELL32.163] | 
|---|
| 118 | * | 
|---|
| 119 | */ | 
|---|
| 120 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString) | 
|---|
| 121 | { | 
|---|
| 122 | TRACE("(%p, %p %s)\n", | 
|---|
| 123 | lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString)); | 
|---|
| 124 |  | 
|---|
| 125 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH); | 
|---|
| 126 |  | 
|---|
| 127 | } | 
|---|
| 128 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString) | 
|---|
| 129 | { | 
|---|
| 130 | TRACE("(%p, %p %s)\n", | 
|---|
| 131 | lpWideCharStr, lpWString, debugstr_w(lpWString)); | 
|---|
| 132 |  | 
|---|
| 133 | strcpyW (lpWideCharStr, lpWString ); | 
|---|
| 134 | return strlenW(lpWideCharStr); | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString) | 
|---|
| 138 | { | 
|---|
| 139 | if (SHELL_OsIsUnicode()) | 
|---|
| 140 | return StrToOleStrW (lpWideCharStr, lpString); | 
|---|
| 141 | return StrToOleStrA (lpWideCharStr, lpString); | 
|---|
| 142 | } | 
|---|
| 143 |  | 
|---|
| 144 | /************************************************************************* | 
|---|
| 145 | * StrToOleStrN                                 [SHELL32.79] | 
|---|
| 146 | *  lpMulti, nMulti, nWide [IN] | 
|---|
| 147 | *  lpWide [OUT] | 
|---|
| 148 | */ | 
|---|
| 149 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr) | 
|---|
| 150 | { | 
|---|
| 151 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr); | 
|---|
| 152 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide); | 
|---|
| 153 | } | 
|---|
| 154 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr) | 
|---|
| 155 | { | 
|---|
| 156 | TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr); | 
|---|
| 157 |  | 
|---|
| 158 | if (lstrcpynW (lpWide, lpStrW, nWide)) | 
|---|
| 159 | { return lstrlenW (lpWide); | 
|---|
| 160 | } | 
|---|
| 161 | return 0; | 
|---|
| 162 | } | 
|---|
| 163 |  | 
|---|
| 164 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr) | 
|---|
| 165 | { | 
|---|
| 166 | if (SHELL_OsIsUnicode()) | 
|---|
| 167 | return StrToOleStrNW (lpWide, nWide, lpStr, nStr); | 
|---|
| 168 | return StrToOleStrNA (lpWide, nWide, lpStr, nStr); | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | /************************************************************************* | 
|---|
| 172 | * OleStrToStrN                                 [SHELL32.78] | 
|---|
| 173 | */ | 
|---|
| 174 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle) | 
|---|
| 175 | { | 
|---|
| 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); | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle) | 
|---|
| 181 | { | 
|---|
| 182 | TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle); | 
|---|
| 183 |  | 
|---|
| 184 | if (lstrcpynW ( lpwStr, lpOle, nwStr)) | 
|---|
| 185 | { return lstrlenW (lpwStr); | 
|---|
| 186 | } | 
|---|
| 187 | return 0; | 
|---|
| 188 | } | 
|---|
| 189 |  | 
|---|
| 190 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn) | 
|---|
| 191 | { | 
|---|
| 192 | if (SHELL_OsIsUnicode()) | 
|---|
| 193 | return OleStrToStrNW (lpOut, nOut, lpIn, nIn); | 
|---|
| 194 | return OleStrToStrNA (lpOut, nOut, lpIn, nIn); | 
|---|
| 195 | } | 
|---|
| 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 | } | 
|---|