VirtualBox

Ignore:
Timestamp:
Jan 25, 2012 4:26:55 PM (13 years ago)
Author:
vboxsync
Message:

IPRT: Implemented RTStrConvertHexBytes; Added RTManifestEntryQueryAttr and RTManifestQueryAttr.

Location:
trunk/src/VBox/Runtime/common/string
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strtonum.cpp

    r33540 r39877  
    969969RT_EXPORT_SYMBOL(RTStrToInt8);
    970970
     971
     972RTDECL(int) RTStrConvertHexBytes(char const *pszHex, void *pv, size_t cb, uint32_t fFlags)
     973{
     974    AssertPtrReturn(pszHex, VERR_INVALID_POINTER);
     975    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
     976
     977    size_t      cbDst   = cb;
     978    uint8_t    *pbDst   = (uint8_t *)pv;
     979    const char *pszSrc  = pszHex;
     980    for (;;)
     981    {
     982        /* Pick the next two digit from the string. */
     983        char ch = *pszSrc++;
     984        unsigned char uchDigit1 = g_auchDigits[(unsigned char)ch];
     985        if (uchDigit1 >= 16)
     986        {
     987            if (!ch)
     988                return cbDst == 0 ? VINF_SUCCESS : VERR_BUFFER_UNDERFLOW;
     989
     990            while (ch == ' ' || ch == '\t')
     991                ch = *pszSrc++;
     992            return ch ? VWRN_TRAILING_CHARS : VWRN_TRAILING_SPACES;
     993        }
     994
     995        ch = *pszSrc++;
     996        unsigned char uchDigit2 = g_auchDigits[(unsigned char)ch];
     997        if (uchDigit2 >= 16)
     998            return VERR_UNEVEN_INPUT;
     999
     1000        /* Add the byte to the output buffer. */
     1001        if (!cbDst)
     1002            return VERR_BUFFER_OVERFLOW;
     1003        cbDst--;
     1004        *pbDst++ = (uchDigit1 << 4) | uchDigit2;
     1005    }
     1006}
     1007RT_EXPORT_SYMBOL(RTStrConvertHexBytes);
     1008
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