1) Added BIT0, BIT1, …, BIT63 to the Base Defines
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLibInternal.h
1 /** @file
2 Print Library Internal Functions.
3
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. 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 Module Name: PrintLibInternal.h
14
15 **/
16
17 #ifndef __PRINT_LIB_INTERNAL_H
18 #define __PRINT_LIB_INTERNAL_H
19
20 //
21 // Print primitives
22 //
23 //#define LEFT_JUSTIFY 0x01
24 #define PREFIX_SIGN 0x02
25 #define PREFIX_BLANK 0x04
26 //#define COMMA_TYPE 0x08
27 #define LONG_TYPE 0x10
28 //#define PREFIX_ZERO 0x20
29 #define OUTPUT_UNICODE 0x40
30 //#define RADIX_HEX 0x80
31 #define FORMAT_UNICODE 0x100
32 #define PAD_TO_WIDTH 0x200
33 #define ARGUMENT_UNICODE 0x400
34 #define PRECISION 0x800
35 #define ARGUMENT_REVERSED 0x1000
36
37 //
38 // Record date and time information
39 //
40 typedef struct {
41 UINT16 Year;
42 UINT8 Month;
43 UINT8 Day;
44 UINT8 Hour;
45 UINT8 Minute;
46 UINT8 Second;
47 UINT8 Pad1;
48 UINT32 Nanosecond;
49 INT16 TimeZone;
50 UINT8 Daylight;
51 UINT8 Pad2;
52 } TIME;
53
54 /**
55 Worker function that produces a Null-terminated string in an output buffer
56 based on a Null-terminated format string and a VA_LIST argument list.
57
58 VSPrint function to process format and place the results in Buffer. Since a
59 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
60 this is the main print working routine.
61
62 @param Buffer Character buffer to print the results of the parsing
63 of Format into.
64 @param BufferSize Maximum number of characters to put into buffer.
65 @param Flags Intial flags value.
66 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
67 @param Format Null-terminated format string.
68 @param Marker Vararg list consumed by processing Format.
69
70 @return Number of characters printed not including the Null-terminator.
71
72 **/
73 UINTN
74 BasePrintLibVSPrint (
75 OUT CHAR8 *Buffer,
76 IN UINTN BufferSize,
77 IN UINTN Flags,
78 IN CONST CHAR8 *Format,
79 IN VA_LIST Marker
80 );
81
82 /**
83 Worker function that produces a Null-terminated string in an output buffer
84 based on a Null-terminated format string and variable argument list.
85
86 VSPrint function to process format and place the results in Buffer. Since a
87 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
88 this is the main print working routine
89
90 @param Buffer Character buffer to print the results of the parsing
91 of Format into.
92 @param BufferSize Maximum number of characters to put into buffer.
93 Zero means no limit.
94 @param Flags Intial flags value.
95 Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
96 @param FormatString Null-terminated format string.
97
98 @return Number of characters printed.
99
100 **/
101 UINTN
102 BasePrintLibSPrint (
103 OUT CHAR8 *Buffer,
104 IN UINTN BufferSize,
105 IN UINTN Flags,
106 IN CONST CHAR8 *FormatString,
107 ...
108 );
109
110 /**
111 Internal function that places the character into the Buffer.
112
113 Internal function that places ASCII or Unicode character into the Buffer.
114
115 @param Buffer Buffer to place the Unicode or ASCII string.
116 @param EndBuffer The end of the input Buffer. No characters will be
117 placed after that.
118 @param Length Count of character to be placed into Buffer.
119 @param Character Character to be placed into Buffer.
120 @param Increment Character increment in Buffer.
121
122 @return Number of characters printed.
123
124 **/
125 CHAR8 *
126 BasePrintLibFillBuffer (
127 CHAR8 *Buffer,
128 CHAR8 *EndBuffer,
129 INTN Length,
130 UINTN Character,
131 INTN Increment
132 );
133
134 /**
135 Internal function that convert a decimal number to a string in Buffer.
136
137 Print worker function that convert a decimal number to a string in Buffer.
138
139 @param Buffer Location to place the Unicode or ASCII string of Value.
140 @param Value Value to convert to a Decimal or Hexidecimal string in Buffer.
141 @param Radix Radix of the value
142
143 @return Number of characters printed.
144
145 **/
146 UINTN
147 EFIAPI
148 BasePrintLibValueToString (
149 IN OUT CHAR8 *Buffer,
150 IN INT64 Value,
151 IN UINTN Radix
152 );
153
154 /**
155 Internal function that converts a decimal value to a Null-terminated string.
156
157 Converts the decimal number specified by Value to a Null-terminated
158 string specified by Buffer containing at most Width characters.
159 If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
160 The total number of characters placed in Buffer is returned.
161 If the conversion contains more than Width characters, then only the first
162 Width characters are returned, and the total number of characters
163 required to perform the conversion is returned.
164 Additional conversion parameters are specified in Flags.
165 The Flags bit LEFT_JUSTIFY is always ignored.
166 All conversions are left justified in Buffer.
167 If Width is 0, PREFIX_ZERO is ignored in Flags.
168 If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
169 are inserted every 3rd digit starting from the right.
170 If Value is < 0, then the fist character in Buffer is a '-'.
171 If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
172 then Buffer is padded with '0' characters so the combination of the optional '-'
173 sign character, '0' characters, digit characters for Value, and the Null-terminator
174 add up to Width characters.
175
176 If Buffer is NULL, then ASSERT().
177 If unsupported bits are set in Flags, then ASSERT().
178 If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
179
180 @param Buffer Pointer to the output buffer for the produced Null-terminated
181 string.
182 @param Flags The bitmask of flags that specify left justification, zero pad,
183 and commas.
184 @param Value The 64-bit signed value to convert to a string.
185 @param Width The maximum number of characters to place in Buffer, not including
186 the Null-terminator.
187 @param Increment Character increment in Buffer.
188
189 @return Total number of characters required to perform the conversion.
190
191 **/
192 UINTN
193 BasePrintLibConvertValueToString (
194 IN OUT CHAR8 *Buffer,
195 IN UINTN Flags,
196 IN INT64 Value,
197 IN UINTN Width,
198 IN UINTN Increment
199 );
200
201 #endif