Revision: 14893
          http://sourceforge.net/p/edk2/code/14893
Author:   jcarsey
Date:     2013-11-22 21:37:34 +0000 (Fri, 22 Nov 2013)
Log Message:
-----------
ShellPkg: Add ShellHexStrToUintn to allow for simple conversion of hex numbers.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Erik Bjorge <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Include/Library/ShellLib.h
    trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c

Modified: trunk/edk2/ShellPkg/Include/Library/ShellLib.h
===================================================================
--- trunk/edk2/ShellPkg/Include/Library/ShellLib.h      2013-11-22 21:17:25 UTC 
(rev 14892)
+++ trunk/edk2/ShellPkg/Include/Library/ShellLib.h      2013-11-22 21:37:34 UTC 
(rev 14893)
@@ -1008,6 +1008,23 @@
   );
 
 /**
+  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
   desired length of copy from Source.
 

Modified: trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2013-11-22 
21:17:25 UTC (rev 14892)
+++ trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2013-11-22 
21:37:34 UTC (rev 14893)
@@ -3057,6 +3057,32 @@
 }
 
 /**
+  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
   and return the number converted from the string.  Spaces are always skipped.
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to