10d1ba665SWarner Losh /** @file 20d1ba665SWarner Losh Provides services to print a formatted string to a buffer. All combinations of 30d1ba665SWarner Losh Unicode and ASCII strings are supported. 40d1ba665SWarner Losh 5*3245fa21SMitchell Horne Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 6*3245fa21SMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent 70d1ba665SWarner Losh 80d1ba665SWarner Losh The Print Library functions provide a simple means to produce formatted output 90d1ba665SWarner Losh strings. Many of the output functions use a format string to describe how to 100d1ba665SWarner Losh format the output of variable arguments. The format string consists of normal 110d1ba665SWarner Losh text and argument descriptors. There are no restrictions for how the normal 120d1ba665SWarner Losh text and argument descriptors can be mixed. The following end of line(EOL) 130d1ba665SWarner Losh translations must be performed on the contents of the format string: 140d1ba665SWarner Losh 150d1ba665SWarner Losh - '\\r' is translated to '\\r' 160d1ba665SWarner Losh - '\\r\\n' is translated to '\\r\\n' 170d1ba665SWarner Losh - '\\n' is translated to '\\r\\n' 180d1ba665SWarner Losh - '\\n\\r' is translated to '\\r\\n' 190d1ba665SWarner Losh 200d1ba665SWarner Losh This does not follow the ANSI C standard for sprint(). The format of argument 210d1ba665SWarner Losh descriptors is described below. The ANSI C standard for sprint() has been 220d1ba665SWarner Losh followed for some of the format types, and has not been followed for others. 230d1ba665SWarner Losh The exceptions are noted below. 240d1ba665SWarner Losh 250d1ba665SWarner Losh %[flags][width][.precision]type 260d1ba665SWarner Losh 270d1ba665SWarner Losh [flags]: 280d1ba665SWarner Losh - - 290d1ba665SWarner Losh - The field is left justified. If not flag is not specified, then the 300d1ba665SWarner Losh field is right justified. 310d1ba665SWarner Losh - space 320d1ba665SWarner Losh - Prefix a space character to a number. Only valid for types X, x, and d. 330d1ba665SWarner Losh - + 340d1ba665SWarner Losh - Prefix a plus character to a number. Only valid for types X, x, and d. 350d1ba665SWarner Losh If both space and + are specified, then space is ignored. 360d1ba665SWarner Losh - 0 370d1ba665SWarner Losh - Pad with 0 characters to the left of a number. Only valid for types 380d1ba665SWarner Losh X, x, and d. 390d1ba665SWarner Losh - , 400d1ba665SWarner Losh - Place a comma every 3rd digit of the number. Only valid for type d. 410d1ba665SWarner Losh If 0 is also specified, then 0 is ignored. 420d1ba665SWarner Losh - L, l 430d1ba665SWarner Losh - The number being printed is size UINT64. Only valid for types X, x, and d. 440d1ba665SWarner Losh If this flag is not specified, then the number being printed is size int. 450d1ba665SWarner Losh - NOTE: All invalid flags are ignored. 460d1ba665SWarner Losh 470d1ba665SWarner Losh [width]: 480d1ba665SWarner Losh 490d1ba665SWarner Losh - * 500d1ba665SWarner Losh - The width of the field is specified by a UINTN argument in the 510d1ba665SWarner Losh argument list. 520d1ba665SWarner Losh - number 530d1ba665SWarner Losh - The number specified as a decimal value represents the width of 540d1ba665SWarner Losh the field. 550d1ba665SWarner Losh - NOTE: If [width] is not specified, then a field width of 0 is assumed. 560d1ba665SWarner Losh 570d1ba665SWarner Losh [.precision]: 580d1ba665SWarner Losh 590d1ba665SWarner Losh - * 600d1ba665SWarner Losh - The precision of the field is specified by a UINTN argument in the 610d1ba665SWarner Losh argument list. 620d1ba665SWarner Losh - number 630d1ba665SWarner Losh - The number specified as a decimal value represents the precision of 640d1ba665SWarner Losh the field. 650d1ba665SWarner Losh - NOTE: If [.precision] is not specified, then a precision of 0 is assumed. 660d1ba665SWarner Losh 670d1ba665SWarner Losh type: 680d1ba665SWarner Losh 690d1ba665SWarner Losh - % 700d1ba665SWarner Losh - Print a %%. 710d1ba665SWarner Losh - c 720d1ba665SWarner Losh - The argument is a Unicode character. ASCII characters can be printed 730d1ba665SWarner Losh using this type too by making sure bits 8..15 of the argument are set to 0. 740d1ba665SWarner Losh - x 750d1ba665SWarner Losh - The argument is an unsigned hexadecimal number. The characters used are 0..9 and 760d1ba665SWarner Losh A..F. If the flag 'L' is not specified, then the argument is assumed 770d1ba665SWarner Losh to be size int. This does not follow ANSI C. 780d1ba665SWarner Losh - X 790d1ba665SWarner Losh - The argument is an unsigned hexadecimal number and the number is padded with 800d1ba665SWarner Losh zeros. This is equivalent to a format string of "0x". If the flag 810d1ba665SWarner Losh 'L' is not specified, then the argument is assumed to be size int. 820d1ba665SWarner Losh This does not follow ANSI C. 830d1ba665SWarner Losh - d 840d1ba665SWarner Losh - The argument is a signed decimal number. If the flag 'L' is not specified, 850d1ba665SWarner Losh then the argument is assumed to be size int. 860d1ba665SWarner Losh - u 870d1ba665SWarner Losh - The argument is a unsigned decimal number. If the flag 'L' is not specified, 880d1ba665SWarner Losh then the argument is assumed to be size int. 890d1ba665SWarner Losh - p 900d1ba665SWarner Losh - The argument is a pointer that is a (VOID *), and it is printed as an 910d1ba665SWarner Losh unsigned hexadecimal number The characters used are 0..9 and A..F. 920d1ba665SWarner Losh - a 930d1ba665SWarner Losh - The argument is a pointer to an ASCII string. 940d1ba665SWarner Losh This does not follow ANSI C. 950d1ba665SWarner Losh - S, s 960d1ba665SWarner Losh - The argument is a pointer to a Unicode string. 970d1ba665SWarner Losh This does not follow ANSI C. 980d1ba665SWarner Losh - g 990d1ba665SWarner Losh - The argument is a pointer to a GUID structure. The GUID is printed 1000d1ba665SWarner Losh in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. 1010d1ba665SWarner Losh This does not follow ANSI C. 1020d1ba665SWarner Losh - t 1030d1ba665SWarner Losh - The argument is a pointer to an EFI_TIME structure. The time and 1040d1ba665SWarner Losh date are printed in the format "mm/dd/yyyy hh:mm" where mm is the 1050d1ba665SWarner Losh month zero padded, dd is the day zero padded, yyyy is the year zero 1060d1ba665SWarner Losh padded, hh is the hour zero padded, and mm is minutes zero padded. 1070d1ba665SWarner Losh This does not follow ANSI C. 1080d1ba665SWarner Losh - r 1090d1ba665SWarner Losh - The argument is a RETURN_STATUS value. This value is converted to 1100d1ba665SWarner Losh a string following the table below. This does not follow ANSI C. 1110d1ba665SWarner Losh - RETURN_SUCCESS 1120d1ba665SWarner Losh - "Success" 1130d1ba665SWarner Losh - RETURN_LOAD_ERROR 1140d1ba665SWarner Losh - "Load Error" 1150d1ba665SWarner Losh - RETURN_INVALID_PARAMETER 1160d1ba665SWarner Losh - "Invalid Parameter" 1170d1ba665SWarner Losh - RETURN_UNSUPPORTED 1180d1ba665SWarner Losh - "Unsupported" 1190d1ba665SWarner Losh - RETURN_BAD_BUFFER_SIZE 1200d1ba665SWarner Losh - "Bad Buffer Size" 1210d1ba665SWarner Losh - RETURN_BUFFER_TOO_SMALL 1220d1ba665SWarner Losh - "Buffer Too Small" 1230d1ba665SWarner Losh - RETURN_NOT_READY 1240d1ba665SWarner Losh - "Not Ready" 1250d1ba665SWarner Losh - RETURN_DEVICE_ERROR 1260d1ba665SWarner Losh - "Device Error" 1270d1ba665SWarner Losh - RETURN_WRITE_PROTECTED 1280d1ba665SWarner Losh - "Write Protected" 1290d1ba665SWarner Losh - RETURN_OUT_OF_RESOURCES 1300d1ba665SWarner Losh - "Out of Resources" 1310d1ba665SWarner Losh - RETURN_VOLUME_CORRUPTED 1320d1ba665SWarner Losh - "Volume Corrupt" 1330d1ba665SWarner Losh - RETURN_VOLUME_FULL 1340d1ba665SWarner Losh - "Volume Full" 1350d1ba665SWarner Losh - RETURN_NO_MEDIA 1360d1ba665SWarner Losh - "No Media" 1370d1ba665SWarner Losh - RETURN_MEDIA_CHANGED 1380d1ba665SWarner Losh - "Media changed" 1390d1ba665SWarner Losh - RETURN_NOT_FOUND 1400d1ba665SWarner Losh - "Not Found" 1410d1ba665SWarner Losh - RETURN_ACCESS_DENIED 1420d1ba665SWarner Losh - "Access Denied" 1430d1ba665SWarner Losh - RETURN_NO_RESPONSE 1440d1ba665SWarner Losh - "No Response" 1450d1ba665SWarner Losh - RETURN_NO_MAPPING 1460d1ba665SWarner Losh - "No mapping" 1470d1ba665SWarner Losh - RETURN_TIMEOUT 1480d1ba665SWarner Losh - "Time out" 1490d1ba665SWarner Losh - RETURN_NOT_STARTED 1500d1ba665SWarner Losh - "Not started" 1510d1ba665SWarner Losh - RETURN_ALREADY_STARTED 1520d1ba665SWarner Losh - "Already started" 1530d1ba665SWarner Losh - RETURN_ABORTED 1540d1ba665SWarner Losh - "Aborted" 1550d1ba665SWarner Losh - RETURN_ICMP_ERROR 1560d1ba665SWarner Losh - "ICMP Error" 1570d1ba665SWarner Losh - RETURN_TFTP_ERROR 1580d1ba665SWarner Losh - "TFTP Error" 1590d1ba665SWarner Losh - RETURN_PROTOCOL_ERROR 1600d1ba665SWarner Losh - "Protocol Error" 1610d1ba665SWarner Losh - RETURN_WARN_UNKNOWN_GLYPH 1620d1ba665SWarner Losh - "Warning Unknown Glyph" 1630d1ba665SWarner Losh - RETURN_WARN_DELETE_FAILURE 1640d1ba665SWarner Losh - "Warning Delete Failure" 1650d1ba665SWarner Losh - RETURN_WARN_WRITE_FAILURE 1660d1ba665SWarner Losh - "Warning Write Failure" 1670d1ba665SWarner Losh - RETURN_WARN_BUFFER_TOO_SMALL 1680d1ba665SWarner Losh - "Warning Buffer Too Small" 1690d1ba665SWarner Losh 1700d1ba665SWarner Losh **/ 1710d1ba665SWarner Losh 1720d1ba665SWarner Losh #ifndef __PRINT_LIB_H__ 1730d1ba665SWarner Losh #define __PRINT_LIB_H__ 1740d1ba665SWarner Losh 1750d1ba665SWarner Losh /// 1760d1ba665SWarner Losh /// Define the maximum number of characters that are required to 1770d1ba665SWarner Losh /// encode with a NULL terminator a decimal, hexadecimal, GUID, 1780d1ba665SWarner Losh /// or TIME value. 1790d1ba665SWarner Losh /// 1800d1ba665SWarner Losh /// Maximum Length Decimal String = 28 1810d1ba665SWarner Losh /// "-9,223,372,036,854,775,808" 1820d1ba665SWarner Losh /// Maximum Length Hexadecimal String = 17 1830d1ba665SWarner Losh /// "FFFFFFFFFFFFFFFF" 1840d1ba665SWarner Losh /// Maximum Length GUID = 37 1850d1ba665SWarner Losh /// "00000000-0000-0000-0000-000000000000" 1860d1ba665SWarner Losh /// Maximum Length TIME = 18 1870d1ba665SWarner Losh /// "12/12/2006 12:12" 1880d1ba665SWarner Losh /// 1890d1ba665SWarner Losh #define MAXIMUM_VALUE_CHARACTERS 38 1900d1ba665SWarner Losh 1910d1ba665SWarner Losh /// 1920d1ba665SWarner Losh /// Flags bitmask values use in UnicodeValueToString() and 1930d1ba665SWarner Losh /// AsciiValueToString() 1940d1ba665SWarner Losh /// 1950d1ba665SWarner Losh #define LEFT_JUSTIFY 0x01 1960d1ba665SWarner Losh #define COMMA_TYPE 0x08 1970d1ba665SWarner Losh #define PREFIX_ZERO 0x20 1980d1ba665SWarner Losh #define RADIX_HEX 0x80 1990d1ba665SWarner Losh 2000d1ba665SWarner Losh /** 2010d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on 2020d1ba665SWarner Losh a Null-terminated Unicode format string and a VA_LIST argument list. 2030d1ba665SWarner Losh 2040d1ba665SWarner Losh This function is similar as vsnprintf_s defined in C11. 2050d1ba665SWarner Losh 2060d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 2070d1ba665SWarner Losh and BufferSize. 2080d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 2090d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on the 2100d1ba665SWarner Losh contents of the format string. 2110d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 2120d1ba665SWarner Losh the Null-terminator. 2130d1ba665SWarner Losh 2140d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 2150d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 2160d1ba665SWarner Losh 2170d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 2180d1ba665SWarner Losh unmodified and 0 is returned. 2190d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 2200d1ba665SWarner Losh unmodified and 0 is returned. 2210d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 2220d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 2230d1ba665SWarner Losh buffer is unmodified and 0 is returned. 2240d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 2250d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 2260d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 2270d1ba665SWarner Losh 2280d1ba665SWarner Losh If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 2290d1ba665SWarner Losh 2300d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 2310d1ba665SWarner Losh Unicode string. 2320d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 2330d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 2340d1ba665SWarner Losh @param Marker VA_LIST marker for the variable argument list. 2350d1ba665SWarner Losh 2360d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 2370d1ba665SWarner Losh Null-terminator. 2380d1ba665SWarner Losh 2390d1ba665SWarner Losh **/ 2400d1ba665SWarner Losh UINTN 2410d1ba665SWarner Losh EFIAPI 2420d1ba665SWarner Losh UnicodeVSPrint ( 2430d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 2440d1ba665SWarner Losh IN UINTN BufferSize, 2450d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 2460d1ba665SWarner Losh IN VA_LIST Marker 2470d1ba665SWarner Losh ); 2480d1ba665SWarner Losh 2490d1ba665SWarner Losh /** 2500d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on 2510d1ba665SWarner Losh a Null-terminated Unicode format string and a BASE_LIST argument list. 2520d1ba665SWarner Losh 2530d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 2540d1ba665SWarner Losh and BufferSize. 2550d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 2560d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on the 2570d1ba665SWarner Losh contents of the format string. 2580d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 2590d1ba665SWarner Losh the Null-terminator. 2600d1ba665SWarner Losh 2610d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 2620d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 2630d1ba665SWarner Losh 2640d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 2650d1ba665SWarner Losh unmodified and 0 is returned. 2660d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 2670d1ba665SWarner Losh unmodified and 0 is returned. 2680d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 2690d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 2700d1ba665SWarner Losh buffer is unmodified and 0 is returned. 2710d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 2720d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 2730d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 2740d1ba665SWarner Losh 2750d1ba665SWarner Losh If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 2760d1ba665SWarner Losh 2770d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 2780d1ba665SWarner Losh Unicode string. 2790d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 2800d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 2810d1ba665SWarner Losh @param Marker BASE_LIST marker for the variable argument list. 2820d1ba665SWarner Losh 2830d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 2840d1ba665SWarner Losh Null-terminator. 2850d1ba665SWarner Losh 2860d1ba665SWarner Losh **/ 2870d1ba665SWarner Losh UINTN 2880d1ba665SWarner Losh EFIAPI 2890d1ba665SWarner Losh UnicodeBSPrint ( 2900d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 2910d1ba665SWarner Losh IN UINTN BufferSize, 2920d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 2930d1ba665SWarner Losh IN BASE_LIST Marker 2940d1ba665SWarner Losh ); 2950d1ba665SWarner Losh 2960d1ba665SWarner Losh /** 2970d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 2980d1ba665SWarner Losh Unicode format string and variable argument list. 2990d1ba665SWarner Losh 3000d1ba665SWarner Losh This function is similar as snprintf_s defined in C11. 3010d1ba665SWarner Losh 3020d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 3030d1ba665SWarner Losh and BufferSize. 3040d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 3050d1ba665SWarner Losh Arguments are pulled from the variable argument list based on the contents of the format string. 3060d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 3070d1ba665SWarner Losh the Null-terminator. 3080d1ba665SWarner Losh 3090d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 3100d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 3110d1ba665SWarner Losh 3120d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 3130d1ba665SWarner Losh unmodified and 0 is returned. 3140d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 3150d1ba665SWarner Losh unmodified and 0 is returned. 3160d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 3170d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 3180d1ba665SWarner Losh buffer is unmodified and 0 is returned. 3190d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 3200d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 3210d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 3220d1ba665SWarner Losh 3230d1ba665SWarner Losh If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. 3240d1ba665SWarner Losh 3250d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 3260d1ba665SWarner Losh Unicode string. 3270d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 3280d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 3290d1ba665SWarner Losh @param ... Variable argument list whose contents are accessed based on the 3300d1ba665SWarner Losh format string specified by FormatString. 3310d1ba665SWarner Losh 3320d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 3330d1ba665SWarner Losh Null-terminator. 3340d1ba665SWarner Losh 3350d1ba665SWarner Losh **/ 3360d1ba665SWarner Losh UINTN 3370d1ba665SWarner Losh EFIAPI 3380d1ba665SWarner Losh UnicodeSPrint ( 3390d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 3400d1ba665SWarner Losh IN UINTN BufferSize, 3410d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 3420d1ba665SWarner Losh ... 3430d1ba665SWarner Losh ); 3440d1ba665SWarner Losh 3450d1ba665SWarner Losh /** 3460d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 3470d1ba665SWarner Losh ASCII format string and a VA_LIST argument list. 3480d1ba665SWarner Losh 3490d1ba665SWarner Losh This function is similar as vsnprintf_s defined in C11. 3500d1ba665SWarner Losh 3510d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 3520d1ba665SWarner Losh and BufferSize. 3530d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 3540d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on the 3550d1ba665SWarner Losh contents of the format string. 3560d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 3570d1ba665SWarner Losh the Null-terminator. 3580d1ba665SWarner Losh 3590d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 3600d1ba665SWarner Losh 3610d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 3620d1ba665SWarner Losh unmodified and 0 is returned. 3630d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 3640d1ba665SWarner Losh unmodified and 0 is returned. 3650d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 3660d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 3670d1ba665SWarner Losh buffer is unmodified and 0 is returned. 3680d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 3690d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 3700d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 3710d1ba665SWarner Losh 3720d1ba665SWarner Losh If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 3730d1ba665SWarner Losh 3740d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 3750d1ba665SWarner Losh Unicode string. 3760d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 3770d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 3780d1ba665SWarner Losh @param Marker VA_LIST marker for the variable argument list. 3790d1ba665SWarner Losh 3800d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 3810d1ba665SWarner Losh Null-terminator. 3820d1ba665SWarner Losh 3830d1ba665SWarner Losh **/ 3840d1ba665SWarner Losh UINTN 3850d1ba665SWarner Losh EFIAPI 3860d1ba665SWarner Losh UnicodeVSPrintAsciiFormat ( 3870d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 3880d1ba665SWarner Losh IN UINTN BufferSize, 3890d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 3900d1ba665SWarner Losh IN VA_LIST Marker 3910d1ba665SWarner Losh ); 3920d1ba665SWarner Losh 3930d1ba665SWarner Losh /** 3940d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 3950d1ba665SWarner Losh ASCII format string and a BASE_LIST argument list. 3960d1ba665SWarner Losh 3970d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 3980d1ba665SWarner Losh and BufferSize. 3990d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 4000d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on the 4010d1ba665SWarner Losh contents of the format string. 4020d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 4030d1ba665SWarner Losh the Null-terminator. 4040d1ba665SWarner Losh 4050d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 4060d1ba665SWarner Losh 4070d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 4080d1ba665SWarner Losh unmodified and 0 is returned. 4090d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 4100d1ba665SWarner Losh unmodified and 0 is returned. 4110d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 4120d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 4130d1ba665SWarner Losh buffer is unmodified and 0 is returned. 4140d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 4150d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 4160d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 4170d1ba665SWarner Losh 4180d1ba665SWarner Losh If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 4190d1ba665SWarner Losh 4200d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 4210d1ba665SWarner Losh Unicode string. 4220d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 4230d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 4240d1ba665SWarner Losh @param Marker BASE_LIST marker for the variable argument list. 4250d1ba665SWarner Losh 4260d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 4270d1ba665SWarner Losh Null-terminator. 4280d1ba665SWarner Losh 4290d1ba665SWarner Losh **/ 4300d1ba665SWarner Losh UINTN 4310d1ba665SWarner Losh EFIAPI 4320d1ba665SWarner Losh UnicodeBSPrintAsciiFormat ( 4330d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 4340d1ba665SWarner Losh IN UINTN BufferSize, 4350d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 4360d1ba665SWarner Losh IN BASE_LIST Marker 4370d1ba665SWarner Losh ); 4380d1ba665SWarner Losh 4390d1ba665SWarner Losh /** 4400d1ba665SWarner Losh Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated 4410d1ba665SWarner Losh ASCII format string and variable argument list. 4420d1ba665SWarner Losh 4430d1ba665SWarner Losh This function is similar as snprintf_s defined in C11. 4440d1ba665SWarner Losh 4450d1ba665SWarner Losh Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer 4460d1ba665SWarner Losh and BufferSize. 4470d1ba665SWarner Losh The Unicode string is produced by parsing the format string specified by FormatString. 4480d1ba665SWarner Losh Arguments are pulled from the variable argument list based on the contents of the 4490d1ba665SWarner Losh format string. 4500d1ba665SWarner Losh The number of Unicode characters in the produced output buffer is returned not including 4510d1ba665SWarner Losh the Null-terminator. 4520d1ba665SWarner Losh 4530d1ba665SWarner Losh If StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). 4540d1ba665SWarner Losh 4550d1ba665SWarner Losh If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 4560d1ba665SWarner Losh unmodified and 0 is returned. 4570d1ba665SWarner Losh If BufferSize > 1 and FormatString is NULL, then ASSERT(). Also, the output buffer is 4580d1ba665SWarner Losh unmodified and 0 is returned. 4590d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and BufferSize > 4600d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * sizeof (CHAR16) + 1), then ASSERT(). Also, the output 4610d1ba665SWarner Losh buffer is unmodified and 0 is returned. 4620d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 4630d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 4640d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 4650d1ba665SWarner Losh 4660d1ba665SWarner Losh If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. 4670d1ba665SWarner Losh 4680d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 4690d1ba665SWarner Losh Unicode string. 4700d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 4710d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 4720d1ba665SWarner Losh @param ... Variable argument list whose contents are accessed based on the 4730d1ba665SWarner Losh format string specified by FormatString. 4740d1ba665SWarner Losh 4750d1ba665SWarner Losh @return The number of Unicode characters in the produced output buffer not including the 4760d1ba665SWarner Losh Null-terminator. 4770d1ba665SWarner Losh 4780d1ba665SWarner Losh **/ 4790d1ba665SWarner Losh UINTN 4800d1ba665SWarner Losh EFIAPI 4810d1ba665SWarner Losh UnicodeSPrintAsciiFormat ( 4820d1ba665SWarner Losh OUT CHAR16 *StartOfBuffer, 4830d1ba665SWarner Losh IN UINTN BufferSize, 4840d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 4850d1ba665SWarner Losh ... 4860d1ba665SWarner Losh ); 4870d1ba665SWarner Losh 4880d1ba665SWarner Losh /** 4890d1ba665SWarner Losh Converts a decimal value to a Null-terminated Unicode string. 4900d1ba665SWarner Losh 4910d1ba665SWarner Losh Converts the decimal number specified by Value to a Null-terminated Unicode 4920d1ba665SWarner Losh string specified by Buffer containing at most Width characters. No padding of 4930d1ba665SWarner Losh spaces is ever performed. If Width is 0 then a width of 4940d1ba665SWarner Losh MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 4950d1ba665SWarner Losh Width characters, then only the first Width characters are placed in Buffer. 4960d1ba665SWarner Losh Additional conversion parameters are specified in Flags. 4970d1ba665SWarner Losh 4980d1ba665SWarner Losh The Flags bit LEFT_JUSTIFY is always ignored. 4990d1ba665SWarner Losh All conversions are left justified in Buffer. 5000d1ba665SWarner Losh If Width is 0, PREFIX_ZERO is ignored in Flags. 5010d1ba665SWarner Losh If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 5020d1ba665SWarner Losh commas are inserted every 3rd digit starting from the right. 5030d1ba665SWarner Losh If RADIX_HEX is set in Flags, then the output buffer will be formatted in 5040d1ba665SWarner Losh hexadecimal format. 5050d1ba665SWarner Losh If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 5060d1ba665SWarner Losh Buffer is a '-'. 5070d1ba665SWarner Losh If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 5080d1ba665SWarner Losh Buffer is padded with '0' characters so the combination of the optional '-' 5090d1ba665SWarner Losh sign character, '0' characters, digit characters for Value, and the 5100d1ba665SWarner Losh Null-terminator add up to Width characters. 5110d1ba665SWarner Losh 5120d1ba665SWarner Losh If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 5130d1ba665SWarner Losh If an error would be returned, then the function will also ASSERT(). 5140d1ba665SWarner Losh 5150d1ba665SWarner Losh @param Buffer The pointer to the output buffer for the produced 5160d1ba665SWarner Losh Null-terminated Unicode string. 5170d1ba665SWarner Losh @param BufferSize The size of Buffer in bytes, including the 5180d1ba665SWarner Losh Null-terminator. 5190d1ba665SWarner Losh @param Flags The bitmask of flags that specify left justification, 5200d1ba665SWarner Losh zero pad, and commas. 5210d1ba665SWarner Losh @param Value The 64-bit signed value to convert to a string. 5220d1ba665SWarner Losh @param Width The maximum number of Unicode characters to place in 5230d1ba665SWarner Losh Buffer, not including the Null-terminator. 5240d1ba665SWarner Losh 5250d1ba665SWarner Losh @retval RETURN_SUCCESS The decimal value is converted. 5260d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 5270d1ba665SWarner Losh value. 5280d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 5290d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not 5300d1ba665SWarner Losh zero, and BufferSize is greater than 5310d1ba665SWarner Losh (PcdMaximumUnicodeStringLength * 5320d1ba665SWarner Losh sizeof (CHAR16) + 1). 5330d1ba665SWarner Losh If unsupported bits are set in Flags. 5340d1ba665SWarner Losh If both COMMA_TYPE and RADIX_HEX are set in 5350d1ba665SWarner Losh Flags. 5360d1ba665SWarner Losh If Width >= MAXIMUM_VALUE_CHARACTERS. 5370d1ba665SWarner Losh 5380d1ba665SWarner Losh **/ 5390d1ba665SWarner Losh RETURN_STATUS 5400d1ba665SWarner Losh EFIAPI 5410d1ba665SWarner Losh UnicodeValueToStringS ( 5420d1ba665SWarner Losh IN OUT CHAR16 *Buffer, 5430d1ba665SWarner Losh IN UINTN BufferSize, 5440d1ba665SWarner Losh IN UINTN Flags, 5450d1ba665SWarner Losh IN INT64 Value, 5460d1ba665SWarner Losh IN UINTN Width 5470d1ba665SWarner Losh ); 5480d1ba665SWarner Losh 5490d1ba665SWarner Losh /** 5500d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 5510d1ba665SWarner Losh ASCII format string and a VA_LIST argument list. 5520d1ba665SWarner Losh 5530d1ba665SWarner Losh This function is similar as vsnprintf_s defined in C11. 5540d1ba665SWarner Losh 5550d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 5560d1ba665SWarner Losh and BufferSize. 5570d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 5580d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on 5590d1ba665SWarner Losh the contents of the format string. 5600d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 5610d1ba665SWarner Losh the Null-terminator. 5620d1ba665SWarner Losh 5630d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 5640d1ba665SWarner Losh unmodified and 0 is returned. 5650d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 5660d1ba665SWarner Losh unmodified and 0 is returned. 5670d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 5680d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 5690d1ba665SWarner Losh is unmodified and 0 is returned. 5700d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 5710d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 5720d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 5730d1ba665SWarner Losh 5740d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 5750d1ba665SWarner Losh 5760d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 5770d1ba665SWarner Losh ASCII string. 5780d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 5790d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 5800d1ba665SWarner Losh @param Marker VA_LIST marker for the variable argument list. 5810d1ba665SWarner Losh 5820d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 5830d1ba665SWarner Losh Null-terminator. 5840d1ba665SWarner Losh 5850d1ba665SWarner Losh **/ 5860d1ba665SWarner Losh UINTN 5870d1ba665SWarner Losh EFIAPI 5880d1ba665SWarner Losh AsciiVSPrint ( 5890d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 5900d1ba665SWarner Losh IN UINTN BufferSize, 5910d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 5920d1ba665SWarner Losh IN VA_LIST Marker 5930d1ba665SWarner Losh ); 5940d1ba665SWarner Losh 5950d1ba665SWarner Losh /** 5960d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 5970d1ba665SWarner Losh ASCII format string and a BASE_LIST argument list. 5980d1ba665SWarner Losh 5990d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 6000d1ba665SWarner Losh and BufferSize. 6010d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 6020d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on 6030d1ba665SWarner Losh the contents of the format string. 6040d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 6050d1ba665SWarner Losh the Null-terminator. 6060d1ba665SWarner Losh 6070d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 6080d1ba665SWarner Losh unmodified and 0 is returned. 6090d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 6100d1ba665SWarner Losh unmodified and 0 is returned. 6110d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 6120d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 6130d1ba665SWarner Losh is unmodified and 0 is returned. 6140d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 6150d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 6160d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 6170d1ba665SWarner Losh 6180d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 6190d1ba665SWarner Losh 6200d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 6210d1ba665SWarner Losh ASCII string. 6220d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 6230d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 6240d1ba665SWarner Losh @param Marker BASE_LIST marker for the variable argument list. 6250d1ba665SWarner Losh 6260d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 6270d1ba665SWarner Losh Null-terminator. 6280d1ba665SWarner Losh 6290d1ba665SWarner Losh **/ 6300d1ba665SWarner Losh UINTN 6310d1ba665SWarner Losh EFIAPI 6320d1ba665SWarner Losh AsciiBSPrint ( 6330d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 6340d1ba665SWarner Losh IN UINTN BufferSize, 6350d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 6360d1ba665SWarner Losh IN BASE_LIST Marker 6370d1ba665SWarner Losh ); 6380d1ba665SWarner Losh 6390d1ba665SWarner Losh /** 6400d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 6410d1ba665SWarner Losh ASCII format string and variable argument list. 6420d1ba665SWarner Losh 6430d1ba665SWarner Losh This function is similar as snprintf_s defined in C11. 6440d1ba665SWarner Losh 6450d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 6460d1ba665SWarner Losh and BufferSize. 6470d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 6480d1ba665SWarner Losh Arguments are pulled from the variable argument list based on the contents of the 6490d1ba665SWarner Losh format string. 6500d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 6510d1ba665SWarner Losh the Null-terminator. 6520d1ba665SWarner Losh 6530d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 6540d1ba665SWarner Losh unmodified and 0 is returned. 6550d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 6560d1ba665SWarner Losh unmodified and 0 is returned. 6570d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 6580d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 6590d1ba665SWarner Losh is unmodified and 0 is returned. 6600d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than 6610d1ba665SWarner Losh PcdMaximumAsciiStringLength Ascii characters not including the Null-terminator, then 6620d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 6630d1ba665SWarner Losh 6640d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 6650d1ba665SWarner Losh 6660d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 6670d1ba665SWarner Losh ASCII string. 6680d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 6690d1ba665SWarner Losh @param FormatString A Null-terminated ASCII format string. 6700d1ba665SWarner Losh @param ... Variable argument list whose contents are accessed based on the 6710d1ba665SWarner Losh format string specified by FormatString. 6720d1ba665SWarner Losh 6730d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 6740d1ba665SWarner Losh Null-terminator. 6750d1ba665SWarner Losh 6760d1ba665SWarner Losh **/ 6770d1ba665SWarner Losh UINTN 6780d1ba665SWarner Losh EFIAPI 6790d1ba665SWarner Losh AsciiSPrint ( 6800d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 6810d1ba665SWarner Losh IN UINTN BufferSize, 6820d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 6830d1ba665SWarner Losh ... 6840d1ba665SWarner Losh ); 6850d1ba665SWarner Losh 6860d1ba665SWarner Losh /** 6870d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 6880d1ba665SWarner Losh Unicode format string and a VA_LIST argument list. 6890d1ba665SWarner Losh 6900d1ba665SWarner Losh This function is similar as vsnprintf_s defined in C11. 6910d1ba665SWarner Losh 6920d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 6930d1ba665SWarner Losh and BufferSize. 6940d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 6950d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on 6960d1ba665SWarner Losh the contents of the format string. 6970d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 6980d1ba665SWarner Losh the Null-terminator. 6990d1ba665SWarner Losh 7000d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 7010d1ba665SWarner Losh 7020d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 7030d1ba665SWarner Losh unmodified and 0 is returned. 7040d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 7050d1ba665SWarner Losh unmodified and 0 is returned. 7060d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 7070d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 7080d1ba665SWarner Losh is unmodified and 0 is returned. 7090d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 7100d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 7110d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 7120d1ba665SWarner Losh 7130d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 7140d1ba665SWarner Losh 7150d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 7160d1ba665SWarner Losh ASCII string. 7170d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 7180d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 7190d1ba665SWarner Losh @param Marker VA_LIST marker for the variable argument list. 7200d1ba665SWarner Losh 7210d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 7220d1ba665SWarner Losh Null-terminator. 7230d1ba665SWarner Losh 7240d1ba665SWarner Losh **/ 7250d1ba665SWarner Losh UINTN 7260d1ba665SWarner Losh EFIAPI 7270d1ba665SWarner Losh AsciiVSPrintUnicodeFormat ( 7280d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 7290d1ba665SWarner Losh IN UINTN BufferSize, 7300d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 7310d1ba665SWarner Losh IN VA_LIST Marker 7320d1ba665SWarner Losh ); 7330d1ba665SWarner Losh 7340d1ba665SWarner Losh /** 7350d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 7360d1ba665SWarner Losh Unicode format string and a BASE_LIST argument list. 7370d1ba665SWarner Losh 7380d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 7390d1ba665SWarner Losh and BufferSize. 7400d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 7410d1ba665SWarner Losh Arguments are pulled from the variable argument list specified by Marker based on 7420d1ba665SWarner Losh the contents of the format string. 7430d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 7440d1ba665SWarner Losh the Null-terminator. 7450d1ba665SWarner Losh 7460d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 7470d1ba665SWarner Losh 7480d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 7490d1ba665SWarner Losh unmodified and 0 is returned. 7500d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 7510d1ba665SWarner Losh unmodified and 0 is returned. 7520d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 7530d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 7540d1ba665SWarner Losh is unmodified and 0 is returned. 7550d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 7560d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 7570d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 7580d1ba665SWarner Losh 7590d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 7600d1ba665SWarner Losh 7610d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 7620d1ba665SWarner Losh ASCII string. 7630d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 7640d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 7650d1ba665SWarner Losh @param Marker BASE_LIST marker for the variable argument list. 7660d1ba665SWarner Losh 7670d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 7680d1ba665SWarner Losh Null-terminator. 7690d1ba665SWarner Losh 7700d1ba665SWarner Losh **/ 7710d1ba665SWarner Losh UINTN 7720d1ba665SWarner Losh EFIAPI 7730d1ba665SWarner Losh AsciiBSPrintUnicodeFormat ( 7740d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 7750d1ba665SWarner Losh IN UINTN BufferSize, 7760d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 7770d1ba665SWarner Losh IN BASE_LIST Marker 7780d1ba665SWarner Losh ); 7790d1ba665SWarner Losh 7800d1ba665SWarner Losh /** 7810d1ba665SWarner Losh Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated 7820d1ba665SWarner Losh Unicode format string and variable argument list. 7830d1ba665SWarner Losh 7840d1ba665SWarner Losh This function is similar as snprintf_s defined in C11. 7850d1ba665SWarner Losh 7860d1ba665SWarner Losh Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer 7870d1ba665SWarner Losh and BufferSize. 7880d1ba665SWarner Losh The ASCII string is produced by parsing the format string specified by FormatString. 7890d1ba665SWarner Losh Arguments are pulled from the variable argument list based on the contents of the 7900d1ba665SWarner Losh format string. 7910d1ba665SWarner Losh The number of ASCII characters in the produced output buffer is returned not including 7920d1ba665SWarner Losh the Null-terminator. 7930d1ba665SWarner Losh 7940d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 7950d1ba665SWarner Losh 7960d1ba665SWarner Losh If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). Also, the output buffer is 7970d1ba665SWarner Losh unmodified and 0 is returned. 7980d1ba665SWarner Losh If BufferSize > 0 and FormatString is NULL, then ASSERT(). Also, the output buffer is 7990d1ba665SWarner Losh unmodified and 0 is returned. 8000d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and BufferSize > 8010d1ba665SWarner Losh (PcdMaximumAsciiStringLength * sizeof (CHAR8)), then ASSERT(). Also, the output buffer 8020d1ba665SWarner Losh is unmodified and 0 is returned. 8030d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than 8040d1ba665SWarner Losh PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then 8050d1ba665SWarner Losh ASSERT(). Also, the output buffer is unmodified and 0 is returned. 8060d1ba665SWarner Losh 8070d1ba665SWarner Losh If BufferSize is 0, then no output buffer is produced and 0 is returned. 8080d1ba665SWarner Losh 8090d1ba665SWarner Losh @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated 8100d1ba665SWarner Losh ASCII string. 8110d1ba665SWarner Losh @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. 8120d1ba665SWarner Losh @param FormatString A Null-terminated Unicode format string. 8130d1ba665SWarner Losh @param ... Variable argument list whose contents are accessed based on the 8140d1ba665SWarner Losh format string specified by FormatString. 8150d1ba665SWarner Losh 8160d1ba665SWarner Losh @return The number of ASCII characters in the produced output buffer not including the 8170d1ba665SWarner Losh Null-terminator. 8180d1ba665SWarner Losh 8190d1ba665SWarner Losh **/ 8200d1ba665SWarner Losh UINTN 8210d1ba665SWarner Losh EFIAPI 8220d1ba665SWarner Losh AsciiSPrintUnicodeFormat ( 8230d1ba665SWarner Losh OUT CHAR8 *StartOfBuffer, 8240d1ba665SWarner Losh IN UINTN BufferSize, 8250d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 8260d1ba665SWarner Losh ... 8270d1ba665SWarner Losh ); 8280d1ba665SWarner Losh 8290d1ba665SWarner Losh /** 8300d1ba665SWarner Losh Converts a decimal value to a Null-terminated Ascii string. 8310d1ba665SWarner Losh 8320d1ba665SWarner Losh Converts the decimal number specified by Value to a Null-terminated Ascii 8330d1ba665SWarner Losh string specified by Buffer containing at most Width characters. No padding of 8340d1ba665SWarner Losh spaces is ever performed. If Width is 0 then a width of 8350d1ba665SWarner Losh MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more than 8360d1ba665SWarner Losh Width characters, then only the first Width characters are placed in Buffer. 8370d1ba665SWarner Losh Additional conversion parameters are specified in Flags. 8380d1ba665SWarner Losh 8390d1ba665SWarner Losh The Flags bit LEFT_JUSTIFY is always ignored. 8400d1ba665SWarner Losh All conversions are left justified in Buffer. 8410d1ba665SWarner Losh If Width is 0, PREFIX_ZERO is ignored in Flags. 8420d1ba665SWarner Losh If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and 8430d1ba665SWarner Losh commas are inserted every 3rd digit starting from the right. 8440d1ba665SWarner Losh If RADIX_HEX is set in Flags, then the output buffer will be formatted in 8450d1ba665SWarner Losh hexadecimal format. 8460d1ba665SWarner Losh If Value is < 0 and RADIX_HEX is not set in Flags, then the fist character in 8470d1ba665SWarner Losh Buffer is a '-'. 8480d1ba665SWarner Losh If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then 8490d1ba665SWarner Losh Buffer is padded with '0' characters so the combination of the optional '-' 8500d1ba665SWarner Losh sign character, '0' characters, digit characters for Value, and the 8510d1ba665SWarner Losh Null-terminator add up to Width characters. 8520d1ba665SWarner Losh 853*3245fa21SMitchell Horne If an error would be returned, then the function will ASSERT(). 8540d1ba665SWarner Losh 8550d1ba665SWarner Losh @param Buffer The pointer to the output buffer for the produced 8560d1ba665SWarner Losh Null-terminated Ascii string. 8570d1ba665SWarner Losh @param BufferSize The size of Buffer in bytes, including the 8580d1ba665SWarner Losh Null-terminator. 8590d1ba665SWarner Losh @param Flags The bitmask of flags that specify left justification, 8600d1ba665SWarner Losh zero pad, and commas. 8610d1ba665SWarner Losh @param Value The 64-bit signed value to convert to a string. 8620d1ba665SWarner Losh @param Width The maximum number of Ascii characters to place in 8630d1ba665SWarner Losh Buffer, not including the Null-terminator. 8640d1ba665SWarner Losh 8650d1ba665SWarner Losh @retval RETURN_SUCCESS The decimal value is converted. 8660d1ba665SWarner Losh @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted 8670d1ba665SWarner Losh value. 8680d1ba665SWarner Losh @retval RETURN_INVALID_PARAMETER If Buffer is NULL. 8690d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not 8700d1ba665SWarner Losh zero, and BufferSize is greater than 8710d1ba665SWarner Losh PcdMaximumAsciiStringLength. 8720d1ba665SWarner Losh If unsupported bits are set in Flags. 8730d1ba665SWarner Losh If both COMMA_TYPE and RADIX_HEX are set in 8740d1ba665SWarner Losh Flags. 8750d1ba665SWarner Losh If Width >= MAXIMUM_VALUE_CHARACTERS. 8760d1ba665SWarner Losh 8770d1ba665SWarner Losh **/ 8780d1ba665SWarner Losh RETURN_STATUS 8790d1ba665SWarner Losh EFIAPI 8800d1ba665SWarner Losh AsciiValueToStringS ( 8810d1ba665SWarner Losh IN OUT CHAR8 *Buffer, 8820d1ba665SWarner Losh IN UINTN BufferSize, 8830d1ba665SWarner Losh IN UINTN Flags, 8840d1ba665SWarner Losh IN INT64 Value, 8850d1ba665SWarner Losh IN UINTN Width 8860d1ba665SWarner Losh ); 8870d1ba665SWarner Losh 8880d1ba665SWarner Losh /** 8890d1ba665SWarner Losh Returns the number of characters that would be produced by if the formatted 8900d1ba665SWarner Losh output were produced not including the Null-terminator. 8910d1ba665SWarner Losh 8920d1ba665SWarner Losh If FormatString is not aligned on a 16-bit boundary, then ASSERT(). 8930d1ba665SWarner Losh 8940d1ba665SWarner Losh If FormatString is NULL, then ASSERT() and 0 is returned. 8950d1ba665SWarner Losh If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more 8960d1ba665SWarner Losh than PcdMaximumUnicodeStringLength Unicode characters not including the 8970d1ba665SWarner Losh Null-terminator, then ASSERT() and 0 is returned. 8980d1ba665SWarner Losh 8990d1ba665SWarner Losh @param[in] FormatString A Null-terminated Unicode format string. 9000d1ba665SWarner Losh @param[in] Marker VA_LIST marker for the variable argument list. 9010d1ba665SWarner Losh 9020d1ba665SWarner Losh @return The number of characters that would be produced, not including the 9030d1ba665SWarner Losh Null-terminator. 9040d1ba665SWarner Losh **/ 9050d1ba665SWarner Losh UINTN 9060d1ba665SWarner Losh EFIAPI 9070d1ba665SWarner Losh SPrintLength ( 9080d1ba665SWarner Losh IN CONST CHAR16 *FormatString, 9090d1ba665SWarner Losh IN VA_LIST Marker 9100d1ba665SWarner Losh ); 9110d1ba665SWarner Losh 9120d1ba665SWarner Losh /** 9130d1ba665SWarner Losh Returns the number of characters that would be produced by if the formatted 9140d1ba665SWarner Losh output were produced not including the Null-terminator. 9150d1ba665SWarner Losh 9160d1ba665SWarner Losh If FormatString is NULL, then ASSERT() and 0 is returned. 9170d1ba665SWarner Losh If PcdMaximumAsciiStringLength is not zero, and FormatString contains more 9180d1ba665SWarner Losh than PcdMaximumAsciiStringLength Ascii characters not including the 9190d1ba665SWarner Losh Null-terminator, then ASSERT() and 0 is returned. 9200d1ba665SWarner Losh 9210d1ba665SWarner Losh @param[in] FormatString A Null-terminated ASCII format string. 9220d1ba665SWarner Losh @param[in] Marker VA_LIST marker for the variable argument list. 9230d1ba665SWarner Losh 9240d1ba665SWarner Losh @return The number of characters that would be produced, not including the 9250d1ba665SWarner Losh Null-terminator. 9260d1ba665SWarner Losh **/ 9270d1ba665SWarner Losh UINTN 9280d1ba665SWarner Losh EFIAPI 9290d1ba665SWarner Losh SPrintLengthAsciiFormat ( 9300d1ba665SWarner Losh IN CONST CHAR8 *FormatString, 9310d1ba665SWarner Losh IN VA_LIST Marker 9320d1ba665SWarner Losh ); 9330d1ba665SWarner Losh 9340d1ba665SWarner Losh #endif 935