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
;
133 CHAR8 Lang
[RFC_3066_ENTRY_SIZE
];
135 Languages
= HiiLibGetSupportedLanguages (HiiHandle
);
136 if (Languages
== NULL
) {
141 LanguageString
= Languages
;
142 while (*LanguageString
!= 0) {
143 HiiLibGetNextLanguage (&LanguageString
, Lang
);
146 FreePool (Languages
);
152 This function returns the list of supported 2nd languages, in the format specified
153 in UEFI specification Appendix M.
155 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
156 If not enough resource to complete the operation, then ASSERT.
158 @param HiiHandle The HII package list handle.
159 @param FirstLanguage Pointer to language name buffer.
161 @return The supported languages.
166 HiiLibGetSupportedSecondaryLanguages (
167 IN EFI_HII_HANDLE HiiHandle
,
168 IN CONST CHAR8
*FirstLanguage
173 CHAR8
*LanguageString
;
175 ASSERT (HiiHandle
!= NULL
);
176 ASSERT (IsHiiHandleRegistered (HiiHandle
));
178 // Collect current supported 2nd Languages for given HII handle
179 // First try allocate 4K buffer to store the current supported 2nd languages.
182 LanguageString
= AllocateZeroPool (BufferSize
);
183 if (LanguageString
== NULL
) {
187 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
189 if (Status
== EFI_BUFFER_TOO_SMALL
) {
190 FreePool (LanguageString
);
191 LanguageString
= AllocateZeroPool (BufferSize
);
192 if (LanguageString
== NULL
) {
196 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
199 if (EFI_ERROR (Status
)) {
200 LanguageString
= NULL
;
203 return LanguageString
;