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