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