]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiOnUefiHiiThunk / Strings.c
index d0b356be5141d6da6ba0597203752b9669221e7e..f246c08b5fb2d46727813505619107916770b070 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
@@ -307,8 +306,10 @@ HiiThunkGetString (
 \r
   Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
 \r
-  Iso639AsciiLanguage = NULL;\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
@@ -322,13 +323,13 @@ HiiThunkGetString (
     // in Iso639. So map it to the Language Identifier defined in RFC4646.\r
     //\r
     Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (Iso639AsciiLanguage);\r
+    FreePool (Iso639AsciiLanguage);\r
 \r
     //\r
     // If Rfc4646AsciiLanguage is NULL, more language mapping must be added to \r
     // Iso639ToRfc4646Map.\r
     //\r
     ASSERT (Rfc4646AsciiLanguage != NULL);\r
-    \r
   }\r
 \r
   UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r
@@ -337,69 +338,57 @@ HiiThunkGetString (
     goto Done;\r
   }\r
 \r
-  if (Rfc4646AsciiLanguage == NULL) {\r
-    //\r
-    // Get the languages that the package specified by HiiHandle supports\r
-    //\r
-    SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
-    if (SupportedLanguages == NULL) {\r
-      goto Error2;\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
-\r
-    //\r
-    // Get the best matching language from SupportedLanguages\r
-    //\r
-    BestLanguage = GetBestLanguage (\r
-                     SupportedLanguages, \r
-                     FALSE,                // RFC 4646 mode\r
-                     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
-      Status = EFI_INVALID_PARAMETER;\r
-      goto Done;\r
-    }\r
+  //\r
+  // Get the languages that the package specified by HiiHandle supports\r
+  //\r
+  SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
+  if (SupportedLanguages == NULL) {\r
+    goto Done;\r
+  }\r
 \r
+  //\r
+  // Get the current platform language setting\r
+  //\r
+  GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL);\r
+\r
+  //\r
+  // Get the best matching language from SupportedLanguages\r
+  //\r
+  BestLanguage = GetBestLanguage (\r
+                   SupportedLanguages, \r
+                   FALSE,                // RFC 4646 mode\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
     Status = mHiiStringProtocol->GetString (\r
                                  mHiiStringProtocol,\r
                                  BestLanguage,\r
                                  UefiHiiHandle,\r
                                  Token,\r
                                  StringBuffer,\r
-                                 BufferLengthTemp,\r
+                                 BufferLength,\r
                                  NULL\r
                                  );\r
     FreePool (BestLanguage);\r
   } else {\r
-    Status = mHiiStringProtocol->GetString (\r
-                                 mHiiStringProtocol,\r
-                                 Rfc4646AsciiLanguage,\r
-                                 UefiHiiHandle,\r
-                                 Token,\r
-                                 StringBuffer,\r
-                                 BufferLengthTemp,\r
-                                 NULL\r
-                                 );\r
+    Status = EFI_INVALID_PARAMETER;\r
   }\r
 \r
 Done:\r
-       if (Iso639AsciiLanguage != NULL) {\r
-    FreePool (Iso639AsciiLanguage);\r
+       if (Rfc4646AsciiLanguage != NULL) {\r
+    FreePool (Rfc4646AsciiLanguage);\r
+  }\r
+\r
+  if (SupportedLanguages != NULL) {\r
+    FreePool (SupportedLanguages);\r
+  }\r
+\r
+  if (PlatformLanguage != NULL) {\r
+    FreePool (PlatformLanguage);\r
   }\r
-  \r
   return Status;\r
 }\r
 \r
@@ -415,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