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