[raccess] Grouping resource access rules based on Darwin VFS.
MacOS X/Darwin kernel supports a few tricky methods to access a resource fork via ANSI C or POSIX interface. Current resource fork accessor tries all possible methods to support all kernels. But if a method could open a resource fork but no font is found, there is no need to try other methods older than tested method. To determine whether the rule index is for Darwin VFS, a local function ftrfork.c::raccess_rule_by_darwin_vfs() is introduced. To use this function in ftobjs.c etc but it should be inlined, it is exposed by ftbase.h. * src/base/ftrfork.c (FT_RFork_Rule): New enum type to identify the rules to access the resource fork. (raccess_guess_rec): New structure to bind the rule function and rule enum type. (FT_Raccess_Guess): The list of the rule functions is replaced by (raccess_guess_table): This. This is exposed to be used by other intra module functions. (raccess_rule_by_darwin_vfs): A function to return a boolean if the rule specified by the rule index is based on Darwin VFS.
This commit is contained in:
parent
4b71871418
commit
c081a4a932
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
||||||
|
2010-10-13 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
||||||
|
|
||||||
|
[raccess] Grouping resource access rules based on Darwin VFS.
|
||||||
|
|
||||||
|
MacOS X/Darwin kernel supports a few tricky methods to access
|
||||||
|
a resource fork via ANSI C or POSIX interface. Current resource
|
||||||
|
fork accessor tries all possible methods to support all kernels.
|
||||||
|
But if a method could open a resource fork but no font is found,
|
||||||
|
there is no need to try other methods older than tested method.
|
||||||
|
To determine whether the rule index is for Darwin VFS, a local
|
||||||
|
function ftrfork.c::raccess_rule_by_darwin_vfs() is introduced.
|
||||||
|
To use this function in ftobjs.c etc but it should be inlined,
|
||||||
|
it is exposed by ftbase.h.
|
||||||
|
|
||||||
|
* src/base/ftrfork.c (FT_RFork_Rule): New enum type to identify
|
||||||
|
the rules to access the resource fork.
|
||||||
|
(raccess_guess_rec): New structure to bind the rule function and
|
||||||
|
rule enum type.
|
||||||
|
(FT_Raccess_Guess): The list of the rule functions is replaced by
|
||||||
|
(raccess_guess_table): This. This is exposed to be used by other
|
||||||
|
intra module functions.
|
||||||
|
(raccess_rule_by_darwin_vfs): A function to return a boolean
|
||||||
|
if the rule specified by the rule index is based on Darwin VFS.
|
||||||
|
|
||||||
2010-10-13 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
2010-10-13 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
||||||
|
|
||||||
Prevent to open a FT_Stream for zero-sized file on non-Unix.
|
Prevent to open a FT_Stream for zero-sized file on non-Unix.
|
||||||
|
|
|
@ -49,6 +49,17 @@ FT_BEGIN_HEADER
|
||||||
FT_Face *aface );
|
FT_Face *aface );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
|
||||||
|
/* Mac OS X/Darwin kernel often changes recommended method to access */
|
||||||
|
/* the resource fork and older methods makes the kernel issue the */
|
||||||
|
/* warning of deprecated method. To calm it down, the methods based */
|
||||||
|
/* on Darwin VFS should be grouped and skip the rest methods after */
|
||||||
|
/* the case the resource is opened but found to lack a font in it. */
|
||||||
|
FT_LOCAL( FT_Bool )
|
||||||
|
raccess_rule_by_darwin_vfs( FT_UInt rule_index );
|
||||||
|
#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
|
||||||
|
|
||||||
|
|
||||||
FT_END_HEADER
|
FT_END_HEADER
|
||||||
|
|
||||||
#endif /* __FTBASE_H__ */
|
#endif /* __FTBASE_H__ */
|
||||||
|
|
|
@ -349,6 +349,42 @@
|
||||||
const char *insertion );
|
const char *insertion );
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum FT_RFork_Rule_ {
|
||||||
|
FT_RFork_Rule_invalid = -2,
|
||||||
|
FT_RFork_Rule_uknown, /* -1 */
|
||||||
|
FT_RFork_Rule_apple_double,
|
||||||
|
FT_RFork_Rule_apple_single,
|
||||||
|
FT_RFork_Rule_darwin_ufs_export,
|
||||||
|
FT_RFork_Rule_darwin_newvfs,
|
||||||
|
FT_RFork_Rule_darwin_hfsplus,
|
||||||
|
FT_RFork_Rule_vfat,
|
||||||
|
FT_RFork_Rule_linux_cap,
|
||||||
|
FT_RFork_Rule_linux_double,
|
||||||
|
FT_RFork_Rule_linux_netatalk
|
||||||
|
} FT_RFork_Rule;
|
||||||
|
|
||||||
|
/* For fast translation between rule index and rule type,
|
||||||
|
* the macros FT_RFORK_xxx should be kept consistent with
|
||||||
|
* the raccess_guess_funcs table
|
||||||
|
*/
|
||||||
|
typedef struct raccess_guess_rec_ {
|
||||||
|
raccess_guess_func func;
|
||||||
|
FT_RFork_Rule type;
|
||||||
|
} raccess_guess_rec;
|
||||||
|
|
||||||
|
static raccess_guess_rec raccess_guess_table[FT_RACCESS_N_RULES] =
|
||||||
|
{
|
||||||
|
{ raccess_guess_apple_double, FT_RFork_Rule_apple_double, },
|
||||||
|
{ raccess_guess_apple_single, FT_RFork_Rule_apple_single, },
|
||||||
|
{ raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, },
|
||||||
|
{ raccess_guess_darwin_newvfs, FT_RFork_Rule_darwin_newvfs, },
|
||||||
|
{ raccess_guess_darwin_hfsplus, FT_RFork_Rule_darwin_hfsplus, },
|
||||||
|
{ raccess_guess_vfat, FT_RFork_Rule_vfat, },
|
||||||
|
{ raccess_guess_linux_cap, FT_RFork_Rule_linux_cap, },
|
||||||
|
{ raccess_guess_linux_double, FT_RFork_Rule_linux_double, },
|
||||||
|
{ raccess_guess_linux_netatalk, FT_RFork_Rule_linux_netatalk, },
|
||||||
|
};
|
||||||
|
|
||||||
FT_BASE_DEF( void )
|
FT_BASE_DEF( void )
|
||||||
FT_Raccess_Guess( FT_Library library,
|
FT_Raccess_Guess( FT_Library library,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
|
@ -360,19 +396,6 @@
|
||||||
FT_Long i;
|
FT_Long i;
|
||||||
|
|
||||||
|
|
||||||
raccess_guess_func funcs[FT_RACCESS_N_RULES] =
|
|
||||||
{
|
|
||||||
raccess_guess_apple_double,
|
|
||||||
raccess_guess_apple_single,
|
|
||||||
raccess_guess_darwin_ufs_export,
|
|
||||||
raccess_guess_darwin_newvfs,
|
|
||||||
raccess_guess_darwin_hfsplus,
|
|
||||||
raccess_guess_vfat,
|
|
||||||
raccess_guess_linux_cap,
|
|
||||||
raccess_guess_linux_double,
|
|
||||||
raccess_guess_linux_netatalk,
|
|
||||||
};
|
|
||||||
|
|
||||||
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
|
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
|
||||||
{
|
{
|
||||||
new_names[i] = NULL;
|
new_names[i] = NULL;
|
||||||
|
@ -384,14 +407,41 @@
|
||||||
if ( errors[i] )
|
if ( errors[i] )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
errors[i] = (funcs[i])( library, stream, base_name,
|
errors[i] = (raccess_guess_table[i].func)( library,
|
||||||
&(new_names[i]), &(offsets[i]) );
|
stream, base_name,
|
||||||
|
&(new_names[i]),
|
||||||
|
&(offsets[i]) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static FT_RFork_Rule
|
||||||
|
raccess_get_rule_type_from_rule_index( FT_UInt rule_index )
|
||||||
|
{
|
||||||
|
if ( rule_index >= FT_RACCESS_N_RULES )
|
||||||
|
return FT_RFork_Rule_invalid;
|
||||||
|
|
||||||
|
return raccess_guess_table[rule_index].type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FT_LOCAL_DEF( FT_Bool )
|
||||||
|
raccess_rule_by_darwin_vfs( FT_UInt rule_index )
|
||||||
|
{
|
||||||
|
switch( raccess_get_rule_type_from_rule_index( rule_index ) )
|
||||||
|
{
|
||||||
|
case FT_RFork_Rule_darwin_newvfs:
|
||||||
|
case FT_RFork_Rule_darwin_hfsplus:
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static FT_Error
|
static FT_Error
|
||||||
raccess_guess_apple_double( FT_Library library,
|
raccess_guess_apple_double( FT_Library library,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
|
|
Loading…
Reference in New Issue