https://bugzilla.tianocore.org/show_bug.cgi?id=1373 Replace BSD 2-Clause License with BSD+Patent License. This change is based on the following emails: https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html RFCs with detailed process for the license change: V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
		
			
				
	
	
		
			91 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /** @file
 | |
|   Language related HII Library implementation.
 | |
| 
 | |
|   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 | |
|   SPDX-License-Identifier: BSD-2-Clause-Patent
 | |
| 
 | |
| **/
 | |
| 
 | |
| 
 | |
| #include "InternalHiiLib.h"
 | |
| 
 | |
| /**
 | |
|   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 supported
 | |
|                  languages.
 | |
|   @retval NULL   The list of supported 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;
 | |
| }
 | |
| 
 |