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