]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Library / UefiHiiLib / HiiLanguage.c
CommitLineData
08e4b3cf 1/** @file\r
2 Language related HII Library implementation.\r
3\r
d1102dba 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5 This program and the accompanying materials\r
08e4b3cf 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**/\r
14\r
15\r
16#include "InternalHiiLib.h"\r
17\r
08e4b3cf 18/**\r
d1102dba
LG
19 Retrieves a pointer to the a Null-terminated ASCII string containing the list\r
20 of languages that an HII handle in the HII Database supports. The returned\r
cb7d01c0 21 string is allocated using AllocatePool(). The caller is responsible for freeing\r
22 the returned string using FreePool(). The format of the returned string follows\r
23 the language format assumed the HII Database.\r
d1102dba 24\r
cb7d01c0 25 If HiiHandle is NULL, then ASSERT().\r
08e4b3cf 26\r
cb7d01c0 27 @param[in] HiiHandle A handle that was previously registered in the HII Database.\r
08e4b3cf 28\r
cb7d01c0 29 @retval NULL HiiHandle is not registered in the HII database\r
3b28e744 30 @retval NULL There are not enough resources available to retrieve the supported\r
cb7d01c0 31 languages.\r
3b28e744 32 @retval NULL The list of supported languages could not be retrieved.\r
cb7d01c0 33 @retval Other A pointer to the Null-terminated ASCII string of supported languages.\r
08e4b3cf 34\r
35**/\r
36CHAR8 *\r
37EFIAPI\r
cb7d01c0 38HiiGetSupportedLanguages (\r
08e4b3cf 39 IN EFI_HII_HANDLE HiiHandle\r
40 )\r
41{\r
42 EFI_STATUS Status;\r
cb7d01c0 43 UINTN LanguageSize;\r
44 CHAR8 TempSupportedLanguages;\r
45 CHAR8 *SupportedLanguages;\r
46\r
47 ASSERT (HiiHandle != NULL);\r
08e4b3cf 48\r
08e4b3cf 49 //\r
cb7d01c0 50 // Retrieve the size required for the supported languages buffer.\r
08e4b3cf 51 //\r
cb7d01c0 52 LanguageSize = 0;\r
53 Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);\r
ea7cd3ec 54\r
08e4b3cf 55 //\r
d1102dba
LG
56 // If GetLanguages() returns EFI_SUCCESS for a zero size,\r
57 // then there are no supported languages registered for HiiHandle. If GetLanguages()\r
cb7d01c0 58 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present\r
59 // in the HII Database\r
08e4b3cf 60 //\r
cb7d01c0 61 if (Status != EFI_BUFFER_TOO_SMALL) {\r
62 //\r
63 // Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database\r
64 //\r
08e4b3cf 65 return NULL;\r
66 }\r
67\r
cb7d01c0 68 //\r
69 // Allocate the supported languages buffer.\r
70 //\r
71 SupportedLanguages = AllocateZeroPool (LanguageSize);\r
72 if (SupportedLanguages == NULL) {\r
73 //\r
74 // Return NULL if allocation fails.\r
75 //\r
76 return NULL;\r
08e4b3cf 77 }\r
78\r
cb7d01c0 79 //\r
80 // Retrieve the supported languages string\r
81 //\r
82 Status = gHiiString->GetLanguages (gHiiString, HiiHandle, SupportedLanguages, &LanguageSize);\r
08e4b3cf 83 if (EFI_ERROR (Status)) {\r
cb7d01c0 84 //\r
85 // Free the buffer and return NULL if the supported languages can not be retrieved.\r
86 //\r
87 FreePool (SupportedLanguages);\r
88 return NULL;\r
08e4b3cf 89 }\r
90\r
cb7d01c0 91 //\r
92 // Return the Null-terminated ASCII string of supported languages\r
93 //\r
94 return SupportedLanguages;\r
08e4b3cf 95}\r
96\r