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