]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Sprint.c\r | |
15 | \r | |
16 | Abstract:\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 | UINTN\r | |
61 | USPrint (\r | |
62 | OUT CHAR16 *Buffer,\r | |
63 | IN UINTN BufferSize,\r | |
64 | IN CONST CHAR16 *Format,\r | |
65 | ...\r | |
66 | )\r | |
67 | /*++\r | |
68 | \r | |
69 | Routine Description:\r | |
70 | \r | |
71 | Process format and place the results in Buffer for wide chars.\r | |
72 | \r | |
73 | Arguments:\r | |
74 | \r | |
75 | Buffer - Wide char buffer to print the results of the parsing of Format into.\r | |
76 | BufferSize - Maximum number of characters to put into buffer.\r | |
77 | Format - Format string\r | |
78 | ... - Vararg list consumed by processing Format.\r | |
79 | \r | |
80 | Returns:\r | |
81 | \r | |
82 | Number of characters printed.\r | |
83 | \r | |
84 | --*/\r | |
85 | {\r | |
86 | UINTN Return;\r | |
87 | VA_LIST Marker;\r | |
88 | \r | |
89 | VA_START (Marker, Format);\r | |
90 | Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r | |
91 | VA_END (Marker);\r | |
92 | \r | |
93 | return Return;\r | |
94 | }\r | |
95 | \r | |
96 | UINTN\r | |
97 | UvSPrint (\r | |
98 | OUT CHAR16 *Buffer,\r | |
99 | IN UINTN BufferSize,\r | |
100 | IN CONST CHAR16 *FormatString,\r | |
101 | IN VA_LIST Marker\r | |
102 | )\r | |
103 | /*++\r | |
104 | \r | |
105 | Routine Description:\r | |
106 | \r | |
107 | Internal implementation of USPrint. \r | |
108 | Process format and place the results in Buffer for wide chars.\r | |
109 | \r | |
110 | Arguments:\r | |
111 | \r | |
112 | Buffer - Wide char buffer to print the results of the parsing of Format into.\r | |
113 | BufferSize - Maximum number of characters to put into buffer.\r | |
114 | FormatString - Format string\r | |
115 | Marker - Vararg list consumed by processing Format.\r | |
116 | \r | |
117 | Returns:\r | |
118 | \r | |
119 | Number of characters printed.\r | |
120 | \r | |
121 | --*/\r | |
122 | {\r | |
123 | UINTN Index;\r | |
124 | CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r | |
125 | CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r | |
126 | \r | |
127 | for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r | |
128 | AsciiFormat[Index] = (CHAR8) FormatString[Index];\r | |
129 | }\r | |
130 | \r | |
131 | AsciiFormat[Index] = '\0';\r | |
132 | \r | |
133 | Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);\r | |
134 | \r | |
135 | for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {\r | |
136 | Buffer[Index] = (CHAR16) AsciiResult[Index];\r | |
137 | }\r | |
138 | \r | |
139 | Buffer[Index] = '\0';\r | |
140 | \r | |
141 | return Index++;\r | |
142 | }\r |