ShellPkg: Add ShellHexStrToUintn to allow for simple conversion of hex numbers.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14893 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1007,6 +1007,23 @@ ShellStrToUintn(
|
|||||||
IN CONST CHAR16 *String
|
IN CONST CHAR16 *String
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function return the number converted from a hex representation of a number.
|
||||||
|
|
||||||
|
Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
|
||||||
|
result. Use ShellConvertStringToUint64 instead.
|
||||||
|
|
||||||
|
@param[in] String String representation of a number.
|
||||||
|
|
||||||
|
@return The unsigned integer result of the conversion.
|
||||||
|
@retval (UINTN)(-1) An error occured.
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ShellHexStrToUintn(
|
||||||
|
IN CONST CHAR16 *String
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Safely append with automatic string resizing given length of Destination and
|
Safely append with automatic string resizing given length of Destination and
|
||||||
desired length of copy from Source.
|
desired length of copy from Source.
|
||||||
|
@ -3056,6 +3056,32 @@ ShellIsFileInPath(
|
|||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function return the number converted from a hex representation of a number.
|
||||||
|
|
||||||
|
Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
|
||||||
|
result. Use ShellConvertStringToUint64 instead.
|
||||||
|
|
||||||
|
@param[in] String String representation of a number.
|
||||||
|
|
||||||
|
@return The unsigned integer result of the conversion.
|
||||||
|
@retval (UINTN)(-1) An error occured.
|
||||||
|
**/
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
ShellHexStrToUintn(
|
||||||
|
IN CONST CHAR16 *String
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 RetVal;
|
||||||
|
|
||||||
|
if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, TRUE, TRUE))) {
|
||||||
|
return ((UINTN)RetVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((UINTN)(-1));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function to determine whether a string is decimal or hex representation of a number
|
Function to determine whether a string is decimal or hex representation of a number
|
||||||
and return the number converted from the string. Spaces are always skipped.
|
and return the number converted from the string. Spaces are always skipped.
|
||||||
|
Reference in New Issue
Block a user