]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/PrintLib.h
Code Scrub
[mirror_edk2.git] / MdePkg / Include / Library / PrintLib.h
CommitLineData
488ee641 1/** @file\r
2 Library header file that defines print services\r
3\r
4 Copyright (c) 2006 - 2008, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#ifndef __PRINT_LIB_H__\r
16#define __PRINT_LIB_H__\r
17\r
18///\r
19/// Define the maximum number of characters that are required to\r
20/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL \r
21/// terminator.\r
22/// \r
23/// Maximum Length Decimal String = 28\r
24/// "-9,223,372,036,854,775,808"\r
25/// Maximum Length Hexidecimal String = 17\r
26/// "FFFFFFFFFFFFFFFF"\r
27/// Maximum Length GUID = 37\r
28/// "00000000-0000-0000-0000-000000000000"\r
29/// Maximum Length TIME = 18\r
30/// "12/12/2006 12:12"\r
31///\r
32#define MAXIMUM_VALUE_CHARACTERS 38\r
33\r
34///\r
35/// Flags bitmask values use in UnicodeValueToString() and \r
36/// AsciiValueToString()\r
37///\r
38#define LEFT_JUSTIFY 0x01\r
39#define COMMA_TYPE 0x08\r
40#define PREFIX_ZERO 0x20\r
41#define RADIX_HEX 0x80\r
42\r
43/**\r
44 Produces a Null-terminated Unicode string in an output buffer based on \r
45 a Null-terminated Unicode format string and a VA_LIST argument list\r
46 \r
47 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
48 and BufferSize. \r
49 The Unicode string is produced by parsing the format string specified by FormatString. \r
50 Arguments are pulled from the variable argument list specified by Marker based on the \r
51 contents of the format string. \r
52 The number of Unicode characters in the produced output buffer is returned not including\r
53 the Null-terminator.\r
54 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
55\r
56 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
57 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
58 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
59 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
60 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
61 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
62 ASSERT().\r
63 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
64 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
65 Null-terminator, then ASSERT().\r
66\r
67 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
68 Unicode string.\r
69 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
70 @param FormatString Null-terminated Unicode format string.\r
71 @param Marker VA_LIST marker for the variable argument list.\r
72 \r
73 @return The number of Unicode characters in the produced output buffer not including the\r
74 Null-terminator.\r
75\r
76**/\r
77UINTN\r
78EFIAPI\r
79UnicodeVSPrint (\r
80 OUT CHAR16 *StartOfBuffer,\r
81 IN UINTN BufferSize,\r
82 IN CONST CHAR16 *FormatString,\r
83 IN VA_LIST Marker\r
84 );\r
85\r
86/**\r
87 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
88 Unicode format string and variable argument list.\r
89 \r
90 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
91 and BufferSize.\r
92 The Unicode string is produced by parsing the format string specified by FormatString.\r
93 Arguments are pulled from the variable argument list based on the contents of the format string.\r
94 The number of Unicode characters in the produced output buffer is returned not including\r
95 the Null-terminator.\r
96 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
97\r
98 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
99 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
100 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
101 If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
102 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r
103 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
104 ASSERT().\r
105 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
106 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
107 Null-terminator, then ASSERT().\r
108\r
109 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
110 Unicode string.\r
111 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
112 @param FormatString Null-terminated Unicode format string.\r
113 @param ... The variable argument list.\r
114 \r
115 @return The number of Unicode characters in the produced output buffer not including the\r
116 Null-terminator.\r
117\r
118**/\r
119UINTN\r
120EFIAPI\r
121UnicodeSPrint (\r
122 OUT CHAR16 *StartOfBuffer,\r
123 IN UINTN BufferSize,\r
124 IN CONST CHAR16 *FormatString,\r
125 ...\r
126 );\r
127\r
128/**\r
129 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r
130 ASCII format string and a VA_LIST argument list\r
131 \r
132 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
133 and BufferSize.\r
134 The Unicode string is produced by parsing the format string specified by FormatString.\r
135 Arguments are pulled from the variable argument list specified by Marker based on the \r
136 contents of the format string.\r
137 The number of Unicode characters in the produced output buffer is returned not including\r
138 the Null-terminator.\r
139 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
140\r
141 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
142 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
143 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
144 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
145 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
146 ASSERT().\r
147 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
148 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
149 Null-terminator, then ASSERT().\r
150\r
151 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
152 Unicode string.\r
153 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
154 @param FormatString Null-terminated ASCII format string.\r
155 @param Marker VA_LIST marker for the variable argument list.\r
156 \r
157 @return The number of Unicode characters in the produced output buffer not including the\r
158 Null-terminator.\r
159\r
160**/\r
161UINTN\r
162EFIAPI\r
163UnicodeVSPrintAsciiFormat (\r
164 OUT CHAR16 *StartOfBuffer,\r
165 IN UINTN BufferSize,\r
166 IN CONST CHAR8 *FormatString,\r
167 IN VA_LIST Marker\r
168 );\r
169\r
170/**\r
171 Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r
172 ASCII format string and variable argument list.\r
173 \r
174 Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r
175 and BufferSize.\r
176 The Unicode string is produced by parsing the format string specified by FormatString.\r
177 Arguments are pulled from the variable argument list based on the contents of the \r
178 format string.\r
179 The number of Unicode characters in the produced output buffer is returned not including\r
180 the Null-terminator.\r
181 If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r
182\r
183 If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r
184 If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().\r
185 If BufferSize > 1 and FormatString is NULL, then ASSERT().\r
186 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
187 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
188 ASSERT().\r
189 If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r
190 contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r
191 Null-terminator, then ASSERT().\r
192\r
193 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
194 Unicode string.\r
195 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
196 @param FormatString Null-terminated ASCII format string.\r
197 @param ... The variable argument list.\r
198 \r
199 @return The number of Unicode characters in the produced output buffer not including the\r
200 Null-terminator.\r
201\r
202**/\r
203UINTN\r
204EFIAPI\r
205UnicodeSPrintAsciiFormat (\r
206 OUT CHAR16 *StartOfBuffer,\r
207 IN UINTN BufferSize,\r
208 IN CONST CHAR8 *FormatString,\r
209 ...\r
210 );\r
211\r
212/**\r
213 Converts a decimal value to a Null-terminated Unicode string.\r
214 \r
215 Converts the decimal number specified by Value to a Null-terminated Unicode \r
216 string specified by Buffer containing at most Width characters. No padding of spaces \r
217 is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
218 The number of Unicode characters in Buffer is returned not including the Null-terminator.\r
219 If the conversion contains more than Width characters, then only the first\r
220 Width characters are returned, and the total number of characters \r
221 required to perform the conversion is returned.\r
222 Additional conversion parameters are specified in Flags. \r
223 \r
224 The Flags bit LEFT_JUSTIFY is always ignored.\r
225 All conversions are left justified in Buffer.\r
226 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
227 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
228 are inserted every 3rd digit starting from the right.\r
229 If HEX_RADIX is set in Flags, then the output buffer will be \r
230 formatted in hexadecimal format.\r
231 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
232 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
233 then Buffer is padded with '0' characters so the combination of the optional '-' \r
234 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
235 add up to Width characters.\r
236 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
237 If Buffer is NULL, then ASSERT().\r
238 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
239 If unsupported bits are set in Flags, then ASSERT().\r
240 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
241 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
242\r
243 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
244 Unicode string.\r
245 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
246 @param Value The 64-bit signed value to convert to a string.\r
247 @param Width The maximum number of Unicode characters to place in Buffer, not including\r
248 the Null-terminator.\r
249 \r
250 @return The number of Unicode characters in Buffer not including the Null-terminator.\r
251\r
252**/\r
253UINTN\r
254EFIAPI\r
255UnicodeValueToString (\r
256 IN OUT CHAR16 *Buffer,\r
257 IN UINTN Flags,\r
258 IN INT64 Value,\r
259 IN UINTN Width\r
260 );\r
261\r
262/**\r
263 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
264 ASCII format string and a VA_LIST argument list.\r
265 \r
266 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
267 and BufferSize.\r
268 The ASCII string is produced by parsing the format string specified by FormatString.\r
269 Arguments are pulled from the variable argument list specified by Marker based on \r
270 the contents of the format string.\r
271 The number of ASCII characters in the produced output buffer is returned not including\r
272 the Null-terminator.\r
273 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
274\r
275 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
276 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
277 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
278 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
279 ASSERT().\r
280 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
281 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
282 Null-terminator, then ASSERT().\r
283\r
284 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
285 ASCII string.\r
286 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
287 @param FormatString Null-terminated ASCII format string.\r
288 @param Marker VA_LIST marker for the variable argument list.\r
289 \r
290 @return The number of ASCII characters in the produced output buffer not including the\r
291 Null-terminator.\r
292\r
293**/\r
294UINTN\r
295EFIAPI\r
296AsciiVSPrint (\r
297 OUT CHAR8 *StartOfBuffer,\r
298 IN UINTN BufferSize,\r
299 IN CONST CHAR8 *FormatString,\r
300 IN VA_LIST Marker\r
301 );\r
302\r
303/**\r
304 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
305 ASCII format string and variable argument list.\r
306 \r
307 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
308 and BufferSize.\r
309 The ASCII string is produced by parsing the format string specified by FormatString.\r
310 Arguments are pulled from the variable argument list based on the contents of the \r
311 format string.\r
312 The number of ASCII characters in the produced output buffer is returned not including\r
313 the Null-terminator.\r
314 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
315\r
316 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
317 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
318 If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r
319 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r
320 ASSERT().\r
321 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
322 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
323 Null-terminator, then ASSERT().\r
324\r
325 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
326 ASCII string.\r
327 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
328 @param FormatString Null-terminated ASCII format string.\r
329 @param ... The variable argument list. \r
330 \r
331 @return The number of ASCII characters in the produced output buffer not including the\r
332 Null-terminator.\r
333\r
334**/\r
335UINTN\r
336EFIAPI\r
337AsciiSPrint (\r
338 OUT CHAR8 *StartOfBuffer,\r
339 IN UINTN BufferSize,\r
340 IN CONST CHAR8 *FormatString,\r
341 ...\r
342 );\r
343\r
344/**\r
345 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
346 Unicode format string and a VA_LIST argument list.\r
347 \r
348 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
349 and BufferSize.\r
350 The ASCII string is produced by parsing the format string specified by FormatString.\r
351 Arguments are pulled from the variable argument list specified by Marker based on \r
352 the contents of the format string.\r
353 The number of ASCII characters in the produced output buffer is returned not including\r
354 the Null-terminator.\r
355 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
356\r
357 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
358 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
359 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
360 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
361 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
362 ASSERT().\r
363 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
364 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
365 Null-terminator, then ASSERT().\r
366\r
367 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
368 ASCII string.\r
369 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
370 @param FormatString Null-terminated Unicode format string.\r
371 @param Marker VA_LIST marker for the variable argument list.\r
372 \r
373 @return The number of ASCII characters in the produced output buffer not including the\r
374 Null-terminator.\r
375\r
376**/\r
377UINTN\r
378EFIAPI\r
379AsciiVSPrintUnicodeFormat (\r
380 OUT CHAR8 *StartOfBuffer,\r
381 IN UINTN BufferSize,\r
382 IN CONST CHAR16 *FormatString,\r
383 IN VA_LIST Marker\r
384 );\r
385\r
386/**\r
387 Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r
388 Unicode format string and variable argument list.\r
389 \r
390 Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r
391 and BufferSize.\r
392 The ASCII string is produced by parsing the format string specified by FormatString.\r
393 Arguments are pulled from the variable argument list based on the contents of the \r
394 format string.\r
395 The number of ASCII characters in the produced output buffer is returned not including\r
396 the Null-terminator.\r
397 If BufferSize is 0, then no output buffer is produced and 0 is returned.\r
398\r
399 If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r
400 If BufferSize > 0 and FormatString is NULL, then ASSERT().\r
401 If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
402 If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r
403 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r
404 ASSERT().\r
405 If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r
406 contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r
407 Null-terminator, then ASSERT().\r
408\r
409 @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r
410 ASCII string.\r
411 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
412 @param FormatString Null-terminated Unicode format string.\r
413 @param ... The variable argument list.\r
414 \r
415 @return The number of ASCII characters in the produced output buffer not including the\r
416 Null-terminator.\r
417\r
418**/\r
419UINTN\r
420EFIAPI\r
421AsciiSPrintUnicodeFormat (\r
422 OUT CHAR8 *StartOfBuffer,\r
423 IN UINTN BufferSize,\r
424 IN CONST CHAR16 *FormatString,\r
425 ...\r
426 );\r
427\r
428/**\r
429 Converts a decimal value to a Null-terminated ASCII string.\r
430 \r
431 Converts the decimal number specified by Value to a Null-terminated ASCII string \r
432 specified by Buffer containing at most Width characters. No padding of spaces \r
433 is ever performed.\r
434 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
435 The number of ASCII characters in Buffer is returned not including the Null-terminator.\r
436 If the conversion contains more than Width characters, then only the first Width\r
437 characters are returned, and the total number of characters required to perform\r
438 the conversion is returned.\r
439 Additional conversion parameters are specified in Flags. \r
440 The Flags bit LEFT_JUSTIFY is always ignored.\r
441 All conversions are left justified in Buffer.\r
442 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
443 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
444 are inserted every 3rd digit starting from the right.\r
445 If HEX_RADIX is set in Flags, then the output buffer will be \r
446 formatted in hexadecimal format.\r
447 If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.\r
448 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
449 then Buffer is padded with '0' characters so the combination of the optional '-' \r
450 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
451 add up to Width characters.\r
452 \r
453 If Buffer is NULL, then ASSERT().\r
454 If unsupported bits are set in Flags, then ASSERT().\r
455 If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().\r
456 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
457\r
458 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
459 ASCII string.\r
460 @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r
461 @param Value The 64-bit signed value to convert to a string.\r
462 @param Width The maximum number of ASCII characters to place in Buffer, not including\r
463 the Null-terminator.\r
464 \r
465 @return The number of ASCII characters in Buffer not including the Null-terminator.\r
466\r
467**/\r
468UINTN\r
469EFIAPI\r
470AsciiValueToString (\r
471 IN OUT CHAR8 *Buffer,\r
472 IN UINTN Flags,\r
473 IN INT64 Value,\r
474 IN UINTN Width\r
475 );\r
476\r
477#endif\r