add function header
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLibInternal.h
CommitLineData
878ddf1f 1/** @file\r
2 Print Library.\r
3\r
4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 Module Name: PrintLibInternal.h\r
14\r
15**/\r
16\r
878ddf1f 17//\r
18// Print primitives\r
19//\r
20//#define LEFT_JUSTIFY 0x01\r
21#define PREFIX_SIGN 0x02\r
22#define PREFIX_BLANK 0x04\r
23//#define COMMA_TYPE 0x08\r
24#define LONG_TYPE 0x10\r
25//#define PREFIX_ZERO 0x20\r
26#define OUTPUT_UNICODE 0x40\r
27#define RADIX_HEX 0x80\r
28#define FORMAT_UNICODE 0x100\r
29#define PAD_TO_WIDTH 0x200\r
30#define ARGUMENT_UNICODE 0x400\r
31#define PRECISION 0x800\r
32#define ARGUMENT_REVERSED 0x1000\r
33\r
34///\r
35/// Define the maximum number of characters that are required to encode\r
36/// a decimal, hexidecimal, GUID, or TIME value with a Nll terminator.\r
37/// Maximum Length Decimal String = 28 "-9,223,372,036,854,775,808"\r
38/// Maximum Length Hexidecimal String = 17 "FFFFFFFFFFFFFFFF"\r
39/// Maximum Length GUID = 37 "00000000-0000-0000-0000-000000000000"\r
a3657e3e 40/// Maximum Length TIME = 18 "12/12/2006 12:12"\r
878ddf1f 41///\r
42#define MAXIMUM_VALUE_CHARACTERS 38\r
43\r
44//\r
3f9f540d 45// Record date and time information\r
878ddf1f 46//\r
47typedef struct {\r
48 UINT16 Year;\r
49 UINT8 Month;\r
50 UINT8 Day;\r
51 UINT8 Hour;\r
52 UINT8 Minute;\r
53 UINT8 Second;\r
54 UINT8 Pad1;\r
55 UINT32 Nanosecond;\r
56 INT16 TimeZone;\r
57 UINT8 Daylight;\r
58 UINT8 Pad2;\r
59} TIME;\r
60\r
3f9f540d 61/**\r
62 Worker function that produces a Null-terminated string in an output buffer \r
63 based on a Null-terminated format string and variable argument list.\r
64\r
65 VSPrint function to process format and place the results in Buffer. Since a \r
66 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
67 this is the main print working routine\r
68\r
69 @param Buffer Character buffer to print the results of the parsing\r
70 of Format into.\r
71 @param BufferSize Maximum number of characters to put into buffer.\r
72 Zero means no limit.\r
73 @param Flags Intial flags value.\r
74 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
75 @param FormatString Null-terminated format string.\r
76\r
77 @return Number of characters printed.\r
78\r
79**/\r
878ddf1f 80UINTN\r
81BasePrintLibSPrint (\r
82 OUT CHAR8 *Buffer,\r
83 IN UINTN BufferSize,\r
84 IN UINTN Flags,\r
85 IN CONST CHAR8 *FormatString,\r
86 ...\r
87 );\r
88\r
3f9f540d 89/**\r
90 Internal function that places the character into the Buffer.\r
91\r
92 Internal function that places ASCII or Unicode character into the Buffer.\r
93\r
94 @param Buffer Buffer to place the Unicode or ASCII string.\r
95 @param Length Count of character to be placed into Buffer.\r
96 @param Character Character to be placed into Buffer.\r
97 @param Increment Character increment in Buffer.\r
98\r
99 @return Number of characters printed.\r
100\r
101**/\r
878ddf1f 102CHAR8 *\r
103BasePrintLibFillBuffer (\r
104 CHAR8 *Buffer,\r
105 INTN Length,\r
106 UINTN Character,\r
107 INTN Increment\r
108 );\r
109\r
3f9f540d 110/**\r
111 Internal function that convert a decimal number to a string in Buffer.\r
112\r
113 Print worker function that convert a decimal number to a string in Buffer.\r
114\r
115 @param Buffer Location to place the Unicode or ASCII string of Value.\r
116 @param Value Value to convert to a Decimal or Hexidecimal string in Buffer.\r
117 @param Radix Radix of the value\r
118\r
119 @return Number of characters printed.\r
120\r
121**/\r
878ddf1f 122UINTN\r
123EFIAPI\r
124BasePrintLibValueToString (\r
125 IN OUT CHAR8 *Buffer, \r
126 IN INT64 Value, \r
127 IN UINTN Radix\r
128 );\r
129\r
3f9f540d 130/**\r
131 Internal function that converts a decimal value to a Null-terminated string.\r
132 \r
133 Converts the decimal number specified by Value to a Null-terminated \r
134 string specified by Buffer containing at most Width characters.\r
135 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r
136 The total number of characters placed in Buffer is returned.\r
137 If the conversion contains more than Width characters, then only the first\r
138 Width characters are returned, and the total number of characters \r
139 required to perform the conversion is returned.\r
140 Additional conversion parameters are specified in Flags. \r
141 The Flags bit LEFT_JUSTIFY is always ignored.\r
142 All conversions are left justified in Buffer.\r
143 If Width is 0, PREFIX_ZERO is ignored in Flags.\r
144 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r
145 are inserted every 3rd digit starting from the right.\r
146 If Value is < 0, then the fist character in Buffer is a '-'.\r
147 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r
148 then Buffer is padded with '0' characters so the combination of the optional '-' \r
149 sign character, '0' characters, digit characters for Value, and the Null-terminator\r
150 add up to Width characters.\r
151\r
152 If Buffer is NULL, then ASSERT().\r
153 If unsupported bits are set in Flags, then ASSERT().\r
154 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r
155\r
156 @param Buffer Pointer to the output buffer for the produced Null-terminated\r
157 string.\r
158 @param Flags The bitmask of flags that specify left justification, zero pad,\r
159 and commas.\r
160 @param Value The 64-bit signed value to convert to a string.\r
161 @param Width The maximum number of characters to place in Buffer.\r
162 @param Increment Character increment in Buffer.\r
163 \r
164 @return Total number of characters required to perform the conversion.\r
165\r
166**/\r
a3657e3e 167UINTN\r
168BasePrintLibConvertValueToString (\r
169 IN OUT CHAR8 *Buffer,\r
170 IN UINTN Flags,\r
171 IN INT64 Value,\r
172 IN UINTN Width,\r
173 IN UINTN Increment\r
174 );\r