1*1370a723SSascha Wildner /** @file 2*1370a723SSascha Wildner Provides services to print a formatted string to a buffer. All combinations of 3*1370a723SSascha Wildner Unicode and ASCII strings are supported. 4*1370a723SSascha Wildner 5*1370a723SSascha Wildner Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 6*1370a723SSascha Wildner SPDX-License-Identifier: BSD-2-Clause-Patent 7*1370a723SSascha Wildner 8*1370a723SSascha Wildner The Print Library functions provide a simple means to produce formatted output 9*1370a723SSascha Wildner strings. Many of the output functions use a format string to describe how to 10*1370a723SSascha Wildner format the output of variable arguments. The format string consists of normal 11*1370a723SSascha Wildner text and argument descriptors. There are no restrictions for how the normal 12*1370a723SSascha Wildner text and argument descriptors can be mixed. The following end of line(EOL) 13*1370a723SSascha Wildner translations must be performed on the contents of the format string: 14*1370a723SSascha Wildner 15*1370a723SSascha Wildner - '\\r' is translated to '\\r' 16*1370a723SSascha Wildner - '\\r\\n' is translated to '\\r\\n' 17*1370a723SSascha Wildner - '\\n' is translated to '\\r\\n' 18*1370a723SSascha Wildner - '\\n\\r' is translated to '\\r\\n' 19*1370a723SSascha Wildner 20*1370a723SSascha Wildner This does not follow the ANSI C standard for sprint(). The format of argument 21*1370a723SSascha Wildner descriptors is described below. The ANSI C standard for sprint() has been 22*1370a723SSascha Wildner followed for some of the format types, and has not been followed for others. 23*1370a723SSascha Wildner The exceptions are noted below. 24*1370a723SSascha Wildner 25*1370a723SSascha Wildner %[flags][width][.precision]type 26*1370a723SSascha Wildner 27*1370a723SSascha Wildner [flags]: 28*1370a723SSascha Wildner - - 29*1370a723SSascha Wildner - The field is left justified. If not flag is not specified, then the 30*1370a723SSascha Wildner field is right justified. 31*1370a723SSascha Wildner - space 32*1370a723SSascha Wildner - Prefix a space character to a number. Only valid for types X, x, and d. 33*1370a723SSascha Wildner - + 34*1370a723SSascha Wildner - Prefix a plus character to a number. Only valid for types X, x, and d. 35*1370a723SSascha Wildner If both space and + are specified, then space is ignored. 36*1370a723SSascha Wildner - 0 37*1370a723SSascha Wildner - Pad with 0 characters to the left of a number. Only valid for types 38*1370a723SSascha Wildner X, x, and d. 39*1370a723SSascha Wildner - , 40*1370a723SSascha Wildner - Place a comma every 3rd digit of the number. Only valid for type d. 41*1370a723SSascha Wildner If 0 is also specified, then 0 is ignored. 42*1370a723SSascha Wildner - L, l 43*1370a723SSascha Wildner - The number being printed is size UINT64. Only valid for types X, x, and d. 44*1370a723SSascha Wildner If this flag is not specified, then the number being printed is size int. 45*1370a723SSascha Wildner - NOTE: All invalid flags are ignored. 46*1370a723SSascha Wildner 47*1370a723SSascha Wildner [width]: 48*1370a723SSascha Wildner 49*1370a723SSascha Wildner - * 50*1370a723SSascha Wildner - The width of the field is specified by a UINTN argument in the 51*1370a723SSascha Wildner argument list. 52*1370a723SSascha Wildner - number 53*1370a723SSascha Wildner - The number specified as a decimal value represents the width of 54*1370a723SSascha Wildner the field. 55*1370a723SSascha Wildner - NOTE: If [width] is not specified, then a field width of 0 is assumed. 56*1370a723SSascha Wildner 57*1370a723SSascha Wildner [.precision]: 58*1370a723SSascha Wildner 59*1370a723SSascha Wildner - * 60*1370a723SSascha Wildner - The precision of the field is specified by a UINTN argument in the 61*1370a723SSascha Wildner argument list. 62*1370a723SSascha Wildner - number 63*1370a723SSascha Wildner - The number specified as a decimal value represents the precision of 64*1370a723SSascha Wildner the field. 65*1370a723SSascha Wildner - NOTE: If [.precision] is not specified, then a precision of 0 is assumed. 66*1370a723SSascha Wildner 67*1370a723SSascha Wildner type: 68*1370a723SSascha Wildner 69*1370a723SSascha Wildner - % 70*1370a723SSascha Wildner - Print a %%. 71*1370a723SSascha Wildner - c 72*1370a723SSascha Wildner - The argument is a Unicode character. ASCII characters can be printed 73*1370a723SSascha Wildner using this type too by making sure bits 8..15 of the argument are set to 0. 74*1370a723SSascha Wildner - x 75*1370a723SSascha Wildner - The argument is an unsigned hexadecimal number. The characters used are 0..9 and 76*1370a723SSascha Wildner A..F. If the flag 'L' is not specified, then the argument is assumed 77*1370a723SSascha Wildner to be size int. This does not follow ANSI C. 78*1370a723SSascha Wildner - X 79*1370a723SSascha Wildner - The argument is an unsigned hexadecimal number and the number is padded with 80*1370a723SSascha Wildner zeros. This is equivalent to a format string of "0x". If the flag 81*1370a723SSascha Wildner 'L' is not specified, then the argument is assumed to be size int. 82*1370a723SSascha Wildner This does not follow ANSI C. 83*1370a723SSascha Wildner - d 84*1370a723SSascha Wildner - The argument is a signed decimal number. If the flag 'L' is not specified, 85*1370a723SSascha Wildner then the argument is assumed to be size int. 86*1370a723SSascha Wildner - u 87*1370a723SSascha Wildner - The argument is a unsigned decimal number. If the flag 'L' is not specified, 88*1370a723SSascha Wildner then the argument is assumed to be size int. 89*1370a723SSascha Wildner - p 90*1370a723SSascha Wildner - The argument is a pointer that is a (VOID *), and it is printed as an 91*1370a723SSascha Wildner unsigned hexadecimal number The characters used are 0..9 and A..F. 92*1370a723SSascha Wildner - a 93*1370a723SSascha Wildner - The argument is a pointer to an ASCII string. 94*1370a723SSascha Wildner This does not follow ANSI C. 95*1370a723SSascha Wildner - S, s 96*1370a723SSascha Wildner - The argument is a pointer to a Unicode string. 97*1370a723SSascha Wildner This does not follow ANSI C. 98*1370a723SSascha Wildner - g 99*1370a723SSascha Wildner - The argument is a pointer to a GUID structure. The GUID is printed 100*1370a723SSascha Wildner in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. 101*1370a723SSascha Wildner This does not follow ANSI C. 102*1370a723SSascha Wildner - t 103*1370a723SSascha Wildner - The argument is a pointer to an EFI_TIME structure. The time and 104*1370a723SSascha Wildner date are printed in the format "mm/dd/yyyy hh:mm" where mm is the 105*1370a723SSascha Wildner month zero padded, dd is the day zero padded, yyyy is the year zero 106*1370a723SSascha Wildner padded, hh is the hour zero padded, and mm is minutes zero padded. 107*1370a723SSascha Wildner This does not follow ANSI C. 108*1370a723SSascha Wildner - r 109*1370a723SSascha Wildner - The argument is a RETURN_STATUS value. This value is converted to 110*1370a723SSascha Wildner a string following the table below. This does not follow ANSI C. 111*1370a723SSascha Wildner - RETURN_SUCCESS 112*1370a723SSascha Wildner - "Success" 113*1370a723SSascha Wildner - RETURN_LOAD_ERROR 114*1370a723SSascha Wildner - "Load Error" 115*1370a723SSascha Wildner - RETURN_INVALID_PARAMETER 116*1370a723SSascha Wildner - "Invalid Parameter" 117*1370a723SSascha Wildner - RETURN_UNSUPPORTED 118*1370a723SSascha Wildner - "Unsupported" 119*1370a723SSascha Wildner - RETURN_BAD_BUFFER_SIZE 120*1370a723SSascha Wildner - "Bad Buffer Size" 121*1370a723SSascha Wildner - RETURN_BUFFER_TOO_SMALL 122*1370a723SSascha Wildner - "Buffer Too Small" 123*1370a723SSascha Wildner - RETURN_NOT_READY 124*1370a723SSascha Wildner - "Not Ready" 125*1370a723SSascha Wildner - RETURN_DEVICE_ERROR 126*1370a723SSascha Wildner - "Device Error" 127*1370a723SSascha Wildner - RETURN_WRITE_PROTECTED 128*1370a723SSascha Wildner - "Write Protected" 129*1370a723SSascha Wildner - RETURN_OUT_OF_RESOURCES 130*1370a723SSascha Wildner - "Out of Resources" 131*1370a723SSascha Wildner - RETURN_VOLUME_CORRUPTED 132*1370a723SSascha Wildner - "Volume Corrupt" 133*1370a723SSascha Wildner - RETURN_VOLUME_FULL 134*1370a723SSascha Wildner - "Volume Full" 135*1370a723SSascha Wildner - RETURN_NO_MEDIA 136*1370a723SSascha Wildner - "No Media" 137*1370a723SSascha Wildner - RETURN_MEDIA_CHANGED 138*1370a723SSascha Wildner - "Media changed" 139*1370a723SSascha Wildner - RETURN_NOT_FOUND 140*1370a723SSascha Wildner - "Not Found" 141*1370a723SSascha Wildner - RETURN_ACCESS_DENIED 142*1370a723SSascha Wildner - "Access Denied" 143*1370a723SSascha Wildner - RETURN_NO_RESPONSE 144*1370a723SSascha Wildner - "No Response" 145*1370a723SSascha Wildner - RETURN_NO_MAPPING 146*1370a723SSascha Wildner - "No mapping" 147*1370a723SSascha Wildner - RETURN_TIMEOUT 148*1370a723SSascha Wildner - "Time out" 149*1370a723SSascha Wildner - RETURN_NOT_STARTED 150*1370a723SSascha Wildner - "Not started" 151*1370a723SSascha Wildner - RETURN_ALREADY_STARTED 152*1370a723SSascha Wildner - "Already started" 153*1370a723SSascha Wildner - RETURN_ABORTED 154*1370a723SSascha Wildner - "Aborted" 155*1370a723SSascha Wildner - RETURN_ICMP_ERROR 156*1370a723SSascha Wildner - "ICMP Error" 157*1370a723SSascha Wildner - RETURN_TFTP_ERROR 158*1370a723SSascha Wildner - "TFTP Error" 159*1370a723SSascha Wildner - RETURN_PROTOCOL_ERROR 160*1370a723SSascha Wildner - "Protocol Error" 161*1370a723SSascha Wildner - RETURN_WARN_UNKNOWN_GLYPH 162*1370a723SSascha Wildner - "Warning Unknown Glyph" 163*1370a723SSascha Wildner - RETURN_WARN_DELETE_FAILURE 164*1370a723SSascha Wildner - "Warning Delete Failure" 165*1370a723SSascha Wildner - RETURN_WARN_WRITE_FAILURE 166*1370a723SSascha Wildner - "Warning Write Failure" 167*1370a723SSascha Wildner - RETURN_WARN_BUFFER_TOO_SMALL 168*1370a723SSascha Wildner - "Warning Buffer Too Small" 169*1370a723SSascha Wildner 170*1370a723SSascha Wildner **/ 171*1370a723SSascha Wildner 172*1370a723SSascha Wildner #ifndef __PRINT_LIB_H__ 173*1370a723SSascha Wildner #define __PRINT_LIB_H__ 174*1370a723SSascha Wildner 175*1370a723SSascha Wildner /// 176*1370a723SSascha Wildner /// Define the maximum number of characters that are required to 177*1370a723SSascha Wildner /// encode with a NULL terminator a decimal, hexadecimal, GUID, 178*1370a723SSascha Wildner /// or TIME value. 179*1370a723SSascha Wildner /// 180*1370a723SSascha Wildner /// Maximum Length Decimal String = 28 181*1370a723SSascha Wildner /// "-9,223,372,036,854,775,808" 182*1370a723SSascha Wildner /// Maximum Length Hexadecimal String = 17 183*1370a723SSascha Wildner /// "FFFFFFFFFFFFFFFF" 184*1370a723SSascha Wildner /// Maximum Length GUID = 37 185*1370a723SSascha Wildner /// "00000000-0000-0000-0000-000000000000" 186*1370a723SSascha Wildner /// Maximum Length TIME = 18 187*1370a723SSascha Wildner /// "12/12/2006 12:12" 188*1370a723SSascha Wildner /// 189*1370a723SSascha Wildner #define MAXIMUM_VALUE_CHARACTERS 38 190*1370a723SSascha Wildner 191*1370a723SSascha Wildner /// 192*1370a723SSascha Wildner /// Flags bitmask values use in UnicodeValueToString() and 193*1370a723SSascha Wildner /// AsciiValueToString() 194*1370a723SSascha Wildner /// 195*1370a723SSascha Wildner #define LEFT_JUSTIFY 0x01 196*1370a723SSascha Wildner #define COMMA_TYPE 0x08 197*1370a723SSascha Wildner #define PREFIX_ZERO 0x20 198*1370a723SSascha Wildner #define RADIX_HEX 0x80 199*1370a723SSascha Wildner 200*1370a723SSascha Wildner /** 201*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on 202*1370a723SSascha Wildner a Null-terminated Unicode format string and a VA_LIST argument list. 203*1370a723SSascha Wildner 204*1370a723SSascha Wildner This function is similar as vsnprintf_s defined in C11. 205*1370a723SSascha Wildner 206*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 207*1370a723SSascha Wildner and BufferSize. 208*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 209*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on the 210*1370a723SSascha Wildner contents of the format string. 211*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 212*1370a723SSascha Wildner the Null-terminator. 213*1370a723SSascha Wildner 214*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 215*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 216*1370a723SSascha Wildner 217*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 218*1370a723SSascha Wildner unmodified and 0 is returned. 219*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 220*1370a723SSascha Wildner unmodified and 0 is returned. 221*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 222*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 223*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 224*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 225*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 226*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 227*1370a723SSascha Wildner 228*1370a723SSascha Wildner If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 229*1370a723SSascha Wildner 230*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 231*1370a723SSascha Wildner Unicode string. 232*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 233*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 234*1370a723SSascha Wildner @param Marker VA_LIST marker for the variable argument list. 235*1370a723SSascha Wildner 236*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 237*1370a723SSascha Wildner Null-terminator. 238*1370a723SSascha Wildner 239*1370a723SSascha Wildner **/ 240*1370a723SSascha Wildner UINTN 241*1370a723SSascha Wildner EFIAPI 242*1370a723SSascha Wildner UnicodeVSPrint ( 243*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 244*1370a723SSascha Wildner IN UINTN BufferSize, 245*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 246*1370a723SSascha Wildner IN VA_LIST Marker 247*1370a723SSascha Wildner ); 248*1370a723SSascha Wildner 249*1370a723SSascha Wildner /** 250*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on 251*1370a723SSascha Wildner a Null-terminated Unicode format string and a BASE_LIST argument list. 252*1370a723SSascha Wildner 253*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 254*1370a723SSascha Wildner and BufferSize. 255*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 256*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on the 257*1370a723SSascha Wildner contents of the format string. 258*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 259*1370a723SSascha Wildner the Null-terminator. 260*1370a723SSascha Wildner 261*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 262*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 263*1370a723SSascha Wildner 264*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 265*1370a723SSascha Wildner unmodified and 0 is returned. 266*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 267*1370a723SSascha Wildner unmodified and 0 is returned. 268*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 269*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 270*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 271*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 272*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 273*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 274*1370a723SSascha Wildner 275*1370a723SSascha Wildner If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 276*1370a723SSascha Wildner 277*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 278*1370a723SSascha Wildner Unicode string. 279*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 280*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 281*1370a723SSascha Wildner @param Marker BASE_LIST marker for the variable argument list. 282*1370a723SSascha Wildner 283*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 284*1370a723SSascha Wildner Null-terminator. 285*1370a723SSascha Wildner 286*1370a723SSascha Wildner **/ 287*1370a723SSascha Wildner UINTN 288*1370a723SSascha Wildner EFIAPI 289*1370a723SSascha Wildner UnicodeBSPrint ( 290*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 291*1370a723SSascha Wildner IN UINTN BufferSize, 292*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 293*1370a723SSascha Wildner IN BASE_LIST Marker 294*1370a723SSascha Wildner ); 295*1370a723SSascha Wildner 296*1370a723SSascha Wildner /** 297*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 298*1370a723SSascha Wildner Unicode format string and variable argument list. 299*1370a723SSascha Wildner 300*1370a723SSascha Wildner This function is similar as snprintf_s defined in C11. 301*1370a723SSascha Wildner 302*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 303*1370a723SSascha Wildner and BufferSize. 304*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 305*1370a723SSascha Wildner Arguments are pulled from the variable argument list based on the contents of the format string. 306*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 307*1370a723SSascha Wildner the Null-terminator. 308*1370a723SSascha Wildner 309*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 310*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 311*1370a723SSascha Wildner 312*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 313*1370a723SSascha Wildner unmodified and 0 is returned. 314*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 315*1370a723SSascha Wildner unmodified and 0 is returned. 316*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 317*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 318*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 319*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 320*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 321*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 322*1370a723SSascha Wildner 323*1370a723SSascha Wildner If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 324*1370a723SSascha Wildner 325*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 326*1370a723SSascha Wildner Unicode string. 327*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 328*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 329*1370a723SSascha Wildner @param ... Variable argument list whose contents are accessed based on the 330*1370a723SSascha Wildner format string specified by FormatString. 331*1370a723SSascha Wildner 332*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 333*1370a723SSascha Wildner Null-terminator. 334*1370a723SSascha Wildner 335*1370a723SSascha Wildner **/ 336*1370a723SSascha Wildner UINTN 337*1370a723SSascha Wildner EFIAPI 338*1370a723SSascha Wildner UnicodeSPrint ( 339*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 340*1370a723SSascha Wildner IN UINTN BufferSize, 341*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 342*1370a723SSascha Wildner ... 343*1370a723SSascha Wildner ); 344*1370a723SSascha Wildner 345*1370a723SSascha Wildner /** 346*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 347*1370a723SSascha Wildner ASCII format string and a VA_LIST argument list. 348*1370a723SSascha Wildner 349*1370a723SSascha Wildner This function is similar as vsnprintf_s defined in C11. 350*1370a723SSascha Wildner 351*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 352*1370a723SSascha Wildner and BufferSize. 353*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 354*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on the 355*1370a723SSascha Wildner contents of the format string. 356*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 357*1370a723SSascha Wildner the Null-terminator. 358*1370a723SSascha Wildner 359*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 360*1370a723SSascha Wildner 361*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 362*1370a723SSascha Wildner unmodified and 0 is returned. 363*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 364*1370a723SSascha Wildner unmodified and 0 is returned. 365*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 366*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 367*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 368*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 369*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 370*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 371*1370a723SSascha Wildner 372*1370a723SSascha Wildner If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 373*1370a723SSascha Wildner 374*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 375*1370a723SSascha Wildner Unicode string. 376*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 377*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 378*1370a723SSascha Wildner @param Marker VA_LIST marker for the variable argument list. 379*1370a723SSascha Wildner 380*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 381*1370a723SSascha Wildner Null-terminator. 382*1370a723SSascha Wildner 383*1370a723SSascha Wildner **/ 384*1370a723SSascha Wildner UINTN 385*1370a723SSascha Wildner EFIAPI 386*1370a723SSascha Wildner UnicodeVSPrintAsciiFormat ( 387*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 388*1370a723SSascha Wildner IN UINTN BufferSize, 389*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 390*1370a723SSascha Wildner IN VA_LIST Marker 391*1370a723SSascha Wildner ); 392*1370a723SSascha Wildner 393*1370a723SSascha Wildner /** 394*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 395*1370a723SSascha Wildner ASCII format string and a BASE_LIST argument list. 396*1370a723SSascha Wildner 397*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 398*1370a723SSascha Wildner and BufferSize. 399*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 400*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on the 401*1370a723SSascha Wildner contents of the format string. 402*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 403*1370a723SSascha Wildner the Null-terminator. 404*1370a723SSascha Wildner 405*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 406*1370a723SSascha Wildner 407*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 408*1370a723SSascha Wildner unmodified and 0 is returned. 409*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 410*1370a723SSascha Wildner unmodified and 0 is returned. 411*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 412*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 413*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 414*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 415*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 416*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 417*1370a723SSascha Wildner 418*1370a723SSascha Wildner If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 419*1370a723SSascha Wildner 420*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 421*1370a723SSascha Wildner Unicode string. 422*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 423*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 424*1370a723SSascha Wildner @param Marker BASE_LIST marker for the variable argument list. 425*1370a723SSascha Wildner 426*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 427*1370a723SSascha Wildner Null-terminator. 428*1370a723SSascha Wildner 429*1370a723SSascha Wildner **/ 430*1370a723SSascha Wildner UINTN 431*1370a723SSascha Wildner EFIAPI 432*1370a723SSascha Wildner UnicodeBSPrintAsciiFormat ( 433*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 434*1370a723SSascha Wildner IN UINTN BufferSize, 435*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 436*1370a723SSascha Wildner IN BASE_LIST Marker 437*1370a723SSascha Wildner ); 438*1370a723SSascha Wildner 439*1370a723SSascha Wildner /** 440*1370a723SSascha Wildner Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 441*1370a723SSascha Wildner ASCII format string and variable argument list. 442*1370a723SSascha Wildner 443*1370a723SSascha Wildner This function is similar as snprintf_s defined in C11. 444*1370a723SSascha Wildner 445*1370a723SSascha Wildner Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 446*1370a723SSascha Wildner and BufferSize. 447*1370a723SSascha Wildner The Unicode string is produced by parsing the format string specified by FormatString. 448*1370a723SSascha Wildner Arguments are pulled from the variable argument list based on the contents of the 449*1370a723SSascha Wildner format string. 450*1370a723SSascha Wildner The number of Unicode characters in the produced output buffer is returned not including 451*1370a723SSascha Wildner the Null-terminator. 452*1370a723SSascha Wildner 453*1370a723SSascha Wildner If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 454*1370a723SSascha Wildner 455*1370a723SSascha Wildner If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 456*1370a723SSascha Wildner unmodified and 0 is returned. 457*1370a723SSascha Wildner If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 458*1370a723SSascha Wildner unmodified and 0 is returned. 459*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 460*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 461*1370a723SSascha Wildner buffer is unmodified and 0 is returned. 462*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 463*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 464*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 465*1370a723SSascha Wildner 466*1370a723SSascha Wildner If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 467*1370a723SSascha Wildner 468*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 469*1370a723SSascha Wildner Unicode string. 470*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 471*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 472*1370a723SSascha Wildner @param ... Variable argument list whose contents are accessed based on the 473*1370a723SSascha Wildner format string specified by FormatString. 474*1370a723SSascha Wildner 475*1370a723SSascha Wildner @return The number of Unicode characters in the produced output buffer not including the 476*1370a723SSascha Wildner Null-terminator. 477*1370a723SSascha Wildner 478*1370a723SSascha Wildner **/ 479*1370a723SSascha Wildner UINTN 480*1370a723SSascha Wildner EFIAPI 481*1370a723SSascha Wildner UnicodeSPrintAsciiFormat ( 482*1370a723SSascha Wildner OUT CHAR16 *StartOfBuffer, 483*1370a723SSascha Wildner IN UINTN BufferSize, 484*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 485*1370a723SSascha Wildner ... 486*1370a723SSascha Wildner ); 487*1370a723SSascha Wildner 488*1370a723SSascha Wildner /** 489*1370a723SSascha Wildner Converts a decimal value to a Null-terminated Unicode string. 490*1370a723SSascha Wildner 491*1370a723SSascha Wildner Converts the decimal number specified by Value to a Null-terminated Unicode 492*1370a723SSascha Wildner string specified by Buffer containing at most Width characters. No padding of 493*1370a723SSascha Wildner spaces is ever performed. If Width is 0 then a width of 494*1370a723SSascha Wildner MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 495*1370a723SSascha Wildner Width characters, then only the first Width characters are placed in Buffer. 496*1370a723SSascha Wildner Additional conversion parameters are specified in Flags. 497*1370a723SSascha Wildner 498*1370a723SSascha Wildner The Flags bit LEFT_JUSTIFY is always ignored. 499*1370a723SSascha Wildner All conversions are left justified in Buffer. 500*1370a723SSascha Wildner If Width is 0, PREFIX_ZERO is ignored in Flags. 501*1370a723SSascha Wildner If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 502*1370a723SSascha Wildner commas are inserted every 3rd digit starting from the right. 503*1370a723SSascha Wildner If RADIX_HEX is set in Flags, then the output buffer will be formatted in 504*1370a723SSascha Wildner hexadecimal format. 505*1370a723SSascha Wildner If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 506*1370a723SSascha Wildner Buffer is a '-'. 507*1370a723SSascha Wildner If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 508*1370a723SSascha Wildner Buffer is padded with '0' characters so the combination of the optional '-' 509*1370a723SSascha Wildner sign character, '0' characters, digit characters for Value, and the 510*1370a723SSascha Wildner Null-terminator add up to Width characters. 511*1370a723SSascha Wildner 512*1370a723SSascha Wildner If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 513*1370a723SSascha Wildner If an error would be returned, then the function will also ASSERT(). 514*1370a723SSascha Wildner 515*1370a723SSascha Wildner @param Buffer The pointer to the output buffer for the produced 516*1370a723SSascha Wildner Null-terminated Unicode string. 517*1370a723SSascha Wildner @param BufferSize The size of Buffer in bytes, including the 518*1370a723SSascha Wildner Null-terminator. 519*1370a723SSascha Wildner @param Flags The bitmask of flags that specify left justification, 520*1370a723SSascha Wildner zero pad, and commas. 521*1370a723SSascha Wildner @param Value The 64-bit signed value to convert to a string. 522*1370a723SSascha Wildner @param Width The maximum number of Unicode characters to place in 523*1370a723SSascha Wildner Buffer, not including the Null-terminator. 524*1370a723SSascha Wildner 525*1370a723SSascha Wildner @retval RETURN_SUCCESS The decimal value is converted. 526*1370a723SSascha Wildner @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 527*1370a723SSascha Wildner value. 528*1370a723SSascha Wildner @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 529*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not 530*1370a723SSascha Wildner zero, and BufferSize is greater than 531*1370a723SSascha Wildner (PcdMaximumUnicodeStringLength * 532*1370a723SSascha Wildner sizeof (CHAR16) + 1). 533*1370a723SSascha Wildner If unsupported bits are set in Flags. 534*1370a723SSascha Wildner If both COMMA_TYPE and RADIX_HEX are set in 535*1370a723SSascha Wildner Flags. 536*1370a723SSascha Wildner If Width >= MAXIMUM_VALUE_CHARACTERS. 537*1370a723SSascha Wildner 538*1370a723SSascha Wildner **/ 539*1370a723SSascha Wildner RETURN_STATUS 540*1370a723SSascha Wildner EFIAPI 541*1370a723SSascha Wildner UnicodeValueToStringS ( 542*1370a723SSascha Wildner IN OUT CHAR16 *Buffer, 543*1370a723SSascha Wildner IN UINTN BufferSize, 544*1370a723SSascha Wildner IN UINTN Flags, 545*1370a723SSascha Wildner IN INT64 Value, 546*1370a723SSascha Wildner IN UINTN Width 547*1370a723SSascha Wildner ); 548*1370a723SSascha Wildner 549*1370a723SSascha Wildner /** 550*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 551*1370a723SSascha Wildner ASCII format string and a VA_LIST argument list. 552*1370a723SSascha Wildner 553*1370a723SSascha Wildner This function is similar as vsnprintf_s defined in C11. 554*1370a723SSascha Wildner 555*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 556*1370a723SSascha Wildner and BufferSize. 557*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 558*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on 559*1370a723SSascha Wildner the contents of the format string. 560*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 561*1370a723SSascha Wildner the Null-terminator. 562*1370a723SSascha Wildner 563*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 564*1370a723SSascha Wildner unmodified and 0 is returned. 565*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 566*1370a723SSascha Wildner unmodified and 0 is returned. 567*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 568*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 569*1370a723SSascha Wildner is unmodified and 0 is returned. 570*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 571*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 572*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 573*1370a723SSascha Wildner 574*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 575*1370a723SSascha Wildner 576*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 577*1370a723SSascha Wildner ASCII string. 578*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 579*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 580*1370a723SSascha Wildner @param Marker VA_LIST marker for the variable argument list. 581*1370a723SSascha Wildner 582*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 583*1370a723SSascha Wildner Null-terminator. 584*1370a723SSascha Wildner 585*1370a723SSascha Wildner **/ 586*1370a723SSascha Wildner UINTN 587*1370a723SSascha Wildner EFIAPI 588*1370a723SSascha Wildner AsciiVSPrint ( 589*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 590*1370a723SSascha Wildner IN UINTN BufferSize, 591*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 592*1370a723SSascha Wildner IN VA_LIST Marker 593*1370a723SSascha Wildner ); 594*1370a723SSascha Wildner 595*1370a723SSascha Wildner /** 596*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 597*1370a723SSascha Wildner ASCII format string and a BASE_LIST argument list. 598*1370a723SSascha Wildner 599*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 600*1370a723SSascha Wildner and BufferSize. 601*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 602*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on 603*1370a723SSascha Wildner the contents of the format string. 604*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 605*1370a723SSascha Wildner the Null-terminator. 606*1370a723SSascha Wildner 607*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 608*1370a723SSascha Wildner unmodified and 0 is returned. 609*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 610*1370a723SSascha Wildner unmodified and 0 is returned. 611*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 612*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 613*1370a723SSascha Wildner is unmodified and 0 is returned. 614*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 615*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 616*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 617*1370a723SSascha Wildner 618*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 619*1370a723SSascha Wildner 620*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 621*1370a723SSascha Wildner ASCII string. 622*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 623*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 624*1370a723SSascha Wildner @param Marker BASE_LIST marker for the variable argument list. 625*1370a723SSascha Wildner 626*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 627*1370a723SSascha Wildner Null-terminator. 628*1370a723SSascha Wildner 629*1370a723SSascha Wildner **/ 630*1370a723SSascha Wildner UINTN 631*1370a723SSascha Wildner EFIAPI 632*1370a723SSascha Wildner AsciiBSPrint ( 633*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 634*1370a723SSascha Wildner IN UINTN BufferSize, 635*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 636*1370a723SSascha Wildner IN BASE_LIST Marker 637*1370a723SSascha Wildner ); 638*1370a723SSascha Wildner 639*1370a723SSascha Wildner /** 640*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 641*1370a723SSascha Wildner ASCII format string and variable argument list. 642*1370a723SSascha Wildner 643*1370a723SSascha Wildner This function is similar as snprintf_s defined in C11. 644*1370a723SSascha Wildner 645*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 646*1370a723SSascha Wildner and BufferSize. 647*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 648*1370a723SSascha Wildner Arguments are pulled from the variable argument list based on the contents of the 649*1370a723SSascha Wildner format string. 650*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 651*1370a723SSascha Wildner the Null-terminator. 652*1370a723SSascha Wildner 653*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 654*1370a723SSascha Wildner unmodified and 0 is returned. 655*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 656*1370a723SSascha Wildner unmodified and 0 is returned. 657*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 658*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 659*1370a723SSascha Wildner is unmodified and 0 is returned. 660*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 661*1370a723SSascha Wildner PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 662*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 663*1370a723SSascha Wildner 664*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 665*1370a723SSascha Wildner 666*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 667*1370a723SSascha Wildner ASCII string. 668*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 669*1370a723SSascha Wildner @param FormatString A Null-terminated ASCII format string. 670*1370a723SSascha Wildner @param ... Variable argument list whose contents are accessed based on the 671*1370a723SSascha Wildner format string specified by FormatString. 672*1370a723SSascha Wildner 673*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 674*1370a723SSascha Wildner Null-terminator. 675*1370a723SSascha Wildner 676*1370a723SSascha Wildner **/ 677*1370a723SSascha Wildner UINTN 678*1370a723SSascha Wildner EFIAPI 679*1370a723SSascha Wildner AsciiSPrint ( 680*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 681*1370a723SSascha Wildner IN UINTN BufferSize, 682*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 683*1370a723SSascha Wildner ... 684*1370a723SSascha Wildner ); 685*1370a723SSascha Wildner 686*1370a723SSascha Wildner /** 687*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 688*1370a723SSascha Wildner Unicode format string and a VA_LIST argument list. 689*1370a723SSascha Wildner 690*1370a723SSascha Wildner This function is similar as vsnprintf_s defined in C11. 691*1370a723SSascha Wildner 692*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 693*1370a723SSascha Wildner and BufferSize. 694*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 695*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on 696*1370a723SSascha Wildner the contents of the format string. 697*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 698*1370a723SSascha Wildner the Null-terminator. 699*1370a723SSascha Wildner 700*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 701*1370a723SSascha Wildner 702*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 703*1370a723SSascha Wildner unmodified and 0 is returned. 704*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 705*1370a723SSascha Wildner unmodified and 0 is returned. 706*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 707*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 708*1370a723SSascha Wildner is unmodified and 0 is returned. 709*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 710*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 711*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 712*1370a723SSascha Wildner 713*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 714*1370a723SSascha Wildner 715*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 716*1370a723SSascha Wildner ASCII string. 717*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 718*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 719*1370a723SSascha Wildner @param Marker VA_LIST marker for the variable argument list. 720*1370a723SSascha Wildner 721*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 722*1370a723SSascha Wildner Null-terminator. 723*1370a723SSascha Wildner 724*1370a723SSascha Wildner **/ 725*1370a723SSascha Wildner UINTN 726*1370a723SSascha Wildner EFIAPI 727*1370a723SSascha Wildner AsciiVSPrintUnicodeFormat ( 728*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 729*1370a723SSascha Wildner IN UINTN BufferSize, 730*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 731*1370a723SSascha Wildner IN VA_LIST Marker 732*1370a723SSascha Wildner ); 733*1370a723SSascha Wildner 734*1370a723SSascha Wildner /** 735*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 736*1370a723SSascha Wildner Unicode format string and a BASE_LIST argument list. 737*1370a723SSascha Wildner 738*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 739*1370a723SSascha Wildner and BufferSize. 740*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 741*1370a723SSascha Wildner Arguments are pulled from the variable argument list specified by Marker based on 742*1370a723SSascha Wildner the contents of the format string. 743*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 744*1370a723SSascha Wildner the Null-terminator. 745*1370a723SSascha Wildner 746*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 747*1370a723SSascha Wildner 748*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 749*1370a723SSascha Wildner unmodified and 0 is returned. 750*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 751*1370a723SSascha Wildner unmodified and 0 is returned. 752*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 753*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 754*1370a723SSascha Wildner is unmodified and 0 is returned. 755*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 756*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 757*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 758*1370a723SSascha Wildner 759*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 760*1370a723SSascha Wildner 761*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 762*1370a723SSascha Wildner ASCII string. 763*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 764*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 765*1370a723SSascha Wildner @param Marker BASE_LIST marker for the variable argument list. 766*1370a723SSascha Wildner 767*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 768*1370a723SSascha Wildner Null-terminator. 769*1370a723SSascha Wildner 770*1370a723SSascha Wildner **/ 771*1370a723SSascha Wildner UINTN 772*1370a723SSascha Wildner EFIAPI 773*1370a723SSascha Wildner AsciiBSPrintUnicodeFormat ( 774*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 775*1370a723SSascha Wildner IN UINTN BufferSize, 776*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 777*1370a723SSascha Wildner IN BASE_LIST Marker 778*1370a723SSascha Wildner ); 779*1370a723SSascha Wildner 780*1370a723SSascha Wildner /** 781*1370a723SSascha Wildner Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 782*1370a723SSascha Wildner Unicode format string and variable argument list. 783*1370a723SSascha Wildner 784*1370a723SSascha Wildner This function is similar as snprintf_s defined in C11. 785*1370a723SSascha Wildner 786*1370a723SSascha Wildner Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 787*1370a723SSascha Wildner and BufferSize. 788*1370a723SSascha Wildner The ASCII string is produced by parsing the format string specified by FormatString. 789*1370a723SSascha Wildner Arguments are pulled from the variable argument list based on the contents of the 790*1370a723SSascha Wildner format string. 791*1370a723SSascha Wildner The number of ASCII characters in the produced output buffer is returned not including 792*1370a723SSascha Wildner the Null-terminator. 793*1370a723SSascha Wildner 794*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 795*1370a723SSascha Wildner 796*1370a723SSascha Wildner If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 797*1370a723SSascha Wildner unmodified and 0 is returned. 798*1370a723SSascha Wildner If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 799*1370a723SSascha Wildner unmodified and 0 is returned. 800*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and BufferSize > 801*1370a723SSascha Wildner (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 802*1370a723SSascha Wildner is unmodified and 0 is returned. 803*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 804*1370a723SSascha Wildner PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 805*1370a723SSascha Wildner ASSERT(). Also, the output buffer is unmodified and 0 is returned. 806*1370a723SSascha Wildner 807*1370a723SSascha Wildner If BufferSize is 0, then no output buffer is produced and 0 is returned. 808*1370a723SSascha Wildner 809*1370a723SSascha Wildner @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 810*1370a723SSascha Wildner ASCII string. 811*1370a723SSascha Wildner @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 812*1370a723SSascha Wildner @param FormatString A Null-terminated Unicode format string. 813*1370a723SSascha Wildner @param ... Variable argument list whose contents are accessed based on the 814*1370a723SSascha Wildner format string specified by FormatString. 815*1370a723SSascha Wildner 816*1370a723SSascha Wildner @return The number of ASCII characters in the produced output buffer not including the 817*1370a723SSascha Wildner Null-terminator. 818*1370a723SSascha Wildner 819*1370a723SSascha Wildner **/ 820*1370a723SSascha Wildner UINTN 821*1370a723SSascha Wildner EFIAPI 822*1370a723SSascha Wildner AsciiSPrintUnicodeFormat ( 823*1370a723SSascha Wildner OUT CHAR8 *StartOfBuffer, 824*1370a723SSascha Wildner IN UINTN BufferSize, 825*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 826*1370a723SSascha Wildner ... 827*1370a723SSascha Wildner ); 828*1370a723SSascha Wildner 829*1370a723SSascha Wildner /** 830*1370a723SSascha Wildner Converts a decimal value to a Null-terminated Ascii string. 831*1370a723SSascha Wildner 832*1370a723SSascha Wildner Converts the decimal number specified by Value to a Null-terminated Ascii 833*1370a723SSascha Wildner string specified by Buffer containing at most Width characters. No padding of 834*1370a723SSascha Wildner spaces is ever performed. If Width is 0 then a width of 835*1370a723SSascha Wildner MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 836*1370a723SSascha Wildner Width characters, then only the first Width characters are placed in Buffer. 837*1370a723SSascha Wildner Additional conversion parameters are specified in Flags. 838*1370a723SSascha Wildner 839*1370a723SSascha Wildner The Flags bit LEFT_JUSTIFY is always ignored. 840*1370a723SSascha Wildner All conversions are left justified in Buffer. 841*1370a723SSascha Wildner If Width is 0, PREFIX_ZERO is ignored in Flags. 842*1370a723SSascha Wildner If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 843*1370a723SSascha Wildner commas are inserted every 3rd digit starting from the right. 844*1370a723SSascha Wildner If RADIX_HEX is set in Flags, then the output buffer will be formatted in 845*1370a723SSascha Wildner hexadecimal format. 846*1370a723SSascha Wildner If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 847*1370a723SSascha Wildner Buffer is a '-'. 848*1370a723SSascha Wildner If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 849*1370a723SSascha Wildner Buffer is padded with '0' characters so the combination of the optional '-' 850*1370a723SSascha Wildner sign character, '0' characters, digit characters for Value, and the 851*1370a723SSascha Wildner Null-terminator add up to Width characters. 852*1370a723SSascha Wildner 853*1370a723SSascha Wildner If an error would be returned, then the function will ASSERT(). 854*1370a723SSascha Wildner 855*1370a723SSascha Wildner @param Buffer The pointer to the output buffer for the produced 856*1370a723SSascha Wildner Null-terminated Ascii string. 857*1370a723SSascha Wildner @param BufferSize The size of Buffer in bytes, including the 858*1370a723SSascha Wildner Null-terminator. 859*1370a723SSascha Wildner @param Flags The bitmask of flags that specify left justification, 860*1370a723SSascha Wildner zero pad, and commas. 861*1370a723SSascha Wildner @param Value The 64-bit signed value to convert to a string. 862*1370a723SSascha Wildner @param Width The maximum number of Ascii characters to place in 863*1370a723SSascha Wildner Buffer, not including the Null-terminator. 864*1370a723SSascha Wildner 865*1370a723SSascha Wildner @retval RETURN_SUCCESS The decimal value is converted. 866*1370a723SSascha Wildner @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 867*1370a723SSascha Wildner value. 868*1370a723SSascha Wildner @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 869*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not 870*1370a723SSascha Wildner zero, and BufferSize is greater than 871*1370a723SSascha Wildner PcdMaximumAsciiStringLength. 872*1370a723SSascha Wildner If unsupported bits are set in Flags. 873*1370a723SSascha Wildner If both COMMA_TYPE and RADIX_HEX are set in 874*1370a723SSascha Wildner Flags. 875*1370a723SSascha Wildner If Width >= MAXIMUM_VALUE_CHARACTERS. 876*1370a723SSascha Wildner 877*1370a723SSascha Wildner **/ 878*1370a723SSascha Wildner RETURN_STATUS 879*1370a723SSascha Wildner EFIAPI 880*1370a723SSascha Wildner AsciiValueToStringS ( 881*1370a723SSascha Wildner IN OUT CHAR8 *Buffer, 882*1370a723SSascha Wildner IN UINTN BufferSize, 883*1370a723SSascha Wildner IN UINTN Flags, 884*1370a723SSascha Wildner IN INT64 Value, 885*1370a723SSascha Wildner IN UINTN Width 886*1370a723SSascha Wildner ); 887*1370a723SSascha Wildner 888*1370a723SSascha Wildner /** 889*1370a723SSascha Wildner Returns the number of characters that would be produced by if the formatted 890*1370a723SSascha Wildner output were produced not including the Null-terminator. 891*1370a723SSascha Wildner 892*1370a723SSascha Wildner If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 893*1370a723SSascha Wildner 894*1370a723SSascha Wildner If FormatString is NULL, then ASSERT() and 0 is returned. 895*1370a723SSascha Wildner If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more 896*1370a723SSascha Wildner than PcdMaximumUnicodeStringLength Unicode characters not including the 897*1370a723SSascha Wildner Null-terminator, then ASSERT() and 0 is returned. 898*1370a723SSascha Wildner 899*1370a723SSascha Wildner @param[in] FormatString A Null-terminated Unicode format string. 900*1370a723SSascha Wildner @param[in] Marker VA_LIST marker for the variable argument list. 901*1370a723SSascha Wildner 902*1370a723SSascha Wildner @return The number of characters that would be produced, not including the 903*1370a723SSascha Wildner Null-terminator. 904*1370a723SSascha Wildner **/ 905*1370a723SSascha Wildner UINTN 906*1370a723SSascha Wildner EFIAPI 907*1370a723SSascha Wildner SPrintLength ( 908*1370a723SSascha Wildner IN CONST CHAR16 *FormatString, 909*1370a723SSascha Wildner IN VA_LIST Marker 910*1370a723SSascha Wildner ); 911*1370a723SSascha Wildner 912*1370a723SSascha Wildner /** 913*1370a723SSascha Wildner Returns the number of characters that would be produced by if the formatted 914*1370a723SSascha Wildner output were produced not including the Null-terminator. 915*1370a723SSascha Wildner 916*1370a723SSascha Wildner If FormatString is NULL, then ASSERT() and 0 is returned. 917*1370a723SSascha Wildner If PcdMaximumAsciiStringLength is not zero, and FormatString contains more 918*1370a723SSascha Wildner than PcdMaximumAsciiStringLength Ascii characters not including the 919*1370a723SSascha Wildner Null-terminator, then ASSERT() and 0 is returned. 920*1370a723SSascha Wildner 921*1370a723SSascha Wildner @param[in] FormatString A Null-terminated ASCII format string. 922*1370a723SSascha Wildner @param[in] Marker VA_LIST marker for the variable argument list. 923*1370a723SSascha Wildner 924*1370a723SSascha Wildner @return The number of characters that would be produced, not including the 925*1370a723SSascha Wildner Null-terminator. 926*1370a723SSascha Wildner **/ 927*1370a723SSascha Wildner UINTN 928*1370a723SSascha Wildner EFIAPI 929*1370a723SSascha Wildner SPrintLengthAsciiFormat ( 930*1370a723SSascha Wildner IN CONST CHAR8 *FormatString, 931*1370a723SSascha Wildner IN VA_LIST Marker 932*1370a723SSascha Wildner ); 933*1370a723SSascha Wildner 934*1370a723SSascha Wildner #endif 935