| 1 | //Note: Odin changes marked by #ifdef __WIN32OS2__!
|
|---|
| 2 | #ifdef __WIN32OS2__
|
|---|
| 3 | #include <odin.h>
|
|---|
| 4 | #include <odinwrap.h>
|
|---|
| 5 | #include <os2sel.h>
|
|---|
| 6 |
|
|---|
| 7 | #include <string.h>
|
|---|
| 8 | #include <wctype.h>
|
|---|
| 9 | #include <wcstr.h>
|
|---|
| 10 | #define HAVE_WCTYPE_H
|
|---|
| 11 | #include <win\shlwapi.h>
|
|---|
| 12 |
|
|---|
| 13 | #include <heapstring.h>
|
|---|
| 14 | #include <winnls.h>
|
|---|
| 15 | #endif
|
|---|
| 16 | #include <ctype.h>
|
|---|
| 17 | #include <stdlib.h>
|
|---|
| 18 | #include <stdio.h>
|
|---|
| 19 | #include <string.h>
|
|---|
| 20 |
|
|---|
| 21 | #include "winerror.h"
|
|---|
| 22 | #include "windef.h"
|
|---|
| 23 | #include "winbase.h"
|
|---|
| 24 | #include "wingdi.h"
|
|---|
| 25 | #include "winuser.h"
|
|---|
| 26 | #include "shlwapi.h"
|
|---|
| 27 | #include "shlobj.h"
|
|---|
| 28 | #include "wine/unicode.h"
|
|---|
| 29 | #include "debugtools.h"
|
|---|
| 30 |
|
|---|
| 31 | DEFAULT_DEBUG_CHANNEL(shell);
|
|---|
| 32 |
|
|---|
| 33 | /*************************************************************************
|
|---|
| 34 | * StrChrA [SHLWAPI]
|
|---|
| 35 | */
|
|---|
| 36 | LPSTR WINAPI StrChrA (LPCSTR str, WORD c)
|
|---|
| 37 | {
|
|---|
| 38 | TRACE("%s %i\n", str,c);
|
|---|
| 39 | return strchr(str, c);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | /*************************************************************************
|
|---|
| 43 | * StrChrW [SHLWAPI]
|
|---|
| 44 | *
|
|---|
| 45 | */
|
|---|
| 46 | LPWSTR WINAPI StrChrW (LPCWSTR str, WCHAR x )
|
|---|
| 47 | {
|
|---|
| 48 | TRACE("%s 0x%04x\n",debugstr_w(str),x);
|
|---|
| 49 | return strchrW(str, x);
|
|---|
| 50 | }
|
|---|
| 51 | #ifndef __WIN32OS2__
|
|---|
| 52 | /*************************************************************************
|
|---|
| 53 | * StrCmpIW [SHLWAPI]
|
|---|
| 54 | */
|
|---|
| 55 | int WINAPI StrCmpIW ( LPCWSTR wstr1, LPCWSTR wstr2 )
|
|---|
| 56 | {
|
|---|
| 57 | TRACE("%s %s\n", debugstr_w(wstr1),debugstr_w(wstr2));
|
|---|
| 58 | return strcmpiW( wstr1, wstr2 );
|
|---|
| 59 | }
|
|---|
| 60 | #endif
|
|---|
| 61 |
|
|---|
| 62 | /*************************************************************************
|
|---|
| 63 | * StrCmpNA [SHLWAPI]
|
|---|
| 64 | */
|
|---|
| 65 | INT WINAPI StrCmpNA ( LPCSTR str1, LPCSTR str2, INT len)
|
|---|
| 66 | {
|
|---|
| 67 | TRACE("%s %s %i stub\n", str1,str2,len);
|
|---|
| 68 | return strncmp(str1, str2, len);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | /*************************************************************************
|
|---|
| 72 | * StrCmpNW [SHLWAPI]
|
|---|
| 73 | */
|
|---|
| 74 | INT WINAPI StrCmpNW ( LPCWSTR wstr1, LPCWSTR wstr2, INT len)
|
|---|
| 75 | {
|
|---|
| 76 | TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
|
|---|
| 77 | return strncmpW(wstr1, wstr2, len);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | /*************************************************************************
|
|---|
| 81 | * StrCmpNIA [SHLWAPI]
|
|---|
| 82 | */
|
|---|
| 83 | int WINAPI StrCmpNIA ( LPCSTR str1, LPCSTR str2, int len)
|
|---|
| 84 | {
|
|---|
| 85 | TRACE("%s %s %i stub\n", str1,str2,len);
|
|---|
| 86 | return strncasecmp(str1, str2, len);
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | /*************************************************************************
|
|---|
| 90 | * StrCmpNIW [SHLWAPI]
|
|---|
| 91 | */
|
|---|
| 92 | int WINAPI StrCmpNIW ( LPCWSTR wstr1, LPCWSTR wstr2, int len)
|
|---|
| 93 | {
|
|---|
| 94 | TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
|
|---|
| 95 | return strncmpiW(wstr1, wstr2, len);
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /*************************************************************************
|
|---|
| 99 | * StrCmpW [SHLWAPI]
|
|---|
| 100 | */
|
|---|
| 101 | int WINAPI StrCmpW ( LPCWSTR wstr1, LPCWSTR wstr2 )
|
|---|
| 102 | {
|
|---|
| 103 | TRACE("%s %s\n", debugstr_w(wstr1),debugstr_w(wstr2));
|
|---|
| 104 | return strcmpW( wstr1, wstr2 );
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | /*************************************************************************
|
|---|
| 108 | * StrCatW [SHLWAPI]
|
|---|
| 109 | */
|
|---|
| 110 | LPWSTR WINAPI StrCatW( LPWSTR wstr1, LPCWSTR wstr2 )
|
|---|
| 111 | {
|
|---|
| 112 | return strcatW( wstr1, wstr2 );
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | /*************************************************************************
|
|---|
| 117 | * StrCpyW [SHLWAPI]
|
|---|
| 118 | */
|
|---|
| 119 | LPWSTR WINAPI StrCpyW( LPWSTR wstr1, LPCWSTR wstr2 )
|
|---|
| 120 | {
|
|---|
| 121 | return strcpyW( wstr1, wstr2 );
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | /*************************************************************************
|
|---|
| 126 | * StrCpyNW [SHLWAPI]
|
|---|
| 127 | */
|
|---|
| 128 | LPWSTR WINAPI StrCpyNW( LPWSTR wstr1, LPCWSTR wstr2, int n )
|
|---|
| 129 | {
|
|---|
| 130 | return lstrcpynW( wstr1, wstr2, n );
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | /*************************************************************************
|
|---|
| 135 | * StrStrA [SHLWAPI]
|
|---|
| 136 | */
|
|---|
| 137 | LPSTR WINAPI StrStrA(LPCSTR lpFirst, LPCSTR lpSrch)
|
|---|
| 138 | {
|
|---|
| 139 | while (*lpFirst)
|
|---|
| 140 | {
|
|---|
| 141 | LPCSTR p1 = lpFirst, p2 = lpSrch;
|
|---|
| 142 | while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
|
|---|
| 143 | if (!*p2) return (LPSTR)lpFirst;
|
|---|
| 144 | lpFirst++;
|
|---|
| 145 | }
|
|---|
| 146 | return NULL;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | /*************************************************************************
|
|---|
| 150 | * StrStrW [SHLWAPI]
|
|---|
| 151 | */
|
|---|
| 152 | LPWSTR WINAPI StrStrW(LPCWSTR lpFirst, LPCWSTR lpSrch)
|
|---|
| 153 | {
|
|---|
| 154 | while (*lpFirst)
|
|---|
| 155 | {
|
|---|
| 156 | LPCWSTR p1 = lpFirst, p2 = lpSrch;
|
|---|
| 157 | while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
|
|---|
| 158 | if (!*p2) return (LPWSTR)lpFirst;
|
|---|
| 159 | lpFirst++;
|
|---|
| 160 | }
|
|---|
| 161 | return NULL;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | /*************************************************************************
|
|---|
| 165 | * StrStrIA [SHLWAPI]
|
|---|
| 166 | */
|
|---|
| 167 | LPSTR WINAPI StrStrIA(LPCSTR lpFirst, LPCSTR lpSrch)
|
|---|
| 168 | {
|
|---|
| 169 | while (*lpFirst)
|
|---|
| 170 | {
|
|---|
| 171 | LPCSTR p1 = lpFirst, p2 = lpSrch;
|
|---|
| 172 | while (*p1 && *p2 && toupper(*p1) == toupper(*p2)) { p1++; p2++; }
|
|---|
| 173 | if (!*p2) return (LPSTR)lpFirst;
|
|---|
| 174 | lpFirst++;
|
|---|
| 175 | }
|
|---|
| 176 | return NULL;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | /*************************************************************************
|
|---|
| 180 | * StrStrIW [SHLWAPI]
|
|---|
| 181 | */
|
|---|
| 182 | LPWSTR WINAPI StrStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch)
|
|---|
| 183 | {
|
|---|
| 184 | while (*lpFirst)
|
|---|
| 185 | {
|
|---|
| 186 | LPCWSTR p1 = lpFirst, p2 = lpSrch;
|
|---|
| 187 | while (*p1 && *p2 && toupperW(*p1) == toupperW(*p2)) { p1++; p2++; }
|
|---|
| 188 | if (!*p2) return (LPWSTR)lpFirst;
|
|---|
| 189 | lpFirst++;
|
|---|
| 190 | }
|
|---|
| 191 | return NULL;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | /*************************************************************************
|
|---|
| 195 | * StrToIntA [SHLWAPI]
|
|---|
| 196 | */
|
|---|
| 197 | int WINAPI StrToIntA(LPCSTR lpSrc)
|
|---|
| 198 | {
|
|---|
| 199 | TRACE("%s\n", lpSrc);
|
|---|
| 200 | return atol(lpSrc);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | /*************************************************************************
|
|---|
| 204 | * StrToIntW [SHLWAPI]
|
|---|
| 205 | */
|
|---|
| 206 | int WINAPI StrToIntW(LPCWSTR lpSrc)
|
|---|
| 207 | {
|
|---|
| 208 | char buffer[32];
|
|---|
| 209 |
|
|---|
| 210 | TRACE("%s\n", debugstr_w(lpSrc));
|
|---|
| 211 | WideCharToMultiByte( CP_ACP, 0, lpSrc, -1, buffer, sizeof(buffer), NULL, NULL );
|
|---|
| 212 | buffer[sizeof(buffer)-1] = 0;
|
|---|
| 213 | return atol(buffer);
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | /*************************************************************************
|
|---|
| 217 | * StrToIntExA [SHLWAPI]
|
|---|
| 218 | */
|
|---|
| 219 | BOOL WINAPI StrToIntExA( LPCSTR pszString, DWORD dwFlags, LPINT piRet)
|
|---|
| 220 | {
|
|---|
| 221 | TRACE("%s %ld stub !\n", debugstr_a(pszString), dwFlags);
|
|---|
| 222 | piRet = (LPINT) StrToIntA(pszString);
|
|---|
| 223 | return TRUE;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | /*************************************************************************
|
|---|
| 227 | * StrToIntExW [SHLWAPI]
|
|---|
| 228 | */
|
|---|
| 229 | BOOL WINAPI StrToIntExW( LPCWSTR pszString, DWORD dwFlags, LPINT piRet)
|
|---|
| 230 | {
|
|---|
| 231 | TRACE("%s %ld stub !\n", debugstr_w(pszString), dwFlags);
|
|---|
| 232 | piRet = (LPINT) StrToIntW(pszString);
|
|---|
| 233 | return TRUE;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | /*************************************************************************
|
|---|
| 237 | * StrDupA [SHLWAPI]
|
|---|
| 238 | */
|
|---|
| 239 | LPSTR WINAPI StrDupA (LPCSTR lpSrc)
|
|---|
| 240 | {
|
|---|
| 241 | int len = strlen(lpSrc);
|
|---|
| 242 | LPSTR lpDest = (LPSTR) LocalAlloc(LMEM_FIXED, len+1);
|
|---|
| 243 |
|
|---|
| 244 | TRACE("%s\n", lpSrc);
|
|---|
| 245 |
|
|---|
| 246 | if (lpDest) strcpy(lpDest, lpSrc);
|
|---|
| 247 | return lpDest;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | /*************************************************************************
|
|---|
| 251 | * StrDupW [SHLWAPI]
|
|---|
| 252 | */
|
|---|
| 253 | LPWSTR WINAPI StrDupW (LPCWSTR lpSrc)
|
|---|
| 254 | {
|
|---|
| 255 | int len = strlenW(lpSrc);
|
|---|
| 256 | LPWSTR lpDest = (LPWSTR) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * (len+1));
|
|---|
| 257 |
|
|---|
| 258 | TRACE("%s\n", debugstr_w(lpSrc));
|
|---|
| 259 |
|
|---|
| 260 | if (lpDest) strcpyW(lpDest, lpSrc);
|
|---|
| 261 | return lpDest;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | /*************************************************************************
|
|---|
| 265 | * StrCSpnA [SHLWAPI]
|
|---|
| 266 | */
|
|---|
| 267 | int WINAPI StrCSpnA (LPCSTR lpStr, LPCSTR lpSet)
|
|---|
| 268 | {
|
|---|
| 269 | int i,j, pos = strlen(lpStr);
|
|---|
| 270 |
|
|---|
| 271 | TRACE("(%p %s %p %s)\n",
|
|---|
| 272 | lpStr, debugstr_a(lpStr), lpSet, debugstr_a(lpSet));
|
|---|
| 273 |
|
|---|
| 274 | for (i=0; i < strlen(lpSet) ; i++ )
|
|---|
| 275 | {
|
|---|
| 276 | for (j = 0; j < pos;j++)
|
|---|
| 277 | {
|
|---|
| 278 | if (lpStr[j] == lpSet[i])
|
|---|
| 279 | {
|
|---|
| 280 | pos = j;
|
|---|
| 281 | }
|
|---|
| 282 | }
|
|---|
| 283 | }
|
|---|
| 284 | TRACE("-- %u\n", pos);
|
|---|
| 285 | return pos;
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | /*************************************************************************
|
|---|
| 289 | * StrCSpnW [SHLWAPI]
|
|---|
| 290 | */
|
|---|
| 291 | int WINAPI StrCSpnW (LPCWSTR lpStr, LPCWSTR lpSet)
|
|---|
| 292 | {
|
|---|
| 293 | int i,j, pos = strlenW(lpStr);
|
|---|
| 294 |
|
|---|
| 295 | TRACE("(%p %s %p %s)\n",
|
|---|
| 296 | lpStr, debugstr_w(lpStr), lpSet, debugstr_w(lpSet));
|
|---|
| 297 |
|
|---|
| 298 | for (i=0; i < strlenW(lpSet) ; i++ )
|
|---|
| 299 | {
|
|---|
| 300 | for (j = 0; j < pos;j++)
|
|---|
| 301 | {
|
|---|
| 302 | if (lpStr[j] == lpSet[i])
|
|---|
| 303 | {
|
|---|
| 304 | pos = j;
|
|---|
| 305 | }
|
|---|
| 306 | }
|
|---|
| 307 | }
|
|---|
| 308 | TRACE("-- %u\n", pos);
|
|---|
| 309 | return pos;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /**************************************************************************
|
|---|
| 313 | * StrRChrA [SHLWAPI.@]
|
|---|
| 314 | *
|
|---|
| 315 | */
|
|---|
| 316 | LPSTR WINAPI StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
|
|---|
| 317 | {
|
|---|
| 318 | LPCSTR lpGotIt = NULL;
|
|---|
| 319 | BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
|
|---|
| 320 |
|
|---|
| 321 | TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|---|
| 322 |
|
|---|
| 323 | if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
|
|---|
| 324 |
|
|---|
| 325 | for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
|
|---|
| 326 | {
|
|---|
| 327 | if (*lpStart != LOBYTE(wMatch)) continue;
|
|---|
| 328 | if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
|
|---|
| 329 | lpGotIt = lpStart;
|
|---|
| 330 | }
|
|---|
| 331 | return (LPSTR)lpGotIt;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 | /**************************************************************************
|
|---|
| 336 | * StrRChrW [SHLWAPI.@]
|
|---|
| 337 | *
|
|---|
| 338 | */
|
|---|
| 339 | LPWSTR WINAPI StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
|
|---|
| 340 | {
|
|---|
| 341 | LPCWSTR lpGotIt = NULL;
|
|---|
| 342 |
|
|---|
| 343 | TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
|
|---|
| 344 | if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
|
|---|
| 345 |
|
|---|
| 346 | for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
|
|---|
| 347 | if (*lpStart == wMatch) lpGotIt = lpStart;
|
|---|
| 348 |
|
|---|
| 349 | return (LPWSTR)lpGotIt;
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 | /*************************************************************************
|
|---|
| 354 | * StrCatBuffA [SHLWAPI]
|
|---|
| 355 | *
|
|---|
| 356 | * Appends back onto front, stopping when front is size-1 characters long.
|
|---|
| 357 | * Returns front.
|
|---|
| 358 | *
|
|---|
| 359 | */
|
|---|
| 360 | LPSTR WINAPI StrCatBuffA(LPSTR front, LPCSTR back, INT size)
|
|---|
| 361 | {
|
|---|
| 362 | LPSTR dst = front + strlen(front);
|
|---|
| 363 | LPCSTR src = back, end = front + size - 1;
|
|---|
| 364 |
|
|---|
| 365 | while(dst < end && *src)
|
|---|
| 366 | *dst++ = *src++;
|
|---|
| 367 | *dst = '\0';
|
|---|
| 368 | return front;
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | /*************************************************************************
|
|---|
| 372 | * StrCatBuffW [SHLWAPI]
|
|---|
| 373 | *
|
|---|
| 374 | * Appends back onto front, stopping when front is size-1 characters long.
|
|---|
| 375 | * Returns front.
|
|---|
| 376 | *
|
|---|
| 377 | */
|
|---|
| 378 | LPWSTR WINAPI StrCatBuffW(LPWSTR front, LPCWSTR back, INT size)
|
|---|
| 379 | {
|
|---|
| 380 | LPWSTR dst = front + strlenW(front);
|
|---|
| 381 | LPCWSTR src = back, end = front + size - 1;
|
|---|
| 382 |
|
|---|
| 383 | while(dst < end && *src)
|
|---|
| 384 | *dst++ = *src++;
|
|---|
| 385 | *dst = '\0';
|
|---|
| 386 | return front;
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | /*************************************************************************
|
|---|
| 390 | * StrRetToBufA [SHLWAPI.@]
|
|---|
| 391 | *
|
|---|
| 392 | * converts a STRRET to a normal string
|
|---|
| 393 | *
|
|---|
| 394 | * NOTES
|
|---|
| 395 | * the pidl is for STRRET OFFSET
|
|---|
| 396 | */
|
|---|
| 397 | HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, DWORD len)
|
|---|
| 398 | {
|
|---|
| 399 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
|---|
| 400 |
|
|---|
| 401 | switch (src->uType)
|
|---|
| 402 | {
|
|---|
| 403 | case STRRET_WSTR:
|
|---|
| 404 | WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
|---|
| 405 | /* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|---|
| 406 | break;
|
|---|
| 407 |
|
|---|
| 408 | case STRRET_CSTRA:
|
|---|
| 409 | lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
|---|
| 410 | break;
|
|---|
| 411 |
|
|---|
| 412 | case STRRET_OFFSETA:
|
|---|
| 413 | lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
|---|
| 414 | break;
|
|---|
| 415 |
|
|---|
| 416 | default:
|
|---|
| 417 | FIXME("unknown type!\n");
|
|---|
| 418 | if (len)
|
|---|
| 419 | {
|
|---|
| 420 | *(LPSTR)dest = '\0';
|
|---|
| 421 | }
|
|---|
| 422 | return(FALSE);
|
|---|
| 423 | }
|
|---|
| 424 | return S_OK;
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| 427 | /*************************************************************************
|
|---|
| 428 | * StrRetToBufW [SHLWAPI.@]
|
|---|
| 429 | *
|
|---|
| 430 | * converts a STRRET to a normal string
|
|---|
| 431 | *
|
|---|
| 432 | * NOTES
|
|---|
| 433 | * the pidl is for STRRET OFFSET
|
|---|
| 434 | */
|
|---|
| 435 | HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, DWORD len)
|
|---|
| 436 | {
|
|---|
| 437 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
|---|
| 438 |
|
|---|
| 439 | switch (src->uType)
|
|---|
| 440 | {
|
|---|
| 441 | case STRRET_WSTR:
|
|---|
| 442 | lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
|
|---|
| 443 | /* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|---|
| 444 | break;
|
|---|
| 445 |
|
|---|
| 446 | case STRRET_CSTRA:
|
|---|
| 447 | if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
|
|---|
| 448 | dest[len-1] = 0;
|
|---|
| 449 | break;
|
|---|
| 450 |
|
|---|
| 451 | case STRRET_OFFSETA:
|
|---|
| 452 | if (pidl)
|
|---|
| 453 | {
|
|---|
| 454 | if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
|
|---|
| 455 | dest, len ) && len)
|
|---|
| 456 | dest[len-1] = 0;
|
|---|
| 457 | }
|
|---|
| 458 | break;
|
|---|
| 459 |
|
|---|
| 460 | default:
|
|---|
| 461 | FIXME("unknown type!\n");
|
|---|
| 462 | if (len)
|
|---|
| 463 | { *(LPSTR)dest = '\0';
|
|---|
| 464 | }
|
|---|
| 465 | return(FALSE);
|
|---|
| 466 | }
|
|---|
| 467 | return S_OK;
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | /*************************************************************************
|
|---|
| 471 | * StrFormatByteSizeA [SHLWAPI]
|
|---|
| 472 | */
|
|---|
| 473 | LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
|
|---|
| 474 | { char buf[64];
|
|---|
| 475 | TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
|
|---|
| 476 | if ( dw<1024L )
|
|---|
| 477 | { sprintf (buf,"%ld bytes", dw);
|
|---|
| 478 | }
|
|---|
| 479 | else if ( dw<1048576L)
|
|---|
| 480 | { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
|
|---|
| 481 | }
|
|---|
| 482 | else if ( dw < 1073741824L)
|
|---|
| 483 | { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
|
|---|
| 484 | }
|
|---|
| 485 | else
|
|---|
| 486 | { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
|
|---|
| 487 | }
|
|---|
| 488 | lstrcpynA (pszBuf, buf, cchBuf);
|
|---|
| 489 | return pszBuf;
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | /*************************************************************************
|
|---|
| 493 | * StrFormatByteSizeW [SHLWAPI]
|
|---|
| 494 | */
|
|---|
| 495 | LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
|
|---|
| 496 | {
|
|---|
| 497 | char buf[64];
|
|---|
| 498 | StrFormatByteSizeA( dw, buf, sizeof(buf) );
|
|---|
| 499 | if (!MultiByteToWideChar( CP_ACP, 0, buf, -1, pszBuf, cchBuf ) && cchBuf)
|
|---|
| 500 | pszBuf[cchBuf-1] = 0;
|
|---|
| 501 | return pszBuf;
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | /*************************************************************************
|
|---|
| 505 | * StrNCatA [SHLWAPI]
|
|---|
| 506 | */
|
|---|
| 507 | LPSTR WINAPI StrNCatA(LPSTR front, LPCSTR back, INT cchMax)
|
|---|
| 508 | {
|
|---|
| 509 | TRACE("%s %s %i stub\n", debugstr_a(front),debugstr_a(back),cchMax);
|
|---|
| 510 | return (front);
|
|---|
| 511 | }
|
|---|
| 512 |
|
|---|
| 513 | /*************************************************************************
|
|---|
| 514 | * StrNCatW [SHLWAPI]
|
|---|
| 515 | */
|
|---|
| 516 | LPWSTR WINAPI StrNCatW(LPWSTR front, LPCWSTR back, INT cchMax)
|
|---|
| 517 | {
|
|---|
| 518 | TRACE("%s %s %i stub\n", debugstr_w(front),debugstr_w(back),cchMax);
|
|---|
| 519 | return (front);
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | /*************************************************************************
|
|---|
| 523 | * StrTrimA [SHLWAPI.@]
|
|---|
| 524 | */
|
|---|
| 525 | BOOL WINAPI StrTrimA(LPSTR pszSource, LPCSTR pszTrimChars)
|
|---|
| 526 | {
|
|---|
| 527 | BOOL trimmed = FALSE;
|
|---|
| 528 | LPSTR pSrc;
|
|---|
| 529 | LPCSTR pTrim;
|
|---|
| 530 |
|
|---|
| 531 | TRACE("('%s', '%s');\n", pszSource, pszTrimChars);
|
|---|
| 532 | for (pTrim = pszTrimChars; *pTrim; pTrim++)
|
|---|
| 533 | {
|
|---|
| 534 | for (pSrc = pszSource; *pSrc; pSrc++)
|
|---|
| 535 | if (*pSrc == *pTrim)
|
|---|
| 536 | {
|
|---|
| 537 | /* match -> remove this char.
|
|---|
| 538 | * strlen(pSrc) equiv. to the correct strlen(pSrc+1)+1 */
|
|---|
| 539 | memmove(pSrc, pSrc+1, strlen(pSrc));
|
|---|
| 540 | trimmed = TRUE;
|
|---|
| 541 | }
|
|---|
| 542 | }
|
|---|
| 543 | TRACE("<- '%s'\n", pszSource);
|
|---|
| 544 | return trimmed;
|
|---|
| 545 | }
|
|---|
| 546 |
|
|---|
| 547 | /*************************************************************************
|
|---|
| 548 | * wnsprintfA [SHLWAPI]
|
|---|
| 549 | */
|
|---|
| 550 | int WINAPIV wnsprintfA(LPSTR lpOut, int cchLimitIn, LPCSTR lpFmt, ...)
|
|---|
| 551 | {
|
|---|
| 552 | va_list valist;
|
|---|
| 553 | INT res;
|
|---|
| 554 |
|
|---|
| 555 | va_start( valist, lpFmt );
|
|---|
| 556 | res = wvsnprintfA( lpOut, cchLimitIn, lpFmt, valist );
|
|---|
| 557 | va_end( valist );
|
|---|
| 558 | return res;
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | /*************************************************************************
|
|---|
| 562 | * wnsprintfW [SHLWAPI]
|
|---|
| 563 | */
|
|---|
| 564 | int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt, ...)
|
|---|
| 565 | {
|
|---|
| 566 | va_list valist;
|
|---|
| 567 | INT res;
|
|---|
| 568 |
|
|---|
| 569 | va_start( valist, lpFmt );
|
|---|
| 570 | res = wvsnprintfW( lpOut, cchLimitIn, lpFmt, valist );
|
|---|
| 571 | va_end( valist );
|
|---|
| 572 | return res;
|
|---|
| 573 | }
|
|---|