]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
Add new interface GetVariable2 and GetEfiGlobalVariable2 to return more info. Also...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiOnUefiHiiThunk / Strings.c
index d83750bc9b8f16bd70e89e7a19dffee64e50140b..3b14c75df5702f17f555f8bd38e5506f8f784850 100644 (file)
@@ -1,8 +1,8 @@
-/**@file\r
+/** @file\r
   This file implements the protocol functions related to string package.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2012, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -135,7 +135,7 @@ UpdateString (
                          identifier, indicating the language to print. A string consisting of\r
                          all spaces indicates that the string is applicable to all languages.\r
   @param Handle          The handle of the language pack to which the string is to be added.\r
-  @param Token           The string token assigned to the string.\r
+  @param Reference       The string token assigned to the string.\r
   @param NewString       The string to be added.\r
 \r
 \r
@@ -143,7 +143,6 @@ UpdateString (
   @retval EFI_INVALID_PARAMETER   The Handle was unknown. The string is not created or updated in the\r
                                   the string package.\r
 **/\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 HiiNewString (\r
@@ -292,7 +291,7 @@ HiiThunkGetString (
   IN     STRING_REF                 Token,\r
   IN     BOOLEAN                    Raw,\r
   IN     CHAR16                     *LanguageString,\r
-  IN OUT UINTN                      *BufferLengthTemp,\r
+  IN OUT UINTN                      *BufferLength,\r
   OUT    EFI_STRING                 StringBuffer\r
   )\r
 {\r
@@ -308,6 +307,9 @@ HiiThunkGetString (
   Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
 \r
   Rfc4646AsciiLanguage = NULL;\r
+  SupportedLanguages   = NULL;\r
+  PlatformLanguage     = NULL;\r
+  Status               = EFI_SUCCESS;\r
 \r
   if (LanguageString != NULL) {\r
     Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
@@ -328,7 +330,6 @@ HiiThunkGetString (
     // Iso639ToRfc4646Map.\r
     //\r
     ASSERT (Rfc4646AsciiLanguage != NULL);\r
-    \r
   }\r
 \r
   UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r
@@ -342,16 +343,13 @@ HiiThunkGetString (
   //\r
   SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
   if (SupportedLanguages == NULL) {\r
-    goto Error2;\r
+    goto Done;\r
   }\r
 \r
   //\r
   // Get the current platform language setting\r
   //\r
-  PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
-  if (PlatformLanguage == NULL) {\r
-    goto Error1;\r
-  }\r
+  GetEfiGlobalVariable2 (L"PlatformLang", &PlatformLanguage, NULL);\r
 \r
   //\r
   // Get the best matching language from SupportedLanguages\r
@@ -359,36 +357,38 @@ HiiThunkGetString (
   BestLanguage = GetBestLanguage (\r
                    SupportedLanguages, \r
                    FALSE,                // RFC 4646 mode\r
-                   (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "",\r
-                   PlatformLanguage,     // Next highest priority\r
+                   (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "", // Highest priority \r
+                   (PlatformLanguage != NULL) ? PlatformLanguage : "",         // Next highest priority\r
                    SupportedLanguages,   // Lowest priority \r
                    NULL\r
                    );\r
-  if (BestLanguage == NULL) {\r
-    FreePool (PlatformLanguage);\r
-Error1:\r
-    FreePool (SupportedLanguages);\r
-Error2:\r
+  if (BestLanguage != NULL) {\r
+    Status = mHiiStringProtocol->GetString (\r
+                                 mHiiStringProtocol,\r
+                                 BestLanguage,\r
+                                 UefiHiiHandle,\r
+                                 Token,\r
+                                 StringBuffer,\r
+                                 BufferLength,\r
+                                 NULL\r
+                                 );\r
+    FreePool (BestLanguage);\r
+  } else {\r
     Status = EFI_INVALID_PARAMETER;\r
-    goto Done;\r
   }\r
 \r
-  Status = mHiiStringProtocol->GetString (\r
-                               mHiiStringProtocol,\r
-                               BestLanguage,\r
-                               UefiHiiHandle,\r
-                               Token,\r
-                               StringBuffer,\r
-                               BufferLengthTemp,\r
-                               NULL\r
-                               );\r
-  FreePool (BestLanguage);\r
-\r
 Done:\r
        if (Rfc4646AsciiLanguage != NULL) {\r
     FreePool (Rfc4646AsciiLanguage);\r
   }\r
-  \r
+\r
+  if (SupportedLanguages != NULL) {\r
+    FreePool (SupportedLanguages);\r
+  }\r
+\r
+  if (PlatformLanguage != NULL) {\r
+    FreePool (PlatformLanguage);\r
+  }\r
   return Status;\r
 }\r
 \r
@@ -404,9 +404,10 @@ Done:
   @param This            A pointer to the EFI_HII_PROTOCOL instance.\r
   @param Handle          The HII handle on which the string resides.\r
   @param Token           The string token assigned to the string.\r
-  @param Raw             If TRUE, the string is returned unedited in the internal storage format described\r
-                         above. If false, the string returned is edited by replacing <cr> with <space>\r
-                         and by removing special characters such as the <wide> prefix.\r
+  @param Index           On input, the offset into the string where the line is to start.\r
+                         On output, the index is updated to point to beyond the last character returned\r
+                         in the call.\r
+  @param LineWidth       The maximum width of the line in units of narrow glyphs.\r
   @param LanguageString  Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
                          identifier, indicating the language to print. If the LanguageString is empty (starts\r
                          with a NULL), the default system language will be used to determine the language.\r