]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Add ShellHexStrToUintn to allow for simple conversion of hex numbers.
authorJaben Carsey <jaben.carsey@intel.com>
Fri, 22 Nov 2013 21:37:34 +0000 (21:37 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Nov 2013 21:37:34 +0000 (21:37 +0000)
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

ShellPkg/Include/Library/ShellLib.h
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index eefa030ad12cc7cf50e57021dac5be3aed35ba72..4a79acdd57852b86f6b46075842183682a6ccba1 100644 (file)
@@ -1007,6 +1007,23 @@ ShellStrToUintn(
   IN CONST CHAR16 *String\r
   );\r
 \r
+/**\r
+  Function return the number converted from a hex representation of a number.\r
+\r
+  Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
+  result.  Use ShellConvertStringToUint64 instead.\r
+\r
+  @param[in] String   String representation of a number.\r
+\r
+  @return             The unsigned integer result of the conversion.\r
+  @retval (UINTN)(-1) An error occured.\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellHexStrToUintn(\r
+  IN CONST CHAR16 *String\r
+  );\r
+\r
 /**\r
   Safely append with automatic string resizing given length of Destination and\r
   desired length of copy from Source.\r
index a0a7da87daec09f3d4d352a9ca6f965cc6fe384b..40b87fec34e99ece7ad32cb7f32db0fdcb7114a8 100644 (file)
@@ -3056,6 +3056,32 @@ ShellIsFileInPath(
   return (Status);\r
 }\r
 \r
+/**\r
+  Function return the number converted from a hex representation of a number.\r
+\r
+  Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
+  result.  Use ShellConvertStringToUint64 instead.\r
+\r
+  @param[in] String   String representation of a number.\r
+\r
+  @return             The unsigned integer result of the conversion.\r
+  @retval (UINTN)(-1) An error occured.\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellHexStrToUintn(\r
+  IN CONST CHAR16 *String\r
+  )\r
+{\r
+  UINT64        RetVal;\r
+\r
+  if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, TRUE, TRUE))) {\r
+    return ((UINTN)RetVal);\r
+  }\r
+  \r
+  return ((UINTN)(-1));\r
+}\r
+\r
 /**\r
   Function to determine whether a string is decimal or hex representation of a number\r
   and return the number converted from the string.  Spaces are always skipped.\r