]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
eceb3a4c | 2 | Base Print Library instance implementation.\r |
e1f414b6 | 3 | \r |
3bbe68a3 | 4 | Copyright (c) 2006 - 2012, 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 |
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 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
33 | and BufferSize. \r | |
34 | The Unicode string is produced by parsing the format string specified by FormatString. \r | |
35 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
36 | contents of the format string. \r | |
37 | The number of Unicode characters in the produced output buffer is returned not including\r | |
38 | the Null-terminator.\r | |
39 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
40 | \r | |
41 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
42 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
43 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
44 | If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
45 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
46 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
47 | ASSERT().\r | |
48 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
49 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
50 | Null-terminator, then ASSERT().\r | |
51 | \r | |
52 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
53 | Unicode string.\r | |
54 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 55 | @param FormatString A Null-terminated Unicode format string.\r |
e1f414b6 | 56 | @param Marker VA_LIST marker for the variable argument list.\r |
57 | \r | |
58 | @return The number of Unicode characters in the produced output buffer not including the\r | |
59 | Null-terminator.\r | |
60 | \r | |
61 | **/\r | |
62 | UINTN\r | |
63 | EFIAPI\r | |
64 | UnicodeVSPrint (\r | |
65 | OUT CHAR16 *StartOfBuffer,\r | |
66 | IN UINTN BufferSize,\r | |
67 | IN CONST CHAR16 *FormatString,\r | |
68 | IN VA_LIST Marker\r | |
69 | )\r | |
70 | {\r | |
2075236e | 71 | ASSERT_UNICODE_BUFFER (StartOfBuffer);\r |
72 | ASSERT_UNICODE_BUFFER (FormatString);\r | |
73 | return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
77 | Produces a Null-terminated Unicode string in an output buffer based on \r | |
78 | a Null-terminated Unicode format string and a BASE_LIST argument list\r | |
79 | \r | |
80 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
81 | and BufferSize. \r | |
82 | The Unicode string is produced by parsing the format string specified by FormatString. \r | |
83 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
84 | contents of the format string. \r | |
85 | The number of Unicode characters in the produced output buffer is returned not including\r | |
86 | the Null-terminator.\r | |
87 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
88 | \r | |
89 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
90 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
91 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
92 | If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
93 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
94 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
95 | ASSERT().\r | |
96 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
97 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
98 | Null-terminator, then ASSERT().\r | |
99 | \r | |
100 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
101 | Unicode string.\r | |
102 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 103 | @param FormatString A Null-terminated Unicode format string.\r |
2075236e | 104 | @param Marker BASE_LIST marker for the variable argument list.\r |
105 | \r | |
106 | @return The number of Unicode characters in the produced output buffer not including the\r | |
107 | Null-terminator.\r | |
108 | \r | |
109 | **/\r | |
110 | UINTN\r | |
111 | EFIAPI\r | |
112 | UnicodeBSPrint (\r | |
113 | OUT CHAR16 *StartOfBuffer,\r | |
114 | IN UINTN BufferSize,\r | |
115 | IN CONST CHAR16 *FormatString,\r | |
116 | IN BASE_LIST Marker\r | |
117 | )\r | |
118 | {\r | |
119 | ASSERT_UNICODE_BUFFER (StartOfBuffer);\r | |
120 | ASSERT_UNICODE_BUFFER (FormatString);\r | |
ebd04fc2 | 121 | return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);\r |
e1f414b6 | 122 | }\r |
123 | \r | |
124 | /**\r | |
125 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
126 | Unicode format string and variable argument list.\r | |
127 | \r | |
128 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
129 | and BufferSize.\r | |
130 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
131 | Arguments are pulled from the variable argument list based on the contents of the format string.\r | |
132 | The number of Unicode characters in the produced output buffer is returned not including\r | |
133 | the Null-terminator.\r | |
134 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
135 | \r | |
136 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
137 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
138 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
139 | If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
140 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
141 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
142 | ASSERT().\r | |
143 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
144 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
145 | Null-terminator, then ASSERT().\r | |
146 | \r | |
147 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
148 | Unicode string.\r | |
149 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 150 | @param FormatString A Null-terminated Unicode format string.\r |
285010e7 | 151 | @param ... Variable argument list whose contents are accessed based on the \r |
152 | format string specified by FormatString.\r | |
122e2191 | 153 | \r |
e1f414b6 | 154 | @return The number of Unicode characters in the produced output buffer not including the\r |
155 | Null-terminator.\r | |
156 | \r | |
157 | **/\r | |
158 | UINTN\r | |
159 | EFIAPI\r | |
160 | UnicodeSPrint (\r | |
161 | OUT CHAR16 *StartOfBuffer,\r | |
162 | IN UINTN BufferSize,\r | |
163 | IN CONST CHAR16 *FormatString,\r | |
164 | ...\r | |
165 | )\r | |
166 | {\r | |
167 | VA_LIST Marker;\r | |
3bbe68a3 | 168 | UINTN NumberOfPrinted;\r |
e1f414b6 | 169 | \r |
170 | VA_START (Marker, FormatString);\r | |
3bbe68a3 | 171 | NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r |
172 | VA_END (Marker);\r | |
173 | return NumberOfPrinted;\r | |
e1f414b6 | 174 | }\r |
175 | \r | |
176 | /**\r | |
177 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
178 | ASCII format string and a VA_LIST argument list\r | |
179 | \r | |
180 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
181 | and BufferSize.\r | |
182 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
183 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
184 | contents of the format string.\r | |
185 | The number of Unicode characters in the produced output buffer is returned not including\r | |
186 | the Null-terminator.\r | |
187 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
188 | \r | |
189 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
190 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
191 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
192 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
193 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
194 | ASSERT().\r | |
195 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
196 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
197 | Null-terminator, then ASSERT().\r | |
198 | \r | |
199 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
200 | Unicode string.\r | |
201 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 202 | @param FormatString A Null-terminated ASCII format string.\r |
e1f414b6 | 203 | @param Marker VA_LIST marker for the variable argument list.\r |
204 | \r | |
205 | @return The number of Unicode characters in the produced output buffer not including the\r | |
206 | Null-terminator.\r | |
207 | \r | |
208 | **/\r | |
209 | UINTN\r | |
210 | EFIAPI\r | |
211 | UnicodeVSPrintAsciiFormat (\r | |
212 | OUT CHAR16 *StartOfBuffer,\r | |
213 | IN UINTN BufferSize,\r | |
214 | IN CONST CHAR8 *FormatString,\r | |
215 | IN VA_LIST Marker\r | |
216 | )\r | |
217 | {\r | |
2075236e | 218 | ASSERT_UNICODE_BUFFER (StartOfBuffer);\r |
219 | return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, Marker, NULL);\r | |
220 | }\r | |
221 | \r | |
222 | /**\r | |
223 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
224 | ASCII format string and a BASE_LIST argument list\r | |
225 | \r | |
226 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
227 | and BufferSize.\r | |
228 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
229 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
230 | contents of the format string.\r | |
231 | The number of Unicode characters in the produced output buffer is returned not including\r | |
232 | the Null-terminator.\r | |
233 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
234 | \r | |
235 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
236 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
237 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
238 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
239 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
240 | ASSERT().\r | |
241 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
242 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
243 | Null-terminator, then ASSERT().\r | |
244 | \r | |
245 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
246 | Unicode string.\r | |
247 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 248 | @param FormatString A Null-terminated ASCII format string.\r |
2075236e | 249 | @param Marker BASE_LIST marker for the variable argument list.\r |
250 | \r | |
251 | @return The number of Unicode characters in the produced output buffer not including the\r | |
252 | Null-terminator.\r | |
253 | \r | |
254 | **/\r | |
255 | UINTN\r | |
256 | EFIAPI\r | |
257 | UnicodeBSPrintAsciiFormat (\r | |
258 | OUT CHAR16 *StartOfBuffer,\r | |
259 | IN UINTN BufferSize,\r | |
260 | IN CONST CHAR8 *FormatString,\r | |
261 | IN BASE_LIST Marker\r | |
262 | )\r | |
263 | {\r | |
264 | ASSERT_UNICODE_BUFFER (StartOfBuffer);\r | |
ebd04fc2 | 265 | return BasePrintLibSPrintMarker ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE, FormatString, gNullVaList, Marker);\r |
e1f414b6 | 266 | }\r |
267 | \r | |
268 | /**\r | |
269 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
270 | ASCII format string and variable argument list.\r | |
271 | \r | |
272 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
273 | and BufferSize.\r | |
274 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
275 | Arguments are pulled from the variable argument list based on the contents of the \r | |
276 | format string.\r | |
277 | The number of Unicode characters in the produced output buffer is returned not including\r | |
278 | the Null-terminator.\r | |
279 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
280 | \r | |
281 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
282 | If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
283 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
284 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
285 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
286 | ASSERT().\r | |
287 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
288 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
289 | Null-terminator, then ASSERT().\r | |
290 | \r | |
291 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
292 | Unicode string.\r | |
293 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 294 | @param FormatString A Null-terminated ASCII format string.\r |
285010e7 | 295 | @param ... Variable argument list whose contents are accessed based on the \r |
296 | format string specified by FormatString.\r | |
e1f414b6 | 297 | \r |
298 | @return The number of Unicode characters in the produced output buffer not including the\r | |
299 | Null-terminator.\r | |
300 | \r | |
301 | **/\r | |
302 | UINTN\r | |
303 | EFIAPI\r | |
304 | UnicodeSPrintAsciiFormat (\r | |
305 | OUT CHAR16 *StartOfBuffer,\r | |
306 | IN UINTN BufferSize,\r | |
307 | IN CONST CHAR8 *FormatString,\r | |
308 | ...\r | |
309 | )\r | |
310 | {\r | |
311 | VA_LIST Marker;\r | |
3bbe68a3 | 312 | UINTN NumberOfPrinted;\r |
e1f414b6 | 313 | \r |
314 | VA_START (Marker, FormatString);\r | |
3bbe68a3 | 315 | NumberOfPrinted = UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r |
316 | VA_END (Marker);\r | |
317 | return NumberOfPrinted;\r | |
e1f414b6 | 318 | }\r |
319 | \r | |
320 | /**\r | |
321 | Converts a decimal value to a Null-terminated Unicode string.\r | |
322 | \r | |
323 | Converts the decimal number specified by Value to a Null-terminated Unicode \r | |
324 | string specified by Buffer containing at most Width characters. No padding of spaces \r | |
325 | is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
326 | The number of Unicode characters in Buffer is returned not including the Null-terminator.\r | |
327 | If the conversion contains more than Width characters, then only the first\r | |
328 | Width characters are returned, and the total number of characters \r | |
329 | required to perform the conversion is returned.\r | |
330 | Additional conversion parameters are specified in Flags. \r | |
331 | \r | |
332 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
333 | All conversions are left justified in Buffer.\r | |
334 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
335 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
336 | are inserted every 3rd digit starting from the right.\r | |
df8d0595 | 337 | If RADIX_HEX is set in Flags, then the output buffer will be \r |
e1f414b6 | 338 | formatted in hexadecimal format.\r |
df8d0595 | 339 | If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r |
e1f414b6 | 340 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r |
341 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
342 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
343 | add up to Width characters.\r | |
df8d0595 | 344 | If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r |
e1f414b6 | 345 | If Buffer is NULL, then ASSERT().\r |
346 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
347 | If unsupported bits are set in Flags, then ASSERT().\r | |
df8d0595 | 348 | If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r |
e1f414b6 | 349 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r |
350 | \r | |
2fc59a00 | 351 | @param Buffer The pointer to the output buffer for the produced Null-terminated\r |
e1f414b6 | 352 | Unicode string.\r |
353 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
354 | @param Value The 64-bit signed value to convert to a string.\r | |
355 | @param Width The maximum number of Unicode characters to place in Buffer, not including\r | |
356 | the Null-terminator.\r | |
357 | \r | |
358 | @return The number of Unicode characters in Buffer not including the Null-terminator.\r | |
359 | \r | |
360 | **/\r | |
361 | UINTN\r | |
362 | EFIAPI\r | |
363 | UnicodeValueToString (\r | |
364 | IN OUT CHAR16 *Buffer,\r | |
365 | IN UINTN Flags,\r | |
366 | IN INT64 Value,\r | |
367 | IN UINTN Width\r | |
368 | )\r | |
369 | {\r | |
370 | ASSERT_UNICODE_BUFFER(Buffer);\r | |
371 | return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r | |
372 | }\r | |
373 | \r | |
374 | /**\r | |
375 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
376 | ASCII format string and a VA_LIST argument list.\r | |
377 | \r | |
378 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
379 | and BufferSize.\r | |
380 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
381 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
382 | the contents of the format string.\r | |
383 | The number of ASCII characters in the produced output buffer is returned not including\r | |
384 | the Null-terminator.\r | |
385 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
386 | \r | |
387 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
388 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
389 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
390 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
391 | ASSERT().\r | |
392 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
393 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
394 | Null-terminator, then ASSERT().\r | |
395 | \r | |
396 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
397 | ASCII string.\r | |
398 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 399 | @param FormatString A Null-terminated ASCII format string.\r |
e1f414b6 | 400 | @param Marker VA_LIST marker for the variable argument list.\r |
401 | \r | |
402 | @return The number of ASCII characters in the produced output buffer not including the\r | |
403 | Null-terminator.\r | |
404 | \r | |
405 | **/\r | |
406 | UINTN\r | |
407 | EFIAPI\r | |
408 | AsciiVSPrint (\r | |
409 | OUT CHAR8 *StartOfBuffer,\r | |
410 | IN UINTN BufferSize,\r | |
411 | IN CONST CHAR8 *FormatString,\r | |
412 | IN VA_LIST Marker\r | |
413 | )\r | |
414 | {\r | |
2075236e | 415 | return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL);\r |
416 | }\r | |
417 | \r | |
418 | /**\r | |
419 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
420 | ASCII format string and a BASE_LIST argument list.\r | |
421 | \r | |
422 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
423 | and BufferSize.\r | |
424 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
425 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
426 | the contents of the format string.\r | |
427 | The number of ASCII characters in the produced output buffer is returned not including\r | |
428 | the Null-terminator.\r | |
429 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
430 | \r | |
431 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
432 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
433 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
434 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
435 | ASSERT().\r | |
436 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
437 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
438 | Null-terminator, then ASSERT().\r | |
439 | \r | |
440 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
441 | ASCII string.\r | |
442 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 443 | @param FormatString A Null-terminated ASCII format string.\r |
2075236e | 444 | @param Marker BASE_LIST marker for the variable argument list.\r |
445 | \r | |
446 | @return The number of ASCII characters in the produced output buffer not including the\r | |
447 | Null-terminator.\r | |
448 | \r | |
449 | **/\r | |
450 | UINTN\r | |
451 | EFIAPI\r | |
452 | AsciiBSPrint (\r | |
453 | OUT CHAR8 *StartOfBuffer,\r | |
454 | IN UINTN BufferSize,\r | |
455 | IN CONST CHAR8 *FormatString,\r | |
456 | IN BASE_LIST Marker\r | |
457 | )\r | |
458 | {\r | |
ebd04fc2 | 459 | return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, gNullVaList, Marker);\r |
e1f414b6 | 460 | }\r |
461 | \r | |
462 | /**\r | |
463 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
464 | ASCII format string and variable argument list.\r | |
465 | \r | |
466 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
467 | and BufferSize.\r | |
468 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
469 | Arguments are pulled from the variable argument list based on the contents of the \r | |
470 | format string.\r | |
471 | The number of ASCII characters in the produced output buffer is returned not including\r | |
472 | the Null-terminator.\r | |
473 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
474 | \r | |
475 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
476 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
477 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
478 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
479 | ASSERT().\r | |
480 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
481 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
482 | Null-terminator, then ASSERT().\r | |
483 | \r | |
484 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
485 | ASCII string.\r | |
486 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 487 | @param FormatString A Null-terminated ASCII format string.\r |
285010e7 | 488 | @param ... Variable argument list whose contents are accessed based on the \r |
489 | format string specified by FormatString.\r | |
efb23117 | 490 | \r |
e1f414b6 | 491 | @return The number of ASCII characters in the produced output buffer not including the\r |
492 | Null-terminator.\r | |
493 | \r | |
494 | **/\r | |
495 | UINTN\r | |
496 | EFIAPI\r | |
497 | AsciiSPrint (\r | |
498 | OUT CHAR8 *StartOfBuffer,\r | |
499 | IN UINTN BufferSize,\r | |
500 | IN CONST CHAR8 *FormatString,\r | |
501 | ...\r | |
502 | )\r | |
503 | {\r | |
504 | VA_LIST Marker;\r | |
3bbe68a3 | 505 | UINTN NumberOfPrinted;\r |
e1f414b6 | 506 | \r |
507 | VA_START (Marker, FormatString);\r | |
3bbe68a3 | 508 | NumberOfPrinted = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r |
509 | VA_END (Marker);\r | |
510 | return NumberOfPrinted;\r | |
e1f414b6 | 511 | }\r |
512 | \r | |
513 | /**\r | |
514 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
eceb3a4c | 515 | Unicode format string and a VA_LIST argument list.\r |
e1f414b6 | 516 | \r |
517 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
518 | and BufferSize.\r | |
519 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
520 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
521 | the contents of the format string.\r | |
522 | The number of ASCII characters in the produced output buffer is returned not including\r | |
523 | the Null-terminator.\r | |
524 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
525 | \r | |
526 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
527 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
528 | If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
529 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
530 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
531 | ASSERT().\r | |
532 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
533 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
534 | Null-terminator, then ASSERT().\r | |
535 | \r | |
536 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
537 | ASCII string.\r | |
538 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 539 | @param FormatString A Null-terminated Unicode format string.\r |
e1f414b6 | 540 | @param Marker VA_LIST marker for the variable argument list.\r |
541 | \r | |
542 | @return The number of ASCII characters in the produced output buffer not including the\r | |
543 | Null-terminator.\r | |
544 | \r | |
545 | **/\r | |
546 | UINTN\r | |
547 | EFIAPI\r | |
548 | AsciiVSPrintUnicodeFormat (\r | |
549 | OUT CHAR8 *StartOfBuffer,\r | |
550 | IN UINTN BufferSize,\r | |
551 | IN CONST CHAR16 *FormatString,\r | |
552 | IN VA_LIST Marker\r | |
553 | )\r | |
554 | {\r | |
555 | ASSERT_UNICODE_BUFFER (FormatString);\r | |
2075236e | 556 | return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker, NULL);\r |
557 | }\r | |
558 | \r | |
559 | /**\r | |
560 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
561 | Unicode format string and a BASE_LIST argument list.\r | |
562 | \r | |
563 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
564 | and BufferSize.\r | |
565 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
566 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
567 | the contents of the format string.\r | |
568 | The number of ASCII characters in the produced output buffer is returned not including\r | |
569 | the Null-terminator.\r | |
570 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
571 | \r | |
572 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
573 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
574 | If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
575 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
576 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
577 | ASSERT().\r | |
578 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
579 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
580 | Null-terminator, then ASSERT().\r | |
581 | \r | |
582 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
583 | ASCII string.\r | |
584 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 585 | @param FormatString A Null-terminated Unicode format string.\r |
2075236e | 586 | @param Marker BASE_LIST marker for the variable argument list.\r |
587 | \r | |
588 | @return The number of ASCII characters in the produced output buffer not including the\r | |
589 | Null-terminator.\r | |
590 | \r | |
591 | **/\r | |
592 | UINTN\r | |
593 | EFIAPI\r | |
594 | AsciiBSPrintUnicodeFormat (\r | |
595 | OUT CHAR8 *StartOfBuffer,\r | |
596 | IN UINTN BufferSize,\r | |
597 | IN CONST CHAR16 *FormatString,\r | |
598 | IN BASE_LIST Marker\r | |
599 | )\r | |
600 | {\r | |
601 | ASSERT_UNICODE_BUFFER (FormatString);\r | |
ebd04fc2 | 602 | return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, gNullVaList, Marker);\r |
e1f414b6 | 603 | }\r |
604 | \r | |
605 | /**\r | |
606 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
eceb3a4c | 607 | Unicode format string and variable argument list.\r |
e1f414b6 | 608 | \r |
609 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
610 | and BufferSize.\r | |
611 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
612 | Arguments are pulled from the variable argument list based on the contents of the \r | |
613 | format string.\r | |
614 | The number of ASCII characters in the produced output buffer is returned not including\r | |
615 | the Null-terminator.\r | |
616 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
617 | \r | |
618 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r | |
619 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
620 | If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
621 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
622 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
623 | ASSERT().\r | |
624 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
625 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
626 | Null-terminator, then ASSERT().\r | |
627 | \r | |
628 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r | |
629 | ASCII string.\r | |
630 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
2fc59a00 | 631 | @param FormatString A Null-terminated Unicode format string.\r |
285010e7 | 632 | @param ... Variable argument list whose contents are accessed based on the \r |
633 | format string specified by FormatString.\r | |
e1f414b6 | 634 | \r |
635 | @return The number of ASCII characters in the produced output buffer not including the\r | |
636 | Null-terminator.\r | |
637 | \r | |
638 | **/\r | |
639 | UINTN\r | |
640 | EFIAPI\r | |
641 | AsciiSPrintUnicodeFormat (\r | |
642 | OUT CHAR8 *StartOfBuffer,\r | |
643 | IN UINTN BufferSize,\r | |
644 | IN CONST CHAR16 *FormatString,\r | |
645 | ...\r | |
646 | )\r | |
647 | {\r | |
648 | VA_LIST Marker;\r | |
3bbe68a3 | 649 | UINTN NumberOfPrinted;\r |
e1f414b6 | 650 | \r |
651 | VA_START (Marker, FormatString);\r | |
3bbe68a3 | 652 | NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r |
653 | VA_END (Marker);\r | |
654 | return NumberOfPrinted;\r | |
e1f414b6 | 655 | }\r |
656 | \r | |
657 | \r | |
658 | /**\r | |
659 | Converts a decimal value to a Null-terminated ASCII string.\r | |
660 | \r | |
661 | Converts the decimal number specified by Value to a Null-terminated ASCII string \r | |
662 | specified by Buffer containing at most Width characters. No padding of spaces \r | |
663 | is ever performed.\r | |
664 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
665 | The number of ASCII characters in Buffer is returned not including the Null-terminator.\r | |
666 | If the conversion contains more than Width characters, then only the first Width\r | |
667 | characters are returned, and the total number of characters required to perform\r | |
668 | the conversion is returned.\r | |
669 | Additional conversion parameters are specified in Flags. \r | |
670 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
671 | All conversions are left justified in Buffer.\r | |
672 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
673 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
674 | are inserted every 3rd digit starting from the right.\r | |
df8d0595 | 675 | If RADIX_HEX is set in Flags, then the output buffer will be \r |
e1f414b6 | 676 | formatted in hexadecimal format.\r |
df8d0595 | 677 | If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'.\r |
e1f414b6 | 678 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r |
679 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
680 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
681 | add up to Width characters.\r | |
682 | \r | |
683 | If Buffer is NULL, then ASSERT().\r | |
684 | If unsupported bits are set in Flags, then ASSERT().\r | |
df8d0595 | 685 | If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT().\r |
e1f414b6 | 686 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r |
687 | \r | |
2fc59a00 | 688 | @param Buffer The pointer to the output buffer for the produced Null-terminated\r |
e1f414b6 | 689 | ASCII string.\r |
690 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
691 | @param Value The 64-bit signed value to convert to a string.\r | |
692 | @param Width The maximum number of ASCII characters to place in Buffer, not including\r | |
693 | the Null-terminator.\r | |
694 | \r | |
695 | @return The number of ASCII characters in Buffer not including the Null-terminator.\r | |
696 | \r | |
697 | **/\r | |
698 | UINTN\r | |
699 | EFIAPI\r | |
700 | AsciiValueToString (\r | |
58125b7a | 701 | OUT CHAR8 *Buffer,\r |
702 | IN UINTN Flags,\r | |
703 | IN INT64 Value,\r | |
704 | IN UINTN Width\r | |
e1f414b6 | 705 | )\r |
706 | {\r | |
707 | return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1);\r | |
708 | }\r | |
f405c067 | 709 | \r |
710 | /**\r | |
711 | Returns the number of characters that would be produced by if the formatted \r | |
712 | output were produced not including the Null-terminator.\r | |
713 | \r | |
714 | If FormatString is NULL, then ASSERT().\r | |
715 | If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r | |
716 | \r | |
717 | @param[in] FormatString A Null-terminated Unicode format string.\r | |
718 | @param[in] Marker VA_LIST marker for the variable argument list.\r | |
719 | \r | |
720 | @return The number of characters that would be produced, not including the \r | |
721 | Null-terminator.\r | |
722 | **/\r | |
723 | UINTN\r | |
724 | EFIAPI\r | |
725 | SPrintLength (\r | |
726 | IN CONST CHAR16 *FormatString,\r | |
727 | IN VA_LIST Marker\r | |
728 | )\r | |
729 | {\r | |
730 | ASSERT(FormatString != NULL);\r | |
731 | ASSERT_UNICODE_BUFFER (FormatString);\r | |
732 | return BasePrintLibSPrintMarker (NULL, 0, FORMAT_UNICODE | OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);\r | |
733 | }\r | |
734 | \r | |
735 | /**\r | |
736 | Returns the number of characters that would be produced by if the formatted \r | |
737 | output were produced not including the Null-terminator.\r | |
738 | \r | |
739 | If FormatString is NULL, then ASSERT().\r | |
740 | \r | |
741 | @param[in] FormatString A Null-terminated ASCII format string.\r | |
742 | @param[in] Marker VA_LIST marker for the variable argument list.\r | |
743 | \r | |
744 | @return The number of characters that would be produced, not including the \r | |
745 | Null-terminator.\r | |
746 | **/\r | |
747 | UINTN\r | |
748 | EFIAPI\r | |
749 | SPrintLengthAsciiFormat (\r | |
750 | IN CONST CHAR8 *FormatString,\r | |
751 | IN VA_LIST Marker\r | |
752 | )\r | |
753 | {\r | |
754 | ASSERT(FormatString != NULL);\r | |
755 | return BasePrintLibSPrintMarker (NULL, 0, OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);\r | |
756 | }\r |