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