summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BasePrintLib/PrintLib.c
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-05 04:17:04 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-05 04:17:04 +0000
commitadd13dc21720eff1a37fdea34c0fef190e2ad37d (patch)
tree0d58a4edded2175903f98276e3fe67f802ab44ce /MdePkg/Library/BasePrintLib/PrintLib.c
parentc16ade35ca4b293255fea78aaf33783501f90f9f (diff)
downloadedk2-platforms-add13dc21720eff1a37fdea34c0fef190e2ad37d.tar.xz
DebugLib:
Fix a bug in PeiDxeDebugLibReportStatusCode: it should use gReportStatusCodeDebugType so that report status code infrastructure can correctly extract debug info. Fix functional and coding style issues in the three instances in EdkModulePkg, namely: EdkDxeDebugLibReportStatusCode, EdkUefiDebugLibStderr, EdkUefiDebugLibConout. DevicePathLib: Sync with MWG 0.57 and add new interface of CreateDevicePathNode(). All the function headers have been updated. PeiServicesLib: Adjust coding style and fix a minor comment error. PciLib: Adjust assert() condition to sync with MWG 0.57 BaseMemoryLib: Adjust assert() for ScanMemXX (), ScanGuid() Rename UefiMemoryLib to DxeMemoryLib PrintLib: Change the return value of all print services to exclude the NULL-terminator. Misc: Slightly adjust the coding style in hob.c in PeiCore module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@757 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BasePrintLib/PrintLib.c')
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLib.c211
1 files changed, 121 insertions, 90 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c
index 1484d891b6..d33f49d388 100644
--- a/MdePkg/Library/BasePrintLib/PrintLib.c
+++ b/MdePkg/Library/BasePrintLib/PrintLib.c
@@ -57,17 +57,17 @@ STATIC CONST CHAR8 *StatusString [] = {
VSPrint function to process format and place the results in Buffer. Since a
VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
- this is the main print working routine
+ this is the main print working routine.
@param Buffer Character buffer to print the results of the parsing
of Format into.
@param BufferSize Maximum number of characters to put into buffer.
@param Flags Intial flags value.
- Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
@param Format Null-terminated format string.
@param Marker Vararg list consumed by processing Format.
- @return Number of characters printed.
+ @return Number of characters printed not including the Null-terminator.
**/
UINTN
@@ -127,8 +127,8 @@ BasePrintLibVSPrint (
FormatMask = 0xffff;
} else {
//
- // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
- // Ascii characters if PcdMaximumUnicodeStringLength is not zero.
+ // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
+ // Ascii characters if PcdMaximumAsciiStringLength is not zero.
//
ASSERT (AsciiStrSize (Format) != 0);
BytesPerFormatCharacter = 1;
@@ -506,7 +506,7 @@ BasePrintLibVSPrint (
// Output the Prefix character if it is present
//
Index = 0;
- if (Prefix) {
+ if (Prefix != 0) {
Index++;
}
@@ -557,18 +557,17 @@ BasePrintLibVSPrint (
//
// Null terminate the Unicode or ASCII string
//
- Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);
+ BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);
//
// Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
// Unicode characters if PcdMaximumUnicodeStringLength is not zero.
//
ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0));
//
- // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
- // Ascii characters if PcdMaximumUnicodeStringLength is not zero.
+ // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
+ // ASCII characters if PcdMaximumAsciiStringLength is not zero.
//
ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));
-
return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);
}
@@ -579,7 +578,7 @@ BasePrintLibVSPrint (
VSPrint function to process format and place the results in Buffer. Since a
VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
- this is the main print working routine
+ this is the main print working routine.
@param Buffer Character buffer to print the results of the parsing
of Format into.
@@ -589,7 +588,7 @@ BasePrintLibVSPrint (
Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
@param FormatString Null-terminated format string.
- @return Number of characters printed.
+ @return Number of characters printed not including the Null-terminator.
**/
UINTN
@@ -616,23 +615,27 @@ BasePrintLibSPrint (
The Unicode string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list specified by Marker based on the
contents of the format string.
- The length of the produced output buffer is returned.
- If BufferSize is 0, then no output buffer is produced and 0 is returned.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
@param Marker VA_LIST marker for the variable argument list.
- @return return Length of the produced output buffer.
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -655,22 +658,26 @@ UnicodeVSPrint (
and BufferSize.
The Unicode string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list based on the contents of the format string.
- The length of the produced output buffer is returned.
- If BufferSize is 0, then no output buffer is produced and 0 is returned.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
- @return Length of the produced output buffer.
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -697,23 +704,27 @@ UnicodeSPrint (
The Unicode string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list specified by Marker based on the
contents of the format string.
- The length of the produced output buffer is returned.
- If BufferSize is 0, then no output buffer is produced and 0 is returned.
-
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
@param Marker VA_LIST marker for the variable argument list.
- @return Length of the produced output buffer.
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -737,22 +748,26 @@ UnicodeVSPrintAsciiFormat (
The Unicode string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list based on the contents of the
format string.
- The length of the produced output buffer is returned.
- If BufferSize is 0, then no output buffer is produced and 0 is returned.
-
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
Unicode string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
- @return Length of the produced output buffer.
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -779,23 +794,27 @@ UnicodeSPrintAsciiFormat (
The ASCII string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list specified by Marker based on
the contents of the format string.
- The length of the produced output buffer is returned.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
If BufferSize is 0, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
@param Marker VA_LIST marker for the variable argument list.
- @return Length of the produced output buffer.
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -819,22 +838,26 @@ AsciiVSPrint (
The ASCII string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list based on the contents of the
format string.
- The length of the produced output buffer is returned.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
If BufferSize is 0, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
- @return Length of the produced output buffer.
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -861,23 +884,27 @@ AsciiSPrint (
The ASCII string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list specified by Marker based on
the contents of the format string.
- The length of the produced output buffer is returned.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
If BufferSize is 0, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
@param Marker VA_LIST marker for the variable argument list.
- @return Length of the produced output buffer.
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -901,22 +928,26 @@ AsciiVSPrintUnicodeFormat (
The ASCII string is produced by parsing the format string specified by FormatString.
Arguments are pulled from the variable argument list based on the contents of the
format string.
- The length of the produced output buffer is returned.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
If BufferSize is 0, then no output buffer is produced and 0 is returned.
- If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
- If BufferSize is not 0 and FormatString is NULL, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
- PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
- If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
- contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
- @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
ASCII string.
@param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
@param FormatString Null-terminated Unicode format string.
- @return Length of the produced output buffer.
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
**/
UINTN
@@ -940,7 +971,7 @@ AsciiSPrintUnicodeFormat (
Converts the decimal number specified by Value to a Null-terminated Unicode
string specified by Buffer containing at most Width characters.
If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
- The total number of characters placed in Buffer is returned.
+ The number of Unicode characters in Buffer is returned not including the Null-terminator.
If the conversion contains more than Width characters, then only the first
Width characters are returned, and the total number of characters
required to perform the conversion is returned.
@@ -964,9 +995,9 @@ AsciiSPrintUnicodeFormat (
Unicode string.
@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.
+ @param Width The maximum number of Unicode characters to place in Buffer.
- @return Total number of characters required to perform the conversion.
+ @return The number of Unicode characters in Buffer not including the Null-terminator.
**/
UINTN
@@ -987,7 +1018,7 @@ UnicodeValueToString (
Converts the decimal number specified by Value to a Null-terminated ASCII string
specified by Buffer containing at most Width characters.
If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
- The total number of characters placed in Buffer is returned.
+ The number of ASCII characters in Buffer is returned not including the Null-terminator.
If the conversion contains more than Width characters, then only the first Width
characters are returned, and the total number of characters required to perform
the conversion is returned.
@@ -1011,9 +1042,9 @@ UnicodeValueToString (
ASCII string.
@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.
+ @param Width The maximum number of ASCII characters to place in Buffer.
- @return Total number of characters required to perform the conversion.
+ @return The number of ASCII characters in Buffer not including the Null-terminator.
**/
UINTN