UnicodeCollationEng.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Driver to implement English version of Unicode Collation Protocol.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UnicodeCollationEng.h"
CHAR8 mOtherChars[] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'\\',
'.',
'_',
'^',
'$',
'~',
'!',
'#',
'%',
'&',
'-',
'{',
'}',
'(',
')',
'@',
'`',
'\'',
'\0'
};
//
// EFI Unicode Collation Protocol supporting ISO 639-2 language code
//
"eng"
};
//
// EFI Unicode Collation2 Protocol supporting RFC 4646 language code
//
"en"
};
/**
The user Entry Point for English module.
This function initializes unicode character mapping and then installs Unicode
Collation & Unicode Collation 2 Protocols based on the feature flags.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval other Some error occurs when executing this entry point.
**/
)
{
//
// Initialize mapping tables for the supported languages
//
mEngInfoMap[Index] = 0;
if ((Index >= 'a' && Index <= 'z') || (Index >= 0xe0 && Index <= 0xf6) || (Index >= 0xf8 && Index <= 0xfe)) {
}
}
}
if (FeaturePcdGet (PcdUnicodeCollation2Support)) {
if (FeaturePcdGet (PcdUnicodeCollationSupport)) {
&mHandle,
);
} else {
&mHandle,
);
}
} else {
if (FeaturePcdGet (PcdUnicodeCollationSupport)) {
&mHandle,
);
} else {
//
// This module must support to produce at least one of Unicode Collation Protocol
// and Unicode Collation 2 Protocol.
//
}
}
return Status;
}
/**
Performs a case-insensitive comparison of two Null-terminated strings.
@param This Protocol instance pointer.
@param Str1 A pointer to a Null-terminated string.
@param Str2 A pointer to a Null-terminated string.
@retval 0 Str1 is equivalent to Str2
@retval > 0 Str1 is lexically greater than Str2
@retval < 0 Str1 is lexically less than Str2
**/
)
{
while (*Str1 != 0) {
break;
}
Str1 += 1;
Str2 += 1;
}
}
/**
Converts all the characters in a Null-terminated string to
lower case characters.
@param This Protocol instance pointer.
@param Str A pointer to a Null-terminated string.
**/
)
{
while (*Str != 0) {
Str += 1;
}
}
/**
Converts all the characters in a Null-terminated string to upper
case characters.
@param This Protocol instance pointer.
@param Str A pointer to a Null-terminated string.
**/
)
{
while (*Str != 0) {
Str += 1;
}
}
/**
Performs a case-insensitive comparison of a Null-terminated
pattern string and a Null-terminated string.
@param This Protocol instance pointer.
@param String A pointer to a Null-terminated string.
@param Pattern A pointer to a Null-terminated pattern string.
@retval TRUE Pattern was found in String.
@retval FALSE Pattern was not found in String.
**/
)
{
for (;;) {
Pattern += 1;
switch (CharP) {
case 0:
//
// End of pattern. If end of string, TRUE match
//
if (*String != 0) {
return FALSE;
} else {
return TRUE;
}
case '*':
//
// Match zero or more chars
//
while (*String != 0) {
return TRUE;
}
String += 1;
}
case '?':
//
// Match any one char
//
if (*String == 0) {
return FALSE;
}
String += 1;
break;
case '[':
//
// Match char set
//
if (CharC == 0) {
//
// syntax problem
//
return FALSE;
}
Index3 = 0;
while (CharP != 0) {
if (CharP == ']') {
return FALSE;
}
if (CharP == '-') {
//
// if range of chars, get high range
//
//
// syntax problem
//
return FALSE;
}
//
// if in range, it's a match
//
break;
}
}
//
// if char matches
//
break;
}
}
//
// skip to end of match char set
//
Pattern += 1;
}
String += 1;
break;
default:
return FALSE;
}
String += 1;
break;
}
}
}
/**
Converts an 8.3 FAT file name in an OEM character set to a Null-terminated string.
@param This Protocol instance pointer.
@param FatSize The size of the string Fat in bytes.
@param Fat A pointer to a Null-terminated string that contains an 8.3 file
name using an 8-bit OEM character set.
@param String A pointer to a Null-terminated string. The string must
be preallocated to hold FatSize characters.
**/
)
{
//
// No DBCS issues, just expand and add null terminate to end of string
//
String += 1;
Fat += 1;
FatSize -= 1;
}
*String = 0;
}
/**
Converts a Null-terminated string to legal characters in a FAT
filename using an OEM character set.
@param This Protocol instance pointer.
@param String A pointer to a Null-terminated string. The string must
be preallocated to hold FatSize characters.
@param FatSize The size of the string Fat in bytes.
@param Fat A pointer to a Null-terminated string that contains an 8.3 file
name using an OEM character set.
@retval TRUE Fat is a Long File Name
@retval FALSE Fat is an 8.3 file name
**/
)
{
//
// Skip '.' or ' ' when making a fat name
//
//
// If this is a valid fat char, move it.
// Otherwise, move a '_' and flag the fact that the name needs a long file name.
//
} else {
*Fat = '_';
}
Fat += 1;
FatSize -= 1;
}
String += 1;
}
//
// Do not terminate that fat string
//
return SpecialCharExist;
}