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