]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BasePrintLib/PrintLibInternal.h
MdePkg: Change OPTIONAL keyword usage style
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLibInternal.h
CommitLineData
e1f414b6 1/** @file\r
eceb3a4c 2 Base Print Library instance Internal Functions definition.\r
e1f414b6 3\r
9095d37b 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e1f414b6 6\r
e1f414b6 7**/\r
8\r
eceb3a4c
LG
9#ifndef __PRINT_LIB_INTERNAL_H__\r
10#define __PRINT_LIB_INTERNAL_H__\r
e1f414b6 11\r
f734a10a
A
12#include <Base.h>\r
13#include <Library/PrintLib.h>\r
14#include <Library/BaseLib.h>\r
15#include <Library/DebugLib.h>\r
9b002aa4 16#include <Library/PcdLib.h>\r
f734a10a 17\r
e1f414b6 18\r
19//\r
20// Print primitives\r
21//\r
f405c067 22#define PREFIX_SIGN BIT1\r
23#define PREFIX_BLANK BIT2\r
24#define LONG_TYPE BIT4\r
25#define OUTPUT_UNICODE BIT6\r
26#define FORMAT_UNICODE BIT8\r
27#define PAD_TO_WIDTH BIT9\r
28#define ARGUMENT_UNICODE BIT10\r
29#define PRECISION BIT11\r
30#define ARGUMENT_REVERSED BIT12\r
31#define COUNT_ONLY_NO_PRINT BIT13\r
9ade4339 32#define UNSIGNED_TYPE BIT14\r
e1f414b6 33\r
34//\r
35// Record date and time information\r
36//\r
37typedef struct {\r
38 UINT16 Year;\r
39 UINT8 Month;\r
40 UINT8 Day;\r
41 UINT8 Hour;\r
42 UINT8 Minute;\r
43 UINT8 Second;\r
44 UINT8 Pad1;\r
45 UINT32 Nanosecond;\r
46 INT16 TimeZone;\r
47 UINT8 Daylight;\r
48 UINT8 Pad2;\r
49} TIME;\r
50\r
51/**\r
9095d37b 52 Worker function that produces a Null-terminated string in an output buffer\r
e1f414b6 53 based on a Null-terminated format string and a VA_LIST argument list.\r
54\r
9095d37b
LG
55 VSPrint function to process format and place the results in Buffer. Since a\r
56 VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
e1f414b6 57 this is the main print working routine.\r
58\r
f405c067 59 If COUNT_ONLY_NO_PRINT is set in Flags, Buffer will not be modified at all.\r
60\r
9095d37b 61 @param[out] Buffer The character buffer to print the results of the\r
f405c067 62 parsing of Format into.\r
9095d37b 63 @param[in] BufferSize The maximum number of characters to put into\r
f405c067 64 buffer.\r
65 @param[in] Flags Initial flags value.\r
9095d37b 66 Can only have FORMAT_UNICODE, OUTPUT_UNICODE,\r
f405c067 67 and COUNT_ONLY_NO_PRINT set.\r
68 @param[in] Format A Null-terminated format string.\r
69 @param[in] VaListMarker VA_LIST style variable argument list consumed by\r
70 processing Format.\r
71 @param[in] BaseListMarker BASE_LIST style variable argument list consumed\r
72 by processing Format.\r
e1f414b6 73\r
2fc59a00 74 @return The number of characters printed not including the Null-terminator.\r
f405c067 75 If COUNT_ONLY_NO_PRINT was set returns the same, but without any\r
76 modification to Buffer.\r
e1f414b6 77\r
78**/\r
79UINTN\r
2075236e 80BasePrintLibSPrintMarker (\r
e1f414b6 81 OUT CHAR8 *Buffer,\r
82 IN UINTN BufferSize,\r
83 IN UINTN Flags,\r
84 IN CONST CHAR8 *Format,\r
d0e2f823 85 IN VA_LIST VaListMarker OPTIONAL,\r
2075236e 86 IN BASE_LIST BaseListMarker OPTIONAL\r
e1f414b6 87 );\r
88\r
89/**\r
9095d37b 90 Worker function that produces a Null-terminated string in an output buffer\r
e1f414b6 91 based on a Null-terminated format string and variable argument list.\r
92\r
9095d37b
LG
93 VSPrint function to process format and place the results in Buffer. Since a\r
94 VA_LIST is used this routine allows the nesting of Vararg routines. Thus\r
e1f414b6 95 this is the main print working routine\r
96\r
2fc59a00 97 @param StartOfBuffer The character buffer to print the results of the parsing\r
e1f414b6 98 of Format into.\r
2fc59a00 99 @param BufferSize The maximum number of characters to put into buffer.\r
e1f414b6 100 Zero means no limit.\r
7c905091 101 @param Flags Initial flags value.\r
e1f414b6 102 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
103 @param FormatString Null-terminated format string.\r
eceb3a4c 104 @param ... The variable argument list.\r
e1f414b6 105\r
2fc59a00 106 @return The number of characters printed.\r
e1f414b6 107\r
108**/\r
109UINTN\r
932d66a9 110EFIAPI\r
e1f414b6 111BasePrintLibSPrint (\r
eceb3a4c 112 OUT CHAR8 *StartOfBuffer,\r
e1f414b6 113 IN UINTN BufferSize,\r
114 IN UINTN Flags,\r
115 IN CONST CHAR8 *FormatString,\r
116 ...\r
117 );\r
118\r
119/**\r
120 Internal function that places the character into the Buffer.\r
121\r
122 Internal function that places ASCII or Unicode character into the Buffer.\r
123\r
124 @param Buffer Buffer to place the Unicode or ASCII string.\r
125 @param EndBuffer The end of the input Buffer. No characters will be\r
9095d37b 126 placed after that.\r
2fc59a00 127 @param Length The count of character to be placed into Buffer.\r
a2bc29c4 128 (Negative value indicates no buffer fill.)\r
2fc59a00 129 @param Character The character to be placed into Buffer.\r
130 @param Increment The character increment in Buffer.\r
e1f414b6 131\r
eceb3a4c 132 @return Buffer Buffer filled with the input Character.\r
e1f414b6 133\r
134**/\r
135CHAR8 *\r
136BasePrintLibFillBuffer (\r
eceb3a4c
LG
137 OUT CHAR8 *Buffer,\r
138 IN CHAR8 *EndBuffer,\r
139 IN INTN Length,\r
140 IN UINTN Character,\r
141 IN INTN Increment\r
e1f414b6 142 );\r
143\r
144/**\r
7c905091 145 Internal function that convert a number to a string in Buffer.\r
e1f414b6 146\r
7c905091 147 Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer.\r
e1f414b6 148\r
7c905091 149 @param Buffer Location to place the ASCII string of Value.\r
2fc59a00 150 @param Value The value to convert to a Decimal or Hexadecimal string in Buffer.\r
e1f414b6 151 @param Radix Radix of the value\r
152\r
7c905091 153 @return A pointer to the end of buffer filled with ASCII string.\r
e1f414b6 154\r
155**/\r
7c905091 156CHAR8 *\r
e1f414b6 157BasePrintLibValueToString (\r
9095d37b
LG
158 IN OUT CHAR8 *Buffer,\r
159 IN INT64 Value,\r
e1f414b6 160 IN UINTN Radix\r
161 );\r
162\r
163/**\r
164 Internal function that converts a decimal value to a Null-terminated string.\r
9095d37b
LG
165\r
166 Converts the decimal number specified by Value to a Null-terminated\r
e1f414b6 167 string specified by Buffer containing at most Width characters.\r
168 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
169 The total number of characters placed in Buffer is returned.\r
170 If the conversion contains more than Width characters, then only the first\r
9095d37b 171 Width characters are returned, and the total number of characters\r
e1f414b6 172 required to perform the conversion is returned.\r
9095d37b 173 Additional conversion parameters are specified in Flags.\r
e1f414b6 174 The Flags bit LEFT_JUSTIFY is always ignored.\r
175 All conversions are left justified in Buffer.\r
176 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
177 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
178 are inserted every 3rd digit starting from the right.\r
179 If Value is < 0, then the fist character in Buffer is a '-'.\r
9095d37b
LG
180 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
181 then Buffer is padded with '0' characters so the combination of the optional '-'\r
e1f414b6 182 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
183 add up to Width characters.\r
184\r
185 If Buffer is NULL, then ASSERT().\r
186 If unsupported bits are set in Flags, then ASSERT().\r
187 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
188\r
2fc59a00 189 @param Buffer The pointer to the output buffer for the produced Null-terminated\r
e1f414b6 190 string.\r
191 @param Flags The bitmask of flags that specify left justification, zero pad,\r
192 and commas.\r
193 @param Value The 64-bit signed value to convert to a string.\r
194 @param Width The maximum number of characters to place in Buffer, not including\r
195 the Null-terminator.\r
196 @param Increment Character increment in Buffer.\r
9095d37b 197\r
e1f414b6 198 @return Total number of characters required to perform the conversion.\r
199\r
200**/\r
201UINTN\r
202BasePrintLibConvertValueToString (\r
203 IN OUT CHAR8 *Buffer,\r
204 IN UINTN Flags,\r
205 IN INT64 Value,\r
206 IN UINTN Width,\r
207 IN UINTN Increment\r
208 );\r
209\r
51f0ceb4
HW
210/**\r
211 Internal function that converts a decimal value to a Null-terminated string.\r
212\r
213 Converts the decimal number specified by Value to a Null-terminated string\r
214 specified by Buffer containing at most Width characters. If Width is 0 then a\r
215 width of MAXIMUM_VALUE_CHARACTERS is assumed. If the conversion contains more\r
216 than Width characters, then only the first Width characters are placed in\r
217 Buffer. Additional conversion parameters are specified in Flags.\r
218 The Flags bit LEFT_JUSTIFY is always ignored.\r
219 All conversions are left justified in Buffer.\r
220 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
221 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and\r
222 commas are inserted every 3rd digit starting from the right.\r
223 If Value is < 0, then the fist character in Buffer is a '-'.\r
224 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,\r
225 then Buffer is padded with '0' characters so the combination of the optional\r
226 '-' sign character, '0' characters, digit characters for Value, and the\r
227 Null-terminator add up to Width characters.\r
228\r
229 If an error would be returned, the function will ASSERT().\r
230\r
231 @param Buffer The pointer to the output buffer for the produced\r
232 Null-terminated string.\r
233 @param BufferSize The size of Buffer in bytes, including the\r
234 Null-terminator.\r
235 @param Flags The bitmask of flags that specify left justification,\r
236 zero pad, and commas.\r
237 @param Value The 64-bit signed value to convert to a string.\r
238 @param Width The maximum number of characters to place in Buffer,\r
239 not including the Null-terminator.\r
240 @param Increment The character increment in Buffer.\r
241\r
242 @retval RETURN_SUCCESS The decimal value is converted.\r
243 @retval RETURN_BUFFER_TOO_SMALL If BufferSize cannot hold the converted\r
244 value.\r
245 @retval RETURN_INVALID_PARAMETER If Buffer is NULL.\r
246 If Increment is 1 and\r
247 PcdMaximumAsciiStringLength is not zero,\r
248 BufferSize is greater than\r
249 PcdMaximumAsciiStringLength.\r
250 If Increment is not 1 and\r
251 PcdMaximumUnicodeStringLength is not zero,\r
252 BufferSize is greater than\r
253 (PcdMaximumUnicodeStringLength *\r
254 sizeof (CHAR16) + 1).\r
255 If unsupported bits are set in Flags.\r
256 If both COMMA_TYPE and RADIX_HEX are set in\r
257 Flags.\r
258 If Width >= MAXIMUM_VALUE_CHARACTERS.\r
259\r
260**/\r
261RETURN_STATUS\r
262BasePrintLibConvertValueToStringS (\r
263 IN OUT CHAR8 *Buffer,\r
264 IN UINTN BufferSize,\r
265 IN UINTN Flags,\r
266 IN INT64 Value,\r
267 IN UINTN Width,\r
268 IN UINTN Increment\r
269 );\r
270\r
e1f414b6 271#endif\r