EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Ascii/SPrint.c

Go to the documentation of this file.
00001 /*++
00002 
00003 Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
00004 This program and the accompanying materials                          
00005 are licensed and made available under the terms and conditions of the BSD License         
00006 which accompanies this distribution.  The full text of the license may be found at        
00007 http://opensource.org/licenses/bsd-license.php                                            
00008                                                                                           
00009 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
00010 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
00011 
00012 Module Name:
00013 
00014   Sprint.c
00015 
00016 Abstract:
00017 
00018   Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
00019   simple implemenation of SPrint() and Print() to support debug. 
00020 
00021   You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a 
00022   time. This makes the implementation very simple.
00023 
00024   VSPrint, Print, SPrint format specification has the follwoing form
00025 
00026   %[flags][width]type
00027 
00028   flags:
00029     '-' - Left justify
00030     '+' - Prefix a sign
00031     ' ' - Prefix a blank
00032     ',' - Place commas in numberss
00033     '0' - Prefix for width with zeros
00034     'l' - UINT64
00035     'L' - UINT64
00036 
00037   width:
00038     '*' - Get width from a UINTN argumnet from the argument list
00039     Decimal number that represents width of print
00040 
00041   type:
00042     'X' - argument is a UINTN hex number, prefix '0'
00043     'x' - argument is a hex number
00044     'd' - argument is a decimal number
00045     'a' - argument is an ascii string 
00046     'S','s' - argument is an Unicode string
00047     'g' - argument is a pointer to an EFI_GUID
00048     't' - argument is a pointer to an EFI_TIME structure
00049     'c' - argument is an ascii character
00050     'r' - argument is EFI_STATUS
00051     '%' - Print a %
00052 
00053 --*/
00054 
00055 #include "TianoCommon.h"
00056 #include "PrintWidth.h"
00057 #include "EfiPrintLib.h"
00058 #include "Print.h"
00059 
00060 UINTN
00061 USPrint (
00062   OUT CHAR16        *Buffer,
00063   IN  UINTN         BufferSize,
00064   IN  CONST CHAR16  *Format,
00065   ...
00066   )
00067 /*++
00068 
00069 Routine Description:
00070 
00071   Process format and place the results in Buffer for wide chars.
00072 
00073 Arguments:
00074 
00075   Buffer      - Wide char buffer to print the results of the parsing of Format into.
00076   BufferSize  - Maximum number of characters to put into buffer.
00077   Format      - Format string
00078   ...         - Vararg list consumed by processing Format.
00079 
00080 Returns:
00081 
00082   Number of characters printed.
00083 
00084 --*/
00085 {
00086   UINTN   Return;
00087   VA_LIST Marker;
00088 
00089   VA_START (Marker, Format);
00090   Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
00091   VA_END (Marker);
00092 
00093   return Return;
00094 }
00095 
00096 UINTN
00097 UvSPrint (
00098   OUT CHAR16        *Buffer,
00099   IN  UINTN         BufferSize,
00100   IN  CONST CHAR16  *FormatString,
00101   IN  VA_LIST       Marker
00102   )
00103 /*++
00104 
00105 Routine Description:
00106 
00107   Internal implementation of USPrint. 
00108   Process format and place the results in Buffer for wide chars.
00109 
00110 Arguments:
00111 
00112   Buffer        - Wide char buffer to print the results of the parsing of Format into.
00113   BufferSize    - Maximum number of characters to put into buffer.
00114   FormatString  - Format string
00115   Marker        - Vararg list consumed by processing Format.
00116 
00117 Returns:
00118 
00119   Number of characters printed.
00120 
00121 --*/
00122 {
00123   UINTN Index;
00124   CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
00125   CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
00126 
00127   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
00128     AsciiFormat[Index] = (CHAR8) FormatString[Index];
00129   }
00130 
00131   AsciiFormat[Index]  = '\0';
00132 
00133   Index               = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);
00134 
00135   for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {
00136     Buffer[Index] = (CHAR16) AsciiResult[Index];
00137   }
00138 
00139   Buffer[Index] = '\0';
00140 
00141   return Index++;
00142 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines