28#include FT_INTERNAL_DEBUG_H
29#include FT_INTERNAL_STREAM_H
30#include FT_INTERNAL_RFORK_H
35#define FT_COMPONENT trace_raccess
58 unsigned char head[16], head2[16];
59 FT_Long map_pos, map_len, rdata_len;
60 int allzeros, allmatch,
i;
75 if (
head[0] >= 0x80 ||
79 return FT_THROW( Unknown_File_Format );
81 *rdata_pos = (
head[ 0] << 24 ) |
85 map_pos = (
head[ 4] << 24 ) |
89 rdata_len = (
head[ 8] << 24 ) |
93 map_len = (
head[12] << 24 ) |
100 return FT_THROW( Unknown_File_Format );
103 if ( *rdata_pos < map_pos )
105 if ( *rdata_pos > map_pos - rdata_len )
106 return FT_THROW( Unknown_File_Format );
110 if ( map_pos > *rdata_pos - map_len )
111 return FT_THROW( Unknown_File_Format );
118 FT_LONG_MAX - ( *rdata_pos + rdata_len ) < rfork_offset ||
119 FT_LONG_MAX - ( map_pos + map_len ) < rfork_offset ||
123 return FT_THROW( Unknown_File_Format );
125 *rdata_pos += rfork_offset;
126 map_pos += rfork_offset;
140 for (
i = 0;
i < 16;
i++ )
144 if ( head2[
i] !=
head[
i] )
147 if ( !allzeros && !allmatch )
148 return FT_THROW( Unknown_File_Format );
160 return FT_THROW( Unknown_File_Format );
166 *map_offset = map_pos + type_list;
175 if (
a->res_id <
b->res_id )
177 else if (
a->res_id >
b->res_id )
195 int i,
j, cnt, subcnt;
231 for (
i = 0;
i < cnt;
i++ )
239 (
char)( 0xFF & ( tag_internal >> 24 ) ),
240 (
char)( 0xFF & ( tag_internal >> 16 ) ),
241 (
char)( 0xFF & ( tag_internal >> 8 ) ),
242 (
char)( 0xFF & ( tag_internal >> 0 ) ) ));
243 FT_TRACE3((
" : subcount=%d, suboffset=0x%04x\n",
246 if ( tag_internal ==
tag )
253 if ( *count < 1 || *count > 2727 )
289 " resource_id=0x%04x, offset=0x%08x\n",
293 if ( sort_by_res_id )
298 (
int(*)(
const void*,
301 FT_TRACE3((
" -- sort resources by their ids --\n" ));
305 " resource_id=0x%04x, offset=0x%08x\n",
328 return FT_THROW( Cannot_Open_Resource );
332#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
351 char *base_file_name,
352 char **result_file_name,
358 char *base_file_name,
359 char **result_file_name,
365 char *base_file_name,
366 char **result_file_name,
372 char *base_file_name,
373 char **result_file_name,
379 char *base_file_name,
380 char **result_file_name,
386 char *base_file_name,
387 char **result_file_name,
393 char *base_file_name,
394 char **result_file_name,
400 char *base_file_name,
401 char **result_file_name,
407 char *base_file_name,
408 char **result_file_name,
412 CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table,
413 ft_raccess_guess_rec)
414 CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double)
415 CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single)
416 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export)
417 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs)
418 CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus)
419 CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat)
420 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap)
421 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double)
422 CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk)
423 CONST_FT_RFORK_RULE_ARRAY_END
435 char *base_file_name,
446 const char *original_name,
447 const char *insertion );
471 errors[
i] = (FT_RACCESS_GUESS_TABLE_GET[
i].func)(
library,
481#if defined( FT_CONFIG_OPTION_MAC_FONTS ) && !defined( FT_MACINTOSH )
489 return FT_RFork_Rule_invalid;
491 return FT_RACCESS_GUESS_TABLE_GET[rule_index].type;
502 switch( raccess_get_rule_type_from_rule_index(
library, rule_index ) )
504 case FT_RFork_Rule_darwin_newvfs:
505 case FT_RFork_Rule_darwin_hfsplus:
518 char *base_file_name,
519 char **result_file_name,
522 FT_Int32 magic = ( 0x00 << 24 ) |
528 *result_file_name =
NULL;
530 return FT_THROW( Cannot_Open_Stream );
532 return raccess_guess_apple_generic(
library,
stream, base_file_name,
533 magic, result_offset );
540 char *base_file_name,
541 char **result_file_name,
544 FT_Int32 magic = ( 0x00 << 24 ) |
550 *result_file_name =
NULL;
552 return FT_THROW( Cannot_Open_Stream );
554 return raccess_guess_apple_generic(
library,
stream, base_file_name,
555 magic, result_offset );
562 char *base_file_name,
563 char **result_file_name,
574 newpath = raccess_make_file_name(
memory, base_file_name,
"._" );
578 error = raccess_guess_linux_double_from_file_name(
library, newpath,
581 *result_file_name = newpath;
592 char *base_file_name,
593 char **result_file_name,
600 char* newpath =
NULL;
612 if (
FT_ALLOC( newpath, base_file_len + 6 ) )
615 FT_MEM_COPY( newpath, base_file_name, base_file_len );
616 FT_MEM_COPY( newpath + base_file_len,
"/rsrc", 6 );
618 *result_file_name = newpath;
628 char *base_file_name,
629 char **result_file_name,
636 char* newpath =
NULL;
648 if (
FT_ALLOC( newpath, base_file_len + 18 ) )
651 FT_MEM_COPY( newpath, base_file_name, base_file_len );
652 FT_MEM_COPY( newpath + base_file_len,
"/..namedfork/rsrc", 18 );
654 *result_file_name = newpath;
664 char *base_file_name,
665 char **result_file_name,
676 newpath = raccess_make_file_name(
memory, base_file_name,
681 *result_file_name = newpath;
691 char *base_file_name,
692 char **result_file_name,
703 newpath = raccess_make_file_name(
memory, base_file_name,
".resource/" );
707 *result_file_name = newpath;
717 char *base_file_name,
718 char **result_file_name,
730 newpath = raccess_make_file_name(
memory, base_file_name,
"%" );
734 error = raccess_guess_linux_double_from_file_name(
library, newpath,
737 *result_file_name = newpath;
748 char *base_file_name,
749 char **result_file_name,
761 newpath = raccess_make_file_name(
memory, base_file_name,
766 error = raccess_guess_linux_double_from_file_name(
library, newpath,
769 *result_file_name = newpath;
780 char *base_file_name,
784 FT_Int32 magic_from_stream;
786 FT_Int32 version_number = 0;
790 FT_Int32 entry_id, entry_offset, entry_length = 0;
792 const FT_Int32 resource_fork_entry_id = 0x2;
802 if ( magic_from_stream != magic )
803 return FT_THROW( Unknown_File_Format );
815 if ( n_of_entries == 0 )
816 return FT_THROW( Unknown_File_Format );
818 for (
i = 0;
i < n_of_entries;
i++ )
822 if ( entry_id == resource_fork_entry_id )
827 *result_offset = entry_offset;
839 return FT_THROW( Unknown_File_Format );
861 &nouse, result_offset );
871 const char *original_name,
872 const char *insertion )
874 char* new_name =
NULL;
884 if (
FT_ALLOC( new_name, new_length + 1 ) )
892 (
size_t)( tmp - original_name + 1 ) );
893 new_name[tmp - original_name + 1] =
'\0';
898 slash = original_name;
935 errors[
i] =
FT_ERR( Unimplemented_Feature );
struct outqueuenode * head
#define FT_TRACE3(varformat)
#define FT_TRACE2(varformat)
#define FT_NEW_ARRAY(ptr, count)
#define FT_ALLOC(ptr, size)
#define FT_MEM_COPY(dest, source, count)
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_Raccess_Get_DataOffsets(FT_Library library, FT_Stream stream, FT_Long map_offset, FT_Long rdata_pos, FT_Long tag, FT_Bool sort_by_res_id, FT_Long **offsets, FT_Long *count)
static int ft_raccess_sort_ref_by_id(FT_RFork_Ref *a, FT_RFork_Ref *b)
#define FT_RACCESS_N_RULES
#define FT_READ_USHORT(var)
#define FT_READ_LONG(var)
#define FT_STREAM_SKIP(distance)
FT_Stream_New(FT_Library library, const FT_Open_Args *args, FT_Stream *astream)
FT_Stream_Read(FT_Stream stream, FT_Byte *buffer, FT_ULong count)
FT_Stream_Free(FT_Stream stream, FT_Int external)
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
#define FT_READ_SHORT(var)
FT_Stream_Skip(FT_Stream stream, FT_Long distance)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_BEGIN_HEADER typedef unsigned char FT_Bool
static const FxOffsetAndName offsets[]
GLuint GLuint GLsizei count
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static char memory[1024 *256]