1314879Simp/** @file 2314879Simp Provides services to print a formatted string to a buffer. All combinations of 3314879Simp Unicode and ASCII strings are supported. 4314879Simp 5314879SimpCopyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> 6314879SimpThis program and the accompanying materials are licensed and made available under 7314879Simpthe terms and conditions of the BSD License that accompanies this distribution. 8314879SimpThe full text of the license may be found at 9314879Simphttp://opensource.org/licenses/bsd-license.php. 10314879Simp 11314879SimpTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12314879SimpWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13314879Simp 14314879Simp The Print Library functions provide a simple means to produce formatted output 15314879Simp strings. Many of the output functions use a format string to describe how to 16314879Simp format the output of variable arguments. The format string consists of normal 17314879Simp text and argument descriptors. There are no restrictions for how the normal 18314879Simp text and argument descriptors can be mixed. The following end of line(EOL) 19314879Simp translations must be performed on the contents of the format string: 20314879Simp 21314879Simp - '\\r' is translated to '\\r' 22314879Simp - '\\r\\n' is translated to '\\r\\n' 23314879Simp - '\\n' is translated to '\\r\\n' 24314879Simp - '\\n\\r' is translated to '\\r\\n' 25314879Simp 26314879Simp This does not follow the ANSI C standard for sprint(). The format of argument 27314879Simp descriptors is described below. The ANSI C standard for sprint() has been 28314879Simp followed for some of the format types, and has not been followed for others. 29314879Simp The exceptions are noted below. 30314879Simp 31314879Simp %[flags][width][.precision]type 32314879Simp 33314879Simp [flags]: 34314879Simp - - 35314879Simp - The field is left justified. If not flag is not specified, then the 36314879Simp field is right justified. 37314879Simp - space 38314879Simp - Prefix a space character to a number. Only valid for types X, x, and d. 39314879Simp - + 40314879Simp - Prefix a plus character to a number. Only valid for types X, x, and d. 41314879Simp If both space and + are specified, then space is ignored. 42314879Simp - 0 43314879Simp - Pad with 0 characters to the left of a number. Only valid for types 44314879Simp X, x, and d. 45314879Simp - , 46314879Simp - Place a comma every 3rd digit of the number. Only valid for type d. 47314879Simp If 0 is also specified, then 0 is ignored. 48314879Simp - L, l 49314879Simp - The number being printed is size UINT64. Only valid for types X, x, and d. 50314879Simp If this flag is not specified, then the number being printed is size int. 51314879Simp - NOTE: All invalid flags are ignored. 52314879Simp 53314879Simp [width]: 54314879Simp 55314879Simp - * 56314879Simp - The width of the field is specified by a UINTN argument in the 57314879Simp argument list. 58314879Simp - number 59314879Simp - The number specified as a decimal value represents the width of 60314879Simp the field. 61314879Simp - NOTE: If [width] is not specified, then a field width of 0 is assumed. 62314879Simp 63314879Simp [.precision]: 64314879Simp 65314879Simp - * 66314879Simp - The precision of the field is specified by a UINTN argument in the 67314879Simp argument list. 68314879Simp - number 69314879Simp - The number specified as a decimal value represents the precision of 70314879Simp the field. 71314879Simp - NOTE: If [.precision] is not specified, then a precision of 0 is assumed. 72314879Simp 73314879Simp type: 74314879Simp 75314879Simp - % 76314879Simp - Print a %%. 77314879Simp - c 78314879Simp - The argument is a Unicode character. ASCII characters can be printed 79314879Simp using this type too by making sure bits 8..15 of the argument are set to 0. 80314879Simp - x 81314879Simp - The argument is an unsigned hexadecimal number. The characters used are 0..9 and 82314879Simp A..F. If the flag 'L' is not specified, then the argument is assumed 83314879Simp to be size int. This does not follow ANSI C. 84314879Simp - X 85314879Simp - The argument is an unsigned hexadecimal number and the number is padded with 86314879Simp zeros. This is equivalent to a format string of "0x". If the flag 87314879Simp 'L' is not specified, then the argument is assumed to be size int. 88314879Simp This does not follow ANSI C. 89314879Simp - d 90314879Simp - The argument is a signed decimal number. If the flag 'L' is not specified, 91314879Simp then the argument is assumed to be size int. 92314879Simp - u 93314879Simp - The argument is a unsigned decimal number. If the flag 'L' is not specified, 94314879Simp then the argument is assumed to be size int. 95314879Simp - p 96314879Simp - The argument is a pointer that is a (VOID *), and it is printed as an 97314879Simp unsigned hexadecimal number The characters used are 0..9 and A..F. 98314879Simp - a 99314879Simp - The argument is a pointer to an ASCII string. 100314879Simp This does not follow ANSI C. 101314879Simp - S, s 102314879Simp - The argument is a pointer to a Unicode string. 103314879Simp This does not follow ANSI C. 104314879Simp - g 105314879Simp - The argument is a pointer to a GUID structure. The GUID is printed 106314879Simp in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. 107314879Simp This does not follow ANSI C. 108314879Simp - t 109314879Simp - The argument is a pointer to an EFI_TIME structure. The time and 110314879Simp date are printed in the format "mm/dd/yyyy hh:mm" where mm is the 111314879Simp month zero padded, dd is the day zero padded, yyyy is the year zero 112314879Simp padded, hh is the hour zero padded, and mm is minutes zero padded. 113314879Simp This does not follow ANSI C. 114314879Simp - r 115314879Simp - The argument is a RETURN_STATUS value. This value is converted to 116314879Simp a string following the table below. This does not follow ANSI C. 117314879Simp - RETURN_SUCCESS 118314879Simp - "Success" 119314879Simp - RETURN_LOAD_ERROR 120314879Simp - "Load Error" 121314879Simp - RETURN_INVALID_PARAMETER 122314879Simp - "Invalid Parameter" 123314879Simp - RETURN_UNSUPPORTED 124314879Simp - "Unsupported" 125314879Simp - RETURN_BAD_BUFFER_SIZE 126314879Simp - "Bad Buffer Size" 127314879Simp - RETURN_BUFFER_TOO_SMALL 128314879Simp - "Buffer Too Small" 129314879Simp - RETURN_NOT_READY 130314879Simp - "Not Ready" 131314879Simp - RETURN_DEVICE_ERROR 132314879Simp - "Device Error" 133314879Simp - RETURN_WRITE_PROTECTED 134314879Simp - "Write Protected" 135314879Simp - RETURN_OUT_OF_RESOURCES 136314879Simp - "Out of Resources" 137314879Simp - RETURN_VOLUME_CORRUPTED 138314879Simp - "Volume Corrupt" 139314879Simp - RETURN_VOLUME_FULL 140314879Simp - "Volume Full" 141314879Simp - RETURN_NO_MEDIA 142314879Simp - "No Media" 143314879Simp - RETURN_MEDIA_CHANGED 144314879Simp - "Media changed" 145314879Simp - RETURN_NOT_FOUND 146314879Simp - "Not Found" 147314879Simp - RETURN_ACCESS_DENIED 148314879Simp - "Access Denied" 149314879Simp - RETURN_NO_RESPONSE 150314879Simp - "No Response" 151314879Simp - RETURN_NO_MAPPING 152314879Simp - "No mapping" 153314879Simp - RETURN_TIMEOUT 154314879Simp - "Time out" 155314879Simp - RETURN_NOT_STARTED 156314879Simp - "Not started" 157314879Simp - RETURN_ALREADY_STARTED 158314879Simp - "Already started" 159314879Simp - RETURN_ABORTED 160314879Simp - "Aborted" 161314879Simp - RETURN_ICMP_ERROR 162314879Simp - "ICMP Error" 163314879Simp - RETURN_TFTP_ERROR 164314879Simp - "TFTP Error" 165314879Simp - RETURN_PROTOCOL_ERROR 166314879Simp - "Protocol Error" 167314879Simp - RETURN_WARN_UNKNOWN_GLYPH 168314879Simp - "Warning Unknown Glyph" 169314879Simp - RETURN_WARN_DELETE_FAILURE 170314879Simp - "Warning Delete Failure" 171314879Simp - RETURN_WARN_WRITE_FAILURE 172314879Simp - "Warning Write Failure" 173314879Simp - RETURN_WARN_BUFFER_TOO_SMALL 174314879Simp - "Warning Buffer Too Small" 175314879Simp 176314879Simp**/ 177314879Simp 178314879Simp#ifndef __PRINT_LIB_H__ 179314879Simp#define __PRINT_LIB_H__ 180314879Simp 181314879Simp/// 182314879Simp/// Define the maximum number of characters that are required to 183314879Simp/// encode with a NULL terminator a decimal, hexadecimal, GUID, 184314879Simp/// or TIME value. 185314879Simp/// 186314879Simp/// Maximum Length Decimal String = 28 187314879Simp/// "-9,223,372,036,854,775,808" 188314879Simp/// Maximum Length Hexadecimal String = 17 189314879Simp/// "FFFFFFFFFFFFFFFF" 190314879Simp/// Maximum Length GUID = 37 191314879Simp/// "00000000-0000-0000-0000-000000000000" 192314879Simp/// Maximum Length TIME = 18 193314879Simp/// "12/12/2006 12:12" 194314879Simp/// 195314879Simp#define MAXIMUM_VALUE_CHARACTERS 38 196314879Simp 197314879Simp/// 198314879Simp/// Flags bitmask values use in UnicodeValueToString() and 199314879Simp/// AsciiValueToString() 200314879Simp/// 201314879Simp#define LEFT_JUSTIFY 0x01 202314879Simp#define COMMA_TYPE 0x08 203314879Simp#define PREFIX_ZERO 0x20 204314879Simp#define RADIX_HEX 0x80 205314879Simp 206314879Simp/** 207314879Simp Produces a Null-terminated Unicode string in an output buffer based on 208314879Simp a Null-terminated Unicode format string and a VA_LIST argument list. 209314879Simp 210314879Simp This function is similar as vsnprintf_s defined in C11. 211314879Simp 212314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 213314879Simp and BufferSize. 214314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 215314879Simp Arguments are pulled from the variable argument list specified by Marker based on the 216314879Simp contents of the format string. 217314879Simp The number of Unicode characters in the produced output buffer is returned not including 218314879Simp the Null-terminator. 219314879Simp 220314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 221314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 222314879Simp 223314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 224314879Simp unmodified and 0 is returned. 225314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 226314879Simp unmodified and 0 is returned. 227314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 228314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 229314879Simp buffer is unmodified and 0 is returned. 230314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 231314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 232314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 233314879Simp 234314879Simp If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 235314879Simp 236314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 237314879Simp Unicode string. 238314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 239314879Simp @param FormatString A Null-terminated Unicode format string. 240314879Simp @param Marker VA_LIST marker for the variable argument list. 241314879Simp 242314879Simp @return The number of Unicode characters in the produced output buffer not including the 243314879Simp Null-terminator. 244314879Simp 245314879Simp**/ 246314879SimpUINTN 247314879SimpEFIAPI 248314879SimpUnicodeVSPrint ( 249314879Simp OUT CHAR16 *StartOfBuffer, 250314879Simp IN UINTN BufferSize, 251314879Simp IN CONST CHAR16 *FormatString, 252314879Simp IN VA_LIST Marker 253314879Simp ); 254314879Simp 255314879Simp/** 256314879Simp Produces a Null-terminated Unicode string in an output buffer based on 257314879Simp a Null-terminated Unicode format string and a BASE_LIST argument list. 258314879Simp 259314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 260314879Simp and BufferSize. 261314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 262314879Simp Arguments are pulled from the variable argument list specified by Marker based on the 263314879Simp contents of the format string. 264314879Simp The number of Unicode characters in the produced output buffer is returned not including 265314879Simp the Null-terminator. 266314879Simp 267314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 268314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 269314879Simp 270314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 271314879Simp unmodified and 0 is returned. 272314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 273314879Simp unmodified and 0 is returned. 274314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 275314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 276314879Simp buffer is unmodified and 0 is returned. 277314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 278314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 279314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 280314879Simp 281314879Simp If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 282314879Simp 283314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 284314879Simp Unicode string. 285314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 286314879Simp @param FormatString A Null-terminated Unicode format string. 287314879Simp @param Marker BASE_LIST marker for the variable argument list. 288314879Simp 289314879Simp @return The number of Unicode characters in the produced output buffer not including the 290314879Simp Null-terminator. 291314879Simp 292314879Simp**/ 293314879SimpUINTN 294314879SimpEFIAPI 295314879SimpUnicodeBSPrint ( 296314879Simp OUT CHAR16 *StartOfBuffer, 297314879Simp IN UINTN BufferSize, 298314879Simp IN CONST CHAR16 *FormatString, 299314879Simp IN BASE_LIST Marker 300314879Simp ); 301314879Simp 302314879Simp/** 303314879Simp Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 304314879Simp Unicode format string and variable argument list. 305314879Simp 306314879Simp This function is similar as snprintf_s defined in C11. 307314879Simp 308314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 309314879Simp and BufferSize. 310314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 311314879Simp Arguments are pulled from the variable argument list based on the contents of the format string. 312314879Simp The number of Unicode characters in the produced output buffer is returned not including 313314879Simp the Null-terminator. 314314879Simp 315314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 316314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 317314879Simp 318314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 319314879Simp unmodified and 0 is returned. 320314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 321314879Simp unmodified and 0 is returned. 322314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 323314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 324314879Simp buffer is unmodified and 0 is returned. 325314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 326314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 327314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 328314879Simp 329314879Simp If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 330314879Simp 331314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 332314879Simp Unicode string. 333314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 334314879Simp @param FormatString A Null-terminated Unicode format string. 335314879Simp @param ... Variable argument list whose contents are accessed based on the 336314879Simp format string specified by FormatString. 337314879Simp 338314879Simp @return The number of Unicode characters in the produced output buffer not including the 339314879Simp Null-terminator. 340314879Simp 341314879Simp**/ 342314879SimpUINTN 343314879SimpEFIAPI 344314879SimpUnicodeSPrint ( 345314879Simp OUT CHAR16 *StartOfBuffer, 346314879Simp IN UINTN BufferSize, 347314879Simp IN CONST CHAR16 *FormatString, 348314879Simp ... 349314879Simp ); 350314879Simp 351314879Simp/** 352314879Simp Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 353314879Simp ASCII format string and a VA_LIST argument list. 354314879Simp 355314879Simp This function is similar as vsnprintf_s defined in C11. 356314879Simp 357314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 358314879Simp and BufferSize. 359314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 360314879Simp Arguments are pulled from the variable argument list specified by Marker based on the 361314879Simp contents of the format string. 362314879Simp The number of Unicode characters in the produced output buffer is returned not including 363314879Simp the Null-terminator. 364314879Simp 365314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 366314879Simp 367314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 368314879Simp unmodified and 0 is returned. 369314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 370314879Simp unmodified and 0 is returned. 371314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 372314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 373314879Simp buffer is unmodified and 0 is returned. 374314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 375314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 376314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 377314879Simp 378314879Simp If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 379314879Simp 380314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 381314879Simp Unicode string. 382314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 383314879Simp @param FormatString A Null-terminated ASCII format string. 384314879Simp @param Marker VA_LIST marker for the variable argument list. 385314879Simp 386314879Simp @return The number of Unicode characters in the produced output buffer not including the 387314879Simp Null-terminator. 388314879Simp 389314879Simp**/ 390314879SimpUINTN 391314879SimpEFIAPI 392314879SimpUnicodeVSPrintAsciiFormat ( 393314879Simp OUT CHAR16 *StartOfBuffer, 394314879Simp IN UINTN BufferSize, 395314879Simp IN CONST CHAR8 *FormatString, 396314879Simp IN VA_LIST Marker 397314879Simp ); 398314879Simp 399314879Simp/** 400314879Simp Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 401314879Simp ASCII format string and a BASE_LIST argument list. 402314879Simp 403314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 404314879Simp and BufferSize. 405314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 406314879Simp Arguments are pulled from the variable argument list specified by Marker based on the 407314879Simp contents of the format string. 408314879Simp The number of Unicode characters in the produced output buffer is returned not including 409314879Simp the Null-terminator. 410314879Simp 411314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 412314879Simp 413314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 414314879Simp unmodified and 0 is returned. 415314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 416314879Simp unmodified and 0 is returned. 417314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 418314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 419314879Simp buffer is unmodified and 0 is returned. 420314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 421314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 422314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 423314879Simp 424314879Simp If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 425314879Simp 426314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 427314879Simp Unicode string. 428314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 429314879Simp @param FormatString A Null-terminated ASCII format string. 430314879Simp @param Marker BASE_LIST marker for the variable argument list. 431314879Simp 432314879Simp @return The number of Unicode characters in the produced output buffer not including the 433314879Simp Null-terminator. 434314879Simp 435314879Simp**/ 436314879SimpUINTN 437314879SimpEFIAPI 438314879SimpUnicodeBSPrintAsciiFormat ( 439314879Simp OUT CHAR16 *StartOfBuffer, 440314879Simp IN UINTN BufferSize, 441314879Simp IN CONST CHAR8 *FormatString, 442314879Simp IN BASE_LIST Marker 443314879Simp ); 444314879Simp 445314879Simp/** 446314879Simp Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 447314879Simp ASCII format string and variable argument list. 448314879Simp 449314879Simp This function is similar as snprintf_s defined in C11. 450314879Simp 451314879Simp Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 452314879Simp and BufferSize. 453314879Simp The Unicode string is produced by parsing the format string specified by FormatString. 454314879Simp Arguments are pulled from the variable argument list based on the contents of the 455314879Simp format string. 456314879Simp The number of Unicode characters in the produced output buffer is returned not including 457314879Simp the Null-terminator. 458314879Simp 459314879Simp If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 460314879Simp 461314879Simp If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 462314879Simp unmodified and 0 is returned. 463314879Simp If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 464314879Simp unmodified and 0 is returned. 465314879Simp If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 466314879Simp (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 467314879Simp buffer is unmodified and 0 is returned. 468314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 469314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 470314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 471314879Simp 472314879Simp If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 473314879Simp 474314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 475314879Simp Unicode string. 476314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 477314879Simp @param FormatString A Null-terminated ASCII format string. 478314879Simp @param ... Variable argument list whose contents are accessed based on the 479314879Simp format string specified by FormatString. 480314879Simp 481314879Simp @return The number of Unicode characters in the produced output buffer not including the 482314879Simp Null-terminator. 483314879Simp 484314879Simp**/ 485314879SimpUINTN 486314879SimpEFIAPI 487314879SimpUnicodeSPrintAsciiFormat ( 488314879Simp OUT CHAR16 *StartOfBuffer, 489314879Simp IN UINTN BufferSize, 490314879Simp IN CONST CHAR8 *FormatString, 491314879Simp ... 492314879Simp ); 493314879Simp 494314879Simp#ifndef DISABLE_NEW_DEPRECATED_INTERFACES 495314879Simp 496314879Simp/** 497314879Simp [ATTENTION] This function is deprecated for security reason. 498314879Simp 499314879Simp Converts a decimal value to a Null-terminated Unicode string. 500314879Simp 501314879Simp Converts the decimal number specified by Value to a Null-terminated Unicode 502314879Simp string specified by Buffer containing at most Width characters. No padding of spaces 503314879Simp is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. 504314879Simp The number of Unicode characters in Buffer is returned, not including the Null-terminator. 505314879Simp If the conversion contains more than Width characters, then only the first 506314879Simp Width characters are returned, and the total number of characters 507314879Simp required to perform the conversion is returned. 508314879Simp Additional conversion parameters are specified in Flags. 509314879Simp 510314879Simp The Flags bit LEFT_JUSTIFY is always ignored. 511314879Simp All conversions are left justified in Buffer. 512314879Simp If Width is 0, PREFIX_ZERO is ignored in Flags. 513314879Simp If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas 514314879Simp are inserted every 3rd digit starting from the right. 515314879Simp If RADIX_HEX is set in Flags, then the output buffer will be 516314879Simp formatted in hexadecimal format. 517314879Simp If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'. 518314879Simp If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, 519314879Simp then Buffer is padded with '0' characters so the combination of the optional '-' 520314879Simp sign character, '0' characters, digit characters for Value, and the Null-terminator 521314879Simp add up to Width characters. 522314879Simp If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT(). 523314879Simp If Buffer is NULL, then ASSERT(). 524314879Simp If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 525314879Simp If unsupported bits are set in Flags, then ASSERT(). 526314879Simp If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT(). 527314879Simp If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() 528314879Simp 529314879Simp @param Buffer The pointer to the output buffer for the produced Null-terminated 530314879Simp Unicode string. 531314879Simp @param Flags The bitmask of flags that specify left justification, zero pad, and commas. 532314879Simp @param Value The 64-bit signed value to convert to a string. 533314879Simp @param Width The maximum number of Unicode characters to place in Buffer, not including 534314879Simp the Null-terminator. 535314879Simp 536314879Simp @return The number of Unicode characters in Buffer, not including the Null-terminator. 537314879Simp 538314879Simp**/ 539314879SimpUINTN 540314879SimpEFIAPI 541314879SimpUnicodeValueToString ( 542314879Simp IN OUT CHAR16 *Buffer, 543314879Simp IN UINTN Flags, 544314879Simp IN INT64 Value, 545314879Simp IN UINTN Width 546314879Simp ); 547314879Simp 548314879Simp#endif 549314879Simp 550314879Simp/** 551314879Simp Converts a decimal value to a Null-terminated Unicode string. 552314879Simp 553314879Simp Converts the decimal number specified by Value to a Null-terminated Unicode 554314879Simp string specified by Buffer containing at most Width characters. No padding of 555314879Simp spaces is ever performed. If Width is 0 then a width of 556314879Simp MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 557314879Simp Width characters, then only the first Width characters are placed in Buffer. 558314879Simp Additional conversion parameters are specified in Flags. 559314879Simp 560314879Simp The Flags bit LEFT_JUSTIFY is always ignored. 561314879Simp All conversions are left justified in Buffer. 562314879Simp If Width is 0, PREFIX_ZERO is ignored in Flags. 563314879Simp If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 564314879Simp commas are inserted every 3rd digit starting from the right. 565314879Simp If RADIX_HEX is set in Flags, then the output buffer will be formatted in 566314879Simp hexadecimal format. 567314879Simp If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 568314879Simp Buffer is a '-'. 569314879Simp If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 570314879Simp Buffer is padded with '0' characters so the combination of the optional '-' 571314879Simp sign character, '0' characters, digit characters for Value, and the 572314879Simp Null-terminator add up to Width characters. 573314879Simp 574314879Simp If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 575314879Simp If an error would be returned, then the function will also ASSERT(). 576314879Simp 577314879Simp @param Buffer The pointer to the output buffer for the produced 578314879Simp Null-terminated Unicode string. 579314879Simp @param BufferSize The size of Buffer in bytes, including the 580314879Simp Null-terminator. 581314879Simp @param Flags The bitmask of flags that specify left justification, 582314879Simp zero pad, and commas. 583314879Simp @param Value The 64-bit signed value to convert to a string. 584314879Simp @param Width The maximum number of Unicode characters to place in 585314879Simp Buffer, not including the Null-terminator. 586314879Simp 587314879Simp @retval RETURN_SUCCESS The decimal value is converted. 588314879Simp @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 589314879Simp value. 590314879Simp @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 591314879Simp If PcdMaximumUnicodeStringLength is not 592314879Simp zero, and BufferSize is greater than 593314879Simp (PcdMaximumUnicodeStringLength * 594314879Simp sizeof (CHAR16) + 1). 595314879Simp If unsupported bits are set in Flags. 596314879Simp If both COMMA_TYPE and RADIX_HEX are set in 597314879Simp Flags. 598314879Simp If Width >= MAXIMUM_VALUE_CHARACTERS. 599314879Simp 600314879Simp**/ 601314879SimpRETURN_STATUS 602314879SimpEFIAPI 603314879SimpUnicodeValueToStringS ( 604314879Simp IN OUT CHAR16 *Buffer, 605314879Simp IN UINTN BufferSize, 606314879Simp IN UINTN Flags, 607314879Simp IN INT64 Value, 608314879Simp IN UINTN Width 609314879Simp ); 610314879Simp 611314879Simp/** 612314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 613314879Simp ASCII format string and a VA_LIST argument list. 614314879Simp 615314879Simp This function is similar as vsnprintf_s defined in C11. 616314879Simp 617314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 618314879Simp and BufferSize. 619314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 620314879Simp Arguments are pulled from the variable argument list specified by Marker based on 621314879Simp the contents of the format string. 622314879Simp The number of ASCII characters in the produced output buffer is returned not including 623314879Simp the Null-terminator. 624314879Simp 625314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 626314879Simp unmodified and 0 is returned. 627314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 628314879Simp unmodified and 0 is returned. 629314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 630314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 631314879Simp is unmodified and 0 is returned. 632314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 633314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 634314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 635314879Simp 636314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 637314879Simp 638314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 639314879Simp ASCII string. 640314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 641314879Simp @param FormatString A Null-terminated ASCII format string. 642314879Simp @param Marker VA_LIST marker for the variable argument list. 643314879Simp 644314879Simp @return The number of ASCII characters in the produced output buffer not including the 645314879Simp Null-terminator. 646314879Simp 647314879Simp**/ 648314879SimpUINTN 649314879SimpEFIAPI 650314879SimpAsciiVSPrint ( 651314879Simp OUT CHAR8 *StartOfBuffer, 652314879Simp IN UINTN BufferSize, 653314879Simp IN CONST CHAR8 *FormatString, 654314879Simp IN VA_LIST Marker 655314879Simp ); 656314879Simp 657314879Simp/** 658314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 659314879Simp ASCII format string and a BASE_LIST argument list. 660314879Simp 661314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 662314879Simp and BufferSize. 663314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 664314879Simp Arguments are pulled from the variable argument list specified by Marker based on 665314879Simp the contents of the format string. 666314879Simp The number of ASCII characters in the produced output buffer is returned not including 667314879Simp the Null-terminator. 668314879Simp 669314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 670314879Simp unmodified and 0 is returned. 671314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 672314879Simp unmodified and 0 is returned. 673314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 674314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 675314879Simp is unmodified and 0 is returned. 676314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 677314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 678314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 679314879Simp 680314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 681314879Simp 682314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 683314879Simp ASCII string. 684314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 685314879Simp @param FormatString A Null-terminated ASCII format string. 686314879Simp @param Marker BASE_LIST marker for the variable argument list. 687314879Simp 688314879Simp @return The number of ASCII characters in the produced output buffer not including the 689314879Simp Null-terminator. 690314879Simp 691314879Simp**/ 692314879SimpUINTN 693314879SimpEFIAPI 694314879SimpAsciiBSPrint ( 695314879Simp OUT CHAR8 *StartOfBuffer, 696314879Simp IN UINTN BufferSize, 697314879Simp IN CONST CHAR8 *FormatString, 698314879Simp IN BASE_LIST Marker 699314879Simp ); 700314879Simp 701314879Simp/** 702314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 703314879Simp ASCII format string and variable argument list. 704314879Simp 705314879Simp This function is similar as snprintf_s defined in C11. 706314879Simp 707314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 708314879Simp and BufferSize. 709314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 710314879Simp Arguments are pulled from the variable argument list based on the contents of the 711314879Simp format string. 712314879Simp The number of ASCII characters in the produced output buffer is returned not including 713314879Simp the Null-terminator. 714314879Simp 715314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 716314879Simp unmodified and 0 is returned. 717314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 718314879Simp unmodified and 0 is returned. 719314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 720314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 721314879Simp is unmodified and 0 is returned. 722314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 723314879Simp PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 724314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 725314879Simp 726314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 727314879Simp 728314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 729314879Simp ASCII string. 730314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 731314879Simp @param FormatString A Null-terminated ASCII format string. 732314879Simp @param ... Variable argument list whose contents are accessed based on the 733314879Simp format string specified by FormatString. 734314879Simp 735314879Simp @return The number of ASCII characters in the produced output buffer not including the 736314879Simp Null-terminator. 737314879Simp 738314879Simp**/ 739314879SimpUINTN 740314879SimpEFIAPI 741314879SimpAsciiSPrint ( 742314879Simp OUT CHAR8 *StartOfBuffer, 743314879Simp IN UINTN BufferSize, 744314879Simp IN CONST CHAR8 *FormatString, 745314879Simp ... 746314879Simp ); 747314879Simp 748314879Simp/** 749314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 750314879Simp Unicode format string and a VA_LIST argument list. 751314879Simp 752314879Simp This function is similar as vsnprintf_s defined in C11. 753314879Simp 754314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 755314879Simp and BufferSize. 756314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 757314879Simp Arguments are pulled from the variable argument list specified by Marker based on 758314879Simp the contents of the format string. 759314879Simp The number of ASCII characters in the produced output buffer is returned not including 760314879Simp the Null-terminator. 761314879Simp 762314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 763314879Simp 764314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 765314879Simp unmodified and 0 is returned. 766314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 767314879Simp unmodified and 0 is returned. 768314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 769314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 770314879Simp is unmodified and 0 is returned. 771314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 772314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 773314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 774314879Simp 775314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 776314879Simp 777314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 778314879Simp ASCII string. 779314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 780314879Simp @param FormatString A Null-terminated Unicode format string. 781314879Simp @param Marker VA_LIST marker for the variable argument list. 782314879Simp 783314879Simp @return The number of ASCII characters in the produced output buffer not including the 784314879Simp Null-terminator. 785314879Simp 786314879Simp**/ 787314879SimpUINTN 788314879SimpEFIAPI 789314879SimpAsciiVSPrintUnicodeFormat ( 790314879Simp OUT CHAR8 *StartOfBuffer, 791314879Simp IN UINTN BufferSize, 792314879Simp IN CONST CHAR16 *FormatString, 793314879Simp IN VA_LIST Marker 794314879Simp ); 795314879Simp 796314879Simp/** 797314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 798314879Simp Unicode format string and a BASE_LIST argument list. 799314879Simp 800314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 801314879Simp and BufferSize. 802314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 803314879Simp Arguments are pulled from the variable argument list specified by Marker based on 804314879Simp the contents of the format string. 805314879Simp The number of ASCII characters in the produced output buffer is returned not including 806314879Simp the Null-terminator. 807314879Simp 808314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 809314879Simp 810314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 811314879Simp unmodified and 0 is returned. 812314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 813314879Simp unmodified and 0 is returned. 814314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 815314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 816314879Simp is unmodified and 0 is returned. 817314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 818314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 819314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 820314879Simp 821314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 822314879Simp 823314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 824314879Simp ASCII string. 825314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 826314879Simp @param FormatString A Null-terminated Unicode format string. 827314879Simp @param Marker BASE_LIST marker for the variable argument list. 828314879Simp 829314879Simp @return The number of ASCII characters in the produced output buffer not including the 830314879Simp Null-terminator. 831314879Simp 832314879Simp**/ 833314879SimpUINTN 834314879SimpEFIAPI 835314879SimpAsciiBSPrintUnicodeFormat ( 836314879Simp OUT CHAR8 *StartOfBuffer, 837314879Simp IN UINTN BufferSize, 838314879Simp IN CONST CHAR16 *FormatString, 839314879Simp IN BASE_LIST Marker 840314879Simp ); 841314879Simp 842314879Simp/** 843314879Simp Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 844314879Simp Unicode format string and variable argument list. 845314879Simp 846314879Simp This function is similar as snprintf_s defined in C11. 847314879Simp 848314879Simp Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 849314879Simp and BufferSize. 850314879Simp The ASCII string is produced by parsing the format string specified by FormatString. 851314879Simp Arguments are pulled from the variable argument list based on the contents of the 852314879Simp format string. 853314879Simp The number of ASCII characters in the produced output buffer is returned not including 854314879Simp the Null-terminator. 855314879Simp 856314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 857314879Simp 858314879Simp If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 859314879Simp unmodified and 0 is returned. 860314879Simp If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 861314879Simp unmodified and 0 is returned. 862314879Simp If PcdMaximumAsciiStringLength is not zero, and BufferSize > 863314879Simp (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 864314879Simp is unmodified and 0 is returned. 865314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 866314879Simp PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 867314879Simp ASSERT(). Also, the output buffer is unmodified and 0 is returned. 868314879Simp 869314879Simp If BufferSize is 0, then no output buffer is produced and 0 is returned. 870314879Simp 871314879Simp @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 872314879Simp ASCII string. 873314879Simp @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 874314879Simp @param FormatString A Null-terminated Unicode format string. 875314879Simp @param ... Variable argument list whose contents are accessed based on the 876314879Simp format string specified by FormatString. 877314879Simp 878314879Simp @return The number of ASCII characters in the produced output buffer not including the 879314879Simp Null-terminator. 880314879Simp 881314879Simp**/ 882314879SimpUINTN 883314879SimpEFIAPI 884314879SimpAsciiSPrintUnicodeFormat ( 885314879Simp OUT CHAR8 *StartOfBuffer, 886314879Simp IN UINTN BufferSize, 887314879Simp IN CONST CHAR16 *FormatString, 888314879Simp ... 889314879Simp ); 890314879Simp 891314879Simp#ifndef DISABLE_NEW_DEPRECATED_INTERFACES 892314879Simp 893314879Simp/** 894314879Simp [ATTENTION] This function is deprecated for security reason. 895314879Simp 896314879Simp Converts a decimal value to a Null-terminated ASCII string. 897314879Simp 898314879Simp Converts the decimal number specified by Value to a Null-terminated ASCII string 899314879Simp specified by Buffer containing at most Width characters. No padding of spaces 900314879Simp is ever performed. 901314879Simp If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. 902314879Simp The number of ASCII characters in Buffer is returned, not including the Null-terminator. 903314879Simp If the conversion contains more than Width characters, then only the first Width 904314879Simp characters are returned, and the total number of characters required to perform 905314879Simp the conversion is returned. 906314879Simp Additional conversion parameters are specified in Flags. 907314879Simp The Flags bit LEFT_JUSTIFY is always ignored. 908314879Simp All conversions are left justified in Buffer. 909314879Simp If Width is 0, PREFIX_ZERO is ignored in Flags. 910314879Simp If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas 911314879Simp are inserted every 3rd digit starting from the right. 912314879Simp If RADIX_HEX is set in Flags, then the output buffer will be 913314879Simp formatted in hexadecimal format. 914314879Simp If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in Buffer is a '-'. 915314879Simp If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, 916314879Simp then Buffer is padded with '0' characters so the combination of the optional '-' 917314879Simp sign character, '0' characters, digit characters for Value, and the Null-terminator 918314879Simp add up to Width characters. 919314879Simp 920314879Simp If Buffer is NULL, then ASSERT(). 921314879Simp If unsupported bits are set in Flags, then ASSERT(). 922314879Simp If both COMMA_TYPE and RADIX_HEX are set in Flags, then ASSERT(). 923314879Simp If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() 924314879Simp 925314879Simp @param Buffer A pointer to the output buffer for the produced Null-terminated 926314879Simp ASCII string. 927314879Simp @param Flags The bitmask of flags that specify left justification, zero pad, and commas. 928314879Simp @param Value The 64-bit signed value to convert to a string. 929314879Simp @param Width The maximum number of ASCII characters to place in Buffer, not including 930314879Simp the Null-terminator. 931314879Simp 932314879Simp @return The number of ASCII characters in Buffer, not including the Null-terminator. 933314879Simp 934314879Simp**/ 935314879SimpUINTN 936314879SimpEFIAPI 937314879SimpAsciiValueToString ( 938314879Simp OUT CHAR8 *Buffer, 939314879Simp IN UINTN Flags, 940314879Simp IN INT64 Value, 941314879Simp IN UINTN Width 942314879Simp ); 943314879Simp 944314879Simp#endif 945314879Simp 946314879Simp/** 947314879Simp Converts a decimal value to a Null-terminated Ascii string. 948314879Simp 949314879Simp Converts the decimal number specified by Value to a Null-terminated Ascii 950314879Simp string specified by Buffer containing at most Width characters. No padding of 951314879Simp spaces is ever performed. If Width is 0 then a width of 952314879Simp MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 953314879Simp Width characters, then only the first Width characters are placed in Buffer. 954314879Simp Additional conversion parameters are specified in Flags. 955314879Simp 956314879Simp The Flags bit LEFT_JUSTIFY is always ignored. 957314879Simp All conversions are left justified in Buffer. 958314879Simp If Width is 0, PREFIX_ZERO is ignored in Flags. 959314879Simp If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 960314879Simp commas are inserted every 3rd digit starting from the right. 961314879Simp If RADIX_HEX is set in Flags, then the output buffer will be formatted in 962314879Simp hexadecimal format. 963314879Simp If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 964314879Simp Buffer is a '-'. 965314879Simp If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 966314879Simp Buffer is padded with '0' characters so the combination of the optional '-' 967314879Simp sign character, '0' characters, digit characters for Value, and the 968314879Simp Null-terminator add up to Width characters. 969314879Simp 970314879Simp If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 971314879Simp If an error would be returned, then the function will also ASSERT(). 972314879Simp 973314879Simp @param Buffer The pointer to the output buffer for the produced 974314879Simp Null-terminated Ascii string. 975314879Simp @param BufferSize The size of Buffer in bytes, including the 976314879Simp Null-terminator. 977314879Simp @param Flags The bitmask of flags that specify left justification, 978314879Simp zero pad, and commas. 979314879Simp @param Value The 64-bit signed value to convert to a string. 980314879Simp @param Width The maximum number of Ascii characters to place in 981314879Simp Buffer, not including the Null-terminator. 982314879Simp 983314879Simp @retval RETURN_SUCCESS The decimal value is converted. 984314879Simp @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 985314879Simp value. 986314879Simp @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 987314879Simp If PcdMaximumAsciiStringLength is not 988314879Simp zero, and BufferSize is greater than 989314879Simp PcdMaximumAsciiStringLength. 990314879Simp If unsupported bits are set in Flags. 991314879Simp If both COMMA_TYPE and RADIX_HEX are set in 992314879Simp Flags. 993314879Simp If Width >= MAXIMUM_VALUE_CHARACTERS. 994314879Simp 995314879Simp**/ 996314879SimpRETURN_STATUS 997314879SimpEFIAPI 998314879SimpAsciiValueToStringS ( 999314879Simp IN OUT CHAR8 *Buffer, 1000314879Simp IN UINTN BufferSize, 1001314879Simp IN UINTN Flags, 1002314879Simp IN INT64 Value, 1003314879Simp IN UINTN Width 1004314879Simp ); 1005314879Simp 1006314879Simp/** 1007314879Simp Returns the number of characters that would be produced by if the formatted 1008314879Simp output were produced not including the Null-terminator. 1009314879Simp 1010314879Simp If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 1011314879Simp 1012314879Simp If FormatString is NULL, then ASSERT() and 0 is returned. 1013314879Simp If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more 1014314879Simp than PcdMaximumUnicodeStringLength Unicode characters not including the 1015314879Simp Null-terminator, then ASSERT() and 0 is returned. 1016314879Simp 1017314879Simp @param[in] FormatString A Null-terminated Unicode format string. 1018314879Simp @param[in] Marker VA_LIST marker for the variable argument list. 1019314879Simp 1020314879Simp @return The number of characters that would be produced, not including the 1021314879Simp Null-terminator. 1022314879Simp**/ 1023314879SimpUINTN 1024314879SimpEFIAPI 1025314879SimpSPrintLength ( 1026314879Simp IN CONST CHAR16 *FormatString, 1027314879Simp IN VA_LIST Marker 1028314879Simp ); 1029314879Simp 1030314879Simp/** 1031314879Simp Returns the number of characters that would be produced by if the formatted 1032314879Simp output were produced not including the Null-terminator. 1033314879Simp 1034314879Simp If FormatString is NULL, then ASSERT() and 0 is returned. 1035314879Simp If PcdMaximumAsciiStringLength is not zero, and FormatString contains more 1036314879Simp than PcdMaximumAsciiStringLength Ascii characters not including the 1037314879Simp Null-terminator, then ASSERT() and 0 is returned. 1038314879Simp 1039314879Simp @param[in] FormatString A Null-terminated ASCII format string. 1040314879Simp @param[in] Marker VA_LIST marker for the variable argument list. 1041314879Simp 1042314879Simp @return The number of characters that would be produced, not including the 1043314879Simp Null-terminator. 1044314879Simp**/ 1045314879SimpUINTN 1046314879SimpEFIAPI 1047314879SimpSPrintLengthAsciiFormat ( 1048314879Simp IN CONST CHAR8 *FormatString, 1049314879Simp IN VA_LIST Marker 1050314879Simp ); 1051314879Simp 1052314879Simp#endif 1053