]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Print Library.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name: PrintLib.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "PrintLibInternal.h"\r | |
18 | \r | |
4ba61e5e | 19 | #define WARNING_STATUS_NUMBER 4\r |
20 | #define ERROR_STATUS_NUMBER 24\r | |
21 | \r | |
22 | STATIC CONST CHAR8 *StatusString [] = {\r | |
23 | "Success", // RETURN_SUCCESS = 0\r | |
24 | "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1\r | |
25 | "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2\r | |
26 | "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3\r | |
27 | "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4\r | |
28 | "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT\r | |
29 | "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT\r | |
30 | "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT\r | |
31 | "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT\r | |
32 | "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT\r | |
33 | "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT\r | |
34 | "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT\r | |
35 | "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT\r | |
36 | "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT\r | |
37 | "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT\r | |
38 | "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT\r | |
39 | "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT\r | |
40 | "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT\r | |
41 | "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT\r | |
42 | "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT\r | |
43 | "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT\r | |
44 | "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT\r | |
45 | "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT\r | |
46 | "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT\r | |
47 | "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT\r | |
48 | "Aborted", // RETURN_ABORTED = 21 | MAX_BIT\r | |
49 | "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT\r | |
50 | "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT\r | |
51 | "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT\r | |
878ddf1f | 52 | };\r |
53 | \r | |
878ddf1f | 54 | /**\r |
3f9f540d | 55 | Worker function that produces a Null-terminated string in an output buffer \r |
56 | based on a Null-terminated format string and a VA_LIST argument list.\r | |
57 | \r | |
878ddf1f | 58 | VSPrint function to process format and place the results in Buffer. Since a \r |
59 | VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r | |
60 | this is the main print working routine\r | |
61 | \r | |
3f9f540d | 62 | @param Buffer Character buffer to print the results of the parsing\r |
63 | of Format into.\r | |
64 | @param BufferSize Maximum number of characters to put into buffer.\r | |
3f9f540d | 65 | @param Flags Intial flags value.\r |
66 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r | |
67 | @param Format Null-terminated format string.\r | |
68 | @param Marker Vararg list consumed by processing Format.\r | |
878ddf1f | 69 | \r |
70 | @return Number of characters printed.\r | |
71 | \r | |
72 | **/\r | |
73 | UINTN\r | |
74 | BasePrintLibVSPrint (\r | |
75 | OUT CHAR8 *Buffer,\r | |
76 | IN UINTN BufferSize,\r | |
77 | IN UINTN Flags,\r | |
78 | IN CONST CHAR8 *Format,\r | |
79 | IN VA_LIST Marker\r | |
80 | )\r | |
81 | {\r | |
82 | CHAR8 *OriginalBuffer;\r | |
83 | CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];\r | |
84 | UINTN BytesPerOutputCharacter;\r | |
85 | UINTN BytesPerFormatCharacter;\r | |
86 | UINTN FormatMask;\r | |
87 | UINTN FormatCharacter;\r | |
88 | UINTN Width;\r | |
89 | UINTN Precision;\r | |
90 | INT64 Value;\r | |
4ba61e5e | 91 | CONST CHAR8 *ArgumentString;\r |
878ddf1f | 92 | UINTN Character;\r |
93 | GUID *TmpGuid;\r | |
94 | TIME *TmpTime;\r | |
95 | UINTN Count;\r | |
96 | UINTN ArgumentMask;\r | |
97 | INTN BytesPerArgumentCharacter;\r | |
98 | UINTN ArgumentCharacter;\r | |
99 | BOOLEAN Done;\r | |
100 | UINTN Index;\r | |
101 | CHAR8 Prefix;\r | |
102 | BOOLEAN ZeroPad;\r | |
103 | BOOLEAN Comma;\r | |
104 | UINTN Digits;\r | |
105 | UINTN Radix;\r | |
106 | RETURN_STATUS Status;\r | |
107 | \r | |
8960cdeb | 108 | if (BufferSize == 0) {\r |
109 | return 0;\r | |
110 | }\r | |
533f039e | 111 | ASSERT (Buffer != NULL);\r |
533f039e | 112 | \r |
878ddf1f | 113 | OriginalBuffer = Buffer;\r |
114 | \r | |
115 | if ((Flags & OUTPUT_UNICODE) != 0) {\r | |
116 | BytesPerOutputCharacter = 2;\r | |
117 | } else {\r | |
118 | BytesPerOutputCharacter = 1;\r | |
119 | }\r | |
120 | if ((Flags & FORMAT_UNICODE) != 0) {\r | |
4ba61e5e | 121 | //\r |
122 | // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength\r | |
123 | // Unicode characters if PcdMaximumUnicodeStringLength is not zero. \r | |
124 | //\r | |
125 | ASSERT (StrSize ((CHAR16 *) Format) != 0);\r | |
878ddf1f | 126 | BytesPerFormatCharacter = 2;\r |
127 | FormatMask = 0xffff;\r | |
128 | } else {\r | |
4ba61e5e | 129 | //\r |
130 | // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength\r | |
131 | // Ascii characters if PcdMaximumUnicodeStringLength is not zero. \r | |
132 | //\r | |
133 | ASSERT (AsciiStrSize (Format) != 0);\r | |
878ddf1f | 134 | BytesPerFormatCharacter = 1;\r |
135 | FormatMask = 0xff;\r | |
136 | }\r | |
137 | \r | |
138 | //\r | |
139 | // Reserve space for the Null terminator.\r | |
878ddf1f | 140 | //\r |
141 | BufferSize--;\r | |
142 | \r | |
143 | //\r | |
144 | // Get the first character from the format string\r | |
145 | //\r | |
f76fd83e | 146 | FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r |
878ddf1f | 147 | \r |
148 | //\r | |
149 | // Loop until the end of the format string is reached or the output buffer is full\r | |
150 | //\r | |
151 | while (FormatCharacter != 0 && BufferSize > 0) {\r | |
152 | //\r | |
153 | // Clear all the flag bits except those that may have been passed in\r | |
154 | //\r | |
155 | Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE);\r | |
156 | \r | |
157 | //\r | |
158 | // Set the default width to zero, and the default precision to 1\r | |
159 | //\r | |
160 | Width = 0;\r | |
161 | Precision = 1;\r | |
162 | Prefix = 0;\r | |
163 | Comma = FALSE;\r | |
164 | ZeroPad = FALSE;\r | |
165 | Count = 0;\r | |
166 | Digits = 0;\r | |
167 | \r | |
168 | switch (FormatCharacter) {\r | |
169 | case '%':\r | |
170 | //\r | |
171 | // Parse Flags and Width\r | |
172 | //\r | |
173 | for (Done = FALSE; !Done; ) {\r | |
174 | Format += BytesPerFormatCharacter;\r | |
175 | FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r | |
176 | switch (FormatCharacter) {\r | |
177 | case '.': \r | |
178 | Flags |= PRECISION; \r | |
179 | break;\r | |
180 | case '-': \r | |
181 | Flags |= LEFT_JUSTIFY; \r | |
182 | break;\r | |
183 | case '+': \r | |
184 | Flags |= PREFIX_SIGN; \r | |
185 | break;\r | |
186 | case ' ': \r | |
187 | Flags |= PREFIX_BLANK; \r | |
188 | break;\r | |
189 | case ',': \r | |
190 | Flags |= COMMA_TYPE; \r | |
191 | break;\r | |
192 | case 'L':\r | |
193 | case 'l': \r | |
194 | Flags |= LONG_TYPE; \r | |
195 | break;\r | |
196 | case '*':\r | |
197 | if ((Flags & PRECISION) == 0) {\r | |
198 | Flags |= PAD_TO_WIDTH;\r | |
199 | Width = VA_ARG (Marker, UINTN);\r | |
200 | } else {\r | |
201 | Precision = VA_ARG (Marker, UINTN);\r | |
202 | }\r | |
203 | break;\r | |
204 | case '0':\r | |
205 | if ((Flags & PRECISION) == 0) {\r | |
206 | Flags |= PREFIX_ZERO;\r | |
207 | }\r | |
208 | case '1':\r | |
209 | case '2':\r | |
210 | case '3':\r | |
211 | case '4':\r | |
212 | case '5':\r | |
213 | case '6':\r | |
214 | case '7':\r | |
215 | case '8':\r | |
216 | case '9':\r | |
217 | for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ){\r | |
218 | Count = (Count * 10) + FormatCharacter - '0';\r | |
219 | Format += BytesPerFormatCharacter;\r | |
220 | FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r | |
221 | }\r | |
222 | Format -= BytesPerFormatCharacter;\r | |
223 | if ((Flags & PRECISION) == 0) {\r | |
224 | Flags |= PAD_TO_WIDTH;\r | |
225 | Width = Count;\r | |
226 | } else {\r | |
227 | Precision = Count;\r | |
228 | }\r | |
229 | break;\r | |
ab1096fd | 230 | \r |
231 | case '\0':\r | |
232 | //\r | |
233 | // Make no output if Format string terminates unexpectedly when\r | |
234 | // looking up for flag, width, precision and type. \r | |
235 | //\r | |
236 | Format -= BytesPerFormatCharacter;\r | |
237 | Precision = 0;\r | |
238 | //\r | |
239 | // break skiped on purpose.\r | |
240 | //\r | |
878ddf1f | 241 | default:\r |
242 | Done = TRUE;\r | |
243 | break;\r | |
244 | }\r | |
245 | } \r | |
246 | \r | |
247 | //\r | |
248 | // Limit the maximum field width to the remaining characters in the output buffer\r | |
249 | //\r | |
250 | if (Width > BufferSize) {\r | |
251 | Width = BufferSize;\r | |
252 | }\r | |
253 | \r | |
254 | //\r | |
255 | // Handle each argument type\r | |
256 | //\r | |
257 | switch (FormatCharacter) {\r | |
1d580c14 | 258 | case 'p':\r |
259 | if (sizeof (VOID *) > 4) {\r | |
260 | Flags |= LONG_TYPE;\r | |
261 | }\r | |
878ddf1f | 262 | case 'X':\r |
263 | Flags |= PREFIX_ZERO;\r | |
264 | //\r | |
265 | // break skiped on purpose\r | |
266 | //\r | |
267 | case 'x':\r | |
268 | Flags |= RADIX_HEX;\r | |
269 | //\r | |
270 | // break skiped on purpose\r | |
271 | //\r | |
272 | case 'd':\r | |
273 | if ((Flags & LONG_TYPE) == 0) {\r | |
1d580c14 | 274 | Value = (VA_ARG (Marker, int));\r |
878ddf1f | 275 | } else {\r |
276 | Value = VA_ARG (Marker, INT64);\r | |
277 | }\r | |
278 | if ((Flags & PREFIX_BLANK) != 0) {\r | |
279 | Prefix = ' ';\r | |
280 | }\r | |
281 | if ((Flags & PREFIX_SIGN) != 0) {\r | |
282 | Prefix = '+';\r | |
283 | }\r | |
284 | if ((Flags & COMMA_TYPE) != 0) {\r | |
285 | Comma = TRUE;\r | |
286 | }\r | |
287 | if ((Flags & RADIX_HEX) == 0) {\r | |
288 | Radix = 10;\r | |
289 | if (Comma) {\r | |
290 | Flags &= (~PREFIX_ZERO);\r | |
291 | Precision = 1;\r | |
292 | }\r | |
293 | if (Value < 0) {\r | |
294 | Flags |= PREFIX_SIGN;\r | |
295 | Prefix = '-';\r | |
296 | Value = -Value;\r | |
297 | }\r | |
298 | } else {\r | |
299 | Radix = 16;\r | |
300 | Comma = FALSE;\r | |
301 | if ((Flags & LONG_TYPE) == 0 && Value < 0) {\r | |
1d580c14 | 302 | Value = (unsigned int)Value;\r |
878ddf1f | 303 | }\r |
304 | }\r | |
305 | //\r | |
306 | // Convert Value to a reversed string\r | |
307 | //\r | |
308 | Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);\r | |
309 | if (Value == 0 && Precision == 0) {\r | |
310 | Count = 0;\r | |
311 | }\r | |
312 | ArgumentString = (CHAR8 *)ValueBuffer + Count;\r | |
ab1096fd | 313 | \r |
314 | Digits = Count % 3;\r | |
315 | if (Digits != 0) {\r | |
316 | Digits = 3 - Digits;\r | |
317 | }\r | |
878ddf1f | 318 | if (Comma && Count != 0) {\r |
319 | Count += ((Count - 1) / 3);\r | |
320 | }\r | |
321 | if (Prefix != 0) {\r | |
322 | Count++;\r | |
ab1096fd | 323 | Precision++;\r |
878ddf1f | 324 | }\r |
325 | Flags |= ARGUMENT_REVERSED;\r | |
326 | ZeroPad = TRUE;\r | |
327 | if ((Flags & PREFIX_ZERO) != 0) {\r | |
ab1096fd | 328 | if ((Flags & LEFT_JUSTIFY) == 0) {\r |
329 | if ((Flags & PAD_TO_WIDTH) != 0) {\r | |
330 | if ((Flags & PRECISION) == 0) {\r | |
331 | Precision = Width;\r | |
332 | }\r | |
878ddf1f | 333 | }\r |
334 | }\r | |
335 | }\r | |
336 | break;\r | |
337 | \r | |
338 | case 's':\r | |
339 | case 'S':\r | |
340 | Flags |= ARGUMENT_UNICODE;\r | |
341 | //\r | |
342 | // break skipped on purpose\r | |
343 | //\r | |
344 | case 'a':\r | |
345 | ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);\r | |
346 | if (ArgumentString == NULL) {\r | |
347 | Flags &= (~ARGUMENT_UNICODE);\r | |
348 | ArgumentString = "<null string>";\r | |
349 | }\r | |
350 | break;\r | |
351 | \r | |
352 | case 'c':\r | |
353 | Character = VA_ARG (Marker, UINTN) & 0xffff;\r | |
354 | ArgumentString = (CHAR8 *)&Character;\r | |
355 | Flags |= ARGUMENT_UNICODE;\r | |
356 | break;\r | |
357 | \r | |
358 | case 'g':\r | |
359 | TmpGuid = VA_ARG (Marker, GUID *);\r | |
360 | if (TmpGuid == NULL) {\r | |
361 | ArgumentString = "<null guid>";\r | |
362 | } else {\r | |
363 | BasePrintLibSPrint (\r | |
364 | ValueBuffer,\r | |
8960cdeb | 365 | MAXIMUM_VALUE_CHARACTERS, \r |
878ddf1f | 366 | 0,\r |
367 | "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r | |
f76fd83e | 368 | TmpGuid->Data1,\r |
369 | TmpGuid->Data2,\r | |
370 | TmpGuid->Data3,\r | |
371 | TmpGuid->Data4[0],\r | |
372 | TmpGuid->Data4[1],\r | |
373 | TmpGuid->Data4[2],\r | |
374 | TmpGuid->Data4[3],\r | |
375 | TmpGuid->Data4[4],\r | |
376 | TmpGuid->Data4[5],\r | |
377 | TmpGuid->Data4[6],\r | |
378 | TmpGuid->Data4[7]\r | |
878ddf1f | 379 | );\r |
380 | ArgumentString = ValueBuffer;\r | |
381 | }\r | |
382 | break;\r | |
383 | \r | |
384 | case 't':\r | |
385 | TmpTime = VA_ARG (Marker, TIME *); \r | |
386 | if (TmpTime == NULL) {\r | |
387 | ArgumentString = "<null time>";\r | |
388 | } else {\r | |
389 | BasePrintLibSPrint (\r | |
390 | ValueBuffer,\r | |
8960cdeb | 391 | MAXIMUM_VALUE_CHARACTERS,\r |
878ddf1f | 392 | 0,\r |
393 | "%02d/%02d/%04d %02d:%02d",\r | |
f76fd83e | 394 | TmpTime->Month,\r |
395 | TmpTime->Day,\r | |
396 | TmpTime->Year,\r | |
397 | TmpTime->Hour,\r | |
398 | TmpTime->Minute\r | |
878ddf1f | 399 | );\r |
400 | ArgumentString = ValueBuffer;\r | |
401 | }\r | |
402 | break;\r | |
403 | \r | |
404 | case 'r':\r | |
405 | Status = VA_ARG (Marker, RETURN_STATUS);\r | |
406 | ArgumentString = ValueBuffer;\r | |
4ba61e5e | 407 | if (RETURN_ERROR (Status)) {\r |
408 | //\r | |
409 | // Clear error bit\r | |
410 | //\r | |
411 | Index = Status & ~MAX_BIT;\r | |
412 | if (Index > 0 && Index <= ERROR_STATUS_NUMBER) {\r | |
413 | ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER];\r | |
414 | }\r | |
415 | } else {\r | |
416 | Index = Status;\r | |
417 | if (Index <= WARNING_STATUS_NUMBER) {\r | |
418 | ArgumentString = StatusString [Index];\r | |
878ddf1f | 419 | }\r |
420 | }\r | |
421 | if (ArgumentString == ValueBuffer) {\r | |
8960cdeb | 422 | BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);\r |
878ddf1f | 423 | }\r |
424 | break;\r | |
425 | \r | |
8960cdeb | 426 | case '\n':\r |
4ba61e5e | 427 | ArgumentString = "\n\r";\r |
8960cdeb | 428 | break;\r |
429 | \r | |
878ddf1f | 430 | case '%':\r |
431 | default:\r | |
432 | //\r | |
433 | // if the type is '%' or unknown, then print it to the screen\r | |
434 | //\r | |
435 | ArgumentString = (CHAR8 *)&FormatCharacter;\r | |
436 | Flags |= ARGUMENT_UNICODE;\r | |
437 | break;\r | |
438 | }\r | |
439 | break;\r | |
4ba61e5e | 440 | \r |
441 | case '\n':\r | |
442 | ArgumentString = "\n\r";\r | |
443 | break;\r | |
444 | \r | |
878ddf1f | 445 | default:\r |
446 | ArgumentString = (CHAR8 *)&FormatCharacter;\r | |
447 | Flags |= ARGUMENT_UNICODE;\r | |
448 | break;\r | |
449 | }\r | |
450 | \r | |
451 | //\r | |
452 | // Retrieve the ArgumentString attriubutes\r | |
453 | //\r | |
454 | if ((Flags & ARGUMENT_UNICODE) != 0) {\r | |
455 | ArgumentMask = 0xffff;\r | |
456 | BytesPerArgumentCharacter = 2;\r | |
457 | } else {\r | |
458 | ArgumentMask = 0xff;\r | |
459 | BytesPerArgumentCharacter = 1;\r | |
460 | }\r | |
461 | if ((Flags & ARGUMENT_REVERSED) != 0) {\r | |
462 | BytesPerArgumentCharacter = -BytesPerArgumentCharacter;\r | |
463 | } else {\r | |
464 | //\r | |
465 | // Compute the number of characters in ArgumentString and store it in Count\r | |
466 | // ArgumentString is either null-terminated, or it contains Precision characters\r | |
467 | //\r | |
468 | for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {\r | |
469 | ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;\r | |
470 | if (ArgumentCharacter == 0) {\r | |
471 | break;\r | |
472 | }\r | |
473 | }\r | |
474 | }\r | |
475 | \r | |
476 | //\r | |
477 | // Limit the length of the string to append to the remaining characters in the output buffer\r | |
478 | //\r | |
479 | if (Count > BufferSize) {\r | |
480 | Count = BufferSize;\r | |
481 | }\r | |
482 | if (Precision < Count) {\r | |
483 | Precision = Count;\r | |
484 | }\r | |
485 | \r | |
486 | //\r | |
487 | // Pad before the string\r | |
488 | //\r | |
489 | if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {\r | |
490 | Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r | |
491 | }\r | |
492 | \r | |
493 | if (ZeroPad) {\r | |
494 | if (Prefix != 0) {\r | |
495 | Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r | |
496 | }\r | |
497 | Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, '0', BytesPerOutputCharacter);\r | |
498 | } else {\r | |
499 | Buffer = BasePrintLibFillBuffer (Buffer, Precision - Count, ' ', BytesPerOutputCharacter);\r | |
500 | if (Prefix != 0) {\r | |
501 | Buffer = BasePrintLibFillBuffer (Buffer, 1, Prefix, BytesPerOutputCharacter);\r | |
502 | }\r | |
503 | }\r | |
504 | \r | |
505 | //\r | |
506 | // Output the Prefix character if it is present\r | |
507 | //\r | |
508 | Index = 0;\r | |
509 | if (Prefix) {\r | |
510 | Index++;\r | |
511 | }\r | |
512 | \r | |
513 | //\r | |
514 | // Copy the string into the output buffer performing the required type conversions\r | |
515 | //\r | |
516 | while (Index < Count) {\r | |
517 | ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;\r | |
518 | \r | |
519 | Buffer = BasePrintLibFillBuffer (Buffer, 1, ArgumentCharacter, BytesPerOutputCharacter);\r | |
520 | ArgumentString += BytesPerArgumentCharacter;\r | |
521 | Index++;\r | |
522 | if (Comma) {\r | |
523 | Digits++;\r | |
524 | if (Digits == 3) {\r | |
525 | Digits = 0;\r | |
526 | Index++;\r | |
527 | if (Index < Count) {\r | |
528 | Buffer = BasePrintLibFillBuffer (Buffer, 1, ',', BytesPerOutputCharacter);\r | |
529 | }\r | |
530 | }\r | |
531 | }\r | |
532 | }\r | |
533 | \r | |
534 | //\r | |
535 | // Pad after the string\r | |
536 | //\r | |
537 | if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {\r | |
538 | Buffer = BasePrintLibFillBuffer (Buffer, Width - Precision, ' ', BytesPerOutputCharacter);\r | |
539 | }\r | |
540 | \r | |
541 | //\r | |
542 | // Reduce the number of characters\r | |
543 | //\r | |
544 | BufferSize -= Count;\r | |
545 | \r | |
546 | //\r | |
547 | // Get the next character from the format string\r | |
548 | //\r | |
549 | Format += BytesPerFormatCharacter;\r | |
550 | \r | |
551 | //\r | |
552 | // Get the next character from the format string\r | |
553 | //\r | |
554 | FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;\r | |
555 | }\r | |
556 | \r | |
557 | //\r | |
558 | // Null terminate the Unicode or ASCII string\r | |
559 | //\r | |
560 | Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter);\r | |
4ba61e5e | 561 | //\r |
562 | // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength\r | |
563 | // Unicode characters if PcdMaximumUnicodeStringLength is not zero. \r | |
564 | //\r | |
565 | ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0));\r | |
566 | //\r | |
567 | // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength\r | |
568 | // Ascii characters if PcdMaximumUnicodeStringLength is not zero. \r | |
569 | //\r | |
570 | ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));\r | |
878ddf1f | 571 | \r |
4ba61e5e | 572 | \r |
878ddf1f | 573 | return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r |
574 | }\r | |
575 | \r | |
3f9f540d | 576 | /**\r |
577 | Worker function that produces a Null-terminated string in an output buffer \r | |
578 | based on a Null-terminated format string and variable argument list.\r | |
579 | \r | |
580 | VSPrint function to process format and place the results in Buffer. Since a \r | |
581 | VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r | |
582 | this is the main print working routine\r | |
583 | \r | |
584 | @param Buffer Character buffer to print the results of the parsing\r | |
585 | of Format into.\r | |
586 | @param BufferSize Maximum number of characters to put into buffer.\r | |
587 | Zero means no limit.\r | |
588 | @param Flags Intial flags value.\r | |
589 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r | |
590 | @param FormatString Null-terminated format string.\r | |
591 | \r | |
592 | @return Number of characters printed.\r | |
593 | \r | |
594 | **/\r | |
878ddf1f | 595 | UINTN\r |
596 | BasePrintLibSPrint (\r | |
597 | OUT CHAR8 *StartOfBuffer,\r | |
598 | IN UINTN BufferSize,\r | |
599 | IN UINTN Flags,\r | |
600 | IN CONST CHAR8 *FormatString,\r | |
601 | ...\r | |
602 | )\r | |
603 | {\r | |
604 | VA_LIST Marker;\r | |
605 | \r | |
606 | VA_START (Marker, FormatString);\r | |
607 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);\r | |
608 | }\r | |
609 | \r | |
3f9f540d | 610 | /**\r |
611 | Produces a Null-terminated Unicode string in an output buffer based on \r | |
612 | a Null-terminated Unicode format string and a VA_LIST argument list\r | |
613 | \r | |
614 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
615 | and BufferSize. \r | |
616 | The Unicode string is produced by parsing the format string specified by FormatString. \r | |
617 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
618 | contents of the format string. \r | |
619 | The length of the produced output buffer is returned.\r | |
620 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
621 | \r | |
622 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
623 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
624 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
625 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
626 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
627 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
628 | \r | |
629 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
630 | Unicode string.\r | |
631 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
632 | @param FormatString Null-terminated Unicode format string.\r | |
633 | @param Marker VA_LIST marker for the variable argument list.\r | |
634 | \r | |
635 | @return return Length of the produced output buffer.\r | |
636 | \r | |
637 | **/\r | |
878ddf1f | 638 | UINTN\r |
639 | EFIAPI\r | |
640 | UnicodeVSPrint (\r | |
641 | OUT CHAR16 *StartOfBuffer,\r | |
642 | IN UINTN BufferSize,\r | |
643 | IN CONST CHAR16 *FormatString,\r | |
644 | IN VA_LIST Marker\r | |
645 | )\r | |
646 | {\r | |
647 | return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);\r | |
648 | }\r | |
649 | \r | |
3f9f540d | 650 | /**\r |
651 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
652 | Unicode format string and variable argument list.\r | |
653 | \r | |
654 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
655 | and BufferSize.\r | |
656 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
657 | Arguments are pulled from the variable argument list based on the contents of the format string.\r | |
658 | The length of the produced output buffer is returned. \r | |
659 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
660 | \r | |
661 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
662 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
663 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
664 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
665 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
666 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
667 | \r | |
668 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
669 | Unicode string.\r | |
670 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
671 | @param FormatString Null-terminated Unicode format string.\r | |
672 | \r | |
673 | @return Length of the produced output buffer.\r | |
674 | \r | |
675 | **/\r | |
878ddf1f | 676 | UINTN\r |
677 | EFIAPI\r | |
678 | UnicodeSPrint (\r | |
679 | OUT CHAR16 *StartOfBuffer,\r | |
680 | IN UINTN BufferSize,\r | |
681 | IN CONST CHAR16 *FormatString,\r | |
682 | ...\r | |
683 | )\r | |
684 | {\r | |
685 | VA_LIST Marker;\r | |
686 | \r | |
687 | VA_START (Marker, FormatString);\r | |
688 | return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
689 | }\r | |
690 | \r | |
3f9f540d | 691 | /**\r |
692 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
693 | ASCII format string and a VA_LIST argument list\r | |
694 | \r | |
695 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
696 | and BufferSize.\r | |
697 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
698 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
699 | contents of the format string.\r | |
700 | The length of the produced output buffer is returned.\r | |
701 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
702 | \r | |
703 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
704 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
705 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
706 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
707 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
708 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
709 | \r | |
710 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
711 | Unicode string.\r | |
712 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
713 | @param FormatString Null-terminated Unicode format string.\r | |
714 | @param Marker VA_LIST marker for the variable argument list.\r | |
715 | \r | |
716 | @return Length of the produced output buffer.\r | |
717 | \r | |
718 | **/\r | |
878ddf1f | 719 | UINTN\r |
720 | EFIAPI\r | |
721 | UnicodeVSPrintAsciiFormat (\r | |
722 | OUT CHAR16 *StartOfBuffer,\r | |
723 | IN UINTN BufferSize,\r | |
724 | IN CONST CHAR8 *FormatString,\r | |
725 | IN VA_LIST Marker\r | |
726 | )\r | |
727 | {\r | |
728 | return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);\r | |
729 | }\r | |
730 | \r | |
3f9f540d | 731 | /**\r |
732 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
733 | ASCII format string and variable argument list.\r | |
734 | \r | |
735 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
736 | and BufferSize.\r | |
737 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
738 | Arguments are pulled from the variable argument list based on the contents of the \r | |
739 | format string.\r | |
740 | The length of the produced output buffer is returned.\r | |
741 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
742 | \r | |
743 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
744 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
745 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
746 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
747 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
748 | contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
749 | \r | |
750 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
751 | Unicode string.\r | |
752 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
753 | @param FormatString Null-terminated Unicode format string.\r | |
754 | \r | |
755 | @return Length of the produced output buffer.\r | |
756 | \r | |
757 | **/\r | |
878ddf1f | 758 | UINTN\r |
759 | EFIAPI\r | |
760 | UnicodeSPrintAsciiFormat (\r | |
761 | OUT CHAR16 *StartOfBuffer,\r | |
762 | IN UINTN BufferSize,\r | |
763 | IN CONST CHAR8 *FormatString,\r | |
764 | ...\r | |
765 | )\r | |
766 | {\r | |
767 | VA_LIST Marker;\r | |
768 | \r | |
769 | VA_START (Marker, FormatString);\r | |
8960cdeb | 770 | return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r |
878ddf1f | 771 | }\r |
772 | \r | |
3f9f540d | 773 | /**\r |
774 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
775 | ASCII format string and a VA_LIST argument list.\r | |
776 | \r | |
777 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
778 | and BufferSize.\r | |
779 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
780 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
781 | the contents of the format string.\r | |
782 | The length of the produced output buffer is returned.\r | |
783 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
784 | \r | |
785 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
786 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
787 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
788 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
789 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
790 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
791 | \r | |
792 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
793 | ASCII string.\r | |
794 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
795 | @param FormatString Null-terminated Unicode format string.\r | |
796 | @param Marker VA_LIST marker for the variable argument list.\r | |
797 | \r | |
798 | @return Length of the produced output buffer.\r | |
799 | \r | |
800 | **/\r | |
878ddf1f | 801 | UINTN\r |
802 | EFIAPI\r | |
803 | AsciiVSPrint (\r | |
804 | OUT CHAR8 *StartOfBuffer,\r | |
805 | IN UINTN BufferSize,\r | |
806 | IN CONST CHAR8 *FormatString,\r | |
807 | IN VA_LIST Marker\r | |
808 | )\r | |
809 | {\r | |
810 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);\r | |
811 | }\r | |
812 | \r | |
3f9f540d | 813 | /**\r |
814 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
815 | ASCII format string and variable argument list.\r | |
816 | \r | |
817 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
818 | and BufferSize.\r | |
819 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
820 | Arguments are pulled from the variable argument list based on the contents of the \r | |
821 | format string.\r | |
822 | The length of the produced output buffer is returned.\r | |
823 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
824 | \r | |
825 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
826 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
827 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
828 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
829 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
830 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
831 | \r | |
832 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
833 | ASCII string.\r | |
834 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
835 | @param FormatString Null-terminated Unicode format string.\r | |
836 | \r | |
837 | @return Length of the produced output buffer.\r | |
838 | \r | |
839 | **/\r | |
878ddf1f | 840 | UINTN\r |
841 | EFIAPI\r | |
842 | AsciiSPrint (\r | |
843 | OUT CHAR8 *StartOfBuffer,\r | |
844 | IN UINTN BufferSize,\r | |
845 | IN CONST CHAR8 *FormatString,\r | |
846 | ...\r | |
847 | )\r | |
848 | {\r | |
849 | VA_LIST Marker;\r | |
850 | \r | |
851 | VA_START (Marker, FormatString);\r | |
852 | return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
853 | }\r | |
854 | \r | |
3f9f540d | 855 | /**\r |
856 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
857 | ASCII format string and a VA_LIST argument list.\r | |
858 | \r | |
859 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
860 | and BufferSize.\r | |
861 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
862 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
863 | the contents of the format string.\r | |
864 | The length of the produced output buffer is returned.\r | |
865 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
866 | \r | |
867 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
868 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
869 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
870 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
871 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
872 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
873 | \r | |
874 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
875 | ASCII string.\r | |
876 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
877 | @param FormatString Null-terminated Unicode format string.\r | |
878 | @param Marker VA_LIST marker for the variable argument list.\r | |
879 | \r | |
880 | @return Length of the produced output buffer.\r | |
881 | \r | |
882 | **/\r | |
878ddf1f | 883 | UINTN\r |
884 | EFIAPI\r | |
885 | AsciiVSPrintUnicodeFormat (\r | |
886 | OUT CHAR8 *StartOfBuffer,\r | |
887 | IN UINTN BufferSize,\r | |
888 | IN CONST CHAR16 *FormatString,\r | |
889 | IN VA_LIST Marker\r | |
890 | )\r | |
891 | {\r | |
892 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);\r | |
893 | }\r | |
894 | \r | |
3f9f540d | 895 | /**\r |
896 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
897 | ASCII format string and variable argument list.\r | |
898 | \r | |
899 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
900 | and BufferSize.\r | |
901 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
902 | Arguments are pulled from the variable argument list based on the contents of the \r | |
903 | format string.\r | |
904 | The length of the produced output buffer is returned.\r | |
905 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r | |
906 | \r | |
907 | If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT().\r | |
908 | If BufferSize is not 0 and FormatString is NULL, then ASSERT().\r | |
909 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r | |
910 | PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
911 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r | |
912 | contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT().\r | |
913 | \r | |
914 | @param StartOfBuffer APointer to the output buffer for the produced Null-terminated \r | |
915 | ASCII string.\r | |
916 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
917 | @param FormatString Null-terminated Unicode format string.\r | |
918 | \r | |
919 | @return Length of the produced output buffer.\r | |
920 | \r | |
921 | **/\r | |
878ddf1f | 922 | UINTN\r |
923 | EFIAPI\r | |
924 | AsciiSPrintUnicodeFormat (\r | |
925 | OUT CHAR8 *StartOfBuffer,\r | |
926 | IN UINTN BufferSize,\r | |
927 | IN CONST CHAR16 *FormatString,\r | |
928 | ...\r | |
929 | )\r | |
930 | {\r | |
931 | VA_LIST Marker;\r | |
932 | \r | |
933 | VA_START (Marker, FormatString);\r | |
934 | return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
935 | }\r | |
a3657e3e | 936 | \r |
3f9f540d | 937 | /**\r |
938 | Converts a decimal value to a Null-terminated Unicode string.\r | |
939 | \r | |
940 | Converts the decimal number specified by Value to a Null-terminated Unicode \r | |
941 | string specified by Buffer containing at most Width characters.\r | |
942 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
943 | The total number of characters placed in Buffer is returned.\r | |
944 | If the conversion contains more than Width characters, then only the first\r | |
945 | Width characters are returned, and the total number of characters \r | |
946 | required to perform the conversion is returned.\r | |
947 | Additional conversion parameters are specified in Flags. \r | |
948 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
949 | All conversions are left justified in Buffer.\r | |
950 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
951 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
952 | are inserted every 3rd digit starting from the right.\r | |
953 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
954 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
955 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
956 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
957 | add up to Width characters.\r | |
958 | \r | |
959 | If Buffer is NULL, then ASSERT().\r | |
960 | If unsupported bits are set in Flags, then ASSERT().\r | |
961 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
962 | \r | |
963 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
964 | Unicode string.\r | |
965 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
966 | @param Value The 64-bit signed value to convert to a string.\r | |
24e25d11 | 967 | @param Width The maximum number of Unicode characters to place in Buffer.\r |
3f9f540d | 968 | \r |
969 | @return Total number of characters required to perform the conversion.\r | |
970 | \r | |
971 | **/\r | |
a3657e3e | 972 | UINTN\r |
973 | EFIAPI\r | |
974 | UnicodeValueToString (\r | |
975 | IN OUT CHAR16 *Buffer,\r | |
976 | IN UINTN Flags,\r | |
977 | IN INT64 Value,\r | |
978 | IN UINTN Width\r | |
979 | )\r | |
980 | {\r | |
981 | return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r | |
982 | }\r | |
983 | \r | |
3f9f540d | 984 | /**\r |
985 | Converts a decimal value to a Null-terminated ASCII string.\r | |
986 | \r | |
987 | Converts the decimal number specified by Value to a Null-terminated ASCII string \r | |
988 | specified by Buffer containing at most Width characters.\r | |
989 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
990 | The total number of characters placed in Buffer is returned.\r | |
991 | If the conversion contains more than Width characters, then only the first Width\r | |
992 | characters are returned, and the total number of characters required to perform\r | |
993 | the conversion is returned.\r | |
994 | Additional conversion parameters are specified in Flags. \r | |
995 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
996 | All conversions are left justified in Buffer.\r | |
997 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
998 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r | |
999 | are inserted every 3rd digit starting from the right.\r | |
1000 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
1001 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r | |
1002 | is padded with '0' characters so the combination of the optional '-'\r | |
1003 | sign character, '0' characters, digit characters for Value, and the \r | |
1004 | Null-terminator add up to Width characters.\r | |
1005 | \r | |
1006 | If Buffer is NULL, then ASSERT().\r | |
1007 | If unsupported bits are set in Flags, then ASSERT().\r | |
1008 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
1009 | \r | |
1010 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
1011 | ASCII string.\r | |
1012 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
1013 | @param Value The 64-bit signed value to convert to a string.\r | |
24e25d11 | 1014 | @param Width The maximum number of ASCII characters to place in Buffer.\r |
3f9f540d | 1015 | \r |
1016 | @return Total number of characters required to perform the conversion.\r | |
1017 | \r | |
1018 | **/\r | |
a3657e3e | 1019 | UINTN\r |
1020 | EFIAPI\r | |
1021 | AsciiValueToString (\r | |
1022 | IN OUT CHAR8 *Buffer,\r | |
1023 | IN UINTN Flags,\r | |
1024 | IN INT64 Value,\r | |
1025 | IN UINTN Width\r | |
1026 | )\r | |
1027 | {\r | |
1028 | return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1);\r | |
1029 | }\r |