From nobody Sat Nov 2 16:30:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1486620179236781.3908799977744; Wed, 8 Feb 2017 22:02:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DEF9F82095; Wed, 8 Feb 2017 22:02:57 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 07C2781FB0 for ; Wed, 8 Feb 2017 22:02:56 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 08 Feb 2017 22:02:56 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by orsmga001.jf.intel.com with ESMTP; 08 Feb 2017 22:02:54 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,349,1484035200"; d="scan'208";a="1092615574" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 9 Feb 2017 14:02:47 +0800 Message-Id: <1486620170-38136-2-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1486620170-38136-1-git-send-email-hao.a.wu@intel.com> References: <1486620170-38136-1-git-send-email-hao.a.wu@intel.com> Subject: [edk2] [PATCH v2 1/4] MdePkg/BasePrintLib: Add safe print functions [A|U]ValueToStringS X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Michael Kinney , Jiewen Yao , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the following 2 APIs: UnicodeValueToStringS AsciiValueToStringS These safe version APIs are used to enhance their counterpart (APIs without trailing 'S' in function names). They perform checks to the input parameters and will return relative status to reflect the check result. Return RETURN_INVALID_PARAMETER when: 1). The input Buffer is NULL. 2). The input BufferSize is greater than (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1) for UnicodeValueToStringS or greater than PcdMaximumAsciiStringLength for AsciiValueToStringS. 3). The input Flags is not set properly. 4). The input Width is not smaller than MAXIMUM_VALUE_CHARACTERS. Return RETURN_BUFFER_TOO_SMALL when: 1). The input BufferSize cannot hold the converted value. Cc: Jiewen Yao Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdePkg/Include/Library/PrintLib.h | 121 ++++++++++++ MdePkg/Library/BasePrintLib/PrintLib.c | 128 ++++++++++++ MdePkg/Library/BasePrintLib/PrintLibInternal.c | 204 ++++++++++++++++++++ MdePkg/Library/BasePrintLib/PrintLibInternal.h | 61 ++++++ 4 files changed, 514 insertions(+) diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/Pri= ntLib.h index 5f66323..8c11dab 100644 --- a/MdePkg/Include/Library/PrintLib.h +++ b/MdePkg/Include/Library/PrintLib.h @@ -542,6 +542,67 @@ UnicodeValueToString ( ); =20 /** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unic= ode + string specified by Buffer containing at most Width characters. No paddi= ng of + spaces is ever performed. If Width is 0 then a width of + MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than + Width characters, then only the first Width characters are placed in Buf= fer. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If RADIX_HEX is set in Flags, then the output buffer will be formatted in + hexadecimal format. + If Value is < 0 and RADIX_HEX is not set in Flags, then the fist charact= er in + Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then + Buffer is padded with '0' characters so the combination of the optional = '-' + sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If an error would be returned, then the function will also ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated Unicode string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in + Buffer, not including the Null-terminator. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If PcdMaximumUnicodeStringLength is not + zero, and BufferSize is greater than + (PcdMaximumUnicodeStringLength * + sizeof (CHAR16) + 1). + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +EFIAPI +UnicodeValueToStringS ( + IN OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +/** Produces a Null-terminated ASCII string in an output buffer based on a N= ull-terminated ASCII format string and a VA_LIST argument list. =20 @@ -871,6 +932,66 @@ AsciiValueToString ( ); =20 /** + Converts a decimal value to a Null-terminated Ascii string. + + Converts the decimal number specified by Value to a Null-terminated Ascii + string specified by Buffer containing at most Width characters. No paddi= ng of + spaces is ever performed. If Width is 0 then a width of + MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than + Width characters, then only the first Width characters are placed in Buf= fer. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If RADIX_HEX is set in Flags, then the output buffer will be formatted in + hexadecimal format. + If Value is < 0 and RADIX_HEX is not set in Flags, then the fist charact= er in + Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then + Buffer is padded with '0' characters so the combination of the optional = '-' + sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If an error would be returned, then the function will also ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated Ascii string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Ascii characters to place in + Buffer, not including the Null-terminator. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If PcdMaximumAsciiStringLength is not + zero, and BufferSize is greater than + PcdMaximumAsciiStringLength. + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +EFIAPI +AsciiValueToStringS ( + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ); + +/** Returns the number of characters that would be produced by if the format= ted=20 output were produced not including the Null-terminator. =20 diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePr= intLib/PrintLib.c index bf8c7bf..221b52e 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -404,6 +404,71 @@ UnicodeValueToString ( } =20 /** + Converts a decimal value to a Null-terminated Unicode string. + + Converts the decimal number specified by Value to a Null-terminated Unic= ode + string specified by Buffer containing at most Width characters. No paddi= ng of + spaces is ever performed. If Width is 0 then a width of + MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than + Width characters, then only the first Width characters are placed in Buf= fer. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If RADIX_HEX is set in Flags, then the output buffer will be formatted in + hexadecimal format. + If Value is < 0 and RADIX_HEX is not set in Flags, then the fist charact= er in + Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then + Buffer is padded with '0' characters so the combination of the optional = '-' + sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If an error would be returned, then the function will also ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated Unicode string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Unicode characters to place in + Buffer, not including the Null-terminator. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If PcdMaximumUnicodeStringLength is not + zero, and BufferSize is greater than + (PcdMaximumUnicodeStringLength * + sizeof (CHAR16) + 1). + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +EFIAPI +UnicodeValueToStringS ( + IN OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + ASSERT_UNICODE_BUFFER(Buffer); + return BasePrintLibConvertValueToStringS ((CHAR8 *)Buffer, BufferSize, F= lags, Value, Width, 2); +} + +/** Produces a Null-terminated ASCII string in an output buffer based on a N= ull-terminated ASCII format string and a VA_LIST argument list. =20 @@ -769,6 +834,69 @@ AsciiValueToString ( } =20 /** + Converts a decimal value to a Null-terminated Ascii string. + + Converts the decimal number specified by Value to a Null-terminated Ascii + string specified by Buffer containing at most Width characters. No paddi= ng of + spaces is ever performed. If Width is 0 then a width of + MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than + Width characters, then only the first Width characters are placed in Buf= fer. + Additional conversion parameters are specified in Flags. + + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If RADIX_HEX is set in Flags, then the output buffer will be formatted in + hexadecimal format. + If Value is < 0 and RADIX_HEX is not set in Flags, then the fist charact= er in + Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then + Buffer is padded with '0' characters so the combination of the optional = '-' + sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If an error would be returned, then the function will also ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated Ascii string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of Ascii characters to place in + Buffer, not including the Null-terminator. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If PcdMaximumAsciiStringLength is not + zero, and BufferSize is greater than + PcdMaximumAsciiStringLength. + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +EFIAPI +AsciiValueToStringS ( + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width + ) +{ + return BasePrintLibConvertValueToStringS (Buffer, BufferSize, Flags, Val= ue, Width, 1); +} + +/** Returns the number of characters that would be produced by if the format= ted=20 output were produced not including the Null-terminator. =20 diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Librar= y/BasePrintLib/PrintLibInternal.c index 155fe6a..9b15a07 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -292,6 +292,210 @@ BasePrintLibConvertValueToString ( } =20 /** + Internal function that converts a decimal value to a Null-terminated str= ing. + + Converts the decimal number specified by Value to a Null-terminated stri= ng + specified by Buffer containing at most Width characters. If Width is 0 t= hen a + width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains= more + than Width characters, then only the first Width characters are placed in + Buffer. Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the opti= onal + '-' sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If an error would be returned, the function will ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, + not including the Null-terminator. + @param Increment The character increment in Buffer. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If Increment is 1 and + PcdMaximumAsciiStringLength is not zero, + BufferSize is greater than + PcdMaximumAsciiStringLength. + If Increment is not 1 and + PcdMaximumUnicodeStringLength is not ze= ro, + BufferSize is greater than + (PcdMaximumUnicodeStringLength * + sizeof (CHAR16) + 1). + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +BasePrintLibConvertValueToStringS ( + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ) +{ + CHAR8 *EndBuffer; + CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS]; + CHAR8 *ValueBufferPtr; + UINTN Count; + UINTN Digits; + UINTN Index; + UINTN Radix; + + // + // 1. Buffer shall not be a null pointer. + // + SAFE_PRINT_CONSTRAINT_CHECK ((Buffer !=3D NULL), RETURN_INVALID_PARAMETE= R); + + // + // 2. BufferSize shall not be greater than (RSIZE_MAX * sizeof (CHAR16))= for + // Unicode output string or shall not be greater than ASCII_RSIZE_MAX= for + // Ascii output string. + // + if (Increment =3D=3D 1) { + // + // Ascii output string + // + if (ASCII_RSIZE_MAX !=3D 0) { + SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize <=3D ASCII_RSIZE_MAX), RETU= RN_INVALID_PARAMETER); + } + } else { + // + // Unicode output string + // + if (RSIZE_MAX !=3D 0) { + SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize <=3D RSIZE_MAX * sizeof (CH= AR16) + 1), RETURN_INVALID_PARAMETER); + } + } + + // + // 3. Flags shall be set properly. + // + SAFE_PRINT_CONSTRAINT_CHECK (((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PRE= FIX_ZERO | RADIX_HEX)) =3D=3D 0), RETURN_INVALID_PARAMETER); + SAFE_PRINT_CONSTRAINT_CHECK ((((Flags & COMMA_TYPE) =3D=3D 0) || ((Flags= & RADIX_HEX) =3D=3D 0)), RETURN_INVALID_PARAMETER); + + // + // 4. Width shall be smaller than MAXIMUM_VALUE_CHARACTERS. + // + SAFE_PRINT_CONSTRAINT_CHECK ((Width < MAXIMUM_VALUE_CHARACTERS), RETURN_= INVALID_PARAMETER); + + // + // Width is 0 or COMMA_TYPE is set, PREFIX_ZERO is ignored. + // + if (Width =3D=3D 0 || (Flags & COMMA_TYPE) !=3D 0) { + Flags &=3D ~((UINTN) PREFIX_ZERO); + } + // + // If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. + // + if (Width =3D=3D 0) { + Width =3D MAXIMUM_VALUE_CHARACTERS - 1; + } + + // + // Count the characters of the output string. + // + Count =3D 0; + Radix =3D ((Flags & RADIX_HEX) =3D=3D 0)? 10 : 16; + + if ((Flags & PREFIX_ZERO) !=3D 0) { + Count =3D Width; + } else { + if ((Value < 0) && ((Flags & RADIX_HEX) =3D=3D 0)) { + Count++; // minus sign + ValueBufferPtr =3D BasePrintLibValueToString (ValueBuffer, -Value, R= adix); + } else { + ValueBufferPtr =3D BasePrintLibValueToString (ValueBuffer, Value, Ra= dix); + } + Digits =3D ValueBufferPtr - ValueBuffer; + Count +=3D Digits; + + if ((Flags & COMMA_TYPE) !=3D 0) { + Count +=3D (Digits - 1) / 3; // commas + } + } + + Width =3D MIN (Count, Width); + + // + // 5. BufferSize shall be large enough to hold the converted string. + // + SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize >=3D (Width + 1) * Increment), = RETURN_BUFFER_TOO_SMALL); + + // + // Set the tag for the end of the input Buffer. + // + EndBuffer =3D Buffer + Width * Increment; + + // + // Convert decimal negative + // + if ((Value < 0) && ((Flags & RADIX_HEX) =3D=3D 0)) { + Value =3D -Value; + Buffer =3D BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Incremen= t); + Width--; + } + + // + // Count the length of the value string. + // + ValueBufferPtr =3D BasePrintLibValueToString (ValueBuffer, Value, Radix); + Count =3D ValueBufferPtr - ValueBuffer; + + // + // Append Zero + // + if ((Flags & PREFIX_ZERO) !=3D 0) { + Buffer =3D BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '= 0', Increment); + } + + // + // Print Comma type for every 3 characters + // + Digits =3D Count % 3; + if (Digits !=3D 0) { + Digits =3D 3 - Digits; + } + for (Index =3D 0; Index < Count; Index++) { + Buffer =3D BasePrintLibFillBuffer (Buffer, EndBuffer, 1, *ValueBufferP= tr--, Increment); + if ((Flags & COMMA_TYPE) !=3D 0) { + Digits++; + if (Digits =3D=3D 3) { + Digits =3D 0; + if ((Index + 1) < Count) { + Buffer =3D BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', In= crement); + } + } + } + } + + // + // Print Null-terminator + // + BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment); + + return RETURN_SUCCESS; +} + +/** Worker function that produces a Null-terminated string in an output buff= er=20 based on a Null-terminated format string and a VA_LIST argument list. =20 diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Librar= y/BasePrintLib/PrintLibInternal.h index fccef9b..052e699 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h @@ -213,4 +213,65 @@ BasePrintLibConvertValueToString ( IN UINTN Increment ); =20 +/** + Internal function that converts a decimal value to a Null-terminated str= ing. + + Converts the decimal number specified by Value to a Null-terminated stri= ng + specified by Buffer containing at most Width characters. If Width is 0 t= hen a + width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains= more + than Width characters, then only the first Width characters are placed in + Buffer. Additional conversion parameters are specified in Flags. + The Flags bit LEFT_JUSTIFY is always ignored. + All conversions are left justified in Buffer. + If Width is 0, PREFIX_ZERO is ignored in Flags. + If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and + commas are inserted every 3rd digit starting from the right. + If Value is < 0, then the fist character in Buffer is a '-'. + If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, + then Buffer is padded with '0' characters so the combination of the opti= onal + '-' sign character, '0' characters, digit characters for Value, and the + Null-terminator add up to Width characters. + + If an error would be returned, the function will ASSERT(). + + @param Buffer The pointer to the output buffer for the produced + Null-terminated string. + @param BufferSize The size of Buffer in bytes, including the + Null-terminator. + @param Flags The bitmask of flags that specify left justification, + zero pad, and commas. + @param Value The 64-bit signed value to convert to a string. + @param Width The maximum number of characters to place in Buffer, + not including the Null-terminator. + @param Increment The character increment in Buffer. + + @retval RETURN_SUCCESS The decimal value is converted. + @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted + value. + @retval RETURN_INVALID_PARAMETER If Buffer is NULL. + If Increment is 1 and + PcdMaximumAsciiStringLength is not zero, + BufferSize is greater than + PcdMaximumAsciiStringLength. + If Increment is not 1 and + PcdMaximumUnicodeStringLength is not ze= ro, + BufferSize is greater than + (PcdMaximumUnicodeStringLength * + sizeof (CHAR16) + 1). + If unsupported bits are set in Flags. + If both COMMA_TYPE and RADIX_HEX are se= t in + Flags. + If Width >=3D MAXIMUM_VALUE_CHARACTERS. + +**/ +RETURN_STATUS +BasePrintLibConvertValueToStringS ( + IN OUT CHAR8 *Buffer, + IN UINTN BufferSize, + IN UINTN Flags, + IN INT64 Value, + IN UINTN Width, + IN UINTN Increment + ); + #endif --=20 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel