]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePrintLib/PrintLib.c
2 Base Print Library instance implementation.
4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "PrintLibInternal.h"
19 // Declare a VA_LIST global variable that is used in calls to BasePrintLibSPrintMarker()
20 // when the BASE_LIST parameter is valid and the VA_LIST parameter is ignored.
21 // A NULL VA_LIST can not be passed into BasePrintLibSPrintMarker() because some
22 // compilers define VA_LIST to be a structure.
26 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
29 Produces a Null-terminated Unicode string in an output buffer based on
30 a Null-terminated Unicode format string and a VA_LIST argument list.
32 This function is similar as vsnprintf_s defined in C11.
34 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
36 The Unicode string is produced by parsing the format string specified by FormatString.
37 Arguments are pulled from the variable argument list specified by Marker based on the
38 contents of the format string.
39 The number of Unicode characters in the produced output buffer is returned not including
42 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
43 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
45 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
46 unmodified and 0 is returned.
47 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
48 unmodified and 0 is returned.
49 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
50 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
51 buffer is unmodified and 0 is returned.
52 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
53 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
54 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
56 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
58 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
60 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
61 @param FormatString A Null-terminated Unicode format string.
62 @param Marker VA_LIST marker for the variable argument list.
64 @return The number of Unicode characters in the produced output buffer not including the
71 OUT CHAR16
*StartOfBuffer
,
73 IN CONST CHAR16
*FormatString
,
77 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
78 ASSERT_UNICODE_BUFFER (FormatString
);
79 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
, NULL
);
83 Produces a Null-terminated Unicode string in an output buffer based on
84 a Null-terminated Unicode format string and a BASE_LIST argument list.
86 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
88 The Unicode string is produced by parsing the format string specified by FormatString.
89 Arguments are pulled from the variable argument list specified by Marker based on the
90 contents of the format string.
91 The number of Unicode characters in the produced output buffer is returned not including
94 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
95 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
97 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
98 unmodified and 0 is returned.
99 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
100 unmodified and 0 is returned.
101 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
102 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
103 buffer is unmodified and 0 is returned.
104 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
105 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
106 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
108 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
110 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
112 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
113 @param FormatString A Null-terminated Unicode format string.
114 @param Marker BASE_LIST marker for the variable argument list.
116 @return The number of Unicode characters in the produced output buffer not including the
123 OUT CHAR16
*StartOfBuffer
,
125 IN CONST CHAR16
*FormatString
,
129 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
130 ASSERT_UNICODE_BUFFER (FormatString
);
131 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, gNullVaList
, Marker
);
135 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
136 Unicode format string and variable argument list.
138 This function is similar as snprintf_s defined in C11.
140 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
142 The Unicode string is produced by parsing the format string specified by FormatString.
143 Arguments are pulled from the variable argument list based on the contents of the format string.
144 The number of Unicode characters in the produced output buffer is returned not including
147 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
148 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
150 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
151 unmodified and 0 is returned.
152 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
153 unmodified and 0 is returned.
154 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
155 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
156 buffer is unmodified and 0 is returned.
157 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
158 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
159 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
161 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
163 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
165 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
166 @param FormatString A Null-terminated Unicode format string.
167 @param ... Variable argument list whose contents are accessed based on the
168 format string specified by FormatString.
170 @return The number of Unicode characters in the produced output buffer not including the
177 OUT CHAR16
*StartOfBuffer
,
179 IN CONST CHAR16
*FormatString
,
184 UINTN NumberOfPrinted
;
186 VA_START (Marker
, FormatString
);
187 NumberOfPrinted
= UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
189 return NumberOfPrinted
;
193 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
194 ASCII format string and a VA_LIST argument list.
196 This function is similar as vsnprintf_s defined in C11.
198 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
200 The Unicode string is produced by parsing the format string specified by FormatString.
201 Arguments are pulled from the variable argument list specified by Marker based on the
202 contents of the format string.
203 The number of Unicode characters in the produced output buffer is returned not including
206 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
208 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
209 unmodified and 0 is returned.
210 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
211 unmodified and 0 is returned.
212 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
213 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
214 buffer is unmodified and 0 is returned.
215 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
216 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
217 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
219 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
221 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
223 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
224 @param FormatString A Null-terminated ASCII format string.
225 @param Marker VA_LIST marker for the variable argument list.
227 @return The number of Unicode characters in the produced output buffer not including the
233 UnicodeVSPrintAsciiFormat (
234 OUT CHAR16
*StartOfBuffer
,
236 IN CONST CHAR8
*FormatString
,
240 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
241 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
, FormatString
, Marker
, NULL
);
245 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
246 ASCII format string and a BASE_LIST argument list.
248 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
250 The Unicode string is produced by parsing the format string specified by FormatString.
251 Arguments are pulled from the variable argument list specified by Marker based on the
252 contents of the format string.
253 The number of Unicode characters in the produced output buffer is returned not including
256 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
258 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
259 unmodified and 0 is returned.
260 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
261 unmodified and 0 is returned.
262 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
263 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
264 buffer is unmodified and 0 is returned.
265 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
266 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
267 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
269 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
271 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
273 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
274 @param FormatString A Null-terminated ASCII format string.
275 @param Marker BASE_LIST marker for the variable argument list.
277 @return The number of Unicode characters in the produced output buffer not including the
283 UnicodeBSPrintAsciiFormat (
284 OUT CHAR16
*StartOfBuffer
,
286 IN CONST CHAR8
*FormatString
,
290 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
291 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
, FormatString
, gNullVaList
, Marker
);
295 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
296 ASCII format string and variable argument list.
298 This function is similar as snprintf_s defined in C11.
300 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
302 The Unicode string is produced by parsing the format string specified by FormatString.
303 Arguments are pulled from the variable argument list based on the contents of the
305 The number of Unicode characters in the produced output buffer is returned not including
308 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
310 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
311 unmodified and 0 is returned.
312 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
313 unmodified and 0 is returned.
314 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
315 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
316 buffer is unmodified and 0 is returned.
317 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
318 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
319 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
321 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
323 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
325 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
326 @param FormatString A Null-terminated ASCII format string.
327 @param ... Variable argument list whose contents are accessed based on the
328 format string specified by FormatString.
330 @return The number of Unicode characters in the produced output buffer not including the
336 UnicodeSPrintAsciiFormat (
337 OUT CHAR16
*StartOfBuffer
,
339 IN CONST CHAR8
*FormatString
,
344 UINTN NumberOfPrinted
;
346 VA_START (Marker
, FormatString
);
347 NumberOfPrinted
= UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
349 return NumberOfPrinted
;
352 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
355 [ATTENTION] This function is deprecated for security reason.
357 Converts a decimal value to a Null-terminated Unicode string.
359 Converts the decimal number specified by Value to a Null-terminated Unicode
360 string specified by Buffer containing at most Width characters. No padding of spaces
361 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
362 The number of Unicode characters in Buffer is returned not including the Null-terminator.
363 If the conversion contains more than Width characters, then only the first
364 Width characters are returned, and the total number of characters
365 required to perform the conversion is returned.
366 Additional conversion parameters are specified in Flags.
368 The Flags bit LEFT_JUSTIFY is always ignored.
369 All conversions are left justified in Buffer.
370 If Width is 0, PREFIX_ZERO is ignored in Flags.
371 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
372 are inserted every 3rd digit starting from the right.
373 If RADIX_HEX is set in Flags, then the output buffer will be
374 formatted in hexadecimal format.
375 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
376 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
377 then Buffer is padded with '0' characters so the combination of the optional '-'
378 sign character, '0' characters, digit characters for Value, and the Null-terminator
379 add up to Width characters.
380 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
381 If Buffer is NULL, then ASSERT().
382 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
383 If unsupported bits are set in Flags, then ASSERT().
384 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
385 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
387 @param Buffer The pointer to the output buffer for the produced Null-terminated
389 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
390 @param Value The 64-bit signed value to convert to a string.
391 @param Width The maximum number of Unicode characters to place in Buffer, not including
394 @return The number of Unicode characters in Buffer not including the Null-terminator.
399 UnicodeValueToString (
400 IN OUT CHAR16
*Buffer
,
406 ASSERT_UNICODE_BUFFER(Buffer
);
407 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
413 Converts a decimal value to a Null-terminated Unicode string.
415 Converts the decimal number specified by Value to a Null-terminated Unicode
416 string specified by Buffer containing at most Width characters. No padding of
417 spaces is ever performed. If Width is 0 then a width of
418 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
419 Width characters, then only the first Width characters are placed in Buffer.
420 Additional conversion parameters are specified in Flags.
422 The Flags bit LEFT_JUSTIFY is always ignored.
423 All conversions are left justified in Buffer.
424 If Width is 0, PREFIX_ZERO is ignored in Flags.
425 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
426 commas are inserted every 3rd digit starting from the right.
427 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
429 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
431 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
432 Buffer is padded with '0' characters so the combination of the optional '-'
433 sign character, '0' characters, digit characters for Value, and the
434 Null-terminator add up to Width characters.
436 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
437 If an error would be returned, then the function will also ASSERT().
439 @param Buffer The pointer to the output buffer for the produced
440 Null-terminated Unicode string.
441 @param BufferSize The size of Buffer in bytes, including the
443 @param Flags The bitmask of flags that specify left justification,
444 zero pad, and commas.
445 @param Value The 64-bit signed value to convert to a string.
446 @param Width The maximum number of Unicode characters to place in
447 Buffer, not including the Null-terminator.
449 @retval RETURN_SUCCESS The decimal value is converted.
450 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
452 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
453 If PcdMaximumUnicodeStringLength is not
454 zero, and BufferSize is greater than
455 (PcdMaximumUnicodeStringLength *
456 sizeof (CHAR16) + 1).
457 If unsupported bits are set in Flags.
458 If both COMMA_TYPE and RADIX_HEX are set in
460 If Width >= MAXIMUM_VALUE_CHARACTERS.
465 UnicodeValueToStringS (
466 IN OUT CHAR16
*Buffer
,
473 ASSERT_UNICODE_BUFFER(Buffer
);
474 return BasePrintLibConvertValueToStringS ((CHAR8
*)Buffer
, BufferSize
, Flags
, Value
, Width
, 2);
478 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
479 ASCII format string and a VA_LIST argument list.
481 This function is similar as vsnprintf_s defined in C11.
483 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
485 The ASCII string is produced by parsing the format string specified by FormatString.
486 Arguments are pulled from the variable argument list specified by Marker based on
487 the contents of the format string.
488 The number of ASCII characters in the produced output buffer is returned not including
491 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
492 unmodified and 0 is returned.
493 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
494 unmodified and 0 is returned.
495 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
496 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
497 is unmodified and 0 is returned.
498 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
499 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
500 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
502 If BufferSize is 0, then no output buffer is produced and 0 is returned.
504 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
506 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
507 @param FormatString A Null-terminated ASCII format string.
508 @param Marker VA_LIST marker for the variable argument list.
510 @return The number of ASCII characters in the produced output buffer not including the
517 OUT CHAR8
*StartOfBuffer
,
519 IN CONST CHAR8
*FormatString
,
523 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
, NULL
);
527 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
528 ASCII format string and a BASE_LIST argument list.
530 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
532 The ASCII string is produced by parsing the format string specified by FormatString.
533 Arguments are pulled from the variable argument list specified by Marker based on
534 the contents of the format string.
535 The number of ASCII characters in the produced output buffer is returned not including
538 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
539 unmodified and 0 is returned.
540 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
541 unmodified and 0 is returned.
542 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
543 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
544 is unmodified and 0 is returned.
545 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
546 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
547 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
549 If BufferSize is 0, then no output buffer is produced and 0 is returned.
551 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
553 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
554 @param FormatString A Null-terminated ASCII format string.
555 @param Marker BASE_LIST marker for the variable argument list.
557 @return The number of ASCII characters in the produced output buffer not including the
564 OUT CHAR8
*StartOfBuffer
,
566 IN CONST CHAR8
*FormatString
,
570 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, gNullVaList
, Marker
);
574 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
575 ASCII format string and variable argument list.
577 This function is similar as snprintf_s defined in C11.
579 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
581 The ASCII string is produced by parsing the format string specified by FormatString.
582 Arguments are pulled from the variable argument list based on the contents of the
584 The number of ASCII characters in the produced output buffer is returned not including
587 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
588 unmodified and 0 is returned.
589 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
590 unmodified and 0 is returned.
591 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
592 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
593 is unmodified and 0 is returned.
594 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
595 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
596 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
598 If BufferSize is 0, then no output buffer is produced and 0 is returned.
600 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
602 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
603 @param FormatString A Null-terminated ASCII format string.
604 @param ... Variable argument list whose contents are accessed based on the
605 format string specified by FormatString.
607 @return The number of ASCII characters in the produced output buffer not including the
614 OUT CHAR8
*StartOfBuffer
,
616 IN CONST CHAR8
*FormatString
,
621 UINTN NumberOfPrinted
;
623 VA_START (Marker
, FormatString
);
624 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
626 return NumberOfPrinted
;
630 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
631 Unicode format string and a VA_LIST argument list.
633 This function is similar as vsnprintf_s defined in C11.
635 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
637 The ASCII string is produced by parsing the format string specified by FormatString.
638 Arguments are pulled from the variable argument list specified by Marker based on
639 the contents of the format string.
640 The number of ASCII characters in the produced output buffer is returned not including
643 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
645 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
646 unmodified and 0 is returned.
647 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
648 unmodified and 0 is returned.
649 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
650 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
651 is unmodified and 0 is returned.
652 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
653 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
654 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
656 If BufferSize is 0, then no output buffer is produced and 0 is returned.
658 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
660 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
661 @param FormatString A Null-terminated Unicode format string.
662 @param Marker VA_LIST marker for the variable argument list.
664 @return The number of ASCII characters in the produced output buffer not including the
670 AsciiVSPrintUnicodeFormat (
671 OUT CHAR8
*StartOfBuffer
,
673 IN CONST CHAR16
*FormatString
,
677 ASSERT_UNICODE_BUFFER (FormatString
);
678 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
, NULL
);
682 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
683 Unicode format string and a BASE_LIST argument list.
685 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
687 The ASCII string is produced by parsing the format string specified by FormatString.
688 Arguments are pulled from the variable argument list specified by Marker based on
689 the contents of the format string.
690 The number of ASCII characters in the produced output buffer is returned not including
693 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
695 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
696 unmodified and 0 is returned.
697 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
698 unmodified and 0 is returned.
699 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
700 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
701 is unmodified and 0 is returned.
702 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
703 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
704 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
706 If BufferSize is 0, then no output buffer is produced and 0 is returned.
708 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
710 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
711 @param FormatString A Null-terminated Unicode format string.
712 @param Marker BASE_LIST marker for the variable argument list.
714 @return The number of ASCII characters in the produced output buffer not including the
720 AsciiBSPrintUnicodeFormat (
721 OUT CHAR8
*StartOfBuffer
,
723 IN CONST CHAR16
*FormatString
,
727 ASSERT_UNICODE_BUFFER (FormatString
);
728 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, gNullVaList
, Marker
);
732 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
733 Unicode format string and variable argument list.
735 This function is similar as snprintf_s defined in C11.
737 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
739 The ASCII string is produced by parsing the format string specified by FormatString.
740 Arguments are pulled from the variable argument list based on the contents of the
742 The number of ASCII characters in the produced output buffer is returned not including
745 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
747 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
748 unmodified and 0 is returned.
749 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
750 unmodified and 0 is returned.
751 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
752 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
753 is unmodified and 0 is returned.
754 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
755 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
756 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
758 If BufferSize is 0, then no output buffer is produced and 0 is returned.
760 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
762 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
763 @param FormatString A Null-terminated Unicode format string.
764 @param ... Variable argument list whose contents are accessed based on the
765 format string specified by FormatString.
767 @return The number of ASCII characters in the produced output buffer not including the
773 AsciiSPrintUnicodeFormat (
774 OUT CHAR8
*StartOfBuffer
,
776 IN CONST CHAR16
*FormatString
,
781 UINTN NumberOfPrinted
;
783 VA_START (Marker
, FormatString
);
784 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
786 return NumberOfPrinted
;
790 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
793 [ATTENTION] This function is deprecated for security reason.
795 Converts a decimal value to a Null-terminated ASCII string.
797 Converts the decimal number specified by Value to a Null-terminated ASCII string
798 specified by Buffer containing at most Width characters. No padding of spaces
800 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
801 The number of ASCII characters in Buffer is returned not including the Null-terminator.
802 If the conversion contains more than Width characters, then only the first Width
803 characters are returned, and the total number of characters required to perform
804 the conversion is returned.
805 Additional conversion parameters are specified in Flags.
806 The Flags bit LEFT_JUSTIFY is always ignored.
807 All conversions are left justified in Buffer.
808 If Width is 0, PREFIX_ZERO is ignored in Flags.
809 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
810 are inserted every 3rd digit starting from the right.
811 If RADIX_HEX is set in Flags, then the output buffer will be
812 formatted in hexadecimal format.
813 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
814 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
815 then Buffer is padded with '0' characters so the combination of the optional '-'
816 sign character, '0' characters, digit characters for Value, and the Null-terminator
817 add up to Width characters.
819 If Buffer is NULL, then ASSERT().
820 If unsupported bits are set in Flags, then ASSERT().
821 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
822 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
824 @param Buffer The pointer to the output buffer for the produced Null-terminated
826 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
827 @param Value The 64-bit signed value to convert to a string.
828 @param Width The maximum number of ASCII characters to place in Buffer, not including
831 @return The number of ASCII characters in Buffer not including the Null-terminator.
843 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);
849 Converts a decimal value to a Null-terminated Ascii string.
851 Converts the decimal number specified by Value to a Null-terminated Ascii
852 string specified by Buffer containing at most Width characters. No padding of
853 spaces is ever performed. If Width is 0 then a width of
854 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
855 Width characters, then only the first Width characters are placed in Buffer.
856 Additional conversion parameters are specified in Flags.
858 The Flags bit LEFT_JUSTIFY is always ignored.
859 All conversions are left justified in Buffer.
860 If Width is 0, PREFIX_ZERO is ignored in Flags.
861 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
862 commas are inserted every 3rd digit starting from the right.
863 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
865 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
867 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
868 Buffer is padded with '0' characters so the combination of the optional '-'
869 sign character, '0' characters, digit characters for Value, and the
870 Null-terminator add up to Width characters.
872 If an error would be returned, then the function will ASSERT().
874 @param Buffer The pointer to the output buffer for the produced
875 Null-terminated Ascii string.
876 @param BufferSize The size of Buffer in bytes, including the
878 @param Flags The bitmask of flags that specify left justification,
879 zero pad, and commas.
880 @param Value The 64-bit signed value to convert to a string.
881 @param Width The maximum number of Ascii characters to place in
882 Buffer, not including the Null-terminator.
884 @retval RETURN_SUCCESS The decimal value is converted.
885 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
887 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
888 If PcdMaximumAsciiStringLength is not
889 zero, and BufferSize is greater than
890 PcdMaximumAsciiStringLength.
891 If unsupported bits are set in Flags.
892 If both COMMA_TYPE and RADIX_HEX are set in
894 If Width >= MAXIMUM_VALUE_CHARACTERS.
899 AsciiValueToStringS (
900 IN OUT CHAR8
*Buffer
,
907 return BasePrintLibConvertValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
, 1);
911 Returns the number of characters that would be produced by if the formatted
912 output were produced not including the Null-terminator.
914 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
916 If FormatString is NULL, then ASSERT() and 0 is returned.
917 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
918 than PcdMaximumUnicodeStringLength Unicode characters not including the
919 Null-terminator, then ASSERT() and 0 is returned.
921 @param[in] FormatString A Null-terminated Unicode format string.
922 @param[in] Marker VA_LIST marker for the variable argument list.
924 @return The number of characters that would be produced, not including the
930 IN CONST CHAR16
*FormatString
,
934 ASSERT_UNICODE_BUFFER (FormatString
);
935 return BasePrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
939 Returns the number of characters that would be produced by if the formatted
940 output were produced not including the Null-terminator.
942 If FormatString is NULL, then ASSERT() and 0 is returned.
943 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
944 than PcdMaximumAsciiStringLength Ascii characters not including the
945 Null-terminator, then ASSERT() and 0 is returned.
947 @param[in] FormatString A Null-terminated ASCII format string.
948 @param[in] Marker VA_LIST marker for the variable argument list.
950 @return The number of characters that would be produced, not including the
955 SPrintLengthAsciiFormat (
956 IN CONST CHAR8
*FormatString
,
960 return BasePrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);