TianoCore EDK2 master
Loading...
Searching...
No Matches
HiiLanguage.c
Go to the documentation of this file.
1
9#include "InternalHiiLib.h"
10
29CHAR8 *
30EFIAPI
32 IN EFI_HII_HANDLE HiiHandle
33 )
34{
35 EFI_STATUS Status;
36 UINTN LanguageSize;
37 CHAR8 TempSupportedLanguages;
38 CHAR8 *SupportedLanguages;
39
40 ASSERT (HiiHandle != NULL);
41
42 //
43 // Retrieve the size required for the supported languages buffer.
44 //
45 LanguageSize = 0;
46 Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);
47
48 //
49 // If GetLanguages() returns EFI_SUCCESS for a zero size,
50 // then there are no supported languages registered for HiiHandle. If GetLanguages()
51 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
52 // in the HII Database
53 //
54 if (Status != EFI_BUFFER_TOO_SMALL) {
55 //
56 // Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database
57 //
58 return NULL;
59 }
60
61 //
62 // Allocate the supported languages buffer.
63 //
64 SupportedLanguages = AllocateZeroPool (LanguageSize);
65 if (SupportedLanguages == NULL) {
66 //
67 // Return NULL if allocation fails.
68 //
69 return NULL;
70 }
71
72 //
73 // Retrieve the supported languages string
74 //
75 Status = gHiiString->GetLanguages (gHiiString, HiiHandle, SupportedLanguages, &LanguageSize);
76 if (EFI_ERROR (Status)) {
77 //
78 // Free the buffer and return NULL if the supported languages can not be retrieved.
79 //
80 FreePool (SupportedLanguages);
81 return NULL;
82 }
83
84 //
85 // Return the Null-terminated ASCII string of supported languages
86 //
87 return SupportedLanguages;
88}
UINT64 UINTN
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
CHAR8 *EFIAPI HiiGetSupportedLanguages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLanguage.c:31
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_HII_STRING_PROTOCOL * gHiiString
VOID * EFI_HII_HANDLE