3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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 24
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
62 Worker function that produces a Null-terminated string in an output buffer
63 based on a Null-terminated format string and a VA_LIST argument list.
65 VSPrint function to process format and place the results in Buffer. Since a
66 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
67 this is the main print working routine.
69 @param Buffer Character buffer to print the results of the parsing
71 @param BufferSize Maximum number of characters to put into buffer.
72 @param Flags Intial flags value.
73 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
74 @param Format Null-terminated format string.
75 @param Marker Vararg list consumed by processing Format.
77 @return Number of characters printed not including the Null-terminator.
85 IN CONST CHAR8
*Format
,
89 CHAR8
*OriginalBuffer
;
91 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
92 UINTN BytesPerOutputCharacter
;
93 UINTN BytesPerFormatCharacter
;
95 UINTN FormatCharacter
;
99 CONST CHAR8
*ArgumentString
;
105 INTN BytesPerArgumentCharacter
;
106 UINTN ArgumentCharacter
;
114 RETURN_STATUS Status
;
116 if (BufferSize
== 0) {
119 ASSERT (Buffer
!= NULL
);
121 if ((Flags
& OUTPUT_UNICODE
) != 0) {
122 BytesPerOutputCharacter
= 2;
124 BytesPerOutputCharacter
= 1;
128 // Reserve space for the Null terminator.
131 OriginalBuffer
= Buffer
;
133 // Set the tag for the end of the input Buffer.
135 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
137 if ((Flags
& FORMAT_UNICODE
) != 0) {
139 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
140 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
142 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
143 BytesPerFormatCharacter
= 2;
147 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
148 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
150 ASSERT (AsciiStrSize (Format
) != 0);
151 BytesPerFormatCharacter
= 1;
158 // Get the first character from the format string
160 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
163 // Loop until the end of the format string is reached or the output buffer is full
165 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
167 // Clear all the flag bits except those that may have been passed in
169 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
172 // Set the default width to zero, and the default precision to 1
182 switch (FormatCharacter
) {
185 // Parse Flags and Width
187 for (Done
= FALSE
; !Done
; ) {
188 Format
+= BytesPerFormatCharacter
;
189 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
190 switch (FormatCharacter
) {
195 Flags
|= LEFT_JUSTIFY
;
198 Flags
|= PREFIX_SIGN
;
201 Flags
|= PREFIX_BLANK
;
211 if ((Flags
& PRECISION
) == 0) {
212 Flags
|= PAD_TO_WIDTH
;
213 Width
= VA_ARG (Marker
, UINTN
);
215 Precision
= VA_ARG (Marker
, UINTN
);
219 if ((Flags
& PRECISION
) == 0) {
220 Flags
|= PREFIX_ZERO
;
231 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
232 Count
= (Count
* 10) + FormatCharacter
- '0';
233 Format
+= BytesPerFormatCharacter
;
234 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
236 Format
-= BytesPerFormatCharacter
;
237 if ((Flags
& PRECISION
) == 0) {
238 Flags
|= PAD_TO_WIDTH
;
247 // Make no output if Format string terminates unexpectedly when
248 // looking up for flag, width, precision and type.
250 Format
-= BytesPerFormatCharacter
;
253 // break skipped on purpose.
262 // Handle each argument type
264 switch (FormatCharacter
) {
267 // Flag space, +, 0, L & l are invalid for type p.
269 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
270 if (sizeof (VOID
*) > 4) {
274 Flags
|= PREFIX_ZERO
;
276 // break skipped on purpose
281 // break skipped on purpose
284 if ((Flags
& LONG_TYPE
) == 0) {
285 Value
= (VA_ARG (Marker
, int));
287 Value
= VA_ARG (Marker
, INT64
);
289 if ((Flags
& PREFIX_BLANK
) != 0) {
292 if ((Flags
& PREFIX_SIGN
) != 0) {
295 if ((Flags
& COMMA_TYPE
) != 0) {
298 if ((Flags
& RADIX_HEX
) == 0) {
301 Flags
&= (~PREFIX_ZERO
);
305 Flags
|= PREFIX_SIGN
;
312 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
313 Value
= (unsigned int)Value
;
317 // Convert Value to a reversed string
319 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
320 if (Value
== 0 && Precision
== 0) {
323 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
329 if (Comma
&& Count
!= 0) {
330 Count
+= ((Count
- 1) / 3);
336 Flags
|= ARGUMENT_REVERSED
;
338 if ((Flags
& PREFIX_ZERO
) != 0) {
339 if ((Flags
& LEFT_JUSTIFY
) == 0) {
340 if ((Flags
& PAD_TO_WIDTH
) != 0) {
341 if ((Flags
& PRECISION
) == 0) {
351 Flags
|= ARGUMENT_UNICODE
;
353 // break skipped on purpose
356 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
357 if (ArgumentString
== NULL
) {
358 Flags
&= (~ARGUMENT_UNICODE
);
359 ArgumentString
= "<null string>";
364 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
365 ArgumentString
= (CHAR8
*)&Character
;
366 Flags
|= ARGUMENT_UNICODE
;
370 TmpGuid
= VA_ARG (Marker
, GUID
*);
371 if (TmpGuid
== NULL
) {
372 ArgumentString
= "<null guid>";
376 MAXIMUM_VALUE_CHARACTERS
,
378 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
391 ArgumentString
= ValueBuffer
;
396 TmpTime
= VA_ARG (Marker
, TIME
*);
397 if (TmpTime
== NULL
) {
398 ArgumentString
= "<null time>";
402 MAXIMUM_VALUE_CHARACTERS
,
404 "%02d/%02d/%04d %02d:%02d",
411 ArgumentString
= ValueBuffer
;
416 Status
= VA_ARG (Marker
, RETURN_STATUS
);
417 ArgumentString
= ValueBuffer
;
418 if (RETURN_ERROR (Status
)) {
422 Index
= Status
& ~MAX_BIT
;
423 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
424 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
428 if (Index
<= WARNING_STATUS_NUMBER
) {
429 ArgumentString
= StatusString
[Index
];
432 if (ArgumentString
== ValueBuffer
) {
433 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
438 ArgumentString
= "\n\r";
444 // if the type is '%' or unknown, then print it to the screen
446 ArgumentString
= (CHAR8
*)&FormatCharacter
;
447 Flags
|= ARGUMENT_UNICODE
;
453 ArgumentString
= "\n\r";
457 ArgumentString
= (CHAR8
*)&FormatCharacter
;
458 Flags
|= ARGUMENT_UNICODE
;
463 // Retrieve the ArgumentString attriubutes
465 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
466 ArgumentMask
= 0xffff;
467 BytesPerArgumentCharacter
= 2;
470 BytesPerArgumentCharacter
= 1;
472 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
473 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
476 // Compute the number of characters in ArgumentString and store it in Count
477 // ArgumentString is either null-terminated, or it contains Precision characters
479 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
480 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
481 if (ArgumentCharacter
== 0) {
487 if (Precision
< Count
) {
492 // Pad before the string
494 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
495 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
500 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
502 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
504 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
506 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
511 // Output the Prefix character if it is present
519 // Copy the string into the output buffer performing the required type conversions
521 while (Index
< Count
) {
522 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
524 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
525 ArgumentString
+= BytesPerArgumentCharacter
;
533 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
540 // Pad after the string
542 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
543 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
547 // Get the next character from the format string
549 Format
+= BytesPerFormatCharacter
;
552 // Get the next character from the format string
554 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
558 // Null terminate the Unicode or ASCII string
560 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
562 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
563 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
565 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
567 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
568 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
570 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
572 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
576 Worker function that produces a Null-terminated string in an output buffer
577 based on a Null-terminated format string and variable argument list.
579 VSPrint function to process format and place the results in Buffer. Since a
580 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
581 this is the main print working routine.
583 @param Buffer Character buffer to print the results of the parsing
585 @param BufferSize Maximum number of characters to put into buffer.
587 @param Flags Intial flags value.
588 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
589 @param FormatString Null-terminated format string.
591 @return Number of characters printed not including the Null-terminator.
596 OUT CHAR8
*StartOfBuffer
,
599 IN CONST CHAR8
*FormatString
,
605 VA_START (Marker
, FormatString
);
606 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
610 Produces a Null-terminated Unicode string in an output buffer based on
611 a Null-terminated Unicode format string and a VA_LIST argument list
613 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
615 The Unicode string is produced by parsing the format string specified by FormatString.
616 Arguments are pulled from the variable argument list specified by Marker based on the
617 contents of the format string.
618 The number of Unicode characters in the produced output buffer is returned not including
620 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
622 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
623 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
624 If BufferSize > 1 and FormatString is NULL, then ASSERT().
625 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
626 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
627 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
629 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
630 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
631 Null-terminator, then ASSERT().
633 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
635 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
636 @param FormatString Null-terminated Unicode format string.
637 @param Marker VA_LIST marker for the variable argument list.
639 @return The number of Unicode characters in the produced output buffer not including the
646 OUT CHAR16
*StartOfBuffer
,
648 IN CONST CHAR16
*FormatString
,
652 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
653 ASSERT_UNICODE_BUFFER(FormatString
);
654 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
658 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
659 Unicode format string and variable argument list.
661 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
663 The Unicode string is produced by parsing the format string specified by FormatString.
664 Arguments are pulled from the variable argument list based on the contents of the format string.
665 The number of Unicode characters in the produced output buffer is returned not including
667 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
669 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
670 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
671 If BufferSize > 1 and FormatString is NULL, then ASSERT().
672 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
673 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
674 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
676 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
677 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
678 Null-terminator, then ASSERT().
680 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
682 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
683 @param FormatString Null-terminated Unicode format string.
685 @return The number of Unicode characters in the produced output buffer not including the
692 OUT CHAR16
*StartOfBuffer
,
694 IN CONST CHAR16
*FormatString
,
700 VA_START (Marker
, FormatString
);
701 return UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
705 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
706 ASCII format string and a VA_LIST argument list
708 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
710 The Unicode string is produced by parsing the format string specified by FormatString.
711 Arguments are pulled from the variable argument list specified by Marker based on the
712 contents of the format string.
713 The number of Unicode characters in the produced output buffer is returned not including
715 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
717 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
718 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
719 If BufferSize > 1 and FormatString is NULL, then ASSERT().
720 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
721 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
723 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
724 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
725 Null-terminator, then ASSERT().
727 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
729 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
730 @param FormatString Null-terminated Unicode format string.
731 @param Marker VA_LIST marker for the variable argument list.
733 @return The number of Unicode characters in the produced output buffer not including the
739 UnicodeVSPrintAsciiFormat (
740 OUT CHAR16
*StartOfBuffer
,
742 IN CONST CHAR8
*FormatString
,
746 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
747 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
751 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
752 ASCII format string and variable argument list.
754 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
756 The Unicode string is produced by parsing the format string specified by FormatString.
757 Arguments are pulled from the variable argument list based on the contents of the
759 The number of Unicode characters in the produced output buffer is returned not including
761 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
763 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
764 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
765 If BufferSize > 1 and FormatString is NULL, then ASSERT().
766 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
767 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
769 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
770 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
771 Null-terminator, then ASSERT().
773 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
775 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
776 @param FormatString Null-terminated Unicode format string.
778 @return The number of Unicode characters in the produced output buffer not including the
784 UnicodeSPrintAsciiFormat (
785 OUT CHAR16
*StartOfBuffer
,
787 IN CONST CHAR8
*FormatString
,
793 VA_START (Marker
, FormatString
);
794 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
798 Converts a decimal value to a Null-terminated Unicode string.
800 Converts the decimal number specified by Value to a Null-terminated Unicode
801 string specified by Buffer containing at most Width characters. No padding of spaces
802 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
803 The number of Unicode characters in Buffer is returned not including the Null-terminator.
804 If the conversion contains more than Width characters, then only the first
805 Width characters are returned, and the total number of characters
806 required to perform the conversion is returned.
807 Additional conversion parameters are specified in Flags.
809 The Flags bit LEFT_JUSTIFY is always ignored.
810 All conversions are left justified in Buffer.
811 If Width is 0, PREFIX_ZERO is ignored in Flags.
812 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
813 are inserted every 3rd digit starting from the right.
814 If HEX_RADIX is set in Flags, then the output buffer will be
815 formatted in hexadecimal format.
816 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
817 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
818 then Buffer is padded with '0' characters so the combination of the optional '-'
819 sign character, '0' characters, digit characters for Value, and the Null-terminator
820 add up to Width characters.
821 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
822 If Buffer is NULL, then ASSERT().
823 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
824 If unsupported bits are set in Flags, then ASSERT().
825 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
826 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
828 @param Buffer Pointer to the output buffer for the produced Null-terminated
830 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
831 @param Value The 64-bit signed value to convert to a string.
832 @param Width The maximum number of Unicode characters to place in Buffer, not including
835 @return The number of Unicode characters in Buffer not including the Null-terminator.
840 UnicodeValueToString (
841 IN OUT CHAR16
*Buffer
,
847 ASSERT_UNICODE_BUFFER(Buffer
);
848 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
852 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
853 ASCII format string and a VA_LIST argument list.
855 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
857 The ASCII string is produced by parsing the format string specified by FormatString.
858 Arguments are pulled from the variable argument list specified by Marker based on
859 the contents of the format string.
860 The number of ASCII characters in the produced output buffer is returned not including
862 If BufferSize is 0, then no output buffer is produced and 0 is returned.
864 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
865 If BufferSize > 0 and FormatString is NULL, then ASSERT().
866 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
867 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
869 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
870 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
871 Null-terminator, then ASSERT().
873 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
875 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
876 @param FormatString Null-terminated Unicode format string.
877 @param Marker VA_LIST marker for the variable argument list.
879 @return The number of ASCII characters in the produced output buffer not including the
886 OUT CHAR8
*StartOfBuffer
,
888 IN CONST CHAR8
*FormatString
,
892 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
896 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
897 ASCII format string and variable argument list.
899 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
901 The ASCII string is produced by parsing the format string specified by FormatString.
902 Arguments are pulled from the variable argument list based on the contents of the
904 The number of ASCII characters in the produced output buffer is returned not including
906 If BufferSize is 0, then no output buffer is produced and 0 is returned.
908 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
909 If BufferSize > 0 and FormatString is NULL, then ASSERT().
910 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
911 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
913 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
914 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
915 Null-terminator, then ASSERT().
917 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
919 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
920 @param FormatString Null-terminated Unicode format string.
922 @return The number of ASCII characters in the produced output buffer not including the
929 OUT CHAR8
*StartOfBuffer
,
931 IN CONST CHAR8
*FormatString
,
937 VA_START (Marker
, FormatString
);
938 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
942 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
943 ASCII format string and a VA_LIST argument list.
945 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
947 The ASCII string is produced by parsing the format string specified by FormatString.
948 Arguments are pulled from the variable argument list specified by Marker based on
949 the contents of the format string.
950 The number of ASCII characters in the produced output buffer is returned not including
952 If BufferSize is 0, then no output buffer is produced and 0 is returned.
954 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
955 If BufferSize > 0 and FormatString is NULL, then ASSERT().
956 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
957 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
958 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
960 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
961 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
962 Null-terminator, then ASSERT().
964 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
966 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
967 @param FormatString Null-terminated Unicode format string.
968 @param Marker VA_LIST marker for the variable argument list.
970 @return The number of ASCII characters in the produced output buffer not including the
976 AsciiVSPrintUnicodeFormat (
977 OUT CHAR8
*StartOfBuffer
,
979 IN CONST CHAR16
*FormatString
,
983 ASSERT_UNICODE_BUFFER (FormatString
);
984 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
988 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
989 ASCII format string and variable argument list.
991 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
993 The ASCII string is produced by parsing the format string specified by FormatString.
994 Arguments are pulled from the variable argument list based on the contents of the
996 The number of ASCII characters in the produced output buffer is returned not including
998 If BufferSize is 0, then no output buffer is produced and 0 is returned.
1000 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
1001 If BufferSize > 0 and FormatString is NULL, then ASSERT().
1002 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
1003 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
1004 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1006 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
1007 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
1008 Null-terminator, then ASSERT().
1010 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1012 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1013 @param FormatString Null-terminated Unicode format string.
1015 @return The number of ASCII characters in the produced output buffer not including the
1021 AsciiSPrintUnicodeFormat (
1022 OUT CHAR8
*StartOfBuffer
,
1023 IN UINTN BufferSize
,
1024 IN CONST CHAR16
*FormatString
,
1030 VA_START (Marker
, FormatString
);
1031 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1036 Converts a decimal value to a Null-terminated ASCII string.
1038 Converts the decimal number specified by Value to a Null-terminated ASCII string
1039 specified by Buffer containing at most Width characters. No padding of spaces
1041 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1042 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1043 If the conversion contains more than Width characters, then only the first Width
1044 characters are returned, and the total number of characters required to perform
1045 the conversion is returned.
1046 Additional conversion parameters are specified in Flags.
1047 The Flags bit LEFT_JUSTIFY is always ignored.
1048 All conversions are left justified in Buffer.
1049 If Width is 0, PREFIX_ZERO is ignored in Flags.
1050 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1051 are inserted every 3rd digit starting from the right.
1052 If HEX_RADIX is set in Flags, then the output buffer will be
1053 formatted in hexadecimal format.
1054 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
1055 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1056 then Buffer is padded with '0' characters so the combination of the optional '-'
1057 sign character, '0' characters, digit characters for Value, and the Null-terminator
1058 add up to Width characters.
1060 If Buffer is NULL, then ASSERT().
1061 If unsupported bits are set in Flags, then ASSERT().
1062 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
1063 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1065 @param Buffer Pointer to the output buffer for the produced Null-terminated
1067 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1068 @param Value The 64-bit signed value to convert to a string.
1069 @param Width The maximum number of ASCII characters to place in Buffer, not including
1070 the Null-terminator.
1072 @return The number of ASCII characters in Buffer not including the Null-terminator.
1077 AsciiValueToString (
1078 IN OUT CHAR8
*Buffer
,
1084 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);