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
18 // Include common header file for this module.
22 #include "PrintLibInternal.h"
24 #define WARNING_STATUS_NUMBER 4
25 #define ERROR_STATUS_NUMBER 24
26 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
28 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
*StatusString
[] = {
29 "Success", // RETURN_SUCCESS = 0
30 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
31 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
32 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
33 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
34 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
35 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
36 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
37 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
38 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
39 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
40 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
41 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
42 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
43 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
44 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
45 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
46 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
47 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
48 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
49 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
50 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
51 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
52 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
53 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
54 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
55 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
56 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
57 "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
61 Worker function that produces a Null-terminated string in an output buffer
62 based on a Null-terminated format string and a VA_LIST argument list.
64 VSPrint function to process format and place the results in Buffer. Since a
65 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
66 this is the main print working routine.
68 @param Buffer Character buffer to print the results of the parsing
70 @param BufferSize Maximum number of characters to put into buffer.
71 @param Flags Intial flags value.
72 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
73 @param Format Null-terminated format string.
74 @param Marker Vararg list consumed by processing Format.
76 @return Number of characters printed not including the Null-terminator.
84 IN CONST CHAR8
*Format
,
88 CHAR8
*OriginalBuffer
;
90 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
91 UINTN BytesPerOutputCharacter
;
92 UINTN BytesPerFormatCharacter
;
94 UINTN FormatCharacter
;
98 CONST CHAR8
*ArgumentString
;
104 INTN BytesPerArgumentCharacter
;
105 UINTN ArgumentCharacter
;
113 RETURN_STATUS Status
;
115 if (BufferSize
== 0) {
118 ASSERT (Buffer
!= NULL
);
120 if ((Flags
& OUTPUT_UNICODE
) != 0) {
121 BytesPerOutputCharacter
= 2;
123 BytesPerOutputCharacter
= 1;
127 // Reserve space for the Null terminator.
130 OriginalBuffer
= Buffer
;
132 // Set the tag for the end of the input Buffer.
134 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
136 if ((Flags
& FORMAT_UNICODE
) != 0) {
138 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
139 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
141 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
142 BytesPerFormatCharacter
= 2;
146 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
147 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
149 ASSERT (AsciiStrSize (Format
) != 0);
150 BytesPerFormatCharacter
= 1;
157 // Get the first character from the format string
159 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
162 // Loop until the end of the format string is reached or the output buffer is full
164 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
166 // Clear all the flag bits except those that may have been passed in
168 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
171 // Set the default width to zero, and the default precision to 1
181 switch (FormatCharacter
) {
184 // Parse Flags and Width
186 for (Done
= FALSE
; !Done
; ) {
187 Format
+= BytesPerFormatCharacter
;
188 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
189 switch (FormatCharacter
) {
194 Flags
|= LEFT_JUSTIFY
;
197 Flags
|= PREFIX_SIGN
;
200 Flags
|= PREFIX_BLANK
;
210 if ((Flags
& PRECISION
) == 0) {
211 Flags
|= PAD_TO_WIDTH
;
212 Width
= VA_ARG (Marker
, UINTN
);
214 Precision
= VA_ARG (Marker
, UINTN
);
218 if ((Flags
& PRECISION
) == 0) {
219 Flags
|= PREFIX_ZERO
;
230 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
231 Count
= (Count
* 10) + FormatCharacter
- '0';
232 Format
+= BytesPerFormatCharacter
;
233 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
235 Format
-= BytesPerFormatCharacter
;
236 if ((Flags
& PRECISION
) == 0) {
237 Flags
|= PAD_TO_WIDTH
;
246 // Make no output if Format string terminates unexpectedly when
247 // looking up for flag, width, precision and type.
249 Format
-= BytesPerFormatCharacter
;
252 // break skipped on purpose.
261 // Handle each argument type
263 switch (FormatCharacter
) {
266 // Flag space, +, 0, L & l are invalid for type p.
268 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
269 if (sizeof (VOID
*) > 4) {
273 Flags
|= PREFIX_ZERO
;
275 // break skipped on purpose
280 // break skipped on purpose
283 if ((Flags
& LONG_TYPE
) == 0) {
284 Value
= (VA_ARG (Marker
, int));
286 Value
= VA_ARG (Marker
, INT64
);
288 if ((Flags
& PREFIX_BLANK
) != 0) {
291 if ((Flags
& PREFIX_SIGN
) != 0) {
294 if ((Flags
& COMMA_TYPE
) != 0) {
297 if ((Flags
& RADIX_HEX
) == 0) {
300 Flags
&= (~PREFIX_ZERO
);
304 Flags
|= PREFIX_SIGN
;
311 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
312 Value
= (unsigned int)Value
;
316 // Convert Value to a reversed string
318 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
319 if (Value
== 0 && Precision
== 0) {
322 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
328 if (Comma
&& Count
!= 0) {
329 Count
+= ((Count
- 1) / 3);
335 Flags
|= ARGUMENT_REVERSED
;
337 if ((Flags
& PREFIX_ZERO
) != 0) {
338 if ((Flags
& LEFT_JUSTIFY
) == 0) {
339 if ((Flags
& PAD_TO_WIDTH
) != 0) {
340 if ((Flags
& PRECISION
) == 0) {
350 Flags
|= ARGUMENT_UNICODE
;
352 // break skipped on purpose
355 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
356 if (ArgumentString
== NULL
) {
357 Flags
&= (~ARGUMENT_UNICODE
);
358 ArgumentString
= "<null string>";
363 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
364 ArgumentString
= (CHAR8
*)&Character
;
365 Flags
|= ARGUMENT_UNICODE
;
369 TmpGuid
= VA_ARG (Marker
, GUID
*);
370 if (TmpGuid
== NULL
) {
371 ArgumentString
= "<null guid>";
375 MAXIMUM_VALUE_CHARACTERS
,
377 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
390 ArgumentString
= ValueBuffer
;
395 TmpTime
= VA_ARG (Marker
, TIME
*);
396 if (TmpTime
== NULL
) {
397 ArgumentString
= "<null time>";
401 MAXIMUM_VALUE_CHARACTERS
,
403 "%02d/%02d/%04d %02d:%02d",
410 ArgumentString
= ValueBuffer
;
415 Status
= VA_ARG (Marker
, RETURN_STATUS
);
416 ArgumentString
= ValueBuffer
;
417 if (RETURN_ERROR (Status
)) {
421 Index
= Status
& ~MAX_BIT
;
422 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
423 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
427 if (Index
<= WARNING_STATUS_NUMBER
) {
428 ArgumentString
= StatusString
[Index
];
431 if (ArgumentString
== ValueBuffer
) {
432 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
437 ArgumentString
= "\n\r";
443 // if the type is '%' or unknown, then print it to the screen
445 ArgumentString
= (CHAR8
*)&FormatCharacter
;
446 Flags
|= ARGUMENT_UNICODE
;
452 ArgumentString
= "\n\r";
456 ArgumentString
= (CHAR8
*)&FormatCharacter
;
457 Flags
|= ARGUMENT_UNICODE
;
462 // Retrieve the ArgumentString attriubutes
464 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
465 ArgumentMask
= 0xffff;
466 BytesPerArgumentCharacter
= 2;
469 BytesPerArgumentCharacter
= 1;
471 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
472 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
475 // Compute the number of characters in ArgumentString and store it in Count
476 // ArgumentString is either null-terminated, or it contains Precision characters
478 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
479 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
480 if (ArgumentCharacter
== 0) {
486 if (Precision
< Count
) {
491 // Pad before the string
493 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
494 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
499 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
501 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
503 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
505 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
510 // Output the Prefix character if it is present
518 // Copy the string into the output buffer performing the required type conversions
520 while (Index
< Count
) {
521 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
523 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
524 ArgumentString
+= BytesPerArgumentCharacter
;
532 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
539 // Pad after the string
541 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
542 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
546 // Get the next character from the format string
548 Format
+= BytesPerFormatCharacter
;
551 // Get the next character from the format string
553 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
557 // Null terminate the Unicode or ASCII string
559 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
561 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
562 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
564 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
566 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
567 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
569 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
571 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
575 Worker function that produces a Null-terminated string in an output buffer
576 based on a Null-terminated format string and variable argument list.
578 VSPrint function to process format and place the results in Buffer. Since a
579 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
580 this is the main print working routine.
582 @param Buffer Character buffer to print the results of the parsing
584 @param BufferSize Maximum number of characters to put into buffer.
586 @param Flags Intial flags value.
587 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
588 @param FormatString Null-terminated format string.
590 @return Number of characters printed not including the Null-terminator.
595 OUT CHAR8
*StartOfBuffer
,
598 IN CONST CHAR8
*FormatString
,
604 VA_START (Marker
, FormatString
);
605 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
609 Produces a Null-terminated Unicode string in an output buffer based on
610 a Null-terminated Unicode format string and a VA_LIST argument list
612 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
614 The Unicode string is produced by parsing the format string specified by FormatString.
615 Arguments are pulled from the variable argument list specified by Marker based on the
616 contents of the format string.
617 The number of Unicode characters in the produced output buffer is returned not including
619 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
621 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
622 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
623 If BufferSize > 1 and FormatString is NULL, then ASSERT().
624 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
625 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
626 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
628 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
629 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
630 Null-terminator, then ASSERT().
632 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
634 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
635 @param FormatString Null-terminated Unicode format string.
636 @param Marker VA_LIST marker for the variable argument list.
638 @return The number of Unicode characters in the produced output buffer not including the
645 OUT CHAR16
*StartOfBuffer
,
647 IN CONST CHAR16
*FormatString
,
651 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
652 ASSERT_UNICODE_BUFFER(FormatString
);
653 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
657 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
658 Unicode format string and variable argument list.
660 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
662 The Unicode string is produced by parsing the format string specified by FormatString.
663 Arguments are pulled from the variable argument list based on the contents of the format string.
664 The number of Unicode characters in the produced output buffer is returned not including
666 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
668 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
669 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
670 If BufferSize > 1 and FormatString is NULL, then ASSERT().
671 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
672 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
673 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
675 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
676 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
677 Null-terminator, then ASSERT().
679 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
681 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
682 @param FormatString Null-terminated Unicode format string.
684 @return The number of Unicode characters in the produced output buffer not including the
691 OUT CHAR16
*StartOfBuffer
,
693 IN CONST CHAR16
*FormatString
,
699 VA_START (Marker
, FormatString
);
700 return UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
704 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
705 ASCII format string and a VA_LIST argument list
707 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
709 The Unicode string is produced by parsing the format string specified by FormatString.
710 Arguments are pulled from the variable argument list specified by Marker based on the
711 contents of the format string.
712 The number of Unicode characters in the produced output buffer is returned not including
714 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
716 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
717 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
718 If BufferSize > 1 and FormatString is NULL, then ASSERT().
719 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
720 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
722 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
723 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
724 Null-terminator, then ASSERT().
726 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
728 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
729 @param FormatString Null-terminated Unicode format string.
730 @param Marker VA_LIST marker for the variable argument list.
732 @return The number of Unicode characters in the produced output buffer not including the
738 UnicodeVSPrintAsciiFormat (
739 OUT CHAR16
*StartOfBuffer
,
741 IN CONST CHAR8
*FormatString
,
745 ASSERT_UNICODE_BUFFER(StartOfBuffer
);
746 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
750 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
751 ASCII format string and variable argument list.
753 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
755 The Unicode string is produced by parsing the format string specified by FormatString.
756 Arguments are pulled from the variable argument list based on the contents of the
758 The number of Unicode characters in the produced output buffer is returned not including
760 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
762 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
763 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
764 If BufferSize > 1 and FormatString is NULL, then ASSERT().
765 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
766 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
768 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
769 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
770 Null-terminator, then ASSERT().
772 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
774 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
775 @param FormatString Null-terminated Unicode format string.
777 @return The number of Unicode characters in the produced output buffer not including the
783 UnicodeSPrintAsciiFormat (
784 OUT CHAR16
*StartOfBuffer
,
786 IN CONST CHAR8
*FormatString
,
792 VA_START (Marker
, FormatString
);
793 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
797 Converts a decimal value to a Null-terminated Unicode string.
799 Converts the decimal number specified by Value to a Null-terminated Unicode
800 string specified by Buffer containing at most Width characters. No padding of spaces
801 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
802 The number of Unicode characters in Buffer is returned not including the Null-terminator.
803 If the conversion contains more than Width characters, then only the first
804 Width characters are returned, and the total number of characters
805 required to perform the conversion is returned.
806 Additional conversion parameters are specified in Flags.
808 The Flags bit LEFT_JUSTIFY is always ignored.
809 All conversions are left justified in Buffer.
810 If Width is 0, PREFIX_ZERO is ignored in Flags.
811 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
812 are inserted every 3rd digit starting from the right.
813 If HEX_RADIX is set in Flags, then the output buffer will be
814 formatted in hexadecimal format.
815 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
816 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
817 then Buffer is padded with '0' characters so the combination of the optional '-'
818 sign character, '0' characters, digit characters for Value, and the Null-terminator
819 add up to Width characters.
820 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
821 If Buffer is NULL, then ASSERT().
822 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
823 If unsupported bits are set in Flags, then ASSERT().
824 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
825 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
827 @param Buffer Pointer to the output buffer for the produced Null-terminated
829 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
830 @param Value The 64-bit signed value to convert to a string.
831 @param Width The maximum number of Unicode characters to place in Buffer, not including
834 @return The number of Unicode characters in Buffer not including the Null-terminator.
839 UnicodeValueToString (
840 IN OUT CHAR16
*Buffer
,
846 ASSERT_UNICODE_BUFFER(Buffer
);
847 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
851 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
852 ASCII format string and a VA_LIST argument list.
854 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
856 The ASCII string is produced by parsing the format string specified by FormatString.
857 Arguments are pulled from the variable argument list specified by Marker based on
858 the contents of the format string.
859 The number of ASCII characters in the produced output buffer is returned not including
861 If BufferSize is 0, then no output buffer is produced and 0 is returned.
863 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
864 If BufferSize > 0 and FormatString is NULL, then ASSERT().
865 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
866 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
868 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
869 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
870 Null-terminator, then ASSERT().
872 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
874 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
875 @param FormatString Null-terminated Unicode format string.
876 @param Marker VA_LIST marker for the variable argument list.
878 @return The number of ASCII characters in the produced output buffer not including the
885 OUT CHAR8
*StartOfBuffer
,
887 IN CONST CHAR8
*FormatString
,
891 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
895 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
896 ASCII format string and variable argument list.
898 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
900 The ASCII string is produced by parsing the format string specified by FormatString.
901 Arguments are pulled from the variable argument list based on the contents of the
903 The number of ASCII characters in the produced output buffer is returned not including
905 If BufferSize is 0, then no output buffer is produced and 0 is returned.
907 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
908 If BufferSize > 0 and FormatString is NULL, then ASSERT().
909 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
910 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
912 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
913 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
914 Null-terminator, then ASSERT().
916 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
918 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
919 @param FormatString Null-terminated Unicode format string.
921 @return The number of ASCII characters in the produced output buffer not including the
928 OUT CHAR8
*StartOfBuffer
,
930 IN CONST CHAR8
*FormatString
,
936 VA_START (Marker
, FormatString
);
937 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
941 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
942 ASCII format string and a VA_LIST argument list.
944 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
946 The ASCII string is produced by parsing the format string specified by FormatString.
947 Arguments are pulled from the variable argument list specified by Marker based on
948 the contents of the format string.
949 The number of ASCII characters in the produced output buffer is returned not including
951 If BufferSize is 0, then no output buffer is produced and 0 is returned.
953 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
954 If BufferSize > 0 and FormatString is NULL, then ASSERT().
955 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
956 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
957 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
959 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
960 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
961 Null-terminator, then ASSERT().
963 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
965 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
966 @param FormatString Null-terminated Unicode format string.
967 @param Marker VA_LIST marker for the variable argument list.
969 @return The number of ASCII characters in the produced output buffer not including the
975 AsciiVSPrintUnicodeFormat (
976 OUT CHAR8
*StartOfBuffer
,
978 IN CONST CHAR16
*FormatString
,
982 ASSERT_UNICODE_BUFFER (FormatString
);
983 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
987 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
988 ASCII format string and variable argument list.
990 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
992 The ASCII string is produced by parsing the format string specified by FormatString.
993 Arguments are pulled from the variable argument list based on the contents of the
995 The number of ASCII characters in the produced output buffer is returned not including
997 If BufferSize is 0, then no output buffer is produced and 0 is returned.
999 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
1000 If BufferSize > 0 and FormatString is NULL, then ASSERT().
1001 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
1002 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
1003 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
1005 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
1006 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
1007 Null-terminator, then ASSERT().
1009 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
1011 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
1012 @param FormatString Null-terminated Unicode format string.
1014 @return The number of ASCII characters in the produced output buffer not including the
1020 AsciiSPrintUnicodeFormat (
1021 OUT CHAR8
*StartOfBuffer
,
1022 IN UINTN BufferSize
,
1023 IN CONST CHAR16
*FormatString
,
1029 VA_START (Marker
, FormatString
);
1030 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1035 Converts a decimal value to a Null-terminated ASCII string.
1037 Converts the decimal number specified by Value to a Null-terminated ASCII string
1038 specified by Buffer containing at most Width characters. No padding of spaces
1040 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1041 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1042 If the conversion contains more than Width characters, then only the first Width
1043 characters are returned, and the total number of characters required to perform
1044 the conversion is returned.
1045 Additional conversion parameters are specified in Flags.
1046 The Flags bit LEFT_JUSTIFY is always ignored.
1047 All conversions are left justified in Buffer.
1048 If Width is 0, PREFIX_ZERO is ignored in Flags.
1049 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1050 are inserted every 3rd digit starting from the right.
1051 If HEX_RADIX is set in Flags, then the output buffer will be
1052 formatted in hexadecimal format.
1053 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
1054 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1055 then Buffer is padded with '0' characters so the combination of the optional '-'
1056 sign character, '0' characters, digit characters for Value, and the Null-terminator
1057 add up to Width characters.
1059 If Buffer is NULL, then ASSERT().
1060 If unsupported bits are set in Flags, then ASSERT().
1061 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
1062 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1064 @param Buffer Pointer to the output buffer for the produced Null-terminated
1066 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1067 @param Value The 64-bit signed value to convert to a string.
1068 @param Width The maximum number of ASCII characters to place in Buffer, not including
1069 the Null-terminator.
1071 @return The number of ASCII characters in Buffer not including the Null-terminator.
1076 AsciiValueToString (
1077 IN OUT CHAR8
*Buffer
,
1083 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);