]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Library that provides print services\r | |
3 | \r | |
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 | |
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 | Module Name: PrintLib.h\r | |
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 | |
53 | The length of the produced output buffer is returned.\r | |
54 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
55 | \r | |
56 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
57 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
58 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
59 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
60 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
61 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
62 | \r | |
63 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
64 | Unicode string.\r | |
65 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
66 | @param FormatString Null-terminated Unicode format string.\r | |
67 | @param Marker VA_LIST marker for the variable argument list.\r | |
68 | \r | |
69 | @return return Length of the produced output buffer.\r | |
70 | \r | |
71 | **/\r | |
878ddf1f | 72 | UINTN\r |
73 | EFIAPI\r | |
74 | UnicodeVSPrint (\r | |
75 | OUT CHAR16 *StartOfBuffer,\r | |
76 | IN UINTN BufferSize,\r | |
77 | IN CONST CHAR16 *FormatString,\r | |
78 | IN VA_LIST Marker\r | |
79 | );\r | |
80 | \r | |
3f9f540d | 81 | /**\r |
82 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
83 | Unicode format string and variable argument list.\r | |
84 | \r | |
85 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
86 | and BufferSize.\r | |
87 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
88 | Arguments are pulled from the variable argument list based on the contents of the format string.\r | |
89 | The length of the produced output buffer is returned. \r | |
90 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
91 | \r | |
92 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
93 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
94 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
95 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
96 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
97 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
98 | \r | |
99 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
100 | Unicode string.\r | |
101 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
102 | @param FormatString Null-terminated Unicode format string.\r | |
103 | \r | |
104 | @return Length of the produced output buffer.\r | |
105 | \r | |
106 | **/\r | |
878ddf1f | 107 | UINTN\r |
108 | EFIAPI\r | |
109 | UnicodeSPrint (\r | |
110 | OUT CHAR16 *StartOfBuffer,\r | |
111 | IN UINTN BufferSize,\r | |
112 | IN CONST CHAR16 *FormatString,\r | |
113 | ...\r | |
114 | );\r | |
115 | \r | |
3f9f540d | 116 | /**\r |
117 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
118 | ASCII format string and a VA_LIST argument list\r | |
119 | \r | |
120 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
121 | and BufferSize.\r | |
122 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
123 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
124 | contents of the format string.\r | |
125 | The length of the produced output buffer is returned.\r | |
126 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
127 | \r | |
128 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
129 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
130 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
131 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
132 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
133 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
134 | \r | |
135 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
136 | Unicode string.\r | |
137 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
138 | @param FormatString Null-terminated Unicode format string.\r | |
139 | @param Marker VA_LIST marker for the variable argument list.\r | |
140 | \r | |
141 | @return Length of the produced output buffer.\r | |
142 | \r | |
143 | **/\r | |
878ddf1f | 144 | UINTN\r |
145 | EFIAPI\r | |
146 | UnicodeVSPrintAsciiFormat (\r | |
147 | OUT CHAR16 *StartOfBuffer,\r | |
148 | IN UINTN BufferSize,\r | |
149 | IN CONST CHAR8 *FormatString,\r | |
150 | IN VA_LIST Marker\r | |
151 | );\r | |
152 | \r | |
3f9f540d | 153 | /**\r |
154 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
155 | ASCII format string and variable argument list.\r | |
156 | \r | |
157 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
158 | and BufferSize.\r | |
159 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
160 | Arguments are pulled from the variable argument list based on the contents of the \r | |
161 | format string.\r | |
162 | The length of the produced output buffer is returned.\r | |
163 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
164 | \r | |
165 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
166 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
167 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
168 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
169 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
170 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
878ddf1f | 171 | \r |
3f9f540d | 172 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r |
173 | Unicode string.\r | |
174 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
175 | @param FormatString Null-terminated Unicode format string.\r | |
176 | \r | |
177 | @return Length of the produced output buffer.\r | |
178 | \r | |
179 | **/\r | |
878ddf1f | 180 | UINTN\r |
181 | EFIAPI\r | |
182 | UnicodeSPrintAsciiFormat (\r | |
183 | OUT CHAR16 *StartOfBuffer,\r | |
184 | IN UINTN BufferSize,\r | |
185 | IN CONST CHAR8 *FormatString,\r | |
186 | ...\r | |
187 | );\r | |
188 | \r | |
3f9f540d | 189 | /**\r |
190 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
191 | ASCII format string and a VA_LIST argument list.\r | |
192 | \r | |
193 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
194 | and BufferSize.\r | |
195 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
196 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
197 | the contents of the format string.\r | |
198 | The length of the produced output buffer is returned.\r | |
199 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
200 | \r | |
201 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
202 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
203 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
204 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
205 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
206 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
207 | \r | |
208 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
209 | ASCII string.\r | |
210 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
211 | @param FormatString Null-terminated Unicode format string.\r | |
212 | @param Marker VA_LIST marker for the variable argument list.\r | |
213 | \r | |
214 | @return Length of the produced output buffer.\r | |
215 | \r | |
216 | **/\r | |
878ddf1f | 217 | UINTN\r |
218 | EFIAPI\r | |
219 | AsciiVSPrint (\r | |
220 | OUT CHAR8 *StartOfBuffer,\r | |
221 | IN UINTN BufferSize,\r | |
222 | IN CONST CHAR8 *FormatString,\r | |
223 | IN VA_LIST Marker\r | |
224 | );\r | |
225 | \r | |
3f9f540d | 226 | /**\r |
227 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
228 | ASCII format string and variable argument list.\r | |
229 | \r | |
230 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
231 | and BufferSize.\r | |
232 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
233 | Arguments are pulled from the variable argument list based on the contents of the \r | |
234 | format string.\r | |
235 | The length of the produced output buffer is returned.\r | |
236 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
237 | \r | |
238 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
239 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
240 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
241 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
242 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
243 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
244 | \r | |
245 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
246 | ASCII string.\r | |
247 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
248 | @param FormatString Null-terminated Unicode format string.\r | |
249 | \r | |
250 | @return Length of the produced output buffer.\r | |
251 | \r | |
252 | **/\r | |
878ddf1f | 253 | UINTN\r |
254 | EFIAPI\r | |
255 | AsciiSPrint (\r | |
256 | OUT CHAR8 *StartOfBuffer,\r | |
257 | IN UINTN BufferSize,\r | |
258 | IN CONST CHAR8 *FormatString,\r | |
259 | ...\r | |
260 | );\r | |
261 | \r | |
3f9f540d | 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 length of the produced output buffer is returned.\r | |
272 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
273 | \r | |
274 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
275 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
276 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
277 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
278 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
279 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
280 | \r | |
281 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
282 | ASCII string.\r | |
283 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
284 | @param FormatString Null-terminated Unicode format string.\r | |
285 | @param Marker VA_LIST marker for the variable argument list.\r | |
286 | \r | |
287 | @return Length of the produced output buffer.\r | |
288 | \r | |
289 | **/\r | |
878ddf1f | 290 | UINTN\r |
291 | EFIAPI\r | |
292 | AsciiVSPrintUnicodeFormat (\r | |
293 | OUT CHAR8 *StartOfBuffer,\r | |
294 | IN UINTN BufferSize,\r | |
295 | IN CONST CHAR16 *FormatString,\r | |
296 | IN VA_LIST Marker\r | |
297 | );\r | |
298 | \r | |
3f9f540d | 299 | /**\r |
300 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
301 | ASCII format string and variable argument list.\r | |
302 | \r | |
303 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
304 | and BufferSize.\r | |
305 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
306 | Arguments are pulled from the variable argument list based on the contents of the \r | |
307 | format string.\r | |
308 | The length of the produced output buffer is returned.\r | |
309 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
310 | \r | |
311 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
312 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
313 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
314 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
315 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
316 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
317 | \r | |
318 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
319 | ASCII string.\r | |
320 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
321 | @param FormatString Null-terminated Unicode format string.\r | |
322 | \r | |
323 | @return Length of the produced output buffer.\r | |
324 | \r | |
325 | **/\r | |
878ddf1f | 326 | UINTN\r |
327 | EFIAPI\r | |
328 | AsciiSPrintUnicodeFormat (\r | |
329 | OUT CHAR8 *StartOfBuffer,\r | |
330 | IN UINTN BufferSize,\r | |
331 | IN CONST CHAR16 *FormatString,\r | |
332 | ...\r | |
333 | );\r | |
334 | \r | |
3f9f540d | 335 | /**\r |
336 | Converts a decimal value to a Null-terminated Unicode string.\r | |
337 | \r | |
338 | Converts the decimal number specified by Value to a Null-terminated Unicode \r | |
339 | string specified by Buffer containing at most Width characters.\r | |
340 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
341 | The total number of characters placed in Buffer is returned.\r | |
342 | If the conversion contains more than Width characters, then only the first\r | |
343 | Width characters are returned, and the total number of characters \r | |
344 | required to perform the conversion is returned.\r | |
345 | Additional conversion parameters are specified in Flags. \r | |
346 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
347 | All conversions are left justified in Buffer.\r | |
348 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
349 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
350 | are inserted every 3rd digit starting from the right.\r | |
351 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
352 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
353 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
354 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
355 | add up to Width characters.\r | |
356 | \r | |
357 | If Buffer is NULL, then ASSERT().\r | |
358 | If unsupported bits are set in Flags, then ASSERT().\r | |
359 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
360 | \r | |
361 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
362 | Unicode string.\r | |
363 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
364 | @param Value The 64-bit signed value to convert to a string.\r | |
365 | @param Width The maximum number of Unicode characters to place in Buffer.\r | |
366 | \r | |
367 | @return Total number of characters required to perform the conversion.\r | |
368 | \r | |
369 | **/\r | |
878ddf1f | 370 | UINTN\r |
a3657e3e | 371 | EFIAPI\r |
878ddf1f | 372 | UnicodeValueToString (\r |
373 | IN OUT CHAR16 *Buffer,\r | |
374 | IN UINTN Flags,\r | |
375 | IN INT64 Value,\r | |
376 | IN UINTN Width\r | |
377 | );\r | |
378 | \r | |
3f9f540d | 379 | /**\r |
380 | Converts a decimal value to a Null-terminated ASCII string.\r | |
381 | \r | |
382 | Converts the decimal number specified by Value to a Null-terminated ASCII string \r | |
383 | specified by Buffer containing at most Width characters.\r | |
384 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
385 | The total number of characters placed in Buffer is returned.\r | |
386 | If the conversion contains more than Width characters, then only the first Width\r | |
387 | characters are returned, and the total number of characters required to perform\r | |
388 | the conversion is returned.\r | |
389 | Additional conversion parameters are specified in Flags. \r | |
390 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
391 | All conversions are left justified in Buffer.\r | |
392 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
393 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r | |
394 | are inserted every 3rd digit starting from the right.\r | |
395 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
396 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r | |
397 | is padded with '0' characters so the combination of the optional '-'\r | |
398 | sign character, '0' characters, digit characters for Value, and the \r | |
399 | Null-terminator add up to Width characters.\r | |
400 | \r | |
401 | If Buffer is NULL, then ASSERT().\r | |
402 | If unsupported bits are set in Flags, then ASSERT().\r | |
403 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
404 | \r | |
405 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
406 | ASCII string.\r | |
407 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
408 | @param Value The 64-bit signed value to convert to a string.\r | |
409 | @param Width The maximum number of ASCII characters to place in Buffer.\r | |
410 | \r | |
411 | @return Total number of characters required to perform the conversion.\r | |
412 | \r | |
413 | **/\r | |
878ddf1f | 414 | UINTN\r |
a3657e3e | 415 | EFIAPI\r |
878ddf1f | 416 | AsciiValueToString (\r |
417 | IN OUT CHAR8 *Buffer,\r | |
418 | IN UINTN Flags,\r | |
419 | IN INT64 Value,\r | |
420 | IN UINTN Width\r | |
421 | );\r | |
422 | \r | |
423 | #endif\r |