]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Graphics / Ascii / Sprint.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 Sprint.c\r
15\r
16Abstract:\r
17\r
18 Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
19 simple implemenation of SPrint() and Print() to support debug. \r
20\r
21 You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
22 time. This makes the implementation very simple.\r
23\r
24 VSPrint, Print, SPrint format specification has the follwoing form\r
25\r
26 %[flags][width]type\r
27\r
28 flags:\r
29 '-' - Left justify\r
30 '+' - Prefix a sign\r
31 ' ' - Prefix a blank\r
32 ',' - Place commas in numberss\r
33 '0' - Prefix for width with zeros\r
34 'l' - UINT64\r
35 'L' - UINT64\r
36\r
37 width:\r
38 '*' - Get width from a UINTN argumnet from the argument list\r
39 Decimal number that represents width of print\r
40\r
41 type:\r
42 'X' - argument is a UINTN hex number, prefix '0'\r
43 'x' - argument is a hex number\r
44 'd' - argument is a decimal number\r
45 'a' - argument is an ascii string \r
46 'S','s' - argument is an Unicode string\r
47 'g' - argument is a pointer to an EFI_GUID\r
48 't' - argument is a pointer to an EFI_TIME structure\r
49 'c' - argument is an ascii character\r
50 'r' - argument is EFI_STATUS\r
51 '%' - Print a %\r
52\r
53--*/\r
54\r
55#include "TianoCommon.h"\r
56#include "PrintWidth.h"\r
57#include "EfiPrintLib.h"\r
58#include "Print.h"\r
59\r
60\r
61UINTN\r
62USPrint (\r
63 OUT CHAR16 *Buffer,\r
64 IN UINTN BufferSize,\r
65 IN CONST CHAR16 *Format,\r
66 ...\r
67 )\r
68/*++\r
69\r
70Routine Description:\r
71\r
72 Process format and place the results in Buffer for wide chars.\r
73\r
74Arguments:\r
75\r
76 Buffer - Wide char buffer to print the results of the parsing of Format into.\r
77 BufferSize - Maximum number of characters to put into buffer.\r
78 Format - Format string\r
79 ... - Vararg list consumed by processing Format.\r
80\r
81Returns:\r
82\r
83 Number of characters printed.\r
84\r
85--*/\r
86{\r
87 UINTN Return;\r
88 VA_LIST Marker;\r
89\r
90 VA_START (Marker, Format);\r
91 Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
92 VA_END (Marker);\r
93\r
94 return Return;\r
95}\r
96\r
97\r
98UINTN\r
99UvSPrint (\r
100 OUT CHAR16 *Buffer,\r
101 IN UINTN BufferSize,\r
102 IN CONST CHAR16 *FormatString,\r
103 IN VA_LIST Marker\r
104 )\r
105/*++\r
106\r
107Routine Description:\r
108\r
109 Internal implementation of USPrint. \r
110 Process format and place the results in Buffer for wide chars.\r
111\r
112Arguments:\r
113\r
114 Buffer - Wide char buffer to print the results of the parsing of Format into.\r
115 BufferSize - Maximum number of characters to put into buffer.\r
116 FormatString - Format string\r
117 Marker - Vararg list consumed by processing Format.\r
118\r
119Returns:\r
120\r
121 Number of characters printed.\r
122\r
123--*/\r
124{\r
125 UINTN Index;\r
126 CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
127 CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
128\r
129 for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
130 AsciiFormat[Index] = (CHAR8) FormatString[Index];\r
131 }\r
132\r
133 AsciiFormat[Index] = '\0';\r
134\r
135 Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r
136\r
137 for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r
138 Buffer[Index] = (CHAR16) AsciiResult[Index];\r
139 }\r
140\r
141 Buffer[Index] = '\0';\r
142\r
143 return Index++;\r
144}\r