]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePrintLib/PrintLibInternal.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLibInternal.h
index 32a21266c82b26c035851141eb890e57a7ba46bb..c20a582a441a78f712fdfb4264bc23cec1a0854d 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Base Print Library instance Internal Functions definition.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -19,6 +13,7 @@
 #include <Library/PrintLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 \r
 //\r
@@ -34,6 +29,7 @@
 #define PRECISION             BIT11\r
 #define ARGUMENT_REVERSED     BIT12\r
 #define COUNT_ONLY_NO_PRINT   BIT13\r
+#define UNSIGNED_TYPE         BIT14\r
 \r
 //\r
 // Record date and time information\r
@@ -53,21 +49,21 @@ typedef struct {
 } TIME;\r
 \r
 /**\r
-  Worker function that produces a Null-terminated string in an output buffer \r
+  Worker function that produces a Null-terminated string in an output buffer\r
   based on a Null-terminated format string and a VA_LIST argument list.\r
 \r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
   this is the main print working routine.\r
 \r
   If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r
 \r
-  @param[out] Buffer          The character buffer to print the results of the \r
+  @param[out] Buffer          The character buffer to print the results of the\r
                               parsing of Format into.\r
-  @param[in]  BufferSize      The maximum number of characters to put into \r
+  @param[in]  BufferSize      The maximum number of characters to put into\r
                               buffer.\r
   @param[in]  Flags           Initial flags value.\r
-                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE, \r
+                              Can only have FORMAT_UNICODE, OUTPUT_UNICODE,\r
                               and COUNT_ONLY_NO_PRINT set.\r
   @param[in]  Format          A Null-terminated format string.\r
   @param[in]  VaListMarker    VA_LIST style variable argument list consumed by\r
@@ -91,11 +87,11 @@ BasePrintLibSPrintMarker (
   );\r
 \r
 /**\r
-  Worker function that produces a Null-terminated string in an output buffer \r
+  Worker function that produces a Null-terminated string in an output buffer\r
   based on a Null-terminated format string and variable argument list.\r
 \r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this routine allows the nesting of Vararg routines. Thus \r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
   this is the main print working routine\r
 \r
   @param  StartOfBuffer The character buffer to print the results of the parsing\r
@@ -127,7 +123,7 @@ BasePrintLibSPrint (
 \r
   @param  Buffer      Buffer to place the Unicode or ASCII string.\r
   @param  EndBuffer   The end of the input Buffer. No characters will be\r
-                      placed after that. \r
+                      placed after that.\r
   @param  Length      The count of character to be placed into Buffer.\r
                       (Negative value indicates no buffer fill.)\r
   @param  Character   The character to be placed into Buffer.\r
@@ -159,30 +155,30 @@ BasePrintLibFillBuffer (
 **/\r
 CHAR8 *\r
 BasePrintLibValueToString (\r
-  IN OUT CHAR8  *Buffer, \r
-  IN INT64      Value, \r
+  IN OUT CHAR8  *Buffer,\r
+  IN INT64      Value,\r
   IN UINTN      Radix\r
   );\r
 \r
 /**\r
   Internal function that converts a decimal value to a Null-terminated string.\r
-  \r
-  Converts the decimal number specified by Value to a Null-terminated  \r
+\r
+  Converts the decimal number specified by Value to a Null-terminated\r
   string specified by Buffer containing at most Width characters.\r
   If Width is 0 then a width of  MAXIMUM_VALUE_CHARACTERS is assumed.\r
   The total number of characters placed in Buffer is returned.\r
   If the conversion contains more than Width characters, then only the first\r
-  Width characters are returned, and the total number of characters \r
+  Width characters are returned, and the total number of characters\r
   required to perform the conversion is returned.\r
-  Additional conversion parameters are specified in Flags.  \r
+  Additional conversion parameters are specified in Flags.\r
   The Flags bit LEFT_JUSTIFY is always ignored.\r
   All conversions are left justified in Buffer.\r
   If Width is 0, PREFIX_ZERO is ignored in Flags.\r
   If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
   are inserted every 3rd digit starting from the right.\r
   If Value is < 0, then the fist character in Buffer is a '-'.\r
-  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
-  then Buffer is padded with '0' characters so the combination of the optional '-' \r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
+  then Buffer is padded with '0' characters so the combination of the optional '-'\r
   sign character, '0' characters, digit characters for Value, and the Null-terminator\r
   add up to Width characters.\r
 \r
@@ -198,7 +194,7 @@ BasePrintLibValueToString (
   @param  Width     The maximum number of characters to place in Buffer, not including\r
                     the Null-terminator.\r
   @param  Increment Character increment in Buffer.\r
-  \r
+\r
   @return Total number of characters required to perform the conversion.\r
 \r
 **/\r
@@ -211,4 +207,65 @@ BasePrintLibConvertValueToString (
   IN UINTN       Increment\r
   );\r
 \r
+/**\r
+  Internal function that converts a decimal value to a Null-terminated string.\r
+\r
+  Converts the decimal number specified by Value to a Null-terminated string\r
+  specified by Buffer containing at most Width characters. If Width is 0 then a\r
+  width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more\r
+  than Width characters, then only the first Width characters are placed in\r
+  Buffer. Additional conversion parameters are specified in Flags.\r
+  The Flags bit LEFT_JUSTIFY is always ignored.\r
+  All conversions are left justified in Buffer.\r
+  If Width is 0, PREFIX_ZERO is ignored in Flags.\r
+  If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
+  commas are inserted every 3rd digit starting from the right.\r
+  If Value is < 0, then the fist character in Buffer is a '-'.\r
+  If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
+  then Buffer is padded with '0' characters so the combination of the optional\r
+  '-' sign character, '0' characters, digit characters for Value, and the\r
+  Null-terminator add up to Width characters.\r
+\r
+  If an error would be returned, the function will ASSERT().\r
+\r
+  @param  Buffer      The pointer to the output buffer for the produced\r
+                      Null-terminated string.\r
+  @param  BufferSize  The size of Buffer in bytes, including the\r
+                      Null-terminator.\r
+  @param  Flags       The bitmask of flags that specify left justification,\r
+                      zero pad, and commas.\r
+  @param  Value       The 64-bit signed value to convert to a string.\r
+  @param  Width       The maximum number of characters to place in Buffer,\r
+                      not including the Null-terminator.\r
+  @param  Increment   The character increment in Buffer.\r
+\r
+  @retval RETURN_SUCCESS           The decimal value is converted.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If BufferSize cannot hold the converted\r
+                                   value.\r
+  @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
+                                   If Increment is 1 and\r
+                                   PcdMaximumAsciiStringLength is not zero,\r
+                                   BufferSize is greater than\r
+                                   PcdMaximumAsciiStringLength.\r
+                                   If Increment is not 1 and\r
+                                   PcdMaximumUnicodeStringLength is not zero,\r
+                                   BufferSize is greater than\r
+                                   (PcdMaximumUnicodeStringLength *\r
+                                   sizeof (CHAR16) + 1).\r
+                                   If unsupported bits are set in Flags.\r
+                                   If both COMMA_TYPE and RADIX_HEX are set in\r
+                                   Flags.\r
+                                   If Width >= MAXIMUM_VALUE_CHARACTERS.\r
+\r
+**/\r
+RETURN_STATUS\r
+BasePrintLibConvertValueToStringS (\r
+  IN OUT CHAR8   *Buffer,\r
+  IN UINTN       BufferSize,\r
+  IN UINTN       Flags,\r
+  IN INT64       Value,\r
+  IN UINTN       Width,\r
+  IN UINTN       Increment\r
+  );\r
+\r
 #endif\r