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
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.
18 Common defines and prototypes for string database management
25 #define LANGUAGE_NAME_STRING_NAME L"$LANGUAGE_NAME"
26 #define PRINTABLE_LANGUAGE_NAME_STRING_NAME L"$PRINTABLE_LANGUAGE_NAME"
30 #define NARROW_CHAR 0xFFF0
31 #define WIDE_CHAR 0xFFF1
32 #define NON_BREAKING_CHAR 0xFFF2
34 #define GLYPH_HEIGHT 19
36 #define STRING_DB_KEY (('S' << 24) | ('D' << 16) | ('B' << 8) | 'K')
38 // Version supported by this tool
40 #define STRING_DB_VERSION 0x00010000
42 #define STRING_DB_MAJOR_VERSION_MASK 0xFFFF0000
43 #define STRING_DB_MINOR_VERSION_MASK 0x0000FFFF
45 #define DEFINE_STR L"// #define"
47 #define EFI_STRING_ID_BEGIN 0x01
50 // This is the header that gets written to the top of the
51 // output binary database file.
57 UINT32 NumStringIdenfiers
;
58 UINT32 StringIdentifiersSize
;
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.
69 } DB_DATA_ITEM_HEADER
;
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
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.
82 typedef struct _STRING_LIST
{
83 struct _STRING_LIST
*Next
;
84 UINT32 Size
; // number of bytes in string, including null terminator
86 WCHAR
*StringName
; // for example STR_ID_TEXT1
88 WCHAR
*Str
; // the actual string
89 UINT16 Flags
; // properties of this string (used, undefined)
92 typedef struct _LANGUAGE_LIST
{
93 struct _LANGUAGE_LIST
*Next
;
95 WCHAR
*PrintableLanguageName
;
96 WCHAR
*SecondaryLanguageList
;
98 STRING_LIST
*LastString
;
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.
105 typedef struct _STRING_IDENTIFIER
{
106 struct _STRING_IDENTIFIER
*Next
;
107 UINT32 Index
; // only need 16 bits, but makes it easier with UINT32
109 UINT16 Flags
; // if someone referenced it via STRING_TOKEN()
112 // Keep our globals in this structure to be as modular as possible.
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
128 typedef struct _SPkgBlkBuffer
{
131 struct _SPkgBlkBuffer
*mNext
;
135 StringDBConstructor (
148 WCHAR
*StringIdentifier
,
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
170 StringDBAddStringIdentifier (
171 WCHAR
*StringIdentifier
,
178 StringDBReadDatabase (
180 BOOLEAN IgnoreIfNotExist
,
186 StringDBWriteDatabase (
193 StringDBDumpDatabase (
195 INT8
*OutputFileName
,
201 StringDBAddLanguage (
203 WCHAR
*PrintableLanguageName
,
204 WCHAR
*SecondaryLanguageList
209 StringDBAddSecondaryLanguage (
211 WCHAR
*SecondaryLanguageList
216 StringDBDumpCStrings (
219 WCHAR_STRING_LIST
*LanguagesOfInterests
224 StringDBCreateHiiExportPack (
225 INT8
*OutputFileName
,
226 WCHAR_STRING_LIST
*LanguagesOfInterests
231 StringDBDumpStringDefines (
238 StringDBSetCurrentLanguage (
244 StringDBSetStringReferenced (
245 INT8
*StringIdentifierName
,
246 BOOLEAN IgnoreNotFound
251 StringDBFormatString (
257 StringDBFindLanguageList (
262 #endif // #ifndef _STRING_DB_H_