4 Copyright (c) 2006 - 2007, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: PrintLib.c
17 #include "PrintLibInternal.h"
19 #define WARNING_STATUS_NUMBER 4
20 #define ERROR_STATUS_NUMBER 24
21 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
23 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
*StatusString
[] = {
24 "Success", // RETURN_SUCCESS = 0
25 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
26 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
27 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
28 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
29 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
30 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
31 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
32 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
33 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
34 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
35 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
36 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
37 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
38 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
39 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
40 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
41 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
42 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
43 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
44 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
45 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
46 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
47 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
48 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
49 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
50 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
51 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
52 "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
56 Worker function that produces a Null-terminated string in an output buffer
57 based on a Null-terminated format string and a VA_LIST argument list.
59 VSPrint function to process format and place the results in Buffer. Since a
60 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
61 this is the main print working routine.
63 @param Buffer Character buffer to print the results of the parsing
65 @param BufferSize Maximum number of characters to put into buffer.
66 @param Flags Intial flags value.
67 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
68 @param Format Null-terminated format string.
69 @param Marker Vararg list consumed by processing Format.
71 @return Number of characters printed not including the Null-terminator.
79 IN CONST CHAR8
*Format
,
83 CHAR8
*OriginalBuffer
;
85 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
86 UINTN BytesPerOutputCharacter
;
87 UINTN BytesPerFormatCharacter
;
89 UINTN FormatCharacter
;
93 CONST CHAR8
*ArgumentString
;
99 INTN BytesPerArgumentCharacter
;
100 UINTN ArgumentCharacter
;
108 RETURN_STATUS Status
;
110 if (BufferSize
== 0) {
113 ASSERT (Buffer
!= NULL
);
115 if ((Flags
& OUTPUT_UNICODE
) != 0) {
116 BytesPerOutputCharacter
= 2;
118 BytesPerOutputCharacter
= 1;
122 // Reserve space for the Null terminator.
125 OriginalBuffer
= Buffer
;
127 // Set the tag for the end of the input Buffer.
129 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
131 if ((Flags
& FORMAT_UNICODE
) != 0) {
133 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
134 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
136 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
137 BytesPerFormatCharacter
= 2;
141 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
142 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
144 ASSERT (AsciiStrSize (Format
) != 0);
145 BytesPerFormatCharacter
= 1;
152 // Get the first character from the format string
154 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
157 // Loop until the end of the format string is reached or the output buffer is full
159 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
161 // Clear all the flag bits except those that may have been passed in
163 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
166 // Set the default width to zero, and the default precision to 1
176 switch (FormatCharacter
) {
179 // Parse Flags and Width
181 for (Done
= FALSE
; !Done
; ) {
182 Format
+= BytesPerFormatCharacter
;
183 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
184 switch (FormatCharacter
) {
189 Flags
|= LEFT_JUSTIFY
;
192 Flags
|= PREFIX_SIGN
;
195 Flags
|= PREFIX_BLANK
;
205 if ((Flags
& PRECISION
) == 0) {
206 Flags
|= PAD_TO_WIDTH
;
207 Width
= VA_ARG (Marker
, UINTN
);
209 Precision
= VA_ARG (Marker
, UINTN
);
213 if ((Flags
& PRECISION
) == 0) {
214 Flags
|= PREFIX_ZERO
;
225 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
226 Count
= (Count
* 10) + FormatCharacter
- '0';
227 Format
+= BytesPerFormatCharacter
;
228 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
230 Format
-= BytesPerFormatCharacter
;
231 if ((Flags
& PRECISION
) == 0) {
232 Flags
|= PAD_TO_WIDTH
;
241 // Make no output if Format string terminates unexpectedly when
242 // looking up for flag, width, precision and type.
244 Format
-= BytesPerFormatCharacter
;
247 // break skipped on purpose.
256 // Handle each argument type
258 switch (FormatCharacter
) {
261 // Flag space, +, 0, L & l are invalid for type p.
263 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
264 if (sizeof (VOID
*) > 4) {
268 Flags
|= PREFIX_ZERO
;
270 // break skipped on purpose
275 // break skipped on purpose
278 if ((Flags
& LONG_TYPE
) == 0) {
279 Value
= (VA_ARG (Marker
, int));
281 Value
= VA_ARG (Marker
, INT64
);
283 if ((Flags
& PREFIX_BLANK
) != 0) {
286 if ((Flags
& PREFIX_SIGN
) != 0) {
289 if ((Flags
& COMMA_TYPE
) != 0) {
292 if ((Flags
& RADIX_HEX
) == 0) {
295 Flags
&= (~PREFIX_ZERO
);
299 Flags
|= PREFIX_SIGN
;
306 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
307 Value
= (unsigned int)Value
;
311 // Convert Value to a reversed string
313 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
314 if (Value
== 0 && Precision
== 0) {
317 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
323 if (Comma
&& Count
!= 0) {
324 Count
+= ((Count
- 1) / 3);
330 Flags
|= ARGUMENT_REVERSED
;
332 if ((Flags
& PREFIX_ZERO
) != 0) {
333 if ((Flags
& LEFT_JUSTIFY
) == 0) {
334 if ((Flags
& PAD_TO_WIDTH
) != 0) {
335 if ((Flags
& PRECISION
) == 0) {
345 Flags
|= ARGUMENT_UNICODE
;
347 // break skipped on purpose
350 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
351 if (ArgumentString
== NULL
) {
352 Flags
&= (~ARGUMENT_UNICODE
);
353 ArgumentString
= "<null string>";
358 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
359 ArgumentString
= (CHAR8
*)&Character
;
360 Flags
|= ARGUMENT_UNICODE
;
364 TmpGuid
= VA_ARG (Marker
, GUID
*);
365 if (TmpGuid
== NULL
) {
366 ArgumentString
= "<null guid>";
370 MAXIMUM_VALUE_CHARACTERS
,
372 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
385 ArgumentString
= ValueBuffer
;
390 TmpTime
= VA_ARG (Marker
, TIME
*);
391 if (TmpTime
== NULL
) {
392 ArgumentString
= "<null time>";
396 MAXIMUM_VALUE_CHARACTERS
,
398 "%02d/%02d/%04d %02d:%02d",
405 ArgumentString
= ValueBuffer
;
410 Status
= VA_ARG (Marker
, RETURN_STATUS
);
411 ArgumentString
= ValueBuffer
;
412 if (RETURN_ERROR (Status
)) {
416 Index
= Status
& ~MAX_BIT
;
417 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
418 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
422 if (Index
<= WARNING_STATUS_NUMBER
) {
423 ArgumentString
= StatusString
[Index
];
426 if (ArgumentString
== ValueBuffer
) {
427 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
432 ArgumentString
= "\n\r";
438 // if the type is '%' or unknown, then print it to the screen
440 ArgumentString
= (CHAR8
*)&FormatCharacter
;
441 Flags
|= ARGUMENT_UNICODE
;
447 ArgumentString
= "\n\r";
451 ArgumentString
= (CHAR8
*)&FormatCharacter
;
452 Flags
|= ARGUMENT_UNICODE
;
457 // Retrieve the ArgumentString attriubutes
459 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
460 ArgumentMask
= 0xffff;
461 BytesPerArgumentCharacter
= 2;
464 BytesPerArgumentCharacter
= 1;
466 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
467 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
470 // Compute the number of characters in ArgumentString and store it in Count
471 // ArgumentString is either null-terminated, or it contains Precision characters
473 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
474 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
475 if (ArgumentCharacter
== 0) {
481 if (Precision
< Count
) {
486 // Pad before the string
488 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
489 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
494 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
496 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
498 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
500 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
505 // Output the Prefix character if it is present
513 // Copy the string into the output buffer performing the required type conversions
515 while (Index
< Count
) {
516 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
518 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
519 ArgumentString
+= BytesPerArgumentCharacter
;
527 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
534 // Pad after the string
536 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
537 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
541 // Get the next character from the format string
543 Format
+= BytesPerFormatCharacter
;
546 // Get the next character from the format string
548 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
552 // Null terminate the Unicode or ASCII string
554 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
556 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
557 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
559 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
561 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
562 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
564 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
566 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
570 Worker function that produces a Null-terminated string in an output buffer
571 based on a Null-terminated format string and variable argument list.
573 VSPrint function to process format and place the results in Buffer. Since a
574 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
575 this is the main print working routine.
577 @param Buffer Character buffer to print the results of the parsing
579 @param BufferSize Maximum number of characters to put into buffer.
581 @param Flags Intial flags value.
582 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
583 @param FormatString Null-terminated format string.
585 @return Number of characters printed not including the Null-terminator.
590 OUT CHAR8
*StartOfBuffer
,
593 IN CONST CHAR8
*FormatString
,
599 VA_START (Marker
, FormatString
);
600 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
604 Produces a Null-terminated Unicode string in an output buffer based on
605 a Null-terminated Unicode format string and a VA_LIST argument list
607 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
609 The Unicode string is produced by parsing the format string specified by FormatString.
610 Arguments are pulled from the variable argument list specified by Marker based on the
611 contents of the format string.
612 The number of Unicode characters in the produced output buffer is returned not including
614 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
616 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
617 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
618 If BufferSize > 1 and FormatString is NULL, then ASSERT().
619 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
620 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
621 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
623 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
624 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
625 Null-terminator, then ASSERT().
627 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
629 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
630 @param FormatString Null-terminated Unicode format string.
631 @param Marker VA_LIST marker for the variable argument list.
633 @return The number of Unicode characters in the produced output buffer not including the
640 OUT CHAR16
*StartOfBuffer
,
642 IN CONST CHAR16
*FormatString
,
646 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
647 ASSERT_UNICODE_BUFFER(FormatString
);
648 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
652 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
653 Unicode format string and variable argument list.
655 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
657 The Unicode string is produced by parsing the format string specified by FormatString.
658 Arguments are pulled from the variable argument list based on the contents of the format string.
659 The number of Unicode characters in the produced output buffer is returned not including
661 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
663 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
664 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
665 If BufferSize > 1 and FormatString is NULL, then ASSERT().
666 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
667 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
668 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
670 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
671 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
672 Null-terminator, then ASSERT().
674 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
676 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
677 @param FormatString Null-terminated Unicode format string.
679 @return The number of Unicode characters in the produced output buffer not including the
686 OUT CHAR16
*StartOfBuffer
,
688 IN CONST CHAR16
*FormatString
,
694 VA_START (Marker
, FormatString
);
695 return UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
699 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
700 ASCII format string and a VA_LIST argument list
702 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
704 The Unicode string is produced by parsing the format string specified by FormatString.
705 Arguments are pulled from the variable argument list specified by Marker based on the
706 contents of the format string.
707 The number of Unicode characters in the produced output buffer is returned not including
709 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
711 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
712 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
713 If BufferSize > 1 and FormatString is NULL, then ASSERT().
714 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
715 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
717 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
718 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
719 Null-terminator, then ASSERT().
721 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
723 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
724 @param FormatString Null-terminated Unicode format string.
725 @param Marker VA_LIST marker for the variable argument list.
727 @return The number of Unicode characters in the produced output buffer not including the
733 UnicodeVSPrintAsciiFormat (
734 OUT CHAR16
*StartOfBuffer
,
736 IN CONST CHAR8
*FormatString
,
740 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
741 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
745 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
746 ASCII format string and variable argument list.
748 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
750 The Unicode string is produced by parsing the format string specified by FormatString.
751 Arguments are pulled from the variable argument list based on the contents of the
753 The number of Unicode characters in the produced output buffer is returned not including
755 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
757 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
758 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
759 If BufferSize > 1 and FormatString is NULL, then ASSERT().
760 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
761 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
763 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
764 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
765 Null-terminator, then ASSERT().
767 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
769 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
770 @param FormatString Null-terminated Unicode format string.
772 @return The number of Unicode characters in the produced output buffer not including the
778 UnicodeSPrintAsciiFormat (
779 OUT CHAR16
*StartOfBuffer
,
781 IN CONST CHAR8
*FormatString
,
787 VA_START (Marker
, FormatString
);
788 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
792 Converts a decimal value to a Null-terminated Unicode string.
794 Converts the decimal number specified by Value to a Null-terminated Unicode
795 string specified by Buffer containing at most Width characters. No padding of spaces
796 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
797 The number of Unicode characters in Buffer is returned not including the Null-terminator.
798 If the conversion contains more than Width characters, then only the first
799 Width characters are returned, and the total number of characters
800 required to perform the conversion is returned.
801 Additional conversion parameters are specified in Flags.
803 The Flags bit LEFT_JUSTIFY is always ignored.
804 All conversions are left justified in Buffer.
805 If Width is 0, PREFIX_ZERO is ignored in Flags.
806 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
807 are inserted every 3rd digit starting from the right.
808 If HEX_RADIX is set in Flags, then the output buffer will be
809 formatted in hexadecimal format.
810 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
811 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
812 then Buffer is padded with '0' characters so the combination of the optional '-'
813 sign character, '0' characters, digit characters for Value, and the Null-terminator
814 add up to Width characters.
815 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
816 If Buffer is NULL, then ASSERT().
817 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
818 If unsupported bits are set in Flags, then ASSERT().
819 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
820 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
822 @param Buffer Pointer to the output buffer for the produced Null-terminated
824 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
825 @param Value The 64-bit signed value to convert to a string.
826 @param Width The maximum number of Unicode characters to place in Buffer, not including
829 @return The number of Unicode characters in Buffer not including the Null-terminator.
834 UnicodeValueToString (
835 IN OUT CHAR16
*Buffer
,
841 ASSERT_UNICODE_BUFFER(Buffer
);
842 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
846 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
847 ASCII format string and a VA_LIST argument list.
849 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
851 The ASCII string is produced by parsing the format string specified by FormatString.
852 Arguments are pulled from the variable argument list specified by Marker based on
853 the contents of the format string.
854 The number of ASCII characters in the produced output buffer is returned not including
856 If BufferSize is 0, then no output buffer is produced and 0 is returned.
858 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
859 If BufferSize > 0 and FormatString is NULL, then ASSERT().
860 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
861 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
863 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
864 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
865 Null-terminator, then ASSERT().
867 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
869 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
870 @param FormatString Null-terminated Unicode format string.
871 @param Marker VA_LIST marker for the variable argument list.
873 @return The number of ASCII characters in the produced output buffer not including the
880 OUT CHAR8
*StartOfBuffer
,
882 IN CONST CHAR8
*FormatString
,
886 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
890 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
891 ASCII format string and variable argument list.
893 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
895 The ASCII string is produced by parsing the format string specified by FormatString.
896 Arguments are pulled from the variable argument list based on the contents of the
898 The number of ASCII characters in the produced output buffer is returned not including
900 If BufferSize is 0, then no output buffer is produced and 0 is returned.
902 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
903 If BufferSize > 0 and FormatString is NULL, then ASSERT().
904 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
905 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
907 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
908 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
909 Null-terminator, then ASSERT().
911 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
913 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
914 @param FormatString Null-terminated Unicode format string.
916 @return The number of ASCII characters in the produced output buffer not including the
923 OUT CHAR8
*StartOfBuffer
,
925 IN CONST CHAR8
*FormatString
,
931 VA_START (Marker
, FormatString
);
932 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
936 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
937 ASCII format string and a VA_LIST argument list.
939 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
941 The ASCII string is produced by parsing the format string specified by FormatString.
942 Arguments are pulled from the variable argument list specified by Marker based on
943 the contents of the format string.
944 The number of ASCII characters in the produced output buffer is returned not including
946 If BufferSize is 0, then no output buffer is produced and 0 is returned.
948 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
949 If BufferSize > 0 and FormatString is NULL, then ASSERT().
950 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
951 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
952 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
954 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
955 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
956 Null-terminator, then ASSERT().
958 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
960 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
961 @param FormatString Null-terminated Unicode format string.
962 @param Marker VA_LIST marker for the variable argument list.
964 @return The number of ASCII characters in the produced output buffer not including the
970 AsciiVSPrintUnicodeFormat (
971 OUT CHAR8
*StartOfBuffer
,
973 IN CONST CHAR16
*FormatString
,
977 ASSERT_UNICODE_BUFFER (FormatString
);
978 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
982 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
983 ASCII format string and variable argument list.
985 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
987 The ASCII string is produced by parsing the format string specified by FormatString.
988 Arguments are pulled from the variable argument list based on the contents of the
990 The number of ASCII characters in the produced output buffer is returned not including
992 If BufferSize is 0, then no output buffer is produced and 0 is returned.
994 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
995 If BufferSize > 0 and FormatString is NULL, then ASSERT().
996 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
997 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
998 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1000 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
1001 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
1002 Null-terminator, then ASSERT().
1004 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1006 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1007 @param FormatString Null-terminated Unicode format string.
1009 @return The number of ASCII characters in the produced output buffer not including the
1015 AsciiSPrintUnicodeFormat (
1016 OUT CHAR8
*StartOfBuffer
,
1017 IN UINTN BufferSize
,
1018 IN CONST CHAR16
*FormatString
,
1024 VA_START (Marker
, FormatString
);
1025 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1030 Converts a decimal value to a Null-terminated ASCII string.
1032 Converts the decimal number specified by Value to a Null-terminated ASCII string
1033 specified by Buffer containing at most Width characters. No padding of spaces
1035 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1036 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1037 If the conversion contains more than Width characters, then only the first Width
1038 characters are returned, and the total number of characters required to perform
1039 the conversion is returned.
1040 Additional conversion parameters are specified in Flags.
1041 The Flags bit LEFT_JUSTIFY is always ignored.
1042 All conversions are left justified in Buffer.
1043 If Width is 0, PREFIX_ZERO is ignored in Flags.
1044 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1045 are inserted every 3rd digit starting from the right.
1046 If HEX_RADIX is set in Flags, then the output buffer will be
1047 formatted in hexadecimal format.
1048 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
1049 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1050 then Buffer is padded with '0' characters so the combination of the optional '-'
1051 sign character, '0' characters, digit characters for Value, and the Null-terminator
1052 add up to Width characters.
1054 If Buffer is NULL, then ASSERT().
1055 If unsupported bits are set in Flags, then ASSERT().
1056 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
1057 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1059 @param Buffer Pointer to the output buffer for the produced Null-terminated
1061 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1062 @param Value The 64-bit signed value to convert to a string.
1063 @param Width The maximum number of ASCII characters to place in Buffer, not including
1064 the Null-terminator.
1066 @return The number of ASCII characters in Buffer not including the Null-terminator.
1071 AsciiValueToString (
1072 IN OUT CHAR8
*Buffer
,
1078 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);