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