VirtualBox

Ignore:
Timestamp:
Nov 29, 2019 11:42:20 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135103
Message:

Shared Clipboard: Resolved some more @todos.

Location:
trunk/src/VBox/GuestHost/SharedClipboard
Files:
2 edited

Legend:

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

    r81444 r82279  
    464464/** @todo convert the remainder of the Assert stuff to AssertLogRel. */
    465465    /* We only take little endian Utf16 */
    466     if (pwszSrc[0] == UTF16BEMARKER)
    467     {
    468         LogRel(("vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
    469         AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
     466    if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
     467    {
     468        LogRel(("Shared Clipboard: vboxClipboardUtf16GetWinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
     469        AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
    470470    }
    471471    cwDest = 0;
    472472    /* Calculate the size of the destination text string. */
    473473    /* Is this Utf16 or Utf16-LE? */
    474     for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest)
     474    for (i = (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0); i < cwSrc; ++i, ++cwDest)
    475475    {
    476476        /* Check for a single line feed */
    477         if (pwszSrc[i] == LINEFEED)
     477        if (pwszSrc[i] == VBOX_SHCL_LINEFEED)
    478478            ++cwDest;
    479479#ifdef RT_OS_DARWIN
    480480        /* Check for a single carriage return (MacOS) */
    481         if (pwszSrc[i] == CARRIAGERETURN)
     481        if (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
    482482            ++cwDest;
    483483#endif
     
    501501    if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest))
    502502    {
    503         LogRel(("vboxClipboardUtf16LinToWin: received an invalid pointer, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));
     503        LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n"));
    504504        AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
    505505    }
     
    516516    }
    517517    /* We only take little endian Utf16 */
    518     if (pwszSrc[0] == UTF16BEMARKER)
    519     {
    520         LogRel(("vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
    521         AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
     518    if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
     519    {
     520        LogRel(("Shared Clipboard: vboxClipboardUtf16LinToWin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
     521        AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
    522522    }
    523523    /* Don't copy the endian marker. */
    524     for (i = (pwszSrc[0] == UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j)
     524    for (i = (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER ? 1 : 0), j = 0; i < cwSrc; ++i, ++j)
    525525    {
    526526        /* Don't copy the null byte, as we add it below. */
     
    532532            return VERR_BUFFER_OVERFLOW;
    533533        }
    534         if (pwszSrc[i] == LINEFEED)
    535         {
    536             pu16Dest[j] = CARRIAGERETURN;
     534        if (pwszSrc[i] == VBOX_SHCL_LINEFEED)
     535        {
     536            pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN;
    537537            ++j;
    538538            if (j == cwDest)
     
    544544#ifdef RT_OS_DARWIN
    545545        /* Check for a single carriage return (MacOS) */
    546         else if (pwszSrc[i] == CARRIAGERETURN)
     546        else if (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
    547547        {
    548548            /* set cr */
    549             pu16Dest[j] = CARRIAGERETURN;
     549            pu16Dest[j] = VBOX_SHCL_CARRIAGERETURN;
    550550            ++j;
    551551            if (j == cwDest)
     
    555555            }
    556556            /* add the lf */
    557             pu16Dest[j] = LINEFEED;
     557            pu16Dest[j] = VBOX_SHCL_LINEFEED;
    558558            continue;
    559559        }
     
    579579    if (!VALID_PTR(pwszSrc))
    580580    {
    581         LogRel(("vboxClipboardUtf16GetLinSize: received an invalid Utf16 string %p.  Returning VERR_INVALID_PARAMETER.\n", pwszSrc));
     581        LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received an invalid Utf16 string, returning VERR_INVALID_PARAMETER\n"));
    582582        AssertReturn(VALID_PTR(pwszSrc), VERR_INVALID_PARAMETER);
    583583    }
     
    589589    }
    590590    /* We only take little endian Utf16 */
    591     if (pwszSrc[0] == UTF16BEMARKER)
    592     {
    593         LogRel(("vboxClipboardUtf16GetLinSize: received a big endian Utf16 string.  Returning VERR_INVALID_PARAMETER.\n"));
    594         AssertReturn(pwszSrc[0] != UTF16BEMARKER, VERR_INVALID_PARAMETER);
     591    if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
     592    {
     593        LogRel(("Shared Clipboard: vboxClipboardUtf16GetLinSize: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
     594        AssertReturn(pwszSrc[0] != VBOX_SHCL_UTF16BEMARKER, VERR_INVALID_PARAMETER);
    595595    }
    596596    /* Calculate the size of the destination text string. */
    597597    /* Is this Utf16 or Utf16-LE? */
    598     if (pwszSrc[0] == UTF16LEMARKER)
     598    if (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER)
    599599        cwDest = 0;
    600600    else
     
    603603    {
    604604        if (   (i + 1 < cwSrc)
    605             && (pwszSrc[i] == CARRIAGERETURN)
    606             && (pwszSrc[i + 1] == LINEFEED))
     605            && (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
     606            && (pwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
    607607        {
    608608            ++i;
     
    630630    if (!VALID_PTR(pwszSrc) || !VALID_PTR(pu16Dest))
    631631    {
    632         LogRel(("vboxClipboardUtf16WinToLin: received an invalid ptr, pwszSrc=%p, pu16Dest=%p, returning VERR_INVALID_PARAMETER\n", pwszSrc, pu16Dest));
     632        LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received an invalid pointer, returning VERR_INVALID_PARAMETER\n"));
    633633        AssertReturn(VALID_PTR(pwszSrc) && VALID_PTR(pu16Dest), VERR_INVALID_PARAMETER);
    634634    }
    635635    /* We only take little endian Utf16 */
    636     if (pwszSrc[0] == UTF16BEMARKER)
    637     {
    638         LogRel(("vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
     636    if (pwszSrc[0] == VBOX_SHCL_UTF16BEMARKER)
     637    {
     638        LogRel(("Shared Clipboard: vboxClipboardUtf16WinToLin: received a big endian Utf16 string, returning VERR_INVALID_PARAMETER\n"));
    639639        AssertMsgFailedReturn(("received a big endian string\n"), VERR_INVALID_PARAMETER);
    640640    }
     
    651651    }
    652652    /* Prepend the Utf16 byte order marker if it is missing. */
    653     if (pwszSrc[0] == UTF16LEMARKER)
     653    if (pwszSrc[0] == VBOX_SHCL_UTF16LEMARKER)
    654654    {
    655655        cwDestPos = 0;
     
    657657    else
    658658    {
    659         pu16Dest[0] = UTF16LEMARKER;
     659        pu16Dest[0] = VBOX_SHCL_UTF16LEMARKER;
    660660        cwDestPos = 1;
    661661    }
     
    672672        }
    673673        if (   (i + 1 < cwSrc)
    674             && (pwszSrc[i] == CARRIAGERETURN)
    675             && (pwszSrc[i + 1] == LINEFEED))
     674            && (pwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
     675            && (pwszSrc[i + 1] == VBOX_SHCL_LINEFEED))
    676676        {
    677677            ++i;
     
    704704    /** @todo Support all the many versions of the DIB headers. */
    705705    if (   cbSrc < sizeof(BMINFOHEADER)
    706         || RT_LE2H_U32(pBitmapInfoHeader->u32Size) < sizeof(BMINFOHEADER)
    707         || RT_LE2H_U32(pBitmapInfoHeader->u32Size) != sizeof(BMINFOHEADER))
    708     {
    709         Log(("vboxClipboardDibToBmp: invalid or unsupported bitmap data.\n"));
     706        || RT_LE2H_U32(pBitmapInfoHeader->uSize) < sizeof(BMINFOHEADER)
     707        || RT_LE2H_U32(pBitmapInfoHeader->uSize) != sizeof(BMINFOHEADER))
     708    {
     709        Log(("vboxClipboardDibToBmp: invalid or unsupported bitmap data\n"));
    710710        return VERR_INVALID_PARAMETER;
    711711    }
    712712
    713713    offPixel = sizeof(BMFILEHEADER)
    714                 + RT_LE2H_U32(pBitmapInfoHeader->u32Size)
    715                 + RT_LE2H_U32(pBitmapInfoHeader->u32ClrUsed) * sizeof(uint32_t);
     714                + RT_LE2H_U32(pBitmapInfoHeader->uSize)
     715                + RT_LE2H_U32(pBitmapInfoHeader->uClrUsed) * sizeof(uint32_t);
    716716    if (cbSrc < offPixel)
    717717    {
    718         Log(("vboxClipboardDibToBmp: invalid bitmap data.\n"));
     718        Log(("vboxClipboardDibToBmp: invalid bitmap data\n"));
    719719        return VERR_INVALID_PARAMETER;
    720720    }
     
    723723    if (!pvDest)
    724724    {
    725         Log(("writeToPasteboard: cannot allocate memory for bitmap.\n"));
     725        Log(("writeToPasteboard: cannot allocate memory for bitmap\n"));
    726726        return VERR_NO_MEMORY;
    727727    }
    728728
    729729    pFileHeader = (PBMFILEHEADER)pvDest;
    730     pFileHeader->u16Type        = BITMAPHEADERMAGIC;
    731     pFileHeader->u32Size        = (uint32_t)RT_H2LE_U32(cb);
    732     pFileHeader->u16Reserved1   = pFileHeader->u16Reserved2 = 0;
    733     pFileHeader->u32OffBits     = (uint32_t)RT_H2LE_U32(offPixel);
     730    pFileHeader->uType        = BITMAPHEADERMAGIC;
     731    pFileHeader->uSize        = (uint32_t)RT_H2LE_U32(cb);
     732    pFileHeader->uReserved1   = pFileHeader->uReserved2 = 0;
     733    pFileHeader->uOffBits     = (uint32_t)RT_H2LE_U32(offPixel);
    734734    memcpy((uint8_t *)pvDest + sizeof(BMFILEHEADER), pvSrc, cbSrc);
    735735    *ppvDest = pvDest;
     
    746746    PBMFILEHEADER pFileHeader = (PBMFILEHEADER)pvSrc;
    747747    if (   cbSrc < sizeof(BMFILEHEADER)
    748         || pFileHeader->u16Type != BITMAPHEADERMAGIC
    749         || RT_LE2H_U32(pFileHeader->u32Size) != cbSrc)
    750     {
    751         Log(("vboxClipboardBmpGetDib: invalid bitmap data.\n"));
     748        || pFileHeader->uType != BITMAPHEADERMAGIC
     749        || RT_LE2H_U32(pFileHeader->uSize) != cbSrc)
     750    {
     751        Log(("vboxClipboardBmpGetDib: invalid bitmap data\n"));
    752752        return VERR_INVALID_PARAMETER;
    753753    }
     
    787787}
    788788
    789 void ShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT u32Format)
    790 {
    791     if (u32Format & VBOX_SHCL_FMT_UNICODETEXT)
     789void ShClDbgDumpData(const void *pv, size_t cb, SHCLFORMAT uFormat)
     790{
     791    if (uFormat & VBOX_SHCL_FMT_UNICODETEXT)
    792792    {
    793793        LogFunc(("VBOX_SHCL_FMT_UNICODETEXT:\n"));
     
    797797            LogFunc(("%p %zu\n", pv, cb));
    798798    }
    799     else if (u32Format & VBOX_SHCL_FMT_BITMAP)
     799    else if (uFormat & VBOX_SHCL_FMT_BITMAP)
    800800        LogFunc(("VBOX_SHCL_FMT_BITMAP\n"));
    801     else if (u32Format & VBOX_SHCL_FMT_HTML)
     801    else if (uFormat & VBOX_SHCL_FMT_HTML)
    802802    {
    803803        LogFunc(("VBOX_SHCL_FMT_HTML:\n"));
     
    822822    }
    823823    else
    824         LogFunc(("Invalid format %02X\n", u32Format));
     824        LogFunc(("Invalid format %02X\n", uFormat));
    825825}
    826826#endif /* LOG_ENABLED */
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r82266 r82279  
    18541854    for (unsigned i = 0; i < cbSrc && pcSrc[i] != '\0'; ++i)
    18551855    {
    1856         if (pcSrc[i] == LINEFEED)
     1856        if (pcSrc[i] == VBOX_SHCL_LINEFEED)
    18571857            cwcDest += 2;
    18581858        else
     
    18751875        for (unsigned i = 0, j = 0; i < cbSrc; ++i, ++j)
    18761876        {
    1877             if (pcSrc[i] != LINEFEED)
     1877            if (pcSrc[i] != VBOX_SHCL_LINEFEED)
    18781878                pwszDest[j] = pcSrc[i];
    18791879            else
    18801880            {
    1881                 pwszDest[j] = CARRIAGERETURN;
    1882                 pwszDest[j + 1] = LINEFEED;
     1881                pwszDest[j] = VBOX_SHCL_CARRIAGERETURN;
     1882                pwszDest[j + 1] = VBOX_SHCL_LINEFEED;
    18831883                ++j;
    18841884            }
Note: See TracChangeset for help on using the changeset viewer.

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