Changeset 85836 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
- Timestamp:
- Aug 19, 2020 4:24:34 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r85829 r85836 470 470 } 471 471 472 int ShClConvUtf16CRLFToUtf8LF(P RTUTF16 pwszSrc, size_t cwcSrc,472 int ShClConvUtf16CRLFToUtf8LF(PCRTUTF16 pcwszSrc, size_t cwcSrc, 473 473 char *pszBuf, size_t cbBuf, size_t *pcbLen) 474 474 { 475 AssertPtrReturn(p wszSrc, VERR_INVALID_POINTER);476 AssertReturn (cwcSrc, VERR_INVALID_PARAMETER);477 AssertPtrReturn(pszBuf, VERR_INVALID_POINTER);478 AssertPtrReturn(pcbLen, VERR_INVALID_POINTER);475 AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER); 476 AssertReturn (cwcSrc, VERR_INVALID_PARAMETER); 477 AssertPtrReturn(pszBuf, VERR_INVALID_POINTER); 478 AssertPtrReturn(pcbLen, VERR_INVALID_POINTER); 479 479 480 480 int rc; … … 486 486 487 487 /* How long will the converted text be? */ 488 rc = ShClUtf16CRLFLenUtf8(p wszSrc, cwcSrc, &cchTmp);488 rc = ShClUtf16CRLFLenUtf8(pcwszSrc, cwcSrc, &cchTmp); 489 489 if (RT_SUCCESS(rc)) 490 490 { … … 494 494 if (pwszTmp) 495 495 { 496 rc = ShClConvUtf16CRLFToLF(p wszSrc, cwcSrc, pwszTmp, cchTmp);496 rc = ShClConvUtf16CRLFToLF(pcwszSrc, cwcSrc, pwszTmp, cchTmp); 497 497 if (RT_SUCCESS(rc)) 498 498 rc = RTUtf16ToUtf8Ex(pwszTmp + 1, cchTmp - 1, &pszBuf, cbBuf, &cbLen); … … 516 516 } 517 517 518 int ShClConvUtf16LFToCRLFA( RTUTF16 *pwcSrc, size_t cwcSrc,518 int ShClConvUtf16LFToCRLFA(PCRTUTF16 pcwszSrc, size_t cwcSrc, 519 519 PRTUTF16 *ppwszDst, size_t *pcwDst) 520 520 { 521 AssertPtrReturn(p wcSrc, VERR_INVALID_POINTER);522 AssertReturn(cwcSrc, VERR_INVALID_PARAMETER);521 AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER); 522 AssertReturn(cwcSrc, VERR_INVALID_PARAMETER); 523 523 AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER); 524 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);524 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER); 525 525 526 526 PRTUTF16 pwszDst = NULL; 527 527 size_t cchDst; 528 528 529 int rc = ShClUtf16LFLenUtf8(p wcSrc, cwcSrc, &cchDst);529 int rc = ShClUtf16LFLenUtf8(pcwszSrc, cwcSrc, &cchDst); 530 530 if (RT_SUCCESS(rc)) 531 531 { … … 534 534 if (pwszDst) 535 535 { 536 rc = ShClConvUtf16LFToCRLF(p wcSrc, cwcSrc, pwszDst, cchDst);536 rc = ShClConvUtf16LFToCRLF(pcwszSrc, cwcSrc, pwszDst, cchDst); 537 537 } 538 538 else … … 552 552 } 553 553 554 int ShClConvUtf8LFToUtf16CRLF(const char *pc Src, unsigned cbSrc,554 int ShClConvUtf8LFToUtf16CRLF(const char *pcszSrc, unsigned cbSrc, 555 555 PRTUTF16 *ppwszDst, size_t *pcwDst) 556 556 { 557 AssertPtrReturn(pc Src,VERR_INVALID_POINTER);558 AssertReturn(cbSrc, VERR_INVALID_PARAMETER);557 AssertPtrReturn(pcszSrc, VERR_INVALID_POINTER); 558 AssertReturn(cbSrc, VERR_INVALID_PARAMETER); 559 559 AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER); 560 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);560 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER); 561 561 562 562 /* Intermediate conversion to UTF-16. */ 563 563 size_t cwcTmp; 564 564 PRTUTF16 pwcTmp = NULL; 565 int rc = RTStrToUtf16Ex(pc Src, cbSrc, &pwcTmp, 0, &cwcTmp);565 int rc = RTStrToUtf16Ex(pcszSrc, cbSrc, &pwcTmp, 0, &cwcTmp); 566 566 if (RT_SUCCESS(rc)) 567 567 { … … 574 574 } 575 575 576 int ShClConvLatin1LFToUtf16CRLF(const char *pc Src, unsigned cbSrc,576 int ShClConvLatin1LFToUtf16CRLF(const char *pcszSrc, unsigned cbSrc, 577 577 PRTUTF16 *ppwszDst, size_t *pcwDst) 578 578 { 579 AssertPtrReturn(pc Src,VERR_INVALID_POINTER);580 AssertReturn(cbSrc, VERR_INVALID_PARAMETER);579 AssertPtrReturn(pcszSrc, VERR_INVALID_POINTER); 580 AssertReturn(cbSrc, VERR_INVALID_PARAMETER); 581 581 AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER); 582 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);582 AssertPtrReturn(pcwDst, VERR_INVALID_POINTER); 583 583 584 584 int rc = VINF_SUCCESS; … … 588 588 /* Calculate the space needed. */ 589 589 unsigned cbDst = 0; 590 for (unsigned i = 0; i < cbSrc && pc Src[i] != '\0'; ++i)591 { 592 if (pc Src[i] == VBOX_SHCL_LINEFEED)590 for (unsigned i = 0; i < cbSrc && pcszSrc[i] != '\0'; ++i) 591 { 592 if (pcszSrc[i] == VBOX_SHCL_LINEFEED) 593 593 cbDst += sizeof(RTUTF16); 594 594 else … … 607 607 for (unsigned i = 0, j = 0; i < cbSrc; ++i, ++j) 608 608 { 609 if (pc Src[i] != VBOX_SHCL_LINEFEED)610 pwszDst[j] = pc Src[i];609 if (pcszSrc[i] != VBOX_SHCL_LINEFEED) 610 pwszDst[j] = pcszSrc[i]; 611 611 else 612 612 { … … 632 632 } 633 633 634 int ShClConvUtf16ToUtf8HTML( RTUTF16 *pwcSrc, size_t cwSrc, char **ppszDst, size_t *pcbDst)635 { 636 AssertPtrReturn(p wcSrc,VERR_INVALID_POINTER);637 AssertReturn (cw Src, VERR_INVALID_PARAMETER);638 AssertPtrReturn(ppszDst, VERR_INVALID_POINTER);639 AssertPtrReturn(pcbDst, VERR_INVALID_POINTER);634 int ShClConvUtf16ToUtf8HTML(PCRTUTF16 pcwszSrc, size_t cwcSrc, char **ppszDst, size_t *pcbDst) 635 { 636 AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER); 637 AssertReturn (cwcSrc, VERR_INVALID_PARAMETER); 638 AssertPtrReturn(ppszDst, VERR_INVALID_POINTER); 639 AssertPtrReturn(pcbDst, VERR_INVALID_POINTER); 640 640 641 641 int rc = VINF_SUCCESS; 642 642 643 size_t cwTmp = cwSrc;644 RTUTF16 *pwTmp = pwcSrc;643 size_t cwTmp = cwcSrc; 644 PCRTUTF16 pwTmp = pcwszSrc; 645 645 646 646 char *pchDst = NULL; … … 651 651 { 652 652 /* Find zero symbol (end of string). */ 653 for (; i < cwTmp && p wcSrc[i] != 0; i++)653 for (; i < cwTmp && pcwszSrc[i] != 0; i++) 654 654 ; 655 655 … … 657 657 char *psz = NULL; 658 658 size_t cch = 0; 659 rc = RTUtf16ToUtf8Ex(pwTmp, cwTmp, &psz, pwTmp - p wcSrc, &cch);659 rc = RTUtf16ToUtf8Ex(pwTmp, cwTmp, &psz, pwTmp - pcwszSrc, &cch); 660 660 if (RT_FAILURE(rc)) 661 661 break; … … 678 678 679 679 /* Skip zero symbols. */ 680 for (; i < cwTmp && p wcSrc[i] == 0; i++)680 for (; i < cwTmp && pcwszSrc[i] == 0; i++) 681 681 ; 682 682 … … 780 780 } 781 781 782 int ShClConvUtf16LFToCRLF(PCRTUTF16 pcwszSrc, size_t cw Src, PRTUTF16 pu16Dst, size_t cwDst)782 int ShClConvUtf16LFToCRLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pu16Dst, size_t cwDst) 783 783 { 784 784 AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER); 785 AssertReturn(cw Src,VERR_INVALID_PARAMETER);786 AssertPtrReturn(pu16Dst, VERR_INVALID_POINTER);787 AssertReturn(cwDst, VERR_INVALID_PARAMETER);785 AssertReturn(cwcSrc, VERR_INVALID_PARAMETER); 786 AssertPtrReturn(pu16Dst, VERR_INVALID_POINTER); 787 AssertReturn(cwDst, VERR_INVALID_PARAMETER); 788 788 789 789 AssertMsgReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, … … 796 796 size_t j = 0; 797 797 798 for (; i < cw Src; ++i, ++j)798 for (; i < cwcSrc; ++i, ++j) 799 799 { 800 800 /* Don't copy the null byte, as we add it below. */ … … 857 857 } 858 858 859 int ShClConvUtf16CRLFToLF(PCRTUTF16 pcwszSrc, size_t cw Src, PRTUTF16 pu16Dst, size_t cwDst)859 int ShClConvUtf16CRLFToLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pu16Dst, size_t cwDst) 860 860 { 861 861 AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER); 862 AssertReturn(cw Src,VERR_INVALID_PARAMETER);863 AssertPtrReturn(pu16Dst, VERR_INVALID_POINTER);864 AssertReturn(cwDst, VERR_INVALID_PARAMETER);862 AssertReturn(cwcSrc, VERR_INVALID_PARAMETER); 863 AssertPtrReturn(pu16Dst, VERR_INVALID_POINTER); 864 AssertReturn(cwDst, VERR_INVALID_PARAMETER); 865 865 866 866 AssertMsgReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, … … 879 879 } 880 880 881 for (size_t i = 0; i < cw Src; ++i, ++cwDstPos)881 for (size_t i = 0; i < cwcSrc; ++i, ++cwDstPos) 882 882 { 883 883 if (pcwszSrc[i] == 0) … … 887 887 return VERR_BUFFER_OVERFLOW; 888 888 889 if ( (i + 1 < cw Src)889 if ( (i + 1 < cwcSrc) 890 890 && (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN) 891 891 && (pcwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
Note:
See TracChangeset
for help on using the changeset viewer.