2008-11-13 10:06:25 +01:00
|
|
|
/** @file
|
|
|
|
Language related HII Library implementation.
|
|
|
|
|
2018-06-27 15:08:52 +02:00
|
|
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:49:11 +02:00
|
|
|
This program and the accompanying materials
|
2008-11-13 10:06:25 +01:00
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
|
#include "InternalHiiLib.h"
|
|
|
|
|
|
|
|
/**
|
2018-06-27 15:08:52 +02:00
|
|
|
Retrieves a pointer to the a Null-terminated ASCII string containing the list
|
|
|
|
of languages that an HII handle in the HII Database supports. The returned
|
2009-04-14 12:47:19 +02:00
|
|
|
string is allocated using AllocatePool(). The caller is responsible for freeing
|
|
|
|
the returned string using FreePool(). The format of the returned string follows
|
|
|
|
the language format assumed the HII Database.
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
If HiiHandle is NULL, then ASSERT().
|
2008-11-13 10:06:25 +01:00
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
@param[in] HiiHandle A handle that was previously registered in the HII Database.
|
2008-11-13 10:06:25 +01:00
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
@retval NULL HiiHandle is not registered in the HII database
|
2016-10-19 09:01:25 +02:00
|
|
|
@retval NULL There are not enough resources available to retrieve the supported
|
2009-04-14 12:47:19 +02:00
|
|
|
languages.
|
2016-10-19 09:01:25 +02:00
|
|
|
@retval NULL The list of supported languages could not be retrieved.
|
2009-04-14 12:47:19 +02:00
|
|
|
@retval Other A pointer to the Null-terminated ASCII string of supported languages.
|
2008-11-13 10:06:25 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
CHAR8 *
|
|
|
|
EFIAPI
|
2009-04-14 12:47:19 +02:00
|
|
|
HiiGetSupportedLanguages (
|
2008-11-13 10:06:25 +01:00
|
|
|
IN EFI_HII_HANDLE HiiHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-04-14 12:47:19 +02:00
|
|
|
UINTN LanguageSize;
|
|
|
|
CHAR8 TempSupportedLanguages;
|
|
|
|
CHAR8 *SupportedLanguages;
|
|
|
|
|
|
|
|
ASSERT (HiiHandle != NULL);
|
2008-11-13 10:06:25 +01:00
|
|
|
|
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
// Retrieve the size required for the supported languages buffer.
|
2008-11-13 10:06:25 +01:00
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
LanguageSize = 0;
|
|
|
|
Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);
|
2009-03-27 04:23:45 +01:00
|
|
|
|
2008-11-13 10:06:25 +01:00
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
// If GetLanguages() returns EFI_SUCCESS for a zero size,
|
|
|
|
// then there are no supported languages registered for HiiHandle. If GetLanguages()
|
2009-04-14 12:47:19 +02:00
|
|
|
// returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
|
|
|
|
// in the HII Database
|
2008-11-13 10:06:25 +01:00
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
if (Status != EFI_BUFFER_TOO_SMALL) {
|
|
|
|
//
|
|
|
|
// Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database
|
|
|
|
//
|
2008-11-13 10:06:25 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
//
|
|
|
|
// Allocate the supported languages buffer.
|
|
|
|
//
|
|
|
|
SupportedLanguages = AllocateZeroPool (LanguageSize);
|
|
|
|
if (SupportedLanguages == NULL) {
|
|
|
|
//
|
|
|
|
// Return NULL if allocation fails.
|
|
|
|
//
|
|
|
|
return NULL;
|
2008-11-13 10:06:25 +01:00
|
|
|
}
|
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
//
|
|
|
|
// Retrieve the supported languages string
|
|
|
|
//
|
|
|
|
Status = gHiiString->GetLanguages (gHiiString, HiiHandle, SupportedLanguages, &LanguageSize);
|
2008-11-13 10:06:25 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2009-04-14 12:47:19 +02:00
|
|
|
//
|
|
|
|
// Free the buffer and return NULL if the supported languages can not be retrieved.
|
|
|
|
//
|
|
|
|
FreePool (SupportedLanguages);
|
|
|
|
return NULL;
|
2008-11-13 10:06:25 +01:00
|
|
|
}
|
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
//
|
|
|
|
// Return the Null-terminated ASCII string of supported languages
|
|
|
|
//
|
|
|
|
return SupportedLanguages;
|
2008-11-13 10:06:25 +01:00
|
|
|
}
|
|
|
|
|