3 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include "PrintLibInternal.h"
25 #define WARNING_STATUS_NUMBER 4
26 #define ERROR_STATUS_NUMBER 31
27 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
29 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
*StatusString
[] = {
30 "Success", // RETURN_SUCCESS = 0
31 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
32 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
33 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
34 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
35 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
36 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
37 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
38 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
39 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
40 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
41 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
42 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
43 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
44 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
45 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
46 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
47 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
48 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
49 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
50 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
51 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
52 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
53 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
54 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
55 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
56 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
57 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
58 "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
59 "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
60 "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
61 "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
62 "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
63 "Reserved (29)", // RESERVED = 29 | MAX_BIT
64 "Reserved (30)", // RESERVED = 30 | MAX_BIT
65 "End of File" // RETURN_END_OF_FILE = 31 | MAX_BIT
69 Worker function that produces a Null-terminated string in an output buffer
70 based on a Null-terminated format string and a VA_LIST argument list.
72 VSPrint function to process format and place the results in Buffer. Since a
73 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
74 this is the main print working routine.
76 @param Buffer Character buffer to print the results of the parsing
78 @param BufferSize Maximum number of characters to put into buffer.
79 @param Flags Intial flags value.
80 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
81 @param Format Null-terminated format string.
82 @param Marker Vararg list consumed by processing Format.
84 @return Number of characters printed not including the Null-terminator.
92 IN CONST CHAR8
*Format
,
96 CHAR8
*OriginalBuffer
;
98 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
99 UINTN BytesPerOutputCharacter
;
100 UINTN BytesPerFormatCharacter
;
102 UINTN FormatCharacter
;
106 CONST CHAR8
*ArgumentString
;
112 INTN BytesPerArgumentCharacter
;
113 UINTN ArgumentCharacter
;
121 RETURN_STATUS Status
;
123 if (BufferSize
== 0) {
126 ASSERT (Buffer
!= NULL
);
128 if ((Flags
& OUTPUT_UNICODE
) != 0) {
129 BytesPerOutputCharacter
= 2;
131 BytesPerOutputCharacter
= 1;
135 // Reserve space for the Null terminator.
138 OriginalBuffer
= Buffer
;
140 // Set the tag for the end of the input Buffer.
142 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
144 if ((Flags
& FORMAT_UNICODE
) != 0) {
146 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
147 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
149 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
150 BytesPerFormatCharacter
= 2;
154 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
155 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
157 ASSERT (AsciiStrSize (Format
) != 0);
158 BytesPerFormatCharacter
= 1;
165 // Get the first character from the format string
167 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
170 // Loop until the end of the format string is reached or the output buffer is full
172 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
174 // Clear all the flag bits except those that may have been passed in
176 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
179 // Set the default width to zero, and the default precision to 1
189 switch (FormatCharacter
) {
192 // Parse Flags and Width
194 for (Done
= FALSE
; !Done
; ) {
195 Format
+= BytesPerFormatCharacter
;
196 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
197 switch (FormatCharacter
) {
202 Flags
|= LEFT_JUSTIFY
;
205 Flags
|= PREFIX_SIGN
;
208 Flags
|= PREFIX_BLANK
;
218 if ((Flags
& PRECISION
) == 0) {
219 Flags
|= PAD_TO_WIDTH
;
220 Width
= VA_ARG (Marker
, UINTN
);
222 Precision
= VA_ARG (Marker
, UINTN
);
226 if ((Flags
& PRECISION
) == 0) {
227 Flags
|= PREFIX_ZERO
;
238 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
239 Count
= (Count
* 10) + FormatCharacter
- '0';
240 Format
+= BytesPerFormatCharacter
;
241 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
243 Format
-= BytesPerFormatCharacter
;
244 if ((Flags
& PRECISION
) == 0) {
245 Flags
|= PAD_TO_WIDTH
;
254 // Make no output if Format string terminates unexpectedly when
255 // looking up for flag, width, precision and type.
257 Format
-= BytesPerFormatCharacter
;
260 // break skipped on purpose.
269 // Handle each argument type
271 switch (FormatCharacter
) {
274 // Flag space, +, 0, L & l are invalid for type p.
276 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
277 if (sizeof (VOID
*) > 4) {
281 Flags
|= PREFIX_ZERO
;
283 // break skipped on purpose
288 // break skipped on purpose
291 if ((Flags
& LONG_TYPE
) == 0) {
292 Value
= (VA_ARG (Marker
, int));
294 Value
= VA_ARG (Marker
, INT64
);
296 if ((Flags
& PREFIX_BLANK
) != 0) {
299 if ((Flags
& PREFIX_SIGN
) != 0) {
302 if ((Flags
& COMMA_TYPE
) != 0) {
305 if ((Flags
& RADIX_HEX
) == 0) {
308 Flags
&= (~PREFIX_ZERO
);
312 Flags
|= PREFIX_SIGN
;
319 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
320 Value
= (unsigned int)Value
;
324 // Convert Value to a reversed string
326 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
327 if (Value
== 0 && Precision
== 0) {
330 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
336 if (Comma
&& Count
!= 0) {
337 Count
+= ((Count
- 1) / 3);
343 Flags
|= ARGUMENT_REVERSED
;
345 if ((Flags
& PREFIX_ZERO
) != 0) {
346 if ((Flags
& LEFT_JUSTIFY
) == 0) {
347 if ((Flags
& PAD_TO_WIDTH
) != 0) {
348 if ((Flags
& PRECISION
) == 0) {
358 Flags
|= ARGUMENT_UNICODE
;
360 // break skipped on purpose
363 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
364 if (ArgumentString
== NULL
) {
365 Flags
&= (~ARGUMENT_UNICODE
);
366 ArgumentString
= "<null string>";
371 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
372 ArgumentString
= (CHAR8
*)&Character
;
373 Flags
|= ARGUMENT_UNICODE
;
377 TmpGuid
= VA_ARG (Marker
, GUID
*);
378 if (TmpGuid
== NULL
) {
379 ArgumentString
= "<null guid>";
383 MAXIMUM_VALUE_CHARACTERS
,
385 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
398 ArgumentString
= ValueBuffer
;
403 TmpTime
= VA_ARG (Marker
, TIME
*);
404 if (TmpTime
== NULL
) {
405 ArgumentString
= "<null time>";
409 MAXIMUM_VALUE_CHARACTERS
,
411 "%02d/%02d/%04d %02d:%02d",
418 ArgumentString
= ValueBuffer
;
423 Status
= VA_ARG (Marker
, RETURN_STATUS
);
424 ArgumentString
= ValueBuffer
;
425 if (RETURN_ERROR (Status
)) {
429 Index
= Status
& ~MAX_BIT
;
430 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
431 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
434 Index
= (UINTN
) Status
;
435 if (Index
<= WARNING_STATUS_NUMBER
) {
436 ArgumentString
= StatusString
[Index
];
439 if (ArgumentString
== ValueBuffer
) {
440 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
445 ArgumentString
= "\n\r";
451 // if the type is '%' or unknown, then print it to the screen
453 ArgumentString
= (CHAR8
*)&FormatCharacter
;
454 Flags
|= ARGUMENT_UNICODE
;
460 ArgumentString
= "\n\r";
464 ArgumentString
= (CHAR8
*)&FormatCharacter
;
465 Flags
|= ARGUMENT_UNICODE
;
470 // Retrieve the ArgumentString attriubutes
472 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
473 ArgumentMask
= 0xffff;
474 BytesPerArgumentCharacter
= 2;
477 BytesPerArgumentCharacter
= 1;
479 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
480 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
483 // Compute the number of characters in ArgumentString and store it in Count
484 // ArgumentString is either null-terminated, or it contains Precision characters
486 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
487 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
488 if (ArgumentCharacter
== 0) {
494 if (Precision
< Count
) {
499 // Pad before the string
501 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
502 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
507 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
509 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
511 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
513 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
518 // Output the Prefix character if it is present
526 // Copy the string into the output buffer performing the required type conversions
528 while (Index
< Count
) {
529 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
531 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
532 ArgumentString
+= BytesPerArgumentCharacter
;
540 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
547 // Pad after the string
549 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
550 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
554 // Get the next character from the format string
556 Format
+= BytesPerFormatCharacter
;
559 // Get the next character from the format string
561 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
565 // Null terminate the Unicode or ASCII string
567 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
569 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
570 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
572 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
574 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
575 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
577 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
579 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
583 Worker function that produces a Null-terminated string in an output buffer
584 based on a Null-terminated format string and variable argument list.
586 VSPrint function to process format and place the results in Buffer. Since a
587 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
588 this is the main print working routine.
590 @param Buffer Character buffer to print the results of the parsing
592 @param BufferSize Maximum number of characters to put into buffer.
594 @param Flags Intial flags value.
595 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
596 @param FormatString Null-terminated format string.
598 @return Number of characters printed not including the Null-terminator.
603 OUT CHAR8
*StartOfBuffer
,
606 IN CONST CHAR8
*FormatString
,
611 UINTN NumberOfPrinted
;
613 VA_START (Marker
, FormatString
);
614 NumberOfPrinted
= BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
616 return NumberOfPrinted
;
620 Produces a Null-terminated Unicode string in an output buffer based on
621 a Null-terminated Unicode format string and a VA_LIST argument list
623 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
625 The Unicode string is produced by parsing the format string specified by FormatString.
626 Arguments are pulled from the variable argument list specified by Marker based on the
627 contents of the format string.
628 The number of Unicode characters in the produced output buffer is returned not including
630 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
632 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
633 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
634 If BufferSize > 1 and FormatString is NULL, then ASSERT().
635 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
636 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
637 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
639 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
640 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
641 Null-terminator, then ASSERT().
643 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
645 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
646 @param FormatString Null-terminated Unicode format string.
647 @param Marker VA_LIST marker for the variable argument list.
649 @return The number of Unicode characters in the produced output buffer not including the
656 OUT CHAR16
*StartOfBuffer
,
658 IN CONST CHAR16
*FormatString
,
662 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
663 ASSERT_UNICODE_BUFFER(FormatString
);
664 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
668 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
669 Unicode format string and variable argument list.
671 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
673 The Unicode string is produced by parsing the format string specified by FormatString.
674 Arguments are pulled from the variable argument list based on the contents of the format string.
675 The number of Unicode characters in the produced output buffer is returned not including
677 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
679 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
680 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
681 If BufferSize > 1 and FormatString is NULL, then ASSERT().
682 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
683 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
684 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
686 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
687 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
688 Null-terminator, then ASSERT().
690 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
692 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
693 @param FormatString Null-terminated Unicode format string.
695 @return The number of Unicode characters in the produced output buffer not including the
702 OUT CHAR16
*StartOfBuffer
,
704 IN CONST CHAR16
*FormatString
,
709 UINTN NumberOfPrinted
;
711 VA_START (Marker
, FormatString
);
712 NumberOfPrinted
= UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
714 return NumberOfPrinted
;
718 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
719 ASCII format string and a VA_LIST argument list
721 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
723 The Unicode string is produced by parsing the format string specified by FormatString.
724 Arguments are pulled from the variable argument list specified by Marker based on the
725 contents of the format string.
726 The number of Unicode characters in the produced output buffer is returned not including
728 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
730 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
731 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
732 If BufferSize > 1 and FormatString is NULL, then ASSERT().
733 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
734 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
736 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
737 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
738 Null-terminator, then ASSERT().
740 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
742 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
743 @param FormatString Null-terminated Unicode format string.
744 @param Marker VA_LIST marker for the variable argument list.
746 @return The number of Unicode characters in the produced output buffer not including the
752 UnicodeVSPrintAsciiFormat (
753 OUT CHAR16
*StartOfBuffer
,
755 IN CONST CHAR8
*FormatString
,
759 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
760 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
764 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
765 ASCII format string and variable argument list.
767 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
769 The Unicode string is produced by parsing the format string specified by FormatString.
770 Arguments are pulled from the variable argument list based on the contents of the
772 The number of Unicode characters in the produced output buffer is returned not including
774 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
776 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
777 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
778 If BufferSize > 1 and FormatString is NULL, then ASSERT().
779 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
780 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
782 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
783 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
784 Null-terminator, then ASSERT().
786 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
788 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
789 @param FormatString Null-terminated Unicode format string.
791 @return The number of Unicode characters in the produced output buffer not including the
797 UnicodeSPrintAsciiFormat (
798 OUT CHAR16
*StartOfBuffer
,
800 IN CONST CHAR8
*FormatString
,
805 UINTN NumberOfPrinted
;
807 VA_START (Marker
, FormatString
);
808 NumberOfPrinted
= UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
810 return NumberOfPrinted
;
814 Converts a decimal value to a Null-terminated Unicode string.
816 Converts the decimal number specified by Value to a Null-terminated Unicode
817 string specified by Buffer containing at most Width characters. No padding of spaces
818 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
819 The number of Unicode characters in Buffer is returned not including the Null-terminator.
820 If the conversion contains more than Width characters, then only the first
821 Width characters are returned, and the total number of characters
822 required to perform the conversion is returned.
823 Additional conversion parameters are specified in Flags.
825 The Flags bit LEFT_JUSTIFY is always ignored.
826 All conversions are left justified in Buffer.
827 If Width is 0, PREFIX_ZERO is ignored in Flags.
828 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
829 are inserted every 3rd digit starting from the right.
830 If RADIX_HEX is set in Flags, then the output buffer will be
831 formatted in hexadecimal format.
832 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
833 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
834 then Buffer is padded with '0' characters so the combination of the optional '-'
835 sign character, '0' characters, digit characters for Value, and the Null-terminator
836 add up to Width characters.
837 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
838 If Buffer is NULL, then ASSERT().
839 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
840 If unsupported bits are set in Flags, then ASSERT().
841 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
842 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
844 @param Buffer Pointer to the output buffer for the produced Null-terminated
846 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
847 @param Value The 64-bit signed value to convert to a string.
848 @param Width The maximum number of Unicode characters to place in Buffer, not including
851 @return The number of Unicode characters in Buffer not including the Null-terminator.
856 UnicodeValueToString (
857 IN OUT CHAR16
*Buffer
,
863 ASSERT_UNICODE_BUFFER(Buffer
);
864 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
868 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
869 ASCII format string and a VA_LIST argument list.
871 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
873 The ASCII string is produced by parsing the format string specified by FormatString.
874 Arguments are pulled from the variable argument list specified by Marker based on
875 the contents of the format string.
876 The number of ASCII characters in the produced output buffer is returned not including
878 If BufferSize is 0, then no output buffer is produced and 0 is returned.
880 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
881 If BufferSize > 0 and FormatString is NULL, then ASSERT().
882 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
883 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
885 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
886 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
887 Null-terminator, then ASSERT().
889 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
891 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
892 @param FormatString Null-terminated Unicode format string.
893 @param Marker VA_LIST marker for the variable argument list.
895 @return The number of ASCII characters in the produced output buffer not including the
902 OUT CHAR8
*StartOfBuffer
,
904 IN CONST CHAR8
*FormatString
,
908 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
912 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
913 ASCII format string and variable argument list.
915 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
917 The ASCII string is produced by parsing the format string specified by FormatString.
918 Arguments are pulled from the variable argument list based on the contents of the
920 The number of ASCII characters in the produced output buffer is returned not including
922 If BufferSize is 0, then no output buffer is produced and 0 is returned.
924 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
925 If BufferSize > 0 and FormatString is NULL, then ASSERT().
926 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
927 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
929 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
930 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
931 Null-terminator, then ASSERT().
933 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
935 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
936 @param FormatString Null-terminated Unicode format string.
938 @return The number of ASCII characters in the produced output buffer not including the
945 OUT CHAR8
*StartOfBuffer
,
947 IN CONST CHAR8
*FormatString
,
952 UINTN NumberOfPrinted
;
954 VA_START (Marker
, FormatString
);
955 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
957 return NumberOfPrinted
;
961 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
962 ASCII format string and a VA_LIST argument list.
964 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
966 The ASCII string is produced by parsing the format string specified by FormatString.
967 Arguments are pulled from the variable argument list specified by Marker based on
968 the contents of the format string.
969 The number of ASCII characters in the produced output buffer is returned not including
971 If BufferSize is 0, then no output buffer is produced and 0 is returned.
973 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
974 If BufferSize > 0 and FormatString is NULL, then ASSERT().
975 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
976 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
977 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
979 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
980 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
981 Null-terminator, then ASSERT().
983 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
985 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
986 @param FormatString Null-terminated Unicode format string.
987 @param Marker VA_LIST marker for the variable argument list.
989 @return The number of ASCII characters in the produced output buffer not including the
995 AsciiVSPrintUnicodeFormat (
996 OUT CHAR8
*StartOfBuffer
,
998 IN CONST CHAR16
*FormatString
,
1002 ASSERT_UNICODE_BUFFER (FormatString
);
1003 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
1007 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
1008 ASCII format string and variable argument list.
1010 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
1012 The ASCII string is produced by parsing the format string specified by FormatString.
1013 Arguments are pulled from the variable argument list based on the contents of the
1015 The number of ASCII characters in the produced output buffer is returned not including
1016 the Null-terminator.
1017 If BufferSize is 0, then no output buffer is produced and 0 is returned.
1019 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
1020 If BufferSize > 0 and FormatString is NULL, then ASSERT().
1021 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
1022 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
1023 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1025 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
1026 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
1027 Null-terminator, then ASSERT().
1029 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1031 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1032 @param FormatString Null-terminated Unicode format string.
1034 @return The number of ASCII characters in the produced output buffer not including the
1040 AsciiSPrintUnicodeFormat (
1041 OUT CHAR8
*StartOfBuffer
,
1042 IN UINTN BufferSize
,
1043 IN CONST CHAR16
*FormatString
,
1048 UINTN NumberOfPrinted
;
1050 VA_START (Marker
, FormatString
);
1051 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1053 return NumberOfPrinted
;
1058 Converts a decimal value to a Null-terminated ASCII string.
1060 Converts the decimal number specified by Value to a Null-terminated ASCII string
1061 specified by Buffer containing at most Width characters. No padding of spaces
1063 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1064 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1065 If the conversion contains more than Width characters, then only the first Width
1066 characters are returned, and the total number of characters required to perform
1067 the conversion is returned.
1068 Additional conversion parameters are specified in Flags.
1069 The Flags bit LEFT_JUSTIFY is always ignored.
1070 All conversions are left justified in Buffer.
1071 If Width is 0, PREFIX_ZERO is ignored in Flags.
1072 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1073 are inserted every 3rd digit starting from the right.
1074 If RADIX_HEX is set in Flags, then the output buffer will be
1075 formatted in hexadecimal format.
1076 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
1077 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1078 then Buffer is padded with '0' characters so the combination of the optional '-'
1079 sign character, '0' characters, digit characters for Value, and the Null-terminator
1080 add up to Width characters.
1082 If Buffer is NULL, then ASSERT().
1083 If unsupported bits are set in Flags, then ASSERT().
1084 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
1085 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1087 @param Buffer Pointer to the output buffer for the produced Null-terminated
1089 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1090 @param Value The 64-bit signed value to convert to a string.
1091 @param Width The maximum number of ASCII characters to place in Buffer, not including
1092 the Null-terminator.
1094 @return The number of ASCII characters in Buffer not including the Null-terminator.
1099 AsciiValueToString (
1100 IN OUT CHAR8
*Buffer
,
1106 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);