Changeset 6650 for trunk/src/shlwapi/string.c
- Timestamp:
- Sep 5, 2001, 3:54:53 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shlwapi/string.c
r6608 r6650 1 /* $Id: string.c,v 1.5 2001-09-05 13:48:39 bird Exp $ */ 1 2 //Note: Odin changes marked by #ifdef __WIN32OS2__! 2 3 #ifdef __WIN32OS2__ … … 15 16 #endif 16 17 #include <ctype.h> 17 #include <stdlib.h> 18 #include <stdlib.h> 18 19 #include <stdio.h> 19 20 #include <string.h> … … 41 42 42 43 /************************************************************************* 43 * StrChrA 44 * StrChrA [SHLWAPI] 44 45 */ 45 46 LPSTR WINAPI StrChrA (LPCSTR str, WORD c) 46 47 { 47 48 49 } 50 51 /************************************************************************* 52 * StrChrW 48 TRACE("%s %i\n", str,c); 49 return strchr(str, c); 50 } 51 52 /************************************************************************* 53 * StrChrW [SHLWAPI] 53 54 * 54 55 */ 55 56 LPWSTR WINAPI StrChrW (LPCWSTR str, WCHAR x ) 56 57 { 57 58 58 TRACE("%s 0x%04x\n",debugstr_w(str),x); 59 return strchrW(str, x); 59 60 } 60 61 #ifndef __WIN32OS2__ 61 62 /************************************************************************* 62 * StrCmpIW 63 * StrCmpIW [SHLWAPI] 63 64 */ 64 65 int WINAPI StrCmpIW ( LPCWSTR wstr1, LPCWSTR wstr2 ) … … 70 71 71 72 /************************************************************************* 72 * StrCmpNA 73 * StrCmpNA [SHLWAPI] 73 74 */ 74 75 INT WINAPI StrCmpNA ( LPCSTR str1, LPCSTR str2, INT len) 75 76 { 76 77 78 } 79 80 /************************************************************************* 81 * StrCmpNW 77 TRACE("%s %s %i stub\n", str1,str2,len); 78 return strncmp(str1, str2, len); 79 } 80 81 /************************************************************************* 82 * StrCmpNW [SHLWAPI] 82 83 */ 83 84 INT WINAPI StrCmpNW ( LPCWSTR wstr1, LPCWSTR wstr2, INT len) 84 85 { 85 86 87 } 88 89 /************************************************************************* 90 * StrCmpNIA 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] 91 92 */ 92 93 int WINAPI StrCmpNIA ( LPCSTR str1, LPCSTR str2, int len) 93 94 { 94 95 96 } 97 98 /************************************************************************* 99 * StrCmpNIW 95 TRACE("%s %s %i stub\n", str1,str2,len); 96 return strncasecmp(str1, str2, len); 97 } 98 99 /************************************************************************* 100 * StrCmpNIW [SHLWAPI] 100 101 */ 101 102 int WINAPI StrCmpNIW ( LPCWSTR wstr1, LPCWSTR wstr2, int len) 102 103 { 103 104 105 } 106 107 /************************************************************************* 108 * StrCmpW 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] 109 110 */ 110 111 int WINAPI StrCmpW ( LPCWSTR wstr1, LPCWSTR wstr2 ) … … 115 116 116 117 /************************************************************************* 117 * StrCatW 118 * StrCatW [SHLWAPI] 118 119 */ 119 120 LPWSTR WINAPI StrCatW( LPWSTR wstr1, LPCWSTR wstr2 ) … … 124 125 125 126 /************************************************************************* 126 * StrCpyW 127 * StrCpyW [SHLWAPI] 127 128 */ 128 129 LPWSTR WINAPI StrCpyW( LPWSTR wstr1, LPCWSTR wstr2 ) … … 133 134 134 135 /************************************************************************* 135 * StrCpyNW 136 * StrCpyNW [SHLWAPI] 136 137 */ 137 138 LPWSTR WINAPI StrCpyNW( LPWSTR wstr1, LPCWSTR wstr2, int n ) … … 142 143 143 144 /************************************************************************* 144 * StrStrA 145 * StrStrA [SHLWAPI] 145 146 */ 146 147 LPSTR WINAPI StrStrA(LPCSTR lpFirst, LPCSTR lpSrch) … … 157 158 158 159 /************************************************************************* 159 * StrStrW 160 * StrStrW [SHLWAPI] 160 161 */ 161 162 LPWSTR WINAPI StrStrW(LPCWSTR lpFirst, LPCWSTR lpSrch) … … 172 173 173 174 /************************************************************************* 174 * StrStrIA 175 * StrStrIA [SHLWAPI] 175 176 */ 176 177 LPSTR WINAPI StrStrIA(LPCSTR lpFirst, LPCSTR lpSrch) … … 187 188 188 189 /************************************************************************* 189 * StrStrIW 190 * StrStrIW [SHLWAPI] 190 191 */ 191 192 LPWSTR WINAPI StrStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch) … … 202 203 203 204 /************************************************************************* 204 * StrToIntA[SHLWAPI]205 * StrToIntA [SHLWAPI] 205 206 */ 206 207 int WINAPI StrToIntA(LPCSTR lpSrc) 207 208 { 208 209 210 } 211 212 /************************************************************************* 213 * StrToIntW[SHLWAPI]209 TRACE("%s\n", lpSrc); 210 return atol(lpSrc); 211 } 212 213 /************************************************************************* 214 * StrToIntW [SHLWAPI] 214 215 */ 215 216 int WINAPI StrToIntW(LPCWSTR lpSrc) … … 224 225 225 226 /************************************************************************* 226 * StrToIntExA[SHLWAPI]227 * StrToIntExA [SHLWAPI] 227 228 */ 228 229 BOOL WINAPI StrToIntExA( LPCSTR pszString, DWORD dwFlags, LPINT piRet) 229 230 { 230 231 232 233 } 234 235 /************************************************************************* 236 * StrToIntExW[SHLWAPI]231 TRACE("%s %ld stub !\n", debugstr_a(pszString), dwFlags); 232 piRet = (LPINT) StrToIntA(pszString); 233 return TRUE; 234 } 235 236 /************************************************************************* 237 * StrToIntExW [SHLWAPI] 237 238 */ 238 239 BOOL WINAPI StrToIntExW( LPCWSTR pszString, DWORD dwFlags, LPINT piRet) 239 240 { 240 241 242 243 } 244 245 /************************************************************************* 246 * StrDupA[SHLWAPI]241 TRACE("%s %ld stub !\n", debugstr_w(pszString), dwFlags); 242 piRet = (LPINT) StrToIntW(pszString); 243 return TRUE; 244 } 245 246 /************************************************************************* 247 * StrDupA [SHLWAPI] 247 248 */ 248 249 LPSTR WINAPI StrDupA (LPCSTR lpSrc) 249 250 { 250 251 252 253 254 255 256 257 } 258 259 /************************************************************************* 260 * StrDupW[SHLWAPI]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] 261 262 */ 262 263 LPWSTR WINAPI StrDupW (LPCWSTR lpSrc) 263 264 { 264 265 266 267 268 269 270 271 } 272 273 /************************************************************************* 274 * StrCSpnA[SHLWAPI]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] 275 276 */ 276 277 int WINAPI StrCSpnA (LPCSTR lpStr, LPCSTR lpSet) 277 278 { 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 } 293 294 return pos; 295 } 296 297 /************************************************************************* 298 * StrCSpnW[SHLWAPI]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] 299 300 */ 300 301 int WINAPI StrCSpnW (LPCWSTR lpStr, LPCWSTR lpSet) 301 302 { 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 } 317 318 return pos; 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; 319 320 } 320 321 … … 337 338 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue; 338 339 lpGotIt = lpStart; 339 } 340 } 340 341 return (LPSTR)lpGotIt; 341 342 } … … 361 362 362 363 /************************************************************************* 363 * StrCatBuffA[SHLWAPI]364 * StrCatBuffA [SHLWAPI] 364 365 * 365 366 * Appends back onto front, stopping when front is size-1 characters long. … … 379 380 380 381 /************************************************************************* 381 * StrCatBuffW[SHLWAPI]382 * StrCatBuffW [SHLWAPI] 382 383 * 383 384 * Appends back onto front, stopping when front is size-1 characters long. … … 397 398 398 399 /************************************************************************* 399 * StrRetToBufA 400 * 400 * StrRetToBufA [SHLWAPI.@] 401 * 401 402 * converts a STRRET to a normal string 402 403 * … … 406 407 HRESULT WINAPI StrRetToBufA (LPSTRRET src, const ITEMIDLIST *pidl, LPSTR dest, DWORD len) 407 408 { 408 409 410 411 412 413 414 /* 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 } 435 436 /************************************************************************* 437 * StrRetToBufW 438 * 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 * 439 440 * converts a STRRET to a normal string 440 441 * … … 444 445 HRESULT WINAPI StrRetToBufW (LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, DWORD len) 445 446 { 446 447 448 449 450 451 452 /* 453 454 455 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: 456 457 if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len) 457 458 dest[len-1] = 0; 458 459 460 461 462 459 break; 460 461 case STRRET_OFFSETA: 462 if (pidl) 463 { 463 464 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, 464 465 dest, len ) && len) 465 466 dest[len-1] = 0; 466 467 468 469 470 471 472 473 474 475 476 477 } 478 479 /************************************************************************* 480 * StrFormatByteSizeA 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] 481 482 */ 482 483 LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf ) 483 { 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 return pszBuf; 499 } 500 501 /************************************************************************* 502 * StrFormatByteSizeW 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] 503 504 */ 504 505 LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf ) … … 512 513 513 514 /************************************************************************* 514 * StrNCatA 515 * StrNCatA [SHLWAPI] 515 516 */ 516 517 LPSTR WINAPI StrNCatA(LPSTR front, LPCSTR back, INT cchMax) 517 518 { 518 519 520 } 521 522 /************************************************************************* 523 * StrNCatW 519 TRACE("%s %s %i stub\n", debugstr_a(front),debugstr_a(back),cchMax); 520 return (front); 521 } 522 523 /************************************************************************* 524 * StrNCatW [SHLWAPI] 524 525 */ 525 526 LPWSTR WINAPI StrNCatW(LPWSTR front, LPCWSTR back, INT cchMax) 526 527 { 527 528 529 } 530 531 /************************************************************************* 532 * StrTrimA 528 TRACE("%s %s %i stub\n", debugstr_w(front),debugstr_w(back),cchMax); 529 return (front); 530 } 531 532 /************************************************************************* 533 * StrTrimA [SHLWAPI.@] 533 534 */ 534 535 BOOL WINAPI StrTrimA(LPSTR pszSource, LPCSTR pszTrimChars) … … 541 542 for (pTrim = pszTrimChars; *pTrim; pTrim++) 542 543 { 543 544 545 546 547 548 549 550 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 } 551 552 } 552 553 TRACE("<- '%s'\n", pszSource); … … 555 556 556 557 /************************************************************************* 557 * wnsprintfA 558 * wnsprintfA [SHLWAPI] 558 559 */ 559 560 int WINAPIV wnsprintfA(LPSTR lpOut, int cchLimitIn, LPCSTR lpFmt, ...) … … 569 570 570 571 /************************************************************************* 571 * wnsprintfW 572 * wnsprintfW [SHLWAPI] 572 573 */ 573 574 int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt, ...)
Note:
See TracChangeset
for help on using the changeset viewer.