]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c
Replace references to RFC 3066 with RFC 4646.
[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
0f268521 270/**\r
271 Get next language from language code list (with separator ';').\r
272\r
273 If LangCode is NULL, then ASSERT.\r
274 If Lang is NULL, then ASSERT.\r
275\r
276 @param LangCode On input: point to first language in the list. On\r
277 output: point to next language in the list, or\r
278 NULL if no more language in the list.\r
279 @param Lang The first language in the list.\r
280\r
281**/\r
282VOID\r
283EFIAPI\r
284GetNextLanguage (\r
285 IN OUT CHAR8 **LangCode,\r
286 OUT CHAR8 *Lang\r
287 )\r
288{\r
289 UINTN Index;\r
290 CHAR8 *StringPtr;\r
291\r
292 ASSERT (LangCode != NULL);\r
293 ASSERT (*LangCode != NULL);\r
294 ASSERT (Lang != NULL);\r
295\r
296 Index = 0;\r
297 StringPtr = *LangCode;\r
298 while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {\r
299 Index++;\r
300 }\r
301\r
302 CopyMem (Lang, StringPtr, Index);\r
303 Lang[Index] = 0;\r
304\r
305 if (StringPtr[Index] == ';') {\r
306 Index++;\r
307 }\r
308 *LangCode = StringPtr + Index;\r
309}\r
310\r
3321fa09 311/**\r
312 Test if all of the characters in a string have corresponding font characters.\r
313\r
314 This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and\r
315 return EFI_UNSUPPORTED.\r
133a9dfb 316\r
3321fa09 317 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
318 @param StringToTest A pointer to a Unicode string.\r
319 @param FirstMissing A pointer to an index into the string. On input, the index of \r
320 the first character in the StringToTest to examine. On exit, the index \r
321 of the first character encountered for which a glyph is unavailable. \r
322 If all glyphs in the string are available, the index is the index of the terminator \r
323 of the string. \r
324 @param GlyphBufferSize A pointer to a value. On output, if the function returns EFI_SUCCESS, \r
cb7d01c0 325 it contains the amount of memory that is required to store the string? glyph equivalent.\r
3321fa09 326\r
327 @retval EFI_UNSUPPORTED The function performs nothing and return EFI_UNSUPPORTED.\r
328**/\r
4259256b 329EFI_STATUS\r
330EFIAPI\r
331HiiTestString (\r
332 IN EFI_HII_PROTOCOL *This,\r
333 IN CHAR16 *StringToTest,\r
334 IN OUT UINT32 *FirstMissing,\r
335 OUT UINT32 *GlyphBufferSize\r
336 )\r
4259256b 337{\r
338 ASSERT (FALSE);\r
3321fa09 339 \r
340 return EFI_UNSUPPORTED;\r
4259256b 341}\r
342\r
133a9dfb 343\r
3321fa09 344/**\r
345 Find the corressponding TAG GUID from a Framework HII Handle given.\r
346\r
347 @param Private The HII Thunk Module Private context.\r
348 @param FwHiiHandle The Framemwork HII Handle.\r
349 @param TagGuid The output of TAG GUID found.\r
133a9dfb 350\r
3321fa09 351 @return NULL If Framework HII Handle is invalid.\r
352 @return The corresponding HII Thunk Context.\r
353**/\r
4259256b 354EFI_STATUS\r
0368663f 355GetTagGuidByFwHiiHandle (\r
356 IN CONST HII_THUNK_PRIVATE_DATA *Private,\r
357 IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle,\r
4259256b 358 OUT EFI_GUID *TagGuid\r
359 )\r
360{\r
0368663f 361 LIST_ENTRY *Link;\r
362 HII_THUNK_CONTEXT *ThunkContext;\r
4259256b 363\r
364 ASSERT (TagGuid != NULL);\r
365\r
0368663f 366 Link = GetFirstNode (&Private->ThunkContextListHead);\r
367 while (!IsNull (&Private->ThunkContextListHead, Link)) {\r
4259256b 368\r
0368663f 369 ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r
4259256b 370\r
0368663f 371 if (FwHiiHandle == ThunkContext->FwHiiHandle) {\r
372 CopyGuid (TagGuid, &ThunkContext->TagGuid);\r
4259256b 373 return EFI_SUCCESS;\r
374 }\r
0368663f 375\r
376 Link = GetNextNode (&Private->ThunkContextListHead, Link);\r
4259256b 377 }\r
0368663f 378\r
4259256b 379 return EFI_NOT_FOUND;\r
380}\r
381\r
3321fa09 382/**\r
383 Create or update the String given a new string and String ID.\r
384\r
385 @param ThunkContext The Thunk Context.\r
386 @param Rfc3066AsciiLanguage The RFC 3066 Language code in ASCII string format.\r
387 @param NewString The new string.\r
388 @param StringId The String ID. If StringId is 0, a new String Token\r
389 is created. Otherwise, the String Token StringId is \r
390 updated.\r
391 \r
392\r
393 @retval EFI_SUCCESS The new string is created or updated successfully. \r
394 The new String Token ID is returned in StringId if\r
395 *StringId is 0 on input.\r
396 @return Others The update of string failed. \r
397 \r
398**/\r
399EFI_STATUS\r
400UpdateString (\r
401 IN CONST HII_THUNK_CONTEXT *ThunkContext,\r
402 IN CONST CHAR8 *Rfc3066AsciiLanguage,\r
403 IN CHAR16 *NewString,\r
404 IN OUT STRING_REF *StringId\r
405 )\r
406{\r
407 EFI_STRING_ID NewStringId;\r
3321fa09 408\r
cb7d01c0 409 NewStringId = HiiSetString (ThunkContext->UefiHiiHandle, *StringId, NewString, Rfc3066AsciiLanguage);\r
410 *StringId = NewStringId;\r
411 if (NewStringId == 0) {\r
3321fa09 412 //\r
413 // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.\r
414 //\r
cb7d01c0 415 return EFI_INVALID_PARAMETER;\r
416 } else {\r
417 return EFI_SUCCESS;\r
3321fa09 418 }\r
3321fa09 419}\r
420\r
421/**\r
422 Create or update a String Token in a String Package.\r
423\r
424 If *Reference == 0, a new String Token is created.\r
425\r
426 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
427 @param Language Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
428 identifier, indicating the language to print. A string consisting of\r
429 all spaces indicates that the string is applicable to all languages.\r
430 @param Handle The handle of the language pack to which the string is to be added.\r
431 @param Token The string token assigned to the string.\r
432 @param NewString The string to be added.\r
433\r
0368663f 434\r
3321fa09 435 @retval EFI_SUCCESS The string was effectively registered.\r
436 @retval EFI_INVALID_PARAMETER The Handle was unknown. The string is not created or updated in the\r
437 the string package.\r
438**/\r
0368663f 439\r
4259256b 440EFI_STATUS\r
0368663f 441EFIAPI\r
442HiiNewString (\r
443 IN EFI_HII_PROTOCOL *This,\r
444 IN CHAR16 *Language,\r
445 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
446 IN OUT STRING_REF *Reference,\r
447 IN CHAR16 *NewString\r
4259256b 448 )\r
449{\r
450 EFI_STATUS Status;\r
0368663f 451 HII_THUNK_PRIVATE_DATA *Private;\r
452 EFI_GUID TagGuid;\r
453 LIST_ENTRY *Link;\r
454 HII_THUNK_CONTEXT *ThunkContext;\r
3321fa09 455 HII_THUNK_CONTEXT *StringPackThunkContext;\r
0368663f 456 EFI_STRING_ID StringId;\r
457 EFI_STRING_ID LastStringId;\r
133a9dfb 458 CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];\r
8ea58c07 459 CHAR16 LanguageCopy[ISO_639_2_ENTRY_SIZE + 1];\r
133a9dfb 460 CHAR8 *Rfc3066AsciiLanguage;\r
4259256b 461\r
0368663f 462 LastStringId = (EFI_STRING_ID) 0;\r
463 StringId = (EFI_STRING_ID) 0;\r
133a9dfb 464 Rfc3066AsciiLanguage = NULL;\r
4259256b 465\r
0368663f 466 if (Language != NULL) {\r
133a9dfb 467 ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;\r
8ea58c07 468 ZeroMem (LanguageCopy, sizeof (LanguageCopy));\r
469 CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));\r
470 UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);\r
133a9dfb 471 Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage);\r
472 ASSERT (Rfc3066AsciiLanguage != NULL);\r
ea58467b 473 }\r
4259256b 474\r
3321fa09 475 Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
4259256b 476\r
3321fa09 477 StringPackThunkContext = FwHiiHandleToThunkContext (Private, Handle);\r
478 if (StringPackThunkContext == NULL) {\r
479 return EFI_INVALID_PARAMETER;\r
480 }\r
481\r
482 if (StringPackThunkContext->SharingStringPack) {\r
483 Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid);\r
484 ASSERT_EFI_ERROR (Status);\r
485\r
486 Link = GetFirstNode (&Private->ThunkContextListHead);\r
487 while (!IsNull (&Private->ThunkContextListHead, Link)) {\r
488 ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r
0368663f 489\r
3321fa09 490 if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) {\r
491 if (ThunkContext->SharingStringPack) {\r
492 StringId = *Reference;\r
493 Status = UpdateString (ThunkContext, Rfc3066AsciiLanguage, NewString, &StringId);\r
494 if (EFI_ERROR (Status)) {\r
495 break;\r
4259256b 496 }\r
3321fa09 497 \r
498 DEBUG_CODE_BEGIN ();\r
499 if (*Reference == 0) {\r
500 //\r
501 // When creating new string token, make sure all created token is the same\r
502 // for all string packages registered using FW HII interface.\r
503 //\r
504 if (LastStringId == (EFI_STRING_ID) 0) {\r
505 LastStringId = StringId;\r
506 } else {\r
507 if (LastStringId != StringId) {\r
508 ASSERT(FALSE);\r
509 }\r
510 }\r
511 }\r
512 DEBUG_CODE_END ();\r
513 \r
4259256b 514 }\r
515 }\r
0368663f 516\r
3321fa09 517 Link = GetNextNode (&Private->ThunkContextListHead, Link);\r
518 }\r
519 } else {\r
520 StringId = *Reference;\r
521 Status = UpdateString (StringPackThunkContext, Rfc3066AsciiLanguage, NewString, &StringId);\r
4259256b 522 }\r
523\r
3321fa09 524 if (!EFI_ERROR (Status)) {\r
0368663f 525 if (*Reference == 0) {\r
526 *Reference = StringId;\r
527 }\r
4259256b 528 } else {\r
0368663f 529 //\r
3321fa09 530 // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.\r
0368663f 531 //\r
3321fa09 532 Status = EFI_INVALID_PARAMETER;\r
4259256b 533 }\r
534 \r
46b5ebc8 535 return Status;\r
4259256b 536}\r
537\r
3321fa09 538/**\r
539 This function removes any new strings that were added after the initial string export for this handle.\r
540 UEFI HII String Protocol does not have Reset String function. This function perform nothing.\r
541\r
542 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
543 @param Handle The HII handle on which the string resides.\r
544\r
545 @retval EFI_SUCCESS This function is a NOP and always return EFI_SUCCESS.\r
546\r
547**/\r
4259256b 548EFI_STATUS\r
549EFIAPI\r
550HiiResetStrings (\r
551 IN EFI_HII_PROTOCOL *This,\r
552 IN FRAMEWORK_EFI_HII_HANDLE Handle\r
553 )\r
4259256b 554{\r
0368663f 555 return EFI_SUCCESS;\r
4259256b 556}\r
557\r
3321fa09 558/**\r
559 This function extracts a string from a package already registered with the EFI HII database.\r
560\r
561 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
562 @param Handle The HII handle on which the string resides.\r
563 @param Token The string token assigned to the string.\r
564 @param Raw If TRUE, the string is returned unedited in the internal storage format described\r
565 above. If false, the string returned is edited by replacing <cr> with <space>\r
566 and by removing special characters such as the <wide> prefix.\r
567 @param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
568 identifier, indicating the language to print. If the LanguageString is empty (starts\r
569 with a NULL), the default system language will be used to determine the language.\r
570 @param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too\r
571 small, this parameter is filled with the length of the buffer needed.\r
572 @param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is\r
573 defined in String.\r
574\r
575 @retval EFI_INVALID_PARAMETER If input parameter is invalid.\r
576 @retval EFI_BUFFER_TOO_SMALL If the *BufferLength is too small.\r
577 @retval EFI_SUCCESS Operation is successful.\r
578\r
579**/\r
4259256b 580EFI_STATUS\r
581EFIAPI\r
cdaf7905 582HiiThunkGetString (\r
133a9dfb 583 IN EFI_HII_PROTOCOL *This,\r
584 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
585 IN STRING_REF Token,\r
586 IN BOOLEAN Raw,\r
587 IN CHAR16 *LanguageString,\r
588 IN OUT UINTN *BufferLengthTemp,\r
589 OUT EFI_STRING StringBuffer\r
4259256b 590 )\r
4259256b 591{\r
0368663f 592 HII_THUNK_PRIVATE_DATA *Private;\r
cb7d01c0 593 CHAR8 *Iso639AsciiLanguage;\r
133a9dfb 594 CHAR8 *Rfc3066AsciiLanguage;\r
cb7d01c0 595 CHAR8 *SupportedLanguages;\r
596 CHAR8 *PlatformLanguage;\r
597 CHAR8 *BestLanguage;\r
133a9dfb 598 EFI_HII_HANDLE UefiHiiHandle;\r
599 EFI_STATUS Status;\r
4259256b 600\r
0368663f 601 Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
4259256b 602\r
133a9dfb 603 Iso639AsciiLanguage = NULL;\r
604 Rfc3066AsciiLanguage = NULL;\r
605\r
606 if (LanguageString != NULL) {\r
607 Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
608 if (Iso639AsciiLanguage == NULL) {\r
4259256b 609 return EFI_OUT_OF_RESOURCES;\r
610 }\r
133a9dfb 611 UnicodeStrToAsciiStr (LanguageString, Iso639AsciiLanguage);\r
ea58467b 612\r
133a9dfb 613 //\r
614 // Caller of Framework HII Interface uses the Language Identification String defined \r
615 // in Iso639. So map it to the Language Identifier defined in RFC3066.\r
616 //\r
617 Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (Iso639AsciiLanguage);\r
1668bd49 618\r
619 //\r
620 // If Rfc3066AsciiLanguage is NULL, more language mapping must be added to \r
621 // Iso639ToRfc3066Map.\r
622 //\r
623 ASSERT (Rfc3066AsciiLanguage != NULL);\r
ea58467b 624 \r
4259256b 625 }\r
626\r
133a9dfb 627 UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r
628 if (UefiHiiHandle == NULL) {\r
629 Status = EFI_NOT_FOUND;\r
630 goto Done;\r
631 }\r
4259256b 632\r
133a9dfb 633 if (Rfc3066AsciiLanguage == NULL) {\r
cb7d01c0 634 //\r
635 // Get the languages that the package specified by HiiHandle supports\r
636 //\r
637 SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);\r
638 if (SupportedLanguages == NULL) {\r
639 goto Error2;\r
640 }\r
641\r
642 //\r
643 // Get the current platform language setting\r
644 //\r
645 PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
646 if (PlatformLanguage == NULL) {\r
647 goto Error1;\r
648 }\r
649\r
650 //\r
651 // Get the best matching language from SupportedLanguages\r
652 //\r
653 BestLanguage = GetBestLanguage (\r
654 SupportedLanguages, \r
655 FALSE, // RFC 4646 mode\r
656 PlatformLanguage, // Next highest priority\r
657 SupportedLanguages, // Lowest priority \r
658 NULL\r
659 );\r
660 if (BestLanguage == NULL) {\r
661 FreePool (PlatformLanguage);\r
662Error1:\r
663 FreePool (SupportedLanguages);\r
664Error2:\r
665 Status = EFI_INVALID_PARAMETER;\r
666 goto Done;\r
667 }\r
668\r
669 Status = mHiiStringProtocol->GetString (\r
670 mHiiStringProtocol,\r
671 BestLanguage,\r
672 UefiHiiHandle,\r
673 Token,\r
674 StringBuffer,\r
675 BufferLengthTemp,\r
676 NULL\r
677 );\r
678 FreePool (BestLanguage);\r
133a9dfb 679 } else {\r
680 Status = mHiiStringProtocol->GetString (\r
681 mHiiStringProtocol,\r
682 Rfc3066AsciiLanguage,\r
683 UefiHiiHandle,\r
684 Token,\r
685 StringBuffer,\r
686 BufferLengthTemp,\r
687 NULL\r
688 );\r
4259256b 689 }\r
690\r
133a9dfb 691Done:\r
7001eaf8 692 if (Iso639AsciiLanguage != NULL) {\r
693 FreePool (Iso639AsciiLanguage);\r
694 }\r
133a9dfb 695 \r
696 return Status;\r
4259256b 697}\r
698\r
3321fa09 699/**\r
4259256b 700\r
701 This function allows a program to extract a part of a string of not more than a given width.\r
702 With repeated calls, this allows a calling program to extract "lines" of text that fit inside\r
703 columns. The effort of measuring the fit of strings inside columns is localized to this call.\r
704\r
3321fa09 705 This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and\r
706 return EFI_UNSUPPORTED.\r
707\r
708 @param This A pointer to the EFI_HII_PROTOCOL instance.\r
709 @param Handle The HII handle on which the string resides.\r
710 @param Token The string token assigned to the string.\r
711 @param Raw If TRUE, the string is returned unedited in the internal storage format described\r
712 above. If false, the string returned is edited by replacing <cr> with <space>\r
713 and by removing special characters such as the <wide> prefix.\r
714 @param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
715 identifier, indicating the language to print. If the LanguageString is empty (starts\r
716 with a NULL), the default system language will be used to determine the language.\r
717 @param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too\r
718 small, this parameter is filled with the length of the buffer needed.\r
719 @param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is\r
720 defined in String.\r
721\r
722 @retval EFI_UNSUPPORTED.\r
723**/\r
724EFI_STATUS\r
725EFIAPI\r
726HiiGetLine (\r
727 IN EFI_HII_PROTOCOL *This,\r
728 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
729 IN STRING_REF Token,\r
730 IN OUT UINT16 *Index,\r
731 IN UINT16 LineWidth,\r
732 IN CHAR16 *LanguageString,\r
733 IN OUT UINT16 *BufferLength,\r
734 OUT EFI_STRING StringBuffer\r
735 )\r
4259256b 736{\r
737 ASSERT (FALSE);\r
738 return EFI_UNSUPPORTED;\r
739}\r
740\r
1668bd49 741\r