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