]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c
Fix a potential bug that GetLanguages() API may return incorrect languages in a strin...
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / R8Lib.c
CommitLineData
e90b081a 1/** @file\r
2Implement a utility function named R8_EfiLibCompareLanguage.\r
3\r
36fe40c2 4 Copyright (c) 2007 - 2008, Intel Corporation\r
93e3992d 5\r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14\r
15**/\r
16\r
17#include "HiiDatabase.h"\r
18\r
19\r
93e3992d 20/**\r
21 Compare whether two names of languages are identical.\r
22\r
23 @param Language1 Name of language 1\r
24 @param Language2 Name of language 2\r
25\r
26 @retval TRUE same\r
27 @retval FALSE not same\r
28\r
29**/\r
30BOOLEAN\r
31R8_EfiLibCompareLanguage (\r
32 IN CHAR8 *Language1,\r
33 IN CHAR8 *Language2\r
34 )\r
35{\r
36 //\r
37 // Porting Guide:\r
38 // This library interface is simply obsolete.\r
39 // Include the source code to user code.\r
40 //\r
41 UINTN Index;\r
42\r
43 for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {\r
44 if (Language1[Index] != Language2[Index]) {\r
45 return FALSE;\r
46 }\r
47 }\r
48\r
49 if (((Language1[Index] == 0) && (Language2[Index] == 0)) || \r
50 ((Language1[Index] == 0) && (Language2[Index] != ';')) ||\r
51 ((Language1[Index] == ';') && (Language2[Index] != 0)) ||\r
52 ((Language1[Index] == ';') && (Language2[Index] != ';'))) {\r
53 return TRUE;\r
54 }\r
55\r
56 return FALSE;\r
57}\r
58\r
59\r
8db9d51d 60/**\r
61 Determine what is the current language setting. The space reserved for Lang\r
62 must be at least RFC_3066_ENTRY_SIZE bytes;\r
63\r
64 If Lang is NULL, then ASSERT.\r
65\r
66 @param Lang Pointer of system language. Lang will always be filled with \r
67 a valid RFC 3066 language string. If "PlatformLang" is not\r
68 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r
69 is returned.\r
70\r
71 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r
72 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r
73\r
74**/\r
75EFI_STATUS\r
76EFIAPI\r
77GetCurrentLanguage (\r
78 OUT CHAR8 *Lang\r
79 )\r
80{\r
81 EFI_STATUS Status;\r
82 UINTN Size;\r
83\r
84 ASSERT (Lang != NULL);\r
85\r
86 //\r
87 // Get current language setting\r
88 //\r
89 Size = RFC_3066_ENTRY_SIZE;\r
90 Status = gRT->GetVariable (\r
91 L"PlatformLang",\r
92 &gEfiGlobalVariableGuid,\r
93 NULL,\r
94 &Size,\r
95 Lang\r
96 );\r
97\r
98 if (EFI_ERROR (Status)) {\r
99 AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang));\r
100 }\r
101\r
102 return Status;\r
103}\r
104\r
93e3992d 105\r