2 Print Library internal worker functions.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 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.
15 #include "PrintLibInternal.h"
17 #define WARNING_STATUS_NUMBER 4
18 #define ERROR_STATUS_NUMBER 24
20 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr
[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
22 GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8
*mStatusString
[] = {
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
56 Internal function that places the character into the Buffer.
58 Internal function that places ASCII or Unicode character into the Buffer.
60 @param Buffer The buffer to place the Unicode or ASCII string.
61 @param EndBuffer The end of the input Buffer. No characters will be
63 @param Length The count of character to be placed into Buffer.
64 (Negative value indicates no buffer fill.)
65 @param Character The character to be placed into Buffer.
66 @param Increment The character increment in Buffer.
72 BasePrintLibFillBuffer (
82 for (Index
= 0; Index
< Length
&& Buffer
< EndBuffer
; Index
++) {
83 *Buffer
= (CHAR8
) Character
;
85 *(Buffer
+ 1) = (CHAR8
)(Character
>> 8);
94 Internal function that convert a number to a string in Buffer.
96 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
98 @param Buffer Location to place the ASCII string of Value.
99 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
100 @param Radix Radix of the value
102 @return A pointer to the end of buffer filled with ASCII string.
106 BasePrintLibValueToString (
107 IN OUT CHAR8
*Buffer
,
115 // Loop to convert one digit at a time in reverse order
119 Value
= (INT64
)DivU64x32Remainder ((UINT64
)Value
, (UINT32
)Radix
, &Remainder
);
120 *(++Buffer
) = mHexStr
[Remainder
];
121 } while (Value
!= 0);
124 // Return pointer of the end of filled buffer.
130 Internal function that converts a decimal value to a Null-terminated string.
132 Converts the decimal number specified by Value to a Null-terminated
133 string specified by Buffer containing at most Width characters.
134 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
135 The total number of characters placed in Buffer is returned.
136 If the conversion contains more than Width characters, then only the first
137 Width characters are returned, and the total number of characters
138 required to perform the conversion is returned.
139 Additional conversion parameters are specified in Flags.
140 The Flags bit LEFT_JUSTIFY is always ignored.
141 All conversions are left justified in Buffer.
142 If Width is 0, PREFIX_ZERO is ignored in Flags.
143 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
144 are inserted every 3rd digit starting from the right.
145 If Value is < 0, then the fist character in Buffer is a '-'.
146 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
147 then Buffer is padded with '0' characters so the combination of the optional '-'
148 sign character, '0' characters, digit characters for Value, and the Null-terminator
149 add up to Width characters.
151 If Buffer is NULL, then ASSERT().
152 If unsupported bits are set in Flags, then ASSERT().
153 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
155 @param Buffer The pointer to the output buffer for the produced Null-terminated
157 @param Flags The bitmask of flags that specify left justification, zero pad,
159 @param Value The 64-bit signed value to convert to a string.
160 @param Width The maximum number of characters to place in Buffer, not including
162 @param Increment The character increment in Buffer.
164 @return Total number of characters required to perform the conversion.
168 BasePrintLibConvertValueToString (
169 IN OUT CHAR8
*Buffer
,
176 CHAR8
*OriginalBuffer
;
178 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
179 CHAR8
*ValueBufferPtr
;
186 // Make sure Buffer is not NULL and Width < MAXIMUM
188 ASSERT (Buffer
!= NULL
);
189 ASSERT (Width
< MAXIMUM_VALUE_CHARACTERS
);
191 // Make sure Flags can only contain supported bits.
193 ASSERT ((Flags
& ~(LEFT_JUSTIFY
| COMMA_TYPE
| PREFIX_ZERO
| RADIX_HEX
)) == 0);
196 // If both COMMA_TYPE and RADIX_HEX are set, then ASSERT ()
198 ASSERT (((Flags
& COMMA_TYPE
) == 0) || ((Flags
& RADIX_HEX
) == 0));
200 OriginalBuffer
= Buffer
;
203 // Width is 0 or COMMA_TYPE is set, PREFIX_ZERO is ignored.
205 if (Width
== 0 || (Flags
& COMMA_TYPE
) != 0) {
206 Flags
&= (~PREFIX_ZERO
);
209 // If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
212 Width
= MAXIMUM_VALUE_CHARACTERS
- 1;
215 // Set the tag for the end of the input Buffer.
217 EndBuffer
= Buffer
+ Width
* Increment
;
220 // Convert decimal negative
222 if ((Value
< 0) && ((Flags
& RADIX_HEX
) == 0)) {
224 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, '-', Increment
);
229 // Count the length of the value string.
231 Radix
= ((Flags
& RADIX_HEX
) == 0)? 10 : 16;
232 ValueBufferPtr
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
);
233 Count
= ValueBufferPtr
- ValueBuffer
;
238 if ((Flags
& PREFIX_ZERO
) != 0) {
239 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Count
, '0', Increment
);
243 // Print Comma type for every 3 characters
249 for (Index
= 0; Index
< Count
; Index
++) {
250 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, *ValueBufferPtr
--, Increment
);
251 if ((Flags
& COMMA_TYPE
) != 0) {
255 if ((Index
+ 1) < Count
) {
256 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', Increment
);
263 // Print Null-terminator
265 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ Increment
, 1, 0, Increment
);
267 return ((Buffer
- OriginalBuffer
) / Increment
);
271 Worker function that produces a Null-terminated string in an output buffer
272 based on a Null-terminated format string and a VA_LIST argument list.
274 VSPrint function to process format and place the results in Buffer. Since a
275 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
276 this is the main print working routine.
278 @param Buffer The character buffer to print the results of the parsing
280 @param BufferSize The maximum number of characters to put into buffer.
281 @param Flags Initial flags value.
282 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
283 @param Format A Null-terminated format string.
284 @param VaListMarker VA_LIST style variable argument list consumed by processing Format.
285 @param BaseListMarker BASE_LIST style variable argument list consumed by processing Format.
287 @return The number of characters printed not including the Null-terminator.
291 BasePrintLibSPrintMarker (
295 IN CONST CHAR8
*Format
,
296 IN VA_LIST VaListMarker
, OPTIONAL
297 IN BASE_LIST BaseListMarker OPTIONAL
300 CHAR8
*OriginalBuffer
;
302 CHAR8 ValueBuffer
[MAXIMUM_VALUE_CHARACTERS
];
303 UINTN BytesPerOutputCharacter
;
304 UINTN BytesPerFormatCharacter
;
306 UINTN FormatCharacter
;
310 CONST CHAR8
*ArgumentString
;
316 INTN BytesPerArgumentCharacter
;
317 UINTN ArgumentCharacter
;
325 RETURN_STATUS Status
;
327 if (BufferSize
== 0) {
330 ASSERT (Buffer
!= NULL
);
332 if ((Flags
& OUTPUT_UNICODE
) != 0) {
333 BytesPerOutputCharacter
= 2;
335 BytesPerOutputCharacter
= 1;
339 // Reserve space for the Null terminator.
342 OriginalBuffer
= Buffer
;
345 // Set the tag for the end of the input Buffer.
347 EndBuffer
= Buffer
+ BufferSize
* BytesPerOutputCharacter
;
349 if ((Flags
& FORMAT_UNICODE
) != 0) {
351 // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
352 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
354 ASSERT (StrSize ((CHAR16
*) Format
) != 0);
355 BytesPerFormatCharacter
= 2;
359 // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
360 // Ascii characters if PcdMaximumAsciiStringLength is not zero.
362 ASSERT (AsciiStrSize (Format
) != 0);
363 BytesPerFormatCharacter
= 1;
368 // Get the first character from the format string
370 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
373 // Loop until the end of the format string is reached or the output buffer is full
375 while (FormatCharacter
!= 0 && Buffer
< EndBuffer
) {
377 // Clear all the flag bits except those that may have been passed in
379 Flags
&= (OUTPUT_UNICODE
| FORMAT_UNICODE
);
382 // Set the default width to zero, and the default precision to 1
392 switch (FormatCharacter
) {
395 // Parse Flags and Width
397 for (Done
= FALSE
; !Done
; ) {
398 Format
+= BytesPerFormatCharacter
;
399 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
400 switch (FormatCharacter
) {
405 Flags
|= LEFT_JUSTIFY
;
408 Flags
|= PREFIX_SIGN
;
411 Flags
|= PREFIX_BLANK
;
421 if ((Flags
& PRECISION
) == 0) {
422 Flags
|= PAD_TO_WIDTH
;
423 if (BaseListMarker
== NULL
) {
424 Width
= VA_ARG (VaListMarker
, UINTN
);
426 Width
= BASE_ARG (BaseListMarker
, UINTN
);
429 if (BaseListMarker
== NULL
) {
430 Precision
= VA_ARG (VaListMarker
, UINTN
);
432 Precision
= BASE_ARG (BaseListMarker
, UINTN
);
437 if ((Flags
& PRECISION
) == 0) {
438 Flags
|= PREFIX_ZERO
;
449 for (Count
= 0; ((FormatCharacter
>= '0') && (FormatCharacter
<= '9')); ){
450 Count
= (Count
* 10) + FormatCharacter
- '0';
451 Format
+= BytesPerFormatCharacter
;
452 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
454 Format
-= BytesPerFormatCharacter
;
455 if ((Flags
& PRECISION
) == 0) {
456 Flags
|= PAD_TO_WIDTH
;
465 // Make no output if Format string terminates unexpectedly when
466 // looking up for flag, width, precision and type.
468 Format
-= BytesPerFormatCharacter
;
471 // break skipped on purpose.
480 // Handle each argument type
482 switch (FormatCharacter
) {
485 // Flag space, +, 0, L & l are invalid for type p.
487 Flags
&= ~(PREFIX_BLANK
| PREFIX_SIGN
| PREFIX_ZERO
| LONG_TYPE
);
488 if (sizeof (VOID
*) > 4) {
492 Flags
|= PREFIX_ZERO
;
494 // break skipped on purpose
499 // break skipped on purpose
502 if ((Flags
& LONG_TYPE
) == 0) {
504 // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
505 // This assumption is made so the format string definition is compatible with the ANSI C
506 // Specification for formatted strings. It is recommended that the Base Types be used
507 // everywhere, but in this one case, compliance with ANSI C is more important, and
508 // provides an implementation that is compatible with that largest possible set of CPU
509 // architectures. This is why the type "int" is used in this one case.
511 if (BaseListMarker
== NULL
) {
512 Value
= VA_ARG (VaListMarker
, int);
514 Value
= BASE_ARG (BaseListMarker
, int);
517 if (BaseListMarker
== NULL
) {
518 Value
= VA_ARG (VaListMarker
, INT64
);
520 Value
= BASE_ARG (BaseListMarker
, INT64
);
523 if ((Flags
& PREFIX_BLANK
) != 0) {
526 if ((Flags
& PREFIX_SIGN
) != 0) {
529 if ((Flags
& COMMA_TYPE
) != 0) {
532 if ((Flags
& RADIX_HEX
) == 0) {
535 Flags
&= (~PREFIX_ZERO
);
539 Flags
|= PREFIX_SIGN
;
546 if ((Flags
& LONG_TYPE
) == 0 && Value
< 0) {
548 // 'd','x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
549 // This assumption is made so the format string definition is compatible with the ANSI C
550 // Specification for formatted strings. It is recommended that the Base Types be used
551 // everywhere, but in this one case, compliance with ANSI C is more important, and
552 // provides an implementation that is compatible with that largest possible set of CPU
553 // architectures. This is why the type "unsigned int" is used in this one case.
555 Value
= (unsigned int)Value
;
559 // Convert Value to a reversed string
561 Count
= BasePrintLibValueToString (ValueBuffer
, Value
, Radix
) - ValueBuffer
;
562 if (Value
== 0 && Precision
== 0) {
565 ArgumentString
= (CHAR8
*)ValueBuffer
+ Count
;
571 if (Comma
&& Count
!= 0) {
572 Count
+= ((Count
- 1) / 3);
578 Flags
|= ARGUMENT_REVERSED
;
580 if ((Flags
& PREFIX_ZERO
) != 0) {
581 if ((Flags
& LEFT_JUSTIFY
) == 0) {
582 if ((Flags
& PAD_TO_WIDTH
) != 0) {
583 if ((Flags
& PRECISION
) == 0) {
593 Flags
|= ARGUMENT_UNICODE
;
595 // break skipped on purpose
598 if (BaseListMarker
== NULL
) {
599 ArgumentString
= VA_ARG (VaListMarker
, CHAR8
*);
601 ArgumentString
= BASE_ARG (BaseListMarker
, CHAR8
*);
603 if (ArgumentString
== NULL
) {
604 Flags
&= (~ARGUMENT_UNICODE
);
605 ArgumentString
= "<null string>";
608 // Set the default precision for string to be zero if not specified.
610 if ((Flags
& PRECISION
) == 0) {
616 if (BaseListMarker
== NULL
) {
617 Character
= VA_ARG (VaListMarker
, UINTN
) & 0xffff;
619 Character
= BASE_ARG (BaseListMarker
, UINTN
) & 0xffff;
621 ArgumentString
= (CHAR8
*)&Character
;
622 Flags
|= ARGUMENT_UNICODE
;
626 if (BaseListMarker
== NULL
) {
627 TmpGuid
= VA_ARG (VaListMarker
, GUID
*);
629 TmpGuid
= BASE_ARG (BaseListMarker
, GUID
*);
631 if (TmpGuid
== NULL
) {
632 ArgumentString
= "<null guid>";
636 MAXIMUM_VALUE_CHARACTERS
,
638 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
651 ArgumentString
= ValueBuffer
;
656 if (BaseListMarker
== NULL
) {
657 TmpTime
= VA_ARG (VaListMarker
, TIME
*);
659 TmpTime
= BASE_ARG (BaseListMarker
, TIME
*);
661 if (TmpTime
== NULL
) {
662 ArgumentString
= "<null time>";
666 MAXIMUM_VALUE_CHARACTERS
,
668 "%02d/%02d/%04d %02d:%02d",
675 ArgumentString
= ValueBuffer
;
680 if (BaseListMarker
== NULL
) {
681 Status
= VA_ARG (VaListMarker
, RETURN_STATUS
);
683 Status
= BASE_ARG (BaseListMarker
, RETURN_STATUS
);
685 ArgumentString
= ValueBuffer
;
686 if (RETURN_ERROR (Status
)) {
690 Index
= Status
& ~MAX_BIT
;
691 if (Index
> 0 && Index
<= ERROR_STATUS_NUMBER
) {
692 ArgumentString
= mStatusString
[Index
+ WARNING_STATUS_NUMBER
];
696 if (Index
<= WARNING_STATUS_NUMBER
) {
697 ArgumentString
= mStatusString
[Index
];
700 if (ArgumentString
== ValueBuffer
) {
701 BasePrintLibSPrint ((CHAR8
*) ValueBuffer
, MAXIMUM_VALUE_CHARACTERS
, 0, "%08X", Status
);
706 Format
+= BytesPerFormatCharacter
;
707 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
708 if (FormatCharacter
== '\n') {
710 // Translate '\r\n' to '\r\n'
712 ArgumentString
= "\r\n";
715 // Translate '\r' to '\r'
717 ArgumentString
= "\r";
718 Format
-= BytesPerFormatCharacter
;
724 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
726 ArgumentString
= "\r\n";
727 Format
+= BytesPerFormatCharacter
;
728 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
729 if (FormatCharacter
!= '\r') {
730 Format
-= BytesPerFormatCharacter
;
737 // if the type is '%' or unknown, then print it to the screen
739 ArgumentString
= (CHAR8
*)&FormatCharacter
;
740 Flags
|= ARGUMENT_UNICODE
;
746 Format
+= BytesPerFormatCharacter
;
747 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
748 if (FormatCharacter
== '\n') {
750 // Translate '\r\n' to '\r\n'
752 ArgumentString
= "\r\n";
755 // Translate '\r' to '\r'
757 ArgumentString
= "\r";
758 Format
-= BytesPerFormatCharacter
;
764 // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
766 ArgumentString
= "\r\n";
767 Format
+= BytesPerFormatCharacter
;
768 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
769 if (FormatCharacter
!= '\r') {
770 Format
-= BytesPerFormatCharacter
;
775 ArgumentString
= (CHAR8
*)&FormatCharacter
;
776 Flags
|= ARGUMENT_UNICODE
;
781 // Retrieve the ArgumentString attriubutes
783 if ((Flags
& ARGUMENT_UNICODE
) != 0) {
784 ArgumentMask
= 0xffff;
785 BytesPerArgumentCharacter
= 2;
788 BytesPerArgumentCharacter
= 1;
790 if ((Flags
& ARGUMENT_REVERSED
) != 0) {
791 BytesPerArgumentCharacter
= -BytesPerArgumentCharacter
;
794 // Compute the number of characters in ArgumentString and store it in Count
795 // ArgumentString is either null-terminated, or it contains Precision characters
797 for (Count
= 0; Count
< Precision
|| ((Flags
& PRECISION
) == 0); Count
++) {
798 ArgumentCharacter
= ((ArgumentString
[Count
* BytesPerArgumentCharacter
] & 0xff) | ((ArgumentString
[Count
* BytesPerArgumentCharacter
+ 1]) << 8)) & ArgumentMask
;
799 if (ArgumentCharacter
== 0) {
805 if (Precision
< Count
) {
810 // Pad before the string
812 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
)) {
813 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
818 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
820 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, '0', BytesPerOutputCharacter
);
822 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Precision
- Count
, ' ', BytesPerOutputCharacter
);
824 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, Prefix
, BytesPerOutputCharacter
);
829 // Output the Prefix character if it is present
837 // Copy the string into the output buffer performing the required type conversions
839 while (Index
< Count
) {
840 ArgumentCharacter
= ((*ArgumentString
& 0xff) | (*(ArgumentString
+ 1) << 8)) & ArgumentMask
;
842 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ArgumentCharacter
, BytesPerOutputCharacter
);
843 ArgumentString
+= BytesPerArgumentCharacter
;
851 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, 1, ',', BytesPerOutputCharacter
);
858 // Pad after the string
860 if ((Flags
& (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) == (PAD_TO_WIDTH
| LEFT_JUSTIFY
)) {
861 Buffer
= BasePrintLibFillBuffer (Buffer
, EndBuffer
, Width
- Precision
, ' ', BytesPerOutputCharacter
);
865 // Get the next character from the format string
867 Format
+= BytesPerFormatCharacter
;
870 // Get the next character from the format string
872 FormatCharacter
= ((*Format
& 0xff) | (*(Format
+ 1) << 8)) & FormatMask
;
876 // Null terminate the Unicode or ASCII string
878 BasePrintLibFillBuffer (Buffer
, EndBuffer
+ BytesPerOutputCharacter
, 1, 0, BytesPerOutputCharacter
);
880 // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
881 // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
883 ASSERT ((((Flags
& OUTPUT_UNICODE
) == 0)) || (StrSize ((CHAR16
*) OriginalBuffer
) != 0));
885 // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
886 // ASCII characters if PcdMaximumAsciiStringLength is not zero.
888 ASSERT ((((Flags
& OUTPUT_UNICODE
) != 0)) || (AsciiStrSize (OriginalBuffer
) != 0));
890 return ((Buffer
- OriginalBuffer
) / BytesPerOutputCharacter
);
894 Worker function that produces a Null-terminated string in an output buffer
895 based on a Null-terminated format string and variable argument list.
897 VSPrint function to process format and place the results in Buffer. Since a
898 VA_LIST is used this routine allows the nesting of Vararg routines. Thus
899 this is the main print working routine
901 @param StartOfBuffer The character buffer to print the results of the parsing
903 @param BufferSize The maximum number of characters to put into buffer.
905 @param Flags Initial flags value.
906 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
907 @param FormatString A Null-terminated format string.
908 @param ... The variable argument list.
910 @return The number of characters printed.
916 OUT CHAR8
*StartOfBuffer
,
919 IN CONST CHAR8
*FormatString
,
925 VA_START (Marker
, FormatString
);
926 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, Flags
, FormatString
, Marker
, NULL
);