]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / UefiStrGather / StringDB.h
1 /*++
2
3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 StringDB.h
15
16 Abstract:
17
18 Common defines and prototypes for string database management
19
20 --*/
21
22 #ifndef _STRING_DB_H_
23 #define _STRING_DB_H_
24
25 #define LANGUAGE_NAME_STRING_NAME L"$LANGUAGE_NAME"
26 #define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME"
27
28 typedef CHAR16 WCHAR;
29
30 #define NARROW_CHAR 0xFFF0
31 #define WIDE_CHAR 0xFFF1
32 #define NON_BREAKING_CHAR 0xFFF2
33 #define GLYPH_WIDTH 8
34 #define GLYPH_HEIGHT 19
35
36 #define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K')
37 //
38 // Version supported by this tool
39 //
40 #define STRING_DB_VERSION 0x00010000
41
42 #define STRING_DB_MAJOR_VERSION_MASK 0xFFFF0000
43 #define STRING_DB_MINOR_VERSION_MASK 0x0000FFFF
44
45 #define DEFINE_STR L"// #define"
46
47 #define EFI_STRING_ID_BEGIN 0x01
48
49 //
50 // This is the header that gets written to the top of the
51 // output binary database file.
52 //
53 typedef struct {
54 UINT32 Key;
55 UINT32 HeaderSize;
56 UINT32 Version;
57 UINT32 NumStringIdenfiers;
58 UINT32 StringIdentifiersSize;
59 UINT32 NumLanguages;
60 } STRING_DB_HEADER;
61
62 //
63 // When we write out data to the database, we have a UINT16 identifier, which
64 // indicates what follows, followed by the data. Here's the structure.
65 //
66 typedef struct {
67 UINT16 DataType;
68 UINT16 Reserved;
69 } DB_DATA_ITEM_HEADER;
70
71 #define DB_DATA_TYPE_INVALID 0x0000
72 #define DB_DATA_TYPE_STRING_IDENTIFIER 0x0001
73 #define DB_DATA_TYPE_LANGUAGE_DEFINITION 0x0002
74 #define DB_DATA_TYPE_STRING_DEFINITION 0x0003
75 #define DB_DATA_TYPE_LAST DB_DATA_TYPE_STRING_DEFINITION
76
77 //
78 // We have to keep track of a list of languages, each of which has its own
79 // list of strings. Define a structure to keep track of all languages and
80 // their list of strings.
81 //
82 typedef struct _STRING_LIST {
83 struct _STRING_LIST *Next;
84 UINT32 Size; // number of bytes in string, including null terminator
85 WCHAR *LanguageName;
86 WCHAR *StringName; // for example STR_ID_TEXT1
87 WCHAR *Scope; //
88 WCHAR *Str; // the actual string
89 UINT16 Flags; // properties of this string (used, undefined)
90 } STRING_LIST;
91
92 typedef struct _LANGUAGE_LIST {
93 struct _LANGUAGE_LIST *Next;
94 WCHAR *LanguageName;
95 WCHAR *PrintableLanguageName;
96 WCHAR *SecondaryLanguageList;
97 STRING_LIST *String;
98 STRING_LIST *LastString;
99 } LANGUAGE_LIST;
100
101 //
102 // We also keep track of all the string identifier names, which we assign unique
103 // values to. Create a structure to keep track of them all.
104 //
105 typedef struct _STRING_IDENTIFIER {
106 struct _STRING_IDENTIFIER *Next;
107 UINT32 Index; // only need 16 bits, but makes it easier with UINT32
108 WCHAR *StringName;
109 UINT16 Flags; // if someone referenced it via STRING_TOKEN()
110 } STRING_IDENTIFIER;
111 //
112 // Keep our globals in this structure to be as modular as possible.
113 //
114 typedef struct {
115 FILE *StringDBFptr;
116 LANGUAGE_LIST *LanguageList;
117 LANGUAGE_LIST *LastLanguageList;
118 LANGUAGE_LIST *CurrentLanguage; // keep track of the last language they used
119 STRING_IDENTIFIER *StringIdentifier;
120 STRING_IDENTIFIER *LastStringIdentifier;
121 UINT8 *StringDBFileName;
122 UINT32 NumStringIdentifiers;
123 UINT32 NumStringIdentifiersReferenced;
124 STRING_IDENTIFIER *CurrentStringIdentifier; // keep track of the last string identifier they added
125 WCHAR *CurrentScope;
126 } STRING_DB_DATA;
127
128 typedef struct _SPkgBlkBuffer {
129 UINT32 mBlkSize;
130 VOID *mBlkBuffer;
131 struct _SPkgBlkBuffer *mNext;
132 } SPkgBlkBuffer;
133
134 void
135 StringDBConstructor (
136 void
137 )
138 ;
139 void
140 StringDBDestructor (
141 void
142 )
143 ;
144
145 STATUS
146 StringDBAddString (
147 WCHAR *LanguageName,
148 WCHAR *StringIdentifier,
149 WCHAR *Scope,
150 WCHAR *String,
151 BOOLEAN Format,
152 UINT16 Flags
153 )
154 ;
155
156 STATUS
157 StringDBSetScope (
158 WCHAR *Scope
159 )
160 ;
161
162 #define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
163 #define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
164 #define STRING_FLAGS_INDEX_ASSIGNED 0x0004 // so don't change the index value
165 #define STRING_ID_INVALID 0xFFFF
166 #define STRING_ID_LANGUAGE_NAME 0x0000
167 #define STRING_ID_PRINTABLE_LANGUAGE_NAME 0x0001
168
169 STATUS
170 StringDBAddStringIdentifier (
171 WCHAR *StringIdentifier,
172 UINT16 *NewId,
173 UINT16 Flags
174 )
175 ;
176
177 STATUS
178 StringDBReadDatabase (
179 INT8 *DBFileName,
180 BOOLEAN IgnoreIfNotExist,
181 BOOLEAN Verbose
182 )
183 ;
184
185 STATUS
186 StringDBWriteDatabase (
187 INT8 *DBFileName,
188 BOOLEAN Verbose
189 )
190 ;
191
192 STATUS
193 StringDBDumpDatabase (
194 INT8 *DBFileName,
195 INT8 *OutputFileName,
196 BOOLEAN Verbose
197 )
198 ;
199
200 STATUS
201 StringDBAddLanguage (
202 WCHAR *LanguageName,
203 WCHAR *PrintableLanguageName,
204 WCHAR *SecondaryLanguageList
205 )
206 ;
207
208 STATUS
209 StringDBAddSecondaryLanguage (
210 WCHAR *LanguageName,
211 WCHAR *SecondaryLanguageList
212 )
213 ;
214
215 STATUS
216 StringDBDumpCStrings (
217 INT8 *BaseName,
218 INT8 *FileName,
219 WCHAR_STRING_LIST *LanguagesOfInterests
220 )
221 ;
222
223 STATUS
224 StringDBCreateHiiExportPack (
225 INT8 *OutputFileName,
226 WCHAR_STRING_LIST *LanguagesOfInterests
227 )
228 ;
229
230 STATUS
231 StringDBDumpStringDefines (
232 INT8 *FileName,
233 INT8 *BaseName
234 )
235 ;
236
237 STATUS
238 StringDBSetCurrentLanguage (
239 WCHAR *LanguageName
240 )
241 ;
242
243 STATUS
244 StringDBSetStringReferenced (
245 INT8 *StringIdentifierName,
246 BOOLEAN IgnoreNotFound
247 )
248 ;
249
250 void
251 StringDBFormatString (
252 WCHAR *String
253 )
254 ;
255
256 LANGUAGE_LIST *
257 StringDBFindLanguageList (
258 WCHAR *LanguageName
259 )
260 ;
261
262 #endif // #ifndef _STRING_DB_H_