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
22 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
*StatusString
[] = {
23 "Success", // RETURN_SUCCESS = 0
24 "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
25 "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
26 "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
27 "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
28 "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
29 "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
30 "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
31 "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
32 "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
33 "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
34 "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
35 "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
36 "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
37 "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
38 "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
39 "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
40 "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
41 "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
42 "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
43 "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
44 "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
45 "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
46 "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
47 "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
48 "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
49 "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
50 "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
51 "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
55 Worker function that produces a Null-terminated string in an output buffer
56 based on a Null-terminated format string and a VA_LIST argument list.
58 VSPrint function to process format and place the results in Buffer. Since a
59 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
60 this is the main print working routine.
62 @param Buffer Character buffer to print the results of the parsing
64 @param BufferSize Maximum number of characters to put into buffer.
65 @param Flags Intial flags value.
66 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
67 @param Format Null-terminated format string.
68 @param Marker Vararg list consumed by processing Format.
70 @return Number of characters printed not including the Null-terminator.
78 IN CONST CHAR8
*Format
,
82 CHAR8
*OriginalBuffer
;
84 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
85 UINTN BytesPerOutputCharacter
;
86 UINTN BytesPerFormatCharacter
;
88 UINTN FormatCharacter
;
92 CONST CHAR8
*ArgumentString
;
98 INTN BytesPerArgumentCharacter
;
99 UINTN ArgumentCharacter
;
107 RETURN_STATUS Status
;
109 if (BufferSize
== 0) {
112 ASSERT (Buffer
!= NULL
);
114 if ((Flags
& OUTPUT_UNICODE
) != 0) {
115 BytesPerOutputCharacter
= 2;
117 BytesPerOutputCharacter
= 1;
121 // Reserve space for the Null terminator.
124 OriginalBuffer
= Buffer
;
126 // Set the tag for the end of the input Buffer.
128 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
130 if ((Flags
& FORMAT_UNICODE
) != 0) {
132 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
133 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
135 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
136 BytesPerFormatCharacter
= 2;
140 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
141 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
143 ASSERT (AsciiStrSize (Format
) != 0);
144 BytesPerFormatCharacter
= 1;
151 // Get the first character from the format string
153 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
156 // Loop until the end of the format string is reached or the output buffer is full
158 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
160 // Clear all the flag bits except those that may have been passed in
162 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
165 // Set the default width to zero, and the default precision to 1
175 switch (FormatCharacter
) {
178 // Parse Flags and Width
180 for (Done
= FALSE
; !Done
; ) {
181 Format
+= BytesPerFormatCharacter
;
182 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
183 switch (FormatCharacter
) {
188 Flags
|= LEFT_JUSTIFY
;
191 Flags
|= PREFIX_SIGN
;
194 Flags
|= PREFIX_BLANK
;
204 if ((Flags
& PRECISION
) == 0) {
205 Flags
|= PAD_TO_WIDTH
;
206 Width
= VA_ARG (Marker
, UINTN
);
208 Precision
= VA_ARG (Marker
, UINTN
);
212 if ((Flags
& PRECISION
) == 0) {
213 Flags
|= PREFIX_ZERO
;
224 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
225 Count
= (Count
* 10) + FormatCharacter
- '0';
226 Format
+= BytesPerFormatCharacter
;
227 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
229 Format
-= BytesPerFormatCharacter
;
230 if ((Flags
& PRECISION
) == 0) {
231 Flags
|= PAD_TO_WIDTH
;
240 // Make no output if Format string terminates unexpectedly when
241 // looking up for flag, width, precision and type.
243 Format
-= BytesPerFormatCharacter
;
246 // break skipped on purpose.
255 // Handle each argument type
257 switch (FormatCharacter
) {
260 // Flag space, +, 0, L & l are invalid for type p.
262 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
263 if (sizeof (VOID
*) > 4) {
267 Flags
|= PREFIX_ZERO
;
269 // break skipped on purpose
274 // break skipped on purpose
277 if ((Flags
& LONG_TYPE
) == 0) {
278 Value
= (VA_ARG (Marker
, int));
280 Value
= VA_ARG (Marker
, INT64
);
282 if ((Flags
& PREFIX_BLANK
) != 0) {
285 if ((Flags
& PREFIX_SIGN
) != 0) {
288 if ((Flags
& COMMA_TYPE
) != 0) {
291 if ((Flags
& RADIX_HEX
) == 0) {
294 Flags
&= (~PREFIX_ZERO
);
298 Flags
|= PREFIX_SIGN
;
305 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
306 Value
= (unsigned int)Value
;
310 // Convert Value to a reversed string
312 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
313 if (Value
== 0 && Precision
== 0) {
316 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
322 if (Comma
&& Count
!= 0) {
323 Count
+= ((Count
- 1) / 3);
329 Flags
|= ARGUMENT_REVERSED
;
331 if ((Flags
& PREFIX_ZERO
) != 0) {
332 if ((Flags
& LEFT_JUSTIFY
) == 0) {
333 if ((Flags
& PAD_TO_WIDTH
) != 0) {
334 if ((Flags
& PRECISION
) == 0) {
344 Flags
|= ARGUMENT_UNICODE
;
346 // break skipped on purpose
349 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
350 if (ArgumentString
== NULL
) {
351 Flags
&= (~ARGUMENT_UNICODE
);
352 ArgumentString
= "<null string>";
357 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
358 ArgumentString
= (CHAR8
*)&Character
;
359 Flags
|= ARGUMENT_UNICODE
;
363 TmpGuid
= VA_ARG (Marker
, GUID
*);
364 if (TmpGuid
== NULL
) {
365 ArgumentString
= "<null guid>";
369 MAXIMUM_VALUE_CHARACTERS
,
371 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
384 ArgumentString
= ValueBuffer
;
389 TmpTime
= VA_ARG (Marker
, TIME
*);
390 if (TmpTime
== NULL
) {
391 ArgumentString
= "<null time>";
395 MAXIMUM_VALUE_CHARACTERS
,
397 "%02d/%02d/%04d %02d:%02d",
404 ArgumentString
= ValueBuffer
;
409 Status
= VA_ARG (Marker
, RETURN_STATUS
);
410 ArgumentString
= ValueBuffer
;
411 if (RETURN_ERROR (Status
)) {
415 Index
= Status
& ~MAX_BIT
;
416 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
417 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
421 if (Index
<= WARNING_STATUS_NUMBER
) {
422 ArgumentString
= StatusString
[Index
];
425 if (ArgumentString
== ValueBuffer
) {
426 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
431 ArgumentString
= "\n\r";
437 // if the type is '%' or unknown, then print it to the screen
439 ArgumentString
= (CHAR8
*)&FormatCharacter
;
440 Flags
|= ARGUMENT_UNICODE
;
446 ArgumentString
= "\n\r";
450 ArgumentString
= (CHAR8
*)&FormatCharacter
;
451 Flags
|= ARGUMENT_UNICODE
;
456 // Retrieve the ArgumentString attriubutes
458 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
459 ArgumentMask
= 0xffff;
460 BytesPerArgumentCharacter
= 2;
463 BytesPerArgumentCharacter
= 1;
465 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
466 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
469 // Compute the number of characters in ArgumentString and store it in Count
470 // ArgumentString is either null-terminated, or it contains Precision characters
472 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
473 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
474 if (ArgumentCharacter
== 0) {
480 if (Precision
< Count
) {
485 // Pad before the string
487 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
488 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
493 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
495 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
497 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
499 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
504 // Output the Prefix character if it is present
512 // Copy the string into the output buffer performing the required type conversions
514 while (Index
< Count
) {
515 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
517 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
518 ArgumentString
+= BytesPerArgumentCharacter
;
526 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
533 // Pad after the string
535 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
536 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
540 // Get the next character from the format string
542 Format
+= BytesPerFormatCharacter
;
545 // Get the next character from the format string
547 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
551 // Null terminate the Unicode or ASCII string
553 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
555 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
556 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
558 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
560 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
561 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
563 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
565 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
569 Worker function that produces a Null-terminated string in an output buffer
570 based on a Null-terminated format string and variable argument list.
572 VSPrint function to process format and place the results in Buffer. Since a
573 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
574 this is the main print working routine.
576 @param Buffer Character buffer to print the results of the parsing
578 @param BufferSize Maximum number of characters to put into buffer.
580 @param Flags Intial flags value.
581 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
582 @param FormatString Null-terminated format string.
584 @return Number of characters printed not including the Null-terminator.
589 OUT CHAR8
*StartOfBuffer
,
592 IN CONST CHAR8
*FormatString
,
598 VA_START (Marker
, FormatString
);
599 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
603 Produces a Null-terminated Unicode string in an output buffer based on
604 a Null-terminated Unicode format string and a VA_LIST argument list
606 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
608 The Unicode string is produced by parsing the format string specified by FormatString.
609 Arguments are pulled from the variable argument list specified by Marker based on the
610 contents of the format string.
611 The number of Unicode characters in the produced output buffer is returned not including
613 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
615 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
616 If BufferSize > 1 and FormatString is NULL, then ASSERT().
617 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
618 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
620 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
621 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
622 Null-terminator, then ASSERT().
624 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
626 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
627 @param FormatString Null-terminated Unicode format string.
628 @param Marker VA_LIST marker for the variable argument list.
630 @return The number of Unicode characters in the produced output buffer not including the
637 OUT CHAR16
*StartOfBuffer
,
639 IN CONST CHAR16
*FormatString
,
643 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
647 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
648 Unicode format string and variable argument list.
650 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
652 The Unicode string is produced by parsing the format string specified by FormatString.
653 Arguments are pulled from the variable argument list based on the contents of the format string.
654 The number of Unicode characters in the produced output buffer is returned not including
656 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
658 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
659 If BufferSize > 1 and FormatString is NULL, then ASSERT().
660 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
661 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
663 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
664 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
665 Null-terminator, then ASSERT().
667 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
669 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
670 @param FormatString Null-terminated Unicode format string.
672 @return The number of Unicode characters in the produced output buffer not including the
679 OUT CHAR16
*StartOfBuffer
,
681 IN CONST CHAR16
*FormatString
,
687 VA_START (Marker
, FormatString
);
688 return UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
692 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
693 ASCII format string and a VA_LIST argument list
695 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
697 The Unicode string is produced by parsing the format string specified by FormatString.
698 Arguments are pulled from the variable argument list specified by Marker based on the
699 contents of the format string.
700 The number of Unicode characters in the produced output buffer is returned not including
702 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
704 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
705 If BufferSize > 1 and FormatString is NULL, then ASSERT().
706 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
707 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
709 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
710 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
711 Null-terminator, then ASSERT().
713 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
715 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
716 @param FormatString Null-terminated Unicode format string.
717 @param Marker VA_LIST marker for the variable argument list.
719 @return The number of Unicode characters in the produced output buffer not including the
725 UnicodeVSPrintAsciiFormat (
726 OUT CHAR16
*StartOfBuffer
,
728 IN CONST CHAR8
*FormatString
,
732 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
736 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
737 ASCII format string and variable argument list.
739 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
741 The Unicode string is produced by parsing the format string specified by FormatString.
742 Arguments are pulled from the variable argument list based on the contents of the
744 The number of Unicode characters in the produced output buffer is returned not including
746 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
748 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
749 If BufferSize > 1 and FormatString is NULL, then ASSERT().
750 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
751 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
753 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
754 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
755 Null-terminator, then ASSERT().
757 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
759 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
760 @param FormatString Null-terminated Unicode format string.
762 @return The number of Unicode characters in the produced output buffer not including the
768 UnicodeSPrintAsciiFormat (
769 OUT CHAR16
*StartOfBuffer
,
771 IN CONST CHAR8
*FormatString
,
777 VA_START (Marker
, FormatString
);
778 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
782 Converts a decimal value to a Null-terminated Unicode string.
784 Converts the decimal number specified by Value to a Null-terminated Unicode
785 string specified by Buffer containing at most Width characters. No padding of spaces
786 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
787 The number of Unicode characters in Buffer is returned not including the Null-terminator.
788 If the conversion contains more than Width characters, then only the first
789 Width characters are returned, and the total number of characters
790 required to perform the conversion is returned.
791 Additional conversion parameters are specified in Flags.
793 The Flags bit LEFT_JUSTIFY is always ignored.
794 All conversions are left justified in Buffer.
795 If Width is 0, PREFIX_ZERO is ignored in Flags.
796 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
797 are inserted every 3rd digit starting from the right.
798 If HEX_RADIX is set in Flags, then the output buffer will be
799 formatted in hexadecimal format.
800 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
801 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
802 then Buffer is padded with '0' characters so the combination of the optional '-'
803 sign character, '0' characters, digit characters for Value, and the Null-terminator
804 add up to Width characters.
805 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
806 If Buffer is NULL, then ASSERT().
807 If unsupported bits are set in Flags, then ASSERT().
808 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
809 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
811 @param Buffer Pointer to the output buffer for the produced Null-terminated
813 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
814 @param Value The 64-bit signed value to convert to a string.
815 @param Width The maximum number of Unicode characters to place in Buffer, not including
818 @return The number of Unicode characters in Buffer not including the Null-terminator.
823 UnicodeValueToString (
824 IN OUT CHAR16
*Buffer
,
830 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
834 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
835 ASCII format string and a VA_LIST argument list.
837 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
839 The ASCII string is produced by parsing the format string specified by FormatString.
840 Arguments are pulled from the variable argument list specified by Marker based on
841 the contents of the format string.
842 The number of ASCII characters in the produced output buffer is returned not including
844 If BufferSize is 0, then no output buffer is produced and 0 is returned.
846 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
847 If BufferSize > 0 and FormatString is NULL, then ASSERT().
848 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
849 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
851 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
852 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
853 Null-terminator, then ASSERT().
855 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
857 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
858 @param FormatString Null-terminated Unicode format string.
859 @param Marker VA_LIST marker for the variable argument list.
861 @return The number of ASCII characters in the produced output buffer not including the
868 OUT CHAR8
*StartOfBuffer
,
870 IN CONST CHAR8
*FormatString
,
874 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
878 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
879 ASCII format string and variable argument list.
881 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
883 The ASCII string is produced by parsing the format string specified by FormatString.
884 Arguments are pulled from the variable argument list based on the contents of the
886 The number of ASCII characters in the produced output buffer is returned not including
888 If BufferSize is 0, then no output buffer is produced and 0 is returned.
890 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
891 If BufferSize > 0 and FormatString is NULL, then ASSERT().
892 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
893 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
895 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
896 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
897 Null-terminator, then ASSERT().
899 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
901 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
902 @param FormatString Null-terminated Unicode format string.
904 @return The number of ASCII characters in the produced output buffer not including the
911 OUT CHAR8
*StartOfBuffer
,
913 IN CONST CHAR8
*FormatString
,
919 VA_START (Marker
, FormatString
);
920 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
924 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
925 ASCII format string and a VA_LIST argument list.
927 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
929 The ASCII string is produced by parsing the format string specified by FormatString.
930 Arguments are pulled from the variable argument list specified by Marker based on
931 the contents of the format string.
932 The number of ASCII characters in the produced output buffer is returned not including
934 If BufferSize is 0, then no output buffer is produced and 0 is returned.
936 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
937 If BufferSize > 0 and FormatString is NULL, then ASSERT().
938 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
939 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
941 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
942 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
943 Null-terminator, then ASSERT().
945 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
947 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
948 @param FormatString Null-terminated Unicode format string.
949 @param Marker VA_LIST marker for the variable argument list.
951 @return The number of ASCII characters in the produced output buffer not including the
957 AsciiVSPrintUnicodeFormat (
958 OUT CHAR8
*StartOfBuffer
,
960 IN CONST CHAR16
*FormatString
,
964 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
968 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
969 ASCII format string and variable argument list.
971 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
973 The ASCII string is produced by parsing the format string specified by FormatString.
974 Arguments are pulled from the variable argument list based on the contents of the
976 The number of ASCII characters in the produced output buffer is returned not including
978 If BufferSize is 0, then no output buffer is produced and 0 is returned.
980 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
981 If BufferSize > 0 and FormatString is NULL, then ASSERT().
982 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
983 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
985 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
986 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
987 Null-terminator, then ASSERT().
989 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
991 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
992 @param FormatString Null-terminated Unicode format string.
994 @return The number of ASCII characters in the produced output buffer not including the
1000 AsciiSPrintUnicodeFormat (
1001 OUT CHAR8
*StartOfBuffer
,
1002 IN UINTN BufferSize
,
1003 IN CONST CHAR16
*FormatString
,
1009 VA_START (Marker
, FormatString
);
1010 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
1015 Converts a decimal value to a Null-terminated ASCII string.
1017 Converts the decimal number specified by Value to a Null-terminated ASCII string
1018 specified by Buffer containing at most Width characters. No padding of spaces
1020 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1021 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1022 If the conversion contains more than Width characters, then only the first Width
1023 characters are returned, and the total number of characters required to perform
1024 the conversion is returned.
1025 Additional conversion parameters are specified in Flags.
1026 The Flags bit LEFT_JUSTIFY is always ignored.
1027 All conversions are left justified in Buffer.
1028 If Width is 0, PREFIX_ZERO is ignored in Flags.
1029 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1030 are inserted every 3rd digit starting from the right.
1031 If HEX_RADIX is set in Flags, then the output buffer will be
1032 formatted in hexadecimal format.
1033 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
1034 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
1035 then Buffer is padded with '0' characters so the combination of the optional '-'
1036 sign character, '0' characters, digit characters for Value, and the Null-terminator
1037 add up to Width characters.
1039 If Buffer is NULL, then ASSERT().
1040 If unsupported bits are set in Flags, then ASSERT().
1041 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
1042 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1044 @param Buffer Pointer to the output buffer for the produced Null-terminated
1046 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1047 @param Value The 64-bit signed value to convert to a string.
1048 @param Width The maximum number of ASCII characters to place in Buffer, not including
1049 the Null-terminator.
1051 @return The number of ASCII characters in Buffer not including the Null-terminator.
1056 AsciiValueToString (
1057 IN OUT CHAR8
*Buffer
,
1063 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 1);