/** @file\r
Instance of Print Library based on gEfiPrint2SProtocolGuid.\r
\r
- Implement the print library instance by wrap the interface \r
+ Implement the print library instance by wrap the interface\r
provided in the Print2S protocol. This protocol is defined as the internal\r
- protocol related to this implementation, not in the public spec. So, this \r
+ protocol related to this implementation, not in the public spec. So, this\r
library instance is only for this code base.\r
\r
-Copyright (c) 2009 - 2017, 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) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
/**\r
The constructor function caches the pointer to Print2S protocol.\r
- \r
+\r
The constructor function locates Print2S protocol from protocol database.\r
- It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+ It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
\r
@param ImageHandle The firmware allocated handle for the EFI image.\r
@param SystemTable A pointer to the EFI System Table.\r
- \r
+\r
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
\r
**/\r
\r
\r
/**\r
- Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated \r
+ Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated\r
format string.\r
\r
@param AsciiFormat TRUE if Format is an ASCII string. FALSE if Format is a Unicode string.\r
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
\r
switch (FormatCharacter) {\r
- case '.': \r
- case '-': \r
- case '+': \r
- case ' ': \r
- case ',': \r
+ case '.':\r
+ case '-':\r
+ case '+':\r
+ case ' ':\r
+ case ',':\r
case '0':\r
case '1':\r
case '2':\r
case '9':\r
break;\r
case 'L':\r
- case 'l': \r
+ case 'l':\r
Long = TRUE;\r
break;\r
case '*':\r
case '\0':\r
//\r
// Make no output if Format string terminates unexpectedly when\r
- // looking up for flag, width, precision and type. \r
+ // looking up for flag, width, precision and type.\r
//\r
Format -= BytesPerFormatCharacter;\r
//\r
Done = TRUE;\r
break;\r
}\r
- } \r
- \r
+ }\r
+\r
//\r
// Handle each argument type\r
//\r
return NumberOfPrinted;\r
}\r
\r
-#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
-\r
-/**\r
- [ATTENTION] This function is deprecated for security reason.\r
-\r
- Converts a decimal value to a Null-terminated Unicode string.\r
- \r
- Converts the decimal number specified by Value to a Null-terminated Unicode \r
- string specified by Buffer containing at most Width characters. No padding of spaces \r
- is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
- The number of Unicode characters in Buffer is returned not including the Null-terminator.\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
- required to perform the conversion is returned.\r
- Additional conversion parameters are specified in Flags. \r
- \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 RADIX_HEX is set in Flags, then the output buffer will be \r
- formatted in hexadecimal format.\r
- If Value is < 0 and RADIX_HEX is not set in Flags, 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 Null-terminator\r
- add up to Width characters.\r
- If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
- If Buffer is NULL, then ASSERT().\r
- If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
- If unsupported bits are set in Flags, then ASSERT().\r
- If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
- If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
-\r
- @param Buffer Pointer to the output buffer for the produced Null-terminated\r
- Unicode string.\r
- @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
- @param Value The 64-bit signed value to convert to a string.\r
- @param Width The maximum number of Unicode characters to place in Buffer, not including\r
- the Null-terminator.\r
- \r
- @return The number of Unicode characters in Buffer not including the Null-terminator.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-UnicodeValueToString (\r
- IN OUT CHAR16 *Buffer,\r
- IN UINTN Flags,\r
- IN INT64 Value,\r
- IN UINTN Width\r
- )\r
-{\r
- RETURN_STATUS Status;\r
- UINTN BufferSize;\r
-\r
- if (Width == 0) {\r
- BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR16);\r
- } else {\r
- BufferSize = (Width + 1) * sizeof (CHAR16);\r
- }\r
-\r
- Status = mPrint2SProtocol->UnicodeValueToStringS (Buffer, BufferSize, Flags, Value, Width);\r
- if (RETURN_ERROR (Status)) {\r
- return 0;\r
- }\r
-\r
- return StrnLenS (Buffer, BufferSize / sizeof (CHAR16));\r
-}\r
-\r
-#endif\r
-\r
/**\r
Converts a decimal value to a Null-terminated Unicode string.\r
\r
}\r
\r
\r
-#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
-\r
-/**\r
- [ATTENTION] This function is deprecated for security reason.\r
-\r
- Converts a decimal value to a Null-terminated ASCII string.\r
- \r
- Converts the decimal number specified by Value to a Null-terminated ASCII string \r
- specified by Buffer containing at most Width characters. No padding of spaces \r
- is ever performed.\r
- If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
- The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
- If the conversion contains more than Width characters, then only the first Width\r
- characters are returned, and the total number of characters required to perform\r
- the conversion is returned.\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 RADIX_HEX is set in Flags, then the output buffer will be \r
- formatted in hexadecimal format.\r
- If Value is < 0 and RADIX_HEX is not set in Flags, 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 Null-terminator\r
- add up to Width characters.\r
- \r
- If Buffer is NULL, then ASSERT().\r
- If unsupported bits are set in Flags, then ASSERT().\r
- If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
- If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
-\r
- @param Buffer Pointer to the output buffer for the produced Null-terminated\r
- ASCII string.\r
- @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
- @param Value The 64-bit signed value to convert to a string.\r
- @param Width The maximum number of ASCII characters to place in Buffer, not including\r
- the Null-terminator.\r
- \r
- @return The number of ASCII characters in Buffer not including the Null-terminator.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-AsciiValueToString (\r
- OUT CHAR8 *Buffer,\r
- IN UINTN Flags,\r
- IN INT64 Value,\r
- IN UINTN Width\r
- )\r
-{\r
- RETURN_STATUS Status;\r
- UINTN BufferSize;\r
-\r
- if (Width == 0) {\r
- BufferSize = (MAXIMUM_VALUE_CHARACTERS + 1) * sizeof (CHAR8);\r
- } else {\r
- BufferSize = (Width + 1) * sizeof (CHAR8);\r
- }\r
-\r
- Status = mPrint2SProtocol->AsciiValueToStringS (Buffer, BufferSize, Flags, Value, Width);\r
- if (RETURN_ERROR (Status)) {\r
- return 0;\r
- }\r
-\r
- return AsciiStrnLenS (Buffer, BufferSize / sizeof (CHAR8));\r
-}\r
-\r
-#endif\r
-\r
/**\r
Converts a decimal value to a Null-terminated Ascii string.\r
\r
**/\r
CHAR8 *\r
InternalPrintLibValueToString (\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
\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
);\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
\r
@param Buffer The 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
)\r
{\r
INTN Index;\r
- \r
+\r
for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {\r
*Buffer = (CHAR8) Character;\r
if (Increment != 1) {\r
}\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
\r
//\r
// If you change this code be sure to match the 2 versions of this function.\r
- // Nearly identical logic is found in the BasePrintLib and \r
+ // Nearly identical logic is found in the BasePrintLib and\r
// DxePrintLibPrint2Protocol (both PrintLib instances).\r
//\r
\r
Format += BytesPerFormatCharacter;\r
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
switch (FormatCharacter) {\r
- case '.': \r
- Flags |= PRECISION; \r
+ case '.':\r
+ Flags |= PRECISION;\r
break;\r
- case '-': \r
- Flags |= LEFT_JUSTIFY; \r
+ case '-':\r
+ Flags |= LEFT_JUSTIFY;\r
break;\r
- case '+': \r
- Flags |= PREFIX_SIGN; \r
+ case '+':\r
+ Flags |= PREFIX_SIGN;\r
break;\r
- case ' ': \r
- Flags |= PREFIX_BLANK; \r
+ case ' ':\r
+ Flags |= PREFIX_BLANK;\r
break;\r
- case ',': \r
- Flags |= COMMA_TYPE; \r
+ case ',':\r
+ Flags |= COMMA_TYPE;\r
break;\r
case 'L':\r
- case 'l': \r
- Flags |= LONG_TYPE; \r
+ case 'l':\r
+ Flags |= LONG_TYPE;\r
break;\r
case '*':\r
if ((Flags & PRECISION) == 0) {\r
Precision = Count;\r
}\r
break;\r
- \r
+\r
case '\0':\r
//\r
// Make no output if Format string terminates unexpectedly when\r
- // looking up for flag, width, precision and type. \r
+ // looking up for flag, width, precision and type.\r
//\r
Format -= BytesPerFormatCharacter;\r
Precision = 0;\r
Done = TRUE;\r
break;\r
}\r
- } \r
+ }\r
\r
//\r
// Handle each argument type\r
//\r
// 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
// This assumption is made so the format string definition is compatible with the ANSI C\r
- // Specification for formatted strings. It is recommended that the Base Types be used \r
- // everywhere, but in this one case, compliance with ANSI C is more important, and \r
- // provides an implementation that is compatible with that largest possible set of CPU \r
+ // Specification for formatted strings. It is recommended that the Base Types be used\r
+ // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+ // provides an implementation that is compatible with that largest possible set of CPU\r
// architectures. This is why the type "int" is used in this one case.\r
//\r
if (BaseListMarker == NULL) {\r
//\r
// 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
// This assumption is made so the format string definition is compatible with the ANSI C\r
- // Specification for formatted strings. It is recommended that the Base Types be used \r
- // everywhere, but in this one case, compliance with ANSI C is more important, and \r
- // provides an implementation that is compatible with that largest possible set of CPU \r
+ // Specification for formatted strings. It is recommended that the Base Types be used\r
+ // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+ // provides an implementation that is compatible with that largest possible set of CPU\r
// architectures. This is why the type "unsigned int" is used in this one case.\r
//\r
Value = (unsigned int)Value;\r
//\r
// 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".\r
// This assumption is made so the format string definition is compatible with the ANSI C\r
- // Specification for formatted strings. It is recommended that the Base Types be used \r
- // everywhere, but in this one case, compliance with ANSI C is more important, and \r
- // provides an implementation that is compatible with that largest possible set of CPU \r
+ // Specification for formatted strings. It is recommended that the Base Types be used\r
+ // everywhere, but in this one case, compliance with ANSI C is more important, and\r
+ // provides an implementation that is compatible with that largest possible set of CPU\r
// architectures. This is why the type "unsigned int" is used in this one case.\r
//\r
Value = (unsigned int)Value;\r
Count = 0;\r
}\r
ArgumentString = (CHAR8 *)ValueBuffer + Count;\r
- \r
+\r
Digits = Count % 3;\r
if (Digits != 0) {\r
Digits = 3 - Digits;\r
GuidData3 = ReadUnaligned16 (&(TmpGuid->Data3));\r
InternalPrintLibSPrint (\r
ValueBuffer,\r
- MAXIMUM_VALUE_CHARACTERS, \r
+ MAXIMUM_VALUE_CHARACTERS,\r
0,\r
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
GuidData1,\r
\r
case 't':\r
if (BaseListMarker == NULL) {\r
- TmpTime = VA_ARG (VaListMarker, TIME *); \r
+ TmpTime = VA_ARG (VaListMarker, TIME *);\r
} else {\r
- TmpTime = BASE_ARG (BaseListMarker, TIME *); \r
+ TmpTime = BASE_ARG (BaseListMarker, TIME *);\r
}\r
if (TmpTime == NULL) {\r
ArgumentString = "<null time>";\r
break;\r
}\r
break;\r
- \r
+\r
case '\r':\r
Format += BytesPerFormatCharacter;\r
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;\r
}\r
\r
/**\r
- Returns the number of characters that would be produced by if the formatted \r
+ Returns the number of characters that would be produced by if the formatted\r
output were produced not including the Null-terminator.\r
\r
If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
@param[in] FormatString A Null-terminated Unicode format string.\r
@param[in] Marker VA_LIST marker for the variable argument list.\r
\r
- @return The number of characters that would be produced, not including the \r
+ @return The number of characters that would be produced, not including the\r
Null-terminator.\r
**/\r
UINTN\r
}\r
\r
/**\r
- Returns the number of characters that would be produced by if the formatted \r
+ Returns the number of characters that would be produced by if the formatted\r
output were produced not including the Null-terminator.\r
\r
If FormatString is NULL, then ASSERT() and 0 is returned.\r
@param[in] FormatString A Null-terminated ASCII format string.\r
@param[in] Marker VA_LIST marker for the variable argument list.\r
\r
- @return The number of characters that would be produced, not including the \r
+ @return The number of characters that would be produced, not including the\r
Null-terminator.\r
**/\r
UINTN\r