+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- Sprint.c\r
-\r
-Abstract:\r
-\r
- Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
- simple implemenation of SPrint() and Print() to support debug. \r
-\r
- You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
- time. This makes the implementation very simple.\r
-\r
- VSPrint, Print, SPrint format specification has the follwoing form\r
-\r
- %[flags][width]type\r
-\r
- flags:\r
- '-' - Left justify\r
- '+' - Prefix a sign\r
- ' ' - Prefix a blank\r
- ',' - Place commas in numberss\r
- '0' - Prefix for width with zeros\r
- 'l' - UINT64\r
- 'L' - UINT64\r
-\r
- width:\r
- '*' - Get width from a UINTN argumnet from the argument list\r
- Decimal number that represents width of print\r
-\r
- type:\r
- 'X' - argument is a UINTN hex number, prefix '0'\r
- 'x' - argument is a hex number\r
- 'd' - argument is a decimal number\r
- 'a' - argument is an ascii string \r
- 'S','s' - argument is an Unicode string\r
- 'g' - argument is a pointer to an EFI_GUID\r
- 't' - argument is a pointer to an EFI_TIME structure\r
- 'c' - argument is an ascii character\r
- 'r' - argument is EFI_STATUS\r
- '%' - Print a %\r
-\r
---*/\r
-\r
-#include "TianoCommon.h"\r
-#include "PrintWidth.h"\r
-#include "EfiPrintLib.h"\r
-#include "Print.h"\r
-\r
-\r
-UINTN\r
-ASPrint (\r
- OUT CHAR8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN CONST CHAR8 *Format,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Process format and place the results in Buffer for narrow chars.\r
-\r
-Arguments:\r
-\r
- Buffer - Narrow char buffer to print the results of the parsing of Format into.\r
- BufferSize - Maximum number of characters to put into buffer.\r
- Format - Format string\r
- ... - Vararg list consumed by processing Format.\r
-\r
-Returns:\r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Return;\r
- VA_LIST Marker;\r
-\r
- VA_START (Marker, Format);\r
- Return = AvSPrint (Buffer, BufferSize, Format, Marker);\r
- VA_END (Marker);\r
-\r
- return Return;\r
-}\r
-\r
-\r
-UINTN\r
-AvSPrint (\r
- OUT CHAR8 *Buffer,\r
- IN UINTN BufferSize,\r
- IN CONST CHAR8 *FormatString,\r
- IN VA_LIST Marker\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Internal implementation of ASPrint. \r
- Process format and place the results in Buffer for narrow chars.\r
-\r
-Arguments:\r
-\r
- Buffer - Narrow char buffer to print the results of the parsing of Format into.\r
- BufferSize - Maximum number of characters to put into buffer.\r
- FormatString - Format string\r
- Marker - Vararg list consumed by processing Format.\r
-\r
-Returns:\r
-\r
- Number of characters printed.\r
-\r
---*/\r
-{\r
- UINTN Index;\r
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
- CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
-\r
- for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
- UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
- }\r
-\r
- UnicodeFormat[Index] = '\0';\r
-\r
- Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
-\r
- for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
- Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
- }\r
-\r
- Buffer[Index] = '\0';\r
-\r
- return Index++;\r
-}\r