| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftrfork.c */ | 3 /* ftrfork.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Embedded resource forks accessor (body). */ | 5 /* Embedded resource forks accessor (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */ | 7 /* Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */ |
| 8 /* Masatake YAMATO and Redhat K.K. */ | 8 /* Masatake YAMATO and Redhat K.K. */ |
| 9 /* */ | 9 /* */ |
| 10 /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ | 10 /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 /***************************************************************************/ | 21 /***************************************************************************/ |
| 22 /* Development of the code in this file is support of */ | 22 /* Development of the code in this file is support of */ |
| 23 /* Information-technology Promotion Agency, Japan. */ | 23 /* Information-technology Promotion Agency, Japan. */ |
| 24 /***************************************************************************/ | 24 /***************************************************************************/ |
| 25 | 25 |
| 26 | 26 |
| 27 #include <ft2build.h> | 27 #include <ft2build.h> |
| 28 #include FT_INTERNAL_DEBUG_H | 28 #include FT_INTERNAL_DEBUG_H |
| 29 #include FT_INTERNAL_STREAM_H | 29 #include FT_INTERNAL_STREAM_H |
| 30 #include FT_INTERNAL_RFORK_H | 30 #include FT_INTERNAL_RFORK_H |
| 31 | 31 #include "basepic.h" |
| 32 | 32 |
| 33 #undef FT_COMPONENT | 33 #undef FT_COMPONENT |
| 34 #define FT_COMPONENT trace_raccess | 34 #define FT_COMPONENT trace_raccess |
| 35 | 35 |
| 36 | 36 |
| 37 /*************************************************************************/ | 37 /*************************************************************************/ |
| 38 /*************************************************************************/ | 38 /*************************************************************************/ |
| 39 /*************************************************************************/ | 39 /*************************************************************************/ |
| 40 /**** ****/ | 40 /**** ****/ |
| 41 /**** ****/ | 41 /**** ****/ |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 /**** ****/ | 246 /**** ****/ |
| 247 /**** Guessing functions ****/ | 247 /**** Guessing functions ****/ |
| 248 /**** ****/ | 248 /**** ****/ |
| 249 /**** When you add a new guessing function, ****/ | 249 /**** When you add a new guessing function, ****/ |
| 250 /**** update FT_RACCESS_N_RULES in ftrfork.h. ****/ | 250 /**** update FT_RACCESS_N_RULES in ftrfork.h. ****/ |
| 251 /**** ****/ | 251 /**** ****/ |
| 252 /*************************************************************************/ | 252 /*************************************************************************/ |
| 253 /*************************************************************************/ | 253 /*************************************************************************/ |
| 254 /*************************************************************************/ | 254 /*************************************************************************/ |
| 255 | 255 |
| 256 typedef FT_Error | |
| 257 (*raccess_guess_func)( FT_Library library, | |
| 258 FT_Stream stream, | |
| 259 char *base_file_name, | |
| 260 char **result_file_name, | |
| 261 FT_Long *result_offset ); | |
| 262 | |
| 263 | |
| 264 static FT_Error | 256 static FT_Error |
| 265 raccess_guess_apple_double( FT_Library library, | 257 raccess_guess_apple_double( FT_Library library, |
| 266 FT_Stream stream, | 258 FT_Stream stream, |
| 267 char *base_file_name, | 259 char *base_file_name, |
| 268 char **result_file_name, | 260 char **result_file_name, |
| 269 FT_Long *result_offset ); | 261 FT_Long *result_offset ); |
| 270 | 262 |
| 271 static FT_Error | 263 static FT_Error |
| 272 raccess_guess_apple_single( FT_Library library, | 264 raccess_guess_apple_single( FT_Library library, |
| 273 FT_Stream stream, | 265 FT_Stream stream, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 FT_Long *result_offset ); | 310 FT_Long *result_offset ); |
| 319 | 311 |
| 320 static FT_Error | 312 static FT_Error |
| 321 raccess_guess_linux_netatalk( FT_Library library, | 313 raccess_guess_linux_netatalk( FT_Library library, |
| 322 FT_Stream stream, | 314 FT_Stream stream, |
| 323 char *base_file_name, | 315 char *base_file_name, |
| 324 char **result_file_name, | 316 char **result_file_name, |
| 325 FT_Long *result_offset ); | 317 FT_Long *result_offset ); |
| 326 | 318 |
| 327 | 319 |
| 320 CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table, |
| 321 ft_raccess_guess_rec) |
| 322 CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double) |
| 323 CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single) |
| 324 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export) |
| 325 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs) |
| 326 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus) |
| 327 CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat) |
| 328 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap) |
| 329 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double) |
| 330 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk) |
| 331 CONST_FT_RFORK_RULE_ARRAY_END |
| 332 |
| 333 |
| 328 /*************************************************************************/ | 334 /*************************************************************************/ |
| 329 /**** ****/ | 335 /**** ****/ |
| 330 /**** Helper functions ****/ | 336 /**** Helper functions ****/ |
| 331 /**** ****/ | 337 /**** ****/ |
| 332 /*************************************************************************/ | 338 /*************************************************************************/ |
| 333 | 339 |
| 334 static FT_Error | 340 static FT_Error |
| 335 raccess_guess_apple_generic( FT_Library library, | 341 raccess_guess_apple_generic( FT_Library library, |
| 336 FT_Stream stream, | 342 FT_Stream stream, |
| 337 char *base_file_name, | 343 char *base_file_name, |
| 338 FT_Int32 magic, | 344 FT_Int32 magic, |
| 339 FT_Long *result_offset ); | 345 FT_Long *result_offset ); |
| 340 | 346 |
| 341 static FT_Error | 347 static FT_Error |
| 342 raccess_guess_linux_double_from_file_name( FT_Library library, | 348 raccess_guess_linux_double_from_file_name( FT_Library library, |
| 343 char * file_name, | 349 char * file_name, |
| 344 FT_Long *result_offset ); | 350 FT_Long *result_offset ); |
| 345 | 351 |
| 346 static char * | 352 static char * |
| 347 raccess_make_file_name( FT_Memory memory, | 353 raccess_make_file_name( FT_Memory memory, |
| 348 const char *original_name, | 354 const char *original_name, |
| 349 const char *insertion ); | 355 const char *insertion ); |
| 350 | 356 |
| 351 | |
| 352 typedef enum FT_RFork_Rule_ { | |
| 353 FT_RFork_Rule_invalid = -2, | |
| 354 FT_RFork_Rule_uknown, /* -1 */ | |
| 355 FT_RFork_Rule_apple_double, | |
| 356 FT_RFork_Rule_apple_single, | |
| 357 FT_RFork_Rule_darwin_ufs_export, | |
| 358 FT_RFork_Rule_darwin_newvfs, | |
| 359 FT_RFork_Rule_darwin_hfsplus, | |
| 360 FT_RFork_Rule_vfat, | |
| 361 FT_RFork_Rule_linux_cap, | |
| 362 FT_RFork_Rule_linux_double, | |
| 363 FT_RFork_Rule_linux_netatalk | |
| 364 } FT_RFork_Rule; | |
| 365 | |
| 366 /* For fast translation between rule index and rule type, | |
| 367 * the macros FT_RFORK_xxx should be kept consistent with | |
| 368 * the raccess_guess_funcs table | |
| 369 */ | |
| 370 typedef struct raccess_guess_rec_ { | |
| 371 raccess_guess_func func; | |
| 372 FT_RFork_Rule type; | |
| 373 } raccess_guess_rec; | |
| 374 | |
| 375 static raccess_guess_rec raccess_guess_table[FT_RACCESS_N_RULES] = | |
| 376 { | |
| 377 { raccess_guess_apple_double, FT_RFork_Rule_apple_double, }, | |
| 378 { raccess_guess_apple_single, FT_RFork_Rule_apple_single, }, | |
| 379 { raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, }, | |
| 380 { raccess_guess_darwin_newvfs, FT_RFork_Rule_darwin_newvfs, }, | |
| 381 { raccess_guess_darwin_hfsplus, FT_RFork_Rule_darwin_hfsplus, }, | |
| 382 { raccess_guess_vfat, FT_RFork_Rule_vfat, }, | |
| 383 { raccess_guess_linux_cap, FT_RFork_Rule_linux_cap, }, | |
| 384 { raccess_guess_linux_double, FT_RFork_Rule_linux_double, }, | |
| 385 { raccess_guess_linux_netatalk, FT_RFork_Rule_linux_netatalk, }, | |
| 386 }; | |
| 387 | |
| 388 FT_BASE_DEF( void ) | 357 FT_BASE_DEF( void ) |
| 389 FT_Raccess_Guess( FT_Library library, | 358 FT_Raccess_Guess( FT_Library library, |
| 390 FT_Stream stream, | 359 FT_Stream stream, |
| 391 char* base_name, | 360 char* base_name, |
| 392 char **new_names, | 361 char **new_names, |
| 393 FT_Long *offsets, | 362 FT_Long *offsets, |
| 394 FT_Error *errors ) | 363 FT_Error *errors ) |
| 395 { | 364 { |
| 396 FT_Long i; | 365 FT_Long i; |
| 397 | 366 |
| 398 | 367 |
| 399 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) | 368 for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) |
| 400 { | 369 { |
| 401 new_names[i] = NULL; | 370 new_names[i] = NULL; |
| 402 if ( NULL != stream ) | 371 if ( NULL != stream ) |
| 403 errors[i] = FT_Stream_Seek( stream, 0 ); | 372 errors[i] = FT_Stream_Seek( stream, 0 ); |
| 404 else | 373 else |
| 405 errors[i] = FT_Err_Ok; | 374 errors[i] = FT_Err_Ok; |
| 406 | 375 |
| 407 if ( errors[i] ) | 376 if ( errors[i] ) |
| 408 continue ; | 377 continue ; |
| 409 | 378 |
| 410 errors[i] = (raccess_guess_table[i].func)( library, | 379 errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library, |
| 411 stream, base_name, | 380 stream, base_name, |
| 412 &(new_names[i]), | 381 &(new_names[i]), |
| 413 &(offsets[i]) ); | 382 &(offsets[i]) ); |
| 414 } | 383 } |
| 415 | 384 |
| 416 return; | 385 return; |
| 417 } | 386 } |
| 418 | 387 |
| 419 | 388 |
| 389 #ifndef FT_MACINTOSH |
| 420 static FT_RFork_Rule | 390 static FT_RFork_Rule |
| 421 raccess_get_rule_type_from_rule_index( FT_UInt rule_index ) | 391 raccess_get_rule_type_from_rule_index( FT_Library library, |
| 392 FT_UInt rule_index ) |
| 422 { | 393 { |
| 394 FT_UNUSED( library ); |
| 395 |
| 423 if ( rule_index >= FT_RACCESS_N_RULES ) | 396 if ( rule_index >= FT_RACCESS_N_RULES ) |
| 424 return FT_RFork_Rule_invalid; | 397 return FT_RFork_Rule_invalid; |
| 425 | 398 |
| 426 return raccess_guess_table[rule_index].type; | 399 return FT_RACCESS_GUESS_TABLE_GET[rule_index].type; |
| 427 } | 400 } |
| 428 | 401 |
| 429 | 402 |
| 403 /* |
| 404 * For this function, refer ftbase.h. |
| 405 */ |
| 430 FT_LOCAL_DEF( FT_Bool ) | 406 FT_LOCAL_DEF( FT_Bool ) |
| 431 raccess_rule_by_darwin_vfs( FT_UInt rule_index ) | 407 ft_raccess_rule_by_darwin_vfs( FT_Library library, |
| 408 FT_UInt rule_index ) |
| 432 { | 409 { |
| 433 switch( raccess_get_rule_type_from_rule_index( rule_index ) ) | 410 switch( raccess_get_rule_type_from_rule_index( library, rule_index ) ) |
| 434 { | 411 { |
| 435 case FT_RFork_Rule_darwin_newvfs: | 412 case FT_RFork_Rule_darwin_newvfs: |
| 436 case FT_RFork_Rule_darwin_hfsplus: | 413 case FT_RFork_Rule_darwin_hfsplus: |
| 437 return TRUE; | 414 return TRUE; |
| 438 | 415 |
| 439 default: | 416 default: |
| 440 return FALSE; | 417 return FALSE; |
| 441 } | 418 } |
| 442 } | 419 } |
| 420 #endif |
| 443 | 421 |
| 444 | 422 |
| 445 static FT_Error | 423 static FT_Error |
| 446 raccess_guess_apple_double( FT_Library library, | 424 raccess_guess_apple_double( FT_Library library, |
| 447 FT_Stream stream, | 425 FT_Stream stream, |
| 448 char *base_file_name, | 426 char *base_file_name, |
| 449 char **result_file_name, | 427 char **result_file_name, |
| 450 FT_Long *result_offset ) | 428 FT_Long *result_offset ) |
| 451 { | 429 { |
| 452 FT_Int32 magic = ( 0x00 << 24 ) | | 430 FT_Int32 magic = ( 0x00 << 24 ) | |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 offsets[i] = 0; | 840 offsets[i] = 0; |
| 863 errors[i] = FT_Err_Unimplemented_Feature; | 841 errors[i] = FT_Err_Unimplemented_Feature; |
| 864 } | 842 } |
| 865 } | 843 } |
| 866 | 844 |
| 867 | 845 |
| 868 #endif /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ | 846 #endif /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ |
| 869 | 847 |
| 870 | 848 |
| 871 /* END */ | 849 /* END */ |
| OLD | NEW |