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