2 Language related HII Library implementation.
4 Copyright (c) 2006 - 2008, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "InternalHiiLib.h"
19 Get next language from language code list (with separator ';').
21 If LangCode is NULL, then ASSERT.
22 If Lang is NULL, then ASSERT.
24 @param LangCode On input: point to first language in the list. On
25 output: point to next language in the list, or
26 NULL if no more language in the list.
27 @param Lang The first language in the list.
32 HiiLibGetNextLanguage (
33 IN OUT CHAR8
**LangCode
,
40 ASSERT (LangCode
!= NULL
);
41 ASSERT (*LangCode
!= NULL
);
42 ASSERT (Lang
!= NULL
);
45 StringPtr
= *LangCode
;
46 while (StringPtr
[Index
] != 0 && StringPtr
[Index
] != ';') {
50 CopyMem (Lang
, StringPtr
, Index
);
53 if (StringPtr
[Index
] == ';') {
56 *LangCode
= StringPtr
+ Index
;
61 This function returns the list of supported languages, in the format specified
62 in UEFI specification Appendix M.
64 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
66 @param HiiHandle The HII package list handle.
68 @retval !NULL The supported languages.
69 @retval NULL If Supported Languages can not be retrived.
74 HiiLibGetSupportedLanguages (
75 IN EFI_HII_HANDLE HiiHandle
80 CHAR8
*LanguageString
;
82 ASSERT (IsHiiHandleRegistered (HiiHandle
));
84 // Collect current supported Languages for given HII handle
85 // First try allocate 4K buffer to store the current supported languages.
88 LanguageString
= AllocateZeroPool (BufferSize
);
89 if (LanguageString
== NULL
) {
93 Status
= mHiiStringProt
->GetLanguages (mHiiStringProt
, HiiHandle
, LanguageString
, &BufferSize
);
95 if (Status
== EFI_BUFFER_TOO_SMALL
) {
96 FreePool (LanguageString
);
97 LanguageString
= AllocateZeroPool (BufferSize
);
98 if (LanguageString
== NULL
) {
102 Status
= mHiiStringProt
->GetLanguages (mHiiStringProt
, HiiHandle
, LanguageString
, &BufferSize
);
105 if (EFI_ERROR (Status
)) {
106 LanguageString
= NULL
;
109 return LanguageString
;
114 This function returns the number of supported languages on HiiHandle.
116 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
117 If not enough resource to complete the operation, then ASSERT.
119 @param HiiHandle The HII package list handle.
121 @return The number of supported languages.
126 HiiLibGetSupportedLanguageNumber (
127 IN EFI_HII_HANDLE HiiHandle
131 CHAR8
*LanguageString
;
135 Languages
= HiiLibGetSupportedLanguages (HiiHandle
);
136 if (Languages
== NULL
) {
141 Lang
= AllocatePool (AsciiStrSize (Languages
));
143 LanguageString
= Languages
;
144 while (*LanguageString
!= 0) {
145 HiiLibGetNextLanguage (&LanguageString
, Lang
);
151 FreePool (Languages
);
157 This function returns the list of supported 2nd languages, in the format specified
158 in UEFI specification Appendix M.
160 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
161 If not enough resource to complete the operation, then ASSERT.
163 @param HiiHandle The HII package list handle.
164 @param FirstLanguage Pointer to language name buffer.
166 @return The supported languages.
171 HiiLibGetSupportedSecondaryLanguages (
172 IN EFI_HII_HANDLE HiiHandle
,
173 IN CONST CHAR8
*FirstLanguage
178 CHAR8
*LanguageString
;
180 ASSERT (HiiHandle
!= NULL
);
181 ASSERT (IsHiiHandleRegistered (HiiHandle
));
183 // Collect current supported 2nd Languages for given HII handle
184 // First try allocate 4K buffer to store the current supported 2nd languages.
187 LanguageString
= AllocateZeroPool (BufferSize
);
188 if (LanguageString
== NULL
) {
192 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
194 if (Status
== EFI_BUFFER_TOO_SMALL
) {
195 FreePool (LanguageString
);
196 LanguageString
= AllocateZeroPool (BufferSize
);
197 if (LanguageString
== NULL
) {
201 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
204 if (EFI_ERROR (Status
)) {
205 LanguageString
= NULL
;
208 return LanguageString
;