4 Copyright (c) 2006, 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 STATIC 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 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
783 ASCII format string and a VA_LIST argument list.
785 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
787 The ASCII string is produced by parsing the format string specified by FormatString.
788 Arguments are pulled from the variable argument list specified by Marker based on
789 the contents of the format string.
790 The number of ASCII characters in the produced output buffer is returned not including
792 If BufferSize is 0, then no output buffer is produced and 0 is returned.
794 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
795 If BufferSize > 0 and FormatString is NULL, then ASSERT().
796 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
797 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
799 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
800 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
801 Null-terminator, then ASSERT().
803 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
805 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
806 @param FormatString Null-terminated Unicode format string.
807 @param Marker VA_LIST marker for the variable argument list.
809 @return The number of ASCII characters in the produced output buffer not including the
816 OUT CHAR8
*StartOfBuffer
,
818 IN CONST CHAR8
*FormatString
,
822 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
826 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
827 ASCII format string and variable argument list.
829 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
831 The ASCII string is produced by parsing the format string specified by FormatString.
832 Arguments are pulled from the variable argument list based on the contents of the
834 The number of ASCII characters in the produced output buffer is returned not including
836 If BufferSize is 0, then no output buffer is produced and 0 is returned.
838 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
839 If BufferSize > 0 and FormatString is NULL, then ASSERT().
840 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
841 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
843 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
844 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
845 Null-terminator, then ASSERT().
847 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
849 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
850 @param FormatString Null-terminated Unicode format string.
852 @return The number of ASCII characters in the produced output buffer not including the
859 OUT CHAR8
*StartOfBuffer
,
861 IN CONST CHAR8
*FormatString
,
867 VA_START (Marker
, FormatString
);
868 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
872 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
873 ASCII format string and a VA_LIST argument list.
875 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
877 The ASCII string is produced by parsing the format string specified by FormatString.
878 Arguments are pulled from the variable argument list specified by Marker based on
879 the contents of the format string.
880 The number of ASCII characters in the produced output buffer is returned not including
882 If BufferSize is 0, then no output buffer is produced and 0 is returned.
884 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
885 If BufferSize > 0 and FormatString is NULL, then ASSERT().
886 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
887 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
889 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
890 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
891 Null-terminator, then ASSERT().
893 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
895 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
896 @param FormatString Null-terminated Unicode format string.
897 @param Marker VA_LIST marker for the variable argument list.
899 @return The number of ASCII characters in the produced output buffer not including the
905 AsciiVSPrintUnicodeFormat (
906 OUT CHAR8
*StartOfBuffer
,
908 IN CONST CHAR16
*FormatString
,
912 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
916 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
917 ASCII format string and variable argument list.
919 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
921 The ASCII string is produced by parsing the format string specified by FormatString.
922 Arguments are pulled from the variable argument list based on the contents of the
924 The number of ASCII characters in the produced output buffer is returned not including
926 If BufferSize is 0, then no output buffer is produced and 0 is returned.
928 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
929 If BufferSize > 0 and FormatString is NULL, then ASSERT().
930 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
931 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
933 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
934 contains more than PcdMaximumAsciiStringLength ASCII characters not including the
935 Null-terminator, then ASSERT().
937 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
939 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
940 @param FormatString Null-terminated Unicode format string.
942 @return The number of ASCII characters in the produced output buffer not including the
948 AsciiSPrintUnicodeFormat (
949 OUT CHAR8
*StartOfBuffer
,
951 IN CONST CHAR16
*FormatString
,
957 VA_START (Marker
, FormatString
);
958 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
962 Converts a decimal value to a Null-terminated Unicode string.
964 Converts the decimal number specified by Value to a Null-terminated Unicode
965 string specified by Buffer containing at most Width characters.
966 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
967 The number of Unicode characters in Buffer is returned not including the Null-terminator.
968 If the conversion contains more than Width characters, then only the first
969 Width characters are returned, and the total number of characters
970 required to perform the conversion is returned.
971 Additional conversion parameters are specified in Flags.
972 The Flags bit LEFT_JUSTIFY is always ignored.
973 All conversions are left justified in Buffer.
974 If Width is 0, PREFIX_ZERO is ignored in Flags.
975 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
976 are inserted every 3rd digit starting from the right.
977 If Value is < 0, then the fist character in Buffer is a '-'.
978 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
979 then Buffer is padded with '0' characters so the combination of the optional '-'
980 sign character, '0' characters, digit characters for Value, and the Null-terminator
981 add up to Width characters.
983 If Buffer is NULL, then ASSERT().
984 If unsupported bits are set in Flags, then ASSERT().
985 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
987 @param Buffer Pointer to the output buffer for the produced Null-terminated
989 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
990 @param Value The 64-bit signed value to convert to a string.
991 @param Width The maximum number of Unicode characters to place in Buffer, not including
994 @return The number of Unicode characters in Buffer not including the Null-terminator.
999 UnicodeValueToString (
1000 IN OUT CHAR16
*Buffer
,
1006 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
1010 Converts a decimal value to a Null-terminated ASCII string.
1012 Converts the decimal number specified by Value to a Null-terminated ASCII string
1013 specified by Buffer containing at most Width characters.
1014 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
1015 The number of ASCII characters in Buffer is returned not including the Null-terminator.
1016 If the conversion contains more than Width characters, then only the first Width
1017 characters are returned, and the total number of characters required to perform
1018 the conversion is returned.
1019 Additional conversion parameters are specified in Flags.
1020 The Flags bit LEFT_JUSTIFY is always ignored.
1021 All conversions are left justified in Buffer.
1022 If Width is 0, PREFIX_ZERO is ignored in Flags.
1023 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
1024 are inserted every 3rd digit starting from the right.
1025 If Value is < 0, then the fist character in Buffer is a '-'.
1026 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer
1027 is padded with '0' characters so the combination of the optional '-'
1028 sign character, '0' characters, digit characters for Value, and the
1029 Null-terminator add up to Width characters.
1031 If Buffer is NULL, then ASSERT().
1032 If unsupported bits are set in Flags, then ASSERT().
1033 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1035 @param Buffer Pointer to the output buffer for the produced Null-terminated
1037 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1038 @param Value The 64-bit signed value to convert to a string.
1039 @param Width The maximum number of ASCII characters to place in Buffer, not including
1040 the Null-terminator.
1042 @return The number of ASCII characters in Buffer not including the Null-terminator.
1047 AsciiValueToString (
1048 IN OUT CHAR8
*Buffer
,
1054 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 1);