]>
Commit | Line | Data |
---|---|---|
08e4b3cf | 1 | /** @file\r |
2 | Language related HII Library implementation.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2008, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | \r | |
16 | #include "InternalHiiLib.h"\r | |
17 | \r | |
18 | /**\r | |
19 | Get next language from language code list (with separator ';').\r | |
20 | \r | |
21 | If LangCode is NULL, then ASSERT.\r | |
22 | If Lang is NULL, then ASSERT.\r | |
23 | \r | |
24 | @param LangCode On input: point to first language in the list. On\r | |
25 | output: point to next language in the list, or\r | |
26 | NULL if no more language in the list.\r | |
27 | @param Lang The first language in the list.\r | |
28 | \r | |
29 | **/\r | |
30 | VOID\r | |
31 | EFIAPI\r | |
32 | HiiLibGetNextLanguage (\r | |
33 | IN OUT CHAR8 **LangCode,\r | |
34 | OUT CHAR8 *Lang\r | |
35 | )\r | |
36 | {\r | |
37 | UINTN Index;\r | |
38 | CHAR8 *StringPtr;\r | |
39 | \r | |
40 | ASSERT (LangCode != NULL);\r | |
41 | ASSERT (*LangCode != NULL);\r | |
42 | ASSERT (Lang != NULL);\r | |
43 | \r | |
44 | Index = 0;\r | |
45 | StringPtr = *LangCode;\r | |
46 | while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {\r | |
47 | Index++;\r | |
48 | }\r | |
49 | \r | |
50 | CopyMem (Lang, StringPtr, Index);\r | |
51 | Lang[Index] = 0;\r | |
52 | \r | |
53 | if (StringPtr[Index] == ';') {\r | |
54 | Index++;\r | |
55 | }\r | |
56 | *LangCode = StringPtr + Index;\r | |
57 | }\r | |
58 | \r | |
59 | \r | |
60 | /**\r | |
cb7d01c0 | 61 | Retrieves a pointer to the a Null-terminated ASCII string containing the list \r |
62 | of languages that an HII handle in the HII Database supports. The returned \r | |
63 | string is allocated using AllocatePool(). The caller is responsible for freeing\r | |
64 | the returned string using FreePool(). The format of the returned string follows\r | |
65 | the language format assumed the HII Database.\r | |
66 | \r | |
67 | If HiiHandle is NULL, then ASSERT().\r | |
08e4b3cf | 68 | \r |
cb7d01c0 | 69 | @param[in] HiiHandle A handle that was previously registered in the HII Database.\r |
08e4b3cf | 70 | \r |
cb7d01c0 | 71 | @retval NULL HiiHandle is not registered in the HII database\r |
72 | @retval NULL There are not enough resources available to retrieve the suported \r | |
73 | languages.\r | |
74 | @retval NULL The list of suported languages could not be retrieved.\r | |
75 | @retval Other A pointer to the Null-terminated ASCII string of supported languages.\r | |
08e4b3cf | 76 | \r |
77 | **/\r | |
78 | CHAR8 *\r | |
79 | EFIAPI\r | |
cb7d01c0 | 80 | HiiGetSupportedLanguages (\r |
08e4b3cf | 81 | IN EFI_HII_HANDLE HiiHandle\r |
82 | )\r | |
83 | {\r | |
84 | EFI_STATUS Status;\r | |
cb7d01c0 | 85 | UINTN LanguageSize;\r |
86 | CHAR8 TempSupportedLanguages;\r | |
87 | CHAR8 *SupportedLanguages;\r | |
88 | \r | |
89 | ASSERT (HiiHandle != NULL);\r | |
08e4b3cf | 90 | \r |
08e4b3cf | 91 | //\r |
cb7d01c0 | 92 | // Retrieve the size required for the supported languages buffer.\r |
08e4b3cf | 93 | //\r |
cb7d01c0 | 94 | LanguageSize = 0;\r |
95 | Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);\r | |
ea7cd3ec | 96 | \r |
08e4b3cf | 97 | //\r |
cb7d01c0 | 98 | // If GetLanguages() returns EFI_SUCCESS for a zero size, \r |
99 | // then there are no supported languages registered for HiiHandle. If GetLanguages() \r | |
100 | // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present\r | |
101 | // in the HII Database\r | |
08e4b3cf | 102 | //\r |
cb7d01c0 | 103 | if (Status != EFI_BUFFER_TOO_SMALL) {\r |
104 | //\r | |
105 | // Return NULL if the size can not be retrieved, or if HiiHandle is not in the HII Database\r | |
106 | //\r | |
08e4b3cf | 107 | return NULL;\r |
108 | }\r | |
109 | \r | |
cb7d01c0 | 110 | //\r |
111 | // Allocate the supported languages buffer.\r | |
112 | //\r | |
113 | SupportedLanguages = AllocateZeroPool (LanguageSize);\r | |
114 | if (SupportedLanguages == NULL) {\r | |
115 | //\r | |
116 | // Return NULL if allocation fails.\r | |
117 | //\r | |
118 | return NULL;\r | |
08e4b3cf | 119 | }\r |
120 | \r | |
cb7d01c0 | 121 | //\r |
122 | // Retrieve the supported languages string\r | |
123 | //\r | |
124 | Status = gHiiString->GetLanguages (gHiiString, HiiHandle, SupportedLanguages, &LanguageSize);\r | |
08e4b3cf | 125 | if (EFI_ERROR (Status)) {\r |
cb7d01c0 | 126 | //\r |
127 | // Free the buffer and return NULL if the supported languages can not be retrieved.\r | |
128 | //\r | |
129 | FreePool (SupportedLanguages);\r | |
130 | return NULL;\r | |
08e4b3cf | 131 | }\r |
132 | \r | |
cb7d01c0 | 133 | //\r |
134 | // Return the Null-terminated ASCII string of supported languages\r | |
135 | //\r | |
136 | return SupportedLanguages;\r | |
08e4b3cf | 137 | }\r |
138 | \r |