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