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