]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c
Fix a type in the directory name. Compatiblity -> Compatibility.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / Strings.c
CommitLineData
4259256b 1/**@file\r
2\r
3 This file contains the keyboard processing code to the HII database.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#include "HiiDatabase.h"\r
18\r
19EFI_STATUS\r
20EFIAPI\r
21HiiTestString (\r
22 IN EFI_HII_PROTOCOL *This,\r
23 IN CHAR16 *StringToTest,\r
24 IN OUT UINT32 *FirstMissing,\r
25 OUT UINT32 *GlyphBufferSize\r
26 )\r
27/*++\r
28\r
29Routine Description:\r
30 Test if all of the characters in a string have corresponding font characters.\r
31\r
32Arguments:\r
33\r
34Returns:\r
35\r
36--*/\r
37{\r
38 ASSERT (FALSE);\r
39 return EFI_SUCCESS;\r
40}\r
41\r
42EFI_STATUS\r
43GetTagGuidByFrameworkHiiHandle (\r
44 IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,\r
45 IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle,\r
46 OUT EFI_GUID *TagGuid\r
47 )\r
48{\r
49 LIST_ENTRY *ListEntry;\r
50 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
51\r
52 ASSERT (TagGuid != NULL);\r
53\r
54 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
55 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
56 ListEntry = ListEntry->ForwardLink\r
57 ) {\r
58\r
59 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
60\r
61 if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) {\r
62 CopyGuid (TagGuid, &HandleMapEntry->TagGuid);\r
63 return EFI_SUCCESS;\r
64 }\r
65 }\r
66 \r
67 return EFI_NOT_FOUND;\r
68}\r
69\r
70EFI_STATUS\r
71HiiThunkNewStringForAllStringPackages (\r
72 IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,\r
73 OUT CONST EFI_GUID *TagGuid,\r
74 IN CHAR16 *Language,\r
75 IN OUT STRING_REF *Reference,\r
76 IN CHAR16 *NewString\r
77 )\r
78{\r
79 EFI_STATUS Status;\r
80 LIST_ENTRY *ListEntry;\r
81 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
82 EFI_STRING_ID StringId1;\r
83 EFI_STRING_ID StringId2;\r
84 CHAR8 *UefiStringProtocolLanguage;\r
85 BOOLEAN Found;\r
86\r
87 ASSERT (TagGuid != NULL);\r
88\r
89 StringId1 = (EFI_STRING_ID) 0;\r
90 StringId2 = (EFI_STRING_ID) 0;\r
91 Found = FALSE;\r
92\r
93 //\r
94 // BugBug: We will handle the case that Language is not NULL later.\r
95 //\r
96 ASSERT (Language == NULL);\r
97 \r
98 //if (Language == NULL) {\r
99 UefiStringProtocolLanguage = NULL;\r
100 //}\r
101\r
102 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
103 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
104 ListEntry = ListEntry->ForwardLink\r
105 ) {\r
106\r
107 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
108\r
109 if (CompareGuid (TagGuid, &HandleMapEntry->TagGuid)) {\r
110 Found = TRUE;\r
111 if (*Reference == 0) {\r
112 Status = HiiLibNewString (HandleMapEntry->UefiHiiHandle, &StringId2, NewString);\r
113 } else {\r
114 Status = HiiLibSetString (HandleMapEntry->UefiHiiHandle, *Reference, NewString);\r
115 }\r
116 if (EFI_ERROR (Status)) {\r
117 return Status;\r
118 }\r
119 if (*Reference == 0) {\r
120 if (StringId1 == (EFI_STRING_ID) 0) {\r
121 StringId1 = StringId2;\r
122 } else {\r
123 if (StringId1 != StringId2) {\r
124 ASSERT(FALSE);\r
125 return EFI_INVALID_PARAMETER;\r
126 }\r
127 }\r
128 }\r
129 }\r
130 }\r
131\r
132 if (Found) {\r
133 *Reference = StringId1;\r
134 Status = EFI_SUCCESS;\r
135 } else {\r
136 Status = EFI_NOT_FOUND;\r
137 }\r
138 \r
139 return Status;\r
140}\r
141\r
142EFI_STATUS\r
143EFIAPI\r
144HiiNewString (\r
145 IN EFI_HII_PROTOCOL *This,\r
146 IN CHAR16 *Language,\r
147 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
148 IN OUT STRING_REF *Reference,\r
149 IN CHAR16 *NewString\r
150 )\r
151/*++\r
152\r
153Routine Description:\r
154 This function allows a new String to be added to an already existing String Package.\r
155 We will make a buffer the size of the package + StrSize of the new string. We will\r
156 copy the string package that first gets changed and the following language packages until\r
157 we encounter the NULL string package. All this time we will ensure that the offsets have\r
158 been adjusted.\r
159\r
160Arguments:\r
161\r
162Returns:\r
163\r
164--*/\r
165{\r
166 EFI_STATUS Status;\r
167 EFI_HII_THUNK_PRIVATE_DATA *Private;\r
168 EFI_GUID TagGuid;\r
169\r
170 Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
171\r
172 Status = GetTagGuidByFrameworkHiiHandle (Private, Handle, &TagGuid);\r
173 ASSERT_EFI_ERROR (Status);\r
174\r
175 Status = HiiThunkNewStringForAllStringPackages (Private, &TagGuid, Language, Reference, NewString);\r
176 ASSERT_EFI_ERROR (Status); \r
177\r
178 return EFI_SUCCESS;\r
179}\r
180\r
181EFI_STATUS\r
182EFIAPI\r
183HiiResetStrings (\r
184 IN EFI_HII_PROTOCOL *This,\r
185 IN FRAMEWORK_EFI_HII_HANDLE Handle\r
186 )\r
187/*++\r
188\r
189Routine Description:\r
190\r
191 This function removes any new strings that were added after the initial string export for this handle.\r
192\r
193Arguments:\r
194\r
195Returns:\r
196\r
197--*/\r
198{\r
199 ASSERT (FALSE);\r
200 return EFI_UNSUPPORTED;\r
201}\r
202\r
203EFI_STATUS\r
204EFIAPI\r
205HiiGetString (\r
206 IN EFI_HII_PROTOCOL *This,\r
207 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
208 IN STRING_REF Token,\r
209 IN BOOLEAN Raw,\r
210 IN CHAR16 *LanguageString,\r
211 IN OUT UINTN *BufferLengthTemp,\r
212 OUT EFI_STRING StringBuffer\r
213 )\r
214/*++\r
215\r
216Routine Description:\r
217\r
218 This function extracts a string from a package already registered with the EFI HII database.\r
219\r
220Arguments:\r
221 This - A pointer to the EFI_HII_PROTOCOL instance.\r
222 Handle - The HII handle on which the string resides.\r
223 Token - The string token assigned to the string.\r
224 Raw - If TRUE, the string is returned unedited in the internal storage format described\r
225 above. If false, the string returned is edited by replacing <cr> with <space>\r
226 and by removing special characters such as the <wide> prefix.\r
227 LanguageString - Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
228 identifier, indicating the language to print. If the LanguageString is empty (starts\r
229 with a NULL), the default system language will be used to determine the language.\r
230 BufferLength - Length of the StringBuffer. If the status reports that the buffer width is too\r
231 small, this parameter is filled with the length of the buffer needed.\r
232 StringBuffer - The buffer designed to receive the characters in the string. Type EFI_STRING is\r
233 defined in String.\r
234\r
235Returns:\r
236 EFI_INVALID_PARAMETER - If input parameter is invalid.\r
237 EFI_BUFFER_TOO_SMALL - If the *BufferLength is too small.\r
238 EFI_SUCCESS - Operation is successful.\r
239\r
240--*/\r
241{\r
242 LIST_ENTRY *ListEntry;\r
243 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
244 CHAR8 *AsciiLanguage;\r
245 EFI_HII_THUNK_PRIVATE_DATA *Private;\r
246\r
247 Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
248\r
249 if (LanguageString == NULL) {\r
250 AsciiLanguage = NULL;\r
251 } else {\r
252 AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
253 if (AsciiLanguage == NULL) {\r
254 return EFI_OUT_OF_RESOURCES;\r
255 }\r
256 UnicodeStrToAsciiStr (LanguageString, AsciiLanguage);\r
257 }\r
258\r
259 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
260 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
261 ListEntry = ListEntry->ForwardLink\r
262 ) {\r
263\r
264 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
265\r
266 if (Handle == HandleMapEntry->FrameworkHiiHandle) {\r
267 if (AsciiLanguage == NULL) {\r
268 return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);\r
269 } else {\r
270 return mUefiStringProtocol->GetString (\r
271 mUefiStringProtocol,\r
272 AsciiLanguage,\r
273 HandleMapEntry->UefiHiiHandle,\r
274 Token,\r
275 StringBuffer,\r
276 BufferLengthTemp,\r
277 NULL\r
278 );\r
279 }\r
280 }\r
281 }\r
282\r
283 return EFI_NOT_FOUND;\r
284}\r
285\r
286EFI_STATUS\r
287EFIAPI\r
288HiiGetLine (\r
289 IN EFI_HII_PROTOCOL *This,\r
290 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
291 IN STRING_REF Token,\r
292 IN OUT UINT16 *Index,\r
293 IN UINT16 LineWidth,\r
294 IN CHAR16 *LanguageString,\r
295 IN OUT UINT16 *BufferLength,\r
296 OUT EFI_STRING StringBuffer\r
297 )\r
298/*++\r
299\r
300Routine Description:\r
301\r
302 This function allows a program to extract a part of a string of not more than a given width.\r
303 With repeated calls, this allows a calling program to extract "lines" of text that fit inside\r
304 columns. The effort of measuring the fit of strings inside columns is localized to this call.\r
305\r
306Arguments:\r
307\r
308Returns:\r
309\r
310--*/\r
311{\r
312 ASSERT (FALSE);\r
313 return EFI_UNSUPPORTED;\r
314}\r
315\r