1 | /** @file
|
---|
2 | Base Print Library instance Internal Functions definition.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php.
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #ifndef __PRINT_LIB_INTERNAL_H__
|
---|
16 | #define __PRINT_LIB_INTERNAL_H__
|
---|
17 |
|
---|
18 | #include <Base.h>
|
---|
19 | #include <Library/PrintLib.h>
|
---|
20 | #include <Library/BaseLib.h>
|
---|
21 | #include <Library/DebugLib.h>
|
---|
22 |
|
---|
23 |
|
---|
24 | //
|
---|
25 | // Print primitives
|
---|
26 | //
|
---|
27 | #define PREFIX_SIGN BIT1
|
---|
28 | #define PREFIX_BLANK BIT2
|
---|
29 | #define LONG_TYPE BIT4
|
---|
30 | #define OUTPUT_UNICODE BIT6
|
---|
31 | #define FORMAT_UNICODE BIT8
|
---|
32 | #define PAD_TO_WIDTH BIT9
|
---|
33 | #define ARGUMENT_UNICODE BIT10
|
---|
34 | #define PRECISION BIT11
|
---|
35 | #define ARGUMENT_REVERSED BIT12
|
---|
36 | #define COUNT_ONLY_NO_PRINT BIT13
|
---|
37 |
|
---|
38 | //
|
---|
39 | // Record date and time information
|
---|
40 | //
|
---|
41 | typedef struct {
|
---|
42 | UINT16 Year;
|
---|
43 | UINT8 Month;
|
---|
44 | UINT8 Day;
|
---|
45 | UINT8 Hour;
|
---|
46 | UINT8 Minute;
|
---|
47 | UINT8 Second;
|
---|
48 | UINT8 Pad1;
|
---|
49 | UINT32 Nanosecond;
|
---|
50 | INT16 TimeZone;
|
---|
51 | UINT8 Daylight;
|
---|
52 | UINT8 Pad2;
|
---|
53 | } TIME;
|
---|
54 |
|
---|
55 | /**
|
---|
56 | Worker function that produces a Null-terminated string in an output buffer
|
---|
57 | based on a Null-terminated format string and a VA_LIST argument list.
|
---|
58 |
|
---|
59 | VSPrint function to process format and place the results in Buffer. Since a
|
---|
60 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus
|
---|
61 | this is the main print working routine.
|
---|
62 |
|
---|
63 | If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.
|
---|
64 |
|
---|
65 | @param[out] Buffer The character buffer to print the results of the
|
---|
66 | parsing of Format into.
|
---|
67 | @param[in] BufferSize The maximum number of characters to put into
|
---|
68 | buffer.
|
---|
69 | @param[in] Flags Initial flags value.
|
---|
70 | Can only have FORMAT_UNICODE, OUTPUT_UNICODE,
|
---|
71 | and COUNT_ONLY_NO_PRINT set.
|
---|
72 | @param[in] Format A Null-terminated format string.
|
---|
73 | @param[in] VaListMarker VA_LIST style variable argument list consumed by
|
---|
74 | processing Format.
|
---|
75 | @param[in] BaseListMarker BASE_LIST style variable argument list consumed
|
---|
76 | by processing Format.
|
---|
77 |
|
---|
78 | @return The number of characters printed not including the Null-terminator.
|
---|
79 | If COUNT_ONLY_NO_PRINT was set returns the same, but without any
|
---|
80 | modification to Buffer.
|
---|
81 |
|
---|
82 | **/
|
---|
83 | UINTN
|
---|
84 | BasePrintLibSPrintMarker (
|
---|
85 | OUT CHAR8 *Buffer,
|
---|
86 | IN UINTN BufferSize,
|
---|
87 | IN UINTN Flags,
|
---|
88 | IN CONST CHAR8 *Format,
|
---|
89 | IN VA_LIST VaListMarker, OPTIONAL
|
---|
90 | IN BASE_LIST BaseListMarker OPTIONAL
|
---|
91 | );
|
---|
92 |
|
---|
93 | /**
|
---|
94 | Worker function that produces a Null-terminated string in an output buffer
|
---|
95 | based on a Null-terminated format string and variable argument list.
|
---|
96 |
|
---|
97 | VSPrint function to process format and place the results in Buffer. Since a
|
---|
98 | VA_LIST is used this routine allows the nesting of Vararg routines. Thus
|
---|
99 | this is the main print working routine
|
---|
100 |
|
---|
101 | @param StartOfBuffer The character buffer to print the results of the parsing
|
---|
102 | of Format into.
|
---|
103 | @param BufferSize The maximum number of characters to put into buffer.
|
---|
104 | Zero means no limit.
|
---|
105 | @param Flags Initial flags value.
|
---|
106 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
|
---|
107 | @param FormatString Null-terminated format string.
|
---|
108 | @param ... The variable argument list.
|
---|
109 |
|
---|
110 | @return The number of characters printed.
|
---|
111 |
|
---|
112 | **/
|
---|
113 | UINTN
|
---|
114 | EFIAPI
|
---|
115 | BasePrintLibSPrint (
|
---|
116 | OUT CHAR8 *StartOfBuffer,
|
---|
117 | IN UINTN BufferSize,
|
---|
118 | IN UINTN Flags,
|
---|
119 | IN CONST CHAR8 *FormatString,
|
---|
120 | ...
|
---|
121 | );
|
---|
122 |
|
---|
123 | /**
|
---|
124 | Internal function that places the character into the Buffer.
|
---|
125 |
|
---|
126 | Internal function that places ASCII or Unicode character into the Buffer.
|
---|
127 |
|
---|
128 | @param Buffer Buffer to place the Unicode or ASCII string.
|
---|
129 | @param EndBuffer The end of the input Buffer. No characters will be
|
---|
130 | placed after that.
|
---|
131 | @param Length The count of character to be placed into Buffer.
|
---|
132 | (Negative value indicates no buffer fill.)
|
---|
133 | @param Character The character to be placed into Buffer.
|
---|
134 | @param Increment The character increment in Buffer.
|
---|
135 |
|
---|
136 | @return Buffer Buffer filled with the input Character.
|
---|
137 |
|
---|
138 | **/
|
---|
139 | CHAR8 *
|
---|
140 | BasePrintLibFillBuffer (
|
---|
141 | OUT CHAR8 *Buffer,
|
---|
142 | IN CHAR8 *EndBuffer,
|
---|
143 | IN INTN Length,
|
---|
144 | IN UINTN Character,
|
---|
145 | IN INTN Increment
|
---|
146 | );
|
---|
147 |
|
---|
148 | /**
|
---|
149 | Internal function that convert a number to a string in Buffer.
|
---|
150 |
|
---|
151 | Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.
|
---|
152 |
|
---|
153 | @param Buffer Location to place the ASCII string of Value.
|
---|
154 | @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.
|
---|
155 | @param Radix Radix of the value
|
---|
156 |
|
---|
157 | @return A pointer to the end of buffer filled with ASCII string.
|
---|
158 |
|
---|
159 | **/
|
---|
160 | CHAR8 *
|
---|
161 | BasePrintLibValueToString (
|
---|
162 | IN OUT CHAR8 *Buffer,
|
---|
163 | IN INT64 Value,
|
---|
164 | IN UINTN Radix
|
---|
165 | );
|
---|
166 |
|
---|
167 | /**
|
---|
168 | Internal function that converts a decimal value to a Null-terminated string.
|
---|
169 |
|
---|
170 | Converts the decimal number specified by Value to a Null-terminated
|
---|
171 | string specified by Buffer containing at most Width characters.
|
---|
172 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
|
---|
173 | The total number of characters placed in Buffer is returned.
|
---|
174 | If the conversion contains more than Width characters, then only the first
|
---|
175 | Width characters are returned, and the total number of characters
|
---|
176 | required to perform the conversion is returned.
|
---|
177 | Additional conversion parameters are specified in Flags.
|
---|
178 | The Flags bit LEFT_JUSTIFY is always ignored.
|
---|
179 | All conversions are left justified in Buffer.
|
---|
180 | If Width is 0, PREFIX_ZERO is ignored in Flags.
|
---|
181 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
|
---|
182 | are inserted every 3rd digit starting from the right.
|
---|
183 | If Value is < 0, then the fist character in Buffer is a '-'.
|
---|
184 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
|
---|
185 | then Buffer is padded with '0' characters so the combination of the optional '-'
|
---|
186 | sign character, '0' characters, digit characters for Value, and the Null-terminator
|
---|
187 | add up to Width characters.
|
---|
188 |
|
---|
189 | If Buffer is NULL, then ASSERT().
|
---|
190 | If unsupported bits are set in Flags, then ASSERT().
|
---|
191 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
|
---|
192 |
|
---|
193 | @param Buffer The pointer to the output buffer for the produced Null-terminated
|
---|
194 | string.
|
---|
195 | @param Flags The bitmask of flags that specify left justification, zero pad,
|
---|
196 | and commas.
|
---|
197 | @param Value The 64-bit signed value to convert to a string.
|
---|
198 | @param Width The maximum number of characters to place in Buffer, not including
|
---|
199 | the Null-terminator.
|
---|
200 | @param Increment Character increment in Buffer.
|
---|
201 |
|
---|
202 | @return Total number of characters required to perform the conversion.
|
---|
203 |
|
---|
204 | **/
|
---|
205 | UINTN
|
---|
206 | BasePrintLibConvertValueToString (
|
---|
207 | IN OUT CHAR8 *Buffer,
|
---|
208 | IN UINTN Flags,
|
---|
209 | IN INT64 Value,
|
---|
210 | IN UINTN Width,
|
---|
211 | IN UINTN Increment
|
---|
212 | );
|
---|
213 |
|
---|
214 | #endif
|
---|