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