MdePkg/BasePrintLib: Add safe print functions [A|U]ValueToStringS
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLib.c
CommitLineData
e1f414b6 1/** @file\r
eceb3a4c 2 Base Print Library instance implementation.\r
e1f414b6 3\r
9b002aa4 4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
19388d29
HT
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
e1f414b6 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
2fc59a00 9 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
e1f414b6 14**/\r
15\r
e1f414b6 16#include "PrintLibInternal.h"\r
17\r
ebd04fc2 18//\r
b5a6c9d9 19// Declare a VA_LIST global variable that is used in calls to BasePrintLibSPrintMarker()\r
20// when the BASE_LIST parameter is valid and the VA_LIST parameter is ignored. \r
21// A NULL VA_LIST can not be passed into BasePrintLibSPrintMarker() because some \r
ebd04fc2 22// compilers define VA_LIST to be a structure.\r
23//\r
b5a6c9d9 24VA_LIST gNullVaList;\r
ebd04fc2 25\r
e1f414b6 26#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)\r
27\r
e1f414b6 28/**\r
9b002aa4
HW
29 Produces a Null-terminated Unicode string in an output buffer based on\r
30 a Null-terminated Unicode format string and a VA_LIST argument list.\r
31\r
32 This function is similar as vsnprintf_s defined in C11.\r
33\r
e1f414b6 34 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
9b002aa4
HW
35 and BufferSize.\r
36 The Unicode string is produced by parsing the format string specified by FormatString.\r
37 Arguments are pulled from the variable argument list specified by Marker based on the\r
38 contents of the format string.\r
e1f414b6 39 The number of Unicode characters in the produced output buffer is returned not including\r
40 the Null-terminator.\r
e1f414b6 41\r
9b002aa4
HW
42 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
43 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
44\r
45 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
46 unmodified and 0 is returned.\r
47 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
48 unmodified and 0 is returned.\r
49 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
50 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
51 buffer is unmodified and 0 is returned.\r
52 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
e1f414b6 53 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4 54 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
e1f414b6 55\r
9b002aa4
HW
56 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
57\r
58 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 59 Unicode string.\r
60 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 61 @param FormatString A Null-terminated Unicode format string.\r
e1f414b6 62 @param Marker VA_LIST marker for the variable argument list.\r
9b002aa4 63\r
e1f414b6 64 @return The number of Unicode characters in the produced output buffer not including the\r
65 Null-terminator.\r
66\r
67**/\r
68UINTN\r
69EFIAPI\r
70UnicodeVSPrint (\r
71 OUT CHAR16 *StartOfBuffer,\r
72 IN UINTN BufferSize,\r
73 IN CONST CHAR16 *FormatString,\r
74 IN VA_LIST Marker\r
75 )\r
76{\r
2075236e 77 ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
78 ASSERT_UNICODE_BUFFER (FormatString);\r
79 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);\r
80}\r
81\r
82/**\r
9b002aa4
HW
83 Produces a Null-terminated Unicode string in an output buffer based on\r
84 a Null-terminated Unicode format string and a BASE_LIST argument list.\r
85\r
2075236e 86 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
9b002aa4
HW
87 and BufferSize.\r
88 The Unicode string is produced by parsing the format string specified by FormatString.\r
89 Arguments are pulled from the variable argument list specified by Marker based on the\r
90 contents of the format string.\r
2075236e 91 The number of Unicode characters in the produced output buffer is returned not including\r
92 the Null-terminator.\r
2075236e 93\r
9b002aa4
HW
94 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
95 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
96\r
97 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
98 unmodified and 0 is returned.\r
99 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
100 unmodified and 0 is returned.\r
101 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
102 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
103 buffer is unmodified and 0 is returned.\r
104 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
2075236e 105 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4
HW
106 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
107\r
108 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
2075236e 109\r
9b002aa4 110 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
2075236e 111 Unicode string.\r
112 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 113 @param FormatString A Null-terminated Unicode format string.\r
2075236e 114 @param Marker BASE_LIST marker for the variable argument list.\r
9b002aa4 115\r
2075236e 116 @return The number of Unicode characters in the produced output buffer not including the\r
117 Null-terminator.\r
118\r
119**/\r
120UINTN\r
121EFIAPI\r
122UnicodeBSPrint (\r
123 OUT CHAR16 *StartOfBuffer,\r
124 IN UINTN BufferSize,\r
125 IN CONST CHAR16 *FormatString,\r
126 IN BASE_LIST Marker\r
127 )\r
128{\r
129 ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
130 ASSERT_UNICODE_BUFFER (FormatString);\r
ebd04fc2 131 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);\r
e1f414b6 132}\r
133\r
134/**\r
9b002aa4 135 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
e1f414b6 136 Unicode format string and variable argument list.\r
9b002aa4
HW
137\r
138 This function is similar as snprintf_s defined in C11.\r
139\r
e1f414b6 140 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
141 and BufferSize.\r
142 The Unicode string is produced by parsing the format string specified by FormatString.\r
143 Arguments are pulled from the variable argument list based on the contents of the format string.\r
144 The number of Unicode characters in the produced output buffer is returned not including\r
145 the Null-terminator.\r
e1f414b6 146\r
9b002aa4
HW
147 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
148 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
149\r
150 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
151 unmodified and 0 is returned.\r
152 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
153 unmodified and 0 is returned.\r
154 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
155 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
156 buffer is unmodified and 0 is returned.\r
157 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
e1f414b6 158 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4
HW
159 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
160\r
161 If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned.\r
e1f414b6 162\r
9b002aa4 163 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 164 Unicode string.\r
165 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 166 @param FormatString A Null-terminated Unicode format string.\r
9b002aa4 167 @param ... Variable argument list whose contents are accessed based on the\r
285010e7 168 format string specified by FormatString.\r
9b002aa4 169\r
e1f414b6 170 @return The number of Unicode characters in the produced output buffer not including the\r
171 Null-terminator.\r
172\r
173**/\r
174UINTN\r
175EFIAPI\r
176UnicodeSPrint (\r
177 OUT CHAR16 *StartOfBuffer,\r
178 IN UINTN BufferSize,\r
179 IN CONST CHAR16 *FormatString,\r
180 ...\r
181 )\r
182{\r
183 VA_LIST Marker;\r
3bbe68a3 184 UINTN NumberOfPrinted;\r
e1f414b6 185\r
186 VA_START (Marker, FormatString);\r
3bbe68a3 187 NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
188 VA_END (Marker);\r
189 return NumberOfPrinted;\r
e1f414b6 190}\r
191\r
192/**\r
193 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
9b002aa4
HW
194 ASCII format string and a VA_LIST argument list.\r
195\r
196 This function is similar as vsnprintf_s defined in C11.\r
197\r
e1f414b6 198 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
199 and BufferSize.\r
200 The Unicode string is produced by parsing the format string specified by FormatString.\r
9b002aa4 201 Arguments are pulled from the variable argument list specified by Marker based on the\r
e1f414b6 202 contents of the format string.\r
203 The number of Unicode characters in the produced output buffer is returned not including\r
204 the Null-terminator.\r
e1f414b6 205\r
9b002aa4
HW
206 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
207\r
208 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
209 unmodified and 0 is returned.\r
210 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
211 unmodified and 0 is returned.\r
212 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
213 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
214 buffer is unmodified and 0 is returned.\r
e1f414b6 215 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
216 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
217 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
e1f414b6 218\r
9b002aa4
HW
219 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
220\r
221 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 222 Unicode string.\r
223 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 224 @param FormatString A Null-terminated ASCII format string.\r
e1f414b6 225 @param Marker VA_LIST marker for the variable argument list.\r
9b002aa4 226\r
e1f414b6 227 @return The number of Unicode characters in the produced output buffer not including the\r
228 Null-terminator.\r
229\r
230**/\r
231UINTN\r
232EFIAPI\r
233UnicodeVSPrintAsciiFormat (\r
234 OUT CHAR16 *StartOfBuffer,\r
235 IN UINTN BufferSize,\r
236 IN CONST CHAR8 *FormatString,\r
237 IN VA_LIST Marker\r
238 )\r
239{\r
2075236e 240 ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
241 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, Marker, NULL);\r
242}\r
243\r
244/**\r
245 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
9b002aa4
HW
246 ASCII format string and a BASE_LIST argument list.\r
247\r
2075236e 248 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
249 and BufferSize.\r
250 The Unicode string is produced by parsing the format string specified by FormatString.\r
9b002aa4 251 Arguments are pulled from the variable argument list specified by Marker based on the\r
2075236e 252 contents of the format string.\r
253 The number of Unicode characters in the produced output buffer is returned not including\r
254 the Null-terminator.\r
2075236e 255\r
9b002aa4
HW
256 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
257\r
258 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
259 unmodified and 0 is returned.\r
260 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
261 unmodified and 0 is returned.\r
262 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
263 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
264 buffer is unmodified and 0 is returned.\r
2075236e 265 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
266 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
267 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
268\r
269 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
2075236e 270\r
9b002aa4 271 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
2075236e 272 Unicode string.\r
273 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 274 @param FormatString A Null-terminated ASCII format string.\r
2075236e 275 @param Marker BASE_LIST marker for the variable argument list.\r
9b002aa4 276\r
2075236e 277 @return The number of Unicode characters in the produced output buffer not including the\r
278 Null-terminator.\r
279\r
280**/\r
281UINTN\r
282EFIAPI\r
283UnicodeBSPrintAsciiFormat (\r
284 OUT CHAR16 *StartOfBuffer,\r
285 IN UINTN BufferSize,\r
286 IN CONST CHAR8 *FormatString,\r
287 IN BASE_LIST Marker\r
288 )\r
289{\r
290 ASSERT_UNICODE_BUFFER (StartOfBuffer);\r
ebd04fc2 291 return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, gNullVaList, Marker);\r
e1f414b6 292}\r
293\r
294/**\r
9b002aa4 295 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
e1f414b6 296 ASCII format string and variable argument list.\r
9b002aa4
HW
297\r
298 This function is similar as snprintf_s defined in C11.\r
299\r
e1f414b6 300 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
301 and BufferSize.\r
302 The Unicode string is produced by parsing the format string specified by FormatString.\r
9b002aa4 303 Arguments are pulled from the variable argument list based on the contents of the\r
e1f414b6 304 format string.\r
305 The number of Unicode characters in the produced output buffer is returned not including\r
306 the Null-terminator.\r
e1f414b6 307\r
9b002aa4
HW
308 If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
309\r
310 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
311 unmodified and 0 is returned.\r
312 If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
313 unmodified and 0 is returned.\r
314 If PcdMaximumUnicodeStringLength is not zero, and BufferSize >\r
315 (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output\r
316 buffer is unmodified and 0 is returned.\r
e1f414b6 317 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
318 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
319 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
320\r
321 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
e1f414b6 322\r
9b002aa4 323 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 324 Unicode string.\r
325 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 326 @param FormatString A Null-terminated ASCII format string.\r
9b002aa4 327 @param ... Variable argument list whose contents are accessed based on the\r
285010e7 328 format string specified by FormatString.\r
9b002aa4 329\r
e1f414b6 330 @return The number of Unicode characters in the produced output buffer not including the\r
331 Null-terminator.\r
332\r
333**/\r
334UINTN\r
335EFIAPI\r
336UnicodeSPrintAsciiFormat (\r
337 OUT CHAR16 *StartOfBuffer,\r
338 IN UINTN BufferSize,\r
339 IN CONST CHAR8 *FormatString,\r
340 ...\r
341 )\r
342{\r
343 VA_LIST Marker;\r
3bbe68a3 344 UINTN NumberOfPrinted;\r
e1f414b6 345\r
346 VA_START (Marker, FormatString);\r
3bbe68a3 347 NumberOfPrinted = UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
348 VA_END (Marker);\r
349 return NumberOfPrinted;\r
e1f414b6 350}\r
351\r
352/**\r
353 Converts a decimal value to a Null-terminated Unicode string.\r
354 \r
355 Converts the decimal number specified by Value to a Null-terminated Unicode \r
356 string specified by Buffer containing at most Width characters. No padding of spaces \r
357 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
358 The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
359 If the conversion contains more than Width characters, then only the first\r
360 Width characters are returned, and the total number of characters \r
361 required to perform the conversion is returned.\r
362 Additional conversion parameters are specified in Flags. \r
363 \r
364 The Flags bit LEFT_JUSTIFY is always ignored.\r
365 All conversions are left justified in Buffer.\r
366 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
367 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
368 are inserted every 3rd digit starting from the right.\r
df8d0595 369 If RADIX_HEX is set in Flags, then the output buffer will be \r
e1f414b6 370 formatted in hexadecimal format.\r
df8d0595 371 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r
e1f414b6 372 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
373 then Buffer is padded with '0' characters so the combination of the optional '-' \r
374 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
375 add up to Width characters.\r
df8d0595 376 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
e1f414b6 377 If Buffer is NULL, then ASSERT().\r
378 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
379 If unsupported bits are set in Flags, then ASSERT().\r
df8d0595 380 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
e1f414b6 381 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
382\r
2fc59a00 383 @param Buffer The pointer to the output buffer for the produced Null-terminated\r
e1f414b6 384 Unicode string.\r
385 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
386 @param Value The 64-bit signed value to convert to a string.\r
387 @param Width The maximum number of Unicode characters to place in Buffer, not including\r
388 the Null-terminator.\r
389 \r
390 @return The number of Unicode characters in Buffer not including the Null-terminator.\r
391\r
392**/\r
393UINTN\r
394EFIAPI\r
395UnicodeValueToString (\r
396 IN OUT CHAR16 *Buffer,\r
397 IN UINTN Flags,\r
398 IN INT64 Value,\r
399 IN UINTN Width\r
400 )\r
401{\r
402 ASSERT_UNICODE_BUFFER(Buffer);\r
403 return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r
404}\r
405\r
51f0ceb4
HW
406/**\r
407 Converts a decimal value to a Null-terminated Unicode string.\r
408\r
409 Converts the decimal number specified by Value to a Null-terminated Unicode\r
410 string specified by Buffer containing at most Width characters. No padding of\r
411 spaces is ever performed. If Width is 0 then a width of\r
412 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than\r
413 Width characters, then only the first Width characters are placed in Buffer.\r
414 Additional conversion parameters are specified in Flags.\r
415\r
416 The Flags bit LEFT_JUSTIFY is always ignored.\r
417 All conversions are left justified in Buffer.\r
418 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
419 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
420 commas are inserted every 3rd digit starting from the right.\r
421 If RADIX_HEX is set in Flags, then the output buffer will be formatted in\r
422 hexadecimal format.\r
423 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in\r
424 Buffer is a '-'.\r
425 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then\r
426 Buffer is padded with '0' characters so the combination of the optional '-'\r
427 sign character, '0' characters, digit characters for Value, and the\r
428 Null-terminator add up to Width characters.\r
429\r
430 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
431 If an error would be returned, then the function will also ASSERT().\r
432\r
433 @param Buffer The pointer to the output buffer for the produced\r
434 Null-terminated Unicode string.\r
435 @param BufferSize The size of Buffer in bytes, including the\r
436 Null-terminator.\r
437 @param Flags The bitmask of flags that specify left justification,\r
438 zero pad, and commas.\r
439 @param Value The 64-bit signed value to convert to a string.\r
440 @param Width The maximum number of Unicode characters to place in\r
441 Buffer, not including the Null-terminator.\r
442\r
443 @retval RETURN_SUCCESS The decimal value is converted.\r
444 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r
445 value.\r
446 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
447 If PcdMaximumUnicodeStringLength is not\r
448 zero, and BufferSize is greater than\r
449 (PcdMaximumUnicodeStringLength *\r
450 sizeof (CHAR16) + 1).\r
451 If unsupported bits are set in Flags.\r
452 If both COMMA_TYPE and RADIX_HEX are set in\r
453 Flags.\r
454 If Width >= MAXIMUM_VALUE_CHARACTERS.\r
455\r
456**/\r
457RETURN_STATUS\r
458EFIAPI\r
459UnicodeValueToStringS (\r
460 IN OUT CHAR16 *Buffer,\r
461 IN UINTN BufferSize,\r
462 IN UINTN Flags,\r
463 IN INT64 Value,\r
464 IN UINTN Width\r
465 )\r
466{\r
467 ASSERT_UNICODE_BUFFER(Buffer);\r
468 return BasePrintLibConvertValueToStringS ((CHAR8 *)Buffer, BufferSize, Flags, Value, Width, 2);\r
469}\r
470\r
e1f414b6 471/**\r
472 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
473 ASCII format string and a VA_LIST argument list.\r
9b002aa4
HW
474\r
475 This function is similar as vsnprintf_s defined in C11.\r
476\r
e1f414b6 477 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
478 and BufferSize.\r
479 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 480 Arguments are pulled from the variable argument list specified by Marker based on\r
e1f414b6 481 the contents of the format string.\r
482 The number of ASCII characters in the produced output buffer is returned not including\r
483 the Null-terminator.\r
e1f414b6 484\r
9b002aa4
HW
485 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
486 unmodified and 0 is returned.\r
487 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
488 unmodified and 0 is returned.\r
489 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
490 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
491 is unmodified and 0 is returned.\r
e1f414b6 492 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
493 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
494 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
495\r
496 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
e1f414b6 497\r
9b002aa4 498 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 499 ASCII string.\r
500 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 501 @param FormatString A Null-terminated ASCII format string.\r
e1f414b6 502 @param Marker VA_LIST marker for the variable argument list.\r
9b002aa4 503\r
e1f414b6 504 @return The number of ASCII characters in the produced output buffer not including the\r
505 Null-terminator.\r
506\r
507**/\r
508UINTN\r
509EFIAPI\r
510AsciiVSPrint (\r
511 OUT CHAR8 *StartOfBuffer,\r
512 IN UINTN BufferSize,\r
513 IN CONST CHAR8 *FormatString,\r
514 IN VA_LIST Marker\r
515 )\r
516{\r
2075236e 517 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL);\r
518}\r
519\r
520/**\r
521 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
522 ASCII format string and a BASE_LIST argument list.\r
9b002aa4 523\r
2075236e 524 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
525 and BufferSize.\r
526 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 527 Arguments are pulled from the variable argument list specified by Marker based on\r
2075236e 528 the contents of the format string.\r
529 The number of ASCII characters in the produced output buffer is returned not including\r
530 the Null-terminator.\r
2075236e 531\r
9b002aa4
HW
532 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
533 unmodified and 0 is returned.\r
534 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
535 unmodified and 0 is returned.\r
536 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
537 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
538 is unmodified and 0 is returned.\r
2075236e 539 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
540 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
541 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
542\r
543 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
2075236e 544\r
9b002aa4 545 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
2075236e 546 ASCII string.\r
547 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 548 @param FormatString A Null-terminated ASCII format string.\r
2075236e 549 @param Marker BASE_LIST marker for the variable argument list.\r
9b002aa4 550\r
2075236e 551 @return The number of ASCII characters in the produced output buffer not including the\r
552 Null-terminator.\r
553\r
554**/\r
555UINTN\r
556EFIAPI\r
557AsciiBSPrint (\r
558 OUT CHAR8 *StartOfBuffer,\r
559 IN UINTN BufferSize,\r
560 IN CONST CHAR8 *FormatString,\r
561 IN BASE_LIST Marker\r
562 )\r
563{\r
ebd04fc2 564 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, gNullVaList, Marker);\r
e1f414b6 565}\r
566\r
567/**\r
568 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
569 ASCII format string and variable argument list.\r
9b002aa4
HW
570\r
571 This function is similar as snprintf_s defined in C11.\r
572\r
e1f414b6 573 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
574 and BufferSize.\r
575 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 576 Arguments are pulled from the variable argument list based on the contents of the\r
e1f414b6 577 format string.\r
578 The number of ASCII characters in the produced output buffer is returned not including\r
579 the Null-terminator.\r
e1f414b6 580\r
9b002aa4
HW
581 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
582 unmodified and 0 is returned.\r
583 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
584 unmodified and 0 is returned.\r
585 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
586 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
587 is unmodified and 0 is returned.\r
e1f414b6 588 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
9b002aa4
HW
589 PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then\r
590 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
e1f414b6 591\r
9b002aa4
HW
592 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
593\r
594 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 595 ASCII string.\r
596 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 597 @param FormatString A Null-terminated ASCII format string.\r
9b002aa4 598 @param ... Variable argument list whose contents are accessed based on the\r
285010e7 599 format string specified by FormatString.\r
9b002aa4 600\r
e1f414b6 601 @return The number of ASCII characters in the produced output buffer not including the\r
602 Null-terminator.\r
603\r
604**/\r
605UINTN\r
606EFIAPI\r
607AsciiSPrint (\r
608 OUT CHAR8 *StartOfBuffer,\r
609 IN UINTN BufferSize,\r
610 IN CONST CHAR8 *FormatString,\r
611 ...\r
612 )\r
613{\r
614 VA_LIST Marker;\r
3bbe68a3 615 UINTN NumberOfPrinted;\r
e1f414b6 616\r
617 VA_START (Marker, FormatString);\r
3bbe68a3 618 NumberOfPrinted = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
619 VA_END (Marker);\r
620 return NumberOfPrinted;\r
e1f414b6 621}\r
622\r
623/**\r
624 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
eceb3a4c 625 Unicode format string and a VA_LIST argument list.\r
9b002aa4
HW
626\r
627 This function is similar as vsnprintf_s defined in C11.\r
628\r
e1f414b6 629 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
630 and BufferSize.\r
631 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 632 Arguments are pulled from the variable argument list specified by Marker based on\r
e1f414b6 633 the contents of the format string.\r
634 The number of ASCII characters in the produced output buffer is returned not including\r
635 the Null-terminator.\r
e1f414b6 636\r
9b002aa4
HW
637 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
638\r
639 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
640 unmodified and 0 is returned.\r
641 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
642 unmodified and 0 is returned.\r
643 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
644 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
645 is unmodified and 0 is returned.\r
e1f414b6 646 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
647 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4
HW
648 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
649\r
650 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
e1f414b6 651\r
9b002aa4 652 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 653 ASCII string.\r
654 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 655 @param FormatString A Null-terminated Unicode format string.\r
e1f414b6 656 @param Marker VA_LIST marker for the variable argument list.\r
9b002aa4 657\r
e1f414b6 658 @return The number of ASCII characters in the produced output buffer not including the\r
659 Null-terminator.\r
660\r
661**/\r
662UINTN\r
663EFIAPI\r
664AsciiVSPrintUnicodeFormat (\r
665 OUT CHAR8 *StartOfBuffer,\r
666 IN UINTN BufferSize,\r
667 IN CONST CHAR16 *FormatString,\r
668 IN VA_LIST Marker\r
669 )\r
670{\r
671 ASSERT_UNICODE_BUFFER (FormatString);\r
2075236e 672 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);\r
673}\r
674\r
675/**\r
676 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
677 Unicode format string and a BASE_LIST argument list.\r
9b002aa4 678\r
2075236e 679 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
680 and BufferSize.\r
681 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 682 Arguments are pulled from the variable argument list specified by Marker based on\r
2075236e 683 the contents of the format string.\r
684 The number of ASCII characters in the produced output buffer is returned not including\r
685 the Null-terminator.\r
2075236e 686\r
9b002aa4
HW
687 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
688\r
689 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
690 unmodified and 0 is returned.\r
691 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
692 unmodified and 0 is returned.\r
693 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
694 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
695 is unmodified and 0 is returned.\r
2075236e 696 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
697 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4 698 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
2075236e 699\r
9b002aa4
HW
700 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
701\r
702 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
2075236e 703 ASCII string.\r
704 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 705 @param FormatString A Null-terminated Unicode format string.\r
2075236e 706 @param Marker BASE_LIST marker for the variable argument list.\r
9b002aa4 707\r
2075236e 708 @return The number of ASCII characters in the produced output buffer not including the\r
709 Null-terminator.\r
710\r
711**/\r
712UINTN\r
713EFIAPI\r
714AsciiBSPrintUnicodeFormat (\r
715 OUT CHAR8 *StartOfBuffer,\r
716 IN UINTN BufferSize,\r
717 IN CONST CHAR16 *FormatString,\r
718 IN BASE_LIST Marker\r
719 )\r
720{\r
721 ASSERT_UNICODE_BUFFER (FormatString);\r
ebd04fc2 722 return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);\r
e1f414b6 723}\r
724\r
725/**\r
726 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
eceb3a4c 727 Unicode format string and variable argument list.\r
9b002aa4
HW
728\r
729 This function is similar as snprintf_s defined in C11.\r
730\r
e1f414b6 731 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
732 and BufferSize.\r
733 The ASCII string is produced by parsing the format string specified by FormatString.\r
9b002aa4 734 Arguments are pulled from the variable argument list based on the contents of the\r
e1f414b6 735 format string.\r
736 The number of ASCII characters in the produced output buffer is returned not including\r
737 the Null-terminator.\r
e1f414b6 738\r
9b002aa4
HW
739 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
740\r
741 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is\r
742 unmodified and 0 is returned.\r
743 If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is\r
744 unmodified and 0 is returned.\r
745 If PcdMaximumAsciiStringLength is not zero, and BufferSize >\r
746 (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer\r
747 is unmodified and 0 is returned.\r
e1f414b6 748 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
749 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
9b002aa4
HW
750 ASSERT(). Also, the output buffer is unmodified and 0 is returned.\r
751\r
752 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
e1f414b6 753\r
9b002aa4 754 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated\r
e1f414b6 755 ASCII string.\r
756 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
2fc59a00 757 @param FormatString A Null-terminated Unicode format string.\r
9b002aa4 758 @param ... Variable argument list whose contents are accessed based on the\r
285010e7 759 format string specified by FormatString.\r
9b002aa4 760\r
e1f414b6 761 @return The number of ASCII characters in the produced output buffer not including the\r
762 Null-terminator.\r
763\r
764**/\r
765UINTN\r
766EFIAPI\r
767AsciiSPrintUnicodeFormat (\r
768 OUT CHAR8 *StartOfBuffer,\r
769 IN UINTN BufferSize,\r
770 IN CONST CHAR16 *FormatString,\r
771 ...\r
772 )\r
773{\r
774 VA_LIST Marker;\r
3bbe68a3 775 UINTN NumberOfPrinted;\r
e1f414b6 776\r
777 VA_START (Marker, FormatString);\r
3bbe68a3 778 NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
779 VA_END (Marker);\r
780 return NumberOfPrinted;\r
e1f414b6 781}\r
782\r
783\r
784/**\r
785 Converts a decimal value to a Null-terminated ASCII string.\r
786 \r
787 Converts the decimal number specified by Value to a Null-terminated ASCII string \r
788 specified by Buffer containing at most Width characters. No padding of spaces \r
789 is ever performed.\r
790 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
791 The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
792 If the conversion contains more than Width characters, then only the first Width\r
793 characters are returned, and the total number of characters required to perform\r
794 the conversion is returned.\r
795 Additional conversion parameters are specified in Flags. \r
796 The Flags bit LEFT_JUSTIFY is always ignored.\r
797 All conversions are left justified in Buffer.\r
798 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
799 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
800 are inserted every 3rd digit starting from the right.\r
df8d0595 801 If RADIX_HEX is set in Flags, then the output buffer will be \r
e1f414b6 802 formatted in hexadecimal format.\r
df8d0595 803 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r
e1f414b6 804 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
805 then Buffer is padded with '0' characters so the combination of the optional '-' \r
806 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
807 add up to Width characters.\r
808 \r
809 If Buffer is NULL, then ASSERT().\r
810 If unsupported bits are set in Flags, then ASSERT().\r
df8d0595 811 If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r
e1f414b6 812 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
813\r
2fc59a00 814 @param Buffer The pointer to the output buffer for the produced Null-terminated\r
e1f414b6 815 ASCII string.\r
816 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
817 @param Value The 64-bit signed value to convert to a string.\r
818 @param Width The maximum number of ASCII characters to place in Buffer, not including\r
819 the Null-terminator.\r
820 \r
821 @return The number of ASCII characters in Buffer not including the Null-terminator.\r
822\r
823**/\r
824UINTN\r
825EFIAPI\r
826AsciiValueToString (\r
58125b7a 827 OUT CHAR8 *Buffer,\r
828 IN UINTN Flags,\r
829 IN INT64 Value,\r
830 IN UINTN Width\r
e1f414b6 831 )\r
832{\r
833 return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);\r
834}\r
f405c067 835\r
51f0ceb4
HW
836/**\r
837 Converts a decimal value to a Null-terminated Ascii string.\r
838\r
839 Converts the decimal number specified by Value to a Null-terminated Ascii\r
840 string specified by Buffer containing at most Width characters. No padding of\r
841 spaces is ever performed. If Width is 0 then a width of\r
842 MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than\r
843 Width characters, then only the first Width characters are placed in Buffer.\r
844 Additional conversion parameters are specified in Flags.\r
845\r
846 The Flags bit LEFT_JUSTIFY is always ignored.\r
847 All conversions are left justified in Buffer.\r
848 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
849 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
850 commas are inserted every 3rd digit starting from the right.\r
851 If RADIX_HEX is set in Flags, then the output buffer will be formatted in\r
852 hexadecimal format.\r
853 If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in\r
854 Buffer is a '-'.\r
855 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then\r
856 Buffer is padded with '0' characters so the combination of the optional '-'\r
857 sign character, '0' characters, digit characters for Value, and the\r
858 Null-terminator add up to Width characters.\r
859\r
860 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
861 If an error would be returned, then the function will also ASSERT().\r
862\r
863 @param Buffer The pointer to the output buffer for the produced\r
864 Null-terminated Ascii string.\r
865 @param BufferSize The size of Buffer in bytes, including the\r
866 Null-terminator.\r
867 @param Flags The bitmask of flags that specify left justification,\r
868 zero pad, and commas.\r
869 @param Value The 64-bit signed value to convert to a string.\r
870 @param Width The maximum number of Ascii characters to place in\r
871 Buffer, not including the Null-terminator.\r
872\r
873 @retval RETURN_SUCCESS The decimal value is converted.\r
874 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r
875 value.\r
876 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
877 If PcdMaximumAsciiStringLength is not\r
878 zero, and BufferSize is greater than\r
879 PcdMaximumAsciiStringLength.\r
880 If unsupported bits are set in Flags.\r
881 If both COMMA_TYPE and RADIX_HEX are set in\r
882 Flags.\r
883 If Width >= MAXIMUM_VALUE_CHARACTERS.\r
884\r
885**/\r
886RETURN_STATUS\r
887EFIAPI\r
888AsciiValueToStringS (\r
889 IN OUT CHAR8 *Buffer,\r
890 IN UINTN BufferSize,\r
891 IN UINTN Flags,\r
892 IN INT64 Value,\r
893 IN UINTN Width\r
894 )\r
895{\r
896 return BasePrintLibConvertValueToStringS (Buffer, BufferSize, Flags, Value, Width, 1);\r
897}\r
898\r
f405c067 899/**\r
900 Returns the number of characters that would be produced by if the formatted \r
901 output were produced not including the Null-terminator.\r
902\r
f405c067 903 If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
904\r
9b002aa4
HW
905 If FormatString is NULL, then ASSERT() and 0 is returned.\r
906 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more\r
907 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
908 Null-terminator, then ASSERT() and 0 is returned.\r
909\r
f405c067 910 @param[in] FormatString A Null-terminated Unicode format string.\r
911 @param[in] Marker VA_LIST marker for the variable argument list.\r
912\r
913 @return The number of characters that would be produced, not including the \r
914 Null-terminator.\r
915**/\r
916UINTN\r
917EFIAPI\r
918SPrintLength (\r
919 IN CONST CHAR16 *FormatString,\r
920 IN VA_LIST Marker\r
921 )\r
922{\r
f405c067 923 ASSERT_UNICODE_BUFFER (FormatString);\r
924 return BasePrintLibSPrintMarker (NULL, 0, FORMAT_UNICODE | OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);\r
925}\r
926\r
927/**\r
928 Returns the number of characters that would be produced by if the formatted \r
929 output were produced not including the Null-terminator.\r
930\r
9b002aa4
HW
931 If FormatString is NULL, then ASSERT() and 0 is returned.\r
932 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more\r
933 than PcdMaximumAsciiStringLength Ascii characters not including the\r
934 Null-terminator, then ASSERT() and 0 is returned.\r
f405c067 935\r
936 @param[in] FormatString A Null-terminated ASCII format string.\r
937 @param[in] Marker VA_LIST marker for the variable argument list.\r
938\r
939 @return The number of characters that would be produced, not including the \r
940 Null-terminator.\r
941**/\r
942UINTN\r
943EFIAPI\r
944SPrintLengthAsciiFormat (\r
945 IN CONST CHAR8 *FormatString,\r
946 IN VA_LIST Marker\r
947 )\r
948{\r
f405c067 949 return BasePrintLibSPrintMarker (NULL, 0, OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);\r
950}\r