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.
78 IN CONST CHAR8
*Format
,
82 CHAR8
*OriginalBuffer
;
83 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
84 UINTN BytesPerOutputCharacter
;
85 UINTN BytesPerFormatCharacter
;
87 UINTN FormatCharacter
;
91 CONST CHAR8
*ArgumentString
;
97 INTN BytesPerArgumentCharacter
;
98 UINTN ArgumentCharacter
;
106 RETURN_STATUS Status
;
108 if (BufferSize
== 0) {
111 ASSERT (Buffer
!= NULL
);
113 OriginalBuffer
= Buffer
;
115 if ((Flags
& OUTPUT_UNICODE
) != 0) {
116 BytesPerOutputCharacter
= 2;
118 BytesPerOutputCharacter
= 1;
120 if ((Flags
& FORMAT_UNICODE
) != 0) {
122 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
123 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
125 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
126 BytesPerFormatCharacter
= 2;
130 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
131 // Ascii characters if PcdMaximumUnicodeStringLength is not zero.
133 ASSERT (AsciiStrSize (Format
) != 0);
134 BytesPerFormatCharacter
= 1;
139 // Reserve space for the Null terminator.
144 // Get the first character from the format string
146 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
149 // Loop until the end of the format string is reached or the output buffer is full
151 while (FormatCharacter
!= 0 && BufferSize
> 0) {
153 // Clear all the flag bits except those that may have been passed in
155 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
158 // Set the default width to zero, and the default precision to 1
168 switch (FormatCharacter
) {
171 // Parse Flags and Width
173 for (Done
= FALSE
; !Done
; ) {
174 Format
+= BytesPerFormatCharacter
;
175 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
176 switch (FormatCharacter
) {
181 Flags
|= LEFT_JUSTIFY
;
184 Flags
|= PREFIX_SIGN
;
187 Flags
|= PREFIX_BLANK
;
197 if ((Flags
& PRECISION
) == 0) {
198 Flags
|= PAD_TO_WIDTH
;
199 Width
= VA_ARG (Marker
, UINTN
);
201 Precision
= VA_ARG (Marker
, UINTN
);
205 if ((Flags
& PRECISION
) == 0) {
206 Flags
|= PREFIX_ZERO
;
217 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
218 Count
= (Count
* 10) + FormatCharacter
- '0';
219 Format
+= BytesPerFormatCharacter
;
220 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
222 Format
-= BytesPerFormatCharacter
;
223 if ((Flags
& PRECISION
) == 0) {
224 Flags
|= PAD_TO_WIDTH
;
233 // Make no output if Format string terminates unexpectedly when
234 // looking up for flag, width, precision and type.
236 Format
-= BytesPerFormatCharacter
;
239 // break skiped on purpose.
248 // Limit the maximum field width to the remaining characters in the output buffer
250 if (Width
> BufferSize
) {
255 // Handle each argument type
257 switch (FormatCharacter
) {
259 if (sizeof (VOID
*) > 4) {
263 Flags
|= PREFIX_ZERO
;
265 // break skiped on purpose
270 // break skiped on purpose
273 if ((Flags
& LONG_TYPE
) == 0) {
274 Value
= (VA_ARG (Marker
, int));
276 Value
= VA_ARG (Marker
, INT64
);
278 if ((Flags
& PREFIX_BLANK
) != 0) {
281 if ((Flags
& PREFIX_SIGN
) != 0) {
284 if ((Flags
& COMMA_TYPE
) != 0) {
287 if ((Flags
& RADIX_HEX
) == 0) {
290 Flags
&= (~PREFIX_ZERO
);
294 Flags
|= PREFIX_SIGN
;
301 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
302 Value
= (unsigned int)Value
;
306 // Convert Value to a reversed string
308 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
309 if (Value
== 0 && Precision
== 0) {
312 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
318 if (Comma
&& Count
!= 0) {
319 Count
+= ((Count
- 1) / 3);
325 Flags
|= ARGUMENT_REVERSED
;
327 if ((Flags
& PREFIX_ZERO
) != 0) {
328 if ((Flags
& LEFT_JUSTIFY
) == 0) {
329 if ((Flags
& PAD_TO_WIDTH
) != 0) {
330 if ((Flags
& PRECISION
) == 0) {
340 Flags
|= ARGUMENT_UNICODE
;
342 // break skipped on purpose
345 ArgumentString
= (CHAR8
*)VA_ARG (Marker
, CHAR8
*);
346 if (ArgumentString
== NULL
) {
347 Flags
&= (~ARGUMENT_UNICODE
);
348 ArgumentString
= "<null string>";
353 Character
= VA_ARG (Marker
, UINTN
) & 0xffff;
354 ArgumentString
= (CHAR8
*)&Character
;
355 Flags
|= ARGUMENT_UNICODE
;
359 TmpGuid
= VA_ARG (Marker
, GUID
*);
360 if (TmpGuid
== NULL
) {
361 ArgumentString
= "<null guid>";
365 MAXIMUM_VALUE_CHARACTERS
,
367 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
380 ArgumentString
= ValueBuffer
;
385 TmpTime
= VA_ARG (Marker
, TIME
*);
386 if (TmpTime
== NULL
) {
387 ArgumentString
= "<null time>";
391 MAXIMUM_VALUE_CHARACTERS
,
393 "%02d/%02d/%04d %02d:%02d",
400 ArgumentString
= ValueBuffer
;
405 Status
= VA_ARG (Marker
, RETURN_STATUS
);
406 ArgumentString
= ValueBuffer
;
407 if (RETURN_ERROR (Status
)) {
411 Index
= Status
& ~MAX_BIT
;
412 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
413 ArgumentString
= StatusString
[Index
+ WARNING_STATUS_NUMBER
];
417 if (Index
<= WARNING_STATUS_NUMBER
) {
418 ArgumentString
= StatusString
[Index
];
421 if (ArgumentString
== ValueBuffer
) {
422 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
427 ArgumentString
= "\n\r";
433 // if the type is '%' or unknown, then print it to the screen
435 ArgumentString
= (CHAR8
*)&FormatCharacter
;
436 Flags
|= ARGUMENT_UNICODE
;
442 ArgumentString
= "\n\r";
446 ArgumentString
= (CHAR8
*)&FormatCharacter
;
447 Flags
|= ARGUMENT_UNICODE
;
452 // Retrieve the ArgumentString attriubutes
454 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
455 ArgumentMask
= 0xffff;
456 BytesPerArgumentCharacter
= 2;
459 BytesPerArgumentCharacter
= 1;
461 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
462 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
465 // Compute the number of characters in ArgumentString and store it in Count
466 // ArgumentString is either null-terminated, or it contains Precision characters
468 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
469 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
470 if (ArgumentCharacter
== 0) {
477 // Limit the length of the string to append to the remaining characters in the output buffer
479 if (Count
> BufferSize
) {
482 if (Precision
< Count
) {
487 // Pad before the string
489 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
490 Buffer
= BasePrintLibFillBuffer (Buffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
495 Buffer
= BasePrintLibFillBuffer (Buffer
, 1, Prefix
, BytesPerOutputCharacter
);
497 Buffer
= BasePrintLibFillBuffer (Buffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
499 Buffer
= BasePrintLibFillBuffer (Buffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
501 Buffer
= BasePrintLibFillBuffer (Buffer
, 1, Prefix
, BytesPerOutputCharacter
);
506 // Output the Prefix character if it is present
514 // Copy the string into the output buffer performing the required type conversions
516 while (Index
< Count
) {
517 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
519 Buffer
= BasePrintLibFillBuffer (Buffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
520 ArgumentString
+= BytesPerArgumentCharacter
;
528 Buffer
= BasePrintLibFillBuffer (Buffer
, 1, ',', BytesPerOutputCharacter
);
535 // Pad after the string
537 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
538 Buffer
= BasePrintLibFillBuffer (Buffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
542 // Reduce the number of characters
547 // Get the next character from the format string
549 Format
+= BytesPerFormatCharacter
;
552 // Get the next character from the format string
554 FormatCharacter
= (*Format
| (*(Format
+ 1) << 8)) & FormatMask
;
558 // Null terminate the Unicode or ASCII string
560 Buffer
= BasePrintLibFillBuffer (Buffer
, 1, 0, BytesPerOutputCharacter
);
562 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
563 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
565 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
567 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
568 // Ascii characters if PcdMaximumUnicodeStringLength is not zero.
570 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
573 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
577 Worker function that produces a Null-terminated string in an output buffer
578 based on a Null-terminated format string and variable argument list.
580 VSPrint function to process format and place the results in Buffer. Since a
581 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
582 this is the main print working routine
584 @param Buffer Character buffer to print the results of the parsing
586 @param BufferSize Maximum number of characters to put into buffer.
588 @param Flags Intial flags value.
589 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
590 @param FormatString Null-terminated format string.
592 @return Number of characters printed.
597 OUT CHAR8
*StartOfBuffer
,
600 IN CONST CHAR8
*FormatString
,
606 VA_START (Marker
, FormatString
);
607 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
);
611 Produces a Null-terminated Unicode string in an output buffer based on
612 a Null-terminated Unicode format string and a VA_LIST argument list
614 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
616 The Unicode string is produced by parsing the format string specified by FormatString.
617 Arguments are pulled from the variable argument list specified by Marker based on the
618 contents of the format string.
619 The length of the produced output buffer is returned.
620 If BufferSize is 0, then no output buffer is produced and 0 is returned.
622 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
623 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
624 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
625 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
626 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
627 contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
629 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
631 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
632 @param FormatString Null-terminated Unicode format string.
633 @param Marker VA_LIST marker for the variable argument list.
635 @return return Length of the produced output buffer.
641 OUT CHAR16
*StartOfBuffer
,
643 IN CONST CHAR16
*FormatString
,
647 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
651 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
652 Unicode format string and variable argument list.
654 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
656 The Unicode string is produced by parsing the format string specified by FormatString.
657 Arguments are pulled from the variable argument list based on the contents of the format string.
658 The length of the produced output buffer is returned.
659 If BufferSize is 0, then no output buffer is produced and 0 is returned.
661 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
662 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
663 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
664 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
665 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
666 contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
668 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
670 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
671 @param FormatString Null-terminated Unicode format string.
673 @return Length of the produced output buffer.
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 length of the produced output buffer is returned.
701 If BufferSize is 0, then no output buffer is produced and 0 is returned.
703 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
704 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
705 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
706 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
707 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
708 contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
710 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
712 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
713 @param FormatString Null-terminated Unicode format string.
714 @param Marker VA_LIST marker for the variable argument list.
716 @return Length of the produced output buffer.
721 UnicodeVSPrintAsciiFormat (
722 OUT CHAR16
*StartOfBuffer
,
724 IN CONST CHAR8
*FormatString
,
728 return BasePrintLibVSPrint ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
,FormatString
, Marker
);
732 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
733 ASCII format string and variable argument list.
735 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
737 The Unicode string is produced by parsing the format string specified by FormatString.
738 Arguments are pulled from the variable argument list based on the contents of the
740 The length of the produced output buffer is returned.
741 If BufferSize is 0, then no output buffer is produced and 0 is returned.
743 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
744 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
745 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
746 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
747 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
748 contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
750 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
752 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
753 @param FormatString Null-terminated Unicode format string.
755 @return Length of the produced output buffer.
760 UnicodeSPrintAsciiFormat (
761 OUT CHAR16
*StartOfBuffer
,
763 IN CONST CHAR8
*FormatString
,
769 VA_START (Marker
, FormatString
);
770 return UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
774 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
775 ASCII format string and a VA_LIST argument list.
777 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
779 The ASCII string is produced by parsing the format string specified by FormatString.
780 Arguments are pulled from the variable argument list specified by Marker based on
781 the contents of the format string.
782 The length of the produced output buffer is returned.
783 If BufferSize is 0, then no output buffer is produced and 0 is returned.
785 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
786 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
787 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
788 PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
789 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
790 contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
792 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
794 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
795 @param FormatString Null-terminated Unicode format string.
796 @param Marker VA_LIST marker for the variable argument list.
798 @return Length of the produced output buffer.
804 OUT CHAR8
*StartOfBuffer
,
806 IN CONST CHAR8
*FormatString
,
810 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
);
814 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
815 ASCII format string and variable argument list.
817 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
819 The ASCII string is produced by parsing the format string specified by FormatString.
820 Arguments are pulled from the variable argument list based on the contents of the
822 The length of the produced output buffer is returned.
823 If BufferSize is 0, then no output buffer is produced and 0 is returned.
825 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
826 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
827 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
828 PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
829 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
830 contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
832 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
834 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
835 @param FormatString Null-terminated Unicode format string.
837 @return Length of the produced output buffer.
843 OUT CHAR8
*StartOfBuffer
,
845 IN CONST CHAR8
*FormatString
,
851 VA_START (Marker
, FormatString
);
852 return AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
856 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
857 ASCII format string and a VA_LIST argument list.
859 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
861 The ASCII string is produced by parsing the format string specified by FormatString.
862 Arguments are pulled from the variable argument list specified by Marker based on
863 the contents of the format string.
864 The length of the produced output buffer is returned.
865 If BufferSize is 0, then no output buffer is produced and 0 is returned.
867 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
868 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
869 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
870 PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
871 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
872 contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
874 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
876 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
877 @param FormatString Null-terminated Unicode format string.
878 @param Marker VA_LIST marker for the variable argument list.
880 @return Length of the produced output buffer.
885 AsciiVSPrintUnicodeFormat (
886 OUT CHAR8
*StartOfBuffer
,
888 IN CONST CHAR16
*FormatString
,
892 return BasePrintLibVSPrint (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
);
896 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
897 ASCII format string and variable argument list.
899 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
901 The ASCII string is produced by parsing the format string specified by FormatString.
902 Arguments are pulled from the variable argument list based on the contents of the
904 The length of the produced output buffer is returned.
905 If BufferSize is 0, then no output buffer is produced and 0 is returned.
907 If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().
908 If BufferSize is not 0 and FormatString is NULL, then ASSERT().
909 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
910 PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
911 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
912 contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().
914 @param StartOfBuffer APointer to the output buffer for the produced Null-terminated
916 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
917 @param FormatString Null-terminated Unicode format string.
919 @return Length of the produced output buffer.
924 AsciiSPrintUnicodeFormat (
925 OUT CHAR8
*StartOfBuffer
,
927 IN CONST CHAR16
*FormatString
,
933 VA_START (Marker
, FormatString
);
934 return AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
938 Converts a decimal value to a Null-terminated Unicode string.
940 Converts the decimal number specified by Value to a Null-terminated Unicode
941 string specified by Buffer containing at most Width characters.
942 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
943 The total number of characters placed in Buffer is returned.
944 If the conversion contains more than Width characters, then only the first
945 Width characters are returned, and the total number of characters
946 required to perform the conversion is returned.
947 Additional conversion parameters are specified in Flags.
948 The Flags bit LEFT_JUSTIFY is always ignored.
949 All conversions are left justified in Buffer.
950 If Width is 0, PREFIX_ZERO is ignored in Flags.
951 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
952 are inserted every 3rd digit starting from the right.
953 If Value is < 0, then the fist character in Buffer is a '-'.
954 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
955 then Buffer is padded with '0' characters so the combination of the optional '-'
956 sign character, '0' characters, digit characters for Value, and the Null-terminator
957 add up to Width characters.
959 If Buffer is NULL, then ASSERT().
960 If unsupported bits are set in Flags, then ASSERT().
961 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
963 @param Buffer Pointer to the output buffer for the produced Null-terminated
965 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
966 @param Value The 64-bit signed value to convert to a string.
967 @param Width The maximum number of Unicode characters to place in Buffer.
969 @return Total number of characters required to perform the conversion.
974 UnicodeValueToString (
975 IN OUT CHAR16
*Buffer
,
981 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
985 Converts a decimal value to a Null-terminated ASCII string.
987 Converts the decimal number specified by Value to a Null-terminated ASCII string
988 specified by Buffer containing at most Width characters.
989 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
990 The total number of characters placed in Buffer is returned.
991 If the conversion contains more than Width characters, then only the first Width
992 characters are returned, and the total number of characters required to perform
993 the conversion is returned.
994 Additional conversion parameters are specified in Flags.
995 The Flags bit LEFT_JUSTIFY is always ignored.
996 All conversions are left justified in Buffer.
997 If Width is 0, PREFIX_ZERO is ignored in Flags.
998 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
999 are inserted every 3rd digit starting from the right.
1000 If Value is < 0, then the fist character in Buffer is a '-'.
1001 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer
1002 is padded with '0' characters so the combination of the optional '-'
1003 sign character, '0' characters, digit characters for Value, and the
1004 Null-terminator add up to Width characters.
1006 If Buffer is NULL, then ASSERT().
1007 If unsupported bits are set in Flags, then ASSERT().
1008 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
1010 @param Buffer Pointer to the output buffer for the produced Null-terminated
1012 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
1013 @param Value The 64-bit signed value to convert to a string.
1014 @param Width The maximum number of ASCII characters to place in Buffer.
1016 @return Total number of characters required to perform the conversion.
1021 AsciiValueToString (
1022 IN OUT CHAR8
*Buffer
,
1028 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 1);