]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePrintLib/PrintLib.c
2 Base Print Library instance implementation.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "PrintLibInternal.h"
13 // Declare a VA_LIST global variable that is used in calls to BasePrintLibSPrintMarker()
14 // when the BASE_LIST parameter is valid and the VA_LIST parameter is ignored.
15 // A NULL VA_LIST can not be passed into BasePrintLibSPrintMarker() because some
16 // compilers define VA_LIST to be a structure.
20 #define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
23 Produces a Null-terminated Unicode string in an output buffer based on
24 a Null-terminated Unicode format string and a VA_LIST argument list.
26 This function is similar as vsnprintf_s defined in C11.
28 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
30 The Unicode string is produced by parsing the format string specified by FormatString.
31 Arguments are pulled from the variable argument list specified by Marker based on the
32 contents of the format string.
33 The number of Unicode characters in the produced output buffer is returned not including
36 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
37 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
39 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
40 unmodified and 0 is returned.
41 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
42 unmodified and 0 is returned.
43 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
44 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
45 buffer is unmodified and 0 is returned.
46 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
47 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
48 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
50 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
52 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
54 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
55 @param FormatString A Null-terminated Unicode format string.
56 @param Marker VA_LIST marker for the variable argument list.
58 @return The number of Unicode characters in the produced output buffer not including the
65 OUT CHAR16
*StartOfBuffer
,
67 IN CONST CHAR16
*FormatString
,
71 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
72 ASSERT_UNICODE_BUFFER (FormatString
);
73 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, Marker
, NULL
);
77 Produces a Null-terminated Unicode string in an output buffer based on
78 a Null-terminated Unicode format string and a BASE_LIST argument list.
80 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
82 The Unicode string is produced by parsing the format string specified by FormatString.
83 Arguments are pulled from the variable argument list specified by Marker based on the
84 contents of the format string.
85 The number of Unicode characters in the produced output buffer is returned not including
88 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
89 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
91 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
92 unmodified and 0 is returned.
93 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
94 unmodified and 0 is returned.
95 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
96 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
97 buffer is unmodified and 0 is returned.
98 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
99 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
100 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
102 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
104 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
106 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
107 @param FormatString A Null-terminated Unicode format string.
108 @param Marker BASE_LIST marker for the variable argument list.
110 @return The number of Unicode characters in the produced output buffer not including the
117 OUT CHAR16
*StartOfBuffer
,
119 IN CONST CHAR16
*FormatString
,
123 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
124 ASSERT_UNICODE_BUFFER (FormatString
);
125 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, FORMAT_UNICODE
| OUTPUT_UNICODE
, (CHAR8
*)FormatString
, gNullVaList
, Marker
);
129 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
130 Unicode format string and variable argument list.
132 This function is similar as snprintf_s defined in C11.
134 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
136 The Unicode string is produced by parsing the format string specified by FormatString.
137 Arguments are pulled from the variable argument list based on the contents of the format string.
138 The number of Unicode characters in the produced output buffer is returned not including
141 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
142 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
144 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
145 unmodified and 0 is returned.
146 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
147 unmodified and 0 is returned.
148 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
149 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
150 buffer is unmodified and 0 is returned.
151 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
152 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
153 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
155 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.
157 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
159 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
160 @param FormatString A Null-terminated Unicode format string.
161 @param ... Variable argument list whose contents are accessed based on the
162 format string specified by FormatString.
164 @return The number of Unicode characters in the produced output buffer not including the
171 OUT CHAR16
*StartOfBuffer
,
173 IN CONST CHAR16
*FormatString
,
178 UINTN NumberOfPrinted
;
180 VA_START (Marker
, FormatString
);
181 NumberOfPrinted
= UnicodeVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
183 return NumberOfPrinted
;
187 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
188 ASCII format string and a VA_LIST argument list.
190 This function is similar as vsnprintf_s defined in C11.
192 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
194 The Unicode string is produced by parsing the format string specified by FormatString.
195 Arguments are pulled from the variable argument list specified by Marker based on the
196 contents of the format string.
197 The number of Unicode characters in the produced output buffer is returned not including
200 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
202 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
203 unmodified and 0 is returned.
204 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
205 unmodified and 0 is returned.
206 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
207 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
208 buffer is unmodified and 0 is returned.
209 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
210 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
211 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
213 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
215 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
217 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
218 @param FormatString A Null-terminated ASCII format string.
219 @param Marker VA_LIST marker for the variable argument list.
221 @return The number of Unicode characters in the produced output buffer not including the
227 UnicodeVSPrintAsciiFormat (
228 OUT CHAR16
*StartOfBuffer
,
230 IN CONST CHAR8
*FormatString
,
234 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
235 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
, FormatString
, Marker
, NULL
);
239 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
240 ASCII format string and a BASE_LIST argument list.
242 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
244 The Unicode string is produced by parsing the format string specified by FormatString.
245 Arguments are pulled from the variable argument list specified by Marker based on the
246 contents of the format string.
247 The number of Unicode characters in the produced output buffer is returned not including
250 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
252 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
253 unmodified and 0 is returned.
254 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
255 unmodified and 0 is returned.
256 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
257 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
258 buffer is unmodified and 0 is returned.
259 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
260 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
261 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
263 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
265 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
267 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
268 @param FormatString A Null-terminated ASCII format string.
269 @param Marker BASE_LIST marker for the variable argument list.
271 @return The number of Unicode characters in the produced output buffer not including the
277 UnicodeBSPrintAsciiFormat (
278 OUT CHAR16
*StartOfBuffer
,
280 IN CONST CHAR8
*FormatString
,
284 ASSERT_UNICODE_BUFFER (StartOfBuffer
);
285 return BasePrintLibSPrintMarker ((CHAR8
*)StartOfBuffer
, BufferSize
>> 1, OUTPUT_UNICODE
, FormatString
, gNullVaList
, Marker
);
289 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
290 ASCII format string and variable argument list.
292 This function is similar as snprintf_s defined in C11.
294 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
296 The Unicode string is produced by parsing the format string specified by FormatString.
297 Arguments are pulled from the variable argument list based on the contents of the
299 The number of Unicode characters in the produced output buffer is returned not including
302 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
304 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
305 unmodified and 0 is returned.
306 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is
307 unmodified and 0 is returned.
308 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >
309 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output
310 buffer is unmodified and 0 is returned.
311 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
312 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
313 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
315 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
317 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
319 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
320 @param FormatString A Null-terminated ASCII format string.
321 @param ... Variable argument list whose contents are accessed based on the
322 format string specified by FormatString.
324 @return The number of Unicode characters in the produced output buffer not including the
330 UnicodeSPrintAsciiFormat (
331 OUT CHAR16
*StartOfBuffer
,
333 IN CONST CHAR8
*FormatString
,
338 UINTN NumberOfPrinted
;
340 VA_START (Marker
, FormatString
);
341 NumberOfPrinted
= UnicodeVSPrintAsciiFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
343 return NumberOfPrinted
;
347 Converts a decimal value to a Null-terminated Unicode string.
349 Converts the decimal number specified by Value to a Null-terminated Unicode
350 string specified by Buffer containing at most Width characters. No padding of
351 spaces is ever performed. If Width is 0 then a width of
352 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
353 Width characters, then only the first Width characters are placed in Buffer.
354 Additional conversion parameters are specified in Flags.
356 The Flags bit LEFT_JUSTIFY is always ignored.
357 All conversions are left justified in Buffer.
358 If Width is 0, PREFIX_ZERO is ignored in Flags.
359 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
360 commas are inserted every 3rd digit starting from the right.
361 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
363 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
365 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
366 Buffer is padded with '0' characters so the combination of the optional '-'
367 sign character, '0' characters, digit characters for Value, and the
368 Null-terminator add up to Width characters.
370 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
371 If an error would be returned, then the function will also ASSERT().
373 @param Buffer The pointer to the output buffer for the produced
374 Null-terminated Unicode string.
375 @param BufferSize The size of Buffer in bytes, including the
377 @param Flags The bitmask of flags that specify left justification,
378 zero pad, and commas.
379 @param Value The 64-bit signed value to convert to a string.
380 @param Width The maximum number of Unicode characters to place in
381 Buffer, not including the Null-terminator.
383 @retval RETURN_SUCCESS The decimal value is converted.
384 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
386 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
387 If PcdMaximumUnicodeStringLength is not
388 zero, and BufferSize is greater than
389 (PcdMaximumUnicodeStringLength *
390 sizeof (CHAR16) + 1).
391 If unsupported bits are set in Flags.
392 If both COMMA_TYPE and RADIX_HEX are set in
394 If Width >= MAXIMUM_VALUE_CHARACTERS.
399 UnicodeValueToStringS (
400 IN OUT CHAR16
*Buffer
,
407 ASSERT_UNICODE_BUFFER (Buffer
);
408 return BasePrintLibConvertValueToStringS ((CHAR8
*)Buffer
, BufferSize
, Flags
, Value
, Width
, 2);
412 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
413 ASCII format string and a VA_LIST argument list.
415 This function is similar as vsnprintf_s defined in C11.
417 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
419 The ASCII string is produced by parsing the format string specified by FormatString.
420 Arguments are pulled from the variable argument list specified by Marker based on
421 the contents of the format string.
422 The number of ASCII characters in the produced output buffer is returned not including
425 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
426 unmodified and 0 is returned.
427 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
428 unmodified and 0 is returned.
429 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
430 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
431 is unmodified and 0 is returned.
432 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
433 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
434 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
436 If BufferSize is 0, then no output buffer is produced and 0 is returned.
438 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
440 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
441 @param FormatString A Null-terminated ASCII format string.
442 @param Marker VA_LIST marker for the variable argument list.
444 @return The number of ASCII characters in the produced output buffer not including the
451 OUT CHAR8
*StartOfBuffer
,
453 IN CONST CHAR8
*FormatString
,
457 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
, NULL
);
461 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
462 ASCII format string and a BASE_LIST argument list.
464 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
466 The ASCII string is produced by parsing the format string specified by FormatString.
467 Arguments are pulled from the variable argument list specified by Marker based on
468 the contents of the format string.
469 The number of ASCII characters in the produced output buffer is returned not including
472 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
473 unmodified and 0 is returned.
474 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
475 unmodified and 0 is returned.
476 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
477 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
478 is unmodified and 0 is returned.
479 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
480 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
481 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
483 If BufferSize is 0, then no output buffer is produced and 0 is returned.
485 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
487 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
488 @param FormatString A Null-terminated ASCII format string.
489 @param Marker BASE_LIST marker for the variable argument list.
491 @return The number of ASCII characters in the produced output buffer not including the
498 OUT CHAR8
*StartOfBuffer
,
500 IN CONST CHAR8
*FormatString
,
504 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, gNullVaList
, Marker
);
508 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
509 ASCII format string and variable argument list.
511 This function is similar as snprintf_s defined in C11.
513 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
515 The ASCII string is produced by parsing the format string specified by FormatString.
516 Arguments are pulled from the variable argument list based on the contents of the
518 The number of ASCII characters in the produced output buffer is returned not including
521 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
522 unmodified and 0 is returned.
523 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
524 unmodified and 0 is returned.
525 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
526 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
527 is unmodified and 0 is returned.
528 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
529 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
530 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
532 If BufferSize is 0, then no output buffer is produced and 0 is returned.
534 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
536 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
537 @param FormatString A Null-terminated ASCII format string.
538 @param ... Variable argument list whose contents are accessed based on the
539 format string specified by FormatString.
541 @return The number of ASCII characters in the produced output buffer not including the
548 OUT CHAR8
*StartOfBuffer
,
550 IN CONST CHAR8
*FormatString
,
555 UINTN NumberOfPrinted
;
557 VA_START (Marker
, FormatString
);
558 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
560 return NumberOfPrinted
;
564 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
565 Unicode format string and a VA_LIST argument list.
567 This function is similar as vsnprintf_s defined in C11.
569 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
571 The ASCII string is produced by parsing the format string specified by FormatString.
572 Arguments are pulled from the variable argument list specified by Marker based on
573 the contents of the format string.
574 The number of ASCII characters in the produced output buffer is returned not including
577 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
579 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
580 unmodified and 0 is returned.
581 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
582 unmodified and 0 is returned.
583 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
584 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
585 is unmodified and 0 is returned.
586 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
587 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
588 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
590 If BufferSize is 0, then no output buffer is produced and 0 is returned.
592 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
594 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
595 @param FormatString A Null-terminated Unicode format string.
596 @param Marker VA_LIST marker for the variable argument list.
598 @return The number of ASCII characters in the produced output buffer not including the
604 AsciiVSPrintUnicodeFormat (
605 OUT CHAR8
*StartOfBuffer
,
607 IN CONST CHAR16
*FormatString
,
611 ASSERT_UNICODE_BUFFER (FormatString
);
612 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
, NULL
);
616 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
617 Unicode format string and a BASE_LIST argument list.
619 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
621 The ASCII string is produced by parsing the format string specified by FormatString.
622 Arguments are pulled from the variable argument list specified by Marker based on
623 the contents of the format string.
624 The number of ASCII characters in the produced output buffer is returned not including
627 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
629 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
630 unmodified and 0 is returned.
631 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
632 unmodified and 0 is returned.
633 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
634 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
635 is unmodified and 0 is returned.
636 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
637 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
638 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
640 If BufferSize is 0, then no output buffer is produced and 0 is returned.
642 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
644 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
645 @param FormatString A Null-terminated Unicode format string.
646 @param Marker BASE_LIST marker for the variable argument list.
648 @return The number of ASCII characters in the produced output buffer not including the
654 AsciiBSPrintUnicodeFormat (
655 OUT CHAR8
*StartOfBuffer
,
657 IN CONST CHAR16
*FormatString
,
661 ASSERT_UNICODE_BUFFER (FormatString
);
662 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, gNullVaList
, Marker
);
666 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
667 Unicode format string and variable argument list.
669 This function is similar as snprintf_s defined in C11.
671 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
673 The ASCII string is produced by parsing the format string specified by FormatString.
674 Arguments are pulled from the variable argument list based on the contents of the
676 The number of ASCII characters in the produced output buffer is returned not including
679 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
681 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
682 unmodified and 0 is returned.
683 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
684 unmodified and 0 is returned.
685 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
686 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
687 is unmodified and 0 is returned.
688 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
689 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
690 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
692 If BufferSize is 0, then no output buffer is produced and 0 is returned.
694 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
696 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
697 @param FormatString A Null-terminated Unicode format string.
698 @param ... Variable argument list whose contents are accessed based on the
699 format string specified by FormatString.
701 @return The number of ASCII characters in the produced output buffer not including the
707 AsciiSPrintUnicodeFormat (
708 OUT CHAR8
*StartOfBuffer
,
710 IN CONST CHAR16
*FormatString
,
715 UINTN NumberOfPrinted
;
717 VA_START (Marker
, FormatString
);
718 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
720 return NumberOfPrinted
;
724 Converts a decimal value to a Null-terminated Ascii string.
726 Converts the decimal number specified by Value to a Null-terminated Ascii
727 string specified by Buffer containing at most Width characters. No padding of
728 spaces is ever performed. If Width is 0 then a width of
729 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than
730 Width characters, then only the first Width characters are placed in Buffer.
731 Additional conversion parameters are specified in Flags.
733 The Flags bit LEFT_JUSTIFY is always ignored.
734 All conversions are left justified in Buffer.
735 If Width is 0, PREFIX_ZERO is ignored in Flags.
736 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and
737 commas are inserted every 3rd digit starting from the right.
738 If RADIX_HEX is set in Flags, then the output buffer will be formatted in
740 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in
742 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then
743 Buffer is padded with '0' characters so the combination of the optional '-'
744 sign character, '0' characters, digit characters for Value, and the
745 Null-terminator add up to Width characters.
747 If an error would be returned, then the function will ASSERT().
749 @param Buffer The pointer to the output buffer for the produced
750 Null-terminated Ascii string.
751 @param BufferSize The size of Buffer in bytes, including the
753 @param Flags The bitmask of flags that specify left justification,
754 zero pad, and commas.
755 @param Value The 64-bit signed value to convert to a string.
756 @param Width The maximum number of Ascii characters to place in
757 Buffer, not including the Null-terminator.
759 @retval RETURN_SUCCESS The decimal value is converted.
760 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted
762 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.
763 If PcdMaximumAsciiStringLength is not
764 zero, and BufferSize is greater than
765 PcdMaximumAsciiStringLength.
766 If unsupported bits are set in Flags.
767 If both COMMA_TYPE and RADIX_HEX are set in
769 If Width >= MAXIMUM_VALUE_CHARACTERS.
774 AsciiValueToStringS (
775 IN OUT CHAR8
*Buffer
,
782 return BasePrintLibConvertValueToStringS (Buffer
, BufferSize
, Flags
, Value
, Width
, 1);
786 Returns the number of characters that would be produced by if the formatted
787 output were produced not including the Null-terminator.
789 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
791 If FormatString is NULL, then ASSERT() and 0 is returned.
792 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
793 than PcdMaximumUnicodeStringLength Unicode characters not including the
794 Null-terminator, then ASSERT() and 0 is returned.
796 @param[in] FormatString A Null-terminated Unicode format string.
797 @param[in] Marker VA_LIST marker for the variable argument list.
799 @return The number of characters that would be produced, not including the
805 IN CONST CHAR16
*FormatString
,
809 ASSERT_UNICODE_BUFFER (FormatString
);
810 return BasePrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
814 Returns the number of characters that would be produced by if the formatted
815 output were produced not including the Null-terminator.
817 If FormatString is NULL, then ASSERT() and 0 is returned.
818 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
819 than PcdMaximumAsciiStringLength Ascii characters not including the
820 Null-terminator, then ASSERT() and 0 is returned.
822 @param[in] FormatString A Null-terminated ASCII format string.
823 @param[in] Marker VA_LIST marker for the variable argument list.
825 @return The number of characters that would be produced, not including the
830 SPrintLengthAsciiFormat (
831 IN CONST CHAR8
*FormatString
,
835 return BasePrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);