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