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