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