]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiLibPrint.c
Add 2 functions to UefiLib library class: CatSPrint and CatVSPrint.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
index 5ce73b0c17ef5371ab2e5551e35eb36cada3a42b..8ecb58dbe979a0c9415dd42bc529706def1b67af 100644 (file)
@@ -2,7 +2,7 @@
   Mde UEFI library API implementation.\r
   Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
 \r
-  Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -706,3 +706,97 @@ AsciiPrintXY (
   return ReturnNum;\r
 }\r
 \r
+/** \r
+  Appends a formatted Unicode string to a Null-terminated Unicode string\r
\r
+  This function appends a formatted Unicode string to the Null-terminated \r
+  Unicode string specified by String.   String is optional and may be NULL.\r
+  Storage for the formatted Unicode string returned is allocated using \r
+  AllocatePool().  The pointer to the appended string is returned.  The caller\r
+  is responsible for freeing the returned string.\r
\r
+  If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().\r
+  If FormatString is NULL, then ASSERT().\r
+  If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
\r
+  @param[in] String         A Null-terminated Unicode string.\r
+  @param[in] FormatString   A Null-terminated Unicode format string.\r
+  @param[in]  Marker        VA_LIST marker for the variable argument list.\r
+\r
+  @retval NULL    There was not enough available memory.\r
+  @return         Null-terminated Unicode string is that is the formatted \r
+                  string appended to String.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+CatVSPrint (\r
+  IN  CHAR16  *String, OPTIONAL\r
+  IN  CONST CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+{\r
+  UINTN   CharactersRequired;\r
+  UINTN   SizeRequired;\r
+  CHAR16  *BufferToReturn;\r
+\r
+  CharactersRequired = SPrintLength(FormatString, Marker);\r
+\r
+  if (String != NULL) {\r
+    SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16));\r
+  } else {\r
+    SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16));\r
+  }\r
+\r
+  BufferToReturn = AllocateZeroPool(SizeRequired);\r
+\r
+  if (BufferToReturn == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  if (String != NULL) {\r
+    StrCpy(BufferToReturn, String);\r
+  }\r
+\r
+  UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);\r
+\r
+  ASSERT(StrSize(BufferToReturn)==SizeRequired);\r
+\r
+  return (BufferToReturn);\r
+}\r
+\r
+/** \r
+  Appends a formatted Unicode string to a Null-terminated Unicode string\r
\r
+  This function appends a formatted Unicode string to the Null-terminated \r
+  Unicode string specified by String.   String is optional and may be NULL.\r
+  Storage for the formatted Unicode string returned is allocated using \r
+  AllocatePool().  The pointer to the appended string is returned.  The caller\r
+  is responsible for freeing the returned string.\r
\r
+  If String is not NULL and not aligned on a 16-bit boundary, then ASSERT().\r
+  If FormatString is NULL, then ASSERT().\r
+  If FormatString is not aligned on a 16-bit boundary, then ASSERT().\r
\r
+  @param[in] String         A Null-terminated Unicode string.\r
+  @param[in] FormatString   A Null-terminated Unicode format string.\r
+  @param[in] ...            The variable argument list whose contents are \r
+                            accessed based on the format string specified by \r
+                            FormatString.\r
+\r
+  @retval NULL    There was not enough available memory.\r
+  @return         Null-terminated Unicode string is that is the formatted \r
+                  string appended to String.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+CatSPrint (\r
+  IN  CHAR16  *String, OPTIONAL\r
+  IN  CONST CHAR16  *FormatString,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST   Marker;\r
+  VA_START (Marker, FormatString);\r
+  return (CatVSPrint(String, FormatString, Marker));\r
+}\r
+\r