The "HiiLib" prefix for all HII Library API function names changed to "Hii". Remove: HiiLibPreparePackageList(), replaced by HiiAddPackages() HiiLibNewString(), replaced by HiiSetString() HiiLibGetStringFromHandle(), replaced by HiiGetString() HiiLibGetStringFromToken(), replaced by HiiGetPackageString() HiiLibExtractGuidFromHiiHandle() HiiLibDevicePathToHiiHandle() HiiLibGetSupportedSecondaryLanguages() HiiLibGetSupportedLanguageNumber() HiiLibExportPackageLists() HiiLibListPackageLists() Interface change: HiiAddPackages() HiiSetString() HiiGetString() HiiGetHiiHandles() git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8083 6f19259b-4bc3-4df7-8a09-765794883524
139 lines
3.9 KiB
C
139 lines
3.9 KiB
C
/** @file
|
|
Language related HII Library implementation.
|
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation<BR>
|
|
All rights reserved. This program and the accompanying materials
|
|
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"
|
|
|
|
/**
|
|
Get next language from language code list (with separator ';').
|
|
|
|
If LangCode is NULL, then ASSERT.
|
|
If Lang is NULL, then ASSERT.
|
|
|
|
@param LangCode On input: point to first language in the list. On
|
|
output: point to next language in the list, or
|
|
NULL if no more language in the list.
|
|
@param Lang The first language in the list.
|
|
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
HiiLibGetNextLanguage (
|
|
IN OUT CHAR8 **LangCode,
|
|
OUT CHAR8 *Lang
|
|
)
|
|
{
|
|
UINTN Index;
|
|
CHAR8 *StringPtr;
|
|
|
|
ASSERT (LangCode != NULL);
|
|
ASSERT (*LangCode != NULL);
|
|
ASSERT (Lang != NULL);
|
|
|
|
Index = 0;
|
|
StringPtr = *LangCode;
|
|
while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
|
|
Index++;
|
|
}
|
|
|
|
CopyMem (Lang, StringPtr, Index);
|
|
Lang[Index] = 0;
|
|
|
|
if (StringPtr[Index] == ';') {
|
|
Index++;
|
|
}
|
|
*LangCode = StringPtr + Index;
|
|
}
|
|
|
|
|
|
/**
|
|
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
|
|
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.
|
|
|
|
If HiiHandle is NULL, then ASSERT().
|
|
|
|
@param[in] HiiHandle A handle that was previously registered in the HII Database.
|
|
|
|
@retval NULL HiiHandle is not registered in the HII database
|
|
@retval NULL There are not enough resources available to retrieve the suported
|
|
languages.
|
|
@retval NULL The list of suported languages could not be retrieved.
|
|
@retval Other A pointer to the Null-terminated ASCII string of supported languages.
|
|
|
|
**/
|
|
CHAR8 *
|
|
EFIAPI
|
|
HiiGetSupportedLanguages (
|
|
IN EFI_HII_HANDLE HiiHandle
|
|
)
|
|
{
|
|
EFI_STATUS Status;
|
|
UINTN LanguageSize;
|
|
CHAR8 TempSupportedLanguages;
|
|
CHAR8 *SupportedLanguages;
|
|
|
|
ASSERT (HiiHandle != NULL);
|
|
|
|
//
|
|
// Retrieve the size required for the supported languages buffer.
|
|
//
|
|
LanguageSize = 0;
|
|
Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);
|
|
|
|
//
|
|
// If GetLanguages() returns EFI_SUCCESS for a zero size,
|
|
// then there are no supported languages registered for HiiHandle. If GetLanguages()
|
|
// returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
|
|
// in the HII Database
|
|
//
|
|
if (Status != EFI_BUFFER_TOO_SMALL) {
|
|
//
|
|
// Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database
|
|
//
|
|
return NULL;
|
|
}
|
|
|
|
//
|
|
// Allocate the supported languages buffer.
|
|
//
|
|
SupportedLanguages = AllocateZeroPool (LanguageSize);
|
|
if (SupportedLanguages == NULL) {
|
|
//
|
|
// Return NULL if allocation fails.
|
|
//
|
|
return NULL;
|
|
}
|
|
|
|
//
|
|
// Retrieve the supported languages string
|
|
//
|
|
Status = gHiiString->GetLanguages (gHiiString, HiiHandle, SupportedLanguages, &LanguageSize);
|
|
if (EFI_ERROR (Status)) {
|
|
//
|
|
// Free the buffer and return NULL if the supported languages can not be retrieved.
|
|
//
|
|
FreePool (SupportedLanguages);
|
|
return NULL;
|
|
}
|
|
|
|
//
|
|
// Return the Null-terminated ASCII string of supported languages
|
|
//
|
|
return SupportedLanguages;
|
|
}
|
|
|