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