28 #include FT_INTERNAL_DEBUG_H 29 #include FT_INTERNAL_STREAM_H 30 #include FT_INTERNAL_RFORK_H 34 #define FT_COMPONENT trace_raccess 57 unsigned char head[16], head2[16];
59 int allzeros, allmatch,
i;
73 *rdata_pos = rfork_offset + ( ( head[0] << 24 ) |
77 map_pos = rfork_offset + ( ( head[4] << 24 ) |
81 rdata_len = ( head[ 8] << 24 ) |
88 if ( *rdata_pos + rdata_len != map_pos || map_pos == rfork_offset )
89 return FT_THROW( Unknown_File_Format );
95 head2[15] = (
FT_Byte)( head[15] + 1 );
103 for ( i = 0; i < 16; ++
i )
107 if ( head2[i] != head[i] )
110 if ( !allzeros && !allmatch )
111 return FT_THROW( Unknown_File_Format );
123 if ( type_list == -1 )
124 return FT_THROW( Unknown_File_Format );
130 *map_offset = map_pos + type_list;
158 int i, j, cnt, subcnt;
174 for (
i = 0;
i < cnt; ++
i )
182 (
char)( 0xff & ( tag_internal >> 24 ) ),
183 (
char)( 0xff & ( tag_internal >> 16 ) ),
184 (
char)( 0xff & ( tag_internal >> 8 ) ),
185 (
char)( 0xff & ( tag_internal >> 0 ) ) ));
187 if ( tag_internal == tag )
199 for ( j = 0; j < *
count; ++j )
210 ref[j].
offset = temp & 0xFFFFFFL;
214 (
int(*)(
const void*,
const void*) )
215 ft_raccess_sort_ref_by_id );
224 for ( j = 0; j < *
count; ++j )
225 offsets_internal[j] = rdata_pos + ref[j].
offset;
227 *offsets = offsets_internal;
236 return FT_THROW( Cannot_Open_Resource );
240 #ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK 259 char *base_file_name,
260 char **result_file_name,
264 raccess_guess_apple_single(
FT_Library library,
266 char *base_file_name,
267 char **result_file_name,
271 raccess_guess_darwin_ufs_export(
FT_Library library,
273 char *base_file_name,
274 char **result_file_name,
278 raccess_guess_darwin_newvfs(
FT_Library library,
280 char *base_file_name,
281 char **result_file_name,
285 raccess_guess_darwin_hfsplus(
FT_Library library,
287 char *base_file_name,
288 char **result_file_name,
294 char *base_file_name,
295 char **result_file_name,
301 char *base_file_name,
302 char **result_file_name,
306 raccess_guess_linux_double(
FT_Library library,
308 char *base_file_name,
309 char **result_file_name,
313 raccess_guess_linux_netatalk(
FT_Library library,
315 char *base_file_name,
316 char **result_file_name,
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
341 raccess_guess_apple_generic(
FT_Library library,
343 char *base_file_name,
348 raccess_guess_linux_double_from_file_name(
FT_Library library,
353 raccess_make_file_name(
FT_Memory memory,
354 const char *original_name,
355 const char *insertion );
371 if (
NULL != stream )
379 errors[
i] = (FT_RACCESS_GUESS_TABLE_GET[
i].func)( library,
391 raccess_get_rule_type_from_rule_index(
FT_Library library,
397 return FT_RFork_Rule_invalid;
399 return FT_RACCESS_GUESS_TABLE_GET[rule_index].type;
407 ft_raccess_rule_by_darwin_vfs(
FT_Library library,
410 switch( raccess_get_rule_type_from_rule_index( library, rule_index ) )
412 case FT_RFork_Rule_darwin_newvfs:
413 case FT_RFork_Rule_darwin_hfsplus:
424 raccess_guess_apple_double(
FT_Library library,
426 char *base_file_name,
427 char **result_file_name,
436 *result_file_name =
NULL;
437 if (
NULL == stream )
438 return FT_THROW( Cannot_Open_Stream );
440 return raccess_guess_apple_generic( library, stream, base_file_name,
441 magic, result_offset );
446 raccess_guess_apple_single(
FT_Library library,
448 char *base_file_name,
449 char **result_file_name,
458 *result_file_name =
NULL;
459 if (
NULL == stream )
460 return FT_THROW( Cannot_Open_Stream );
462 return raccess_guess_apple_generic( library, stream, base_file_name,
463 magic, result_offset );
468 raccess_guess_darwin_ufs_export(
FT_Library library,
470 char *base_file_name,
471 char **result_file_name,
482 newpath = raccess_make_file_name( memory, base_file_name,
"._" );
486 error = raccess_guess_linux_double_from_file_name( library, newpath,
489 *result_file_name = newpath;
498 raccess_guess_darwin_hfsplus(
FT_Library library,
500 char *base_file_name,
501 char **result_file_name,
508 char* newpath =
NULL;
520 if (
FT_ALLOC( newpath, base_file_len + 6 ) )
523 FT_MEM_COPY( newpath, base_file_name, base_file_len );
524 FT_MEM_COPY( newpath + base_file_len,
"/rsrc", 6 );
526 *result_file_name = newpath;
534 raccess_guess_darwin_newvfs(
FT_Library library,
536 char *base_file_name,
537 char **result_file_name,
544 char* newpath =
NULL;
556 if (
FT_ALLOC( newpath, base_file_len + 18 ) )
559 FT_MEM_COPY( newpath, base_file_name, base_file_len );
560 FT_MEM_COPY( newpath + base_file_len,
"/..namedfork/rsrc", 18 );
562 *result_file_name = newpath;
572 char *base_file_name,
573 char **result_file_name,
584 newpath = raccess_make_file_name( memory, base_file_name,
589 *result_file_name = newpath;
599 char *base_file_name,
600 char **result_file_name,
611 newpath = raccess_make_file_name( memory, base_file_name,
".resource/" );
615 *result_file_name = newpath;
623 raccess_guess_linux_double(
FT_Library library,
625 char *base_file_name,
626 char **result_file_name,
638 newpath = raccess_make_file_name( memory, base_file_name,
"%" );
642 error = raccess_guess_linux_double_from_file_name( library, newpath,
645 *result_file_name = newpath;
654 raccess_guess_linux_netatalk(
FT_Library library,
656 char *base_file_name,
657 char **result_file_name,
669 newpath = raccess_make_file_name( memory, base_file_name,
674 error = raccess_guess_linux_double_from_file_name( library, newpath,
677 *result_file_name = newpath;
686 raccess_guess_apple_generic(
FT_Library library,
688 char *base_file_name,
698 FT_UInt32 entry_id, entry_offset, entry_length = 0;
700 const FT_UInt32 resource_fork_entry_id = 0x2;
710 if ( magic_from_stream != magic )
711 return FT_THROW( Unknown_File_Format );
723 if ( n_of_entries == 0 )
724 return FT_THROW( Unknown_File_Format );
726 for ( i = 0; i < n_of_entries; i++ )
730 if ( entry_id == resource_fork_entry_id )
735 *result_offset = entry_offset;
747 return FT_THROW( Unknown_File_Format );
752 raccess_guess_linux_double_from_file_name(
FT_Library library,
768 error = raccess_guess_apple_double( library, stream2, file_name,
769 &nouse, result_offset );
778 raccess_make_file_name(
FT_Memory memory,
779 const char *original_name,
780 const char *insertion )
782 char* new_name =
NULL;
792 if (
FT_ALLOC( new_name, new_length + 1 ) )
798 ft_strncpy( new_name, original_name, tmp - original_name + 1 );
799 new_name[tmp - original_name + 1] =
'\0';
804 slash = original_name;
841 errors[
i] =
FT_ERR( Unimplemented_Feature );
#define FT_ALLOC(ptr, size)
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
GLboolean GLboolean GLboolean GLboolean a
return FT_THROW(Missing_Property)
#define FT_READ_USHORT(var)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
GLboolean GLboolean GLboolean b
FT_BEGIN_HEADER typedef unsigned char FT_Bool
#define FT_RACCESS_N_RULES
#define FT_STREAM_SKIP(distance)
FT_Raccess_Get_DataOffsets(FT_Library library, FT_Stream stream, FT_Long map_offset, FT_Long rdata_pos, FT_Long tag, FT_Long **offsets, FT_Long *count)
FT_Stream_Read(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
#define FT_TRACE2(varformat)
#define FT_READ_LONG(var)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
FT_Stream_New(FT_Library library, const FT_Open_Args *args, FT_Stream *astream)
FT_Raccess_Guess(FT_Library library, FT_Stream stream, char *base_name, char **new_names, FT_Long *offsets, FT_Error *errors)
FT_Raccess_Get_HeaderInfo(FT_Library library, FT_Stream stream, FT_Long rfork_offset, FT_Long *map_offset, FT_Long *rdata_pos)
FT_Stream_Free(FT_Stream stream, FT_Int external)
GLuint GLuint GLsizei count
FT_Stream_Skip(FT_Stream stream, FT_Long distance)
#define FT_MEM_COPY(dest, source, count)