FreeBSD/sys/contrib/dev/acpica/compiler/dtutils.c
/******************************************************************************
 *
 * FUNCTION:    DtStrtoul64
 *
 * PARAMETERS:  String              - Null terminated string
 *              ReturnInteger       - Where the converted integer is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Simple conversion of a string hex integer constant to unsigned
 *              value. Assumes no leading "0x" for the constant.
 *
 * Portability note: The reason this function exists is because a 64-bit
 * sscanf is not available in all environments.
 *
 *****************************************************************************/
DtStrtoul64
PARAMETERS:  String              - Null terminated string
ReturnInteger       - Where the converted integer is returned

Status

Simple conversion of a string hex integer constant to unsigned
value. Assumes no leading "0x" for the constant.

Portability note: The reason this function exists is because a 64-bit
sscanf is not available in all environments.
DtStrtoul64 PARAMETERS : String - Null terminated string ReturnInteger - Where the converted integer is returned Status Simple conversion of a string hex integer constant to unsigned value . Assumes no leading " 0x " for the constant . Portability note : The reason this function exists is because a 64 - bit sscanf is not available in all environments .
ACPI_STATUS
DtStrtoul64 (
    char                    *String,
    UINT64                  *ReturnInteger)
{
    char                    *ThisChar = String;
    UINT32                  ThisDigit;
    UINT64                  ReturnValue = 0;
    int                     DigitCount = 0;
    while ((*ThisChar == ' ') || (*ThisChar == '\t'))
    {
        ThisChar++;
    }
    while ((*ThisChar) == '0')
    {
        ThisChar++;
    }
    while (*ThisChar)
    {
        if (isdigit ((int) *ThisChar))
        {
            ThisDigit = ((UINT8) *ThisChar) - '0';
        }
        else 
        {
            ThisDigit = (UINT32) toupper ((int) *ThisChar);
            if (!isxdigit ((int) ThisDigit))
            {
                return (AE_BAD_CHARACTER);
            }
            ThisDigit = (ThisDigit - 'A') + 10;
        }
        ReturnValue <<= 4;
        ReturnValue += ThisDigit;
        ThisChar++;
        DigitCount++;
        if (DigitCount > 16)
        {
            return (AE_LIMIT);
        }
    }
    *ReturnInteger = ReturnValue;
    return (AE_OK);
}
ACPI_STATUS DtStrtoul64 ( char * String , UINT64 * ReturnInteger ) { char * ThisChar = String ; UINT32 ThisDigit ; UINT64 ReturnValue = 0 ; int DigitCount = 0 ; while ( ( * ThisChar == ' ' ) || ( * ThisChar == ' \t ' ) ) { ThisChar ++ ; } while ( ( * ThisChar ) == ' ' ) { ThisChar ++ ; } while ( * ThisChar ) { if ( isdigit ( ( int ) * ThisChar ) ) { ThisDigit = ( ( UINT8 ) * ThisChar ) - ' ' ; } else { ThisDigit = ( UINT32 ) toupper ( ( int ) * ThisChar ) ; if ( ! isxdigit ( ( int ) ThisDigit ) ) { return ( AE_BAD_CHARACTER ) ; } ThisDigit = ( ThisDigit - ' ' ) + 10 ; } ReturnValue <<= 4 ; ReturnValue += ThisDigit ; ThisChar ++ ; DigitCount ++ ; if ( DigitCount > 16 ) { return ( AE_LIMIT ) ; } } * ReturnInteger = ReturnValue ; return ( AE_OK ) ; }
FUNCTION:    DtStrtoul64
 PARAMETERS:  String              - Null terminated string
              ReturnInteger       - Where the converted integer is returned
FUNCTION : DtStrtoul64 PARAMETERS : String - Null terminated string ReturnInteger - Where the converted integer is returned
/* Skip over any white space in the buffer */ /* Skip leading zeros */ /* Convert character-by-character */ /* Convert ASCII 0-9 to Decimal value */ /* Letter */ /* Not A-F */ /* Convert ASCII Hex char (A-F) to value */ /* Insert the 4-bit hex digit */ /* Value is too large (> 64 bits/8 bytes/16 hex digits) */