]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
Retire language conversion APIs from HII library class.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiOnUefiHiiThunk / Strings.c
CommitLineData
4259256b 1/**@file\r
0368663f 2 This file implements the protocol functions related to string package.\r
3 \r
4259256b 4Copyright (c) 2006 - 2008, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15\r
16#include "HiiDatabase.h"\r
17\r
133a9dfb 18typedef struct {\r
19 CHAR8 *Iso639;\r
20 CHAR8 *Rfc3066;\r
21} ISO639TORFC3066MAP;\r
22\r
23ISO639TORFC3066MAP Iso639ToRfc3066Map [] = {\r
24 {"eng", "en-US"},\r
25 {"fra", "fr-FR"},\r
26};\r
27\r
ad5a96ab 28//\r
29// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes\r
30// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.\r
31// The last 2 CHAR8 values are the ISO 639-1 code.\r
32//\r
33GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Iso639ToRfc3066ConversionTable[] =\r
34"\\r
35aaraa\\r
36abkab\\r
37afraf\\r
38amham\\r
39araar\\r
40asmas\\r
41aymay\\r
42azeaz\\r
43bakba\\r
44belbe\\r
45benbn\\r
46bihbh\\r
47bisbi\\r
48bodbo\\r
49brebr\\r
50bulbg\\r
51catca\\r
52cescs\\r
53corkw\\r
54cosco\\r
55cymcy\\r
56danda\\r
57deude\\r
58dzodz\\r
59ellel\\r
60engen\\r
61epoeo\\r
62estet\\r
63euseu\\r
64faofo\\r
65fasfa\\r
66fijfj\\r
67finfi\\r
68frafr\\r
69fryfy\\r
70gaiga\\r
71gdhgd\\r
72glggl\\r
73grngn\\r
74gujgu\\r
75hauha\\r
76hebhe\\r
77hinhi\\r
78hrvhr\\r
79hunhu\\r
80hyehy\\r
81ikuiu\\r
82ileie\\r
83inaia\\r
84indid\\r
85ipkik\\r
86islis\\r
87itait\\r
88jawjw\\r
89jpnja\\r
90kalkl\\r
91kankn\\r
92kasks\\r
93katka\\r
94kazkk\\r
95khmkm\\r
96kinrw\\r
97kirky\\r
98korko\\r
99kurku\\r
100laolo\\r
101latla\\r
102lavlv\\r
103linln\\r
104litlt\\r
105ltzlb\\r
106malml\\r
107marmr\\r
108mkdmk\\r
109mlgmg\\r
110mltmt\\r
111molmo\\r
112monmn\\r
113mrimi\\r
114msams\\r
115myamy\\r
116nauna\\r
117nepne\\r
118nldnl\\r
119norno\\r
120ocioc\\r
121ormom\\r
122panpa\\r
123polpl\\r
124porpt\\r
125pusps\\r
126quequ\\r
127rohrm\\r
128ronro\\r
129runrn\\r
130rusru\\r
131sagsg\\r
132sansa\\r
133sinsi\\r
134slksk\\r
135slvsl\\r
136smise\\r
137smosm\\r
138snasn\\r
139sndsd\\r
140somso\\r
141sotst\\r
142spaes\\r
143sqisq\\r
144srpsr\\r
145sswss\\r
146sunsu\\r
147swasw\\r
148swesv\\r
149tamta\\r
150tattt\\r
151telte\\r
152tgktg\\r
153tgltl\\r
154thath\\r
155tsnts\\r
156tuktk\\r
157twitw\\r
158uigug\\r
159ukruk\\r
160urdur\\r
161uzbuz\\r
162vievi\\r
163volvo\\r
164wolwo\\r
165xhoxh\\r
166yidyi\\r
167zhaza\\r
168zhozh\\r
169zulzu\\r
170";\r
171\r
133a9dfb 172CHAR8 *\r
173ConvertIso639ToRfc3066 (\r
174 CHAR8 *Iso638Lang\r
175 )\r
176{\r
177 UINTN Index;\r
66df2531
LG
178 CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];\r
179 \r
180 AsciiStrnCpy (AsciiLanguage, Iso638Lang, sizeof (AsciiLanguage));\r
181 for (Index = 0; Index < ISO_639_2_ENTRY_SIZE + 1; Index ++) {\r
182 if (AsciiLanguage [Index] == 0) {\r
183 break;\r
184 } else if (AsciiLanguage [Index] >= 'A' && AsciiLanguage [Index] <= 'Z') {\r
98b16b9d 185 AsciiLanguage [Index] = (CHAR8) (AsciiLanguage [Index] - 'A' + 'a');\r
66df2531
LG
186 }\r
187 }\r
133a9dfb 188\r
189 for (Index = 0; Index < sizeof (Iso639ToRfc3066Map) / sizeof (Iso639ToRfc3066Map[0]); Index++) {\r
66df2531 190 if (AsciiStrnCmp (AsciiLanguage, Iso639ToRfc3066Map[Index].Iso639, AsciiStrSize (AsciiLanguage)) == 0) {\r
133a9dfb 191 return Iso639ToRfc3066Map[Index].Rfc3066;\r
192 }\r
193 }\r
194\r
195 return (CHAR8 *) NULL;\r
196}\r
197\r
ad5a96ab 198/**\r
199 Convert language code from RFC3066 to ISO639-2.\r
200\r
201 @param LanguageRfc3066 RFC3066 language code.\r
202 @param LanguageIso639 ISO639-2 language code.\r
203\r
204 @retval EFI_SUCCESS Language code converted.\r
205 @retval EFI_NOT_FOUND Language code not found.\r
206\r
207**/\r
208EFI_STATUS\r
209EFIAPI\r
210ConvertRfc3066LanguageToIso639Language (\r
211 IN CHAR8 *LanguageRfc3066,\r
212 OUT CHAR8 *LanguageIso639\r
213 )\r
214{\r
215 UINTN Index;\r
216\r
217 if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {\r
218 CopyMem (LanguageIso639, LanguageRfc3066, 3);\r
219 return EFI_SUCCESS;\r
220 }\r
221\r
222 for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {\r
223 if (CompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {\r
224 CopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);\r
225 return EFI_SUCCESS;\r
226 }\r
227 }\r
228\r
229 return EFI_NOT_FOUND;\r
230}\r
231\r
232\r
233/**\r
234 Convert language code from ISO639-2 to RFC3066 and return the converted language.\r
235 Caller is responsible for freeing the allocated buffer.\r
236\r
237 LanguageIso639 contain a single ISO639-2 code such as\r
238 "eng" or "fra".\r
239\r
240 If LanguageIso639 is NULL, then ASSERT.\r
241 If LanguageRfc3066 is NULL, then ASSERT.\r
242\r
243 @param LanguageIso639 ISO639-2 language code.\r
244\r
245 @return the allocated buffer or NULL, if the language is not found.\r
246\r
247**/\r
248CHAR8*\r
249EFIAPI\r
250ConvertIso639LanguageToRfc3066Language (\r
251 IN CONST CHAR8 *LanguageIso639\r
252 )\r
253{\r
254 UINTN Index;\r
255 CHAR8 *Rfc3066Language;\r
256 \r
257 for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {\r
258 if (CompareMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3) == 0) {\r
259 Rfc3066Language = AllocateZeroPool (3);\r
260 if (Rfc3066Language != NULL) {\r
261 Rfc3066Language = CopyMem (Rfc3066Language, &Iso639ToRfc3066ConversionTable[Index + 3], 2);\r
262 }\r
263 return Rfc3066Language;\r
264 }\r
265 }\r
266\r
267 return NULL;\r
268}\r
269\r
3321fa09 270/**\r
271 Test if all of the characters in a string have corresponding font characters.\r
272\r
273 This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and\r
274 return EFI_UNSUPPORTED.\r
133a9dfb 275\r
3321fa09 276 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
277 @param StringToTest A pointer to a Unicode string.\r
278 @param FirstMissing A pointer to an index into the string. On input, the index of \r
279 the first character in the StringToTest to examine. On exit, the index \r
280 of the first character encountered for which a glyph is unavailable. \r
281 If all glyphs in the string are available, the index is the index of the terminator \r
282 of the string. \r
283 @param GlyphBufferSize A pointer to a value. On output, if the function returns EFI_SUCCESS, \r
cb7d01c0 284 it contains the amount of memory that is required to store the string? glyph equivalent.\r
3321fa09 285\r
286 @retval EFI_UNSUPPORTED The function performs nothing and return EFI_UNSUPPORTED.\r
287**/\r
4259256b 288EFI_STATUS\r
289EFIAPI\r
290HiiTestString (\r
291 IN EFI_HII_PROTOCOL *This,\r
292 IN CHAR16 *StringToTest,\r
293 IN OUT UINT32 *FirstMissing,\r
294 OUT UINT32 *GlyphBufferSize\r
295 )\r
4259256b 296{\r
297 ASSERT (FALSE);\r
3321fa09 298 \r
299 return EFI_UNSUPPORTED;\r
4259256b 300}\r
301\r
133a9dfb 302\r
3321fa09 303/**\r
304 Find the corressponding TAG GUID from a Framework HII Handle given.\r
305\r
306 @param Private The HII Thunk Module Private context.\r
307 @param FwHiiHandle The Framemwork HII Handle.\r
308 @param TagGuid The output of TAG GUID found.\r
133a9dfb 309\r
3321fa09 310 @return NULL If Framework HII Handle is invalid.\r
311 @return The corresponding HII Thunk Context.\r
312**/\r
4259256b 313EFI_STATUS\r
0368663f 314GetTagGuidByFwHiiHandle (\r
315 IN CONST HII_THUNK_PRIVATE_DATA *Private,\r
316 IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle,\r
4259256b 317 OUT EFI_GUID *TagGuid\r
318 )\r
319{\r
0368663f 320 LIST_ENTRY *Link;\r
321 HII_THUNK_CONTEXT *ThunkContext;\r
4259256b 322\r
323 ASSERT (TagGuid != NULL);\r
324\r
0368663f 325 Link = GetFirstNode (&Private->ThunkContextListHead);\r
326 while (!IsNull (&Private->ThunkContextListHead, Link)) {\r
4259256b 327\r
0368663f 328 ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r
4259256b 329\r
0368663f 330 if (FwHiiHandle == ThunkContext->FwHiiHandle) {\r
331 CopyGuid (TagGuid, &ThunkContext->TagGuid);\r
4259256b 332 return EFI_SUCCESS;\r
333 }\r
0368663f 334\r
335 Link = GetNextNode (&Private->ThunkContextListHead, Link);\r
4259256b 336 }\r
0368663f 337\r
4259256b 338 return EFI_NOT_FOUND;\r
339}\r
340\r
3321fa09 341/**\r
342 Create or update the String given a new string and String ID.\r
343\r
344 @param ThunkContext The Thunk Context.\r
345 @param Rfc3066AsciiLanguage The RFC 3066 Language code in ASCII string format.\r
346 @param NewString The new string.\r
347 @param StringId The String ID. If StringId is 0, a new String Token\r
348 is created. Otherwise, the String Token StringId is \r
349 updated.\r
350 \r
351\r
352 @retval EFI_SUCCESS The new string is created or updated successfully. \r
353 The new String Token ID is returned in StringId if\r
354 *StringId is 0 on input.\r
355 @return Others The update of string failed. \r
356 \r
357**/\r
358EFI_STATUS\r
359UpdateString (\r
360 IN CONST HII_THUNK_CONTEXT *ThunkContext,\r
361 IN CONST CHAR8 *Rfc3066AsciiLanguage,\r
362 IN CHAR16 *NewString,\r
363 IN OUT STRING_REF *StringId\r
364 )\r
365{\r
366 EFI_STRING_ID NewStringId;\r
3321fa09 367\r
cb7d01c0 368 NewStringId = HiiSetString (ThunkContext->UefiHiiHandle, *StringId, NewString, Rfc3066AsciiLanguage);\r
369 *StringId = NewStringId;\r
370 if (NewStringId == 0) {\r
3321fa09 371 //\r
372 // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.\r
373 //\r
cb7d01c0 374 return EFI_INVALID_PARAMETER;\r
375 } else {\r
376 return EFI_SUCCESS;\r
3321fa09 377 }\r
3321fa09 378}\r
379\r
380/**\r
381 Create or update a String Token in a String Package.\r
382\r
383 If *Reference == 0, a new String Token is created.\r
384\r
385 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
386 @param Language Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
387 identifier, indicating the language to print. A string consisting of\r
388 all spaces indicates that the string is applicable to all languages.\r
389 @param Handle The handle of the language pack to which the string is to be added.\r
390 @param Token The string token assigned to the string.\r
391 @param NewString The string to be added.\r
392\r
0368663f 393\r
3321fa09 394 @retval EFI_SUCCESS The string was effectively registered.\r
395 @retval EFI_INVALID_PARAMETER The Handle was unknown. The string is not created or updated in the\r
396 the string package.\r
397**/\r
0368663f 398\r
4259256b 399EFI_STATUS\r
0368663f 400EFIAPI\r
401HiiNewString (\r
402 IN EFI_HII_PROTOCOL *This,\r
403 IN CHAR16 *Language,\r
404 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
405 IN OUT STRING_REF *Reference,\r
406 IN CHAR16 *NewString\r
4259256b 407 )\r
408{\r
409 EFI_STATUS Status;\r
0368663f 410 HII_THUNK_PRIVATE_DATA *Private;\r
411 EFI_GUID TagGuid;\r
412 LIST_ENTRY *Link;\r
413 HII_THUNK_CONTEXT *ThunkContext;\r
3321fa09 414 HII_THUNK_CONTEXT *StringPackThunkContext;\r
0368663f 415 EFI_STRING_ID StringId;\r
416 EFI_STRING_ID LastStringId;\r
133a9dfb 417 CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];\r
8ea58c07 418 CHAR16 LanguageCopy[ISO_639_2_ENTRY_SIZE + 1];\r
133a9dfb 419 CHAR8 *Rfc3066AsciiLanguage;\r
4259256b 420\r
0368663f 421 LastStringId = (EFI_STRING_ID) 0;\r
422 StringId = (EFI_STRING_ID) 0;\r
133a9dfb 423 Rfc3066AsciiLanguage = NULL;\r
4259256b 424\r
0368663f 425 if (Language != NULL) {\r
133a9dfb 426 ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;\r
8ea58c07 427 ZeroMem (LanguageCopy, sizeof (LanguageCopy));\r
428 CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));\r
429 UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);\r
133a9dfb 430 Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage);\r
431 ASSERT (Rfc3066AsciiLanguage != NULL);\r
ea58467b 432 }\r
4259256b 433\r
3321fa09 434 Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
4259256b 435\r
3321fa09 436 StringPackThunkContext = FwHiiHandleToThunkContext (Private, Handle);\r
437 if (StringPackThunkContext == NULL) {\r
438 return EFI_INVALID_PARAMETER;\r
439 }\r
440\r
441 if (StringPackThunkContext->SharingStringPack) {\r
442 Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid);\r
443 ASSERT_EFI_ERROR (Status);\r
444\r
445 Link = GetFirstNode (&Private->ThunkContextListHead);\r
446 while (!IsNull (&Private->ThunkContextListHead, Link)) {\r
447 ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r
0368663f 448\r
3321fa09 449 if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) {\r
450 if (ThunkContext->SharingStringPack) {\r
451 StringId = *Reference;\r
452 Status = UpdateString (ThunkContext, Rfc3066AsciiLanguage, NewString, &StringId);\r
453 if (EFI_ERROR (Status)) {\r
454 break;\r
4259256b 455 }\r
3321fa09 456 \r
457 DEBUG_CODE_BEGIN ();\r
458 if (*Reference == 0) {\r
459 //\r
460 // When creating new string token, make sure all created token is the same\r
461 // for all string packages registered using FW HII interface.\r
462 //\r
463 if (LastStringId == (EFI_STRING_ID) 0) {\r
464 LastStringId = StringId;\r
465 } else {\r
466 if (LastStringId != StringId) {\r
467 ASSERT(FALSE);\r
468 }\r
469 }\r
470 }\r
471 DEBUG_CODE_END ();\r
472 \r
4259256b 473 }\r
474 }\r
0368663f 475\r
3321fa09 476 Link = GetNextNode (&Private->ThunkContextListHead, Link);\r
477 }\r
478 } else {\r
479 StringId = *Reference;\r
480 Status = UpdateString (StringPackThunkContext, Rfc3066AsciiLanguage, NewString, &StringId);\r
4259256b 481 }\r
482\r
3321fa09 483 if (!EFI_ERROR (Status)) {\r
0368663f 484 if (*Reference == 0) {\r
485 *Reference = StringId;\r
486 }\r
4259256b 487 } else {\r
0368663f 488 //\r
3321fa09 489 // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.\r
0368663f 490 //\r
3321fa09 491 Status = EFI_INVALID_PARAMETER;\r
4259256b 492 }\r
493 \r
46b5ebc8 494 return Status;\r
4259256b 495}\r
496\r
3321fa09 497/**\r
498 This function removes any new strings that were added after the initial string export for this handle.\r
499 UEFI HII String Protocol does not have Reset String function. This function perform nothing.\r
500\r
501 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
502 @param Handle The HII handle on which the string resides.\r
503\r
504 @retval EFI_SUCCESS This function is a NOP and always return EFI_SUCCESS.\r
505\r
506**/\r
4259256b 507EFI_STATUS\r
508EFIAPI\r
509HiiResetStrings (\r
510 IN EFI_HII_PROTOCOL *This,\r
511 IN FRAMEWORK_EFI_HII_HANDLE Handle\r
512 )\r
4259256b 513{\r
0368663f 514 return EFI_SUCCESS;\r
4259256b 515}\r
516\r
3321fa09 517/**\r
518 This function extracts a string from a package already registered with the EFI HII database.\r
519\r
520 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
521 @param Handle The HII handle on which the string resides.\r
522 @param Token The string token assigned to the string.\r
523 @param Raw If TRUE, the string is returned unedited in the internal storage format described\r
524 above. If false, the string returned is edited by replacing <cr> with <space>\r
525 and by removing special characters such as the <wide> prefix.\r
526 @param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
527 identifier, indicating the language to print. If the LanguageString is empty (starts\r
528 with a NULL), the default system language will be used to determine the language.\r
529 @param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too\r
530 small, this parameter is filled with the length of the buffer needed.\r
531 @param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is\r
532 defined in String.\r
533\r
534 @retval EFI_INVALID_PARAMETER If input parameter is invalid.\r
535 @retval EFI_BUFFER_TOO_SMALL If the *BufferLength is too small.\r
536 @retval EFI_SUCCESS Operation is successful.\r
537\r
538**/\r
4259256b 539EFI_STATUS\r
540EFIAPI\r
cdaf7905 541HiiThunkGetString (\r
133a9dfb 542 IN EFI_HII_PROTOCOL *This,\r
543 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
544 IN STRING_REF Token,\r
545 IN BOOLEAN Raw,\r
546 IN CHAR16 *LanguageString,\r
547 IN OUT UINTN *BufferLengthTemp,\r
548 OUT EFI_STRING StringBuffer\r
4259256b 549 )\r
4259256b 550{\r
0368663f 551 HII_THUNK_PRIVATE_DATA *Private;\r
cb7d01c0 552 CHAR8 *Iso639AsciiLanguage;\r
133a9dfb 553 CHAR8 *Rfc3066AsciiLanguage;\r
cb7d01c0 554 CHAR8 *SupportedLanguages;\r
555 CHAR8 *PlatformLanguage;\r
556 CHAR8 *BestLanguage;\r
133a9dfb 557 EFI_HII_HANDLE UefiHiiHandle;\r
558 EFI_STATUS Status;\r
4259256b 559\r
0368663f 560 Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
4259256b 561\r
133a9dfb 562 Iso639AsciiLanguage = NULL;\r
563 Rfc3066AsciiLanguage = NULL;\r
564\r
565 if (LanguageString != NULL) {\r
566 Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
567 if (Iso639AsciiLanguage == NULL) {\r
4259256b 568 return EFI_OUT_OF_RESOURCES;\r
569 }\r
133a9dfb 570 UnicodeStrToAsciiStr (LanguageString, Iso639AsciiLanguage);\r
ea58467b 571\r
133a9dfb 572 //\r
573 // Caller of Framework HII Interface uses the Language Identification String defined \r
574 // in Iso639. So map it to the Language Identifier defined in RFC3066.\r
575 //\r
576 Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (Iso639AsciiLanguage);\r
1668bd49 577\r
578 //\r
579 // If Rfc3066AsciiLanguage is NULL, more language mapping must be added to \r
580 // Iso639ToRfc3066Map.\r
581 //\r
582 ASSERT (Rfc3066AsciiLanguage != NULL);\r
ea58467b 583 \r
4259256b 584 }\r
585\r
133a9dfb 586 UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r
587 if (UefiHiiHandle == NULL) {\r
588 Status = EFI_NOT_FOUND;\r
589 goto Done;\r
590 }\r
4259256b 591\r
133a9dfb 592 if (Rfc3066AsciiLanguage == NULL) {\r
cb7d01c0 593 //\r
594 // Get the languages that the package specified by HiiHandle supports\r
595 //\r
596 SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
597 if (SupportedLanguages == NULL) {\r
598 goto Error2;\r
599 }\r
600\r
601 //\r
602 // Get the current platform language setting\r
603 //\r
604 PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
605 if (PlatformLanguage == NULL) {\r
606 goto Error1;\r
607 }\r
608\r
609 //\r
610 // Get the best matching language from SupportedLanguages\r
611 //\r
612 BestLanguage = GetBestLanguage (\r
613 SupportedLanguages, \r
614 FALSE, // RFC 4646 mode\r
615 PlatformLanguage, // Next highest priority\r
616 SupportedLanguages, // Lowest priority \r
617 NULL\r
618 );\r
619 if (BestLanguage == NULL) {\r
620 FreePool (PlatformLanguage);\r
621Error1:\r
622 FreePool (SupportedLanguages);\r
623Error2:\r
624 Status = EFI_INVALID_PARAMETER;\r
625 goto Done;\r
626 }\r
627\r
628 Status = mHiiStringProtocol->GetString (\r
629 mHiiStringProtocol,\r
630 BestLanguage,\r
631 UefiHiiHandle,\r
632 Token,\r
633 StringBuffer,\r
634 BufferLengthTemp,\r
635 NULL\r
636 );\r
637 FreePool (BestLanguage);\r
133a9dfb 638 } else {\r
639 Status = mHiiStringProtocol->GetString (\r
640 mHiiStringProtocol,\r
641 Rfc3066AsciiLanguage,\r
642 UefiHiiHandle,\r
643 Token,\r
644 StringBuffer,\r
645 BufferLengthTemp,\r
646 NULL\r
647 );\r
4259256b 648 }\r
649\r
133a9dfb 650Done:\r
7001eaf8 651 if (Iso639AsciiLanguage != NULL) {\r
652 FreePool (Iso639AsciiLanguage);\r
653 }\r
133a9dfb 654 \r
655 return Status;\r
4259256b 656}\r
657\r
3321fa09 658/**\r
4259256b 659\r
660 This function allows a program to extract a part of a string of not more than a given width.\r
661 With repeated calls, this allows a calling program to extract "lines" of text that fit inside\r
662 columns. The effort of measuring the fit of strings inside columns is localized to this call.\r
663\r
3321fa09 664 This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and\r
665 return EFI_UNSUPPORTED.\r
666\r
667 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
668 @param Handle The HII handle on which the string resides.\r
669 @param Token The string token assigned to the string.\r
670 @param Raw If TRUE, the string is returned unedited in the internal storage format described\r
671 above. If false, the string returned is edited by replacing <cr> with <space>\r
672 and by removing special characters such as the <wide> prefix.\r
673 @param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
674 identifier, indicating the language to print. If the LanguageString is empty (starts\r
675 with a NULL), the default system language will be used to determine the language.\r
676 @param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too\r
677 small, this parameter is filled with the length of the buffer needed.\r
678 @param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is\r
679 defined in String.\r
680\r
681 @retval EFI_UNSUPPORTED.\r
682**/\r
683EFI_STATUS\r
684EFIAPI\r
685HiiGetLine (\r
686 IN EFI_HII_PROTOCOL *This,\r
687 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
688 IN STRING_REF Token,\r
689 IN OUT UINT16 *Index,\r
690 IN UINT16 LineWidth,\r
691 IN CHAR16 *LanguageString,\r
692 IN OUT UINT16 *BufferLength,\r
693 OUT EFI_STRING StringBuffer\r
694 )\r
4259256b 695{\r
696 ASSERT (FALSE);\r
697 return EFI_UNSUPPORTED;\r
698}\r
699\r
1668bd49 700\r