]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePrintLib/PrintLib.c
bf8c7bfe123a8b438182262813d5ee6499dbabd3
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
;
353 Converts a decimal value to a Null-terminated Unicode string.
355 Converts the decimal number specified by Value to a Null-terminated Unicode
356 string specified by Buffer containing at most Width characters. No padding of spaces
357 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
358 The number of Unicode characters in Buffer is returned not including the Null-terminator.
359 If the conversion contains more than Width characters, then only the first
360 Width characters are returned, and the total number of characters
361 required to perform the conversion is returned.
362 Additional conversion parameters are specified in Flags.
364 The Flags bit LEFT_JUSTIFY is always ignored.
365 All conversions are left justified in Buffer.
366 If Width is 0, PREFIX_ZERO is ignored in Flags.
367 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
368 are inserted every 3rd digit starting from the right.
369 If RADIX_HEX is set in Flags, then the output buffer will be
370 formatted in hexadecimal format.
371 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
372 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
373 then Buffer is padded with '0' characters so the combination of the optional '-'
374 sign character, '0' characters, digit characters for Value, and the Null-terminator
375 add up to Width characters.
376 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
377 If Buffer is NULL, then ASSERT().
378 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
379 If unsupported bits are set in Flags, then ASSERT().
380 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
381 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
383 @param Buffer The pointer to the output buffer for the produced Null-terminated
385 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
386 @param Value The 64-bit signed value to convert to a string.
387 @param Width The maximum number of Unicode characters to place in Buffer, not including
390 @return The number of Unicode characters in Buffer not including the Null-terminator.
395 UnicodeValueToString (
396 IN OUT CHAR16
*Buffer
,
402 ASSERT_UNICODE_BUFFER(Buffer
);
403 return BasePrintLibConvertValueToString ((CHAR8
*)Buffer
, Flags
, Value
, Width
, 2);
407 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
408 ASCII format string and a VA_LIST argument list.
410 This function is similar as vsnprintf_s defined in C11.
412 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
414 The ASCII string is produced by parsing the format string specified by FormatString.
415 Arguments are pulled from the variable argument list specified by Marker based on
416 the contents of the format string.
417 The number of ASCII characters in the produced output buffer is returned not including
420 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
421 unmodified and 0 is returned.
422 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
423 unmodified and 0 is returned.
424 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
425 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
426 is unmodified and 0 is returned.
427 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
428 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
429 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
431 If BufferSize is 0, then no output buffer is produced and 0 is returned.
433 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
435 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
436 @param FormatString A Null-terminated ASCII format string.
437 @param Marker VA_LIST marker for the variable argument list.
439 @return The number of ASCII characters in the produced output buffer not including the
446 OUT CHAR8
*StartOfBuffer
,
448 IN CONST CHAR8
*FormatString
,
452 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, Marker
, NULL
);
456 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
457 ASCII format string and a BASE_LIST argument list.
459 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
461 The ASCII string is produced by parsing the format string specified by FormatString.
462 Arguments are pulled from the variable argument list specified by Marker based on
463 the contents of the format string.
464 The number of ASCII characters in the produced output buffer is returned not including
467 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
468 unmodified and 0 is returned.
469 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
470 unmodified and 0 is returned.
471 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
472 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
473 is unmodified and 0 is returned.
474 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
475 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
476 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
478 If BufferSize is 0, then no output buffer is produced and 0 is returned.
480 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
482 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
483 @param FormatString A Null-terminated ASCII format string.
484 @param Marker BASE_LIST marker for the variable argument list.
486 @return The number of ASCII characters in the produced output buffer not including the
493 OUT CHAR8
*StartOfBuffer
,
495 IN CONST CHAR8
*FormatString
,
499 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, 0, FormatString
, gNullVaList
, Marker
);
503 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
504 ASCII format string and variable argument list.
506 This function is similar as snprintf_s defined in C11.
508 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
510 The ASCII string is produced by parsing the format string specified by FormatString.
511 Arguments are pulled from the variable argument list based on the contents of the
513 The number of ASCII characters in the produced output buffer is returned not including
516 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
517 unmodified and 0 is returned.
518 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
519 unmodified and 0 is returned.
520 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
521 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
522 is unmodified and 0 is returned.
523 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
524 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then
525 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
527 If BufferSize is 0, then no output buffer is produced and 0 is returned.
529 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
531 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
532 @param FormatString A Null-terminated ASCII format string.
533 @param ... Variable argument list whose contents are accessed based on the
534 format string specified by FormatString.
536 @return The number of ASCII characters in the produced output buffer not including the
543 OUT CHAR8
*StartOfBuffer
,
545 IN CONST CHAR8
*FormatString
,
550 UINTN NumberOfPrinted
;
552 VA_START (Marker
, FormatString
);
553 NumberOfPrinted
= AsciiVSPrint (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
555 return NumberOfPrinted
;
559 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
560 Unicode format string and a VA_LIST argument list.
562 This function is similar as vsnprintf_s defined in C11.
564 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
566 The ASCII string is produced by parsing the format string specified by FormatString.
567 Arguments are pulled from the variable argument list specified by Marker based on
568 the contents of the format string.
569 The number of ASCII characters in the produced output buffer is returned not including
572 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
574 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
575 unmodified and 0 is returned.
576 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
577 unmodified and 0 is returned.
578 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
579 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
580 is unmodified and 0 is returned.
581 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
582 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
583 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
585 If BufferSize is 0, then no output buffer is produced and 0 is returned.
587 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
589 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
590 @param FormatString A Null-terminated Unicode format string.
591 @param Marker VA_LIST marker for the variable argument list.
593 @return The number of ASCII characters in the produced output buffer not including the
599 AsciiVSPrintUnicodeFormat (
600 OUT CHAR8
*StartOfBuffer
,
602 IN CONST CHAR16
*FormatString
,
606 ASSERT_UNICODE_BUFFER (FormatString
);
607 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, Marker
, NULL
);
611 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
612 Unicode format string and a BASE_LIST argument list.
614 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
616 The ASCII 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
618 the contents of the format string.
619 The number of ASCII characters in the produced output buffer is returned not including
622 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
624 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
625 unmodified and 0 is returned.
626 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
627 unmodified and 0 is returned.
628 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
629 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
630 is unmodified and 0 is returned.
631 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
632 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
633 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
635 If BufferSize is 0, then no output buffer is produced and 0 is returned.
637 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
639 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
640 @param FormatString A Null-terminated Unicode format string.
641 @param Marker BASE_LIST marker for the variable argument list.
643 @return The number of ASCII characters in the produced output buffer not including the
649 AsciiBSPrintUnicodeFormat (
650 OUT CHAR8
*StartOfBuffer
,
652 IN CONST CHAR16
*FormatString
,
656 ASSERT_UNICODE_BUFFER (FormatString
);
657 return BasePrintLibSPrintMarker (StartOfBuffer
, BufferSize
, FORMAT_UNICODE
, (CHAR8
*)FormatString
, gNullVaList
, Marker
);
661 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
662 Unicode format string and variable argument list.
664 This function is similar as snprintf_s defined in C11.
666 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
668 The ASCII string is produced by parsing the format string specified by FormatString.
669 Arguments are pulled from the variable argument list based on the contents of the
671 The number of ASCII characters in the produced output buffer is returned not including
674 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
676 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is
677 unmodified and 0 is returned.
678 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is
679 unmodified and 0 is returned.
680 If PcdMaximumAsciiStringLength is not zero, and BufferSize >
681 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer
682 is unmodified and 0 is returned.
683 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
684 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
685 ASSERT(). Also, the output buffer is unmodified and 0 is returned.
687 If BufferSize is 0, then no output buffer is produced and 0 is returned.
689 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
691 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
692 @param FormatString A Null-terminated Unicode format string.
693 @param ... Variable argument list whose contents are accessed based on the
694 format string specified by FormatString.
696 @return The number of ASCII characters in the produced output buffer not including the
702 AsciiSPrintUnicodeFormat (
703 OUT CHAR8
*StartOfBuffer
,
705 IN CONST CHAR16
*FormatString
,
710 UINTN NumberOfPrinted
;
712 VA_START (Marker
, FormatString
);
713 NumberOfPrinted
= AsciiVSPrintUnicodeFormat (StartOfBuffer
, BufferSize
, FormatString
, Marker
);
715 return NumberOfPrinted
;
720 Converts a decimal value to a Null-terminated ASCII string.
722 Converts the decimal number specified by Value to a Null-terminated ASCII string
723 specified by Buffer containing at most Width characters. No padding of spaces
725 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
726 The number of ASCII characters in Buffer is returned not including the Null-terminator.
727 If the conversion contains more than Width characters, then only the first Width
728 characters are returned, and the total number of characters required to perform
729 the conversion is returned.
730 Additional conversion parameters are specified in Flags.
731 The Flags bit LEFT_JUSTIFY is always ignored.
732 All conversions are left justified in Buffer.
733 If Width is 0, PREFIX_ZERO is ignored in Flags.
734 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
735 are inserted every 3rd digit starting from the right.
736 If RADIX_HEX is set in Flags, then the output buffer will be
737 formatted in hexadecimal format.
738 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.
739 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
740 then Buffer is padded with '0' characters so the combination of the optional '-'
741 sign character, '0' characters, digit characters for Value, and the Null-terminator
742 add up to Width characters.
744 If Buffer is NULL, then ASSERT().
745 If unsupported bits are set in Flags, then ASSERT().
746 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().
747 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
749 @param Buffer The pointer to the output buffer for the produced Null-terminated
751 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
752 @param Value The 64-bit signed value to convert to a string.
753 @param Width The maximum number of ASCII characters to place in Buffer, not including
756 @return The number of ASCII characters in Buffer not including the Null-terminator.
768 return BasePrintLibConvertValueToString (Buffer
, Flags
, Value
, Width
, 1);
772 Returns the number of characters that would be produced by if the formatted
773 output were produced not including the Null-terminator.
775 If FormatString is not aligned on a 16-bit boundary, then ASSERT().
777 If FormatString is NULL, then ASSERT() and 0 is returned.
778 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more
779 than PcdMaximumUnicodeStringLength Unicode characters not including the
780 Null-terminator, then ASSERT() and 0 is returned.
782 @param[in] FormatString A Null-terminated Unicode format string.
783 @param[in] Marker VA_LIST marker for the variable argument list.
785 @return The number of characters that would be produced, not including the
791 IN CONST CHAR16
*FormatString
,
795 ASSERT_UNICODE_BUFFER (FormatString
);
796 return BasePrintLibSPrintMarker (NULL
, 0, FORMAT_UNICODE
| OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);
800 Returns the number of characters that would be produced by if the formatted
801 output were produced not including the Null-terminator.
803 If FormatString is NULL, then ASSERT() and 0 is returned.
804 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more
805 than PcdMaximumAsciiStringLength Ascii characters not including the
806 Null-terminator, then ASSERT() and 0 is returned.
808 @param[in] FormatString A Null-terminated ASCII format string.
809 @param[in] Marker VA_LIST marker for the variable argument list.
811 @return The number of characters that would be produced, not including the
816 SPrintLengthAsciiFormat (
817 IN CONST CHAR8
*FormatString
,
821 return BasePrintLibSPrintMarker (NULL
, 0, OUTPUT_UNICODE
| COUNT_ONLY_NO_PRINT
, (CHAR8
*)FormatString
, Marker
, NULL
);