]>
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 | |
add13dc2 | 60 | this is the main print working routine.\r |
878ddf1f | 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 |
add13dc2 | 66 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.\r |
3f9f540d | 67 | @param Format Null-terminated format string.\r |
68 | @param Marker Vararg list consumed by processing Format.\r | |
878ddf1f | 69 | \r |
add13dc2 | 70 | @return Number of characters printed not including the Null-terminator.\r |
878ddf1f | 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 |
add13dc2 | 130 | // Make sure format string cannot contain more than PcdMaximumAsciiStringLength\r |
131 | // Ascii characters if PcdMaximumAsciiStringLength is not zero. \r | |
4ba61e5e | 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 | |
add13dc2 | 509 | if (Prefix != 0) {\r |
878ddf1f | 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 | |
add13dc2 | 560 | 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 | |
add13dc2 | 567 | // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength\r |
568 | // ASCII characters if PcdMaximumAsciiStringLength is not zero. \r | |
4ba61e5e | 569 | //\r |
570 | ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));\r | |
4ba61e5e | 571 | \r |
878ddf1f | 572 | return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);\r |
573 | }\r | |
574 | \r | |
3f9f540d | 575 | /**\r |
576 | Worker function that produces a Null-terminated string in an output buffer \r | |
577 | based on a Null-terminated format string and variable argument list.\r | |
578 | \r | |
579 | VSPrint function to process format and place the results in Buffer. Since a \r | |
580 | VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r | |
add13dc2 | 581 | this is the main print working routine.\r |
3f9f540d | 582 | \r |
583 | @param Buffer Character buffer to print the results of the parsing\r | |
584 | of Format into.\r | |
585 | @param BufferSize Maximum number of characters to put into buffer.\r | |
586 | Zero means no limit.\r | |
587 | @param Flags Intial flags value.\r | |
588 | Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r | |
589 | @param FormatString Null-terminated format string.\r | |
590 | \r | |
add13dc2 | 591 | @return Number of characters printed not including the Null-terminator.\r |
3f9f540d | 592 | \r |
593 | **/\r | |
878ddf1f | 594 | UINTN\r |
595 | BasePrintLibSPrint (\r | |
596 | OUT CHAR8 *StartOfBuffer,\r | |
597 | IN UINTN BufferSize,\r | |
598 | IN UINTN Flags,\r | |
599 | IN CONST CHAR8 *FormatString,\r | |
600 | ...\r | |
601 | )\r | |
602 | {\r | |
603 | VA_LIST Marker;\r | |
604 | \r | |
605 | VA_START (Marker, FormatString);\r | |
606 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);\r | |
607 | }\r | |
608 | \r | |
3f9f540d | 609 | /**\r |
610 | Produces a Null-terminated Unicode string in an output buffer based on \r | |
611 | a Null-terminated Unicode format string and a VA_LIST argument list\r | |
612 | \r | |
613 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
614 | and BufferSize. \r | |
615 | The Unicode string is produced by parsing the format string specified by FormatString. \r | |
616 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
617 | contents of the format string. \r | |
add13dc2 | 618 | The number of Unicode characters in the produced output buffer is returned not including\r |
619 | the Null-terminator.\r | |
620 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
3f9f540d | 621 | \r |
add13dc2 | 622 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r |
623 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
3f9f540d | 624 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r |
add13dc2 | 625 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r |
626 | ASSERT().\r | |
3f9f540d | 627 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r |
add13dc2 | 628 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r |
629 | Null-terminator, then ASSERT().\r | |
3f9f540d | 630 | \r |
add13dc2 | 631 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 632 | Unicode string.\r |
633 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
634 | @param FormatString Null-terminated Unicode format string.\r | |
635 | @param Marker VA_LIST marker for the variable argument list.\r | |
636 | \r | |
add13dc2 | 637 | @return The number of Unicode characters in the produced output buffer not including the\r |
638 | Null-terminator.\r | |
3f9f540d | 639 | \r |
640 | **/\r | |
878ddf1f | 641 | UINTN\r |
642 | EFIAPI\r | |
643 | UnicodeVSPrint (\r | |
644 | OUT CHAR16 *StartOfBuffer,\r | |
645 | IN UINTN BufferSize,\r | |
646 | IN CONST CHAR16 *FormatString,\r | |
647 | IN VA_LIST Marker\r | |
648 | )\r | |
649 | {\r | |
650 | return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);\r | |
651 | }\r | |
652 | \r | |
3f9f540d | 653 | /**\r |
654 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
655 | Unicode format string and variable argument list.\r | |
656 | \r | |
657 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
658 | and BufferSize.\r | |
659 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
660 | Arguments are pulled from the variable argument list based on the contents of the format string.\r | |
add13dc2 | 661 | The number of Unicode characters in the produced output buffer is returned not including\r |
662 | the Null-terminator.\r | |
663 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
3f9f540d | 664 | \r |
add13dc2 | 665 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r |
666 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
3f9f540d | 667 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than \r |
add13dc2 | 668 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r |
669 | ASSERT().\r | |
3f9f540d | 670 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r |
add13dc2 | 671 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r |
672 | Null-terminator, then ASSERT().\r | |
3f9f540d | 673 | \r |
add13dc2 | 674 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 675 | Unicode string.\r |
676 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
677 | @param FormatString Null-terminated Unicode format string.\r | |
678 | \r | |
add13dc2 | 679 | @return The number of Unicode characters in the produced output buffer not including the\r |
680 | Null-terminator.\r | |
3f9f540d | 681 | \r |
682 | **/\r | |
878ddf1f | 683 | UINTN\r |
684 | EFIAPI\r | |
685 | UnicodeSPrint (\r | |
686 | OUT CHAR16 *StartOfBuffer,\r | |
687 | IN UINTN BufferSize,\r | |
688 | IN CONST CHAR16 *FormatString,\r | |
689 | ...\r | |
690 | )\r | |
691 | {\r | |
692 | VA_LIST Marker;\r | |
693 | \r | |
694 | VA_START (Marker, FormatString);\r | |
695 | return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
696 | }\r | |
697 | \r | |
3f9f540d | 698 | /**\r |
699 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated\r | |
700 | ASCII format string and a VA_LIST argument list\r | |
701 | \r | |
702 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
703 | and BufferSize.\r | |
704 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
705 | Arguments are pulled from the variable argument list specified by Marker based on the \r | |
706 | contents of the format string.\r | |
add13dc2 | 707 | The number of Unicode characters in the produced output buffer is returned not including\r |
708 | the Null-terminator.\r | |
709 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
710 | \r | |
711 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
712 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
713 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
714 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
715 | ASSERT().\r | |
3f9f540d | 716 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r |
add13dc2 | 717 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r |
718 | Null-terminator, then ASSERT().\r | |
3f9f540d | 719 | \r |
add13dc2 | 720 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 721 | Unicode string.\r |
722 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
723 | @param FormatString Null-terminated Unicode format string.\r | |
724 | @param Marker VA_LIST marker for the variable argument list.\r | |
725 | \r | |
add13dc2 | 726 | @return The number of Unicode characters in the produced output buffer not including the\r |
727 | Null-terminator.\r | |
3f9f540d | 728 | \r |
729 | **/\r | |
878ddf1f | 730 | UINTN\r |
731 | EFIAPI\r | |
732 | UnicodeVSPrintAsciiFormat (\r | |
733 | OUT CHAR16 *StartOfBuffer,\r | |
734 | IN UINTN BufferSize,\r | |
735 | IN CONST CHAR8 *FormatString,\r | |
736 | IN VA_LIST Marker\r | |
737 | )\r | |
738 | {\r | |
739 | return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);\r | |
740 | }\r | |
741 | \r | |
3f9f540d | 742 | /**\r |
743 | Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated \r | |
744 | ASCII format string and variable argument list.\r | |
745 | \r | |
746 | Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer\r | |
747 | and BufferSize.\r | |
748 | The Unicode string is produced by parsing the format string specified by FormatString.\r | |
749 | Arguments are pulled from the variable argument list based on the contents of the \r | |
750 | format string.\r | |
add13dc2 | 751 | The number of Unicode characters in the produced output buffer is returned not including\r |
752 | the Null-terminator.\r | |
753 | If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.\r | |
754 | \r | |
755 | If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().\r | |
756 | If BufferSize > 1 and FormatString is NULL, then ASSERT().\r | |
757 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
758 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
759 | ASSERT().\r | |
3f9f540d | 760 | If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string\r |
add13dc2 | 761 | contains more than PcdMaximumUnicodeStringLength Unicode characters not including the\r |
762 | Null-terminator, then ASSERT().\r | |
3f9f540d | 763 | \r |
add13dc2 | 764 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 765 | Unicode string.\r |
766 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
767 | @param FormatString Null-terminated Unicode format string.\r | |
768 | \r | |
add13dc2 | 769 | @return The number of Unicode characters in the produced output buffer not including the\r |
770 | Null-terminator.\r | |
3f9f540d | 771 | \r |
772 | **/\r | |
878ddf1f | 773 | UINTN\r |
774 | EFIAPI\r | |
775 | UnicodeSPrintAsciiFormat (\r | |
776 | OUT CHAR16 *StartOfBuffer,\r | |
777 | IN UINTN BufferSize,\r | |
778 | IN CONST CHAR8 *FormatString,\r | |
779 | ...\r | |
780 | )\r | |
781 | {\r | |
782 | VA_LIST Marker;\r | |
783 | \r | |
784 | VA_START (Marker, FormatString);\r | |
8960cdeb | 785 | return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r |
878ddf1f | 786 | }\r |
787 | \r | |
3f9f540d | 788 | /**\r |
789 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
790 | ASCII format string and a VA_LIST argument list.\r | |
791 | \r | |
792 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
793 | and BufferSize.\r | |
794 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
795 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
796 | the contents of the format string.\r | |
add13dc2 | 797 | The number of ASCII characters in the produced output buffer is returned not including\r |
798 | the Null-terminator.\r | |
3f9f540d | 799 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r |
800 | \r | |
add13dc2 | 801 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r |
802 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
803 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
804 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
805 | ASSERT().\r | |
806 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
807 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
808 | Null-terminator, then ASSERT().\r | |
3f9f540d | 809 | \r |
add13dc2 | 810 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 811 | ASCII string.\r |
812 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
813 | @param FormatString Null-terminated Unicode format string.\r | |
814 | @param Marker VA_LIST marker for the variable argument list.\r | |
815 | \r | |
add13dc2 | 816 | @return The number of ASCII characters in the produced output buffer not including the\r |
817 | Null-terminator.\r | |
3f9f540d | 818 | \r |
819 | **/\r | |
878ddf1f | 820 | UINTN\r |
821 | EFIAPI\r | |
822 | AsciiVSPrint (\r | |
823 | OUT CHAR8 *StartOfBuffer,\r | |
824 | IN UINTN BufferSize,\r | |
825 | IN CONST CHAR8 *FormatString,\r | |
826 | IN VA_LIST Marker\r | |
827 | )\r | |
828 | {\r | |
829 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);\r | |
830 | }\r | |
831 | \r | |
3f9f540d | 832 | /**\r |
833 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
834 | ASCII format string and variable argument list.\r | |
835 | \r | |
836 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
837 | and BufferSize.\r | |
838 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
839 | Arguments are pulled from the variable argument list based on the contents of the \r | |
840 | format string.\r | |
add13dc2 | 841 | The number of ASCII characters in the produced output buffer is returned not including\r |
842 | the Null-terminator.\r | |
3f9f540d | 843 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r |
844 | \r | |
add13dc2 | 845 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r |
846 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
847 | If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than\r | |
848 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then\r | |
849 | ASSERT().\r | |
850 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
851 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
852 | Null-terminator, then ASSERT().\r | |
3f9f540d | 853 | \r |
add13dc2 | 854 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 855 | ASCII string.\r |
856 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
857 | @param FormatString Null-terminated Unicode format string.\r | |
858 | \r | |
add13dc2 | 859 | @return The number of ASCII characters in the produced output buffer not including the\r |
860 | Null-terminator.\r | |
3f9f540d | 861 | \r |
862 | **/\r | |
878ddf1f | 863 | UINTN\r |
864 | EFIAPI\r | |
865 | AsciiSPrint (\r | |
866 | OUT CHAR8 *StartOfBuffer,\r | |
867 | IN UINTN BufferSize,\r | |
868 | IN CONST CHAR8 *FormatString,\r | |
869 | ...\r | |
870 | )\r | |
871 | {\r | |
872 | VA_LIST Marker;\r | |
873 | \r | |
874 | VA_START (Marker, FormatString);\r | |
875 | return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
876 | }\r | |
877 | \r | |
3f9f540d | 878 | /**\r |
879 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
880 | ASCII format string and a VA_LIST argument list.\r | |
881 | \r | |
882 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
883 | and BufferSize.\r | |
884 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
885 | Arguments are pulled from the variable argument list specified by Marker based on \r | |
886 | the contents of the format string.\r | |
add13dc2 | 887 | The number of ASCII characters in the produced output buffer is returned not including\r |
888 | the Null-terminator.\r | |
3f9f540d | 889 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r |
890 | \r | |
add13dc2 | 891 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r |
892 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
893 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
894 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
895 | ASSERT().\r | |
896 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
897 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
898 | Null-terminator, then ASSERT().\r | |
3f9f540d | 899 | \r |
add13dc2 | 900 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 901 | ASCII string.\r |
902 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
903 | @param FormatString Null-terminated Unicode format string.\r | |
904 | @param Marker VA_LIST marker for the variable argument list.\r | |
905 | \r | |
add13dc2 | 906 | @return The number of ASCII characters in the produced output buffer not including the\r |
907 | Null-terminator.\r | |
3f9f540d | 908 | \r |
909 | **/\r | |
878ddf1f | 910 | UINTN\r |
911 | EFIAPI\r | |
912 | AsciiVSPrintUnicodeFormat (\r | |
913 | OUT CHAR8 *StartOfBuffer,\r | |
914 | IN UINTN BufferSize,\r | |
915 | IN CONST CHAR16 *FormatString,\r | |
916 | IN VA_LIST Marker\r | |
917 | )\r | |
918 | {\r | |
919 | return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);\r | |
920 | }\r | |
921 | \r | |
3f9f540d | 922 | /**\r |
923 | Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated\r | |
924 | ASCII format string and variable argument list.\r | |
925 | \r | |
926 | Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer\r | |
927 | and BufferSize.\r | |
928 | The ASCII string is produced by parsing the format string specified by FormatString.\r | |
929 | Arguments are pulled from the variable argument list based on the contents of the \r | |
930 | format string.\r | |
add13dc2 | 931 | The number of ASCII characters in the produced output buffer is returned not including\r |
932 | the Null-terminator.\r | |
3f9f540d | 933 | If BufferSize is 0, then no output buffer is produced and 0 is returned.\r |
934 | \r | |
add13dc2 | 935 | If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().\r |
936 | If BufferSize > 0 and FormatString is NULL, then ASSERT().\r | |
937 | If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than\r | |
938 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then\r | |
939 | ASSERT().\r | |
940 | If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string\r | |
941 | contains more than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
942 | Null-terminator, then ASSERT().\r | |
3f9f540d | 943 | \r |
add13dc2 | 944 | @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated \r |
3f9f540d | 945 | ASCII string.\r |
946 | @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r | |
947 | @param FormatString Null-terminated Unicode format string.\r | |
948 | \r | |
add13dc2 | 949 | @return The number of ASCII characters in the produced output buffer not including the\r |
950 | Null-terminator.\r | |
3f9f540d | 951 | \r |
952 | **/\r | |
878ddf1f | 953 | UINTN\r |
954 | EFIAPI\r | |
955 | AsciiSPrintUnicodeFormat (\r | |
956 | OUT CHAR8 *StartOfBuffer,\r | |
957 | IN UINTN BufferSize,\r | |
958 | IN CONST CHAR16 *FormatString,\r | |
959 | ...\r | |
960 | )\r | |
961 | {\r | |
962 | VA_LIST Marker;\r | |
963 | \r | |
964 | VA_START (Marker, FormatString);\r | |
965 | return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r | |
966 | }\r | |
a3657e3e | 967 | \r |
3f9f540d | 968 | /**\r |
969 | Converts a decimal value to a Null-terminated Unicode string.\r | |
970 | \r | |
971 | Converts the decimal number specified by Value to a Null-terminated Unicode \r | |
972 | string specified by Buffer containing at most Width characters.\r | |
973 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
add13dc2 | 974 | The number of Unicode characters in Buffer is returned not including the Null-terminator.\r |
3f9f540d | 975 | If the conversion contains more than Width characters, then only the first\r |
976 | Width characters are returned, and the total number of characters \r | |
977 | required to perform the conversion is returned.\r | |
978 | Additional conversion parameters are specified in Flags. \r | |
979 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
980 | All conversions are left justified in Buffer.\r | |
981 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
982 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas\r | |
983 | are inserted every 3rd digit starting from the right.\r | |
984 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
985 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, \r | |
986 | then Buffer is padded with '0' characters so the combination of the optional '-' \r | |
987 | sign character, '0' characters, digit characters for Value, and the Null-terminator\r | |
988 | add up to Width characters.\r | |
989 | \r | |
990 | If Buffer is NULL, then ASSERT().\r | |
991 | If unsupported bits are set in Flags, then ASSERT().\r | |
992 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
993 | \r | |
994 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
995 | Unicode string.\r | |
996 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
997 | @param Value The 64-bit signed value to convert to a string.\r | |
add13dc2 | 998 | @param Width The maximum number of Unicode characters to place in Buffer.\r |
3f9f540d | 999 | \r |
add13dc2 | 1000 | @return The number of Unicode characters in Buffer not including the Null-terminator.\r |
3f9f540d | 1001 | \r |
1002 | **/\r | |
a3657e3e | 1003 | UINTN\r |
1004 | EFIAPI\r | |
1005 | UnicodeValueToString (\r | |
1006 | IN OUT CHAR16 *Buffer,\r | |
1007 | IN UINTN Flags,\r | |
1008 | IN INT64 Value,\r | |
1009 | IN UINTN Width\r | |
1010 | )\r | |
1011 | {\r | |
1012 | return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);\r | |
1013 | }\r | |
1014 | \r | |
3f9f540d | 1015 | /**\r |
1016 | Converts a decimal value to a Null-terminated ASCII string.\r | |
1017 | \r | |
1018 | Converts the decimal number specified by Value to a Null-terminated ASCII string \r | |
1019 | specified by Buffer containing at most Width characters.\r | |
1020 | If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.\r | |
add13dc2 | 1021 | The number of ASCII characters in Buffer is returned not including the Null-terminator.\r |
3f9f540d | 1022 | If the conversion contains more than Width characters, then only the first Width\r |
1023 | characters are returned, and the total number of characters required to perform\r | |
1024 | the conversion is returned.\r | |
1025 | Additional conversion parameters are specified in Flags. \r | |
1026 | The Flags bit LEFT_JUSTIFY is always ignored.\r | |
1027 | All conversions are left justified in Buffer.\r | |
1028 | If Width is 0, PREFIX_ZERO is ignored in Flags.\r | |
1029 | If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas \r | |
1030 | are inserted every 3rd digit starting from the right.\r | |
1031 | If Value is < 0, then the fist character in Buffer is a '-'.\r | |
1032 | If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer\r | |
1033 | is padded with '0' characters so the combination of the optional '-'\r | |
1034 | sign character, '0' characters, digit characters for Value, and the \r | |
1035 | Null-terminator add up to Width characters.\r | |
1036 | \r | |
1037 | If Buffer is NULL, then ASSERT().\r | |
1038 | If unsupported bits are set in Flags, then ASSERT().\r | |
1039 | If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()\r | |
1040 | \r | |
1041 | @param Buffer Pointer to the output buffer for the produced Null-terminated\r | |
1042 | ASCII string.\r | |
1043 | @param Flags The bitmask of flags that specify left justification, zero pad, and commas.\r | |
1044 | @param Value The 64-bit signed value to convert to a string.\r | |
add13dc2 | 1045 | @param Width The maximum number of ASCII characters to place in Buffer.\r |
3f9f540d | 1046 | \r |
add13dc2 | 1047 | @return The number of ASCII characters in Buffer not including the Null-terminator.\r |
3f9f540d | 1048 | \r |
1049 | **/\r | |
a3657e3e | 1050 | UINTN\r |
1051 | EFIAPI\r | |
1052 | AsciiValueToString (\r | |
1053 | IN OUT CHAR8 *Buffer,\r | |
1054 | IN UINTN Flags,\r | |
1055 | IN INT64 Value,\r | |
1056 | IN UINTN Width\r | |
1057 | )\r | |
1058 | {\r | |
1059 | return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1);\r | |
1060 | }\r |