VirtualBox

Ignore:
Timestamp:
Aug 19, 2020 4:24:34 PM (4 years ago)
Author:
vboxsync
Message:

Shared Clipboard: Doxygen fixes, make more use of PCRTUTF16 for source arguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r85829 r85836  
    470470}
    471471
    472 int ShClConvUtf16CRLFToUtf8LF(PRTUTF16 pwszSrc, size_t cwcSrc,
     472int ShClConvUtf16CRLFToUtf8LF(PCRTUTF16 pcwszSrc, size_t cwcSrc,
    473473                              char *pszBuf, size_t cbBuf, size_t *pcbLen)
    474474{
    475     AssertPtrReturn(pwszSrc, 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);
    479479
    480480    int rc;
     
    486486
    487487    /* How long will the converted text be? */
    488     rc = ShClUtf16CRLFLenUtf8(pwszSrc, cwcSrc, &cchTmp);
     488    rc = ShClUtf16CRLFLenUtf8(pcwszSrc, cwcSrc, &cchTmp);
    489489    if (RT_SUCCESS(rc))
    490490    {
     
    494494            if (pwszTmp)
    495495            {
    496                 rc = ShClConvUtf16CRLFToLF(pwszSrc, cwcSrc, pwszTmp, cchTmp);
     496                rc = ShClConvUtf16CRLFToLF(pcwszSrc, cwcSrc, pwszTmp, cchTmp);
    497497                if (RT_SUCCESS(rc))
    498498                    rc = RTUtf16ToUtf8Ex(pwszTmp + 1, cchTmp - 1, &pszBuf, cbBuf, &cbLen);
     
    516516}
    517517
    518 int ShClConvUtf16LFToCRLFA(RTUTF16 *pwcSrc, size_t cwcSrc,
     518int ShClConvUtf16LFToCRLFA(PCRTUTF16 pcwszSrc, size_t cwcSrc,
    519519                           PRTUTF16 *ppwszDst, size_t *pcwDst)
    520520{
    521     AssertPtrReturn(pwcSrc, VERR_INVALID_POINTER);
    522     AssertReturn(cwcSrc, VERR_INVALID_PARAMETER);
     521    AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER);
     522    AssertReturn(cwcSrc,      VERR_INVALID_PARAMETER);
    523523    AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER);
    524     AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);
     524    AssertPtrReturn(pcwDst,   VERR_INVALID_POINTER);
    525525
    526526    PRTUTF16 pwszDst = NULL;
    527527    size_t   cchDst;
    528528
    529     int rc = ShClUtf16LFLenUtf8(pwcSrc, cwcSrc, &cchDst);
     529    int rc = ShClUtf16LFLenUtf8(pcwszSrc, cwcSrc, &cchDst);
    530530    if (RT_SUCCESS(rc))
    531531    {
     
    534534        if (pwszDst)
    535535        {
    536             rc = ShClConvUtf16LFToCRLF(pwcSrc, cwcSrc, pwszDst, cchDst);
     536            rc = ShClConvUtf16LFToCRLF(pcwszSrc, cwcSrc, pwszDst, cchDst);
    537537        }
    538538        else
     
    552552}
    553553
    554 int ShClConvUtf8LFToUtf16CRLF(const char *pcSrc, unsigned cbSrc,
     554int ShClConvUtf8LFToUtf16CRLF(const char *pcszSrc, unsigned cbSrc,
    555555                              PRTUTF16 *ppwszDst, size_t *pcwDst)
    556556{
    557     AssertPtrReturn(pcSrc, VERR_INVALID_POINTER);
    558     AssertReturn(cbSrc, VERR_INVALID_PARAMETER);
     557    AssertPtrReturn(pcszSrc, VERR_INVALID_POINTER);
     558    AssertReturn(cbSrc,       VERR_INVALID_PARAMETER);
    559559    AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER);
    560     AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);
     560    AssertPtrReturn(pcwDst,   VERR_INVALID_POINTER);
    561561
    562562    /* Intermediate conversion to UTF-16. */
    563563    size_t   cwcTmp;
    564564    PRTUTF16 pwcTmp = NULL;
    565     int rc = RTStrToUtf16Ex(pcSrc, cbSrc, &pwcTmp, 0, &cwcTmp);
     565    int rc = RTStrToUtf16Ex(pcszSrc, cbSrc, &pwcTmp, 0, &cwcTmp);
    566566    if (RT_SUCCESS(rc))
    567567    {
     
    574574}
    575575
    576 int ShClConvLatin1LFToUtf16CRLF(const char *pcSrc, unsigned cbSrc,
     576int ShClConvLatin1LFToUtf16CRLF(const char *pcszSrc, unsigned cbSrc,
    577577                                PRTUTF16 *ppwszDst, size_t *pcwDst)
    578578{
    579     AssertPtrReturn(pcSrc, VERR_INVALID_POINTER);
    580     AssertReturn(cbSrc, VERR_INVALID_PARAMETER);
     579    AssertPtrReturn(pcszSrc, VERR_INVALID_POINTER);
     580    AssertReturn(cbSrc,       VERR_INVALID_PARAMETER);
    581581    AssertPtrReturn(ppwszDst, VERR_INVALID_POINTER);
    582     AssertPtrReturn(pcwDst, VERR_INVALID_POINTER);
     582    AssertPtrReturn(pcwDst,   VERR_INVALID_POINTER);
    583583
    584584    int rc = VINF_SUCCESS;
     
    588588    /* Calculate the space needed. */
    589589    unsigned cbDst = 0;
    590     for (unsigned i = 0; i < cbSrc && pcSrc[i] != '\0'; ++i)
    591     {
    592         if (pcSrc[i] == VBOX_SHCL_LINEFEED)
     590    for (unsigned i = 0; i < cbSrc && pcszSrc[i] != '\0'; ++i)
     591    {
     592        if (pcszSrc[i] == VBOX_SHCL_LINEFEED)
    593593            cbDst += sizeof(RTUTF16);
    594594        else
     
    607607        for (unsigned i = 0, j = 0; i < cbSrc; ++i, ++j)
    608608        {
    609             if (pcSrc[i] != VBOX_SHCL_LINEFEED)
    610                 pwszDst[j] = pcSrc[i];
     609            if (pcszSrc[i] != VBOX_SHCL_LINEFEED)
     610                pwszDst[j] = pcszSrc[i];
    611611            else
    612612            {
     
    632632}
    633633
    634 int ShClConvUtf16ToUtf8HTML(RTUTF16 *pwcSrc, size_t cwSrc, char **ppszDst, size_t *pcbDst)
    635 {
    636     AssertPtrReturn(pwcSrc, VERR_INVALID_POINTER);
    637     AssertReturn   (cwSrc,   VERR_INVALID_PARAMETER);
    638     AssertPtrReturn(ppszDst, VERR_INVALID_POINTER);
    639     AssertPtrReturn(pcbDst,  VERR_INVALID_POINTER);
     634int 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);
    640640
    641641    int rc = VINF_SUCCESS;
    642642
    643     size_t   cwTmp = cwSrc;
    644     RTUTF16 *pwTmp = pwcSrc;
     643    size_t    cwTmp = cwcSrc;
     644    PCRTUTF16 pwTmp = pcwszSrc;
    645645
    646646    char  *pchDst = NULL;
     
    651651    {
    652652        /* Find  zero symbol (end of string). */
    653         for (; i < cwTmp && pwcSrc[i] != 0; i++)
     653        for (; i < cwTmp && pcwszSrc[i] != 0; i++)
    654654            ;
    655655
     
    657657        char  *psz = NULL;
    658658        size_t cch = 0;
    659         rc = RTUtf16ToUtf8Ex(pwTmp, cwTmp, &psz, pwTmp - pwcSrc, &cch);
     659        rc = RTUtf16ToUtf8Ex(pwTmp, cwTmp, &psz, pwTmp - pcwszSrc, &cch);
    660660        if (RT_FAILURE(rc))
    661661            break;
     
    678678
    679679        /* Skip zero symbols. */
    680         for (; i < cwTmp && pwcSrc[i] == 0; i++)
     680        for (; i < cwTmp && pcwszSrc[i] == 0; i++)
    681681            ;
    682682
     
    780780}
    781781
    782 int ShClConvUtf16LFToCRLF(PCRTUTF16 pcwszSrc, size_t cwSrc, PRTUTF16 pu16Dst, size_t cwDst)
     782int ShClConvUtf16LFToCRLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pu16Dst, size_t cwDst)
    783783{
    784784    AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER);
    785     AssertReturn(cwSrc, 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);
    788788
    789789    AssertMsgReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER,
     
    796796    size_t j = 0;
    797797
    798     for (; i < cwSrc; ++i, ++j)
     798    for (; i < cwcSrc; ++i, ++j)
    799799    {
    800800        /* Don't copy the null byte, as we add it below. */
     
    857857}
    858858
    859 int ShClConvUtf16CRLFToLF(PCRTUTF16 pcwszSrc, size_t cwSrc, PRTUTF16 pu16Dst, size_t cwDst)
     859int ShClConvUtf16CRLFToLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pu16Dst, size_t cwDst)
    860860{
    861861    AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER);
    862     AssertReturn(cwSrc, 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);
    865865
    866866    AssertMsgReturn(pcwszSrc[0] != VBOX_SHCL_UTF16BEMARKER,
     
    879879    }
    880880
    881     for (size_t i = 0; i < cwSrc; ++i, ++cwDstPos)
     881    for (size_t i = 0; i < cwcSrc; ++i, ++cwDstPos)
    882882    {
    883883        if (pcwszSrc[i] == 0)
     
    887887            return VERR_BUFFER_OVERFLOW;
    888888
    889         if (   (i + 1 < cwSrc)
     889        if (   (i + 1 < cwcSrc)
    890890            && (pcwszSrc[i]     == VBOX_SHCL_CARRIAGERETURN)
    891891            && (pcwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette